├── License ├── README ├── TODO.md ├── buildall ├── snem ├── .preload.js.swp ├── 65816.c ├── buildjs ├── buildww ├── buildxnes ├── drawansi.h ├── dsp.c ├── exec.c ├── extract_script.py ├── io.c ├── main.c ├── native.c ├── ppu.c ├── pre.js ├── snes.h ├── snesEmu.html ├── snesWW.html ├── snesWW2.html ├── spc.c ├── testmain.html └── testworker.js └── snes9x ├── 65c816.h ├── apu ├── SNES_SPC.cpp ├── SNES_SPC.h ├── SNES_SPC_misc.cpp ├── SNES_SPC_state.cpp ├── SPC_CPU.h ├── SPC_DSP.cpp ├── SPC_DSP.h ├── SPC_Filter.cpp ├── SPC_Filter.h ├── apu.cpp ├── apu.h ├── apu.h~ ├── blargg_common.h ├── blargg_config.h ├── blargg_endian.h ├── blargg_source.h ├── hermite_resampler.h ├── license.txt ├── linear_resampler.h ├── resampler.h └── ring_buffer.h ├── bsx.cpp ├── bsx.h ├── c4.cpp ├── c4.h ├── c4emu.cpp ├── cheats.cpp ├── cheats.h ├── cheats2.cpp ├── clip.cpp ├── conffile.cpp ├── conffile.h ├── controls.cpp ├── controls.h ├── cpu.cpp ├── cpuaddr.h ├── cpuexec.cpp ├── cpuexec.h ├── cpumacro.h ├── cpuops.cpp ├── cpuops.h ├── crosshairs.cpp ├── crosshairs.h ├── debug.cpp ├── debug.h ├── display.h ├── dma.cpp ├── dma.h ├── docs ├── changes.txt ├── control-inputs.txt ├── controls.txt ├── gpl-2.0.txt ├── lgpl-2.1.txt ├── porting.html ├── portsofsnes9x.txt ├── snapshots.txt ├── snes9x-license.txt └── snes9x.conf.default ├── dsp.cpp ├── dsp.h ├── dsp1.cpp ├── dsp2.cpp ├── dsp3.cpp ├── dsp4.cpp ├── filter ├── 2xsai.cpp ├── 2xsai.h ├── blit.cpp ├── blit.h ├── epx.cpp ├── epx.h ├── hq2x.cpp ├── hq2x.h ├── snes_ntsc-license.txt ├── snes_ntsc.c ├── snes_ntsc.h ├── snes_ntsc_config.h └── snes_ntsc_impl.h ├── font.h ├── fxdbg.cpp ├── fxemu.cpp ├── fxemu.h ├── fxinst.cpp ├── fxinst.h ├── getset.h ├── gfx.cpp ├── gfx.h ├── globals.cpp ├── icons ├── burger1.png ├── burger2.png └── burger3.png ├── jma ├── 7z.h ├── 7zlzma.cpp ├── aribitcd.h ├── ariconst.h ├── ariprice.h ├── btreecd.h ├── crc32.cpp ├── crc32.h ├── iiostrm.cpp ├── iiostrm.h ├── inbyte.cpp ├── inbyte.h ├── jma.cpp ├── jma.h ├── lencoder.h ├── license.txt ├── litcoder.h ├── lzma.cpp ├── lzma.h ├── lzmadec.cpp ├── lzmadec.h ├── portable.h ├── rcdefs.h ├── rngcoder.h ├── s9x-jma.cpp ├── s9x-jma.h ├── winout.cpp └── winout.h ├── language.h ├── loadzip.cpp ├── logger.cpp ├── logger.h ├── memmap.cpp ├── memmap.h ├── messages.h ├── missing.h ├── movie.cpp ├── movie.h ├── netplay.cpp ├── netplay.h ├── obc1.cpp ├── obc1.h ├── pixform.h ├── port.h ├── ppu.cpp ├── ppu.h ├── reader.cpp ├── reader.h ├── sa1.cpp ├── sa1.h ├── sa1cpu.cpp ├── sar.h ├── screenshot.cpp ├── screenshot.h ├── sdd1.cpp ├── sdd1.h ├── sdd1emu.cpp ├── sdd1emu.h ├── sdl ├── CREDITS ├── Makefile ├── Makefile.in ├── buildhtml ├── config.guess ├── config.info ├── config.log ├── config.status ├── config.sub ├── configure ├── configure.ac ├── docs │ ├── control-inputs.txt │ ├── readme_unix.html │ └── snes9x-sdl.conf ├── drawansi.h ├── em.makefile ├── extract_script.py ├── install-sh ├── modern-ui-shell.html ├── sdl_snes9x.h ├── sdlaudio.cpp ├── sdlinput.cpp ├── sdlmain.cpp ├── sdlvideo.cpp ├── snes9x.html └── xnes9x_shell.html ├── server.cpp ├── seta.cpp ├── seta.h ├── seta010.cpp ├── seta011.cpp ├── seta018.cpp ├── snapshot.cpp ├── snapshot.h ├── snes9x.cpp ├── snes9x.h ├── spc7110.cpp ├── spc7110.h ├── spc7110dec.cpp ├── spc7110dec.h ├── spc7110emu.cpp ├── spc7110emu.h ├── srtc.cpp ├── srtc.h ├── srtcemu.cpp ├── srtcemu.h ├── tile.cpp ├── tile.h └── unzip ├── crypt.h ├── ioapi.c ├── ioapi.h ├── iowin32.c ├── iowin32.h ├── miniunz.c ├── minizip.c ├── mztools.c ├── mztools.h ├── unzip.c ├── unzip.h ├── zip.c └── zip.h /License: -------------------------------------------------------------------------------- 1 | The license of this project depends on the license of snes9x, snem, and emscript 2 | snes9x is a freeware for PERSONAL USE only. see https://github.com/snes9xgit/snes9x/blob/master/docs/snes9x-license.txt 3 | snem claimed to be open source but not sure wich license it is. I sent an email to the author asking for the license(2 years ago), 4 | but have not get response yet. 5 | mscripten is available under 2 licenses, the MIT license and the University of Illinois/NCSA Open Source License. 6 | https://github.com/kripken/emscripten/blob/master/LICENSE 7 | 8 | All my modifications, if applicatable, are under public domain. 9 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | Build: 2 | Install emscripten and make sure emcc is in your $PATH. 3 | ./buildall 4 | see output for compiled results. 5 | 6 | snem port is outdated, can only be compiled by a very old version of emscripten. 7 | I might update it in future but snes9x seems to be fast enough for modern devices. 8 | 9 | snes9x port requires emscripten 1.36+ 10 | 11 | snes9x is build with sound by default. comment out -Dsound in snes9x/sdl/buildhtml to disable sound. 12 | 13 | More information: 14 | http://tjwei.github.com/xnes # Demo and information (brought your own roms) 15 | 16 | Blog posts (Tradition Chinese) 17 | http://weijr-note.blogspot.tw/2012/06/javascript-snes-emulator-wip.html # Orginal version (6/22/2012) 18 | http://weijr-note.blogspot.tw/2012/08/js.html # more videos 19 | http://weijr-note.blogspot.tw/2012/08/coscup-2012.html # COSCUP slides 20 | 21 | -------------------------------------------------------------------------------- /TODO.md: -------------------------------------------------------------------------------- 1 | # Battery Saves 2 | 3 | * Fix filename underscore bit 4 | * optional Directory creation on ROM load 5 | * autosave timing, at interval n, at exit when tab closes or new ROM is loaded to ensure no data loss 6 | * ensure ROM load not possible prior to initial sync 7 | -------------------------------------------------------------------------------- /buildall: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -o verbose 3 | mkdir -p output 4 | # cd snem 5 | # time ./buildxnes || exit 1 6 | # time ./buildww || exit 1 7 | # cd .. 8 | cd snes9x/sdl 9 | time ./buildhtml || exit 1 10 | cd ../.. 11 | -------------------------------------------------------------------------------- /snem/.preload.js.swp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tjwei/xnes/741561eab1286cc7d4b3692fc432b7023adf518b/snem/.preload.js.swp -------------------------------------------------------------------------------- /snem/buildjs: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # build an ascii version for benchmark, see drawansi.h for various mode of ansi art graphics 3 | set -o verbose 4 | OUT=../output 5 | emcc -O2 -s EXPORTED_FUNCTIONS="['_main', '_reboot']" -DASCII -DBENCHMARK -o $OUT/xnes.js *.c --embed-file smw.smc 6 | -------------------------------------------------------------------------------- /snem/buildww: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -o verbose 3 | OUT=../output 4 | emcc -DEMCCHACK -O2 -o $OUT/xnes.ww.js *.c \ 5 | -s EXPORTED_FUNCTIONS="['_main', '_reboot_emulator', '_native_set_joypad_state', '_renderscreen', '_mainloop', '_native_bitmap_pointer']" || exit 1 6 | (cat $OUT/xnes.ww.js;grep -v "// WW2" testworker.js) > $OUT/ww.js || exit 1 7 | (cat $OUT/xnes.ww.js;grep -v "// WW1" testworker.js) > $OUT/ww2.js || exit 1 8 | rm $OUT/xnes.ww.js || exit 1 9 | cp snesWW.html $OUT || exit 1 10 | cp snesWW2.html $OUT || exit 1 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /snem/buildxnes: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -o verbose 3 | OUT=../output 4 | emcc -DEMCCHACK -O2 -o $OUT/xnes.html *.c \ 5 | -s EXPORTED_FUNCTIONS="['_main', '_reboot_emulator', '_native_set_joypad_state', '_renderscreen', '_mainloop', '_native_bitmap_pointer']" || exit 1 6 | python extract_script.py $OUT/xnes.html > $OUT/xnes.html.js || exit 1 7 | rm $OUT/xnes.html || exit 1 8 | cp snesEmu.html $OUT 9 | 10 | -------------------------------------------------------------------------------- /snem/exec.c: -------------------------------------------------------------------------------- 1 | #include "snes.h" 2 | 3 | int padready; 4 | unsigned short oldspcpc; 5 | int spcpchi=1; 6 | unsigned char spuram[0x10080]; 7 | int cycs; 8 | int soundupdate; 9 | unsigned short sobjaddr; 10 | int curline; 11 | int curframe; 12 | int spcemu; 13 | unsigned char spctctrl; 14 | unsigned char spctimer[3],spclatch[3],spccount[3]; 15 | int spctimer2[3]; 16 | 17 | struct 18 | { 19 | union 20 | { 21 | unsigned short ya; 22 | struct 23 | { 24 | unsigned char a,y; 25 | } b; 26 | } ya; 27 | unsigned char x; 28 | unsigned char s; 29 | unsigned short pc; 30 | struct 31 | { 32 | int c,z,h,p,v,n; 33 | } p; 34 | unsigned short opc[8]; 35 | } spc; 36 | 37 | unsigned char spuram[0x10080]; 38 | 39 | void (*opcodes[256][5])(); 40 | void (*spcopcodes[256])(); 41 | 42 | int slines; 43 | int irqon,fastrom,nmipend,palf; 44 | int cycles=0,spccycles=0; 45 | unsigned char opcode; 46 | int ins; 47 | int gcycs=0,spccycs=0; 48 | 49 | #define readspc(a) ((a&0xFF00)?spuram[a]:readspcl(a)) 50 | 51 | int cyclookup[3][10]= 52 | { 53 | {0,8,16,24,32,40,48,56,64,72}, 54 | {0,6,12,18,24,30,36,42,48,54}, 55 | {0,10,20,30,40,50,60,70,80,90}, 56 | }; 57 | 58 | /*Main loop - switches between 65816,SPC,and PPU 59 | VERY loose timing here*/ 60 | void mainloop(int linenum) 61 | { 62 | int lines; 63 | int ocycles; 64 | for (lines=0;lines0) 82 | { 83 | cycles=0; 84 | opcode=readmem(pbr,pc); pc++; 85 | opcodes[opcode][mode](); 86 | gcycs-=cyclookup[fastrom][-cycles]; 87 | if (irqon && !struct_p.i) int65816(); 88 | if (spcemu) 89 | { 90 | while (spccycs>gcycs) 91 | { 92 | opcode=readspc(spc.pc); spc.pc++; 93 | spcopcodes[opcode](); 94 | spccycs-=cyclookup[2][cycs]; 95 | } 96 | } 97 | } 98 | UPDATE_SOUND; 99 | if (spcemu) 100 | { 101 | if (spctctrl&1) 102 | { 103 | spctimer2[0]++; 104 | if (spctimer2[0]==2) 105 | { 106 | spctimer2[0]=0; 107 | spctimer[0]++; 108 | if (spctimer[0]==spclatch[0]) 109 | { 110 | spctimer[0]=0; 111 | spccount[0]++; 112 | } 113 | } 114 | } 115 | if (spctctrl&2) 116 | { 117 | spctimer2[1]++; 118 | if (spctimer2[1]==2) 119 | { 120 | spctimer2[1]=0; 121 | spctimer[1]++; 122 | if (spctimer[1]==spclatch[1]) 123 | { 124 | spctimer[1]=0; 125 | spccount[1]++; 126 | } 127 | } 128 | } 129 | if (spctctrl&4) 130 | { 131 | spctimer[2]+=4; 132 | if (spctimer[2]>=spclatch[2]) 133 | { 134 | spctimer[2]=0; 135 | spccount[2]++; 136 | } 137 | } 138 | } 139 | if (slines==231) nmiocc=nmipend=1; 140 | if (slines==231 && nmiena) nmi65816(); 141 | if (slines==224) 142 | { 143 | vbl=1; 144 | vblankhdma(); 145 | curframe++; 146 | padready=1; 147 | } 148 | if (slines==227) padready=0; 149 | if (slines<224) doline(slines); 150 | if ((vertint && (slines==vertline)) || (horint && !vertint)) 151 | irqon=1; 152 | else 153 | irqon=0; 154 | slines++; 155 | if (palf) 156 | { 157 | if (slines==312) 158 | { 159 | slines=0; 160 | objaddr=sobjaddr; 161 | vbl=nmiocc=nmipend=0; 162 | decodesprites(); 163 | } 164 | } 165 | else 166 | { 167 | if (slines==262) 168 | { 169 | slines=0; 170 | objaddr=sobjaddr; 171 | vbl=nmiocc=nmipend=0; 172 | decodesprites(); 173 | } 174 | } 175 | } 176 | } 177 | -------------------------------------------------------------------------------- /snem/extract_script.py: -------------------------------------------------------------------------------- 1 | import re 2 | import sys 3 | 4 | with open(sys.argv[1], "r") as f: 5 | buf=f.read() 6 | while 1: 7 | m=re.search(r"]*>|", buf, re.DOTALL|re.MULTILINE) 12 | if m==None: 13 | break 14 | print buf[:m.start(0)] 15 | print 16 | buf=buf[m.end(0):] 17 | 18 | -------------------------------------------------------------------------------- /snem/main.c: -------------------------------------------------------------------------------- 1 | //1b15a 2 | #include 3 | #include 4 | #include "snes.h" 5 | 6 | int sblankchk=0; 7 | int soundupdate=0; 8 | static int speed_count=0; 9 | #ifdef SOUND 10 | static void soundcheck() 11 | { 12 | soundupdate=1; 13 | } 14 | #endif 15 | static int incspeedcount() 16 | { 17 | speed_count++; 18 | //printf("%d\n",speed_count); 19 | return 0; 20 | } 21 | int spcemu,palf; 22 | int reboot_emulator (char *) __attribute__((used)); 23 | int reboot_emulator (char *romfilename){ 24 | if(loadsmc(romfilename)==-1){ 25 | printf("can not find rom file %s\n",romfilename); 26 | exit(1); 27 | return 0; 28 | } 29 | makeopcodetable(); 30 | makeromtable(); 31 | reset65816(); 32 | //resetppu(); 33 | resetspc(); 34 | initppu(); 35 | speed_count=0; 36 | return palf; 37 | } 38 | 39 | #ifdef EMCCHACK 40 | #if 0 41 | #include "romlist.h" 42 | //char *roms[2]={"roms/smw.smc", "roms/Angel Eyes (PD).fig"}; 43 | int reboot_romnum=-1; 44 | int js_callback(){ 45 | if(reboot_romnum>=0 && reboot_romnum0) 96 | { 97 | mainloop(palf ? 312 : 262); 98 | speed_count--; 99 | vbl=0; 100 | //dumpregs(); 101 | } 102 | renderscreen(); 103 | UPDATE_SOUND; 104 | } 105 | #endif 106 | #else 107 | //reboot(0); 108 | //native_tick_callback(js_callback, 200); 109 | #endif 110 | native_set_joypad_state(0x80000000); 111 | return 0; 112 | } 113 | -------------------------------------------------------------------------------- /snem/native.c: -------------------------------------------------------------------------------- 1 | #define uint32 unsigned int 2 | #define uint16 unsigned short 3 | #ifdef SET_BY_SOURCE 4 | #define USE_SDL 5 | #define ASCII 6 | #endif 7 | #ifdef ASCII 8 | #include "drawansi.h" 9 | #endif 10 | #ifdef USE_SDL 11 | #include 12 | #include 13 | #endif 14 | #include 15 | #include 16 | #include 17 | 18 | 19 | #ifdef USE_SDL 20 | SDL_Surface *screen; 21 | Uint8 *keystates; 22 | uint32 *bitmap; 23 | #else 24 | uint32 bitmap[288*256]; 25 | #endif 26 | #ifdef EMCCHACK 27 | #define RGB555toRGB24(t) \ 28 | ( (((t)&0x1f)<<3) | (((t)&0x3e0)<<6) | (((t)&0x7c00)<<9) ) 29 | #else 30 | #define RGB555toRGB24(t) \ 31 | ( (((t)&0x1f)<<19) | (((t)&0x3e0)<<6) | (((t)&0x7c00)>>7) ) 32 | #endif 33 | void native_hardware_init(int spcemu){ 34 | #ifdef USE_SDL 35 | 36 | if( SDL_Init( SDL_INIT_VIDEO|SDL_INIT_TIMER|SDL_INIT_AUDIO) == -1 ) exit(-1); 37 | screen = SDL_SetVideoMode( 288, 256, 32, SDL_SWSURFACE|SDL_DOUBLEBUF); 38 | SDL_LockSurface(screen); 39 | bitmap=(uint32 *)screen->pixels; 40 | //keystates = SDL_GetKeyState( NULL ); 41 | #ifdef EMCCHACK 42 | keystates = SDL_GetKeyboardState( NULL ); 43 | #else 44 | atexit(SDL_Quit); 45 | keystates = SDL_GetKeyState( NULL ); 46 | #endif 47 | #endif 48 | #ifdef SOUND 49 | if (spcemu) initsound(); 50 | if (spcemu) install_int_ex(soundcheck,BPS_TO_TIMER(500)); 51 | #endif 52 | } 53 | 54 | uint32* native_set_joypad_state(uint32 state) __attribute__((used)); 55 | uint32* native_bitmap_pointer(int x, int y){ 56 | return (void *)(&bitmap[(y+16)*288+x+16]); 57 | } 58 | static int cnt=0; 59 | void native_bitmap_to_screen(){ 60 | #ifdef USE_SDL 61 | uint32 *bp=(uint32 *)native_bitmap_pointer(-16,-16); 62 | int x,y; 63 | for(y=0;y<16*288;y++) 64 | *bp++=0; 65 | bp=(uint32 *)native_bitmap_pointer(-16,224); 66 | for(y=0;y<16*288;y++) 67 | *bp++=0; 68 | for(y=0;y<=224;y++){ 69 | bp=(uint32 *)native_bitmap_pointer(-32,y); 70 | for(x=0;x<32;x++) 71 | *bp++=0; 72 | } 73 | 74 | SDL_UnlockSurface(screen); 75 | SDL_Flip(screen); 76 | SDL_LockSurface(screen); 77 | #endif 78 | #ifdef ASCII 79 | if((cnt&7)==0){ 80 | drawansi(256, 224, (void *)native_bitmap_pointer(0,0), 32, 288*4); 81 | printf("%d\n",cnt); 82 | } 83 | #endif 84 | 85 | cnt++; 86 | 87 | } 88 | void native_bitmap_clear_line(int line, uint32 color){ 89 | int x; 90 | uint32 *bp=(uint32 *)native_bitmap_pointer(0, line); 91 | for(x=0;x<256;x++) 92 | bp[x]=color; 93 | //memset(native_bitmap_pointer(0, line), 0, 264*2); 94 | } 95 | 96 | int native_poll_keyboard(){ 97 | #if defined(USE_SDL) 98 | SDL_Event event; 99 | while( SDL_PollEvent( &event ) ){ 100 | if( event.type == SDL_QUIT ) {return -1;} 101 | } 102 | if(keystates[SDLK_ESCAPE]) {return -1;} 103 | #else 104 | 105 | #endif 106 | return 0; 107 | 108 | } 109 | #ifdef USE_SDL 110 | static Uint32 my_callbackfunc(Uint32 interval, void *param) 111 | { 112 | 113 | int (*func)(void); 114 | int stop_running; 115 | func=(int (*)(void))param; 116 | stop_running=func(); 117 | if(stop_running) 118 | return 0; 119 | #ifdef EMCCHACK 120 | SDL_AddTimer( interval, my_callbackfunc, param); 121 | #endif 122 | return(interval); 123 | } 124 | #endif 125 | void native_tick_callback( int (*func)(void), int fps){ 126 | #ifdef USE_SDL 127 | SDL_AddTimer( 1000/fps, my_callbackfunc, (void *)func); 128 | #endif 129 | } 130 | static uint32 joy1state=0x80000000; 131 | uint32* native_set_joypad_state(uint32 state){ 132 | joy1state=state; 133 | return &joy1state; 134 | } 135 | uint32 native_joypad_state(int num) 136 | { 137 | uint32 joy1=0x80000000; 138 | if(num!=0) return joy1; 139 | #ifdef USE_SDL 140 | native_poll_keyboard(); 141 | if (keystates[SDLK_w]) joy1|=0x0010; 142 | if (keystates[SDLK_q]) joy1|=0x0020; 143 | if (keystates[SDLK_a]) joy1|=0x0040; 144 | if (keystates[SDLK_s]) joy1|=0x0080; 145 | if (keystates[SDLK_RIGHT]) joy1|=0x0100; 146 | if (keystates[SDLK_LEFT]) joy1|=0x0200; 147 | if (keystates[SDLK_DOWN]) joy1|=0x0400; 148 | if (keystates[SDLK_UP]) joy1|=0x0800; 149 | if (keystates[SDLK_c]) joy1|=0x1000; 150 | if (keystates[SDLK_d]) joy1|=0x2000; 151 | if (keystates[SDLK_z]) joy1|=0x4000; 152 | if (keystates[SDLK_x]) joy1|=0x8000; 153 | #else 154 | /*if(cnt%120==111) 155 | joy1|=(cnt&0xffff);*/ 156 | joy1=joy1state; 157 | 158 | #endif 159 | return joy1; 160 | } -------------------------------------------------------------------------------- /snem/pre.js: -------------------------------------------------------------------------------- 1 | var Module = { 2 | 'postRun': function() { 3 | alert("ttt"); 4 | js_main() 5 | } 6 | }; 7 | -------------------------------------------------------------------------------- /snem/snes.h: -------------------------------------------------------------------------------- 1 | #ifndef SNEM_H 2 | #define SNEM_H 3 | int stage; 4 | #include 5 | #include 6 | #include 7 | #define uint32 unsigned 8 | #define uint16 unsigned short 9 | #ifdef EMCCHACK 10 | #define RGB555toRGB24(t) \ 11 | ( (((t)&0x1f)<<3) | (((t)&0x3e0)<<6) | (((t)&0x7c00)<<9)|0xff000000 ) 12 | #else 13 | #define RGB555toRGB24(t) \ 14 | ( (((t)&0x1f)<<19) | (((t)&0x3e0)<<6) | (((t)&0x7c00)>>7)|0xff000000 ) 15 | #endif 16 | /*65816*/ 17 | typedef union 18 | { 19 | unsigned short w; 20 | struct { unsigned char l,h; } b; 21 | } reg; 22 | 23 | reg reg_A,reg_X,reg_Y,reg_S; 24 | unsigned short pc,dp; 25 | unsigned char pbr,dbr; 26 | int mode; 27 | int nmiena; 28 | int setzf; 29 | 30 | struct 31 | { 32 | int c,z,i,d,v,n,x,m,e; 33 | } struct_p; 34 | 35 | /*I/O*/ 36 | void writeio(unsigned short addr, unsigned char val); 37 | int nmiocc; 38 | struct 39 | { 40 | unsigned short src[8],size[8]; 41 | unsigned char srcbank[8],ctrl[8],dest[8]; 42 | } dma; 43 | int vertint,vertline; 44 | int horint; 45 | 46 | /*Memory*/ 47 | unsigned char *mempoint[256][8]; 48 | int mempointv[256][8],mempointw[256][8]; 49 | #define readmem(b,a) ((mempointv[b&255][((a)&0xFFFF)>>13])?mempoint[b&255][((a)&0xFFFF)>>13][(a)&0x1FFF]:readmeml(b,a)) 50 | #define writemem(b,a,v) {if (mempointw[b&255][((a)&0xFFFF)>>13]) {mempoint[b&255][((a)&0xFFFF)>>13][(a)&0x1FFF]=v; } else {writememl(b,a,v);} } 51 | /*if (a==0x163B || a==0x22A) printf("%04X write %02X %02X:%04X %06X\n",a,v,pbr,pc,(ram[reg_S.w+1]|(ram[reg_S.w+2]<<8)|(ram[reg_S.w+3]<<16))+1); if (b==0x7F && (a&0xFFFF)==0x49) printf("7F0049 write %02X %02X:%04X %04X\n",v,pbr,pc,(ram[reg_S.w+1]|(ram[reg_S.w+2]<<8))+1); */ 52 | /*PPU*/ 53 | void writeppu(unsigned short addr, unsigned char val); 54 | void initppu(); 55 | int vbl; 56 | 57 | unsigned char hdmaena; 58 | int curline; 59 | 60 | unsigned short sprchraddr; 61 | unsigned char objram[1024]; 62 | unsigned short objaddr; 63 | int firstobjwrite; 64 | struct 65 | { 66 | int hdmaon[8]; 67 | int hdmacount[8]; 68 | uint32 hdmaval[8]; 69 | unsigned char srcbank[8]; 70 | unsigned short src[8]; 71 | int repeat[8]; 72 | unsigned char ibank[8]; 73 | unsigned short ta[8]; 74 | } hdma; 75 | 76 | 77 | /*DSP*/ 78 | unsigned char dspregs[128]; 79 | int dspaddr; 80 | unsigned char readdsp(int a); 81 | void vblankhdma(); 82 | void decodesprites(); 83 | unsigned char readmeml(unsigned char b, unsigned short addr); 84 | unsigned char readspcl(unsigned short a); 85 | void doline(int line); 86 | void updatespuaccess(int page); 87 | void writedsp(int a, unsigned char v); 88 | void int65816(); 89 | unsigned char readio(unsigned short addr); 90 | unsigned char readppu(unsigned short a); 91 | void nmi65816(); 92 | void dumpregs(); 93 | void mainloop(int) __attribute__((used)); 94 | void reset65816(); 95 | void resetspc(); 96 | void resetppu(); 97 | void dumpspcregs(); 98 | void makeopcodetable(); 99 | void makeromtable(); 100 | void makespctables(); 101 | void maketables(); 102 | int loadsmc(char *fn); 103 | void renderscreen() __attribute__((used)); 104 | void native_hardware_init(int); 105 | uint32 *native_bitmap_pointer(int x, int y) __attribute__((used)); 106 | void native_bitmap_clear_line(int line, uint32); 107 | void native_bitmap_to_screen(); 108 | void native_tick_callback( int (*func)(void), int fps); 109 | int native_poll_keyboard() __attribute__((used)); 110 | uint32* native_set_joypad_state(uint32 state) __attribute__((used)); 111 | uint32 native_joypad_state(int num); 112 | #ifdef SOUND 113 | #define UPDATE_SOUND if (soundupdate && spcemu) { soundupdate=0; updatesound();} 114 | #else 115 | #define UPDATE_SOUND 116 | #endif 117 | #ifdef USE_SDL 118 | extern Uint8 *keystates; 119 | extern uint32 *bitmap; 120 | #else 121 | extern uint32 bitmap[288*256]; 122 | #endif 123 | #endif 124 | -------------------------------------------------------------------------------- /snem/testmain.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /snem/testworker.js: -------------------------------------------------------------------------------- 1 | function snes_init(){ 2 | reboot_emulator=Module.cwrap('reboot_emulator', 'number', ['string']) 3 | native_set_joypad_state=Module._native_set_joypad_state 4 | native_bitmap_pointer=Module._native_bitmap_pointer 5 | mainloop=Module._mainloop 6 | renderscreen=Module._renderscreen 7 | palf=reboot_emulator("/_.smc") 8 | native_set_joypad_state(0x80000000) 9 | frameskip=0 10 | 11 | } 12 | function snes_mainloop(){ 13 | for(var _i=0;_i<=frameskip;_i++) 14 | mainloop(palf ? 312 :262) 15 | renderscreen() 16 | var bitmap=native_bitmap_pointer(-16,0)>>2 17 | var src=i.subarray(bitmap,bitmap+288*224) // // Unstable Hack: i is Heap32 compiled by closure 18 | var buffer=new ArrayBuffer(4*288*224) 19 | var src2=new Uint32Array(buffer) // WW2 20 | for(var _i=0;_i<288*224;_i++) src2[_i]=src[_i] // WW2 21 | postMessage({cmd:"render2", src:buffer}, [buffer]) // WW2 22 | postMessage({cmd:"render", src:src}) // WW1 23 | setTimeout("snes_mainloop()", 0); 24 | } 25 | 26 | onmessage=function(event) { 27 | var data=event.data 28 | switch(data.cmd){ 29 | case "loadfile": 30 | Module.FS_createDataFile("/", "_.smc", new Uint8Array(data.buffer) , true, true) 31 | postMessage({cmd: "print", txt:"file loaded"}) 32 | break 33 | case "start": 34 | snes_init() 35 | snes_mainloop() 36 | break 37 | case "joy1": 38 | native_set_joypad_state(data.state) 39 | break 40 | case "frameskip": 41 | frameskip=data.value 42 | break 43 | default: 44 | postMessage({cmd:"print", txt:"unknown command "+data.cmd}) 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /snes9x/apu/SNES_SPC_state.cpp: -------------------------------------------------------------------------------- 1 | // SPC emulation state save/load: copy_state(), save_spc() 2 | // Separate file to avoid linking in unless needed 3 | 4 | // snes_spc 0.9.0. http://www.slack.net/‾ant/ 5 | 6 | #include "SNES_SPC.h" 7 | 8 | #if !SPC_NO_COPY_STATE_FUNCS 9 | 10 | #include 11 | 12 | /* Copyright (C) 2004-2007 Shay Green. This module is free software; you 13 | can redistribute it and/or modify it under the terms of the GNU Lesser 14 | General Public License as published by the Free Software Foundation; either 15 | version 2.1 of the License, or (at your option) any later version. This 16 | module is distributed in the hope that it will be useful, but WITHOUT ANY 17 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 18 | FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 19 | details. You should have received a copy of the GNU Lesser General Public 20 | License along with this module; if not, write to the Free Software Foundation, 21 | Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ 22 | 23 | #include 24 | #include "blargg_source.h" 25 | 26 | #define RAM (m.ram.ram) 27 | #define REGS (m.smp_regs [0]) 28 | #define REGS_IN (m.smp_regs [1]) 29 | 30 | void SNES_SPC::save_regs( uint8_t out [reg_count] ) 31 | { 32 | // Use current timer counter values 33 | for ( int i = 0; i < timer_count; i++ ) 34 | out [r_t0out + i] = m.timers [i].counter; 35 | 36 | // Last written values 37 | memcpy( out, REGS, r_t0out ); 38 | } 39 | 40 | void SNES_SPC::init_header( void* spc_out ) 41 | { 42 | spc_file_t* const spc = (spc_file_t*) spc_out; 43 | 44 | spc->has_id666 = 26; // has none 45 | spc->version = 30; 46 | memcpy( spc, signature, sizeof spc->signature ); 47 | memset( spc->text, 0, sizeof spc->text ); 48 | } 49 | 50 | void SNES_SPC::save_spc( void* spc_out ) 51 | { 52 | spc_file_t* const spc = (spc_file_t*) spc_out; 53 | 54 | // CPU 55 | spc->pcl = (uint8_t) (m.cpu_regs.pc >> 0); 56 | spc->pch = (uint8_t) (m.cpu_regs.pc >> 8); 57 | spc->a = m.cpu_regs.a; 58 | spc->x = m.cpu_regs.x; 59 | spc->y = m.cpu_regs.y; 60 | spc->psw = m.cpu_regs.psw; 61 | spc->sp = m.cpu_regs.sp; 62 | 63 | // RAM, ROM 64 | memcpy( spc->ram, RAM, sizeof spc->ram ); 65 | if ( m.rom_enabled ) 66 | memcpy( spc->ram + rom_addr, m.hi_ram, sizeof m.hi_ram ); 67 | memset( spc->unused, 0, sizeof spc->unused ); 68 | memcpy( spc->ipl_rom, m.rom, sizeof spc->ipl_rom ); 69 | 70 | // SMP registers 71 | save_regs( &spc->ram [0xF0] ); 72 | int i; 73 | for ( i = 0; i < port_count; i++ ) 74 | spc->ram [0xF0 + r_cpuio0 + i] = REGS_IN [r_cpuio0 + i]; 75 | 76 | // DSP registers 77 | for ( i = 0; i < SPC_DSP::register_count; i++ ) 78 | spc->dsp [i] = dsp.read( i ); 79 | } 80 | 81 | #undef IF_0_THEN_256 82 | #define IF_0_THEN_256( n ) ((uint8_t) ((n) - 1) + 1) 83 | void SNES_SPC::copy_state( unsigned char** io, copy_func_t copy ) 84 | { 85 | SPC_State_Copier copier( io, copy ); 86 | 87 | // Make state data more readable by putting 64K RAM, 16 SMP registers, 88 | // then DSP (with its 128 registers) first 89 | 90 | // RAM 91 | enable_rom( 0 ); // will get re-enabled if necessary in regs_loaded() below 92 | copier.copy( RAM, 0x10000 ); 93 | 94 | { 95 | // SMP registers 96 | uint8_t regs [reg_count]; 97 | uint8_t regs_in [reg_count]; 98 | 99 | memcpy( regs, REGS, reg_count ); 100 | memcpy( regs_in, REGS_IN, reg_count ); 101 | 102 | copier.copy( regs, sizeof regs ); 103 | copier.copy( regs_in, sizeof regs_in ); 104 | 105 | memcpy( REGS, regs, reg_count); 106 | memcpy( REGS_IN, regs_in, reg_count ); 107 | 108 | enable_rom( REGS [r_control] & 0x80 ); 109 | } 110 | 111 | // CPU registers 112 | SPC_COPY( uint16_t, m.cpu_regs.pc ); 113 | SPC_COPY( uint8_t, m.cpu_regs.a ); 114 | SPC_COPY( uint8_t, m.cpu_regs.x ); 115 | SPC_COPY( uint8_t, m.cpu_regs.y ); 116 | SPC_COPY( uint8_t, m.cpu_regs.psw ); 117 | SPC_COPY( uint8_t, m.cpu_regs.sp ); 118 | copier.extra(); 119 | 120 | SPC_COPY( int16_t, m.spc_time ); 121 | SPC_COPY( int16_t, m.dsp_time ); 122 | 123 | // DSP 124 | dsp.copy_state( io, copy ); 125 | 126 | // Timers 127 | for ( int i = 0; i < timer_count; i++ ) 128 | { 129 | Timer* t = &m.timers [i]; 130 | t->period = IF_0_THEN_256( REGS [r_t0target + i] ); 131 | t->enabled = REGS [r_control] >> i & 1; 132 | SPC_COPY( int16_t, t->next_time ); 133 | SPC_COPY( uint8_t, t->divider ); 134 | SPC_COPY( uint8_t, t->counter ); 135 | copier.extra(); 136 | } 137 | 138 | set_tempo( m.tempo ); 139 | 140 | copier.extra(); 141 | } 142 | #endif 143 | -------------------------------------------------------------------------------- /snes9x/apu/SPC_Filter.cpp: -------------------------------------------------------------------------------- 1 | // snes_spc 0.9.0. http://www.slack.net/~ant/ 2 | 3 | #include "SPC_Filter.h" 4 | 5 | #include 6 | 7 | /* Copyright (C) 2007 Shay Green. This module is free software; you 8 | can redistribute it and/or modify it under the terms of the GNU Lesser 9 | General Public License as published by the Free Software Foundation; either 10 | version 2.1 of the License, or (at your option) any later version. This 11 | module is distributed in the hope that it will be useful, but WITHOUT ANY 12 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 13 | FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 14 | details. You should have received a copy of the GNU Lesser General Public 15 | License along with this module; if not, write to the Free Software Foundation, 16 | Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ 17 | 18 | #include "blargg_source.h" 19 | 20 | void SPC_Filter::clear() { memset( ch, 0, sizeof ch ); } 21 | 22 | SPC_Filter::SPC_Filter() 23 | { 24 | gain = gain_unit; 25 | bass = bass_norm; 26 | clear(); 27 | } 28 | 29 | void SPC_Filter::run( short* io, int count ) 30 | { 31 | require( (count & 1) == 0 ); // must be even 32 | 33 | int const gain = this->gain; 34 | int const bass = this->bass; 35 | chan_t* c = &ch [2]; 36 | do 37 | { 38 | // cache in registers 39 | int sum = (--c)->sum; 40 | int pp1 = c->pp1; 41 | int p1 = c->p1; 42 | 43 | for ( int i = 0; i < count; i += 2 ) 44 | { 45 | // Low-pass filter (two point FIR with coeffs 0.25, 0.75) 46 | int f = io [i] + p1; 47 | p1 = io [i] * 3; 48 | 49 | // High-pass filter ("leaky integrator") 50 | int delta = f - pp1; 51 | pp1 = f; 52 | int s = sum >> (gain_bits + 2); 53 | sum += (delta * gain) - (sum >> bass); 54 | 55 | // Clamp to 16 bits 56 | if ( (short) s != s ) 57 | s = (s >> 31) ^ 0x7FFF; 58 | 59 | io [i] = (short) s; 60 | } 61 | 62 | c->p1 = p1; 63 | c->pp1 = pp1; 64 | c->sum = sum; 65 | ++io; 66 | } 67 | while ( c != ch ); 68 | } 69 | -------------------------------------------------------------------------------- /snes9x/apu/SPC_Filter.h: -------------------------------------------------------------------------------- 1 | // Simple low-pass and high-pass filter to better match sound output of a SNES 2 | 3 | // snes_spc 0.9.0 4 | #ifndef SPC_FILTER_H 5 | #define SPC_FILTER_H 6 | 7 | #include "blargg_common.h" 8 | 9 | struct SPC_Filter { 10 | public: 11 | 12 | // Filters count samples of stereo sound in place. Count must be a multiple of 2. 13 | typedef short sample_t; 14 | void run( sample_t* io, int count ); 15 | 16 | // Optional features 17 | 18 | // Clears filter to silence 19 | void clear(); 20 | 21 | // Sets gain (volume), where gain_unit is normal. Gains greater than gain_unit 22 | // are fine, since output is clamped to 16-bit sample range. 23 | enum { gain_unit = 0x100 }; 24 | void set_gain( int gain ); 25 | 26 | // Sets amount of bass (logarithmic scale) 27 | enum { bass_none = 0 }; 28 | enum { bass_norm = 8 }; // normal amount 29 | enum { bass_max = 31 }; 30 | void set_bass( int bass ); 31 | 32 | public: 33 | SPC_Filter(); 34 | BLARGG_DISABLE_NOTHROW 35 | private: 36 | enum { gain_bits = 8 }; 37 | int gain; 38 | int bass; 39 | struct chan_t { int p1, pp1, sum; }; 40 | chan_t ch [2]; 41 | }; 42 | 43 | inline void SPC_Filter::set_gain( int g ) { gain = g; } 44 | 45 | inline void SPC_Filter::set_bass( int b ) { bass = b; } 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /snes9x/apu/blargg_common.h: -------------------------------------------------------------------------------- 1 | // Sets up common environment for Shay Green's libraries. 2 | // To change configuration options, modify blargg_config.h, not this file. 3 | 4 | // snes_spc 0.9.0 5 | #ifndef BLARGG_COMMON_H 6 | #define BLARGG_COMMON_H 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | #undef BLARGG_COMMON_H 14 | // allow blargg_config.h to #include blargg_common.h 15 | #include "blargg_config.h" 16 | #ifndef BLARGG_COMMON_H 17 | #define BLARGG_COMMON_H 18 | 19 | // BLARGG_RESTRICT: equivalent to restrict, where supported 20 | #if defined (__GNUC__) || _MSC_VER >= 1100 21 | #define BLARGG_RESTRICT __restrict 22 | #else 23 | #define BLARGG_RESTRICT 24 | #endif 25 | 26 | // STATIC_CAST(T,expr): Used in place of static_cast (expr) 27 | #ifndef STATIC_CAST 28 | #define STATIC_CAST(T,expr) ((T) (expr)) 29 | #endif 30 | 31 | // blargg_err_t (0 on success, otherwise error string) 32 | #ifndef blargg_err_t 33 | typedef const char* blargg_err_t; 34 | #endif 35 | 36 | // blargg_vector - very lightweight vector of POD types (no constructor/destructor) 37 | template 38 | class blargg_vector { 39 | T* begin_; 40 | size_t size_; 41 | public: 42 | blargg_vector() : begin_( 0 ), size_( 0 ) { } 43 | ~blargg_vector() { free( begin_ ); } 44 | size_t size() const { return size_; } 45 | T* begin() const { return begin_; } 46 | T* end() const { return begin_ + size_; } 47 | blargg_err_t resize( size_t n ) 48 | { 49 | // TODO: blargg_common.cpp to hold this as an outline function, ugh 50 | void* p = realloc( begin_, n * sizeof (T) ); 51 | if ( p ) 52 | begin_ = (T*) p; 53 | else if ( n > size_ ) // realloc failure only a problem if expanding 54 | return "Out of memory"; 55 | size_ = n; 56 | return 0; 57 | } 58 | void clear() { void* p = begin_; begin_ = 0; size_ = 0; free( p ); } 59 | T& operator [] ( size_t n ) const 60 | { 61 | assert( n <= size_ ); // <= to allow past-the-end value 62 | return begin_ [n]; 63 | } 64 | }; 65 | 66 | #ifndef BLARGG_DISABLE_NOTHROW 67 | // throw spec mandatory in ISO C++ if operator new can return NULL 68 | #if __cplusplus >= 199711 || defined (__GNUC__) 69 | #define BLARGG_THROWS( spec ) throw spec 70 | #else 71 | #define BLARGG_THROWS( spec ) 72 | #endif 73 | #define BLARGG_DISABLE_NOTHROW \ 74 | void* operator new ( size_t s ) BLARGG_THROWS(()) { return malloc( s ); }\ 75 | void operator delete ( void* p ) { free( p ); } 76 | #define BLARGG_NEW new 77 | #else 78 | #include 79 | #define BLARGG_NEW new (std::nothrow) 80 | #endif 81 | 82 | // BLARGG_4CHAR('a','b','c','d') = 'abcd' (four character integer constant) 83 | #define BLARGG_4CHAR( a, b, c, d ) \ 84 | ((a&0xFF)*0x1000000L + (b&0xFF)*0x10000L + (c&0xFF)*0x100L + (d&0xFF)) 85 | 86 | // BOOST_STATIC_ASSERT( expr ): Generates compile error if expr is 0. 87 | #ifndef BOOST_STATIC_ASSERT 88 | #ifdef _MSC_VER 89 | // MSVC6 (_MSC_VER < 1300) fails for use of __LINE__ when /Zl is specified 90 | #define BOOST_STATIC_ASSERT( expr ) \ 91 | void blargg_failed_( int (*arg) [2 / (int) !!(expr) - 1] ) 92 | #else 93 | // Some other compilers fail when declaring same function multiple times in class, 94 | // so differentiate them by line 95 | #define BOOST_STATIC_ASSERT( expr ) \ 96 | void blargg_failed_( int (*arg) [2 / !!(expr) - 1] [__LINE__] ) 97 | #endif 98 | #endif 99 | 100 | // BLARGG_COMPILER_HAS_BOOL: If 0, provides bool support for old compiler. If 1, 101 | // compiler is assumed to support bool. If undefined, availability is determined. 102 | #ifndef BLARGG_COMPILER_HAS_BOOL 103 | #if defined (__MWERKS__) 104 | #if !__option(bool) 105 | #define BLARGG_COMPILER_HAS_BOOL 0 106 | #endif 107 | #elif defined (_MSC_VER) 108 | #if _MSC_VER < 1100 109 | #define BLARGG_COMPILER_HAS_BOOL 0 110 | #endif 111 | #elif defined (__GNUC__) 112 | // supports bool 113 | #elif __cplusplus < 199711 114 | #define BLARGG_COMPILER_HAS_BOOL 0 115 | #endif 116 | #endif 117 | #if defined (BLARGG_COMPILER_HAS_BOOL) && !BLARGG_COMPILER_HAS_BOOL 118 | // If you get errors here, modify your blargg_config.h file 119 | typedef int bool; 120 | const bool true = 1; 121 | const bool false = 0; 122 | #endif 123 | 124 | // blargg_long/blargg_ulong = at least 32 bits, int if it's big enough 125 | 126 | #if INT_MAX < 0x7FFFFFFF || LONG_MAX == 0x7FFFFFFF 127 | typedef long blargg_long; 128 | #else 129 | typedef int blargg_long; 130 | #endif 131 | 132 | #if UINT_MAX < 0xFFFFFFFF || ULONG_MAX == 0xFFFFFFFF 133 | typedef unsigned long blargg_ulong; 134 | #else 135 | typedef unsigned blargg_ulong; 136 | #endif 137 | 138 | // BOOST::int8_t etc. 139 | 140 | // HAVE_STDINT_H: If defined, use for int8_t etc. 141 | #if defined (HAVE_STDINT_H) 142 | #include 143 | #define BOOST 144 | 145 | // HAVE_INTTYPES_H: If defined, use for int8_t etc. 146 | #elif defined (HAVE_INTTYPES_H) 147 | #include 148 | #define BOOST 149 | 150 | #else 151 | struct BOOST 152 | { 153 | #if UCHAR_MAX == 0xFF && SCHAR_MAX == 0x7F 154 | typedef signed char int8_t; 155 | typedef unsigned char uint8_t; 156 | #else 157 | // No suitable 8-bit type available 158 | typedef struct see_blargg_common_h int8_t; 159 | typedef struct see_blargg_common_h uint8_t; 160 | #endif 161 | 162 | #if USHRT_MAX == 0xFFFF 163 | typedef short int16_t; 164 | typedef unsigned short uint16_t; 165 | #else 166 | // No suitable 16-bit type available 167 | typedef struct see_blargg_common_h int16_t; 168 | typedef struct see_blargg_common_h uint16_t; 169 | #endif 170 | 171 | #if ULONG_MAX == 0xFFFFFFFF 172 | typedef long int32_t; 173 | typedef unsigned long uint32_t; 174 | #elif UINT_MAX == 0xFFFFFFFF 175 | typedef int int32_t; 176 | typedef unsigned int uint32_t; 177 | #else 178 | // No suitable 32-bit type available 179 | typedef struct see_blargg_common_h int32_t; 180 | typedef struct see_blargg_common_h uint32_t; 181 | #endif 182 | }; 183 | #endif 184 | 185 | #endif 186 | #endif 187 | -------------------------------------------------------------------------------- /snes9x/apu/blargg_config.h: -------------------------------------------------------------------------------- 1 | // snes_spc 0.9.0 user configuration file. Don't replace when updating library. 2 | 3 | // snes_spc 0.9.0 4 | #ifndef BLARGG_CONFIG_H 5 | #define BLARGG_CONFIG_H 6 | 7 | // Uncomment to disable debugging checks 8 | //#define NDEBUG 1 9 | 10 | // Uncomment to enable platform-specific (and possibly non-portable) optimizations 11 | //#define BLARGG_NONPORTABLE 1 12 | 13 | // Uncomment if automatic byte-order determination doesn't work 14 | //#define BLARGG_BIG_ENDIAN 1 15 | 16 | // Uncomment if you get errors in the bool section of blargg_common.h 17 | //#define BLARGG_COMPILER_HAS_BOOL 1 18 | 19 | // Use standard config.h if present 20 | #ifdef HAVE_CONFIG_H 21 | #include "config.h" 22 | #endif 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /snes9x/apu/blargg_source.h: -------------------------------------------------------------------------------- 1 | /* Included at the beginning of library source files, after all other #include lines. 2 | Sets up helpful macros and services used in my source code. They don't need 3 | module an annoying module prefix on their names since they are defined after 4 | all other #include lines. */ 5 | 6 | // snes_spc 0.9.0 7 | #ifndef BLARGG_SOURCE_H 8 | #define BLARGG_SOURCE_H 9 | 10 | // If debugging is enabled, abort program if expr is false. Meant for checking 11 | // internal state and consistency. A failed assertion indicates a bug in the module. 12 | // void assert( bool expr ); 13 | #include 14 | 15 | // If debugging is enabled and expr is false, abort program. Meant for checking 16 | // caller-supplied parameters and operations that are outside the control of the 17 | // module. A failed requirement indicates a bug outside the module. 18 | // void require( bool expr ); 19 | #undef require 20 | #define require( expr ) assert( expr ) 21 | 22 | // Like printf() except output goes to debug log file. Might be defined to do 23 | // nothing (not even evaluate its arguments). 24 | // void dprintf( const char* format, ... ); 25 | static inline void blargg_dprintf_( const char*, ... ) { } 26 | #undef dprintf 27 | #define dprintf (1) ? (void) 0 : blargg_dprintf_ 28 | 29 | // If enabled, evaluate expr and if false, make debug log entry with source file 30 | // and line. Meant for finding situations that should be examined further, but that 31 | // don't indicate a problem. In all cases, execution continues normally. 32 | #undef check 33 | #define check( expr ) ((void) 0) 34 | 35 | // If expr yields error string, return it from current function, otherwise continue. 36 | #undef RETURN_ERR 37 | #define RETURN_ERR( expr ) do { \ 38 | blargg_err_t blargg_return_err_ = (expr); \ 39 | if ( blargg_return_err_ ) return blargg_return_err_; \ 40 | } while ( 0 ) 41 | 42 | // If ptr is 0, return out of memory error string. 43 | #undef CHECK_ALLOC 44 | #define CHECK_ALLOC( ptr ) do { if ( (ptr) == 0 ) return "Out of memory"; } while ( 0 ) 45 | 46 | // Avoid any macros which evaluate their arguments multiple times 47 | #undef min 48 | #undef max 49 | 50 | #define DEF_MIN_MAX( type ) \ 51 | static inline type min( type x, type y ) { if ( x < y ) return x; return y; }\ 52 | static inline type max( type x, type y ) { if ( y < x ) return x; return y; } 53 | 54 | DEF_MIN_MAX( int ) 55 | DEF_MIN_MAX( unsigned ) 56 | DEF_MIN_MAX( long ) 57 | DEF_MIN_MAX( unsigned long ) 58 | DEF_MIN_MAX( float ) 59 | DEF_MIN_MAX( double ) 60 | 61 | #undef DEF_MIN_MAX 62 | 63 | /* 64 | // using const references generates crappy code, and I am currenly only using these 65 | // for built-in types, so they take arguments by value 66 | 67 | // TODO: remove 68 | inline int min( int x, int y ) 69 | template 70 | inline T min( T x, T y ) 71 | { 72 | if ( x < y ) 73 | return x; 74 | return y; 75 | } 76 | 77 | template 78 | inline T max( T x, T y ) 79 | { 80 | if ( x < y ) 81 | return y; 82 | return x; 83 | } 84 | */ 85 | 86 | // TODO: good idea? bad idea? 87 | #undef byte 88 | #define byte byte_ 89 | typedef unsigned char byte; 90 | 91 | // deprecated 92 | #define BLARGG_CHECK_ALLOC CHECK_ALLOC 93 | #define BLARGG_RETURN_ERR RETURN_ERR 94 | 95 | // BLARGG_SOURCE_BEGIN: If defined, #included, allowing redefition of dprintf and check 96 | #ifdef BLARGG_SOURCE_BEGIN 97 | #include BLARGG_SOURCE_BEGIN 98 | #endif 99 | 100 | #endif 101 | -------------------------------------------------------------------------------- /snes9x/apu/hermite_resampler.h: -------------------------------------------------------------------------------- 1 | /* Simple resampler based on bsnes's ruby audio library */ 2 | 3 | #ifndef __HERMITE_RESAMPLER_H 4 | #define __HERMITE_RESAMPLER_H 5 | 6 | #include "resampler.h" 7 | 8 | #undef CLAMP 9 | #undef SHORT_CLAMP 10 | #define CLAMP(x, low, high) (((x) > (high)) ? (high) : (((x) < (low)) ? (low) : (x))) 11 | #define SHORT_CLAMP(n) ((short) CLAMP((n), -32768, 32767)) 12 | 13 | class HermiteResampler : public Resampler 14 | { 15 | protected: 16 | 17 | double r_step; 18 | double r_frac; 19 | int r_left[4], r_right[4]; 20 | 21 | double 22 | hermite (double mu1, double a, double b, double c, double d) 23 | { 24 | const double tension = 0.0; //-1 = low, 0 = normal, 1 = high 25 | const double bias = 0.0; //-1 = left, 0 = even, 1 = right 26 | 27 | double mu2, mu3, m0, m1, a0, a1, a2, a3; 28 | 29 | mu2 = mu1 * mu1; 30 | mu3 = mu2 * mu1; 31 | 32 | m0 = (b - a) * (1 + bias) * (1 - tension) / 2; 33 | m0 += (c - b) * (1 - bias) * (1 - tension) / 2; 34 | m1 = (c - b) * (1 + bias) * (1 - tension) / 2; 35 | m1 += (d - c) * (1 - bias) * (1 - tension) / 2; 36 | 37 | a0 = +2 * mu3 - 3 * mu2 + 1; 38 | a1 = mu3 - 2 * mu2 + mu1; 39 | a2 = mu3 - mu2; 40 | a3 = -2 * mu3 + 3 * mu2; 41 | 42 | return (a0 * b) + (a1 * m0) + (a2 * m1) + (a3 * c); 43 | } 44 | 45 | public: 46 | HermiteResampler (int num_samples) : Resampler (num_samples) 47 | { 48 | clear (); 49 | } 50 | 51 | ~HermiteResampler () 52 | { 53 | } 54 | 55 | void 56 | time_ratio (double ratio) 57 | { 58 | r_step = ratio; 59 | clear (); 60 | } 61 | 62 | void 63 | clear (void) 64 | { 65 | ring_buffer::clear (); 66 | r_frac = 1.0; 67 | r_left [0] = r_left [1] = r_left [2] = r_left [3] = 0; 68 | r_right[0] = r_right[1] = r_right[2] = r_right[3] = 0; 69 | } 70 | 71 | void 72 | read (short *data, int num_samples) 73 | { 74 | int i_position = start >> 1; 75 | short *internal_buffer = (short *) buffer; 76 | int o_position = 0; 77 | int consumed = 0; 78 | 79 | while (o_position < num_samples && consumed < buffer_size) 80 | { 81 | int s_left = internal_buffer[i_position]; 82 | int s_right = internal_buffer[i_position + 1]; 83 | int max_samples = buffer_size >> 1; 84 | const double margin_of_error = 1.0e-10; 85 | 86 | if (fabs(r_step - 1.0) < margin_of_error) 87 | { 88 | data[o_position] = (short) s_left; 89 | data[o_position + 1] = (short) s_right; 90 | 91 | o_position += 2; 92 | i_position += 2; 93 | if (i_position >= max_samples) 94 | i_position -= max_samples; 95 | consumed += 2; 96 | 97 | continue; 98 | } 99 | 100 | while (r_frac <= 1.0 && o_position < num_samples) 101 | { 102 | data[o_position] = SHORT_CLAMP (hermite (r_frac, r_left [0], r_left [1], r_left [2], r_left [3])); 103 | data[o_position + 1] = SHORT_CLAMP (hermite (r_frac, r_right[0], r_right[1], r_right[2], r_right[3])); 104 | 105 | o_position += 2; 106 | 107 | r_frac += r_step; 108 | } 109 | 110 | if (r_frac > 1.0) 111 | { 112 | r_left [0] = r_left [1]; 113 | r_left [1] = r_left [2]; 114 | r_left [2] = r_left [3]; 115 | r_left [3] = s_left; 116 | 117 | r_right[0] = r_right[1]; 118 | r_right[1] = r_right[2]; 119 | r_right[2] = r_right[3]; 120 | r_right[3] = s_right; 121 | 122 | r_frac -= 1.0; 123 | 124 | i_position += 2; 125 | if (i_position >= max_samples) 126 | i_position -= max_samples; 127 | consumed += 2; 128 | } 129 | } 130 | 131 | size -= consumed << 1; 132 | start += consumed << 1; 133 | if (start >= buffer_size) 134 | start -= buffer_size; 135 | } 136 | 137 | inline int 138 | avail (void) 139 | { 140 | return (int) floor (((size >> 2) - r_frac) / r_step) * 2; 141 | } 142 | }; 143 | 144 | #endif /* __HERMITE_RESAMPLER_H */ 145 | -------------------------------------------------------------------------------- /snes9x/apu/linear_resampler.h: -------------------------------------------------------------------------------- 1 | /* Simple fixed-point linear resampler by BearOso*/ 2 | 3 | #ifndef __LINEAR_RESAMPLER_H 4 | #define __LINEAR_RESAMPLER_H 5 | 6 | #include "resampler.h" 7 | #include "snes9x.h" 8 | 9 | static const int f_prec = 15; 10 | static const uint32 f__one = (1 << f_prec); 11 | 12 | #define lerp(t, a, b) (((((b) - (a)) * (t)) >> f_prec) + (a)) 13 | 14 | class LinearResampler : public Resampler 15 | { 16 | protected: 17 | uint32 f__r_step; 18 | uint32 f__inv_r_step; 19 | uint32 f__r_frac; 20 | int r_left, r_right; 21 | 22 | public: 23 | LinearResampler (int num_samples) : Resampler (num_samples) 24 | { 25 | f__r_frac = 0; 26 | } 27 | 28 | ~LinearResampler () 29 | { 30 | } 31 | 32 | void 33 | time_ratio (double ratio) 34 | { 35 | if (ratio == 0.0) 36 | ratio = 1.0; 37 | f__r_step = (uint32) (ratio * f__one); 38 | f__inv_r_step = (uint32) (f__one / ratio); 39 | clear (); 40 | } 41 | 42 | void 43 | clear (void) 44 | { 45 | ring_buffer::clear (); 46 | f__r_frac = 0; 47 | r_left = 0; 48 | r_right = 0; 49 | } 50 | 51 | void 52 | read (short *data, int num_samples) 53 | { 54 | int i_position = start >> 1; 55 | short *internal_buffer = (short *) buffer; 56 | int o_position = 0; 57 | int consumed = 0; 58 | int max_samples = (buffer_size >> 1); 59 | 60 | while (o_position < num_samples && consumed < buffer_size) 61 | { 62 | if (f__r_step == f__one) 63 | { 64 | data[o_position] = internal_buffer[i_position]; 65 | data[o_position + 1] = internal_buffer[i_position + 1]; 66 | 67 | o_position += 2; 68 | i_position += 2; 69 | if (i_position >= max_samples) 70 | i_position -= max_samples; 71 | consumed += 2; 72 | 73 | continue; 74 | } 75 | 76 | while (f__r_frac <= f__one && o_position < num_samples) 77 | { 78 | data[o_position] = lerp (f__r_frac, 79 | r_left, 80 | internal_buffer[i_position]); 81 | data[o_position + 1] = lerp (f__r_frac, 82 | r_right, 83 | internal_buffer[i_position + 1]); 84 | 85 | o_position += 2; 86 | 87 | f__r_frac += f__r_step; 88 | } 89 | 90 | if (f__r_frac > f__one) 91 | { 92 | f__r_frac -= f__one; 93 | r_left = internal_buffer[i_position]; 94 | r_right = internal_buffer[i_position + 1]; 95 | i_position += 2; 96 | if (i_position >= max_samples) 97 | i_position -= max_samples; 98 | consumed += 2; 99 | } 100 | } 101 | 102 | size -= consumed << 1; 103 | start += consumed << 1; 104 | if (start >= buffer_size) 105 | start -= buffer_size; 106 | } 107 | 108 | inline int 109 | avail (void) 110 | { 111 | return (((size >> 2) * f__inv_r_step) - ((f__r_frac * f__inv_r_step) >> f_prec)) >> (f_prec - 1); 112 | } 113 | }; 114 | 115 | #endif /* __LINEAR_RESAMPLER_H */ 116 | -------------------------------------------------------------------------------- /snes9x/apu/resampler.h: -------------------------------------------------------------------------------- 1 | /* Simple resampler based on bsnes's ruby audio library */ 2 | 3 | #ifndef __RESAMPLER_H 4 | #define __RESAMPLER_H 5 | 6 | #include "ring_buffer.h" 7 | 8 | class Resampler : public ring_buffer 9 | { 10 | public: 11 | virtual void clear (void) = 0; 12 | virtual void time_ratio (double) = 0; 13 | virtual void read (short *, int) = 0; 14 | virtual int avail (void) = 0; 15 | 16 | Resampler (int num_samples) : ring_buffer (num_samples << 1) 17 | { 18 | } 19 | 20 | virtual ~Resampler () 21 | { 22 | } 23 | 24 | inline bool 25 | push (short *src, int num_samples) 26 | { 27 | if (max_write () < num_samples) 28 | return false; 29 | 30 | !num_samples || ring_buffer::push ((unsigned char *) src, num_samples << 1); 31 | 32 | return true; 33 | } 34 | 35 | inline int 36 | space_empty (void) 37 | { 38 | return buffer_size - size; 39 | } 40 | 41 | inline int 42 | space_filled (void) 43 | { 44 | return size; 45 | } 46 | 47 | inline int 48 | max_write (void) 49 | { 50 | return space_empty () >> 1; 51 | } 52 | 53 | inline void 54 | resize (int num_samples) 55 | { 56 | ring_buffer::resize (num_samples << 1); 57 | } 58 | }; 59 | 60 | #endif /* __RESAMPLER_H */ 61 | -------------------------------------------------------------------------------- /snes9x/apu/ring_buffer.h: -------------------------------------------------------------------------------- 1 | /* Simple byte-based ring buffer. Licensed under public domain (C) BearOso. */ 2 | 3 | #ifndef __RING_BUFFER_H 4 | #define __RING_BUFFER_H 5 | 6 | #include 7 | 8 | #undef MIN 9 | #define MIN(a, b) ((a) < (b) ? (a) : (b)) 10 | 11 | class ring_buffer 12 | { 13 | protected: 14 | int size; 15 | int buffer_size; 16 | int start; 17 | unsigned char *buffer; 18 | 19 | public: 20 | ring_buffer (int buffer_size) 21 | { 22 | this->buffer_size = buffer_size; 23 | buffer = new unsigned char[this->buffer_size]; 24 | memset (buffer, 0, this->buffer_size); 25 | 26 | size = 0; 27 | start = 0; 28 | } 29 | 30 | ~ring_buffer (void) 31 | { 32 | delete[] buffer; 33 | } 34 | 35 | bool 36 | push (unsigned char *src, int bytes) 37 | { 38 | if (space_empty () < bytes) 39 | return false; 40 | 41 | int end = (start + size) % buffer_size; 42 | int first_write_size = MIN (bytes, buffer_size - end); 43 | 44 | memcpy (buffer + end, src, first_write_size); 45 | 46 | if (bytes > first_write_size) 47 | memcpy (buffer, src + first_write_size, bytes - first_write_size); 48 | 49 | size += bytes; 50 | 51 | return true; 52 | } 53 | 54 | bool 55 | pull (unsigned char *dst, int bytes) 56 | { 57 | if (space_filled () < bytes) 58 | return false; 59 | 60 | memcpy (dst, buffer + start, MIN (bytes, buffer_size - start)); 61 | 62 | if (bytes > (buffer_size - start)) 63 | memcpy (dst + (buffer_size - start), buffer, bytes - (buffer_size - start)); 64 | 65 | start = (start + bytes) % buffer_size; 66 | size -= bytes; 67 | 68 | return true; 69 | } 70 | 71 | inline int 72 | space_empty (void) 73 | { 74 | return buffer_size - size; 75 | } 76 | 77 | inline int 78 | space_filled (void) 79 | { 80 | return size; 81 | } 82 | 83 | void 84 | clear (void) 85 | { 86 | start = 0; 87 | size = 0; 88 | memset (buffer, 0, buffer_size); 89 | } 90 | 91 | void 92 | resize (int size) 93 | { 94 | delete[] buffer; 95 | buffer_size = size; 96 | buffer = new unsigned char[buffer_size]; 97 | memset (buffer, 0, this->buffer_size); 98 | 99 | size = 0; 100 | start = 0; 101 | } 102 | 103 | inline void 104 | cache_silence (void) 105 | { 106 | clear (); 107 | size = buffer_size; 108 | } 109 | }; 110 | 111 | #endif 112 | -------------------------------------------------------------------------------- /snes9x/docs/control-inputs.txt: -------------------------------------------------------------------------------- 1 | Control input names are completely defined by the individual ports. This 2 | document is intended to collect the rules for all ports. 3 | 4 | The various meta-characters in the rules are: 5 | # - A number. The range is detemined by the context 6 | ## - A two-digit number (i.e. with leading zeros) 7 | [...] - Something optional 8 | (...) - For grouping with | 9 | | - "or", choose one of the options. 10 | <...> - A named field 11 | {...} - A list of possible values. Multiple values may be used, but they 12 | must be in the order listed and joined with +-signs. 13 | "" - 'ditto', used to indicate the same list as the above line. 14 | 15 | ================================================================================ 16 | Unix 17 | ================================================================================ 18 | 19 | Input names: 20 | Jxx:Axis# Axis # on joystick xx. Axis0 may be 21 | Up/Down, and Axis1 Left/Right. 22 | Jxx:B# Button # on joystick xx. 23 | 24 | Jxx:{M1,M2,M3,M4,M5,M6,M7,M8}+B# Used with the 'JSx Meta#' port 25 | Jxx:{M1,M2,M3,M4,M5,M6,M7,M8}+Axis# command. 26 | 27 | Jxx:X+B# Used to 'define' this key for all 28 | Jxx:X+Axis# combinations of JS Meta. 29 | 30 | Port-specific Commands: 31 | JSx Meta# Used to specify modifier keys (i.e. Shift, Control) to 32 | affect the specified joystick. For example, you could 33 | map J00:B20 to "JS0 Meta1", then map J00:B0 to "Joypad1 34 | A" and J00:M1+B0 to "Joypad1 Turbo A". '#' may range 35 | from 1-8. 36 | 37 | Jsx ToggleMeta# Like the above, but toggles the meta-state each time 38 | the button is pressed. 39 | 40 | ================================================================================ 41 | Unix/X11 42 | ================================================================================ 43 | 44 | Keyboard Input: 45 | 46 | Note that only one keyboard (K00) is currently supported. If you know how 47 | to support multiple keyboards (and can test it!), feel free to fix x11.cpp 48 | and delete this note. 49 | 50 | Keyboard modifiers are S=Shift, C=Control, A=Alt, M=Meta. Combine them in 51 | order, i.e. all 4 would be "SCAM". 52 | 53 | Kxx: Key names are as recognized by XStringToKeysym. 54 | Kxx:+ Note however that keys are mapped by keycode, 55 | so for example on a standard qwerty keyboard 56 | "K00:colon" and "K00:semicolon" are identical. 57 | 58 | Pointer Input: 59 | 60 | Note that only one mouse (M00) is currently supported. If you know how to 61 | support multiple pointing devices (and can test it!), feel free to fix 62 | x11.cpp and delete this note. 63 | 64 | Mxx:Pointer Map the mouse pointer. If someone has a mouse 65 | Mxx:Pointer# device with multiple pointers, fix x11.cpp to 66 | report that and you can use the second syntax. 67 | 68 | Mxx:B# Mouse buttons. 69 | -------------------------------------------------------------------------------- /snes9x/docs/controls.txt: -------------------------------------------------------------------------------- 1 | This lists the available commands, excluding the ones you get back from 2 | S9xGetAllSnes9xCommands(). The various meta-characters are: 3 | # - A number. The range is detemined by the context 4 | ## - A two-digit number (i.e. with leading zeros) 5 | [...] - Something optional 6 | (...) - For grouping with | 7 | | - "or", choose one of the options. 8 | <...> - A named field 9 | {...} - A list of possible values. Multiple values may be used, but they 10 | must be in the order listed and joined with +-signs. 11 | "" - 'ditto', used to indicate the same list as the above line. 12 | 13 | Speeds are: Var, Slow, Med, and Fast. 'Var' starts slow and speeds up as the 14 | button is held. 15 | 16 | Axes are: Left/Right, Right/Left, Up/Down, Down/Up, Y/A, A/Y, X/B, B/X, L/R, 17 | and R/L. Negative is listed first (i.e. "Y/A" means negative deflection is 18 | towards Y, while "A/Y" means negative deflection is towards A). 19 | 20 | AxisToPointer, ButtonToPointer, and AxisToButtons allow for translating 21 | between different input types. There are 8 'pointers' with IDs 22 | PseudoPointerBase+0 to PseudoPointerBase+7, and 256 'buttons' with IDs 23 | PseudoButtonBase+0 to PseudoButtonBase+255. So for example, 24 | "AxisToButtons 0/255 T=50%" would take the axis data, and do 25 | S9xReportButton(PseudoButtonBase+0,1) when said axis goes past 50% in the 26 | negative direction and S9xReportButton(PseudoButtonBase+255,1) when it goes 27 | over 50% deflection in the positive direction. Similarly, it will do 28 | S9xReportButton(...,0) when the deflection drops under 50% in either 29 | direction. "ButtonToPointer 1u Slow" would move the pointer with ID 30 | PseudoPointerBase+0 up one pixel per frame as long as the button is pressed 31 | (reporting this change at the end of each frame). 32 | 33 | --------------- 34 | Button Commands 35 | --------------- 36 | 37 | Joypad# {Up, Down, Left, Right, A, B, X, Y, L, R, Start, Select} 38 | Joypad# Turbo "" 39 | Joypad# Sticky "" 40 | Joypad# StickyTurbo "" 41 | Joypad# ToggleTurbo "" 42 | Joypad# ToggleSticky "" 43 | Joypad# ToggleStickyTurbo "" 44 | 45 | Mouse# (L|R|LR) 46 | 47 | Superscope AimOffscreen 48 | Superscope {Fire, Cursor, ToggleTurbo, Pause} 49 | Superscope AimOffscreen "" 50 | 51 | Justifier# AimOffscreen 52 | Justifier# {Trigger, Start} 53 | Justifier# AimOffscreen "" 54 | 55 | ButtonToPointer #[u|d][l|r] ; NOTE: "# " is invalid 56 | 57 | ------------- 58 | Axis Commands 59 | ------------- 60 | 61 | Joypad# Axis T=#% ; T = 0.1 to 100 by tenths 62 | AxisToButtons #/# T=#% ; neg then pos, range 0-255, T as above 63 | AxisToPointer #(h|v) [-] ; NOTE: '-' inverts the axis 64 | 65 | ---------------- 66 | Pointer Commands 67 | ---------------- 68 | 69 | Pointer {Mouse1, Mouse2, Superscope, Justifier1, Justifier2} 70 | 71 | ------ 72 | Multis 73 | ------ 74 | 75 | Multis are a type of button command. The basic format of a multi is "{...}", 76 | where the '...' consists of 1 or more valid non-multi button command 77 | strings. The braces are literal, not metacharacters. Subcommands separated 78 | by commas are executed one after the next. Semicolons skip one frame before 79 | continuing subcommand execution. Semicolons may be repeated. When the multi 80 | button is pressed, each subcommand is 'pressed', and when the multi button 81 | is released each subcommand is 'released'. 82 | 83 | There are also press-only multis, defined as "+{...}". These act just like 84 | regular multis, with two differences: the multi is only run when you press 85 | the button (release isignored), and each subcommand must be prefixed with 86 | '+' or '-' to indicate whether the the subcommand should be pressed or 87 | released. 88 | 89 | For example: {Joypad1 A,Joypad2 A;Joypad3 A;;;;;QuickSave000} 90 | This presses (or releases) A on pads 1 and 2, then waits one frame, then 91 | presses A on pad 3, then waits 5 frames, then saves to snapshot 0 (on press 92 | only). 93 | 94 | You may access the multi number in the returned s9xcommand_t structure as 95 | cmd.button.multi_idx. This may be used to assign the same multi to multiple 96 | buttons: 97 | MULTI# ; NOTE: that's a literal octothorpe 98 | -------------------------------------------------------------------------------- /snes9x/docs/portsofsnes9x.txt: -------------------------------------------------------------------------------- 1 | These are all the known ports of Snes9X to other consoles/handhelds/etc as of 2 | 2011/08/28. They are all supported and welcomed on the official Snes9X site. 3 | 4 | **If you know of anyone who is currently working on a port of Snes9X, or if you 5 | have some interest in making a port, please have them go to the Snes9X forums 6 | (http://www.snes9x.com/phpbb2/) and have them register an account there. After 7 | that, speak to Ryan and/or Jerremy so you can be let into the devs area and the 8 | git so you can have access to the most current code, collaborate with the other 9 | developers, make the port officialized, etc.** 10 | 11 | Ports and how to get them running are as follows: 12 | 13 | *PSP Version of Snes9X* 14 | Name: Snes9X Euphoria 15 | Latest version: R5 Beta 16 | Homepage/forum: http://code.google.com/p/snes9x-euphoria/ 17 | Maintainer: Open due to Zack discontinuing the port; he has made the source 18 | code available. If you are interested in taking over the project or starting a 19 | new port from scratch, let Ryan and/or Jerremy know ASAP. 20 | 21 | HOW TO GET IT RUNNING: 22 | *DISCLAIMER* You will have to do some Googling, including but not limited to: 23 | * Downgrading/upgrading your firmware 24 | * Checking if your PSP-2000 series can use Pandora's Battery 25 | * Checking if your PSP-3000 series can use DaveeFTW's and/or some1's Downgrader 26 | * Creating Pandora's Battery (as needed) 27 | * Finding the hacks, HENs, CFWs, etc and how to use/install them 28 | 29 | 1. Make sure your PSP is hackable in some way. This means: 30 | * All PSP-1000 series and certain PSP-2000 series can use Pandora Battery; this 31 | would be considered fully hackable. 32 | * PSP-2000 series that can't use Pandora Battery, just about all PSP-3000 33 | series, and PSP Gos are hackable via other means (DaveeFTW's and/or some1's 34 | Downgrader, etc); this would be considered partially hackable. 35 | 36 | 2. Make sure your PSP has custom firmware or a HEN that's useable (you'll have 37 | to upgrade/downgrade the firmware as necessary). (Hint: I personally prefer 38 | 5.50 GEN-D3 if your PSP can use Pandora Battery; latest version of 6.20 or 39 | 6.35 PRO CFW if your PSP can't use Pandora Battery (if you can't downgrade past 40 | 6.35, then you should be able to use 6.39 and/or 6.60 PRO).) 41 | 42 | 3. When that’s done, be sure to put the Snes9X Euphoria folder in /PSP/GAME on 43 | your PSP’s memory stick (PSP-1000/2000/3000 series) or internal memory 44 | (PSP Go). Be sure to copy the ROMs into the roms folder, saves (*.srm, etc) 45 | into the saves folder, and cheats into the cheats folder. 46 | 47 | Note: as of right now, there is no one to maintain the PSP port; I am leaving 48 | these instructions up just in case someone wants to take it over, and you can 49 | use these tips to get other homebrews going. 50 | 51 | *Wii/Gamecube version of Snes9X* 52 | Name: Snes9X GX 53 | Latest Version: 4.2.8 54 | Homepage/forum: http://code.google.com/p/snes9x-gx 55 | Maintainer: Tantric 56 | 57 | HOW TO GET IT RUNNING: 58 | *DISCLAIMER* You will have to do some Googling, including but not limited to: 59 | * Finding and installing the latest versions of: Homebrew Channel, Snes9X GX 60 | Channel (optional), and/or IOS58 installer (also optional; this is to make the 61 | Snes9X GX channel work) 62 | * Finding a modchip for your GameCube and installing it 63 | 64 | Wii: You will need the latest Homebrew Channel installed on your Wii. After 65 | that, copy and paste the apps folder onto the root of your SD card; same goes 66 | for the snes9xgx folder. After that, copy over any ROMs you have to the 67 | \snes9xgx\roms folder, save files (*.srm, etc) to the \snes9xgx\saves folder, 68 | and cheats to the \snes9xgx\cheats folder. 69 | 70 | In addition, there appears to be a channel for Snes9X GX; you will need the 71 | Homebrew Channel installed and you MUST be on System Menu 4.3 so you can be on 72 | IOS58 (or use the IOS58 installer). After that, you should be able to run the 73 | installer from the Homebrew Channel, and you'll be good to go! 74 | 75 | Gamecube: You might need a modchip. 76 | 77 | *Android and iOS (Apple iPhone/iPod Touch) version of Snes9X* 78 | Name: Snes9X EX 79 | Latest Version: 1.4.2 (iOS); 1.4.7.1 (Android) 80 | Homepage/forum: http://www.explusalpha.com/home/snes9x-ex 81 | Maintainer: Rakashazi 82 | 83 | HOW TO GET IT RUNNING: 84 | *DISCLAIMER* You will have to do some Googling, including but not limited to: 85 | * iOS (iPhone/iPod Touch) ONLY!!!: Jailbreaking your firmware 86 | 87 | Android: Due to the Android Marketplace unfairly taking down Snes9X EX, you 88 | will have to visit Rakashazi's website and download the apk either using your 89 | PC (you'll have to connect the Android to your computer, mount the SD card, 90 | then copy the apk to it) or your Android, then run package installer 91 | (or easy installer is fine too) on your Android to install the app. 92 | 93 | iOS: You’ll have to jailbreak your firmware and install the Cydia app 94 | installer. Then you’ll have to install the BigBoss repository within Cydia and 95 | search for Snes9X EX; you may also want to search for the sshd and all needed 96 | stuff for that, as it’s the only way you can put the ROMs, saves, etc onto your 97 | iPhone/iPod Touch. After that you should be able to download and run from there 98 | :) 99 | 100 | Hint: a more detailed description of copying your ROMs/saves/etc over to the 101 | iOS device can be found here: 102 | http://snes9x.com/phpbb2/viewtopic.php?t=5107 103 | 104 | *PS3 version of Snes9X* 105 | Name: Snes9X PS3 106 | Latest Version: 4.4.9 107 | Homepage/forum: https://code.google.com/p/snes9x-ps3/ (although for some 108 | reason, you may have to Google for the latest version) 109 | Maintainer: Squarepusher 110 | 111 | HOW TO GET IT RUNNING: 112 | *DISCLAIMER* You will have to do some Googling, including but not limited to: 113 | * Finding a HEN/Jailbreaker/CFW/etc onto your PS3 and installing it 114 | * (if necessary) Downgrading/Upgrading your PS3's firmware 115 | 116 | You’ll have to install a HEN/Jailbreaker/CFW/etc on your PS3 (you might have to 117 | upgrade or downgrade your PS3’s firmware as needed). After that, it should be 118 | as simple as copy the emulator, ROMs, saves, etc over to the PS3 and it should 119 | work :) 120 | 121 | *X-Box Version of Snes9X* 122 | Name: Snes9xbox 123 | Latest Version: V2 (V3 should be out soon) 124 | Homepage/forum: http://forums.xbox-scene.com/index.php?showforum=96 125 | 126 | HOW TO GET IT RUNNING: 127 | *DISCLAIMER* You will need to do some Googling, including but not limited to: 128 | * Finding a softmod (hack) or a modchip and installing/using it 129 | * Finding a replacement dashboard such as XBMC 130 | 131 | Really, it's not hard. Read the readme, and use a softmod or modchip and a 132 | replacement dashboard. After that's installed, it should be as simple as 133 | copying over the emulator, ROMs, saves, etc to the X-Box and it should work. 134 | 135 | Updated most recently by: 2011/11/2 adventure_of_link -------------------------------------------------------------------------------- /snes9x/docs/snapshots.txt: -------------------------------------------------------------------------------- 1 | ***** Important notice ******************************************************** 2 | This document describes the snapshot file format for Snes9x 1.52 and later, 3 | not compatible with 1.51. 4 | ******************************************************************************* 5 | 6 | Snes9x snapshot file format: (may be gzip-compressed) 7 | 8 | Begins with fixed length signature, consisting of a string, ':', a 4-digit 9 | decimal version, and a '\n'. 10 | 11 | #!s9xsnp:0006 <-- '\n' after the 6 12 | 13 | Then we have various blocks. The block format is: 3-character block name, 14 | ':', 6-digit length, ':', then the data. Blocks are written in a defined 15 | order. Structs are written packed with their members in a defined order, in 16 | big-endian order where applicable. 17 | 18 | NAM:000019:Chrono Trigger.zip 19 | 20 | Currently defined blocks (in order) are: 21 | 22 | Essential parts: 23 | NAM - ROM filename, from Memory.ROMFilename. 0-terminated string. 24 | CPU - struct SCPUState, CPU internal state variables. 25 | REG - struct SRegisters, emulated CPU registers. 26 | PPU - struct SPPU, PPU internal variables. Note that IPPU is never saved. 27 | DMA - struct SDMA, DMA/HDMA state variables. 28 | VRA - Memory.VRAM, 0x10000 bytes. 29 | RAM - Memory.RAM, 0x20000 bytes (WRAM). 30 | SRA - Memory.SRAM, 0x20000 bytes. 31 | FIL - Memory.FillRAM, 0x8000 bytes (register backing store). 32 | SND - All of sound emulated registers and state valiables. 33 | CTL - struct SControlSnapshot, controller emulation. 34 | TIM - struct STimings, variables about timings between emulated events. 35 | 36 | Optional parts: 37 | SFX - struct FxRegs_s, Super FX. 38 | SA1 - struct SSA1, SA1 internal state variables. 39 | SAR - struct SSA1Registers, SA1 emulated registers. 40 | DP1 - struct SDSP1, DSP-1. 41 | DP2 - struct SDSP2, DSP-2. 42 | DP4 - struct SDSP4, DSP-4. 43 | CX4 - Memory.C4RAM, 0x2000 bytes. 44 | ST0 - struct SST010, ST-010. 45 | OBC - struct SOBC1, OBC1 internal state variables. 46 | OBM - Memory.OBC1RAM, 0x2000 byts. 47 | S71 - struct SSPC7110Snapshot, SPC7110. 48 | SRT - struct SSRTCSnapshot, S-RTC internal state variables. 49 | CLK - struct SRTCData, S-RTC emulated registers. 50 | BSX - struct SBSX, BS-X. 51 | SHO - rendered SNES screen. 52 | MOV - struct SnapshotMovieInfo. 53 | MID - Some block of data the movie subsystem. 54 | 55 | ================== 56 | 57 | Without changing the snapshot version number: 58 | --------------------------------------------- 59 | 60 | Blocks may be safely added at the END of the file, as anything after the last 61 | block is ignored. Blocks may not be moved or removed. 62 | 63 | Blocks may not decrease in size. Say you decrease from 10 bytes to 5. Then 64 | later you increase back to 8. The only way you could safely do this is if 65 | bytes 5-7 still mean the same thing they meant when the block was 10 bytes 66 | long. 67 | 68 | Blocks may increase in size as you wish, as long as you can handle old 69 | savestates with the old shorter size. 70 | 71 | Struct members may not change in interpretation. New struct members may be 72 | added (at the END!) only if you can cope with them being binary-0 in older 73 | savestates. Struct members may not be removed or changed in size/type. 74 | 75 | With changing the snapshot version number: 76 | ------------------------------------------ 77 | 78 | Blocks may be added, moved, or removed at will. 79 | 80 | Blocks may decrease in size. 81 | 82 | Struct members may be added, moved, or deleted, and their 83 | interpretations/types may be changed. Use the 'debuted_in' and 'deleted_in' 84 | fields to indicate when the new member debuted or the old member went away. 85 | -------------------------------------------------------------------------------- /snes9x/docs/snes9x-license.txt: -------------------------------------------------------------------------------- 1 | Snes9x - Portable Super Nintendo Entertainment System (TM) emulator. 2 | 3 | (c) Copyright 1996 - 2002 Gary Henderson (gary.henderson@ntlworld.com), 4 | Jerremy Koot (jkoot@snes9x.com) 5 | 6 | (c) Copyright 2002 - 2004 Matthew Kendora 7 | 8 | (c) Copyright 2002 - 2005 Peter Bortas (peter@bortas.org) 9 | 10 | (c) Copyright 2004 - 2005 Joel Yliluoma (http://iki.fi/bisqwit/) 11 | 12 | (c) Copyright 2001 - 2006 John Weidman (jweidman@slip.net) 13 | 14 | (c) Copyright 2002 - 2006 funkyass (funkyass@spam.shaw.ca), 15 | Kris Bleakley (codeviolation@hotmail.com) 16 | 17 | (c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net), 18 | Nach (n-a-c-h@users.sourceforge.net), 19 | 20 | (c) Copyright 2002 - 2011 zones (kasumitokoduck@yahoo.com) 21 | 22 | (c) Copyright 2006 - 2007 nitsuja 23 | 24 | (c) Copyright 2009 - 2011 BearOso, 25 | OV2 26 | 27 | 28 | BS-X C emulator code 29 | (c) Copyright 2005 - 2006 Dreamer Nom, 30 | zones 31 | 32 | C4 x86 assembler and some C emulation code 33 | (c) Copyright 2000 - 2003 _Demo_ (_demo_@zsnes.com), 34 | Nach, 35 | zsKnight (zsknight@zsnes.com) 36 | 37 | C4 C++ code 38 | (c) Copyright 2003 - 2006 Brad Jorsch, 39 | Nach 40 | 41 | DSP-1 emulator code 42 | (c) Copyright 1998 - 2006 _Demo_, 43 | Andreas Naive (andreasnaive@gmail.com), 44 | Gary Henderson, 45 | Ivar (ivar@snes9x.com), 46 | John Weidman, 47 | Kris Bleakley, 48 | Matthew Kendora, 49 | Nach, 50 | neviksti (neviksti@hotmail.com) 51 | 52 | DSP-2 emulator code 53 | (c) Copyright 2003 John Weidman, 54 | Kris Bleakley, 55 | Lord Nightmare (lord_nightmare@users.sourceforge.net), 56 | Matthew Kendora, 57 | neviksti 58 | 59 | DSP-3 emulator code 60 | (c) Copyright 2003 - 2006 John Weidman, 61 | Kris Bleakley, 62 | Lancer, 63 | z80 gaiden 64 | 65 | DSP-4 emulator code 66 | (c) Copyright 2004 - 2006 Dreamer Nom, 67 | John Weidman, 68 | Kris Bleakley, 69 | Nach, 70 | z80 gaiden 71 | 72 | OBC1 emulator code 73 | (c) Copyright 2001 - 2004 zsKnight, 74 | pagefault (pagefault@zsnes.com), 75 | Kris Bleakley 76 | Ported from x86 assembler to C by sanmaiwashi 77 | 78 | SPC7110 and RTC C++ emulator code used in 1.39-1.51 79 | (c) Copyright 2002 Matthew Kendora with research by 80 | zsKnight, 81 | John Weidman, 82 | Dark Force 83 | 84 | SPC7110 and RTC C++ emulator code used in 1.52+ 85 | (c) Copyright 2009 byuu, 86 | neviksti 87 | 88 | S-DD1 C emulator code 89 | (c) Copyright 2003 Brad Jorsch with research by 90 | Andreas Naive, 91 | John Weidman 92 | 93 | S-RTC C emulator code 94 | (c) Copyright 2001 - 2006 byuu, 95 | John Weidman 96 | 97 | ST010 C++ emulator code 98 | (c) Copyright 2003 Feather, 99 | John Weidman, 100 | Kris Bleakley, 101 | Matthew Kendora 102 | 103 | Super FX x86 assembler emulator code 104 | (c) Copyright 1998 - 2003 _Demo_, 105 | pagefault, 106 | zsKnight 107 | 108 | Super FX C emulator code 109 | (c) Copyright 1997 - 1999 Ivar, 110 | Gary Henderson, 111 | John Weidman 112 | 113 | Sound emulator code used in 1.5-1.51 114 | (c) Copyright 1998 - 2003 Brad Martin 115 | (c) Copyright 1998 - 2006 Charles Bilyue' 116 | 117 | Sound emulator code used in 1.52+ 118 | (c) Copyright 2004 - 2007 Shay Green (gblargg@gmail.com) 119 | 120 | SH assembler code partly based on x86 assembler code 121 | (c) Copyright 2002 - 2004 Marcus Comstedt (marcus@mc.pp.se) 122 | 123 | 2xSaI filter 124 | (c) Copyright 1999 - 2001 Derek Liauw Kie Fa 125 | 126 | HQ2x, HQ3x, HQ4x filters 127 | (c) Copyright 2003 Maxim Stepin (maxim@hiend3d.com) 128 | 129 | NTSC filter 130 | (c) Copyright 2006 - 2007 Shay Green 131 | 132 | GTK+ GUI code 133 | (c) Copyright 2004 - 2011 BearOso 134 | 135 | Win32 GUI code 136 | (c) Copyright 2003 - 2006 blip, 137 | funkyass, 138 | Matthew Kendora, 139 | Nach, 140 | nitsuja 141 | (c) Copyright 2009 - 2011 OV2 142 | 143 | Mac OS GUI code 144 | (c) Copyright 1998 - 2001 John Stiles 145 | (c) Copyright 2001 - 2011 zones 146 | 147 | 148 | Specific ports contains the works of other authors. See headers in 149 | individual files. 150 | 151 | 152 | Snes9x homepage: http://www.snes9x.com/ 153 | 154 | Permission to use, copy, modify and/or distribute Snes9x in both binary 155 | and source form, for non-commercial purposes, is hereby granted without 156 | fee, providing that this license information and copyright notice appear 157 | with all copies and any derived work. 158 | 159 | This software is provided 'as-is', without any express or implied 160 | warranty. In no event shall the authors be held liable for any damages 161 | arising from the use of this software or it's derivatives. 162 | 163 | Snes9x is freeware for PERSONAL USE only. Commercial users should 164 | seek permission of the copyright holders first. Commercial use includes, 165 | but is not limited to, charging money for Snes9x or software derived from 166 | Snes9x, including Snes9x or derivatives in commercial game bundles, and/or 167 | using Snes9x as a promotion for your commercial product. 168 | 169 | The copyright holders request that bug fixes and improvements to the code 170 | should be forwarded to them so everyone can benefit from the modifications 171 | in future versions. 172 | 173 | Super NES and Super Nintendo Entertainment System are trademarks of 174 | Nintendo Co., Limited and its subsidiary companies. 175 | -------------------------------------------------------------------------------- /snes9x/docs/snes9x.conf.default: -------------------------------------------------------------------------------- 1 | #----------------------------------------- 2 | # snes9x.conf : Snes9x Configuration file 3 | #----------------------------------------- 4 | 5 | [ROM] 6 | # Filename = 7 | LoROM = FALSE 8 | HiROM = FALSE 9 | PAL = FALSE 10 | NTSC = FALSE 11 | # Header = TRUE/FALSE to ForceHeader or ForceNoHeader 12 | # Interleaved = TRUE/FALSE to ForceInterleaved or ForceNoInterleaved 13 | Interleaved2 = FALSE 14 | InterleaveGD24 = FALSE 15 | Cheat = FALSE 16 | Patch = TRUE 17 | 18 | [Sound] 19 | Sync = FALSE 20 | 16BitSound = TRUE 21 | Stereo = TRUE 22 | ReverseStereo = FALSE 23 | Rate = 32000 24 | InputRate = 32000 25 | Mute = FALSE 26 | 27 | [Display] 28 | HiRes = TRUE 29 | Transparency = TRUE 30 | GraphicWindows = TRUE 31 | DisplayFrameRate = FALSE 32 | DisplayWatchedAddresses = FALSE 33 | DisplayInput = FALSE 34 | DisplayFrameCount = FALSE 35 | MessagesInImage = TRUE 36 | MessageDisplayTime = 120 37 | 38 | [Settings] 39 | BSXBootup = FALSE 40 | # FrameTime = 41 | FrameSkip = Auto 42 | TurboMode = FALSE 43 | TurboFrameSkip = 15 44 | MovieTruncateAtEnd = FALSE 45 | MovieNotifyIgnored = FALSE 46 | WrongMovieStateProtection = TRUE 47 | StretchScreenshots = 1 48 | SnapshotScreenshots = TRUE 49 | DontSaveOopsSnapshot = FALSE 50 | AutoSaveDelay = 0 51 | 52 | [Controls] 53 | MouseMaster = TRUE 54 | SuperscopeMaster = TRUE 55 | JustifierMaster = TRUE 56 | MP5Master = TRUE 57 | AllowLeftRight = FALSE 58 | Port1 = pad1 59 | Port2 = none 60 | Mouse1Crosshair = 1 White/Black 61 | Mouse2Crosshair = 1 White/Black 62 | SuperscopeCrosshair = 2 White/Black 63 | Justifier1Crosshair = 4 Blue/Black 64 | Justifier2Crosshair = 4 MagicPink/Black 65 | 66 | [Hack] 67 | EnableGameSpecificHacks = TRUE 68 | AllowInvalidVRAMAccess = FALSE 69 | SpeedHacks = FALSE 70 | HDMATiming = 100 71 | 72 | [Netplay] 73 | Enable = FALSE 74 | Port = 6096 75 | Server = "" 76 | 77 | [DEBUG] 78 | Debugger = FALSE 79 | Trace = FALSE 80 | 81 | [Unix] 82 | # BaseDir = ~/.snes9x 83 | # SnapshotFilename = 84 | # PlayMovieFilename = 85 | # RecordMovieFilename = 86 | EnableGamePad = TRUE 87 | PadDevice1 = (null) 88 | PadDevice2 = (null) 89 | PadDevice3 = (null) 90 | PadDevice4 = (null) 91 | PadDevice5 = (null) 92 | PadDevice6 = (null) 93 | PadDevice7 = (null) 94 | PadDevice8 = (null) 95 | ThreadSound = FALSE 96 | SoundBufferSize = 100 97 | SoundFragmentSize = 2048 98 | # SoundDevice = 99 | ClearAllControls = FALSE 100 | 101 | [Unix/X11] 102 | SetKeyRepeat = TRUE 103 | VideoMode = 1 104 | 105 | [Unix/X11 Controls] 106 | J00:Axis1 = Joypad1 Axis Up/Down T=50% 107 | J00:Axis0 = Joypad1 Axis Left/Right T=50% 108 | J00:B1 = Joypad1 A 109 | J00:B2 = Joypad1 B 110 | J00:B0 = Joypad1 X 111 | J00:B3 = Joypad1 Y 112 | J00:B6 = Joypad1 L 113 | J00:B7 = Joypad1 R 114 | J00:B8 = Joypad1 Select 115 | J00:B11 = Joypad1 Start 116 | K00:u = Joypad1 Up 117 | K00:Up = Joypad1 Up 118 | K00:j = Joypad1 Down 119 | K00:n = Joypad1 Down 120 | K00:Down = Joypad1 Down 121 | K00:h = Joypad1 Left 122 | K00:Left = Joypad1 Left 123 | K00:k = Joypad1 Right 124 | K00:Right = Joypad1 Right 125 | K00:d = Joypad1 A 126 | K00:S+d = Joypad1 ToggleTurbo A 127 | K00:C+d = Joypad1 ToggleSticky A 128 | K00:c = Joypad1 B 129 | K00:S+c = Joypad1 ToggleTurbo B 130 | K00:C+c = Joypad1 ToggleSticky B 131 | K00:s = Joypad1 X 132 | K00:S+s = Joypad1 ToggleTurbo X 133 | K00:C+s = Joypad1 ToggleSticky X 134 | K00:x = Joypad1 Y 135 | K00:S+x = Joypad1 ToggleTurbo Y 136 | K00:C+x = Joypad1 ToggleSticky Y 137 | K00:a = Joypad1 L 138 | K00:v = Joypad1 L 139 | K00:S+a = Joypad1 ToggleTurbo L 140 | K00:S+v = Joypad1 ToggleTurbo L 141 | K00:C+a = Joypad1 ToggleSticky L 142 | K00:C+v = Joypad1 ToggleSticky L 143 | K00:z = Joypad1 R 144 | K00:S+z = Joypad1 ToggleTurbo R 145 | K00:C+z = Joypad1 ToggleSticky R 146 | K00:space = Joypad1 Select 147 | K00:Return = Joypad1 Start 148 | K00:KP_Up = Joypad2 Up 149 | K00:KP_Down = Joypad2 Down 150 | K00:KP_Left = Joypad2 Left 151 | K00:KP_Right = Joypad2 Right 152 | K00:Prior = Joypad2 A 153 | K00:Next = Joypad2 B 154 | K00:Home = Joypad2 X 155 | K00:End = Joypad2 Y 156 | K00:Insert = Joypad2 L 157 | K00:Delete = Joypad2 R 158 | K00:KP_Add = Joypad2 Select 159 | K00:KP_Enter = Joypad2 Start 160 | K00:Escape = ExitEmu 161 | K00:Pause = Pause 162 | K00:Scroll_Lock = Pause 163 | K00:CS+Escape = Reset 164 | K00:S+Escape = SoftReset 165 | K00:F12 = SaveFreezeFile 166 | K00:A+F3 = SaveFreezeFile 167 | K00:C+F3 = SaveFreezeFile 168 | K00:F11 = LoadFreezeFile 169 | K00:A+F2 = LoadFreezeFile 170 | K00:C+F2 = LoadFreezeFile 171 | K00:S+F1 = QuickSave000 172 | K00:S+F2 = QuickSave001 173 | K00:S+F3 = QuickSave002 174 | K00:S+F4 = QuickSave003 175 | K00:S+F5 = QuickSave004 176 | K00:S+F6 = QuickSave005 177 | K00:S+F7 = QuickSave006 178 | K00:S+F8 = QuickSave007 179 | K00:S+F9 = QuickSave008 180 | K00:F1 = QuickLoad000 181 | K00:F2 = QuickLoad001 182 | K00:F3 = QuickLoad002 183 | K00:F4 = QuickLoad003 184 | K00:F5 = QuickLoad004 185 | K00:F6 = QuickLoad005 186 | K00:F7 = QuickLoad006 187 | K00:F8 = QuickLoad007 188 | K00:F9 = QuickLoad008 189 | K00:F10 = LoadOopsFile 190 | K00:A+F1 = SaveSPC 191 | K00:C+F1 = SaveSPC 192 | K00:Print = Screenshot 193 | K00:S+1 = BeginRecordingMovie 194 | K00:S+2 = EndRecordingMovie 195 | K00:S+3 = LoadMovie 196 | K00:Tab = EmuTurbo 197 | K00:S+Tab = ToggleEmuTurbo 198 | K00:equal = IncFrameRate 199 | K00:minus = DecFrameRate 200 | K00:S+equal = IncFrameTime 201 | K00:S+minus = DecFrameTime 202 | K00:A+equal = IncEmuTurbo 203 | K00:A+minus = DecEmuTurbo 204 | K00:C+equal = IncTurboSpeed 205 | K00:C+minus = DecTurboSpeed 206 | K00:6 = SwapJoypads 207 | K00:A+F4 = SoundChannel0 208 | K00:C+F4 = SoundChannel0 209 | K00:A+F5 = SoundChannel1 210 | K00:C+F5 = SoundChannel1 211 | K00:A+F6 = SoundChannel2 212 | K00:C+F6 = SoundChannel2 213 | K00:A+F7 = SoundChannel3 214 | K00:C+F7 = SoundChannel3 215 | K00:A+F8 = SoundChannel4 216 | K00:C+F8 = SoundChannel4 217 | K00:A+F9 = SoundChannel5 218 | K00:C+F9 = SoundChannel5 219 | K00:A+F10 = SoundChannel6 220 | K00:C+F10 = SoundChannel6 221 | K00:A+F11 = SoundChannel7 222 | K00:C+F11 = SoundChannel7 223 | K00:A+F12 = SoundChannelsOn 224 | K00:C+F12 = SoundChannelsOn 225 | K00:1 = ToggleBG0 226 | K00:2 = ToggleBG1 227 | K00:3 = ToggleBG2 228 | K00:4 = ToggleBG3 229 | K00:5 = ToggleSprites 230 | K00:9 = ToggleTransparency 231 | K00:BackSpace = ClipWindows 232 | K00:A+Escape = Debugger 233 | M00:Pointer = Pointer Mouse1+Superscope+Justifier1 234 | M00:B0 = {Mouse1 L,Superscope Fire,Justifier1 Trigger} 235 | M00:B2 = {Mouse1 R,Superscope Cursor,Justifier1 Start} 236 | M00:B1 = {Justifier1 AimOffscreen Trigger,Superscope AimOffscreen} 237 | K00:grave = Superscope ToggleTurbo 238 | K00:slash = Superscope Pause 239 | -------------------------------------------------------------------------------- /snes9x/filter/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_RGB15 8 | /* #define SNES_NTSC_IN_FORMAT SNES_NTSC_RGB16 */ 9 | /* #define SNES_NTSC_IN_FORMAT SNES_NTSC_BGR15 */ 10 | 11 | /* The following affect the built-in blitter only; a custom blitter can 12 | handle things however it wants. */ 13 | 14 | /* Bits per pixel of output. Can be 15, 16, 32, or 24 (same as 32). */ 15 | #define SNES_NTSC_OUT_DEPTH 15 16 | 17 | /* Type of input pixel values */ 18 | #define SNES_NTSC_IN_T unsigned short 19 | 20 | /* Each raw pixel input value is passed through this. You might want to mask 21 | the pixel index if you use the high bits as flags, etc. */ 22 | #define SNES_NTSC_ADJ_IN( in ) in 23 | 24 | /* For each pixel, this is the basic operation: 25 | output_color = SNES_NTSC_ADJ_IN( SNES_NTSC_IN_T ) */ 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /snes9x/icons/burger1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tjwei/xnes/741561eab1286cc7d4b3692fc432b7023adf518b/snes9x/icons/burger1.png -------------------------------------------------------------------------------- /snes9x/icons/burger2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tjwei/xnes/741561eab1286cc7d4b3692fc432b7023adf518b/snes9x/icons/burger2.png -------------------------------------------------------------------------------- /snes9x/icons/burger3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tjwei/xnes/741561eab1286cc7d4b3692fc432b7023adf518b/snes9x/icons/burger3.png -------------------------------------------------------------------------------- /snes9x/jma/7z.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2005-2006 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 | 29 | -------------------------------------------------------------------------------- /snes9x/jma/7zlzma.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2005-2006 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 | { 27 | NCompress::NLZMA::CDecoder cc; 28 | 29 | UINT64 in_size_l = in_size; 30 | UINT64 out_size_l = out_size; 31 | 32 | if (cc.ReadCoderProperties(&in) != S_OK) { return(false); } 33 | if (cc.Code(&in, &out, &in_size_l, &out_size_l) != S_OK) { return(false); } 34 | if (out.size_get() != out_size || out.overflow_get()) { return(false); } 35 | 36 | return(true); 37 | } 38 | catch (...) 39 | { 40 | return(false); 41 | } 42 | } 43 | 44 | bool decompress_lzma_7z(const unsigned char* in_data, unsigned int in_size, unsigned char* out_data, unsigned int out_size) throw () 45 | { 46 | ISequentialInStream_Array in(reinterpret_cast(in_data), in_size); 47 | ISequentialOutStream_Array out(reinterpret_cast(out_data), out_size); 48 | 49 | return(decompress_lzma_7z(in, in_size, out, out_size)); 50 | } 51 | -------------------------------------------------------------------------------- /snes9x/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 | { 20 | public: 21 | UINT32 m_Probability; 22 | void UpdateModel(UINT32 aSymbol) 23 | { 24 | /* 25 | m_Probability -= (m_Probability + ((aSymbol - 1) & ((1 << aNumMoveBits) - 1))) >> aNumMoveBits; 26 | m_Probability += (1 - aSymbol) << (kNumBitModelTotalBits - aNumMoveBits); 27 | */ 28 | if (aSymbol == 0) 29 | m_Probability += (kBitModelTotal - m_Probability) >> aNumMoveBits; 30 | else 31 | m_Probability -= (m_Probability) >> aNumMoveBits; 32 | } 33 | public: 34 | void Init() { m_Probability = kBitModelTotal / 2; } 35 | }; 36 | 37 | template 38 | class CBitDecoder: public CBitModel 39 | { 40 | public: 41 | UINT32 Decode(CRangeDecoder *aRangeDecoder) 42 | { 43 | UINT32 aNewBound = (aRangeDecoder->m_Range >> kNumBitModelTotalBits) * CBitModel::m_Probability; 44 | if (aRangeDecoder->m_Code < aNewBound) 45 | { 46 | aRangeDecoder->m_Range = aNewBound; 47 | CBitModel::m_Probability += (kBitModelTotal - CBitModel::m_Probability) >> aNumMoveBits; 48 | if (aRangeDecoder->m_Range < kTopValue) 49 | { 50 | aRangeDecoder->m_Code = (aRangeDecoder->m_Code << 8) | aRangeDecoder->m_Stream.ReadByte(); 51 | aRangeDecoder->m_Range <<= 8; 52 | } 53 | return 0; 54 | } 55 | else 56 | { 57 | aRangeDecoder->m_Range -= aNewBound; 58 | aRangeDecoder->m_Code -= aNewBound; 59 | CBitModel::m_Probability -= (CBitModel::m_Probability) >> aNumMoveBits; 60 | if (aRangeDecoder->m_Range < kTopValue) 61 | { 62 | aRangeDecoder->m_Code = (aRangeDecoder->m_Code << 8) | aRangeDecoder->m_Stream.ReadByte(); 63 | aRangeDecoder->m_Range <<= 8; 64 | } 65 | return 1; 66 | } 67 | } 68 | }; 69 | 70 | }} 71 | 72 | 73 | #endif 74 | -------------------------------------------------------------------------------- /snes9x/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 | 25 | typedef NCompression::NArithmetic::CRangeDecoder CMyRangeDecoder; 26 | template class CMyBitDecoder: 27 | public NCompression::NArithmetic::CBitDecoder {}; 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /snes9x/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 | #endif 13 | -------------------------------------------------------------------------------- /snes9x/jma/btreecd.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 __BITTREECODER_H 20 | #define __BITTREECODER_H 21 | 22 | #include "aribitcd.h" 23 | #include "rcdefs.h" 24 | 25 | 26 | ////////////////////////// 27 | // CBitTreeDecoder 28 | 29 | template 30 | class CBitTreeDecoder 31 | { 32 | CMyBitDecoder m_Models[1 << m_NumBitLevels]; 33 | public: 34 | void Init() 35 | { 36 | for(UINT32 i = 1; i < (1 << m_NumBitLevels); i++) 37 | m_Models[i].Init(); 38 | } 39 | UINT32 Decode(CMyRangeDecoder *aRangeDecoder) 40 | { 41 | UINT32 aModelIndex = 1; 42 | RC_INIT_VAR 43 | for(UINT32 aBitIndex = m_NumBitLevels; aBitIndex > 0; aBitIndex--) 44 | { 45 | // aModelIndex = (aModelIndex << 1) + m_Models[aModelIndex].Decode(aRangeDecoder); 46 | RC_GETBIT(aNumMoveBits, m_Models[aModelIndex].m_Probability, aModelIndex) 47 | } 48 | RC_FLUSH_VAR 49 | return aModelIndex - (1 << m_NumBitLevels); 50 | }; 51 | }; 52 | 53 | //////////////////////////////// 54 | // CReverseBitTreeDecoder 55 | 56 | template 57 | class CReverseBitTreeDecoder2 58 | { 59 | CMyBitDecoder *m_Models; 60 | UINT32 m_NumBitLevels; 61 | public: 62 | CReverseBitTreeDecoder2(): m_Models(0) { } 63 | ~CReverseBitTreeDecoder2() { delete []m_Models; } 64 | bool Create(UINT32 aNumBitLevels) 65 | { 66 | m_NumBitLevels = aNumBitLevels; 67 | m_Models = new CMyBitDecoder[1 << aNumBitLevels]; 68 | return (m_Models != 0); 69 | } 70 | void Init() 71 | { 72 | UINT32 aNumModels = 1 << m_NumBitLevels; 73 | for(UINT32 i = 1; i < aNumModels; i++) 74 | m_Models[i].Init(); 75 | } 76 | UINT32 Decode(CMyRangeDecoder *aRangeDecoder) 77 | { 78 | UINT32 aModelIndex = 1; 79 | UINT32 aSymbol = 0; 80 | RC_INIT_VAR 81 | for(UINT32 aBitIndex = 0; aBitIndex < m_NumBitLevels; aBitIndex++) 82 | { 83 | // UINT32 aBit = m_Models[aModelIndex].Decode(aRangeDecoder); 84 | // aModelIndex <<= 1; 85 | // aModelIndex += aBit; 86 | // aSymbol |= (aBit << aBitIndex); 87 | RC_GETBIT2(aNumMoveBits, m_Models[aModelIndex].m_Probability, aModelIndex, ; , aSymbol |= (1 << aBitIndex)) 88 | } 89 | RC_FLUSH_VAR 90 | return aSymbol; 91 | }; 92 | }; 93 | //////////////////////////// 94 | // CReverseBitTreeDecoder2 95 | 96 | template 97 | class CReverseBitTreeDecoder 98 | { 99 | CMyBitDecoder m_Models[1 << m_NumBitLevels]; 100 | public: 101 | void Init() 102 | { 103 | for(UINT32 i = 1; i < (1 << m_NumBitLevels); i++) 104 | m_Models[i].Init(); 105 | } 106 | UINT32 Decode(CMyRangeDecoder *aRangeDecoder) 107 | { 108 | UINT32 aModelIndex = 1; 109 | UINT32 aSymbol = 0; 110 | RC_INIT_VAR 111 | for(UINT32 aBitIndex = 0; aBitIndex < m_NumBitLevels; aBitIndex++) 112 | { 113 | // UINT32 aBit = m_Models[aModelIndex].Decode(aRangeDecoder); 114 | // aModelIndex <<= 1; 115 | // aModelIndex += aBit; 116 | // aSymbol |= (aBit << aBitIndex); 117 | RC_GETBIT2(aNumMoveBits, m_Models[aModelIndex].m_Probability, aModelIndex, ; , aSymbol |= (1 << aBitIndex)) 118 | } 119 | RC_FLUSH_VAR 120 | return aSymbol; 121 | } 122 | }; 123 | 124 | 125 | 126 | #endif 127 | -------------------------------------------------------------------------------- /snes9x/jma/crc32.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2004-2006 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 | #include "crc32.h" 20 | 21 | namespace CRC32lib 22 | { 23 | //Don't ask questions, this is the PKZip CRC32 table 24 | const unsigned int crc32Table[256] = { 25 | 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, 26 | 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, 27 | 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, 0x1db71064, 0x6ab020f2, 28 | 0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, 29 | 0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9, 30 | 0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172, 31 | 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, 0x35b5a8fa, 0x42b2986c, 32 | 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59, 33 | 0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, 34 | 0xcfba9599, 0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924, 35 | 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190, 0x01db7106, 36 | 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433, 37 | 0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d, 38 | 0x91646c97, 0xe6635c01, 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, 39 | 0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950, 40 | 0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65, 41 | 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, 0x4adfa541, 0x3dd895d7, 42 | 0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0, 43 | 0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa, 44 | 0xbe0b1010, 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f, 45 | 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, 0x2eb40d81, 46 | 0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a, 47 | 0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683, 0xe3630b12, 0x94643b84, 48 | 0x0d6d6a3e, 0x7a6a5aa8, 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1, 49 | 0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb, 50 | 0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc, 51 | 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, 0xd6d6a3e8, 0xa1d1937e, 52 | 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b, 53 | 0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55, 54 | 0x316e8eef, 0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236, 55 | 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe, 0xb2bd0b28, 56 | 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d, 57 | 0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, 0x9c0906a9, 0xeb0e363f, 58 | 0x72076785, 0x05005713, 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, 59 | 0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242, 60 | 0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777, 61 | 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, 0x8f659eff, 0xf862ae69, 62 | 0x616bffd3, 0x166ccf45, 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2, 63 | 0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc, 64 | 0x40df0b66, 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9, 65 | 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 0xcdd70693, 66 | 0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94, 67 | 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d }; 68 | 69 | 70 | //CRC32 for char arrays 71 | unsigned int CRC32(const unsigned char *array, size_t size, register unsigned int crc32) 72 | { 73 | const unsigned char *end_p = array+size; 74 | for (register const unsigned char *p = array; p < end_p; p++) 75 | { 76 | crc32 = ((crc32 >> 8) & 0x00FFFFFF) ^ crc32Table[(crc32 ^ *p) & 0xFF]; 77 | } 78 | 79 | return(~crc32); 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /snes9x/jma/crc32.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2004-2006 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 | { 23 | unsigned int CRC32(const unsigned char *, size_t, register unsigned int crc32 = 0xFFFFFFFF); 24 | } 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /snes9x/jma/iiostrm.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2005-2006 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 "portable.h" 21 | #include "iiostrm.h" 22 | #include "crc32.h" 23 | 24 | HRESULT ISequentialInStream_Array::Read(void *aData, UINT32 aSize, UINT32 *aProcessedSize) 25 | { 26 | if (aSize > size) 27 | { 28 | aSize = size; 29 | } 30 | 31 | *aProcessedSize = aSize; 32 | memcpy(aData, data, aSize); 33 | size -= aSize; 34 | data += aSize; 35 | return(S_OK); 36 | } 37 | 38 | HRESULT ISequentialOutStream_Array::Write(const void *aData, UINT32 aSize, UINT32 *aProcessedSize) 39 | { 40 | if (aSize > size) 41 | { 42 | overflow = true; 43 | aSize = size; 44 | } 45 | 46 | *aProcessedSize = aSize; 47 | memcpy(data, aData, aSize); 48 | size -= aSize; 49 | data += aSize; 50 | total += aSize; 51 | return(S_OK); 52 | } 53 | 54 | HRESULT ISequentialInStream_String::Read(void *aData, UINT32 aSize, UINT32 *aProcessedSize) 55 | { 56 | if (aSize > data.size()) 57 | { 58 | aSize = data.size(); 59 | } 60 | 61 | *aProcessedSize = aSize; 62 | memcpy(aData, data.c_str(), aSize); 63 | data.erase(0, aSize); 64 | return(S_OK); 65 | } 66 | 67 | HRESULT ISequentialOutStream_String::Write(const void *aData, UINT32 aSize, UINT32 *aProcessedSize) 68 | { 69 | *aProcessedSize = aSize; 70 | data.append((const char *)aData, aSize); 71 | total += aSize; 72 | return(S_OK); 73 | } 74 | 75 | HRESULT ISequentialInStream_Istream::Read(void *aData, UINT32 aSize, UINT32 *aProcessedSize) 76 | { 77 | data.read((char *)aData, aSize); 78 | *aProcessedSize = data.gcount(); 79 | return(S_OK); 80 | } 81 | 82 | HRESULT ISequentialOutStream_Ostream::Write(const void *aData, UINT32 aSize, UINT32 *aProcessedSize) 83 | { 84 | *aProcessedSize = aSize; 85 | data.write((char *)aData, aSize); 86 | total += aSize; 87 | return(S_OK); 88 | } 89 | 90 | 91 | 92 | HRESULT ISequentialInStreamCRC32_Array::Read(void *aData, UINT32 aSize, UINT32 *aProcessedSize) 93 | { 94 | ISequentialInStream_Array::Read(aData, aSize, aProcessedSize); 95 | crc32 = CRC32lib::CRC32((const unsigned char *)aData, *aProcessedSize, ~crc32); 96 | return(S_OK); 97 | } 98 | 99 | HRESULT ISequentialOutStreamCRC32_Array::Write(const void *aData, UINT32 aSize, UINT32 *aProcessedSize) 100 | { 101 | ISequentialOutStream_Array::Write(aData, aSize, aProcessedSize); 102 | crc32 = CRC32lib::CRC32((const unsigned char *)aData, *aProcessedSize, ~crc32); 103 | return(S_OK); 104 | } 105 | 106 | HRESULT ISequentialInStreamCRC32_String::Read(void *aData, UINT32 aSize, UINT32 *aProcessedSize) 107 | { 108 | ISequentialInStream_String::Read(aData, aSize, aProcessedSize); 109 | crc32 = CRC32lib::CRC32((const unsigned char *)aData, *aProcessedSize, ~crc32); 110 | return(S_OK); 111 | } 112 | 113 | HRESULT ISequentialOutStreamCRC32_String::Write(const void *aData, UINT32 aSize, UINT32 *aProcessedSize) 114 | { 115 | ISequentialOutStream_String::Write(aData, aSize, aProcessedSize); 116 | crc32 = CRC32lib::CRC32((const unsigned char *)aData, *aProcessedSize, ~crc32); 117 | return(S_OK); 118 | } 119 | 120 | HRESULT ISequentialInStreamCRC32_Istream::Read(void *aData, UINT32 aSize, UINT32 *aProcessedSize) 121 | { 122 | ISequentialInStream_Istream::Read(aData, aSize, aProcessedSize); 123 | crc32 = CRC32lib::CRC32((const unsigned char *)aData, *aProcessedSize, ~crc32); 124 | return(S_OK); 125 | } 126 | 127 | HRESULT ISequentialOutStreamCRC32_Ostream::Write(const void *aData, UINT32 aSize, UINT32 *aProcessedSize) 128 | { 129 | ISequentialOutStream_Ostream::Write(aData, aSize, aProcessedSize); 130 | crc32 = CRC32lib::CRC32((const unsigned char *)aData, *aProcessedSize, ~crc32); 131 | return(S_OK); 132 | } 133 | -------------------------------------------------------------------------------- /snes9x/jma/iiostrm.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2005-2006 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 __IINOUTSTREAMS_H 21 | #define __IINOUTSTREAMS_H 22 | 23 | #include 24 | #include 25 | 26 | #include "portable.h" 27 | 28 | 29 | class ISequentialInStream 30 | { 31 | public: 32 | virtual HRESULT Read(void *, UINT32, UINT32 *) = 0; 33 | 34 | virtual ~ISequentialInStream() {} 35 | }; 36 | 37 | 38 | class ISequentialInStream_Array : public ISequentialInStream 39 | { 40 | const char *data; 41 | unsigned int size; 42 | public: 43 | ISequentialInStream_Array(const char *Adata, unsigned Asize) : data(Adata), size(Asize) { } 44 | 45 | HRESULT Read(void *aData, UINT32 aSize, UINT32 *aProcessedSize); 46 | 47 | virtual ~ISequentialInStream_Array() {} 48 | }; 49 | 50 | class ISequentialInStream_String : public ISequentialInStream 51 | { 52 | std::string& data; 53 | public: 54 | ISequentialInStream_String(std::string& Adata) : data(Adata) { } 55 | 56 | HRESULT Read(void *aData, UINT32 aSize, UINT32 *aProcessedSize); 57 | 58 | virtual ~ISequentialInStream_String() {} 59 | }; 60 | 61 | class ISequentialInStream_Istream : public ISequentialInStream 62 | { 63 | std::istream& data; 64 | public: 65 | ISequentialInStream_Istream(std::istream& Adata) : data(Adata) { } 66 | 67 | HRESULT Read(void *aData, UINT32 aSize, UINT32 *aProcessedSize); 68 | 69 | virtual ~ISequentialInStream_Istream() {} 70 | }; 71 | 72 | 73 | 74 | class ISequentialOutStream 75 | { 76 | public: 77 | virtual bool overflow_get() const = 0; 78 | virtual unsigned int size_get() const = 0; 79 | 80 | virtual HRESULT Write(const void *, UINT32, UINT32 *) = 0; 81 | 82 | virtual ~ISequentialOutStream() {} 83 | }; 84 | 85 | 86 | class ISequentialOutStream_Array : public ISequentialOutStream 87 | { 88 | char *data; 89 | unsigned int size; 90 | bool overflow; 91 | unsigned int total; 92 | public: 93 | ISequentialOutStream_Array(char *Adata, unsigned Asize) : data(Adata), size(Asize), overflow(false), total(0) { } 94 | 95 | bool overflow_get() const { return(overflow); } 96 | unsigned int size_get() const { return(total); } 97 | 98 | HRESULT Write(const void *aData, UINT32 aSize, UINT32 *aProcessedSize); 99 | 100 | virtual ~ISequentialOutStream_Array() {} 101 | }; 102 | 103 | class ISequentialOutStream_String : public ISequentialOutStream 104 | { 105 | std::string& data; 106 | unsigned int total; 107 | public: 108 | ISequentialOutStream_String(std::string& Adata) : data(Adata), total(0) { } 109 | 110 | bool overflow_get() const { return(false); } 111 | unsigned int size_get() const { return(total); } 112 | 113 | HRESULT Write(const void *aData, UINT32 aSize, UINT32 *aProcessedSize); 114 | 115 | virtual ~ISequentialOutStream_String() {} 116 | }; 117 | 118 | 119 | class ISequentialOutStream_Ostream : public ISequentialOutStream 120 | { 121 | std::ostream& data; 122 | unsigned int total; 123 | public: 124 | ISequentialOutStream_Ostream(std::ostream& Adata) : data(Adata), total(0) { } 125 | 126 | bool overflow_get() const { return(false); } 127 | unsigned int size_get() const { return(total); } 128 | 129 | HRESULT Write(const void *aData, UINT32 aSize, UINT32 *aProcessedSize); 130 | 131 | virtual ~ISequentialOutStream_Ostream() {} 132 | }; 133 | 134 | 135 | 136 | class ISequentialStreamCRC32 137 | { 138 | protected: 139 | unsigned int crc32; 140 | public: 141 | ISequentialStreamCRC32() : crc32(0) {} 142 | unsigned int crc32_get() const { return(crc32); } 143 | 144 | virtual ~ISequentialStreamCRC32() {} 145 | }; 146 | 147 | 148 | class ISequentialInStreamCRC32_Array : public ISequentialInStream_Array, public ISequentialStreamCRC32 149 | { 150 | public: 151 | ISequentialInStreamCRC32_Array(const char *Adata, unsigned Asize) : ISequentialInStream_Array(Adata, Asize) { } 152 | 153 | HRESULT Read(void *aData, UINT32 aSize, UINT32 *aProcessedSize); 154 | 155 | virtual ~ISequentialInStreamCRC32_Array() {} 156 | }; 157 | 158 | class ISequentialInStreamCRC32_String : public ISequentialInStream_String, public ISequentialStreamCRC32 159 | { 160 | public: 161 | ISequentialInStreamCRC32_String(std::string& Adata) : ISequentialInStream_String(Adata) { } 162 | 163 | HRESULT Read(void *aData, UINT32 aSize, UINT32 *aProcessedSize); 164 | 165 | virtual ~ISequentialInStreamCRC32_String() {} 166 | }; 167 | 168 | class ISequentialInStreamCRC32_Istream : public ISequentialInStream_Istream, public ISequentialStreamCRC32 169 | { 170 | public: 171 | ISequentialInStreamCRC32_Istream(std::istream& Adata) : ISequentialInStream_Istream(Adata) { } 172 | 173 | HRESULT Read(void *aData, UINT32 aSize, UINT32 *aProcessedSize); 174 | 175 | virtual ~ISequentialInStreamCRC32_Istream() {} 176 | }; 177 | 178 | 179 | class ISequentialOutStreamCRC32_Array : public ISequentialOutStream_Array, public ISequentialStreamCRC32 180 | { 181 | public: 182 | ISequentialOutStreamCRC32_Array(char *Adata, unsigned Asize) : ISequentialOutStream_Array(Adata, Asize) { } 183 | 184 | HRESULT Write(const void *aData, UINT32 aSize, UINT32 *aProcessedSize); 185 | 186 | virtual ~ISequentialOutStreamCRC32_Array() {} 187 | }; 188 | 189 | class ISequentialOutStreamCRC32_String : public ISequentialOutStream_String, public ISequentialStreamCRC32 190 | { 191 | public: 192 | ISequentialOutStreamCRC32_String(std::string& Adata) : ISequentialOutStream_String(Adata) { } 193 | 194 | HRESULT Write(const void *aData, UINT32 aSize, UINT32 *aProcessedSize); 195 | 196 | virtual ~ISequentialOutStreamCRC32_String() {} 197 | }; 198 | 199 | 200 | class ISequentialOutStreamCRC32_Ostream : public ISequentialOutStream_Ostream, public ISequentialStreamCRC32 201 | { 202 | public: 203 | ISequentialOutStreamCRC32_Ostream(std::ostream& Adata) : ISequentialOutStream_Ostream(Adata) { } 204 | 205 | HRESULT Write(const void *aData, UINT32 aSize, UINT32 *aProcessedSize); 206 | 207 | virtual ~ISequentialOutStreamCRC32_Ostream() {} 208 | }; 209 | 210 | #endif 211 | -------------------------------------------------------------------------------- /snes9x/jma/inbyte.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2005-2006 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 | -------------------------------------------------------------------------------- /snes9x/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 | { 28 | UINT64 m_ProcessedSize; 29 | BYTE *m_BufferBase; 30 | UINT32 m_BufferSize; 31 | BYTE *m_Buffer; 32 | BYTE *m_BufferLimit; 33 | ISequentialInStream* m_Stream; 34 | bool m_StreamWasExhausted; 35 | 36 | bool ReadBlock(); 37 | 38 | public: 39 | CInByte(UINT32 aBufferSize = 0x100000); 40 | ~CInByte(); 41 | 42 | void Init(ISequentialInStream *aStream); 43 | 44 | bool ReadByte(BYTE &aByte) 45 | { 46 | if(m_Buffer >= m_BufferLimit) 47 | if(!ReadBlock()) 48 | return false; 49 | aByte = *m_Buffer++; 50 | return true; 51 | } 52 | BYTE ReadByte() 53 | { 54 | if(m_Buffer >= m_BufferLimit) 55 | if(!ReadBlock()) 56 | return 0x0; 57 | return *m_Buffer++; 58 | } 59 | void ReadBytes(void *aData, UINT32 aSize, UINT32 &aProcessedSize) 60 | { 61 | for(aProcessedSize = 0; aProcessedSize < aSize; aProcessedSize++) 62 | if (!ReadByte(((BYTE *)aData)[aProcessedSize])) 63 | return; 64 | } 65 | bool ReadBytes(void *aData, UINT32 aSize) 66 | { 67 | UINT32 aProcessedSize; 68 | ReadBytes(aData, aSize, aProcessedSize); 69 | return (aProcessedSize == aSize); 70 | } 71 | UINT64 GetProcessedSize() const { return m_ProcessedSize + (m_Buffer - m_BufferBase); } 72 | }; 73 | 74 | } 75 | 76 | #endif 77 | -------------------------------------------------------------------------------- /snes9x/jma/jma.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2005-2006 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 | 26 | namespace JMA 27 | { 28 | enum jma_errors { JMA_NO_CREATE, JMA_NO_MEM_ALLOC, JMA_NO_OPEN, JMA_BAD_FILE, 29 | JMA_UNSUPPORTED_VERSION, JMA_COMPRESS_FAILED, JMA_DECOMPRESS_FAILED, 30 | JMA_FILE_NOT_FOUND }; 31 | 32 | struct jma_file_info_base 33 | { 34 | std::string name; 35 | std::string comment; 36 | size_t size; 37 | unsigned int crc32; 38 | }; 39 | 40 | struct jma_public_file_info : jma_file_info_base 41 | { 42 | time_t datetime; 43 | }; 44 | 45 | struct jma_file_info : jma_file_info_base 46 | { 47 | unsigned short date; 48 | unsigned short time; 49 | const unsigned char *buffer; 50 | }; 51 | 52 | template 53 | inline size_t get_total_size(std::vector& files) 54 | { 55 | size_t size = 0; 56 | for (typename std::vector::iterator i = files.begin(); i != files.end(); i++) 57 | { 58 | size += i->size; //We do have a problem if this wraps around 59 | } 60 | 61 | return(size); 62 | } 63 | 64 | class jma_open 65 | { 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 | time_t uint_to_time(unsigned short, unsigned short); 87 | const char *jma_error_text(jma_errors); 88 | } 89 | #endif 90 | -------------------------------------------------------------------------------- /snes9x/jma/lencoder.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2005-2006 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 | 31 | const int kNumPosStatesBitsEncodingMax = 4; 32 | const int kNumPosStatesEncodingMax = (1 << kNumPosStatesBitsEncodingMax); 33 | 34 | 35 | const int kNumMoveBits = 5; 36 | 37 | const int kNumLenBits = 3; 38 | const int kNumLowSymbols = 1 << kNumLenBits; 39 | const int kNumMidBits = 3; 40 | const int kNumMidSymbols = 1 << kNumMidBits; 41 | 42 | const int kNumHighBits = 8; 43 | 44 | const int kNumSymbolsTotal = kNumLowSymbols + kNumMidSymbols + (1 << kNumHighBits); 45 | 46 | const int kNumSpecSymbols = kNumLowSymbols + kNumMidSymbols; 47 | 48 | class CDecoder 49 | { 50 | CMyBitDecoder m_Choice; 51 | CBitTreeDecoder m_LowCoder[kNumPosStatesMax]; 52 | CMyBitDecoder m_Choice2; 53 | CBitTreeDecoder m_MidCoder[kNumPosStatesMax]; 54 | CBitTreeDecoder m_HighCoder; 55 | UINT32 m_NumPosStates; 56 | public: 57 | void Create(UINT32 aNumPosStates) 58 | { m_NumPosStates = aNumPosStates; } 59 | void Init() 60 | { 61 | m_Choice.Init(); 62 | for (UINT32 aPosState = 0; aPosState < m_NumPosStates; aPosState++) 63 | { 64 | m_LowCoder[aPosState].Init(); 65 | m_MidCoder[aPosState].Init(); 66 | } 67 | m_Choice2.Init(); 68 | m_HighCoder.Init(); 69 | } 70 | UINT32 Decode(CMyRangeDecoder *aRangeDecoder, UINT32 aPosState) 71 | { 72 | if(m_Choice.Decode(aRangeDecoder) == 0) 73 | return m_LowCoder[aPosState].Decode(aRangeDecoder); 74 | else 75 | { 76 | UINT32 aSymbol = kNumLowSymbols; 77 | if(m_Choice2.Decode(aRangeDecoder) == 0) 78 | aSymbol += m_MidCoder[aPosState].Decode(aRangeDecoder); 79 | else 80 | { 81 | aSymbol += kNumMidSymbols; 82 | aSymbol += m_HighCoder.Decode(aRangeDecoder); 83 | } 84 | return aSymbol; 85 | } 86 | } 87 | 88 | }; 89 | 90 | } 91 | 92 | 93 | #endif 94 | -------------------------------------------------------------------------------- /snes9x/jma/license.txt: -------------------------------------------------------------------------------- 1 | Some of the code in this directory is under the LGPL v2. 2 | 3 | Other bits of the code is under GPL v2. 4 | The authors of the GPL portions have granted an exception to Snes9x (but not to Snes9x derivitives) 5 | to use their code. 6 | 7 | s9x-jma.h and s9x-jma.cpp are under Snes9x license. 8 | -------------------------------------------------------------------------------- /snes9x/jma/litcoder.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 __LITERALCODER_H 20 | #define __LITERALCODER_H 21 | 22 | #include "aribitcd.h" 23 | #include "rcdefs.h" 24 | 25 | namespace NLiteral { 26 | 27 | const int kNumMoveBits = 5; 28 | 29 | class CDecoder2 30 | { 31 | CMyBitDecoder m_Decoders[3][1 << 8]; 32 | public: 33 | void Init() 34 | { 35 | for (int i = 0; i < 3; i++) 36 | for (int j = 1; j < (1 << 8); j++) 37 | m_Decoders[i][j].Init(); 38 | } 39 | 40 | BYTE DecodeNormal(CMyRangeDecoder *aRangeDecoder) 41 | { 42 | UINT32 aSymbol = 1; 43 | RC_INIT_VAR 44 | do 45 | { 46 | // aSymbol = (aSymbol << 1) | m_Decoders[0][aSymbol].Decode(aRangeDecoder); 47 | RC_GETBIT(kNumMoveBits, m_Decoders[0][aSymbol].m_Probability, aSymbol) 48 | } 49 | while (aSymbol < 0x100); 50 | RC_FLUSH_VAR 51 | return aSymbol; 52 | } 53 | 54 | BYTE DecodeWithMatchByte(CMyRangeDecoder *aRangeDecoder, BYTE aMatchByte) 55 | { 56 | UINT32 aSymbol = 1; 57 | RC_INIT_VAR 58 | do 59 | { 60 | UINT32 aMatchBit = (aMatchByte >> 7) & 1; 61 | aMatchByte <<= 1; 62 | // UINT32 aBit = m_Decoders[1 + aMatchBit][aSymbol].Decode(aRangeDecoder); 63 | // aSymbol = (aSymbol << 1) | aBit; 64 | UINT32 aBit; 65 | RC_GETBIT2(kNumMoveBits, m_Decoders[1 + aMatchBit][aSymbol].m_Probability, aSymbol, 66 | aBit = 0, aBit = 1) 67 | if (aMatchBit != aBit) 68 | { 69 | while (aSymbol < 0x100) 70 | { 71 | // aSymbol = (aSymbol << 1) | m_Decoders[0][aSymbol].Decode(aRangeDecoder); 72 | RC_GETBIT(kNumMoveBits, m_Decoders[0][aSymbol].m_Probability, aSymbol) 73 | } 74 | break; 75 | } 76 | } 77 | while (aSymbol < 0x100); 78 | RC_FLUSH_VAR 79 | return aSymbol; 80 | } 81 | }; 82 | 83 | class CDecoder 84 | { 85 | CDecoder2 *m_Coders; 86 | UINT32 m_NumPrevBits; 87 | UINT32 m_NumPosBits; 88 | UINT32 m_PosMask; 89 | public: 90 | CDecoder(): m_Coders(0) {} 91 | ~CDecoder() { Free(); } 92 | void Free() 93 | { 94 | delete []m_Coders; 95 | m_Coders = 0; 96 | } 97 | void Create(UINT32 aNumPosBits, UINT32 aNumPrevBits) 98 | { 99 | Free(); 100 | m_NumPosBits = aNumPosBits; 101 | m_PosMask = (1 << aNumPosBits) - 1; 102 | m_NumPrevBits = aNumPrevBits; 103 | UINT32 aNumStates = 1 << (m_NumPrevBits + m_NumPosBits); 104 | m_Coders = new CDecoder2[aNumStates]; 105 | } 106 | void Init() 107 | { 108 | UINT32 aNumStates = 1 << (m_NumPrevBits + m_NumPosBits); 109 | for (UINT32 i = 0; i < aNumStates; i++) 110 | m_Coders[i].Init(); 111 | } 112 | UINT32 GetState(UINT32 aPos, BYTE aPrevByte) const 113 | { return ((aPos & m_PosMask) << m_NumPrevBits) + (aPrevByte >> (8 - m_NumPrevBits)); } 114 | BYTE DecodeNormal(CMyRangeDecoder *aRangeDecoder, UINT32 aPos, BYTE aPrevByte) 115 | { return m_Coders[GetState(aPos, aPrevByte)].DecodeNormal(aRangeDecoder); } 116 | BYTE DecodeWithMatchByte(CMyRangeDecoder *aRangeDecoder, UINT32 aPos, BYTE aPrevByte, BYTE aMatchByte) 117 | { return m_Coders[GetState(aPos, aPrevByte)].DecodeWithMatchByte(aRangeDecoder, aMatchByte); } 118 | }; 119 | 120 | } 121 | 122 | #endif 123 | -------------------------------------------------------------------------------- /snes9x/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 | { 28 | public: 29 | CConstInit() 30 | { 31 | UINT32 aStartValue = 0; 32 | int i; 33 | for (i = 0; i < kDistTableSizeMax; i++) 34 | { 35 | kDistStart[i] = aStartValue; 36 | aStartValue += (1 << kDistDirectBits[i]); 37 | } 38 | } 39 | } g_ConstInit; 40 | 41 | }} 42 | -------------------------------------------------------------------------------- /snes9x/jma/lzma.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2005-2006 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 "lencoder.h" 21 | 22 | #ifndef __LZMA_H 23 | #define __LZMA_H 24 | 25 | namespace NCompress { 26 | namespace NLZMA { 27 | 28 | const UINT32 kNumRepDistances = 4; 29 | 30 | const BYTE kNumStates = 12; 31 | 32 | const BYTE kLiteralNextStates[kNumStates] = {0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 4, 5}; 33 | const BYTE kMatchNextStates[kNumStates] = {7, 7, 7, 7, 7, 7, 7, 10, 10, 10, 10, 10}; 34 | const BYTE kRepNextStates[kNumStates] = {8, 8, 8, 8, 8, 8, 8, 11, 11, 11, 11, 11}; 35 | const BYTE kShortRepNextStates[kNumStates]= {9, 9, 9, 9, 9, 9, 9, 11, 11, 11, 11, 11}; 36 | 37 | class CState 38 | { 39 | public: 40 | BYTE m_Index; 41 | void Init() 42 | { m_Index = 0; } 43 | void UpdateChar() 44 | { m_Index = kLiteralNextStates[m_Index]; } 45 | void UpdateMatch() 46 | { m_Index = kMatchNextStates[m_Index]; } 47 | void UpdateRep() 48 | { m_Index = kRepNextStates[m_Index]; } 49 | void UpdateShortRep() 50 | { m_Index = kShortRepNextStates[m_Index]; } 51 | }; 52 | 53 | class CBaseCoder 54 | { 55 | protected: 56 | CState m_State; 57 | BYTE m_PreviousByte; 58 | bool m_PeviousIsMatch; 59 | UINT32 m_RepDistances[kNumRepDistances]; 60 | void Init() 61 | { 62 | m_State.Init(); 63 | m_PreviousByte = 0; 64 | m_PeviousIsMatch = false; 65 | for(UINT32 i = 0 ; i < kNumRepDistances; i++) 66 | m_RepDistances[i] = 0; 67 | } 68 | }; 69 | 70 | const int kNumPosSlotBits = 6; 71 | const int kDicLogSizeMax = 28; 72 | const int kDistTableSizeMax = kDicLogSizeMax * 2; 73 | 74 | extern UINT32 kDistStart[kDistTableSizeMax]; 75 | const BYTE kDistDirectBits[kDistTableSizeMax] = 76 | { 77 | 0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 78 | 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 79 | 20, 20, 21, 21, 22, 22, 23, 23, 24, 24, 25, 25, 26, 26 80 | }; 81 | 82 | const UINT32 kNumLenToPosStates = 4; 83 | inline UINT32 GetLenToPosState(UINT32 aLen) 84 | { 85 | aLen -= 2; 86 | if (aLen < kNumLenToPosStates) 87 | return aLen; 88 | return kNumLenToPosStates - 1; 89 | } 90 | 91 | const int kMatchMinLen = 2; 92 | 93 | const int kMatchMaxLen = kMatchMinLen + NLength::kNumSymbolsTotal - 1; 94 | 95 | const int kNumAlignBits = 4; 96 | const int kAlignTableSize = 1 << kNumAlignBits; 97 | const UINT32 kAlignMask = (kAlignTableSize - 1); 98 | 99 | const int kStartPosModelIndex = 4; 100 | const int kEndPosModelIndex = 14; 101 | const int kNumPosModels = kEndPosModelIndex - kStartPosModelIndex; 102 | 103 | const int kNumFullDistances = 1 << (kEndPosModelIndex / 2); 104 | 105 | 106 | const int kMainChoiceLiteralIndex = 0; 107 | const int kMainChoiceMatchIndex = 1; 108 | 109 | const int kMatchChoiceDistanceIndex= 0; 110 | const int kMatchChoiceRepetitionIndex = 1; 111 | 112 | const int kNumMoveBitsForMainChoice = 5; 113 | const int kNumMoveBitsForPosCoders = 5; 114 | 115 | const int kNumMoveBitsForAlignCoders = 5; 116 | 117 | const int kNumMoveBitsForPosSlotCoder = 5; 118 | 119 | const int kNumLitPosStatesBitsEncodingMax = 4; 120 | const int kNumLitContextBitsMax = 8; 121 | 122 | }} 123 | 124 | #endif 125 | -------------------------------------------------------------------------------- /snes9x/jma/lzmadec.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 __LZARITHMETIC_DECODER_H 20 | #define __LZARITHMETIC_DECODER_H 21 | 22 | #include "winout.h" 23 | #include "lzma.h" 24 | #include "lencoder.h" 25 | #include "litcoder.h" 26 | 27 | namespace NCompress { 28 | namespace NLZMA { 29 | 30 | typedef CMyBitDecoder CMyBitDecoder2; 31 | 32 | class CDecoder 33 | { 34 | NStream::NWindow::COut m_OutWindowStream; 35 | CMyRangeDecoder m_RangeDecoder; 36 | 37 | CMyBitDecoder2 m_MainChoiceDecoders[kNumStates][NLength::kNumPosStatesMax]; 38 | CMyBitDecoder2 m_MatchChoiceDecoders[kNumStates]; 39 | CMyBitDecoder2 m_MatchRepChoiceDecoders[kNumStates]; 40 | CMyBitDecoder2 m_MatchRep1ChoiceDecoders[kNumStates]; 41 | CMyBitDecoder2 m_MatchRep2ChoiceDecoders[kNumStates]; 42 | CMyBitDecoder2 m_MatchRepShortChoiceDecoders[kNumStates][NLength::kNumPosStatesMax]; 43 | 44 | CBitTreeDecoder m_PosSlotDecoder[kNumLenToPosStates]; 45 | 46 | CReverseBitTreeDecoder2 m_PosDecoders[kNumPosModels]; 47 | CReverseBitTreeDecoder m_PosAlignDecoder; 48 | // CBitTreeDecoder2 m_PosDecoders[kNumPosModels]; 49 | // CBitTreeDecoder m_PosAlignDecoder; 50 | 51 | NLength::CDecoder m_LenDecoder; 52 | NLength::CDecoder m_RepMatchLenDecoder; 53 | 54 | NLiteral::CDecoder m_LiteralDecoder; 55 | 56 | UINT32 m_DictionarySize; 57 | 58 | UINT32 m_PosStateMask; 59 | 60 | HRESULT Create(); 61 | 62 | HRESULT Init(ISequentialInStream *anInStream, ISequentialOutStream *anOutStream); 63 | 64 | HRESULT Flush() { return m_OutWindowStream.Flush(); } 65 | 66 | HRESULT CodeReal(ISequentialInStream *anInStream, ISequentialOutStream *anOutStream, const UINT64 *anInSize, const UINT64 *anOutSize); 67 | 68 | public: 69 | 70 | CDecoder(); 71 | 72 | HRESULT Code(ISequentialInStream *anInStream, ISequentialOutStream *anOutStream, const UINT64 *anInSize, const UINT64 *anOutSize); 73 | HRESULT ReadCoderProperties(ISequentialInStream *anInStream); 74 | 75 | HRESULT SetDictionarySize(UINT32 aDictionarySize); 76 | HRESULT SetLiteralProperties(UINT32 aLiteralPosStateBits, UINT32 aLiteralContextBits); 77 | HRESULT SetPosBitsProperties(UINT32 aNumPosStateBits); 78 | }; 79 | 80 | }} 81 | 82 | #endif 83 | -------------------------------------------------------------------------------- /snes9x/jma/portable.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2004-2006 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 | #ifdef __GNUC__ 24 | #include 25 | 26 | typedef int8_t INT8; 27 | typedef uint8_t UINT8; 28 | typedef int16_t INT16; 29 | typedef uint16_t UINT16; 30 | typedef int32_t INT32; 31 | typedef uint32_t UINT32; 32 | typedef int64_t INT64; 33 | typedef uint64_t UINT64; 34 | typedef uintptr_t UINT_PTR; 35 | 36 | #else 37 | 38 | typedef signed char INT8; 39 | typedef unsigned char UINT8; 40 | typedef short INT16; 41 | typedef unsigned short UINT16; 42 | typedef int INT32; 43 | typedef unsigned int UINT32; 44 | #ifdef _MSC_VER 45 | typedef __int64 INT64; 46 | typedef unsigned __int64 UINT64; 47 | #else 48 | typedef long long INT64; 49 | typedef unsigned long long UINT64; 50 | #endif 51 | typedef unsigned UINT_PTR; 52 | 53 | #endif 54 | 55 | typedef UINT8 BYTE; 56 | typedef UINT16 WORD; 57 | typedef UINT32 DWORD; 58 | 59 | typedef int BOOL; 60 | #define FALSE 0 61 | #define TRUE 1 62 | 63 | #define HRESULT int 64 | #define S_OK 0 65 | #define E_INVALIDARG -1 66 | #define E_OUTOFMEMORY -2 67 | #define E_FAIL -3 68 | #define E_INTERNAL_ERROR -4 69 | #define E_INVALIDDATA -5 70 | 71 | template inline T MyMin(T a, T b) { 72 | return a < b ? a : b; 73 | } 74 | 75 | template inline T MyMax(T a, T b) { 76 | return a > b ? a : b; 77 | } 78 | 79 | #define RETURN_IF_NOT_S_OK(x) { HRESULT __aResult_ = (x); if(__aResult_ != S_OK) return __aResult_; } 80 | 81 | 82 | #define UINT_SIZE ((int)sizeof(unsigned int)) 83 | #define USHORT_SIZE ((int)sizeof(unsigned short)) 84 | 85 | //Convert an array of 4 bytes back into an integer 86 | inline UINT32 charp_to_uint(const UINT8 buffer[UINT_SIZE]) 87 | { 88 | UINT32 num = (UINT32)buffer[3]; 89 | num |= ((UINT32)buffer[2]) << 8; 90 | num |= ((UINT32)buffer[1]) << 16; 91 | num |= ((UINT32)buffer[0]) << 24; 92 | return(num); 93 | } 94 | 95 | //Convert an array of 2 bytes back into a short integer 96 | inline UINT16 charp_to_ushort(const UINT8 buffer[USHORT_SIZE]) 97 | { 98 | UINT16 num = (UINT16)buffer[1]; 99 | num |= ((UINT16)buffer[0]) << 8; 100 | return(num); 101 | } 102 | 103 | #endif 104 | -------------------------------------------------------------------------------- /snes9x/jma/rcdefs.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 __RCDEFS_H 20 | #define __RCDEFS_H 21 | 22 | #include "aribitcd.h" 23 | #include "ariconst.h" 24 | 25 | #define RC_INIT_VAR \ 26 | UINT32 aRange = aRangeDecoder->m_Range; \ 27 | UINT32 aCode = aRangeDecoder->m_Code; 28 | 29 | #define RC_FLUSH_VAR \ 30 | aRangeDecoder->m_Range = aRange; \ 31 | aRangeDecoder->m_Code = aCode; 32 | 33 | #define RC_NORMALIZE \ 34 | if (aRange < NCompression::NArithmetic::kTopValue) \ 35 | { \ 36 | aCode = (aCode << 8) | aRangeDecoder->m_Stream.ReadByte(); \ 37 | aRange <<= 8; } 38 | 39 | #define RC_GETBIT2(aNumMoveBits, aProb, aModelIndex, Action0, Action1) \ 40 | {UINT32 aNewBound = (aRange >> NCompression::NArithmetic::kNumBitModelTotalBits) * aProb; \ 41 | if (aCode < aNewBound) \ 42 | { \ 43 | Action0; \ 44 | aRange = aNewBound; \ 45 | aProb += (NCompression::NArithmetic::kBitModelTotal - aProb) >> aNumMoveBits; \ 46 | aModelIndex <<= 1; \ 47 | } \ 48 | else \ 49 | { \ 50 | Action1; \ 51 | aRange -= aNewBound; \ 52 | aCode -= aNewBound; \ 53 | aProb -= (aProb) >> aNumMoveBits; \ 54 | aModelIndex = (aModelIndex << 1) + 1; \ 55 | }} \ 56 | RC_NORMALIZE 57 | 58 | #define RC_GETBIT(aNumMoveBits, aProb, aModelIndex) RC_GETBIT2(aNumMoveBits, aProb, aModelIndex, ; , ;) 59 | 60 | #endif 61 | -------------------------------------------------------------------------------- /snes9x/jma/rngcoder.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 __COMPRESSION_RANGECODER_H 20 | #define __COMPRESSION_RANGECODER_H 21 | 22 | #include "inbyte.h" 23 | 24 | namespace NCompression { 25 | namespace NArithmetic { 26 | 27 | const UINT32 kNumTopBits = 24; 28 | const UINT32 kTopValue = (1 << kNumTopBits); 29 | 30 | class CRangeDecoder 31 | { 32 | public: 33 | NStream::CInByte m_Stream; 34 | UINT32 m_Range; 35 | UINT32 m_Code; 36 | UINT32 m_Word; 37 | void Normalize() 38 | { 39 | while (m_Range < kTopValue) 40 | { 41 | m_Code = (m_Code << 8) | m_Stream.ReadByte(); 42 | m_Range <<= 8; 43 | } 44 | } 45 | 46 | void Init(ISequentialInStream *aStream) 47 | { 48 | m_Stream.Init(aStream); 49 | m_Code = 0; 50 | m_Range = UINT32(-1); 51 | for(int i = 0; i < 5; i++) 52 | m_Code = (m_Code << 8) | m_Stream.ReadByte(); 53 | } 54 | 55 | UINT32 GetThreshold(UINT32 aTotal) 56 | { 57 | return (m_Code) / ( m_Range /= aTotal); 58 | } 59 | 60 | void Decode(UINT32 aStart, UINT32 aSize, UINT32 aTotal) 61 | { 62 | m_Code -= aStart * m_Range; 63 | m_Range *= aSize; 64 | Normalize(); 65 | } 66 | 67 | /* 68 | UINT32 DecodeDirectBitsDiv(UINT32 aNumTotalBits) 69 | { 70 | m_Range >>= aNumTotalBits; 71 | UINT32 aThreshold = m_Code / m_Range; 72 | m_Code -= aThreshold * m_Range; 73 | 74 | Normalize(); 75 | return aThreshold; 76 | } 77 | 78 | UINT32 DecodeDirectBitsDiv2(UINT32 aNumTotalBits) 79 | { 80 | if (aNumTotalBits <= kNumBottomBits) 81 | return DecodeDirectBitsDiv(aNumTotalBits); 82 | UINT32 aResult = DecodeDirectBitsDiv(aNumTotalBits - kNumBottomBits) << kNumBottomBits; 83 | return (aResult | DecodeDirectBitsDiv(kNumBottomBits)); 84 | } 85 | */ 86 | 87 | UINT32 DecodeDirectBits(UINT32 aNumTotalBits) 88 | { 89 | UINT32 aRange = m_Range; 90 | UINT32 aCode = m_Code; 91 | UINT32 aResult = 0; 92 | for (UINT32 i = aNumTotalBits; i > 0; i--) 93 | { 94 | aRange >>= 1; 95 | /* 96 | aResult <<= 1; 97 | if (aCode >= aRange) 98 | { 99 | aCode -= aRange; 100 | aResult |= 1; 101 | } 102 | */ 103 | UINT32 t = (aCode - aRange) >> 31; 104 | aCode -= aRange & (t - 1); 105 | // aRange = aRangeTmp + ((aRange & 1) & (1 - t)); 106 | aResult = (aResult << 1) | (1 - t); 107 | 108 | if (aRange < kTopValue) 109 | { 110 | aCode = (aCode << 8) | m_Stream.ReadByte(); 111 | aRange <<= 8; 112 | } 113 | } 114 | m_Range = aRange; 115 | m_Code = aCode; 116 | return aResult; 117 | } 118 | 119 | UINT32 DecodeBit(UINT32 aSize0, UINT32 aNumTotalBits) 120 | { 121 | UINT32 aNewBound = (m_Range >> aNumTotalBits) * aSize0; 122 | UINT32 aSymbol; 123 | if (m_Code < aNewBound) 124 | { 125 | aSymbol = 0; 126 | m_Range = aNewBound; 127 | } 128 | else 129 | { 130 | aSymbol = 1; 131 | m_Code -= aNewBound; 132 | m_Range -= aNewBound; 133 | } 134 | Normalize(); 135 | return aSymbol; 136 | } 137 | 138 | UINT64 GetProcessedSize() {return m_Stream.GetProcessedSize(); } 139 | }; 140 | 141 | }} 142 | 143 | #endif 144 | -------------------------------------------------------------------------------- /snes9x/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 | { 58 | m_Pos = 0; 59 | m_PosLimit = m_KeepSizeReserv + m_KeepSizeBefore; 60 | m_StreamPos = 0; 61 | } 62 | } 63 | 64 | HRESULT COut::Flush() 65 | { 66 | UINT32 aSize = m_Pos - m_StreamPos; 67 | if(aSize == 0) 68 | return S_OK; 69 | UINT32 aProcessedSize; 70 | HRESULT aResult = m_Stream->Write(m_Buffer + m_StreamPos, aSize, &aProcessedSize); 71 | if (aResult != S_OK) 72 | return aResult; 73 | if (aSize != aProcessedSize) 74 | return E_FAIL; 75 | m_StreamPos = m_Pos; 76 | return S_OK; 77 | } 78 | 79 | void COut::MoveBlockBackward() 80 | { 81 | HRESULT aResult = Flush(); 82 | if (aResult != S_OK) 83 | throw aResult; 84 | memmove(m_Buffer, m_Buffer + m_MoveFrom, m_WindowSize + m_KeepSizeAfter); 85 | m_Pos -= m_MoveFrom; 86 | m_StreamPos -= m_MoveFrom; 87 | } 88 | 89 | }} 90 | -------------------------------------------------------------------------------- /snes9x/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 | { 34 | BYTE *m_Buffer; 35 | UINT32 m_Pos; 36 | UINT32 m_PosLimit; 37 | UINT32 m_KeepSizeBefore; 38 | UINT32 m_KeepSizeAfter; 39 | UINT32 m_KeepSizeReserv; 40 | UINT32 m_StreamPos; 41 | 42 | UINT32 m_WindowSize; 43 | UINT32 m_MoveFrom; 44 | 45 | ISequentialOutStream *m_Stream; 46 | 47 | virtual void MoveBlockBackward(); 48 | public: 49 | COut(): m_Buffer(0), m_Stream(0) {} 50 | virtual ~COut(); 51 | void Create(UINT32 aKeepSizeBefore, 52 | UINT32 aKeepSizeAfter, UINT32 aKeepSizeReserv = (1<<17)); 53 | void SetWindowSize(UINT32 aWindowSize); 54 | 55 | void Init(ISequentialOutStream *aStream, bool aSolid = false); 56 | HRESULT Flush(); 57 | 58 | UINT32 GetCurPos() const { return m_Pos; } 59 | const BYTE *GetPointerToCurrentPos() const { return m_Buffer + m_Pos;}; 60 | 61 | void CopyBackBlock(UINT32 aDistance, UINT32 aLen) 62 | { 63 | if (m_Pos >= m_PosLimit) 64 | MoveBlockBackward(); 65 | BYTE *p = m_Buffer + m_Pos; 66 | aDistance++; 67 | BYTE *p2 = p - aDistance; 68 | for(UINT32 i = 0; i < aLen; i++) 69 | p[i] = p2[i]; 70 | m_Pos += aLen; 71 | } 72 | 73 | void PutOneByte(BYTE aByte) 74 | { 75 | if (m_Pos >= m_PosLimit) 76 | MoveBlockBackward(); 77 | m_Buffer[m_Pos++] = aByte; 78 | } 79 | 80 | BYTE GetOneByte(UINT32 anIndex) const 81 | { 82 | return m_Buffer[m_Pos + anIndex]; 83 | } 84 | 85 | BYTE *GetBuffer() const { return m_Buffer; } 86 | }; 87 | 88 | }} 89 | 90 | #endif 91 | -------------------------------------------------------------------------------- /snes9x/screenshot.h: -------------------------------------------------------------------------------- 1 | /*********************************************************************************** 2 | Snes9x - Portable Super Nintendo Entertainment System (TM) emulator. 3 | 4 | (c) Copyright 1996 - 2002 Gary Henderson (gary.henderson@ntlworld.com), 5 | Jerremy Koot (jkoot@snes9x.com) 6 | 7 | (c) Copyright 2002 - 2004 Matthew Kendora 8 | 9 | (c) Copyright 2002 - 2005 Peter Bortas (peter@bortas.org) 10 | 11 | (c) Copyright 2004 - 2005 Joel Yliluoma (http://iki.fi/bisqwit/) 12 | 13 | (c) Copyright 2001 - 2006 John Weidman (jweidman@slip.net) 14 | 15 | (c) Copyright 2002 - 2006 funkyass (funkyass@spam.shaw.ca), 16 | Kris Bleakley (codeviolation@hotmail.com) 17 | 18 | (c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net), 19 | Nach (n-a-c-h@users.sourceforge.net), 20 | 21 | (c) Copyright 2002 - 2011 zones (kasumitokoduck@yahoo.com) 22 | 23 | (c) Copyright 2006 - 2007 nitsuja 24 | 25 | (c) Copyright 2009 - 2011 BearOso, 26 | OV2 27 | 28 | 29 | BS-X C emulator code 30 | (c) Copyright 2005 - 2006 Dreamer Nom, 31 | zones 32 | 33 | C4 x86 assembler and some C emulation code 34 | (c) Copyright 2000 - 2003 _Demo_ (_demo_@zsnes.com), 35 | Nach, 36 | zsKnight (zsknight@zsnes.com) 37 | 38 | C4 C++ code 39 | (c) Copyright 2003 - 2006 Brad Jorsch, 40 | Nach 41 | 42 | DSP-1 emulator code 43 | (c) Copyright 1998 - 2006 _Demo_, 44 | Andreas Naive (andreasnaive@gmail.com), 45 | Gary Henderson, 46 | Ivar (ivar@snes9x.com), 47 | John Weidman, 48 | Kris Bleakley, 49 | Matthew Kendora, 50 | Nach, 51 | neviksti (neviksti@hotmail.com) 52 | 53 | DSP-2 emulator code 54 | (c) Copyright 2003 John Weidman, 55 | Kris Bleakley, 56 | Lord Nightmare (lord_nightmare@users.sourceforge.net), 57 | Matthew Kendora, 58 | neviksti 59 | 60 | DSP-3 emulator code 61 | (c) Copyright 2003 - 2006 John Weidman, 62 | Kris Bleakley, 63 | Lancer, 64 | z80 gaiden 65 | 66 | DSP-4 emulator code 67 | (c) Copyright 2004 - 2006 Dreamer Nom, 68 | John Weidman, 69 | Kris Bleakley, 70 | Nach, 71 | z80 gaiden 72 | 73 | OBC1 emulator code 74 | (c) Copyright 2001 - 2004 zsKnight, 75 | pagefault (pagefault@zsnes.com), 76 | Kris Bleakley 77 | Ported from x86 assembler to C by sanmaiwashi 78 | 79 | SPC7110 and RTC C++ emulator code used in 1.39-1.51 80 | (c) Copyright 2002 Matthew Kendora with research by 81 | zsKnight, 82 | John Weidman, 83 | Dark Force 84 | 85 | SPC7110 and RTC C++ emulator code used in 1.52+ 86 | (c) Copyright 2009 byuu, 87 | neviksti 88 | 89 | S-DD1 C emulator code 90 | (c) Copyright 2003 Brad Jorsch with research by 91 | Andreas Naive, 92 | John Weidman 93 | 94 | S-RTC C emulator code 95 | (c) Copyright 2001 - 2006 byuu, 96 | John Weidman 97 | 98 | ST010 C++ emulator code 99 | (c) Copyright 2003 Feather, 100 | John Weidman, 101 | Kris Bleakley, 102 | Matthew Kendora 103 | 104 | Super FX x86 assembler emulator code 105 | (c) Copyright 1998 - 2003 _Demo_, 106 | pagefault, 107 | zsKnight 108 | 109 | Super FX C emulator code 110 | (c) Copyright 1997 - 1999 Ivar, 111 | Gary Henderson, 112 | John Weidman 113 | 114 | Sound emulator code used in 1.5-1.51 115 | (c) Copyright 1998 - 2003 Brad Martin 116 | (c) Copyright 1998 - 2006 Charles Bilyue' 117 | 118 | Sound emulator code used in 1.52+ 119 | (c) Copyright 2004 - 2007 Shay Green (gblargg@gmail.com) 120 | 121 | SH assembler code partly based on x86 assembler code 122 | (c) Copyright 2002 - 2004 Marcus Comstedt (marcus@mc.pp.se) 123 | 124 | 2xSaI filter 125 | (c) Copyright 1999 - 2001 Derek Liauw Kie Fa 126 | 127 | HQ2x, HQ3x, HQ4x filters 128 | (c) Copyright 2003 Maxim Stepin (maxim@hiend3d.com) 129 | 130 | NTSC filter 131 | (c) Copyright 2006 - 2007 Shay Green 132 | 133 | GTK+ GUI code 134 | (c) Copyright 2004 - 2011 BearOso 135 | 136 | Win32 GUI code 137 | (c) Copyright 2003 - 2006 blip, 138 | funkyass, 139 | Matthew Kendora, 140 | Nach, 141 | nitsuja 142 | (c) Copyright 2009 - 2011 OV2 143 | 144 | Mac OS GUI code 145 | (c) Copyright 1998 - 2001 John Stiles 146 | (c) Copyright 2001 - 2011 zones 147 | 148 | 149 | Specific ports contains the works of other authors. See headers in 150 | individual files. 151 | 152 | 153 | Snes9x homepage: http://www.snes9x.com/ 154 | 155 | Permission to use, copy, modify and/or distribute Snes9x in both binary 156 | and source form, for non-commercial purposes, is hereby granted without 157 | fee, providing that this license information and copyright notice appear 158 | with all copies and any derived work. 159 | 160 | This software is provided 'as-is', without any express or implied 161 | warranty. In no event shall the authors be held liable for any damages 162 | arising from the use of this software or it's derivatives. 163 | 164 | Snes9x is freeware for PERSONAL USE only. Commercial users should 165 | seek permission of the copyright holders first. Commercial use includes, 166 | but is not limited to, charging money for Snes9x or software derived from 167 | Snes9x, including Snes9x or derivatives in commercial game bundles, and/or 168 | using Snes9x as a promotion for your commercial product. 169 | 170 | The copyright holders request that bug fixes and improvements to the code 171 | should be forwarded to them so everyone can benefit from the modifications 172 | in future versions. 173 | 174 | Super NES and Super Nintendo Entertainment System are trademarks of 175 | Nintendo Co., Limited and its subsidiary companies. 176 | ***********************************************************************************/ 177 | 178 | 179 | #ifndef _SCREENSHOT_H_ 180 | #define _SCREENSHOT_H_ 181 | 182 | bool8 S9xDoScreenshot (int, int); 183 | 184 | #endif 185 | -------------------------------------------------------------------------------- /snes9x/sdd1emu.h: -------------------------------------------------------------------------------- 1 | /*********************************************************************************** 2 | Snes9x - Portable Super Nintendo Entertainment System (TM) emulator. 3 | 4 | (c) Copyright 1996 - 2002 Gary Henderson (gary.henderson@ntlworld.com), 5 | Jerremy Koot (jkoot@snes9x.com) 6 | 7 | (c) Copyright 2002 - 2004 Matthew Kendora 8 | 9 | (c) Copyright 2002 - 2005 Peter Bortas (peter@bortas.org) 10 | 11 | (c) Copyright 2004 - 2005 Joel Yliluoma (http://iki.fi/bisqwit/) 12 | 13 | (c) Copyright 2001 - 2006 John Weidman (jweidman@slip.net) 14 | 15 | (c) Copyright 2002 - 2006 funkyass (funkyass@spam.shaw.ca), 16 | Kris Bleakley (codeviolation@hotmail.com) 17 | 18 | (c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net), 19 | Nach (n-a-c-h@users.sourceforge.net), 20 | 21 | (c) Copyright 2002 - 2011 zones (kasumitokoduck@yahoo.com) 22 | 23 | (c) Copyright 2006 - 2007 nitsuja 24 | 25 | (c) Copyright 2009 - 2011 BearOso, 26 | OV2 27 | 28 | 29 | BS-X C emulator code 30 | (c) Copyright 2005 - 2006 Dreamer Nom, 31 | zones 32 | 33 | C4 x86 assembler and some C emulation code 34 | (c) Copyright 2000 - 2003 _Demo_ (_demo_@zsnes.com), 35 | Nach, 36 | zsKnight (zsknight@zsnes.com) 37 | 38 | C4 C++ code 39 | (c) Copyright 2003 - 2006 Brad Jorsch, 40 | Nach 41 | 42 | DSP-1 emulator code 43 | (c) Copyright 1998 - 2006 _Demo_, 44 | Andreas Naive (andreasnaive@gmail.com), 45 | Gary Henderson, 46 | Ivar (ivar@snes9x.com), 47 | John Weidman, 48 | Kris Bleakley, 49 | Matthew Kendora, 50 | Nach, 51 | neviksti (neviksti@hotmail.com) 52 | 53 | DSP-2 emulator code 54 | (c) Copyright 2003 John Weidman, 55 | Kris Bleakley, 56 | Lord Nightmare (lord_nightmare@users.sourceforge.net), 57 | Matthew Kendora, 58 | neviksti 59 | 60 | DSP-3 emulator code 61 | (c) Copyright 2003 - 2006 John Weidman, 62 | Kris Bleakley, 63 | Lancer, 64 | z80 gaiden 65 | 66 | DSP-4 emulator code 67 | (c) Copyright 2004 - 2006 Dreamer Nom, 68 | John Weidman, 69 | Kris Bleakley, 70 | Nach, 71 | z80 gaiden 72 | 73 | OBC1 emulator code 74 | (c) Copyright 2001 - 2004 zsKnight, 75 | pagefault (pagefault@zsnes.com), 76 | Kris Bleakley 77 | Ported from x86 assembler to C by sanmaiwashi 78 | 79 | SPC7110 and RTC C++ emulator code used in 1.39-1.51 80 | (c) Copyright 2002 Matthew Kendora with research by 81 | zsKnight, 82 | John Weidman, 83 | Dark Force 84 | 85 | SPC7110 and RTC C++ emulator code used in 1.52+ 86 | (c) Copyright 2009 byuu, 87 | neviksti 88 | 89 | S-DD1 C emulator code 90 | (c) Copyright 2003 Brad Jorsch with research by 91 | Andreas Naive, 92 | John Weidman 93 | 94 | S-RTC C emulator code 95 | (c) Copyright 2001 - 2006 byuu, 96 | John Weidman 97 | 98 | ST010 C++ emulator code 99 | (c) Copyright 2003 Feather, 100 | John Weidman, 101 | Kris Bleakley, 102 | Matthew Kendora 103 | 104 | Super FX x86 assembler emulator code 105 | (c) Copyright 1998 - 2003 _Demo_, 106 | pagefault, 107 | zsKnight 108 | 109 | Super FX C emulator code 110 | (c) Copyright 1997 - 1999 Ivar, 111 | Gary Henderson, 112 | John Weidman 113 | 114 | Sound emulator code used in 1.5-1.51 115 | (c) Copyright 1998 - 2003 Brad Martin 116 | (c) Copyright 1998 - 2006 Charles Bilyue' 117 | 118 | Sound emulator code used in 1.52+ 119 | (c) Copyright 2004 - 2007 Shay Green (gblargg@gmail.com) 120 | 121 | SH assembler code partly based on x86 assembler code 122 | (c) Copyright 2002 - 2004 Marcus Comstedt (marcus@mc.pp.se) 123 | 124 | 2xSaI filter 125 | (c) Copyright 1999 - 2001 Derek Liauw Kie Fa 126 | 127 | HQ2x, HQ3x, HQ4x filters 128 | (c) Copyright 2003 Maxim Stepin (maxim@hiend3d.com) 129 | 130 | NTSC filter 131 | (c) Copyright 2006 - 2007 Shay Green 132 | 133 | GTK+ GUI code 134 | (c) Copyright 2004 - 2011 BearOso 135 | 136 | Win32 GUI code 137 | (c) Copyright 2003 - 2006 blip, 138 | funkyass, 139 | Matthew Kendora, 140 | Nach, 141 | nitsuja 142 | (c) Copyright 2009 - 2011 OV2 143 | 144 | Mac OS GUI code 145 | (c) Copyright 1998 - 2001 John Stiles 146 | (c) Copyright 2001 - 2011 zones 147 | 148 | 149 | Specific ports contains the works of other authors. See headers in 150 | individual files. 151 | 152 | 153 | Snes9x homepage: http://www.snes9x.com/ 154 | 155 | Permission to use, copy, modify and/or distribute Snes9x in both binary 156 | and source form, for non-commercial purposes, is hereby granted without 157 | fee, providing that this license information and copyright notice appear 158 | with all copies and any derived work. 159 | 160 | This software is provided 'as-is', without any express or implied 161 | warranty. In no event shall the authors be held liable for any damages 162 | arising from the use of this software or it's derivatives. 163 | 164 | Snes9x is freeware for PERSONAL USE only. Commercial users should 165 | seek permission of the copyright holders first. Commercial use includes, 166 | but is not limited to, charging money for Snes9x or software derived from 167 | Snes9x, including Snes9x or derivatives in commercial game bundles, and/or 168 | using Snes9x as a promotion for your commercial product. 169 | 170 | The copyright holders request that bug fixes and improvements to the code 171 | should be forwarded to them so everyone can benefit from the modifications 172 | in future versions. 173 | 174 | Super NES and Super Nintendo Entertainment System are trademarks of 175 | Nintendo Co., Limited and its subsidiary companies. 176 | ***********************************************************************************/ 177 | 178 | 179 | #ifndef _SDD1EMU_H_ 180 | #define _SDD1EMU_H_ 181 | 182 | void SDD1_decompress (uint8 *, uint8 *, int); 183 | 184 | #endif 185 | -------------------------------------------------------------------------------- /snes9x/sdl/CREDITS: -------------------------------------------------------------------------------- 1 | 2 | Snes9x - Portable Super Nintendo Entertainment System (TM) emulator. 3 | 4 | (c) Copyright 1996 - 2002 Gary Henderson (gary.henderson@ntlworld.com), 5 | Jerremy Koot (jkoot@snes9x.com) 6 | 7 | (c) Copyright 2002 - 2004 Matthew Kendora 8 | 9 | (c) Copyright 2002 - 2005 Peter Bortas (peter@bortas.org) 10 | 11 | (c) Copyright 2004 - 2005 Joel Yliluoma (http://iki.fi/bisqwit/) 12 | 13 | (c) Copyright 2001 - 2006 John Weidman (jweidman@slip.net) 14 | 15 | (c) Copyright 2002 - 2006 funkyass (funkyass@spam.shaw.ca), 16 | Kris Bleakley (codeviolation@hotmail.com) 17 | 18 | (c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net), 19 | Nach (n-a-c-h@users.sourceforge.net), 20 | 21 | (c) Copyright 2002 - 2011 zones (kasumitokoduck@yahoo.com) 22 | 23 | (c) Copyright 2006 - 2007 nitsuja 24 | 25 | (c) Copyright 2009 - 2011 BearOso, 26 | OV2 27 | 28 | BS-X C emulator code 29 | (c) Copyright 2005 - 2006 Dreamer Nom, 30 | zones 31 | 32 | C4 x86 assembler and some C emulation code 33 | (c) Copyright 2000 - 2003 _Demo_ (_demo_@zsnes.com), 34 | Nach, 35 | zsKnight (zsknight@zsnes.com) 36 | 37 | C4 C++ code 38 | (c) Copyright 2003 - 2006 Brad Jorsch, 39 | Nach 40 | 41 | DSP-1 emulator code 42 | (c) Copyright 1998 - 2006 _Demo_, 43 | Andreas Naive (andreasnaive@gmail.com), 44 | Gary Henderson, 45 | Ivar (ivar@snes9x.com), 46 | John Weidman, 47 | Kris Bleakley, 48 | Matthew Kendora, 49 | Nach, 50 | neviksti (neviksti@hotmail.com) 51 | 52 | DSP-2 emulator code 53 | (c) Copyright 2003 John Weidman, 54 | Kris Bleakley, 55 | Lord Nightmare (lord_nightmare@users.sourceforge.net), 56 | Matthew Kendora, 57 | neviksti 58 | 59 | DSP-3 emulator code 60 | (c) Copyright 2003 - 2006 John Weidman, 61 | Kris Bleakley, 62 | Lancer, 63 | z80 gaiden 64 | 65 | DSP-4 emulator code 66 | (c) Copyright 2004 - 2006 Dreamer Nom, 67 | John Weidman, 68 | Kris Bleakley, 69 | Nach, 70 | z80 gaiden 71 | 72 | OBC1 emulator code 73 | (c) Copyright 2001 - 2004 zsKnight, 74 | pagefault (pagefault@zsnes.com), 75 | Kris Bleakley 76 | Ported from x86 assembler to C by sanmaiwashi 77 | 78 | SPC7110 and RTC C++ emulator code used in 1.39-1.51 79 | (c) Copyright 2002 Matthew Kendora with research by 80 | zsKnight, 81 | John Weidman, 82 | Dark Force 83 | 84 | SPC7110 and RTC C++ emulator code used in 1.52+ 85 | (c) Copyright 2009 byuu, 86 | neviksti 87 | 88 | S-DD1 C emulator code 89 | (c) Copyright 2003 Brad Jorsch with research by 90 | Andreas Naive, 91 | John Weidman 92 | 93 | S-RTC C emulator code 94 | (c) Copyright 2001 - 2006 byuu, 95 | John Weidman 96 | 97 | ST010 C++ emulator code 98 | (c) Copyright 2003 Feather, 99 | John Weidman, 100 | Kris Bleakley, 101 | Matthew Kendora 102 | 103 | Super FX x86 assembler emulator code 104 | (c) Copyright 1998 - 2003 _Demo_, 105 | pagefault, 106 | zsKnight 107 | 108 | Super FX C emulator code 109 | (c) Copyright 1997 - 1999 Ivar, 110 | Gary Henderson, 111 | John Weidman 112 | 113 | Sound emulator code used in 1.5-1.51 114 | (c) Copyright 1998 - 2003 Brad Martin 115 | (c) Copyright 1998 - 2006 Charles Bilyue' 116 | 117 | Sound emulator code used in 1.52+ 118 | (c) Copyright 2004 - 2007 Shay Green (gblargg@gmail.com) 119 | 120 | SH assembler code partly based on x86 assembler code 121 | (c) Copyright 2002 - 2004 Marcus Comstedt (marcus@mc.pp.se) 122 | 123 | 2xSaI filter 124 | (c) Copyright 1999 - 2001 Derek Liauw Kie Fa 125 | 126 | HQ2x, HQ3x, HQ4x filters 127 | (c) Copyright 2003 Maxim Stepin (maxim@hiend3d.com) 128 | 129 | NTSC filter 130 | (c) Copyright 2006 - 2007 Shay Green 131 | 132 | GTK+ GUI code 133 | (c) Copyright 2004 - 2011 BearOso 134 | 135 | Win32 GUI code 136 | (c) Copyright 2003 - 2006 blip, 137 | funkyass, 138 | Matthew Kendora, 139 | Nach, 140 | nitsuja 141 | (c) Copyright 2009 - 2011 OV2 142 | 143 | Mac OS GUI code 144 | (c) Copyright 1998 - 2001 John Stiles 145 | (c) Copyright 2001 - 2011 zones 146 | 147 | 148 | -------------------------------------------------------------------------------- /snes9x/sdl/Makefile: -------------------------------------------------------------------------------- 1 | #S9XDEBUGGER=1 2 | #S9XNETPLAY=1 3 | #S9XZIP=1 4 | #S9XJMA=1 5 | 6 | # Fairly good and special-char-safe descriptor of the os being built on. 7 | OS = `uname -s -r -m|sed \"s/ /-/g\"|tr \"[A-Z]\" \"[a-z]\"|tr \"/()\" \"___\"` 8 | BUILDDIR = . 9 | 10 | OBJECTS = ../apu/apu.o ../apu/SNES_SPC.o ../apu/SNES_SPC_misc.o ../apu/SNES_SPC_state.o ../apu/SPC_DSP.o ../apu/SPC_Filter.o ../bsx.o ../c4.o ../c4emu.o ../clip.o ../controls.o ../cpu.o ../cpuexec.o ../cpuops.o ../dma.o ../dsp.o ../dsp1.o ../dsp2.o ../dsp3.o ../dsp4.o ../fxinst.o ../fxemu.o ../gfx.o ../globals.o ../memmap.o ../obc1.o ../ppu.o ../reader.o ../sa1.o ../sa1cpu.o ../sdd1.o ../sdd1emu.o ../seta.o ../seta010.o ../seta011.o ../seta018.o ../snes9x.o ../spc7110.o ../srtc.o ../tile.o sdlmain.o sdlinput.o sdlvideo.o sdlaudio.o 11 | 12 | 13 | CCC = clang++ 14 | CC = clang 15 | GASM = clang 16 | INCLUDES = -I. -I.. -I../apu/ 17 | 18 | # -I../unzip/ -I../jma/ -I../filter/ 19 | 20 | CCFLAGS = -U__linux -O3 -fomit-frame-pointer -fno-exceptions -fno-rtti -pedantic -Wall -W -Wno-unused-parameter -I/usr/include/SDL -D_GNU_SOURCE=1 -D_REENTRANT -DHAVE_MKSTEMP -DHAVE_STRINGS_H -DHAVE_SYS_IOCTL_H -DHAVE_STDINT_H -DRIGHTSHIFT_IS_SAR $(DEFS) -DUSE_SDL -DSOUND 21 | CFLAGS = $(CCFLAGS) 22 | 23 | .SUFFIXES: .o .cpp .c .cc .h .m .i .s .obj 24 | 25 | all: Makefile configure snes9x-sdl 26 | 27 | Makefile: configure Makefile.in 28 | @echo "Makefile is older than configure or in-file. Run configure or touch Makefile." 29 | exit 1 30 | 31 | configure: configure.ac 32 | @echo "configure is older than in-file. Run autoconf or touch configure." 33 | exit 1 34 | 35 | snes9x-sdl: $(OBJECTS) 36 | $(CCC) $(INCLUDES) -o $@ $(OBJECTS) -lm -lSDL 37 | 38 | ../jma/s9x-jma.o: ../jma/s9x-jma.cpp 39 | $(CCC) $(INCLUDES) -c $(CCFLAGS) -fexceptions $*.cpp -o $@ 40 | ../jma/7zlzma.o: ../jma/7zlzma.cpp 41 | $(CCC) $(INCLUDES) -c $(CCFLAGS) -fexceptions $*.cpp -o $@ 42 | ../jma/crc32.o: ../jma/crc32.cpp 43 | $(CCC) $(INCLUDES) -c $(CCFLAGS) -fexceptions $*.cpp -o $@ 44 | ../jma/iiostrm.o: ../jma/iiostrm.cpp 45 | $(CCC) $(INCLUDES) -c $(CCFLAGS) -fexceptions $*.cpp -o $@ 46 | ../jma/inbyte.o: ../jma/inbyte.cpp 47 | $(CCC) $(INCLUDES) -c $(CCFLAGS) -fexceptions $*.cpp -o $@ 48 | ../jma/jma.o: ../jma/jma.cpp 49 | $(CCC) $(INCLUDES) -c $(CCFLAGS) -fexceptions $*.cpp -o $@ 50 | ../jma/lzma.o: ../jma/lzma.cpp 51 | $(CCC) $(INCLUDES) -c $(CCFLAGS) -fexceptions $*.cpp -o $@ 52 | ../jma/lzmadec.o: ../jma/lzmadec.cpp 53 | $(CCC) $(INCLUDES) -c $(CCFLAGS) -fexceptions $*.cpp -o $@ 54 | ../jma/winout.o: ../jma/winout.cpp 55 | $(CCC) $(INCLUDES) -c $(CCFLAGS) -fexceptions $*.cpp -o $@ 56 | 57 | .cpp.o: 58 | $(CCC) $(INCLUDES) -c $(CCFLAGS) $*.cpp -o $@ 59 | 60 | .c.o: 61 | $(CC) $(INCLUDES) -c $(CCFLAGS) $*.c -o $@ 62 | 63 | .cpp.S: 64 | $(GASM) $(INCLUDES) -S $(CCFLAGS) $*.cpp -o $@ 65 | 66 | .cpp.i: 67 | $(GASM) $(INCLUDES) -E $(CCFLAGS) $*.cpp -o $@ 68 | 69 | .S.o: 70 | $(GASM) $(INCLUDES) -c $(CCFLAGS) $*.S -o $@ 71 | 72 | .S.i: 73 | $(GASM) $(INCLUDES) -c -E $(CCFLAGS) $*.S -o $@ 74 | 75 | .s.o: 76 | @echo Compiling $*.s 77 | sh-elf-as -little $*.s -o $@ 78 | 79 | .obj.o: 80 | cp $*.obj $*.o 81 | 82 | clean: 83 | rm -f $(OBJECTS) 84 | -------------------------------------------------------------------------------- /snes9x/sdl/Makefile.in: -------------------------------------------------------------------------------- 1 | @S9XDEBUGGER@ 2 | @S9XNETPLAY@ 3 | @S9XZIP@ 4 | @S9XJMA@ 5 | 6 | # Fairly good and special-char-safe descriptor of the os being built on. 7 | OS = `uname -s -r -m|sed \"s/ /-/g\"|tr \"[A-Z]\" \"[a-z]\"|tr \"/()\" \"___\"` 8 | BUILDDIR = . 9 | 10 | OBJECTS = ../apu/apu.o ../apu/SNES_SPC.o ../apu/SNES_SPC_misc.o ../apu/SNES_SPC_state.o ../apu/SPC_DSP.o ../apu/SPC_Filter.o ../bsx.o ../c4.o ../c4emu.o ../cheats.o ../cheats2.o ../clip.o ../conffile.o ../controls.o ../cpu.o ../cpuexec.o ../cpuops.o ../crosshairs.o ../dma.o ../dsp.o ../dsp1.o ../dsp2.o ../dsp3.o ../dsp4.o ../fxinst.o ../fxemu.o ../gfx.o ../globals.o ../logger.o ../memmap.o ../movie.o ../obc1.o ../ppu.o ../reader.o ../sa1.o ../sa1cpu.o ../screenshot.o ../sdd1.o ../sdd1emu.o ../seta.o ../seta010.o ../seta011.o ../seta018.o ../snapshot.o ../snes9x.o ../spc7110.o ../srtc.o ../tile.o ../filter/2xsai.o ../filter/blit.o ../filter/epx.o ../filter/hq2x.o ../filter/snes_ntsc.o sdlmain.o sdlinput.o sdlvideo.o sdlaudio.o 11 | 12 | ifdef S9XDEBUGGER 13 | OBJECTS += ../debug.o ../fxdbg.o 14 | endif 15 | 16 | ifdef S9XNETPLAY 17 | OBJECTS += ../netplay.o ../server.o 18 | endif 19 | 20 | ifdef S9XZIP 21 | OBJECTS += ../loadzip.o ../unzip/ioapi.o ../unzip/unzip.o 22 | endif 23 | 24 | ifdef S9XJMA 25 | OBJECTS += ../jma/7zlzma.o ../jma/crc32.o ../jma/iiostrm.o ../jma/inbyte.o ../jma/jma.o ../jma/lzma.o ../jma/lzmadec.o ../jma/s9x-jma.o ../jma/winout.o 26 | endif 27 | 28 | CCC = @CXX@ 29 | CC = @CC@ 30 | GASM = @CXX@ 31 | INCLUDES = -I. -I.. -I../apu/ -I../unzip/ -I../jma/ -I../filter/ 32 | 33 | CCFLAGS = @S9XFLGS@ @S9XDEFS@ $(DEFS) 34 | CFLAGS = $(CCFLAGS) 35 | 36 | .SUFFIXES: .o .cpp .c .cc .h .m .i .s .obj 37 | 38 | all: Makefile configure snes9x-sdl 39 | 40 | Makefile: configure Makefile.in 41 | @echo "Makefile is older than configure or in-file. Run configure or touch Makefile." 42 | exit 1 43 | 44 | configure: configure.ac 45 | @echo "configure is older than in-file. Run autoconf or touch configure." 46 | exit 1 47 | 48 | snes9x-sdl: $(OBJECTS) 49 | $(CCC) $(INCLUDES) -o $@ $(OBJECTS) -lm @S9XLIBS@ 50 | 51 | ../jma/s9x-jma.o: ../jma/s9x-jma.cpp 52 | $(CCC) $(INCLUDES) -c $(CCFLAGS) -fexceptions $*.cpp -o $@ 53 | ../jma/7zlzma.o: ../jma/7zlzma.cpp 54 | $(CCC) $(INCLUDES) -c $(CCFLAGS) -fexceptions $*.cpp -o $@ 55 | ../jma/crc32.o: ../jma/crc32.cpp 56 | $(CCC) $(INCLUDES) -c $(CCFLAGS) -fexceptions $*.cpp -o $@ 57 | ../jma/iiostrm.o: ../jma/iiostrm.cpp 58 | $(CCC) $(INCLUDES) -c $(CCFLAGS) -fexceptions $*.cpp -o $@ 59 | ../jma/inbyte.o: ../jma/inbyte.cpp 60 | $(CCC) $(INCLUDES) -c $(CCFLAGS) -fexceptions $*.cpp -o $@ 61 | ../jma/jma.o: ../jma/jma.cpp 62 | $(CCC) $(INCLUDES) -c $(CCFLAGS) -fexceptions $*.cpp -o $@ 63 | ../jma/lzma.o: ../jma/lzma.cpp 64 | $(CCC) $(INCLUDES) -c $(CCFLAGS) -fexceptions $*.cpp -o $@ 65 | ../jma/lzmadec.o: ../jma/lzmadec.cpp 66 | $(CCC) $(INCLUDES) -c $(CCFLAGS) -fexceptions $*.cpp -o $@ 67 | ../jma/winout.o: ../jma/winout.cpp 68 | $(CCC) $(INCLUDES) -c $(CCFLAGS) -fexceptions $*.cpp -o $@ 69 | 70 | .cpp.o: 71 | $(CCC) $(INCLUDES) -c $(CCFLAGS) $*.cpp -o $@ 72 | 73 | .c.o: 74 | $(CC) $(INCLUDES) -c $(CCFLAGS) $*.c -o $@ 75 | 76 | .cpp.S: 77 | $(GASM) $(INCLUDES) -S $(CCFLAGS) $*.cpp -o $@ 78 | 79 | .cpp.i: 80 | $(GASM) $(INCLUDES) -E $(CCFLAGS) $*.cpp -o $@ 81 | 82 | .S.o: 83 | $(GASM) $(INCLUDES) -c $(CCFLAGS) $*.S -o $@ 84 | 85 | .S.i: 86 | $(GASM) $(INCLUDES) -c -E $(CCFLAGS) $*.S -o $@ 87 | 88 | .s.o: 89 | @echo Compiling $*.s 90 | sh-elf-as -little $*.s -o $@ 91 | 92 | .obj.o: 93 | cp $*.obj $*.o 94 | 95 | clean: 96 | rm -f $(OBJECTS) 97 | -------------------------------------------------------------------------------- /snes9x/sdl/buildhtml: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -o verbose 3 | OUT=../../output 4 | OBJECTS="../apu/apu.cpp ../apu/SNES_SPC.cpp ../apu/SNES_SPC_misc.cpp ../apu/SNES_SPC_state.cpp ../apu/SPC_DSP.cpp ../apu/SPC_Filter.cpp ../bsx.cpp ../c4.cpp ../c4emu.cpp ../clip.cpp ../controls.cpp ../cpu.cpp ../cpuexec.cpp ../cpuops.cpp ../dma.cpp ../dsp.cpp ../dsp1.cpp ../dsp2.cpp ../dsp3.cpp ../dsp4.cpp ../fxinst.cpp ../fxemu.cpp ../gfx.cpp ../globals.cpp ../memmap.cpp ../obc1.cpp ../ppu.cpp ../reader.cpp ../sa1.cpp ../sa1cpu.cpp ../sdd1.cpp ../sdd1emu.cpp ../seta.cpp ../seta010.cpp ../seta011.cpp ../seta018.cpp ../snes9x.cpp ../spc7110.cpp ../srtc.cpp ../tile.cpp sdlmain.cpp sdlinput.cpp sdlvideo.cpp sdlaudio.cpp" 5 | INCLUDES="-I. -I.. -I../apu/" 6 | CCFLAGS="-U__linux -O3 -DLSB_FIRST -fomit-frame-pointer -fno-exceptions -fno-rtti -pedantic -Wall -W -Wno-unused-parameter -I/usr/include/SDL -D_GNU_SOURCE=1 -D_REENTRANT -DHAVE_MKSTEMP -DHAVE_STRINGS_H -DHAVE_SYS_IOCTL_H -DHAVE_STDINT_H -DRIGHTSHIFT_IS_SAR -Wno-c++11-extensions" 7 | 8 | emcc -O3 -s EXPORTED_FUNCTIONS="['_main', '_set_frameskip', '_set_transparency', '_run', '_toggle_display_framerate', '_S9xAutoSaveSRAM' ]" \ 9 | -s FORCE_FILESYSTEM=1 \ 10 | --shell-file xnes9x_shell.html \ 11 | -o $OUT/snes9x.html \ 12 | -DUSE_SDL \ 13 | -DHTML $INCLUDES $CCFLAGS $OBJECTS \ 14 | -lm -lSDL -s TOTAL_MEMORY=50331648 \ 15 | -DSOUND 16 | -------------------------------------------------------------------------------- /snes9x/sdl/config.info: -------------------------------------------------------------------------------- 1 | 2 | build information: 3 | cc...............,,,. gcc 4 | c++.................. g++ 5 | options.............. -O3 -fomit-frame-pointer -fno-exceptions -fno-rtti -pedantic -Wall -W -Wno-unused-parameter -I/usr/include/SDL -D_GNU_SOURCE=1 -D_REENTRANT 6 | defines.............. -DHAVE_MKSTEMP -DHAVE_STRINGS_H -DHAVE_SYS_IOCTL_H -DHAVE_STDINT_H -DRIGHTSHIFT_IS_SAR 7 | libs................. -L/usr/lib/x86_64-linux-gnu -lSDL 8 | 9 | features: 10 | screenshot support... no 11 | netplay support...... no 12 | GZIP support......... no 13 | ZIP support.......... no 14 | JMA support.......... no 15 | debugger............. no 16 | 17 | -------------------------------------------------------------------------------- /snes9x/sdl/docs/control-inputs.txt: -------------------------------------------------------------------------------- 1 | Control-input for snes9x-sdl 2 | makoto.sugano@gmail.com 3 | 4 | This document is based on snes9x/doc/control* 5 | It is recommended to read controls.txt and control-inputs.txt 6 | to gain the basic understandings over how the control inputs are handled in 7 | general in sne9x. 8 | 9 | Compared to the snes9x/unix/x11.cpp, the supported inputs are 10 | reduced in snes9x-sdl by default. This is to simplify the design and the make 11 | the porting to other platforms even easier. Additionally, keyboard identifier 12 | has been changed to ease the SDL coding. 13 | 14 | The following features are either removed or not tested. 15 | 16 | - Joystick MOD keys. 17 | - Mouse pointer input. 18 | - Port specific commands 19 | 20 | The following features are added/modified on the unix/x11.cpp 21 | 22 | + is now SDL_keysym (see the /usr/include/SDL/SDL_keysym.h). 23 | 24 | ================================================================================ 25 | Unix/SDL 26 | ================================================================================ 27 | 28 | Joystick Input: 29 | 30 | Jxx:Hat{Up,Down,Left,Right} Hats direction on joystick xx. 31 | Jxx:Axis# Axis # on joystick xx. Axis0 may be 32 | Up/Down, and Axis1 Left/Right. 33 | Jxx:B# Button # on joystick xx. 34 | 35 | Keyboard Input: 36 | 37 | K00: Key names are as recognized by SDL_keysym. 38 | K00:+ Keyboard modifiers are S=Shift, C=Control, 39 | A=Alt, M=Meta. Combine them in order, 40 | i.e. all 4 would be "SCAM". 41 | 42 | Pointer Input: 43 | 44 | M00:Pointer Map the mouse pointer. If someone has a mouse 45 | M00:B# Mouse buttons. 46 | 47 | ================================================================================ 48 | S9xMapButton/S9xMapAxis/S9xMapPointer ID structure 49 | ================================================================================ 50 | 51 | MapButton ID is a 32bit integer value to inform the button ID to the snes9x engine 52 | from the frontend. 53 | 54 | === S9xMapButton (id, command, poll); Keyboard and Joystick. === 55 | 56 | id is a 32 bit integer that follows the below protocol. 57 | 58 | |AB|CD|EF|GH| 59 | 60 | switch A (4 bit) 61 | case 0: keyboard device 62 | case 8: joystick device 63 | 64 | switch B (4 bit) 65 | case 0: the 1st keyboard/joystick 66 | case 1: the 2nd joystick 67 | ... 68 | case 7: the 8th joystick 69 | 70 | #if (keyboard) 71 | 72 | switch ABCD (16 bit) 73 | case KMOD_x: MOD key masks. 74 | 75 | switch FGH (12 bit) 76 | case SDLK_a: SDL_keysym (e.g. SDLK_a) 77 | 78 | #elif (joystick) 79 | 80 | switch FGH (12 bit) 81 | event.jbutton.button (0, 1, 2...) 82 | 83 | #endif 84 | 85 | === S9xMapAxis (id, command, poll); Joystick only. === 86 | 87 | id is a 32 bit integer that follows the below protocol. 88 | 89 | |AB|CD|EF|GH| 90 | 91 | switch A (4 bit) 92 | case 8: J device 93 | 94 | switch B (4 bit) 95 | case 0: the 1st joystick 96 | case 1: the 2nd joystick 97 | ... 98 | case 7: the 8th joystick 99 | 100 | switch E (upper 1 bit) 101 | case 8: Axis mode 102 | 103 | switch FGH (12 bit) 104 | case d: event.jaxis.axis (left/right or up/down) 105 | 106 | === S9xMapPointer (id, command, poll); Mouse only. === 107 | 108 | switch A (4 bit) 109 | case 4: M device 110 | 111 | switch B (4 bit) 112 | case 0: the 1st mouse 113 | 114 | -------------------------------------------------------------------------------- /snes9x/sdl/docs/snes9x-sdl.conf: -------------------------------------------------------------------------------- 1 | #----------------------------------------- 2 | # snes9x-sdl.conf : snes9x-sdl Configuration file 3 | #----------------------------------------- 4 | 5 | [ROM] 6 | # Filename = 7 | LoROM = FALSE 8 | HiROM = FALSE 9 | PAL = FALSE 10 | NTSC = FALSE 11 | # Header = TRUE/FALSE to ForceHeader or ForceNoHeader 12 | # Interleaved = TRUE/FALSE to ForceInterleaved or ForceNoInterleaved 13 | Interleaved2 = FALSE 14 | InterleaveGD24 = FALSE 15 | Cheat = FALSE 16 | Patch = TRUE 17 | 18 | [Sound] 19 | Sync = FALSE 20 | 16BitSound = TRUE 21 | Stereo = TRUE 22 | ReverseStereo = FALSE 23 | Rate = 32000 24 | InputRate = 32000 25 | Mute = FALSE 26 | 27 | [Display] 28 | HiRes = TRUE 29 | Transparency = TRUE 30 | GraphicWindows = TRUE 31 | DisplayFrameRate = FALSE 32 | DisplayWatchedAddresses = FALSE 33 | DisplayInput = FALSE 34 | DisplayFrameCount = FALSE 35 | MessagesInImage = TRUE 36 | MessageDisplayTime = 120 37 | 38 | [Settings] 39 | BSXBootup = FALSE 40 | # FrameTime = 41 | FrameSkip = Auto 42 | TurboMode = FALSE 43 | TurboFrameSkip = 15 44 | MovieTruncateAtEnd = FALSE 45 | MovieNotifyIgnored = FALSE 46 | WrongMovieStateProtection = TRUE 47 | StretchScreenshots = 1 48 | SnapshotScreenshots = TRUE 49 | DontSaveOopsSnapshot = FALSE 50 | AutoSaveDelay = 0 51 | 52 | [Controls] 53 | MouseMaster = TRUE 54 | SuperscopeMaster = TRUE 55 | JustifierMaster = TRUE 56 | MP5Master = TRUE 57 | AllowLeftRight = FALSE 58 | Port1 = pad1 59 | Port2 = none 60 | Mouse1Crosshair = 1 White/Black 61 | Mouse2Crosshair = 1 White/Black 62 | SuperscopeCrosshair = 2 White/Black 63 | Justifier1Crosshair = 4 Blue/Black 64 | Justifier2Crosshair = 4 MagicPink/Black 65 | 66 | [Hack] 67 | EnableGameSpecificHacks = TRUE 68 | AllowInvalidVRAMAccess = FALSE 69 | SpeedHacks = FALSE 70 | HDMATiming = 100 71 | 72 | [Netplay] 73 | Enable = FALSE 74 | Port = 6096 75 | Server = "" 76 | 77 | [DEBUG] 78 | Debugger = FALSE 79 | Trace = FALSE 80 | 81 | [Unix] 82 | # BaseDir = ~/.snes9x 83 | # SnapshotFilename = 84 | # PlayMovieFilename = 85 | # RecordMovieFilename = 86 | SoundBufferSize = 100 87 | ClearAllControls = FALSE 88 | 89 | [Unix/SDL] 90 | # SetKeyRepeat = TRUE 91 | VideoMode = 1 92 | 93 | [Unix/SDL Controls] 94 | J00:Axis1 = Joypad1 Axis Up/Down T=50% 95 | J00:Axis0 = Joypad1 Axis Left/Right T=50% 96 | J00:B1 = Joypad1 A 97 | J00:B2 = Joypad1 B 98 | J00:B0 = Joypad1 X 99 | J00:B3 = Joypad1 Y 100 | J00:B6 = Joypad1 L 101 | J00:B7 = Joypad1 R 102 | J00:B8 = Joypad1 Select 103 | J00:B11 = Joypad1 Start 104 | K00:Up = Joypad1 Up 105 | K00:Down = Joypad1 Down 106 | K00:Left = Joypad1 Left 107 | K00:Right = Joypad1 Right 108 | K00:d = Joypad1 A 109 | K00:c = Joypad1 B 110 | K00:s = Joypad1 X 111 | K00:x = Joypad1 Y 112 | K00:a = Joypad1 L 113 | K00:z = Joypad1 R 114 | K00:space = Joypad1 Select 115 | K00:Return = Joypad1 Start 116 | K00:Escape = ExitEmu 117 | K00:Pause = Pause 118 | M00:Pointer = Pointer Mouse1+Superscope+Justifier1 119 | M00:B0 = {Mouse1 L,Superscope Fire,Justifier1 Trigger} 120 | M00:B2 = {Mouse1 R,Superscope Cursor,Justifier1 Start} 121 | M00:B1 = {Justifier1 AimOffscreen Trigger,Superscope AimOffscreen} 122 | -------------------------------------------------------------------------------- /snes9x/sdl/em.makefile: -------------------------------------------------------------------------------- 1 | #S9XDEBUGGER=1 2 | #S9XNETPLAY=1 3 | #S9XZIP=1 4 | #S9XJMA=1 5 | 6 | # Fairly good and special-char-safe descriptor of the os being built on. 7 | OS = `uname -s -r -m|sed \"s/ /-/g\"|tr \"[A-Z]\" \"[a-z]\"|tr \"/()\" \"___\"` 8 | BUILDDIR = . 9 | 10 | OBJECTS = ../apu/apu.bc ../apu/SNES_SPC.bc ../apu/SNES_SPC_misc.bc ../apu/SNES_SPC_state.bc ../apu/SPC_DSP.bc ../apu/SPC_Filter.bc ../bsx.bc ../c4.bc ../c4emu.bc ../clip.bc ../controls.bc ../cpu.bc ../cpuexec.bc ../cpuops.bc ../dma.bc ../dsp.bc ../dsp1.bc ../dsp2.bc ../dsp3.bc ../dsp4.bc ../fxinst.bc ../fxemu.bc ../gfx.bc ../globals.bc ../memmap.bc ../obc1.bc ../ppu.bc ../reader.bc ../sa1.bc ../sa1cpu.bc ../sdd1.bc ../sdd1emu.bc ../seta.bc ../seta010.bc ../seta011.bc ../seta018.bc ../snes9x.bc ../spc7110.bc ../srtc.bc ../tile.bc 11 | 12 | GUISRC = sdlmain.cpp sdlinput.cpp sdlvideo.cpp sdlaudio.cpp 13 | 14 | 15 | 16 | CCC = emcc 17 | CC = emcc 18 | GASM = emcc 19 | INCLUDES = -I. -I.. -I../apu/ 20 | 21 | CCFLAGS = --llvm-opts 3 -O1 -DLSB_FIRST -U__linux -fomit-frame-pointer -fno-exceptions -fno-rtti -pedantic -Wall -W -Wno-unused-parameter -I/usr/include/SDL -D_GNU_SOURCE=1 -D_REENTRANT -DHAVE_MKSTEMP -DHAVE_STRINGS_H -DHAVE_SYS_IOCTL_H -DHAVE_STDINT_H -DRIGHTSHIFT_IS_SAR $(DEFS) 22 | CFLAGS = $(CCFLAGS) 23 | 24 | .SUFFIXES: .bc .cpp .c .cc .h .m .i .s .bcbj 25 | 26 | all: snes9x.js 27 | 28 | snes9x.js: $(OBJECTS) 29 | $(CCC) $(INCLUDES) $(CCFLAGS) -O2 --closure 0 --embed-file smw.smc $(INCLUDES) -o $@ $(OBJECTS) $(GUISRC) -lm -lSDL 30 | 31 | html: $(OBJECTS) 32 | $(CCC) -O1 --closure 0 --embed-file smw.smc $(INCLUDES) -o xnes9x.html -DUSE_SDL -DHTML $(INCLUDES) $(CCFLAGS) $(GUISRC) $(OBJECTS) -lm -lSDL 33 | 34 | ../jma/s9x-jma.bc: ../jma/s9x-jma.cpp 35 | $(CCC) $(INCLUDES) -c $(CCFLAGS) -fexceptions $*.cpp -o $@ 36 | ../jma/7zlzma.bc: ../jma/7zlzma.cpp 37 | $(CCC) $(INCLUDES) -c $(CCFLAGS) -fexceptions $*.cpp -o $@ 38 | ../jma/crc32.bc: ../jma/crc32.cpp 39 | $(CCC) $(INCLUDES) -c $(CCFLAGS) -fexceptions $*.cpp -o $@ 40 | ../jma/iiostrm.bc: ../jma/iiostrm.cpp 41 | $(CCC) $(INCLUDES) -c $(CCFLAGS) -fexceptions $*.cpp -o $@ 42 | ../jma/inbyte.bc: ../jma/inbyte.cpp 43 | $(CCC) $(INCLUDES) -c $(CCFLAGS) -fexceptions $*.cpp -o $@ 44 | ../jma/jma.bc: ../jma/jma.cpp 45 | $(CCC) $(INCLUDES) -c $(CCFLAGS) -fexceptions $*.cpp -o $@ 46 | ../jma/lzma.bc: ../jma/lzma.cpp 47 | $(CCC) $(INCLUDES) -c $(CCFLAGS) -fexceptions $*.cpp -o $@ 48 | ../jma/lzmadec.bc: ../jma/lzmadec.cpp 49 | $(CCC) $(INCLUDES) -c $(CCFLAGS) -fexceptions $*.cpp -o $@ 50 | ../jma/winout.bc: ../jma/winout.cpp 51 | $(CCC) $(INCLUDES) -c $(CCFLAGS) -fexceptions $*.cpp -o $@ 52 | 53 | .cpp.bc: 54 | $(CCC) $(INCLUDES) -c $(CCFLAGS) $*.cpp -o $@ 55 | 56 | .c.bc: 57 | $(CC) $(INCLUDES) -c $(CCFLAGS) $*.c -o $@ 58 | 59 | .cpp.S: 60 | $(GASM) $(INCLUDES) -S $(CCFLAGS) $*.cpp -o $@ 61 | 62 | .cpp.i: 63 | $(GASM) $(INCLUDES) -E $(CCFLAGS) $*.cpp -o $@ 64 | 65 | .S.bc: 66 | $(GASM) $(INCLUDES) -c $(CCFLAGS) $*.S -o $@ 67 | 68 | .S.i: 69 | $(GASM) $(INCLUDES) -c -E $(CCFLAGS) $*.S -o $@ 70 | 71 | .s.bc: 72 | @echo Compiling $*.s 73 | sh-elf-as -little $*.s -o $@ 74 | 75 | .bcbj.bc: 76 | cp $*.bcbj $*.bc 77 | 78 | clean: 79 | rm -f $(OBJECTS) 80 | -------------------------------------------------------------------------------- /snes9x/sdl/extract_script.py: -------------------------------------------------------------------------------- 1 | import re 2 | import sys 3 | 4 | with open(sys.argv[1], "r") as f: 5 | buf=f.read() 6 | while 1: 7 | m=re.search(r"]*>|", buf, re.DOTALL|re.MULTILINE) 12 | if m==None: 13 | break 14 | print buf[:m.start(0)] 15 | print 16 | buf=buf[m.end(0):] 17 | 18 | -------------------------------------------------------------------------------- /snes9x/sdl/sdl_snes9x.h: -------------------------------------------------------------------------------- 1 | #ifdef USE_SDL 2 | #include 3 | #endif 4 | #include "port.h" 5 | #include "conffile.h" 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /snes9x/sdl/sdlaudio.cpp: -------------------------------------------------------------------------------- 1 | /*********************************************************************************** 2 | Snes9x - Portable Super Nintendo Entertainment System (TM) emulator. 3 | 4 | See CREDITS file to find the copyright owners of this file. 5 | 6 | SDL Input/Audio/Video code (many lines of code come from snes9x & drnoksnes) 7 | (c) Copyright 2011 Makoto Sugano (makoto.sugano@gmail.com) 8 | 9 | Snes9x homepage: http://www.snes9x.com/ 10 | 11 | Permission to use, copy, modify and/or distribute Snes9x in both binary 12 | and source form, for non-commercial purposes, is hereby granted without 13 | fee, providing that this license information and copyright notice appear 14 | with all copies and any derived work. 15 | 16 | This software is provided 'as-is', without any express or implied 17 | warranty. In no event shall the authors be held liable for any damages 18 | arising from the use of this software or it's derivatives. 19 | 20 | Snes9x is freeware for PERSONAL USE only. Commercial users should 21 | seek permission of the copyright holders first. Commercial use includes, 22 | but is not limited to, charging money for Snes9x or software derived from 23 | Snes9x, including Snes9x or derivatives in commercial game bundles, and/or 24 | using Snes9x as a promotion for your commercial product. 25 | 26 | The copyright holders request that bug fixes and improvements to the code 27 | should be forwarded to them so everyone can benefit from the modifications 28 | in future versions. 29 | 30 | Super NES and Super Nintendo Entertainment System are trademarks of 31 | Nintendo Co., Limited and its subsidiary companies. 32 | ***********************************************************************************/ 33 | 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | 43 | #ifdef HAVE_STRINGS_H 44 | #include 45 | #endif 46 | 47 | #include 48 | #include 49 | 50 | #include "snes9x.h" 51 | #include "memmap.h" 52 | #include "apu/apu.h" 53 | #include "gfx.h" 54 | #include "snapshot.h" 55 | #include "controls.h" 56 | #include "cheats.h" 57 | #include "movie.h" 58 | #include "logger.h" 59 | #include "display.h" 60 | #include "conffile.h" 61 | 62 | #ifdef DEBUGGER 63 | #include "debug.h" 64 | #endif 65 | 66 | #include 67 | //#include "sdl_snes9x.h" 68 | uint32 sound_buffer_size; 69 | #ifdef SOUND 70 | SDL_AudioSpec *audiospec; 71 | #endif 72 | 73 | void S9xToggleSoundChannel (int c) 74 | { 75 | #ifdef SOUND 76 | static uint8 sound_switch = 255; 77 | 78 | if (c == 8) 79 | sound_switch = 255; 80 | else 81 | sound_switch ^= 1 << c; 82 | 83 | S9xSetSoundControl(sound_switch); 84 | #endif 85 | } 86 | 87 | #ifdef SOUND 88 | static void 89 | sdl_audio_callback (void *userdata, Uint8 *stream, int len) 90 | { 91 | SDL_LockAudio (); 92 | S9xMixSamples (stream, len >> (Settings.SixteenBitSound ? 1 : 0)); 93 | SDL_UnlockAudio (); 94 | 95 | return; 96 | } 97 | 98 | static void 99 | samples_available (void *data) 100 | { 101 | SDL_LockAudio (); 102 | S9xFinalizeSamples (); 103 | SDL_UnlockAudio (); 104 | 105 | return; 106 | } 107 | #endif 108 | bool8 S9xOpenSoundDevice (void) 109 | { 110 | 111 | #ifdef SOUND 112 | SDL_InitSubSystem (SDL_INIT_AUDIO); 113 | 114 | audiospec = (SDL_AudioSpec *) malloc (sizeof (SDL_AudioSpec)); 115 | 116 | audiospec->freq = Settings.SoundPlaybackRate; 117 | audiospec->channels = Settings.Stereo ? 2 : 1; 118 | audiospec->format = Settings.SixteenBitSound ? AUDIO_S16SYS : AUDIO_U8; 119 | #ifdef HTML 120 | audiospec->samples = 1024; // needs to be power-of-two 121 | #else 122 | audiospec->samples = (sound_buffer_size * audiospec->freq / 1000) >> 1; 123 | #endif 124 | audiospec->callback = sdl_audio_callback; 125 | 126 | printf ("SDL sound driver initializing...\n"); 127 | printf (" --> (Frequency: %dhz, Latency: %dms)...", 128 | audiospec->freq, 129 | (audiospec->samples * 1000 / audiospec->freq) << 1); 130 | 131 | if (SDL_OpenAudio (audiospec, NULL) < 0) 132 | { 133 | printf ("Failed\n"); 134 | 135 | free (audiospec); 136 | audiospec = NULL; 137 | 138 | return FALSE; 139 | } 140 | 141 | printf ("OK\n"); 142 | 143 | SDL_PauseAudio (0); 144 | 145 | S9xSetSamplesAvailableCallback (samples_available, NULL); 146 | return TRUE; 147 | #else 148 | return FALSE; 149 | #endif 150 | 151 | } 152 | -------------------------------------------------------------------------------- /snes9x/sdl/sdlinput.cpp: -------------------------------------------------------------------------------- 1 | /*********************************************************************************** 2 | Snes9x - Portable Super Nintendo Entertainment System (TM) emulator. 3 | 4 | See CREDITS file to find the copyright owners of this file. 5 | 6 | SDL Input/Audio/Video code (many lines of code come from snes9x & drnoksnes) 7 | (c) Copyright 2011 Makoto Sugano (makoto.sugano@gmail.com) 8 | 9 | Snes9x homepage: http://www.snes9x.com/ 10 | 11 | Permission to use, copy, modify and/or distribute Snes9x in both binary 12 | and source form, for non-commercial purposes, is hereby granted without 13 | fee, providing that this license information and copyright notice appear 14 | with all copies and any derived work. 15 | 16 | This software is provided 'as-is', without any express or implied 17 | warranty. In no event shall the authors be held liable for any damages 18 | arising from the use of this software or it's derivatives. 19 | 20 | Snes9x is freeware for PERSONAL USE only. Commercial users should 21 | seek permission of the copyright holders first. Commercial use includes, 22 | but is not limited to, charging money for Snes9x or software derived from 23 | Snes9x, including Snes9x or derivatives in commercial game bundles, and/or 24 | using Snes9x as a promotion for your commercial product. 25 | 26 | The copyright holders request that bug fixes and improvements to the code 27 | should be forwarded to them so everyone can benefit from the modifications 28 | in future versions. 29 | 30 | Super NES and Super Nintendo Entertainment System are trademarks of 31 | Nintendo Co., Limited and its subsidiary companies. 32 | ***********************************************************************************/ 33 | 34 | #include "sdl_snes9x.h" 35 | 36 | #include "snes9x.h" 37 | #include "port.h" 38 | #include "controls.h" 39 | #include "display.h" 40 | 41 | // domaemon: FIXME, just collecting the essentials. 42 | // domaemon: *) here we define the keymapping. 43 | void S9xParseInputConfig (ConfigFile &conf, int pass) 44 | { 45 | 46 | return; 47 | } 48 | 49 | // void S9xInitInputDevices (void) 50 | // { 51 | // S9xUnmapAllControls(); 52 | // #ifdef USE_SDL 53 | // S9xMapButton(SDLK_RIGHT, S9xGetCommandT("Joypad1 Right"), false); 54 | // S9xMapButton(SDLK_LEFT, S9xGetCommandT("Joypad1 Left"), false); 55 | // S9xMapButton(SDLK_DOWN, S9xGetCommandT("Joypad1 Down"), false); 56 | // S9xMapButton(SDLK_UP, S9xGetCommandT("Joypad1 Up"), false); 57 | // S9xMapButton(SDLK_RETURN, S9xGetCommandT("Joypad1 Start"), false); 58 | // S9xMapButton(SDLK_SPACE, S9xGetCommandT("Joypad1 Select"), false); 59 | // S9xMapButton(SDLK_d, S9xGetCommandT("Joypad1 A"), false); 60 | // S9xMapButton(SDLK_c, S9xGetCommandT("Joypad1 B"), false); 61 | // S9xMapButton(SDLK_s, S9xGetCommandT("Joypad1 X"), false); 62 | // S9xMapButton(SDLK_x, S9xGetCommandT("Joypad1 Y"), false); 63 | // S9xMapButton(SDLK_a, S9xGetCommandT("Joypad1 L"), false); 64 | // S9xMapButton(SDLK_z, S9xGetCommandT("Joypad1 R"), false); 65 | // #endif 66 | // } 67 | void S9xInitInputDevices (int r, int l, int d, int u, int st, int sl, int a, int b, int x, int y, int lb, int rb) 68 | { 69 | S9xUnmapAllControls(); 70 | #ifdef USE_SDL 71 | S9xMapButton(r, S9xGetCommandT("Joypad1 Right"), false); 72 | S9xMapButton(l, S9xGetCommandT("Joypad1 Left"), false); 73 | S9xMapButton(d, S9xGetCommandT("Joypad1 Down"), false); 74 | S9xMapButton(u, S9xGetCommandT("Joypad1 Up"), false); 75 | S9xMapButton(st, S9xGetCommandT("Joypad1 Start"), false); 76 | S9xMapButton(sl, S9xGetCommandT("Joypad1 Select"), false); 77 | S9xMapButton(a, S9xGetCommandT("Joypad1 A"), false); 78 | S9xMapButton(b, S9xGetCommandT("Joypad1 B"), false); 79 | S9xMapButton(x, S9xGetCommandT("Joypad1 X"), false); 80 | S9xMapButton(y, S9xGetCommandT("Joypad1 Y"), false); 81 | S9xMapButton(lb, S9xGetCommandT("Joypad1 L"), false); 82 | S9xMapButton(rb, S9xGetCommandT("Joypad1 R"), false); 83 | #endif 84 | } 85 | 86 | void S9xProcessEvents (bool8 block) 87 | { 88 | #ifdef USE_SDL 89 | SDL_Event event; 90 | bool8 quit_state = FALSE; 91 | 92 | while ((block) || (SDL_PollEvent (&event) != 0)) 93 | { 94 | switch (event.type) { 95 | case SDL_KEYDOWN: 96 | case SDL_KEYUP: 97 | // domaemon: not sure it's the best idea, but reserving the SDLK_q for quit. 98 | if (event.key.keysym.sym == SDLK_q) 99 | { 100 | quit_state = TRUE; 101 | } 102 | else 103 | { 104 | S9xReportButton(event.key.keysym.mod << 16 | // keyboard mod 105 | event.key.keysym.sym, // keyboard ksym 106 | event.type == SDL_KEYDOWN); // press or release 107 | } 108 | break; 109 | 110 | 111 | case SDL_QUIT: 112 | // domaemon: we come here when the window is getting closed. 113 | quit_state = TRUE; 114 | break; 115 | } 116 | } 117 | 118 | if (quit_state == TRUE) 119 | { 120 | printf ("Quit Event. Bye.\n"); 121 | S9xExit(); 122 | } 123 | #endif 124 | } 125 | 126 | bool S9xPollButton (uint32 id, bool *pressed) 127 | { 128 | return (false); 129 | } 130 | 131 | bool S9xPollAxis (uint32 id, int16 *value) 132 | { 133 | return (false); 134 | } 135 | 136 | bool S9xPollPointer (uint32 id, int16 *x, int16 *y) 137 | { 138 | return (false); 139 | } 140 | 141 | // domaemon: needed by SNES9X 142 | void S9xHandlePortCommand (s9xcommand_t cmd, int16 data1, int16 data2) 143 | { 144 | return; 145 | } 146 | -------------------------------------------------------------------------------- /snes9x/spc7110dec.h: -------------------------------------------------------------------------------- 1 | /***** 2 | * SPC7110 emulator - version 0.03 (2008-08-10) 3 | * Copyright (c) 2008, byuu and neviksti 4 | * 5 | * Permission to use, copy, modify, and/or distribute this software for any 6 | * purpose with or without fee is hereby granted, provided that the above 7 | * copyright notice and this permission notice appear in all copies. 8 | * 9 | * The software is provided "as is" and the author disclaims all warranties 10 | * with regard to this software including all implied warranties of 11 | * merchantibility and fitness, in no event shall the author be liable for 12 | * any special, direct, indirect, or consequential damages or any damages 13 | * whatsoever resulting from loss of use, data or profits, whether in an 14 | * action of contract, negligence or other tortious action, arising out of 15 | * or in connection with the use or performance of this software. 16 | *****/ 17 | 18 | 19 | #ifndef _SPC7110DEC_H_ 20 | #define _SPC7110DEC_H_ 21 | 22 | class SPC7110Decomp { 23 | public: 24 | uint8 read(); 25 | void init(unsigned mode, unsigned offset, unsigned index); 26 | void reset(); 27 | 28 | SPC7110Decomp(); 29 | ~SPC7110Decomp(); 30 | 31 | unsigned decomp_mode; 32 | unsigned decomp_offset; 33 | 34 | //read() will spool chunks half the size of decomp_buffer_size 35 | enum { decomp_buffer_size = SPC7110_DECOMP_BUFFER_SIZE }; //must be >= 64, and must be a power of two 36 | uint8 *decomp_buffer; 37 | unsigned decomp_buffer_rdoffset; 38 | unsigned decomp_buffer_wroffset; 39 | unsigned decomp_buffer_length; 40 | 41 | void write(uint8 data); 42 | uint8 dataread(); 43 | 44 | void mode0(bool init); 45 | void mode1(bool init); 46 | void mode2(bool init); 47 | 48 | static const uint8 evolution_table[53][4]; 49 | static const uint8 mode2_context_table[32][2]; 50 | 51 | struct ContextState { 52 | uint8 index; 53 | uint8 invert; 54 | } context[32]; 55 | 56 | uint8 probability(unsigned n); 57 | uint8 next_lps(unsigned n); 58 | uint8 next_mps(unsigned n); 59 | bool toggle_invert(unsigned n); 60 | 61 | unsigned morton16[2][256]; 62 | unsigned morton32[4][256]; 63 | unsigned morton_2x8(unsigned data); 64 | unsigned morton_4x8(unsigned data); 65 | }; 66 | 67 | #endif 68 | -------------------------------------------------------------------------------- /snes9x/spc7110emu.h: -------------------------------------------------------------------------------- 1 | /***** 2 | * SPC7110 emulator - version 0.03 (2008-08-10) 3 | * Copyright (c) 2008, byuu and neviksti 4 | * 5 | * Permission to use, copy, modify, and/or distribute this software for any 6 | * purpose with or without fee is hereby granted, provided that the above 7 | * copyright notice and this permission notice appear in all copies. 8 | * 9 | * The software is provided "as is" and the author disclaims all warranties 10 | * with regard to this software including all implied warranties of 11 | * merchantibility and fitness, in no event shall the author be liable for 12 | * any special, direct, indirect, or consequential damages or any damages 13 | * whatsoever resulting from loss of use, data or profits, whether in an 14 | * action of contract, negligence or other tortious action, arising out of 15 | * or in connection with the use or performance of this software. 16 | *****/ 17 | 18 | 19 | #ifndef _SPC7110EMU_H_ 20 | #define _SPC7110EMU_H_ 21 | 22 | #include "spc7110dec.h" 23 | 24 | class SPC7110 { 25 | public: 26 | void init(); 27 | void enable(); 28 | void power(); 29 | void reset(); 30 | 31 | unsigned datarom_addr(unsigned addr); 32 | 33 | unsigned data_pointer(); 34 | unsigned data_adjust(); 35 | unsigned data_increment(); 36 | void set_data_pointer(unsigned addr); 37 | void set_data_adjust(unsigned addr); 38 | 39 | void update_time(int offset = 0); 40 | time_t create_time(); 41 | 42 | uint8 mmio_read (unsigned addr); 43 | void mmio_write(unsigned addr, uint8 data); 44 | 45 | uint8 read (unsigned addr); 46 | void write(unsigned addr, uint8 data); 47 | 48 | //spc7110decomp 49 | void decomp_init(); 50 | uint8 decomp_read(); 51 | 52 | SPC7110(); 53 | 54 | //================== 55 | //decompression unit 56 | //================== 57 | uint8 r4801; //compression table low 58 | uint8 r4802; //compression table high 59 | uint8 r4803; //compression table bank 60 | uint8 r4804; //compression table index 61 | uint8 r4805; //decompression buffer index low 62 | uint8 r4806; //decompression buffer index high 63 | uint8 r4807; //??? 64 | uint8 r4808; //??? 65 | uint8 r4809; //compression length low 66 | uint8 r480a; //compression length high 67 | uint8 r480b; //decompression control register 68 | uint8 r480c; //decompression status 69 | 70 | SPC7110Decomp decomp; 71 | 72 | //============== 73 | //data port unit 74 | //============== 75 | uint8 r4811; //data pointer low 76 | uint8 r4812; //data pointer high 77 | uint8 r4813; //data pointer bank 78 | uint8 r4814; //data adjust low 79 | uint8 r4815; //data adjust high 80 | uint8 r4816; //data increment low 81 | uint8 r4817; //data increment high 82 | uint8 r4818; //data port control register 83 | 84 | uint8 r481x; 85 | 86 | bool r4814_latch; 87 | bool r4815_latch; 88 | 89 | //========= 90 | //math unit 91 | //========= 92 | uint8 r4820; //16-bit multiplicand B0, 32-bit dividend B0 93 | uint8 r4821; //16-bit multiplicand B1, 32-bit dividend B1 94 | uint8 r4822; //32-bit dividend B2 95 | uint8 r4823; //32-bit dividend B3 96 | uint8 r4824; //16-bit multiplier B0 97 | uint8 r4825; //16-bit multiplier B1 98 | uint8 r4826; //16-bit divisor B0 99 | uint8 r4827; //16-bit divisor B1 100 | uint8 r4828; //32-bit product B0, 32-bit quotient B0 101 | uint8 r4829; //32-bit product B1, 32-bit quotient B1 102 | uint8 r482a; //32-bit product B2, 32-bit quotient B2 103 | uint8 r482b; //32-bit product B3, 32-bit quotient B3 104 | uint8 r482c; //16-bit remainder B0 105 | uint8 r482d; //16-bit remainder B1 106 | uint8 r482e; //math control register 107 | uint8 r482f; //math status 108 | 109 | //=================== 110 | //memory mapping unit 111 | //=================== 112 | uint8 r4830; //SRAM write enable 113 | uint8 r4831; //$[d0-df]:[0000-ffff] mapping 114 | uint8 r4832; //$[e0-ef]:[0000-ffff] mapping 115 | uint8 r4833; //$[f0-ff]:[0000-ffff] mapping 116 | uint8 r4834; //??? 117 | 118 | unsigned dx_offset; 119 | unsigned ex_offset; 120 | unsigned fx_offset; 121 | 122 | //==================== 123 | //real-time clock unit 124 | //==================== 125 | uint8 r4840; //RTC latch 126 | uint8 r4841; //RTC index/data port 127 | uint8 r4842; //RTC status 128 | 129 | enum RTC_State { RTCS_Inactive, RTCS_ModeSelect, RTCS_IndexSelect, RTCS_Write } rtc_state; 130 | enum RTC_Mode { RTCM_Linear = 0x03, RTCM_Indexed = 0x0c } rtc_mode; 131 | unsigned rtc_index; 132 | 133 | static const unsigned months[12]; 134 | }; 135 | 136 | #endif 137 | -------------------------------------------------------------------------------- /snes9x/srtcemu.h: -------------------------------------------------------------------------------- 1 | /***** 2 | * S-RTC emulation code 3 | * Copyright (c) byuu 4 | *****/ 5 | 6 | 7 | #ifndef _SRTCEMU_H_ 8 | #define _SRTCEMU_H_ 9 | 10 | class SRTC { 11 | public: 12 | void update_time(); 13 | unsigned weekday(unsigned year, unsigned month, unsigned day); 14 | 15 | void init(); 16 | void enable(); 17 | void power(); 18 | void reset(); 19 | 20 | uint8 mmio_read (unsigned addr); 21 | void mmio_write(unsigned addr, uint8 data); 22 | 23 | SRTC(); 24 | 25 | static const unsigned months[12]; 26 | enum RTC_Mode { RTCM_Ready, RTCM_Command, RTCM_Read, RTCM_Write } rtc_mode; 27 | signed rtc_index; 28 | }; 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /snes9x/unzip/crypt.h: -------------------------------------------------------------------------------- 1 | /* crypt.h -- base code for crypt/uncrypt ZIPfile 2 | 3 | 4 | Version 1.01h, December 28th, 2009 5 | 6 | Copyright (C) 1998-2009 Gilles Vollant 7 | 8 | This code is a modified version of crypting code in Infozip distribution 9 | 10 | The encryption/decryption parts of this source code (as opposed to the 11 | non-echoing password parts) were originally written in Europe. The 12 | whole source package can be freely distributed, including from the USA. 13 | (Prior to January 2000, re-export from the US was a violation of US law.) 14 | 15 | This encryption code is a direct transcription of the algorithm from 16 | Roger Schlafly, described by Phil Katz in the file appnote.txt. This 17 | file (appnote.txt) is distributed with the PKZIP program (even in the 18 | version without encryption capabilities). 19 | 20 | If you don't need crypting in your application, just define symbols 21 | NOCRYPT and NOUNCRYPT. 22 | 23 | This code support the "Traditional PKWARE Encryption". 24 | 25 | The new AES encryption added on Zip format by Winzip (see the page 26 | http://www.winzip.com/aes_info.htm ) and PKWare PKZip 5.x Strong 27 | Encryption is not supported. 28 | */ 29 | 30 | #define CRC32(c, b) ((*(pcrc_32_tab+(((int)(c) ^ (b)) & 0xff))) ^ ((c) >> 8)) 31 | 32 | /*********************************************************************** 33 | * Return the next byte in the pseudo-random sequence 34 | */ 35 | static int decrypt_byte(unsigned long* pkeys, const unsigned long* pcrc_32_tab) 36 | { 37 | unsigned temp; /* POTENTIAL BUG: temp*(temp^1) may overflow in an 38 | * unpredictable manner on 16-bit systems; not a problem 39 | * with any known compiler so far, though */ 40 | 41 | temp = ((unsigned)(*(pkeys+2)) & 0xffff) | 2; 42 | return (int)(((temp * (temp ^ 1)) >> 8) & 0xff); 43 | } 44 | 45 | /*********************************************************************** 46 | * Update the encryption keys with the next byte of plain text 47 | */ 48 | static int update_keys(unsigned long* pkeys,const unsigned long* pcrc_32_tab,int c) 49 | { 50 | (*(pkeys+0)) = CRC32((*(pkeys+0)), c); 51 | (*(pkeys+1)) += (*(pkeys+0)) & 0xff; 52 | (*(pkeys+1)) = (*(pkeys+1)) * 134775813L + 1; 53 | { 54 | register int keyshift = (int)((*(pkeys+1)) >> 24); 55 | (*(pkeys+2)) = CRC32((*(pkeys+2)), keyshift); 56 | } 57 | return c; 58 | } 59 | 60 | 61 | /*********************************************************************** 62 | * Initialize the encryption keys and the random header according to 63 | * the given password. 64 | */ 65 | static void init_keys(const char* passwd,unsigned long* pkeys,const unsigned long* pcrc_32_tab) 66 | { 67 | *(pkeys+0) = 305419896L; 68 | *(pkeys+1) = 591751049L; 69 | *(pkeys+2) = 878082192L; 70 | while (*passwd != '\0') { 71 | update_keys(pkeys,pcrc_32_tab,(int)*passwd); 72 | passwd++; 73 | } 74 | } 75 | 76 | #define zdecode(pkeys,pcrc_32_tab,c) \ 77 | (update_keys(pkeys,pcrc_32_tab,c ^= decrypt_byte(pkeys,pcrc_32_tab))) 78 | 79 | #define zencode(pkeys,pcrc_32_tab,c,t) \ 80 | (t=decrypt_byte(pkeys,pcrc_32_tab), update_keys(pkeys,pcrc_32_tab,c), t^(c)) 81 | 82 | #ifdef INCLUDECRYPTINGCODE_IFCRYPTALLOWED 83 | 84 | #define RAND_HEAD_LEN 12 85 | /* "last resort" source for second part of crypt seed pattern */ 86 | # ifndef ZCR_SEED2 87 | # define ZCR_SEED2 3141592654UL /* use PI as default pattern */ 88 | # endif 89 | 90 | static int crypthead(passwd, buf, bufSize, pkeys, pcrc_32_tab, crcForCrypting) 91 | const char *passwd; /* password string */ 92 | unsigned char *buf; /* where to write header */ 93 | int bufSize; 94 | unsigned long* pkeys; 95 | const unsigned long* pcrc_32_tab; 96 | unsigned long crcForCrypting; 97 | { 98 | int n; /* index in random header */ 99 | int t; /* temporary */ 100 | int c; /* random byte */ 101 | unsigned char header[RAND_HEAD_LEN-2]; /* random header */ 102 | static unsigned calls = 0; /* ensure different random header each time */ 103 | 104 | if (bufSize> 7) & 0xff; 119 | header[n] = (unsigned char)zencode(pkeys, pcrc_32_tab, c, t); 120 | } 121 | /* Encrypt random header (last two bytes is high word of crc) */ 122 | init_keys(passwd, pkeys, pcrc_32_tab); 123 | for (n = 0; n < RAND_HEAD_LEN-2; n++) 124 | { 125 | buf[n] = (unsigned char)zencode(pkeys, pcrc_32_tab, header[n], t); 126 | } 127 | buf[n++] = zencode(pkeys, pcrc_32_tab, (int)(crcForCrypting >> 16) & 0xff, t); 128 | buf[n++] = zencode(pkeys, pcrc_32_tab, (int)(crcForCrypting >> 24) & 0xff, t); 129 | return n; 130 | } 131 | 132 | #endif 133 | -------------------------------------------------------------------------------- /snes9x/unzip/ioapi.c: -------------------------------------------------------------------------------- 1 | /* ioapi.c -- IO base function header for compress/uncompress .zip 2 | files using zlib + zip or unzip API 3 | 4 | Version 1.01h, December 28th, 2009 5 | 6 | Copyright (C) 1998-2009 Gilles Vollant 7 | */ 8 | 9 | #include 10 | #include 11 | #include 12 | 13 | #include "zlib.h" 14 | #include "ioapi.h" 15 | 16 | 17 | 18 | /* I've found an old Unix (a SunOS 4.1.3_U1) without all SEEK_* defined.... */ 19 | 20 | #ifndef SEEK_CUR 21 | #define SEEK_CUR 1 22 | #endif 23 | 24 | #ifndef SEEK_END 25 | #define SEEK_END 2 26 | #endif 27 | 28 | #ifndef SEEK_SET 29 | #define SEEK_SET 0 30 | #endif 31 | 32 | voidpf ZCALLBACK fopen_file_func OF(( 33 | voidpf opaque, 34 | const char* filename, 35 | int mode)); 36 | 37 | uLong ZCALLBACK fread_file_func OF(( 38 | voidpf opaque, 39 | voidpf stream, 40 | void* buf, 41 | uLong size)); 42 | 43 | uLong ZCALLBACK fwrite_file_func OF(( 44 | voidpf opaque, 45 | voidpf stream, 46 | const void* buf, 47 | uLong size)); 48 | 49 | long ZCALLBACK ftell_file_func OF(( 50 | voidpf opaque, 51 | voidpf stream)); 52 | 53 | long ZCALLBACK fseek_file_func OF(( 54 | voidpf opaque, 55 | voidpf stream, 56 | uLong offset, 57 | int origin)); 58 | 59 | int ZCALLBACK fclose_file_func OF(( 60 | voidpf opaque, 61 | voidpf stream)); 62 | 63 | int ZCALLBACK ferror_file_func OF(( 64 | voidpf opaque, 65 | voidpf stream)); 66 | 67 | 68 | voidpf ZCALLBACK fopen_file_func (opaque, filename, mode) 69 | voidpf opaque; 70 | const char* filename; 71 | int mode; 72 | { 73 | FILE* file = NULL; 74 | const char* mode_fopen = NULL; 75 | if ((mode & ZLIB_FILEFUNC_MODE_READWRITEFILTER)==ZLIB_FILEFUNC_MODE_READ) 76 | mode_fopen = "rb"; 77 | else 78 | if (mode & ZLIB_FILEFUNC_MODE_EXISTING) 79 | mode_fopen = "r+b"; 80 | else 81 | if (mode & ZLIB_FILEFUNC_MODE_CREATE) 82 | mode_fopen = "wb"; 83 | 84 | if ((filename!=NULL) && (mode_fopen != NULL)) 85 | file = fopen(filename, mode_fopen); 86 | return file; 87 | } 88 | 89 | 90 | uLong ZCALLBACK fread_file_func (opaque, stream, buf, size) 91 | voidpf opaque; 92 | voidpf stream; 93 | void* buf; 94 | uLong size; 95 | { 96 | uLong ret; 97 | ret = (uLong)fread(buf, 1, (size_t)size, (FILE *)stream); 98 | return ret; 99 | } 100 | 101 | 102 | uLong ZCALLBACK fwrite_file_func (opaque, stream, buf, size) 103 | voidpf opaque; 104 | voidpf stream; 105 | const void* buf; 106 | uLong size; 107 | { 108 | uLong ret; 109 | ret = (uLong)fwrite(buf, 1, (size_t)size, (FILE *)stream); 110 | return ret; 111 | } 112 | 113 | long ZCALLBACK ftell_file_func (opaque, stream) 114 | voidpf opaque; 115 | voidpf stream; 116 | { 117 | long ret; 118 | ret = ftell((FILE *)stream); 119 | return ret; 120 | } 121 | 122 | long ZCALLBACK fseek_file_func (opaque, stream, offset, origin) 123 | voidpf opaque; 124 | voidpf stream; 125 | uLong offset; 126 | int origin; 127 | { 128 | int fseek_origin=0; 129 | long ret; 130 | switch (origin) 131 | { 132 | case ZLIB_FILEFUNC_SEEK_CUR : 133 | fseek_origin = SEEK_CUR; 134 | break; 135 | case ZLIB_FILEFUNC_SEEK_END : 136 | fseek_origin = SEEK_END; 137 | break; 138 | case ZLIB_FILEFUNC_SEEK_SET : 139 | fseek_origin = SEEK_SET; 140 | break; 141 | default: return -1; 142 | } 143 | ret = 0; 144 | if (fseek((FILE *)stream, offset, fseek_origin) != 0) 145 | ret = -1; 146 | return ret; 147 | } 148 | 149 | int ZCALLBACK fclose_file_func (opaque, stream) 150 | voidpf opaque; 151 | voidpf stream; 152 | { 153 | int ret; 154 | ret = fclose((FILE *)stream); 155 | return ret; 156 | } 157 | 158 | int ZCALLBACK ferror_file_func (opaque, stream) 159 | voidpf opaque; 160 | voidpf stream; 161 | { 162 | int ret; 163 | ret = ferror((FILE *)stream); 164 | return ret; 165 | } 166 | 167 | void fill_fopen_filefunc (pzlib_filefunc_def) 168 | zlib_filefunc_def* pzlib_filefunc_def; 169 | { 170 | pzlib_filefunc_def->zopen_file = fopen_file_func; 171 | pzlib_filefunc_def->zread_file = fread_file_func; 172 | pzlib_filefunc_def->zwrite_file = fwrite_file_func; 173 | pzlib_filefunc_def->ztell_file = ftell_file_func; 174 | pzlib_filefunc_def->zseek_file = fseek_file_func; 175 | pzlib_filefunc_def->zclose_file = fclose_file_func; 176 | pzlib_filefunc_def->zerror_file = ferror_file_func; 177 | pzlib_filefunc_def->opaque = NULL; 178 | } 179 | -------------------------------------------------------------------------------- /snes9x/unzip/ioapi.h: -------------------------------------------------------------------------------- 1 | /* ioapi.h -- IO base function header for compress/uncompress .zip 2 | files using zlib + zip or unzip API 3 | 4 | Version 1.01h, December 28th, 2009 5 | 6 | Copyright (C) 1998-2009 Gilles Vollant 7 | */ 8 | 9 | #ifndef _ZLIBIOAPI_H 10 | #define _ZLIBIOAPI_H 11 | 12 | 13 | #define ZLIB_FILEFUNC_SEEK_CUR (1) 14 | #define ZLIB_FILEFUNC_SEEK_END (2) 15 | #define ZLIB_FILEFUNC_SEEK_SET (0) 16 | 17 | #define ZLIB_FILEFUNC_MODE_READ (1) 18 | #define ZLIB_FILEFUNC_MODE_WRITE (2) 19 | #define ZLIB_FILEFUNC_MODE_READWRITEFILTER (3) 20 | 21 | #define ZLIB_FILEFUNC_MODE_EXISTING (4) 22 | #define ZLIB_FILEFUNC_MODE_CREATE (8) 23 | 24 | 25 | #ifndef ZCALLBACK 26 | 27 | #if (defined(WIN32) || defined (WINDOWS) || defined (_WINDOWS)) && defined(CALLBACK) && defined (USEWINDOWS_CALLBACK) 28 | #define ZCALLBACK CALLBACK 29 | #else 30 | #define ZCALLBACK 31 | #endif 32 | #endif 33 | 34 | #ifdef __cplusplus 35 | extern "C" { 36 | #endif 37 | 38 | typedef voidpf (ZCALLBACK *open_file_func) OF((voidpf opaque, const char* filename, int mode)); 39 | typedef uLong (ZCALLBACK *read_file_func) OF((voidpf opaque, voidpf stream, void* buf, uLong size)); 40 | typedef uLong (ZCALLBACK *write_file_func) OF((voidpf opaque, voidpf stream, const void* buf, uLong size)); 41 | typedef long (ZCALLBACK *tell_file_func) OF((voidpf opaque, voidpf stream)); 42 | typedef long (ZCALLBACK *seek_file_func) OF((voidpf opaque, voidpf stream, uLong offset, int origin)); 43 | typedef int (ZCALLBACK *close_file_func) OF((voidpf opaque, voidpf stream)); 44 | typedef int (ZCALLBACK *testerror_file_func) OF((voidpf opaque, voidpf stream)); 45 | 46 | typedef struct zlib_filefunc_def_s 47 | { 48 | open_file_func zopen_file; 49 | read_file_func zread_file; 50 | write_file_func zwrite_file; 51 | tell_file_func ztell_file; 52 | seek_file_func zseek_file; 53 | close_file_func zclose_file; 54 | testerror_file_func zerror_file; 55 | voidpf opaque; 56 | } zlib_filefunc_def; 57 | 58 | 59 | 60 | void fill_fopen_filefunc OF((zlib_filefunc_def* pzlib_filefunc_def)); 61 | 62 | #define ZREAD(filefunc,filestream,buf,size) ((*((filefunc).zread_file))((filefunc).opaque,filestream,buf,size)) 63 | #define ZWRITE(filefunc,filestream,buf,size) ((*((filefunc).zwrite_file))((filefunc).opaque,filestream,buf,size)) 64 | #define ZTELL(filefunc,filestream) ((*((filefunc).ztell_file))((filefunc).opaque,filestream)) 65 | #define ZSEEK(filefunc,filestream,pos,mode) ((*((filefunc).zseek_file))((filefunc).opaque,filestream,pos,mode)) 66 | #define ZCLOSE(filefunc,filestream) ((*((filefunc).zclose_file))((filefunc).opaque,filestream)) 67 | #define ZERROR(filefunc,filestream) ((*((filefunc).zerror_file))((filefunc).opaque,filestream)) 68 | 69 | 70 | #ifdef __cplusplus 71 | } 72 | #endif 73 | 74 | #endif 75 | 76 | -------------------------------------------------------------------------------- /snes9x/unzip/iowin32.h: -------------------------------------------------------------------------------- 1 | /* iowin32.h -- IO base function header for compress/uncompress .zip 2 | files using zlib + zip or unzip API 3 | This IO API version uses the Win32 API (for Microsoft Windows) 4 | 5 | Version 1.01h, December 28th, 2009 6 | 7 | Copyright (C) 1998-2009 Gilles Vollant 8 | */ 9 | 10 | #include 11 | 12 | 13 | #ifdef __cplusplus 14 | extern "C" { 15 | #endif 16 | 17 | void fill_win32_filefunc OF((zlib_filefunc_def* pzlib_filefunc_def)); 18 | 19 | #ifdef __cplusplus 20 | } 21 | #endif 22 | -------------------------------------------------------------------------------- /snes9x/unzip/mztools.h: -------------------------------------------------------------------------------- 1 | /* 2 | Additional tools for Minizip 3 | Code: Xavier Roche '2004 4 | License: Same as ZLIB (www.gzip.org) 5 | */ 6 | 7 | #ifndef _zip_tools_H 8 | #define _zip_tools_H 9 | 10 | #ifdef __cplusplus 11 | extern "C" { 12 | #endif 13 | 14 | #ifndef _ZLIB_H 15 | #include "zlib.h" 16 | #endif 17 | 18 | #include "unzip.h" 19 | 20 | /* Repair a ZIP file (missing central directory) 21 | file: file to recover 22 | fileOut: output file after recovery 23 | fileOutTmp: temporary file name used for recovery 24 | */ 25 | extern int ZEXPORT unzRepair(const char* file, 26 | const char* fileOut, 27 | const char* fileOutTmp, 28 | uLong* nRecovered, 29 | uLong* bytesRecovered); 30 | 31 | #endif 32 | --------------------------------------------------------------------------------