keen: score updates properly

This commit is contained in:
Vince Weaver 2024-03-20 01:40:58 -04:00
parent f3f4681194
commit 7387e83a63
3 changed files with 133 additions and 54 deletions

View File

@ -21,11 +21,21 @@ check_item:
; 4 = carbonated beverage 200 pts ; 4 = carbonated beverage 200 pts
; ? = bear 5000 pts ; ? = bear 5000 pts
beq get_laser_gun
; otherwise look up points and add it
tay
lda score_lookup,Y
jsr inc_score
jmp done_item_pickup
get_laser_gun:
; keycards go here too... ; keycards go here too...
get_keycard:
; use value to update score done_item_pickup:
; erase ; erase
@ -104,3 +114,13 @@ check_blue_key:
.endif .endif
done_check_item: done_check_item:
rts rts
score_lookup:
.byte $00,$01,$10,$05,$02,$50 ; BCD
; 0 = laser gun
; 1 = lollipop 100 pts
; 2 = book 1000 pts
; 3 = pizza 500 pts
; 4 = carbonated beverage 200 pts
; ? = bear 5000 pts

View File

@ -21,6 +21,7 @@ inc_score:
lda SCORE2 lda SCORE2
adc #0 adc #0
sta SCORE2 sta SCORE2
cld cld
rts rts
@ -28,67 +29,103 @@ inc_score:
;=========================== ;===========================
; update score ; update score
;=========================== ;===========================
; remove leading zeros
; leftmost is score_string+4 (it's +2 due to x,y coord at begin)
update_score: update_score:
lda #0
sta LEADING_ZERO
lda SCORE0 update_score2_l:
and #$f lda SCORE2
ora #$b0 ; 0 -> $b0 lsr
sta score_string+6 lsr
lsr
lsr
lda SCORE0 beq update_score2_r
lsr
lsr
lsr
lsr
ora #$b0 ; 0 -> $b0
sta score_string+5
lda SCORE1
and #$f
ora #$b0 ; 0 -> $b0
sta score_string+4
lda SCORE1
lsr
lsr
lsr
lsr
ora #$b0 ; 0 -> $b0 ora #$b0 ; 0 -> $b0
sta score_string+3 sta score_string+3
inc LEADING_ZERO
update_score2_r:
lda SCORE2 lda SCORE2
and #$f and #$f
bne write_score2_r
ldx LEADING_ZERO
beq update_score_1_l
write_score2_r:
ora #$b0 ; 0 -> $b0 ora #$b0 ; 0 -> $b0
sta score_string+2 sta score_string+4
inc LEADING_ZERO
update_score_1_l:
lda SCORE1
lsr
lsr
lsr
lsr
bne write_score1_l
ldx LEADING_ZERO
beq update_score_1_r
write_score1_l:
ora #$b0 ; 0 -> $b0
sta score_string+5
inc LEADING_ZERO
update_score_1_r:
lda SCORE1
and #$f
bne write_score1_r
ldx LEADING_ZERO
beq update_score_0_l
write_score1_r:
ora #$b0 ; 0 -> $b0
sta score_string+6
inc LEADING_ZERO
update_score_0_l:
lda SCORE0
lsr
lsr
lsr
lsr
bne write_score0_l
ldx LEADING_ZERO
beq update_score_0_r
write_score0_l:
ora #$b0 ; 0 -> $b0
sta score_string+7
inc LEADING_ZERO
update_score_0_r:
lda SCORE0
and #$f
bne write_score0_r
ldx LEADING_ZERO
beq done_write_score
write_score0_r:
ora #$b0 ; 0 -> $b0
sta score_string+8
lda #$b0 ; after first string, this digit always 0
sta score_string+9
done_write_score:
rts rts
;===========================
; update health
;===========================
.if 0
update_health:
ldx #0
update_health_loop:
cpx HEALTH
bcc health_on
lda #'_'|$80
bne done_health
health_on:
lda #' '
done_health:
sta score_string+9,X
inx
cpx #8
bne update_health_loop
rts
.endif
;=========================== ;===========================
; update items ; update items
@ -177,8 +214,22 @@ draw_box_inner:
bne draw_box_loop bne draw_box_loop
;============
; draw keens ; draw keens
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 ldx #<keen_sprite_stand_right
stx INL stx INL
lda #>keen_sprite_stand_right lda #>keen_sprite_stand_right
@ -186,14 +237,22 @@ draw_box_inner:
; XPOS, YPOS ; XPOS, YPOS
lda #2 lda TEMP_STATUS
asl
asl
; clc
; adc #1
sta XPOS sta XPOS
lda #32 lda #32
sta YPOS sta YPOS
jsr put_sprite_crop jsr put_sprite_crop
dec TEMP_STATUS
bpl draw_keens_loop
done_draw_keens:
; TODO: draw keycards ; TODO: draw keycards
@ -236,5 +295,5 @@ status_string:
.byte 0,21," ",0 .byte 0,21," ",0
.byte 0,22," SCORE NEXT KEEN RAYGUN POGO ",0 .byte 0,22," SCORE NEXT KEEN RAYGUN POGO ",0
score_string: score_string:
.byte 0,23," 00000000 20000 0 N ",0 .byte 0,23," 0 20000 0 N ",0

View File

@ -187,8 +187,8 @@ SAMPLE_H = $F3
LEADING_ZERO = $F8
TEMP_STATUS = $F9
TEMP = $FA TEMP = $FA
TEMPY = $FB TEMPY = $FB
INL = $FC INL = $FC