From 910ae02506458af9b3a83fa893b7b4a56a0055af Mon Sep 17 00:00:00 2001 From: pagefault <> Date: Sun, 28 Dec 2003 22:31:17 +0000 Subject: [PATCH] SETA ST010 Support (Thanks The Dumper!) --- zsnes/src/chips/st10proc.asm | 128 +++++++++++++++++++++++++++++++++++ zsnes/src/cpu/execute.asm | 44 +++++++++++- zsnes/src/gui/gui.asm | 30 +++++++- zsnes/src/init.asm | 48 ++++++++++++- zsnes/src/ui.asm | 2 + 5 files changed, 249 insertions(+), 3 deletions(-) create mode 100644 zsnes/src/chips/st10proc.asm diff --git a/zsnes/src/chips/st10proc.asm b/zsnes/src/chips/st10proc.asm new file mode 100644 index 00000000..a3fc8727 --- /dev/null +++ b/zsnes/src/chips/st10proc.asm @@ -0,0 +1,128 @@ +;Copyright (C) 2003 ZSNES Team ( zsknight@zsnes.com / _demo_@zsnes.com ) +; +;This program is free software; you can redistribute it and/or +;modify it under the terms of the GNU General Public License +;as published by the Free Software Foundation; either +;version 2 of the License, or (at your option) any later +;version. +; +;This program is distributed in the hope that it will be useful, +;but WITHOUT ANY WARRANTY; without even the implied warranty of +;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;GNU General Public License for more details. +; +;You should have received a copy of the GNU General Public License +;along with this program; if not, write to the Free Software +;Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +%include "macros.mac" + +NEWSYM SetaCmdEnable, dd 0 ; Seta ST010/ST011 command enable register. Maybe also status. +EXTSYM setaramdata +;; EXTSYM ST010DoCommand ; coming soon + +;; TODO - should return ROM for > 8000h +NEWSYM setaaccessbankr8 + mov ebx,[setaramdata] + and ecx,0fffh + mov al,[ebx+ecx] + xor ebx,ebx + ret + +NEWSYM setaaccessbankw8 + test ecx,8000h + jnz .nosetenablew8 ; ignore ROM writes + and ecx,0fffh + mov ebx,[setaramdata] + mov [ebx+ecx],al + cmp byte [ebx+021h], 80h + jnz .nosetenablew8 + pushad +;; call ST010DoCommand + popad +.nosetenablew8 + xor ebx,ebx + ret + +;; We ignore the case where it wraps into ROM reads - should never happen +NEWSYM setaaccessbankr16 + mov ebx,[setaramdata] + and ecx,0fffh + mov ax,[ebx+ecx] + xor ebx,ebx + ret + +NEWSYM setaaccessbankw16 + test ecx,8000h + jnz .nosetenablew16 ; ignore ROM writes + cmp ecx,7fffh + jne .noromw16 + mov [setaramdata+0fffh],al ; only write ram part in, not rom part + jmp short .nosetenablew16 +.noromw16 + and ecx,0fffh + mov ebx,[setaramdata] + cmp ecx,0fffh + jne .nowrapw16 + mov [ebx+ecx],al + xchg ah,al + mov [ebx],al + jmp short .nosetenablew16 +.nowrapw16 + mov word [ebx+ecx],ax + cmp byte [ebx+021h], 80h + jnz .nosetenablew16 + pushad +;; call ST010DoCommand + popad +.nosetenablew16 + xor ebx,ebx + ret + + +NEWSYM setaaccessbankr8a + xor al,al + cmp ecx,4000h + jae .nosetenabler8a + and ecx, 3 + mov al,[SetaCmdEnable+ecx] +.nosetenabler8a + xor ebx,ebx + ret + +NEWSYM setaaccessbankw8a + cmp ecx,4000h + jae .nosetenablew8a + and ecx, 03h + mov [SetaCmdEnable+ecx],al +.nosetenablew8a + xor ebx,ebx + ret + +NEWSYM setaaccessbankr16a + xor ax,ax + cmp ecx,4000h + jae .nosetenabler16a + and ecx,3 + mov al,[SetaCmdEnable+ecx] + xchg ah,al + inc ecx + and ecx,3 + mov al,[SetaCmdEnable+ecx] +.nosetenabler16a + xor ebx,ebx + ret + +NEWSYM setaaccessbankw16a + cmp ecx,4000h + jae .nosetenablew16a + mov ebx,[setaramdata] + and ecx,3 + mov [ebx+ecx],al + xchg ah,al + inc ecx + and ecx,3 + mov [ebx+ecx],al +.nosetenablew16a + xor ebx,ebx + ret diff --git a/zsnes/src/cpu/execute.asm b/zsnes/src/cpu/execute.asm index 419e36a3..9db0b711 100644 --- a/zsnes/src/cpu/execute.asm +++ b/zsnes/src/cpu/execute.asm @@ -50,7 +50,7 @@ EXTSYM nextmenupopup EXTSYM MovieProcessing EXTSYM MovieFileHand, PrintStr EXTSYM OSExit,DosExit,InitDir,InitDrive,createnewcfg,fnames,gotoroot,previdmode -EXTSYM ramsize,sfxramdata,sram,SRAMDrive,SRAMDir,welcome +EXTSYM ramsize,sfxramdata,setaramdata,SETAEnable,sram,SRAMDrive,SRAMDir,welcome ; EXTSYM tempstore EXTSYM printhex %ifdef __MSDOS__ @@ -599,6 +599,11 @@ NEWSYM BackupCVFrame BackupCVMacB prevoamptr,1 BackupCVMac ReadHead,1 + cmp byte[SETAEnable],1 + jne .noseta + BackupCVMacM [setaramdata],256 +.noseta + mov edx,[sram] mov ecx,[ramsize] shr ecx,4 @@ -694,6 +699,11 @@ NEWSYM RestoreCVFrame BackupCVRMacB prevoamptr,1 BackupCVRMac ReadHead,1 + cmp byte[SETAEnable],1 + jne .noseta + BackupCVRMacM [setaramdata],256 +.noseta + mov edx,[sram] mov ecx,[ramsize] shr ecx,4 @@ -1393,6 +1403,19 @@ NEWSYM endprog call Write_File call Close_File .nosfxsram + + cmp byte[SETAEnable],0 + je .nosetasram + mov edx,fnames+1 + call Create_File + jc .nosetasram + mov bx,ax + mov ecx,4096 + mov edx,[setaramdata] + call Write_File + call Close_File +.nosetasram + cmp byte[SA1Enable],1 jne .nosa1 mov edx,fnames+1 @@ -1654,6 +1677,14 @@ NEWSYM statesaver mov ecx,[SfxRAMMem] add [SfxLastRamAdr],ecx .nosfx + + cmp byte[SETAEnable],1 + jne .noseta + mov ecx,4096 + mov edx,[setaramdata] + call Write_File +.noseta + cmp byte[SPC7110Enable],1 jne .nospc7110 mov edx,[romdata] @@ -1686,6 +1717,7 @@ NEWSYM statesaver mov edx,PrevPicture call Write_File .nocapturepicture + call Close_File add dword[Curtableaddr],tableA add dword[spcPCRam],spcRam @@ -1852,6 +1884,15 @@ NEWSYM stateloader .nosfx + cmp byte[SETAEnable],1 + jne near .noseta + mov ecx,4096 + add dword[Totalbyteloaded],ecx + mov edx,[setaramdata] + call Read_File + ; TODO: load the SetaCmdEnable? For completeness we should do it but currently we ignore it anyway. +.noseta + cmp byte[C4Enable],1 jne .noc4 mov ecx,2000h @@ -1889,6 +1930,7 @@ NEWSYM stateloader jne .nosdd1 call UpdateBanksSDD1 .nosdd1 + call Close_File call repackfunct mov dword[spcnumread],0 diff --git a/zsnes/src/gui/gui.asm b/zsnes/src/gui/gui.asm index 7807d77c..ea3ec242 100644 --- a/zsnes/src/gui/gui.asm +++ b/zsnes/src/gui/gui.asm @@ -77,7 +77,7 @@ EXTSYM Voice0Status, Voice1Status, Voice2Status, Voice3Status, Voice4Status EXTSYM Voice5Status, Voice6Status, Voice7Status, romtype, SetIRQVectors EXTSYM ClearScreen, statesaver, loadstate2, vidbuffer, ASCII2Font, hirestiledat EXTSYM showallext, ROMTypeNOTFound, scanlines,statefileloc,pl1selk,pl2selk -EXTSYM fnamest,sprlefttot,spritetablea,fnames,SFXSRAM,sfxramdata,cgram,srama +EXTSYM fnamest,sprlefttot,spritetablea,fnames,SFXSRAM,sfxramdata,setaramdata,SETAEnable,cgram,srama EXTSYM tempco0,prevbright,maxbr,prevpal,coladdr,coladdg,coladdb EXTSYM scaddtype,ScreenScale,vesa2red10,initvideo2,initvideo,pressed,UpdateDevices EXTSYM memtabler8,memtablew8,writeon,pl1contrl,pl2contrl,JoyRead,SetInputDevice @@ -800,6 +800,18 @@ clearsram: dec ecx jnz .loop2 .nosfxsram + + cmp byte[SETAEnable],0 + je .nosetasram + mov eax,[setaramdata] + mov ecx,4096 +.loop2seta + mov byte[eax],0FFh + inc eax + dec ecx + jnz .loop2seta +.nosetasram + cmp byte[SA1Enable],1 jne .nosa1 mov eax,[SA1RAMArea] @@ -1769,6 +1781,22 @@ NEWSYM StartGUI .nosfxramwrite stim .nosfxsram + + cmp byte[SETAEnable],0 + je .nosetasram + clim + mov edx,fnames+1 + call Create_File + jc .nosetaramwrite + mov bx,ax + mov ecx,4096 + mov edx,[setaramdata] + call Write_File + call Close_File +.nosetaramwrite + stim +.nosetasram + call GUIQuickLoadUpdate call LoadDetermine ; change dir to LoadDrive/LoadDir diff --git a/zsnes/src/init.asm b/zsnes/src/init.asm index a475e148..62582d81 100644 --- a/zsnes/src/init.asm +++ b/zsnes/src/init.asm @@ -123,6 +123,10 @@ EXTSYM CalcChecksum EXTSYM BankCheck EXTSYM MirrorROM +EXTSYM SetaCmdEnable,setaramdata +EXTSYM setaaccessbankr8,setaaccessbankw8,setaaccessbankr8a,setaaccessbankw8a +EXTSYM setaaccessbankr16,setaaccessbankw16,setaaccessbankr16a,setaaccessbankw16a + %ifdef __LINUX__ EXTSYM LoadDir, popdir, pushdir %endif @@ -4487,7 +4491,7 @@ NEWSYM CheckROMType cmp ax,0F630h jne .notSETAB mov byte[SETAEnable],1 - mov byte[CHIPSRAM],1 ;Check later if this should be removed +;; mov byte[CHIPSRAM],1 ;Check later if this should be removed jmp .endchpdtct .notSETAB ;Super FX has SRAM, but only a battery to save it on the latter two @@ -4738,6 +4742,48 @@ NEWSYM CheckROMType .nosramsfx call InitFxTables .nosfx + + + + ;Setup Seta ST010 / ST011 stuff + cmp byte[SETAEnable],1 + jne near .noseta + ; Really banks 68h-6Fh:0000-7FFF are all mapped the same by the chip but F1ROCII only uses bank 68h + mov dword[memtabler8+68h*4],setaaccessbankr8 + mov dword[memtablew8+68h*4],setaaccessbankw8 + mov dword[memtabler16+68h*4],setaaccessbankr16 + mov dword[memtablew16+68h*4],setaaccessbankw16 + + ; Control register (and some status?) is in banks 60h-67h:0000-3FFF + mov dword[memtabler8+60h*4],setaaccessbankr8a + mov dword[memtablew8+60h*4],setaaccessbankw8a + mov dword[memtabler16+60h*4],setaaccessbankr16a + mov dword[memtablew16+60h*4],setaaccessbankw16a + + mov dword[SetaCmdEnable],00000080h ; 60:0000 + mov esi,[setaramdata] + mov ecx,1024 ; 4096 bytes +.loopsetaclear + mov dword[esi],0 + add esi,4 + dec ecx + jnz .loopsetaclear + cmp byte[SramExists],0 + je .nosramseta + mov esi,[sram] + mov edi,[setaramdata] + mov ecx,1024 +.setasramloop + mov eax,[esi] + mov [edi],eax + add esi,4 + add edi,4 + dec ecx + jnz .setasramloop +.nosramseta +.noseta + + ;General Stuff all mixed together mov dword[SfxSFR],0 diff --git a/zsnes/src/ui.asm b/zsnes/src/ui.asm index f541d0e6..87d77c46 100644 --- a/zsnes/src/ui.asm +++ b/zsnes/src/ui.asm @@ -192,6 +192,7 @@ NEWSYM vidbufferofsmos, resd 1 ; mosaic offset for new graphics engine NEWSYM headdata, resd 1 NEWSYM romdata, resd 1 ; rom data (4MB = 4194304) NEWSYM sfxramdata, resd 1 ; SuperFX Ram Data +NEWSYM setaramdata, resd 1 ; Seta ST010/ST011 SRam Data NEWSYM wramdata, resd 1 ; stack (64K = 32768) NEWSYM ram7f, resd 1 ; ram @ 7f = 65536 NEWSYM vram, resd 1 ; vram = 65536 @@ -724,6 +725,7 @@ NEWSYM allocptr add eax,4194304 mov dword[sfxramdata],eax + mov dword[setaramdata],eax ; share ram data with sfx mov esi,[romdata] cmp byte[Sup48mbit],0 je .no48mbit