diff --git a/plat.nes b/plat.nes index d33954f..b99e483 100644 Binary files a/plat.nes and b/plat.nes differ diff --git a/plat.s b/plat.s index d7a251c..026eb41 100644 --- a/plat.s +++ b/plat.s @@ -326,6 +326,7 @@ example_palette: buttons: .res 1 player_pos_x: .res 1 +player_nmt_x: .res 1 player_pos_y: .res 1 player_subpos_x: .res 1 ; XXXXYYYY | first 4 bits X subposition, last 4 bits Y player_subpos_y: .res 1 ; XXXXYYYY | first 4 bits X subposition, last 4 bits Y @@ -333,6 +334,8 @@ player_vel_x: .res 1 ; +PPPSSSS | first bit sign, next 3 pixels, last subpixel player_vel_y: .res 1 ; in subpixels player_status: .res 1 ; 76543210 | 0: facing (0 right, 1 left) + ; | 1: nametable X + ; | 2: nametable Y ; | 7: talking horizontal_speed: .res 1 @@ -382,8 +385,15 @@ main: adc #1 sta frame_counter + lda scroll_x + adc #1 + cmp scroll_x sta scroll_x - + bcs :+ + lda scroll_nmt + eor #%00000001 + sta scroll_nmt + : jsr controller jsr movement @@ -406,6 +416,47 @@ draw_player: sta oam + (4 * 0) + 0 sta oam + (4 * 1) + 0 + + +jmp @after + ; 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 + bcs :+ + lda player_status + clc + ror + eor scroll_nmt + beq @end_position_application + jmp :++ + : + ; if nothing, nametable bits must be same to continue + lda player_status + clc + ror + eor scroll_nmt + bne @end_position_application + : +@after: + + +;;;;;;;;;;;;;;;;;;;;;;;;;PUT WHEN VELOCITY IS BEING APPLIED + lda player_pos_x + adc #1 + cmp player_pos_x + sta player_pos_x + bcs :+ + lda player_status + eor #%00000010 + sta player_status + : +;;;;;;;;;;;;;;;;;;;;;;;;; + + + + lda player_status and #%00000001 cmp #0 @@ -432,6 +483,8 @@ draw_player: sta oam + (4 * 3) + 3 : + @end_position_application: + lda player_status and #%10000000 cmp #0 @@ -606,6 +659,8 @@ movement: : @end: + + ; Jump jsr btn_a cmp #0