support date field, correct time display

This commit is contained in:
Peter Ferrie 2018-06-18 14:32:17 -07:00
parent f8a24a8277
commit bb14d6a805
4 changed files with 139 additions and 41 deletions

View File

@ -13,12 +13,13 @@
; TODO move these to a ZINFO_MLI kind of separate file ; TODO move these to a ZINFO_MLI kind of separate file
zinfo_base = $2000 zinfo_base = $2000
zinfo_recordlen= 64
zinfo_maxslots = 8 zinfo_maxslots = 8
name_offset = 0 ;1+37 bytes name_offset = 0 ;1+37 bytes, a zero-length name is an empty record
time_offset = 42 ;1+8 bytes ("12:01 pm") time_offset = 42 ;1+8 bytes ("12:01 pm")
score_offset = 51 ;1+6 bytes (-12345) score_offset = 51 ;1+6 bytes (-12345)
moves_offset = 58 ;1+5 bytes (12345) moves_offset = 58 ;1+5 bytes (12345)
date_offset = 64 ;1+10 bytes ("10/10/2099")
zinfo_recordlen= 75 ;bytes
gSavedGamesStore gSavedGamesStore
!word $FDFD ; set in LoadGameInfo !word $FDFD ; set in LoadGameInfo
@ -57,43 +58,82 @@ LoadSavedGameInfo
phx phx
jsr ResetPath jsr ResetPath
lda (ZPTR) lda (ZPTR)
beq @saveAndMoveToNextSlot; no saved game in this slot beq @branchToNextSlot ; no saved game in this slot
inc gSavedGamesSlotsInUse ; update number of slots in use (separate from length of store) inc gSavedGamesSlotsInUse ; update number of slots in use (separate from length of store)
+LDAY ZPTR +LDAY ZPTR
jsr AddToPathWithHighBit ; add location information jsr AddToPathWithHighBit ; add location information
lda ZPTR ldx #0 ; count elements to print (there can be 0-3 of them)
clc jsr @queryTime
adc #time_offset beq +
sta ZPTR inx
bcc + + jsr @queryScore
inc ZPTR+1 beq +
+ ; ZPTR -> ZINFO time field (length-prefixed string, may be empty string if no time) inx
+ jsr @queryMoves
beq +
inx
+ jsr @queryDate
beq +
inx
+ stx @tempX+1
plx
ply
pla
pha
phy
phx
+STAY ZPTR
@tempX ldx #0 ; self-modified
cpx #0 ; to allow branch-linking from above
@branchToNextSlot
beq @saveAndMoveToNextSlot; only location, nothing more to print
phx
+LDADDR kLeftParen +LDADDR kLeftParen
jsr AddToPathWithHighBit ; add ' (' jsr AddToPathWithHighBit ; add ' ('
lda (ZPTR) jsr @queryTime
bne @justTime beq @noTime
lda ZPTR
clc
adc #(score_offset-time_offset)
sta ZPTR
bcc +
inc ZPTR+1
+ ; ZPTR -> ZINFO score field (length-prefixed string, guaranteed non-empty if no time)
ldy ZPTR+1
jsr AddToPathWithHighBit ; add score information
+LDADDR kSlash
jsr AddToPathWithHighBit ; add '/'
lda ZPTR
clc
adc #(moves_offset-score_offset)
sta ZPTR
bcc +
inc ZPTR+1
+ ; A/Y -> ZINFO moves field (length-prefixed string, guaranteed non-empty)
; execution falls through here
@justTime
+LDAY ZPTR +LDAY ZPTR
jsr AddToPathWithHighBit ; add final piece of information (moves or time, depending on how we got here) jsr AddToPathWithHighBit ; add time information
; execution falls through here
plx
dex
beq @doneState
phx
+LDADDR kSlash
jsr AddToPathWithHighBit ; add '/' because we have more to print
@noTime
jsr @queryScore
beq @noScore
+LDAY ZPTR
jsr AddToPathWithHighBit ; add score information
; execution falls through here
plx
dex
beq @doneState
phx
+LDADDR kSlash
jsr AddToPathWithHighBit ; add '/' because we have more to print
@noScore
jsr @queryMoves
beq @noMoves
+LDAY ZPTR
jsr AddToPathWithHighBit ; add moves information
; execution falls through here
plx
dex
beq @doneState
phx
+LDADDR kSlash
jsr AddToPathWithHighBit ; add '/' because we have more to print
@noMoves
jsr @queryDate
beq @noDate
plx
+LDAY ZPTR
jsr AddToPathWithHighBit ; add date information
; execution falls through here
@noDate
@doneState
+LDADDR kRightParen +LDADDR kRightParen
jsr AddToPathWithHighBit ; add ')' jsr AddToPathWithHighBit ; add ')'
+LDADDR kNullByte +LDADDR kNullByte
@ -133,6 +173,50 @@ LoadSavedGameInfo
jmp @zParseLoop jmp @zParseLoop
+ rts + rts
@queryTime
lda ZPTR
clc
adc #time_offset-name_offset
sta ZPTR
bcc +
inc ZPTR+1
+ ; ZPTR -> ZINFO time field (length-prefixed string, may be empty string if no time)
lda (ZPTR)
rts
@queryScore
lda ZPTR
clc
adc #score_offset-time_offset
sta ZPTR
bcc +
inc ZPTR+1
+ ; ZPTR -> ZINFO score field (length-prefixed string, may be empty string if no score)
lda (ZPTR)
rts
@queryMoves
lda ZPTR
clc
adc #moves_offset-score_offset
sta ZPTR
bcc +
inc ZPTR+1
+ ; ZPTR -> ZINFO moves field (length-prefixed string, may be empty string if no moves)
lda (ZPTR)
rts
@queryDate
lda ZPTR
clc
adc #date_offset-moves_offset
sta ZPTR
bcc +
inc ZPTR+1
+ ; ZPTR -> ZINFO date field (length-prefixed string, may be empty string if no date)
lda (ZPTR)
rts
kZINFOFilename kZINFOFilename
!byte 12 !byte 12
!raw "ZINFO.SYSTEM" !raw "ZINFO.SYSTEM"

