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

📄 guiload.inc

📁 十七种模拟器源代码 非常有用的作课程设计不可缺少的
💻 INC
📖 第 1 页 / 共 3 页
字号:
;Copyright (C) 1997-2001 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.




; GUI File (Game) Loader

%macro GUIGetEntry 1
    mov edx,%1
    mov cx,20h
    call Get_First_Entry
    jc %%nomore
%%moreentries
    test byte[DTALoc+15h],10h
    jnz %%nofile
    inc dword[GUInumentries]
    mov esi,DTALoc+1Eh
    mov byte[edi],0
    inc edi
    mov ecx,13
%%nextchar
    mov al,[esi]
    mov [edi],al
    inc esi
    inc edi
    dec ecx
    jnz %%nextchar
%%nofile
    call Get_Next_Entry
    jnc %%moreentries
%%nomore
%endmacro

%macro GUIGetEntry2 1
    mov edx,%1
    mov cx,20h
    call Get_First_Entry
    jc %%nomore
%%moreentries
    test byte[DTALoc+15h],10h
    jnz %%nofile
    mov eax,[GUInumentries]
    shl eax,2
    add eax,spcRamcmp
    mov [eax],edi
    inc dword[GUInumentries]
    mov esi,DTALoc+1Eh
    mov byte[edi],0
    inc edi
%%nextchar
    mov al,[esi]
    mov [edi],al
    inc esi
    inc edi
    or al,al
    jnz %%nextchar
%%nofile
    call Get_Next_Entry
    jnc %%moreentries
%%nomore
%endmacro

%macro GUIGetDir2 0
    mov edx,GUIfindDIR
    mov cx,10h
    call Get_First_Entry
    jc .nomore
.moreentries
    test byte[DTALoc+15h],10h
    jz .nodir
    mov eax,[GUInumentries]
    shl eax,2
    add eax,spcRamcmp
    mov [eax],edi
    inc dword[GUInumentries]
    inc dword[GUIdirentries]
    mov esi,DTALoc+1Eh
    mov byte[edi],1
    inc edi
.nextchar
    mov al,[esi]
    mov [edi],al
    inc esi
    inc edi
    or al,al
    jnz .nextchar
.nodir
    call Get_Next_Entry
    jnc .moreentries
.nomore
%endmacro

%macro GUIGetDir 0
    mov edx,GUIfindDIR
    mov cx,10h
    call Get_First_Entry
    jc .nomore
.moreentries
    test byte[DTALoc+15h],10h
    jz .nodir
    inc dword[GUInumentries]
    inc dword[GUIdirentries]
    mov esi,DTALoc+1Eh
    mov byte[edi],1
    inc edi
    mov ecx,13
.nextchar
    mov al,[esi]
    mov [edi],al
    inc esi
    inc edi
    dec ecx
    jnz .nextchar
.nodir
    call Get_Next_Entry
    jnc .moreentries
.nomore
%endmacro

%macro GUIPutDrive 0
    mov byte[edi],2
    inc edi
    mov byte[edi],'['
    mov [edi+1],al
    mov byte[edi+2],':'
    mov byte[edi+3],']'
    mov byte[edi+4],0
    add edi,13
    mov byte[esi],2
    inc esi
    mov byte[esi],'['
    mov [esi+1],al
    mov byte[esi+2],':'
    mov byte[esi+3],']'
    mov byte[esi+4],0
    add esi,31
    inc dword[GUInumentries]
    inc dword[GUIdirentries]
%endmacro

%macro GUIPutDrive2 0
    mov byte[edi],2
    inc edi
    mov byte[edi],'['
    mov [edi+1],al
    mov byte[edi+2],':'
    mov byte[edi+3],']'
    mov byte[edi+4],0
    add edi,5
    inc dword[GUInumentries]
    inc dword[GUIdirentries]
%endmacro

;LGUI

netlastloaded db 0

GUIloadfilename:
    cmp byte[CNetType],15
    je .noload
    cmp byte[CNetType],12
    je .noload
    cmp byte[CNetType],11
    je .noload
    cmp byte[CNetType],10
    je .noload
    cmp byte[CNetType],21
    je .noload
    cmp byte[CNetType],22
    jne .yesload
.noload
    ret
.yesload
    cmp byte[CNetType],20
    jne near .nocnettype
    mov byte[netlastloaded],1
; FileNameMod times 29 db 0
    cmp byte[GUIcmenupos],1
    jne .nomenuout
    mov byte[GUIcmenupos],0
