📄 zsnes.asm
字号:
; Snes9x - Portable Super Nintendo Entertainment System (TM) emulator.;; Super FX assembler emulator code; (c) Copyright 1998, 1999 zsKnight and _Demo_.;; Permission to use, copy, modify and distribute Snes9x in both binary and; source form, for non-commercial purposes, is hereby granted without fee,; providing that this license information and copyright notice appear with; all copies and any derived work.;; This software is provided 'as-is', without any express or implied; warranty. In no event shall the authors be held liable for any damages; arising from the use of this software.;; Snes9x is freeware for PERSONAL USE only. Commercial users should; seek permission of the copyright holders first. Commercial use includes; charging money for Snes9x or software derived from Snes9x.;; The copyright holders request that bug fixes and improvements to the code; should be forwarded to them so everyone can benefit from the modifications; in future versions.;; Super NES and Super Nintendo Entertainment System are trademarks of; Nintendo Co., Limited and its subsidiary companies.;; ZSNES SuperFX emulation code and wrappers; (C) Copyright 1997-8 zsKnight and _Demo_; Used with the kind permission of the copyright holders.;%include "i386/macros.mac"EXTSYM SfxR1,SfxR2,InitFxTables,SfxSFR,SfxSCMR,initsfxregsw,initsfxregsrEXTSYM SfxPBR,SfxSCMR,NumberOfOpcodes,SfxCLSR,MainLoop,SfxCROMEXTSYM SfxRomBuffer,SfxRAMMem,SfxLastRamAdr,SfxR0EXTSYM PHnum2writesfxreg, SfxCPB, SfxROMBR, SfxRAMBR, SfxnRamBanks[BITS 32]SECTION .dataNEWSYM flagnz, dd 0NEWSYM romdata, dd 0 ; rom data (4MB = 4194304)NEWSYM regptr, dd 0 ; pointer to registersNEWSYM regptw, dd 0 ; pointer to registersNEWSYM regptra, times 49152 db 0NEWSYM regptwa, times 49152 db 0NEWSYM debstop, db 0NEWSYM sfxramdata, dd 0 ; SuperFX Ram DataNEWSYM sfxplottable, dd 0NEWSYM FxTable, times 256 dd 0NEWSYM FxTableA1, times 256 dd 0NEWSYM FxTableA2, times 256 dd 0NEWSYM FxTableA3, times 256 dd 0NEWSYM FxTableb, times 256 dd 0NEWSYM FxTablebA1, times 256 dd 0NEWSYM FxTablebA2, times 256 dd 0NEWSYM FxTablebA3, times 256 dd 0NEWSYM FxTablec, times 256 dd 0NEWSYM FxTablecA1, times 256 dd 0NEWSYM FxTablecA2, times 256 dd 0NEWSYM FxTablecA3, times 256 dd 0NEWSYM FxTabled, times 256 dd 0NEWSYM FxTabledA1, times 256 dd 0NEWSYM FxTabledA2, times 256 dd 0NEWSYM FxTabledA3, times 256 dd 0NEWSYM SfxMemTable, times 256 dd 0NEWSYM fxxand, times 256 dd 0NEWSYM fxbit01, times 256 dd 0NEWSYM fxbit23, times 256 dd 0NEWSYM fxbit45, times 256 dd 0NEWSYM fxbit67, times 256 dd 0NEWSYM PLOTJmpa, times 64 dd 0NEWSYM PLOTJmpb, times 64 dd 0;%INCLUDE "i386/fxtable.asm";%INCLUDE "i386/sfxproc.asm";%INCLUDE "i386/fxemu2.asm";%INCLUDE "i386/fxemu2b.asm";%INCLUDE "i386/fxemu2c.asm";; Snes9x wrapper functions for the zsnes SuperFX code; (C) Copyright 1998 Gary HendersonSECTION .data%ifdef __DJGPP__%define SRAM _SRAM%define ROM _ROM%define RegRAM _RegRAM%define S9xResetSuperFX _S9xResetSuperFX%define S9xSuperFXWriteReg _S9xSuperFXWriteReg%define S9xSuperFXReadReg _S9xSuperFXReadReg%define S9xSuperFXExec _S9xSuperFXExec%define S9xSuperFXPreSaveState _S9xSuperFXPreSaveState%define S9xSuperFXPostSaveState _S9xSuperFXPostSaveState%define S9xSuperFXPostLoadState _S9xSuperFXPostLoadState%define SFXPlotTable _SFXPlotTable%define WinterGold _WinterGold%endifEXTERN SRAMEXTERN ROMEXTERN RegRAMEXTERN SFXPlotTableEXTERN WinterGoldSECTION .textGLOBAL S9xResetSuperFXGLOBAL S9xSuperFXWriteRegGLOBAL S9xSuperFXReadRegGLOBAL S9xSuperFXExecGLOBAL S9xSuperFXPreSaveStateGLOBAL S9xSuperFXPostSaveStateGLOBAL S9xSuperFXPostLoadStateGLOBAL StartSFXStartSFX:StartSFXret: jmp S9xSuperFXExecS9xResetSuperFX: push ebx push esi push edi push ebp mov dword[SfxR1],0 mov dword[SfxR2],0 mov eax,dword[SRAM] mov dword[sfxramdata],eax mov eax,dword[ROM] mov dword[romdata],eax mov eax,dword[SFXPlotTable] mov dword[sfxplottable],eax call InitFxTables mov dword[SfxSFR],0 mov byte[SfxSCMR],0 mov dword[regptr],regptra sub dword[regptr],8000h ; Since register address starts @ 2000h mov dword[regptw],regptwa sub dword[regptw],8000h ; Since register address starts @ 2000h call initsfxregsw call initsfxregsr pop ebp pop edi pop esi pop ebx retS9xSuperFXWriteReg: mov eax,dword[esp+4] mov ecx,dword[esp+8] push ebx push esi push edi push ebp test dword[regptwa+ecx*4-8000h], ~0 jz .skipwrite call dword[regptwa+ecx*4-8000h].skipwrite: pop ebp pop edi pop esi pop ebx retS9xSuperFXReadReg: mov ecx,dword[esp+4] push ebx push esi push edi push ebp test dword[regptra+ecx*4-8000h], ~0 jz .skipread call dword[regptra+ecx*4-8000h].skipread: pop ebp pop edi pop esi pop ebx and eax, 255endfx: retEXTSYM SfxPBR,SCBRrel,SfxSCBR,SfxCOLR,SfxPOREXTSYM sfx128lineloc,sfx160lineloc,sfx192lineloc,sfxobjlineloc,sfxclinelocEXTSYM fxbit01pcal,fxbit23pcal,fxbit45pcal,fxbit67pcalS9xSuperFXExec: test byte[SfxSFR],20h jz endfx push ebx push esi push edi push ebp test byte[SfxPOR],10h jnz .objmode mov al,[SfxSCMR] and al,00100100b ; 4 + 32 cmp al,4 je .lines160 cmp al,32 je .lines192 cmp al,36 je .objmode mov eax,[sfx128lineloc] jmp .donelines.lines160 mov eax,[sfx160lineloc] jmp .donelines.lines192 mov eax,[sfx192lineloc] jmp .donelines.objmode mov eax,[sfxobjlineloc].donelines mov [sfxclineloc],eax mov al,[SfxSCMR] and eax,00000011b mov bl,[SfxPOR] and bl,0Fh shl bl,2 or al,bl mov ebx,[PLOTJmpb+eax*4] mov eax,[PLOTJmpa+eax*4] mov dword [FxTable+4Ch*4],eax mov dword [FxTableb+4Ch*4],eax mov dword [FxTablec+4Ch*4],eax mov dword [FxTabled+4Ch*4],ebx mov ebx,[SfxSCBR] shl ebx,10 add ebx,[sfxramdata] mov [SCBRrel],ebx mov eax,[SfxCOLR] mov ebx,[fxbit01+eax*4] mov [fxbit01pcal],ebx mov ebx,[fxbit23+eax*4] mov [fxbit23pcal],ebx mov ebx,[fxbit45+eax*4] mov [fxbit45pcal],ebx mov ebx,[fxbit67+eax*4] mov [fxbit67pcal],ebx xor ebx,ebx;EXTSYM PLOTJmpa,PLOTJmpb,FxTable,FxTableb,FxTablec,FxTabled mov bl,[SfxPBR] mov al,[SfxSCMR] and bl,7Fh cmp bl,70h jae .ram test al,10h jz .noaccess jmp .noram.ram test al,08h jz .noaccess.noram mov dword [NumberOfOpcodes],350 ; 0FFFFFFFh;350 test byte[SfxCLSR],01h jz .nohighsfx mov dword [NumberOfOpcodes],700 ;700.nohighsfx cmp byte[WinterGold],0 jne .wintergold; XXX: HERE mov dword [NumberOfOpcodes],0FFFFFFFh.wintergold call MainLoop.noaccess pop ebp pop edi pop esi pop edx retS9xSuperFXPreSaveState: mov ecx,dword[SfxCROM] sub dword[SfxRomBuffer],ecx mov ecx,dword[SfxRAMMem] sub dword[SfxLastRamAdr],ecx; Copy num2writesfxreg bytes from SfxR0 to a free area in RegRAM. push ebx mov ecx,SfxR0 mov edx,dword[RegRAM] add edx,7000h mov ebx,[PHnum2writesfxreg].loop mov al,[ecx] mov [edx],al inc ecx inc edx dec ebx jnz .loop pop ebx mov ecx,dword[SfxCROM] add dword[SfxRomBuffer],ecx mov ecx,dword[SfxRAMMem] add dword[SfxLastRamAdr],ecx retS9xSuperFXPostSaveState: retS9xSuperFXPostLoadState:; Copy num2writesfxreg bytes from a free area in RegRAM to SfxR0 push ebx mov ecx,SfxR0 mov edx,dword[RegRAM] add edx,7000h mov ebx,[PHnum2writesfxreg].loop mov al,[edx] mov [ecx],al inc ecx inc edx dec ebx jnz .loop pop ebx xor ecx,ecx mov cl,byte[SfxPBR] mov ecx,dword[SfxMemTable+ecx*4] mov dword[SfxCPB],ecx xor ecx,ecx mov cl,byte[SfxROMBR] mov ecx,dword[SfxMemTable+ecx*4] mov dword[SfxCROM],ecx xor ecx,ecx mov cl,byte[SfxRAMBR] shl ecx,16 add ecx,dword[sfxramdata] mov dword [SfxRAMMem],ecx mov ecx,dword[SfxCROM] add dword[SfxRomBuffer],ecx mov ecx,dword[SfxRAMMem] add dword[SfxLastRamAdr],ecx; Fix for mystery zeroing of SfxnRamBanks, allowing junk RAMBR values to be; set in turn causing a crash when the code tries to access the junk RAM bank. mov dword [SfxnRamBanks], 4 ret
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -