move okvs_init to init-only section

This commit is contained in:
4am 2021-11-17 23:54:51 -05:00
parent 7482420c8d
commit da8498e330
3 changed files with 31 additions and 32 deletions

View File

@ -11,7 +11,7 @@
; ...unused...
; E000..E3FF - HGR font data
; ...unused...
; E893..FFEE - main program code
; E8CB..FFEE - main program code
; FFEF..FFF9 - API functions and global constants available for main program
; code, prelaunchers, transition effects, &c.
; (LoadFileDirect, Wait/UnwaitForVBL, MockingboardStuff, MachineStatus)

View File

@ -4,7 +4,6 @@
; Ordered key/value store (6502 compatible)(256+ records compatible)
;
; Public functions
; - okvs_init(address) reset (required)
; - okvs_len(address) get number of keys
; - okvs_update(address, key, value) update key/value pair
; - okvs_get(address, key) get value by key lookup
@ -67,36 +66,6 @@
; +K+3 value
; ... filler bytes up to value max length (set at append() time)
;------------------------------------------------------------------------------
; okvs_init
;
; in: A/Y = handle to storage space
; out: $00/$01 clobbered
; $02/$03 clobbered
; all registers clobbered
;------------------------------------------------------------------------------
okvs_init
jsr GetStoreAddressFromAY
; PTR -> store
; Y = 0
tya
sta (PTR),y ; set number of keys in store to 0 (word)
iny
sta (PTR),y
iny ; set next-free-space pointer to store + 4
ldx PTR+1
lda PTR
clc
adc #$04
bcc +
inx
+ sta (PTR),y
iny
txa
sta (PTR),y
rts
;------------------------------------------------------------------------------
; okvs_len
; okvs_len_imm

View File

@ -238,3 +238,33 @@ okvs_append
ldy #0
sta (SAVE),y ; set record length
rts
;------------------------------------------------------------------------------
; okvs_init
;
; in: A/Y = handle to storage space
; out: $00/$01 clobbered
; $02/$03 clobbered
; all registers clobbered
;------------------------------------------------------------------------------
okvs_init
jsr GetStoreAddressFromAY
; PTR -> store
; Y = 0
tya
sta (PTR),y ; set number of keys in store to 0 (word)
iny
sta (PTR),y
iny ; set next-free-space pointer to store + 4
ldx PTR+1
lda PTR
clc
adc #$04
bcc +
inx
+ sta (PTR),y
iny
txa
sta (PTR),y
rts