.nomenuout
    mov esi,FileNameMod
.nextfnc
    mov cl,[eax]
    mov [esi],cl
    inc eax
    inc esi
    cmp cl,0
    jne .nextfnc
    mov byte[RemoteCommand],10
    pushad
    call GUIQuickLoadUpdate
    popad
    ret
.nocnettype
    cmp byte[CNetType],20
    je .okay20
;    ret
.okay20
    mov esi,eax
    ; find length of string & copy filename
    xor cl,cl
.findnext
    mov ch,[esi]
    cmp byte[esi],0
    je .foundend
    inc esi
    inc cl
    jmp .findnext
.foundend
    mov [fname],cl
    ; copy filename
    mov esi,eax
    mov edi,fname+1
.continuecopy
    mov al,[esi]
    mov [edi],al
    cmp al,0
    je .foundzero
    inc esi
    inc edi
    jmp .continuecopy
.foundzero

    ; get LoadDrive/LoadDir & SRAMDrive/SRAMDir
    mov ebx,LoadDir
    mov edx,LoadDrive
    call Get_Dir
%ifndef __LINUX__
    cmp byte[cfgloadsdir],0
    jne .nosdrive
    mov ebx,SRAMDir
    mov edx,SRAMDrive
    call Get_Dir
%endif
.nosdrive

    ; create .srm header
    call makeextension
    ; clear memory
    mov edi,[sram]
    mov eax,0FFFFFFFFh
    mov ecx,8192
.n
    mov [edi],eax
    add edi,4
    dec ecx
    jnz .n
    call clearmem2

    mov dword[nmiprevaddrl],0
    mov dword[nmiprevaddrh],0
    mov dword[nmirept],0
    mov dword[nmiprevline],224
    mov dword[nmistatus],0
    mov byte[spcnumread],0
    mov byte[NextLineCache],0
    mov byte[curexecstate],1

    ; load file
    call loadfileGUI
    cmp byte[ZipSupport],2
    je near .noloader
    cmp byte[GUIloadfailed],1
    je near .noloader

    mov byte[CheatOn],0
    mov byte[NumCheats],0
;    mov byte[CheatSrcByteSize],0
;    mov byte[CheatSrcByteBase],0
;    mov byte[CheatSrcSearchType],0
    mov byte[CheatWinMode],0
    mov byte[CheatSearchStatus],0

    call CheckROMType
    cmp byte[ROMTypeNOTFound],0
    je .foundromtype
    mov byte[romtype],1
.foundromtype
    call SetIRQVectors
    call ClearScreen
    cmp byte[cbitmode],0
    jne .nomakepal
    call makepal
.nomakepal
    ; get sram size
    mov esi,[romdata]
    add esi,7FD8h
    cmp byte[romtype],2
    jne .nohirom2
    add esi,8000h
.nohirom2
    mov cl,[esi-1]
    mov [curromsize],cl

    mov cl,[esi]
    inc esi
    xor eax,eax
    mov al,1
    shl al,cl
    cmp al,1
    jne .yessram
    mov al,0
.yessram
    shl eax,10
    cmp eax,65536
    jbe .nosramc
    mov eax,65536
.nosramc
    mov [ramsize],eax
    dec eax
    mov [ramsizeand],eax

    ; get pal/ntsc
    mov al,[esi]
    cmp byte[ForcePal],1
    jne .nontsc
    mov al,0
.nontsc
    cmp byte[ForcePal],2
    jne .nopal2
    mov al,2
.nopal2
    mov byte[romispal],0
    mov word[totlines],262
    mov dword[MsgCount],120
    cmp al,1
    jbe .nopal
    mov byte[romispal],1
    mov word[totlines],314
    mov dword[MsgCount],100
.nopal
    call initsnes
    mov byte[snesmouse],0
    mov byte[sramsavedis],0
    mov eax,regsbackup
    mov ebx,sndrot
    mov ecx,3019
.rbackupl
    mov dl,[eax]
    mov [ebx],dl
    inc ebx
    inc eax
    loop .rbackupl
    cmp byte[yesoutofmemory],1
    jne .noout
    call outofmemfix
.noout
    call GUIDoReset
    call GUIQuickLoadUpdate
    cmp byte[AutoLoadCht],0
    je .nocheatload
    cmp byte[CNetType],20
    je .nocheatload
    ; change dir to LoadDrive/LoadDir
    mov dl,[LoadDrive]
    mov ebx,LoadDir
    call Change_Dir

    call CheatCodeLoad
