-
Notifications
You must be signed in to change notification settings - Fork 0
/
paper.asm
291 lines (256 loc) · 9.19 KB
/
paper.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
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
!ifndef is_main !eof
; This file serves as paperwork of the game's design
; it contains variables, explications and other neat stuff
;
; VIDEO DETAILS :
; screensize: 320x240
;
; Layer 0 : map 16x32 8bpp
; tile data: $1 0000
; map data : $1 8000
vram_layer0_tilebase_b = $01
vram_layer0_tilebase = $0000
vram_layer0_mapbase_b = $01
vram_layer0_mapbase = $8000
;
; Layer 1 : text (system default)
; tile data: system default
; map data : $0 0000
;vram_layer1_tilebase =
vram_layer1_mapbase_b = $00
vram_layer1_mapbase = $0000
;
; Sprites :
; 128 8x8 4bpp $0 8000
vram_sprites_base_b = $00
vram_sprites_base = $8000
;
;
; GAME DETAILS :
;
;
; ADDRESSES AND STUFF
obj_size = $04
obj_idx_type = $00
obj_idx_param = $01
obj_idx_pos_x = $02
obj_idx_pos_y = $03
; CONSTANTS
SAVE_FILE = $01
IO_DEVICE = $08
IOCHECK_FILE = $02
FILE_WRITE = $03
FILE_READ = $03
IOCHECK = 15
WFRAME_MOVE = %00000001
WFRAME_CHOR = %00000010
WFRAME_MUSIC= %00000100
DIFFICULTY_EASY = $00
DIFFICULTY_NORMAL = $01
DIFFICULTY_HARD = $02
STATUS_FINISHED_EASY = %00000001
STATUS_FINISHED_NORMAL = %00000010
STATUS_FINISHED_HARD = %00000100
GRAZE_BONUS_EASY = $01
GRAZE_BONUS_NORMAL = $02
GRAZE_BONUS_HARD = $04
INVINCIBILITY_FRAMES = $3C
GAMEOVER_WAIT_S = $03
; LOW USAGE VARIABLES
; $0400 to $07FF
dynamic_string = $0400 ; 0~256 bytes
kernal_irq = $0500 ; 2 bytes
hiscore_87 = $0502 ; 1 byte
hiscore_65 = $0503 ; 1 byte
hiscore_43 = $0504 ; 1 byte
hiscore_21 = $0505 ; 1 byte
saved_volume = $0506 ; 1 byte
game_status = $0507 ; 1 byte
psg_vo_cnt = $050F ; 1 byte
psg_vo_note = $0510 ; 8 bytes
psg_vo_instr = $0518 ; 8 bytes
psg_vo_delay = $0520 ; 8 bytes
psg_vo_mode = $0528 ; 8 bytes
psg_vo_deltaLo = $0530 ; 8 bytes
psg_vo_deltaHi = $0538 ; 8 bytes
psg_vo_volumeLo = $0540 ; 8 bytes
psg_vo_volumeHi = $0548 ; 8 bytes
obj_count = $05FF ; 1 byte
obj_table = $0600 ; 512 bytes
; TEMPORARY VARIABLES
; $02 to $21
volume_cooldown = x16_r2
; VARIABLES
; $22 to $7F
unsafe_addr = $22
unsafe_addr_l = $22
unsafe_addr_h = $23
r_obj_a = $24 ; address
r_obj_p = $26 ; param
r_obj_t = $27 ; type
r_obj_x = $28 ; x pos
r_obj_y = $29 ; y pos
r_obj_r0 = $2A ; reg 0
r_obj_r1 = $2B ; reg 1
plyr_x = $2C
plyr_y = $2D
; $2E
; $2F
choregraphy_pc = $30
choregraphy_pc_l = $30
choregraphy_pc_h = $31
choregraphy_pos = $32
choregraphy_pos_l = $32
choregraphy_pos_h = $33
choregraphy_pos_x = $32
choregraphy_pos_y = $33
choregraphy_sleep = $34
choregraphy_reg_a = $35
choregraphy_reg_b = $36
choregraphy_reg_c = $37
composer_pc = $40
composer_pc_l = $40
composer_pc_h = $41
composer_delay = $42
composer_rythm = $43
composer_sr = $44
composer_sr_l = $44
composer_sr_h = $45
dividend = $46
;dividend+1 = $47
divisor = $48
remainder = $49
;remainder+1 = $4A
result = dividend
sfx_duration = $4B
sfx_freq_l = $4C
sfx_freq_h = $4D
sfx_wave = $4E
sfx_change = $4F
music_volume = $50
sfx_volume = $51
difficulty = $70
graze_bonus = $71
score_over_time = $72
scroll_speed = $73
invincibility_cnt = $74
panics = $75
lives = $76
score_87 = $77
score_65 = $78
score_43 = $79
score_21 = $7A
rng_seed_0 = $7B
rng_seed_1 = $7C
wait_frame = $7D
frame_count = $7E
game_mode = $7F
!macro game_video_init {
lda #64 ; \
sta vera_vscale ; |- set scale
lda #64 ; |
sta vera_hscale ; /
; configure layer 0
+fn_vera_set_layer0_config vera_layer_config_map_width_32tiles | vera_layer_config_map_height_64tiles | vera_layer_config_color_depth_8bpp
+fn_vera_set_layer0_tilebase $80 | vera_layer_tilebase_tile_width_8px | vera_layer_tilebase_tile_height_8px
+fn_vera_set_layer0_mapbase (vram_layer0_mapbase_b << 7) | ((vram_layer0_mapbase >> 9) & %01111111)
; set video mode
+fn_vera_set_video vera_video_mask_sprite | vera_video_mask_layer0 | vera_video_mask_layer1 | vera_video_mask_output_vga
; clear the text and background layers
jsr clear_layer0
jsr clear_layer1
+fn_print str_white_on_black
; upload tiles
+fn_vera_upload t_empty, $10|t_empty_bank, t_empty_address, t_empty_packet_size, t_empty_packet_qty
+fn_vera_direct_upload t_square, t_square_packet_size, t_square_packet_qty
+fn_vera_direct_upload t_trace_b0, t_trace_b0_packet_size, t_trace_b0_packet_qty
+fn_vera_direct_upload t_trace_b1, t_trace_b1_packet_size, t_trace_b1_packet_qty
+fn_vera_direct_upload t_trace_b2, t_trace_b2_packet_size, t_trace_b2_packet_qty
+fn_vera_direct_upload t_trace_gl, t_trace_gl_packet_size, t_trace_gl_packet_qty
+fn_vera_direct_upload t_dots, t_dots_packet_size, t_dots_packet_qty
+fn_vera_direct_upload t_scanl, t_scanl_packet_size, t_scanl_packet_qty
; upload sprites
+fn_vera_upload bullet, $10|bullet_bank, bullet_address, bullet_packet_size, bullet_packet_qty
+fn_vera_direct_upload bullet_panic, bullet_panic_packet_size, bullet_panic_packet_qty
+fn_vera_direct_upload bullet_glitch1, bullet_glitch1_packet_size, bullet_glitch1_packet_qty
+fn_vera_direct_upload bullet_glitch2, bullet_glitch2_packet_size, bullet_glitch2_packet_qty
+fn_vera_direct_upload player, player_packet_size, player_packet_qty
+fn_vera_direct_upload touched_player, touched_player_packet_size, touched_player_packet_qty
+fn_vera_direct_upload virus1, virus1_packet_size, virus1_packet_qty
+fn_vera_direct_upload virus2, virus2_packet_size, virus2_packet_qty
+fn_vera_direct_upload virus3, virus3_packet_size, virus3_packet_qty
+fn_vera_direct_upload virus4, virus4_packet_size, virus4_packet_qty
+fn_vera_direct_upload virus5, virus5_packet_size, virus5_packet_qty
+fn_vera_direct_upload virus6, virus6_packet_size, virus6_packet_qty
}
!macro game_init {
lda #$15 ; \
sta rng_seed_0 ; |- rng initialization
lda #$84 ; |
sta rng_seed_1 ; /
lda $9fbe ; \
cmp #"1" ; |
bne .emu_check_end ; |- detect emulator's magic number
lda $9fbf ; |
cmp #"6" ; |
bne .emu_check_end ; /
+fn_locate 0,2, str_emulator_msg; \_ display a message for the emulator
jsr CHRIN ; /
.emu_check_end:
; initializes sprites
+fn_vera_set_address $10 + vera_mem_sprite_bank, vera_mem_sprite
lda #player_spid ; \
sta vera_data_0 ; |
lda #player_spid_def ; |
sta vera_data_0 ; |
stz vera_data_0 ; pos x (low) ; |- init player sprite
stz vera_data_0 ; pos x (high) ; |
stz vera_data_0 ; pos y (low) ; |
stz vera_data_0 ; pos y (high) ; |
; |
lda #vera_sprite_zdepth_behind_layer1 ; |
sta vera_data_0 ; |
lda #player_spid_size ; |
sta vera_data_0 ; /
lda #virus1_spid ; \
sta vera_data_0 ; |
lda #virus1_spid_def ; |
sta vera_data_0 ; |
stz vera_data_0 ; pos x (low) ; |- init virus sprite
stz vera_data_0 ; pos x (high) ; |
stz vera_data_0 ; pos y (low) ; |
stz vera_data_0 ; pos y (high) ; |
; |
lda #vera_sprite_zdepth_behind_layer1 ; |
sta vera_data_0 ; |
lda #virus1_spid_size ; |
sta vera_data_0 ; /
ldx #$7D
- ; \
lda #bullet_spid ; |
sta vera_data_0 ; |- init all sprites
lda #bullet_spid_def ; |
sta vera_data_0 ; addr_mode ; |
stz vera_data_0 ; pos x (low) ; |- init bullet sprites
stz vera_data_0 ; pos x (high) ; |
stz vera_data_0 ; pos y (low) ; |
stz vera_data_0 ; pos y (high) ; |
; |
lda #vera_sprite_zdepth_behind_layer1 ; |
sta vera_data_0 ; |
lda #bullet_spid_size ; |
sta vera_data_0 ; |
; |
dex ; |
bne - ; /
; prepare game
+fn_irq_init kernal_irq, vsync_loop ; initialize vsync loop
lda #gamemode_title ; \_ set gamemode to titlescreen
sta game_mode ; /
lda #63 ; \
sta music_volume ; |- init global volume
lda #63 ; |
sta sfx_volume ; /
lda #DIFFICULTY_NORMAL ; \_ init default difficulty
sta difficulty ; /
}