Movement refactor
This commit is contained in:
67
plat.s
67
plat.s
@@ -333,6 +333,7 @@ jump_pressed_last_frame: .res 1
|
|||||||
|
|
||||||
frame_counter: .res 1
|
frame_counter: .res 1
|
||||||
last_frame_jumped: .res 1
|
last_frame_jumped: .res 1
|
||||||
|
last_frame_moving: .res 1
|
||||||
|
|
||||||
.segment "CODE"
|
.segment "CODE"
|
||||||
main:
|
main:
|
||||||
@@ -514,6 +515,9 @@ movement:
|
|||||||
lda player_status
|
lda player_status
|
||||||
and #%11111110
|
and #%11111110
|
||||||
sta player_status
|
sta player_status
|
||||||
|
|
||||||
|
lda frame_counter
|
||||||
|
sta last_frame_moving
|
||||||
:
|
:
|
||||||
|
|
||||||
jsr btn_left
|
jsr btn_left
|
||||||
@@ -521,31 +525,41 @@ movement:
|
|||||||
beq :+
|
beq :+
|
||||||
ldx #1
|
ldx #1
|
||||||
lda horizontal_speed
|
lda horizontal_speed
|
||||||
ora #%10000000
|
eor #%11111111
|
||||||
|
clc
|
||||||
|
adc #1
|
||||||
sta player_vel_x
|
sta player_vel_x
|
||||||
|
|
||||||
lda player_status
|
lda player_status
|
||||||
ora #%00000001
|
ora #%00000001
|
||||||
sta player_status
|
sta player_status
|
||||||
|
|
||||||
|
lda frame_counter
|
||||||
|
sta last_frame_moving
|
||||||
:
|
:
|
||||||
|
|
||||||
cpx #1
|
cpx #1 ; skip decay if right or left pressed
|
||||||
beq @end
|
beq @end
|
||||||
lda frame_counter
|
lda frame_counter
|
||||||
and #1
|
clc
|
||||||
|
sbc last_frame_moving
|
||||||
|
and #3
|
||||||
cmp #0
|
cmp #0
|
||||||
bne @end
|
bne @end
|
||||||
|
|
||||||
lda #0
|
lda player_vel_x
|
||||||
cmp player_vel_x
|
and #%01111111
|
||||||
|
cmp #0
|
||||||
beq @end ; If player_vel_x = 0, skip decay
|
beq @end ; If player_vel_x = 0, skip decay
|
||||||
|
|
||||||
; If player_vel_x > 0, decrement
|
lda player_vel_x
|
||||||
bpl :+
|
and #%10000000
|
||||||
|
; If player_vel_x positive, decrement
|
||||||
|
bne :+
|
||||||
lda player_vel_x
|
lda player_vel_x
|
||||||
sec
|
sec
|
||||||
sbc #16
|
sbc #16
|
||||||
stx player_vel_x
|
sta player_vel_x
|
||||||
jmp @end
|
jmp @end
|
||||||
:
|
:
|
||||||
; Else if player_vel_x < 0, increment
|
; Else if player_vel_x < 0, increment
|
||||||
@@ -603,7 +617,7 @@ movement:
|
|||||||
bne :+
|
bne :+
|
||||||
; 0: right
|
; 0: right
|
||||||
lda player_vel_x
|
lda player_vel_x
|
||||||
and #%01110000
|
and #%01111111
|
||||||
clc
|
clc
|
||||||
ror
|
ror
|
||||||
clc
|
clc
|
||||||
@@ -612,7 +626,9 @@ movement:
|
|||||||
ror
|
ror
|
||||||
clc
|
clc
|
||||||
ror
|
ror
|
||||||
sta var_n ; pixels
|
clc
|
||||||
|
adc player_pos_x
|
||||||
|
sta player_pos_x ; add pixels
|
||||||
|
|
||||||
lda player_vel_x
|
lda player_vel_x
|
||||||
and #%00001111
|
and #%00001111
|
||||||
@@ -633,19 +649,19 @@ movement:
|
|||||||
:
|
:
|
||||||
; 1: left
|
; 1: left
|
||||||
lda player_vel_x
|
lda player_vel_x
|
||||||
and #%01110000
|
sec
|
||||||
clc
|
ror
|
||||||
|
sec
|
||||||
|
ror
|
||||||
|
sec
|
||||||
|
ror
|
||||||
|
sec
|
||||||
ror
|
ror
|
||||||
clc
|
clc
|
||||||
ror
|
ora #%10000000
|
||||||
clc
|
adc player_pos_x
|
||||||
ror
|
sta player_pos_x ; add pixels
|
||||||
clc
|
|
||||||
ror
|
|
||||||
eor #%11111111
|
|
||||||
clc
|
|
||||||
adc #1
|
|
||||||
sta var_n ; pixels
|
|
||||||
|
|
||||||
lda player_vel_x
|
lda player_vel_x
|
||||||
and #%00001111
|
and #%00001111
|
||||||
@@ -662,17 +678,10 @@ movement:
|
|||||||
bmi @end_sub_subpos ; so skip if subpos is bigger than result
|
bmi @end_sub_subpos ; so skip if subpos is bigger than result
|
||||||
ldx player_pos_x
|
ldx player_pos_x
|
||||||
dex
|
dex
|
||||||
stx player_pos_x
|
;stx player_pos_x
|
||||||
@end_sub_subpos:
|
@end_sub_subpos:
|
||||||
:
|
:
|
||||||
|
|
||||||
lda player_pos_x
|
|
||||||
clc
|
|
||||||
adc var_n ; add pixels
|
|
||||||
|
|
||||||
|
|
||||||
sta player_pos_x
|
|
||||||
|
|
||||||
|
|
||||||
; load x pos, filter blocks, check up and down
|
; load x pos, filter blocks, check up and down
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user