refactor okvs_len

This commit is contained in:
4am 2019-09-20 19:42:26 -04:00
parent db5961b606
commit 6983328969
3 changed files with 11 additions and 19 deletions

View File

@ -206,8 +206,8 @@ OneTimeSetup
!word gGamesListStore
!word -
+LDADDR gGamesListStore
jsr okvs_len
!word gGamesListStore
sta GameCount
sta SAVE

View File

@ -94,16 +94,15 @@ okvs_init
;------------------------------------------------------------------------------
; okvs_len
;
; in: stack contains 2 bytes of parameters:
; +1 [word] handle to storage space
; in: A/Y = handle to storage space
; out: A contains number of keys in this store
; X, Y clobbered
; X preserved
; Y clobbered
; $00/$01 clobbered
; $02/$03 clobbered
;------------------------------------------------------------------------------
okvs_len
+PARAMS_ON_STACK 2
jsr GetStoreAddress
jsr GetStoreAddressFromAY
; PTR -> store
; Y = 0
lda (PTR),y ; A = number of keys in store
@ -295,24 +294,17 @@ okvs_get
; X = record index
; out: A/Y = lo/hi address of (X+1)th key, or first key if X was the last record
; X = next record index
; Z = 0
; all other flags clobbered
; PARAM clobbered
; PTR clobbered
; SAVE clobbered
; see okvs_nth for other exit conditions
;------------------------------------------------------------------------------
okvs_next
+STAY @store1
inx
stx SAVE
+STAY PARAM
jsr okvs_len
@store1 !word $FDFD ; SMC
ldx SAVE
cmp SAVE
bne +
ldx #0
+
+LDAY @store1
ldx #$FF
+ inx
+LDAY PARAM
; execution falls through here
;------------------------------------------------------------------------------
; okvs_nth

View File

@ -87,8 +87,8 @@ MiniAttractMode
!word -
!byte 0
+LDADDR gAttractModeStore
jsr okvs_len
!word gAttractModeStore
cmp @MiniAttractIndex
beq @exit ; we've run through all modules, so exit to caller