⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 execute.asm

📁 十七种模拟器源代码 非常有用的作课程设计不可缺少的
💻 ASM
📖 第 1 页 / 共 5 页
字号:
    jmp .nomovie2
.movie2
    call cpuover.returntoloop
.nomovie2

    call joinflags

    ; de-init variables (copy to variables)

    mov [spcPCRam],ebp
    mov [Curtableaddr],edi
    mov [xp],dl
    mov [curcyc],dh

    mov eax,[initaddrl]
    sub esi,eax                 ; subtract program counter by address
    mov [xpc],si
    call ResetTripleBuf

    mov eax,[KeySaveState]
    cmp byte[CNetType],20
    je .skipsoundreinit
    test byte[pressed+eax],1
    jnz .soundreinit
    mov eax,[KeyLoadState]
    test byte[pressed+eax],1
    jz .skipsoundreinit
.soundreinit
    mov byte[NoSoundReinit],1
    mov byte[csounddisable],1
.skipsoundreinit

    cmp byte[NoSoundReinit],1
    je .skippostgame
    call DeInitPostGame
.skippostgame

    call WriteSPC7110log

    ; clear all keys
    call Check_Key
    cmp al,0
    je .nokeys
.yeskeys
    call Get_Key
    call Check_Key
    cmp al,0
    jne .yeskeys
.nokeys

;    mov edi,memtabler8+40h*4
;    mov ecx,30h
;    mov eax,memaccessbankr848mb
;    rep stosd
;    mov edi,memtabler16+40h*4
;    mov ecx,30h
;    mov eax,memaccessbankr1648mb
;    rep stosd

    cmp byte[nextmenupopup],1
    je near showmenu
    cmp byte[ReturnFromSPCStall],1
    je near .activatereset
    mov eax,[KeySaveState]
    cmp byte[CNetType],20
    je .net
    test byte[pressed+eax],1
    jnz near savestate
    mov eax,[KeyLoadState]
    test byte[pressed+eax],1
    jnz near loadstate
    cmp byte[SSKeyPressed],1
    je near showmenu
    cmp byte[debugdisble],0
    jne .nodebugger
    test byte[pressed+59],1
    jne near startdebugger
.nodebugger
    test byte[pressed+59],1
    jne near showmenu
    mov eax,[KeyQuickRst]
.net
    test byte[pressed+eax],1
    jz .noreset
.activatereset
    pushad
    call GUIDoReset
    popad
    mov byte[ReturnFromSPCStall],0
    jmp continueprog
.noreset
    cmp byte[guioff],1
    je near endprog
    mov eax,[KeyQuickExit]
    test byte[pressed+eax],1
    jnz near endprog
    jmp StartGUI

NEWSYM EndMessage
db '                                                                   ',13,10,0


NEWSYM endprog
    call deinitvideo

    cmp byte[previdmode],3
    jne .noendmessage
    mov byte[EndMessage+13],','
    mov eax,[welcome+9]
    mov [EndMessage+9],eax
    mov ax,[welcome+7]
    mov [EndMessage+7],ax
    mov edx,EndMessage
    call PrintStr
.noendmessage

;    mov eax,[opcd]
;    mov eax,[numinst]          ;Temporary
;    mov eax,[NumBRRconv]
;    call printnum
    ; save sram

    ; change to sram dir
    mov dl,[SRAMDrive]
    mov ebx,SRAMDir
    call Change_Dir

    EXTSYM SDD1Array,SDD1Entry,SDD1Sort
    call SDD1Sort
;    jmp .nodecomppack
    cmp byte[SDD1Enable],0
    jne .yesdecomppack
    cmp dword[SDD1Entry],0
    je .nodecomppack
.yesdecomppack
    mov edx,.blah
    call Create_File
    mov bx,ax
    mov edx,SDD1Array
    mov ecx,[SDD1Entry]
    call Write_File
    call Close_File
.nodecomppack

    cmp byte[sramsavedis],1
    je .nosram
    cmp dword[ramsize],0
    je .nosram
    xor eax,eax
    xor ebx,ebx
    xor ecx,ecx
    xor edx,edx
    xor esi,esi
    xor edi,edi
    mov edx,fnames+1
    call Create_File
    jc .nosram
    mov bx,ax
    xor ecx,ecx
    mov ecx,[ramsize]
    mov edx,[sram]
    call Write_File
    call Close_File
