pitch-dark/src/glue.common.a

46 lines
1.5 KiB
Plaintext

;license:MIT
;(c) 2018 by 4am
;
; Common functions across glue code
;
; Public functions
; - SetStartupPathToCurrentVersionOfCurrentGame
;
; Public constants
; - kGameRootDirectory
;
kGameRootDirectory ; length-prefixed pathname of game subdirectories
!byte 2
!raw "Z/"
;------------------------------------------------------------------------------
; SetStartupPathToCurrentVersionOfCurrentGame
; gets path+filename of current version of current game and stores it in $2006
;
; in: current ProDOS prefix is the same as the ONBEYOND.SYSTEM file
; out: all other registers and flags clobbered
;------------------------------------------------------------------------------
SetStartupPathToCurrentVersionOfCurrentGame
jsr ResetPath ; gPathname = ''
+LDADDR kGameRootDirectory ; gPathname = game root directory + '/'
jsr AddToPath
jsr okvs_get
!word gGlobalPrefsStore
!word kLastPlayed
+STAY + ; A/Y contains address
jsr AddToPath ; gPathname = root + '/' + game shortname
+LDADDR kPathSeparator
jsr AddToPath ; gPathname = root + '/' + game shortname + '/'
jsr okvs_get
!word gGlobalPrefsStore
+ !word $FDFD ; SMC
jsr AddToPath ; gPathname = root + '/' + game shortname + '/' + game filename
+LDADDR gPathname
jmp SetStartupPath ; store gPathname at $2006 to pass it to interpreter