├── win ├── resource.h ├── zsnes.ico ├── zsnes.rc ├── c_winintrf.h ├── lib.h ├── safelib.h ├── vc_head │ └── stdbool.h ├── lib.c ├── gl_draw.h ├── confloc.psr ├── winintrf.asm └── winlink.h ├── html ├── README.md ├── images │ ├── gui.png │ ├── cheat.png │ ├── config.png │ ├── game.png │ ├── misc.png │ ├── quick.png │ ├── f1_menu.png │ ├── netplay.png │ ├── saveslot.png │ └── zsneslogo.png └── styles │ ├── corner.png │ ├── release.css │ ├── plaintxt.css │ ├── print.css │ └── shared.css ├── doc ├── README.md ├── images │ ├── game.png │ ├── gui.png │ ├── misc.png │ ├── cheat.png │ ├── config.png │ ├── f1_menu.png │ ├── netplay.png │ ├── quick.png │ ├── saveslot.png │ └── zsneslogo.png └── styles │ ├── corner.png │ ├── release.css │ ├── plaintxt.css │ ├── print.css │ └── shared.css ├── icons ├── 16x16x32.png ├── 32x32x32.png ├── 48x48x32.png ├── 64x64x32.png └── 128x128x32.png ├── effects ├── burn.h ├── smoke.h └── water.h ├── TODO.md ├── cpu ├── c_dsp.h ├── c_regs.h ├── c_regsw.h ├── c_table.h ├── c_stable.h ├── c_tablec.h ├── firtable.h ├── memory.h ├── s65816d.h ├── c_irq.h ├── table.h ├── c_65816d.h ├── c_dsp.c ├── c_dma.h ├── c_dspproc.h ├── c_memory.h ├── c_execute.h ├── execute.h ├── c_memory.c ├── tablec.asm ├── c_65816d.c ├── executec.c ├── dma.asm ├── regsw.mac ├── regs.mac ├── stable.asm ├── spcaddr.inc ├── c_irq.c ├── regsw.h └── dspproc.h ├── chips ├── c_dsp2proc.h ├── c4proc.h ├── c_sfxproc.h ├── 7110proc.h ├── sa1proc.h ├── fxtable.h ├── dsp2proc.h ├── c_dsp2proc.c ├── c_sa1regs.h ├── fxemu2.h ├── msu1emu.h ├── dsp3proc.asm ├── obc1proc.asm ├── dsp4proc.asm ├── msu1regs.asm ├── fxemu2b.mac └── sfxproc.h ├── video ├── c_mode716.h ├── makev16t.h ├── mode716b.h ├── mode716.h ├── c_2xsaiw.h ├── procvidc.h ├── mode716e.h ├── c_makevid.h ├── makev16b.h ├── c_newgfx16.h ├── c_mode716.c ├── copyvwin.h ├── sw_draw.h ├── 2xsaiw.h ├── c_makev16b.h ├── newgfx.h ├── c_2xsaiw.c ├── snes_ntsc │ └── snes_ntsc_config.h ├── ntsc.h ├── procvid.h ├── makevid.h ├── makev16b.asm └── newgfx16.h ├── .gitignore ├── ver.h ├── linux ├── c_sdlintrf.h ├── sdllink.h ├── zsnes.desktop ├── sockserv.c ├── sockserv.h ├── sw_draw.h ├── gl_draw.h ├── safelib.h ├── lib.h ├── audio.h ├── lib.c ├── io.github.xyproto.zsnes.metainfo.xml └── sdlintrf.asm ├── ztimec.h ├── debugasm.h ├── gui ├── guicombo.h ├── menu.h ├── guikeys.h ├── guimouse.h ├── guicheat.h ├── guimisc.h ├── guitools.h ├── c_gui.h ├── guiwindp.h ├── guifuncs.h ├── c_guiwindp.h ├── gui.h └── guicombo.c ├── zip └── zpng.h ├── intrf.h ├── debugger.h ├── fmt.sh ├── jma ├── ariprice.h ├── zsnesjma.h ├── crc32.h ├── ariconst.h ├── 7z.h ├── lzma.cpp ├── zsnesjma.cpp ├── inbyte.cpp ├── 7zlzma.cpp ├── inbyte.h ├── aribitcd.h ├── jma.h ├── portable.h ├── winout.cpp ├── winout.h └── lencoder.h ├── macros.h ├── types.h ├── asm.h ├── c_vcache.h ├── zstate.h ├── link.h ├── c_init.h ├── version.sh ├── asm_call.h ├── init.h ├── debugger ├── load.h ├── zthread.h ├── zthread.cpp ├── ui.h ├── ui.cpp └── load.cpp ├── initc.h ├── zloader.h ├── tools ├── cver.c ├── strutil.h ├── fileutil.h ├── compile.txt ├── srccount.cpp ├── strutil.cpp └── fileutil.cpp ├── ui.h ├── ver.c ├── zdir.h ├── vcache.h ├── ztimec.c ├── gblvars.h ├── mmlib └── mm.h ├── zmovie.h ├── endmem.h ├── macros.mac └── gblhdr.h /win/resource.h: -------------------------------------------------------------------------------- 1 | #define IDI_ICON1 101 2 | -------------------------------------------------------------------------------- /html/README.md: -------------------------------------------------------------------------------- 1 | This is the old HTML documentation from ZSNES 1.51 2 | -------------------------------------------------------------------------------- /win/zsnes.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xyproto/zsnes/HEAD/win/zsnes.ico -------------------------------------------------------------------------------- /doc/README.md: -------------------------------------------------------------------------------- 1 | # Doc 2 | 3 | This documentation came with the old release of ZSNES. 4 | -------------------------------------------------------------------------------- /doc/images/game.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xyproto/zsnes/HEAD/doc/images/game.png -------------------------------------------------------------------------------- /doc/images/gui.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xyproto/zsnes/HEAD/doc/images/gui.png -------------------------------------------------------------------------------- /doc/images/misc.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xyproto/zsnes/HEAD/doc/images/misc.png -------------------------------------------------------------------------------- /html/images/gui.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xyproto/zsnes/HEAD/html/images/gui.png -------------------------------------------------------------------------------- /icons/16x16x32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xyproto/zsnes/HEAD/icons/16x16x32.png -------------------------------------------------------------------------------- /icons/32x32x32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xyproto/zsnes/HEAD/icons/32x32x32.png -------------------------------------------------------------------------------- /icons/48x48x32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xyproto/zsnes/HEAD/icons/48x48x32.png -------------------------------------------------------------------------------- /icons/64x64x32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xyproto/zsnes/HEAD/icons/64x64x32.png -------------------------------------------------------------------------------- /doc/images/cheat.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xyproto/zsnes/HEAD/doc/images/cheat.png -------------------------------------------------------------------------------- /doc/images/config.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xyproto/zsnes/HEAD/doc/images/config.png -------------------------------------------------------------------------------- /doc/images/f1_menu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xyproto/zsnes/HEAD/doc/images/f1_menu.png -------------------------------------------------------------------------------- /doc/images/netplay.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xyproto/zsnes/HEAD/doc/images/netplay.png -------------------------------------------------------------------------------- /doc/images/quick.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xyproto/zsnes/HEAD/doc/images/quick.png -------------------------------------------------------------------------------- /doc/styles/corner.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xyproto/zsnes/HEAD/doc/styles/corner.png -------------------------------------------------------------------------------- /html/images/cheat.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xyproto/zsnes/HEAD/html/images/cheat.png -------------------------------------------------------------------------------- /html/images/config.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xyproto/zsnes/HEAD/html/images/config.png -------------------------------------------------------------------------------- /html/images/game.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xyproto/zsnes/HEAD/html/images/game.png -------------------------------------------------------------------------------- /html/images/misc.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xyproto/zsnes/HEAD/html/images/misc.png -------------------------------------------------------------------------------- /html/images/quick.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xyproto/zsnes/HEAD/html/images/quick.png -------------------------------------------------------------------------------- /html/styles/corner.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xyproto/zsnes/HEAD/html/styles/corner.png -------------------------------------------------------------------------------- /icons/128x128x32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xyproto/zsnes/HEAD/icons/128x128x32.png -------------------------------------------------------------------------------- /doc/images/saveslot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xyproto/zsnes/HEAD/doc/images/saveslot.png -------------------------------------------------------------------------------- /doc/images/zsneslogo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xyproto/zsnes/HEAD/doc/images/zsneslogo.png -------------------------------------------------------------------------------- /effects/burn.h: -------------------------------------------------------------------------------- 1 | #ifndef BURN_H 2 | #define BURN_H 3 | 4 | void DrawBurn(void); 5 | 6 | #endif 7 | -------------------------------------------------------------------------------- /html/images/f1_menu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xyproto/zsnes/HEAD/html/images/f1_menu.png -------------------------------------------------------------------------------- /html/images/netplay.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xyproto/zsnes/HEAD/html/images/netplay.png -------------------------------------------------------------------------------- /html/images/saveslot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xyproto/zsnes/HEAD/html/images/saveslot.png -------------------------------------------------------------------------------- /TODO.md: -------------------------------------------------------------------------------- 1 | # Plans 2 | 3 | - [ ] FreeBSD has a patch for building without `-fcommon`. Look into that. 4 | -------------------------------------------------------------------------------- /cpu/c_dsp.h: -------------------------------------------------------------------------------- 1 | #ifndef C_DSP_H 2 | #define C_DSP_H 3 | 4 | void ProcessKeyOn(u1 al); 5 | 6 | #endif 7 | -------------------------------------------------------------------------------- /cpu/c_regs.h: -------------------------------------------------------------------------------- 1 | #ifndef C_REGS_H 2 | #define C_REGS_H 3 | 4 | void initregr(void); 5 | 6 | #endif 7 | -------------------------------------------------------------------------------- /cpu/c_regsw.h: -------------------------------------------------------------------------------- 1 | #ifndef C_REGSW_H 2 | #define C_REGSW_H 3 | 4 | void initregw(void); 5 | 6 | #endif 7 | -------------------------------------------------------------------------------- /effects/smoke.h: -------------------------------------------------------------------------------- 1 | #ifndef SMOKE_H 2 | #define SMOKE_H 3 | 4 | void DrawSmoke(void); 5 | 6 | #endif 7 | -------------------------------------------------------------------------------- /effects/water.h: -------------------------------------------------------------------------------- 1 | #ifndef WATER_H 2 | #define WATER_H 3 | 4 | void DrawWater(void); 5 | 6 | #endif 7 | -------------------------------------------------------------------------------- /html/images/zsneslogo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xyproto/zsnes/HEAD/html/images/zsneslogo.png -------------------------------------------------------------------------------- /win/zsnes.rc: -------------------------------------------------------------------------------- 1 | #include "resource.h" 2 | 3 | IDI_ICON1 ICON DISCARDABLE "zsnes.ico" 4 | -------------------------------------------------------------------------------- /cpu/c_table.h: -------------------------------------------------------------------------------- 1 | #ifndef C_TABLE_H 2 | #define C_TABLE_H 3 | 4 | void inittable(void); 5 | 6 | #endif 7 | -------------------------------------------------------------------------------- /cpu/c_stable.h: -------------------------------------------------------------------------------- 1 | #ifndef STABLE_H 2 | #define STABLE_H 3 | 4 | extern void SA1inittable(); 5 | 6 | #endif 7 | -------------------------------------------------------------------------------- /chips/c_dsp2proc.h: -------------------------------------------------------------------------------- 1 | #ifndef C_DSP2PROC_H 2 | #define C_DSP2PROC_H 3 | 4 | void InitDSP2(void); 5 | 6 | #endif 7 | -------------------------------------------------------------------------------- /video/c_mode716.h: -------------------------------------------------------------------------------- 1 | #ifndef C_MODE716_H 2 | #define C_MODE716_H 3 | 4 | void Makemode7Table(void); 5 | 6 | #endif 7 | -------------------------------------------------------------------------------- /video/makev16t.h: -------------------------------------------------------------------------------- 1 | #ifndef MAKEV16T_H 2 | #define MAKEV16T_H 3 | 4 | extern void drawline16t(); 5 | 6 | #endif 7 | -------------------------------------------------------------------------------- /video/mode716b.h: -------------------------------------------------------------------------------- 1 | #ifndef MODE716B_H 2 | #define MODE716B_H 3 | 4 | extern void drawmode716b(); 5 | 6 | #endif 7 | -------------------------------------------------------------------------------- /chips/c4proc.h: -------------------------------------------------------------------------------- 1 | #ifndef C4PROC_H 2 | #define C4PROC_H 3 | 4 | #include "../types.h" 5 | 6 | extern u1* C4Ram; 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /cpu/c_tablec.h: -------------------------------------------------------------------------------- 1 | #ifndef C_TABLEC_H 2 | #define C_TABLEC_H 3 | 4 | // Generate OpCode Table 5 | void inittablec(void); 6 | 7 | #endif 8 | -------------------------------------------------------------------------------- /cpu/firtable.h: -------------------------------------------------------------------------------- 1 | #ifndef FIRTABLE_H 2 | #define FIRTABLE_H 3 | 4 | #include "../types.h" 5 | 6 | extern u2 fir_lut[]; 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /video/mode716.h: -------------------------------------------------------------------------------- 1 | #ifndef MODE716_H 2 | #define MODE716_H 3 | 4 | #include "../types.h" 5 | 6 | extern u2 m7starty; 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /cpu/memory.h: -------------------------------------------------------------------------------- 1 | #ifndef MEMORY_H 2 | #define MEMORY_H 3 | 4 | extern void membank0w8(); 5 | extern void regaccessbankr8(); 6 | 7 | #endif 8 | -------------------------------------------------------------------------------- /cpu/s65816d.h: -------------------------------------------------------------------------------- 1 | #ifndef S65816D_H 2 | #define S65816D_H 3 | 4 | extern void Sjoinflags(); 5 | extern void Ssplitflags(); 6 | 7 | #endif 8 | -------------------------------------------------------------------------------- /chips/c_sfxproc.h: -------------------------------------------------------------------------------- 1 | #ifndef C_SFXPROC_H 2 | #define C_SFXPROC_H 3 | 4 | void initsfxregsr(void); 5 | void initsfxregsw(void); 6 | 7 | #endif 8 | -------------------------------------------------------------------------------- /video/c_2xsaiw.h: -------------------------------------------------------------------------------- 1 | #ifndef C_2XSAIW_H 2 | #define C_2XSAIW_H 3 | 4 | #include "../types.h" 5 | 6 | u4 Init_2xSaIMMX(u4 format); 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /video/procvidc.h: -------------------------------------------------------------------------------- 1 | #ifndef PROCVIDC_H 2 | #define PROCVIDC_H 3 | 4 | void Clear2xSaIBuffer(void); 5 | void LoadPicture(void); 6 | 7 | #endif 8 | -------------------------------------------------------------------------------- /chips/7110proc.h: -------------------------------------------------------------------------------- 1 | #ifndef H7110PROC_H 2 | #define H7110PROC_H 3 | 4 | extern void SPC7110Reset(); 5 | extern void initSPC7110regs(); 6 | 7 | #endif 8 | -------------------------------------------------------------------------------- /video/mode716e.h: -------------------------------------------------------------------------------- 1 | #ifndef MODE716E_H 2 | #define MODE716E_H 3 | 4 | extern void drawmode716extbg(); 5 | extern void drawmode716extbg2(); 6 | 7 | #endif 8 | -------------------------------------------------------------------------------- /cpu/c_irq.h: -------------------------------------------------------------------------------- 1 | #ifndef C_IRQ_H 2 | #define C_IRQ_H 3 | 4 | void IRQemulmode(u4* pedx, u1** pesi); 5 | void switchtovirq(u4* pedx, u1** pesi); 6 | 7 | #endif 8 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.[do] 2 | build/ 3 | cfg.h 4 | config.default 5 | include.txt 6 | input.h 7 | md.h 8 | parsegen 9 | win/confloc.h 10 | zsnes 11 | zsnes.exe 12 | -------------------------------------------------------------------------------- /chips/sa1proc.h: -------------------------------------------------------------------------------- 1 | #ifndef SA1PROC_H 2 | #define SA1PROC_H 3 | 4 | #include "../types.h" 5 | 6 | extern u1 SA1Status; // 0 = 65816, 1 = SA1A, 2 = SA1B 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /ver.h: -------------------------------------------------------------------------------- 1 | #ifndef VERSION_H 2 | #define VERSION_H 3 | 4 | #define ZVER "2.0.12" 5 | 6 | void placedate(void); 7 | 8 | extern char* VERSION_STR; 9 | 10 | #endif 11 | -------------------------------------------------------------------------------- /cpu/table.h: -------------------------------------------------------------------------------- 1 | #ifndef TABLE_H 2 | #define TABLE_H 3 | 4 | #include "../types.h" 5 | 6 | extern void eopINVALID(); 7 | 8 | extern u1 cpucycle[256]; 9 | 10 | #endif 11 | -------------------------------------------------------------------------------- /cpu/c_65816d.h: -------------------------------------------------------------------------------- 1 | #ifndef C_65816D_H 2 | #define C_65816D_H 3 | 4 | #include "../types.h" 5 | 6 | void splitflags(u4 edx); 7 | 8 | u4 joinflags(u4 edx); 9 | 10 | #endif 11 | -------------------------------------------------------------------------------- /linux/c_sdlintrf.h: -------------------------------------------------------------------------------- 1 | #ifndef SDLINTRF_H 2 | #define SDLINTRF_H 3 | 4 | #include "../types.h" 5 | 6 | #ifdef __OPENGL__ 7 | extern u1 blinit; 8 | #endif 9 | 10 | #endif 11 | -------------------------------------------------------------------------------- /linux/sdllink.h: -------------------------------------------------------------------------------- 1 | #ifndef SDLLINK_H 2 | #define SDLLINK_H 3 | 4 | #include 5 | 6 | void sem_sleep(void); 7 | 8 | extern uint32_t numlockptr; 9 | 10 | #endif 11 | -------------------------------------------------------------------------------- /video/c_makevid.h: -------------------------------------------------------------------------------- 1 | #ifndef C_MAKEVID_H 2 | #define C_MAKEVID_H 3 | 4 | void makewindow(u1 al, Layer); 5 | void makewindowsp(void); 6 | void procbackgrnd(u4 layer); 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /video/makev16b.h: -------------------------------------------------------------------------------- 1 | #ifndef MAKEV16B_H 2 | #define MAKEV16B_H 3 | 4 | #include "../types.h" 5 | 6 | extern void domosaic16b(); 7 | 8 | extern u1 tileleft16b; 9 | 10 | #endif 11 | -------------------------------------------------------------------------------- /ztimec.h: -------------------------------------------------------------------------------- 1 | #ifndef ZTIMEC_H 2 | #define ZTIMEC_H 3 | 4 | #include "types.h" 5 | 6 | u4 GetDate(void); 7 | u4 GetTime(void); 8 | u4 GetTimeInSeconds(void); 9 | 10 | #endif 11 | -------------------------------------------------------------------------------- /doc/styles/release.css: -------------------------------------------------------------------------------- 1 | /****This file has styling information that changes depending on the medium through which the docs are released.****/ 2 | 3 | .web_only { 4 | display: none; 5 | } 6 | -------------------------------------------------------------------------------- /html/styles/release.css: -------------------------------------------------------------------------------- 1 | /****This file has styling information that changes depending on the medium through which the docs are released.****/ 2 | 3 | .web_only { 4 | display: none; 5 | } 6 | -------------------------------------------------------------------------------- /debugasm.h: -------------------------------------------------------------------------------- 1 | #ifndef DEBUGASM_H 2 | #define DEBUGASM_H 3 | 4 | // Breaks at Breakpoint 5 | void breakops(void); 6 | 7 | // Execute Next Opcode 8 | void execnextop(void); 9 | 10 | #endif 11 | -------------------------------------------------------------------------------- /gui/guicombo.h: -------------------------------------------------------------------------------- 1 | #ifndef GUICOMBO_H 2 | #define GUICOMBO_H 3 | 4 | void ComboAdder(void); 5 | void ComboClip(void); 6 | void ComboRemoval(void); 7 | void ComboReplace(void); 8 | 9 | #endif 10 | -------------------------------------------------------------------------------- /zip/zpng.h: -------------------------------------------------------------------------------- 1 | #ifndef ZPNG_H 2 | #define ZPNG_H 3 | 4 | #ifndef NO_PNG 5 | void Grab_PNG_Data(void); 6 | #endif 7 | void Grab_BMP_Data(void); 8 | void Grab_BMP_Data_8(void); 9 | 10 | #endif 11 | -------------------------------------------------------------------------------- /chips/fxtable.h: -------------------------------------------------------------------------------- 1 | #ifndef FXTABLE_H 2 | #define FXTABLE_H 3 | 4 | extern u4 sfx128lineloc; 5 | extern u4 sfx160lineloc; 6 | extern u4 sfx192lineloc; 7 | extern u4 sfxobjlineloc; 8 | 9 | #endif 10 | -------------------------------------------------------------------------------- /intrf.h: -------------------------------------------------------------------------------- 1 | #ifndef INTRF_H 2 | #define INTRF_H 3 | 4 | #include "types.h" 5 | 6 | extern u4 CurKeyReadPos; 7 | extern u4 KeyBuffer[16]; 8 | extern u4 converta; 9 | extern u4 volatile CurKeyPos; 10 | 11 | #endif 12 | -------------------------------------------------------------------------------- /video/c_newgfx16.h: -------------------------------------------------------------------------------- 1 | #ifndef C_NEWGFX16_H 2 | #define C_NEWGFX16_H 3 | 4 | #include "../types.h" 5 | 6 | void setpalette16bng(void); 7 | void BackAreaFill(u4 eax); 8 | void Gendcolortable(void); 9 | 10 | #endif 11 | -------------------------------------------------------------------------------- /gui/menu.h: -------------------------------------------------------------------------------- 1 | #ifndef MENU_H 2 | #define MENU_H 3 | 4 | #include "../types.h" 5 | 6 | void showmenu(void); 7 | 8 | extern u1 NoInputRead; 9 | extern u1 SPCSave; 10 | extern u1 keyonsn; 11 | extern u1 nextmenupopup; 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /win/c_winintrf.h: -------------------------------------------------------------------------------- 1 | #ifndef C_WININTRF_H 2 | #define C_WININTRF_H 3 | 4 | #include "../types.h" 5 | 6 | // This function is called ~60 times/s at full speed 7 | void SoundProcess(void); 8 | 9 | extern u4 delayvalue; 10 | 11 | #endif 12 | -------------------------------------------------------------------------------- /debugger.h: -------------------------------------------------------------------------------- 1 | #ifndef DEBUGGER_H 2 | #define DEBUGGER_H 3 | 4 | void startdebugger(void); 5 | 6 | extern unsigned int numinst; // # of instructions 7 | extern unsigned short PrevBreakPt_offset; 8 | extern unsigned char PrevBreakPt_page; 9 | 10 | #endif 11 | -------------------------------------------------------------------------------- /chips/dsp2proc.h: -------------------------------------------------------------------------------- 1 | #ifndef DSP2PROC_H 2 | #define DSP2PROC_H 3 | 4 | #include "../types.h" 5 | 6 | extern u4 dsp2enforcerQueue[512][2]; 7 | extern u4 dsp2enforcerReaderCursor; 8 | extern u4 dsp2enforcerWriterCursor; 9 | extern u4 dsp2state; 10 | 11 | #endif 12 | -------------------------------------------------------------------------------- /cpu/c_dsp.c: -------------------------------------------------------------------------------- 1 | #include "../gui/menu.h" 2 | #include "c_dsp.h" 3 | #include "c_dspproc.h" 4 | 5 | 6 | void ProcessKeyOn(u1 const al) 7 | { 8 | for (u4 i = 0; i != 8; ++i) 9 | { 10 | if (al & 1U << i) VoiceStart(i); 11 | } 12 | if (al != 0) keyonsn = 1; 13 | } 14 | -------------------------------------------------------------------------------- /fmt.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | find . -path ./cpu -prune -false -o -name "*.c" -exec clang-format -style=file -i {} \; 3 | find . -path ./cpu -prune -false -o -name "*.h" -exec clang-format -style=file -i {} \; 4 | find . -path ./cpu -prune -false -o -name "*.cpp" -exec clang-format -style=file -i {} \; 5 | -------------------------------------------------------------------------------- /chips/c_dsp2proc.c: -------------------------------------------------------------------------------- 1 | #include "c_dsp2proc.h" 2 | #include "dsp2proc.h" 3 | 4 | void InitDSP2(void) 5 | { 6 | dsp2state = 0; 7 | dsp2enforcerQueue[0][0] = 0; 8 | dsp2enforcerQueue[0][1] = 0x8000; 9 | dsp2enforcerReaderCursor = 0; 10 | dsp2enforcerWriterCursor = 1; 11 | } 12 | -------------------------------------------------------------------------------- /jma/ariprice.h: -------------------------------------------------------------------------------- 1 | #ifndef __COMPRESSION_ARIPRICE_H 2 | #define __COMPRESSION_ARIPRICE_H 3 | 4 | namespace NCompression { 5 | namespace NArithmetic { 6 | 7 | const UINT32 kNumBitPriceShiftBits = 6; 8 | const UINT32 kBitPrice = 1 << kNumBitPriceShiftBits; 9 | 10 | } 11 | } 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /video/c_mode716.c: -------------------------------------------------------------------------------- 1 | #include "c_mode716.h" 2 | #include "../macros.h" 3 | #include "../types.h" 4 | #include "../ui.h" 5 | 6 | void Makemode7Table(void) 7 | { 8 | for (u4 i = 0; i != lengthof(mode7tab); ++i) { 9 | mode7tab[i] = ((i & 0x07) << 4) + ((i >> 8 & 0x07) << 1) + 1; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /macros.h: -------------------------------------------------------------------------------- 1 | #ifndef MACROS_H 2 | #define MACROS_H 3 | 4 | #define STATIC_ASSERT(x) extern int STATIC_ASSERT[((x) != 0) * 2 - 1] 5 | 6 | #define lengthof(x) (sizeof(x) / sizeof *(x)) 7 | #define endof(x) ((x) + lengthof(x)) 8 | 9 | #define ROL(x, n) ((x) << (n) | (x) >> (sizeof(x) * 8 - (n))) 10 | 11 | #endif 12 | -------------------------------------------------------------------------------- /video/copyvwin.h: -------------------------------------------------------------------------------- 1 | #ifndef COPYVWIN_H 2 | #define COPYVWIN_H 3 | 4 | #include "../types.h" 5 | 6 | void copy640x480x16bwin(void); 7 | 8 | extern u1* WinVidMemStart; 9 | extern u4 AddEndBytes; // Number of bytes between each line 10 | extern u4 NumBytesPerLine; // Total number of bytes per line (1024+AddEndBytes) 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /cpu/c_dma.h: -------------------------------------------------------------------------------- 1 | #ifndef C_DMA_H 2 | #define C_DMA_H 3 | 4 | #include "regs.h" 5 | 6 | void c_reg420Bw(u4 eax); 7 | void c_reg420Cw(u4 eax); 8 | void exechdma(void); 9 | void setuphdma(u4 eax, HDMAInfo* edx, DMAInfo* esi); // HDMA Settings 10 | void starthdma(void); // HDMA enable register 11 | 12 | extern u1 AddrNoIncr; 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /gui/guikeys.h: -------------------------------------------------------------------------------- 1 | #ifndef GUIKEYS_H 2 | #define GUIKEYS_H 3 | 4 | // GUI Keyboard Routines 5 | 6 | void GUIWaitForKey(void); 7 | void GUIgetcurrentinput(void); 8 | 9 | extern u1 CSOverValue; 10 | extern u1 GUIDelayB; 11 | extern u4 CSCurValue; 12 | extern u4 GUIInputBox; 13 | extern u4 GUIInputLimit; 14 | extern u4 GUIkeydelay; 15 | 16 | #endif 17 | -------------------------------------------------------------------------------- /types.h: -------------------------------------------------------------------------------- 1 | #ifndef TYPES_H 2 | #define TYPES_H 3 | 4 | typedef signed char s1; 5 | typedef signed short s2; 6 | typedef signed int s4; 7 | typedef signed long long s8; 8 | 9 | typedef unsigned char u1; 10 | typedef unsigned short u2; 11 | typedef unsigned int u4; 12 | typedef unsigned long long u8; 13 | 14 | typedef void eop(); 15 | 16 | #endif 17 | -------------------------------------------------------------------------------- /chips/c_sa1regs.h: -------------------------------------------------------------------------------- 1 | #ifndef C_SA1REGS_H 2 | #define C_SA1REGS_H 3 | 4 | void RTCReset(void); 5 | void RTCReset2(void); 6 | void RTCinit(void); 7 | void SA1Reset(void); 8 | void SDD1Reset(void); 9 | void initSA1regs(void); 10 | void initSA1regsw(void); 11 | void initSDD1regs(void); 12 | void sa1dmabwram(void); 13 | void sa1dmairam(void); 14 | 15 | #endif 16 | -------------------------------------------------------------------------------- /linux/zsnes.desktop: -------------------------------------------------------------------------------- 1 | [Desktop Entry] 2 | Version=1.4 3 | Type=Application 4 | Name=ZSNES 5 | Comment=Super Nintendo emulator 6 | Exec=zsnes %f 7 | TryExec=zsnes 8 | Icon=io.github.xyproto.zsnes 9 | Terminal=false 10 | StartupNotify=false 11 | X-SingleMainWindow=true 12 | Categories=Game;Emulator; 13 | MimeType=application/vnd.nintendo.snes.rom;application/x-snes-rom; 14 | -------------------------------------------------------------------------------- /video/sw_draw.h: -------------------------------------------------------------------------------- 1 | #ifndef SW_DRAW_H 2 | #define SW_DRAW_H 3 | 4 | #include "../types.h" 5 | 6 | void ClearWin16(void); 7 | void ClearWin32(void); 8 | void DrawWin256x224x16(void); 9 | void DrawWin320x240x16(void); 10 | 11 | #ifdef __WIN32__ 12 | void DrawWin256x224x32(void); 13 | #endif 14 | 15 | extern u1* ScreenPtr; 16 | extern u1* SurfBufD; 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /cpu/c_dspproc.h: -------------------------------------------------------------------------------- 1 | #ifndef C_DSPPROC_H 2 | #define C_DSPPROC_H 3 | 4 | #include "../types.h" 5 | 6 | void AdjustFrequency(void); 7 | void InitSPC(void); 8 | void LPFexit(void); 9 | void LPFstereo(s4* esi); 10 | void MixEcho(void); 11 | void MixEcho2(void); 12 | void ProcessVoiceHandler16(u4 p1); 13 | void VoiceStart(u4 voice); 14 | void VoiceStarter(u1 voice); 15 | 16 | #endif 17 | -------------------------------------------------------------------------------- /cpu/c_memory.h: -------------------------------------------------------------------------------- 1 | #ifndef C_MEMORY_H 2 | #define C_MEMORY_H 3 | 4 | #include "../types.h" 5 | 6 | void SA1UpdateDPage(void); 7 | void UpdateDPage(void); 8 | 9 | extern eop* DPageR16; 10 | extern eop* DPageR8; 11 | extern eop* DPageW16; 12 | extern eop* DPageW8; 13 | extern eop* SA1DPageR16; 14 | extern eop* SA1DPageR8; 15 | extern eop* SA1DPageW16; 16 | extern eop* SA1DPageW8; 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /gui/guimouse.h: -------------------------------------------------------------------------------- 1 | #ifndef GUIMOUSE_H 2 | #define GUIMOUSE_H 3 | 4 | // Mouse implementation 5 | 6 | #include "../types.h" 7 | 8 | void SwitchFullScreen(void); 9 | void ProcessMouse(void); 10 | u4 guipresstest(void); 11 | void guipresstestb(u4* guicpressptr, char const* guipressptr); 12 | void DrawMouse(void); 13 | 14 | extern u1 GUIcwinpress; 15 | extern u1 lastmouseholded; 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /video/2xsaiw.h: -------------------------------------------------------------------------------- 1 | #ifndef H2XSAIW_H 2 | #define H2XSAIW_H 3 | 4 | #include "../types.h" 5 | 6 | typedef void LineFilter(u2*, u1*, u4, u4, u1*, u4); 7 | extern LineFilter _2xSaISuperEagleLine; 8 | extern LineFilter _2xSaISuper2xSaILine; 9 | extern LineFilter _2xSaILine; 10 | 11 | extern u4 colorMask[2]; 12 | extern u4 lowPixelMask[2]; 13 | extern u4 qcolorMask[2]; 14 | extern u4 qlowpixelMask[2]; 15 | 16 | #endif 17 | -------------------------------------------------------------------------------- /video/c_makev16b.h: -------------------------------------------------------------------------------- 1 | #ifndef C_MAKEV16B_H 2 | #define C_MAKEV16B_H 3 | 4 | #include "../types.h" 5 | 6 | void clearback16b(void); 7 | void draw16x1616b(u4 eax, u4 ecx, u2* edx, u1* ebx, u4 esi, u2 const* edi); 8 | void draw8x816b(u4 eax, u4 ecx, u2* edx, u1* ebx, u4 layer, u4 esi, u2 const* edi); 9 | void drawline16b(void); 10 | void drawsprites16b(u1 cl, u4 ebp); 11 | void procspritesmain16b(u4 ebp); 12 | void setpalette16b(void); 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /doc/styles/plaintxt.css: -------------------------------------------------------------------------------- 1 | /* The Plain Text stylesheet. 2 | The goal with this style is to make the docs look as much as possible like the text version of the docs. */ 3 | 4 | /* ALL PROPERTIES ARE ALPHABETIZED!!! KEEP THEM THAT WAY!!! */ 5 | 6 | body { 7 | font-family: "Lucida Console", "Courier New", Courier, monospace; 8 | font-size: 10pt; 9 | width: 48em; 10 | } 11 | 12 | img { 13 | display: none; 14 | } 15 | 16 | a:after { 17 | content: " [" attr(href) "]"; 18 | } 19 | -------------------------------------------------------------------------------- /gui/guicheat.h: -------------------------------------------------------------------------------- 1 | #ifndef GUICHEAT_H 2 | #define GUICHEAT_H 3 | 4 | // GUI Cheat Code Routines 5 | 6 | void AddCSCheatCode(void); 7 | void CheatCodeFix(void); 8 | void CheatCodeRemove(void); 9 | void CheatCodeSearchInit(void); 10 | void CheatCodeSearchProcess(void); 11 | void CheatCodeToggle(void); 12 | void DisableCheatsOnLoad(void); 13 | void EnableCheatCodeNoPrevMod(u1* esi); 14 | void EnableCheatsOnLoad(void); 15 | void ProcessCheatCode(void); 16 | 17 | extern u1 CopyRamToggle; 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /html/styles/plaintxt.css: -------------------------------------------------------------------------------- 1 | /* The Plain Text stylesheet. 2 | The goal with this style is to make the docs look as much as possible like the text version of the docs. */ 3 | 4 | /* ALL PROPERTIES ARE ALPHABETIZED!!! KEEP THEM THAT WAY!!! */ 5 | 6 | body { 7 | font-family: "Lucida Console", "Courier New", Courier, monospace; 8 | font-size: 10pt; 9 | width: 48em; 10 | } 11 | 12 | img { 13 | display: none; 14 | } 15 | 16 | a:after { 17 | content: " [" attr(href) "]"; 18 | } 19 | -------------------------------------------------------------------------------- /asm.h: -------------------------------------------------------------------------------- 1 | #ifndef ASM_H 2 | #define ASM_H 3 | 4 | #include "types.h" 5 | 6 | static inline void cli(void) { asm volatile("cli"); } 7 | static inline void sti(void) { asm volatile("sti"); } 8 | 9 | static inline u1 inb(u2 const port) 10 | { 11 | u1 val; 12 | asm volatile("inb %1, %0" 13 | : "=a"(val) 14 | : "Nd"(port)); 15 | return val; 16 | } 17 | 18 | static inline void outb(u2 const port, u1 const val) 19 | { 20 | asm volatile("outb %0, %1" ::"a"(val), "dN"(port)); 21 | } 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /c_vcache.h: -------------------------------------------------------------------------------- 1 | #ifndef C_VCACHE_H 2 | #define C_VCACHE_H 3 | 4 | #include "types.h" 5 | 6 | void cachevideo(void); 7 | void genfulladdtab(void); 8 | void ConvertToAFormat(void); 9 | 10 | extern u1 SloMo; // number of extra times to draw a frame 11 | extern u1 colormodedef[][4]; 12 | extern u1 curblank; // current blank state (40h = skip fill) 13 | extern u1 curcolbg[4]; 14 | extern u1 hiresstuff; 15 | extern u1 osm2dis; 16 | extern u1* colormodeofs; 17 | extern u2 curbgofs[4]; 18 | extern u4 CSprWinPtr; 19 | extern u4 sramb4save; 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /gui/guimisc.h: -------------------------------------------------------------------------------- 1 | #ifndef GUIMISC_H 2 | #define GUIMISC_H 3 | 4 | // Joystick setting (display) routines, SNES Reset Function 5 | 6 | #include "../types.h" 7 | 8 | void SetAllKeys(void); 9 | void CalibrateDev1(void); 10 | void SetDevice(void); 11 | void GUIDoReset(void); 12 | void GetCoords(u2 port); 13 | void GetCoords3(u2 port); 14 | 15 | extern u1 JoyExists2; 16 | extern u1 JoyExists; 17 | extern u4 JoyMaxX; 18 | extern u4 JoyMaxY; 19 | extern u4 JoyMinX; 20 | extern u4 JoyMinY; 21 | extern u4 JoyX2; 22 | extern u4 JoyX; 23 | extern u4 JoyY2; 24 | extern u4 JoyY; 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /video/newgfx.h: -------------------------------------------------------------------------------- 1 | #ifndef NEWGFX_H 2 | #define NEWGFX_H 3 | 4 | #include "../types.h" 5 | 6 | extern void preparesprpr(); 7 | 8 | extern u1 Mode7HiRes; // XXX always 0 9 | extern u1 sprclprio[4]; 10 | extern u1* ofsmcptr; 11 | extern u4 bgcmsung; 12 | extern u4 bgtxadd; 13 | extern u4 flipyposngom; 14 | extern u4 modeused[2]; 15 | extern u4 ngextbg; 16 | extern u4 ngwintable[32]; 17 | extern u4 ofsmadx; 18 | extern u4 ofsmady; 19 | extern u4 ofsmcyps; 20 | extern u4 ofsmmptr; 21 | extern u4 ofsmtptr; 22 | extern u4 scfbl; 23 | extern u4 sprsingle; 24 | extern u4 yposngom; 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /chips/fxemu2.h: -------------------------------------------------------------------------------- 1 | #ifndef FXEMU2_H 2 | #define FXEMU2_H 3 | 4 | #include "../types.h" 5 | 6 | extern void MainLoop(); 7 | 8 | extern u1* SCBRrel; 9 | extern u4 NumberOfOpcodes; // Number of opcodes to execute 10 | extern u4 SfxCLSR; // clock speed register (8bit) 11 | extern u4 SfxCOLR; // Internal color register 12 | extern u4 SfxPBR; // program bank register (8bit) 13 | extern u4 SfxPOR; // Plot option register 14 | extern u4 SfxSCBR; // screen bank register (8bit) 15 | extern u4 SfxSCMR; // screen mode register (8bit) 16 | extern u4 fxbit01pcal; 17 | extern u4 fxbit23pcal; 18 | extern u4 fxbit45pcal; 19 | extern u4 fxbit67pcal; 20 | extern u4 sfxclineloc; 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /cpu/c_execute.h: -------------------------------------------------------------------------------- 1 | #ifndef C_EXECUTE_H 2 | #define C_EXECUTE_H 3 | 4 | #include "../types.h" 5 | 6 | // this wonderful mess starts up the CPU and initialized the emulation state 7 | void start65816(void); 8 | 9 | void continueprog(void); 10 | 11 | void continueprognokeys(void); 12 | 13 | void reexecuteb(void); 14 | 15 | void endprog(void); 16 | 17 | void interror(void); 18 | 19 | void Donextlinecache(void); 20 | 21 | void execute(u4* pedx, u1** pebp, u1** pesi, eop*** pedi); 22 | 23 | void StartSFXdebugb(void); 24 | 25 | void UpdatePORSCMR(void); 26 | 27 | void UpdateSCBRCOLR(void); 28 | 29 | void UpdateCLSR(void); 30 | 31 | void StartSFX(void); 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /cpu/execute.h: -------------------------------------------------------------------------------- 1 | #ifndef EXECUTE_H 2 | #define EXECUTE_H 3 | 4 | #include "../types.h" 5 | 6 | extern void cpuover(); 7 | extern void execsingle(); 8 | 9 | extern u1 EMUPause; 10 | extern u1 ExecExitOkay; 11 | extern u1 NextLineCache; 12 | extern u1 NextNGDisplay; 13 | extern u1 NoSoundReinit; 14 | extern u1 SPCKeyPressed; 15 | extern u1 SSKeyPressed; 16 | extern u1 exiter; 17 | extern u1 nextframe; // tick count for timer 18 | extern u1 pdh; 19 | extern u1 pressed[256 + 128 + 64]; // keyboard pressed keys in scancode 20 | extern u1 romloadskip; 21 | extern u1* initaddrl; // initial address location 22 | extern u2 t1cc; 23 | extern u4 NumberOfOpcodes2; 24 | extern u4 timercount; 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /zstate.h: -------------------------------------------------------------------------------- 1 | #ifndef ZSTATE_H 2 | #define ZSTATE_H 3 | 4 | #include 5 | #include 6 | 7 | int zst_exists(void); 8 | void BackupSystemVars(void); 9 | void LoadSecondState(void); 10 | void RestoreSystemVars(void); 11 | void SaveSecondState(void); 12 | void SaveSramData(void); 13 | void loadstate2(void); 14 | void statesaver(void); 15 | void zst_determine_newest(void); 16 | 17 | void statesaver(void); 18 | 19 | void loadstate(void); 20 | 21 | void SaveSramData(void); 22 | 23 | void savespcdata(void); 24 | 25 | extern time_t newestfiledate; 26 | extern uint32_t current_zst; 27 | extern uint32_t newest_zst; 28 | 29 | extern char spcsaved[16]; 30 | extern u4 Totalbyteloaded; 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /cpu/c_memory.c: -------------------------------------------------------------------------------- 1 | #include "c_memory.h" 2 | #include "../chips/sa1regs.h" 3 | #include "../endmem.h" 4 | #include "../init.h" 5 | 6 | eop* DPageR16; 7 | eop* DPageR8; 8 | eop* DPageW16; 9 | eop* DPageW8; 10 | eop* SA1DPageR16; 11 | eop* SA1DPageR8; 12 | eop* SA1DPageW16; 13 | eop* SA1DPageW8; 14 | 15 | void UpdateDPage(void) 16 | { 17 | u1 const d = xd >> 8; 18 | DPageR8 = Bank0datr8[d]; 19 | DPageR16 = Bank0datr16[d]; 20 | DPageW8 = Bank0datw8[d]; 21 | DPageW16 = Bank0datw16[d]; 22 | } 23 | 24 | void SA1UpdateDPage(void) 25 | { 26 | u1 const d = SA1xd >> 8; 27 | SA1DPageR8 = Bank0datr8[d]; 28 | SA1DPageR16 = Bank0datr16[d]; 29 | SA1DPageW8 = Bank0datw8[d]; 30 | SA1DPageW16 = Bank0datw16[d]; 31 | } 32 | -------------------------------------------------------------------------------- /link.h: -------------------------------------------------------------------------------- 1 | #ifndef LINK_H 2 | #define LINK_H 3 | 4 | #include "types.h" 5 | 6 | s4 GetMouseButton(void); 7 | s4 GetMouseMoveX(void); 8 | s4 GetMouseMoveY(void); 9 | s4 GetMouseX(void); 10 | s4 GetMouseY(void); 11 | void CheckTimers(void); 12 | void DocsPage(void); 13 | void Start36HZ(void); 14 | void Start60HZ(void); 15 | void Stop36HZ(void); 16 | void Stop60HZ(void); 17 | void UpdateVFrame(void); 18 | void ZsnesPage(void); 19 | void clearwin(void); 20 | void drawscreenwin(void); 21 | void initwinvideo(void); 22 | 23 | extern s4 SurfaceX; 24 | extern s4 SurfaceY; 25 | extern u1 MouseButton; 26 | extern u1 T36HZEnabled; 27 | extern u1 changeRes; 28 | extern u4 pitch; 29 | extern u8 copymagic; 30 | extern u8 copymaskG; 31 | extern u8 copymaskRB; 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /c_init.h: -------------------------------------------------------------------------------- 1 | #ifndef C_INIT_H 2 | #define C_INIT_H 3 | 4 | #include "types.h" 5 | 6 | void init(void); 7 | void ReadInputDevice(void); 8 | void DosExit(void); 9 | void MMXCheck(void); 10 | void outofmemfix(void); 11 | void idledetectspc(void); 12 | 13 | // Print Hexadecimal (16-bit) 14 | void printhex(u2 ax); 15 | 16 | extern u1 ComboCounter; 17 | extern u1 MMXSupport; 18 | extern u1 ReturnFromSPCStall; 19 | extern u1 SPCStallSetting; 20 | extern u1 WhichSW; 21 | extern u4 JoyANow; 22 | extern u4 JoyAOrig; 23 | extern u4 JoyBNow; 24 | extern u4 JoyBOrig; 25 | extern u4 JoyCNow; 26 | extern u4 JoyCOrig; 27 | extern u4 JoyDNow; 28 | extern u4 JoyDOrig; 29 | extern u4 JoyENow; 30 | extern u4 JoyEOrig; 31 | extern u4 numspcvblleft; 32 | extern u4 spc700idle; 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /linux/sockserv.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1997-2008 ZSNES Team ( zsKnight, _Demo_, pagefault, Nach ) 3 | 4 | http://www.zsnes.com 5 | http://sourceforge.net/projects/zsnes 6 | https://zsnes.bountysource.com 7 | 8 | This program is free software; you can redistribute it and/or 9 | modify it under the terms of the GNU General Public License 10 | version 2 as published by the Free Software Foundation. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program; if not, write to the Free Software 19 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 20 | */ 21 | -------------------------------------------------------------------------------- /linux/sockserv.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1997-2008 ZSNES Team ( zsKnight, _Demo_, pagefault, Nach ) 3 | 4 | http://www.zsnes.com 5 | http://sourceforge.net/projects/zsnes 6 | https://zsnes.bountysource.com 7 | 8 | This program is free software; you can redistribute it and/or 9 | modify it under the terms of the GNU General Public License 10 | version 2 as published by the Free Software Foundation. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program; if not, write to the Free Software 19 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 20 | */ 21 | -------------------------------------------------------------------------------- /jma/zsnesjma.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2004-2008 NSRT Team ( http://nsrt.edgeemu.com ) 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | version 2 as published by the Free Software Foundation. 7 | 8 | This program is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | GNU General Public License for more details. 12 | 13 | You should have received a copy of the GNU General Public License 14 | along with this program; if not, write to the Free Software 15 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 16 | */ 17 | 18 | #ifdef __cplusplus 19 | extern "C" { 20 | #endif 21 | void load_jma_file(const char* filename); 22 | #ifdef __cplusplus 23 | } 24 | #endif 25 | -------------------------------------------------------------------------------- /version.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh -e 2 | # 3 | # Self-modifying script that updates the version numbers 4 | # 5 | 6 | # The current version goes here, as the default value 7 | VERSION=${1:-'2.0.12'} 8 | 9 | if [ -z "$1" ]; then 10 | echo "The current version is $VERSION, pass the new version as the first argument if you wish to change it" 11 | exit 0 12 | fi 13 | 14 | echo "Setting the version to $VERSION" 15 | 16 | # Set the version in README.md 17 | sed -i "s/Version: [[:digit:]]*\.[[:digit:]]*\.[[:digit:]]*/Version: $VERSION/g" README.md 18 | 19 | # Set the version in various files 20 | sed -i "s/[[:digit:]]*\.[[:digit:]]*\.[[:digit:]]*/$VERSION/g" ver.h 21 | 22 | # Set the version in the man page 23 | sed -i "s/[[:digit:]]*\.[[:digit:]]*\.[[:digit:]]*/$VERSION/g" man/zsnes.1 24 | 25 | # Set the version in this script 26 | sed -i "s/[[:digit:]]*\.[[:digit:]]*\.[[:digit:]]*/$VERSION/g" "$0" 27 | -------------------------------------------------------------------------------- /video/c_2xsaiw.c: -------------------------------------------------------------------------------- 1 | #include "c_2xsaiw.h" 2 | #include "2xsaiw.h" 3 | 4 | u4 Init_2xSaIMMX(u4 const format) 5 | { 6 | u4 full; 7 | u4 color; 8 | switch (format) // PixelFormat 9 | { 10 | case 555: 11 | full = 0x7FFF7FFF; 12 | color = 0x7BDE7BDE; 13 | break; 14 | case 565: 15 | full = 0xFFFFFFFF; 16 | color = 0xF7DEF7DE; 17 | break; 18 | default: 19 | return 1; 20 | } 21 | 22 | colorMask[0] = color; 23 | colorMask[1] = color; 24 | u4 const lowPixel = color ^ full; 25 | lowPixelMask[0] = lowPixel; 26 | lowPixelMask[1] = lowPixel; 27 | u4 const qcolor = color & (color << 1); 28 | qcolorMask[0] = qcolor; 29 | qcolorMask[1] = qcolor; 30 | u4 const qlowpixel = qcolor ^ full; 31 | qlowpixelMask[0] = qlowpixel; 32 | qlowpixelMask[1] = qlowpixel; 33 | return 0; 34 | } 35 | -------------------------------------------------------------------------------- /jma/crc32.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2004-2008 NSRT Team ( http://nsrt.edgeemu.com ) 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | version 2 as published by the Free Software Foundation. 7 | 8 | This program is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | GNU General Public License for more details. 12 | 13 | You should have received a copy of the GNU General Public License 14 | along with this program; if not, write to the Free Software 15 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 16 | */ 17 | 18 | #ifndef CRC32_H 19 | #define CRC32_H 20 | 21 | namespace CRC32lib { 22 | unsigned int CRC32(const unsigned char*, size_t, register unsigned int crc32 = 0xFFFFFFFF); 23 | } 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /asm_call.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file provides the DJGPP/MinGW/MSVC/GCC on *nix compatible 3 | * "call asm function safely from C/C++" macro function. 4 | * 5 | * Usage: 6 | * asm_call( func_name ); 7 | * 8 | * NOTE: It might not work with GCC and the -MASM=intel flag. 9 | */ 10 | 11 | #ifndef ASM_CALL_H 12 | #define ASM_CALL_H 13 | 14 | #ifdef __GNUC__ 15 | #if defined __x86_64__ 16 | #define asm_call(func) asm volatile("push %%rbx; call %P0; pop %%rbx" ::"X"(func) \ 17 | : "cc", "memory", "rax", "rcx", "rdx", "rbp", "rsi", "rdi") 18 | #elif defined __i386__ 19 | #define asm_call(func) asm volatile("push %%ebp; call %P0; pop %%ebp" ::"X"(func) \ 20 | : "cc", "memory", "eax", "ecx", "edx", "ebx", "esi", "edi") 21 | #else 22 | #error unknown architecture 23 | #endif 24 | #elif defined _MSC_VER 25 | #define asm_call(func) __asm { __asm pushad __asm call func __asm popad } 26 | #else 27 | #error unknown compiler 28 | #endif 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /video/snes_ntsc/snes_ntsc_config.h: -------------------------------------------------------------------------------- 1 | /* Configure library by modifying this file */ 2 | 3 | #ifndef SNES_NTSC_CONFIG_H 4 | #define SNES_NTSC_CONFIG_H 5 | 6 | /* Format of source pixels */ 7 | #define SNES_NTSC_IN_FORMAT SNES_NTSC_RGB16 8 | /* #define SNES_NTSC_IN_FORMAT SNES_NTSC_BGR15 */ 9 | 10 | /* The following affect the built-in blitter only; a custom blitter can 11 | handle things however it wants. */ 12 | 13 | /* Bits per pixel of output. Can be 15, 16, 32, or 24 (same as 32). */ 14 | #define SNES_NTSC_OUT_DEPTH 16 15 | 16 | /* Type of input pixel values */ 17 | #define SNES_NTSC_IN_T unsigned short 18 | 19 | /* Each raw pixel input value is passed through this. You might want to mask 20 | the pixel index if you use the high bits as flags, etc. */ 21 | #define SNES_NTSC_ADJ_IN(in) in 22 | 23 | /* For each pixel, this is the basic operation: 24 | output_color = SNES_NTSC_ADJ_IN( SNES_NTSC_IN_T ) */ 25 | 26 | /* Disable standard blitters */ 27 | #define SNES_NTSC_NO_BLITTERS 1 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /gui/guitools.h: -------------------------------------------------------------------------------- 1 | #ifndef GUITOOLS_H 2 | #define GUITOOLS_H 3 | 4 | #include "../types.h" 5 | 6 | char const* GUIOutputString(u1* dst, char const* text, u1 colour); 7 | void GUIOuttext(u4 x, u4 y, char const* text, u1 colour); 8 | void GUIDrawBox(u1* dst, u4 w, u4 h, u1 colour); 9 | void GUIBox(u4 x1, u4 y1, u4 x2, u4 y2, u1 colour); 10 | void GUIHLine(s4 x1, s4 x2, s4 y, u1 colour); 11 | void GUIShadow(u4 x1, u4 y1, u4 x2, u4 y2); 12 | void GUIDrawShadow2(u1* buf, u4 w, u4 h); 13 | void GUIOuttextwin2(u4 win_id, u4 x, u4 y, char const* text, u1 colour); 14 | void GUIOuttextwin2l(u4 win_id, u4 x, u4 y, char const* text, u1 colour); 15 | void GUIOuttextwin(u4 x, u4 y, char const* text, u1 colour); 16 | void GUIOuttextwin2u(u4 win_id, u4 x, u4 y, char const* text, u1 colour, u4 under_pos); 17 | void GUIoutputiconwin(s4 x, u4 y, u1 const* src); 18 | void GUIDisplayIconWin(u4 win_id, u4 x, u4 y, u1 const* icon); 19 | void DrawSlideBarWin(u4 win_id, u4 x, u4 y, u4 list_loc, u4 list_size, u4 screen_size, u4 bar_size, u4* bar_dims); 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /linux/sw_draw.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1997-2008 ZSNES Team ( zsKnight, _Demo_, pagefault, Nach ) 3 | 4 | http://www.zsnes.com 5 | http://sourceforge.net/projects/zsnes 6 | https://zsnes.bountysource.com 7 | 8 | This program is free software; you can redistribute it and/or 9 | modify it under the terms of the GNU General Public License 10 | version 2 as published by the Free Software Foundation. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program; if not, write to the Free Software 19 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 20 | */ 21 | 22 | #ifndef SW_DRAW_h 23 | #define SW_DRAW_h 1 24 | 25 | int sw_start(int width, int height, int req_depth, int FullScreen); 26 | void sw_end(); 27 | void sw_clearwin(); 28 | void sw_drawwin(); 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /init.h: -------------------------------------------------------------------------------- 1 | #ifndef INIT_H 2 | #define INIT_H 3 | 4 | #include "types.h" 5 | 6 | extern u1 ENVDisable; 7 | extern u1 ZMVRawDump; 8 | extern u1 autoloadmovie; 9 | extern u1 autoloadstate; // auto load state slot number 10 | extern u1 cacheud; // update cache every ? frames 11 | extern u1 ccud; // current cache increment 12 | extern u1 curcyc; // cycles left in scanline 13 | extern u1 debugger; // Start with debugger (1=yes,0=no) 14 | extern u1 forceromtype; 15 | extern u1 regsbackup[3019]; 16 | extern u1 romtype; // ROM type in bytes 17 | extern u1 spcon; // SPC Enable (1=enabled) 18 | extern u1 writeon; // Write enable/disable on snes rom memory 19 | extern u1 xpb; 20 | extern u1 yesoutofmemory; 21 | extern u2 irqv2; // IRQ vector 22 | extern u2 irqv8; // irq vector emulation mode 23 | extern u2 irqv; // IRQ vector 24 | extern u2 nmiv2; // NMI vector 25 | extern u2 nmiv; // NMI vector 26 | extern u2 resetv; // reset vector 27 | extern u2 xd; 28 | extern u2 xpc; 29 | extern u2 xs; 30 | extern u4 cycpblt; // percentage of CPU/SPC to run 31 | extern u4 flagc; 32 | extern u4 flagnz; 33 | extern u4 flago; 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /chips/msu1emu.h: -------------------------------------------------------------------------------- 1 | #ifndef MSU1REGS_H 2 | #define MSU1REGS_H 3 | 4 | #include "../types.h" 5 | 6 | // File 7 | extern u1 MSU_StatusRead; 8 | extern u1 MSU_MusicVolume; 9 | extern int MSU_Track_Position; 10 | extern char MSU_BasePath[]; 11 | int readMSU(); 12 | 13 | // Registers 14 | extern void initMSU1regsRead(); 15 | extern void initMSU1regsWrite(); 16 | 17 | // Read Registers 18 | extern void msuid1(); 19 | extern void msuid2(); 20 | extern void msuid3(); 21 | extern void msuid4(); 22 | extern void msuid5(); 23 | extern void msuid6(); 24 | extern void msudataread(); 25 | extern void msustatusread(); 26 | 27 | // Write Registers 28 | extern void msudataseek0(); 29 | extern void msudataseek1(); 30 | extern void msudataseek2(); 31 | extern void msudataseek3(); 32 | extern void msu1track0(); 33 | extern void msu1track1(); 34 | extern void msu1volume(); 35 | extern void msu1statecontrol(); 36 | 37 | // Misc. Functions 38 | extern void mixMSU1Audio(int* start, int* end, int rate); 39 | extern void MSU1GetStatusBitsSpecial(); 40 | extern void MSU1HandleTrackChange(); 41 | extern void MSU1HandleStatusBits(); 42 | 43 | #endif -------------------------------------------------------------------------------- /debugger/load.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1997-2008 ZSNES Team ( zsKnight, _Demo_, pagefault, Nach ) 3 | 4 | http://www.zsnes.com 5 | http://sourceforge.net/projects/zsnes 6 | https://zsnes.bountysource.com 7 | 8 | This program is free software; you can redistribute it and/or 9 | modify it under the terms of the GNU General Public License 10 | version 2 as published by the Free Software Foundation. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program; if not, write to the Free Software 19 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 20 | */ 21 | 22 | #ifndef LOAD_H 23 | #define LOAD_H 24 | 25 | #ifdef __cplusplus 26 | extern "C" { 27 | #endif 28 | 29 | void debug_main(); 30 | void debug_exit(int); 31 | 32 | extern unsigned char debugger_quit; 33 | 34 | #ifdef __cplusplus 35 | } 36 | #endif 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /win/lib.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1997-2008 ZSNES Team ( zsKnight, _Demo_, pagefault, Nach ) 3 | 4 | http://www.zsnes.com 5 | http://sourceforge.net/projects/zsnes 6 | https://zsnes.bountysource.com 7 | 8 | This program is free software; you can redistribute it and/or 9 | modify it under the terms of the GNU General Public License 10 | version 2 as published by the Free Software Foundation. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program; if not, write to the Free Software 19 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 20 | */ 21 | 22 | #ifndef LIB_H 23 | #define LIB_H 24 | 25 | #include 26 | #include 27 | 28 | #ifdef _MSC_VER 29 | #define strcasecmp _stricmp 30 | #define strncasecmp _strnicmp 31 | #endif 32 | 33 | char* realpath(const char* path, char* resolved_path); 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /linux/gl_draw.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1997-2008 ZSNES Team ( zsKnight, _Demo_, pagefault, Nach ) 3 | 4 | http://www.zsnes.com 5 | http://sourceforge.net/projects/zsnes 6 | https://zsnes.bountysource.com 7 | 8 | This program is free software; you can redistribute it and/or 9 | modify it under the terms of the GNU General Public License 10 | version 2 as published by the Free Software Foundation. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program; if not, write to the Free Software 19 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 20 | */ 21 | 22 | #ifndef GL_DRAW_h 23 | #define GL_DRAW_h 1 24 | 25 | int gl_start(int width, int height, int req_depth, int FullScreen); 26 | void gl_end(); 27 | void gl_clearwin(); 28 | void gl_drawwin(); 29 | void SetGLAttributes(); 30 | 31 | extern char allow_glvsync; 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /doc/styles/print.css: -------------------------------------------------------------------------------- 1 | /* The stylesheet used for printing. 2 | This stylesheet is used to render the docs nicely for printing. */ 3 | 4 | /* ALL PROPERTIES ARE ALPHABETIZED!!! KEEP THEM THAT WAY!!! */ 5 | 6 | @import url(shared.css); /* Loads styles/shared.css, which contains shared styling information. */ 7 | 8 | body { 9 | background-color: white; 10 | color: black; 11 | font-family: Verdana, "Arial Unicode MS", Arial, sans-serif; 12 | font-size: 10pt; 13 | margin: 1px; 14 | } 15 | 16 | img { 17 | display: none; 18 | } 19 | 20 | a { 21 | background-color: inherit; 22 | color: black; 23 | } 24 | 25 | #content a:after { 26 | content: " [" attr(href) "]"; 27 | } 28 | 29 | #nav_column { 30 | display: none; 31 | } 32 | 33 | #content code { 34 | background-color: inherit; 35 | color: black; 36 | } 37 | 38 | #footer { 39 | clear: both; /* This is mainly for pages that might be shorter than the nav-list on the left. Keeps things looking correct. */ 40 | font-size: 0.7em; 41 | font-weight: bold; 42 | text-align: center; 43 | } 44 | 45 | #footer h2 { 46 | display: none; 47 | } -------------------------------------------------------------------------------- /html/styles/print.css: -------------------------------------------------------------------------------- 1 | /* The stylesheet used for printing. 2 | This stylesheet is used to render the docs nicely for printing. */ 3 | 4 | /* ALL PROPERTIES ARE ALPHABETIZED!!! KEEP THEM THAT WAY!!! */ 5 | 6 | @import url(shared.css); /* Loads styles/shared.css, which contains shared styling information. */ 7 | 8 | body { 9 | background-color: white; 10 | color: black; 11 | font-family: Verdana, "Arial Unicode MS", Arial, sans-serif; 12 | font-size: 10pt; 13 | margin: 1px; 14 | } 15 | 16 | img { 17 | display: none; 18 | } 19 | 20 | a { 21 | background-color: inherit; 22 | color: black; 23 | } 24 | 25 | #content a:after { 26 | content: " [" attr(href) "]"; 27 | } 28 | 29 | #nav_column { 30 | display: none; 31 | } 32 | 33 | #content code { 34 | background-color: inherit; 35 | color: black; 36 | } 37 | 38 | #footer { 39 | clear: both; /* This is mainly for pages that might be shorter than the nav-list on the left. Keeps things looking correct. */ 40 | font-size: 0.7em; 41 | font-weight: bold; 42 | text-align: center; 43 | } 44 | 45 | #footer h2 { 46 | display: none; 47 | } -------------------------------------------------------------------------------- /jma/ariconst.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2002 Andrea Mazzoleni ( http://advancemame.sf.net ) 3 | Copyright (C) 2001-4 Igor Pavlov ( http://www.7-zip.org ) 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License version 2.1 as published by the Free Software Foundation. 8 | 9 | This library is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public 15 | License along with this library; if not, write to the Free Software 16 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 | */ 18 | 19 | #ifndef __ARICONST_H 20 | #define __ARICONST_H 21 | 22 | #include "aribitcd.h" 23 | 24 | typedef NCompression::NArithmetic::CRangeDecoder CMyRangeDecoder; 25 | template 26 | class CMyBitDecoder : public NCompression::NArithmetic::CBitDecoder { 27 | }; 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /linux/safelib.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1997-2008 ZSNES Team ( zsKnight, _Demo_, pagefault, Nach ) 3 | 4 | http://www.zsnes.com 5 | http://sourceforge.net/projects/zsnes 6 | https://zsnes.bountysource.com 7 | 8 | This program is free software; you can redistribute it and/or 9 | modify it under the terms of the GNU General Public License 10 | version 2 as published by the Free Software Foundation. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program; if not, write to the Free Software 19 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 20 | */ 21 | 22 | #ifndef SAFELIB_H 23 | #define SAFELIB_H 24 | 25 | #include 26 | #include 27 | 28 | pid_t safe_fork(int*, size_t); 29 | 30 | FILE* safe_popen(char*, const char*); 31 | void safe_pclose(FILE*); 32 | 33 | #define popen safe_popen 34 | #define pclose safe_pclose 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /initc.h: -------------------------------------------------------------------------------- 1 | #ifndef INITC_H 2 | #define INITC_H 3 | 4 | #include 5 | #include 6 | 7 | #include "types.h" 8 | 9 | bool loadfileGUI(void); 10 | uint32_t showinfogui(void); 11 | void Setper2exec(void); 12 | void SetupROM(void); 13 | void clearmem(void); 14 | void init65816(void); 15 | void initsnes(void); 16 | void procexecloop(void); 17 | void zexit(void); 18 | 19 | extern bool RTCEnable; 20 | extern bool SDD1Enable; 21 | extern char CSStatus[41]; 22 | extern char CSStatus2[41]; 23 | extern char CSStatus3[41]; 24 | extern char CSStatus4[41]; 25 | extern u1 ComboHeader[23]; 26 | extern u1 sramsavedis; 27 | 28 | extern uint8_t snesinputdefault1; 29 | extern uint8_t snesinputdefault2; 30 | extern uint8_t disableeffects; 31 | extern uint16_t curypos; // current y position 32 | extern uint8_t xp; 33 | extern uint8_t xe; 34 | extern eop** Curtableaddr; // Current table address 35 | 36 | extern u1 SFXCounter; 37 | extern u1 xirqb; // which bank the irqs start at 38 | extern u2 stackand; // value to and stack to keep it from going to the wrong area 39 | extern u2 stackor; // value to or stack to keep it from going to the wrong area 40 | extern s4 echobuf[22500]; 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /jma/7z.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2005-2008 NSRT Team ( http://nsrt.edgeemu.com ) 3 | Copyright (C) 2002 Andrea Mazzoleni ( http://advancemame.sf.net ) 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License version 2.1 as published by the Free Software Foundation. 8 | 9 | This library is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public 15 | License along with this library; if not, write to the Free Software 16 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 | */ 18 | 19 | #ifndef __7Z_H 20 | #define __7Z_H 21 | 22 | #include "iiostrm.h" 23 | 24 | bool decompress_lzma_7z(ISequentialInStream& in, unsigned in_size, ISequentialOutStream& out, unsigned out_size) throw(); 25 | bool decompress_lzma_7z(const unsigned char* in_data, unsigned in_size, unsigned char* out_data, unsigned out_size) throw(); 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /cpu/tablec.asm: -------------------------------------------------------------------------------- 1 | ;Copyright (C) 1997-2008 ZSNES Team ( zsKnight, _Demo_, pagefault, Nach ) 2 | ; 3 | ;http://www.zsnes.com 4 | ;http://sourceforge.net/projects/zsnes 5 | ;https://zsnes.bountysource.com 6 | ; 7 | ;This program is free software; you can redistribute it and/or 8 | ;modify it under the terms of the GNU General Public License 9 | ;version 2 as published by the Free Software Foundation. 10 | ; 11 | ;This program is distributed in the hope that it will be useful, 12 | ;but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | ;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | ;GNU General Public License for more details. 15 | ; 16 | ;You should have received a copy of the GNU General Public License 17 | ;along with this program; if not, write to the Free Software 18 | ;Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 | 20 | 21 | 22 | %include "macros.mac" 23 | 24 | EXTSYM tableAc,tableBc,tableCc,tableDc,tableEc 25 | EXTSYM tableFc,tableGc,tableHc,tableadc 26 | 27 | %include "cpu/65816dc.inc" 28 | %include "cpu/address.inc" 29 | %include "cpu/addrni.inc" 30 | %include "cpu/e65816c.inc" 31 | 32 | ; global variables 33 | 34 | SECTION .text 35 | 36 | eopINVALID 37 | ret 38 | -------------------------------------------------------------------------------- /linux/lib.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1997-2008 ZSNES Team ( zsKnight, _Demo_, pagefault, Nach ) 3 | 4 | http://www.zsnes.com 5 | http://sourceforge.net/projects/zsnes 6 | https://zsnes.bountysource.com 7 | 8 | This program is free software; you can redistribute it and/or 9 | modify it under the terms of the GNU General Public License 10 | version 2 as published by the Free Software Foundation. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program; if not, write to the Free Software 19 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 20 | */ 21 | 22 | #ifndef LIB_H 23 | #define LIB_H 24 | 25 | #include 26 | 27 | #ifndef HAVE_AT_FUNCTIONS 28 | 29 | #ifndef AT_FDCWD 30 | #define AT_FDCWD -2 31 | #endif 32 | 33 | #ifndef AT_SYMLINK_NOFOLLOW 34 | #define AT_SYMLINK_NOFOLLOW 1 35 | #endif 36 | 37 | int fstatat(int dirfd, const char* pathname, struct stat* buf, int flags); 38 | 39 | #endif 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /win/safelib.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1997-2008 ZSNES Team ( zsKnight, _Demo_, pagefault, Nach ) 3 | 4 | http://www.zsnes.com 5 | http://sourceforge.net/projects/zsnes 6 | https://zsnes.bountysource.com 7 | 8 | This program is free software; you can redistribute it and/or 9 | modify it under the terms of the GNU General Public License 10 | version 2 as published by the Free Software Foundation. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program; if not, write to the Free Software 19 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 20 | */ 21 | 22 | #ifndef SAFELIB_H 23 | #define SAFELIB_H 24 | 25 | #include 26 | 27 | #ifndef STDIN_FILENO 28 | #define STDIN_FILENO 0 29 | #endif 30 | 31 | #ifndef STDOUT_FILENO 32 | #define STDOUT_FILENO 1 33 | #endif 34 | 35 | FILE* safe_popen(char*, const char*); 36 | void safe_pclose(FILE* fp); 37 | 38 | #define popen safe_popen 39 | #define pclose safe_pclose 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /linux/audio.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1997-2008 ZSNES Team ( zsKnight, _Demo_, pagefault, Nach ) 3 | 4 | http://www.zsnes.com 5 | http://sourceforge.net/projects/zsnes 6 | https://zsnes.bountysource.com 7 | 8 | This program is free software; you can redistribute it and/or 9 | modify it under the terms of the GNU General Public License 10 | version 2 as published by the Free Software Foundation. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program; if not, write to the Free Software 19 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 20 | */ 21 | 22 | #ifndef AUDIO_H 23 | #define AUDIO_H 24 | 25 | void InitSampleControl(); 26 | int InitSound(); 27 | void DeinitSound(); 28 | 29 | #ifdef __LIBAO__ 30 | void SoundWrite_ao(); 31 | #endif 32 | void SoundWrite_sdl(); 33 | 34 | extern int SoundEnabled; 35 | extern unsigned char PrevStereoSound; 36 | extern unsigned int PrevSoundQuality; 37 | extern unsigned char sound_sdl; 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /debugger/zthread.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1997-2008 ZSNES Team ( zsKnight, _Demo_, pagefault, Nach ) 3 | 4 | http://www.zsnes.com 5 | http://sourceforge.net/projects/zsnes 6 | https://zsnes.bountysource.com 7 | 8 | This program is free software; you can redistribute it and/or 9 | modify it under the terms of the GNU General Public License 10 | version 2 as published by the Free Software Foundation. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program; if not, write to the Free Software 19 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 20 | */ 21 | 22 | #ifndef ZTHREAD_H 23 | #define ZTHREAD_H 24 | 25 | #include 26 | #include 27 | 28 | class ZSNESThread : public QThread { 29 | Q_OBJECT 30 | 31 | private: 32 | bool running; 33 | jmp_buf jump; 34 | 35 | public: 36 | ZSNESThread(); 37 | void run(); 38 | void done(); 39 | 40 | public slots: 41 | void prepare_close(); 42 | }; 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /cpu/c_65816d.c: -------------------------------------------------------------------------------- 1 | #include "c_65816d.h" 2 | #include "../chips/sa1regs.h" 3 | #include "../init.h" 4 | #include "s65816d.h" 5 | 6 | static void restoredl(u4 const edx) 7 | { 8 | u4 nz = 0; 9 | if (edx & 0x80) 10 | nz |= 0x00010000; // neg 11 | if (!(edx & 0x02)) 12 | nz |= 0x00000001; // no zero 13 | flagnz = nz; 14 | flagc = edx & 0x01 ? 0x000000FF : 0; // carry 15 | flago = edx & 0x40 ? 0x000000FF : 0; // v 16 | } 17 | 18 | void splitflags(u4 const edx) 19 | { 20 | asm volatile("call %P0" ::"X"(Ssplitflags), "d"(SA1RegP) 21 | : "cc", "memory"); 22 | restoredl(edx); 23 | } 24 | 25 | static u4 makedl(u4 edx) 26 | { 27 | edx &= 0xFFFFFF3C; 28 | if ((flagnz & 0x00018000) != 0) 29 | edx |= 0x80; // neg 30 | if ((flagnz & 0x0000FFFF) == 0) 31 | edx |= 0x02; // zero 32 | if ((flagc & 0x000000FF) != 0) 33 | edx |= 0x01; // carry 34 | if ((flago & 0x000000FF) != 0) 35 | edx |= 0x40; // v 36 | return edx; 37 | } 38 | 39 | u4 joinflags(u4 edx) 40 | { 41 | edx = makedl(edx); 42 | asm volatile("call %P1" 43 | : "+d"(SA1RegP) 44 | : "X"(Sjoinflags) 45 | : "cc", "memory"); 46 | return edx; 47 | } 48 | -------------------------------------------------------------------------------- /cpu/executec.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1997-2008 ZSNES Team ( zsKnight, _Demo_, pagefault, Nach ) 3 | 4 | http://www.zsnes.com 5 | http://sourceforge.net/projects/zsnes 6 | https://zsnes.bountysource.com 7 | 8 | This program is free software; you can redistribute it and/or 9 | modify it under the terms of the GNU General Public License 10 | version 2 as published by the Free Software Foundation. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program; if not, write to the Free Software 19 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 20 | */ 21 | 22 | #ifdef __UNIXSDL__ 23 | #include "../gblhdr.h" 24 | #else 25 | #include 26 | #include 27 | #include 28 | #include 29 | #endif 30 | #include "../gblvars.h" 31 | 32 | //Start of execute.asm goodness 33 | extern unsigned char t1cc; // not sure about this one 34 | extern unsigned short int nextframe; // framecounter for frameskipping 35 | 36 | void Game60hzcall() 37 | { 38 | t1cc++; 39 | nextframe++; 40 | } 41 | -------------------------------------------------------------------------------- /video/ntsc.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1997-2008 ZSNES Team ( zsKnight, _Demo_, pagefault, Nach ) 3 | 4 | http://www.zsnes.com 5 | http://sourceforge.net/projects/zsnes 6 | https://zsnes.bountysource.com 7 | 8 | This program is free software; you can redistribute it and/or 9 | modify it under the terms of the GNU General Public License 10 | version 2 as published by the Free Software Foundation. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program; if not, write to the Free Software 19 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 20 | */ 21 | 22 | /* NTSC video filter */ 23 | 24 | #ifndef NTSC_H 25 | #define NTSC_H 26 | 27 | #include "../types.h" 28 | #include "snes_ntsc/snes_ntsc.h" 29 | 30 | extern u1 NTSCPresetVar; /* 0 to 3 */ 31 | 32 | /* (Re)initialize filter with new NTSC settings above */ 33 | void NTSCFilterInit(); 34 | 35 | /* Draw current image to specified output pixels */ 36 | void NTSCFilterDraw(int out_width, int out_height, int out_pitch, unsigned char* rgb16_out); 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /win/vc_head/stdbool.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1997-2008 ZSNES Team ( zsKnight, _Demo_, pagefault, Nach ) 3 | 4 | http://www.zsnes.com 5 | http://sourceforge.net/projects/zsnes 6 | https://zsnes.bountysource.com 7 | 8 | This program is free software; you can redistribute it and/or 9 | modify it under the terms of the GNU General Public License 10 | version 2 as published by the Free Software Foundation. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program; if not, write to the Free Software 19 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 20 | */ 21 | 22 | #ifndef _MSC_STDBOOL_H_ 23 | #define _MSC_STDBOOL_H_ 24 | 25 | #ifndef __cplusplus 26 | 27 | #ifndef false 28 | #define false 0 29 | #endif 30 | 31 | #ifndef true 32 | #define true 1 33 | #endif 34 | 35 | typedef unsigned char bool; 36 | #else 37 | typedef bool _Bool; 38 | #endif 39 | 40 | #ifndef FALSE 41 | #define FALSE false 42 | #endif 43 | 44 | #ifndef TRUE 45 | #define TRUE true 46 | #endif 47 | 48 | #define __bool_true_false_are_defined 1 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /gui/c_gui.h: -------------------------------------------------------------------------------- 1 | #ifndef C_GUI_H 2 | #define C_GUI_H 3 | 4 | #include "../types.h" 5 | 6 | void GUIinit18_2hz(void); 7 | void GUIinit36_4hz(void); 8 | void GUI36hzcall(void); 9 | void StartGUI(void); 10 | void guimencodermsg(void); 11 | void guilamemsg(void); 12 | void guiprevideo(void); 13 | void guipostvideo(void); 14 | void CheckMenuItemHelp(u4 id); 15 | void GUITryMenuItem(void); 16 | void GUIProcStates(void); 17 | void GUIProcReset(void); 18 | void GUIUnBuffer(void); 19 | void GUISetPal(void); 20 | void convertnum(char* dst, u4 val); 21 | void converthex(char* dst, u4 val, u4 n /* bytes */); 22 | void guicheaterror(void); 23 | void DisplayBoxes(void); 24 | void DisplayMenu(void); 25 | 26 | void GUIBox3D(u4 const x1, u4 const y1, u4 const x2, u4 const y2); 27 | void GUIOuttextShadowed(u4 const x, u4 const y, char const* const text); 28 | 29 | u1* GetAnyPressedKey(void); 30 | 31 | extern u1 GUIFontData1[141][5]; 32 | extern u1 GUIwinptr; 33 | extern u1 MouseDis; 34 | extern u1 MousePRClick; 35 | extern u1 ShowTimer; 36 | extern u1 SnowVelDist[800]; 37 | extern u1 const GUIFontData[141][5]; 38 | extern u1 savecfgforce; 39 | extern u2 GUICPC[256]; 40 | extern u2 SnowData[800]; 41 | extern u4 GUIwinsizex[22]; 42 | extern u4 GUIwinsizey[22]; 43 | extern u4 MsgGiftLeft; 44 | extern u4 NumSnow; 45 | extern u4 SantaPos; 46 | extern u4 SnowTimer; 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /zloader.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1997-2008 ZSNES Team ( zsKnight, _Demo_, pagefault, Nach ) 3 | 4 | http://www.zsnes.com 5 | http://sourceforge.net/projects/zsnes 6 | https://zsnes.bountysource.com 7 | 8 | This program is free software; you can redistribute it and/or 9 | modify it under the terms of the GNU General Public License 10 | version 2 as published by the Free Software Foundation. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program; if not, write to the Free Software 19 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 20 | */ 21 | 22 | #ifndef ZLOADER_H 23 | #define ZLOADER_H 24 | 25 | struct backup_cmdline_vars { 26 | #ifdef __WIN32__ 27 | unsigned char _KitchenSync, _KitchenSyncPAL, _ForceRefreshRate, _SetRefreshRate; 28 | #endif 29 | unsigned short _joy_sensitivity; 30 | unsigned char _guioff; 31 | unsigned char _per2exec; 32 | unsigned char _HacksDisable; 33 | unsigned char _AllowMMX; 34 | }; 35 | 36 | extern struct backup_cmdline_vars saved_cmdline_vars; 37 | 38 | void swap_backup_vars(); 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /jma/lzma.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2002 Andrea Mazzoleni ( http://advancemame.sf.net ) 3 | Copyright (C) 2001-4 Igor Pavlov ( http://www.7-zip.org ) 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License version 2.1 as published by the Free Software Foundation. 8 | 9 | This library is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public 15 | License along with this library; if not, write to the Free Software 16 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 | */ 18 | 19 | #include "lzma.h" 20 | 21 | namespace NCompress { 22 | namespace NLZMA { 23 | 24 | UINT32 kDistStart[kDistTableSizeMax]; 25 | 26 | static class CConstInit { 27 | public: 28 | CConstInit() 29 | { 30 | UINT32 aStartValue = 0; 31 | int i; 32 | for (i = 0; i < kDistTableSizeMax; i++) { 33 | kDistStart[i] = aStartValue; 34 | aStartValue += (1 << kDistDirectBits[i]); 35 | } 36 | } 37 | } g_ConstInit; 38 | 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /win/lib.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1997-2008 ZSNES Team ( zsKnight, _Demo_, pagefault, Nach ) 3 | 4 | http://www.zsnes.com 5 | http://sourceforge.net/projects/zsnes 6 | https://zsnes.bountysource.com 7 | 8 | This program is free software; you can redistribute it and/or 9 | modify it under the terms of the GNU General Public License 10 | version 2 as published by the Free Software Foundation. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program; if not, write to the Free Software 19 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 20 | */ 21 | 22 | #include "lib.h" 23 | #include "../zpath.h" 24 | #include 25 | #include 26 | #include 27 | 28 | #define fullpath _fullpath 29 | 30 | // This file contains library functions that can be found on other OSs 31 | 32 | char* realpath(const char* path, char* resolved_path) 33 | { 34 | char* ret = 0; 35 | 36 | if (!path || !resolved_path) { 37 | errno = EINVAL; 38 | } else if (!access(path, F_OK)) { 39 | ret = fullpath(resolved_path, path, PATH_SIZE); 40 | } 41 | 42 | return (ret); 43 | } 44 | -------------------------------------------------------------------------------- /cpu/dma.asm: -------------------------------------------------------------------------------- 1 | ;Copyright (C) 1997-2008 ZSNES Team ( zsKnight, _Demo_, pagefault, Nach ) 2 | ; 3 | ;http://www.zsnes.com 4 | ;http://sourceforge.net/projects/zsnes 5 | ;https://zsnes.bountysource.com 6 | ; 7 | ;This program is free software; you can redistribute it and/or 8 | ;modify it under the terms of the GNU General Public License 9 | ;version 2 as published by the Free Software Foundation. 10 | ; 11 | ;This program is distributed in the hope that it will be useful, 12 | ;but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | ;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | ;GNU General Public License for more details. 15 | ; 16 | ;You should have received a copy of the GNU General Public License 17 | ;along with this program; if not, write to the Free Software 18 | ;Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 | 20 | %include "cpu/regs.mac" 21 | %include "cpu/regsw.mac" 22 | %include "macros.mac" 23 | 24 | EXTSYM c_reg420Bw 25 | EXTSYM c_reg420Cw 26 | 27 | ;******************************************************* 28 | ; Transfer DMA Inits & Transfers DMA 29 | ;******************************************************* 30 | ; DMA transfer register 31 | 32 | section .text 33 | 34 | ; DMA enable register 35 | ; use dmadata for input on dma 36 | NEWSYM reg420Bw 37 | ccallv c_reg420Bw, eax 38 | ret 39 | 40 | NEWSYM reg420Cw 41 | ccallv c_reg420Cw, eax 42 | ret 43 | -------------------------------------------------------------------------------- /video/procvid.h: -------------------------------------------------------------------------------- 1 | #ifndef PROCVID_H 2 | #define PROCVID_H 3 | 4 | #include "../types.h" 5 | 6 | // Processes & displays video 7 | void showvideo(void); 8 | 9 | u4 SwapMouseButtons(u4 buttons); 10 | 11 | void processmouse1(void); 12 | void processmouse2(void); 13 | 14 | void outputhex16(u2* buf, u1 val); 15 | 16 | void outputchar16b(u2* buf, u1 glyph); 17 | 18 | // Outputs String from text to buf 19 | void OutputGraphicString(u1* buf, char const* text); 20 | 21 | void OutputGraphicString16b(u2* buf, char const* text); 22 | 23 | void OutputGraphicString16b5x5(u2* buf, char const* text); 24 | 25 | void drawhline16b(u2* buf, u4 n, u2 colour); 26 | 27 | void drawvline16b(u2* buf, u4 n, u2 colour); 28 | 29 | void doveg(void); 30 | 31 | void dovegrest(void); 32 | 33 | // Copies buffer into video 34 | void copyvid(void); 35 | 36 | extern char const* Msgptr; // Pointer to message 37 | extern u1 FPSOn; 38 | extern u1 CPUOn; 39 | extern u1 ForceNonTransp; 40 | extern u1 csounddisable; 41 | extern u1 f3menuen; 42 | extern u1 mousexdir; 43 | extern u1 mouseydir; 44 | extern u1 prevbright; // previous brightness 45 | extern u1 ssautosw; 46 | extern u1 const ASCII2Font[256]; 47 | extern u2 mousebuttons; 48 | extern u2 mousexloc; 49 | extern u2 mousexpos; 50 | extern u2 mouseyloc; 51 | extern u2 mouseypos; 52 | extern u2 tempco0; 53 | extern u4 MessageOn; // Message On Countdown 54 | extern u4 MsgCount; // How long message will stay (PAL = 100) 55 | 56 | #endif 57 | -------------------------------------------------------------------------------- /debugger/zthread.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1997-2008 ZSNES Team ( zsKnight, _Demo_, pagefault, Nach ) 3 | 4 | http://www.zsnes.com 5 | http://sourceforge.net/projects/zsnes 6 | https://zsnes.bountysource.com 7 | 8 | This program is free software; you can redistribute it and/or 9 | modify it under the terms of the GNU General Public License 10 | version 2 as published by the Free Software Foundation. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program; if not, write to the Free Software 19 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 20 | */ 21 | 22 | #include "zthread.h" 23 | #include "load.h" 24 | 25 | extern "C" { 26 | void zstart(); 27 | } 28 | 29 | ZSNESThread::ZSNESThread() 30 | : running(false) 31 | { 32 | } 33 | 34 | void ZSNESThread::run() 35 | { 36 | if (!running) { 37 | if (!setjmp(jump)) { 38 | running = true; 39 | zstart(); 40 | } 41 | } 42 | } 43 | 44 | void ZSNESThread::done() 45 | { 46 | if (running) { 47 | running = false; 48 | longjmp(jump, 1); 49 | } 50 | } 51 | 52 | void ZSNESThread::prepare_close() 53 | { 54 | if (running) { 55 | debugger_quit = true; 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /gui/guiwindp.h: -------------------------------------------------------------------------------- 1 | #ifndef GUIWINDP_H 2 | #define GUIWINDP_H 3 | 4 | #include "../types.h" 5 | 6 | extern char CSDescDisplay[20]; 7 | extern char CSInputDisplay[12]; 8 | extern char* GUICustomResTextPtr[2]; 9 | extern char* GUIPathsTab1Ptr[4]; 10 | extern char* GUIPathsTab2Ptr[5]; 11 | extern char* GUIPathsTab3Ptr[4]; 12 | extern char** GUIMovieTextPtr; 13 | extern u1 CheatCompareValue; 14 | extern u1 CheatSearchStatus; 15 | extern u1 CheatWinMode; 16 | extern u1 GUICheatPosA; 17 | extern u1 GUICheatPosB; 18 | extern u1 GUIComboData[50]; 19 | extern u1 GUIComboLHorz; 20 | extern u1 GUIComboPNum; 21 | extern u1 GUIComboPos; 22 | extern u1 GUINumCombo; 23 | extern u4 CurCStextpos; 24 | extern u4 GUICSStA[3]; 25 | extern u4 GUICSStC[3]; 26 | extern u4 GUICStA[3]; 27 | extern u4 GUIComboKey; 28 | extern u4 GUIDumpingTab[2]; 29 | extern u4 GUIInputTabs[]; 30 | extern u4 GUIMovieTabs[]; 31 | extern u4 GUIOptionTabs[]; 32 | extern u4 GUIPathTabs[]; 33 | extern u4 GUIVideoTabs[]; 34 | extern u4 GUIVntscTab[]; 35 | extern u4 GUIccombcursloc; 36 | extern u4 GUIccomblcursloc; 37 | extern u4 GUIccombviewloc; 38 | extern u4 GUIcurrentcheatcursloc; 39 | extern u4 GUIcurrentcheatviewloc; 40 | extern u4 GUIcurrentcheatwin; 41 | extern u4 GUIcurrentchtsrccursloc; 42 | extern u4 GUIcurrentchtsrcviewloc; 43 | extern u4 NumCheatSrc; 44 | extern u4 NumCombo; 45 | extern u4 NumComboGlob; 46 | extern u4 NumComboLocl; 47 | extern u4 SrcMask[4]; 48 | extern u4 curaddrvalcs; 49 | extern u4 curentryval; 50 | extern u4 curvaluecs; 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /cpu/regsw.mac: -------------------------------------------------------------------------------- 1 | ;Copyright (C) 1997-2008 ZSNES Team ( zsKnight, _Demo_, pagefault, Nach ) 2 | ; 3 | ;http://www.zsnes.com 4 | ;http://sourceforge.net/projects/zsnes 5 | ;https://zsnes.bountysource.com 6 | ; 7 | ;This program is free software; you can redistribute it and/or 8 | ;modify it under the terms of the GNU General Public License 9 | ;version 2 as published by the Free Software Foundation. 10 | ; 11 | ;This program is distributed in the hope that it will be useful, 12 | ;but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | ;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | ;GNU General Public License for more details. 15 | ; 16 | ;You should have received a copy of the GNU General Public License 17 | ;along with this program; if not, write to the Free Software 18 | ;Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 | 20 | 21 | %define regptw(x) [regptwa - 0x2000 * 4 + x * 4] 22 | 23 | ;******************************************************* 24 | ; InitRegW Initializes Write Registers 25 | ;******************************************************* 26 | 27 | %macro reenablespc 0 28 | cmp dword[cycpbl],1000000h 29 | jb %%enspc 30 | mov dword[cycpbl],0 31 | test byte[curexecstate],02h 32 | jnz %%enspc 33 | or byte[curexecstate],02h 34 | push ebx 35 | xor ebx,ebx 36 | mov bl,dl 37 | mov edi,[tableadc+ebx*4] 38 | pop ebx 39 | %%enspc 40 | %endmacro 41 | 42 | %macro setregw 2 43 | mov regptw(%1), dword %2 44 | %endmacro 45 | -------------------------------------------------------------------------------- /debugger/ui.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1997-2008 ZSNES Team ( zsKnight, _Demo_, pagefault, Nach ) 3 | 4 | http://www.zsnes.com 5 | http://sourceforge.net/projects/zsnes 6 | https://zsnes.bountysource.com 7 | 8 | This program is free software; you can redistribute it and/or 9 | modify it under the terms of the GNU General Public License 10 | version 2 as published by the Free Software Foundation. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program; if not, write to the Free Software 19 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 20 | */ 21 | 22 | #ifndef UI_H 23 | #define UI_H 24 | 25 | #include 26 | #include 27 | 28 | #ifdef __UNIXSDL__ // I hate this hack -Nach 29 | #include "debugger/ui_debugger.h" 30 | #else 31 | #include "ui_debugger.h" 32 | #endif 33 | 34 | class QtDebugger : public QMainWindow { 35 | Q_OBJECT 36 | 37 | private: 38 | Ui::Debugger ui; 39 | 40 | static QtDebugger* singleton; 41 | 42 | QtDebugger(QWidget* parent); 43 | ~QtDebugger(); 44 | 45 | private slots: 46 | void on_pauseButton_clicked(); 47 | 48 | public: 49 | static void showQtDebugger(QWidget* parent); 50 | static void destroyQtDebugger(); 51 | }; 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /gui/guifuncs.h: -------------------------------------------------------------------------------- 1 | #ifndef GUIFUNCS_H 2 | #define GUIFUNCS_H 3 | 4 | #include 5 | 6 | #include "../types.h" 7 | 8 | bool Keep43Check(void); 9 | u4 GUILoadKeysNavigate(u1 gui_key_extended); 10 | void CheatCodeLoad(void); 11 | void CheatCodeSave(void); 12 | void GUIGenericJumpTo(void); 13 | void GUILoadData(void); 14 | void GUILoadKeysJumpTo(void); 15 | void GUIQuickLoadUpdate(void); 16 | void GUISaveVars(void); 17 | void GetLoadData(void); 18 | void GetMovieForcedLength(void); 19 | void LoadCheatSearchFile(void); 20 | void SaveCheatSearchFile(void); 21 | void SetMovieForcedLength(void); 22 | void dumpsound(void); 23 | void loadquickfname(u1 slot); 24 | 25 | char const* const* horizon_get(u4 distance); 26 | 27 | void GetCustomXY(void); 28 | void SetCustomXY(void); 29 | 30 | extern char GUICustomX[5]; 31 | extern char GUICustomY[5]; 32 | 33 | extern char GUIMovieForcedText[11]; 34 | extern char** d_names; // Directory Names 35 | extern char** selected_names; // Used to point to requested one 36 | extern s4 GUIJT_entries; 37 | extern s4 GUIJT_offset; 38 | extern s4 GUIJT_viewable; 39 | extern s4 GUIcurrentcursloc; // current cursor position (GUI) 40 | extern s4 GUIcurrentdircursloc; // current dir position (GUI) 41 | extern s4 GUIcurrentdirviewloc; // current directory position 42 | extern s4 GUIcurrentviewloc; // current file position 43 | extern s4 GUIdirentries; 44 | extern s4 GUIfileentries; 45 | extern s4* GUIJT_currentcursloc; 46 | extern s4* GUIJT_currentviewloc; 47 | extern u4 GUIcurrentfilewin; 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /win/gl_draw.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1997-2008 ZSNES Team ( zsKnight, _Demo_, pagefault, Nach ) 3 | 4 | http://www.zsnes.com 5 | http://sourceforge.net/projects/zsnes 6 | https://zsnes.bountysource.com 7 | 8 | This program is free software; you can redistribute it and/or 9 | modify it under the terms of the GNU General Public License 10 | version 2 as published by the Free Software Foundation. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program; if not, write to the Free Software 19 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 20 | */ 21 | 22 | #ifndef GL_DRAW_h 23 | #define GL_DRAW_h 1 24 | 25 | #include 26 | #include 27 | 28 | int gl_start(int width, int height, int req_depth, int FullScreen); 29 | void gl_end(); 30 | void gl_clearwin(); 31 | void gl_drawwin(); 32 | 33 | // FUNCTIONS 34 | extern void hq2x_16b(); 35 | 36 | // VIDEO VARIABLES 37 | extern int32_t SurfaceLocking; 38 | 39 | extern HWND hMainWindow; 40 | extern HDC hDC; 41 | extern HGLRC hRC; 42 | 43 | // OPENGL VARIABLES 44 | extern uint8_t GUIOn2; 45 | extern unsigned char* vidbuffer; 46 | extern uint8_t curblank; 47 | extern uint8_t GUIRESIZE[]; 48 | 49 | void gl_clearwin(); 50 | void gl_scanlines(); 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /debugger/ui.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1997-2008 ZSNES Team ( zsKnight, _Demo_, pagefault, Nach ) 3 | 4 | http://www.zsnes.com 5 | http://sourceforge.net/projects/zsnes 6 | https://zsnes.bountysource.com 7 | 8 | This program is free software; you can redistribute it and/or 9 | modify it under the terms of the GNU General Public License 10 | version 2 as published by the Free Software Foundation. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program; if not, write to the Free Software 19 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 20 | */ 21 | 22 | #include 23 | 24 | #include "ui.h" 25 | 26 | QtDebugger::QtDebugger(QWidget* parent) 27 | : QMainWindow(parent) 28 | { 29 | ui.setupUi(this); 30 | } 31 | 32 | QtDebugger::~QtDebugger() 33 | { 34 | } 35 | 36 | QtDebugger* QtDebugger::singleton = 0; 37 | 38 | void QtDebugger::showQtDebugger(QWidget* parent) 39 | { 40 | if (!singleton) { 41 | singleton = new QtDebugger(parent); 42 | } 43 | singleton->show(); 44 | } 45 | 46 | void QtDebugger::destroyQtDebugger() 47 | { 48 | if (singleton) { 49 | delete singleton; 50 | singleton = 0; 51 | } 52 | } 53 | 54 | extern "C" { 55 | extern unsigned char EMUPause; 56 | } 57 | 58 | void QtDebugger::on_pauseButton_clicked() 59 | { 60 | EMUPause ^= 1; 61 | } 62 | -------------------------------------------------------------------------------- /linux/lib.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1997-2008 ZSNES Team ( zsKnight, _Demo_, pagefault, Nach ) 3 | 4 | http://www.zsnes.com 5 | http://sourceforge.net/projects/zsnes 6 | https://zsnes.bountysource.com 7 | 8 | This program is free software; you can redistribute it and/or 9 | modify it under the terms of the GNU General Public License 10 | version 2 as published by the Free Software Foundation. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program; if not, write to the Free Software 19 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 20 | */ 21 | 22 | #include 23 | #include 24 | #include 25 | #include 26 | 27 | #include "lib.h" 28 | 29 | #ifndef HAVE_AT_FUNCTIONS 30 | 31 | int fstatat(int dirfd, const char* pathname, struct stat* buf, int flags) 32 | { 33 | int success = -1; 34 | 35 | if ((!flags || (flags == AT_SYMLINK_NOFOLLOW))) { 36 | int cwdfd = -1; 37 | if ((dirfd == AT_FDCWD) || (pathname && (*pathname == '/')) || (((cwdfd = open(".", O_RDONLY)) != -1) && !fchdir(dirfd))) { 38 | success = (!flags) ? stat(pathname, buf) : lstat(pathname, buf); 39 | } 40 | 41 | if (cwdfd != -1) { 42 | fchdir(cwdfd); 43 | close(cwdfd); 44 | } 45 | } else { 46 | errno = EINVAL; 47 | } 48 | 49 | return (success); 50 | } 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /tools/cver.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2007-2008 Nach ( http://www.zsnes.com ) 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | version 2 as published by the Free Software Foundation. 7 | 8 | This program is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | GNU General Public License for more details. 12 | 13 | You should have received a copy of the GNU General Public License 14 | along with this program; if not, write to the Free Software 15 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 16 | */ 17 | 18 | #include 19 | 20 | #if defined(__i386__) || defined(_M_IX86) 21 | static int x86_32 = 1; 22 | #else 23 | static int x86_32 = 0; 24 | #endif 25 | 26 | #if defined(__x86_64__) || defined(_M_X64) 27 | static int x86_64 = 1; 28 | #else 29 | static int x86_64 = 0; 30 | #endif 31 | 32 | #ifdef __STDC_VERSION__ 33 | static int stdcv = __STDC_VERSION__; 34 | #else 35 | static int stdcv = 198900; 36 | #endif 37 | 38 | int main() 39 | { 40 | #ifdef __GNUC__ 41 | printf("Compiler: GCC\nMajor: %u\nMinor: %u\nMicro: %u\nVersion: %s\n", 42 | __GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__, __VERSION__); 43 | #elif defined(_MSC_VER) 44 | printf("Compiler: MSVC\nMajor: %u\nMinor: %u\nVersion: %u\n", 45 | _MSC_VER / 100, _MSC_VER % 100, _MSC_VER); 46 | #endif 47 | printf("C99: %s\nx86-32: %s\nx86-64: %s\n", (stdcv >= 199901L) ? "Yes" : "No", x86_32 ? "Yes" : "No", x86_64 ? "Yes" : "No"); 48 | fflush(stdout); 49 | return (0); 50 | } 51 | -------------------------------------------------------------------------------- /win/confloc.psr: -------------------------------------------------------------------------------- 1 | @ This allows you to define where ZSNES settings are stored 2 | @ and enables/disables multiuser support. 3 | @ 4 | @ 0 = User's directory contains ZSNES config files. (multiuser) 5 | @ 1 = ZSNES directory contains ZSNES config files. (no multiuser) 6 | @ 7 | @ On 9x system that all users don't have seperate profiles, 8 | @ the user's directory will be: 9 | @ \Application Data\ZSNES 10 | @ 11 | @ On 9x systems that are configured to use seperate profiles, 12 | @ the user's directory will be: 13 | @ \Profiles\\Application Data\ZSNES 14 | @ 15 | @ On older NT systems, the user's directory will be: 16 | @ C:\Documents and Settings\\Application Data\ZSNES 17 | @ 18 | @ On NT 6+ (Vista) the user's directory will be: 19 | @ C:\Users\\Saved Games\ZSNES 20 | @ Or if that fails for some reason, it will be: 21 | @ C:\Users\\AppData\Roaming\ZSNES 22 | @ 23 | @ Note: all the default locations listed above can be changed 24 | @ in Windows using software such as TweakUI. 25 | @ 26 | @ 27 | @ If you plan on putting ZSNES on a CD, it is advisable to 28 | @ enable multiuser here so you can save your settings on 29 | @ any machine you use the CD in. 30 | @ 31 | @ If you want different copies of ZSNES tweaked for different 32 | @ things, you can disable multiuser support and each directory 33 | @ with ZSNES will contain it's own configuration settings. 34 | @ 35 | @ If one user of your PC would like to use the User's directory 36 | @ for settings and another wants the ZSNES directory, just 37 | @ copy ZSNES into two different directories and edit this file 38 | @ appropriatly in both of them. 39 | @ 40 | zsnesw_config_location db -1 41 | -------------------------------------------------------------------------------- /ui.h: -------------------------------------------------------------------------------- 1 | #ifndef UI_H 2 | #define UI_H 3 | 4 | #include 5 | 6 | #include "types.h" 7 | 8 | #define REGPTR(x) (regptra[(x) - 0x2000]) 9 | #define REGPTW(x) (regptwa[(x) - 0x2000]) 10 | 11 | void cycleinputdevice1(void); 12 | bool cycleinputdevice2(void); 13 | 14 | void DisplayBatteryStatus(void); 15 | 16 | extern eop* dspRptr[256]; 17 | extern eop* dspWptr[256]; 18 | extern eop* regptra[0x3000]; 19 | extern eop* regptwa[0x3000]; 20 | extern u1 DSPDisable; // Disable DSP emulation 21 | extern u1 MusicVol; 22 | extern u1 V8Mode; // Vegetable mode! =) (Greyscale mode) 23 | extern u1 cbitmode; // bit mode, 0=8bit, 1=16bit 24 | extern u1 debugdisble; // debugger disable. 0 = no, 1 = yes 25 | extern u1 gammalevel16b; // gamma level (16-bit engine) 26 | extern u1 mode7tab[65536]; 27 | extern u1 newgfx16b; 28 | extern u1 romispal; // 0 = NTSC, 1 = PAL 29 | extern u1* romdata; // rom data (4MB = 4194304) 30 | extern u1* sfxramdata; // SuperFX Ram Data 31 | extern u1* spcBuffera; 32 | extern u1* spritetablea; 33 | extern u1* sram; // sram = 65536 * 2 = 131072 34 | extern u1* vbufdptr; 35 | extern u1* vcache2b; // 2-bit video cache 36 | extern u1* vcache4b; // 4-bit video cache 37 | extern u1* vcache8b; // 8-bit video cache 38 | extern u1* vidbuffer; // video buffer (1024x239 = 244736) 39 | extern u1* vidbufferofsa; // offset 1 40 | extern u1* vidbufferofsb; // offset 2 41 | extern u1* vram; // vram = 65536 42 | extern u1* wramdata; // stack (64K = 65536) 43 | extern u2 VolumeConvTable[32768]; 44 | extern u2 fulladdtab[65536]; 45 | extern u2 selcA000; 46 | 47 | void MultiMouseProcess(void); 48 | 49 | extern s4 MouseCount; 50 | extern u1 mouse; 51 | extern u2 MouseButtons[2]; 52 | extern u2 MouseMoveX[2]; 53 | extern u2 MouseMoveY[2]; 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /cpu/regs.mac: -------------------------------------------------------------------------------- 1 | ;Copyright (C) 1997-2008 ZSNES Team ( zsKnight, _Demo_, pagefault, Nach ) 2 | ; 3 | ;http://www.zsnes.com 4 | ;http://sourceforge.net/projects/zsnes 5 | ;https://zsnes.bountysource.com 6 | ; 7 | ;This program is free software; you can redistribute it and/or 8 | ;modify it under the terms of the GNU General Public License 9 | ;version 2 as published by the Free Software Foundation. 10 | ; 11 | ;This program is distributed in the hope that it will be useful, 12 | ;but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | ;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | ;GNU General Public License for more details. 15 | ; 16 | ;You should have received a copy of the GNU General Public License 17 | ;along with this program; if not, write to the Free Software 18 | ;Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 | 20 | 21 | 22 | %define regptr(x) [regptra - 0x2000 * 4 + x * 4] 23 | 24 | ;******************************************************* 25 | ; InitReg Initializes Registers 26 | ;******************************************************* 27 | 28 | %macro setreg 2 29 | mov regptr(%1), dword %2 30 | %endmacro 31 | 32 | ;******************************************************* 33 | ; Registers Note : Remember to restore AH, ECX, & DX 34 | ;******************************************************* 35 | 36 | %macro checkmultchange 0 37 | ; execute multiplication 38 | cmp byte[multchange],0 39 | je .nomult 40 | push edx 41 | push eax 42 | xor bh,bh 43 | mov bl,[mode7B+1] 44 | mov ax,[mode7A] 45 | test bl,80h 46 | jz .noneg 47 | mov bh,0FFh 48 | .noneg 49 | imul bx 50 | mov [compmult],ax 51 | mov [compmult+2],dl 52 | pop eax 53 | pop edx 54 | mov byte[multchange],0 55 | .nomult 56 | %endmacro 57 | -------------------------------------------------------------------------------- /gui/c_guiwindp.h: -------------------------------------------------------------------------------- 1 | #ifndef C_GUIWINDP_H 2 | #define C_GUIWINDP_H 3 | 4 | void DisplayGUIAbout(void); // Displays the About Box 5 | void DisplayGUIAddOns(void); // Select Special Controllers 6 | void DisplayGUICheat(void); // Add/Browse Cheats menu 7 | void DisplayGUIChipConfig(void); 8 | void DisplayGUIChoseSave(void); // Pick Save State 9 | void DisplayGUICombo(void); 10 | void DisplayGUIInput(void); // Player Select, Joystick/keyboard Type List, Button Assignments 11 | void DisplayGUILoad(void); 12 | void DisplayGUIMovies(void); // Movie Record/Playback options 13 | void DisplayGUIOption(void); // Emu Options 14 | void DisplayGUIOptns(void); // GUI Options 15 | void DisplayGUIPaths(void); 16 | void DisplayGUIReset(void); // Reset Confirmation 17 | void DisplayGUISave(void); // Save & Rewind options/Hotkeys 18 | void DisplayGUISearch(void); 19 | void DisplayGUISound(void); // Sound Related Options 20 | void DisplayGUISpeed(void); // Speed Options 21 | void DisplayGUIStates(void); // Save/Load State Confirmation 22 | void DisplayGUIVideo(void); 23 | void DisplayGameOptns(void); // Misc Key Window 24 | void DisplayNetOptns(void); 25 | 26 | extern char CMovieExt; 27 | extern char GUICheatTextZ1[]; 28 | extern char GUICheatTextZ2[]; 29 | extern char GUIChoseSaveText2[2]; 30 | extern char GUIChoseSlotTextX[2]; 31 | extern char GUIComboTextH[21]; 32 | extern char GUILoadTextA[38]; 33 | extern u1 GUIFreshInputSelect; 34 | extern u1 GUILoadPos; 35 | extern u1 GUIStatesText5; 36 | extern u1 GUIWincoladd; 37 | extern u1 ShowMMXSupport; 38 | extern u1* const GUIInputRefP[]; 39 | extern u4 GUIIStA[3]; 40 | extern u4 GUILStA[3]; 41 | extern u4 GUILStB[3]; 42 | extern u4 GUIVStA[3]; 43 | extern u4 GUIcurrentinputcursloc; 44 | extern u4 GUIcurrentinputviewloc; 45 | extern u4 GUIcurrentvideocursloc; 46 | extern u4 GUIcurrentvideoviewloc; 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /doc/styles/shared.css: -------------------------------------------------------------------------------- 1 | /* Shared styles. 2 | This stylesheet contains styling information for some tags commonly used in the zdocs. These generally aren't page-specific. */ 3 | 4 | /* ALL PROPERTIES ARE ALPHABETIZED!!! KEEP THEM THAT WAY!!! */ 5 | 6 | #content table { 7 | border: 1px solid black; 8 | border-collapse: collapse; 9 | margin-bottom: 1em; 10 | margin-top: 1em; 11 | } 12 | 13 | #content th { 14 | border-style: solid; 15 | border-width: 1px 1px 2px 1px; 16 | font-weight: bold; 17 | padding-left: 1em; 18 | padding-right: 1em; 19 | } 20 | 21 | #content td { 22 | border: 1px dotted black; 23 | padding-right: 0.3em; 24 | padding-left: 0.3em; 25 | } 26 | 27 | #content table.argument_list td{ 28 | border-style: dotted none dotted none; 29 | } 30 | 31 | #content .gui 32 | { 33 | font-family: "Lucida Console", "Courier New", Courier, monospace; 34 | font-weight: bold; 35 | } 36 | 37 | #content strong.gui_windows { 38 | background-color: #d4d0c8; 39 | color: black; 40 | font-family: Tahoma, sans-serif; 41 | font-size: 8pt; 42 | font-weight: normal; 43 | } 44 | 45 | #content em.game /* Just a reminder that you can change the text style of a game name. */ 46 | {} 47 | 48 | #content code { 49 | background-color: inherit; 50 | color: blue; 51 | font-family: "Lucida Console", "Courier New", Courier, monospace; 52 | } 53 | 54 | #content code.file /* Just a reminder that you can change the style of filenames. */ 55 | {} 56 | 57 | #content kbd { 58 | background-color: black; 59 | color: white; 60 | font-family: "Lucida Console", "Courier New", Courier, monospace; 61 | } 62 | 63 | #content kbd.key 64 | { 65 | background-color: white; 66 | border: solid 2px black; 67 | color: black; 68 | padding-left: 1px; 69 | padding-right: 1px; 70 | } 71 | -------------------------------------------------------------------------------- /html/styles/shared.css: -------------------------------------------------------------------------------- 1 | /* Shared styles. 2 | This stylesheet contains styling information for some tags commonly used in the zdocs. These generally aren't page-specific. */ 3 | 4 | /* ALL PROPERTIES ARE ALPHABETIZED!!! KEEP THEM THAT WAY!!! */ 5 | 6 | #content table { 7 | border: 1px solid black; 8 | border-collapse: collapse; 9 | margin-bottom: 1em; 10 | margin-top: 1em; 11 | } 12 | 13 | #content th { 14 | border-style: solid; 15 | border-width: 1px 1px 2px 1px; 16 | font-weight: bold; 17 | padding-left: 1em; 18 | padding-right: 1em; 19 | } 20 | 21 | #content td { 22 | border: 1px dotted black; 23 | padding-right: 0.3em; 24 | padding-left: 0.3em; 25 | } 26 | 27 | #content table.argument_list td{ 28 | border-style: dotted none dotted none; 29 | } 30 | 31 | #content .gui 32 | { 33 | font-family: "Lucida Console", "Courier New", Courier, monospace; 34 | font-weight: bold; 35 | } 36 | 37 | #content strong.gui_windows { 38 | background-color: #d4d0c8; 39 | color: black; 40 | font-family: Tahoma, sans-serif; 41 | font-size: 8pt; 42 | font-weight: normal; 43 | } 44 | 45 | #content em.game /* Just a reminder that you can change the text style of a game name. */ 46 | {} 47 | 48 | #content code { 49 | background-color: inherit; 50 | color: blue; 51 | font-family: "Lucida Console", "Courier New", Courier, monospace; 52 | } 53 | 54 | #content code.file /* Just a reminder that you can change the style of filenames. */ 55 | {} 56 | 57 | #content kbd { 58 | background-color: black; 59 | color: white; 60 | font-family: "Lucida Console", "Courier New", Courier, monospace; 61 | } 62 | 63 | #content kbd.key 64 | { 65 | background-color: white; 66 | border: solid 2px black; 67 | color: black; 68 | padding-left: 1px; 69 | padding-right: 1px; 70 | } 71 | -------------------------------------------------------------------------------- /ver.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1997-2008 ZSNES Team ( zsKnight, _Demo_, pagefault, Nach ) 3 | 4 | http://www.zsnes.com 5 | http://sourceforge.net/projects/zsnes 6 | https://zsnes.bountysource.com 7 | 8 | This program is free software; you can redistribute it and/or 9 | modify it under the terms of the GNU General Public License 10 | version 2 as published by the Free Software Foundation. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program; if not, write to the Free Software 19 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 20 | */ 21 | 22 | #include 23 | #include 24 | 25 | char* VERSION_STR; 26 | char* VERSION_DATE = __DATE__; 27 | 28 | #ifdef __WIN32__ 29 | char* VERSION_PORT = "WIN"; 30 | #elif defined(__MACOSX__) 31 | char* VERSION_PORT = "SDL - Mac OS X"; 32 | #elif defined(__BSDSDL__) 33 | char* VERSION_PORT = "SDL - BSD"; 34 | #elif defined(__BEOS__) 35 | char* VERSION_PORT = "SDL - BeOS"; 36 | #elif defined(__linux__) 37 | char* VERSION_PORT = "SDL - Linux"; 38 | #else 39 | char* VERSION_PORT = "SDL - Unknown"; 40 | #endif 41 | 42 | // Place compilation date at the end of VERSION_STR 43 | void placedate(void) 44 | { 45 | strcpy(VERSION_STR + strlen(VERSION_STR) - strlen(VERSION_DATE), VERSION_DATE); 46 | } 47 | 48 | // Place compilation time at the end of VERSION_STR 49 | void placetime() 50 | { 51 | strcpy(VERSION_STR + strlen(VERSION_STR) - strlen(__TIME__), __TIME__); 52 | } 53 | 54 | unsigned int version_hash() 55 | { 56 | return (~crc32(0, (const unsigned char*)__DATE__, strlen(__DATE__))); 57 | } 58 | -------------------------------------------------------------------------------- /linux/io.github.xyproto.zsnes.metainfo.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | io.github.xyproto.zsnes 5 | ZSNES 6 | Super Nintendo emulator 7 | Alexander F. Rødseth 8 | io.github.xyproto.zsnes.desktop 9 | CC0-1.0 10 | GPL-2.0 11 | 12 |

