mirror of
https://github.com/robmcmullen/fujirun.git
synced 2025-01-14 00:32:55 +00:00
Added debug check for boundary crossing in text screen or tile movement
This commit is contained in:
parent
e1a7386f96
commit
ebb1cae8d2
13
background.s
13
background.s
@ -327,12 +327,23 @@ restorebg_cont lda (damageptr),y ; groups of 4 x1 -> x2, y1 -> y2
|
||||
|
||||
ldy param_y
|
||||
restorebg_row lda textrows_h,y
|
||||
.if DEBUG_BOUNDS
|
||||
cpy #24
|
||||
bcc ?1
|
||||
jsr debug_bounds
|
||||
.endif
|
||||
?1 lda textrows_h,y
|
||||
sta restorebg_row_smc+2
|
||||
lda textrows_l,y
|
||||
sta restorebg_row_smc+1
|
||||
ldx param_x
|
||||
restorebg_row_smc lda $ffff,x
|
||||
jsr fastfont
|
||||
.if DEBUG_BOUNDS
|
||||
cpx #40
|
||||
bcc ?1
|
||||
jsr debug_bounds
|
||||
.endif
|
||||
?1 jsr fastfont
|
||||
inx
|
||||
cpx param_col
|
||||
bcc restorebg_row_smc
|
||||
|
116
debug.s
116
debug.s
@ -45,6 +45,122 @@ printstr ; X = column, Y = row, scratch_ptr is text (null terminated)
|
||||
bne ?next
|
||||
?exit rts
|
||||
|
||||
error_bounds_text .byte "BOUNDS", 0
|
||||
|
||||
; debug function to display address near where the problem was found.
|
||||
; By calling using a JSR, the return address is available on the stack
|
||||
error_bounds nop
|
||||
lda #9
|
||||
sta scratch_row
|
||||
|
||||
ldx #34 ; x coord on screen for "BOUNDS"
|
||||
ldy scratch_row
|
||||
lda #<error_bounds_text
|
||||
sta scratch_ptr
|
||||
lda #>error_bounds_text
|
||||
sta scratch_ptr+1
|
||||
jsr printstr
|
||||
|
||||
inc scratch_row
|
||||
pla
|
||||
ldx #38
|
||||
ldy scratch_row
|
||||
jsr debughex
|
||||
pla
|
||||
ldx #36
|
||||
ldy scratch_row
|
||||
jsr debughex
|
||||
|
||||
inc scratch_row
|
||||
lda current_actor
|
||||
ldx #38
|
||||
ldy scratch_row
|
||||
jsr debughex
|
||||
|
||||
inc scratch_row
|
||||
ldx #34
|
||||
ldy scratch_row
|
||||
lda #'x'
|
||||
jsr fastfont
|
||||
ldx current_actor
|
||||
lda actor_x,x
|
||||
ldx #35
|
||||
ldy scratch_row
|
||||
jsr debughex
|
||||
ldx current_actor
|
||||
lda actor_y,x
|
||||
ldx #38
|
||||
ldy scratch_row
|
||||
jsr debughex
|
||||
|
||||
inc scratch_row
|
||||
ldx #34
|
||||
ldy scratch_row
|
||||
lda #'c'
|
||||
jsr fastfont
|
||||
ldx current_actor
|
||||
lda actor_col,x
|
||||
ldx #35
|
||||
ldy scratch_row
|
||||
jsr debughex
|
||||
ldx current_actor
|
||||
lda actor_row,x
|
||||
ldx #38
|
||||
ldy scratch_row
|
||||
jsr debughex
|
||||
|
||||
inc scratch_row
|
||||
ldx #34
|
||||
ldy scratch_row
|
||||
lda #'p'
|
||||
jsr fastfont
|
||||
ldx current_actor
|
||||
lda actor_xpixel,x
|
||||
ldx #35
|
||||
ldy scratch_row
|
||||
jsr debughex
|
||||
ldx current_actor
|
||||
lda actor_ypixel,x
|
||||
ldx #38
|
||||
ldy scratch_row
|
||||
jsr debughex
|
||||
|
||||
inc scratch_row
|
||||
ldx #34
|
||||
ldy scratch_row
|
||||
lda #'.'
|
||||
jsr fastfont
|
||||
ldx current_actor
|
||||
lda actor_xfrac,x
|
||||
ldx #35
|
||||
ldy scratch_row
|
||||
jsr debughex
|
||||
ldx current_actor
|
||||
lda actor_yfrac,x
|
||||
ldx #38
|
||||
ldy scratch_row
|
||||
jsr debughex
|
||||
|
||||
inc scratch_row
|
||||
ldx #34
|
||||
ldy scratch_row
|
||||
lda #'d'
|
||||
jsr fastfont
|
||||
ldx current_actor
|
||||
lda actor_dir,x
|
||||
ldx #35
|
||||
ldy scratch_row
|
||||
jsr debughex
|
||||
ldx current_actor
|
||||
lda actor_target_col,x
|
||||
ldx #38
|
||||
ldy scratch_row
|
||||
jsr debughex
|
||||
|
||||
jsr pageflip
|
||||
ldx current_actor ; restore X register
|
||||
?1 jmp ?1 ; wait for debugger
|
||||
|
||||
|
||||
debug_damage .byte 0
|
||||
debug_paint_box .byte 0
|
||||
|
46
logic.s
46
logic.s
@ -56,13 +56,23 @@ evaluate_status nop
|
||||
; convert tile and sub-tile position into coordinate on screen
|
||||
get_sprite nop
|
||||
lda actor_row,x
|
||||
tay
|
||||
.if DEBUG_BOUNDS
|
||||
cmp #24
|
||||
bcc ?1
|
||||
jsr debug_bounds
|
||||
.endif
|
||||
?1 tay
|
||||
lda player_row_to_y,y
|
||||
clc
|
||||
adc actor_ypixel,x
|
||||
sta actor_y,x
|
||||
lda actor_col,x
|
||||
tay
|
||||
.if DEBUG_BOUNDS
|
||||
cmp #40
|
||||
bcc ?2
|
||||
jsr debug_bounds
|
||||
.endif
|
||||
?2 tay
|
||||
lda player_col_to_x,y
|
||||
clc
|
||||
adc actor_xpixel,x
|
||||
@ -369,7 +379,13 @@ move_tile nop
|
||||
?left lda actor_xpixel,x
|
||||
bpl ?right
|
||||
dec actor_col,x
|
||||
lda actor_xpixel,x
|
||||
.if DEBUG_BOUNDS
|
||||
lda actor_col,x
|
||||
cmp #MAZE_LEFT_COL
|
||||
bcs ?1b
|
||||
jsr error_bounds
|
||||
.endif
|
||||
?1b lda actor_xpixel,x
|
||||
clc
|
||||
adc #X_TILEMAX
|
||||
sta actor_xpixel,x
|
||||
@ -382,7 +398,13 @@ move_tile nop
|
||||
cmp #X_TILEMAX
|
||||
bcc ?up
|
||||
inc actor_col,x
|
||||
lda actor_xpixel,x
|
||||
.if DEBUG_BOUNDS
|
||||
lda actor_col,x
|
||||
cmp #MAZE_RIGHT_COL+1
|
||||
bcc ?2b
|
||||
jsr error_bounds
|
||||
.endif
|
||||
?2b lda actor_xpixel,x
|
||||
sec
|
||||
sbc #X_TILEMAX
|
||||
sta actor_xpixel,x
|
||||
@ -396,7 +418,13 @@ move_tile nop
|
||||
?up lda actor_ypixel,x
|
||||
bpl ?down
|
||||
dec actor_row,x
|
||||
lda actor_ypixel,x
|
||||
.if DEBUG_BOUNDS
|
||||
lda actor_row,x
|
||||
cmp #MAZE_TOP_ROW
|
||||
bcs ?3b
|
||||
jsr error_bounds
|
||||
.endif
|
||||
?3b lda actor_ypixel,x
|
||||
clc
|
||||
adc #Y_TILEMAX
|
||||
sta actor_ypixel,x
|
||||
@ -409,7 +437,13 @@ move_tile nop
|
||||
cmp #Y_TILEMAX
|
||||
bcc ?ret
|
||||
inc actor_row,x
|
||||
lda actor_ypixel,x
|
||||
.if DEBUG_BOUNDS
|
||||
lda actor_row,x
|
||||
cmp #MAZE_BOT_ROW+1
|
||||
bcc ?4b
|
||||
jsr error_bounds
|
||||
.endif
|
||||
?4b lda actor_ypixel,x
|
||||
sec
|
||||
sbc #Y_TILEMAX
|
||||
sta actor_ypixel,x
|
||||
|
Loading…
x
Reference in New Issue
Block a user