.nocheatload
    cmp byte[AutoState],0
    je .noloader
    call LoadSecondState
.noloader
    cmp byte[GUIwinptr],1
    jne .nowinopen
    mov al,[GUIpmenupos]
    mov [GUIcmenupos],al
.nowinopen
    ; change dir to LoadDrive/LoadDir
    mov dl,[LoadDrive]
    mov ebx,LoadDir
    call Change_Dir
    ret

GUILoadData:
    mov byte[GUICBHold],0
    cmp byte[GUIcurrentfilewin],0
    je near .loadfiles
    ; Change directory
    cmp byte[GUIloadfntype],0
    jne .nottype0c
    mov eax,[GUIcurrentdircursloc]
    add eax,[GUIfileentries]
    mov eax,[spcRamcmp+eax*4]
    jmp .donetype0
.nottype0c
    mov eax,[GUIcurrentdircursloc]
    mov ebx,eax
    lea eax,[eax*8]
    add ebx,ebx
    add eax,ebx
    add ebx,ebx
    add eax,ebx
    add eax,[GUIdirStartLoc]
.donetype0
    inc eax
    cmp byte[eax+2],':'
    je .drive
    mov edx,eax
    call Change_Single_Dir
    jc .error
    call GetLoadData.a
.error
    ret
.drive
    ; Change Drive
    mov dl,[eax+1]
    sub dl,65
    call Change_Drive
    call GetLoadData.a
    ret
.unableload
    pop eax
    ret
.loadfiles
    mov byte[LoadDuplicFound],0
    cmp byte[prevlfreeze],0
    jne near .frozen
;    cmp byte[GUIloadfntype],0
;    je near .frozen

    ; check if a duplicate exists
    mov esi,prevloadnames
.checkanother
    push esi
    mov edx,[GUIcurrentcursloc]
    shl edx,5
    add edx,[spcBuffera]
    cmp byte[GUIloadfntype],0
    jne .nottype0
    mov edx,[GUIcurrentcursloc]
    mov edx,[spcRamcmp+edx*4]
.nottype0
    inc edx
    mov cl,16
.dloop
    mov al,[edx]
    cmp [esi],al
    jne .nomatch
    inc edx
    inc esi
    dec cl
    jz .matchfound
    cmp al,0
    jne .dloop
.matchfound
    pop esi
    mov byte[LoadDuplicFound],1
    jmp .frozen
.nomatch
    pop esi
    add esi,16
    cmp esi,prevloadnames+10*16
    jne near .checkanother

    ; copy game name
    ; shift names down
    mov esi,prevloadnames+16*9-1
    mov ecx,16*9
.loop
    mov al,[esi]
    mov [esi+16],al
    dec esi
    dec edi
    dec ecx
    jnz .loop
    mov esi,prevloadfnamel+512*9-1
    mov edi,prevloaddnamel+512*9-1
    mov ecx,512*9
.loop2
    mov al,[esi]
    mov [esi+512],al
    mov al,[edi]
    mov [edi+512],al
    dec esi
    dec edi
    dec ecx
    jnz .loop2
.skip
    ; copy game name
    mov edx,[GUIcurrentcursloc]
    shl edx,5
    add edx,[spcBuffera]
    cmp byte[GUIloadfntype],0
    jne .nottype0b
    mov edx,[GUIcurrentcursloc]
    mov edx,[spcRamcmp+edx*4]
.nottype0b
    inc edx
    mov ebx,prevloadnames
    mov ecx,16
.loopfnc
    mov al,[edx]
    mov [ebx],al
    inc edx
    inc ebx
    loop .loopfnc

    ; get Drive/Dir
    mov ebx,prevloaddnamel+1
    mov edx,prevloaddnamel
    call Get_Dir
.frozen

    cmp byte[GUIloadfntype],0
    jne .nottype0b2
    mov eax,[GUIcurrentcursloc]
    mov eax,[spcRamcmp+eax*4]
    jmp .donetype0b
.nottype0b2
    mov eax,[GUIcurrentcursloc]
    mov ebx,eax
    lea eax,[eax*8]
    add ebx,ebx
    add eax,ebx
    add ebx,ebx
    add eax,ebx
    add eax,spcRamcmp
.donetype0b
    inc eax
    cmp byte[prevlfreeze],0
    jne .foundend
    cmp byte[LoadDuplicFound],0

⌨️ 快捷键说明

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