refactoring

This commit is contained in:
4am 2019-09-21 18:04:38 -04:00
parent d28a84a6f6
commit cc7ea09ec9
10 changed files with 114 additions and 149 deletions

View File

@ -9,8 +9,6 @@
; - Launch ; - Launch
; ;
!zone {
GetGameDisplayName GetGameDisplayName
; in: A/Y points to game filename ; in: A/Y points to game filename
; X = #$60 if we should only look in gGamesListStore for a match ; X = #$60 if we should only look in gGamesListStore for a match
@ -173,4 +171,3 @@ Launch
dey dey
bne - bne -
jmp $106 ; jump to pre-launch code jmp $106 ; jump to pre-launch code
}

View File

@ -60,6 +60,22 @@ kStandardPrelaunch
!byte 8 !byte 8
!raw "STANDARD" !raw "STANDARD"
kFXConfFile
!byte 7
!text "FX.CONF"
kDFXConfFile
!byte 8
!text "DFX.CONF"
kCreditsFile
!byte 7
!text "CREDITS"
kCoverFadeFile
!byte 9
!text "COVERFADE"
;------------------------------------------------------------------------------ ;------------------------------------------------------------------------------
; SetPath/AddToPath ; SetPath/AddToPath
; append a length-prefixed string to gPathname ; append a length-prefixed string to gPathname

View File

@ -9,8 +9,6 @@
; - DHGRSingle ; - DHGRSingle
; ;
!zone {
DHGRTitleSlideshow DHGRTitleSlideshow
bit MachineStatus ; only run DHGR slideshow if we have 128K bit MachineStatus ; only run DHGR slideshow if we have 128K
bvs + bvs +
@ -86,9 +84,6 @@ DHGRSingle
@filename !word $FDFD ; SMC @filename !word $FDFD ; SMC
!word $6000 !word $6000
rts rts
kDFXConfFile
!byte 8
!text "DFX.CONF"
;------------------------------------------------------------------------------ ;------------------------------------------------------------------------------
; .DHGRTitleCallback [private] ; .DHGRTitleCallback [private]
@ -162,5 +157,3 @@ kDFXConfFile
+LDADDR $6000 +LDADDR $6000
jmp ExecuteTransitionAndWait jmp ExecuteTransitionAndWait
}

View File

@ -8,8 +8,6 @@
; - GRSingle ; - GRSingle
; ;
!zone {
GRActionSlideshow GRActionSlideshow
jsr .LoadGRTransition ; load transition effect code at $6000 jsr .LoadGRTransition ; load transition effect code at $6000
jsr BlankGR ; switch GR mode with initial blank screen jsr BlankGR ; switch GR mode with initial blank screen
@ -108,5 +106,3 @@ kGRFizzleFile
+LDADDR $6400 +LDADDR $6400
jmp ExecuteTransitionAndWait jmp ExecuteTransitionAndWait
}

View File

@ -9,8 +9,6 @@
; - HGRSingle ; - HGRSingle
; ;
!zone {
HGRTitleSlideshow HGRTitleSlideshow
jsr .LoadHGRTransition ; load transition effect code at $6000 jsr .LoadHGRTransition ; load transition effect code at $6000
jsr okvs_iter ; cycle through all listed HGR files jsr okvs_iter ; cycle through all listed HGR files
@ -187,7 +185,3 @@ HGRSingle
@filename !word $FDFD ; SMC @filename !word $FDFD ; SMC
!word $6000 !word $6000
rts rts
kFXConfFile
!byte 7
!text "FX.CONF"
}

View File

@ -8,8 +8,6 @@
; - SHRSingle ; - SHRSingle
; ;
!zone {
SHRSlideshow SHRSlideshow
lda MachineStatus ; only show SHR on IIgs or if we have a VidHD card lda MachineStatus ; only show SHR on IIgs or if we have a VidHD card
and #SUPPORTS_SHR and #SUPPORTS_SHR
@ -137,5 +135,3 @@ kSFXFizzleFile
sta NEWVIDEO sta NEWVIDEO
rts rts
}

View File

