dos33fsprogs/games/keen/status_bar.s

329 lines
4.2 KiB
ArmAsm
Raw Normal View History

2024-03-10 05:44:20 +00:00
; Draw Status Bar
;===========================
; inc_score
2024-03-10 05:44:20 +00:00
;===========================
; make sure any interrupt routine handles d flag properly
; value to add by in A (BCD/100)
; for Keen assume always a multiple of 100
inc_score:
2024-03-10 05:44:20 +00:00
sed
2024-03-10 05:44:20 +00:00
clc
adc SCORE0
2024-03-10 05:44:20 +00:00
sta SCORE0
lda SCORE1
adc #0
sta SCORE1
lda SCORE2
adc #0
sta SCORE2
2024-03-20 05:40:58 +00:00
2024-03-10 05:44:20 +00:00
cld
rts
2024-03-20 05:45:37 +00:00
;===========================
; update rayguns
;===========================
; remove leading zeros
; leftmost is score_string+26
update_rayguns:
update_raygun_l:
lda RAYGUNS
lsr
lsr
lsr
lsr
beq update_raygun_r
ora #$b0 ; 0 -> $b0
sta score_string+26
update_raygun_r:
lda RAYGUNS
and #$f
ora #$b0 ; 0 -> $b0
sta score_string+27
rts
2024-03-10 05:44:20 +00:00
;===========================
; update score
;===========================
2024-03-20 05:40:58 +00:00
; remove leading zeros
; leftmost is score_string+4 (it's +2 due to x,y coord at begin)
2024-03-10 05:44:20 +00:00
update_score:
2024-03-20 05:40:58 +00:00
lda #0
sta LEADING_ZERO
2024-03-10 05:44:20 +00:00
2024-03-20 05:40:58 +00:00
update_score2_l:
lda SCORE2
lsr
lsr
lsr
lsr
beq update_score2_r
ora #$b0 ; 0 -> $b0
sta score_string+3
inc LEADING_ZERO
update_score2_r:
lda SCORE2
2024-03-10 05:44:20 +00:00
and #$f
2024-03-20 05:40:58 +00:00
bne write_score2_r
ldx LEADING_ZERO
beq update_score_1_l
write_score2_r:
2024-03-10 05:44:20 +00:00
ora #$b0 ; 0 -> $b0
2024-03-20 05:40:58 +00:00
sta score_string+4
inc LEADING_ZERO
2024-03-10 05:44:20 +00:00
2024-03-20 05:40:58 +00:00
update_score_1_l:
lda SCORE1
2024-03-10 05:44:20 +00:00
lsr
lsr
lsr
lsr
2024-03-20 05:40:58 +00:00
bne write_score1_l
ldx LEADING_ZERO
beq update_score_1_r
write_score1_l:
2024-03-10 05:44:20 +00:00
ora #$b0 ; 0 -> $b0
sta score_string+5
2024-03-20 05:40:58 +00:00
inc LEADING_ZERO
2024-03-10 05:44:20 +00:00
2024-03-20 05:40:58 +00:00
update_score_1_r:
2024-03-10 05:44:20 +00:00
lda SCORE1
and #$f
2024-03-20 05:40:58 +00:00
bne write_score1_r
ldx LEADING_ZERO
beq update_score_0_l
write_score1_r:
2024-03-10 05:44:20 +00:00
ora #$b0 ; 0 -> $b0
2024-03-20 05:40:58 +00:00
sta score_string+6
inc LEADING_ZERO
2024-03-10 05:44:20 +00:00
2024-03-20 05:40:58 +00:00
update_score_0_l:
lda SCORE0
2024-03-10 05:44:20 +00:00
lsr
lsr
lsr
lsr
2024-03-20 05:40:58 +00:00
bne write_score0_l
ldx LEADING_ZERO
beq update_score_0_r
write_score0_l:
2024-03-10 05:44:20 +00:00
ora #$b0 ; 0 -> $b0
2024-03-20 05:40:58 +00:00
sta score_string+7
inc LEADING_ZERO
2024-03-10 05:44:20 +00:00
2024-03-20 05:40:58 +00:00
update_score_0_r:
lda SCORE0
2024-03-10 05:44:20 +00:00
and #$f
2024-03-20 05:40:58 +00:00
bne write_score0_r
ldx LEADING_ZERO
beq done_write_score
write_score0_r:
ora #$b0 ; 0 -> $b0
sta score_string+8
2024-03-10 05:44:20 +00:00
2024-03-20 05:40:58 +00:00
lda #$b0 ; after first string, this digit always 0
sta score_string+9
2024-03-10 05:44:20 +00:00
2024-03-20 05:40:58 +00:00
done_write_score:
2024-03-10 05:44:20 +00:00
2024-03-20 05:40:58 +00:00
rts
2024-03-10 05:44:20 +00:00
2024-03-10 05:44:20 +00:00
;===========================
; update items
;===========================
update_items:
lda KEYCARDS
2024-03-10 05:44:20 +00:00
and #INV_RED_KEY
beq done_red_key
lda #'R'&$3f
sta score_string+33
2024-03-10 05:44:20 +00:00
done_red_key:
lda KEYCARDS
2024-03-10 05:44:20 +00:00
and #INV_BLUE_KEY
beq done_blue_key
lda #'B'&$3f
sta score_string+35
2024-03-10 05:44:20 +00:00
done_blue_key:
rts
;===========================
; update the status bar
;===========================
;update_status_bar:
;
; jsr update_score
;
; jsr update_health
;
; jsr update_items
;
; lda #2
; sta UPDATE_STATUS
;
; rts
2024-03-10 05:44:20 +00:00
;===========================
; draw the status bar
;===========================
2024-03-16 05:28:25 +00:00
; only draw when ENTER pressed, not always
2024-03-10 05:44:20 +00:00
draw_status_bar:
jsr update_score
2024-03-20 05:45:37 +00:00
jsr update_rayguns
bit TEXTGR ; split graphics/text
2024-03-10 05:44:20 +00:00
2024-03-16 05:28:25 +00:00
; draw to visible frame
lda DRAW_PAGE
eor #$4
sta DRAW_PAGE
2024-03-10 05:44:20 +00:00
; draw white box
ldx #30
draw_box_loop:
lda gr_offsets,X
sta OUTL
lda gr_offsets+1,X
clc
adc DRAW_PAGE
sta OUTH
ldy #39
lda #$FF
draw_box_inner:
sta (OUTL),Y
dey
bpl draw_box_inner
inx
inx
cpx #40
bne draw_box_loop
2024-03-20 05:40:58 +00:00
;============
; draw keens
2024-03-20 05:40:58 +00:00
ldx KEENS
cpx #7 ; max out at 7
bcc draw_keens
ldx #7
draw_keens:
dex
stx TEMP_STATUS
beq done_draw_keens ; if 0, don't draw any
draw_keens_loop:
ldx #<keen_sprite_stand_right
stx INL
lda #>keen_sprite_stand_right
sta INH
; XPOS, YPOS
2024-03-20 05:40:58 +00:00
lda TEMP_STATUS
asl
asl
; clc
; adc #1
sta XPOS
lda #32
sta YPOS
jsr put_sprite_crop
2024-03-20 05:40:58 +00:00
dec TEMP_STATUS
bpl draw_keens_loop
2024-03-20 05:40:58 +00:00
done_draw_keens:
; TODO: draw keycards
; TODO: draw parts
; draw text at bottom
jsr inverse_text
lda #<status_string
2024-03-10 05:44:20 +00:00
sta OUTL
lda #>status_string
2024-03-10 05:44:20 +00:00
sta OUTH
jsr move_and_print
jsr move_and_print
jsr move_and_print
jsr move_and_print
2024-03-16 05:28:25 +00:00
; wait for keypress
bit KEYRESET
wait_status_bar:
lda KEYPRESS
bpl wait_status_bar
bit KEYRESET
; back to original page
lda DRAW_PAGE
eor #$4
sta DRAW_PAGE
bit FULLGR
2024-03-10 05:44:20 +00:00
rts
status_string:
; 0123456789012345678901234567890123456789
.byte 0,20," KEENS KEYCARDS PARTS ",0
.byte 0,21," ",0
.byte 0,22," SCORE NEXT KEEN RAYGUN POGO ",0
score_string:
2024-03-20 05:40:58 +00:00
.byte 0,23," 0 20000 0 N ",0
2024-03-10 05:44:20 +00:00