-
Notifications
You must be signed in to change notification settings - Fork 0
/
Snorlax.asm
276 lines (203 loc) · 6.97 KB
/
Snorlax.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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
;==============================================================================
; Sprite Properties
;==============================================================================
!SPRID = $D6 ; The sprite ID you are overwriting (HEX)
!NbrTiles = 4 ; Number of tiles used in a frame
!Harmless = 01 ; 00 = Sprite is Harmful, 01 = Sprite is Harmless
!HVelocity = 00 ; Is your sprite going super fast? put 01 if it is
!Health = 0 ; Number of Health the sprite have
!Damage = 0 ; (08 is a whole heart), 04 is half heart
!DeathAnimation = 00 ; 00 = normal death, 01 = no death animation
!ImperviousAll = 01 ; 00 = Can be attack, 01 = attack will clink on it
!SmallShadow = 00 ; 01 = small shadow, 00 = no shadow
!Shadow = 00 ; 00 = don't draw shadow, 01 = draw a shadow
!Palette = 0 ; Unused in this template (can be 0 to 7)
!Hitbox = 11 ; 00 to 31, can be viewed in sprite draw tool
!Persist = 00 ; 01 = your sprite continue to live offscreen
!Statis = 00 ; 00 = is sprite is alive?, (kill all enemies room)
!CollisionLayer = 00 ; 01 = will check both layer for collision
!CanFall = 00 ; 01 sprite can fall in hole, 01 = can't fall
!DeflectArrow = 01 ; 01 = deflect arrows
!WaterSprite = 00 ; 01 = can only walk shallow water
!Blockable = 00 ; 01 = can be blocked by link's shield?
!Prize = 0 ; 00-15 = the prize pack the sprite will drop from
!Sound = 00 ; 01 = Play different sound when taking damage
!Interaction = 00 ; ?? No documentation
!Statue = 00 ; 01 = Sprite is statue
!DeflectProjectiles = 01 ; 01 = Sprite will deflect ALL projectiles
!ImperviousArrow = 01 ; 01 = Impervious to arrows
!ImpervSwordHammer = 01 ; 01 = Impervious to sword and hammer attacks
!Boss = 00 ; 00 = normal sprite, 01 = sprite is a boss
%Set_Sprite_Properties(Sprite_Snorlax_Prep, Sprite_Snorlax_Long)
; ==============================================================================
; Sprite Long Hook for that sprite
; ==============================================================================
; This code can be left unchanged
; handle the draw code and if the sprite is active and should move or not
; ==============================================================================
Sprite_Snorlax_Long:
{
PHB : PHK : PLB
JSR Sprite_Snorlax_Draw ; Call the draw code
JSL Sprite_CheckActive ; Check if game is not paused
BCC .SpriteIsNotActive ; Skip Main code is sprite is innactive
JSR Sprite_Snorlax_Main ; Call the main sprite code
.SpriteIsNotActive
PLB ; Get back the databank we stored previously
RTL ; Go back to original code
}
; ==============================================================================
; Sprite initialization
; ==============================================================================
; this code only get called once perfect to initialize sprites substate or timers
; this code as soon as the room transitions/ overworld transition occurs
; ==============================================================================
Sprite_Snorlax_Prep:
{
PHB : PHK : PLB
; Add more code here to initialize data
PHX ; keep sprite in dex
LDX $8A ; load map index
LDA.l $7EF280, X : AND #$40 : BEQ .NotGone
PLX
STZ.w $0DD0, X
BRA .return
.NotGone
PLX
.return
PLB
RTL
}
; ==============================================================================
; Sprite Main routines code
; ==============================================================================
; This is the main local code of your sprite
; This contains all the Subroutines of your sprites you can add more below
; ==============================================================================
Sprite_Snorlax_Main:
{
LDA.w SprAction, X; Load the SprAction
JSL UseImplicitRegIndexedLocalJumpTable; Goto the SprAction we are currently in
dw StandingWaiting
dw BookRead
dw PhasingOut
}
StandingWaiting:
{
LDA.w $0F60,X
PHA
LDA #$07 : STA.w $0F60,X
JSL Sprite_CheckDamageToPlayerSameLayer : BCC .no_collision
JSR Sprite_HaltAllMovement
.no_collision
PLA
STA.w $0F60,X
%ShowSolicitedMessage($42)
; Check if player have book equipped
LDA.w $0303 : CMP #$0C : BNE .nobookequipped
; Check if player is close enough
REP #$20
JSR GetLinkDistance16bit : CMP #$0030 : BCS .toofar
SEP #$20
LDA.b $F0 : AND.b #$40 : BEQ .YNotPressed
LDA #$09 : STA.w $012E ; clear the buzz souund of the book multiple times
%GotoAction(1)
.YNotPressed
.toofar
SEP #$20
.nobookequipped
RTS
}
Sprite_HaltAllMovement:
{
PHX
JSL Sprite_NullifyHookshotDrag
STZ.b $5E
JSL Player_HaltDashAttack
PLX
RTS
}
BookRead:
{
LDA #$33 : STA.w $012E ; play minor puzzle sound ( optional )
PHX ; keep sprite in dex
LDX $8A ; load map index
LDA #$40 : STA.l $7EF280, X
PLX
%GotoAction(2)
%SetTimerA(60) ; amount of frames flashing
RTS
}
PhasingOut:
{
LDA.w SprTimerA, X : BNE .stillalive
STZ $0DD0, X ; kill the sprite
.stillalive
AND #$01 : STA.w SprMiscA, X
RTS
}
; ==============================================================================
; Sprite Draw code
; ==============================================================================
; Draw the tiles on screen with the data provided by the sprite maker editor
; ==============================================================================
Sprite_Snorlax_Draw:
{
LDA SprMiscA, X : BEQ .draw
RTS
.draw
JSL Sprite_PrepOamCoord
JSL Sprite_OAM_AllocateDeferToPlayer
LDA $0DC0, X : CLC : ADC $0D90, X : TAY;Animation Frame
LDA .start_index, Y : STA $06
PHX
LDX .nbr_of_tiles, Y ;amount of tiles -1
LDY.b #$00
.nextTile
PHX ; Save current Tile Index?
TXA : CLC : ADC $06 ; Add Animation Index Offset
PHA ; Keep the value with animation index offset?
ASL A : TAX
REP #$20
LDA $00 : CLC : ADC .x_offsets, X : STA ($90), Y
AND.w #$0100 : STA $0E
INY
LDA $02 : CLC : ADC .y_offsets, X : STA ($90), Y
CLC : ADC #$0010 : CMP.w #$0100
SEP #$20
BCC .on_screen_y
LDA.b #$F0 : STA ($90), Y ;Put the sprite out of the way
STA $0E
.on_screen_y
PLX ; Pullback Animation Index Offset (without the *2 not 16bit anymore)
INY
LDA .chr, X : STA ($90), Y
INY
LDA .properties, X : STA ($90), Y
PHY
TYA : LSR #2 : TAY
LDA .sizes, X : ORA $0F : STA ($92), Y ; store size in oam buffer
PLY : INY
PLX : DEX : BPL .nextTile
PLX
RTS
}
; ==============================================================================
; Sprite Draw Generated Data
; ==============================================================================
; This is where the generated Data for the sprite go
; ==============================================================================
.start_index
db $00
.nbr_of_tiles
db 3
.x_offsets
dw -8, 8, -8, 8
.y_offsets
dw 8, 8, -8, -8
.chr
db $E6, $E6, $E4, $E4
.properties
db $39, $79, $39, $79
.sizes
db $02, $02, $02, $02