.nosram
    cmp byte[SFXSRAM],0
    je .nosfxsram
    mov edx,fnames+1
    call Create_File
    jc .nosfxsram
    mov bx,ax
    mov ecx,65536
    mov edx,[sfxramdata]
    call Write_File
    call Close_File
.nosfxsram
    cmp byte[SA1Enable],1
    jne .nosa1
    mov edx,fnames+1
    call Create_File
    jc .nosa1
    mov bx,ax
    mov ecx,65536*2
    mov edx,[SA1RAMArea]
    call Write_File
    call Close_File
.nosa1

    ; change dir to InitDrive/InitDir
    mov dl,[InitDrive]
    mov ebx,InitDir
    call Change_Dir

    call createnewcfg
    call GUISaveVars

    cmp byte[MovieProcessing],0
    je .nomovieclose
    mov bx,[MovieFileHand]
    mov byte[MovieProcessing],0
    call Close_File
.nomovieclose
;NEWSYM tempstore, times 1024*1024 db 0
;    mov esi,tempstore
;    mov ecx,1024*1024
;.loop
;    mov al,[esi]
;    cmp al,0
;    jne .faulty
;    inc esi
;    dec ecx
;    jnz .loop
;    xor eax,eax
;    jmp .notfaulty
;.faulty
;    mov eax,1
;.notfaulty
;    mov eax,[vidbufferofsa]
;    call printnum
;    mov dl,32
;    mov ah,02h
;    call Output_Text
;    mov eax,[vidbufferofsb]
;    call printnum
;    mov dl,32
;    mov ah,02h
;    call Output_Text
;    mov eax,[romdata]
;    call printnum

    ; change dir to InitDrive/InitDir
    mov dl,[InitDrive]
    mov ebx,InitDir
    call Change_Dir

    ; Deinit modem if necessary
    cmp byte[ModemInitStat],0
    je .nodeinitmodem
    call DeInitModem
.nodeinitmodem
;    cmp byte[OSPort],1
;    jae .nodeinitipx
%ifdef __MSDOS__
    call deinitipx
%endif
;.nodeinitipx
    jmp OSExit
.blah db 'sdd1dat.dat',0

NEWSYM interror
    stim
    call deinitvideo
    mov edx,.nohand         ;use extended
    mov ah,9                ;DOS- API
    call Output_Text                 ;to print a string
    jmp DosExit

.nohand db 'Cannot process interrupt handler!',13,10,0

; global variables
NEWSYM invalid, db 0
NEWSYM invopcd, db 0
NEWSYM pressed, times 256+128+64 db 0          ; keyboard pressed keys in scancode
NEWSYM exiter, db 0
NEWSYM oldhand9o, dd 0
NEWSYM oldhand9s, dw 0
NEWSYM oldhand8o, dd 0
NEWSYM oldhand8s, dw 0
NEWSYM opcd,      dd 0
NEWSYM pdh,       dd 0
NEWSYM pcury,     dd 0
NEWSYM timercount, dd 0
NEWSYM initaddrl, dd 0                  ; initial address location
NEWSYM NetSent, dd 0
NEWSYM nextframe, dd 0                  ; tick count for timer
NEWSYM curfps,    db 0                  ; frame/sec for current screen
NEWSYM SFXSRAM,   db 0
NEWSYM newgfxerror, db 'NEED MEMORY FOR GFX ENGINE',0
NEWSYM newgfxerror2, db 'NEED 320x240 FOR NEW GFX 16B',0
;newgfxerror db 'NEW GFX IN 16BIT IS N/A',0
NEWSYM HIRQCycNext,   dd 0
NEWSYM HIRQNextExe,   db 0

;*******************************************************
; Save/Load States
;*******************************************************

NEWSYM sramsave
    mov byte[pressed+1],0
    mov byte[pressed+41],0
    ; save sram
    cmp byte[sramsavedis],1
    je .nosram
    cmp word[ramsize],0
    je .nosram
    mov edx,fnames+1
    call Create_File
    jc .nosram
    mov bx,ax
    xor ecx,ecx
    mov cx,[ramsize]
    mov edx,[sram]
    call Write_File
    call Close_File
    mov dword[Msgptr],.savesrmmsg1
    mov eax,[MsgCount]
    mov [MessageOn],eax
    jmp reexecute
