Added text damage

This commit is contained in:
Rob McMullen 2017-07-20 21:49:24 -07:00
parent f7924f12bd
commit 0d0705b43f
4 changed files with 100 additions and 6 deletions

View File

@ -40,6 +40,7 @@ check_dots nop
; update both screens!
damage_maze nop
jsr damage_char
rts

12
debug.s
View File

@ -80,4 +80,16 @@ debug_player nop
ldy scratch_row
jsr printhex
dec scratch_row
ldx #0
lda tdamageindex1
ldx #35
ldy scratch_row
jsr printhex
ldx #0
lda tdamageindex2
ldx #38
ldy scratch_row
jsr printhex
rts

View File

@ -14,6 +14,10 @@ init_screen_once nop
sta damageptr1+1
lda #damagepage2
sta damageptr2+1
lda #0
sta tdamageindex1
lda #128
sta tdamageindex2
jsr draw_to_page1
rts
@ -196,6 +200,13 @@ draw_to_page1 lda #$00
lda damageindex1
sta damageindex
lda tdamageindex ; save other page's damage pointer
sta tdamageindex2
lda tdamageindex1 ; point to page 1's damage area
sta tdamageindex
lda #0
sta damagestart
; copy addresses for functions that write to one page or the other
lda #<FASTFONT_H1
sta fastfont+1
@ -219,6 +230,14 @@ draw_to_page2 lda #$60
sta damageptr+1
lda damageindex2
sta damageindex
lda tdamageindex ; save other page's damage pointer
sta tdamageindex1
lda tdamageindex2 ; point to page 2's damage area
sta tdamageindex
lda #128
sta damagestart
lda #<FASTFONT_H2
sta fastfont+1
sta copytexthgr_dest_smc+1
@ -347,7 +366,61 @@ renderend
rts
damage_text nop
; text position in r, c. add to both pages!
damage_char nop
ldy tdamageindex1
lda c
sta TEXTDAMAGE,y
iny
lda r
sta TEXTDAMAGE,y
iny
sty tdamageindex1
ldy tdamageindex2
lda c
sta TEXTDAMAGE,y
iny
lda r
sta TEXTDAMAGE,y
iny
sty tdamageindex2
lda damagestart
bmi ?2
lda tdamageindex1
sta tdamageindex
rts
?2 lda tdamageindex2
sta tdamageindex
rts
restoretext nop
ldy damagestart
sty param_index
?loop1 ldy param_index
cpy tdamageindex
bcc ?cont ; possible there's no damage, so have to check first
lda damagestart
sta tdamageindex ; clear damage index for this page
rts
?cont lda TEXTDAMAGE,y ; groups of 4 x1 -> x2, y1 -> y2
sta param_col
iny
lda TEXTDAMAGE,y
sta param_row
iny
sty param_index
ldy param_row
lda textrows_h,y
sta ?row_smc+2
lda textrows_l,y
sta ?row_smc+1
ldx param_col
?row_smc lda $ffff,x
jsr fastfont
jmp ?loop1

View File

@ -49,13 +49,19 @@ damage_h .ds 1
damageptr .ds 2
damageptr1 .ds 2
damageptr2 .ds 2
hgrhi .ds 1 ; either $20 or $40, the base of each hgr screen
hgrselect .ds 1 ; either $00 or $60, used as xor mask for HGRROWS_H1
*= $0030
tdamageindex .ds 1
tdamageindex1 .ds 1
tdamageindex2 .ds 1
damagestart .ds 1
*= $0040
; global variables for this program
rendercount .ds 1
drawpage .ds 1 ; pos = page1, neg = page2
hgrhi .ds 1 ; either $20 or $40, the base of each hgr screen
hgrselect .ds 1 ; either $00 or $60, used as xor mask for HGRROWS_H1
tempaddr .ds 2
counter1 .ds 1
textptr .ds 2
@ -63,7 +69,7 @@ hgrptr .ds 2
temprow .ds 1
tempcol .ds 1
*= $0040
*= $0050
mazeaddr .ds 2
next_level_box .ds 1
box_row_save .ds 1
@ -75,7 +81,7 @@ frame_count .ds 2
countdown_time .ds 1
still_alive .ds 1
*= $50
*= $0060
current_actor .ds 1
current .ds 1 ; current direction
allowed .ds 1 ; allowed directions
@ -91,11 +97,12 @@ last_enemy .ds 1
; BF00 - BFFF: damage for page 1
; BE00 - BEFF: damage for page 2
; BD00 - BDFF: level box storage
; BC00 - BCFF: text damage
; constants
DAMAGEPAGE1 = $bf ; page number of damage list for screen 1
DAMAGEPAGE2 = $be ; "" for screen 2
TEXTDAMAGE = $bc00
MAXPOSX = 220
MAXPOSY = 192 - 16
@ -227,6 +234,7 @@ game_loop nop
; draw_actors()
; show_screen()
?draw jsr restorebg_driver
jsr restoretext
jsr renderstart
jsr pageflip
jsr wait