diff --git a/plat.nes b/plat.nes index 82e5f6b..9c9c72f 100644 Binary files a/plat.nes and b/plat.nes differ diff --git a/plat.s b/plat.s index 026eb41..a639ff6 100644 --- a/plat.s +++ b/plat.s @@ -279,20 +279,37 @@ level: level2: .byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -.byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -.byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -.byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -.byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -.byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +.byte 0,1,0,0,1,0,0,0,0,1,0,0,2,7,7,3 +.byte 0,0,0,0,0,0,0,0,0,0,0,0,6,0,0,9 +.byte 0,1,0,0,1,7,7,7,7,1,7,7,6,0,0,9 +.byte 0,0,1,1,0,0,0,0,0,1,0,0,4,8,8,5 +.byte 0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0 .byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 .byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 .byte 0,0,0,0,1,1,1,1,1,0,0,0,0,0,0,0 .byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 .byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 .byte 0,0,0,0,0,0,0,0,0,0,0,10,10,10,10,10 +.byte 0,0,1,0,0,0,0,1,0,0,0,11,11,11,11,11 +.byte 0,1,2,3,4,5,6,7,8,9,0,11,11,11,11,11 .byte 0,0,0,0,0,0,0,0,0,0,0,11,11,11,11,11 -.byte 0,1,7,7,7,7,7,7,7,1,0,11,11,11,11,11 -.byte 0,0,0,0,0,0,0,0,0,0,0,11,11,11,11,11 + +;level2: +;.byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +;.byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +;.byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +;.byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +;.byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +;.byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +;.byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +;.byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +;.byte 0,0,0,0,1,1,1,1,1,0,0,0,0,0,0,0 +;.byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +;.byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +;.byte 0,0,0,0,0,0,0,0,0,0,0,10,10,10,10,10 +;.byte 0,0,0,0,0,0,0,0,0,0,0,11,11,11,11,11 +;.byte 0,1,7,7,7,7,7,7,7,1,0,11,11,11,11,11 +;.byte 0,0,0,0,0,0,0,0,0,0,0,11,11,11,11,11 metatiles: .byte 0,0,0,0,0 @@ -385,19 +402,9 @@ 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 - lda player_pos_x + jsr move_camera @draw: jsr draw_player @@ -405,7 +412,40 @@ main: jmp @loop +move_camera: + lda scroll_x + clc + adc #0 + cmp scroll_x + sta scroll_x + bcs :+ + lda scroll_nmt + eor #%00000001 + sta scroll_nmt + : + 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 @@ -416,47 +456,6 @@ 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 @@ -482,8 +481,17 @@ jmp @after sta oam + (4 * 1) + 3 sta oam + (4 * 3) + 3 : + jmp @end_hide_player - @end_position_application: + @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 @@ -709,6 +717,7 @@ movement: bne :+ ; 0: right lda player_vel_x + sta var_o ; store initial velocity in o and #%01111111 clc ror @@ -721,6 +730,12 @@ movement: clc adc player_pos_x sta player_pos_x ; add pixels + bcc @end_pixel_overflow_right + lda player_nmt_x + eor #%00000001 + sta player_nmt_x + @end_pixel_overflow_right: + lda player_vel_x ; A contains signed subpixels @@ -732,15 +747,22 @@ movement: sta player_subpos_x beq @end_add_subpos bcs @end_add_subpos ; so skip if subpos is smaller than result - ldx player_pos_x - inx - stx player_pos_x + lda player_pos_x + clc + adc #1 + sta player_pos_x + bcc @end_subpixel_overflow_right + lda player_nmt_x + eor #%00000001 + sta player_nmt_x + @end_subpixel_overflow_right: @end_add_subpos: jmp :++ : ; 1: left lda player_vel_x + sta var_o sec ror sec @@ -751,10 +773,23 @@ movement: ror ora #%10000000 clc - adc #1 - clc adc player_pos_x sta player_pos_x ; add pixels + bcs @end_pixel_overflow_left + lda player_nmt_x + eor #%00000001 + sta player_nmt_x + @end_pixel_overflow_left: + ; :| + lda player_pos_x + clc + adc #1 + sta player_pos_x ; add... correction? + bcc @end_correction + lda player_nmt_x + eor #%00000001 + sta player_nmt_x + @end_correction: lda player_vel_x @@ -767,13 +802,23 @@ movement: sta player_subpos_x beq @end_sub_subpos bcc @end_sub_subpos ; so skip if subpos is bigger than result - ldx player_pos_x - dex - stx player_pos_x + lda player_pos_x + sec + sbc #1 + sta player_pos_x + bcs @end_subpixel_overflow_left + lda player_nmt_x + eor #%00000001 + sta player_nmt_x + @end_subpixel_overflow_left: @end_sub_subpos: : + + + + ; load x pos, filter blocks, check up and down lda player_vel_y