View File

@ -93,15 +93,19 @@ gameloc
gametime gametime
;amfvr77 ;amfvr77
!byte $50
!byte $aa !byte $aa
;amfvr77d ;amfvr77d
!byte $50
!byte $aa !byte $aa
;amfvr79 ;amfvr79
!byte $50
!byte $aa !byte $aa
;amfvr79d ;amfvr79d
!byte $50
!byte $aa !byte $aa
;bureaur86 ;bureaur86

View File

@ -149,11 +149,7 @@ position
bcs nextpos bcs nextpos
ldy #name_offset ldy #name_offset
sty zpage_ptr sty zpage_ptr
lda zpage_gamind
pha
jsr dump_info jsr dump_info
pla
sta zpage_gamind
nextpos nextpos
clc clc
@ -311,9 +307,21 @@ dump_info
sta max_chars ;can't overflow anymore sta max_chars ;can't overflow anymore
sta (zpage_info),y sta (zpage_info),y
asl zpage_gamind
ldx zpage_gamind ldx zpage_gamind
lda gametime, x lda gametime, x
beq skip_time beq skip_time
lda #$9d ;in-simulation
jsr fetch_obj
lda zp_6B
ora zp_6C
bne in_sim1
inc zpage_gamind
in_sim1
ldx zpage_gamind
lda gametime, x
jsr fetch_obj jsr fetch_obj
lda zp_6B lda zp_6B
sta zp_58 sta zp_58
@ -325,7 +333,7 @@ dump_info
sta zp_5B sta zp_5B
jsr sub_E7FB jsr sub_E7FB
sta zp_59 sta zp_59
cpx #$0c cpx #$0d
bcc + bcc +
txa txa
sbc #$0c sbc #$0c
@ -368,6 +376,7 @@ is_am
sta (zpage_info),y sta (zpage_info),y
skip_time skip_time
lsr zpage_gamind
ldy #score_offset ldy #score_offset
sty zpage_ptr sty zpage_ptr
lda #0 lda #0
@ -424,10 +433,10 @@ skip_moves
jsr fetch_obj jsr fetch_obj
lda zp_6B lda zp_6B
ora zp_6C ora zp_6C
bne in_sim bne in_sim2
inc zpage_gamind inc zpage_gamind
in_sim in_sim2
ldx zpage_gamind ldx zpage_gamind
lda gamemonth, x lda gamemonth, x
jsr fetch_obj jsr fetch_obj
@ -463,6 +472,7 @@ in_sim
sta (zpage_info),y sta (zpage_info),y
skip_date skip_date
lsr zpage_gamind
rts rts
!source "src/zinfo/z4/gamedata.txt" !source "src/zinfo/z4/gamedata.txt"

View File

@ -359,7 +359,7 @@ wishbr
lda #$5c lda #$5c
jsr fetch_obj jsr fetch_obj
lda zp_6B lda zp_6B
cmp #$0c cmp #$0d
bcc + bcc +
sbc #$0c sbc #$0c
+ sta zp_58 + sta zp_58