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

📄 guicheat.inc

📁 十七种模拟器源代码 非常有用的作课程设计不可缺少的
💻 INC
📖 第 1 页 / 共 2 页
字号:
    inc ebx
    inc eax
    loop .dloop
    pop edx
    pop ebx
    pop eax
    ; toggle, value, address, pvalue, name(12)
    mov byte[edx],0
    mov [edx+1],bl
    push eax
    sub eax,7E0000h
    add eax,[wramdata]
    mov bh,[eax]
    mov [eax],bl
    pop eax
    mov [edx+2],eax
    mov [edx+5],bh
    inc dword[NumCheats]
    mov edx,7
    mov al,[GUIpmenupos]
    push eax
    call CheckMenuItemHelp
    pop eax
    mov [GUIpmenupos],al
    mov byte[CheatOn],1
    ret

ProcessCheatCode:
    mov byte[GUICBHold],0
    cmp dword[NumCheats],255
    je .fail
    cmp byte[GUICheatPosA],0
    je .fail
    jmp .okay
.fail
    ret
.okay
    ; make sure flashing cursor doesn't exist
    xor ebx,ebx
    mov bl,[GUICheatPosB]
    mov byte[GUICheatTextA+ebx],0
    ; transfer description
    mov eax,[NumCheats]
    shl eax,5
    sub eax,[NumCheats]
    sub eax,[NumCheats]
    sub eax,[NumCheats]
    sub eax,[NumCheats]
    add eax,cheatdata
    add eax,6
    mov ebx,GUICheatTextA
    mov ecx,20
.dloop
    mov dl,[ebx]
    mov [eax+2],dl
    mov [eax+18+2],dl
    mov [eax+18*2+2],dl
    inc ebx
    inc eax
    loop .dloop
    ; determine whether it is gamegenie, par, or GF
    ; uppercase all codes if necessary
    mov eax,GUICheatText9
    mov ecx,14
.loop
    mov bl,[eax]
    cmp bl,'a'
    jb .nolower
    cmp bl,'z'
    ja .nolower
    sub bl,'a'-'A'
    mov [eax],bl
.nolower
    inc eax
    loop .loop
    mov byte[guicheatvalrep],0
    xor eax,eax
    mov al,[GUICheatPosA]
    dec al
    cmp byte[GUICheatText9+eax],'R'
    jne .notrep
    mov byte[guicheatvalrep],80h
    dec byte[GUICheatPosA]
.notrep
    cmp byte[GUICheatPosA],8
    je near .par
    cmp byte[GUICheatPosA],9
    je near .gg
    cmp byte[GUICheatPosA],14
    je near .gf
.invalidpar
    jmp guicheaterror
.par
    ; check if code is valid
    mov eax,GUICheatText9
    mov ecx,8
.looppar
    mov bl,[eax]
    cmp bl,'0'
    jb .invalidpar
    cmp bl,'9'
    jbe .okaypar
    cmp bl,'A'
    jb .invalidpar
    cmp bl,'F'
    ja .invalidpar
.okaypar
    inc eax
    loop .looppar
    jmp decodepar
.invalidgg
    jmp guicheaterror
.gg
    ; check if code is valid
    mov eax,GUICheatText9
    mov ecx,9
.loopgg
    cmp ecx,5
    jne .nomid
    cmp byte[eax],'-'
    jne .invalidgg
    inc eax
    dec ecx
.nomid
    mov bl,[eax]
    cmp bl,'0'
    jb .invalidgg
    cmp bl,'9'
    jbe .okaygg
    cmp bl,'A'
    jb .invalidgg
    cmp bl,'F'
    ja .invalidgg
.okaygg
    inc eax
    loop .loopgg
    jmp decodegg
    ret
.invalidgf
    jmp guicheaterror
.gf
    ; check if code is valid
    mov eax,GUICheatText9
    mov ecx,5
