mirror of
https://github.com/a2-4am/4cade.git
synced 2024-11-27 08:50:01 +00:00
Ctrl-C in search or browse mode to toggle cheats, persist in prefs file, honor pref on startup
This commit is contained in:
parent
bab7c81481
commit
de7a06f2cd
@ -1 +1 @@
|
|||||||
# Total Replay preferences file
# Do not edit by hand.
# Or do. I'm a comment, not a cop.
# value=attract mode module listed in ATTRACT.CONF, or empty
NEXTATTRACT=
# value=transition effect listed in FX.CONF, or empty
NEXTFX=
# value=transition effect listed in DFX.CONF, or empty
NEXTDFX=
[eof]
|
# Total Replay preferences file
# Do not edit by hand.
# Or do. I'm a comment, not a cop.
# value=attract mode module listed in ATTRACT.CONF, or empty
NEXTATTRACT=
# value=transition effect listed in FX.CONF, or empty
NEXTFX=
# value=transition effect listed in DFX.CONF, or empty
NEXTDFX=
# value=0 or 1
CHEAT=0
[eof]
|
@ -216,11 +216,20 @@ OneTimeSetup
|
|||||||
sta GameCount
|
sta GameCount
|
||||||
sta SAVE
|
sta SAVE
|
||||||
|
|
||||||
lda #$80 ; TODO make this a pref
|
jsr pref_get ; see if cheats are enabled by default
|
||||||
|
!word kCheat
|
||||||
|
!word 0
|
||||||
|
+STAY PTR ; (PTR) -> cheat pref value as length-prefixed string '1' or '0'
|
||||||
|
ldy #1
|
||||||
|
lda (PTR),y ; A = #$B1 or #$B0
|
||||||
|
and #1 ; A = #$01 or #$00
|
||||||
|
clc
|
||||||
|
ror
|
||||||
|
ror ; A = #$80 or #$00
|
||||||
sta gCheatsEnabled
|
sta gCheatsEnabled
|
||||||
|
|
||||||
; calculate and update visible game count (3-digit decimal number as ASCII string)
|
; calculate and update visible game count (3-digit decimal number as ASCII string)
|
||||||
ldy #0
|
dey ; Y = 0
|
||||||
@outer
|
@outer
|
||||||
lda #0
|
lda #0
|
||||||
pha
|
pha
|
||||||
|
@ -29,11 +29,14 @@ kNextFX
|
|||||||
kNextDFX
|
kNextDFX
|
||||||
!byte 7
|
!byte 7
|
||||||
!raw "NEXTDFX"
|
!raw "NEXTDFX"
|
||||||
|
kCheat
|
||||||
|
!byte 5
|
||||||
|
!raw "CHEAT"
|
||||||
|
|
||||||
;------------------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
||||||
; pref_get
|
; pref_get
|
||||||
; get pref value by pref key, and validate that the pref value exists as a key
|
; get pref value by pref key, and optionally validate that the pref value
|
||||||
; in another OKVS
|
; exists as a key in another OKVS
|
||||||
;
|
;
|
||||||
; example usage:
|
; example usage:
|
||||||
; jsr pref_get
|
; jsr pref_get
|
||||||
@ -47,10 +50,12 @@ kNextDFX
|
|||||||
;
|
;
|
||||||
; in: stack contains 4 bytes of parameters:
|
; in: stack contains 4 bytes of parameters:
|
||||||
; +1 [word] address of length-prefixed pref key
|
; +1 [word] address of length-prefixed pref key
|
||||||
; +3 [word] address of OKVS
|
; +3 [word] address of OKVS, or 0
|
||||||
; gGlobalPrefsStore must be initialized (this is done in 4cade.init)
|
; gGlobalPrefsStore must be initialized (this is done in 4cade.init)
|
||||||
; out: A/Y = address of pref value
|
; out: A/Y = address of pref value
|
||||||
; X = index of pref value in passed store
|
; X = index of pref value in passed store
|
||||||
|
; (if OKVS parameter is 0, no validation occurs and X=0 and Z=1 on exit,
|
||||||
|
; some callers rely on this behavior, so don't change it!)
|
||||||
; PARAM clobbered
|
; PARAM clobbered
|
||||||
; PTR clobbered
|
; PTR clobbered
|
||||||
; SRC clobbered
|
; SRC clobbered
|
||||||
@ -68,6 +73,8 @@ pref_get
|
|||||||
!word gGlobalPrefsStore
|
!word gGlobalPrefsStore
|
||||||
@prefkey !word $FDFD ; SMC
|
@prefkey !word $FDFD ; SMC
|
||||||
bcs .useDefaultValue ; if pref key is not found, use default value
|
bcs .useDefaultValue ; if pref key is not found, use default value
|
||||||
|
ldx @store2+1
|
||||||
|
beq @done
|
||||||
+STAY +
|
+STAY +
|
||||||
+STAY PTR
|
+STAY PTR
|
||||||
ldy #0
|
ldy #0
|
||||||
@ -84,7 +91,7 @@ pref_get
|
|||||||
@store2 !word $FDFD ; SMC
|
@store2 !word $FDFD ; SMC
|
||||||
@n !byte $FD ; SMC
|
@n !byte $FD ; SMC
|
||||||
ldx @n
|
ldx @n
|
||||||
rts
|
@done rts
|
||||||
|
|
||||||
;------------------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
||||||
; pref_set
|
; pref_set
|
||||||
@ -140,6 +147,11 @@ pref_set
|
|||||||
+LDADDR kNextDFX
|
+LDADDR kNextDFX
|
||||||
jsr @addStringFromStore
|
jsr @addStringFromStore
|
||||||
|
|
||||||
|
+LDADDR @kFluff4
|
||||||
|
jsr @addString
|
||||||
|
+LDADDR kCheat
|
||||||
|
jsr @addStringFromStore
|
||||||
|
|
||||||
+LDADDR @kEOF
|
+LDADDR @kEOF
|
||||||
jsr @addString
|
jsr @addString
|
||||||
|
|
||||||
@ -194,9 +206,12 @@ pref_set
|
|||||||
@kFluff2 !byte @kFluff3-*-1
|
@kFluff2 !byte @kFluff3-*-1
|
||||||
!byte $0D
|
!byte $0D
|
||||||
!raw "# value=transition effect listed in FX.CONF, or empty",$0D
|
!raw "# value=transition effect listed in FX.CONF, or empty",$0D
|
||||||
@kFluff3 !byte @kEOF-*-1
|
@kFluff3 !byte @kFluff4-*-1
|
||||||
!byte $0D
|
!byte $0D
|
||||||
!raw "# value=transition effect listed in DFX.CONF, or empty",$0D
|
!raw "# value=transition effect listed in DFX.CONF, or empty",$0D
|
||||||
|
@kFluff4 !byte @kEOF-*-1
|
||||||
|
!byte $0D
|
||||||
|
!raw "# value=0 or 1",$0D
|
||||||
@kEOF !byte @_-*-1
|
@kEOF !byte @_-*-1
|
||||||
!byte $0D
|
!byte $0D
|
||||||
!raw "[eof]",$0D
|
!raw "[eof]",$0D
|
||||||
|
@ -81,17 +81,21 @@ GameCount = *+1
|
|||||||
ldx BrowseSelectedIndex
|
ldx BrowseSelectedIndex
|
||||||
jsr PlayGameFromBrowse
|
jsr PlayGameFromBrowse
|
||||||
jsr BlankHGR
|
jsr BlankHGR
|
||||||
jmp +
|
jmp .ForceBrowseChanged
|
||||||
|
|
||||||
|
.OnCheat
|
||||||
|
jsr ToggleCheat
|
||||||
|
beq .ForceBrowseChanged ; always branches because Z=1 on exit from ToggleCheat
|
||||||
|
|
||||||
.OnTab
|
.OnTab
|
||||||
ldx BrowseSelectedIndex
|
ldx BrowseSelectedIndex
|
||||||
jsr MiniAttractMode
|
jsr MiniAttractMode
|
||||||
cmp #$8D
|
cmp #$8D
|
||||||
beq .OnLaunch
|
beq .OnLaunch
|
||||||
+ bit CLEARKBD
|
.ForceBrowseChanged
|
||||||
|
bit CLEARKBD
|
||||||
ldx BrowseSelectedIndex
|
ldx BrowseSelectedIndex
|
||||||
; execution falls through here
|
; execution falls through here
|
||||||
|
|
||||||
.OnBrowseChanged
|
.OnBrowseChanged
|
||||||
stx @index
|
stx @index
|
||||||
jsr okvs_nth ; get the name of the new game
|
jsr okvs_nth ; get the name of the new game
|
||||||
@ -146,6 +150,7 @@ kBrowseExitToSearch = 3
|
|||||||
kBrowseTab = 4
|
kBrowseTab = 4
|
||||||
kBrowseLaunch = 5
|
kBrowseLaunch = 5
|
||||||
kBrowseCredits = 6
|
kBrowseCredits = 6
|
||||||
|
kBrowseCheat = 7
|
||||||
|
|
||||||
.BrowseDispatchTableLo
|
.BrowseDispatchTableLo
|
||||||
!byte <.OnSearch
|
!byte <.OnSearch
|
||||||
@ -155,6 +160,7 @@ kBrowseCredits = 6
|
|||||||
!byte <.OnTab
|
!byte <.OnTab
|
||||||
!byte <.OnLaunch
|
!byte <.OnLaunch
|
||||||
!byte <Credits
|
!byte <Credits
|
||||||
|
!byte <.OnCheat
|
||||||
.BrowseDispatchTableHi
|
.BrowseDispatchTableHi
|
||||||
!byte >.OnSearch
|
!byte >.OnSearch
|
||||||
!byte >.OnPrevious
|
!byte >.OnPrevious
|
||||||
@ -163,9 +169,11 @@ kBrowseCredits = 6
|
|||||||
!byte >.OnTab
|
!byte >.OnTab
|
||||||
!byte >.OnLaunch
|
!byte >.OnLaunch
|
||||||
!byte >Credits
|
!byte >Credits
|
||||||
|
!byte >.OnCheat
|
||||||
|
|
||||||
kNumBrowseKeys = 10 ; number of entries in next 2 tables (each)
|
kNumBrowseKeys = 11 ; number of entries in next 2 tables (each)
|
||||||
.BrowseKeys
|
.BrowseKeys
|
||||||
|
!byte $83 ; Ctrl-C = toggle cheat mode
|
||||||
!byte $AF ; '/' = credits
|
!byte $AF ; '/' = credits
|
||||||
!byte $BF ; '?' = credits
|
!byte $BF ; '?' = credits
|
||||||
!byte $A0 ; Space = mini attract mode
|
!byte $A0 ; Space = mini attract mode
|
||||||
@ -177,6 +185,7 @@ kNumBrowseKeys = 10 ; number of entries in next 2 tables (each)
|
|||||||
!byte $8B ; up arrow = previous
|
!byte $8B ; up arrow = previous
|
||||||
!byte $88 ; left arrow = previous
|
!byte $88 ; left arrow = previous
|
||||||
.BrowseKeyDispatch
|
.BrowseKeyDispatch
|
||||||
|
!byte kBrowseCheat
|
||||||
!byte kBrowseCredits
|
!byte kBrowseCredits
|
||||||
!byte kBrowseCredits
|
!byte kBrowseCredits
|
||||||
!byte kBrowseTab
|
!byte kBrowseTab
|
||||||
|
@ -4,11 +4,31 @@
|
|||||||
; cheat-related UI functions
|
; cheat-related UI functions
|
||||||
;
|
;
|
||||||
; Public functions:
|
; Public functions:
|
||||||
|
; - ToggleCheat
|
||||||
; - BuildUILine1WithNoDots
|
; - BuildUILine1WithNoDots
|
||||||
; - BuildCheatLine1
|
; - BuildCheatLine1
|
||||||
; - BuildCheatLine2
|
; - BuildCheatLine2
|
||||||
;
|
;
|
||||||
|
|
||||||
|
ToggleCheat
|
||||||
|
; in: none
|
||||||
|
; out: all registers clobbered
|
||||||
|
; X = 0, Z = 1 (guaranteed by pref_set)
|
||||||
|
lda gCheatsEnabled
|
||||||
|
eor #$80
|
||||||
|
sta gCheatsEnabled
|
||||||
|
beq +
|
||||||
|
lda #$B1
|
||||||
|
+HIDE_NEXT_2_BYTES
|
||||||
|
+ lda #$B0
|
||||||
|
sta @val
|
||||||
|
jsr pref_set
|
||||||
|
!word kCheat
|
||||||
|
!word @pref
|
||||||
|
rts
|
||||||
|
@pref !byte 1
|
||||||
|
@val !byte $FD
|
||||||
|
|
||||||
BuildUILine1WithNoDots
|
BuildUILine1WithNoDots
|
||||||
; in: X = game index, or #$FF if no game selected
|
; in: X = game index, or #$FF if no game selected
|
||||||
; out: all registers clobbered
|
; out: all registers clobbered
|
||||||
|
@ -107,6 +107,10 @@ SearchMode
|
|||||||
sec ; tell caller to redraw UI
|
sec ; tell caller to redraw UI
|
||||||
rts
|
rts
|
||||||
|
|
||||||
|
.OnCheat
|
||||||
|
jsr ToggleCheat
|
||||||
|
beq .OnInputChanged ; always branches because Z=1 on exit from ToggleCheat
|
||||||
|
|
||||||
.OnSearch
|
.OnSearch
|
||||||
ldx InputLength
|
ldx InputLength
|
||||||
cpx #MaxInputLength
|
cpx #MaxInputLength
|
||||||
@ -236,7 +240,8 @@ kInputBrowse = 3
|
|||||||
kInputTab = 4
|
kInputTab = 4
|
||||||
kInputLaunch = 5
|
kInputLaunch = 5
|
||||||
kInputCredits = 6
|
kInputCredits = 6
|
||||||
kInputError = 7
|
kInputCheat = 7
|
||||||
|
kInputError = 8
|
||||||
|
|
||||||
.InputDispatchTableLo
|
.InputDispatchTableLo
|
||||||
!byte <.OnSearch
|
!byte <.OnSearch
|
||||||
@ -246,6 +251,7 @@ kInputError = 7
|
|||||||
!byte <.OnTab
|
!byte <.OnTab
|
||||||
!byte <.OnLaunch
|
!byte <.OnLaunch
|
||||||
!byte <Credits
|
!byte <Credits
|
||||||
|
!byte <.OnCheat
|
||||||
!byte <.OnError
|
!byte <.OnError
|
||||||
.InputDispatchTableHi
|
.InputDispatchTableHi
|
||||||
!byte >.OnSearch
|
!byte >.OnSearch
|
||||||
@ -255,10 +261,12 @@ kInputError = 7
|
|||||||
!byte >.OnTab
|
!byte >.OnTab
|
||||||
!byte >.OnLaunch
|
!byte >.OnLaunch
|
||||||
!byte >Credits
|
!byte >Credits
|
||||||
|
!byte >.OnCheat
|
||||||
!byte >.OnError
|
!byte >.OnError
|
||||||
|
|
||||||
kNumInputKeys = 8 ; number of entries in next 2 tables (each)
|
kNumInputKeys = 9 ; number of entries in next 2 tables (each)
|
||||||
.InputKeys
|
.InputKeys
|
||||||
|
!byte $83 ; Ctrl-C = toggle cheat mode
|
||||||
!byte $AF ; '/' = credits
|
!byte $AF ; '/' = credits
|
||||||
!byte $BF ; '?' = credits
|
!byte $BF ; '?' = credits
|
||||||
!byte $A0 ; Space = mini attract mode
|
!byte $A0 ; Space = mini attract mode
|
||||||
@ -270,6 +278,7 @@ kNumInputKeys = 8 ; number of entries in next 2 tables (each)
|
|||||||
!byte $9B ; Esc = clear input buffer (if any)
|
!byte $9B ; Esc = clear input buffer (if any)
|
||||||
; or switch to mega attract mode
|
; or switch to mega attract mode
|
||||||
.InputKeyDispatch
|
.InputKeyDispatch
|
||||||
|
!byte kInputCheat
|
||||||
!byte kInputCredits
|
!byte kInputCredits
|
||||||
!byte kInputCredits
|
!byte kInputCredits
|
||||||
!byte kInputTab
|
!byte kInputTab
|
||||||
|
Loading…
Reference in New Issue
Block a user