change LoadFile API

This commit is contained in:
4am 2019-06-18 22:40:17 -04:00
parent 98ed226562
commit c9a00d6bef
11 changed files with 49 additions and 115 deletions

View File

@ -78,8 +78,9 @@ OneTimeSetup
sta promote + ProDOS_unit - $bf00
; save unit while overriding !pseudopc
+LDADDR kGlobalPrefsFilename
jsr SetPath
jsr LoadFile ; load preferences file into $8000
!word kGlobalPrefsFilename
jsr ParseKeyValueList ; parse contents into OKVS data structure into LC RAM bank
!word gGlobalPrefsStore
@ -88,8 +89,10 @@ OneTimeSetup
+LDAY SRC ; (SRC) points to free space after the OKVS data structure we just created
+STAY gGamesListStore ; save pointer to free space for next store
+LDADDR kGameListConfFile
jsr SetPath
jsr LoadFile ; load games list file into $8000
!word kGameListConfFile
jsr ParseGamesList ; parse games list into OKVS data structure in LC RAM bank
!word gGamesListStore
!word ldrlo2 ; (ldrlo2) points to last load address, so $8000

View File

@ -12,8 +12,9 @@
; (only valid during slideshows, not updated once a key is pressed)
Play
+LDADDR kAttractModeConfFile
jsr SetPath
jsr LoadFile ; load attract-mode configuration file at $8000
!word kAttractModeConfFile
jsr ParseKeyValueList ; parse attract-mode configuration into OKVS data structure at $6000
!word gAttractModeStore
!word ldrlo2 ; (ldrlo2) points to last load address, so $8000
@ -91,8 +92,9 @@ Go
bcs --
stx ProDOS_prefix
+LDADDR ProDOS_prefix
jsr SetPath
jsr LoadFile
!word ProDOS_prefix
ldy #0
lda (namlo), y

View File

@ -1,10 +1,11 @@
;license:MIT
;(c) 2018 by 4am & qkumba
;(c) 2018-9 by 4am & qkumba
;
; ProRWTS2 glue functions
;
; Public functions
; - LoadFile
; - LoadFileAt
; - LoadDHRFile
; - SaveSmallFile
; - CloseHandles
@ -12,7 +13,7 @@
;
; A general note about paths:
;
; LoadFile, LoadDHRFile, and SaveSmallFile support files in subdirectories.
; LoadFile, LoadFileAt, LoadDHRFile, and SaveSmallFile support subdirectories.
; Directories are delimited by '/' like ProDOS. At program startup, we get the
; current directory and save it; that is the PROGRAM ROOT DIRECTORY. All
; pathnames are relative to the PROGRAM ROOT DIRECTORY. There is no concept of
@ -45,19 +46,13 @@ gRootDirectory
;
; supports paths, see note
;
; in: stack contains 2 bytes of parameters:
; +1 address of filename
; in: gPathname contains filename
; out: all flags clobbered
; all registers clobbered
; filename clobbered (hey, this is important, you can't call this with
; the same filename buffer twice unless you REALLY know what you're
; doing, so you should probably use one of the LOAD_* macros which
; copies the filename to a temporary buffer)
; stack set to next instruction after parameters
; gPathname clobbered
;------------------------------------------------------------------------------
LoadFile
+PARAMS_ON_STACK 2
+LDPARAM 1
+LDADDR gPathname
+STAY namlo ; set filename
jsr traverse ; go to subdirectory, set up filename for read
lda #cmdread ; read (instead of write)
@ -81,23 +76,20 @@ LoadFile
;
; supports paths, see note
;
; in: stack contains 4 bytes of parameters:
; +1 address of filename
; +3 address to load file
; in: gPathname contains filename
; stack contains 2 bytes of parameters:
; +1 address to load file
; out: all flags clobbered
; all registers clobbered
; filename clobbered (hey, this is important, you can't call this with
; the same filename buffer twice unless you REALLY know what you're
; doing, so you should probably use one of the LOAD_* macros which
; copies the filename to a temporary buffer)
; gPathname clobbered
; stack set to next instruction after parameters
;------------------------------------------------------------------------------
LoadFileAt
+PARAMS_ON_STACK 4
+PARAMS_ON_STACK 2
+LDPARAM 1
+STAY namlo ; set filename
+LDPARAM 3
+STAY ldrlo ; set load address
+LDADDR gPathname
+STAY namlo ; set filename
jsr traverse ; go to subdirectory, set up filename for read
lda #cmdread ; read (instead of write)
sta reqcmd
@ -116,15 +108,13 @@ LoadFileAt
;
; supports paths, see note
;
; in: stack contains 2 bytes of parameters:
; +1 address of filename
; in: gPathname contains filename
; out: all flags clobbered
; all registers clobbered
; stack set to next instruction after parameters
;------------------------------------------------------------------------------
LoadDHRFile
+PARAMS_ON_STACK 2
+LDPARAM 1
+LDADDR gPathname
+STAY namlo ; set filename
jsr traverse ; go to subdirectory, set up filename for read
lda #$00 ; read first $2000 bytes
@ -155,19 +145,18 @@ LoadDHRFile
;
; supports paths, see note
;
; in: stack contains 4 bytes of parameters:
; +1 address of filename
; +3 address of data buffer
; in: stack contains 2 bytes of parameters:
; +1 address of data buffer
; out: all flags clobbered
; all registers clobbered
; stack set to next instruction after parameters
;------------------------------------------------------------------------------
SaveSmallFile
+PARAMS_ON_STACK 4
+PARAMS_ON_STACK 2
+LDPARAM 1
+STAY namlo ; set filename for ProRWTS2
+LDPARAM 3
+STAY ldrlo ; set data buffer address for ProRWTS2
+LDADDR gPathname
+STAY namlo ; set filename for ProRWTS2
jsr traverse ; go to subdirectory, set up filename for read
;;if the write address is always a fixed value then we can discard the query
lda #cmdread ; read (instead of write)

