From bb14d6a805b63d02f51b84d51ec5fa1a6f2f89d6 Mon Sep 17 00:00:00 2001 From: Peter Ferrie Date: Mon, 18 Jun 2018 14:32:17 -0700 Subject: [PATCH] support date field, correct time display --- src/glue.zinfo.a | 150 +++++++++++++++++++++++++++++--------- src/zinfo/z4/gamedata.txt | 4 + src/zinfo/z4/z4.s | 24 ++++-- src/zinfo/z5/z5.s | 2 +- 4 files changed, 139 insertions(+), 41 deletions(-) diff --git a/src/glue.zinfo.a b/src/glue.zinfo.a index efa6830..55c99f5 100644 --- a/src/glue.zinfo.a +++ b/src/glue.zinfo.a @@ -13,12 +13,13 @@ ; TODO move these to a ZINFO_MLI kind of separate file zinfo_base = $2000 -zinfo_recordlen= 64 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") score_offset = 51 ;1+6 bytes (-12345) moves_offset = 58 ;1+5 bytes (12345) +date_offset = 64 ;1+10 bytes ("10/10/2099") +zinfo_recordlen= 75 ;bytes gSavedGamesStore !word $FDFD ; set in LoadGameInfo @@ -57,43 +58,82 @@ LoadSavedGameInfo phx jsr ResetPath 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) +LDAY ZPTR jsr AddToPathWithHighBit ; add location information - lda ZPTR - clc - adc #time_offset - sta ZPTR - bcc + - inc ZPTR+1 -+ ; ZPTR -> ZINFO time field (length-prefixed string, may be empty string if no time) + ldx #0 ; count elements to print (there can be 0-3 of them) + jsr @queryTime + beq + + inx ++ jsr @queryScore + beq + + 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 jsr AddToPathWithHighBit ; add ' (' - lda (ZPTR) - bne @justTime - 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 + jsr @queryTime + beq @noTime +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 jsr AddToPathWithHighBit ; add ')' +LDADDR kNullByte @@ -133,6 +173,50 @@ LoadSavedGameInfo jmp @zParseLoop + 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 !byte 12 !raw "ZINFO.SYSTEM" diff --git a/src/zinfo/z4/gamedata.txt b/src/zinfo/z4/gamedata.txt index 58b0302..d136b9d 100644 --- a/src/zinfo/z4/gamedata.txt +++ b/src/zinfo/z4/gamedata.txt @@ -93,15 +93,19 @@ gameloc gametime ;amfvr77 + !byte $50 !byte $aa ;amfvr77d + !byte $50 !byte $aa ;amfvr79 + !byte $50 !byte $aa ;amfvr79d + !byte $50 !byte $aa ;bureaur86 diff --git a/src/zinfo/z4/z4.s b/src/zinfo/z4/z4.s index 8dad6e1..23e8751 100644 --- a/src/zinfo/z4/z4.s +++ b/src/zinfo/z4/z4.s @@ -149,11 +149,7 @@ position bcs nextpos ldy #name_offset sty zpage_ptr - lda zpage_gamind - pha jsr dump_info - pla - sta zpage_gamind nextpos clc @@ -311,9 +307,21 @@ dump_info sta max_chars ;can't overflow anymore sta (zpage_info),y + asl zpage_gamind ldx zpage_gamind lda gametime, x 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 lda zp_6B sta zp_58 @@ -325,7 +333,7 @@ dump_info sta zp_5B jsr sub_E7FB sta zp_59 - cpx #$0c + cpx #$0d bcc + txa sbc #$0c @@ -368,6 +376,7 @@ is_am sta (zpage_info),y skip_time + lsr zpage_gamind ldy #score_offset sty zpage_ptr lda #0 @@ -424,10 +433,10 @@ skip_moves jsr fetch_obj lda zp_6B ora zp_6C - bne in_sim + bne in_sim2 inc zpage_gamind -in_sim +in_sim2 ldx zpage_gamind lda gamemonth, x jsr fetch_obj @@ -463,6 +472,7 @@ in_sim sta (zpage_info),y skip_date + lsr zpage_gamind rts !source "src/zinfo/z4/gamedata.txt" diff --git a/src/zinfo/z5/z5.s b/src/zinfo/z5/z5.s index 47941dd..46a39b5 100644 --- a/src/zinfo/z5/z5.s +++ b/src/zinfo/z5/z5.s @@ -359,7 +359,7 @@ wishbr lda #$5c jsr fetch_obj lda zp_6B - cmp #$0c + cmp #$0d bcc + sbc #$0c + sta zp_58