This commit is contained in:
4am 2018-04-11 22:52:36 -04:00
parent b123b4ebcf
commit 9eda7ac043
2 changed files with 28 additions and 24 deletions

View File

@ -26,7 +26,7 @@
[versions]
R8B.840521.Z3=Release 8 / Serial number 840521
R8A.830521.Z3=Release 8 / Serial number 830521
R7.830419.Z3=Release 7 / Seial number 830419
R7.830419.Z3=Release 7 / Serial number 830419
R5.830222.Z3=Release 5 / Serial number 830222
[options]

View File

@ -10,6 +10,7 @@
; - okvs_update(address, key, value) update key/value pair
; - okvs_get(address, key) get value by key lookup
; - okvs_nth(address, n) get key by numeric index
; - okvs_iter_values(address, callback) iterate through records
; - okvs_as_boolean(value) set Z flag based on value
;
; Used for global preferences, per-game options, and per-game version lists
@ -124,12 +125,8 @@ okvs_append
+STAY SAVE ; save PTR
jsr incptr
jsr incptr ; PTR -> space for new key
ldy #3
lda (PARAM),y ; get source address of new key to copy
sta SRC
iny
lda (PARAM),y
sta SRC+1
+LDPARAM 3
+STAY SRC ; SRC -> new key to copy
lda (SRC)
inc
sta .keylen
@ -148,13 +145,9 @@ okvs_append
bcc +
inc PTR+1
+ ; PTR -> space for new value
ldy #5
lda (PARAM),y ; get source address of new value
sta SRC
iny
lda (PARAM),y
sta SRC+1
iny
+LDPARAM 5
+STAY SRC ; SRC -> new value to copy
ldy #7
lda (PARAM),y ; get max length of value
bne +
lda (SRC) ; no max, use actual length instead
@ -210,18 +203,11 @@ okvs_get
stx .maxKeys
ldx #0
jsr incptr ; PTR -> first record
ldy #3
lda (PARAM),y
sta SRC
iny
lda (PARAM),y
sta SRC+1 ; SRC -> key we want to find
+LDPARAM 3
+STAY SRC ; SRC -> key we want to find
lda (SRC)
inc
sta .matchlen
.matchRecordLoop
lda PTR+1
sta DEST+1
@ -277,7 +263,6 @@ okvs_nth
+PARAMS_ON_STACK 3
jsr SetPTRFromStackParams
jsr incptr ; PTR -> first record
ldy #3
lda (PARAM),y
tax ; X = numeric index of key to get
@ -335,6 +320,25 @@ okvs_update
clc
.exit rts
;------------------------------------------------------------------------------
; okvs_iter_values
;
; in: stack contains 4 bytes of parameters:
; +1 [word] handle to storage space
; +3 [word] address of callback
; out: <callback> will be called for each record in the store with
; X = numeric index of record
; A/Y = address of value
; all registers are clobbered
; all flags clobbered
; $00/$01 clobbered
;------------------------------------------------------------------------------
okvs_iter_values
+PARAMS_ON_STACK 4
jsr SetPTRFromStackParams
; TODO
rts
;------------------------------------------------------------------------------
; okvs_as_boolean
;