diff --git a/plat.nes b/plat.nes index 9c9c72f..af23c2d 100644 Binary files a/plat.nes and b/plat.nes differ diff --git a/plat.s b/plat.s index a639ff6..9e65f34 100644 --- a/plat.s +++ b/plat.s @@ -413,9 +413,9 @@ main: jmp @loop move_camera: - lda scroll_x + lda #%1 clc - adc #0 + adc scroll_x cmp scroll_x sta scroll_x bcs :+ @@ -426,26 +426,6 @@ move_camera: rts 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 sec sbc #1 @@ -456,6 +436,98 @@ draw_player: sta oam + (4 * 0) + 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 and #%00000001 cmp #0 @@ -481,17 +553,6 @@ draw_player: sta oam + (4 * 1) + 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 and #%10000000