lemm: update percent in counter

This commit is contained in:
Vince Weaver 2022-03-23 00:34:33 -04:00
parent ddb9328748
commit 08dd4bf01d
2 changed files with 94 additions and 36 deletions

View File

@ -220,10 +220,10 @@ remove_lemming:
bcc no_percent_oflo
inc PERCENT_RESCUED_H
no_percent_oflo:
cld
no_percent_oflo:
jsr update_percent_in
didnt_exit:
@ -237,6 +237,7 @@ didnt_exit:
jsr click_speaker
lda #0
ldy CURRENT_LEMMING
sta lemming_out,Y
jsr update_lemmings_out
@ -283,7 +284,7 @@ ground_walking:
ldy CURRENT_LEMMING
lda lemming_fall_distance,Y
cmp #24
cmp #32
bcs lemming_goes_splat
lda #0

View File

@ -1,8 +1,16 @@
;============================
; update the time
;============================
; this gets called approximately once a second
; updates the time left
update_time:
;==============================
; update explosion timer
;==============================
; not ideal (first second might be short)
ldy #0
@ -81,45 +89,51 @@ draw_time:
jsr hgr_draw_sprite_autoshift
;================
; draw seconds
lda TIME_SECONDS
lsr
lsr
lsr
lsr
tay
lda bignums_l,Y
sta INL
lda bignums_h,Y
sta INH
ldx #37
stx XPOS
lda #152
sta YPOS
jsr hgr_draw_sprite_autoshift
sec ; no leading zero removal
jmp print_two_digits
; draw seconds
lda TIME_SECONDS
and #$f
tay
;===========================
;===========================
; update percent in
;===========================
;===========================
update_percent_in:
; draw hundreds
ldy PERCENT_RESCUED_H
beq not_hundred_yet
lda bignums_l,Y
sta INL
lda bignums_h,Y
sta INH
ldx #38
ldx #23
stx XPOS
lda #152
sta YPOS
jsr hgr_draw_sprite_autoshift
rts
sec ; no leading zero for rest
bcs hundreds_entry
not_hundred_yet:
; print tens/ones
clc ; leading zero removal
hundreds_entry:
lda PERCENT_RESCUED_L
ldx #24
jmp print_two_digits
;===========================
;===========================
@ -127,18 +141,57 @@ draw_time:
;===========================
;===========================
; TODO: combine with time drawing code?
update_lemmings_out:
; draw tens
lda LEMMINGS_OUT
ldx #15
clc ; leading zero removal
jmp print_two_digits
;===========================
;===========================
; print two-digit number
;===========================
;===========================
; A is the BCD value
; X is the X location
; C set means print 0
; we assume 152 for Y location
print_two_digits:
ldy #0
bcs ptd_leading_zero
ldy #10
ptd_leading_zero:
sty ptt_lz_smc+1
stx ptt_smc+1
inx
stx pto_smc+1
print_two_tens:
; draw tens
pha
lsr
lsr
lsr
lsr
beq lemmings_out_ones
lemmings_out_tens:
bne no_handle_zero
clc
ptt_lz_smc:
adc #10 ; blank or zero, depending
no_handle_zero:
tay
lda bignums_l,Y
@ -146,16 +199,17 @@ lemmings_out_tens:
lda bignums_h,Y
sta INH
ldx #15 ; 105
stx XPOS
ptt_smc:
lda #15
sta XPOS
lda #152
sta YPOS
jsr hgr_draw_sprite_autoshift
lemmings_out_ones:
lda LEMMINGS_OUT
print_two_ones:
pla
and #$f
tay
@ -164,8 +218,9 @@ lemmings_out_ones:
lda bignums_h,Y
sta INH
ldx #16 ; 112
stx XPOS
pto_smc:
lda #16
sta XPOS
lda #152
sta YPOS
@ -178,7 +233,9 @@ lemmings_out_ones:
bignums_l:
.byte <big0_sprite,<big1_sprite,<big2_sprite,<big3_sprite,<big4_sprite
.byte <big5_sprite,<big6_sprite,<big7_sprite,<big8_sprite,<big9_sprite
.byte <blank_sprite
bignums_h:
.byte >big0_sprite,>big1_sprite,>big2_sprite,>big3_sprite,>big4_sprite
.byte >big5_sprite,>big6_sprite,>big7_sprite,>big8_sprite,>big9_sprite
.byte >blank_sprite