-
Notifications
You must be signed in to change notification settings - Fork 0
/
_woodcutter.asm
242 lines (199 loc) · 5.57 KB
/
_woodcutter.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
////////////////////////////////////////////////////////////////////////////////
//
// Project : ForestSaver - https://github.com/intoinside/ForestSaver
// Target : Commodore 64
// Author : Raffaele Intorcia - raffaele.intorcia@gmail.com
//
// Handler for enemy type 1 (woodcutter)
//
////////////////////////////////////////////////////////////////////////////////
#importonce
// Set woodcutter position
.macro CallSetPosition(trackX, trackY, xBit, spriteXLow, spriteYLow) {
lda trackX
sta WoodCutter.SetPosition.NewX
lda trackY
sta WoodCutter.SetPosition.NewY
lda #spriteXLow
sta WoodCutter.SetPosition.SpriteXLow
lda #spriteYLow
sta WoodCutter.SetPosition.SpriteYLow
jsr WoodCutter.SetPosition
lda c64lib.SPRITE_MSB_X
.if (xBit==0)
{
.if (spriteXLow == $00) and #%11111110
.if (spriteXLow == $02) and #%11111101
.if (spriteXLow == $04) and #%11111011
.if (spriteXLow == $06) and #%11110111
.if (spriteXLow == $08) and #%11101111
.if (spriteXLow == $0a) and #%11011111
.if (spriteXLow == $0c) and #%10111111
.if (spriteXLow == $0e) and #%01111111
}
else
{
.if (spriteXLow == $00) ora #%00000001
.if (spriteXLow == $02) ora #%00000010
.if (spriteXLow == $04) ora #%00000100
.if (spriteXLow == $06) ora #%00001000
.if (spriteXLow == $08) ora #%00010000
.if (spriteXLow == $0a) ora #%00100000
.if (spriteXLow == $0c) ora #%01000000
.if (spriteXLow == $0e) ora #%10000000
}
sta c64lib.SPRITE_MSB_X
}
// Update woodcutter frame
.macro CallUpdateWoodCutterFrame(directionX, directionY, woodCutterFrame) {
lda directionX
sta WoodCutter.UpdateWoodCutterFrame.DirectionX
lda directionY
sta WoodCutter.UpdateWoodCutterFrame.DirectionY
lda woodCutterFrame
sta WoodCutter.UpdateWoodCutterFrame.WoodCutterFrame
jsr WoodCutter.UpdateWoodCutterFrame
lda WoodCutter.UpdateWoodCutterFrame.WoodCutterFrame
sta woodCutterFrame
}
// Update woodcutter frame with reverse hatchet
.macro CallUpdateWoodCutterFrameReverse(directionX, directionY, woodCutterFrame) {
lda directionX
sec
sbc #2
sta WoodCutter.UpdateWoodCutterFrame.DirectionX
lda directionY
sta WoodCutter.UpdateWoodCutterFrame.DirectionY
lda woodCutterFrame
sta WoodCutter.UpdateWoodCutterFrame.WoodCutterFrame
jsr WoodCutter.UpdateWoodCutterFrame
lda WoodCutter.UpdateWoodCutterFrame.WoodCutterFrame
sta woodCutterFrame
}
.filenamespace WoodCutter
* = * "WoodCutter Init"
Init: {
clc
lda ScreenMemoryAddress
adc #$03
sta ScreenMemoryAddress
// Self modify code to use current screen memory address, update hibyte
sta UpdateWoodCutterFrame.LoadSprite1 + 2
sta UpdateWoodCutterFrame.LoadSprite2 + 2
sta UpdateWoodCutterFrame.LoadSprite3 + 2
sta UpdateWoodCutterFrame.LoadSprite4 + 2
sta UpdateWoodCutterFrame.StoreSprite1 + 2
sta UpdateWoodCutterFrame.StoreSprite2 + 2
sta UpdateWoodCutterFrame.StoreSprite3 + 2
sta UpdateWoodCutterFrame.StoreSprite4 + 2
rts
}
* = * "WoodCutter UpdateWoodCutterFrame"
UpdateWoodCutterFrame: {
lda ScreenMemoryAddress + 1
sta UpdateWoodCutterFrame.LoadSprite1 + 1
sta UpdateWoodCutterFrame.LoadSprite2 + 1
sta UpdateWoodCutterFrame.LoadSprite3 + 1
sta UpdateWoodCutterFrame.LoadSprite4 + 1
sta UpdateWoodCutterFrame.StoreSprite1 + 1
sta UpdateWoodCutterFrame.StoreSprite2 + 1
sta UpdateWoodCutterFrame.StoreSprite3 + 1
sta UpdateWoodCutterFrame.StoreSprite4 + 1
inc WoodCutterFrame
lda WoodCutterFrame
lsr
lsr
lsr
lsr
bcc NoMove
lda #$00
sta WoodCutterFrame
LoadDirection:
lda DirectionX
beq CheckVerticalMove
cmp #$ff
beq Left
Right:
ldx #SPRITES.ENEMY_STANDING + 5
LoadSprite1:
lda SPRITE_PTR
cmp #SPRITES.ENEMY_STANDING + 6
beq RightUpdate
inx
jsr Sfx.Walkstep
RightUpdate:
// If right frame edit occours, no other frame switch will be performed
StoreSprite1:
stx SPRITE_PTR
jmp NoMove
Left:
ldx #SPRITES.ENEMY_STANDING + 7
LoadSprite2:
lda SPRITE_PTR
cmp #SPRITES.ENEMY_STANDING + 8
beq LeftUpdate
inx
jsr Sfx.Walkstep
LeftUpdate:
// If left frame edit occours, no other frame switch will be performed
StoreSprite2:
stx SPRITE_PTR
jmp NoMove
CheckVerticalMove:
LoadDirectionY:
lda DirectionY
beq NoMove
cmp #$ff
beq Up
Down:
ldx #SPRITES.ENEMY_STANDING + 1
LoadSprite3:
lda SPRITE_PTR
cmp #SPRITES.ENEMY_STANDING + 2
beq UpUpdate
inx
jsr Sfx.Walkstep
DownUpdate:
StoreSprite3:
stx SPRITE_PTR
jmp NoMove
Up:
ldx #SPRITES.ENEMY_STANDING + 3
LoadSprite4:
lda SPRITE_PTR
cmp #SPRITES.ENEMY_STANDING + 4
beq UpUpdate
inx
jsr Sfx.Walkstep
UpUpdate:
StoreSprite4:
stx SPRITE_PTR
NoMove:
rts
WoodCutterFrame: .byte $00
DirectionX: .byte $00
DirectionY: .byte $00
}
SetPosition: {
lda SpriteXLow
sta SetX + 1
lda SpriteYLow
sta SetY + 1
lda NewX
SetX:
sta $d0ef
lda NewY
SetY:
sta $d0ef
Done:
rts
NewX: .byte $00
NewY: .byte $00
SpriteXLow: .byte $00
SpriteYLow: .byte $00
}
ScreenMemoryAddress: .byte $be
.label SPRITE_PTR = $beef
#import "_label.asm"
#import "_sounds.asm"
#import "chipset/lib/vic2.asm"