Skip to content

Commit

Permalink
consolidate prefix handling
Browse files Browse the repository at this point in the history
  • Loading branch information
peterferrie committed Oct 9, 2019
1 parent 45bdefe commit e391dcd
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 47 deletions.
4 changes: 2 additions & 2 deletions src/constants.a
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
64 changes: 38 additions & 26 deletions src/glue.launch.a
Original file line number Diff line number Diff line change
Expand Up @@ -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 -
; 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
plp
bcs --
stx ProDOS_prefix
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
Expand Down
2 changes: 1 addition & 1 deletion src/prodos.impl.a
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 1 addition & 4 deletions src/prodos.path.a
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ kDemoDirectory
kGameDirectory
!byte 2
!raw "X/"
kGameDirectoryLen = 3 ; we need this elsewhere

kFXDirectory
!byte 3
Expand Down Expand Up @@ -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"
;}
7 changes: 0 additions & 7 deletions src/ui.animation.a
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 0 additions & 7 deletions src/ui.attract.mode.a
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit e391dcd

Please sign in to comment.