@ -7,8 +7,6 @@
; - BrowseMode ; - BrowseMode
; ;
!zone {
;------------------------------------------------------------------------------ ;------------------------------------------------------------------------------
; BrowseMode ; BrowseMode
; main entry point for Browse Mode, which allows the user to browse the game ; main entry point for Browse Mode, which allows the user to browse the game
@ -21,44 +19,44 @@ BrowseMode
ldx #$FF ldx #$FF
txs txs
.BrowseModeInputLoop @BrowseModeInputLoop
jsr WaitForKeyFor30Seconds jsr WaitForKeyFor30Seconds
bit CLEARKBD bit CLEARKBD
ldy #kNumBrowseKeys ldy #kNumBrowseKeys
- dey - dey
bmi @noKeyMatch bmi @noKeyMatch
cmp .BrowseKeys,y cmp BrowseKeys,y
bne - bne -
ldx .BrowseKeyDispatch,y ldx BrowseKeyDispatch,y
bne @BrowseDispatch ; always branches bne @BrowseDispatch ; always branches
@noKeyMatch @noKeyMatch
jsr IsSearchKey jsr IsSearchKey
beq + beq +
jsr SoftBell ; beep on invalid input jsr SoftBell ; beep on invalid input
jmp .BrowseModeInputLoop ; and start over jmp @BrowseModeInputLoop ; and start over
+ +
ldx #kBrowseSearch ldx #kBrowseSearch
; execution falls through here ; execution falls through here
@BrowseDispatch @BrowseDispatch
ldy .BrowseDispatchTableLo,x ldy BrowseDispatchTableLo,x
sty @j+1 sty @j+1
ldy .BrowseDispatchTableHi,x ldy BrowseDispatchTableHi,x
sty @j+2 sty @j+2
@j jsr $FDFD ; SMC @j jsr $FDFD ; SMC
jmp .BrowseModeInputLoop jmp @BrowseModeInputLoop
.OnSearch OnBrowseSearch
sta InputBuffer sta InputBuffer
lda #$01 lda #$01
sta InputLength sta InputLength
jmp SearchMode jmp SearchMode
.OnPrevious OnBrowsePrevious
dec gGameToLaunch dec gGameToLaunch
jmp + jmp +
.OnNext OnBrowseNext
inc gGameToLaunch inc gGameToLaunch
+ +
ldx gGameToLaunch ldx gGameToLaunch
@ -73,27 +71,28 @@ GameCount = *+1
bcc @done bcc @done
ldx #0 ldx #0
@done stx gGameToLaunch @done stx gGameToLaunch
jmp .OnBrowseChanged jmp OnBrowseChanged
.OnLaunch OnBrowseLaunch
jsr PlayGame jsr PlayGame
jsr BlankHGR jsr BlankHGR
jmp .ForceBrowseChanged jmp ForceBrowseChanged
.OnCheat OnBrowseCheat
jsr ToggleCheat jsr ToggleCheat
beq .ForceBrowseChanged ; always branches because Z=1 on exit from ToggleCheat beq ForceBrowseChanged ; always branches because Z=1 on exit from ToggleCheat
.OnTab OnBrowseTab
ldx gGameToLaunch ldx gGameToLaunch
jsr MiniAttractMode jsr MiniAttractMode
cmp #$8D cmp #$8D
beq .OnLaunch beq OnBrowseLaunch
.ForceBrowseChanged ; execution falls through here
ForceBrowseChanged
bit CLEARKBD bit CLEARKBD
ldx gGameToLaunch ldx gGameToLaunch
; execution falls through here ; execution falls through here
.OnBrowseChanged OnBrowseChanged
; in: X = game index ; in: X = game index
jsr LoadGameTitleOffscreen jsr LoadGameTitleOffscreen
jmp DrawUIWithoutDots jmp DrawUIWithoutDots
@ -110,27 +109,27 @@ kBrowseLaunch = 5
kBrowseCredits = 6 kBrowseCredits = 6
kBrowseCheat = 7 kBrowseCheat = 7
.BrowseDispatchTableLo BrowseDispatchTableLo
!byte <.OnSearch !byte <OnBrowseSearch
!byte <.OnPrevious !byte <OnBrowsePrevious
!byte <.OnNext !byte <OnBrowseNext
!byte <SearchMode !byte <SearchMode
!byte <.OnTab !byte <OnBrowseTab
!byte <.OnLaunch !byte <OnBrowseLaunch
!byte <Credits !byte <Credits
!byte <.OnCheat !byte <OnBrowseCheat
.BrowseDispatchTableHi BrowseDispatchTableHi
!byte >.OnSearch !byte >OnBrowseSearch
!byte >.OnPrevious !byte >OnBrowsePrevious
!byte >.OnNext !byte >OnBrowseNext
!byte >SearchMode !byte >SearchMode
!byte >.OnTab !byte >OnBrowseTab
!byte >.OnLaunch !byte >OnBrowseLaunch
!byte >Credits !byte >Credits
!byte >.OnCheat !byte >OnBrowseCheat
kNumBrowseKeys = 11 ; 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 $83 ; Ctrl-C = toggle cheat mode
!byte $AF ; '/' = credits !byte $AF ; '/' = credits
!byte $BF ; '?' = credits !byte $BF ; '?' = credits
@ -142,7 +141,7 @@ kNumBrowseKeys = 11 ; number of entries in next 2 tables (each)
!byte $95 ; right arrow = next !byte $95 ; right arrow = next
!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 kBrowseCheat
!byte kBrowseCredits !byte kBrowseCredits
!byte kBrowseCredits !byte kBrowseCredits
@ -154,4 +153,3 @@ kNumBrowseKeys = 11 ; number of entries in next 2 tables (each)
!byte kBrowseNext !byte kBrowseNext
!byte kBrowsePrevious !byte kBrowsePrevious
!byte kBrowsePrevious !byte kBrowsePrevious
}

