diff --git a/plat.nes b/plat.nes index b3b2a42..bf83f6b 100644 Binary files a/plat.nes and b/plat.nes differ diff --git a/plat.s b/plat.s index 6be9576..d83eb34 100644 --- a/plat.s +++ b/plat.s @@ -263,8 +263,8 @@ gamepad_poll: level: .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,1,0,0,6,0,0,9 -.byte 0,1,0,0,1,0,0,0,0,1,0,0,6,0,0,9 +.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 @@ -478,7 +478,7 @@ init_objects: sta player_vel_y sta player_status - lda #32 + lda #%00101000 sta horizontal_speed rts @@ -555,11 +555,17 @@ movement: lda player_vel_x and #%10000000 ; If player_vel_x positive, decrement - bne :+ + bne :++ lda player_vel_x sec sbc #16 sta player_vel_x + cmp #0 + bpl :+ + ; negative, clamp to 0 + lda #0 + sta player_vel_x + : jmp @end : ; Else if player_vel_x < 0, increment @@ -567,6 +573,13 @@ movement: clc adc #16 sta player_vel_x + cmp #0 + beq :+ + bmi :+ + ; positive, clamp to 0 + lda #0 + sta player_vel_x + : @end: ; Jump @@ -631,15 +644,15 @@ movement: sta player_pos_x ; add pixels lda player_vel_x - and #%00001111 - sta var_m ; subpixels ; A contains signed subpixels clc adc player_subpos_x ; add subposition and velocity subpixels and #%00001111 cmp player_subpos_x ; if A (result) is less than current subpos, overflow occurred - bpl @end_add_subpos ; so skip if subpos is smaller than result + 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 @@ -657,28 +670,27 @@ movement: ror sec ror - clc ora #%10000000 + clc + adc #1 + clc adc player_pos_x sta player_pos_x ; add pixels lda player_vel_x - and #%00001111 - eor #%00001111 - clc - adc #1 - and #%00001111 ; A contains signed subpixels clc adc player_subpos_x ; add subposition and velocity subpixels and #%00001111 cmp player_subpos_x ; if A (result) is greater than current subpos, underflow occurred - bmi @end_sub_subpos ; so skip if subpos is bigger than result + 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 + stx player_pos_x @end_sub_subpos: : @@ -1063,11 +1075,11 @@ downward_collision_check: cpx #0 bne :+ sec - sbc #6 + sbc #5 jmp :++ : clc - adc #5 + adc #4 : ; divide by 16 clc @@ -1132,11 +1144,11 @@ upward_collision_check: cpx #0 bne :+ sec - sbc #6 + sbc #5 jmp :++ : clc - adc #5 + adc #4 : ; divide by 16 clc