refactor incptr

This commit is contained in:
4am 2019-09-10 09:20:32 -04:00
parent 35c48d8bf3
commit 003b6ad6f0
2 changed files with 9 additions and 17 deletions

View File

@ -9,7 +9,7 @@
; D000..E4E9 - persistent data structures (gGlobalPrefsStore, gGamesListStore) ; D000..E4E9 - persistent data structures (gGlobalPrefsStore, gGamesListStore)
; ...end of data and start of code are approximate, in between is unused... ; ...end of data and start of code are approximate, in between is unused...
; ...if they ever overlap, things will go boom... ; ...if they ever overlap, things will go boom...
; E9F0..FFF9 - main program code ; E9FF..FFF9 - main program code
; FFFA..FFFF - NMI, reset, IRQ vectors ; FFFA..FFFF - NMI, reset, IRQ vectors
; ;
; LC RAM BANK 2 ; LC RAM BANK 2

View File

@ -142,8 +142,8 @@ okvs_append
sta SAVE sta SAVE
; PTR -> new record ; PTR -> new record
; SAVE -> new record ; SAVE -> new record
jsr incptr jsr incptr2
jsr incptr ; PTR -> space for new key ; PTR -> space for new key
+LDPARAM 3 +LDPARAM 3
+STAY SRC ; SRC -> new key to copy +STAY SRC ; SRC -> new key to copy
ldy #0 ldy #0
@ -231,10 +231,7 @@ okvs_get
lda (PTR),y lda (PTR),y
beq @fail ; no keys, fail immediately beq @fail ; no keys, fail immediately
sta @maxkeys ; A = number of keys sta @maxkeys ; A = number of keys
ldx #3 jsr incptr3
- jsr incptr
dex
bne -
; PTR -> first record ; PTR -> first record
ldx #0 ldx #0
+LDPARAM 3 +LDPARAM 3
@ -297,10 +294,7 @@ okvs_get
okvs_nth okvs_nth
+PARAMS_ON_STACK 3 +PARAMS_ON_STACK 3
jsr SetPTRFromStackParams jsr SetPTRFromStackParams
ldx #3 jsr incptr3
- jsr incptr
dex
bne -
; PTR -> first record ; PTR -> first record
ldy #3 ldy #3
lda (PARAM),y lda (PARAM),y
@ -309,8 +303,7 @@ okvs_nth
- jsr derefptr - jsr derefptr
dex dex
bne - bne -
@found jsr incptr @found jsr incptr2
jsr incptr
+LDAY PTR +LDAY PTR
rts rts
@ -386,10 +379,7 @@ okvs_iter_values
sta @max sta @max
+LDPARAM 3 +LDPARAM 3
+STAY @callback +STAY @callback
ldx #3 jsr incptr3
- jsr incptr
dex
bne -
; PTR -> first record ; PTR -> first record
ldx #0 ldx #0
@loop @loop
@ -431,6 +421,8 @@ okvs_iter_values
;------------------------------------------------------------------------------ ;------------------------------------------------------------------------------
; internal functions ; internal functions
incptr3 jsr incptr
incptr2 jsr incptr
incptr incptr
; preserves A and X ; preserves A and X
ldy PTR ldy PTR