.loopgf
    mov bl,[eax]
    cmp bl,'0'
    jb .invalidgf
    cmp bl,'9'
    jbe .okaygf
    cmp bl,'A'
    jb .invalidgf
    cmp bl,'F'
    ja .invalidgf
.okaygf
    inc eax
    loop .loopgf
    mov eax,GUICheatText9+5
    mov ecx,6
.loopgf2
    mov bl,[eax]
    cmp bl,'X'
    je .okaygf2
    cmp bl,'0'
    jb .invalidgf
    cmp bl,'9'
    jbe .okaygf2
    cmp bl,'A'
    jb near .invalidgf
    cmp bl,'F'
    ja near .invalidgf
.okaygf2
    inc eax
    loop .loopgf2
    mov bl,[GUICheatText9+13]
    cmp bl,'0'
    je .okaygf3
    cmp bl,'1'
    jne near .invalidgf
.okaygf3
    jmp decodegf

decodegf:
    ; convert code to number format
    mov ecx,14
    mov esi,GUICheatText9
.loopb2
    mov al,[esi]
    cmp al,'X'
    je .let2
    cmp al,'A'
    jb .num2
    sub al,'A'
    add al,10
    jmp .let2
.num2
    sub al,'0'
.let2
    mov [esi],al
    inc esi
    dec ecx
    jnz .loopb2

    ; get address
    xor ebx,ebx
    xor ecx,ecx
    mov cl,[GUICheatText9]
    shl ecx,4
    add cl,[GUICheatText9+1]
    shl ecx,4
    add cl,[GUICheatText9+2]
    shl ecx,4
    add cl,[GUICheatText9+3]
    shl ecx,4
    add cl,[GUICheatText9+4]

    mov edx,[NumCheats]
    shl edx,5
    sub edx,[NumCheats]
    sub edx,[NumCheats]
    sub edx,[NumCheats]
    sub edx,[NumCheats]

    ; Write data to memory
    cmp byte[GUICheatText9+13],1
    je near .modifysram

    ; get data
    cmp byte[GUICheatText9+5],'X'
    je near .nocode
    cmp byte[GUICheatText9+6],'X'
    je near .nocode
    mov bl,[GUICheatText9+5]
    shl bl,4
    add bl,[GUICheatText9+6]
    mov esi,[romdata]
    mov al,[esi+ecx]
    mov [esi+ecx],bl
    mov byte[cheatdata+edx],1
    mov [cheatdata+edx+2],ecx
    mov [cheatdata+edx+1],bl
    mov [cheatdata+edx+5],al
    push eax
    mov al,[guicheatvalrep]
    or [cheatdata+edx],al
    pop eax
    inc byte[NumCheats]
    add edx,28
.nocode
    inc ecx
    cmp byte[GUICheatText9+7],'X'
    je near .nocode1
    cmp byte[GUICheatText9+8],'X'
    je near .nocode1
    cmp byte[NumCheats],255
    je near .nocode1
    mov bl,[GUICheatText9+7]
    shl bl,4
    add bl,[GUICheatText9+8]
    mov esi,[romdata]
    mov al,[esi+ecx]
    mov [esi+ecx],bl
    mov byte[cheatdata+edx],1
    mov [cheatdata+edx+2],ecx
    mov [cheatdata+edx+1],bl
    mov [cheatdata+edx+5],al
    inc byte[NumCheats]
    add edx,28
.nocode1
    inc ecx
    cmp byte[GUICheatText9+9],'X'
    je near .nocode2
    cmp byte[GUICheatText9+10],'X'
    je near .nocode2
    cmp byte[NumCheats],255
    je near .nocode2
    mov bl,[GUICheatText9+9]
    shl bl,4
    add bl,[GUICheatText9+10]
    mov esi,[romdata]
    mov al,[esi+ecx]
    mov [esi+ecx],bl
    mov byte[cheatdata+edx],1
    mov [cheatdata+edx+2],ecx
    mov [cheatdata+edx+1],bl
    mov [cheatdata+edx+5],al
    inc byte[NumCheats]