.nosram
    mov dword[Msgptr],.savesrmmsg2
    mov eax,[MsgCount]
    mov [MessageOn],eax
    jmp reexecute

.savesrmmsg1 db 'SRAM DATA SAVED.',0
.savesrmmsg2 db 'NO SRAM DATA.',0



NEWSYM statesaver
    clim


    sub dword[Curtableaddr],tableA
    sub dword[spcPCRam],spcRam
    sub dword[spcRamDP],spcRam
    call PrepareSaveState
    call unpackfunct
    call initrevst
;    jmp .skipsaves
    ; Save State
%ifdef __LINUX__
    mov dl,[SRAMDrive]
    mov ebx,SRAMDir
    call Change_Dir
%endif
    mov edx,fnamest+1
    call Create_File
    jc near .nosavestuff
    ; Save 65816 status, etc.
    mov bx,ax
    mov ecx,[PHnum2writecpureg]
    mov edx,zsmesg
    call Write_File
    mov ecx,8
    mov edx,cycpbl
    call Write_File
    ; Save SNES PPU Register status
    mov ecx,3019
    mov edx,sndrot
    call Write_File
    ; Save RAM (WRAM(128k),VRAM(64k),SRAM)
;    xor ecx,ecx
;    mov cx,[ramsize]
    mov ecx,65536+65536
    mov edx,[wramdata]
    call Write_File
    mov ecx,65536
    mov edx,[vram]
    call Write_File
    cmp byte[spcon],0
    je .nospcon
    ; Save SPC stuff
    mov ecx,[PHspcsave]
    mov edx,spcRam
    call Write_File
    ; Save DSP stuff
    mov ecx,[PHdspsave]
    mov edx,BRRBuffer
    call Write_File
    ; Save DSP Mem
    mov ecx,256
    mov edx,DSPMem
    call Write_File
.nospcon
    cmp byte[C4Enable],1
    jne .noc4
    mov ecx,2000h
    mov edx,[C4Ram]
    call Write_File
.noc4
    cmp byte[SFXEnable],1
    jne .nosfx
    mov ecx,[SfxCROM]
    sub [SfxRomBuffer],ecx
    mov ecx,[SfxRAMMem]
    sub [SfxLastRamAdr],ecx
    mov ecx,65536*2
    mov edx,[sfxramdata]
    call Write_File
    ; uncomment the following
    mov ecx,[PHnum2writesfxreg]
    mov edx,SfxR0
    call Write_File
    mov ecx,[SfxCROM]
    add [SfxRomBuffer],ecx
    mov ecx,[SfxRAMMem]
    add [SfxLastRamAdr],ecx
.nosfx
    cmp byte[SPC7110Enable],1
    jne .nospc7110
    mov edx,[romdata]
    add edx,510000h
    mov ecx,65536
    call Write_File
    mov edx,SPCMultA
    mov ecx,[PHnum2writespc7110reg]
    call Write_File
.nospc7110
    cmp byte[SA1Enable],1
    jne .nossa1
    ; Convert SA-1 stuff to standard, non displacement format
    call SaveSA1
    mov ecx,[PHnum2writesa1reg]
    mov edx,SA1Mode
    call Write_File
    mov ecx,65536*2
    mov edx,[SA1RAMArea]
    call Write_File
    ; Convert back SA-1 stuff
    call RestoreSA1
.nossa1
    cmp byte[cbitmode],0
    je .nocapturepicture
    cmp byte[NoPictureSave],1
    je .nocapturepicture
    call CapturePicture
    mov ecx,64*56*2
    mov edx,PrevPicture
    call Write_File
.nocapturepicture
    call Close_File
    add dword[Curtableaddr],tableA
    add dword[spcPCRam],spcRam
    add dword[spcRamDP],spcRam
    call ResetState
    call initrevst
    stim

    ; Get the state number
    mov ebx,[statefileloc]
    mov cl,[fnamest+ebx]
    cmp cl,'T'
    je  .stateiszero
    cmp cl,'t'
    jne .writewhichstate
