-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathair_attack.dasm
251 lines (217 loc) · 3.58 KB
/
air_attack.dasm
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
processor 6502
include "vcs.h"
include "macro.h"
PlayerHeight = 9
seg.u variables
org $80
PlayerXPos byte
PlayerYPos byte
EnemyXPos byte
EnemyYPos byte
PAnimOffset byte
seg code
org $F000
Start:
CLEAN_START
sei
cld
ldx #$FF
txs
Init:
lda #99
sta PlayerXPos
lda #10
sta PlayerYPos
lda #99
sta EnemyXPos
lda #70
sta EnemyYPos
Frame:
lda #2
sta VSYNC
sta VBLANK
REPEAT 3
sta WSYNC
REPEND
lda #0
sta VSYNC
sta PAnimOffset
lda #$AD
sta COLUBK
lda #$C6
sta COLUPF
lda #%11111111
sta PF0
lda #%11110000
sta PF1
lda #%00000001
sta CTRLPF
sta WSYNC
; Read Input
InputUp:
lda #%00010000
bit SWCHA
bne InputDown
inc PlayerYPos
InputDown:
lda #%00100000
bit SWCHA
bne InputLeft
dec PlayerYPos
InputLeft:
lda #%01000000
bit SWCHA
bne InputRight
dec PlayerXPos
lda #16
sta PAnimOffset
InputRight:
lda #%10000000
bit SWCHA
bne NoInput
inc PlayerXPos
lda #16
sta PAnimOffset
NoInput:
sta WSYNC
lda PlayerXPos
ldy 0
jsr MoveHorizontal
sta WSYNC
lda EnemyXPos
ldy 1
jsr MoveHorizontal
sta WSYNC
sta HMOVE
REPEAT 33
sta WSYNC
REPEND
sta VBLANK
ldx #96
Line:
CheckPlayer:
txa
sec
sbc PlayerYPos
cmp PlayerHeight
bcc DrawPlayer
lda #0
DrawPlayer:
clc
adc PAnimOffset
tay
lda PlayerSpriteNormal,Y
sta GRP0
lda PlayerSpriteNormalColor,Y
sta COLUP0
sta WSYNC
CheckEnemy:
txa
sec
sbc EnemyYPos
cmp PlayerHeight
bcc DrawEnemy
lda #0
DrawEnemy:
tay
lda EnemySprite,Y
sta GRP1
lda EnemySpriteColor,Y
sta COLUP1
sta WSYNC
dex
bne Line
lda #2
sta VBLANK
REPEAT 30
sta WSYNC
REPEND
jmp Frame
; X position in A register
; Y register is used for sprite choose
; 1 - HMP0 player 0
; 2 - HMP1 player 1
; 3 - HMM0 missile 0
; 4 - HMM1 missile 1
; 5 - HMBL ball
MoveHorizontal subroutine
sta WSYNC
sec
; all this shit is about to position p0 sprite horizontally
; (x + 68) / 15 cycles waiting
; x is TIA color cycles. Kinda pixels
; 68 because of horizontal blank
; 15 because it's 5 x 3. Where 5 is CPU cycles wasted by
; sbs and bcs, 2 and 3 cycles
; and x3 because 1 CPU cycle is 3 TIA cycles
; Reminder goes to fine hpos value
.DivideLoop:
sbc #15
bcs .DivideLoop
eor #7
asl
asl
asl
asl
sta HMP0,y ; set fine value (from -8 to 7)
sta RESP0,y ; set rough "15" value
rts
org #$FFB4
PlayerSpriteNormal:
.byte #%00000000;$00
.byte #%01000100;$1E
.byte #%11111110;$02
.byte #%01111100;$02
.byte #%00111000;$02
.byte #%00111000;$AE
.byte #%00010000;$AC
.byte #%00010000;$F0
PlayerSpriteNormalColor:
.byte #$00;
.byte #$1E;
.byte #$02;
.byte #$02;
.byte #$02;
.byte #$AE;
.byte #$AE;
.byte #$02;
PlayerSpriteTilt:
.byte #%00000000;$00
.byte #%00101000;$1E
.byte #%01111100;$02
.byte #%00111000;$02
.byte #%00111000;$02
.byte #%00010000;$AE
.byte #%00010000;$AC
.byte #%00010000;$F0
PlayerSpriteTiltColor:
.byte #$00;
.byte #$1E;
.byte #$02;
.byte #$02;
.byte #$02;
.byte #$AE;
.byte #$AC;
.byte #$F0;
EnemySprite:
.byte #%00000000;$00
.byte #%01000100;$42
.byte #%11111110;$02
.byte #%11111110;$02
.byte #%00111000;$02
.byte #%00101000;$42
.byte #%01111100;$02
.byte #%00010000;$40
EnemySpriteColor
.byte #$00;
.byte #$42;
.byte #$02;
.byte #$02;
.byte #$02;
.byte #$42;
.byte #$02;
.byte #$40;
EndOfSprites:
org $FFFC
word Start
word Start