add okvs_iter_values function and use in versions dialog

This commit is contained in:
4am 2018-04-12 22:54:51 -04:00
parent 9eda7ac043
commit 42c3a9a1d4
2 changed files with 44 additions and 23 deletions

View File

@ -329,6 +329,7 @@ okvs_update
; out: <callback> will be called for each record in the store with
; X = numeric index of record
; A/Y = address of value
; callback must not clobber PTR
; all registers are clobbered
; all flags clobbered
; $00/$01 clobbered
@ -336,7 +337,36 @@ okvs_update
okvs_iter_values
+PARAMS_ON_STACK 4
jsr SetPTRFromStackParams
; TODO
lda (PTR)
beq .iterDone ; no keys, exit immediately
inc
sta .iterMax
+LDPARAM 3
+STAY .iterCallback
jsr incptr ; PTR -> first record
ldx #0
.iterLoop
ldy #2
lda (PTR),y ; A = length of key
clc
adc #3 ; skip over pointer to next record (2 bytes) + key length (1 byte)
sta .iterSkipLen
+LDAY PTR
clc
.iterSkipLen=*+1 ; skip over key
adc #$FD ; SMC
bcc +
iny ; A/Y -> value
+ phx
.iterCallback=*+1
jsr $FDFD ; SMC
plx
jsr derefptr ; PTR -> next record
inx
.iterMax=*+1
cpx #$FD ; SMC
bne .iterLoop
.iterDone
rts
;------------------------------------------------------------------------------

View File

@ -159,29 +159,9 @@ VersionsDialog
lda #1 ; WeeGUI radio button labels are limited to 15 characters, so we have
sta .vtab ; just the hotkeys (1-9) in the radio button label then print the
ldx #0 ; longer version string separately
.printLabelsLoop
phx ; X = index of radio button (0-based)
stx +
jsr okvs_nth
jsr okvs_iter_values
!word gVersionsStore
+ !byte $FD ; SMC
+STAY +
jsr okvs_get
!word gVersionsStore
+ !word $FDFD ; SMC
ldx #50
jsr CreateNullTerminatedString
jsr PrintAt
!byte 7 ; htab (constant)
.vtab !byte $FD ; SMC
!word kNullTerminatedBuffer
inc .vtab
inc .vtab
plx
inx
cpx .numVersions
bcc .printLabelsLoop
!word PrintVersionLabelCallback
bit $C010 ; clear keyboard strobe
ldx #WGClearPendingClick ; clear WeeGUI mouse strobe
@ -198,6 +178,17 @@ VersionsDialog
;------------------------------------------------------------------------------
; internal functions
PrintVersionLabelCallback
ldx #50
jsr CreateNullTerminatedString
jsr PrintAt
!byte 7 ; htab (constant)
.vtab !byte $FD ; SMC
!word kNullTerminatedBuffer
inc .vtab
inc .vtab
rts
HandleVersionsKey
ldx #.endkeys-.keys
- cmp .keys,x