.nocode2
    jmp .quit

.modifysram
    cmp ecx,65535
    ja near .quit
    mov esi,[sram]
    ; get data
    cmp byte[GUICheatText9+5],'X'
    je .nocodeb
    cmp byte[GUICheatText9+6],'X'
    je .nocodeb
    mov bl,[GUICheatText9+5]
    shl bl,4
    add bl,[GUICheatText9+6]
    mov al,[esi+ecx]
    mov [esi+ecx],bl
    mov byte[cheatdata+edx],2
    mov [cheatdata+edx+2],ecx
    mov [cheatdata+edx+1],bl
    mov [cheatdata+edx+5],al
    inc byte[NumCheats]
    add edx,28
.nocodeb
    inc ecx
    cmp byte[GUICheatText9+7],'X'
    je .nocode1b
    cmp byte[GUICheatText9+8],'X'
    je .nocode1b
    cmp byte[NumCheats],255
    je .nocode1b
    cmp ecx,65535
    ja .nocode1b
    mov bl,[GUICheatText9+7]
    shl bl,4
    add bl,[GUICheatText9+8]
    mov al,[esi+ecx+1]
    mov [esi+ecx+1],bl
    mov byte[cheatdata+edx],2
    mov [cheatdata+edx+2],ecx
    mov [cheatdata+edx+1],bl
    mov [cheatdata+edx+5],al
    inc byte[NumCheats]
    add edx,28
.nocode1b
    inc ecx
    cmp byte[GUICheatText9+9],'X'
    je .nocode2c
    cmp byte[GUICheatText9+10],'X'
    je .nocode2c
    cmp byte[NumCheats],255
    je .nocode2c
    cmp ecx,65535
    ja .nocode2c
    mov bl,[GUICheatText9+9]
    shl bl,4
    add bl,[GUICheatText9+10]
    mov al,[esi+ecx+2]
    mov [esi+ecx+2],bl
    mov byte[cheatdata+edx],2
    mov [cheatdata+edx+2],ecx
    mov [cheatdata+edx+1],bl
    mov [cheatdata+edx+5],al
    inc byte[NumCheats]
.nocode2c

.quit
    cmp byte[NumCheats],0
    je .nocheat
    mov byte[CheatOn],1
    mov dword[GUIcurrentcheatwin],1
    mov eax,[NumCheats]
    dec eax
    mov [GUIcurrentcheatcursloc],eax
    sub eax,11
    mov [GUIcurrentcheatviewloc],eax
    test dword[GUIcurrentcheatviewloc],80000000h
    jz .noview
    mov dword[GUIcurrentcheatviewloc],0
.noview
.nocheat
    mov dword[GUICheatText9],0
    mov dword[GUICheatTextA],0
    mov byte[GUICheatPosA],0
    mov byte[GUICheatPosB],0
    ret

decodegg:
;Genie Hex:    D  F  4  7  0  9  1  5  6  B  C  8  A  2  3  E
;Normal  Hex:  0  1  2  3  4  5  6  7  8  9  A  B  C  D  E  F
;              4  6  D  E  2  7  8  3  B  5  C  9  A  0  F  1
    ; Convert code
    mov esi,GUICheatText9
    mov eax,[esi+5]
    mov [esi+4],eax
    ; convert code to number format
    mov ecx,8
    xor eax,eax
.loopb3
    mov al,[esi]
    cmp al,'A'
    jb .num3
    sub al,'A'
    add al,10
    jmp .let3
.num3
    sub al,'0'
.let3
    mov al,[.GG2Norm+eax]
    mov [esi],al
    inc esi
    dec ecx
    jnz .loopb3

    mov esi,GUICheatText9
    xor ecx,ecx
    mov cl,[esi+2]
    shl ecx,4
    add cl,[esi+3]
    shl ecx,4
    add cl,[esi+4]
    shl ecx,4
    add cl,[esi+5]
    shl ecx,4
    add cl,[esi+6]
    shl ecx,4
    add cl,[esi+7]
