-
Notifications
You must be signed in to change notification settings - Fork 0
/
_custom_jump.asm
152 lines (135 loc) · 2.65 KB
/
_custom_jump.asm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
_custom_jump:
if CUSTOM_JUMP_BANK == PLAYER_UPDATE_BANK
jsr rts_if_cutscene
if INERTIA != 0
ERROR INERTIA must be 0 if PLAYER_UPDATE_BANK=E
endif
JSR zero_hspfra
else
; return if in cutscene
lda cutscene_timer
beq __continue
lda cutscene_input
beq __continue
rts
__continue
if INERTIA == 0
; zero out fractional hspeed
lda #$00
sta hspfra
endif
endif
LDA joypad_down
AND #$03 ; 1=right, 2=left
BEQ hcancel
LSR A
BCC air_control_left
air_control_right:
; if left and right, hcancel
LSR A
BCS hcancel
; standard right
if INERTIA == 0
LDX #$01
STX hspint
else
jsr apply_inertia_rightward_full
endif
LDY #$00
BEQ __jumping_contd ; guaranteed
air_control_left:
if INERTIA == 0
LDX #$FF
STX hspint
else
jsr apply_inertia_leftward_full
endif
LDY #$01
__jumping_contd
; decide whether or not to set facing
LDA simon_state
CMP #8 ; jumping
BNE check_vcancel
LDA imgsin
CMP #$10
set_facing:
BEQ check_vcancel
STY facing
BNE check_vcancel ; guaranteed
hcancel:
if INERTIA == 0
STA hspint
else
; apply positive or negative inertia as necessary
; zero out hspfra *if* within INERTIA of #$0
lda hspint
bne standard_hcancel:
ldy #$0
lda hspfra
sty hspfra
cmp #INERTIA
bcc check_vcancel
CMP #($100-INERTIA)
bcs check_vcancel
sta hspfra
standard_hcancel
bit hspint
bmi +
jsr apply_inertia_leftward_full
jmp check_vcancel
+
jsr apply_inertia_rightward_full
endif
check_vcancel:
ifdef VCANCEL
LDA joypad_down
AND #$80 ; holding jump button?
BNE __vcancel_rts
LDA vspint ; already moving downward?
BPL __vcancel_rts
lda vsp_control
cmp #MINIMUM_VSP_CANCEL
bcc __vcancel_rts
LDA #VSP_CONTROL_ZERO_VSPEED
STA vsp_control
LDA #$00
STA vspint
endif
__vcancel_rts:
RTS
if INERTIA != 0
apply_inertia_rightward_full:
clc
lda #INERTIA
adc hspfra
sta hspfra
lda #$0
adc hspint
; clamp hspint
cmp #$01
bpl __apply_inertia_rts_r
sta hspint
rts
__apply_inertia_rts_r
lda #$01
__apply_inertia_rts
sta hspint
zero_hspfra_custom_bank:
lda #$0
sta hspfra
rts
apply_inertia_leftward_full:
sec
lda hspfra
sbc #INERTIA
sta hspfra
lda hspint
sbc #0
cmp #$FF
bmi __apply_inertia_l_rts
sta hspint
rts
__apply_inertia_l_rts:
lda #$FF
bne __apply_inertia_rts ; guaranteed
endif