├── Makefile_cfgs ├── Platforms │ ├── Unknown.cfg │ ├── Linux.cfg │ ├── macOS.cfg │ ├── Emscripten.cfg │ ├── Windows.cfg │ ├── Switch.cfg │ ├── WiiU.cfg │ ├── 3DS.cfg │ └── Vita.cfg └── Backends │ ├── Audio │ ├── null.cfg │ ├── Soloud_Backends │ │ ├── vita.cfg │ │ ├── winmm.cfg │ │ ├── wasapi.cfg │ │ ├── sdl.cfg │ │ └── sdl2.cfg │ ├── sdlmixer.cfg │ └── sdl2mixer.cfg │ ├── Input │ ├── null.cfg │ ├── sdl.cfg │ ├── glfw.cfg │ └── sdl2.cfg │ └── Video │ ├── null.cfg │ ├── sdl.cfg │ ├── sdl2.cfg │ └── glfw.cfg ├── src ├── icon.rc ├── md.ico ├── core │ ├── cd_hw │ │ ├── libchdr │ │ │ ├── deps │ │ │ │ ├── lzma │ │ │ │ │ ├── DOC │ │ │ │ │ │ └── lzma-history.txt │ │ │ │ │ ├── Precomp.h │ │ │ │ │ ├── Compiler.h │ │ │ │ │ ├── LzHash.h │ │ │ │ │ └── LzmaEnc.h │ │ │ │ ├── zlib │ │ │ │ │ ├── inffast.h │ │ │ │ │ └── inftrees.h │ │ │ │ └── libFLAC │ │ │ │ │ ├── COPYING.Xiph │ │ │ │ │ ├── include │ │ │ │ │ ├── private │ │ │ │ │ │ ├── md5.h │ │ │ │ │ │ ├── format.h │ │ │ │ │ │ ├── macros.h │ │ │ │ │ │ ├── crc.h │ │ │ │ │ │ └── memory.h │ │ │ │ │ ├── FLAC │ │ │ │ │ │ ├── assert.h │ │ │ │ │ │ └── ordinals.h │ │ │ │ │ ├── protected │ │ │ │ │ │ └── stream_decoder.h │ │ │ │ │ └── share │ │ │ │ │ │ └── endswap.h │ │ │ │ │ ├── AUTHORS │ │ │ │ │ └── bitmath.c │ │ │ ├── README.md │ │ │ ├── src │ │ │ │ ├── coretypes.h │ │ │ │ ├── bitstream.h │ │ │ │ ├── flac.h │ │ │ │ ├── cdrom.h │ │ │ │ └── huffman.h │ │ │ └── LICENSE.txt │ │ ├── cd_cart.h │ │ └── cdc.h │ ├── tremor │ │ ├── CHANGELOG │ │ ├── Version_script.in │ │ ├── block.h │ │ ├── config_types.h │ │ ├── window.h │ │ ├── COPYING │ │ ├── registry.h │ │ ├── mdct.h │ │ ├── os_types.h │ │ ├── registry.c │ │ ├── os.h │ │ ├── README │ │ └── window.c │ ├── types.h │ ├── sound │ │ ├── ym2413.h │ │ ├── ym2612.h │ │ ├── eq.h │ │ ├── sound.h │ │ ├── psg.h │ │ └── blip_buf.h │ ├── cart_hw │ │ ├── svp │ │ │ ├── svp.h │ │ │ ├── ssp16.h │ │ │ └── svp.c │ │ ├── eeprom_i2c.h │ │ ├── eeprom_spi.h │ │ ├── ggenie.h │ │ ├── areplay.h │ │ ├── sms_cart.h │ │ ├── sram.h │ │ └── eeprom_93c.h │ ├── shared.h │ ├── ntsc │ │ ├── md_ntsc_config.h │ │ ├── sms_ntsc_config.h │ │ ├── readme.txt │ │ └── changes.txt │ ├── z80 │ │ ├── osd_cpu.h │ │ └── z80.h │ ├── input_hw │ │ ├── mouse.h │ │ ├── terebi_oekaki.h │ │ ├── graphic_board.h │ │ ├── paddle.h │ │ ├── xe_1ap.h │ │ ├── activator.h │ │ ├── sportspad.h │ │ ├── teamplayer.h │ │ ├── lightgun.h │ │ ├── terebi_oekaki.c │ │ └── gamepad.h │ ├── debug │ │ └── cpuhook.c │ ├── state.h │ ├── macros.h │ ├── membnk.h │ ├── io_ctrl.h │ └── memz80.h ├── ips.h ├── main.h ├── backends │ ├── input │ │ ├── input_null.c │ │ └── input_base.h │ ├── sound │ │ ├── sound_null.c │ │ └── sound_base.h │ └── video │ │ ├── video_null.c │ │ ├── video_base.h │ │ └── video_sdl.c ├── error.h ├── inputact.h ├── error.c ├── osd.h ├── config.h ├── ips.c └── fileio.h ├── .gitignore ├── .gitmodules ├── compat ├── Windows │ ├── openmpt_null.c │ ├── usleep.c │ └── dpi.cpp └── macOS │ └── malloc.h ├── .github └── workflows │ ├── switch.yml │ ├── linux.yml │ └── windows.yml └── README.md /Makefile_cfgs/Platforms/Unknown.cfg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/icon.rc: -------------------------------------------------------------------------------- 1 | MAINICON ICON "md.ico" 2 | -------------------------------------------------------------------------------- /Makefile_cfgs/Backends/Audio/null.cfg: -------------------------------------------------------------------------------- 1 | SOURCES += src/backends/sound/sound_null -------------------------------------------------------------------------------- /Makefile_cfgs/Backends/Input/null.cfg: -------------------------------------------------------------------------------- 1 | SOURCES += src/backends/input/input_null -------------------------------------------------------------------------------- /Makefile_cfgs/Backends/Video/null.cfg: -------------------------------------------------------------------------------- 1 | SOURCES += src/backends/video/video_null -------------------------------------------------------------------------------- /Makefile_cfgs/Platforms/Linux.cfg: -------------------------------------------------------------------------------- 1 | STATIC = 0 2 | LIBS += -lm -ldl -lpthread -------------------------------------------------------------------------------- /src/md.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/heyjoeway/Genesis-Plus-GX/HEAD/src/md.ico -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .vscode/ 2 | objects/ 3 | bin/ 4 | *.o 5 | *.a 6 | *.srm 7 | .DS_Store 8 | lib_ext/ -------------------------------------------------------------------------------- /Makefile_cfgs/Platforms/macOS.cfg: -------------------------------------------------------------------------------- 1 | STATIC = 0 2 | LIBS += -lm -ldl -lpthread 3 | DEFINES = -DMACOS -------------------------------------------------------------------------------- /Makefile_cfgs/Backends/Audio/Soloud_Backends/vita.cfg: -------------------------------------------------------------------------------- 1 | SOURCES += lib/soloud/src/backend/vita_homebrew/soloud_vita_homebrew 2 | DEFINES += -DWITH_VITA_HOMEBREW -------------------------------------------------------------------------------- /Makefile_cfgs/Backends/Audio/Soloud_Backends/winmm.cfg: -------------------------------------------------------------------------------- 1 | SOURCES += lib/soloud/src/backend/winmm/soloud_winmm 2 | LIBS += -lwinmm 3 | DEFINES += -DWITH_WINMM -------------------------------------------------------------------------------- /src/core/cd_hw/libchdr/deps/lzma/DOC/lzma-history.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/heyjoeway/Genesis-Plus-GX/HEAD/src/core/cd_hw/libchdr/deps/lzma/DOC/lzma-history.txt -------------------------------------------------------------------------------- /src/ips.h: -------------------------------------------------------------------------------- 1 | #ifndef __IPS_H__ 2 | #define __IPS_H__ 3 | 4 | int ips_patch( 5 | char *buf_rom, int len_rom, 6 | char *buf_ips, int len_ips 7 | ); 8 | 9 | #endif -------------------------------------------------------------------------------- /Makefile_cfgs/Backends/Input/sdl.cfg: -------------------------------------------------------------------------------- 1 | CFLAGS += `$(PKGCONFIG) --cflags sdl` 2 | LIBS += `$(PKGCONFIG) --libs-only-l --libs-only-L sdl` 3 | SOURCES += src/backends/input/input_sdl -------------------------------------------------------------------------------- /Makefile_cfgs/Backends/Audio/Soloud_Backends/wasapi.cfg: -------------------------------------------------------------------------------- 1 | # Not compiling atm 2 | SOURCES += lib/soloud/src/backend/wasapi/soloud_wasapi 3 | LIBS += -luuid 4 | DEFINES += -DWITH_WASAPI -------------------------------------------------------------------------------- /Makefile_cfgs/Backends/Input/glfw.cfg: -------------------------------------------------------------------------------- 1 | CFLAGS += `$(PKGCONFIG) --cflags glfw3` 2 | LIBS += `$(PKGCONFIG) --libs-only-l --libs-only-L glfw3` 3 | SOURCES += src/backends/input/input_glfw -------------------------------------------------------------------------------- /Makefile_cfgs/Backends/Input/sdl2.cfg: -------------------------------------------------------------------------------- 1 | CFLAGS += `$(PKGCONFIG) --cflags sdl2` 2 | LIBS += `$(PKGCONFIG) --libs-only-l --libs-only-L sdl2` 3 | SOURCES += src/backends/input/input_sdl2 -------------------------------------------------------------------------------- /src/main.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef _MAIN_H_ 3 | #define _MAIN_H_ 4 | 5 | #define MAX_INPUTS 8 6 | 7 | extern int debug_on; 8 | extern int log_error; 9 | 10 | #endif /* _MAIN_H_ */ 11 | -------------------------------------------------------------------------------- /Makefile_cfgs/Backends/Video/sdl.cfg: -------------------------------------------------------------------------------- 1 | CFLAGS += `$(PKGCONFIG) --cflags sdl` 2 | LIBS += `$(PKGCONFIG) --libs-only-l --libs-only-L sdl` 3 | SOURCES += src/backends/video/video_sdl 4 | SOLOUD_BACKEND ?= sdl -------------------------------------------------------------------------------- /Makefile_cfgs/Backends/Audio/sdlmixer.cfg: -------------------------------------------------------------------------------- 1 | CFLAGS += `$(PKGCONFIG) --cflags SDL_mixer flac mad` 2 | LIBS += `$(PKGCONFIG) --libs-only-l --libs-only-L SDL_mixer flac mad` 3 | SOURCES += src/backends/sound/sound_sdlmixer 4 | -------------------------------------------------------------------------------- /Makefile_cfgs/Backends/Audio/sdl2mixer.cfg: -------------------------------------------------------------------------------- 1 | CFLAGS += `$(PKGCONFIG) --cflags SDL2_mixer flac vorbis` 2 | LIBS += `$(PKGCONFIG) --libs-only-l --libs-only-L SDL2_mixer flac vorbis` 3 | SOURCES += src/backends/sound/sound_sdl2mixer 4 | -------------------------------------------------------------------------------- /Makefile_cfgs/Backends/Video/sdl2.cfg: -------------------------------------------------------------------------------- 1 | CFLAGS += `$(PKGCONFIG) --cflags sdl2 SDL2_image libjpeg libpng` 2 | LIBS += `$(PKGCONFIG) --libs-only-l --libs-only-L sdl2 SDL2_image libjpeg libpng` 3 | SOURCES += src/backends/video/video_sdl2 4 | -------------------------------------------------------------------------------- /src/backends/input/input_null.c: -------------------------------------------------------------------------------- 1 | #include "input_base.h" 2 | 3 | int Backend_Input_Update() { return 1; } 4 | int Backend_Input_Init() { return 1; } 5 | int Backend_Input_Close() { return 1; } 6 | int Backend_Input_MainLoop() { return 1; } -------------------------------------------------------------------------------- /src/core/cd_hw/libchdr/deps/lzma/Precomp.h: -------------------------------------------------------------------------------- 1 | /* Precomp.h -- StdAfx 2 | 2013-11-12 : Igor Pavlov : Public domain */ 3 | 4 | #ifndef __7Z_PRECOMP_H 5 | #define __7Z_PRECOMP_H 6 | 7 | #include "Compiler.h" 8 | /* #include "7zTypes.h" */ 9 | 10 | #endif 11 | -------------------------------------------------------------------------------- /src/error.h: -------------------------------------------------------------------------------- 1 | #ifndef _ERROR_H_ 2 | #define _ERROR_H_ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | 9 | /* Function prototypes */ 10 | void error_init(void); 11 | void error_shutdown(void); 12 | void error(char *format, ...); 13 | 14 | #ifdef __cplusplus 15 | } 16 | #endif 17 | 18 | #endif /* _ERROR_H_ */ 19 | 20 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "lib/soloud"] 2 | path = lib/soloud 3 | url = https://github.com/jarikomppa/soloud 4 | [submodule "lib/portable-file-dialogs"] 5 | path = lib/portable-file-dialogs 6 | url = https://github.com/samhocevar/portable-file-dialogs 7 | [submodule "lib/argparse"] 8 | path = lib/argparse 9 | url = https://github.com/cofyc/argparse 10 | -------------------------------------------------------------------------------- /src/backends/input/input_base.h: -------------------------------------------------------------------------------- 1 | #ifndef __BACKEND_INPUT_BASE___ 2 | #define __BACKEND_INPUT_BASE___ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | int Backend_Input_Update(); 9 | int Backend_Input_Init(); 10 | int Backend_Input_Close(); 11 | int Backend_Input_MainLoop(); 12 | 13 | #ifdef __cplusplus 14 | } 15 | #endif 16 | 17 | #endif -------------------------------------------------------------------------------- /compat/Windows/openmpt_null.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void openmpt_module_destroy(void * mod) { } 4 | void *openmpt_module_create_from_memory(const void * filedata, size_t filesize, void *logfunc, void * user, void * ctls) { } 5 | int openmpt_module_read_float_stereo(void * mod, int samplerate, size_t count, float * left, float * right) { 6 | return 0; 7 | } 8 | -------------------------------------------------------------------------------- /compat/Windows/usleep.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void usleep(__int64 usec) 4 | { 5 | HANDLE timer; 6 | LARGE_INTEGER ft; 7 | 8 | ft.QuadPart = -(10*usec); // Convert to 100 nanosecond interval, negative value indicates relative time 9 | 10 | timer = CreateWaitableTimer(NULL, TRUE, NULL); 11 | SetWaitableTimer(timer, &ft, 0, NULL, NULL, 0); 12 | WaitForSingleObject(timer, INFINITE); 13 | CloseHandle(timer); 14 | } -------------------------------------------------------------------------------- /Makefile_cfgs/Backends/Audio/Soloud_Backends/sdl.cfg: -------------------------------------------------------------------------------- 1 | # This is currently broken on SoLoud's end. Blame them. 2 | 3 | ifeq ($(STATIC),1) 4 | SOURCES += lib/soloud/src/backend/sdl_static/soloud_sdl_static 5 | DEFINES += -DWITH_SDL1_STATIC 6 | else 7 | SOURCES += lib/soloud/src/backend/sdl/soloud_sdl \ 8 | lib/soloud/src/backend/sdl/soloud_sdl_dll \ 9 | lib/soloud/src/audiosource/openmpt/soloud_openmpt_dll 10 | DEFINES += -DWITH_SDL1 11 | endif -------------------------------------------------------------------------------- /src/core/cd_hw/libchdr/README.md: -------------------------------------------------------------------------------- 1 | # libchdr 2 | 3 | libchdr is a standalone library for reading MAME's CHDv1-v5 formats. 4 | 5 | The code is based off of MAME's old C codebase which read up to CHDv4 with OS-dependent features removed, and CHDv5 support backported from MAME's current C++ codebase. 6 | 7 | libchdr is licensed under the BSD 3-Clause (see [LICENSE.txt](LICENSE.txt)) and uses third party libraries that are each distributed under their own terms (see each library's license in [deps/](deps/)). 8 | -------------------------------------------------------------------------------- /src/core/cd_hw/libchdr/deps/zlib/inffast.h: -------------------------------------------------------------------------------- 1 | /* inffast.h -- header to use inffast.c 2 | * Copyright (C) 1995-2003, 2010 Mark Adler 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | /* WARNING: this file should *not* be used by applications. It is 7 | part of the implementation of the compression library and is 8 | subject to change. Applications should only use zlib.h. 9 | */ 10 | 11 | void ZLIB_INTERNAL inflate_fast OF((z_streamp strm, unsigned start)); 12 | -------------------------------------------------------------------------------- /Makefile_cfgs/Backends/Audio/Soloud_Backends/sdl2.cfg: -------------------------------------------------------------------------------- 1 | ifeq ($(STATIC),1) 2 | SOURCES += lib/soloud/src/backend/sdl2_static/soloud_sdl2_static 3 | DEFINES += -DWITH_SDL2_STATIC 4 | else 5 | SOURCES += lib/soloud/src/backend/sdl/soloud_sdl2 \ 6 | lib/soloud/src/backend/sdl/soloud_sdl2_dll \ 7 | lib/soloud/src/audiosource/openmpt/soloud_openmpt_dll 8 | DEFINES += -DWITH_SDL2 9 | endif 10 | 11 | CFLAGS += `$(PKGCONFIG) --cflags sdl2` 12 | LIBS += `$(PKGCONFIG) --libs-only-l --libs-only-L sdl2` -------------------------------------------------------------------------------- /src/inputact.h: -------------------------------------------------------------------------------- 1 | #ifndef __INPUTACT_H__ 2 | #define __INPUTACT_H__ 3 | 4 | #include "shared.h" 5 | 6 | #ifdef __cplusplus 7 | extern "C" { 8 | #endif 9 | 10 | void input_run_action(char *str, int press); 11 | int input_process_keycode(char *keystr, int press); 12 | void inputact_init(); 13 | void input_process_joystick(int joynum, int button, int press); 14 | void input_update_pad(int padnum); 15 | 16 | extern uint16 pad_action[MAX_DEVICES]; 17 | extern uint16 pad_analog[MAX_DEVICES]; 18 | 19 | #ifdef __cplusplus 20 | } 21 | #endif 22 | 23 | #endif -------------------------------------------------------------------------------- /src/core/tremor/CHANGELOG: -------------------------------------------------------------------------------- 1 | *** 20020517: 1.0.2 *** 2 | 3 | Playback bugfix to floor1; mode mistakenly used for sizing instead 4 | of blockflag 5 | 6 | *** 20020515: 1.0.1 *** 7 | 8 | Added complete API documentation to source tarball. No code 9 | changes. 10 | 11 | *** 20020412: 1.0.1 *** 12 | 13 | Fixed a clipping bug that affected ARM processors; negative 14 | overflows were being properly clipped, but then clobbered to 15 | positive by the positive overflow chec (asm_arm.h:CLIP_TO_15) 16 | 17 | *** 20020403: 1.0.0 *** 18 | 19 | Initial version -------------------------------------------------------------------------------- /compat/Windows/dpi.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main (int argc, char *argv[]); 5 | 6 | #ifndef __argc 7 | extern int __argc; 8 | #endif 9 | 10 | #ifndef __argv 11 | extern char *__argv[]; 12 | #endif 13 | 14 | // Fuck windows and its janky ass hidpi shit 15 | // No, I am not including a manifest file just to stop you from fucking with scaling, microsoft 16 | int __stdcall WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, char* lpCmdLine, int nShowCmd) 17 | { 18 | SetProcessDPIAware(); 19 | return main(__argc, __argv); 20 | } -------------------------------------------------------------------------------- /Makefile_cfgs/Platforms/Emscripten.cfg: -------------------------------------------------------------------------------- 1 | PKGCONFIG = : 2 | BACKEND_VIDEO = sdl2 3 | BACKEND_AUDIO = soloud 4 | BACKEND_INPUT = sdl2 5 | STRIP = : 6 | CFLAGS += \ 7 | -s USE_SDL=2 -s USE_SDL_MIXER=2 -s USE_SDL_IMAGE=2 -s USE_ZLIB=1 -s USE_VORBIS=1 \ 8 | -s TOTAL_MEMORY=41484288 -s LLD_REPORT_UNDEFINED -s ALLOW_MEMORY_GROWTH=1 \ 9 | --preload-file "patch.ips" \ 10 | -lidbfs.js \ 11 | -s EXPORTED_FUNCTIONS='["_emscripten_main","_sram_write"]' 12 | DEFINES += -DHAVE_ALLOCA_H 13 | SUFFIX = .html 14 | INCLUDES += -I./lib_ext/jansson/src 15 | LIBS += -L./lib_ext/jansson/src/.libs -ljansson -------------------------------------------------------------------------------- /src/backends/sound/sound_null.c: -------------------------------------------------------------------------------- 1 | #include "sound_base.h" 2 | 3 | int Backend_Sound_Init() { return 1; } 4 | int Backend_Sound_Update(int size) { return 1; } 5 | int Backend_Sound_Close() { return 1; } 6 | int Backend_Sound_PlayMusic(char *path) { return 1; } 7 | int Backend_Sound_StopMusic() { return 1; } 8 | int Backend_Sound_FadeOutMusic(int fadeTime) { return 1; } 9 | int Backend_Sound_MusicSpeed(float speed) { return 1; } 10 | int Backend_Sound_MusicSetUnderwater(int isUnderwater) { return 1; } 11 | int Backend_Sound_PlaySFX(char *path) { return 1; } 12 | int Backend_Sound_SetPause(int paused) { return 1; } -------------------------------------------------------------------------------- /Makefile_cfgs/Backends/Video/glfw.cfg: -------------------------------------------------------------------------------- 1 | CFLAGS += `$(PKGCONFIG) --cflags glfw3` 2 | LIBS += `$(PKGCONFIG) --libs-only-l --libs-only-L glfw3` 3 | SOURCES += src/backends/video/video_glfw 4 | 5 | GL_LOADER ?= glew 6 | 7 | ifeq ($(GL_LOADER), glew) 8 | CFLAGS += `$(PKGCONFIG) --cflags glew` 9 | LIBS += `$(PKGCONFIG) --libs-only-l --libs-only-L glew` -lopengl32 10 | DEFINES += -DGLEW_STATIC -DGL_LOADER_GLEW 11 | else ifeq ($(GL_LOADER), glad) 12 | CFLAGS += `$(PKGCONFIG) --cflags libglad` 13 | LIBS += `$(PKGCONFIG) --libs-only-l --libs-only-L libglad` 14 | DEFINES += -DGL_LOADER_GLAD 15 | endif 16 | -------------------------------------------------------------------------------- /Makefile_cfgs/Platforms/Windows.cfg: -------------------------------------------------------------------------------- 1 | WINDRES = windres 2 | 3 | LIBS += -lshlwapi 4 | OBJECTS += $(OBJDIR)/icon.o 5 | SUFFIX = .exe 6 | STATIC ?= 1 7 | ENABLE_DIALOGS ?= 1 8 | SOURCES += compat/Windows/openmpt_null \ 9 | compat/Windows/usleep 10 | DEFINES += -D__WINDOWS__ 11 | 12 | SOLOUD_BACKEND ?= winmm 13 | 14 | ifneq ($(BACKEND_VIDEO), null) 15 | SOURCES += compat/Windows/dpi 16 | endif 17 | 18 | ifeq ($(DEBUG),1) 19 | LIBS += -mconsole 20 | else 21 | LIBS += -mwindows 22 | endif 23 | 24 | #Compile the Windows icon file into an object 25 | $(OBJDIR)/icon.o: src/icon.rc src/md.ico 26 | @mkdir -p $(@D) 27 | @$(WINDRES) $< $@ -------------------------------------------------------------------------------- /src/core/types.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef _TYPES_H_ 3 | #define _TYPES_H_ 4 | 5 | #undef uint8 6 | #undef uint16 7 | #undef uint32 8 | #undef int8 9 | #undef int16 10 | #undef int32 11 | 12 | #define uint8 unsigned char 13 | #define uint16 unsigned short 14 | #define uint32 unsigned int 15 | #define int8 signed char 16 | #define int16 signed short 17 | #define int32 signed int 18 | 19 | typedef union 20 | { 21 | uint16 w; 22 | struct 23 | { 24 | #ifdef LSB_FIRST 25 | uint8 l; 26 | uint8 h; 27 | #else 28 | uint8 h; 29 | uint8 l; 30 | #endif 31 | } byte; 32 | 33 | } reg16_t; 34 | 35 | #endif /* _TYPES_H_ */ 36 | -------------------------------------------------------------------------------- /src/error.c: -------------------------------------------------------------------------------- 1 | /* 2 | error.c -- 3 | Error logging 4 | */ 5 | 6 | #include "osd.h" 7 | 8 | #ifdef LOGERROR 9 | static FILE *error_log; 10 | #endif 11 | 12 | void error_init(void) 13 | { 14 | #ifdef LOGERROR 15 | error_log = fopen("error.log","w"); 16 | #endif 17 | } 18 | 19 | void error_shutdown(void) 20 | { 21 | #ifdef LOGERROR 22 | if(error_log) fclose(error_log); 23 | #endif 24 | } 25 | 26 | void error(char *format, ...) 27 | { 28 | #ifdef LOGERROR 29 | if (log_error) 30 | { 31 | va_list ap; 32 | va_start(ap, format); 33 | if(error_log) vfprintf(error_log, format, ap); 34 | va_end(ap); 35 | } 36 | #endif 37 | } 38 | -------------------------------------------------------------------------------- /.github/workflows/switch.yml: -------------------------------------------------------------------------------- 1 | name: Nintendo Switch 2 | 3 | on: 4 | push: 5 | branches: [ master ] 6 | pull_request: 7 | branches: [ master ] 8 | 9 | jobs: 10 | build: 11 | runs-on: ubuntu-20.04 12 | container: devkitpro/devkita64:20200730 13 | steps: 14 | - name: Checkout repo 15 | uses: actions/checkout@v1 16 | with: 17 | submodules: 'recursive' 18 | - name: make clean 19 | run: make clean 20 | - name: make 21 | run: make PLATFORM=Switch 22 | - name: Upload artifacts 23 | uses: actions/upload-artifact@v2 24 | with: 25 | name: artifacts 26 | path: bin/ 27 | -------------------------------------------------------------------------------- /src/core/sound/ym2413.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** 3 | ** File: ym2413.c - software implementation of YM2413 4 | ** FM sound generator type OPLL 5 | ** 6 | ** Copyright (C) 2002 Jarek Burczynski 7 | ** 8 | ** Version 1.0 9 | ** 10 | */ 11 | 12 | #ifndef _H_YM2413_ 13 | #define _H_YM2413_ 14 | 15 | extern void YM2413Init(void); 16 | extern void YM2413ResetChip(void); 17 | extern void YM2413Update(int *buffer, int length); 18 | extern void YM2413Write(unsigned int a, unsigned int v); 19 | extern unsigned int YM2413Read(void); 20 | extern unsigned char *YM2413GetContextPtr(void); 21 | extern unsigned int YM2413GetContextSize(void); 22 | 23 | #endif /*_H_YM2413_*/ 24 | -------------------------------------------------------------------------------- /src/backends/video/video_null.c: -------------------------------------------------------------------------------- 1 | #include "video_base.h" 2 | 3 | #include "shared.h" 4 | 5 | int Backend_Video_Close() { return 1; } 6 | int Backend_Video_Init() { 7 | bitmap.data = (unsigned char *)malloc(bitmap.pitch * bitmap.height); 8 | return 1; 9 | } 10 | int Backend_Video_SetFullscreen(int arg_fullscreen) { return 1; } 11 | int Backend_Video_ToggleFullscreen() { return 1; } 12 | int Backend_Video_Update() { return 1; } 13 | int Backend_Video_SetWindowTitle(char *caption) { return 1; } 14 | void *Backend_Video_LoadImage(char *path) { } 15 | void *Backend_Video_GetRenderer() { } 16 | int Backend_Video_Clear() { return 1; } 17 | int Backend_Video_Present() { return 1; } -------------------------------------------------------------------------------- /src/core/cart_hw/svp/svp.h: -------------------------------------------------------------------------------- 1 | /* 2 | basic, incomplete SSP160x (SSP1601?) interpreter 3 | with SVP memory controller emu 4 | 5 | (c) Copyright 2008, Grazvydas "notaz" Ignotas 6 | Free for non-commercial use. 7 | 8 | For commercial use, separate licencing terms must be obtained. 9 | 10 | Modified for Genesis Plus GX (Eke-Eke): added BIG ENDIAN support, fixed addr/code inversion 11 | */ 12 | 13 | #ifndef _SVP_H_ 14 | #define _SVP_H_ 15 | 16 | #include "shared.h" 17 | #include "ssp16.h" 18 | 19 | typedef struct { 20 | unsigned char iram_rom[0x20000]; /* IRAM (0-0x7ff) and program ROM (0x800-0x1ffff) */ 21 | unsigned char dram[0x20000]; 22 | ssp1601_t ssp1601; 23 | } svp_t; 24 | 25 | extern svp_t *svp; 26 | 27 | extern void svp_init(void); 28 | extern void svp_reset(void); 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /.github/workflows/linux.yml: -------------------------------------------------------------------------------- 1 | name: Linux 2 | 3 | on: 4 | push: 5 | branches: [ master ] 6 | pull_request: 7 | branches: [ master ] 8 | 9 | jobs: 10 | build: 11 | 12 | runs-on: ubuntu-20.04 13 | 14 | steps: 15 | - name: Checkout repo 16 | uses: actions/checkout@v2 17 | with: 18 | submodules: 'recursive' 19 | - name: apt update 20 | run: sudo apt update 21 | - name: apt install 22 | run: sudo apt install libsdl2-dev libsdl2-image-dev libopusfile-dev libmpg123-dev libflac-dev libvorbis-dev libopus-dev libjansson-dev 23 | - name: make clean 24 | run: make clean 25 | - name: make 26 | run: make 27 | - name: Upload artifacts 28 | uses: actions/upload-artifact@v2 29 | with: 30 | name: artifacts 31 | path: bin/ 32 | -------------------------------------------------------------------------------- /src/core/cd_hw/libchdr/src/coretypes.h: -------------------------------------------------------------------------------- 1 | #ifndef __CORETYPES_H__ 2 | #define __CORETYPES_H__ 3 | 4 | #include 5 | #include 6 | 7 | #define ARRAY_LENGTH(x) (sizeof(x)/sizeof(x[0])) 8 | 9 | typedef uint64_t UINT64; 10 | #ifndef OSD_CPU_H 11 | typedef uint32_t UINT32; 12 | typedef uint16_t UINT16; 13 | typedef uint8_t UINT8; 14 | #endif 15 | 16 | typedef int64_t INT64; 17 | #ifndef OSD_CPU_H 18 | typedef int32_t INT32; 19 | typedef int16_t INT16; 20 | typedef int8_t INT8; 21 | #endif 22 | 23 | #define core_file cdStream 24 | #define core_fopen cdStreamOpen 25 | #define core_fseek cdStreamSeek 26 | #define core_fread(fc, buff, len) cdStreamRead(buff, 1, len, fc) 27 | #define core_fclose cdStreamClose 28 | #define core_ftell cdStreamTell 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /src/backends/sound/sound_base.h: -------------------------------------------------------------------------------- 1 | #ifndef __BACKEND_SOUND_BASE___ 2 | #define __BACKEND_SOUND_BASE___ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #define SOUND_FREQUENCY 44100 9 | #define SOUND_SAMPLES_SIZE 2048 10 | 11 | // This is in main.c 12 | extern short soundframe[SOUND_SAMPLES_SIZE]; 13 | 14 | int Backend_Sound_Init(); 15 | int Backend_Sound_Update(int size); 16 | int Backend_Sound_Close(); 17 | 18 | int Backend_Sound_PlayMusic(char *path); 19 | int Backend_Sound_IsPlayingMusic(); 20 | int Backend_Sound_StopMusic(); 21 | int Backend_Sound_FadeOutMusic(int fadeTime); 22 | int Backend_Sound_MusicSpeed(float speed); 23 | int Backend_Sound_MusicSetUnderwater(int isUnderwater); 24 | int Backend_Sound_PlaySFX(char *path); 25 | int Backend_Sound_SetPause(int paused); 26 | 27 | #ifdef __cplusplus 28 | } 29 | #endif 30 | 31 | #endif -------------------------------------------------------------------------------- /src/osd.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef _OSD_H_ 3 | #define _OSD_H_ 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | #include 11 | 12 | #include "main.h" 13 | #include "config.h" 14 | #include "error.h" 15 | #include "unzip.h" 16 | #include "fileio.h" 17 | #include "input_base.h" 18 | 19 | #define osd_input_update Backend_Input_Update 20 | 21 | #define GG_ROM "./ggenie.bin" 22 | #define AR_ROM "./areplay.bin" 23 | #define SK_ROM "./sk.bin" 24 | #define SK_UPMEM "./sk2chip.bin" 25 | #define CD_BIOS_US "./bios_CD_U.bin" 26 | #define CD_BIOS_EU "./bios_CD_E.bin" 27 | #define CD_BIOS_JP "./bios_CD_J.bin" 28 | #define MD_BIOS "./bios_MD.bin" 29 | #define MS_BIOS_US "./bios_U.sms" 30 | #define MS_BIOS_EU "./bios_E.sms" 31 | #define MS_BIOS_JP "./bios_J.sms" 32 | #define GG_BIOS "./bios.gg" 33 | 34 | #endif /* _OSD_H_ */ 35 | -------------------------------------------------------------------------------- /src/backends/video/video_base.h: -------------------------------------------------------------------------------- 1 | #ifndef __BACKEND_VIDEO_BASE___ 2 | #define __BACKEND_VIDEO_BASE___ 3 | 4 | #define VIDEO_WIDTH 400 5 | #define VIDEO_HEIGHT 224 6 | 7 | #define WINDOW_SCALE 3 8 | 9 | extern int option_mirrormode; 10 | extern int option_scaling; 11 | 12 | #ifdef __cplusplus 13 | extern "C" { 14 | #endif 15 | 16 | int Backend_Video_Close(); 17 | int Backend_Video_Init(); 18 | int Backend_Video_SetFullscreen(int arg_fullscreen); 19 | int Backend_Video_ToggleFullscreen(); 20 | int Backend_Video_Update(); 21 | int Backend_Video_Clear(); 22 | int Backend_Video_Present(); 23 | int Backend_Video_SetWindowTitle(char *caption); 24 | void *Backend_Video_LoadImage(char *path); 25 | void *Backend_Video_GetRenderer(); 26 | int Backend_Video_SetVsync(int vsync); 27 | int Backend_Video_GetRefreshRate(); 28 | int Backend_Video_GetActive(); 29 | 30 | #ifdef __cplusplus 31 | } 32 | #endif 33 | 34 | #endif -------------------------------------------------------------------------------- /src/core/shared.h: -------------------------------------------------------------------------------- 1 | #ifndef _SHARED_H_ 2 | #define _SHARED_H_ 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | #include "types.h" 10 | #include "osd.h" 11 | #include "macros.h" 12 | #include "loadrom.h" 13 | #include "m68k.h" 14 | #include "z80.h" 15 | #include "system.h" 16 | #include "genesis.h" 17 | #include "vdp_ctrl.h" 18 | #include "vdp_render.h" 19 | #include "mem68k.h" 20 | #include "memz80.h" 21 | #include "membnk.h" 22 | #include "io_ctrl.h" 23 | #include "input.h" 24 | #include "sound.h" 25 | #include "psg.h" 26 | #include "ym2413.h" 27 | #include "ym2612.h" 28 | #ifdef HAVE_YM3438_CORE 29 | #include "ym3438.h" 30 | #endif 31 | #ifdef HAVE_OPLL_CORE 32 | #include "opll.h" 33 | #endif 34 | #include "sram.h" 35 | #include "ggenie.h" 36 | #include "areplay.h" 37 | #include "svp.h" 38 | #include "state.h" 39 | 40 | extern int running; 41 | extern void *window_shared; 42 | 43 | #endif /* _SHARED_H_ */ 44 | 45 | -------------------------------------------------------------------------------- /src/core/sound/ym2612.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** 3 | ** software implementation of Yamaha FM sound generator (YM2612/YM3438) 4 | ** 5 | ** Original code (MAME fm.c) 6 | ** 7 | ** Copyright (C) 2001, 2002, 2003 Jarek Burczynski (bujar at mame dot net) 8 | ** Copyright (C) 1998 Tatsuyuki Satoh , MultiArcadeMachineEmulator development 9 | ** 10 | ** Version 1.4 (final beta) 11 | ** 12 | ** Additional code & fixes by Eke-Eke for Genesis Plus GX 13 | ** 14 | */ 15 | 16 | #ifndef _H_YM2612_ 17 | #define _H_YM2612_ 18 | 19 | enum { 20 | YM2612_DISCRETE = 0, 21 | YM2612_INTEGRATED, 22 | YM2612_ENHANCED 23 | }; 24 | 25 | extern void YM2612Init(void); 26 | extern void YM2612Config(int type); 27 | extern void YM2612ResetChip(void); 28 | extern void YM2612Update(int *buffer, int length); 29 | extern void YM2612Write(unsigned int a, unsigned int v); 30 | extern unsigned int YM2612Read(void); 31 | extern int YM2612LoadContext(unsigned char *state); 32 | extern int YM2612SaveContext(unsigned char *state); 33 | 34 | #endif /* _YM2612_ */ 35 | -------------------------------------------------------------------------------- /src/core/ntsc/md_ntsc_config.h: -------------------------------------------------------------------------------- 1 | /* Configure library by modifying this file */ 2 | 3 | #ifndef MD_NTSC_CONFIG_H 4 | #define MD_NTSC_CONFIG_H 5 | 6 | /* Format of source & output pixels (RGB555 or RGB565 only)*/ 7 | #ifdef USE_15BPP_RENDERING 8 | #define MD_NTSC_IN_FORMAT MD_NTSC_RGB15 9 | #define MD_NTSC_OUT_DEPTH 15 10 | #else 11 | #define MD_NTSC_IN_FORMAT MD_NTSC_RGB16 12 | #define MD_NTSC_OUT_DEPTH 16 13 | #endif 14 | 15 | /* Original CRAM format (not used) */ 16 | /* #define MD_NTSC_IN_FORMAT MD_NTSC_BGR9 */ 17 | 18 | /* The following affect the built-in blitter only; a custom blitter can 19 | handle things however it wants. */ 20 | 21 | /* Type of input pixel values (fixed to 16-bit) */ 22 | #define MD_NTSC_IN_T unsigned short 23 | 24 | /* Each raw pixel input value is passed through this. You might want to mask 25 | the pixel index if you use the high bits as flags, etc. */ 26 | #define MD_NTSC_ADJ_IN( in ) in 27 | 28 | /* For each pixel, this is the basic operation: 29 | output_color = MD_NTSC_ADJ_IN( MD_NTSC_IN_T ) */ 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /src/core/tremor/Version_script.in: -------------------------------------------------------------------------------- 1 | # 2 | # Export file for libvorbisidec 3 | # 4 | # Only the symbols listed in the global section will be callable from 5 | # applications linking to libvorbisidec. 6 | # 7 | 8 | @PACKAGE@.so.1 9 | { 10 | global: 11 | ov_clear; 12 | ov_open; 13 | ov_open_callbacks; 14 | ov_test; 15 | ov_test_callbacks; 16 | ov_test_open; 17 | ov_bitrate; 18 | ov_bitrate_instant; 19 | ov_streams; 20 | ov_seekable; 21 | ov_serialnumber; 22 | ov_raw_total; 23 | ov_pcm_total; 24 | ov_time_total; 25 | ov_raw_seek; 26 | ov_pcm_seek; 27 | ov_pcm_seek_page; 28 | ov_time_seek; 29 | ov_time_seek_page; 30 | ov_raw_tell; 31 | ov_pcm_tell; 32 | ov_time_tell; 33 | ov_info; 34 | ov_comment; 35 | ov_read; 36 | 37 | vorbis_info_init; 38 | vorbis_info_clear; 39 | vorbis_info_blocksize; 40 | vorbis_comment_init; 41 | vorbis_comment_add; 42 | vorbis_comment_add_tag; 43 | vorbis_comment_query; 44 | vorbis_comment_query_count; 45 | vorbis_comment_clear; 46 | 47 | local: 48 | *; 49 | }; 50 | -------------------------------------------------------------------------------- /src/core/ntsc/sms_ntsc_config.h: -------------------------------------------------------------------------------- 1 | /* Configure library by modifying this file */ 2 | 3 | #ifndef SMS_NTSC_CONFIG_H 4 | #define SMS_NTSC_CONFIG_H 5 | 6 | /* Format of source & output pixels (RGB555 or RGB565 only) */ 7 | #ifdef USE_15BPP_RENDERING 8 | #define SMS_NTSC_IN_FORMAT SMS_NTSC_RGB15 9 | #define SMS_NTSC_OUT_DEPTH 15 10 | #else 11 | #define SMS_NTSC_IN_FORMAT SMS_NTSC_RGB16 12 | #define SMS_NTSC_OUT_DEPTH 16 13 | #endif 14 | 15 | /* Original CRAM format (not used) */ 16 | /* #define SMS_NTSC_IN_FORMAT SMS_NTSC_BGR12 */ 17 | 18 | /* The following affect the built-in blitter only; a custom blitter can 19 | handle things however it wants. */ 20 | 21 | /* Type of input pixel values (fixed to 16-bit)*/ 22 | #define SMS_NTSC_IN_T unsigned short 23 | 24 | /* Each raw pixel input value is passed through this. You might want to mask 25 | the pixel index if you use the high bits as flags, etc. */ 26 | #define SMS_NTSC_ADJ_IN( in ) in 27 | 28 | /* For each pixel, this is the basic operation: 29 | output_color = SMS_NTSC_ADJ_IN( SMS_NTSC_IN_T ) */ 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /Makefile_cfgs/Platforms/Switch.cfg: -------------------------------------------------------------------------------- 1 | STATIC = 1 2 | 3 | BACKEND_VIDEO ?= sdl2 4 | BACKEND_INPUT ?= sdl2 5 | BACKEND_AUDIO ?= soloud 6 | SOLOUD_BACKEND = sdl2 7 | 8 | GL_LOADER = glad 9 | 10 | include $(DEVKITPRO)/libnx/switch_rules 11 | PKGCONFIG = $(DEVKITPRO)/portlibs/switch/bin/aarch64-none-elf-pkg-config 12 | 13 | CFLAGS += -DARM -march=armv8-a -mtune=cortex-a57 -mtp=soft -DLSB_FIRST \ 14 | -DBYTE_ORDER=LITTLE_ENDIAN -DALIGN_LONG -DALIGN_WORD \ 15 | -DM68K_OVERCLOCK_SHIFT=20 -DHAVE_ZLIB -DSWITCH -fPIE \ 16 | -Wl,--allow-multiple-definition -specs=$(DEVKITPRO)/libnx/switch.specs 17 | DEFINES += -DHAVE_ALLOCA_H -DUSE_NORMAL_SLEEP 18 | LDFLAGS += -L$(LIBNX)/lib 19 | LIBS += -lnx -lEGL -lm -lglapi -lm -ldrm_nouveau 20 | INCLUDES += -I$(LIBNX)/include -I$(PORTLIBS)/include/GLFW -I$(PORTLIBS)/include 21 | 22 | ifdef NXLINK 23 | DEFINES += -DENABLE_NXLINK 24 | endif 25 | 26 | SUFFIX = .elf 27 | PKGSUFFIX = .nro 28 | 29 | $(OUTDIR)/$(NAME)$(PKGSUFFIX): $(OUTDIR)/$(NAME)$(SUFFIX) 30 | @echo -n "Building nro..." 31 | @elf2nro $< $@ $(NROFLAGS) 32 | @echo " Done!" -------------------------------------------------------------------------------- /src/core/tremor/block.h: -------------------------------------------------------------------------------- 1 | /******************************************************************** 2 | * * 3 | * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. * 4 | * * 5 | * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * 6 | * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * 7 | * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * 8 | * * 9 | * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2008 * 10 | * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ * 11 | * * 12 | ******************************************************************** 13 | 14 | function: shared block functions 15 | 16 | ********************************************************************/ 17 | 18 | #ifndef _V_BLOCK_ 19 | #define _V_BLOCK_ 20 | 21 | extern void _vorbis_block_ripcord(vorbis_block *vb); 22 | extern void *_vorbis_block_alloc(vorbis_block *vb,long bytes); 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /.github/workflows/windows.yml: -------------------------------------------------------------------------------- 1 | name: Windows 2 | 3 | on: 4 | push: 5 | branches: [ master ] 6 | pull_request: 7 | branches: [ master ] 8 | 9 | jobs: 10 | build: 11 | 12 | runs-on: windows-2019 13 | 14 | defaults: 15 | run: 16 | shell: msys2 {0} 17 | steps: 18 | - name: Setup MSYS2 19 | uses: msys2/setup-msys2@v2 20 | with: 21 | msystem: MINGW32 22 | update: true 23 | install: >- 24 | base-devel 25 | git 26 | mingw-w64-i686-gcc 27 | mingw-w64-i686-binutils 28 | mingw-w64-i686-SDL2 29 | mingw-w64-i686-SDL2_image 30 | mingw-w64-i686-opus 31 | mingw-w64-i686-opusfile 32 | mingw-w64-i686-mpg123 33 | mingw-w64-i686-flac 34 | mingw-w64-i686-libvorbis 35 | mingw-w64-i686-jansson 36 | - name: Checkout repo 37 | uses: actions/checkout@v2 38 | with: 39 | submodules: 'recursive' 40 | - name: make clean 41 | run: make clean 42 | - name: make 43 | run: make 44 | - name: Upload artifacts 45 | uses: actions/upload-artifact@v2 46 | with: 47 | name: artifacts 48 | path: bin/ 49 | -------------------------------------------------------------------------------- /src/core/tremor/config_types.h: -------------------------------------------------------------------------------- 1 | /******************************************************************** 2 | * * 3 | * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. * 4 | * * 5 | * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * 6 | * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * 7 | * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * 8 | * * 9 | * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002 * 10 | * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ * 11 | * * 12 | ******************************************************************** 13 | 14 | function: #ifdef jail to whip a few platforms into the UNIX ideal. 15 | 16 | ********************************************************************/ 17 | #ifndef _OS_CVTYPES_H 18 | #define _OS_CVTYPES_H 19 | 20 | typedef long long ogg_int64_t; 21 | typedef int ogg_int32_t; 22 | typedef unsigned int ogg_uint32_t; 23 | typedef short ogg_int16_t; 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /src/core/tremor/window.h: -------------------------------------------------------------------------------- 1 | /******************************************************************** 2 | * * 3 | * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. * 4 | * * 5 | * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * 6 | * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * 7 | * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * 8 | * * 9 | * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002 * 10 | * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ * 11 | * * 12 | ******************************************************************** 13 | 14 | function: window functions 15 | 16 | ********************************************************************/ 17 | 18 | #ifndef _V_WINDOW_ 19 | #define _V_WINDOW_ 20 | 21 | extern const void *_vorbis_window(int type,int left); 22 | extern void _vorbis_apply_window(ogg_int32_t *d,const void *window[2], 23 | long *blocksizes, 24 | int lW,int W,int nW); 25 | 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /src/core/cd_hw/libchdr/deps/lzma/Compiler.h: -------------------------------------------------------------------------------- 1 | /* Compiler.h 2 | 2015-08-02 : Igor Pavlov : Public domain */ 3 | 4 | #ifndef __7Z_COMPILER_H 5 | #define __7Z_COMPILER_H 6 | 7 | #ifdef _MSC_VER 8 | 9 | #ifdef UNDER_CE 10 | #define RPC_NO_WINDOWS_H 11 | /* #pragma warning(disable : 4115) // '_RPC_ASYNC_STATE' : named type definition in parentheses */ 12 | #pragma warning(disable : 4201) // nonstandard extension used : nameless struct/union 13 | #pragma warning(disable : 4214) // nonstandard extension used : bit field types other than int 14 | #endif 15 | 16 | #if _MSC_VER >= 1300 17 | #pragma warning(disable : 4996) // This function or variable may be unsafe 18 | #else 19 | #pragma warning(disable : 4511) // copy constructor could not be generated 20 | #pragma warning(disable : 4512) // assignment operator could not be generated 21 | #pragma warning(disable : 4514) // unreferenced inline function has been removed 22 | #pragma warning(disable : 4702) // unreachable code 23 | #pragma warning(disable : 4710) // not inlined 24 | #pragma warning(disable : 4786) // identifier was truncated to '255' characters in the debug information 25 | #endif 26 | 27 | #endif 28 | 29 | #define UNUSED_VAR(x) (void)x; 30 | /* #define UNUSED_VAR(x) x=x; */ 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /src/core/tremor/COPYING: -------------------------------------------------------------------------------- 1 | Copyright (c) 2002, Xiph.org Foundation 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions 5 | are met: 6 | 7 | - Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | 10 | - Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | 14 | - Neither the name of the Xiph.org Foundation nor the names of its 15 | contributors may be used to endorse or promote products derived from 16 | this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION 22 | OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | -------------------------------------------------------------------------------- /Makefile_cfgs/Platforms/WiiU.cfg: -------------------------------------------------------------------------------- 1 | # Wii U is currently broken! 2 | # Compilation works fine but Wii U crashes instantly. 3 | 4 | STATIC = 1 5 | 6 | BACKEND_VIDEO ?= sdl2 7 | BACKEND_INPUT ?= sdl2 8 | BACKEND_AUDIO ?= null 9 | 10 | 11 | ifeq ($(strip $(DEVKITPPC)),) 12 | $(error "Please set DEVKITPPC in your environment. export DEVKITPPC=devkitPPC") 13 | endif 14 | ifeq ($(strip $(DEVKITPRO)),) 15 | $(error "Please set DEVKITPRO in your environment. export DEVKITPRO=devkitPRO") 16 | endif 17 | export PATH := $(DEVKITPPC)/bin:$(PORTLIBS)/bin:$(PATH) 18 | export LIBOGC_INC := $(DEVKITPRO)/libogc/include 19 | export LIBOGC_LIB := $(DEVKITPRO)/libogc/lib/wii 20 | export PORTLIBS := $(DEVKITPRO)/portlibs/ppc 21 | 22 | PREFIX := powerpc-eabi- 23 | 24 | export AS := $(PREFIX)as 25 | export CC := $(PREFIX)gcc 26 | export CXX := $(PREFIX)g++ 27 | export AR := $(PREFIX)ar 28 | export OBJCOPY := $(PREFIX)objcopy 29 | 30 | 31 | 32 | PKGCONFIG = $(DEVKITPRO)/portlibs/wiiu/bin/powerpc-eabi-pkg-config 33 | 34 | 35 | CFLAGS += -std=gnu11 -mrvl -mcpu=750 -meabi -mhard-float -ffast-math \ 36 | -O3 -Wall -Wextra -Wno-unused-parameter -Wno-strict-aliasing 37 | # DEFINES += -DHAVE_ALLOCA_H 38 | LIBS += -L$(DEVKITPPC)/lib -L$(DEVKITPPC)/lib/gcc/powerpc-eabi/4.8.2 39 | INCLUDES += -I$(LIBOGC_INC) -I$(DEVKITPRO)/portlibs/wiiu/include/SDL2 -I$(PORTLIBS)/include -I$(DEVKITPRO)/portlibs/wiiu/include -I$(DEVKITPPC)/lib/gcc/powerpc-eabi/4.8.2 40 | 41 | SUFFIX = .elf 42 | 43 | # $(PKGPATH): $(OUTDIR)/$(NAME) 44 | # @echo -n "Building nro..." 45 | # @elf2nro $< $@ $(NROFLAGS) 46 | # @echo " Done!" -------------------------------------------------------------------------------- /src/core/cd_hw/libchdr/LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright Romain Tisserand 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | * Redistributions of source code must retain the above copyright 7 | notice, this list of conditions and the following disclaimer. 8 | * Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | * Neither the name of the nor the 12 | names of its contributors may be used to endorse or promote products 13 | derived from this software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY 19 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | -------------------------------------------------------------------------------- /src/core/cd_hw/libchdr/src/bitstream.h: -------------------------------------------------------------------------------- 1 | /* license:BSD-3-Clause 2 | * copyright-holders:Aaron Giles 3 | *************************************************************************** 4 | 5 | bitstream.h 6 | 7 | Helper classes for reading/writing at the bit level. 8 | 9 | ***************************************************************************/ 10 | 11 | #pragma once 12 | 13 | #ifndef __BITSTREAM_H__ 14 | #define __BITSTREAM_H__ 15 | 16 | #include 17 | 18 | /*************************************************************************** 19 | * TYPE DEFINITIONS 20 | *************************************************************************** 21 | */ 22 | 23 | /* helper class for reading from a bit buffer */ 24 | struct bitstream 25 | { 26 | uint32_t buffer; /* current bit accumulator */ 27 | int bits; /* number of bits in the accumulator */ 28 | const uint8_t * read; /* read pointer */ 29 | uint32_t doffset; /* byte offset within the data */ 30 | uint32_t dlength; /* length of the data */ 31 | }; 32 | 33 | struct bitstream* create_bitstream(const void *src, uint32_t srclength); 34 | int bitstream_overflow(struct bitstream* bitstream); 35 | uint32_t bitstream_read_offset(struct bitstream* bitstream); 36 | 37 | uint32_t bitstream_read(struct bitstream* bitstream, int numbits); 38 | uint32_t bitstream_peek(struct bitstream* bitstream, int numbits); 39 | void bitstream_remove(struct bitstream* bitstream, int numbits); 40 | uint32_t bitstream_flush(struct bitstream* bitstream); 41 | 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /src/core/tremor/registry.h: -------------------------------------------------------------------------------- 1 | /******************************************************************** 2 | * * 3 | * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. * 4 | * * 5 | * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * 6 | * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * 7 | * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * 8 | * * 9 | * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002 * 10 | * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ * 11 | * * 12 | ******************************************************************** 13 | 14 | function: registry for time, floor, res backends and channel mappings 15 | 16 | ********************************************************************/ 17 | 18 | #ifndef _V_REG_H_ 19 | #define _V_REG_H_ 20 | 21 | #define VI_TRANSFORMB 1 22 | #define VI_WINDOWB 1 23 | #define VI_TIMEB 1 24 | #define VI_FLOORB 2 25 | #define VI_RESB 3 26 | #define VI_MAPB 1 27 | 28 | #include "backends.h" 29 | 30 | #if defined(_WIN32) && defined(VORBISDLL_IMPORT) 31 | # define EXTERN __declspec(dllimport) extern 32 | #else 33 | # define EXTERN extern 34 | #endif 35 | 36 | EXTERN vorbis_func_floor *_floor_P[]; 37 | EXTERN vorbis_func_residue *_residue_P[]; 38 | EXTERN vorbis_func_mapping *_mapping_P[]; 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /src/config.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef _CONFIG_H_ 3 | #define _CONFIG_H_ 4 | 5 | #ifdef __cplusplus 6 | extern "C" { 7 | #endif 8 | 9 | 10 | #include "shared.h" 11 | #include "jansson.h" 12 | 13 | /**************************************************************************** 14 | * Config Option 15 | * 16 | ****************************************************************************/ 17 | typedef struct 18 | { 19 | uint8 padtype; 20 | } t_input_config; 21 | 22 | typedef struct 23 | { 24 | uint8 hq_fm; 25 | uint8 filter; 26 | uint8 hq_psg; 27 | uint8 ym2612; 28 | uint8 ym2413; 29 | #ifdef HAVE_YM3438_CORE 30 | uint8 ym3438; 31 | #endif 32 | #ifdef HAVE_OPLL_CORE 33 | uint8 opll; 34 | #endif 35 | int16 psg_preamp; 36 | int16 fm_preamp; 37 | uint32 lp_range; 38 | int16 low_freq; 39 | int16 high_freq; 40 | int16 lg; 41 | int16 mg; 42 | int16 hg; 43 | uint8 mono; 44 | uint8 system; 45 | uint8 region_detect; 46 | uint8 vdp_mode; 47 | uint8 master_clock; 48 | uint8 force_dtack; 49 | uint8 addr_error; 50 | uint8 bios; 51 | uint8 lock_on; 52 | #ifdef HAVE_OVERCLOCK 53 | uint32 overclock; 54 | #endif 55 | uint8 no_sprite_limit; 56 | uint8 hot_swap; 57 | uint8 invert_mouse; 58 | uint8 gun_cursor[2]; 59 | uint8 overscan; 60 | uint8 gg_extra; 61 | uint8 ntsc; 62 | uint8 lcd; 63 | uint8 render; 64 | t_input_config input[MAX_INPUTS]; 65 | } t_config; 66 | 67 | /* Global variables */ 68 | extern t_config config_legacy; 69 | extern json_t *config_json; 70 | extern int config_load(char *config_path); 71 | 72 | #ifdef __cplusplus 73 | } 74 | #endif 75 | 76 | #endif /* _CONFIG_H_ */ 77 | 78 | -------------------------------------------------------------------------------- /src/core/cd_hw/libchdr/deps/libFLAC/COPYING.Xiph: -------------------------------------------------------------------------------- 1 | Copyright (C) 2000-2009 Josh Coalson 2 | Copyright (C) 2011-2016 Xiph.Org Foundation 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions 6 | are met: 7 | 8 | - Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | 11 | - Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in the 13 | documentation and/or other materials provided with the distribution. 14 | 15 | - Neither the name of the Xiph.org Foundation nor the names of its 16 | contributors may be used to endorse or promote products derived from 17 | this software without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR 23 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 24 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 25 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 26 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 27 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 28 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 29 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | -------------------------------------------------------------------------------- /Makefile_cfgs/Platforms/3DS.cfg: -------------------------------------------------------------------------------- 1 | # 3DS is currently broken! 2 | # Compilation works fine but 3DS crashes after the first few frames. 3 | 4 | BACKEND_VIDEO ?= sdl 5 | BACKEND_INPUT ?= sdl 6 | BACKEND_AUDIO ?= sdlmixer 7 | 8 | STATIC = 1 9 | 10 | include $(DEVKITARM)/3ds_rules 11 | #PKGCONFIG = $(DEVKITPRO)/portlibs/3ds/bin/arm-none-eabi-pkg-config 12 | 13 | CFLAGS += -g -Wall -O2 -mword-relocations \ 14 | -ffunction-sections \ 15 | -march=armv6k -mtune=mpcore -mfloat-abi=hard -mtp=soft \ 16 | -fno-rtti -fno-exceptions -std=gnu++11 17 | DEFINES += -DARM11 -D_3DS 18 | LIBS += -L$(CTRULIB)/lib -lSDL_gfx -lSDL_mixer -lSDL_image -lSDL -lmikmod -lmad -lvorbisidec -logg -lpng -ljpeg -lz -lcitro3d -lctru -lm 19 | INCLUDES += -I$(CTRULIB)/include 20 | 21 | PKGCONFIG = : 22 | CFLAGS += -D_GNU_SOURCE=1 -ffunction-sections -fdata-sections -march=armv6k \ 23 | -mtune=mpcore -mfloat-abi=hard -mword-relocations -DARM11 -D_3DS \ 24 | -IC:/msys64/opt/devkitpro/portlibs/3ds/include/SDL \ 25 | -I/opt/devkitpro/libctru/include \ 26 | -IC:/msys64/opt/devkitpro/portlibs/3ds/include \ 27 | -LC:/msys64/opt/devkitpro/portlibs/3ds/lib \ 28 | -L/opt/devkitpro/portlibs/3ds \ 29 | -L/opt/devkitpro/libctru/lib \ 30 | -L/opt/devkitpro/portlibs/3ds \ 31 | -L/opt/devkitpro/libctru/lib \ 32 | -LC:/msys64/opt/devkitpro/portlibs/3ds/lib \ 33 | -specs=3dsx.specs -march=armv6k -mfloat-abi=hard \ 34 | -march=armv6k -mfloat-abi=hard 35 | 36 | SUFFIX = .elf 37 | PKGSUFFIX = .3dsx 38 | DEFINES += -DHAVE_ALLOCA_H 39 | 40 | $(PKGPATH): $(OUTDIR)/$(NAME) 41 | @echo -n "Building 3dsx..." 42 | @3dsxtool $< $@ 43 | @echo " Done!" -------------------------------------------------------------------------------- /src/core/tremor/mdct.h: -------------------------------------------------------------------------------- 1 | /******************************************************************** 2 | * * 3 | * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. * 4 | * * 5 | * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * 6 | * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * 7 | * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * 8 | * * 9 | * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002 * 10 | * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ * 11 | * * 12 | ******************************************************************** 13 | 14 | function: modified discrete cosine transform prototypes 15 | 16 | ********************************************************************/ 17 | 18 | #ifndef _OGG_mdct_H_ 19 | #define _OGG_mdct_H_ 20 | 21 | #include "ivorbiscodec.h" 22 | #include "misc.h" 23 | 24 | #define DATA_TYPE ogg_int32_t 25 | #define REG_TYPE register ogg_int32_t 26 | 27 | #ifdef _LOW_ACCURACY_ 28 | #define cPI3_8 (0x0062) 29 | #define cPI2_8 (0x00b5) 30 | #define cPI1_8 (0x00ed) 31 | #else 32 | #define cPI3_8 (0x30fbc54d) 33 | #define cPI2_8 (0x5a82799a) 34 | #define cPI1_8 (0x7641af3d) 35 | #endif 36 | 37 | extern void mdct_forward(int n, DATA_TYPE *in, DATA_TYPE *out); 38 | extern void mdct_backward(int n, DATA_TYPE *in, DATA_TYPE *out); 39 | 40 | #endif 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /Makefile_cfgs/Platforms/Vita.cfg: -------------------------------------------------------------------------------- 1 | STATIC = 1 2 | 3 | BACKEND_VIDEO ?= sdl 4 | BACKEND_INPUT ?= sdl 5 | BACKEND_AUDIO ?= soloud 6 | SOLOUD_BACKEND ?= vita 7 | 8 | PREFIX = arm-vita-eabi 9 | PREFIX :=$(VITASDK)/bin/$(PREFIX) 10 | 11 | CC = $(PREFIX)-gcc 12 | CXX = $(PREFIX)-g++ 13 | PKGCONFIG = : 14 | 15 | CFLAGS += -g -flto -fsigned-char $(INCLUDE) -D__vita__ $(WFLAGS) -DNOLOADSO \ 16 | -DNOOBJDUMP -Wl,-q -DHAVE_MIXER -DHAVE_SDL -DSTATIC_OPENGL -DMINI_GL_COMPATIBILITY 17 | DEFINES += -DHAVE_ALLOCA_H 18 | # TODO: clean up these libraries 19 | # Alot of them are probably unused 20 | LIBS += -lSDL2 -lSDL2_ttf -lSDL2_image -lvorbisfile -lvorbis -logg -lsndfile -lvitaGL -lvita2d -lSceLibKernel_stub -lScePvf_stub \ 21 | -lSceJpegEnc_stub -lSceAppMgr_stub -lSceCtrl_stub -lSceTouch_stub -lSceMotion_stub \ 22 | -lScePromoterUtil_stub -lm -lSceNet_stub -lSceNetCtl_stub -lSceAppUtil_stub -lScePgf_stub \ 23 | -ljpeg -lfreetype -lc -lScePower_stub -lSceCommonDialog_stub -lpng16 -lz -lSceCamera_stub \ 24 | -lspeexdsp -lmpg123 -lSceAudio_stub -lSceGxm_stub -lSceDisplay_stub -lSceShellSvc_stub -lm \ 25 | -lopus -lSceHttp_stub -lSceSysmodule_stub -lpng -lz -ljpeg -lSceHid_stub 26 | INCLUDES += -I$(VITASDK)/include/SDL2 27 | 28 | SUFFIX = .elf 29 | PKGSUFFIX = .vpk 30 | 31 | $(OUTDIR)/$(NAME)$(PKGSUFFIX): $(OUTDIR)/$(NAME)$(SUFFIX) 32 | @echo -n "Building vpk..." 33 | @cp $< $(OUTDIR)/$(NAME).unstripped.elf 34 | @$(PREFIX)-strip -g $< 35 | @vita-elf-create $< $(OUTDIR)/$(NAME).velf 36 | @vita-make-fself $(OUTDIR)/$(NAME).velf $(OUTDIR)/eboot.bin 37 | @vita-mksfoex -s TITLE_ID=GPGXWIDE1 "GPGX Widescreen" $(OUTDIR)/param.sfo 38 | @vita-pack-vpk -s $(OUTDIR)/param.sfo -b $(OUTDIR)/eboot.bin $@ 39 | @echo " Done!" -------------------------------------------------------------------------------- /src/core/sound/eq.h: -------------------------------------------------------------------------------- 1 | /*--------------------------------------------------------------------------- 2 | // 3 | // 3 Band EQ :) 4 | // 5 | // EQ.H - Header file for 3 band EQ 6 | // 7 | // (c) Neil C / Etanza Systems / 2K6 8 | // 9 | // Shouts / Loves / Moans = etanza at lycos dot co dot uk 10 | // 11 | // This work is hereby placed in the public domain for all purposes, including 12 | // use in commercial applications. 13 | // 14 | // The author assumes NO RESPONSIBILITY for any problems caused by the use of 15 | // this software. 16 | // 17 | //----------------------------------------------------------------------------*/ 18 | 19 | #ifndef __EQ3BAND__ 20 | #define __EQ3BAND__ 21 | 22 | /* ------------ 23 | //| Structures | 24 | // ------------*/ 25 | 26 | typedef struct { 27 | /* Filter #1 (Low band) */ 28 | 29 | double lf; /* Frequency */ 30 | double f1p0; /* Poles ... */ 31 | double f1p1; 32 | double f1p2; 33 | double f1p3; 34 | 35 | /* Filter #2 (High band) */ 36 | 37 | double hf; /* Frequency */ 38 | double f2p0; /* Poles ... */ 39 | double f2p1; 40 | double f2p2; 41 | double f2p3; 42 | 43 | /* Sample history buffer */ 44 | 45 | double sdm1; /* Sample data minus 1 */ 46 | double sdm2; /* 2 */ 47 | double sdm3; /* 3 */ 48 | 49 | /* Gain Controls */ 50 | 51 | double lg; /* low gain */ 52 | double mg; /* mid gain */ 53 | double hg; /* high gain */ 54 | 55 | } EQSTATE; 56 | 57 | 58 | /* --------- 59 | //| Exports | 60 | // ---------*/ 61 | 62 | extern void init_3band_state(EQSTATE * es, int lowfreq, int highfreq, 63 | int mixfreq); 64 | extern double do_3band(EQSTATE * es, int sample); 65 | 66 | 67 | #endif /* #ifndef __EQ3BAND__ */ 68 | -------------------------------------------------------------------------------- /src/core/tremor/os_types.h: -------------------------------------------------------------------------------- 1 | /******************************************************************** 2 | * * 3 | * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. * 4 | * * 5 | * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * 6 | * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * 7 | * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * 8 | * * 9 | * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002 * 10 | * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ * 11 | * * 12 | ******************************************************************** 13 | 14 | function: #ifdef jail to whip a few platforms into the UNIX ideal. 15 | 16 | ********************************************************************/ 17 | #ifndef _OS_TYPES_H 18 | #define _OS_TYPES_H 19 | 20 | #ifdef _LOW_ACCURACY_ 21 | # define X(n) (((((n)>>22)+1)>>1) - ((((n)>>22)+1)>>9)) 22 | # define LOOKUP_T const unsigned char 23 | #else 24 | # define X(n) (n) 25 | # define LOOKUP_T const ogg_int32_t 26 | #endif 27 | 28 | /* make it easy on the folks that want to compile the libs with a 29 | different malloc than stdlib */ 30 | #define _ogg_malloc malloc 31 | #define _ogg_calloc calloc 32 | #define _ogg_realloc realloc 33 | #define _ogg_free free 34 | 35 | #if defined(_WIN32) && defined(__LIBRETRO__) 36 | #include 37 | #else 38 | #include 39 | #endif 40 | 41 | typedef int64_t ogg_int64_t; 42 | typedef int32_t ogg_int32_t; 43 | typedef uint32_t ogg_uint32_t; 44 | typedef int16_t ogg_int16_t; 45 | 46 | #endif /* _OS_TYPES_H */ 47 | -------------------------------------------------------------------------------- /src/core/cd_hw/libchdr/deps/libFLAC/include/private/md5.h: -------------------------------------------------------------------------------- 1 | #ifndef FLAC__PRIVATE__MD5_H 2 | #define FLAC__PRIVATE__MD5_H 3 | 4 | /* 5 | * This is the header file for the MD5 message-digest algorithm. 6 | * The algorithm is due to Ron Rivest. This code was 7 | * written by Colin Plumb in 1993, no copyright is claimed. 8 | * This code is in the public domain; do with it what you wish. 9 | * 10 | * Equivalent code is available from RSA Data Security, Inc. 11 | * This code has been tested against that, and is equivalent, 12 | * except that you don't need to include two pages of legalese 13 | * with every copy. 14 | * 15 | * To compute the message digest of a chunk of bytes, declare an 16 | * MD5Context structure, pass it to MD5Init, call MD5Update as 17 | * needed on buffers full of bytes, and then call MD5Final, which 18 | * will fill a supplied 16-byte array with the digest. 19 | * 20 | * Changed so as no longer to depend on Colin Plumb's `usual.h' 21 | * header definitions; now uses stuff from dpkg's config.h 22 | * - Ian Jackson . 23 | * Still in the public domain. 24 | * 25 | * Josh Coalson: made some changes to integrate with libFLAC. 26 | * Still in the public domain, with no warranty. 27 | */ 28 | 29 | #include "FLAC/ordinals.h" 30 | 31 | typedef union { 32 | FLAC__byte *p8; 33 | FLAC__int16 *p16; 34 | FLAC__int32 *p32; 35 | } FLAC__multibyte; 36 | 37 | typedef struct { 38 | FLAC__uint32 in[16]; 39 | FLAC__uint32 buf[4]; 40 | FLAC__uint32 bytes[2]; 41 | FLAC__multibyte internal_buf; 42 | size_t capacity; 43 | } FLAC__MD5Context; 44 | 45 | void FLAC__MD5Init(FLAC__MD5Context *context); 46 | void FLAC__MD5Final(FLAC__byte digest[16], FLAC__MD5Context *context); 47 | 48 | FLAC__bool FLAC__MD5Accumulate(FLAC__MD5Context *ctx, const FLAC__int32 * const signal[], unsigned channels, unsigned samples, unsigned bytes_per_sample); 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /src/core/tremor/registry.c: -------------------------------------------------------------------------------- 1 | /******************************************************************** 2 | * * 3 | * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. * 4 | * * 5 | * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * 6 | * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * 7 | * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * 8 | * * 9 | * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002 * 10 | * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ * 11 | * * 12 | ******************************************************************** 13 | 14 | function: registry for floor, res backends and channel mappings 15 | 16 | ********************************************************************/ 17 | 18 | #include "ivorbiscodec.h" 19 | #include "codec_internal.h" 20 | #include "registry.h" 21 | #include "misc.h" 22 | 23 | 24 | /* seems like major overkill now; the backend numbers will grow into 25 | the infrastructure soon enough */ 26 | 27 | extern vorbis_func_floor floor0_exportbundle; 28 | extern vorbis_func_floor floor1_exportbundle; 29 | extern vorbis_func_residue residue0_exportbundle; 30 | extern vorbis_func_residue residue1_exportbundle; 31 | extern vorbis_func_residue residue2_exportbundle; 32 | extern vorbis_func_mapping mapping0_exportbundle; 33 | 34 | vorbis_func_floor *_floor_P[]={ 35 | &floor0_exportbundle, 36 | &floor1_exportbundle, 37 | }; 38 | 39 | vorbis_func_residue *_residue_P[]={ 40 | &residue0_exportbundle, 41 | &residue1_exportbundle, 42 | &residue2_exportbundle, 43 | }; 44 | 45 | vorbis_func_mapping *_mapping_P[]={ 46 | &mapping0_exportbundle, 47 | }; 48 | 49 | 50 | 51 | -------------------------------------------------------------------------------- /compat/macOS/malloc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 James Hollister 3 | * 4 | * This file is subject to the terms and conditions of the GNU Lesser 5 | * General Public License v2.1. See the file LICENSE in the top level 6 | * directory for more details. 7 | */ 8 | 9 | /** 10 | * @ingroup sys 11 | * 12 | * @brief Malloc header for use with native on OSX since there is no 13 | * malloc.h file in the standard include path. 14 | * 15 | * @{ 16 | * @file 17 | * 18 | * @author James Hollister 19 | */ 20 | 21 | #ifndef MALLOC_H 22 | #define MALLOC_H 23 | 24 | #include 25 | #include 26 | 27 | #ifdef __cplusplus 28 | extern "C" { 29 | #endif 30 | 31 | /** 32 | * @brief Allocate SIZE bytes of memory. 33 | * @param[in] size Size of the block to allocate. 34 | * @returns New memory block. NULL if failed to allocate. 35 | */ 36 | extern void *malloc (size_t size); 37 | 38 | /** 39 | * @brief Allocate NMEMB elements of SIZE bytes each, all initialized to 0. 40 | * @param[in] nmemb Number of elements to be allocated. 41 | * @param[in] size Size of the block to allocate. 42 | * @returns New memory block. NULL if failed to allocate. 43 | */ 44 | extern void *calloc (size_t nmemb, size_t size); 45 | 46 | /** 47 | * @brief Re-allocate the previously allocated block in ptr, making the new 48 | * block SIZE bytes long. 49 | * @param[in] ptr Old memory block. 50 | * @param[in] size Size of the new block to allocate. 51 | * @returns New memory block. NULL if failed to allocate. 52 | */ 53 | extern void *realloc (void *ptr, size_t size); 54 | 55 | /** 56 | * @brief Free a block allocated by `malloc', `realloc' or `calloc'. 57 | * @param[in] ptr Memory block that was allocated with 'malloc, 'realloc, 58 | * or 'calloc'. 59 | */ 60 | extern void free (void *ptr); 61 | 62 | #ifdef __cplusplus 63 | } 64 | #endif 65 | 66 | #endif /* malloc.h */ 67 | 68 | /** 69 | * @} 70 | */ -------------------------------------------------------------------------------- /src/core/cd_hw/libchdr/deps/lzma/LzHash.h: -------------------------------------------------------------------------------- 1 | /* LzHash.h -- HASH functions for LZ algorithms 2 | 2015-04-12 : Igor Pavlov : Public domain */ 3 | 4 | #ifndef __LZ_HASH_H 5 | #define __LZ_HASH_H 6 | 7 | #define kHash2Size (1 << 10) 8 | #define kHash3Size (1 << 16) 9 | #define kHash4Size (1 << 20) 10 | 11 | #define kFix3HashSize (kHash2Size) 12 | #define kFix4HashSize (kHash2Size + kHash3Size) 13 | #define kFix5HashSize (kHash2Size + kHash3Size + kHash4Size) 14 | 15 | #define HASH2_CALC hv = cur[0] | ((UInt32)cur[1] << 8); 16 | 17 | #define HASH3_CALC { \ 18 | UInt32 temp = p->crc[cur[0]] ^ cur[1]; \ 19 | h2 = temp & (kHash2Size - 1); \ 20 | hv = (temp ^ ((UInt32)cur[2] << 8)) & p->hashMask; } 21 | 22 | #define HASH4_CALC { \ 23 | UInt32 temp = p->crc[cur[0]] ^ cur[1]; \ 24 | h2 = temp & (kHash2Size - 1); \ 25 | temp ^= ((UInt32)cur[2] << 8); \ 26 | h3 = temp & (kHash3Size - 1); \ 27 | hv = (temp ^ (p->crc[cur[3]] << 5)) & p->hashMask; } 28 | 29 | #define HASH5_CALC { \ 30 | UInt32 temp = p->crc[cur[0]] ^ cur[1]; \ 31 | h2 = temp & (kHash2Size - 1); \ 32 | temp ^= ((UInt32)cur[2] << 8); \ 33 | h3 = temp & (kHash3Size - 1); \ 34 | temp ^= (p->crc[cur[3]] << 5); \ 35 | h4 = temp & (kHash4Size - 1); \ 36 | hv = (temp ^ (p->crc[cur[4]] << 3)) & p->hashMask; } 37 | 38 | /* #define HASH_ZIP_CALC hv = ((cur[0] | ((UInt32)cur[1] << 8)) ^ p->crc[cur[2]]) & 0xFFFF; */ 39 | #define HASH_ZIP_CALC hv = ((cur[2] | ((UInt32)cur[0] << 8)) ^ p->crc[cur[1]]) & 0xFFFF; 40 | 41 | 42 | #define MT_HASH2_CALC \ 43 | h2 = (p->crc[cur[0]] ^ cur[1]) & (kHash2Size - 1); 44 | 45 | #define MT_HASH3_CALC { \ 46 | UInt32 temp = p->crc[cur[0]] ^ cur[1]; \ 47 | h2 = temp & (kHash2Size - 1); \ 48 | h3 = (temp ^ ((UInt32)cur[2] << 8)) & (kHash3Size - 1); } 49 | 50 | #define MT_HASH4_CALC { \ 51 | UInt32 temp = p->crc[cur[0]] ^ cur[1]; \ 52 | h2 = temp & (kHash2Size - 1); \ 53 | temp ^= ((UInt32)cur[2] << 8); \ 54 | h3 = temp & (kHash3Size - 1); \ 55 | h4 = (temp ^ (p->crc[cur[3]] << 5)) & (kHash4Size - 1); } 56 | 57 | #endif 58 | -------------------------------------------------------------------------------- /src/core/z80/osd_cpu.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * * 3 | * Define size independent data types and operations. * 4 | * * 5 | * The following types must be supported by all platforms: * 6 | * * 7 | * UINT8 - Unsigned 8-bit Integer INT8 - Signed 8-bit integer * 8 | * UINT16 - Unsigned 16-bit Integer INT16 - Signed 16-bit integer * 9 | * UINT32 - Unsigned 32-bit Integer INT32 - Signed 32-bit integer * 10 | * * 11 | *******************************************************************************/ 12 | 13 | #ifndef OSD_CPU_H 14 | #define OSD_CPU_H 15 | 16 | #undef TRUE 17 | #undef FALSE 18 | #define TRUE 1 19 | #define FALSE 0 20 | 21 | typedef unsigned char UINT8; 22 | typedef unsigned short UINT16; 23 | typedef unsigned int UINT32; 24 | typedef signed char INT8; 25 | typedef signed short INT16; 26 | typedef signed int INT32; 27 | 28 | /****************************************************************************** 29 | * Union of UINT8, UINT16 and UINT32 in native endianess of the target 30 | * This is used to access bytes and words in a machine independent manner. 31 | * The upper bytes h2 and h3 normally contain zero (16 bit CPU cores) 32 | * thus PAIR.d can be used to pass arguments to the memory system 33 | * which expects 'int' really. 34 | ******************************************************************************/ 35 | 36 | typedef union { 37 | #ifdef LSB_FIRST 38 | struct { UINT8 l,h,h2,h3; } b; 39 | struct { UINT16 l,h; } w; 40 | #else 41 | struct { UINT8 h3,h2,h,l; } b; 42 | struct { UINT16 h,l; } w; 43 | #endif 44 | UINT32 d; 45 | } PAIR; 46 | 47 | #endif /* defined OSD_CPU_H */ 48 | -------------------------------------------------------------------------------- /src/core/tremor/os.h: -------------------------------------------------------------------------------- 1 | #ifndef _OS_H 2 | #define _OS_H 3 | /******************************************************************** 4 | * * 5 | * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. * 6 | * * 7 | * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * 8 | * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * 9 | * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * 10 | * * 11 | * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002 * 12 | * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ * 13 | * * 14 | ******************************************************************** 15 | 16 | function: #ifdef jail to whip a few platforms into the UNIX ideal. 17 | 18 | ********************************************************************/ 19 | 20 | #include 21 | #include "os_types.h" 22 | 23 | #ifndef _V_IFDEFJAIL_H_ 24 | # define _V_IFDEFJAIL_H_ 25 | 26 | # ifdef __GNUC__ 27 | # define STIN static __inline__ 28 | # elif _WIN32 29 | # define STIN static __inline 30 | # endif 31 | #else 32 | # define STIN static 33 | #endif 34 | 35 | #ifndef M_PI 36 | # define M_PI (3.1415926536f) 37 | #endif 38 | 39 | #ifdef _WIN32 40 | # include 41 | # define rint(x) (floor((x)+0.5f)) 42 | # define NO_FLOAT_MATH_LIB 43 | # define FAST_HYPOT(a, b) sqrt((a)*(a) + (b)*(b)) 44 | #ifndef _XBOX360 45 | # define LITTLE_ENDIAN 1 46 | # define BYTE_ORDER LITTLE_ENDIAN 47 | #endif 48 | #endif 49 | 50 | #ifdef HAVE_ALLOCA_H 51 | # include 52 | #endif 53 | 54 | #ifdef USE_MEMORY_H 55 | # include 56 | #endif 57 | 58 | #ifndef min 59 | # define min(x,y) ((x)>(y)?(y):(x)) 60 | #endif 61 | 62 | #ifndef max 63 | # define max(x,y) ((x)<(y)?(y):(x)) 64 | #endif 65 | 66 | #endif /* _OS_H */ 67 | -------------------------------------------------------------------------------- /src/core/tremor/README: -------------------------------------------------------------------------------- 1 | This README covers the Ogg Vorbis 'Tremor' integer playback codec 2 | source as of date 2002 09 02, version 1.0.0. 3 | 4 | ****** 5 | 6 | The C source in this package will build on any ANSI C compiler and 7 | function completely and properly on any platform. The included build 8 | system assumes GNU build system and make tools (m4, automake, 9 | autoconf, libtool and gmake). GCC is not required, although GCC is 10 | the most tested compiler. To build using GNU tools, type in the 11 | source directory: 12 | 13 | ./autogen.sh 14 | make 15 | 16 | Currently, the source implements playback in pure C on all platforms 17 | except ARM, where a [currently] small amount of assembly (see 18 | asm_arm.h) is used to implement 64 bit math operations and fast LSP 19 | computation. If building on ARM without the benefit of GNU build 20 | system tools, be sure that '_ARM_ASSEM_' is #defined by the build 21 | system if this assembly is desired, else the resulting library will 22 | use whatever 64 bit math builtins the compiler implements. 23 | 24 | No math library is required by this source. No floating point 25 | operations are used at any point in either setup or decode. This 26 | decoder library will properly decode any past, current or future 27 | Vorbis I file or stream. 28 | 29 | ******** 30 | 31 | The build system produces a static and [when supported by the OS] 32 | dynamic library named 'libvorbisidec'. This library exposes an API 33 | nearly identical to the BSD reference library's 'libvorbisfile', 34 | including all the features familiar to users of vorbisfile. This API 35 | is similar enough that the proper header file to include is named 36 | 'ivorbisfile.h' [included in the source build directory]. Lower level 37 | libvorbis-style headers and structures are in 'ivorbiscodec.h' 38 | [included in the source build directory]. A simple example program, 39 | ivorbisfile_example.c, can be built with 'make example'. 40 | 41 | ******** 42 | 43 | Detailed Tremor API Documentation begins at doc/index.html 44 | 45 | Monty 46 | xiph.org 47 | -------------------------------------------------------------------------------- /src/ips.c: -------------------------------------------------------------------------------- 1 | // Implemented as per https://zerosoft.zophar.net/ips.php 2 | 3 | #include 4 | #include 5 | 6 | #ifndef MAX 7 | #define MAX(a,b) ((a) > (b)) ? (a) : (b) 8 | #endif 9 | 10 | #define BUF_CHECK(buf, buf_end) \ 11 | if (buf >= buf_end) { printf("ERROR: Buffer overflow"); return 0; } 12 | 13 | #define BYTE3_TO_UINT(bp) \ 14 | (((unsigned int)(bp)[0] << 16) & 0x00FF0000) | \ 15 | (((unsigned int)(bp)[1] << 8) & 0x0000FF00) | \ 16 | ((unsigned int)(bp)[2] & 0x000000FF) 17 | 18 | #define BYTE2_TO_UINT(bp) \ 19 | (((unsigned int)(bp)[0] << 8) & 0xFF00) | \ 20 | ((unsigned int) (bp)[1] & 0x00FF) 21 | 22 | int ips_patch( 23 | char *buf_rom, int len_rom, 24 | char *buf_ips, int len_ips 25 | ) { 26 | int size_out = 0; 27 | char *buf_ips_end = buf_ips + len_ips; 28 | char *buf_rom_end = buf_rom + len_rom; 29 | 30 | BUF_CHECK(buf_ips + 5, buf_ips_end); 31 | if (strncmp("PATCH", buf_ips, 5) != 0) 32 | return 0; 33 | buf_ips += 5; 34 | 35 | while (strncmp("EOF", buf_ips, 3) != 0) { 36 | BUF_CHECK(buf_ips + 3, buf_ips_end); 37 | unsigned int offset = BYTE3_TO_UINT(buf_ips); 38 | buf_ips += 3; 39 | BUF_CHECK(buf_ips + 2, buf_ips_end); 40 | unsigned int size = BYTE2_TO_UINT(buf_ips); 41 | buf_ips += 2; 42 | 43 | // RLE encoding 44 | if (size == 0) { 45 | BUF_CHECK(buf_ips + 2, buf_ips_end); 46 | unsigned int RLE_size = BYTE2_TO_UINT(buf_ips); 47 | buf_ips += 2; 48 | BUF_CHECK(buf_ips, buf_ips_end); 49 | unsigned char value = *buf_ips; 50 | buf_ips++; 51 | size_out = MAX(size_out, offset + RLE_size); 52 | BUF_CHECK(buf_rom + offset + RLE_size, buf_rom_end); 53 | memset(buf_rom + offset, value, RLE_size); 54 | } else { 55 | size_out = MAX(size_out, offset + size); 56 | BUF_CHECK(buf_ips + size, buf_ips_end); 57 | BUF_CHECK(buf_rom + offset + size, buf_rom_end); 58 | memcpy(buf_rom + offset, buf_ips, size); 59 | buf_ips += size; 60 | } 61 | } 62 | 63 | return size_out; 64 | } -------------------------------------------------------------------------------- /src/core/cd_hw/libchdr/deps/libFLAC/include/FLAC/assert.h: -------------------------------------------------------------------------------- 1 | /* libFLAC - Free Lossless Audio Codec library 2 | * Copyright (C) 2001-2009 Josh Coalson 3 | * Copyright (C) 2011-2016 Xiph.Org Foundation 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 9 | * - Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 12 | * - Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 16 | * - Neither the name of the Xiph.org Foundation nor the names of its 17 | * contributors may be used to endorse or promote products derived from 18 | * this software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR 24 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 25 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 26 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 27 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 28 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 29 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 30 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | */ 32 | 33 | #ifndef FLAC__ASSERT_H 34 | #define FLAC__ASSERT_H 35 | 36 | /* we need this since some compilers (like MSVC) leave assert()s on release code (and we don't want to use their ASSERT) */ 37 | #ifdef DEBUG 38 | #include 39 | #define FLAC__ASSERT(x) assert(x) 40 | #define FLAC__ASSERT_DECLARATION(x) x 41 | #else 42 | #define FLAC__ASSERT(x) 43 | #define FLAC__ASSERT_DECLARATION(x) 44 | #endif 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /src/core/cart_hw/eeprom_i2c.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * Genesis Plus 3 | * I2C Serial EEPROM (24Cxx) boards 4 | * 5 | * Copyright (C) 2007-2016 Eke-Eke (Genesis Plus GX) 6 | * 7 | * Redistribution and use of this code or any derivative works are permitted 8 | * provided that the following conditions are met: 9 | * 10 | * - Redistributions may not be sold, nor may they be used in a commercial 11 | * product or activity. 12 | * 13 | * - Redistributions that are modified from the original source must include the 14 | * complete source code, including the source code for all components used by a 15 | * binary built from the modified sources. However, as a special exception, the 16 | * source code distributed need not include anything that is normally distributed 17 | * (in either source or binary form) with the major components (compiler, kernel, 18 | * and so on) of the operating system on which the executable runs, unless that 19 | * component itself accompanies the executable. 20 | * 21 | * - Redistributions must reproduce the above copyright notice, this list of 22 | * conditions and the following disclaimer in the documentation and/or other 23 | * materials provided with the distribution. 24 | * 25 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 26 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 27 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 28 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 29 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 30 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 31 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 32 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 33 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 34 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 35 | * POSSIBILITY OF SUCH DAMAGE. 36 | * 37 | ****************************************************************************************/ 38 | 39 | #ifndef _EEPROM_I2C_H_ 40 | #define _EEPROM_I2C_H_ 41 | 42 | /* Function prototypes */ 43 | extern void eeprom_i2c_init(); 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /src/core/cd_hw/libchdr/src/flac.h: -------------------------------------------------------------------------------- 1 | // license:BSD-3-Clause 2 | // copyright-holders:Aaron Giles 3 | /*************************************************************************** 4 | 5 | flac.h 6 | 7 | FLAC compression wrappers 8 | 9 | ***************************************************************************/ 10 | 11 | #pragma once 12 | 13 | #ifndef __FLAC_H__ 14 | #define __FLAC_H__ 15 | 16 | #include 17 | #include "FLAC/ordinals.h" 18 | #include "FLAC/stream_decoder.h" 19 | 20 | //************************************************************************** 21 | // TYPE DEFINITIONS 22 | //************************************************************************** 23 | 24 | typedef struct _flac_decoder flac_decoder; 25 | struct _flac_decoder { 26 | // output state 27 | FLAC__StreamDecoder* decoder; // actual encoder 28 | uint32_t sample_rate; // decoded sample rate 29 | uint8_t channels; // decoded number of channels 30 | uint8_t bits_per_sample; // decoded bits per sample 31 | uint32_t compressed_offset; // current offset in compressed data 32 | const FLAC__byte * compressed_start; // start of compressed data 33 | uint32_t compressed_length; // length of compressed data 34 | const FLAC__byte * compressed2_start; // start of compressed data 35 | uint32_t compressed2_length; // length of compressed data 36 | int16_t * uncompressed_start[8]; // pointer to start of uncompressed data (up to 8 streams) 37 | uint32_t uncompressed_offset; // current position in uncompressed data 38 | uint32_t uncompressed_length; // length of uncompressed data 39 | int uncompressed_swap; // swap uncompressed sample data 40 | uint8_t custom_header[0x2a]; // custom header 41 | }; 42 | 43 | // ======================> flac_decoder 44 | 45 | void flac_decoder_init(flac_decoder* decoder); 46 | void flac_decoder_free(flac_decoder* decoder); 47 | int flac_decoder_reset(flac_decoder* decoder, uint32_t sample_rate, uint8_t num_channels, uint32_t block_size, const void *buffer, uint32_t length); 48 | int flac_decoder_decode_interleaved(flac_decoder* decoder, int16_t *samples, uint32_t num_samples, int swap_endian); 49 | uint32_t flac_decoder_finish(flac_decoder* decoder); 50 | 51 | #endif // __FLAC_H__ 52 | -------------------------------------------------------------------------------- /src/core/cd_hw/libchdr/deps/libFLAC/AUTHORS: -------------------------------------------------------------------------------- 1 | /* FLAC - Free Lossless Audio Codec 2 | * Copyright (C) 2001-2009 Josh Coalson 3 | * Copyright (C) 2011-2016 Xiph.Org Foundation 4 | * 5 | * This file is part the FLAC project. FLAC is comprised of several 6 | * components distributed under different licenses. The codec libraries 7 | * are distributed under Xiph.Org's BSD-like license (see the file 8 | * COPYING.Xiph in this distribution). All other programs, libraries, and 9 | * plugins are distributed under the GPL (see COPYING.GPL). The documentation 10 | * is distributed under the Gnu FDL (see COPYING.FDL). Each file in the 11 | * FLAC distribution contains at the top the terms under which it may be 12 | * distributed. 13 | * 14 | * Since this particular file is relevant to all components of FLAC, 15 | * it may be distributed under the Xiph.Org license, which is the least 16 | * restrictive of those mentioned above. See the file COPYING.Xiph in this 17 | * distribution. 18 | */ 19 | 20 | Current FLAC maintainer: Erik de Castro Lopo 21 | 22 | Original author: Josh Coalson 23 | 24 | Website : https://www.xiph.org/flac/ 25 | 26 | FLAC is an Open Source lossless audio codec originally developed by Josh Coalson 27 | between 2001 and 2009. From 2009 to 2012 FLAC was basically unmaintained. In 28 | 2012 the Erik de Castro Lopo became the chief maintainer as part of the 29 | Xiph.Org Foundation. 30 | 31 | Other major contributors and their contributions: 32 | 33 | "lvqcl" 34 | * Visual Studio build system. 35 | * Optimisations in the encoder and decoder. 36 | 37 | "Janne Hyvärinen" 38 | * Visual Studio build system. 39 | * Unicode handling on Windows. 40 | 41 | "Andrey Astafiev" 42 | * Russian translation of the HTML documentation 43 | 44 | "Miroslav Lichvar" 45 | * IA-32 assembly versions of several libFLAC routines 46 | 47 | "Brady Patterson" 48 | * AIFF file support, PPC assembly versions of libFLAC routines 49 | 50 | "Daisuke Shimamura" 51 | * i18n support in the XMMS plugin 52 | 53 | "X-Fixer" 54 | * Configuration system, tag editing, and file info in the Winamp2 plugin 55 | 56 | "Matt Zimmerman" 57 | * Libtool/autoconf/automake make system, flac man page 58 | 59 | -------------------------------------------------------------------------------- /src/core/cart_hw/svp/ssp16.h: -------------------------------------------------------------------------------- 1 | /* 2 | basic, incomplete SSP160x (SSP1601?) interpreter 3 | with SVP memory controller emu 4 | 5 | (c) Copyright 2008, Grazvydas "notaz" Ignotas 6 | Free for non-commercial use. 7 | 8 | For commercial use, separate licencing terms must be obtained. 9 | 10 | Modified for Genesis Plus GX (Eke-Eke): added BIG ENDIAN support, fixed addr/code inversion 11 | */ 12 | 13 | #ifndef _SSP16_H_ 14 | #define _SSP16_H_ 15 | 16 | /* emulation event logging (from Picodrive) */ 17 | #ifdef LOG_SVP 18 | #define EL_SVP 0x00004000 /* SVP stuff */ 19 | #define EL_ANOMALY 0x80000000 /* some unexpected conditions (during emulation) */ 20 | #define elprintf(w,f,...) error("%d(%d): " f "\n",frame_count,v_counter,##__VA_ARGS__); 21 | #endif 22 | 23 | /* register names */ 24 | enum { 25 | SSP_GR0, SSP_X, SSP_Y, SSP_A, 26 | SSP_ST, SSP_STACK, SSP_PC, SSP_P, 27 | SSP_PM0, SSP_PM1, SSP_PM2, SSP_XST, 28 | SSP_PM4, SSP_gr13, SSP_PMC, SSP_AL 29 | }; 30 | 31 | typedef union 32 | { 33 | unsigned int v; 34 | struct { 35 | #ifdef LSB_FIRST 36 | unsigned short l; 37 | unsigned short h; 38 | #else 39 | unsigned short h; 40 | unsigned short l; 41 | #endif 42 | } byte; 43 | } ssp_reg_t; 44 | 45 | typedef struct 46 | { 47 | union { 48 | unsigned short RAM[256*2]; /* 2 internal RAM banks */ 49 | struct { 50 | unsigned short RAM0[256]; 51 | unsigned short RAM1[256]; 52 | } bank; 53 | } mem; 54 | ssp_reg_t gr[16]; /* general registers */ 55 | union { 56 | unsigned char r[8]; /* BANK pointers */ 57 | struct { 58 | unsigned char r0[4]; 59 | unsigned char r1[4]; 60 | } bank; 61 | } ptr; 62 | unsigned short stack[6]; 63 | unsigned int pmac[2][6]; /* read/write modes/addrs for PM0-PM5 */ 64 | #define SSP_PMC_HAVE_ADDR 0x0001 /* address written to PMAC, waiting for mode */ 65 | #define SSP_PMC_SET 0x0002 /* PMAC is set */ 66 | #define SSP_HANG 0x1000 /* 68000 hangs SVP */ 67 | #define SSP_WAIT_PM0 0x2000 /* bit1 in PM0 */ 68 | #define SSP_WAIT_30FE06 0x4000 /* ssp tight loops on 30FE08 to become non-zero */ 69 | #define SSP_WAIT_30FE08 0x8000 /* same for 30FE06 */ 70 | #define SSP_WAIT_MASK 0xf000 71 | unsigned int emu_status; 72 | unsigned int pad[30]; 73 | } ssp1601_t; 74 | 75 | 76 | void ssp1601_reset(ssp1601_t *ssp); 77 | void ssp1601_run(int cycles); 78 | 79 | #endif 80 | -------------------------------------------------------------------------------- /src/core/input_hw/mouse.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************************** 2 | * Genesis Plus 3 | * Sega/Mega Mouse support 4 | * 5 | * Copyright (C) 2007-2017 Eke-Eke (Genesis Plus GX) 6 | * 7 | * Redistribution and use of this code or any derivative works are permitted 8 | * provided that the following conditions are met: 9 | * 10 | * - Redistributions may not be sold, nor may they be used in a commercial 11 | * product or activity. 12 | * 13 | * - Redistributions that are modified from the original source must include the 14 | * complete source code, including the source code for all components used by a 15 | * binary built from the modified sources. However, as a special exception, the 16 | * source code distributed need not include anything that is normally distributed 17 | * (in either source or binary form) with the major components (compiler, kernel, 18 | * and so on) of the operating system on which the executable runs, unless that 19 | * component itself accompanies the executable. 20 | * 21 | * - Redistributions must reproduce the above copyright notice, this list of 22 | * conditions and the following disclaimer in the documentation and/or other 23 | * materials provided with the distribution. 24 | * 25 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 26 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 27 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 28 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 29 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 30 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 31 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 32 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 33 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 34 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 35 | * POSSIBILITY OF SUCH DAMAGE. 36 | * 37 | ****************************************************************************************/ 38 | 39 | #ifndef _MOUSE_H_ 40 | #define _MOUSE_H_ 41 | 42 | /* Function prototypes */ 43 | extern void mouse_reset(int port); 44 | extern unsigned char mouse_read(void); 45 | extern void mouse_write(unsigned char data, unsigned char mask); 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /src/fileio.h: -------------------------------------------------------------------------------- 1 | /* 2 | * fileio.c 3 | * 4 | * Load a normal file, or ZIP/GZ archive. 5 | * Returns loaded ROM size (zero if an error occured) 6 | * 7 | * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Charles Mac Donald 8 | * modified by Eke-Eke (Genesis Plus GX) 9 | * 10 | * Redistribution and use of this code or any derivative works are permitted 11 | * provided that the following conditions are met: 12 | * 13 | * - Redistributions may not be sold, nor may they be used in a commercial 14 | * product or activity. 15 | * 16 | * - Redistributions that are modified from the original source must include the 17 | * complete source code, including the source code for all components used by a 18 | * binary built from the modified sources. However, as a special exception, the 19 | * source code distributed need not include anything that is normally distributed 20 | * (in either source or binary form) with the major components (compiler, kernel, 21 | * and so on) of the operating system on which the executable runs, unless that 22 | * component itself accompanies the executable. 23 | * 24 | * - Redistributions must reproduce the above copyright notice, this list of 25 | * conditions and the following disclaimer in the documentation and/or other 26 | * materials provided with the distribution. 27 | * 28 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 29 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 30 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 31 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 32 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 33 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 34 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 35 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 36 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 37 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 38 | * POSSIBILITY OF SUCH DAMAGE. 39 | * 40 | ****************************************************************************************/ 41 | 42 | #ifndef _FILEIO_H_ 43 | #define _FILEIO_H_ 44 | 45 | /* Function prototypes */ 46 | extern int load_archive(char *filename, unsigned char *buffer, int maxsize, char *extension); 47 | 48 | #endif /* _FILEIO_H_ */ 49 | -------------------------------------------------------------------------------- /src/core/cart_hw/eeprom_spi.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * Genesis Plus 3 | * SPI Serial EEPROM (25XX512 only) support 4 | * 5 | * Copyright (C) 2012 Eke-Eke (Genesis Plus GX) 6 | * 7 | * Redistribution and use of this code or any derivative works are permitted 8 | * provided that the following conditions are met: 9 | * 10 | * - Redistributions may not be sold, nor may they be used in a commercial 11 | * product or activity. 12 | * 13 | * - Redistributions that are modified from the original source must include the 14 | * complete source code, including the source code for all components used by a 15 | * binary built from the modified sources. However, as a special exception, the 16 | * source code distributed need not include anything that is normally distributed 17 | * (in either source or binary form) with the major components (compiler, kernel, 18 | * and so on) of the operating system on which the executable runs, unless that 19 | * component itself accompanies the executable. 20 | * 21 | * - Redistributions must reproduce the above copyright notice, this list of 22 | * conditions and the following disclaimer in the documentation and/or other 23 | * materials provided with the distribution. 24 | * 25 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 26 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 27 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 28 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 29 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 30 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 31 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 32 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 33 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 34 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 35 | * POSSIBILITY OF SUCH DAMAGE. 36 | * 37 | ****************************************************************************************/ 38 | 39 | #ifndef _EEPROM_SPI_H_ 40 | #define _EEPROM_SPI_H_ 41 | 42 | /* Function prototypes */ 43 | extern void eeprom_spi_init(); 44 | extern void eeprom_spi_write(unsigned char data); 45 | extern unsigned int eeprom_spi_read(unsigned int address); 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /src/core/input_hw/terebi_oekaki.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************************** 2 | * Genesis Plus 3 | * Terebi Oekaki graphic board support 4 | * 5 | * Copyright (C) 2011 Eke-Eke (Genesis Plus GX) 6 | * 7 | * Redistribution and use of this code or any derivative works are permitted 8 | * provided that the following conditions are met: 9 | * 10 | * - Redistributions may not be sold, nor may they be used in a commercial 11 | * product or activity. 12 | * 13 | * - Redistributions that are modified from the original source must include the 14 | * complete source code, including the source code for all components used by a 15 | * binary built from the modified sources. However, as a special exception, the 16 | * source code distributed need not include anything that is normally distributed 17 | * (in either source or binary form) with the major components (compiler, kernel, 18 | * and so on) of the operating system on which the executable runs, unless that 19 | * component itself accompanies the executable. 20 | * 21 | * - Redistributions must reproduce the above copyright notice, this list of 22 | * conditions and the following disclaimer in the documentation and/or other 23 | * materials provided with the distribution. 24 | * 25 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 26 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 27 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 28 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 29 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 30 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 31 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 32 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 33 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 34 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 35 | * POSSIBILITY OF SUCH DAMAGE. 36 | * 37 | ****************************************************************************************/ 38 | 39 | #ifndef _TEREBI_H_ 40 | #define _TEREBI_H_ 41 | 42 | /* Function prototypes */ 43 | extern void terebi_oekaki_reset(void); 44 | extern unsigned short terebi_oekaki_read(void); 45 | extern void terebi_oekaki_write(unsigned char data); 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /src/core/tremor/window.c: -------------------------------------------------------------------------------- 1 | /******************************************************************** 2 | * * 3 | * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. * 4 | * * 5 | * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * 6 | * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * 7 | * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * 8 | * * 9 | * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002 * 10 | * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ * 11 | * * 12 | ******************************************************************** 13 | 14 | function: window functions 15 | 16 | ********************************************************************/ 17 | 18 | #include 19 | #include 20 | #include "misc.h" 21 | #include "window.h" 22 | #include "window_lookup.h" 23 | 24 | const void *_vorbis_window(int type, int left){ 25 | 26 | switch(type){ 27 | case 0: 28 | 29 | switch(left){ 30 | case 32: 31 | return vwin64; 32 | case 64: 33 | return vwin128; 34 | case 128: 35 | return vwin256; 36 | case 256: 37 | return vwin512; 38 | case 512: 39 | return vwin1024; 40 | case 1024: 41 | return vwin2048; 42 | case 2048: 43 | return vwin4096; 44 | case 4096: 45 | return vwin8192; 46 | default: 47 | return(0); 48 | } 49 | break; 50 | default: 51 | return(0); 52 | } 53 | } 54 | 55 | void _vorbis_apply_window(ogg_int32_t *d,const void *window_p[2], 56 | long *blocksizes, 57 | int lW,int W,int nW){ 58 | 59 | LOOKUP_T *window[2]; 60 | long n=blocksizes[W]; 61 | long ln=blocksizes[lW]; 62 | long rn=blocksizes[nW]; 63 | 64 | long leftbegin=n/4-ln/4; 65 | long leftend=leftbegin+ln/2; 66 | 67 | long rightbegin=n/2+n/4-rn/4; 68 | long rightend=rightbegin+rn/2; 69 | 70 | int i,p; 71 | 72 | window[0]=window_p[0]; 73 | window[1]=window_p[1]; 74 | 75 | for(i=0;i 24 | Website : http://www.slack.net/~ant/ 25 | Forum : http://groups.google.com/group/blargg-sound-libs 26 | License : GNU Lesser General Public License (LGPL) 27 | Language: C or C++ 28 | 29 | 30 | Getting Started 31 | --------------- 32 | Build a program from demo.c, sms_ntsc.c, and the SDL multimedia library 33 | (see http://libsdl.org/). Run it with "test.bmp" in the same directory 34 | and it should show the filtered image. See demo.c for more. 35 | 36 | See sms_ntsc.txt for documentation and sms_ntsc.h for reference. Post to 37 | the discussion forum for assistance. 38 | 39 | 40 | Files 41 | ----- 42 | readme.txt Essential information 43 | sms_ntsc.txt Library documentation 44 | changes.txt Changes made since previous releases 45 | license.txt GNU Lesser General Public License 46 | 47 | benchmark.c Measures frame rate and processor usage of library 48 | demo.c Displays and saves NTSC filtered image 49 | demo_impl.h Internal routines used by demo 50 | test.bmp Test image for demo 51 | 52 | sms_ntsc_config.h Library configuration (modify as needed) 53 | sms_ntsc.h Library header and source 54 | sms_ntsc.c 55 | sms_ntsc_impl.h 56 | 57 | -- 58 | Shay Green 59 | -------------------------------------------------------------------------------- /src/core/cart_hw/ggenie.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * Genesis Plus 3 | * Game Genie Hardware emulation 4 | * 5 | * Copyright (C) 2009-2014 Eke-Eke (Genesis Plus GX) 6 | * 7 | * Based on documentation from Charles McDonald 8 | * (http://cgfm2.emuviews.com/txt/genie.txt) 9 | * 10 | * Redistribution and use of this code or any derivative works are permitted 11 | * provided that the following conditions are met: 12 | * 13 | * - Redistributions may not be sold, nor may they be used in a commercial 14 | * product or activity. 15 | * 16 | * - Redistributions that are modified from the original source must include the 17 | * complete source code, including the source code for all components used by a 18 | * binary built from the modified sources. However, as a special exception, the 19 | * source code distributed need not include anything that is normally distributed 20 | * (in either source or binary form) with the major components (compiler, kernel, 21 | * and so on) of the operating system on which the executable runs, unless that 22 | * component itself accompanies the executable. 23 | * 24 | * - Redistributions must reproduce the above copyright notice, this list of 25 | * conditions and the following disclaimer in the documentation and/or other 26 | * materials provided with the distribution. 27 | * 28 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 29 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 30 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 31 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 32 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 33 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 34 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 35 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 36 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 37 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 38 | * POSSIBILITY OF SUCH DAMAGE. 39 | * 40 | ****************************************************************************************/ 41 | 42 | #ifndef _GGENIE_H_ 43 | #define _GGENIE_H_ 44 | 45 | /* Function prototypes */ 46 | extern void ggenie_init(void); 47 | extern void ggenie_shutdown(void); 48 | extern void ggenie_reset(int hard); 49 | extern void ggenie_switch(int enable); 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /src/core/cd_hw/libchdr/src/cdrom.h: -------------------------------------------------------------------------------- 1 | /* license:BSD-3-Clause */ 2 | /* copyright-holders:Aaron Giles */ 3 | /*************************************************************************** 4 | 5 | cdrom.h 6 | 7 | Generic MAME cd-rom implementation 8 | 9 | ***************************************************************************/ 10 | 11 | #pragma once 12 | 13 | #ifndef __CDROM_H__ 14 | #define __CDROM_H__ 15 | 16 | #include 17 | 18 | 19 | /*************************************************************************** 20 | CONSTANTS 21 | ***************************************************************************/ 22 | 23 | /* tracks are padded to a multiple of this many frames */ 24 | #define CD_TRACK_PADDING (4) 25 | 26 | #define CD_MAX_TRACKS (99) /* AFAIK the theoretical limit */ 27 | #define CD_MAX_SECTOR_DATA (2352) 28 | #define CD_MAX_SUBCODE_DATA (96) 29 | 30 | #define CD_FRAME_SIZE (CD_MAX_SECTOR_DATA + CD_MAX_SUBCODE_DATA) 31 | #define CD_FRAMES_PER_HUNK (8) 32 | 33 | #define CD_METADATA_WORDS (1+(CD_MAX_TRACKS * 6)) 34 | 35 | enum 36 | { 37 | CD_TRACK_MODE1 = 0, /* mode 1 2048 bytes/sector */ 38 | CD_TRACK_MODE1_RAW, /* mode 1 2352 bytes/sector */ 39 | CD_TRACK_MODE2, /* mode 2 2336 bytes/sector */ 40 | CD_TRACK_MODE2_FORM1, /* mode 2 2048 bytes/sector */ 41 | CD_TRACK_MODE2_FORM2, /* mode 2 2324 bytes/sector */ 42 | CD_TRACK_MODE2_FORM_MIX, /* mode 2 2336 bytes/sector */ 43 | CD_TRACK_MODE2_RAW, /* mode 2 2352 bytes / sector */ 44 | CD_TRACK_AUDIO, /* redbook audio track 2352 bytes/sector (588 samples) */ 45 | 46 | CD_TRACK_RAW_DONTCARE /* special flag for cdrom_read_data: just return me whatever is there */ 47 | }; 48 | 49 | enum 50 | { 51 | CD_SUB_NORMAL = 0, /* "cooked" 96 bytes per sector */ 52 | CD_SUB_RAW, /* raw uninterleaved 96 bytes per sector */ 53 | CD_SUB_NONE /* no subcode data stored */ 54 | }; 55 | 56 | #define CD_FLAG_GDROM 0x00000001 // disc is a GD-ROM, all tracks should be stored with GD-ROM metadata 57 | #define CD_FLAG_GDROMLE 0x00000002 // legacy GD-ROM, with little-endian CDDA data 58 | 59 | /*************************************************************************** 60 | FUNCTION PROTOTYPES 61 | ***************************************************************************/ 62 | 63 | #ifdef WANT_RAW_DATA_SECTOR 64 | /* ECC utilities */ 65 | int ecc_verify(const uint8_t *sector); 66 | void ecc_generate(uint8_t *sector); 67 | void ecc_clear(uint8_t *sector); 68 | #endif 69 | 70 | #endif /* __CDROM_H__ */ 71 | -------------------------------------------------------------------------------- /src/core/input_hw/paddle.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************************** 2 | * Genesis Plus 3 | * Sega Paddle Control support 4 | * 5 | * Copyright (C) 2007-2013 Eke-Eke (Genesis Plus GX) 6 | * 7 | * Redistribution and use of this code or any derivative works are permitted 8 | * provided that the following conditions are met: 9 | * 10 | * - Redistributions may not be sold, nor may they be used in a commercial 11 | * product or activity. 12 | * 13 | * - Redistributions that are modified from the original source must include the 14 | * complete source code, including the source code for all components used by a 15 | * binary built from the modified sources. However, as a special exception, the 16 | * source code distributed need not include anything that is normally distributed 17 | * (in either source or binary form) with the major components (compiler, kernel, 18 | * and so on) of the operating system on which the executable runs, unless that 19 | * component itself accompanies the executable. 20 | * 21 | * - Redistributions must reproduce the above copyright notice, this list of 22 | * conditions and the following disclaimer in the documentation and/or other 23 | * materials provided with the distribution. 24 | * 25 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 26 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 27 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 28 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 29 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 30 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 31 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 32 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 33 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 34 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 35 | * POSSIBILITY OF SUCH DAMAGE. 36 | * 37 | ****************************************************************************************/ 38 | 39 | #ifndef _PADDLE_H_ 40 | #define _PADDLE_H_ 41 | 42 | /* Function prototypes */ 43 | extern void paddle_reset(int index); 44 | extern unsigned char paddle_1_read(void); 45 | extern unsigned char paddle_2_read(void); 46 | extern void paddle_1_write(unsigned char data, unsigned char mask); 47 | extern void paddle_2_write(unsigned char data, unsigned char mask); 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /src/core/input_hw/xe_1ap.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************************** 2 | * Genesis Plus 3 | * XE-1AP analog controller support 4 | * 5 | * Copyright (C) 2011-2015 Eke-Eke (Genesis Plus GX) 6 | * 7 | * Redistribution and use of this code or any derivative works are permitted 8 | * provided that the following conditions are met: 9 | * 10 | * - Redistributions may not be sold, nor may they be used in a commercial 11 | * product or activity. 12 | * 13 | * - Redistributions that are modified from the original source must include the 14 | * complete source code, including the source code for all components used by a 15 | * binary built from the modified sources. However, as a special exception, the 16 | * source code distributed need not include anything that is normally distributed 17 | * (in either source or binary form) with the major components (compiler, kernel, 18 | * and so on) of the operating system on which the executable runs, unless that 19 | * component itself accompanies the executable. 20 | * 21 | * - Redistributions must reproduce the above copyright notice, this list of 22 | * conditions and the following disclaimer in the documentation and/or other 23 | * materials provided with the distribution. 24 | * 25 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 26 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 27 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 28 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 29 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 30 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 31 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 32 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 33 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 34 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 35 | * POSSIBILITY OF SUCH DAMAGE. 36 | * 37 | ****************************************************************************************/ 38 | 39 | #ifndef _XE_1APH_ 40 | #define _XE_1APH_ 41 | 42 | /* Function prototypes */ 43 | extern void xe_1ap_reset(int index); 44 | extern unsigned char xe_1ap_1_read(void); 45 | extern unsigned char xe_1ap_2_read(void); 46 | extern void xe_1ap_1_write(unsigned char data, unsigned char mask); 47 | extern void xe_1ap_2_write(unsigned char data, unsigned char mask); 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /src/core/z80/z80.h: -------------------------------------------------------------------------------- 1 | #ifndef Z80_H_ 2 | #define Z80_H_ 3 | 4 | #include "osd_cpu.h" 5 | 6 | enum 7 | { 8 | /* line states */ 9 | CLEAR_LINE = 0, /* clear (a fired, held or pulsed) line */ 10 | ASSERT_LINE, /* assert an interrupt immediately */ 11 | HOLD_LINE, /* hold interrupt line until acknowledged */ 12 | PULSE_LINE /* pulse interrupt line for one instruction */ 13 | }; 14 | 15 | enum { 16 | Z80_PC, Z80_SP, 17 | Z80_A, Z80_B, Z80_C, Z80_D, Z80_E, Z80_H, Z80_L, 18 | Z80_AF, Z80_BC, Z80_DE, Z80_HL, 19 | Z80_IX, Z80_IY, Z80_AF2, Z80_BC2, Z80_DE2, Z80_HL2, 20 | Z80_R, Z80_I, Z80_IM, Z80_IFF1, Z80_IFF2, Z80_HALT, 21 | Z80_DC0, Z80_DC1, Z80_DC2, Z80_DC3, Z80_WZ 22 | }; 23 | 24 | enum { 25 | Z80_TABLE_op, 26 | Z80_TABLE_cb, 27 | Z80_TABLE_ed, 28 | Z80_TABLE_xy, 29 | Z80_TABLE_xycb, 30 | Z80_TABLE_ex /* cycles counts for taken jr/jp/call and interrupt latency (rst opcodes) */ 31 | }; 32 | 33 | /****************************************************************************/ 34 | /* The Z80 registers. HALT is set to 1 when the CPU is halted, the refresh */ 35 | /* register is calculated as follows: refresh=(Z80.r&127)|(Z80.r2&128) */ 36 | /****************************************************************************/ 37 | typedef struct 38 | { 39 | PAIR pc,sp,af,bc,de,hl,ix,iy,wz; 40 | PAIR af2,bc2,de2,hl2; 41 | UINT8 r,r2,iff1,iff2,halt,im,i; 42 | UINT8 nmi_state; /* nmi line state */ 43 | UINT8 nmi_pending; /* nmi pending */ 44 | UINT8 irq_state; /* irq line state */ 45 | UINT8 after_ei; /* are we in the EI shadow? */ 46 | UINT32 cycles; /* master clock cycles global counter */ 47 | const struct z80_irq_daisy_chain *daisy; 48 | int (*irq_callback)(int irqline); 49 | } Z80_Regs; 50 | 51 | 52 | extern Z80_Regs Z80; 53 | 54 | #ifdef Z80_OVERCLOCK_SHIFT 55 | extern UINT32 z80_cycle_ratio; 56 | #endif 57 | 58 | extern unsigned char *z80_readmap[64]; 59 | extern unsigned char *z80_writemap[64]; 60 | 61 | extern void (*z80_writemem)(unsigned int address, unsigned char data); 62 | extern unsigned char (*z80_readmem)(unsigned int address); 63 | extern void (*z80_writeport)(unsigned int port, unsigned char data); 64 | extern unsigned char (*z80_readport)(unsigned int port); 65 | 66 | extern void z80_init(const void *config, int (*irqcallback)(int)); 67 | extern void z80_reset (void); 68 | extern void z80_run(unsigned int cycles); 69 | extern void z80_get_context (void *dst); 70 | extern void z80_set_context (void *src); 71 | extern void z80_set_irq_line(unsigned int state); 72 | extern void z80_set_nmi_line(unsigned int state); 73 | 74 | #endif 75 | 76 | -------------------------------------------------------------------------------- /src/core/cart_hw/areplay.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * Genesis Plus 3 | * DATEL Action Replay / Pro Action Replay emulation 4 | * 5 | * Copyright (C) 2009-2014 Eke-Eke (Genesis Plus GX) 6 | * 7 | * Redistribution and use of this code or any derivative works are permitted 8 | * provided that the following conditions are met: 9 | * 10 | * - Redistributions may not be sold, nor may they be used in a commercial 11 | * product or activity. 12 | * 13 | * - Redistributions that are modified from the original source must include the 14 | * complete source code, including the source code for all components used by a 15 | * binary built from the modified sources. However, as a special exception, the 16 | * source code distributed need not include anything that is normally distributed 17 | * (in either source or binary form) with the major components (compiler, kernel, 18 | * and so on) of the operating system on which the executable runs, unless that 19 | * component itself accompanies the executable. 20 | * 21 | * - Redistributions must reproduce the above copyright notice, this list of 22 | * conditions and the following disclaimer in the documentation and/or other 23 | * materials provided with the distribution. 24 | * 25 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 26 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 27 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 28 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 29 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 30 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 31 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 32 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 33 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 34 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 35 | * POSSIBILITY OF SUCH DAMAGE. 36 | * 37 | ****************************************************************************************/ 38 | 39 | #ifndef _AREPLAY_H_ 40 | #define _AREPLAY_H_ 41 | 42 | #define AR_SWITCH_OFF (0) 43 | #define AR_SWITCH_ON (1) 44 | #define AR_SWITCH_TRAINER (2) 45 | 46 | extern void areplay_init(void); 47 | extern void areplay_shutdown(void); 48 | extern void areplay_reset(int hard); 49 | extern void areplay_set_status(int status); 50 | extern int areplay_get_status(void); 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /src/core/input_hw/activator.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************************** 2 | * Genesis Plus 3 | * Sega Activator support 4 | * 5 | * Copyright (C) 2011-2013 Eke-Eke (Genesis Plus GX) 6 | * 7 | * Redistribution and use of this code or any derivative works are permitted 8 | * provided that the following conditions are met: 9 | * 10 | * - Redistributions may not be sold, nor may they be used in a commercial 11 | * product or activity. 12 | * 13 | * - Redistributions that are modified from the original source must include the 14 | * complete source code, including the source code for all components used by a 15 | * binary built from the modified sources. However, as a special exception, the 16 | * source code distributed need not include anything that is normally distributed 17 | * (in either source or binary form) with the major components (compiler, kernel, 18 | * and so on) of the operating system on which the executable runs, unless that 19 | * component itself accompanies the executable. 20 | * 21 | * - Redistributions must reproduce the above copyright notice, this list of 22 | * conditions and the following disclaimer in the documentation and/or other 23 | * materials provided with the distribution. 24 | * 25 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 26 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 27 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 28 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 29 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 30 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 31 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 32 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 33 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 34 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 35 | * POSSIBILITY OF SUCH DAMAGE. 36 | * 37 | ****************************************************************************************/ 38 | 39 | #ifndef _ACTIVATOR_H_ 40 | #define _ACTIVATOR_H_ 41 | 42 | /* Function prototypes */ 43 | extern void activator_reset(int index); 44 | extern unsigned char activator_1_read(void); 45 | extern unsigned char activator_2_read(void); 46 | extern void activator_1_write(unsigned char data, unsigned char mask); 47 | extern void activator_2_write(unsigned char data, unsigned char mask); 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /src/core/input_hw/sportspad.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************************** 2 | * Genesis Plus 3 | * Sega Sports Pad support 4 | * 5 | * Copyright (C) 2007-2013 Eke-Eke (Genesis Plus GX) 6 | * 7 | * Redistribution and use of this code or any derivative works are permitted 8 | * provided that the following conditions are met: 9 | * 10 | * - Redistributions may not be sold, nor may they be used in a commercial 11 | * product or activity. 12 | * 13 | * - Redistributions that are modified from the original source must include the 14 | * complete source code, including the source code for all components used by a 15 | * binary built from the modified sources. However, as a special exception, the 16 | * source code distributed need not include anything that is normally distributed 17 | * (in either source or binary form) with the major components (compiler, kernel, 18 | * and so on) of the operating system on which the executable runs, unless that 19 | * component itself accompanies the executable. 20 | * 21 | * - Redistributions must reproduce the above copyright notice, this list of 22 | * conditions and the following disclaimer in the documentation and/or other 23 | * materials provided with the distribution. 24 | * 25 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 26 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 27 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 28 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 29 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 30 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 31 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 32 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 33 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 34 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 35 | * POSSIBILITY OF SUCH DAMAGE. 36 | * 37 | ****************************************************************************************/ 38 | 39 | #ifndef _SPORTSPAD_H_ 40 | #define _SPORTSPAD_H_ 41 | 42 | /* Function prototypes */ 43 | extern void sportspad_reset(int index); 44 | extern unsigned char sportspad_1_read(void); 45 | extern unsigned char sportspad_2_read(void); 46 | extern void sportspad_1_write(unsigned char data, unsigned char mask); 47 | extern void sportspad_2_write(unsigned char data, unsigned char mask); 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /src/core/debug/cpuhook.c: -------------------------------------------------------------------------------- 1 | /*************************************************************************************** 2 | * Genesis Plus GX 3 | * CPU hooking support 4 | * 5 | * HOOK_CPU should be defined in a makefile or MSVC project to enable this functionality 6 | * 7 | * Copyright feos (2019) 8 | * 9 | * Redistribution and use of this code or any derivative works are permitted 10 | * provided that the following conditions are met: 11 | * 12 | * - Redistributions may not be sold, nor may they be used in a commercial 13 | * product or activity. 14 | * 15 | * - Redistributions that are modified from the original source must include the 16 | * complete source code, including the source code for all components used by a 17 | * binary built from the modified sources. However, as a special exception, the 18 | * source code distributed need not include anything that is normally distributed 19 | * (in either source or binary form) with the major components (compiler, kernel, 20 | * and so on) of the operating system on which the executable runs, unless that 21 | * component itself accompanies the executable. 22 | * 23 | * - Redistributions must reproduce the above copyright notice, this list of 24 | * conditions and the following disclaimer in the documentation and/or other 25 | * materials provided with the distribution. 26 | * 27 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 28 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 29 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 30 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 31 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 32 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 33 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 34 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 35 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 36 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 37 | * POSSIBILITY OF SUCH DAMAGE. 38 | * 39 | ****************************************************************************************/ 40 | 41 | #ifdef HOOK_CPU 42 | 43 | #include 44 | #include "cpuhook.h" 45 | 46 | void(*cpu_hook)(hook_type_t type, int width, unsigned int address, unsigned int value) = NULL; 47 | 48 | void set_cpu_hook(void(*hook)(hook_type_t type, int width, unsigned int address, unsigned int value)) 49 | { 50 | cpu_hook = hook; 51 | } 52 | 53 | #endif /* HOOK_CPU */ -------------------------------------------------------------------------------- /src/core/cd_hw/libchdr/deps/libFLAC/bitmath.c: -------------------------------------------------------------------------------- 1 | /* libFLAC - Free Lossless Audio Codec library 2 | * Copyright (C) 2001-2009 Josh Coalson 3 | * Copyright (C) 2011-2016 Xiph.Org Foundation 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 9 | * - Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 12 | * - Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 16 | * - Neither the name of the Xiph.org Foundation nor the names of its 17 | * contributors may be used to endorse or promote products derived from 18 | * this software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR 24 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 25 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 26 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 27 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 28 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 29 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 30 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | */ 32 | 33 | #ifdef HAVE_CONFIG_H 34 | # include 35 | #endif 36 | 37 | #include "private/bitmath.h" 38 | 39 | /* An example of what FLAC__bitmath_silog2() computes: 40 | * 41 | * silog2(-10) = 5 42 | * silog2(- 9) = 5 43 | * silog2(- 8) = 4 44 | * silog2(- 7) = 4 45 | * silog2(- 6) = 4 46 | * silog2(- 5) = 4 47 | * silog2(- 4) = 3 48 | * silog2(- 3) = 3 49 | * silog2(- 2) = 2 50 | * silog2(- 1) = 2 51 | * silog2( 0) = 0 52 | * silog2( 1) = 2 53 | * silog2( 2) = 3 54 | * silog2( 3) = 3 55 | * silog2( 4) = 4 56 | * silog2( 5) = 4 57 | * silog2( 6) = 4 58 | * silog2( 7) = 4 59 | * silog2( 8) = 5 60 | * silog2( 9) = 5 61 | * silog2( 10) = 5 62 | */ 63 | unsigned FLAC__bitmath_silog2(FLAC__int64 v) 64 | { 65 | if(v == 0) 66 | return 0; 67 | 68 | if(v == -1) 69 | return 2; 70 | 71 | v = (v < 0) ? (-(v+1)) : v; 72 | return FLAC__bitmath_ilog2_wide(v)+2; 73 | } 74 | -------------------------------------------------------------------------------- /src/core/input_hw/teamplayer.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************************** 2 | * Genesis Plus 3 | * Team Player support 4 | * 5 | * Copyright (C) 2007-2014 Eke-Eke (Genesis Plus GX) 6 | * 7 | * Redistribution and use of this code or any derivative works are permitted 8 | * provided that the following conditions are met: 9 | * 10 | * - Redistributions may not be sold, nor may they be used in a commercial 11 | * product or activity. 12 | * 13 | * - Redistributions that are modified from the original source must include the 14 | * complete source code, including the source code for all components used by a 15 | * binary built from the modified sources. However, as a special exception, the 16 | * source code distributed need not include anything that is normally distributed 17 | * (in either source or binary form) with the major components (compiler, kernel, 18 | * and so on) of the operating system on which the executable runs, unless that 19 | * component itself accompanies the executable. 20 | * 21 | * - Redistributions must reproduce the above copyright notice, this list of 22 | * conditions and the following disclaimer in the documentation and/or other 23 | * materials provided with the distribution. 24 | * 25 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 26 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 27 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 28 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 29 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 30 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 31 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 32 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 33 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 34 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 35 | * POSSIBILITY OF SUCH DAMAGE. 36 | * 37 | ****************************************************************************************/ 38 | 39 | #ifndef _TEAMPLAYER_H_ 40 | #define _TEAMPLAYER_H_ 41 | 42 | /* Function prototypes */ 43 | extern void teamplayer_init(int port); 44 | extern void teamplayer_reset(int port); 45 | extern unsigned char teamplayer_1_read(void); 46 | extern unsigned char teamplayer_2_read(void); 47 | extern void teamplayer_1_write(unsigned char data, unsigned char mask); 48 | extern void teamplayer_2_write(unsigned char data, unsigned char mask); 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /src/core/cart_hw/svp/svp.c: -------------------------------------------------------------------------------- 1 | /* 2 | basic, incomplete SSP160x (SSP1601?) interpreter 3 | with SVP memory controller emu 4 | 5 | (c) Copyright 2008, Grazvydas "notaz" Ignotas 6 | Free for non-commercial use. 7 | 8 | For commercial use, separate licencing terms must be obtained. 9 | 10 | Modified for Genesis Plus GX (Eke-Eke): added BIG ENDIAN support, fixed addr/code inversion 11 | */ 12 | 13 | #include "shared.h" 14 | 15 | svp_t *svp; 16 | 17 | static void svp_write_dram(uint32 address, uint32 data) 18 | { 19 | *(uint16 *)(svp->dram + (address & 0x1fffe)) = data; 20 | if (data) 21 | { 22 | if (address == 0x30fe06) svp->ssp1601.emu_status &= ~SSP_WAIT_30FE06; 23 | else if (address == 0x30fe08) svp->ssp1601.emu_status &= ~SSP_WAIT_30FE08; 24 | } 25 | } 26 | 27 | static uint32 svp_read_cell_1(uint32 address) 28 | { 29 | address = (address & 0xe002) | ((address & 0x7c) << 6) | ((address & 0x1f80) >> 5); 30 | return *(uint16 *)(svp->dram + address); 31 | } 32 | 33 | static uint32 svp_read_cell_2(uint32 address) 34 | { 35 | address = (address & 0xf002) | ((address & 0x3c) << 6) | ((address & 0xfc0) >> 4); 36 | return *(uint16 *)(svp->dram + address); 37 | } 38 | 39 | static uint32 svp_read_cell_byte(uint32 address) 40 | { 41 | uint16 data = m68k.memory_map[address >> 16].read16(address); 42 | 43 | if (address & 0x01) 44 | { 45 | return (data & 0xff); 46 | } 47 | 48 | return (data >> 8); 49 | } 50 | 51 | void svp_init(void) 52 | { 53 | svp = (svp_t *) ((char *)cart.rom + 0x200000); 54 | memset(svp, 0, sizeof(*svp)); 55 | 56 | m68k.memory_map[0x30].base = svp->dram; 57 | m68k.memory_map[0x30].read8 = NULL; 58 | m68k.memory_map[0x30].read16 = NULL; 59 | m68k.memory_map[0x30].write8 = NULL; 60 | m68k.memory_map[0x30].write16 = svp_write_dram; 61 | zbank_memory_map[0x30].read = NULL; 62 | zbank_memory_map[0x30].write = NULL; 63 | 64 | m68k.memory_map[0x31].base = svp->dram + 0x10000; 65 | m68k.memory_map[0x31].read8 = NULL; 66 | m68k.memory_map[0x31].read16 = NULL; 67 | m68k.memory_map[0x31].write8 = NULL; 68 | m68k.memory_map[0x31].write16 = NULL; 69 | zbank_memory_map[0x31].read = NULL; 70 | zbank_memory_map[0x31].write = NULL; 71 | 72 | m68k.memory_map[0x39].read8 = svp_read_cell_byte; 73 | m68k.memory_map[0x39].read16 = svp_read_cell_1; 74 | zbank_memory_map[0x39].read = svp_read_cell_byte; 75 | m68k.memory_map[0x3a].read8 = svp_read_cell_byte; 76 | m68k.memory_map[0x3a].read16 = svp_read_cell_2; 77 | zbank_memory_map[0x3a].read = svp_read_cell_byte; 78 | } 79 | 80 | void svp_reset(void) 81 | { 82 | memcpy(svp->iram_rom + 0x800, cart.rom + 0x800, 0x20000 - 0x800); 83 | ssp1601_reset(&svp->ssp1601); 84 | } 85 | 86 | -------------------------------------------------------------------------------- /src/core/cd_hw/libchdr/deps/libFLAC/include/private/format.h: -------------------------------------------------------------------------------- 1 | /* libFLAC - Free Lossless Audio Codec library 2 | * Copyright (C) 2000-2009 Josh Coalson 3 | * Copyright (C) 2011-2016 Xiph.Org Foundation 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 9 | * - Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 12 | * - Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 16 | * - Neither the name of the Xiph.org Foundation nor the names of its 17 | * contributors may be used to endorse or promote products derived from 18 | * this software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR 24 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 25 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 26 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 27 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 28 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 29 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 30 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | */ 32 | 33 | #ifndef FLAC__PRIVATE__FORMAT_H 34 | #define FLAC__PRIVATE__FORMAT_H 35 | 36 | #include "FLAC/format.h" 37 | 38 | unsigned FLAC__format_get_max_rice_partition_order(unsigned blocksize, unsigned predictor_order); 39 | unsigned FLAC__format_get_max_rice_partition_order_from_blocksize(unsigned blocksize); 40 | unsigned FLAC__format_get_max_rice_partition_order_from_blocksize_limited_max_and_predictor_order(unsigned limit, unsigned blocksize, unsigned predictor_order); 41 | void FLAC__format_entropy_coding_method_partitioned_rice_contents_init(FLAC__EntropyCodingMethod_PartitionedRiceContents *object); 42 | void FLAC__format_entropy_coding_method_partitioned_rice_contents_clear(FLAC__EntropyCodingMethod_PartitionedRiceContents *object); 43 | FLAC__bool FLAC__format_entropy_coding_method_partitioned_rice_contents_ensure_size(FLAC__EntropyCodingMethod_PartitionedRiceContents *object, unsigned max_partition_order); 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /src/core/input_hw/lightgun.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************************** 2 | * Genesis Plus 3 | * Sega Light Phaser, Menacer & Konami Justifiers support 4 | * 5 | * Copyright (C) 2007-2013 Eke-Eke (Genesis Plus GX) 6 | * 7 | * Redistribution and use of this code or any derivative works are permitted 8 | * provided that the following conditions are met: 9 | * 10 | * - Redistributions may not be sold, nor may they be used in a commercial 11 | * product or activity. 12 | * 13 | * - Redistributions that are modified from the original source must include the 14 | * complete source code, including the source code for all components used by a 15 | * binary built from the modified sources. However, as a special exception, the 16 | * source code distributed need not include anything that is normally distributed 17 | * (in either source or binary form) with the major components (compiler, kernel, 18 | * and so on) of the operating system on which the executable runs, unless that 19 | * component itself accompanies the executable. 20 | * 21 | * - Redistributions must reproduce the above copyright notice, this list of 22 | * conditions and the following disclaimer in the documentation and/or other 23 | * materials provided with the distribution. 24 | * 25 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 26 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 27 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 28 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 29 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 30 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 31 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 32 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 33 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 34 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 35 | * POSSIBILITY OF SUCH DAMAGE. 36 | * 37 | ****************************************************************************************/ 38 | 39 | #ifndef _LIGHTGUN_H_ 40 | #define _LIGHTGUN_H_ 41 | 42 | /* Input devices port handlers */ 43 | extern void lightgun_reset(int index); 44 | extern void lightgun_refresh(int port); 45 | extern unsigned char phaser_1_read(void); 46 | extern unsigned char phaser_2_read(void); 47 | extern unsigned char menacer_read(void); 48 | extern unsigned char justifier_read(void); 49 | extern void justifier_write(unsigned char data, unsigned char mask); 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /src/core/state.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************************** 2 | * Genesis Plus 3 | * Savestate support 4 | * 5 | * Copyright (C) 2007-2019 Eke-Eke (Genesis Plus GX) 6 | * 7 | * Redistribution and use of this code or any derivative works are permitted 8 | * provided that the following conditions are met: 9 | * 10 | * - Redistributions may not be sold, nor may they be used in a commercial 11 | * product or activity. 12 | * 13 | * - Redistributions that are modified from the original source must include the 14 | * complete source code, including the source code for all components used by a 15 | * binary built from the modified sources. However, as a special exception, the 16 | * source code distributed need not include anything that is normally distributed 17 | * (in either source or binary form) with the major components (compiler, kernel, 18 | * and so on) of the operating system on which the executable runs, unless that 19 | * component itself accompanies the executable. 20 | * 21 | * - Redistributions must reproduce the above copyright notice, this list of 22 | * conditions and the following disclaimer in the documentation and/or other 23 | * materials provided with the distribution. 24 | * 25 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 26 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 27 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 28 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 29 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 30 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 31 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 32 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 33 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 34 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 35 | * POSSIBILITY OF SUCH DAMAGE. 36 | * 37 | ****************************************************************************************/ 38 | 39 | #ifndef _STATE_H_ 40 | #define _STATE_H_ 41 | 42 | #define STATE_SIZE 0xfd000 43 | #define STATE_VERSION "GENPLUS-GX 1.7.5" 44 | 45 | #define load_param(param, size) \ 46 | memcpy(param, &state[bufferptr], size); \ 47 | bufferptr+= size; 48 | 49 | #define save_param(param, size) \ 50 | memcpy(&state[bufferptr], param, size); \ 51 | bufferptr+= size; 52 | 53 | /* Function prototypes */ 54 | extern int state_load(unsigned char *state); 55 | extern int state_save(unsigned char *state); 56 | 57 | #endif 58 | -------------------------------------------------------------------------------- /src/core/cart_hw/sms_cart.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * Genesis Plus 3 | * SG-1000, Master System & Game Gear cartridge hardware support 4 | * 5 | * Copyright (C) 2007-2019 Eke-Eke (Genesis Plus GX) 6 | * 7 | * Redistribution and use of this code or any derivative works are permitted 8 | * provided that the following conditions are met: 9 | * 10 | * - Redistributions may not be sold, nor may they be used in a commercial 11 | * product or activity. 12 | * 13 | * - Redistributions that are modified from the original source must include the 14 | * complete source code, including the source code for all components used by a 15 | * binary built from the modified sources. However, as a special exception, the 16 | * source code distributed need not include anything that is normally distributed 17 | * (in either source or binary form) with the major components (compiler, kernel, 18 | * and so on) of the operating system on which the executable runs, unless that 19 | * component itself accompanies the executable. 20 | * 21 | * - Redistributions must reproduce the above copyright notice, this list of 22 | * conditions and the following disclaimer in the documentation and/or other 23 | * materials provided with the distribution. 24 | * 25 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 26 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 27 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 28 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 29 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 30 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 31 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 32 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 33 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 34 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 35 | * POSSIBILITY OF SUCH DAMAGE. 36 | * 37 | ****************************************************************************************/ 38 | 39 | #ifndef _SMS_CART_H_ 40 | #define _SMS_CART_H_ 41 | 42 | /* Special hardware */ 43 | #define HW_3D_GLASSES 0x01 44 | #define HW_TEREBI_OEKAKI 0x02 45 | 46 | /* Function prototypes */ 47 | extern void sms_cart_init(void); 48 | extern void sms_cart_reset(void); 49 | extern void sms_cart_switch(uint8 mode); 50 | extern int sms_cart_region_detect(void); 51 | extern int sms_cart_context_save(uint8 *state); 52 | extern int sms_cart_context_load(uint8 *state); 53 | 54 | #endif 55 | 56 | 57 | -------------------------------------------------------------------------------- /src/core/macros.h: -------------------------------------------------------------------------------- 1 | #ifndef _MACROS_H_ 2 | #define _MACROS_H_ 3 | 4 | #ifdef LSB_FIRST 5 | 6 | #define READ_BYTE(BASE, ADDR) (BASE)[(ADDR)^1] 7 | 8 | #define READ_WORD(BASE, ADDR) (((BASE)[ADDR]<<8) | (BASE)[(ADDR)+1]) 9 | 10 | #define READ_WORD_LONG(BASE, ADDR) (((BASE)[(ADDR)+1]<<24) | \ 11 | ((BASE)[(ADDR)]<<16) | \ 12 | ((BASE)[(ADDR)+3]<<8) | \ 13 | (BASE)[(ADDR)+2]) 14 | 15 | #define WRITE_BYTE(BASE, ADDR, VAL) (BASE)[(ADDR)^1] = (VAL)&0xff 16 | 17 | #define WRITE_WORD(BASE, ADDR, VAL) (BASE)[ADDR] = ((VAL)>>8) & 0xff; \ 18 | (BASE)[(ADDR)+1] = (VAL)&0xff 19 | 20 | #define WRITE_WORD_LONG(BASE, ADDR, VAL) (BASE)[(ADDR+1)] = ((VAL)>>24) & 0xff; \ 21 | (BASE)[(ADDR)] = ((VAL)>>16)&0xff; \ 22 | (BASE)[(ADDR+3)] = ((VAL)>>8)&0xff; \ 23 | (BASE)[(ADDR+2)] = (VAL)&0xff 24 | 25 | #else 26 | 27 | #define READ_BYTE(BASE, ADDR) (BASE)[ADDR] 28 | #define READ_WORD(BASE, ADDR) *(uint16 *)((BASE) + (ADDR)) 29 | #define READ_WORD_LONG(BASE, ADDR) *(uint32 *)((BASE) + (ADDR)) 30 | #define WRITE_BYTE(BASE, ADDR, VAL) (BASE)[ADDR] = VAL & 0xff 31 | #define WRITE_WORD(BASE, ADDR, VAL) *(uint16 *)((BASE) + (ADDR)) = VAL & 0xffff 32 | #define WRITE_WORD_LONG(BASE, ADDR, VAL) *(uint32 *)((BASE) + (ADDR)) = VAL & 0xffffffff 33 | #endif 34 | 35 | /* C89 compatibility */ 36 | #ifndef M_PI 37 | #define M_PI 3.14159265358979323846264338327f 38 | #endif /* M_PI */ 39 | 40 | /* Set to your compiler's static inline keyword to enable it, or 41 | * set it to blank to disable it. 42 | * If you define INLINE in makefile or osd.h, it will override this value. 43 | * NOTE: not enabling inline functions will SEVERELY slow down emulation. 44 | */ 45 | #ifndef INLINE 46 | #define INLINE static __inline__ 47 | #endif /* INLINE */ 48 | 49 | /* Alignment macros for cross compiler compatibility */ 50 | #if defined(_MSC_VER) 51 | #define ALIGNED_(x) __declspec(align(x)) 52 | #elif defined(__GNUC__) 53 | #define ALIGNED_(x) __attribute__ ((aligned(x))) 54 | #endif 55 | 56 | /* Default CD image file access (read-only) functions */ 57 | /* If you need to override default stdio.h functions with custom filesystem API, 58 | redefine following macros in platform specific include file (osd.h) or Makefile 59 | */ 60 | #ifndef cdStream 61 | #define cdStream FILE 62 | #define cdStreamOpen(fname) fopen(fname, "rb") 63 | #define cdStreamClose fclose 64 | #define cdStreamRead fread 65 | #define cdStreamSeek fseek 66 | #define cdStreamTell ftell 67 | #define cdStreamGets fgets 68 | #endif 69 | 70 | #endif /* _MACROS_H_ */ 71 | -------------------------------------------------------------------------------- /src/core/cd_hw/libchdr/deps/libFLAC/include/protected/stream_decoder.h: -------------------------------------------------------------------------------- 1 | /* libFLAC - Free Lossless Audio Codec library 2 | * Copyright (C) 2000-2009 Josh Coalson 3 | * Copyright (C) 2011-2016 Xiph.Org Foundation 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 9 | * - Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 12 | * - Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 16 | * - Neither the name of the Xiph.org Foundation nor the names of its 17 | * contributors may be used to endorse or promote products derived from 18 | * this software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR 24 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 25 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 26 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 27 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 28 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 29 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 30 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | */ 32 | 33 | #ifndef FLAC__PROTECTED__STREAM_DECODER_H 34 | #define FLAC__PROTECTED__STREAM_DECODER_H 35 | 36 | #include "FLAC/stream_decoder.h" 37 | #if FLAC__HAS_OGG 38 | #include "private/ogg_decoder_aspect.h" 39 | #endif 40 | 41 | typedef struct FLAC__StreamDecoderProtected { 42 | FLAC__StreamDecoderState state; 43 | FLAC__StreamDecoderInitStatus initstate; 44 | unsigned channels; 45 | FLAC__ChannelAssignment channel_assignment; 46 | unsigned bits_per_sample; 47 | unsigned sample_rate; /* in Hz */ 48 | unsigned blocksize; /* in samples (per channel) */ 49 | FLAC__bool md5_checking; /* if true, generate MD5 signature of decoded data and compare against signature in the STREAMINFO metadata block */ 50 | #if FLAC__HAS_OGG 51 | FLAC__OggDecoderAspect ogg_decoder_aspect; 52 | #endif 53 | } FLAC__StreamDecoderProtected; 54 | 55 | /* 56 | * return the number of input bytes consumed 57 | */ 58 | unsigned FLAC__stream_decoder_get_input_bytes_unconsumed(const FLAC__StreamDecoder *decoder); 59 | 60 | #endif 61 | -------------------------------------------------------------------------------- /src/core/sound/sound.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************************** 2 | * Genesis Plus 3 | * Sound Hardware 4 | * 5 | * Copyright (C) 1998-2003 Charles Mac Donald (original code) 6 | * Copyright (C) 2007-2019 Eke-Eke (Genesis Plus GX) 7 | * 8 | * Redistribution and use of this code or any derivative works are permitted 9 | * provided that the following conditions are met: 10 | * 11 | * - Redistributions may not be sold, nor may they be used in a commercial 12 | * product or activity. 13 | * 14 | * - Redistributions that are modified from the original source must include the 15 | * complete source code, including the source code for all components used by a 16 | * binary built from the modified sources. However, as a special exception, the 17 | * source code distributed need not include anything that is normally distributed 18 | * (in either source or binary form) with the major components (compiler, kernel, 19 | * and so on) of the operating system on which the executable runs, unless that 20 | * component itself accompanies the executable. 21 | * 22 | * - Redistributions must reproduce the above copyright notice, this list of 23 | * conditions and the following disclaimer in the documentation and/or other 24 | * materials provided with the distribution. 25 | * 26 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 27 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 28 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 29 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 30 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 31 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 32 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 33 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 34 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 35 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 36 | * POSSIBILITY OF SUCH DAMAGE. 37 | * 38 | ****************************************************************************************/ 39 | 40 | #ifndef _SOUND_H_ 41 | #define _SOUND_H_ 42 | 43 | /* Function prototypes */ 44 | extern void sound_init(void); 45 | extern void sound_reset(void); 46 | extern int sound_context_save(uint8 *state); 47 | extern int sound_context_load(uint8 *state); 48 | extern int sound_update(unsigned int cycles); 49 | extern void (*fm_reset)(unsigned int cycles); 50 | extern void (*fm_write)(unsigned int cycles, unsigned int address, unsigned int data); 51 | extern unsigned int (*fm_read)(unsigned int cycles, unsigned int address); 52 | 53 | #endif /* _SOUND_H_ */ 54 | -------------------------------------------------------------------------------- /src/core/cart_hw/sram.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************************** 2 | * Genesis Plus 3 | * Backup RAM support 4 | * 5 | * Copyright (C) 2007-2019 Eke-Eke (Genesis Plus GX) 6 | * 7 | * Redistribution and use of this code or any derivative works are permitted 8 | * provided that the following conditions are met: 9 | * 10 | * - Redistributions may not be sold, nor may they be used in a commercial 11 | * product or activity. 12 | * 13 | * - Redistributions that are modified from the original source must include the 14 | * complete source code, including the source code for all components used by a 15 | * binary built from the modified sources. However, as a special exception, the 16 | * source code distributed need not include anything that is normally distributed 17 | * (in either source or binary form) with the major components (compiler, kernel, 18 | * and so on) of the operating system on which the executable runs, unless that 19 | * component itself accompanies the executable. 20 | * 21 | * - Redistributions must reproduce the above copyright notice, this list of 22 | * conditions and the following disclaimer in the documentation and/or other 23 | * materials provided with the distribution. 24 | * 25 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 26 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 27 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 28 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 29 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 30 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 31 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 32 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 33 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 34 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 35 | * POSSIBILITY OF SUCH DAMAGE. 36 | * 37 | ****************************************************************************************/ 38 | 39 | #ifndef _SRAM_H_ 40 | #define _SRAM_H_ 41 | 42 | typedef struct 43 | { 44 | uint8 detected; 45 | uint8 on; 46 | uint8 custom; 47 | uint32 start; 48 | uint32 end; 49 | uint32 crc; 50 | uint8 *sram; 51 | } T_SRAM; 52 | 53 | /* Function prototypes */ 54 | extern void sram_init(); 55 | extern unsigned int sram_read_byte(unsigned int address); 56 | extern unsigned int sram_read_word(unsigned int address); 57 | extern void sram_write_byte(unsigned int address, unsigned int data); 58 | extern void sram_write_word(unsigned int address, unsigned int data); 59 | 60 | /* global variables */ 61 | extern T_SRAM sram; 62 | 63 | #endif 64 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # GPGX Wide 2 | 3 | [![Windows](https://github.com/heyjoeway/Genesis-Plus-GX/actions/workflows/windows.yml/badge.svg)](https://github.com/heyjoeway/Genesis-Plus-GX/actions/workflows/windows.yml) 4 | [![Linux](https://github.com/heyjoeway/Genesis-Plus-GX/actions/workflows/linux.yml/badge.svg)](https://github.com/heyjoeway/Genesis-Plus-GX/actions/workflows/linux.yml) 5 | [![Nintendo Switch](https://github.com/heyjoeway/Genesis-Plus-GX/actions/workflows/switch.yml/badge.svg)](https://github.com/heyjoeway/Genesis-Plus-GX/actions/workflows/switch.yml) 6 | 7 | This is a fork of the Genesis Plus GX emulator (https://github.com/ekeeke/Genesis-Plus-GX) that is meant to run classic Sonic games (and possibly other titles, with ROM modifications) in 16:9 widescreen. Specifically, it's meant to run with [this hack of Sonic 2](https://github.com/heyjoeway/s2disasm). 8 | 9 | This project has strayed pretty far from base repository. It has a complete restructuring of the file layout, only supports building standalone emulators (with a completely rewritten makefile), has custom backends for input, sound, and rendering, and has a plethora of new features. Those include: 10 | - Widescreen support 11 | - Support for OGG music (custom Sonic 2 mod only) 12 | - Multi-system multiplayer (to avoid dealing with the weird splitscreen VDP mode) 13 | - Compilation for strange platforms, including 14 | - Emscripten 15 | - Nintendo Switch 16 | - JSON configuration 17 | 18 | ## Building 19 | 20 | ### Windows 21 | 22 | Compilation is done with the GNU Make system under [msys2](https://www.msys2.org/). You'll need to install some dependencies: 23 | ``` 24 | pacman -Syu # Re-run this until no new packages are installed 25 | pacman -S git base-devel 26 | pacman -S mingw-w64-x86_64-binutils mingw-w64-x86_64-gcc mingw-w64-x86_64-SDL2 mingw-w64-x86_64-SDL2_image mingw-w64-x86_64-SDL2_mixer mingw-w64-x86_64-jansson 27 | pacman -S mingw-w64-i686-binutils mingw-w64-i686-gcc mingw-w64-i686-SDL2 mingw-w64-i686-SDL2_image mingw-w64-i686-SDL2_mixer mingw-w64-i686-jansson # Optional 28 | ``` 29 | 30 | Once you've got them, it's pretty simple to compile: 31 | ``` 32 | git clone --recurse-submodules https://github.com/heyjoeway/Genesis-Plus-GX 33 | cd Genesis-Plus-GX 34 | make 35 | ``` 36 | Executable should end up at `./bin/Windows/gen.exe`. 37 | 38 | ### Emscripten 39 | 40 | (need to finish this section) 41 | 42 | You'll need to set up an [Emscripten development environment](https://emscripten.org/docs/getting_started/downloads.html#installation-instructions). Once you've got it ready: 43 | ``` 44 | git clone --recurse-submodules https://github.com/heyjoeway/Genesis-Plus-GX 45 | cd Genesis-Plus-GX 46 | emmake make 47 | ``` 48 | This will output files at `./bin/Emscripten`. You can serve these files locally to test them. Additionally, copy the files from `./emscripten` to the output folder if you want a more refined UI. -------------------------------------------------------------------------------- /src/core/cd_hw/libchdr/deps/libFLAC/include/private/macros.h: -------------------------------------------------------------------------------- 1 | /* libFLAC - Free Lossless Audio Codec library 2 | * Copyright (C) 2012-2016 Xiph.org Foundation 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 8 | * - Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * - Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 15 | * - Neither the name of the Xiph.org Foundation nor the names of its 16 | * contributors may be used to endorse or promote products derived from 17 | * this software without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR 23 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 24 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 25 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 26 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 27 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 28 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 29 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | */ 31 | 32 | #ifndef FLAC__PRIVATE__MACROS_H 33 | #define FLAC__PRIVATE__MACROS_H 34 | 35 | #if defined(__GNUC__) && (__GNUC__ > 4 || ( __GNUC__ == 4 && __GNUC_MINOR__ >= 3)) 36 | 37 | #define flac_max(a,b) \ 38 | ({ __typeof__ (a) _a = (a); \ 39 | __typeof__ (b) _b = (b); \ 40 | _a > _b ? _a : _b; }) 41 | 42 | #define MIN_PASTE(A,B) A##B 43 | #define MIN_IMPL(A,B,L) ({ \ 44 | __typeof__(A) MIN_PASTE(__a,L) = (A); \ 45 | __typeof__(B) MIN_PASTE(__b,L) = (B); \ 46 | MIN_PASTE(__a,L) < MIN_PASTE(__b,L) ? MIN_PASTE(__a,L) : MIN_PASTE(__b,L); \ 47 | }) 48 | 49 | #define flac_min(A,B) MIN_IMPL(A,B,__COUNTER__) 50 | 51 | /* Whatever other unix that has sys/param.h */ 52 | #elif defined(HAVE_SYS_PARAM_H) 53 | #include 54 | #define flac_max(a,b) MAX(a,b) 55 | #define flac_min(a,b) MIN(a,b) 56 | 57 | /* Windows VS has them in stdlib.h.. XXX:Untested */ 58 | #elif defined(_MSC_VER) 59 | #include 60 | #define flac_max(a,b) __max(a,b) 61 | #define flac_min(a,b) __min(a,b) 62 | #endif 63 | 64 | #ifndef MIN 65 | #define MIN(x,y) ((x) <= (y) ? (x) : (y)) 66 | #endif 67 | 68 | #ifndef MAX 69 | #define MAX(x,y) ((x) >= (y) ? (x) : (y)) 70 | #endif 71 | 72 | #endif 73 | -------------------------------------------------------------------------------- /src/core/cd_hw/libchdr/deps/libFLAC/include/private/crc.h: -------------------------------------------------------------------------------- 1 | /* libFLAC - Free Lossless Audio Codec library 2 | * Copyright (C) 2000-2009 Josh Coalson 3 | * Copyright (C) 2011-2016 Xiph.Org Foundation 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 9 | * - Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 12 | * - Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 16 | * - Neither the name of the Xiph.org Foundation nor the names of its 17 | * contributors may be used to endorse or promote products derived from 18 | * this software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR 24 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 25 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 26 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 27 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 28 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 29 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 30 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | */ 32 | 33 | #ifndef FLAC__PRIVATE__CRC_H 34 | #define FLAC__PRIVATE__CRC_H 35 | 36 | #include "FLAC/ordinals.h" 37 | 38 | /* 8 bit CRC generator, MSB shifted first 39 | ** polynomial = x^8 + x^2 + x^1 + x^0 40 | ** init = 0 41 | */ 42 | extern FLAC__byte const FLAC__crc8_table[256]; 43 | #define FLAC__CRC8_UPDATE(data, crc) (crc) = FLAC__crc8_table[(crc) ^ (data)]; 44 | void FLAC__crc8_update(const FLAC__byte data, FLAC__uint8 *crc); 45 | void FLAC__crc8_update_block(const FLAC__byte *data, unsigned len, FLAC__uint8 *crc); 46 | FLAC__uint8 FLAC__crc8(const FLAC__byte *data, unsigned len); 47 | 48 | /* 16 bit CRC generator, MSB shifted first 49 | ** polynomial = x^16 + x^15 + x^2 + x^0 50 | ** init = 0 51 | */ 52 | extern unsigned const FLAC__crc16_table[256]; 53 | 54 | #define FLAC__CRC16_UPDATE(data, crc) ((((crc)<<8) & 0xffff) ^ FLAC__crc16_table[((crc)>>8) ^ (data)]) 55 | /* this alternate may be faster on some systems/compilers */ 56 | #if 0 57 | #define FLAC__CRC16_UPDATE(data, crc) ((((crc)<<8) ^ FLAC__crc16_table[((crc)>>8) ^ (data)]) & 0xffff) 58 | #endif 59 | 60 | unsigned FLAC__crc16(const FLAC__byte *data, unsigned len); 61 | 62 | #endif 63 | -------------------------------------------------------------------------------- /src/core/cd_hw/cd_cart.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************************** 2 | * Genesis Plus 3 | * CD compatible ROM/RAM cartridge support 4 | * 5 | * Copyright (C) 2012-2016 Eke-Eke (Genesis Plus GX) 6 | * 7 | * Redistribution and use of this code or any derivative works are permitted 8 | * provided that the following conditions are met: 9 | * 10 | * - Redistributions may not be sold, nor may they be used in a commercial 11 | * product or activity. 12 | * 13 | * - Redistributions that are modified from the original source must include the 14 | * complete source code, including the source code for all components used by a 15 | * binary built from the modified sources. However, as a special exception, the 16 | * source code distributed need not include anything that is normally distributed 17 | * (in either source or binary form) with the major components (compiler, kernel, 18 | * and so on) of the operating system on which the executable runs, unless that 19 | * component itself accompanies the executable. 20 | * 21 | * - Redistributions must reproduce the above copyright notice, this list of 22 | * conditions and the following disclaimer in the documentation and/or other 23 | * materials provided with the distribution. 24 | * 25 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 26 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 27 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 28 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 29 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 30 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 31 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 32 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 33 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 34 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 35 | * POSSIBILITY OF SUCH DAMAGE. 36 | * 37 | ****************************************************************************************/ 38 | 39 | 40 | /* CD compatible ROM/RAM cartridge */ 41 | typedef struct 42 | { 43 | uint8 area[0x840080]; /* cartridge ROM/RAM area (max. 8MB ROM + 64KB backup memory + Pro Action Replay 128KB ROM / 64KB RAM + cartridge infos) */ 44 | uint8 boot; /* cartridge boot mode (0x00: boot from CD with ROM/RAM cartridge enabled, 0x40: boot from ROM cartridge with CD enabled) */ 45 | uint8 id; /* RAM cartridge ID (related to RAM size, 0 if disabled) */ 46 | uint8 prot; /* RAM cartridge write protection */ 47 | uint32 mask; /* RAM cartridge size mask */ 48 | } cd_cart_t; 49 | 50 | /* Function prototypes */ 51 | extern void cd_cart_init(void); 52 | -------------------------------------------------------------------------------- /src/core/sound/psg.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************************** 2 | * Genesis Plus 3 | * PSG sound chip (SN76489A compatible) 4 | * 5 | * Support for discrete chip & integrated (ASIC) clones 6 | * 7 | * Noise implementation based on http://www.smspower.org/Development/SN76489#NoiseChannel 8 | * 9 | * Copyright (C) 2016-2017 Eke-Eke (Genesis Plus GX) 10 | * 11 | * Redistribution and use of this code or any derivative works are permitted 12 | * provided that the following conditions are met: 13 | * 14 | * - Redistributions may not be sold, nor may they be used in a commercial 15 | * product or activity. 16 | * 17 | * - Redistributions that are modified from the original source must include the 18 | * complete source code, including the source code for all components used by a 19 | * binary built from the modified sources. However, as a special exception, the 20 | * source code distributed need not include anything that is normally distributed 21 | * (in either source or binary form) with the major components (compiler, kernel, 22 | * and so on) of the operating system on which the executable runs, unless that 23 | * component itself accompanies the executable. 24 | * 25 | * - Redistributions must reproduce the above copyright notice, this list of 26 | * conditions and the following disclaimer in the documentation and/or other 27 | * materials provided with the distribution. 28 | * 29 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 30 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 31 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 32 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 33 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 34 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 35 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 36 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 37 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 38 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 39 | * POSSIBILITY OF SUCH DAMAGE. 40 | * 41 | ****************************************************************************************/ 42 | 43 | #ifndef _PSG_H_ 44 | #define _PSG_H_ 45 | 46 | typedef enum { 47 | PSG_DISCRETE, 48 | PSG_INTEGRATED 49 | } PSG_TYPE; 50 | 51 | /* Function prototypes */ 52 | extern void psg_init(PSG_TYPE type); 53 | extern void psg_reset(void); 54 | extern int psg_context_save(uint8 *state); 55 | extern int psg_context_load(uint8 *state); 56 | extern void psg_write(unsigned int clocks, unsigned int data); 57 | extern void psg_config(unsigned int clocks, unsigned int preamp, unsigned int panning); 58 | extern void psg_end_frame(unsigned int clocks); 59 | 60 | #endif /* _PSG_H_ */ 61 | -------------------------------------------------------------------------------- /src/core/input_hw/terebi_oekaki.c: -------------------------------------------------------------------------------- 1 | /*************************************************************************************** 2 | * Genesis Plus 3 | * Terebi Oekaki graphic board support 4 | * 5 | * Copyright (C) 2011 Eke-Eke (Genesis Plus GX) 6 | * 7 | * Redistribution and use of this code or any derivative works are permitted 8 | * provided that the following conditions are met: 9 | * 10 | * - Redistributions may not be sold, nor may they be used in a commercial 11 | * product or activity. 12 | * 13 | * - Redistributions that are modified from the original source must include the 14 | * complete source code, including the source code for all components used by a 15 | * binary built from the modified sources. However, as a special exception, the 16 | * source code distributed need not include anything that is normally distributed 17 | * (in either source or binary form) with the major components (compiler, kernel, 18 | * and so on) of the operating system on which the executable runs, unless that 19 | * component itself accompanies the executable. 20 | * 21 | * - Redistributions must reproduce the above copyright notice, this list of 22 | * conditions and the following disclaimer in the documentation and/or other 23 | * materials provided with the distribution. 24 | * 25 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 26 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 27 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 28 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 29 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 30 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 31 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 32 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 33 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 34 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 35 | * POSSIBILITY OF SUCH DAMAGE. 36 | * 37 | ****************************************************************************************/ 38 | 39 | #include "shared.h" 40 | 41 | static struct 42 | { 43 | uint8 axis; 44 | uint8 busy; 45 | } tablet; 46 | 47 | void terebi_oekaki_reset(void) 48 | { 49 | input.analog[0][0] = 128; 50 | input.analog[0][1] = 128; 51 | tablet.axis = 1; 52 | tablet.busy = 1; 53 | } 54 | 55 | unsigned short terebi_oekaki_read(void) 56 | { 57 | uint16 data = (tablet.busy << 15) | input.analog[0][tablet.axis]; 58 | 59 | if (!(input.pad[0] & INPUT_B)) 60 | { 61 | data |= 0x100; 62 | } 63 | 64 | /* clear BUSY flag */ 65 | tablet.busy = 0; 66 | 67 | return data; 68 | } 69 | 70 | void terebi_oekaki_write(unsigned char data) 71 | { 72 | /* X (1) or Y (0) axis */ 73 | tablet.axis = (data & 1) ^ 1; 74 | 75 | /* set BUSY flag */ 76 | tablet.busy = 1; 77 | } 78 | -------------------------------------------------------------------------------- /src/core/cd_hw/libchdr/deps/libFLAC/include/FLAC/ordinals.h: -------------------------------------------------------------------------------- 1 | /* libFLAC - Free Lossless Audio Codec library 2 | * Copyright (C) 2000-2009 Josh Coalson 3 | * Copyright (C) 2011-2016 Xiph.Org Foundation 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 9 | * - Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 12 | * - Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 16 | * - Neither the name of the Xiph.org Foundation nor the names of its 17 | * contributors may be used to endorse or promote products derived from 18 | * this software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR 24 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 25 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 26 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 27 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 28 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 29 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 30 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | */ 32 | 33 | #ifndef FLAC__ORDINALS_H 34 | #define FLAC__ORDINALS_H 35 | 36 | #if defined(_MSC_VER) && _MSC_VER < 1600 37 | 38 | /* Microsoft Visual Studio earlier than the 2010 version did not provide 39 | * the 1999 ISO C Standard header file . 40 | */ 41 | 42 | typedef __int8 FLAC__int8; 43 | typedef unsigned __int8 FLAC__uint8; 44 | 45 | typedef __int16 FLAC__int16; 46 | typedef __int32 FLAC__int32; 47 | typedef __int64 FLAC__int64; 48 | typedef unsigned __int16 FLAC__uint16; 49 | typedef unsigned __int32 FLAC__uint32; 50 | typedef unsigned __int64 FLAC__uint64; 51 | 52 | #else 53 | 54 | /* For MSVC 2010 and everything else which provides . */ 55 | 56 | #include 57 | 58 | typedef int8_t FLAC__int8; 59 | typedef uint8_t FLAC__uint8; 60 | 61 | typedef int16_t FLAC__int16; 62 | typedef int32_t FLAC__int32; 63 | typedef int64_t FLAC__int64; 64 | typedef uint16_t FLAC__uint16; 65 | typedef uint32_t FLAC__uint32; 66 | typedef uint64_t FLAC__uint64; 67 | 68 | #endif 69 | 70 | typedef int FLAC__bool; 71 | 72 | typedef FLAC__uint8 FLAC__byte; 73 | 74 | 75 | #ifdef true 76 | #undef true 77 | #endif 78 | #ifdef false 79 | #undef false 80 | #endif 81 | #ifndef __cplusplus 82 | #define true 1 83 | #define false 0 84 | #endif 85 | 86 | #endif 87 | -------------------------------------------------------------------------------- /src/core/cd_hw/libchdr/deps/libFLAC/include/private/memory.h: -------------------------------------------------------------------------------- 1 | /* libFLAC - Free Lossless Audio Codec library 2 | * Copyright (C) 2001-2009 Josh Coalson 3 | * Copyright (C) 2011-2016 Xiph.Org Foundation 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 9 | * - Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 12 | * - Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 16 | * - Neither the name of the Xiph.org Foundation nor the names of its 17 | * contributors may be used to endorse or promote products derived from 18 | * this software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR 24 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 25 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 26 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 27 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 28 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 29 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 30 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | */ 32 | 33 | #ifndef FLAC__PRIVATE__MEMORY_H 34 | #define FLAC__PRIVATE__MEMORY_H 35 | 36 | #ifdef HAVE_CONFIG_H 37 | #include 38 | #endif 39 | 40 | #include /* for size_t */ 41 | 42 | #include "private/float.h" 43 | #include "FLAC/ordinals.h" /* for FLAC__bool */ 44 | 45 | /* Returns the unaligned address returned by malloc. 46 | * Use free() on this address to deallocate. 47 | */ 48 | void *FLAC__memory_alloc_aligned(size_t bytes, void **aligned_address); 49 | FLAC__bool FLAC__memory_alloc_aligned_int32_array(size_t elements, FLAC__int32 **unaligned_pointer, FLAC__int32 **aligned_pointer); 50 | FLAC__bool FLAC__memory_alloc_aligned_uint32_array(size_t elements, FLAC__uint32 **unaligned_pointer, FLAC__uint32 **aligned_pointer); 51 | FLAC__bool FLAC__memory_alloc_aligned_uint64_array(size_t elements, FLAC__uint64 **unaligned_pointer, FLAC__uint64 **aligned_pointer); 52 | FLAC__bool FLAC__memory_alloc_aligned_unsigned_array(size_t elements, unsigned **unaligned_pointer, unsigned **aligned_pointer); 53 | #ifndef FLAC__INTEGER_ONLY_LIBRARY 54 | FLAC__bool FLAC__memory_alloc_aligned_real_array(size_t elements, FLAC__real **unaligned_pointer, FLAC__real **aligned_pointer); 55 | #endif 56 | void *safe_malloc_mul_2op_p(size_t size1, size_t size2); 57 | 58 | #endif 59 | -------------------------------------------------------------------------------- /src/core/membnk.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************************** 2 | * Genesis Plus 3 | * Z80 bank access to 68k bus 4 | * 5 | * Copyright (C) 1998-2003 Charles Mac Donald (original code) 6 | * Copyright (C) 2007-2016 Eke-Eke (Genesis Plus GX) 7 | * 8 | * Redistribution and use of this code or any derivative works are permitted 9 | * provided that the following conditions are met: 10 | * 11 | * - Redistributions may not be sold, nor may they be used in a commercial 12 | * product or activity. 13 | * 14 | * - Redistributions that are modified from the original source must include the 15 | * complete source code, including the source code for all components used by a 16 | * binary built from the modified sources. However, as a special exception, the 17 | * source code distributed need not include anything that is normally distributed 18 | * (in either source or binary form) with the major components (compiler, kernel, 19 | * and so on) of the operating system on which the executable runs, unless that 20 | * component itself accompanies the executable. 21 | * 22 | * - Redistributions must reproduce the above copyright notice, this list of 23 | * conditions and the following disclaimer in the documentation and/or other 24 | * materials provided with the distribution. 25 | * 26 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 27 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 28 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 29 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 30 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 31 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 32 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 33 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 34 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 35 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 36 | * POSSIBILITY OF SUCH DAMAGE. 37 | * 38 | ****************************************************************************************/ 39 | 40 | #ifndef _MEMBNK_H_ 41 | #define _MEMBNK_H_ 42 | 43 | extern unsigned int zbank_unused_r(unsigned int address); 44 | extern void zbank_unused_w(unsigned int address, unsigned int data); 45 | extern unsigned int zbank_lockup_r(unsigned int address); 46 | extern void zbank_lockup_w(unsigned int address, unsigned int data); 47 | extern unsigned int zbank_read_ctrl_io(unsigned int address); 48 | extern void zbank_write_ctrl_io(unsigned int address, unsigned int data); 49 | extern unsigned int zbank_read_vdp(unsigned int address); 50 | extern void zbank_write_vdp(unsigned int address, unsigned int data); 51 | 52 | struct _zbank_memory_map 53 | { 54 | unsigned int (*read)(unsigned int address); 55 | void (*write)(unsigned int address, unsigned int data); 56 | }; 57 | extern struct _zbank_memory_map zbank_memory_map[256]; 58 | 59 | #endif /* _MEMBNK_H_ */ 60 | -------------------------------------------------------------------------------- /src/core/cd_hw/libchdr/deps/zlib/inftrees.h: -------------------------------------------------------------------------------- 1 | /* inftrees.h -- header to use inftrees.c 2 | * Copyright (C) 1995-2005, 2010 Mark Adler 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | /* WARNING: this file should *not* be used by applications. It is 7 | part of the implementation of the compression library and is 8 | subject to change. Applications should only use zlib.h. 9 | */ 10 | 11 | /* Structure for decoding tables. Each entry provides either the 12 | information needed to do the operation requested by the code that 13 | indexed that table entry, or it provides a pointer to another 14 | table that indexes more bits of the code. op indicates whether 15 | the entry is a pointer to another table, a literal, a length or 16 | distance, an end-of-block, or an invalid code. For a table 17 | pointer, the low four bits of op is the number of index bits of 18 | that table. For a length or distance, the low four bits of op 19 | is the number of extra bits to get after the code. bits is 20 | the number of bits in this code or part of the code to drop off 21 | of the bit buffer. val is the actual byte to output in the case 22 | of a literal, the base length or distance, or the offset from 23 | the current table to the next table. Each entry is four bytes. */ 24 | typedef struct { 25 | unsigned char op; /* operation, extra bits, table bits */ 26 | unsigned char bits; /* bits in this part of the code */ 27 | unsigned short val; /* offset in table or code value */ 28 | } code; 29 | 30 | /* op values as set by inflate_table(): 31 | 00000000 - literal 32 | 0000tttt - table link, tttt != 0 is the number of table index bits 33 | 0001eeee - length or distance, eeee is the number of extra bits 34 | 01100000 - end of block 35 | 01000000 - invalid code 36 | */ 37 | 38 | /* Maximum size of the dynamic table. The maximum number of code structures is 39 | 1444, which is the sum of 852 for literal/length codes and 592 for distance 40 | codes. These values were found by exhaustive searches using the program 41 | examples/enough.c found in the zlib distribtution. The arguments to that 42 | program are the number of symbols, the initial root table size, and the 43 | maximum bit length of a code. "enough 286 9 15" for literal/length codes 44 | returns returns 852, and "enough 30 6 15" for distance codes returns 592. 45 | The initial root table size (9 or 6) is found in the fifth argument of the 46 | inflate_table() calls in inflate.c and infback.c. If the root table size is 47 | changed, then these maximum sizes would be need to be recalculated and 48 | updated. */ 49 | #define ENOUGH_LENS 852 50 | #define ENOUGH_DISTS 592 51 | #define ENOUGH (ENOUGH_LENS+ENOUGH_DISTS) 52 | 53 | /* Type of code to build for inflate_table() */ 54 | typedef enum { 55 | CODES, 56 | LENS, 57 | DISTS 58 | } codetype; 59 | 60 | int ZLIB_INTERNAL inflate_table OF((codetype type, unsigned short FAR *lens, 61 | unsigned codes, code FAR * FAR *table, 62 | unsigned FAR *bits, unsigned short FAR *work)); 63 | -------------------------------------------------------------------------------- /src/core/cart_hw/eeprom_93c.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * Genesis Plus 3 | * Microwire Serial EEPROM (93C46 only) support 4 | * 5 | * Copyright (C) 2011 Eke-Eke (Genesis Plus GX) 6 | * 7 | * Redistribution and use of this code or any derivative works are permitted 8 | * provided that the following conditions are met: 9 | * 10 | * - Redistributions may not be sold, nor may they be used in a commercial 11 | * product or activity. 12 | * 13 | * - Redistributions that are modified from the original source must include the 14 | * complete source code, including the source code for all components used by a 15 | * binary built from the modified sources. However, as a special exception, the 16 | * source code distributed need not include anything that is normally distributed 17 | * (in either source or binary form) with the major components (compiler, kernel, 18 | * and so on) of the operating system on which the executable runs, unless that 19 | * component itself accompanies the executable. 20 | * 21 | * - Redistributions must reproduce the above copyright notice, this list of 22 | * conditions and the following disclaimer in the documentation and/or other 23 | * materials provided with the distribution. 24 | * 25 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 26 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 27 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 28 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 29 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 30 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 31 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 32 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 33 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 34 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 35 | * POSSIBILITY OF SUCH DAMAGE. 36 | * 37 | ****************************************************************************************/ 38 | 39 | #ifndef _EEPROM_93C_H_ 40 | #define _EEPROM_93C_H_ 41 | 42 | typedef enum 43 | { 44 | WAIT_STANDBY, 45 | WAIT_START, 46 | GET_OPCODE, 47 | WRITE_WORD, 48 | READ_WORD 49 | } T_STATE_93C; 50 | 51 | typedef struct 52 | { 53 | uint8 enabled; /* 1: chip enabled */ 54 | uint8 cs; /* CHIP SELECT line state */ 55 | uint8 clk; /* CLK line state */ 56 | uint8 data; /* DATA OUT line state */ 57 | uint8 cycles; /* current operation cycle */ 58 | uint8 we; /* 1: write enabled */ 59 | uint8 opcode; /* 8-bit opcode + address */ 60 | uint16 buffer; /* 16-bit data buffer */ 61 | T_STATE_93C state; /* current operation state */ 62 | } T_EEPROM_93C; 63 | 64 | /* global variables */ 65 | extern T_EEPROM_93C eeprom_93c; 66 | 67 | /* Function prototypes */ 68 | extern void eeprom_93c_init(); 69 | extern void eeprom_93c_write(unsigned char data); 70 | extern unsigned char eeprom_93c_read(void); 71 | 72 | #endif 73 | -------------------------------------------------------------------------------- /src/core/cd_hw/cdc.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************************** 2 | * Genesis Plus 3 | * CD data controller (LC8951x compatible) 4 | * 5 | * Copyright (C) 2012-2019 Eke-Eke (Genesis Plus GX) 6 | * 7 | * Redistribution and use of this code or any derivative works are permitted 8 | * provided that the following conditions are met: 9 | * 10 | * - Redistributions may not be sold, nor may they be used in a commercial 11 | * product or activity. 12 | * 13 | * - Redistributions that are modified from the original source must include the 14 | * complete source code, including the source code for all components used by a 15 | * binary built from the modified sources. However, as a special exception, the 16 | * source code distributed need not include anything that is normally distributed 17 | * (in either source or binary form) with the major components (compiler, kernel, 18 | * and so on) of the operating system on which the executable runs, unless that 19 | * component itself accompanies the executable. 20 | * 21 | * - Redistributions must reproduce the above copyright notice, this list of 22 | * conditions and the following disclaimer in the documentation and/or other 23 | * materials provided with the distribution. 24 | * 25 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 26 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 27 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 28 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 29 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 30 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 31 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 32 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 33 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 34 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 35 | * POSSIBILITY OF SUCH DAMAGE. 36 | * 37 | ****************************************************************************************/ 38 | #ifndef _HW_CDC_ 39 | #define _HW_CDC_ 40 | 41 | #define cdc scd.cdc_hw 42 | 43 | /* CDC hardware */ 44 | typedef struct 45 | { 46 | uint8 ifstat; 47 | uint8 ifctrl; 48 | reg16_t dbc; 49 | reg16_t dac; 50 | reg16_t pt; 51 | reg16_t wa; 52 | uint8 ctrl[2]; 53 | uint8 head[2][4]; 54 | uint8 stat[4]; 55 | int cycles; 56 | void (*dma_w)(unsigned int words); /* DMA transfer callback */ 57 | uint8 ram[0x4000 + 2352]; /* 16K external RAM (with one block overhead to handle buffer overrun) */ 58 | } cdc_t; 59 | 60 | /* Function prototypes */ 61 | extern void cdc_init(void); 62 | extern void cdc_reset(void); 63 | extern int cdc_context_save(uint8 *state); 64 | extern int cdc_context_load(uint8 *state); 65 | extern void cdc_dma_update(void); 66 | extern void cdc_decoder_update(uint32 header); 67 | extern void cdc_reg_w(unsigned char data); 68 | extern unsigned char cdc_reg_r(void); 69 | extern unsigned short cdc_host_r(void); 70 | 71 | #endif 72 | -------------------------------------------------------------------------------- /src/core/cd_hw/libchdr/src/huffman.h: -------------------------------------------------------------------------------- 1 | // license:BSD-3-Clause 2 | // copyright-holders:Aaron Giles 3 | /*************************************************************************** 4 | 5 | huffman.h 6 | 7 | Static Huffman compression and decompression helpers. 8 | 9 | ***************************************************************************/ 10 | 11 | #pragma once 12 | 13 | #ifndef __HUFFMAN_H__ 14 | #define __HUFFMAN_H__ 15 | 16 | #include "bitstream.h" 17 | 18 | 19 | //************************************************************************** 20 | // CONSTANTS 21 | //************************************************************************** 22 | 23 | enum huffman_error 24 | { 25 | HUFFERR_NONE = 0, 26 | HUFFERR_TOO_MANY_BITS, 27 | HUFFERR_INVALID_DATA, 28 | HUFFERR_INPUT_BUFFER_TOO_SMALL, 29 | HUFFERR_OUTPUT_BUFFER_TOO_SMALL, 30 | HUFFERR_INTERNAL_INCONSISTENCY, 31 | HUFFERR_TOO_MANY_CONTEXTS 32 | }; 33 | 34 | 35 | 36 | //************************************************************************** 37 | // TYPE DEFINITIONS 38 | //************************************************************************** 39 | 40 | typedef uint16_t lookup_value; 41 | 42 | // a node in the huffman tree 43 | struct node_t 44 | { 45 | struct node_t* parent; // pointer to parent node 46 | uint32_t count; // number of hits on this node 47 | uint32_t weight; // assigned weight of this node 48 | uint32_t bits; // bits used to encode the node 49 | uint8_t numbits; // number of bits needed for this node 50 | }; 51 | 52 | // ======================> huffman_context_base 53 | 54 | // context class for decoding 55 | struct huffman_decoder 56 | { 57 | // internal state 58 | uint32_t numcodes; // number of total codes being processed 59 | uint8_t maxbits; // maximum bits per code 60 | uint8_t prevdata; // value of the previous data (for delta-RLE encoding) 61 | int rleremaining; // number of RLE bytes remaining (for delta-RLE encoding) 62 | lookup_value * lookup; // pointer to the lookup table 63 | struct node_t * huffnode; // array of nodes 64 | uint32_t * datahisto; // histogram of data values 65 | 66 | // array versions of the info we need 67 | //node_t* huffnode_array; //[_NumCodes]; 68 | //lookup_value* lookup_array; //[1 << _MaxBits]; 69 | }; 70 | 71 | // ======================> huffman_decoder 72 | 73 | struct huffman_decoder* create_huffman_decoder(int numcodes, int maxbits); 74 | void delete_huffman_decoder(struct huffman_decoder* decoder); 75 | 76 | // single item operations 77 | uint32_t huffman_decode_one(struct huffman_decoder* decoder, struct bitstream* bitbuf); 78 | 79 | enum huffman_error huffman_import_tree_rle(struct huffman_decoder* decoder, struct bitstream* bitbuf); 80 | enum huffman_error huffman_import_tree_huffman(struct huffman_decoder* decoder, struct bitstream* bitbuf); 81 | 82 | int huffman_build_tree(struct huffman_decoder* decoder, uint32_t totaldata, uint32_t totalweight); 83 | enum huffman_error huffman_assign_canonical_codes(struct huffman_decoder* decoder); 84 | enum huffman_error huffman_compute_tree_from_histo(struct huffman_decoder* decoder); 85 | 86 | void huffman_build_lookup_table(struct huffman_decoder* decoder); 87 | 88 | #endif 89 | -------------------------------------------------------------------------------- /src/core/io_ctrl.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************************** 2 | * Genesis Plus 3 | * I/O controller 4 | * 5 | * Support for Master System (315-5216, 315-5237 & 315-5297), Game Gear & Mega Drive I/O chips 6 | * 7 | * Copyright (C) 1998-2003 Charles Mac Donald (original code) 8 | * Copyright (C) 2007-2019 Eke-Eke (Genesis Plus GX) 9 | * 10 | * Redistribution and use of this code or any derivative works are permitted 11 | * provided that the following conditions are met: 12 | * 13 | * - Redistributions may not be sold, nor may they be used in a commercial 14 | * product or activity. 15 | * 16 | * - Redistributions that are modified from the original source must include the 17 | * complete source code, including the source code for all components used by a 18 | * binary built from the modified sources. However, as a special exception, the 19 | * source code distributed need not include anything that is normally distributed 20 | * (in either source or binary form) with the major components (compiler, kernel, 21 | * and so on) of the operating system on which the executable runs, unless that 22 | * component itself accompanies the executable. 23 | * 24 | * - Redistributions must reproduce the above copyright notice, this list of 25 | * conditions and the following disclaimer in the documentation and/or other 26 | * materials provided with the distribution. 27 | * 28 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 29 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 30 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 31 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 32 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 33 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 34 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 35 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 36 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 37 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 38 | * POSSIBILITY OF SUCH DAMAGE. 39 | * 40 | ****************************************************************************************/ 41 | 42 | #ifndef _IO_CTRL_H_ 43 | #define _IO_CTRL_H_ 44 | 45 | #define IO_RESET_HI 0x10 46 | #define IO_CONT1_HI 0x20 47 | 48 | #define REGION_JAPAN_NTSC 0x00 49 | #define REGION_JAPAN_PAL 0x40 50 | #define REGION_USA 0x80 51 | #define REGION_EUROPE 0xC0 52 | 53 | /* Global variables */ 54 | extern uint8 io_reg[0x10]; 55 | extern uint8 region_code; 56 | 57 | /* Function prototypes */ 58 | extern void io_init(void); 59 | extern void io_reset(void); 60 | extern void io_68k_write(unsigned int offset, unsigned int data); 61 | extern unsigned int io_68k_read(unsigned int offset); 62 | extern void io_z80_write(unsigned int offset, unsigned int data, unsigned int cycles); 63 | extern unsigned int io_z80_read(unsigned int offset); 64 | extern void io_gg_write(unsigned int offset, unsigned int data); 65 | extern unsigned int io_gg_read(unsigned int offset); 66 | 67 | #endif /* _IO_CTRL_H_ */ 68 | 69 | -------------------------------------------------------------------------------- /src/core/cd_hw/libchdr/deps/libFLAC/include/share/endswap.h: -------------------------------------------------------------------------------- 1 | /* libFLAC - Free Lossless Audio Codec library 2 | * Copyright (C) 2012-2016 Xiph.org Foundation 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 8 | * - Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * - Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 15 | * - Neither the name of the Xiph.org Foundation nor the names of its 16 | * contributors may be used to endorse or promote products derived from 17 | * this software without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR 23 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 24 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 25 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 26 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 27 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 28 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 29 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | */ 31 | 32 | /* It is assumed that this header will be included after "config.h". */ 33 | 34 | #if HAVE_BSWAP32 /* GCC and Clang */ 35 | 36 | /* GCC prior to 4.8 didn't provide bswap16 on x86_64 */ 37 | #if ! HAVE_BSWAP16 38 | static inline unsigned short __builtin_bswap16(unsigned short a) 39 | { 40 | return (a<<8)|(a>>8); 41 | } 42 | #endif 43 | 44 | #define ENDSWAP_16(x) (__builtin_bswap16 (x)) 45 | #define ENDSWAP_32(x) (__builtin_bswap32 (x)) 46 | #define ENDSWAP_64(x) (__builtin_bswap64 (x)) 47 | 48 | #elif defined _MSC_VER /* Windows */ 49 | 50 | #include 51 | 52 | #define ENDSWAP_16(x) (_byteswap_ushort (x)) 53 | #define ENDSWAP_32(x) (_byteswap_ulong (x)) 54 | #define ENDSWAP_64(x) (_byteswap_uint64 (x)) 55 | 56 | #elif defined HAVE_BYTESWAP_H /* Linux */ 57 | 58 | #include 59 | 60 | #define ENDSWAP_16(x) (bswap_16 (x)) 61 | #define ENDSWAP_32(x) (bswap_32 (x)) 62 | #define ENDSWAP_64(x) (bswap_64 (x)) 63 | 64 | #else 65 | 66 | #define ENDSWAP_16(x) ((((x) >> 8) & 0xFF) | (((x) & 0xFF) << 8)) 67 | #define ENDSWAP_32(x) ((((x) >> 24) & 0xFF) | (((x) >> 8) & 0xFF00) | (((x) & 0xFF00) << 8) | (((x) & 0xFF) << 24)) 68 | #define ENDSWAP_64(x) ((ENDSWAP_32(((x) >> 32) & 0xFFFFFFFF)) | (ENDSWAP_32((x) & 0xFFFFFFFF) << 32)) 69 | 70 | #endif 71 | 72 | 73 | /* Host to little-endian byte swapping (for MD5 calculation) */ 74 | #if CPU_IS_BIG_ENDIAN 75 | 76 | #define H2LE_16(x) ENDSWAP_16 (x) 77 | #define H2LE_32(x) ENDSWAP_32 (x) 78 | 79 | #else 80 | 81 | #define H2LE_16(x) (x) 82 | #define H2LE_32(x) (x) 83 | 84 | #endif 85 | -------------------------------------------------------------------------------- /src/core/ntsc/changes.txt: -------------------------------------------------------------------------------- 1 | sms_ntsc Change Log 2 | ------------------- 3 | 4 | sms_ntsc 0.2.3 5 | -------------- 6 | - Moved configuration options to sms_ntsc_config.h, making it easier to 7 | manage 8 | 9 | - Greatly clarified and improved demo to read any uncompressed BMP image 10 | and write filtered image when done 11 | 12 | - Improved gamma to be properly applied to each RGB channel, and changed 13 | default to compensate for difference between PC monitor and TV gamma 14 | 15 | - Improved contrast to be properly applied to each RGB channel rather 16 | than just luma 17 | 18 | - Improved floating point calculations in library to be more stable and 19 | not need double precision, which was causing problems with the sharpness 20 | control on Windows when the DirectX libraries changed the FPU to single 21 | precision mode 22 | 23 | - Added extern "C" to header, allowing use in C++ without having to 24 | rename the source file 25 | 26 | - Made internal changes to factor out code common from all my NTSC 27 | filter libraries, greatly simplifying things for me 28 | 29 | 30 | sms_ntsc 0.2.2 31 | -------------- 32 | - Changed sms_ntsc_blit() again, this time to always take a pixel count 33 | for input pitch (since the type is known) and a byte count for the 34 | output pitch (since it can output at multiple depths now). I think I've 35 | got the right interface this time. :) 36 | 37 | - Improved default blitter to have selectable input and output pixel 38 | formats 39 | 40 | - Added parameters for resolution, color bleed, and artifacts 41 | 42 | - Added presets for composite video, S-video, RGB, and monochrome 43 | 44 | - Added SMS_NTSC_OUT_WIDTH() and SMS_NTSC_IN_WIDTH() for calculating 45 | input/output widths 46 | 47 | - Improved demo with more controls and interpolation and darkening of 48 | scanlines rather than duplicating them 49 | 50 | - Improved documentation 51 | 52 | - Interface changes: sms_ntsc_blit() takes output pitch in bytes again. 53 | Sorry for the multiple changes; I think I got it right this time. :) 54 | 55 | - Removed: SMS_NTSC_CALC_WIDTH (use SMS_NTSC_OUT_WIDTH) 56 | 57 | 58 | sms_ntsc 0.2.1 59 | -------------- 60 | - Added parameters for color fringing and edge artifacts 61 | 62 | 63 | sms_ntsc 0.2.0 64 | -------------- 65 | - Changed sms_ntsc_blit() to take pixel counts instead of byte counts 66 | for in_pitch and out_pitch, making it simpler to use. This requires that 67 | current code be updated. 68 | 69 | - Significantly improved NTSC signal processing to give clearer image 70 | and better sharpness control 71 | 72 | - Reduced scrolling shimmer and color artifacts to be closer to what 73 | console generates 74 | 75 | - Added gamma curve parameter to allow better matching of darker colors 76 | on a TV 77 | 78 | - Added ability to generate matching RGB palette for use in a normal 79 | blitter 80 | 81 | 82 | sms_ntsc 0.1.1 83 | -------------- 84 | - Changed sms_ntsc_blit() to accept 12-bit BGR pixels instead of palette 85 | indicies and a separate palette. 86 | 87 | - Improved sms_ntsc_blit() to accept any input width, allowing all the 88 | different screen widths to be handled without complication. Use 89 | SMS_NTSC_CALC_WIDTH() to find the output width for a given input width. 90 | 91 | - Added toggling of left 8 column display to demo 92 | 93 | 94 | sms_ntsc 0.1.0 95 | -------------- 96 | - First version 97 | -------------------------------------------------------------------------------- /src/core/cd_hw/libchdr/deps/lzma/LzmaEnc.h: -------------------------------------------------------------------------------- 1 | /* LzmaEnc.h -- LZMA Encoder 2 | 2013-01-18 : Igor Pavlov : Public domain */ 3 | 4 | #ifndef __LZMA_ENC_H 5 | #define __LZMA_ENC_H 6 | 7 | #include "7zTypes.h" 8 | 9 | EXTERN_C_BEGIN 10 | 11 | #define LZMA_PROPS_SIZE 5 12 | 13 | typedef struct _CLzmaEncProps 14 | { 15 | int level; /* 0 <= level <= 9 */ 16 | UInt32 dictSize; /* (1 << 12) <= dictSize <= (1 << 27) for 32-bit version 17 | (1 << 12) <= dictSize <= (1 << 30) for 64-bit version 18 | default = (1 << 24) */ 19 | UInt64 reduceSize; /* estimated size of data that will be compressed. default = 0xFFFFFFFF. 20 | Encoder uses this value to reduce dictionary size */ 21 | int lc; /* 0 <= lc <= 8, default = 3 */ 22 | int lp; /* 0 <= lp <= 4, default = 0 */ 23 | int pb; /* 0 <= pb <= 4, default = 2 */ 24 | int algo; /* 0 - fast, 1 - normal, default = 1 */ 25 | int fb; /* 5 <= fb <= 273, default = 32 */ 26 | int btMode; /* 0 - hashChain Mode, 1 - binTree mode - normal, default = 1 */ 27 | int numHashBytes; /* 2, 3 or 4, default = 4 */ 28 | UInt32 mc; /* 1 <= mc <= (1 << 30), default = 32 */ 29 | unsigned writeEndMark; /* 0 - do not write EOPM, 1 - write EOPM, default = 0 */ 30 | int numThreads; /* 1 or 2, default = 2 */ 31 | } CLzmaEncProps; 32 | 33 | void LzmaEncProps_Init(CLzmaEncProps *p); 34 | void LzmaEncProps_Normalize(CLzmaEncProps *p); 35 | UInt32 LzmaEncProps_GetDictSize(const CLzmaEncProps *props2); 36 | 37 | 38 | /* ---------- CLzmaEncHandle Interface ---------- */ 39 | 40 | /* LzmaEnc_* functions can return the following exit codes: 41 | Returns: 42 | SZ_OK - OK 43 | SZ_ERROR_MEM - Memory allocation error 44 | SZ_ERROR_PARAM - Incorrect paramater in props 45 | SZ_ERROR_WRITE - Write callback error. 46 | SZ_ERROR_PROGRESS - some break from progress callback 47 | SZ_ERROR_THREAD - errors in multithreading functions (only for Mt version) 48 | */ 49 | 50 | typedef void * CLzmaEncHandle; 51 | 52 | CLzmaEncHandle LzmaEnc_Create(ISzAlloc *alloc); 53 | void LzmaEnc_Destroy(CLzmaEncHandle p, ISzAlloc *alloc, ISzAlloc *allocBig); 54 | SRes LzmaEnc_SetProps(CLzmaEncHandle p, const CLzmaEncProps *props); 55 | SRes LzmaEnc_WriteProperties(CLzmaEncHandle p, Byte *properties, SizeT *size); 56 | SRes LzmaEnc_Encode(CLzmaEncHandle p, ISeqOutStream *outStream, ISeqInStream *inStream, 57 | ICompressProgress *progress, ISzAlloc *alloc, ISzAlloc *allocBig); 58 | SRes LzmaEnc_MemEncode(CLzmaEncHandle p, Byte *dest, SizeT *destLen, const Byte *src, SizeT srcLen, 59 | int writeEndMark, ICompressProgress *progress, ISzAlloc *alloc, ISzAlloc *allocBig); 60 | 61 | /* ---------- One Call Interface ---------- */ 62 | 63 | /* LzmaEncode 64 | Return code: 65 | SZ_OK - OK 66 | SZ_ERROR_MEM - Memory allocation error 67 | SZ_ERROR_PARAM - Incorrect paramater 68 | SZ_ERROR_OUTPUT_EOF - output buffer overflow 69 | SZ_ERROR_THREAD - errors in multithreading functions (only for Mt version) 70 | */ 71 | 72 | SRes LzmaEncode(Byte *dest, SizeT *destLen, const Byte *src, SizeT srcLen, 73 | const CLzmaEncProps *props, Byte *propsEncoded, SizeT *propsSize, int writeEndMark, 74 | ICompressProgress *progress, ISzAlloc *alloc, ISzAlloc *allocBig); 75 | 76 | EXTERN_C_END 77 | 78 | #endif 79 | -------------------------------------------------------------------------------- /src/core/memz80.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************************** 2 | * Genesis Plus 3 | * Z80 bus handlers (Genesis & Master System modes) 4 | * 5 | * Support for SG-1000, Mark-III, Master System, Game Gear & Mega Drive ports access 6 | * 7 | * Copyright (C) 1998-2003 Charles Mac Donald (original code) 8 | * Copyright (C) 2007-2016 Eke-Eke (Genesis Plus GX) 9 | * 10 | * Redistribution and use of this code or any derivative works are permitted 11 | * provided that the following conditions are met: 12 | * 13 | * - Redistributions may not be sold, nor may they be used in a commercial 14 | * product or activity. 15 | * 16 | * - Redistributions that are modified from the original source must include the 17 | * complete source code, including the source code for all components used by a 18 | * binary built from the modified sources. However, as a special exception, the 19 | * source code distributed need not include anything that is normally distributed 20 | * (in either source or binary form) with the major components (compiler, kernel, 21 | * and so on) of the operating system on which the executable runs, unless that 22 | * component itself accompanies the executable. 23 | * 24 | * - Redistributions must reproduce the above copyright notice, this list of 25 | * conditions and the following disclaimer in the documentation and/or other 26 | * materials provided with the distribution. 27 | * 28 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 29 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 30 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 31 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 32 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 33 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 34 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 35 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 36 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 37 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 38 | * POSSIBILITY OF SUCH DAMAGE. 39 | * 40 | ****************************************************************************************/ 41 | 42 | #ifndef _MEMZ80_H_ 43 | #define _MEMZ80_H_ 44 | 45 | extern unsigned char z80_memory_r(unsigned int address); 46 | extern void z80_memory_w(unsigned int address, unsigned char data); 47 | extern unsigned char z80_unused_port_r(unsigned int port); 48 | extern void z80_unused_port_w(unsigned int port, unsigned char data); 49 | extern unsigned char z80_md_port_r(unsigned int port); 50 | extern void z80_md_port_w(unsigned int port, unsigned char data); 51 | extern unsigned char z80_gg_port_r(unsigned int port); 52 | extern void z80_gg_port_w(unsigned int port, unsigned char data); 53 | extern unsigned char z80_ms_port_r(unsigned int port); 54 | extern void z80_ms_port_w(unsigned int port, unsigned char data); 55 | extern unsigned char z80_m3_port_r(unsigned int port); 56 | extern void z80_m3_port_w(unsigned int port, unsigned char data); 57 | extern unsigned char z80_sg_port_r(unsigned int port); 58 | extern void z80_sg_port_w(unsigned int port, unsigned char data); 59 | 60 | #endif /* _MEMZ80_H_ */ 61 | -------------------------------------------------------------------------------- /src/backends/video/video_sdl.c: -------------------------------------------------------------------------------- 1 | #include "video_base.h" 2 | 3 | #include 4 | #include "shared.h" 5 | 6 | // #if defined(USE_8BPP_RENDERING) 7 | // #define SURFACE_FORMAT SDL_PIXELFORMAT_RGB332 8 | // #elif defined(USE_15BPP_RENDERING) 9 | // #define SURFACE_FORMAT SDL_PIXELFORMAT_RGB555 10 | // #elif defined(USE_16BPP_RENDERING) 11 | // #define SURFACE_FORMAT SDL_PIXELFORMAT_RGB565 12 | // #elif defined(USE_32BPP_RENDERING) 13 | // #define SURFACE_FORMAT SDL_PIXELFORMAT_RGB888 14 | // #endif 15 | 16 | struct { 17 | SDL_Surface* surf_screen; 18 | SDL_Surface* surf_bitmap; 19 | SDL_Rect srect; 20 | SDL_Rect drect; 21 | Uint32 frames_rendered; 22 | Uint16 screen_width; 23 | Uint16 screen_height; 24 | int fullscreen; 25 | } sdl_video; 26 | 27 | 28 | 29 | int SDL_OnResize(void* data, SDL_Event* event) { 30 | if (event->type == SDL_VIDEORESIZE) { 31 | bitmap.viewport.changed = 1; 32 | } 33 | return 1; 34 | } 35 | 36 | int Backend_Video_Init() { 37 | if(SDL_InitSubSystem(SDL_INIT_VIDEO) < 0) { 38 | printf("SDL Video initialization failed"); 39 | return 0; 40 | } 41 | 42 | sdl_video.surf_screen = SDL_SetVideoMode(VIDEO_WIDTH, VIDEO_HEIGHT, 16, SDL_SWSURFACE); 43 | sdl_video.surf_bitmap = SDL_CreateRGBSurface(SDL_SWSURFACE, 720, 576, 16, 0, 0, 0, 0); 44 | sdl_video.frames_rendered = 0; 45 | SDL_ShowCursor(0); 46 | 47 | SDL_LockSurface(sdl_video.surf_bitmap); 48 | bitmap.data = (unsigned char *)sdl_video.surf_bitmap->pixels; 49 | SDL_UnlockSurface(sdl_video.surf_bitmap); 50 | 51 | return 1; 52 | } 53 | 54 | int Backend_Video_Update() { 55 | /* viewport size changed */ 56 | if(bitmap.viewport.changed & 1) 57 | { 58 | sdl_video.surf_screen = SDL_GetVideoSurface(); 59 | 60 | /* source bitmap */ 61 | sdl_video.srect.w = 400; 62 | sdl_video.srect.h = 240; 63 | sdl_video.srect.x = 0; 64 | sdl_video.srect.y = 0; 65 | 66 | /* destination bitmap */ 67 | sdl_video.drect.w = sdl_video.srect.w; 68 | sdl_video.drect.h = sdl_video.srect.h; 69 | sdl_video.drect.x = 0; 70 | sdl_video.drect.y = 0; 71 | } 72 | 73 | // SDL_UnlockSurface(sdl_video.surf_bitmap); 74 | SDL_BlitSurface(sdl_video.surf_bitmap, &sdl_video.srect, sdl_video.surf_screen, &sdl_video.drect); 75 | 76 | ++sdl_video.frames_rendered; 77 | 78 | return 1; 79 | } 80 | 81 | int Backend_Video_Close() { 82 | SDL_FreeSurface(sdl_video.surf_bitmap); 83 | // SDL_DestroyWindow(sdl_video.window); 84 | SDL_Quit(); 85 | 86 | return 1; 87 | } 88 | 89 | int Backend_Video_SetFullscreen(int arg_fullscreen) { 90 | sdl_video.fullscreen = arg_fullscreen; 91 | // SDL_SetWindowFullscreen(sdl_video.window, sdl_video.fullscreen); 92 | 93 | return 1; 94 | } 95 | 96 | int Backend_Video_ToggleFullscreen() { 97 | Backend_Video_SetFullscreen(!sdl_video.fullscreen); 98 | 99 | return 1; 100 | } 101 | 102 | int Backend_Video_SetWindowTitle(char *caption) { 103 | SDL_WM_SetCaption(caption, NULL); 104 | return 1; 105 | } 106 | 107 | int Backend_Video_Present() { 108 | SDL_UpdateRect(sdl_video.surf_screen, 0, 0, 0, 0); 109 | return 1; 110 | } 111 | 112 | int Backend_Video_Clear() { 113 | SDL_FillRect(sdl_video.surf_screen, 0, 0); 114 | return 1; 115 | } 116 | 117 | int Backend_Video_SetVsync(int vsync) { return -1 }; 118 | int Backend_Video_GetRefreshRate() { return -1 }; -------------------------------------------------------------------------------- /src/core/input_hw/gamepad.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************************** 2 | * Genesis Plus 3 | * 2-Buttons, 3-Buttons & 6-Buttons controller support 4 | * with support for J-Cart, 4-Way Play & Master Tap adapters 5 | * 6 | * Copyright (C) 2007-2019 Eke-Eke (Genesis Plus GX) 7 | * 8 | * Redistribution and use of this code or any derivative works are permitted 9 | * provided that the following conditions are met: 10 | * 11 | * - Redistributions may not be sold, nor may they be used in a commercial 12 | * product or activity. 13 | * 14 | * - Redistributions that are modified from the original source must include the 15 | * complete source code, including the source code for all components used by a 16 | * binary built from the modified sources. However, as a special exception, the 17 | * source code distributed need not include anything that is normally distributed 18 | * (in either source or binary form) with the major components (compiler, kernel, 19 | * and so on) of the operating system on which the executable runs, unless that 20 | * component itself accompanies the executable. 21 | * 22 | * - Redistributions must reproduce the above copyright notice, this list of 23 | * conditions and the following disclaimer in the documentation and/or other 24 | * materials provided with the distribution. 25 | * 26 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 27 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 28 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 29 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 30 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 31 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 32 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 33 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 34 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 35 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 36 | * POSSIBILITY OF SUCH DAMAGE. 37 | * 38 | ****************************************************************************************/ 39 | 40 | #ifndef _GAMEPAD_H_ 41 | #define _GAMEPAD_H_ 42 | 43 | /* Function prototypes */ 44 | extern void gamepad_reset(int port); 45 | extern void gamepad_refresh(int port); 46 | extern void gamepad_end_frame(int port, unsigned int cycles); 47 | extern unsigned char gamepad_1_read(void); 48 | extern unsigned char gamepad_2_read(void); 49 | extern void gamepad_1_write(unsigned char data, unsigned char mask); 50 | extern void gamepad_2_write(unsigned char data, unsigned char mask); 51 | extern unsigned char wayplay_1_read(void); 52 | extern unsigned char wayplay_2_read(void); 53 | extern void wayplay_1_write(unsigned char data, unsigned char mask); 54 | extern void wayplay_2_write(unsigned char data, unsigned char mask); 55 | extern unsigned int jcart_read(unsigned int address); 56 | extern void jcart_write(unsigned int address, unsigned int data); 57 | extern unsigned char mastertap_1_read(void); 58 | extern unsigned char mastertap_2_read(void); 59 | extern void mastertap_1_write(unsigned char data, unsigned char mask); 60 | extern void mastertap_2_write(unsigned char data, unsigned char mask); 61 | 62 | #endif 63 | -------------------------------------------------------------------------------- /src/core/sound/blip_buf.h: -------------------------------------------------------------------------------- 1 | /** Sample buffer that resamples from input clock rate to output sample rate \file */ 2 | 3 | /* blip_buf $vers */ 4 | #ifndef BLIP_BUF_H 5 | #define BLIP_BUF_H 6 | 7 | #ifdef __cplusplus 8 | extern "C" { 9 | #endif 10 | 11 | /** First parameter of most functions is blip_t*, or const blip_t* if nothing 12 | is changed. */ 13 | typedef struct blip_t blip_t; 14 | 15 | /** Creates new buffer that can hold at most sample_count samples. Sets rates 16 | so that there are blip_max_ratio clocks per sample. Returns pointer to new 17 | buffer, or NULL if insufficient memory. */ 18 | blip_t* blip_new( int sample_count ); 19 | 20 | /** Sets approximate input clock rate and output sample rate. For every 21 | clock_rate input clocks, approximately sample_rate samples are generated. */ 22 | void blip_set_rates( blip_t*, double clock_rate, double sample_rate ); 23 | 24 | enum { /** Maximum clock_rate/sample_rate ratio. For a given sample_rate, 25 | clock_rate must not be greater than sample_rate*blip_max_ratio. */ 26 | blip_max_ratio = 1 << 20 }; 27 | 28 | /** Clears entire buffer. Afterwards, blip_samples_avail() == 0. */ 29 | void blip_clear( blip_t* ); 30 | 31 | #ifndef BLIP_MONO 32 | 33 | /** Adds positive/negative deltas into stereo buffers at specified clock time. */ 34 | void blip_add_delta( blip_t*, unsigned time, int delta_l, int delta_r ); 35 | 36 | /** Same as blip_add_delta(), but uses faster, lower-quality synthesis. */ 37 | void blip_add_delta_fast( blip_t*, unsigned int clock_time, int delta_l, int delta_r ); 38 | 39 | #else 40 | 41 | /** Adds positive/negative delta into buffer at specified clock time. */ 42 | void blip_add_delta( blip_t*, unsigned int clock_time, int delta ); 43 | 44 | /** Same as blip_add_delta(), but uses faster, lower-quality synthesis. */ 45 | void blip_add_delta_fast( blip_t*, unsigned int clock_time, int delta ); 46 | 47 | #endif 48 | 49 | /** Length of time frame, in clocks, needed to make sample_count additional 50 | samples available. */ 51 | int blip_clocks_needed( const blip_t*, int sample_count ); 52 | 53 | enum { /** Maximum number of samples that can be generated from one time frame. */ 54 | blip_max_frame = 4000 }; 55 | 56 | /** Makes input clocks before clock_duration available for reading as output 57 | samples. Also begins new time frame at clock_duration, so that clock time 0 in 58 | the new time frame specifies the same clock as clock_duration in the old time 59 | frame specified. Deltas can have been added slightly past clock_duration (up to 60 | however many clocks there are in two output samples). */ 61 | void blip_end_frame( blip_t*, unsigned int clock_duration ); 62 | 63 | /** Number of buffered samples available for reading. */ 64 | int blip_samples_avail( const blip_t* ); 65 | 66 | /** Reads and removes at most 'count' samples and writes them to to every other 67 | element of 'out', allowing easy interleaving of two buffers into a stereo sample 68 | stream. Outputs 16-bit signed samples. Returns number of samples actually read. */ 69 | int blip_read_samples( blip_t*, short out [], int count); 70 | 71 | /* Same as above function except sample is mixed from three blip buffers source */ 72 | int blip_mix_samples( blip_t* m1, blip_t* m2, blip_t* m3, short out [], int count); 73 | 74 | /** Frees buffer. No effect if NULL is passed. */ 75 | void blip_delete( blip_t* ); 76 | 77 | 78 | /* Deprecated */ 79 | typedef blip_t blip_buffer_t; 80 | 81 | #ifdef __cplusplus 82 | } 83 | #endif 84 | 85 | #endif 86 | --------------------------------------------------------------------------------