;                        0123456789ABCDEF01234567
; 24bit encoded address: ijklqrstopabcduvwxefghmn
;                        abcdefghijklmnopqrstuvwx
;                        >8  >12 >6<10 >6  <14 <10
    mov ebx,ecx
    and ebx,000000000011110000000000b   ;abcd
    shl ebx,10
    mov eax,ecx
    and eax,000000000000000000111100b   ;efgh
    shl eax,14
    add ebx,eax
    mov eax,ecx
    and eax,111100000000000000000000b   ;ijkl
    shr eax,8
    add ebx,eax
    mov eax,ecx
    and eax,000000000000000000000011b   ;mn
    shl eax,10
    add ebx,eax
    mov eax,ecx
    and eax,000000001100000000000000b   ;op
    shr eax,6
    add ebx,eax
    mov eax,ecx
    and eax,000011110000000000000000b   ;qrst
    shr eax,12
    add ebx,eax
    mov eax,ecx
    and eax,000000000000001111000000b   ;uvwx
    shr eax,6
    add ebx,eax
    xor ecx,ecx
    mov cx,bx
    shr ebx,16
    test bl,40h
    jz .noover
;    xor cx,8000h
.noover
    mov al,[esi]
    shl al,4
    add al,[esi+1]

    ; store into cheatdata
    mov edx,[NumCheats]
    shl edx,5
    sub edx,[NumCheats]
    sub edx,[NumCheats]
    sub edx,[NumCheats]
    sub edx,[NumCheats]
    mov byte[cheatdata+edx],0
    mov [cheatdata+edx+1],al
    mov [cheatdata+edx+2],cx
    mov [cheatdata+edx+4],bl
    push eax
    mov al,[guicheatvalrep]
    or [cheatdata+edx],al
    pop eax
    push ecx
    push eax
    push ebx
    push edx
    call dword near [memtabler8+ebx*4]
    pop edx
    mov byte[cheatdata+edx+5],al
    pop ebx
    pop eax
    pop ecx

    mov byte[writeon],1

    test byte[cheatdata+edx],80h
    jnz .nowrite
    test byte[cheatdata+edx-28],80h
    jnz .nowrite
    call dword near [memtablew8+ebx*4]
.nowrite

    mov byte[writeon],0
    mov byte[CheatOn],1
    inc byte[NumCheats]
    mov dword[GUICheatText9],0
    mov dword[GUICheatTextA],0
    mov byte[GUICheatPosA],0
    mov byte[GUICheatPosB],0
    mov dword[GUIcurrentcheatwin],1
    mov eax,[NumCheats]
    dec eax
    mov [GUIcurrentcheatcursloc],eax
    sub eax,11
    mov [GUIcurrentcheatviewloc],eax
    test dword[GUIcurrentcheatviewloc],80000000h
    jz .noview
    mov dword[GUIcurrentcheatviewloc],0
.noview
    ret
.GG2Norm db 04h,06h,0Dh,0Eh,02h,07h,08h,03h,0Bh,05h,0Ch,09h,0Ah,00h,0Fh,01h

decodepar:
    ; convert code to number format
    mov ecx,8
    mov esi,GUICheatText9
.loopb
    mov al,[esi]
    cmp al,'A'
    jb .num
    sub al,'A'
    add al,10
    jmp .let
.num
    sub al,'0'
