shave some bytes

This commit is contained in:
4am 2019-10-08 14:43:41 -04:00
parent b006096104
commit 2d392ba566
7 changed files with 26 additions and 27 deletions

View File

@ -9,7 +9,7 @@
; D000..E611 - persistent data structures (per-game cheat categories,
; gGlobalPrefsStore, gGamesListStore)
; ...unused...
; EC0C..FFF9 - main program code
; EC22..FFF9 - main program code
; FFFA..FFFF - NMI, reset, IRQ vectors
;
; LC RAM BANK 2

View File

@ -4,6 +4,7 @@
; Functions to launch games and self-running demos
;
; Public functions
; - GetGameToLaunch
; - GetGameInfo
; - GetGameInfoInActionSlideshow
; - PlayGame
@ -13,6 +14,14 @@
; - gGameToLaunch - 0-based index into gGamesListStore
;
GetGameToLaunch
; in: gGameToLaunch = index into gGamesListStore
; out: A/Y points to game filename
gGameToLaunch=*+1
ldx #$FF ; SMC
+LDADDR gGamesListStore
jmp okvs_nth
GetGameInfo
; in: A/Y points to game filename
; out: C clear if game exists in gGamesListStore, and
@ -73,10 +82,7 @@ GetGameInfoInActionSlideshow
@exit rts
PlayGame
gGameToLaunch=*+1
ldx #$FF ; SMC
+LDADDR gGamesListStore
jsr okvs_nth
jsr GetGameToLaunch
; A/Y = address of game filename
+STAY SAVE
+STAY @pfile ; assume we're loading a game-specific prelaunch file

View File

@ -41,13 +41,12 @@ MaybeAnimateTitle
dex
bne @a
+LDADDR gGamesListStore ; if so, load the animation routine
ldx gGameToLaunch ; which is stored in a subdirectory
jsr okvs_nth ; and keyed off the current game's
+STAY @fname ; filename
jsr GetGameToLaunch ; load the animation routine, which is
; stored in a subdirectory by filename
+STAY +
jsr LoadFile
!word kAnimatedTitleDirectory
@fname !word $FDFD
+ !word $FDFD
!word 0
ldy kAnimatedTitleDirectory

View File

@ -69,15 +69,13 @@ MegaAttractMode
; MiniAttractMode
; run attract modules related to one game
;
; in: X = index in gGamesListStore
; gGlobalPrefsStore must be initialized
; in: gGameToLaunch = index in gGamesListStore
; out: all flags and registers clobbered
; assume all of main memory has been clobbered
;------------------------------------------------------------------------------
MiniAttractMode
+LDADDR gGamesListStore
jsr okvs_nth
+STAY @fname
jsr GetGameToLaunch
+STAY +
jsr BlankHGR
@ -86,7 +84,7 @@ MiniAttractMode
@loop
jsr LoadFile ; load mini attract mode configuration file into $8000
!word kMiniAttractDirectory
@fname !word $FDFD ; SMC
+ !word $FDFD ; SMC
- !word $8000
jsr ParseKeyValueList ; parse configuration into OKVS data structure at $6000

View File

@ -99,7 +99,6 @@ OnBrowseCheat
beq ForceBrowseChanged ; always branches because Z=1 on exit from ToggleCheat
OnBrowseTab
ldx gGameToLaunch
jsr MiniAttractMode
cmp #$8D
beq OnBrowseLaunch
@ -111,7 +110,6 @@ OnBrowseChanged
; in: gGameToLaunch = game index
jsr SwitchToBank2
jsr EnableAcceleratorAndSwitchToBank1
ldx gGameToLaunch
jsr LoadGameTitleOffscreen
jsr DrawUIWithoutDots
jsr SwitchToBank2

View File

@ -89,17 +89,16 @@ LoadOffscreenFromAY
rts
LoadGameTitleOffscreen
; in: X = game index
+LDADDR gGamesListStore
jsr okvs_nth
+STAY @fname
; in: gGameToLaunch = index into gGamesListStore
jsr GetGameToLaunch
+STAY +
jsr GetOffscreenAddress
sta +
sta ++
jsr LoadFile
!word kHGRTitleDirectory
@fname !word $FDFD ; SMC
+ !word $FDFD ; SMC
!byte $00
+ !byte $FD ; SMC
++ !byte $FD ; SMC
rts
;------------------------------------------------------------------------------

View File

@ -95,8 +95,7 @@ DrawUI
cpx #$FF ; if no game, nothing more to do on UI line 2
beq @doneWithLine2
+LDADDR gGamesListStore
jsr okvs_nth
jsr GetGameToLaunch
jsr okvs_get_current
; (PTR) -> game title
ldy #0 ; copy game title into UI line 2