View File

@ -13,22 +13,20 @@
; - DrawSearchUI ; - DrawSearchUI
; - ShowOtherPage ; - ShowOtherPage
; - ToggleOffscreenPage ; - ToggleOffscreenPage
; - CoverFade
; - SoftBell ; - SoftBell
; - Home ; - Home
; - BlankHGR ; - BlankHGR
; - BlankDHGR ; - BlankDHGR
; - ClearOffscreen ; - ClearOffscreen
; - ExecuteTransitionAndWait
; - IsSearchKey ; - IsSearchKey
; - ExecuteTransitionAndWait
; - CoverFade
; Public variables ; Public variables
; - OffscreenPage ; - OffscreenPage
; - VisibleGameCount (set during init) ; - VisibleGameCount (set during init)
; ;
!zone {
OffscreenPage OffscreenPage
!byte 1 ; 0 = currently showing HGR page 2 !byte 1 ; 0 = currently showing HGR page 2
; (so offscreen is page 1 @ $2000) ; (so offscreen is page 1 @ $2000)
@ -159,30 +157,6 @@ LoadGameTitleOffscreen
+ !byte $FD ; SMC + !byte $FD ; SMC
rts rts
;------------------------------------------------------------------------------
; CoverFade
; load cover screen and animate per-character fade
;
; in: none
; out: all flags and registers clobbered
;------------------------------------------------------------------------------
CoverFade
jsr LoadCoverOffscreen
jsr ShowOtherPage
lda OffscreenPage
bne +
jsr LoadCoverOffscreen
jsr ShowOtherPage
+
jsr LoadFile ; load transition effect code at $6000
!word kFXDirectory
!word @CoverFadeFile
!word $6000
jmp $6000 ; exit via loaded code
@CoverFadeFile
!byte 9
!text "COVERFADE"
;------------------------------------------------------------------------------ ;------------------------------------------------------------------------------
; DrawUIWithoutDots/DrawUI ; DrawUIWithoutDots/DrawUI
; draw 2- or 4-line UI on the HGR page that is not currently showing, then ; draw 2- or 4-line UI on the HGR page that is not currently showing, then
@ -630,7 +604,17 @@ WaitForKeyFor30Seconds
bne @loop ; on every keypress (whether or not bne @loop ; on every keypress (whether or not
dec Timeout+2 ; the key leads to an action) dec Timeout+2 ; the key leads to an action)
bne @loop bne @loop
jsr CoverFade ; no input for ~30 seconds, switch to ; execution falls through here
jmp MegaAttractMode ; mega-attract mode CoverFade
jsr LoadCoverOffscreen
} jsr ShowOtherPage
lda OffscreenPage
bne +
jsr LoadCoverOffscreen
jsr ShowOtherPage
+ jsr LoadFile ; load transition effect code at $6000
!word kFXDirectory
!word kCoverFadeFile
!word $6000
jsr $6000 ; call transition effect
jmp MegaAttractMode ; exit via mega attract mode

