Drawing player across two nametables complete

This commit is contained in:
RochesterX
2026-02-21 16:01:27 -05:00
parent 7016042cff
commit 8cc2052c99
2 changed files with 94 additions and 33 deletions

BIN
plat.nes

Binary file not shown.

127
plat.s
View File

@@ -413,9 +413,9 @@ main:
jmp @loop jmp @loop
move_camera: move_camera:
lda scroll_x lda #%1
clc clc
adc #0 adc scroll_x
cmp scroll_x cmp scroll_x
sta scroll_x sta scroll_x
bcs :+ bcs :+
@@ -426,26 +426,6 @@ move_camera:
rts rts
draw_player: draw_player:
; see if we can skip drawing the player because it's off screen
lda player_pos_x
sec
sbc scroll_x
cmp player_pos_x ; if underflow, nametable bits must be different to continue
beq @skip_bcs
bcs :+
@skip_bcs:
lda player_nmt_x
eor scroll_nmt
beq @hide_player
jmp :++
:
; if nothing, nametable bits must be same to continue
lda player_nmt_x
eor scroll_nmt
bne @hide_player
:
lda player_pos_y lda player_pos_y
sec sec
sbc #1 sbc #1
@@ -456,6 +436,98 @@ draw_player:
sta oam + (4 * 0) + 0 sta oam + (4 * 0) + 0
sta oam + (4 * 1) + 0 sta oam + (4 * 1) + 0
; RIGHT HALF LOGIC
; see if we can skip drawing the player because it's off screen
lda player_pos_x
sec
sbc scroll_x
cmp player_pos_x ; if underflow, nametable bits must be different to continue
beq @skip_bcs_right
bcs :+
@skip_bcs_right:
lda player_nmt_x
eor scroll_nmt
beq @hide_player_right
jmp :++
:
; if nothing, nametable bits must be same to continue
lda player_nmt_x
eor scroll_nmt
bne @hide_player_right
:
jmp @end_hide_player_right
@hide_player_right:
lda player_status
and #%00000001
cmp #0
bne :+
lda #250
sta oam + (4 * 1) + 0
sta oam + (4 * 3) + 0
jmp :++
:
lda #250
sta oam + (4 * 0) + 0
sta oam + (4 * 2) + 0
:
@end_hide_player_right:
; LEFT HALF LOGIC
; store what nametable the player's left half is on in var_n
; store what position the player's left half is at in var_p
lda player_pos_x
sec
sbc #8
sta var_p
bcs :+
lda player_nmt_x
eor #%00000001
sta var_n
jmp :++
:
lda player_nmt_x
sta var_n
:
lda var_p
sec
sbc scroll_x
cmp var_p ; if underflow, nametable bits must be different to continue
beq @skip_bcs_left
bcs :+
@skip_bcs_left:
lda var_n
eor scroll_nmt
beq @hide_player_left
jmp :++
:
; if nothing, nametable bits must be same to continue
lda var_n
eor scroll_nmt
bne @hide_player_left
:
jmp @end_hide_player_left
@hide_player_left:
lda player_status
and #%00000001
cmp #0
bne :+
lda #250
sta oam + (4 * 0) + 0
sta oam + (4 * 2) + 0
jmp :++
:
lda #250
sta oam + (4 * 1) + 0
sta oam + (4 * 3) + 0
:
@end_hide_player_left:
lda player_status lda player_status
and #%00000001 and #%00000001
cmp #0 cmp #0
@@ -481,17 +553,6 @@ draw_player:
sta oam + (4 * 1) + 3 sta oam + (4 * 1) + 3
sta oam + (4 * 3) + 3 sta oam + (4 * 3) + 3
: :
jmp @end_hide_player
@hide_player:
lda #250
sta oam + (4 * 2) + 0
sta oam + (4 * 3) + 0
sta oam + (4 * 0) + 0
sta oam + (4 * 1) + 0
@end_hide_player:
lda player_status lda player_status
and #%10000000 and #%10000000