ZSNES is a classical SNES Emulator. Its development started 1998 and is was one of the most used SNES Emulators for years.

13 |

Today you should use ZSNES only for historical and nostalgia reasons, as there are Emulators out there which provide more Features and a better Game compatibility.

14 |
15 | 16 | 17 | https://upload.wikimedia.org/wikipedia/commons/5/5d/ZSNES.jpg 18 | 19 | 20 | 21 | 22 | 23 | 24 | https://github.com/xyproto/zsnes 25 | https://github.com/xyproto/zsnes/issues 26 | 27 | Game 28 | Emulator 29 | 30 | 31 | pointing 32 | keyboard 33 | gamepad 34 | 35 | 36 | 37 | zsnes 38 | application/vnd.nintendo.snes.rom 39 | application/x-snes-rom 40 | 41 |
42 | -------------------------------------------------------------------------------- /debugger/load.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1997-2008 ZSNES Team ( zsKnight, _Demo_, pagefault, Nach ) 3 | 4 | http://www.zsnes.com 5 | http://sourceforge.net/projects/zsnes 6 | https://zsnes.bountysource.com 7 | 8 | This program is free software; you can redistribute it and/or 9 | modify it under the terms of the GNU General Public License 10 | version 2 as published by the Free Software Foundation. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program; if not, write to the Free Software 19 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 20 | */ 21 | 22 | #include "load.h" 23 | #include "ui.h" 24 | #include "zthread.h" 25 | #include 26 | 27 | static bool debugger_running = false; 28 | static int app_exit_num = 0; 29 | static ZSNESThread zthread; 30 | 31 | unsigned char debugger_quit = false; 32 | 33 | void debug_main() 34 | { 35 | if (!debugger_running) { 36 | debugger_running = true; 37 | 38 | int argc = 1; 39 | char* argv[] = { "debug" }; 40 | QApplication app(argc, argv); 41 | QObject::connect(&app, SIGNAL(lastWindowClosed()), &zthread, SLOT(prepare_close())); 42 | 43 | QtDebugger::showQtDebugger(0); 44 | 45 | zthread.start(); 46 | app.exec(); 47 | zthread.wait(); 48 | QtDebugger::destroyQtDebugger(); 49 | exit(app_exit_num); 50 | } 51 | } 52 | 53 | void debug_exit(int exit_num) 54 | { 55 | if (debugger_running) { 56 | app_exit_num = exit_num; 57 | qApp->quit(); 58 | zthread.done(); 59 | } else { 60 | exit(exit_num); 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /video/makevid.h: -------------------------------------------------------------------------------- 1 | #ifndef MAKEVID_H 2 | #define MAKEVID_H 3 | 4 | #include "../macros.h" 5 | #include "../types.h" 6 | 7 | typedef struct SpriteInfo { 8 | u2 x; 9 | u1* obj __attribute__((packed, aligned(2))); // XXX unaligned 10 | u1 pal; 11 | u1 status; 12 | } SpriteInfo; 13 | STATIC_ASSERT(sizeof(SpriteInfo) == 8); 14 | 15 | extern void dualstartprocess(); 16 | extern void makedualwinsp(); 17 | 18 | extern SpriteInfo* currentobjptr; 19 | extern u1 a16x16xinc; 20 | extern u1 a16x16yinc; 21 | extern u1 alreadydrawn; 22 | extern u1 bg3high2; 23 | extern u1 bgcoloradder; 24 | extern u1 bshifter; 25 | extern u1 csprbit; 26 | extern u1 csprprlft; 27 | extern u1 curbgnum; 28 | extern u1 curbgpr; // 00h = low priority, 20h = high priority 29 | extern u1 curmosaicsz; 30 | extern u1 cwinenabm; 31 | extern u1 drawn; 32 | extern u1 dualwinbg; 33 | extern u1 dualwinsp; 34 | extern u1 extbgdone; 35 | extern u1 hirestiledat[256]; 36 | extern u1 maxbr; 37 | extern u1 pwinbgenab; 38 | extern u1 pwinspenab; 39 | extern u1 res512switch; 40 | extern u1 temp; 41 | extern u1 winon; 42 | extern u1 winonbtype; 43 | extern u1 winonsp; 44 | extern u1 winonstype; 45 | extern u1* bg1cachloc[4]; 46 | extern u1* bgofwptr; 47 | extern u1* cursprloc; 48 | extern u1* curvidoffset; 49 | extern u1* cwinptr; 50 | extern u1* dwinptrproc; 51 | extern u1* tempcach; // points to cached memory 52 | extern u1* winptrref; 53 | extern u2 MosaicYAdder[16]; 54 | extern u2 curtileptr; 55 | extern u2* bg1tdabloc[4]; 56 | extern u2* bg1tdatloc[4]; 57 | extern u2* temptile; // points to the secondary video pointer 58 | extern u4 bg1vbufloc[4]; 59 | extern u4 bg1xposloc[4]; 60 | extern u4 bg1yaddval[4]; 61 | extern u4 bgptr; 62 | extern u4 bgptrc; 63 | extern u4 bgptrd; 64 | extern u4 bgptrx1; 65 | extern u4 bgptrx2; 66 | extern u4 bgsubby; 67 | extern u4 pwinbgtype; 68 | extern u4 pwinsptype; 69 | extern u4 yadder; 70 | extern u4 yrevadder; 71 | 72 | #endif 73 | -------------------------------------------------------------------------------- /jma/zsnesjma.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2004-2008 NSRT Team ( http://nsrt.edgeemu.com ) 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | version 2 as published by the Free Software Foundation. 7 | 8 | This program is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | GNU General Public License for more details. 12 | 13 | You should have received a copy of the GNU General Public License 14 | along with this program; if not, write to the Free Software 15 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 16 | */ 17 | 18 | #include 19 | using namespace std; 20 | 21 | #include "jma.h" 22 | #include "zsnesjma.h" 23 | 24 | extern "C" { 25 | extern unsigned char* romdata; 26 | extern unsigned int curromspace; 27 | extern unsigned int maxromspace; 28 | } 29 | 30 | void load_jma_file(const char* filename) 31 | { 32 | try { 33 | JMA::jma_open JMAFile(filename); 34 | vector file_info = JMAFile.get_files_info(); 35 | 36 | string our_file_name; 37 | size_t our_file_size = 0; 38 | 39 | for (vector::iterator i = file_info.begin(); i != file_info.end(); i++) { 40 | // Check for valid ROM based on size 41 | if ((i->size <= maxromspace + 512) && (i->size > our_file_size)) { 42 | our_file_name = i->name; 43 | our_file_size = i->size; 44 | } 45 | } 46 | 47 | if (!our_file_size) { 48 | return; 49 | } 50 | 51 | JMAFile.extract_file(our_file_name, romdata); 52 | 53 | curromspace = our_file_size; 54 | } catch (JMA::jma_errors jma_error) { 55 | // No need to do anything 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /tools/strutil.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2005-2008 Nach, grinvader ( http://www.zsnes.com ) 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | version 2 as published by the Free Software Foundation. 7 | 8 | This program is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | GNU General Public License for more details. 12 | 13 | You should have received a copy of the GNU General Public License 14 | along with this program; if not, write to the Free Software 15 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 16 | */ 17 | 18 | /* 19 | This is part of a toolkit used to assist in ZSNES development 20 | */ 21 | 22 | #ifndef STRUTIL_H 23 | #define STRUTIL_H 24 | 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | 31 | struct ci_char_traits : public std::char_traits { 32 | static bool eq(char c1, char c2) { return (tolower(c1) == tolower(c2)); } 33 | static bool ne(char c1, char c2) { return (tolower(c1) != tolower(c2)); } 34 | static bool lt(char c1, char c2) { return (tolower(c1) < tolower(c2)); } 35 | static int compare(const char* s1, const char* s2, size_t n) { return (strncasecmp(s1, s2, n)); } 36 | 37 | static const char* find(const char* s, int n, char a) 38 | { 39 | while (n-- > 0 && tolower(*s) != tolower(a)) { 40 | s++; 41 | } 42 | return (n >= 0 ? s : 0); 43 | } 44 | }; 45 | 46 | typedef std::basic_string string_ci; 47 | 48 | void Tokenize(const std::string&, std::vector&, const std::string&); 49 | void Tokenize(const string_ci&, std::vector&, const string_ci&); 50 | bool all_whitespace(const char*); 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /gui/gui.h: -------------------------------------------------------------------------------- 1 | #ifndef GUI_H 2 | #define GUI_H 3 | 4 | #include "../macros.h" 5 | #include "../types.h" 6 | 7 | typedef struct ComboData { 8 | char name[20]; 9 | u1 combo[42]; 10 | u2 key; 11 | u1 player; 12 | u1 ff; 13 | } ComboData; 14 | STATIC_ASSERT(sizeof(ComboData) == 66); 15 | 16 | extern ComboData CombinDataGlob[50]; 17 | extern ComboData CombinDataLocl[50]; 18 | 19 | extern char GUIPrevMenuData[]; 20 | extern s4 GUIDClCEntry; 21 | extern u1 CheatOn; 22 | extern u1 CurPalSelect; 23 | extern u1 EEgg; 24 | extern u1 ForceHiLoROM; 25 | extern u1 ForceROMTiming; 26 | extern u1 GUICBHold2; 27 | extern u1 GUICBHold; 28 | extern u1 GUICCFlash; 29 | extern u1 GUICResetPos; 30 | extern u1 GUICStatePos; 31 | extern u1 GUIHold; 32 | extern u1 GUILDFlash; 33 | extern u1 GUIOn2; 34 | extern u1 GUIOn; 35 | extern u1 GUIQuit; 36 | extern u1 GUIReset; 37 | extern u1 GUIcmenupos; 38 | extern u1 GUIcrowpos; 39 | extern u1 GUIescpress; 40 | extern u1 GUIpclicked; 41 | extern u1 GUIpmenupos; 42 | extern u1 GUIwinactiv[]; 43 | extern u1 GUIwinorder[22]; 44 | extern u1 cheatdata[28 * 255 + 56]; 45 | extern u1 cplayernum; 46 | extern u1 cwindrawn; 47 | extern u1* GUICYLocPtr; 48 | extern u2 GUImouseposx; 49 | extern u2 GUImouseposy; 50 | extern u4 CalibXmax209; 51 | extern u4 CalibXmax; 52 | extern u4 CalibXmin209; 53 | extern u4 CalibXmin; 54 | extern u4 CalibYmax209; 55 | extern u4 CalibYmax; 56 | extern u4 CalibYmin209; 57 | extern u4 CalibYmin; 58 | extern u4 GUICHold; 59 | extern u4 GUIDClCWin; 60 | extern u4 GUIDClickTL; 61 | extern u4 GUIHoldXlimL; 62 | extern u4 GUIHoldXlimR; 63 | extern u4 GUIHoldYlim; 64 | extern u4 GUIHoldYlimR; 65 | extern u4 GUIHoldx; 66 | extern u4 GUIHoldxm; 67 | extern u4 GUIHoldy; 68 | extern u4 GUIHoldym; 69 | extern u4 GUIMenuD; 70 | extern u4 GUIMenuL; 71 | extern u4 GUIMenuR; 72 | extern u4 GUIScrolTim1; 73 | extern u4 GUIScrolTim2; 74 | extern u4 NumCheats; 75 | extern u4 cloadmaxlen; 76 | 77 | #endif 78 | -------------------------------------------------------------------------------- /tools/fileutil.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2005-2008 Nach, grinvader ( http://www.zsnes.com ) 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | version 2 as published by the Free Software Foundation. 7 | 8 | This program is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | GNU General Public License for more details. 12 | 13 | You should have received a copy of the GNU General Public License 14 | along with this program; if not, write to the Free Software 15 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 16 | */ 17 | 18 | /* 19 | This is part of a toolkit used to assist in ZSNES development 20 | */ 21 | 22 | #ifndef FILEUTIL_H 23 | #define FILEUTIL_H 24 | 25 | #include 26 | #include 27 | 28 | void parse_dir(const char*, void (*func)(const char*, struct stat&)); 29 | bool parse_path(const char*, void (*func)(const char*, struct stat&)); 30 | 31 | inline bool extension_match(const char* filename, const char* ext) 32 | { 33 | size_t filen_len = strlen(filename); 34 | size_t ext_len = strlen(ext); 35 | return ((filen_len > ext_len) && !strcasecmp(filename + filen_len - ext_len, ext)); 36 | } 37 | 38 | inline bool is_c_file(const char* filename) 39 | { 40 | return (extension_match(filename, ".c") || extension_match(filename, ".h")); 41 | } 42 | 43 | inline bool is_cpp_file(const char* filename) 44 | { 45 | return (extension_match(filename, ".cpp")); 46 | } 47 | 48 | inline bool is_psr_file(const char* filename) 49 | { 50 | return (extension_match(filename, ".psr")); 51 | } 52 | 53 | inline bool is_asm_file(const char* filename) 54 | { 55 | return (extension_match(filename, ".asm") || extension_match(filename, ".inc") || extension_match(filename, ".mac")); 56 | } 57 | 58 | #endif 59 | -------------------------------------------------------------------------------- /chips/dsp3proc.asm: -------------------------------------------------------------------------------- 1 | ;Copyright (C) 1997-2008 ZSNES Team ( zsKnight, _Demo_, pagefault, Nach ) 2 | ; 3 | ;http://www.zsnes.com 4 | ;http://sourceforge.net/projects/zsnes 5 | ;https://zsnes.bountysource.com 6 | ; 7 | ;This program is free software; you can redistribute it and/or 8 | ;modify it under the terms of the GNU General Public License 9 | ;version 2 as published by the Free Software Foundation. 10 | ; 11 | ;This program is distributed in the hope that it will be useful, 12 | ;but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | ;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | ;GNU General Public License for more details. 15 | ; 16 | ;You should have received a copy of the GNU General Public License 17 | ;along with this program; if not, write to the Free Software 18 | ;Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 | 20 | %include "macros.mac" 21 | 22 | EXTSYM dsp3_address,dsp3_byte,DSP3GetByte,DSP3SetByte 23 | EXTSYM regaccessbankr16,regaccessbankr8,regaccessbankw16,regaccessbankw8 24 | 25 | SECTION .text 26 | 27 | %macro RouteAccess 1 28 | test ecx,8000h 29 | jz %1 30 | %endmacro 31 | 32 | NEWSYM DSP3Read8b 33 | RouteAccess regaccessbankr8 34 | mov [dsp3_address],cx 35 | ccallv DSP3GetByte 36 | mov al,[dsp3_byte] 37 | ret 38 | 39 | NEWSYM DSP3Write8b 40 | RouteAccess regaccessbankw8 41 | mov [dsp3_address],cx 42 | mov [dsp3_byte],al 43 | ccallv DSP3SetByte 44 | ret 45 | 46 | NEWSYM DSP3Read16b 47 | RouteAccess regaccessbankr16 48 | mov [dsp3_address],cx 49 | ccallv DSP3GetByte 50 | mov al,[dsp3_byte] 51 | inc word[dsp3_address] 52 | ccallv DSP3GetByte 53 | mov ah,[dsp3_byte] 54 | ret 55 | 56 | NEWSYM DSP3Write16b 57 | RouteAccess regaccessbankw16 58 | mov [dsp3_address],cx 59 | mov [dsp3_byte],al 60 | ccallv DSP3SetByte 61 | mov [dsp3_byte],ah 62 | inc word[dsp3_address] 63 | ccallv DSP3SetByte 64 | ret 65 | -------------------------------------------------------------------------------- /zdir.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1997-2008 ZSNES Team ( zsKnight, _Demo_, pagefault, Nach ) 3 | 4 | http://www.zsnes.com 5 | http://sourceforge.net/projects/zsnes 6 | https://zsnes.bountysource.com 7 | 8 | This program is free software; you can redistribute it and/or 9 | modify it under the terms of the GNU General Public License 10 | version 2 as published by the Free Software Foundation. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program; if not, write to the Free Software 19 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 20 | */ 21 | 22 | #ifndef ZDIR_H 23 | #define ZDIR_H 24 | 25 | struct dirent_info { 26 | char* name; 27 | mode_t mode; 28 | off_t size; 29 | #ifdef __UNIXSDL__ 30 | uid_t uid; 31 | gid_t gid; 32 | #endif 33 | }; 34 | 35 | #ifndef __UNIXSDL__ 36 | #include 37 | 38 | #include 39 | #include 40 | 41 | // Avoid clashing with DJGPP and MinGW extras 42 | 43 | struct z_dirent { 44 | char d_name[256]; 45 | }; 46 | 47 | typedef struct 48 | { 49 | intptr_t find_first_handle; 50 | struct _finddata_t fileinfo; 51 | struct z_dirent entry; 52 | } z_DIR; 53 | 54 | z_DIR* z_opendir(const char* path); 55 | struct z_dirent* z_readdir(z_DIR* dir); 56 | int z_closedir(z_DIR* dir); 57 | 58 | #ifndef NO_ZDIR_TYPEDEF 59 | #define dirent z_dirent 60 | typedef z_DIR DIR; 61 | #define opendir z_opendir 62 | #define readdir z_readdir 63 | #define closedir z_closedir 64 | #endif 65 | 66 | #else 67 | #include 68 | typedef DIR z_DIR; 69 | #endif 70 | 71 | struct dirent_info* readdir_info(z_DIR* dir); 72 | int dirent_access(struct dirent_info* entry, int mode); 73 | 74 | #endif 75 | -------------------------------------------------------------------------------- /jma/inbyte.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2005-2008 NSRT Team ( http://nsrt.edgeemu.com ) 3 | Copyright (C) 2002 Andrea Mazzoleni ( http://advancemame.sf.net ) 4 | Copyright (C) 2001-4 Igor Pavlov ( http://www.7-zip.org ) 5 | 6 | This library is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU Lesser General Public 8 | License version 2.1 as published by the Free Software Foundation. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | */ 19 | 20 | #include "inbyte.h" 21 | 22 | namespace NStream { 23 | 24 | CInByte::CInByte(UINT32 aBufferSize) 25 | : m_BufferBase(0) 26 | , m_BufferSize(aBufferSize) 27 | { 28 | m_BufferBase = new BYTE[m_BufferSize]; 29 | } 30 | 31 | CInByte::~CInByte() 32 | { 33 | delete[] m_BufferBase; 34 | } 35 | 36 | void CInByte::Init(ISequentialInStream* aStream) 37 | { 38 | m_Stream = aStream; 39 | m_ProcessedSize = 0; 40 | m_Buffer = m_BufferBase; 41 | m_BufferLimit = m_Buffer; 42 | m_StreamWasExhausted = false; 43 | } 44 | 45 | bool CInByte::ReadBlock() 46 | { 47 | if (m_StreamWasExhausted) 48 | return false; 49 | m_ProcessedSize += (m_Buffer - m_BufferBase); 50 | UINT32 aNumProcessedBytes; 51 | HRESULT aResult = m_Stream->Read(m_BufferBase, m_BufferSize, &aNumProcessedBytes); 52 | if (aResult != S_OK) 53 | throw aResult; 54 | m_Buffer = m_BufferBase; 55 | m_BufferLimit = m_Buffer + aNumProcessedBytes; 56 | m_StreamWasExhausted = (aNumProcessedBytes == 0); 57 | return (!m_StreamWasExhausted); 58 | } 59 | 60 | } 61 | -------------------------------------------------------------------------------- /jma/7zlzma.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2005-2008 NSRT Team ( http://nsrt.edgeemu.com ) 3 | Copyright (C) 2002 Andrea Mazzoleni ( http://advancemame.sf.net ) 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License version 2.1 as published by the Free Software Foundation. 8 | 9 | This library is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public 15 | License along with this library; if not, write to the Free Software 16 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 | */ 18 | 19 | #include "7z.h" 20 | 21 | #include "lzmadec.h" 22 | 23 | bool decompress_lzma_7z(ISequentialInStream& in, unsigned in_size, ISequentialOutStream& out, unsigned out_size) throw() 24 | { 25 | try { 26 | NCompress::NLZMA::CDecoder cc; 27 | 28 | UINT64 in_size_l = in_size; 29 | UINT64 out_size_l = out_size; 30 | 31 | if (cc.ReadCoderProperties(&in) != S_OK) { 32 | return (false); 33 | } 34 | if (cc.Code(&in, &out, &in_size_l, &out_size_l) != S_OK) { 35 | return (false); 36 | } 37 | if (out.size_get() != out_size || out.overflow_get()) { 38 | return (false); 39 | } 40 | 41 | return (true); 42 | } catch (...) { 43 | return (false); 44 | } 45 | } 46 | 47 | bool decompress_lzma_7z(const unsigned char* in_data, unsigned int in_size, unsigned char* out_data, unsigned int out_size) throw() 48 | { 49 | ISequentialInStream_Array in(reinterpret_cast(in_data), in_size); 50 | ISequentialOutStream_Array out(reinterpret_cast(out_data), out_size); 51 | 52 | return (decompress_lzma_7z(in, in_size, out, out_size)); 53 | } 54 | -------------------------------------------------------------------------------- /chips/obc1proc.asm: -------------------------------------------------------------------------------- 1 | ;Copyright (C) 1997-2008 ZSNES Team ( zsKnight, _Demo_, pagefault, Nach ) 2 | ; 3 | ;http://www.zsnes.com 4 | ;http://sourceforge.net/projects/zsnes 5 | ;https://zsnes.bountysource.com 6 | ; 7 | ;This program is free software; you can redistribute it and/or 8 | ;modify it under the terms of the GNU General Public License 9 | ;version 2 as published by the Free Software Foundation. 10 | ; 11 | ;This program is distributed in the hope that it will be useful, 12 | ;but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | ;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | ;GNU General Public License for more details. 15 | ; 16 | ;You should have received a copy of the GNU General Public License 17 | ;along with this program; if not, write to the Free Software 18 | ;Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 | 20 | %include "macros.mac" 21 | 22 | EXTSYM obc1_address,obc1_byte,SetOBC1,GetOBC1 23 | EXTSYM regaccessbankr16,regaccessbankr8,regaccessbankw16,regaccessbankw8 24 | EXTSYM memaccessbankr16,memaccessbankr8,memaccessbankw16,memaccessbankw8 25 | 26 | SECTION .text 27 | 28 | %macro RouteAccess 1 29 | test ecx,8000h 30 | jnz memaccessbank%1 31 | cmp ecx,6000h 32 | jb regaccessbank%1 33 | %endmacro 34 | 35 | NEWSYM OBC1Read8b 36 | RouteAccess r8 37 | mov [obc1_address],cx 38 | ccallv GetOBC1 39 | mov al,[obc1_byte] 40 | ret 41 | 42 | NEWSYM OBC1Write8b 43 | RouteAccess w8 44 | mov [obc1_address],cx 45 | mov [obc1_byte],al 46 | ccallv SetOBC1 47 | ret 48 | 49 | NEWSYM OBC1Read16b 50 | RouteAccess r16 51 | mov [obc1_address],cx 52 | ccallv GetOBC1 53 | mov al,[obc1_byte] 54 | inc word[obc1_address] 55 | ccallv GetOBC1 56 | mov ah,[obc1_byte] 57 | ret 58 | 59 | NEWSYM OBC1Write16b 60 | RouteAccess w16 61 | mov [obc1_address],cx 62 | mov [obc1_byte],al 63 | ccallv SetOBC1 64 | mov [obc1_byte],ah 65 | inc word[obc1_address] 66 | ccallv SetOBC1 67 | ret 68 | -------------------------------------------------------------------------------- /vcache.h: -------------------------------------------------------------------------------- 1 | #ifndef VCACHE_H 2 | #define VCACHE_H 3 | 4 | #include "types.h" 5 | 6 | extern void cachesingle4bng(); 7 | extern void cachesprites(); 8 | extern void cachetile2b(); 9 | extern void cachetile2b16x16(); 10 | extern void cachetile4b(); 11 | extern void cachetile4b16x16(); 12 | extern void cachetile8b(); 13 | extern void cachetile8b16x16(); 14 | extern void processsprites(); 15 | 16 | extern u1 lineleft; 17 | extern u1 res480; 18 | extern u1 res640; 19 | extern u1 sprprifix; 20 | extern u1 videotroub; 21 | extern u2 dcolortab[2][256]; 22 | extern u2 vesa2_bfull; // red max (or bit*1Fh) 23 | extern u2 vesa2_btrcl; // red transparency clear (bit+4) 24 | extern u2 vesa2_btrcla; // red transparency (AND) clear (not(bit+4)) 25 | extern u2 vesa2_clbit; // clear all bit 0's if AND is used 26 | extern u2 vesa2_gfull; // red max (or bit*1Fh) 27 | extern u2 vesa2_gtrcl; // red transparency clear (bit+4) 28 | extern u2 vesa2_gtrcla; // red transparency (AND) clear (not(bit+4)) 29 | extern u2 vesa2_rfull; // red max (or bit*1Fh) 30 | extern u2 vesa2_rtrcl; // red transparency clear (bit+4) 31 | extern u2 vesa2_rtrcla; // red transparency (AND) clear (not(bit+4)) 32 | extern u2 vesa2_usbit; // Unused bit in proper bit location 33 | extern u2 vesa2_x; // Desired screen width 34 | extern u2 vesa2_y; // Height 35 | extern u4 OMBGTestVal; 36 | extern u4 ngptrdat2; 37 | extern u4 ofshvaladd; 38 | extern u4 ofsmcptr2; 39 | extern u4 ofsmtptrs; 40 | extern u4 vesa2_bits; // Bits per pixel 41 | extern u4 vesa2_bpos; // Blue bit position 42 | extern u4 vesa2_bposng; // Blue bit position 43 | extern u4 vesa2_clbitng2[2]; // clear all bit 0's if AND is used 44 | extern u4 vesa2_clbitng3; // clear all bit 0's if AND is used 45 | extern u4 vesa2_clbitng; // clear all bit 0's if AND is used 46 | extern u4 vesa2_gpos; // Green bit position 47 | extern u4 vesa2_gposng; // Green bit position 48 | extern u4 vesa2_rpos; // Red bit position 49 | extern u4 vesa2_rposng; // Red bit position 50 | extern u4 vesa2red10; // red position at bit 10 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /chips/dsp4proc.asm: -------------------------------------------------------------------------------- 1 | ;Copyright (C) 1997-2008 ZSNES Team ( zsKnight, _Demo_, pagefault, Nach ) 2 | ; 3 | ;http://www.zsnes.com 4 | ;http://sourceforge.net/projects/zsnes 5 | ;https://zsnes.bountysource.com 6 | ; 7 | ;This program is free software; you can redistribute it and/or 8 | ;modify it under the terms of the GNU General Public License 9 | ;version 2 as published by the Free Software Foundation. 10 | ; 11 | ;This program is distributed in the hope that it will be useful, 12 | ;but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | ;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | ;GNU General Public License for more details. 15 | ; 16 | ;You should have received a copy of the GNU General Public License 17 | ;along with this program; if not, write to the Free Software 18 | ;Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 | 20 | %include "macros.mac" 21 | 22 | EXTSYM dsp4_address,dsp4_byte,DSP4GetByte,DSP4SetByte 23 | EXTSYM regaccessbankr16,regaccessbankr8,regaccessbankw16,regaccessbankw8 24 | 25 | SECTION .text 26 | 27 | %macro RouteAccess 1 28 | test ecx,8000h 29 | jz %1 30 | test ecx,4000h 31 | jz .dsp4continue 32 | ret 33 | .dsp4continue 34 | %endmacro 35 | 36 | NEWSYM DSP4Read8b 37 | RouteAccess regaccessbankr8 38 | mov [dsp4_address],cx 39 | ccallv DSP4GetByte 40 | mov al,[dsp4_byte] 41 | ret 42 | 43 | NEWSYM DSP4Write8b 44 | RouteAccess regaccessbankw8 45 | mov [dsp4_address],cx 46 | mov [dsp4_byte],al 47 | ccallv DSP4SetByte 48 | ret 49 | 50 | NEWSYM DSP4Read16b 51 | RouteAccess regaccessbankr16 52 | mov [dsp4_address],cx 53 | ccallv DSP4GetByte 54 | mov al,[dsp4_byte] 55 | inc word[dsp4_address] 56 | ccallv DSP4GetByte 57 | mov ah,[dsp4_byte] 58 | ret 59 | 60 | NEWSYM DSP4Write16b 61 | RouteAccess regaccessbankw16 62 | mov [dsp4_address],cx 63 | mov [dsp4_byte],al 64 | ccallv DSP4SetByte 65 | mov [dsp4_byte],ah 66 | inc word[dsp4_address] 67 | ccallv DSP4SetByte 68 | ret 69 | -------------------------------------------------------------------------------- /ztimec.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1997-2008 ZSNES Team ( zsKnight, _Demo_, pagefault, Nach ) 3 | 4 | http://www.zsnes.com 5 | http://sourceforge.net/projects/zsnes 6 | https://zsnes.bountysource.com 7 | 8 | This program is free software; you can redistribute it and/or 9 | modify it under the terms of the GNU General Public License 10 | version 2 as published by the Free Software Foundation. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program; if not, write to the Free Software 19 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 20 | */ 21 | 22 | #include 23 | 24 | #include "ztimec.h" 25 | 26 | u4 GetTimeInSeconds(void) 27 | { 28 | time_t current; 29 | struct tm* timeptr; 30 | 31 | time(¤t); 32 | timeptr = localtime(¤t); 33 | return (timeptr->tm_hour * 60 + timeptr->tm_min) * 60 + timeptr->tm_sec; 34 | } 35 | 36 | u4 GetTime(void) 37 | { 38 | unsigned int value; 39 | struct tm* newtime; 40 | time_t long_time; 41 | 42 | time(&long_time); 43 | newtime = localtime(&long_time); 44 | 45 | value = ((newtime->tm_sec) % 10) + ((newtime->tm_sec) / 10) * 16 46 | + ((((newtime->tm_min) % 10) + ((newtime->tm_min) / 10) * 16) << 8) 47 | + ((((newtime->tm_hour) % 10) + ((newtime->tm_hour) / 10) * 16) << 16); 48 | return (value); 49 | } 50 | 51 | u4 GetDate(void) 52 | { 53 | unsigned int value; 54 | struct tm* newtime; 55 | time_t long_time; 56 | 57 | time(&long_time); 58 | newtime = localtime(&long_time); 59 | value = ((newtime->tm_mday) % 10) + ((newtime->tm_mday) / 10) * 16 60 | + (((newtime->tm_mon) + 1) << 8) 61 | + ((((newtime->tm_year) % 10) + ((newtime->tm_year) / 10) * 16) << 16) 62 | + ((newtime->tm_wday) << 28); 63 | return (value); 64 | } 65 | -------------------------------------------------------------------------------- /tools/compile.txt: -------------------------------------------------------------------------------- 1 | How to compile the tools: 2 | 3 | First build the utility files used by the tools. 4 | 5 | g++ -Wall -O3 -o fileutil.o -c fileutil.cpp 6 | g++ -Wall -O3 -o strutil.o -c strutil.cpp 7 | 8 | 9 | Architecture detector: 10 | gcc -Wall -O3 -o archopt.exe archopt.c 11 | 12 | Cut Redundant ASM Typecasts: 13 | g++ -Wall -O3 -o cutrtype.exe cutrtype.cpp fileutil.o strutil.o 14 | 15 | Dependency Builder: 16 | g++ -Wall -O3 -o depbuild.exe depbuild.cpp fileutil.o strutil.o 17 | 18 | Extra EXTSYMs: 19 | g++ -Wall -O3 -o extraext.exe extraext.cpp fileutil.o strutil.o 20 | 21 | Minimize Whitespace: 22 | g++ -Wall -O3 -o minwhite.exe minwhite.cpp fileutil.o 23 | 24 | Nach's Replacer: 25 | g++ -Wall -O3 -o nreplace.exe nreplace.cpp fileutil.o 26 | 27 | Section Tester: 28 | g++ -Wall -O3 -o sec-test.exe sec-test.cpp fileutil.o strutil.o 29 | 30 | Source Counter: 31 | g++ -Wall -O3 -o srccount.exe srccount.cpp fileutil.o 32 | 33 | Macro Unroller: 34 | g++ -Wall -O3 -o macroll.exe macroll.cpp fileutil.o strutil.o 35 | 36 | Variable Replacer: 37 | g++ -Wall -O3 -o varrep.exe varrep.cpp fileutil.o strutil.o 38 | 39 | All the tools scan every compatible file they find from the directory they are 40 | in. It also scans all sub directories recursively. 41 | 42 | Extra EXTSYMs accepts command line arguments. You can specify filenames to put 43 | on the can't be opened ignore list. 44 | 45 | Nach's Replacer accept parameters for various files, and -r for recursive 46 | directory support. 47 | 48 | Dependency Builder requires parameters for CC, CFLAGS, NASM, NASM_FLAGS. 49 | Example: depbuild gcc "-I/usr/include -D__UNIXSDL__ -O3 -march=athlon64" nasm 50 | "-D__UNIXSDL__ -f elf -DELF -D__OPENGL__ -O1" 51 | 52 | Macro Unroller has the macro as parameter passed to it. 53 | Example: macroll DiffOrNot w4,w2,PIXEL00_0,PIXEL00_100 54 | 55 | Variable Replacer requires parameters for variable file, variable prefix 56 | and suffix. It can also optionally take a file list. Variable file should 57 | contain each variable on a line by itself. 58 | Example: varrep vf.txt "DSP4_vars." "" chips/dsp4emu.c 59 | -------------------------------------------------------------------------------- /gblvars.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1997-2008 ZSNES Team ( zsKnight, _Demo_, pagefault, Nach ) 3 | 4 | http://www.zsnes.com 5 | http://sourceforge.net/projects/zsnes 6 | https://zsnes.bountysource.com 7 | 8 | This program is free software; you can redistribute it and/or 9 | modify it under the terms of the GNU General Public License 10 | version 2 as published by the Free Software Foundation. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program; if not, write to the Free Software 19 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 20 | */ 21 | 22 | #include 23 | #include 24 | 25 | extern uint32_t cycpbl; 26 | extern uint32_t PHspcsave, PHdspsave; 27 | extern uint32_t PHnum2writesa1reg, SA1Mode, prevedi, SA1xpc; 28 | extern uint32_t soundcycleft, spc700read, timer2upd, xa, PHnum2writesfxreg; 29 | extern uint32_t opcd, HIRQCycNext, oamaddr, curexecstate, nmiprevaddrl; 30 | extern uint32_t nmirept, nmiprevline, nmistatus, joycontren; 31 | extern uint32_t SfxR0, ramsize, nmiprevaddrh; 32 | extern uint32_t tempesi, tempedi, tempedx, tempebp; 33 | extern uint32_t SPCMultA, PHnum2writespc7110reg, PHdspsave2; 34 | 35 | extern uint32_t* setaramdata; 36 | extern uint8_t *romdata, *SA1RAMArea; 37 | 38 | extern unsigned char sndrot, SPCRAM[], DSPMem[256], SA1Status; 39 | extern unsigned char DSP1Enable, DSP1COp, prevoamptr, BRRBuffer[]; 40 | extern unsigned char curcyc, spcnumread, NextLineCache, HIRQNextExe; 41 | extern unsigned char vidmemch8[4096], vidmemch2[4096]; 42 | 43 | extern bool C4Enable, SFXEnable, SA1Enable, SPC7110Enable, SETAEnable, DSP4Enable, MSUEnable; 44 | 45 | extern int16_t C4WFXVal, C41FXVal, Op00Multiplicand, Op04Angle, Op08X, Op18X; 46 | extern int16_t Op28X, Op0CA, Op02FX, Op0AVS, Op06X, Op01m, Op0DX, Op03F, Op14Zr; 47 | extern int16_t Op0EH, Op10Coefficient; 48 | -------------------------------------------------------------------------------- /tools/srccount.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2005-2008 Nach, grinvader ( http://www.zsnes.com ) 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | version 2 as published by the Free Software Foundation. 7 | 8 | This program is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | GNU General Public License for more details. 12 | 13 | You should have received a copy of the GNU General Public License 14 | along with this program; if not, write to the Free Software 15 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 16 | */ 17 | 18 | /* 19 | This is part of a toolkit used to assist in ZSNES development 20 | 21 | This program tells us how far our port progress is. 22 | */ 23 | 24 | #include 25 | #include 26 | using namespace std; 27 | 28 | #include "fileutil.h" 29 | 30 | size_t c_count = 0; 31 | size_t cpp_count = 0; 32 | size_t asm_count = 0; 33 | size_t psr_count = 0; 34 | 35 | void size_tally(const char* filename, struct stat& stat_buffer) 36 | { 37 | if (is_c_file(filename)) { 38 | c_count += stat_buffer.st_size; 39 | } else if (is_asm_file(filename)) { 40 | asm_count += stat_buffer.st_size; 41 | } else if (is_cpp_file(filename)) { 42 | cpp_count += stat_buffer.st_size; 43 | } else if (is_psr_file(filename)) { 44 | psr_count += stat_buffer.st_size; 45 | } 46 | } 47 | 48 | int main() 49 | { 50 | parse_dir(".", size_tally); 51 | 52 | unsigned int total_count = asm_count + c_count + cpp_count + psr_count; 53 | 54 | cout << "ASM code uses " << asm_count << " bytes. (" << (float)(asm_count * 100) / total_count << ")\n" 55 | << "C code uses " << c_count << " bytes. (" << (float)(c_count * 100) / total_count << ")\n" 56 | << "C++ code uses " << cpp_count << " bytes. (" << (float)(cpp_count * 100) / total_count << ")\n" 57 | << "PSR code uses " << psr_count << " bytes. (" << (float)(psr_count * 100) / total_count << ")\n" 58 | << endl; 59 | return (0); 60 | } 61 | -------------------------------------------------------------------------------- /cpu/stable.asm: -------------------------------------------------------------------------------- 1 | ;Copyright (C) 1997-2008 ZSNES Team ( zsKnight, _Demo_, pagefault, Nach ) 2 | ; 3 | ;http://www.zsnes.com 4 | ;http://sourceforge.net/projects/zsnes 5 | ;https://zsnes.bountysource.com 6 | ; 7 | ;This program is free software; you can redistribute it and/or 8 | ;modify it under the terms of the GNU General Public License 9 | ;version 2 as published by the Free Software Foundation. 10 | ; 11 | ;This program is distributed in the hope that it will be useful, 12 | ;but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | ;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | ;GNU General Public License for more details. 15 | ; 16 | ;You should have received a copy of the GNU General Public License 17 | ;along with this program; if not, write to the Free Software 18 | ;Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 | 20 | %include "macros.mac" 21 | 22 | EXTSYM SA1tableA,SA1tableB,SA1tableC,SA1tableD,SA1tableE 23 | EXTSYM SA1tableF,SA1tableG,SA1tableH,SA1tablead 24 | EXTSYM cpucycle,SA1UpdateDPage,intrset 25 | 26 | %include "cpu/s65816d.inc" 27 | %include "cpu/saddress.inc" 28 | %include "cpu/saddrni.inc" 29 | %include "cpu/se65816.inc" 30 | 31 | ; global variables 32 | ;tableA times 256 ; Table addresses (M:0,X:0,D:0) 33 | ;tableB times 256 ; Table addresses (M:1,X:0,D:0) 34 | ;tableC times 256 ; Table addresses (M:0,X:1,D:0) 35 | ;tableD times 256 ; Table addresses (M:1,X:1,D:0) 36 | ;tableE times 256 ; Table addresses (M:0,X:0,D:1) 37 | ;tableF times 256 ; Table addresses (M:1,X:0,D:1) 38 | ;tableG times 256 ; Table addresses (M:0,X:1,D:1) 39 | ;tableH times 256 ; Table addresses (M:1,X:1,D:1) 40 | ;tablead times 256 ; Table address location according to P 41 | ;memtabler8 times 256 ; Memory Bank Locations for reading 8-bit 42 | ;memtablew8 times 256 ; Memory Bank Locations for writing 8-bit 43 | ;memtabler16 times 256 ; Memory Bank Locations for reading 16-bit 44 | ;memtablew16 times 256 ; Memory Bank Locations for reading 16-bit 45 | 46 | ; global variables 47 | 48 | SECTION .text 49 | 50 | eopINVALID 51 | ret 52 | -------------------------------------------------------------------------------- /tools/strutil.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2005-2008 Nach, grinvader ( http://www.zsnes.com ) 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | version 2 as published by the Free Software Foundation. 7 | 8 | This program is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | GNU General Public License for more details. 12 | 13 | You should have received a copy of the GNU General Public License 14 | along with this program; if not, write to the Free Software 15 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 16 | */ 17 | 18 | /* 19 | This is part of a toolkit used to assist in ZSNES development 20 | */ 21 | 22 | #include "strutil.h" 23 | using namespace std; 24 | 25 | template 26 | static inline void Tokenize(const T1& str, T2& tokens, const T1& delimiters) 27 | { 28 | // Skip delimiters at beginning 29 | string::size_type lastPos = str.find_first_not_of(delimiters, 0); 30 | 31 | // Find first "non-delimiter" 32 | string::size_type pos = str.find_first_of(delimiters, lastPos); 33 | 34 | while (string::npos != pos || string::npos != lastPos) { 35 | // Found a token, add it to the vector 36 | tokens.push_back(str.substr(lastPos, pos - lastPos)); 37 | 38 | // Skip delimiters. Note the "not_of" 39 | lastPos = str.find_first_not_of(delimiters, pos); 40 | 41 | // Find next "non-delimiter" 42 | pos = str.find_first_of(delimiters, lastPos); 43 | } 44 | } 45 | 46 | void Tokenize(const string& str, vector& tokens, const string& delimiters) 47 | { 48 | Tokenize>(str, tokens, delimiters); 49 | } 50 | 51 | void Tokenize(const string_ci& str, vector& tokens, const string_ci& delimiters) 52 | { 53 | Tokenize>(str, tokens, delimiters); 54 | } 55 | 56 | bool all_whitespace(const char* str) 57 | { 58 | for (; *str; str++) { 59 | if (!isspace(*str)) { 60 | return (false); 61 | } 62 | } 63 | return (true); 64 | } 65 | -------------------------------------------------------------------------------- /mmlib/mm.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2003-2007 Ryan C. Gordon and others. 3 | 4 | http://icculus.org/manymouse/ 5 | 6 | This software is provided 'as-is', without any express or implied warranty. 7 | In no event will the authors be held liable for any damages arising from 8 | the use of this software. 9 | 10 | Permission is granted to anyone to use this software for any purpose, 11 | including commercial applications, and to alter it and redistribute it 12 | freely, subject to the following restrictions: 13 | 14 | 1. The origin of this software must not be misrepresented; you must not 15 | claim that you wrote the original software. If you use this software in a 16 | product, an acknowledgment in the product documentation would be 17 | appreciated but is not required. 18 | 19 | 2. Altered source versions must be plainly marked as such, and must not be 20 | misrepresented as being the original software. 21 | 22 | 3. This notice may not be removed or altered from any source distribution. 23 | 24 | Ryan C. Gordon 25 | */ 26 | 27 | // ManyMouse main header. Include this from your app. 28 | 29 | #ifndef _INCLUDE_MANYMOUSE_H_ 30 | #define _INCLUDE_MANYMOUSE_H_ 31 | 32 | #ifdef __cplusplus 33 | extern "C" { 34 | #endif 35 | 36 | #define MANYMOUSE_VERSION "0.0.1" 37 | 38 | typedef enum { 39 | MANYMOUSE_EVENT_ABSMOTION = 0, 40 | MANYMOUSE_EVENT_RELMOTION, 41 | MANYMOUSE_EVENT_BUTTON, 42 | MANYMOUSE_EVENT_SCROLL, 43 | MANYMOUSE_EVENT_DISCONNECT, 44 | MANYMOUSE_EVENT_MAX 45 | } ManyMouseEventType; 46 | 47 | typedef struct 48 | { 49 | ManyMouseEventType type; 50 | unsigned int device; 51 | unsigned int item; 52 | int value; 53 | int minval; 54 | int maxval; 55 | } ManyMouseEvent; 56 | 57 | /* internal use only. */ 58 | typedef struct 59 | { 60 | int (*init)(void); 61 | void (*quit)(void); 62 | const char* (*name)(unsigned int index); 63 | int (*poll)(ManyMouseEvent* event); 64 | } ManyMouseDriver; 65 | 66 | int ManyMouse_Init(void); 67 | void ManyMouse_Quit(void); 68 | const char* ManyMouse_DeviceName(unsigned int index); 69 | int ManyMouse_PollEvent(ManyMouseEvent* event); 70 | 71 | #ifdef __cplusplus 72 | } 73 | #endif 74 | 75 | #endif /* !defined _INCLUDE_MANYMOUSE_H_ */ 76 | 77 | /* end of manymouse.h ... */ 78 | -------------------------------------------------------------------------------- /cpu/spcaddr.inc: -------------------------------------------------------------------------------- 1 | ;Copyright (C) 1997-2008 ZSNES Team ( zsKnight, _Demo_, pagefault, Nach ) 2 | ; 3 | ;http://www.zsnes.com 4 | ;http://sourceforge.net/projects/zsnes 5 | ;https://zsnes.bountysource.com 6 | ; 7 | ;This program is free software; you can redistribute it and/or 8 | ;modify it under the terms of the GNU General Public License 9 | ;version 2 as published by the Free Software Foundation. 10 | ; 11 | ;This program is distributed in the hope that it will be useful, 12 | ;but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | ;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | ;GNU General Public License for more details. 15 | ; 16 | ;You should have received a copy of the GNU General Public License 17 | ;along with this program; if not, write to the Free Software 18 | ;Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 | 20 | 21 | 22 | ; A,DP addressing mode 23 | %macro SPCaddr_DP 0 24 | mov bl,[ebp] 25 | add ebx,[spcRamDP] 26 | inc ebp 27 | ReadByte 28 | %endmacro 29 | 30 | %macro SPCaddr_DP_X 0 31 | mov bl,[ebp] 32 | add bl,[spcX] 33 | add ebx,[spcRamDP] 34 | inc ebp 35 | ReadByte 36 | %endmacro 37 | 38 | %macro SPCaddr_LABS 0 39 | mov bx,[ebp] 40 | add ebx,SPCRAM 41 | ReadByte 42 | add ebp,2 43 | %endmacro 44 | 45 | %macro SPCaddr_LABS_X 0 46 | mov bl,[spcX] 47 | add bx,[ebp] 48 | add ebp,2 49 | add ebx,SPCRAM 50 | ReadByte 51 | %endmacro 52 | 53 | ; A,(X) 54 | %macro SPCaddr__X_ 0 55 | mov bl,[spcX] 56 | add ebx,[spcRamDP] 57 | ReadByte 58 | %endmacro 59 | 60 | ; A,labs+Y 61 | %macro SPCaddr_LABS_Y 0 62 | mov bl,[spcY] 63 | add bx,[ebp] 64 | add ebp,2 65 | add ebx,SPCRAM 66 | ReadByte 67 | %endmacro 68 | 69 | ; A,(DP,X) 70 | %macro SPCaddr_bDP_Xb 0 71 | mov bl,[ebp] 72 | add bl,[spcX] 73 | xor eax,eax 74 | add ebx,[spcRamDP] 75 | inc ebp 76 | mov ax, [ebx] 77 | mov ebx,eax 78 | add ebx,SPCRAM 79 | ReadByte 80 | %endmacro 81 | 82 | %macro SPCaddr_bDPb_Y 0 83 | mov bl,[ebp] 84 | xor eax,eax 85 | add ebx,[spcRamDP] 86 | inc ebp 87 | mov ax,[ebx] 88 | add ax,[spcY] 89 | mov ebx,eax 90 | add ebx,SPCRAM 91 | ReadByte 92 | %endmacro 93 | -------------------------------------------------------------------------------- /zmovie.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1997-2008 ZSNES Team ( zsKnight, _Demo_, pagefault, Nach ) 3 | 4 | http://www.zsnes.com 5 | http://sourceforge.net/projects/zsnes 6 | https://zsnes.bountysource.com 7 | 8 | This program is free software; you can redistribute it and/or 9 | modify it under the terms of the GNU General Public License 10 | version 2 as published by the Free Software Foundation. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program; if not, write to the Free Software 19 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 20 | */ 21 | 22 | #ifndef ZMOVIE_H 23 | #define ZMOVIE_H 24 | 25 | #include "gblvars.h" 26 | #include "types.h" 27 | #include 28 | #include 29 | 30 | void mzt_chdir_up(); 31 | void mzt_chdir_down(); 32 | bool mzt_save(int, bool, bool); 33 | bool mzt_load(int, bool); 34 | 35 | void GetMovieFrameStr(void); 36 | void MovieRecord(); 37 | void MoviePlay(); 38 | void MovieStop(); 39 | void MovieAppend(); 40 | void MovieDumpRaw(void); 41 | bool MovieInProgress(); 42 | void MovieInsertChapter(void); 43 | void MovieSeekAhead(void); 44 | void MovieSeekBehind(void); 45 | void ResetDuringMovie(void); 46 | void SkipMovie(void); 47 | 48 | extern unsigned char MovieProcessing; 49 | extern uint8_t MovieRecordWinVal; 50 | 51 | enum MovieStatus { MOVIE_OFF = 0, 52 | MOVIE_PLAYBACK, 53 | MOVIE_RECORD, 54 | MOVIE_OLD_PLAY, 55 | MOVIE_ENDING_DUMPING, 56 | MOVIE_DUMPING_NEW, 57 | MOVIE_DUMPING_OLD }; 58 | #define SetMovieMode(mode) (MovieProcessing = (unsigned char)mode) 59 | 60 | enum MZT_FORCE_MODE_SWITCH { RTR_OFF = 0, 61 | RTR_REPLAY_TO_RECORD, 62 | RTR_RECORD_TO_REPLAY }; 63 | 64 | void MovieInsertChapter(void); 65 | 66 | void MovieSeekAhead(void); 67 | 68 | void MovieSeekBehind(void); 69 | 70 | void ResetDuringMovie(void); 71 | 72 | void MovieDumpRaw(void); 73 | 74 | extern u1 MovieForcedLengthEnabled; 75 | extern u1 lameExists; 76 | extern u1 mencoderExists; 77 | extern bool RawDumpInProgress; 78 | extern char MovieFrameStr[10]; 79 | extern unsigned char MoviePassWaiting; 80 | 81 | #endif 82 | -------------------------------------------------------------------------------- /jma/inbyte.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2002 Andrea Mazzoleni ( http://advancemame.sf.net ) 3 | Copyright (C) 2001-4 Igor Pavlov ( http://www.7-zip.org ) 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License version 2.1 as published by the Free Software Foundation. 8 | 9 | This library is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public 15 | License along with this library; if not, write to the Free Software 16 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 | */ 18 | 19 | #ifndef __STREAM_INBYTE_H 20 | #define __STREAM_INBYTE_H 21 | 22 | #include "iiostrm.h" 23 | 24 | namespace NStream { 25 | 26 | class CInByte { 27 | UINT64 m_ProcessedSize; 28 | BYTE* m_BufferBase; 29 | UINT32 m_BufferSize; 30 | BYTE* m_Buffer; 31 | BYTE* m_BufferLimit; 32 | ISequentialInStream* m_Stream; 33 | bool m_StreamWasExhausted; 34 | 35 | bool ReadBlock(); 36 | 37 | public: 38 | CInByte(UINT32 aBufferSize = 0x100000); 39 | ~CInByte(); 40 | 41 | void Init(ISequentialInStream* aStream); 42 | 43 | bool ReadByte(BYTE& aByte) 44 | { 45 | if (m_Buffer >= m_BufferLimit) 46 | if (!ReadBlock()) 47 | return false; 48 | aByte = *m_Buffer++; 49 | return true; 50 | } 51 | BYTE ReadByte() 52 | { 53 | if (m_Buffer >= m_BufferLimit) 54 | if (!ReadBlock()) 55 | return 0x0; 56 | return *m_Buffer++; 57 | } 58 | void ReadBytes(void* aData, UINT32 aSize, UINT32& aProcessedSize) 59 | { 60 | for (aProcessedSize = 0; aProcessedSize < aSize; aProcessedSize++) 61 | if (!ReadByte(((BYTE*)aData)[aProcessedSize])) 62 | return; 63 | } 64 | bool ReadBytes(void* aData, UINT32 aSize) 65 | { 66 | UINT32 aProcessedSize; 67 | ReadBytes(aData, aSize, aProcessedSize); 68 | return (aProcessedSize == aSize); 69 | } 70 | UINT64 GetProcessedSize() const { return m_ProcessedSize + (m_Buffer - m_BufferBase); } 71 | }; 72 | 73 | } 74 | 75 | #endif 76 | -------------------------------------------------------------------------------- /chips/msu1regs.asm: -------------------------------------------------------------------------------- 1 | ;Copyright (C) 2023 Sneed, ZSNES Team ( zsKnight, _Demo_, pagefault, Nach ) 2 | ; 3 | ;This program is free software; you can redistribute it and/or 4 | ;modify it under the terms of the GNU General Public License 5 | ;version 2 as published by the Free Software Foundation. 6 | ; 7 | ;This program is distributed in the hope that it will be useful, 8 | ;but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | ;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | ;GNU General Public License for more details. 11 | ; 12 | ;You should have received a copy of the GNU General Public License 13 | ;along with this program; if not, write to the Free Software 14 | ;Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 15 | %include "macros.mac" 16 | 17 | EXTSYM MSU_CurrentStatus,MSU_MusicVolume,MSU_Track,MSU_Data_Seek,MSU_DATA,MSU_StatusRead,MSU1HandleTrackChange,MSU1HandleStatusBits,MSU1GetStatusBitsSpecial 18 | 19 | SECTION .text 20 | 21 | ;STATUS read 22 | ;Data busy Audio busy Audio repeat Audio playing Track missing Revision 23 | ;No need for busy bits since data will be stored in RAM 24 | NEWSYM msustatusread 25 | ccall MSU1GetStatusBitsSpecial 26 | mov al,[MSU_StatusRead] 27 | ret 28 | 29 | ;DATA read 30 | NEWSYM msudataread 31 | mov ebx,[MSU_DATA] 32 | add ebx,[MSU_Data_Seek] 33 | mov al,[ebx] 34 | 35 | ;increment seek 36 | inc dword[MSU_Data_Seek] 37 | ret 38 | 39 | ;MSU-1 ID 40 | NEWSYM msuid1 41 | mov al,'S' 42 | ret 43 | NEWSYM msuid2 44 | mov al,'-' 45 | ret 46 | NEWSYM msuid3 47 | mov al,'M' 48 | ret 49 | NEWSYM msuid4 50 | mov al,'S' 51 | ret 52 | NEWSYM msuid5 53 | mov al,'U' 54 | ret 55 | NEWSYM msuid6 56 | mov al,'1' 57 | ret 58 | 59 | ;--------------------------- Write Registers --------------------------- 60 | 61 | ;DATA Seek Pointer 62 | NEWSYM msudataseek0 63 | mov [MSU_Data_Seek],al 64 | ret 65 | NEWSYM msudataseek1 66 | mov [MSU_Data_Seek+1],al 67 | ret 68 | NEWSYM msudataseek2 69 | mov [MSU_Data_Seek+2],al 70 | ret 71 | NEWSYM msudataseek3 72 | mov [MSU_Data_Seek+3],al 73 | ret 74 | 75 | ;TRACK 76 | NEWSYM msu1track0 77 | mov [MSU_Track],al 78 | ret 79 | NEWSYM msu1track1 80 | mov [MSU_Track+1],al 81 | ccall MSU1HandleTrackChange 82 | ret 83 | 84 | ;VOLUME 85 | NEWSYM msu1volume 86 | mov [MSU_MusicVolume],al 87 | ret 88 | 89 | ;STATE CONTROL 90 | NEWSYM msu1statecontrol 91 | mov [MSU_CurrentStatus],al 92 | ccall MSU1HandleStatusBits 93 | ret -------------------------------------------------------------------------------- /tools/fileutil.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2005-2008 Nach, grinvader ( http://www.zsnes.com ) 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | version 2 as published by the Free Software Foundation. 7 | 8 | This program is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | GNU General Public License for more details. 12 | 13 | You should have received a copy of the GNU General Public License 14 | along with this program; if not, write to the Free Software 15 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 16 | */ 17 | 18 | /* 19 | This is part of a toolkit used to assist in ZSNES development 20 | */ 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | #include "fileutil.h" 27 | 28 | void parse_dir(const char* dir_loc, void (*func)(const char*, struct stat&)) 29 | { 30 | char path[4096]; 31 | 32 | DIR* curDir = opendir(dir_loc); 33 | dirent* curFile; 34 | if (curDir) { 35 | while ((curFile = readdir(curDir))) { 36 | if (!strcmp(curFile->d_name, ".") || !strcmp(curFile->d_name, "..")) { 37 | continue; 38 | } 39 | 40 | char* filename; 41 | if (!strcmp(dir_loc, ".")) { 42 | filename = curFile->d_name; 43 | } else { 44 | sprintf(path, "%s/%s", dir_loc, curFile->d_name); 45 | filename = path; 46 | } 47 | 48 | struct stat stat_buffer; 49 | if (stat(filename, &stat_buffer)) { 50 | continue; 51 | } 52 | 53 | // Directory 54 | if (S_ISDIR(stat_buffer.st_mode)) { 55 | parse_dir(filename, func); 56 | continue; 57 | } 58 | 59 | func(filename, stat_buffer); 60 | } 61 | closedir(curDir); 62 | } 63 | } 64 | 65 | bool parse_path(const char* path, void (*func)(const char*, struct stat&)) 66 | { 67 | struct stat stat_buffer; 68 | if (!stat(path, &stat_buffer)) { 69 | if (S_ISDIR(stat_buffer.st_mode)) { 70 | parse_dir(path, func); 71 | } else { 72 | func(path, stat_buffer); 73 | } 74 | return (true); 75 | } 76 | return (false); 77 | } 78 | -------------------------------------------------------------------------------- /endmem.h: -------------------------------------------------------------------------------- 1 | #ifndef ENDMEM_H 2 | #define ENDMEM_H 3 | 4 | #include "types.h" 5 | 6 | extern eop* Bank0datr16[256]; 7 | extern eop* Bank0datr8[256]; 8 | extern eop* Bank0datw16[256]; 9 | extern eop* Bank0datw8[256]; 10 | extern eop* opcjmptab[256]; 11 | 12 | extern eop* tableA[256]; 13 | extern eop* tableAc[256]; 14 | extern eop* SA1tableA[256]; 15 | extern eop* tableB[256]; 16 | extern eop* tableBc[256]; 17 | extern eop* SA1tableB[256]; 18 | extern eop* tableC[256]; 19 | extern eop* tableCc[256]; 20 | extern eop* SA1tableC[256]; 21 | extern eop* tableD[256]; 22 | extern eop* tableDc[256]; 23 | extern eop* SA1tableD[256]; 24 | extern eop* tableE[256]; 25 | extern eop* tableEc[256]; 26 | extern eop* SA1tableE[256]; 27 | extern eop* tableF[256]; 28 | extern eop* tableFc[256]; 29 | extern eop* SA1tableF[256]; 30 | extern eop* tableG[256]; 31 | extern eop* tableGc[256]; 32 | extern eop* SA1tableG[256]; 33 | extern eop* tableH[256]; 34 | extern eop* tableHc[256]; 35 | extern eop* SA1tableH[256]; 36 | extern eop** tablead[256]; 37 | extern eop** tableadc[256]; 38 | extern eop** SA1tablead[256]; 39 | 40 | extern u1 SpecialLine[256]; 41 | extern u1 cachebg[4][64]; 42 | extern u1 sprcnt[256]; 43 | extern u1 sprend[256]; 44 | extern u1 sprleftpr1[256]; // sprites left for priority 1 45 | extern u1 sprleftpr2[256]; // sprites left for priority 2 46 | extern u1 sprleftpr3[256]; // sprites left for priority 3 47 | extern u1 sprleftpr[256]; // sprites left for priority 0 48 | extern u1 sprlefttot[256]; // total sprites left 49 | extern u1 sprpriodata[288]; 50 | extern u1 sprstart[256]; 51 | extern u1 sprtilecnt[256]; 52 | extern u1 winbgbackenval[256]; 53 | extern u1 winbgdata[288]; // window buffer for backgrounds 54 | extern u1 winspdata[288]; // window buffer for sprites 55 | extern u1* snesmap2[256]; 56 | extern u1* snesmmap[256]; 57 | extern u2 PrevPicture[56 * 64]; 58 | extern u2 prevpal[256]; // previous palette buffer 59 | extern u2 sprendx[256]; 60 | extern u2 vidmemch4[2048]; 61 | extern u2 xtravbuf[288]; 62 | extern u4 FxTable[256]; 63 | extern u4 FxTableb[256]; 64 | extern u4 FxTablec[256]; 65 | extern u4 FxTabled[256]; 66 | extern u4 PLOTJmpa[64]; 67 | extern u4 PLOTJmpb[64]; 68 | extern u4 fxbit01[256]; 69 | extern u4 fxbit23[256]; 70 | extern u4 fxbit45[256]; 71 | extern u4 fxbit67[256]; 72 | extern u4 ngpalcon2b[32]; 73 | extern u4 ngpalcon4b[32]; 74 | extern u4 objwlrpos[256]; 75 | extern u4 pal16b[256]; 76 | extern u4 pal16bcl[256]; 77 | extern u4 pal16bxcl[256]; 78 | 79 | #endif 80 | -------------------------------------------------------------------------------- /chips/fxemu2b.mac: -------------------------------------------------------------------------------- 1 | ;Copyright (C) 1997-2008 ZSNES Team ( zsKnight, _Demo_, pagefault, Nach ) 2 | ; 3 | ;http://www.zsnes.com 4 | ;http://sourceforge.net/projects/zsnes 5 | ;https://zsnes.bountysource.com 6 | ; 7 | ;This program is free software; you can redistribute it and/or 8 | ;modify it under the terms of the GNU General Public License 9 | ;version 2 as published by the Free Software Foundation. 10 | ; 11 | ;This program is distributed in the hope that it will be useful, 12 | ;but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | ;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | ;GNU General Public License for more details. 15 | ; 16 | ;You should have received a copy of the GNU General Public License 17 | ;along with this program; if not, write to the Free Software 18 | ;Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | %macro TORNb 1 ; V 29 | FETCHPIPE 30 | test dword[SfxB],1 31 | jnz .VersionB 32 | mov edi, SfxR0+%1*4 33 | inc ebp ; Increase program counter 34 | mov eax,ebp 35 | sub eax,[SfxCPB] 36 | mov dword[withr15sk],1 37 | mov [SfxR15],eax 38 | call [FxTableb+ecx*4] 39 | mov edi,SfxR0 40 | ret 41 | .VersionB 42 | mov eax,[esi] ; Read Source 43 | mov dword[withr15sk],1 44 | inc ebp ; Increase program counter 45 | mov [SfxR0+%1*4],eax ; Write 46 | CLRFLAGS 47 | ret 48 | %endmacro 49 | 50 | %macro FROMRNb 1 ; V 51 | FETCHPIPE 52 | test dword[SfxB],1 53 | jnz .VersionB 54 | mov esi,SfxR0+%1*4 55 | inc ebp ; Increase program counter 56 | call [FxTable+ecx*4] 57 | mov esi,SfxR0 58 | ret 59 | .VersionB 60 | mov eax,[SfxR0+%1*4] ; Read 61 | inc ebp 62 | mov [edi],eax ; Write Destination 63 | mov [SfxSignZero],eax 64 | shr al,7 65 | mov [SfxOverflow],al 66 | CLRFLAGS 67 | ret 68 | %endmacro 69 | 70 | %macro TORNc 1 ; V 71 | FETCHPIPE 72 | mov eax,[esi] ; Read Source 73 | inc ebp ; Increase program counter 74 | mov [SfxR0+%1*4],eax ; Write 75 | CLRFLAGS 76 | ret 77 | %endmacro 78 | 79 | 80 | %macro FROMRNc 1 ; V 81 | FETCHPIPE 82 | mov eax,[SfxR0+%1*4] ; Read 83 | inc ebp 84 | mov [edi],eax ; Write Destination 85 | mov [SfxSignZero],eax 86 | shr al,7 87 | mov [SfxOverflow],al 88 | CLRFLAGS 89 | ret 90 | %endmacro 91 | 92 | 93 | -------------------------------------------------------------------------------- /macros.mac: -------------------------------------------------------------------------------- 1 | ;Copyright (C) 1997-2008 ZSNES Team ( zsKnight, _Demo_, pagefault, Nach ) 2 | ; 3 | ;http://www.zsnes.com 4 | ;http://sourceforge.net/projects/zsnes 5 | ;https://zsnes.bountysource.com 6 | ; 7 | ;This program is free software; you can redistribute it and/or 8 | ;modify it under the terms of the GNU General Public License 9 | ;version 2 as published by the Free Software Foundation. 10 | ; 11 | ;This program is distributed in the hope that it will be useful, 12 | ;but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | ;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | ;GNU General Public License for more details. 15 | ; 16 | ;You should have received a copy of the GNU General Public License 17 | ;along with this program; if not, write to the Free Software 18 | ;Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 | 20 | 21 | %ifdef __AMD64__ 22 | bits 64 23 | %else 24 | bits 32 25 | %endif 26 | 27 | section .text 28 | ; Zsnes required macros 29 | 30 | %ifdef MACHO 31 | section .text align=16 32 | section .data align=4 33 | section .bss align=4 34 | %endif 35 | 36 | %ifdef ELF 37 | 38 | %imacro newsym 1 39 | GLOBAL %1 40 | %1: 41 | %endmacro 42 | %imacro newsym 2+ 43 | GLOBAL %1 44 | %1: %2 45 | %endmacro 46 | %define EXTSYM EXTERN 47 | 48 | section .note.GNU-stack noalloc noexec nowrite progbits 49 | 50 | %else 51 | 52 | %imacro newsym 1 53 | GLOBAL _%1 54 | _%1: 55 | %1: 56 | %endmacro 57 | %imacro newsym 2+ 58 | GLOBAL _%1 59 | _%1: 60 | %1: %2 61 | %endmacro 62 | %imacro EXTSYM 1-* 63 | %rep %0 64 | EXTERN _%1 65 | %define %1 _%1 66 | %rotate 1 67 | %endrep 68 | %endmacro 69 | %endif 70 | 71 | %macro ALIGN32 0 72 | times ($$-$) & 1Fh nop ; Long word alignment 73 | %endmacro 74 | %macro ALIGN16 0 75 | times ($$-$) & 1Fh nop ; Long word alignment 76 | %endmacro 77 | 78 | %macro ccall 1-* 79 | push ecx 80 | push edx 81 | %ifdef MACHO 82 | mov edx, esp 83 | sub esp, %0 * 4 84 | and esp, 0xFFFFFFF0 ; Align the stack pointer 85 | %if %0 != 1 86 | add esp, %0 * 4 87 | push edx 88 | mov edx, [edx] 89 | %else 90 | mov [esp], edx 91 | %endif 92 | %endif 93 | %rep %0 - 1 94 | %rotate -1 95 | push dword %1 96 | %endrep 97 | %rotate -1 98 | call %1 99 | %ifdef MACHO 100 | mov esp, [esp + (%0 - 1) * 4] 101 | %elif %0 != 1 102 | add esp, (%0 - 1) * 4 103 | %endif 104 | pop edx 105 | pop ecx 106 | %endmacro 107 | 108 | %macro ccallv 1+ 109 | push eax 110 | ccall %1 111 | pop eax 112 | %endmacro 113 | -------------------------------------------------------------------------------- /jma/aribitcd.h: -------------------------------------------------------------------------------- 1 | #ifndef __COMPRESSION_BITCODER_H 2 | #define __COMPRESSION_BITCODER_H 3 | 4 | #include "rngcoder.h" 5 | 6 | namespace NCompression { 7 | namespace NArithmetic { 8 | 9 | const int kNumBitModelTotalBits = 11; 10 | const UINT32 kBitModelTotal = (1 << kNumBitModelTotalBits); 11 | 12 | const int kNumMoveReducingBits = 2; 13 | 14 | ///////////////////////////// 15 | // CBitModel 16 | 17 | template 18 | class CBitModel { 19 | public: 20 | UINT32 m_Probability; 21 | void UpdateModel(UINT32 aSymbol) 22 | { 23 | /* 24 | m_Probability -= (m_Probability + ((aSymbol - 1) & ((1 << aNumMoveBits) - 1))) >> aNumMoveBits; 25 | m_Probability += (1 - aSymbol) << (kNumBitModelTotalBits - aNumMoveBits); 26 | */ 27 | if (aSymbol == 0) 28 | m_Probability += (kBitModelTotal - m_Probability) >> aNumMoveBits; 29 | else 30 | m_Probability -= (m_Probability) >> aNumMoveBits; 31 | } 32 | 33 | public: 34 | void Init() { m_Probability = kBitModelTotal / 2; } 35 | }; 36 | 37 | template 38 | class CBitDecoder : public CBitModel { 39 | public: 40 | UINT32 Decode(CRangeDecoder* aRangeDecoder) 41 | { 42 | UINT32 aNewBound = (aRangeDecoder->m_Range >> kNumBitModelTotalBits) * CBitModel::m_Probability; 43 | if (aRangeDecoder->m_Code < aNewBound) { 44 | aRangeDecoder->m_Range = aNewBound; 45 | CBitModel::m_Probability += (kBitModelTotal - CBitModel::m_Probability) >> aNumMoveBits; 46 | if (aRangeDecoder->m_Range < kTopValue) { 47 | aRangeDecoder->m_Code = (aRangeDecoder->m_Code << 8) | aRangeDecoder->m_Stream.ReadByte(); 48 | aRangeDecoder->m_Range <<= 8; 49 | } 50 | return 0; 51 | } else { 52 | aRangeDecoder->m_Range -= aNewBound; 53 | aRangeDecoder->m_Code -= aNewBound; 54 | CBitModel::m_Probability -= (CBitModel::m_Probability) >> aNumMoveBits; 55 | if (aRangeDecoder->m_Range < kTopValue) { 56 | aRangeDecoder->m_Code = (aRangeDecoder->m_Code << 8) | aRangeDecoder->m_Stream.ReadByte(); 57 | aRangeDecoder->m_Range <<= 8; 58 | } 59 | return 1; 60 | } 61 | } 62 | }; 63 | 64 | } 65 | } 66 | 67 | #endif 68 | -------------------------------------------------------------------------------- /video/makev16b.asm: -------------------------------------------------------------------------------- 1 | ;Copyright (C) 1997-2008 ZSNES Team ( zsKnight, _Demo_, pagefault, Nach ) 2 | ; 3 | ;http://www.zsnes.com 4 | ;http://sourceforge.net/projects/zsnes 5 | ;https://zsnes.bountysource.com 6 | ; 7 | ;This program is free software; you can redistribute it and/or 8 | ;modify it under the terms of the GNU General Public License 9 | ;version 2 as published by the Free Software Foundation. 10 | ; 11 | ;This program is distributed in the hope that it will be useful, 12 | ;but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | ;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | ;GNU General Public License for more details. 15 | ; 16 | ;You should have received a copy of the GNU General Public License 17 | ;along with this program; if not, write to the Free Software 18 | ;Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 | 20 | 21 | 22 | %include "macros.mac" 23 | 24 | EXTSYM winon 25 | EXTSYM curvidoffset 26 | EXTSYM winptrref,xtravbuf 27 | 28 | ;drawspritesprio 29 | 30 | SECTION .bss 31 | NEWSYM tileleft16b, resb 1 32 | SECTION .text 33 | 34 | NEWSYM domosaic16b 35 | mov esi,xtravbuf+32 36 | mov edi,[curvidoffset] 37 | mov dl,dh 38 | mov cl,0 39 | mov ax,[esi] 40 | cmp byte[winon],0 41 | jne near domosaicwin16b 42 | test ax,0FFFFh 43 | jz .zeroloop 44 | .loopm 45 | mov [edi],ax 46 | add esi,2 47 | add edi,2 48 | dec cl 49 | jz .doneloop 50 | dec dl 51 | jnz .loopm 52 | mov ax,[esi] 53 | mov dl,dh 54 | test ax,0FFFFh 55 | jnz .loopm 56 | .zeroloop 57 | add esi,2 58 | add edi,2 59 | dec cl 60 | jz .doneloop 61 | dec dl 62 | jnz .zeroloop 63 | mov ax,[esi] 64 | mov dl,dh 65 | test ax,0FFFFh 66 | jnz .loopm 67 | jmp .zeroloop 68 | .doneloop 69 | ret 70 | 71 | NEWSYM domosaicwin16b 72 | mov ebp,[winptrref] 73 | test ax,0FFFFh 74 | jz .zeroloop 75 | .loopm 76 | cmp byte[ebp],0 77 | jne .nozero 78 | mov [edi],ax 79 | .nozero 80 | add esi,2 81 | add edi,2 82 | inc ebp 83 | dec cl 84 | jz .doneloop 85 | dec dl 86 | jnz .loopm 87 | mov ax,[esi] 88 | mov dl,dh 89 | test ax,0FFFFh 90 | jnz .loopm 91 | .zeroloop 92 | add esi,2 93 | add edi,2 94 | inc ebp 95 | dec cl 96 | jz .doneloop 97 | dec dl 98 | jnz .zeroloop 99 | mov ax,[esi] 100 | mov dl,dh 101 | test ax,0FFFFh 102 | jnz .loopm 103 | jmp .zeroloop 104 | .doneloop 105 | ret 106 | -------------------------------------------------------------------------------- /jma/jma.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2005-2008 NSRT Team ( http://nsrt.edgeemu.com ) 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | version 2 as published by the Free Software Foundation. 7 | 8 | This program is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | GNU General Public License for more details. 12 | 13 | You should have received a copy of the GNU General Public License 14 | along with this program; if not, write to the Free Software 15 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 16 | */ 17 | 18 | #ifndef JMA_H 19 | #define JMA_H 20 | 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | 27 | namespace JMA { 28 | enum jma_errors { JMA_NO_CREATE, 29 | JMA_NO_MEM_ALLOC, 30 | JMA_NO_OPEN, 31 | JMA_BAD_FILE, 32 | JMA_UNSUPPORTED_VERSION, 33 | JMA_COMPRESS_FAILED, 34 | JMA_DECOMPRESS_FAILED, 35 | JMA_FILE_NOT_FOUND }; 36 | 37 | struct jma_file_info_base { 38 | std::string name; 39 | std::string comment; 40 | size_t size; 41 | unsigned int crc32; 42 | }; 43 | 44 | struct jma_public_file_info : jma_file_info_base { 45 | time_t datetime; 46 | }; 47 | 48 | struct jma_file_info : jma_file_info_base { 49 | unsigned short date; 50 | unsigned short time; 51 | const unsigned char* buffer; 52 | }; 53 | 54 | template 55 | inline size_t get_total_size(std::vector& files) 56 | { 57 | size_t size = 0; 58 | for (typename std::vector::iterator i = files.begin(); i != files.end(); i++) { 59 | size += i->size; // We do have a problem if this wraps around 60 | } 61 | 62 | return (size); 63 | } 64 | 65 | class jma_open { 66 | public: 67 | jma_open(const char*) throw(jma_errors); 68 | ~jma_open(); 69 | 70 | std::vector get_files_info(); 71 | std::vector get_all_files(unsigned char*) throw(jma_errors); 72 | void extract_file(std::string& name, unsigned char*) throw(jma_errors); 73 | bool is_solid(); 74 | 75 | private: 76 | std::ifstream stream; 77 | std::vector files; 78 | size_t chunk_size; 79 | unsigned char* decompressed_buffer; 80 | unsigned char* compressed_buffer; 81 | 82 | void chunk_seek(unsigned int) throw(jma_errors); 83 | void retrieve_file_block() throw(jma_errors); 84 | }; 85 | 86 | const char* jma_error_text(jma_errors); 87 | } 88 | #endif 89 | -------------------------------------------------------------------------------- /jma/portable.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2004-2008 NSRT Team ( http://nsrt.edgeemu.com ) 3 | Copyright (C) 2002 Andrea Mazzoleni ( http://advancemame.sf.net ) 4 | 5 | This program is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU General Public License 7 | version 2 as published by the Free Software Foundation. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, write to the Free Software 16 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #ifndef __PORTABLE_H 20 | #define __PORTABLE_H 21 | 22 | #include 23 | #include 24 | 25 | typedef int8_t INT8; 26 | typedef uint8_t UINT8; 27 | typedef int16_t INT16; 28 | typedef uint16_t UINT16; 29 | typedef int32_t INT32; 30 | typedef uint32_t UINT32; 31 | typedef int64_t INT64; 32 | typedef uint64_t UINT64; 33 | 34 | typedef UINT8 BYTE; 35 | typedef UINT16 WORD; 36 | typedef UINT32 DWORD; 37 | 38 | typedef unsigned UINT_PTR; 39 | 40 | typedef int BOOL; 41 | #define FALSE 0 42 | #define TRUE 1 43 | 44 | #define HRESULT int 45 | #define S_OK 0 46 | #define E_INVALIDARG -1 47 | #define E_OUTOFMEMORY -2 48 | #define E_FAIL -3 49 | #define E_INTERNAL_ERROR -4 50 | #define E_INVALIDDATA -5 51 | 52 | template 53 | inline T MyMin(T a, T b) 54 | { 55 | return a < b ? a : b; 56 | } 57 | 58 | template 59 | inline T MyMax(T a, T b) 60 | { 61 | return a > b ? a : b; 62 | } 63 | 64 | #define RETURN_IF_NOT_S_OK(x) \ 65 | { \ 66 | HRESULT __aResult_ = (x); \ 67 | if (__aResult_ != S_OK) \ 68 | return __aResult_; \ 69 | } 70 | 71 | #define UINT_SIZE (4) 72 | #define USHORT_SIZE (2) 73 | 74 | // Convert an array of 4 bytes back into an integer 75 | inline unsigned int charp_to_uint(const unsigned char buffer[UINT_SIZE]) 76 | { 77 | unsigned int num = (unsigned int)buffer[3]; 78 | num |= ((unsigned int)buffer[2]) << 8; 79 | num |= ((unsigned int)buffer[1]) << 16; 80 | num |= ((unsigned int)buffer[0]) << 24; 81 | return (num); 82 | } 83 | 84 | // Convert an array of 2 bytes back into a short integer 85 | inline unsigned short charp_to_ushort(const unsigned char buffer[USHORT_SIZE]) 86 | { 87 | unsigned short num = (unsigned short)buffer[1]; 88 | num |= ((unsigned short)buffer[0]) << 8; 89 | return (num); 90 | } 91 | 92 | #endif 93 | -------------------------------------------------------------------------------- /video/newgfx16.h: -------------------------------------------------------------------------------- 1 | #ifndef NEWGFX16_H 2 | #define NEWGFX16_H 3 | 4 | #include "../types.h" 5 | 6 | extern void mosdraw216b(); 7 | extern void mosdraw316b(); 8 | extern void mosdraw416b(); 9 | extern void mosdraw516b(); 10 | extern void mosdraw616b(); 11 | extern void mosdraw716b(); 12 | extern void mosdraw816b(); 13 | extern void mosdraw916b(); 14 | extern void mosdraw1016b(); 15 | extern void mosdraw1116b(); 16 | extern void mosdraw1216b(); 17 | extern void mosdraw1316b(); 18 | extern void mosdraw1416b(); 19 | extern void mosdraw1516b(); 20 | extern void mosdraw1616b(); 21 | 22 | extern void mosdraw216bt(); 23 | extern void mosdraw316bt(); 24 | extern void mosdraw416bt(); 25 | extern void mosdraw516bt(); 26 | extern void mosdraw616bt(); 27 | extern void mosdraw716bt(); 28 | extern void mosdraw816bt(); 29 | extern void mosdraw916bt(); 30 | extern void mosdraw1016bt(); 31 | extern void mosdraw1116bt(); 32 | extern void mosdraw1216bt(); 33 | extern void mosdraw1316bt(); 34 | extern void mosdraw1416bt(); 35 | extern void mosdraw1516bt(); 36 | extern void mosdraw1616bt(); 37 | 38 | extern void mosdraw216btms(); 39 | extern void mosdraw316btms(); 40 | extern void mosdraw416btms(); 41 | extern void mosdraw516btms(); 42 | extern void mosdraw616btms(); 43 | extern void mosdraw716btms(); 44 | extern void mosdraw816btms(); 45 | extern void mosdraw916btms(); 46 | extern void mosdraw1016btms(); 47 | extern void mosdraw1116btms(); 48 | extern void mosdraw1216btms(); 49 | extern void mosdraw1316btms(); 50 | extern void mosdraw1416btms(); 51 | extern void mosdraw1516btms(); 52 | extern void mosdraw1616btms(); 53 | 54 | extern void mosdraw216bntms(); 55 | extern void mosdraw316bntms(); 56 | extern void mosdraw416bntms(); 57 | extern void mosdraw516bntms(); 58 | extern void mosdraw616bntms(); 59 | extern void mosdraw716bntms(); 60 | extern void mosdraw816bntms(); 61 | extern void mosdraw916bntms(); 62 | extern void mosdraw1016bntms(); 63 | extern void mosdraw1116bntms(); 64 | extern void mosdraw1216bntms(); 65 | extern void mosdraw1316bntms(); 66 | extern void mosdraw1416bntms(); 67 | extern void mosdraw1516bntms(); 68 | extern void mosdraw1616bntms(); 69 | 70 | extern eop* mosjmptab16b[15]; 71 | extern eop* mosjmptab16bntms[15]; 72 | extern eop* mosjmptab16bt[15]; 73 | extern eop* mosjmptab16btms[15]; 74 | extern u4 BackAreaAdd; 75 | extern u4 BackAreaFillCol; 76 | extern u4 BackAreaUnFillCol; 77 | extern u4 HalfTransB[2]; 78 | extern u4 HalfTransC[2]; 79 | extern u4 HalfTrans[2]; 80 | extern u4 UnusedBitXor[2]; 81 | extern u4 UnusedBit[2]; 82 | extern u4 cpalptrng; 83 | extern u4 ngbposng; 84 | extern u4 nggposng; 85 | extern u4 ngmsdraw; 86 | extern u4 ngrposng; 87 | extern u4 palchanged; 88 | 89 | #endif 90 | -------------------------------------------------------------------------------- /cpu/c_irq.c: -------------------------------------------------------------------------------- 1 | #include "../chips/fxemu2.h" 2 | #include "../endmem.h" 3 | #include "../init.h" 4 | #include "../initc.h" 5 | #include "c_irq.h" 6 | #include "execute.h" 7 | #include "memory.h" 8 | #include "regs.h" 9 | 10 | 11 | static u4 makedl(u4 edx) 12 | { 13 | edx &= 0xFFFFFF3C; 14 | if ((flagnz & 0x00018000) != 0) edx |= 0x00000080; // Negative. 15 | if ((flagnz & 0x0000FFFF) == 0) edx |= 0x00000002; // Zero. 16 | if ((flagc & 0x000000FF) != 0) edx |= 0x00000001; // Carry. 17 | if ((flago & 0x000000FF) != 0) edx |= 0x00000040; // Overflow. 18 | return edx; 19 | } 20 | 21 | 22 | static void call_membank0w8(u2 const cx, u1 const al) 23 | { 24 | u4 eax; 25 | u4 ecx; 26 | u4 ebx; 27 | asm volatile("call %P3" : "=a" (eax), "=c" (ecx), "=b" (ebx) : "X" (membank0w8), "a" (al), "c" (cx) : "cc", "memory"); 28 | } 29 | 30 | 31 | void IRQemulmode(u4* const pedx, u1** const pesi) 32 | { 33 | xpc = *pesi - initaddrl; 34 | 35 | u2 cx = xs; 36 | 37 | call_membank0w8(cx, (u1)(xpc >> 8)); 38 | cx = (cx - 1) & stackand | stackor; 39 | 40 | call_membank0w8(cx, (u1)xpc); 41 | cx = (cx - 1) & stackand | stackor; 42 | 43 | u4 const edx = makedl(*pedx); 44 | call_membank0w8(cx, (u1)edx); 45 | cx = (cx - 1) & stackand | stackor; 46 | 47 | xs = cx; 48 | 49 | u2 const ax = irqv8; 50 | xpb = 0; 51 | xpc = ax; 52 | u1* const esi = ax & 0x8000 ? snesmmap[0] : snesmap2[0]; 53 | initaddrl = esi; 54 | 55 | *pedx = edx & 0xFFFFFFF3 | 0x00000004; 56 | *pesi = esi + ax; 57 | } 58 | 59 | 60 | void switchtovirq(u4* const pedx, u1** const pesi) 61 | { 62 | irqon = 0x80; 63 | 64 | #if 0 // XXX 0x00 seems wrong 65 | if (doirqnext & 0x02) edx = edx & 0xFFFF00FF | ((edx - (3 << 8)) & 0x0000FF00); // Cycle adjust. 66 | #endif 67 | 68 | if (xe & 0x01) 69 | { // IRQ emulation mode. 70 | IRQemulmode(pedx, pesi); 71 | } 72 | else 73 | { 74 | xpc = *pesi - initaddrl; 75 | 76 | u2 cx = xs; 77 | 78 | call_membank0w8(cx, xpb); 79 | cx = (cx - 1) & stackand | stackor; 80 | 81 | call_membank0w8(cx, (u1)(xpc >> 8)); 82 | cx = (cx - 1) & stackand | stackor; 83 | 84 | call_membank0w8(cx, (u1)xpc); 85 | cx = (cx - 1) & stackand | stackor; 86 | 87 | u4 const edx = makedl(*pedx); 88 | call_membank0w8(cx, (u1)edx); 89 | cx = (cx - 1) & stackand | stackor; 90 | 91 | xs = cx; 92 | 93 | u1 const bl = xirqb; 94 | u2 const ax = SfxSCMR & 0x00000010 ? 0x010C /* SFX NMI */ : irqv; 95 | xpb = bl; 96 | xpc = ax; 97 | u1* const esi = ax & 0x8000 ? snesmmap[bl] : snesmap2[bl]; 98 | initaddrl = esi; 99 | 100 | *pedx = edx & 0xFFFFFFF3 | 0x00000004; 101 | *pesi = esi + ax; 102 | } 103 | } 104 | -------------------------------------------------------------------------------- /cpu/regsw.h: -------------------------------------------------------------------------------- 1 | #ifndef REGSW_H 2 | #define REGSW_H 3 | 4 | #include "../types.h" 5 | 6 | extern void reg2100w(); 7 | extern void reg2101w(); 8 | extern void reg2102w(); 9 | extern void reg2103w(); 10 | extern void reg2104w(); 11 | extern void reg2105w(); 12 | extern void reg2106w(); 13 | extern void reg2107w(); 14 | extern void reg2108w(); 15 | extern void reg2109w(); 16 | extern void reg210Aw(); 17 | extern void reg210Bw(); 18 | extern void reg210Cw(); 19 | extern void reg210Dw(); 20 | extern void reg210Ew(); 21 | extern void reg210Fw(); 22 | extern void reg2110w(); 23 | extern void reg2111w(); 24 | extern void reg2112w(); 25 | extern void reg2113w(); 26 | extern void reg2114w(); 27 | extern void reg2115w(); 28 | extern void reg2116w(); 29 | extern void reg2117w(); 30 | extern void reg2118(); 31 | extern void reg2119inc(); 32 | extern void reg211Aw(); 33 | extern void reg211Bw(); 34 | extern void reg211Cw(); 35 | extern void reg211Dw(); 36 | extern void reg211Ew(); 37 | extern void reg211Fw(); 38 | extern void reg2120w(); 39 | extern void reg2121w(); 40 | extern void reg2122w(); 41 | extern void reg2123w(); 42 | extern void reg2124w(); 43 | extern void reg2125w(); 44 | extern void reg2126w(); 45 | extern void reg2127w(); 46 | extern void reg2128w(); 47 | extern void reg2129w(); 48 | extern void reg212Aw(); 49 | extern void reg212Bw(); 50 | extern void reg212Cw(); 51 | extern void reg212Dw(); 52 | extern void reg212Ew(); 53 | extern void reg212Fw(); 54 | extern void reg2130w(); 55 | extern void reg2131w(); 56 | extern void reg2132w(); 57 | extern void reg2133w(); 58 | extern void reg2140w(); 59 | extern void reg2141w(); 60 | extern void reg2142w(); 61 | extern void reg2143w(); 62 | extern void reg2180w(); 63 | extern void reg2181w(); 64 | extern void reg2182w(); 65 | extern void reg2183w(); 66 | extern void reg4016w(); 67 | extern void reg4200w(); 68 | extern void reg4201w(); 69 | extern void reg4202w(); 70 | extern void reg4203w(); 71 | extern void reg4204w(); 72 | extern void reg4205w(); 73 | extern void reg4206w(); 74 | extern void reg4207w(); 75 | extern void reg4208w(); 76 | extern void reg4209w(); 77 | extern void reg420Aw(); 78 | extern void reg420Bw(); 79 | extern void reg420Cw(); 80 | extern void reg420Dw(); 81 | extern void reg43X0w(); 82 | extern void reg43X1w(); 83 | extern void reg43XAw(); 84 | extern void reg43XBw(); 85 | extern void reg43x2w(); 86 | extern void reg43x3w(); 87 | extern void reg43x4w(); 88 | extern void reg43x5w(); 89 | extern void reg43x6w(); 90 | extern void reg43x7w(); 91 | extern void reg43x8w(); 92 | extern void reg43x9w(); 93 | extern void regINVALIDw(); 94 | 95 | extern u1 multchange; 96 | extern u2 bg1scrolx_m7; 97 | extern u2 bg1scroly_m7; 98 | 99 | #endif 100 | -------------------------------------------------------------------------------- /chips/sfxproc.h: -------------------------------------------------------------------------------- 1 | #ifndef SFXPROC_H 2 | #define SFXPROC_H 3 | 4 | extern void cacheregr(); 5 | extern void reg3000r(); 6 | extern void reg3001r(); 7 | extern void reg3002r(); 8 | extern void reg3003r(); 9 | extern void reg3004r(); 10 | extern void reg3005r(); 11 | extern void reg3006r(); 12 | extern void reg3007r(); 13 | extern void reg3008r(); 14 | extern void reg3009r(); 15 | extern void reg300Ar(); 16 | extern void reg300Br(); 17 | extern void reg300Cr(); 18 | extern void reg300Dr(); 19 | extern void reg300Er(); 20 | extern void reg300Fr(); 21 | extern void reg3010r(); 22 | extern void reg3011r(); 23 | extern void reg3012r(); 24 | extern void reg3013r(); 25 | extern void reg3014r(); 26 | extern void reg3015r(); 27 | extern void reg3016r(); 28 | extern void reg3017r(); 29 | extern void reg3018r(); 30 | extern void reg3019r(); 31 | extern void reg301Ar(); 32 | extern void reg301Br(); 33 | extern void reg301Cr(); 34 | extern void reg301Dr(); 35 | extern void reg301Er(); 36 | extern void reg301Fr(); 37 | extern void reg3030r(); 38 | extern void reg3031r(); 39 | extern void reg3032r(); 40 | extern void reg3033r(); 41 | extern void reg3034r(); 42 | extern void reg3035r(); 43 | extern void reg3036r(); 44 | extern void reg3037r(); 45 | extern void reg3038r(); 46 | extern void reg3039r(); 47 | extern void reg303Ar(); 48 | extern void reg303Br(); 49 | extern void reg303Cr(); 50 | extern void reg303Dr(); 51 | extern void reg303Er(); 52 | extern void reg303Fr(); 53 | 54 | extern void cacheregw(); 55 | extern void reg3000w(); 56 | extern void reg3001w(); 57 | extern void reg3002w(); 58 | extern void reg3003w(); 59 | extern void reg3004w(); 60 | extern void reg3005w(); 61 | extern void reg3006w(); 62 | extern void reg3007w(); 63 | extern void reg3008w(); 64 | extern void reg3009w(); 65 | extern void reg300Aw(); 66 | extern void reg300Bw(); 67 | extern void reg300Cw(); 68 | extern void reg300Dw(); 69 | extern void reg300Ew(); 70 | extern void reg300Fw(); 71 | extern void reg3010w(); 72 | extern void reg3011w(); 73 | extern void reg3012w(); 74 | extern void reg3013w(); 75 | extern void reg3014w(); 76 | extern void reg3015w(); 77 | extern void reg3016w(); 78 | extern void reg3017w(); 79 | extern void reg3018w(); 80 | extern void reg3019w(); 81 | extern void reg301Aw(); 82 | extern void reg301Bw(); 83 | extern void reg301Cw(); 84 | extern void reg301Dw(); 85 | extern void reg301Ew(); 86 | extern void reg301Fw(); 87 | extern void reg3030w(); 88 | extern void reg3031w(); 89 | extern void reg3032w(); 90 | extern void reg3033w(); 91 | extern void reg3034w(); 92 | extern void reg3035w(); 93 | extern void reg3036w(); 94 | extern void reg3037w(); 95 | extern void reg3038w(); 96 | extern void reg3039w(); 97 | extern void reg303Aw(); 98 | extern void reg303Bw(); 99 | extern void reg303Cw(); 100 | extern void reg303Dw(); 101 | extern void reg303Ew(); 102 | extern void reg303Fw(); 103 | 104 | #endif 105 | -------------------------------------------------------------------------------- /cpu/dspproc.h: -------------------------------------------------------------------------------- 1 | #ifndef DSPPROC_H 2 | #define DSPPROC_H 3 | 4 | #include "../types.h" 5 | 6 | extern void BRRDecode(); 7 | extern void EchoMono(); 8 | extern void EchoMonoInterpolated(); 9 | extern void EchoMonoPM(); 10 | extern void EchoStereo(); 11 | extern void EchoStereoInterpolated(); 12 | extern void EchoStereoPM(); 13 | extern void NonEchoMono(); 14 | extern void NonEchoMonoInterpolated(); 15 | extern void NonEchoMonoPM(); 16 | extern void NonEchoStereo(); 17 | extern void NonEchoStereoInterpolated(); 18 | extern void NonEchoStereoPM(); 19 | extern void ProcessSoundBuffer(); 20 | 21 | typedef s4 interpolatefunc(u4 edx, u4 ebp); 22 | extern interpolatefunc* DSPInterpolate; 23 | 24 | extern eop* spcRptr[16]; 25 | extern eop* spcWptr[16]; 26 | extern s2 BRRreadahead[4]; 27 | extern s2* Voice0BufPtr[8]; // Ptr to Buffer Block to be played 28 | extern s4 DSPBuffer[320 * 4]; // The play buffer 29 | extern s4 EchoBuffer[320 * 4]; // The play buffer 30 | extern s4 EchoFB; 31 | extern s4 FIRTAPVal0[8]; 32 | extern s4 FiltLoopR[16]; 33 | extern s4 FiltLoop[16]; 34 | extern s4 LPFsample1; 35 | extern s4 LPFsample2; 36 | extern u1 AdsrBlocksLeft[8]; 37 | extern u1 AdsrSustLevLoc[8]; 38 | extern u1 EchoVL; 39 | extern u1 EchoVR; 40 | extern u1 GainDecBendDataDat[8]; 41 | extern u1 GainDecBendDataPos[8]; 42 | extern u1 GlobalVL; 43 | extern u1 GlobalVR; 44 | extern u1 SBHDMA; 45 | extern u1 SoundLooped0[8]; 46 | extern u1 StatTemp[8]; 47 | extern u1 UniqueSoundv; 48 | extern u1 Voice0End[8]; 49 | extern u1 Voice0FirstBlock[8]; 50 | extern u1 Voice0Loop[8]; 51 | extern u1 Voice0State[8]; 52 | extern u1 Voice0Status[8]; // 0=Not Playing 1=Playing 53 | extern u1 Voice0VolumeL[8]; 54 | extern u1 Voice0VolumeLe[8]; 55 | extern u1 Voice0VolumeR[8]; 56 | extern u1 Voice0VolumeRe[8]; 57 | extern u1 Voice0Volume[8]; 58 | extern u1 Voice0Volumee[8]; 59 | extern u1 echoon0[8]; 60 | extern u1 lastbl; // Last block if = 1 61 | extern u1 loopbl; // Loop if = 1 62 | extern u2 DSPInterP[1024]; 63 | extern u2 Voice0Pitch[8]; 64 | extern u4 AdsrNextTimeDepth[8]; 65 | extern u4 AttackRate[]; 66 | extern u4 BRRPlace0[8][2]; 67 | extern u4 BufferSizeB; 68 | extern u4 BufferSizeW; 69 | extern u4 CEchoPtr; 70 | extern u4 DLPFsamples[8][24]; 71 | extern u4 DecayRate[]; 72 | extern u4 DecreaseRateExp[]; 73 | extern u4 Decrease[]; 74 | extern u4 EchoRate[]; 75 | extern u4 EnvITemp[8]; 76 | extern u4 GainDecBendDataTime[8]; 77 | extern u4 IncNTemp[8]; 78 | extern u4 IncreaseBent[]; 79 | extern u4 Increase[]; 80 | extern u4 MaxEcho; 81 | extern u4 PSampleBuf[8][24]; 82 | extern u4 SustainRate[]; 83 | extern u4 TimeTemp[8]; 84 | extern u4 Voice0EnvInc[8]; 85 | extern u4 Voice0Freq[8]; // Frequency of Voice (Delta Freq) 86 | extern u4 Voice0IncNumber[8]; 87 | extern u4 Voice0LoopPtr[8]; 88 | extern u4 Voice0Prev0[8]; 89 | extern u4 Voice0Prev1[8]; 90 | extern u4 Voice0Ptr[8]; 91 | extern u4 Voice0Time[8]; 92 | extern u4 dspPAdj; 93 | extern u4 powhack; 94 | extern u4 prev0; // previous value 1 95 | extern u4 prev1; // previous value 2 96 | 97 | #endif 98 | -------------------------------------------------------------------------------- /jma/winout.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2002 Andrea Mazzoleni ( http://advancemame.sf.net ) 3 | Copyright (C) 2001-4 Igor Pavlov ( http://www.7-zip.org ) 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License version 2.1 as published by the Free Software Foundation. 8 | 9 | This library is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public 15 | License along with this library; if not, write to the Free Software 16 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 | */ 18 | 19 | #include "winout.h" 20 | 21 | namespace NStream { 22 | namespace NWindow { 23 | 24 | void COut::Create(UINT32 aKeepSizeBefore, UINT32 aKeepSizeAfter, UINT32 aKeepSizeReserv) 25 | { 26 | m_Pos = 0; 27 | m_PosLimit = aKeepSizeReserv + aKeepSizeBefore; 28 | m_KeepSizeBefore = aKeepSizeBefore; 29 | m_KeepSizeAfter = aKeepSizeAfter; 30 | m_KeepSizeReserv = aKeepSizeReserv; 31 | m_StreamPos = 0; 32 | m_MoveFrom = m_KeepSizeReserv; 33 | m_WindowSize = aKeepSizeBefore; 34 | UINT32 aBlockSize = m_KeepSizeBefore + m_KeepSizeAfter + m_KeepSizeReserv; 35 | delete[] m_Buffer; 36 | m_Buffer = new BYTE[aBlockSize]; 37 | } 38 | 39 | COut::~COut() 40 | { 41 | delete[] m_Buffer; 42 | } 43 | 44 | void COut::SetWindowSize(UINT32 aWindowSize) 45 | { 46 | m_WindowSize = aWindowSize; 47 | m_MoveFrom = m_KeepSizeReserv + m_KeepSizeBefore - aWindowSize; 48 | } 49 | 50 | void COut::Init(ISequentialOutStream* aStream, bool aSolid) 51 | { 52 | m_Stream = aStream; 53 | 54 | if (aSolid) 55 | m_StreamPos = m_Pos; 56 | else { 57 | m_Pos = 0; 58 | m_PosLimit = m_KeepSizeReserv + m_KeepSizeBefore; 59 | m_StreamPos = 0; 60 | } 61 | } 62 | 63 | HRESULT COut::Flush() 64 | { 65 | UINT32 aSize = m_Pos - m_StreamPos; 66 | if (aSize == 0) 67 | return S_OK; 68 | UINT32 aProcessedSize; 69 | HRESULT aResult = m_Stream->Write(m_Buffer + m_StreamPos, aSize, &aProcessedSize); 70 | if (aResult != S_OK) 71 | return aResult; 72 | if (aSize != aProcessedSize) 73 | return E_FAIL; 74 | m_StreamPos = m_Pos; 75 | return S_OK; 76 | } 77 | 78 | void COut::MoveBlockBackward() 79 | { 80 | HRESULT aResult = Flush(); 81 | if (aResult != S_OK) 82 | throw aResult; 83 | memmove(m_Buffer, m_Buffer + m_MoveFrom, m_WindowSize + m_KeepSizeAfter); 84 | m_Pos -= m_MoveFrom; 85 | m_StreamPos -= m_MoveFrom; 86 | } 87 | 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /win/winintrf.asm: -------------------------------------------------------------------------------- 1 | ;Copyright (C) 1997-2008 ZSNES Team ( zsKnight, _Demo_, pagefault, Nach ) 2 | ; 3 | ;http://www.zsnes.com 4 | ;http://sourceforge.net/projects/zsnes 5 | ;https://zsnes.bountysource.com 6 | ; 7 | ;This program is free software; you can redistribute it and/or 8 | ;modify it under the terms of the GNU General Public License 9 | ;version 2 as published by the Free Software Foundation. 10 | ; 11 | ;This program is distributed in the hope that it will be useful, 12 | ;but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | ;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | ;GNU General Public License for more details. 15 | ; 16 | ;You should have received a copy of the GNU General Public License 17 | ;along with this program; if not, write to the Free Software 18 | ;Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 | 20 | 21 | 22 | %include "macros.mac" 23 | 24 | ; NOTE: For timing, Game60hzcall should be called at 50hz or 60hz (depending 25 | ; on romispal) after a call to InitPreGame and before DeInitPostGame are 26 | ; made. GUI36hzcall should be called at 36hz after a call GUIInit and 27 | ; before GUIDeInit. 28 | 29 | SECTION .data 30 | NEWSYM CurKeyPos, dd 0 31 | NEWSYM CurKeyReadPos, dd 0 32 | NEWSYM KeyBuffer, times 16 dd 0 33 | SECTION .text 34 | 35 | ; **************************** 36 | ; Video Stuff 37 | ; **************************** 38 | 39 | ; ** copy video mode functions ** 40 | SECTION .data 41 | NEWSYM converta, dd 0 42 | 43 | ; **************************** 44 | ; Input Device Stuff 45 | ; **************************** 46 | 47 | ; Variables related to Input Device Routines: 48 | ; pl1selk,pl1startk,pl1upk,pl1downk,pl1leftk,pl1rightk,pl1Xk, 49 | ; pl1Ak,pl1Lk,pl1Yk,pl1Bk,pl1Rk 50 | ; (Change 1 to 2,3,4 for other players) 51 | ; Each of these variables contains the corresponding key pressed value 52 | ; for the key data 53 | ; pressed[] 54 | ; - This is an array of pressed/released data (bytes) where the 55 | ; corresponding key pressed value is used as the index. The value 56 | ; for each entry is 0 for released and 1 for pressed. Also, when 57 | ; writing keyboard data to this array, be sure to first check if 58 | ; the value of the array entry is 2 or not. If it is 2, do not write 1 59 | ; to that array entry. (however, you can write 0 to it) 60 | ; As an example, to access Player 1 L button press data, it is 61 | ; done like : pressed[pl1Lk] 62 | ; The 3 character key description of that array entry is accessed by the 63 | ; GUI through ScanCodeListing[pl1Lk*3] 64 | 65 | ; Note: When storing the input device configuration of a dynamic input 66 | ; device system (ie. Win9x) rather than a static system (ie. Dos), it 67 | ; is best to store in the name of the device and relative button 68 | ; assignments in the configuration file, then convert it to ZSNES' 69 | ; numerical corresponding key format after reading from it. And then 70 | ; convert it back when writing to it back. 71 | -------------------------------------------------------------------------------- /linux/sdlintrf.asm: -------------------------------------------------------------------------------- 1 | ;Copyright (C) 1997-2008 ZSNES Team ( zsKnight, _Demo_, pagefault, Nach ) 2 | ; 3 | ;http://www.zsnes.com 4 | ;http://sourceforge.net/projects/zsnes 5 | ;https://zsnes.bountysource.com 6 | ; 7 | ;This program is free software; you can redistribute it and/or 8 | ;modify it under the terms of the GNU General Public License 9 | ;version 2 as published by the Free Software Foundation. 10 | ; 11 | ;This program is distributed in the hope that it will be useful, 12 | ;but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | ;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | ;GNU General Public License for more details. 15 | ; 16 | ;You should have received a copy of the GNU General Public License 17 | ;along with this program; if not, write to the Free Software 18 | ;Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 | 20 | 21 | 22 | %include "macros.mac" 23 | 24 | ; NOTE: For timing, Game60hzcall should be called at 50hz or 60hz (depending 25 | ; on romispal) after a call to InitPreGame and before DeInitPostGame are 26 | ; made. GUI36hzcall should be called at 36hz after a call GUIInit and 27 | ; before GUIDeInit. 28 | 29 | SECTION .data 30 | NEWSYM CurKeyPos, dd 0 31 | NEWSYM CurKeyReadPos, dd 0 32 | NEWSYM KeyBuffer, times 16 dd 0 33 | SECTION .text 34 | 35 | ; **************************** 36 | ; Video Stuff 37 | ; **************************** 38 | 39 | ; ** copy video mode functions ** 40 | SECTION .data 41 | NEWSYM converta, dd 0 42 | 43 | ; **************************** 44 | ; Input Device Stuff 45 | ; **************************** 46 | 47 | ; Variables related to Input Device Routines: 48 | ; pl1selk,pl1startk,pl1upk,pl1downk,pl1leftk,pl1rightk,pl1Xk, 49 | ; pl1Ak,pl1Lk,pl1Yk,pl1Bk,pl1Rk 50 | ; (Change 1 to 2,3,4 for other players) 51 | ; Each of these variables contains the corresponding key pressed value 52 | ; for the key data 53 | ; pressed[] 54 | ; - This is an array of pressed/released data (bytes) where the 55 | ; corresponding key pressed value is used as the index. The value 56 | ; for each entry is 0 for released and 1 for pressed. Also, when 57 | ; writing keyboard data to this array, be sure to first check if 58 | ; the value of the array entry is 2 or not. If it is 2, do not write 1 59 | ; to that array entry. (however, you can write 0 to it) 60 | ; As an example, to access Player 1 L button press data, it is 61 | ; done like : pressed[pl1Lk] 62 | ; The 3 character key description of that array entry is accessed by the 63 | ; GUI through ScanCodeListing[pl1Lk*3] 64 | 65 | ; Note: When storing the input device configuration of a dynamic input 66 | ; device system (ie. Win9x) rather than a static system (ie. Dos), it 67 | ; is best to store in the name of the device and relative button 68 | ; assignments in the configuration file, then convert it to ZSNES' 69 | ; numerical corresponding key format after reading from it. And then 70 | ; convert it back when writing to it back. 71 | -------------------------------------------------------------------------------- /win/winlink.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1997-2008 ZSNES Team ( zsKnight, _Demo_, pagefault, Nach ) 3 | 4 | http://www.zsnes.com 5 | http://sourceforge.net/projects/zsnes 6 | https://zsnes.bountysource.com 7 | 8 | This program is free software; you can redistribute it and/or 9 | modify it under the terms of the GNU General Public License 10 | version 2 as published by the Free Software Foundation. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program; if not, write to the Free Software 19 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 20 | */ 21 | 22 | #ifndef WINLINK_H 23 | #define WINLINK_H 24 | 25 | #include 26 | 27 | typedef HRESULT(WINAPI* lpDirectDrawCreateEx)(GUID FAR* lpGuid, LPVOID* lplpDD, REFIID iid, 28 | IUnknown FAR* pUnkOuter); 29 | 30 | #ifdef __cplusplus 31 | extern "C" { 32 | #endif 33 | extern BYTE changeRes; 34 | extern unsigned int BitConv32Ptr; 35 | extern unsigned int RGBtoYUVPtr; 36 | extern unsigned short resolutn; 37 | extern BYTE PrevRes; 38 | extern BYTE hqFilterlevel; 39 | extern WORD totlines; 40 | extern DWORD CurMode; 41 | extern DWORD WindowWidth; 42 | extern DWORD WindowHeight; 43 | extern BYTE BitDepth; 44 | extern DWORD GBitMask; 45 | extern WORD Refresh; 46 | extern DWORD FirstVid; 47 | extern DWORD FirstFull; 48 | extern DWORD DMode; 49 | extern DWORD SMode; 50 | extern DWORD DSMode; 51 | extern DWORD NTSCMode; 52 | extern DWORD prevHQMode; 53 | extern DWORD prevNTSCMode; 54 | extern DWORD prevScanlines; 55 | extern HWND hMainWindow; 56 | extern BYTE curblank; 57 | extern WORD totlines; 58 | extern DWORD FullScreen; 59 | extern RECT rcWindow; 60 | extern RECT BlitArea; 61 | extern BYTE AltSurface; 62 | extern lpDirectDrawCreateEx pDirectDrawCreateEx; 63 | extern BYTE* SurfBuf; 64 | extern int X; 65 | extern DWORD newmode; 66 | extern WINDOWPLACEMENT wndpl; 67 | extern RECT rc1; 68 | 69 | void Clear2xSaIBuffer(); 70 | void FrameSemaphore(void); 71 | void clear_display(); 72 | char CheckTVRatioReq(); 73 | void KeepTVRatio(); 74 | 75 | void CheckAlwaysOnTop(void); 76 | void CheckPriority(void); 77 | void CheckScreenSaver(void); 78 | void DisplayWIPDisclaimer(void); 79 | void DoSleep(void); 80 | void MinimizeWindow(void); 81 | void PasteClipBoard(void); 82 | void SetMouseMaxX(int MaxX); 83 | void SetMouseMaxY(int MaxY); 84 | void SetMouseMinX(int MinX); 85 | void SetMouseMinY(int MinY); 86 | void SetMouseX(int X); 87 | void SetMouseY(int Y); 88 | void WinUpdateDevices(void); 89 | void initDirectDraw(void); 90 | void reInitSound(void); 91 | 92 | extern BOOL ctrlptr; 93 | extern char* CBBuffer; 94 | extern u4 CBLength; 95 | 96 | #ifdef __cplusplus 97 | } 98 | 99 | BOOL ReInitSound(); 100 | void ReleaseDirectDraw(); 101 | void DDDrawScreen(); 102 | #endif 103 | 104 | #endif 105 | -------------------------------------------------------------------------------- /gui/guicombo.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 1997-2008 ZSNES Team ( zsKnight, _Demo_, pagefault, Nach ) 3 | * 4 | * http://www.zsnes.com 5 | * http://sourceforge.net/projects/zsnes 6 | * https://zsnes.bountysource.com 7 | * 8 | * This program is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU General Public License 10 | * version 2 as published by the Free Software Foundation. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 20 | */ 21 | 22 | #include 23 | 24 | #include "../cfg.h" 25 | #include "../cpu/execute.h" 26 | #include "c_guiwindp.h" 27 | #include "gui.h" 28 | #include "guicombo.h" 29 | #include "guiwindp.h" 30 | 31 | void ComboClip(void) 32 | { 33 | u4 eax = GUINumCombo; 34 | while ((eax & 0xFF) < 42) 35 | GUIComboData[eax++] = 0; 36 | } 37 | 38 | void ComboAdder(void) 39 | { 40 | if (romloadskip != 0 && GUIComboGameSpec != 0) 41 | return; 42 | 43 | ComboClip(); 44 | // copy data to c 45 | ComboData* const c = &(GUIComboGameSpec == 0 ? CombinDataGlob : CombinDataLocl)[NumCombo]; 46 | memcpy(c->name, GUIComboTextH, sizeof(c->name)); // copy name 47 | memcpy(c->combo, GUIComboData, sizeof(c->combo)); // copy combination code 48 | c->key = GUIComboKey; 49 | c->player = GUIComboPNum; 50 | c->ff = GUIComboLHorz; 51 | 52 | GUIccombcursloc = NumCombo; 53 | s4 const eax = (s4)NumCombo - 7; 54 | if ((s4)GUIccombviewloc < eax) 55 | GUIccombviewloc = eax; 56 | *(GUIComboGameSpec == 0 ? &NumComboGlob : &NumComboLocl) = ++NumCombo; 57 | 58 | GUIComboTextH[0] = '\0'; 59 | GUINumCombo = 0; 60 | GUIComboKey = 0; 61 | } 62 | 63 | void ComboReplace(void) 64 | { 65 | ComboClip(); 66 | ComboData* const eax = &(GUIComboGameSpec == 0 ? CombinDataGlob : CombinDataLocl)[GUIccombcursloc]; 67 | // copy data to eax 68 | memcpy(eax->name, GUIComboTextH, sizeof(eax->name)); // copy name 69 | memcpy(eax->combo, GUIComboData, sizeof(eax->combo)); // copy combination code 70 | eax->key = GUIComboKey; 71 | eax->player = GUIComboPNum; 72 | eax->ff = GUIComboLHorz; 73 | } 74 | 75 | void ComboRemoval(void) 76 | { 77 | ComboData* const c = (GUIComboGameSpec == 0 ? CombinDataGlob : CombinDataLocl) + GUIccombcursloc; 78 | u4 const ecx = NumCombo - GUIccombcursloc - 1; 79 | if ((s4)ecx > 0) 80 | memmove(c, c + 1, sizeof(*c) * ecx); 81 | 82 | u4 eax = --NumCombo; 83 | if (eax != 0) 84 | --eax; 85 | if (GUIccombviewloc > eax) 86 | GUIccombviewloc = eax; 87 | if (GUIccombcursloc > eax) 88 | GUIccombcursloc = eax; 89 | *(GUIComboGameSpec == 0 ? &NumComboGlob : &NumComboLocl) = NumCombo; 90 | } 91 | -------------------------------------------------------------------------------- /gblhdr.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1997-2008 ZSNES Team ( zsKnight, _Demo_, pagefault, Nach ) 3 | 4 | http://www.zsnes.com 5 | http://sourceforge.net/projects/zsnes 6 | https://zsnes.bountysource.com 7 | 8 | This program is free software; you can redistribute it and/or 9 | modify it under the terms of the GNU General Public License 10 | version 2 as published by the Free Software Foundation. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program; if not, write to the Free Software 19 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 20 | */ 21 | 22 | #ifndef GBLHDR_H 23 | #define GBLHDR_H 24 | 25 | /*************************************\ 26 | * Global Definitions and Headers File * 27 | \*************************************/ 28 | 29 | // Standard stuff 30 | 31 | #include "fcntl.h" 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | 38 | // General time.h checking 39 | 40 | #if TIME_WITH_SYS_TIME 41 | #include 42 | #include 43 | #else 44 | #if HAVE_SYS_TIME_H 45 | #include 46 | #else 47 | #include 48 | #endif 49 | #endif 50 | 51 | // General dirent.h stuff 52 | 53 | #if HAVE_DIRENT_H 54 | #include 55 | #else 56 | #if HAVE_SYS_NDIR_H 57 | #include 58 | #endif 59 | #if HAVE_SYS_DIR_H 60 | #include 61 | #endif 62 | #if HAVE_NDIR_H 63 | #include 64 | #endif 65 | #endif 66 | 67 | // more standard stuff 68 | 69 | #include 70 | #include 71 | #include 72 | 73 | // unistd.h stuff 74 | 75 | // #if HAVE_UNISTD_H 76 | // Small hack for now 77 | #if unix 78 | #include 79 | #include 80 | #endif 81 | 82 | // opengl stuff 83 | 84 | #ifdef __OPENGL__ 85 | #ifndef __MACOSX__ 86 | #include 87 | #else 88 | #include 89 | #endif 90 | #endif 91 | 92 | // os specific stuff 93 | 94 | #ifdef __QNXNTO__ 95 | /* QNX6 has getpagesize() commented out in unistd.h, 96 | however it's a static value that we can just define */ 97 | #define getpagesize() 4096 98 | #endif 99 | 100 | #ifdef __UNIXSDL__ 101 | #include "SDL.h" 102 | #include 103 | #ifndef __BEOS__ 104 | #include 105 | #include 106 | #include 107 | #endif 108 | #include 109 | #include 110 | #include 111 | #include 112 | #include 113 | #include 114 | #include 115 | #include 116 | #ifndef NO_PNG 117 | #include 118 | #endif 119 | #endif 120 | 121 | #ifdef __UNIXSDL__ 122 | #ifdef __linux__ 123 | #include 124 | #else 125 | #include 126 | #endif 127 | #endif 128 | 129 | #endif 130 | -------------------------------------------------------------------------------- /jma/winout.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2002 Andrea Mazzoleni ( http://advancemame.sf.net ) 3 | Copyright (C) 2001-4 Igor Pavlov ( http://www.7-zip.org ) 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License version 2.1 as published by the Free Software Foundation. 8 | 9 | This library is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public 15 | License along with this library; if not, write to the Free Software 16 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 | */ 18 | 19 | #ifndef __STREAM_WINDOWOUT_H 20 | #define __STREAM_WINDOWOUT_H 21 | 22 | #include "iiostrm.h" 23 | 24 | namespace NStream { 25 | namespace NWindow { 26 | 27 | // m_KeepSizeBefore: how mach BYTEs must be in buffer before m_Pos; 28 | // m_KeepSizeAfter: how mach BYTEs must be in buffer after m_Pos; 29 | // m_KeepSizeReserv: how mach BYTEs must be in buffer for Moving Reserv; 30 | // must be >= aKeepSizeAfter; // test it 31 | 32 | class COut { 33 | BYTE* m_Buffer; 34 | UINT32 m_Pos; 35 | UINT32 m_PosLimit; 36 | UINT32 m_KeepSizeBefore; 37 | UINT32 m_KeepSizeAfter; 38 | UINT32 m_KeepSizeReserv; 39 | UINT32 m_StreamPos; 40 | 41 | UINT32 m_WindowSize; 42 | UINT32 m_MoveFrom; 43 | 44 | ISequentialOutStream* m_Stream; 45 | 46 | virtual void MoveBlockBackward(); 47 | 48 | public: 49 | COut() 50 | : m_Buffer(0) 51 | , m_Stream(0) 52 | { 53 | } 54 | virtual ~COut(); 55 | void Create(UINT32 aKeepSizeBefore, 56 | UINT32 aKeepSizeAfter, UINT32 aKeepSizeReserv = (1 << 17)); 57 | void SetWindowSize(UINT32 aWindowSize); 58 | 59 | void Init(ISequentialOutStream* aStream, bool aSolid = false); 60 | HRESULT Flush(); 61 | 62 | UINT32 GetCurPos() const { return m_Pos; } 63 | const BYTE* GetPointerToCurrentPos() const { return m_Buffer + m_Pos; }; 64 | 65 | void CopyBackBlock(UINT32 aDistance, UINT32 aLen) 66 | { 67 | if (m_Pos >= m_PosLimit) 68 | MoveBlockBackward(); 69 | BYTE* p = m_Buffer + m_Pos; 70 | aDistance++; 71 | for (UINT32 i = 0; i < aLen; i++) 72 | p[i] = p[i - aDistance]; 73 | m_Pos += aLen; 74 | } 75 | 76 | void PutOneByte(BYTE aByte) 77 | { 78 | if (m_Pos >= m_PosLimit) 79 | MoveBlockBackward(); 80 | m_Buffer[m_Pos++] = aByte; 81 | } 82 | 83 | BYTE GetOneByte(UINT32 anIndex) const 84 | { 85 | return m_Buffer[m_Pos + anIndex]; 86 | } 87 | 88 | BYTE* GetBuffer() const { return m_Buffer; } 89 | }; 90 | 91 | } 92 | } 93 | 94 | #endif 95 | -------------------------------------------------------------------------------- /jma/lencoder.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2005-2008 NSRT Team ( http://nsrt.edgeemu.com ) 3 | Copyright (C) 2002 Andrea Mazzoleni ( http://advancemame.sf.net ) 4 | Copyright (C) 2001-4 Igor Pavlov ( http://www.7-zip.org ) 5 | 6 | This library is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU Lesser General Public 8 | License version 2.1 as published by the Free Software Foundation. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | */ 19 | 20 | #ifndef __LENCODER_H 21 | #define __LENCODER_H 22 | 23 | #include "btreecd.h" 24 | 25 | namespace NLength { 26 | 27 | const UINT32 kNumPosStatesBitsMax = 4; 28 | const int kNumPosStatesMax = (1 << kNumPosStatesBitsMax); 29 | 30 | const int kNumPosStatesBitsEncodingMax = 4; 31 | const int kNumPosStatesEncodingMax = (1 << kNumPosStatesBitsEncodingMax); 32 | 33 | const int kNumMoveBits = 5; 34 | 35 | const int kNumLenBits = 3; 36 | const int kNumLowSymbols = 1 << kNumLenBits; 37 | const int kNumMidBits = 3; 38 | const int kNumMidSymbols = 1 << kNumMidBits; 39 | 40 | const int kNumHighBits = 8; 41 | 42 | const int kNumSymbolsTotal = kNumLowSymbols + kNumMidSymbols + (1 << kNumHighBits); 43 | 44 | const int kNumSpecSymbols = kNumLowSymbols + kNumMidSymbols; 45 | 46 | class CDecoder { 47 | CMyBitDecoder m_Choice; 48 | CBitTreeDecoder m_LowCoder[kNumPosStatesMax]; 49 | CMyBitDecoder m_Choice2; 50 | CBitTreeDecoder m_MidCoder[kNumPosStatesMax]; 51 | CBitTreeDecoder m_HighCoder; 52 | UINT32 m_NumPosStates; 53 | 54 | public: 55 | void Create(UINT32 aNumPosStates) 56 | { 57 | m_NumPosStates = aNumPosStates; 58 | } 59 | void Init() 60 | { 61 | m_Choice.Init(); 62 | for (UINT32 aPosState = 0; aPosState < m_NumPosStates; aPosState++) { 63 | m_LowCoder[aPosState].Init(); 64 | m_MidCoder[aPosState].Init(); 65 | } 66 | m_Choice2.Init(); 67 | m_HighCoder.Init(); 68 | } 69 | UINT32 Decode(CMyRangeDecoder* aRangeDecoder, UINT32 aPosState) 70 | { 71 | if (m_Choice.Decode(aRangeDecoder) == 0) 72 | return m_LowCoder[aPosState].Decode(aRangeDecoder); 73 | else { 74 | UINT32 aSymbol = kNumLowSymbols; 75 | if (m_Choice2.Decode(aRangeDecoder) == 0) 76 | aSymbol += m_MidCoder[aPosState].Decode(aRangeDecoder); 77 | else { 78 | aSymbol += kNumMidSymbols; 79 | aSymbol += m_HighCoder.Decode(aRangeDecoder); 80 | } 81 | return aSymbol; 82 | } 83 | } 84 | }; 85 | 86 | } 87 | 88 | #endif 89 | --------------------------------------------------------------------------------