.let
    mov [esi],al
    inc esi
    dec ecx
    jnz .loopb
    ; get address
    xor ebx,ebx
    xor ecx,ecx
    mov bl,[GUICheatText9]
    shl bl,4
    add bl,[GUICheatText9+1]
    mov cl,[GUICheatText9+2]
    shl cx,4
    add cl,[GUICheatText9+3]
    shl cx,4
    add cl,[GUICheatText9+4]
    shl cx,4
    add cl,[GUICheatText9+5]
    mov al,[GUICheatText9+6]
    shl al,4
    add al,[GUICheatText9+7]

    ; store into cheatdata
    xor edx,edx
    mov dl,[NumCheats]
    push ebx
    mov ebx,edx
    shl edx,5
    sub edx,ebx
    sub edx,ebx
    sub edx,ebx
    sub edx,ebx
    pop ebx
    mov byte[cheatdata+edx],0
    mov [cheatdata+edx+1],al
    mov [cheatdata+edx+2],cx
    mov [cheatdata+edx+4],bl
    push eax
    mov al,[guicheatvalrep]
    or [cheatdata+edx],al
    pop eax
    push ecx
    push eax
    push ebx
    push edx
    call dword near [memtabler8+ebx*4]
    pop edx
    mov byte[cheatdata+edx+5],al
    pop ebx
    pop eax
    pop ecx

    mov byte[writeon],1
    test byte[cheatdata+edx],80h
    jnz .nowrite
    test byte[cheatdata+edx-28],80h
    jnz .nowrite
    call dword near [memtablew8+ebx*4]
.nowrite
    mov byte[writeon],0
    mov byte[CheatOn],1
    inc dword[NumCheats]
    mov dword[GUICheatText9],0
    mov dword[GUICheatTextA],0
    mov byte[GUICheatPosA],0
    mov byte[GUICheatPosB],0
    mov dword[GUIcurrentcheatwin],1
    mov eax,[NumCheats]
    dec eax
    mov [GUIcurrentcheatcursloc],eax
    sub eax,11
    mov [GUIcurrentcheatviewloc],eax
    test dword[GUIcurrentcheatviewloc],80000000h
    jz .noview
    mov dword[GUIcurrentcheatviewloc],0
.noview
    ret

guicheaterror:
    xor ebx,ebx
    mov ecx,256+128+64
.a
    mov byte[pressed+ebx],0
    inc ebx
    loop .a
.again
    call GUIUnBuffer
    call DisplayBoxes
    call DisplayMenu
    GUIBox 75,95,192,143,160
    GUIBox 75,95,192,95,162
    GUIBox 75,95,75,143,161
    GUIBox 192,95,192,143,159
    GUIBox 75,143,192,143,158
    GUIOuttext 81,101,guicheaterror1,220-15
    GUIOuttext 80,100,guicheaterror1,220
    GUIOuttext 81,109,guicheaterror2,220-15
    GUIOuttext 80,108,guicheaterror2,220
    GUIOuttext 81,117,guicheaterror3,220-15
    GUIOuttext 80,116,guicheaterror3,220
    GUIOuttext 81,125,guicheaterror4,220-15
    GUIOuttext 80,124,guicheaterror4,220
    GUIOuttext 81,135,guicheaterror5,220-15
    GUIOuttext 80,134,guicheaterror5,220
    call vidpastecopyscr
    call JoyRead
    xor ebx,ebx
    mov ecx,256+128+64
.b
    cmp byte[pressed+ebx],0
    jne .pressedokay
    inc ebx
    loop .b
    cmp byte[MouseDis],1
    je .mousedis
    call Get_MouseData
    test bx,01h
    jnz .pressedokay
.mousedis
    jmp .again
.pressedokay
.again2
    call Check_Key
    or al,al
    jz .nokey
    call Get_Key
    jmp .again2
.nokey
    cmp byte[MouseDis],1
    je .mousedis2
    push ebx
;    mov eax,0Bh
;    int 33h
    pop ebx
.mousedis2
    mov dword[GUIcurrentcheatwin],1
    mov byte[GUIpclicked],1
    ret
guicheaterror1 db 'INVALID CODE!  YOU',0
guicheaterror2 db 'MUST ENTER A VALID',0
guicheaterror3 db 'GAME GENIE,PAR, OR',0
guicheaterror4 db 'GOLD FINGER CODE.',0
guicheaterror5 db 'PRESS ANY KEY.',0
guicheatvalrep db 0

⌨️ 快捷键说明

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