View File

@ -6,13 +6,11 @@
; Public functions ; Public functions
; - Credits ; - Credits
!zone {
Credits Credits
; clobbers all ; clobbers all
jsr LoadFile ; load credits text into $8000 jsr LoadFile ; load credits text into $8000
!word kRootDirectory !word kRootDirectory
!word .CreditsFile !word kCreditsFile
!word $8000 !word $8000
jsr ClearOffscreen jsr ClearOffscreen
lda OffscreenPage lda OffscreenPage
@ -25,7 +23,3 @@ Credits
jsr ShowOtherPage ; back to previous page jsr ShowOtherPage ; back to previous page
clc ; if called from search mode, tell caller not to refresh clc ; if called from search mode, tell caller not to refresh
rts rts
.CreditsFile
!byte 7
!text "CREDITS"
}

View File

@ -7,8 +7,6 @@
; - SearchMode ; - SearchMode
; ;
!zone {
;------------------------------------------------------------------------------ ;------------------------------------------------------------------------------
; SearchMode ; SearchMode
; main entry point for Search Mode, which allows the user to search the game ; main entry point for Search Mode, which allows the user to search the game
@ -24,11 +22,11 @@ SearchMode
inx inx
stx OffscreenPage ; $00 = currently showing HGR page 2 stx OffscreenPage ; $00 = currently showing HGR page 2
jsr Home ; clear screen (switches to text mode) jsr Home ; clear screen (switches to text mode)
jsr .OnInputChanged ; draw UI on HGR page 1 jsr OnInputChanged ; draw UI on HGR page 1
jsr HGRMode ; show HGR screen jsr HGRMode ; show HGR screen
bit CLEARKBD bit CLEARKBD
.SearchModeInputLoop @SearchModeInputLoop
jsr WaitForKeyFor30Seconds jsr WaitForKeyFor30Seconds
; Don't clear keyboard strobe yet. If the user pressed an arrow key, ; Don't clear keyboard strobe yet. If the user pressed an arrow key,
@ -49,9 +47,9 @@ SearchMode
ldy #kNumBrowseKeys ldy #kNumBrowseKeys
- dey - dey
bmi @noKeyMatch bmi @noKeyMatch
cmp .InputKeys,y cmp InputKeys,y
bne - bne -
ldx .InputKeyDispatch,y ldx InputKeyDispatch,y
bne @InputDispatch ; always branches bne @InputDispatch ; always branches
@noKeyMatch @noKeyMatch
@ -63,63 +61,63 @@ SearchMode
ldx #kInputSearch ldx #kInputSearch
; execution falls through here ; execution falls through here
@InputDispatch @InputDispatch
ldy .InputDispatchTableLo,x ldy InputDispatchTableLo,x
sty @j+1 sty @j+1
ldy .InputDispatchTableHi,x ldy InputDispatchTableHi,x
sty @j+2 sty @j+2
@j jsr $FDFD ; SMC @j jsr $FDFD ; SMC
bcc .SearchModeInputLoop ; if carry is clear, we're done bcc @SearchModeInputLoop ; if carry is clear, we're done
bcs SearchMode ; if carry is set, force full redraw bcs SearchMode ; if carry is set, force full redraw
.OnError OnError
jmp SoftBell ; Beep on invalid input and start over. jmp SoftBell ; Beep on invalid input and start over.
.OnClear OnClear
ldx InputLength ldx InputLength
bne + bne +
jsr CoverFade ; Esc with no input switches to jmp CoverFade ; Esc with no input transitions to
jmp MegaAttractMode ; mega-attract mode ; mega attract mode
+ ldx #0 ; Esc with input clears the input + ldx #0 ; Esc with input clears the input
stx InputLength stx InputLength
beq .OnInputChanged ; always branches beq OnInputChanged ; always branches
.OnBack OnBack
ldx InputLength ldx InputLength
beq .OnError beq OnError
dec InputLength dec InputLength
jmp .OnInputChanged jmp OnInputChanged
.OnTab OnTab
ldx gGameToLaunch ldx gGameToLaunch
cpx #$FF cpx #$FF
beq .OnError beq OnError
jsr MiniAttractMode jsr MiniAttractMode
cmp #$8D ; if we exited mini attract mode cmp #$8D ; if we exited mini attract mode
beq .OnLaunch ; by pressing Enter, launch the game beq OnLaunch ; by pressing Enter, launch the game
sec ; tell caller to redraw UI sec ; tell caller to redraw UI
rts rts
.OnLaunch OnLaunch
ldx gGameToLaunch ldx gGameToLaunch
cpx #$FF cpx #$FF
beq .OnError beq OnError
jsr PlayGame jsr PlayGame
sec ; tell caller to redraw UI sec ; tell caller to redraw UI
rts rts
.OnCheat OnCheat
dec gGameToLaunch ; force reload (will be reset to correct value in .OnInputChanged) dec gGameToLaunch ; force reload (will be reset to correct value in OnInputChanged)
jsr ToggleCheat jsr ToggleCheat
beq .OnInputChanged ; always branches because Z=1 on exit from ToggleCheat beq OnInputChanged ; always branches because Z=1 on exit from ToggleCheat
.OnSearch OnSearch
ldx InputLength ldx InputLength
cpx #MaxInputLength cpx #MaxInputLength
beq .OnError beq OnError
sta InputBuffer,x sta InputBuffer,x
inc InputLength inc InputLength
; execution falls through here ; execution falls through here
.OnInputChanged OnInputChanged
lda InputLength lda InputLength
bne @findMatchingTitle bne @findMatchingTitle
; no input, reset params and UI ; no input, reset params and UI
@ -141,7 +139,7 @@ SearchMode
bne + bne +
; no matches for this input buffer ; no matches for this input buffer
dec InputLength ; ignore the last key typed dec InputLength ; ignore the last key typed
jmp .OnError ; beep and return jmp OnError ; beep and return
+ +
ldx BestMatchIndex ; check if the new best match is the same ldx BestMatchIndex ; check if the new best match is the same
cpx gGameToLaunch ; as the current best match cpx gGameToLaunch ; as the current best match
@ -167,29 +165,29 @@ kInputCredits = 6
kInputCheat = 7 kInputCheat = 7
kInputError = 8 kInputError = 8
.InputDispatchTableLo InputDispatchTableLo
!byte <.OnSearch !byte <OnSearch
!byte <.OnClear !byte <OnClear
!byte <.OnBack !byte <OnBack
!byte <BrowseMode !byte <BrowseMode
!byte <.OnTab !byte <OnTab
!byte <.OnLaunch !byte <OnLaunch
!byte <Credits !byte <Credits
!byte <.OnCheat !byte <OnCheat
!byte <.OnError !byte <OnError
.InputDispatchTableHi InputDispatchTableHi
!byte >.OnSearch !byte >OnSearch
!byte >.OnClear !byte >OnClear
!byte >.OnBack !byte >OnBack
!byte >BrowseMode !byte >BrowseMode
!byte >.OnTab !byte >OnTab
!byte >.OnLaunch !byte >OnLaunch
!byte >Credits !byte >Credits
!byte >.OnCheat !byte >OnCheat
!byte >.OnError !byte >OnError
kNumInputKeys = 9 ; 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 $83 ; Ctrl-C = toggle cheat mode
!byte $AF ; '/' = credits !byte $AF ; '/' = credits
!byte $BF ; '?' = credits !byte $BF ; '?' = credits
@ -201,7 +199,7 @@ kNumInputKeys = 9 ; number of entries in next 2 tables (each)
!byte $8D ; ENTER = launch current game (if any) !byte $8D ; ENTER = launch current game (if any)
!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 kInputCheat
!byte kInputCredits !byte kInputCredits
!byte kInputCredits !byte kInputCredits
@ -211,4 +209,3 @@ kNumInputKeys = 9 ; number of entries in next 2 tables (each)
!byte kInputBack !byte kInputBack
!byte kInputLaunch !byte kInputLaunch
!byte kInputClear !byte kInputClear
}