.stateiszero
    mov cl,'0'
.writewhichstate
    mov [.savemsg+6],cl
	
    mov dword[Msgptr],.savemsg
    mov eax,[MsgCount]
    mov [MessageOn],eax
    ret
.nosavestuff
    add dword[Curtableaddr],tableA
    add dword[spcPCRam],spcRam
    add dword[spcRamDP],spcRam
    call ResetState
    call initrevst
    stim
    mov dword[Msgptr],.savemsgfail
    mov eax,[MsgCount]
    mov [MessageOn],eax
    ret

.savemsg db 'STATE - SAVED.',0
.savemsgfail db 'UNABLE TO SAVE.',0

NEWSYM savestate
    jmp .save
    mov byte[pressed+1],0
    mov byte[pressed+60],0
    mov edx,.fname2+1
    call Create_File
    mov esi,[vidbuffer]
    add esi,16*2+256*2+32*2
    mov edi,[vidbuffer]
    mov dl,[resolutn]
    mov bx,ax
    ; move data to a linear address from esi to edi
.loopa
    mov ecx,128
    add esi,64+128*4
    dec dl
    jnz .loopa
    push edx
    push esi
    mov ecx,128*4
    mov edx,esi
    call Write_File
    pop esi
    pop edx
    add esi,64+128*4
    call Close_File
    jmp reexecuteb
.save
    mov byte[pressed+1],0
    mov eax,[KeySaveState]
    mov byte[pressed+eax],2
    call statesaver
    jmp reexecuteb

.fname2 db 9,'image.dat',0

cycpblblah dd 0,0

    ; Load State
NEWSYM stateloader
    mov byte[MovieProcessing],0
    mov byte[prevoamptr],0FFh
    ; Load 65816 status, etc.
    mov bx,ax
    mov ecx,[PHnum2writecpureg]
    add dword[Totalbyteloaded],ecx
    mov edx,zsmesg
    call Read_File
    cmp byte[versn],60
    jne near .convert
    ; Load SPC timers
    mov ecx,8
    add dword[Totalbyteloaded],ecx
    mov edx,cycpbl
    call Read_File
    ; Load SNES PPU Register status
    mov ecx,3019    ; 3019
    add dword[Totalbyteloaded],ecx
    mov edx,sndrot
    call Read_File
    ; Load RAM (WRAM(128k),VRAM(64k),SRAM)
    mov ecx,65536+65536
    add dword[Totalbyteloaded],ecx
    mov edx,[wramdata]
    call Read_File
    mov ecx,65536
    add dword[Totalbyteloaded],ecx
    mov edx,[vram]
    call Read_File
    cmp byte[spcon],0
    je .nospcon
    ; Load SPC stuff
    mov ecx,[PHspcsave]
    add dword[Totalbyteloaded],ecx
    mov edx,spcRam
    call Read_File
    ; Load DSP stuff
    mov ecx,[PHdspsave]
    add dword[Totalbyteloaded],ecx
    mov edx,BRRBuffer
    call Read_File
    ; Load DSP Mem
    mov ecx,256
    add dword[Totalbyteloaded],ecx
    mov edx,DSPMem
    call Read_File
.nospcon
    cmp byte[SFXEnable],1
    jne near .nosfx
    mov ecx,65536*2
    add dword[Totalbyteloaded],ecx
    mov edx,[sfxramdata]
    call Read_File

    mov ecx,[PHnum2writesfxreg]
    add dword[Totalbyteloaded],ecx
    mov edx,SfxR0
    call Read_File

    xor ecx,ecx
    mov cl,[SfxPBR]
    mov ecx,[SfxMemTable+ecx*4]
    mov [SfxCPB],ecx

    xor ecx,ecx
    mov cl,[SfxROMBR]
    mov ecx,[SfxMemTable+ecx*4]
    mov [SfxCROM],ecx

    xor ecx,ecx
    mov cl,[SfxRAMBR]
    shl ecx,16
    add ecx,[sfxramdata]
    mov dword [SfxRAMMem],ecx

    mov ecx,[SfxCROM]
    add [SfxRomBuffer],ecx
    mov ecx,[SfxRAMMem]
    add [SfxLastRamAdr],ecx

.nosfx

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -