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 gGamesListStore
!word - !word -
+LDADDR gGamesListStore
jsr okvs_len jsr okvs_len
!word gGamesListStore
sta GameCount sta GameCount
sta SAVE sta SAVE

View File

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

View File

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