mirror of
https://github.com/a2-4am/pitch-dark.git
synced 2025-01-01 14:31:16 +00:00
okvs_update, move gPrefsStore to immediately after end of code
This commit is contained in:
parent
f4a8190cf7
commit
c87b07f35c
@ -6,9 +6,6 @@
|
||||
; Public functions
|
||||
; - LoadGameInfo
|
||||
;
|
||||
; Public variables
|
||||
; - gCurrentGame
|
||||
;
|
||||
; Public constants
|
||||
; - kNumberOfGames
|
||||
; - GAMES
|
||||
|
70
src/okvs.a
70
src/okvs.a
@ -9,7 +9,7 @@
|
||||
; - okvs_append(address, key, value, max_len)
|
||||
; - okvs_update(address, key, value)
|
||||
; - okvs_get(address, key)
|
||||
; - okvs_iter(address, callback)
|
||||
; - [TODO] okvs_iter(address, callback)
|
||||
;
|
||||
; Used for global preferences, per-game options, and per-game version lists
|
||||
;
|
||||
@ -63,6 +63,7 @@
|
||||
PTR = $02
|
||||
SRC = $04
|
||||
DEST = $06
|
||||
SAVE = $08
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; okvs_init
|
||||
@ -197,7 +198,7 @@ okvs_append
|
||||
; +3 [word] address of key
|
||||
; out: if C clear, key was found and A/Y = lo/hi address of value
|
||||
; if C set, key was not found and all registers are clobbered
|
||||
; all other flags
|
||||
; all other flags clobbered
|
||||
; $00/$01 clobbered
|
||||
; $02/$03 clobbered
|
||||
; $04/$05 clobbered
|
||||
@ -244,6 +245,7 @@ okvs_get
|
||||
ldy PTR+1
|
||||
clc
|
||||
adc .matchlen
|
||||
adc #2
|
||||
sta PTR
|
||||
bcc +
|
||||
iny
|
||||
@ -256,25 +258,73 @@ okvs_get
|
||||
.fail sec
|
||||
rts
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; okvs_update
|
||||
;
|
||||
; in: stack contains 6 bytes of parameters:
|
||||
; +1 [word] handle to storage space
|
||||
; +3 [word] address of key
|
||||
; +5 [word] address of new value
|
||||
; out: if C clear, key was found and value was updated
|
||||
; if C set, key was not found
|
||||
; all registers are clobbered
|
||||
; all other flags clobbered
|
||||
; $00/$01 clobbered
|
||||
; $02/$03 clobbered
|
||||
; $04/$05 clobbered
|
||||
;------------------------------------------------------------------------------
|
||||
okvs_update
|
||||
+PARAMS_ON_STACK 6
|
||||
ldy #6
|
||||
lda (PARAM),y
|
||||
sta SAVE+1
|
||||
dey
|
||||
lda (PARAM),y
|
||||
sta SAVE
|
||||
dey
|
||||
- lda (PARAM),y
|
||||
sta .getparams,y
|
||||
dey
|
||||
bne -
|
||||
jsr okvs_get
|
||||
.getparams=*-1
|
||||
!word $FDFD ; set at runtime
|
||||
!word $FDFD ; set at runtime
|
||||
bcs .exit
|
||||
sta DEST
|
||||
sty DEST+1
|
||||
lda (SAVE)
|
||||
tay
|
||||
iny
|
||||
- lda (SAVE),y
|
||||
sta (DEST),y
|
||||
dey
|
||||
cpy #$FF
|
||||
bne -
|
||||
clc
|
||||
.exit rts
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; internal functions
|
||||
|
||||
incptr
|
||||
; preserves all registers
|
||||
phx
|
||||
ldx PTR
|
||||
inx
|
||||
stx PTR
|
||||
; preserves A and X
|
||||
ldy PTR
|
||||
iny
|
||||
sty PTR
|
||||
bne +
|
||||
inc PTR+1
|
||||
+ plx
|
||||
rts
|
||||
+ rts
|
||||
|
||||
SetPTRFromStackParams
|
||||
; preserves X
|
||||
ldy #1
|
||||
lda (PARAM),y
|
||||
sta PTR
|
||||
iny
|
||||
lda (PARAM),y
|
||||
sta PTR+1 ; PTR -> first parameter on stack
|
||||
; execution falls through here
|
||||
; execution falls through here
|
||||
derefptr
|
||||
; preserves X
|
||||
lda (PTR)
|
||||
|
@ -92,3 +92,6 @@ SoftBell
|
||||
plx
|
||||
plp
|
||||
rts
|
||||
|
||||
gPrefsStore
|
||||
!word *+2 ; address of storage space for prefs
|
||||
|
82
src/prefs.a
82
src/prefs.a
@ -5,32 +5,36 @@
|
||||
;
|
||||
; Public functions
|
||||
; - LoadGlobalPreferences
|
||||
; - SaveGlobalPreferences
|
||||
;
|
||||
; Public variables
|
||||
; - gForce40 byte 0=false, 1=true
|
||||
; - gForceUpper byte 0=false, 1=true
|
||||
; - gSort byte 0=name, 1=year, 2=genre, 3=difficulty
|
||||
; - gCurrentGame byte 0..kNumberOfGames-1
|
||||
; - gVersions[] array of fixed length records, each 16 bytes
|
||||
;
|
||||
; Public constants
|
||||
; - kForce40
|
||||
; - kForceUpper
|
||||
; - kSort
|
||||
; - kLastPlayed
|
||||
|
||||
!zone {
|
||||
TRUE = 1
|
||||
FALSE = 0
|
||||
kDefaultGame = 30 ; Zork I
|
||||
gPrefsStore
|
||||
!word $8000 ; address of storage space for prefs
|
||||
|
||||
; global storage for parsed preference values
|
||||
gForce40
|
||||
!byte 0
|
||||
gForceUpper
|
||||
!byte 0
|
||||
gSort
|
||||
!byte 0
|
||||
gCurrentGame
|
||||
!byte 0
|
||||
gVersions
|
||||
!fill kNumberOfGames*16,0
|
||||
|
||||
kForce40
|
||||
!byte 14
|
||||
!raw "FORCE40COLUMNS"
|
||||
kForceUpper
|
||||
!byte 14
|
||||
!raw "FORCEUPPERCASE"
|
||||
kSort
|
||||
!byte 4
|
||||
!raw "SORT"
|
||||
kLastPlayed
|
||||
!byte 10
|
||||
!raw "LASTPLAYED"
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; LoadGlobalPreferences
|
||||
@ -39,13 +43,6 @@ gVersions
|
||||
; out: all registers and flags clobbered
|
||||
;------------------------------------------------------------------------------
|
||||
LoadGlobalPreferences
|
||||
; set defaults first in case prefs file is missing or incomplete
|
||||
lda #FALSE
|
||||
sta gForce40
|
||||
lda #FALSE
|
||||
sta gForceUpper
|
||||
lda #0
|
||||
sta gSort
|
||||
lda #kDefaultGame
|
||||
sta gCurrentGame
|
||||
|
||||
@ -54,25 +51,32 @@ LoadGlobalPreferences
|
||||
|
||||
jsr okvs_append
|
||||
!word gPrefsStore
|
||||
!word .force40
|
||||
!word kForce40
|
||||
!word .debug0
|
||||
!byte 0
|
||||
|
||||
jsr okvs_append
|
||||
!word gPrefsStore
|
||||
!word .forceupper
|
||||
!word kForceUpper
|
||||
!word .debug0
|
||||
!byte 0
|
||||
|
||||
jsr okvs_append
|
||||
!word gPrefsStore
|
||||
!word .sort
|
||||
!word kSort
|
||||
!word .debugsortvalue
|
||||
!byte 0
|
||||
!byte 11
|
||||
|
||||
jsr okvs_get
|
||||
jsr okvs_append
|
||||
!word gPrefsStore
|
||||
!word .sort
|
||||
!word kLastPlayed
|
||||
!word .debuglastplayed
|
||||
!byte 16
|
||||
|
||||
jsr okvs_update
|
||||
!word gPrefsStore
|
||||
!word kSort
|
||||
!word kByDifficulty
|
||||
bcs .exit
|
||||
;jmp $ff59
|
||||
|
||||
@ -95,19 +99,6 @@ SaveGlobalPreferences
|
||||
!byte 15
|
||||
!raw "PITCH.DARK.CONF"
|
||||
|
||||
.force40
|
||||
!byte 14
|
||||
!raw "FORCE40COLUMNS"
|
||||
.forceupper
|
||||
!byte 14
|
||||
!raw "FORCEUPPERCASE"
|
||||
.sort
|
||||
!byte 4
|
||||
!raw "SORT"
|
||||
.lastplayed
|
||||
!byte 10
|
||||
!raw "LASTPLAYED"
|
||||
|
||||
.debug0
|
||||
!byte 1
|
||||
!raw "0"
|
||||
@ -116,4 +107,11 @@ SaveGlobalPreferences
|
||||
!byte 4
|
||||
!raw "NAME"
|
||||
|
||||
.debuglastplayed
|
||||
!byte 6
|
||||
!raw "ZORK.I"
|
||||
|
||||
kByDifficulty
|
||||
!byte 10
|
||||
!raw "DIFFICULTY"
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user