dos33fsprogs/games/lemm/update_time.s

310 lines
4.3 KiB
ArmAsm
Raw Permalink Normal View History

2022-03-23 04:34:33 +00:00
;==============================
2022-03-16 01:00:30 +00:00
; update explosion timer
2022-03-23 04:34:33 +00:00
;==============================
2022-03-16 01:00:30 +00:00
; not ideal (first second might be short)
2022-04-13 03:21:51 +00:00
; called roughly at 7Hz
2022-03-23 01:48:02 +00:00
2022-04-13 03:21:51 +00:00
update_explosion_timer:
2022-03-23 01:48:02 +00:00
ldy #0
update_exploding_loop:
lda lemming_exploding,Y
2022-03-16 01:00:30 +00:00
beq not_done_exploding
2022-04-13 03:21:51 +00:00
lda lemming_exploding_frame,Y ; roughly 1s?
cmp #7
bne not_done_exploding
lda #0 ; reset
sta lemming_exploding_frame,Y
2022-03-23 01:48:02 +00:00
tya
tax
inc lemming_exploding,X
lda lemming_exploding,Y
2022-04-13 03:21:51 +00:00
cmp #7 ; value is 2+displayed
2022-03-16 01:00:30 +00:00
bne not_done_exploding
lda #LEMMING_EXPLODING
2022-03-23 01:48:02 +00:00
sta lemming_status,Y
2022-03-16 01:00:30 +00:00
lda #0
2022-03-23 01:48:02 +00:00
sta lemming_frame,Y
sta lemming_exploding,Y
2022-03-16 01:00:30 +00:00
not_done_exploding:
2022-03-23 01:48:02 +00:00
iny
cpy #MAX_LEMMINGS
bne update_exploding_loop
2022-04-13 03:21:51 +00:00
rts
;============================
; update the time
;============================
; this gets called approximately once a second
; updates the time left
update_time:
2022-03-23 01:48:02 +00:00
2022-04-13 03:21:51 +00:00
; jsr update_explosion_timer
2022-03-16 01:00:30 +00:00
2022-03-08 05:49:10 +00:00
sed
sec
lda TIME_SECONDS
sbc #1
cmp #$99
bne no_time_uflo
lda #$59
dec TIME_MINUTES
no_time_uflo:
sta TIME_SECONDS
cld
2022-03-09 05:35:13 +00:00
lda TIME_MINUTES
bne not_over
lda TIME_SECONDS
bne not_over
2022-03-15 04:50:35 +00:00
; out of time
lda #LEVEL_FAIL
sta LEVEL_OVER
2022-03-09 05:35:13 +00:00
not_over:
2022-03-08 05:49:10 +00:00
draw_time:
;==============
2022-03-08 05:49:10 +00:00
; draw minute
; draw twice, once on each page
2022-03-08 05:49:10 +00:00
jsr hgr_sprite_as_toggle
2022-03-08 05:49:10 +00:00
lda TIME_MINUTES
ldx #35 ; XPOS
jsr print_one_digit
jsr hgr_sprite_as_toggle
lda TIME_MINUTES
ldx #35 ; XPOS
jsr print_one_digit
2022-03-08 05:49:10 +00:00
2022-03-23 04:34:33 +00:00
;================
2022-03-08 05:49:10 +00:00
; draw seconds
; draw twice, once on each page
jsr hgr_sprite_as_toggle
2022-03-23 04:34:33 +00:00
lda TIME_SECONDS
ldx #37 ; x location
2022-03-23 04:34:33 +00:00
sec ; no leading zero removal
jsr print_two_digits
jsr hgr_sprite_as_toggle
lda TIME_SECONDS
ldx #37 ; x location
sec ; no leading zero removal
jmp print_two_digits ; tail call
2022-03-08 05:49:10 +00:00
2022-03-23 04:34:33 +00:00
;===========================
;===========================
; update percent in
;===========================
;===========================
update_percent_in:
2022-03-08 05:49:10 +00:00
2022-03-23 04:34:33 +00:00
; draw hundreds
ldy PERCENT_RESCUED_H
beq not_hundred_yet
2022-03-08 05:49:10 +00:00
lda bignums_l,Y
sta INL
lda bignums_h,Y
sta INH
2022-03-23 04:34:33 +00:00
ldx #23
2022-03-09 20:15:38 +00:00
stx XPOS
2022-03-08 05:49:10 +00:00
lda #152
2022-03-09 20:15:38 +00:00
sta YPOS
2022-03-08 05:49:10 +00:00
2022-03-09 05:35:13 +00:00
jsr hgr_draw_sprite_autoshift
2022-03-08 05:49:10 +00:00
2022-03-23 04:34:33 +00:00
sec ; no leading zero for rest
bcs hundreds_entry
not_hundred_yet:
; print tens/ones
clc ; leading zero removal
hundreds_entry:
php
jsr hgr_sprite_as_toggle
lda PERCENT_RESCUED_L
ldx #24
plp
php
jsr print_two_digits
jsr hgr_sprite_as_toggle
2022-03-23 04:34:33 +00:00
lda PERCENT_RESCUED_L
ldx #24
plp
2022-03-23 04:34:33 +00:00
jmp print_two_digits
2022-03-08 05:49:10 +00:00
2022-03-22 03:00:30 +00:00
;===========================
;===========================
2022-03-11 04:43:10 +00:00
; update lemmings out number
2022-03-22 03:00:30 +00:00
;===========================
;===========================
2022-03-11 04:43:10 +00:00
update_lemmings_out:
jsr hgr_sprite_as_toggle
lda LEMMINGS_OUT
ldx #15
clc ; leading zero removal
jsr print_two_digits
2022-03-23 04:34:33 +00:00
jsr hgr_sprite_as_toggle
2022-03-22 03:00:30 +00:00
lda LEMMINGS_OUT
2022-03-23 04:34:33 +00:00
ldx #15
clc ; leading zero removal
jmp print_two_digits
;===========================
;===========================
; print one-digit number
;===========================
;===========================
; A is the BCD value
; X is the X location
; we assume 152 for Y location
print_one_digit:
tay
lda bignums_l,Y
sta INL
lda bignums_h,Y
sta INH
stx XPOS
lda #152
sta YPOS
jsr hgr_draw_sprite_autoshift
rts
2022-03-23 04:34:33 +00:00
;===========================
;===========================
; 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
2022-03-22 03:00:30 +00:00
lsr
lsr
lsr
lsr
2022-03-23 04:34:33 +00:00
bne no_handle_zero
clc
ptt_lz_smc:
adc #10 ; blank or zero, depending
no_handle_zero:
2022-03-11 04:43:10 +00:00
2022-03-22 03:00:30 +00:00
tay
2022-03-11 04:43:10 +00:00
lda bignums_l,Y
sta INL
lda bignums_h,Y
sta INH
2022-03-23 04:34:33 +00:00
ptt_smc:
lda #15
sta XPOS
2022-03-11 04:43:10 +00:00
lda #152
sta YPOS
jsr hgr_draw_sprite_autoshift
2022-03-22 03:00:30 +00:00
2022-03-23 04:34:33 +00:00
print_two_ones:
pla
2022-03-22 03:00:30 +00:00
and #$f
tay
lda bignums_l,Y
sta INL
lda bignums_h,Y
sta INH
2022-03-23 04:34:33 +00:00
pto_smc:
lda #16
sta XPOS
2022-03-22 03:00:30 +00:00
lda #152
sta YPOS
jsr hgr_draw_sprite_autoshift
2022-03-11 04:43:10 +00:00
rts
2022-03-08 05:49:10 +00:00
bignums_l:
.byte <big0_sprite,<big1_sprite,<big2_sprite,<big3_sprite,<big4_sprite
.byte <big5_sprite,<big6_sprite,<big7_sprite,<big8_sprite,<big9_sprite
2022-03-23 04:34:33 +00:00
.byte <blank_sprite
2022-03-08 05:49:10 +00:00
bignums_h:
.byte >big0_sprite,>big1_sprite,>big2_sprite,>big3_sprite,>big4_sprite
.byte >big5_sprite,>big6_sprite,>big7_sprite,>big8_sprite,>big9_sprite
2022-03-23 04:34:33 +00:00
.byte >blank_sprite