tfv: battle menu update the HP and MP

This commit is contained in:
Vince Weaver 2021-01-18 00:52:12 -05:00
parent 386a719783
commit 4458f81f57
5 changed files with 167 additions and 2 deletions

View File

@ -72,6 +72,10 @@ gr_put_num_print_tens:
gr_put_num_ones:
; we were non-zero, notify leading zero
ldy #0
sty gr_put_num_leading_zero
; print ones digit
pla
and #$f

View File

@ -24,6 +24,11 @@ do_battle:
lda #20
sta BATTLE_COUNT
;======================
; update hp and mp
jsr update_hero_hp
jsr update_hero_mp
;========================
; rotate intro

View File

@ -127,6 +127,8 @@ health_too_high:
sta HERO_HP_LO
health_is_good:
jsr update_hero_hp
rts
;========================
@ -160,4 +162,7 @@ damage_hero_do_sub:
cld
damage_hero_done:
jsr update_hero_hp
rts

View File

@ -25,6 +25,7 @@ magic_attack:
beq do_magic_bolt
cmp #MENU_MAGIC_MALAISE
beq do_magic_malaise
brk
do_magic_heal: ; MENU_MAGIC_HEAL
lda #33
@ -177,6 +178,20 @@ magic_happens_loop:
; decrease magic points
; mp-=5;
lda HERO_MP
cmp #5
bcc hero_done_dec_mp
sed
sec
sbc #5
sta HERO_MP
cld
jsr update_hero_mp
hero_done_dec_mp:
jsr gr_copy_to_current
@ -208,6 +223,17 @@ magic_happens_loop:
was_heal_magic:
jsr heal_hero
; FIXME: print green
lda #30
sta XPOS
lda #10
sta YPOS
jsr gr_put_num
done_magic_damage:
jsr draw_battle_bottom

View File

@ -822,6 +822,131 @@ done_attack:
;===========================
; update_hero_mp
;===========================
; update displayed magic points
; one BCD byte
; put into mp_string
update_hero_mp:
lda #1
sta convert_bcd_to_string_leading_zero
lda #<(mp_string+2)
sta OUTL
lda #>(mp_string+2)
sta OUTH
lda HERO_MP
jmp convert_bcd_to_string
;===========================
; update_hero_hp
;===========================
; update displayed hitpoints
; two BCD bytes
; put into hp_string
update_hero_hp:
lda #1
sta convert_bcd_to_string_leading_zero
lda #<(hp_string+2)
sta OUTL
lda #>(hp_string+2)
sta OUTH
lda HERO_HP_HI
beq update_hero_hp_bottom_byte
jsr convert_bcd_to_string
update_hero_hp_bottom_byte:
lda HERO_HP_LO
jmp convert_bcd_to_string
;==========================================
;==========================================
; print two-digit BCD number into a string
;==========================================
;==========================================
convert_bcd_to_string:
pha ; store on stack
convert_bcd_tens:
and #$f0
bne convert_bcd_print_tens
; was zero, check if we should print
lda convert_bcd_to_string_leading_zero ; if 1, we skip
beq convert_bcd_tens_print_after_all
lda #' '|$80
bne convert_bcd_output_tens
convert_bcd_tens_print_after_all:
pla ; restore value
pha
convert_bcd_print_tens:
; we were non-zero, notify leading zero
ldy #0
sty convert_bcd_to_string_leading_zero
; print tens digit
lsr
lsr
lsr
lsr
ora #$B0 ; convert to ascii with hi bit set
convert_bcd_output_tens:
ldy #0
sta (OUTL),Y
inc OUTL
bne convert_bcd_tens_no_oflo
inc OUTH
convert_bcd_tens_no_oflo:
convert_bcd_num_ones:
; we were non-zero, notify leading zero
ldy #0
sty convert_bcd_to_string_leading_zero
; print ones digit
pla
and #$f
ora #$B0 ; convert to ascii with hi bit set
convert_bcd_output_ones:
ldy #0
sta (OUTL),Y
inc OUTL
bne convert_bcd_ones_no_oflo
inc OUTH
convert_bcd_ones_no_oflo:
rts
convert_bcd_to_string_leading_zero: .byte $01
;=========================
; menu strings
;=========================
@ -846,9 +971,9 @@ battle_menu_none:
.byte 30,20,"TIME",0
.byte 35,20,"LIMIT",0
hp_string:
.byte 23,21,"100",0
.byte 22,21," 100",0
mp_string:
.byte 26,21," 50",0
.byte 27,21,"50",0
; main menu strings