View File

@ -83,21 +83,18 @@
}
!macro LOAD_FILE .subdirectory, .filename {
jsr ResetPath
+LDADDR .subdirectory
jsr AddToPath
jsr SetPath
+LDADDR kPathSeparator
jsr AddToPath
+LDAY .filename
jsr AddToPath
jsr LoadFile
!word gPathname
}
!macro LOAD_PATH .subdirectory {
jsr ResetPath
+LDADDR .subdirectory
jsr AddToPath
jsr SetPath
+LDADDR kPathSeparator
jsr AddToPath
}
@ -106,7 +103,6 @@
+LDAY .filename
jsr AddToPath
jsr LoadFile
!word gPathname
}
!macro LOW_ASCII_TO_LOWER {

View File

@ -64,8 +64,9 @@ ResetPath
rts
;------------------------------------------------------------------------------
; AddToPath
; SetPath/AddToPath
; append a length-prefixed string to gPathname
; SetPath will reset the path first
;
; in: A contains low byte of address of length-prefixed string to append
; Y contains high byte of address of length-prefixed string to append
@ -73,6 +74,9 @@ ResetPath
; $00/$01 clobbered
; gPathname updated with concatenated length-prefixed string
;------------------------------------------------------------------------------
SetPath
jsr ResetPath
; execution falls through here
AddToPath
+STAY $00
ldx gPathname ; current pathname length

View File

@ -41,8 +41,9 @@ DHGRActionSlideshow
; $6000..$BFFF/main contains transition effect code
;------------------------------------------------------------------------------
LoadDHGRTransition
+LDADDR kDFXConfFile
jsr SetPath
jsr LoadFile ; load DHGR transition effects list into $8000
!word kDFXConfFile
jsr ParseKeyValueList ; parse DHGR transition effects list into $6000
!word gDFXStore
!word ldrlo2 ; (ldrlo2) points to last load address

View File

@ -187,8 +187,9 @@ HGRActionCallback
; $6000..$BFFF contains transition effect code
;------------------------------------------------------------------------------
LoadHGRTransition
+LDADDR kFXConfFile
jsr SetPath
jsr LoadFile ; load HGR transition effects list into $8000
!word kFXConfFile
jsr ParseKeyValueList ; parse HGR transition effects list into $6000
!word gFXStore
!word ldrlo2 ; (ldrlo2) points to last load address

View File

@ -25,8 +25,10 @@
; memory, unused portions of the stack page, all registers, all flags)
;------------------------------------------------------------------------------
AttractMode
+LDADDR kAttractModeConfFile
jsr SetPath
jsr LoadFile ; load attract-mode configuration file at $8000
!word kAttractModeConfFile
jsr ParseKeyValueList ; parse attract-mode configuration into OKVS data structure at $6000
!word gAttractModeStore
!word ldrlo2 ; (ldrlo2) points to last load address, so $8000
@ -83,7 +85,9 @@ gAttractIndex
jsr @RunNextAttractModule
lda $C000
bpl AttractMode
bmi +
jmp AttractMode
+
rts
@RunNextAttractModule

View File

@ -65,15 +65,13 @@ SHRArtworkCallback
jsr BlankSHR
; load SHR artwork at $2000/main (not aux)
jsr ResetPath
+LDADDR kSHRArtworkDirectory
jsr AddToPath
jsr SetPath
+LDADDR kPathSeparator
jsr AddToPath
+LDAY PTR
jsr AddToPath
jsr LoadFile
!word gPathname
jsr $A000
jmp WaitAfterTransition

View File

@ -128,8 +128,9 @@ OnInputChanged
lda #$7F
sta UILine2+1
+LDADDR Cover
jsr SetPath
jsr LoadFile ; load default background at $2000
!word Cover
lda #22 ; draw visible search bar
sta VTAB

View File

@ -1,65 +0,0 @@
ShowCover
bit MachineStatus
bvs @Load128
jsr LoadFile
!word cover64
clc
bcc @Show
@Load128
jsr LoadDHRFile
!word cover128
sta $C000 ; double hi-res mode
sta $C00D
sta $C05E
sta $C001
@Show
sta $C057 ; show graphics page 1 (HGR or DHGR)
sta $C052
sta $C054
sta $C050
bit $C010
- lda $C000
bpl -
bit $C010
rts
cover64
!byte cover64_e-cover64_b
cover64_b
!text "COVER"
cover64_e
cover128
!byte cover128_e-cover128_b
cover128_b
!text "COVER.A2FC"
cover128_e
HGR2To1
lda #$40
sta @a+2
ldx #$20
stx @b+2
ldy #0
@a lda $FD00,y ; SMC
@b sta $FD00,y ; SMC
iny
bne @a
inc @a+2
inc @b+2
dex
bne @a
rts