consolidate prefix handling

This commit is contained in:
Peter Ferrie 2019-10-08 21:25:10 -07:00
parent 45bdefea5f
commit e391dcd5e2
6 changed files with 43 additions and 48 deletions

View File

@ -9,7 +9,7 @@
; D000..E611 - persistent data structures (per-game cheat categories,
; gGlobalPrefsStore, gGamesListStore)
; ...unused...
; EC41..FFF9 - main program code
; EC5F..FFF9 - main program code
; FFFA..FFFF - NMI, reset, IRQ vectors
;
; LC RAM BANK 2
@ -99,7 +99,7 @@ BestMatchIndex = $FD ; byte
; $FF ; used by ParseGamesList
; main memory
gPathname = $1F00 ; used by SetPath/AddToPath
gPathname = $BFD0 ; used by SetPath/AddToPath
gKeyLen = $1F00 ; used by ParseGamesList
gKey = $1F01
UILine1 = $1FB0

View File

@ -105,35 +105,47 @@ PlayGame
@pfile !word $FDFD
!word $0106
ldx #1 ; construct path to game's startup file
sec ; which is always /X/game/game
!byte $2c
-- pha
clc
php
ldy #0
lda (SAVE), y
tay
iny
sty MAX
ldy #0
lda #'X'
sta ProDOS_prefix+1
lda #'/'
- inx
sta ProDOS_prefix, x
iny
lda (SAVE), y
cpy MAX
bne -
txa
plp
bcs --
stx ProDOS_prefix
; we start by placing the subdirectory name at gPathname+kGameDirectoryLen
; to leave room for the GameDirectory name as the parent
lda #kGameDirectoryLen
sta gPathname
+LDAY SAVE
jsr AddToPath
; then we save the length of the resulting string without the count byte
ldx gPathname
dex
txa
pha
; attach the separator
inc gPathname
lda #'/'
sta gPathname+1,x
; then attach the game name
+LDAY SAVE
jsr AddToPath
; don't look while I do this
; we "place" a string at gPathname+kGameDirectoryLen
; whose length is the subdirectory name and game name
; then we load it
; the load sets the path to the GameDirectory
; and then finds the subdirectory name and game name right after it
; and attaches it to the path by overwriting the count byte
sec
lda gPathname
sbc #kGameDirectoryLen
sta gPathname+kGameDirectoryLen
jsr LoadFile ; load the game startup file
!word kRootDirectory
!word ProDOS_prefix
!word kGameDirectory
!word gPathname+kGameDirectoryLen
!word 0 ; use file's default address
pla

View File

@ -524,7 +524,7 @@ ProDOS_fatal ;only for debugging, will be removed
;;*=$bf58
;; !fill $18 ;filled by init instead
ProDOS_prefix=$bfd0
ProDOS_prefix=gPathname
; !fill $2e
}
end_promote

View File

@ -51,6 +51,7 @@ kDemoDirectory
kGameDirectory
!byte 2
!raw "X/"
kGameDirectoryLen = 3 ; we need this elsewhere
kFXDirectory
!byte 3
@ -144,7 +145,3 @@ AddToPath
stx gPathname
@done
rts
;!if >kTitleFile != >kCoverFile {
; !error ">kTitleFile != >kCoverFile, uncomment LoadTitleOffscreen block in ui.offscreen and disable this check"
;}

View File

@ -42,13 +42,6 @@ MaybeAnimateTitle
+ !word $FDFD
!word 0
ldy kAnimatedTitleDirectory
sty ProDOS_prefix ; temporarily set 'root' directory to
- lda kAnimatedTitleDirectory,y;/title.animated/ so animation file
sta ProDOS_prefix, y ; can load other files in the same subdirectory
dey
bne -
ldx #5 ; copy prelaunch code
- lda @titleAnimPrelaunch,x
sta $106,x

View File

@ -150,13 +150,6 @@ RunAttractModule
!word kStandardPrelaunch
!word $0106
ldy kDemoDirectory
sty ProDOS_prefix ; temporarily set 'root' directory to
- lda kDemoDirectory, y ; /demos/ directory so demos can can load
sta ProDOS_prefix, y ; other resources in the same directory
dey
bne -
jsr LoadFile ; load self-running demo into its default address (varies)
!word kDemoDirectory
@key !word $FDFD