-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.ras
404 lines (346 loc) · 10.2 KB
/
main.ras
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
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
program C64Project;
@use "screen/screen"
var
// Charsets (http://home-2002.code-cop.org/c64/index.html)
const charsetLocation1: address = $2800;
charset1: incbin("assets/charset.bin", charsetLocation1);
const charsetLocation2: address = $3800;
charset2: incbin("assets/ancipital.64c", charsetLocation2, 2);
const charsetLocation3: address = $3000;
charset3: incbin("assets/aeg.64c", charsetLocation3, 2);
// Hollow+ ! (https://csdb.dk/sid/?id=15626)
music: incsid("assets/Hollow_plus.sid", 2);
// Logo bitmap data + VIC config holder
img_color: incbin("assets/logo_4_color.bin", $5000);
img_data: incbin("assets/logo_4_data.bin", $6000);
orig: byte = 0;
// njmcode logo sprites
@define spriteLocation $4000
@define spritex 78 // 31
@define spritey 52
@define spritex2 204 // 245
@define spritey2 229
njmsprites: incbin("assets/logosprites.bin", @spriteLocation);
sprite_hi_x: integer = @spritex;
sprite_lo_x: integer = @spritex2;
// Sine data calculation
sine_table: array[256] of byte;
sine_idx: byte = 0;
// Text constants for display
S_TITLE_0: string = "- THE -";
S_TITLE_1: string = "R A S T E R";
S_TITLE_1A: cstring = (82, 32, 65, 32, 83, 32, 84, 32, 69, 32, 82); // Lower half of 1x2 'R A S T E R' text
S_TITLE_2: string = "= BAR =";
S_BY: string = "B Y";
S_NJMCODE: string = ".:. NJMCODE .:.";
// Color cycle sequences
F_TITLE_1: array[] of byte = (BLUE, PURPLE, LIGHT_BLUE, CYAN, LIGHT_GREEN, WHITE, LIGHT_GREEN, CYAN, LIGHT_BLUE, PURPLE, BLUE, BLACK);
F_TITLE_2: array[] of byte = (DARK_GREY, LIGHT_RED);
F_NJMCODE: array[] of byte = (RED, LIGHT_RED, YELLOW, WHITE, YELLOW, LIGHT_RED);
F_SCROLL_L: cstring = (DARK_GREY, GREY, LIGHT_GREY, LIGHT_GREEN, WHITE);
F_SCROLL_R: cstring = (WHITE, LIGHT_GREEN, LIGHT_GREY, GREY, DARK_GREY);
F_BORDERS: cstring = (BLUE, LIGHT_BLUE, CYAN, WHITE, CYAN, LIGHT_BLUE);
// Color cycling + other general vars/pointers
const useKernal : byte = 1;
const CX: byte = SCREEN_WIDTH / 2;
i: byte = 0;
f1pos: byte = 0;
f1cpos: byte = 0;
f2pos: byte = 0;
fnpos: byte = 0;
fbpos: byte = 0;
delay1: byte = 0;
p_title_1a: ^byte;
scene: byte = 0;
sceneTime: byte = 255;
// Scrolling message vars + data
const scroll_cy: byte = 19;
const scroll_ry: byte = 200;
scrollval: byte = 0;
p_scrolltext: ^byte;
scrolltext: cstring = (" ",
"HELLO AND WELCOME TO -- THE RASTER BAR -- A C64 NOSTALGIA BLOG BROUGHT TO YOU IN 2021 BY -NJMCODE- ",
"FROM THE ASHES OF AWESOFT, A NEW FORCE RISES! THIS IS MY FIRST 'DEMO' IN ABOUT 25 YEARS, AND I HAVE SO MUCH TO LEARN! ",
"MUSIC IS THE AMAZING 'HOLLOW+' BY JENS-CHRISTIAN HUUS, WHICH I FIRST HEARD IN 'STUBBY-NOTER' BACK IN THE DAY. SHOUT OUT ",
"TO HAPPI, MY AWESOFT PARTNER-IN-CRIME, TO NINA, AND TO ANYONE READING THIS. CHECK OUT THE BLOG AT THERASTERBAR.COM...",
" ");
// Convenience function for printing the scroll text
procedure PrintScrollText();
begin
moveto(0, scroll_cy, hi(#screen_char_loc));
memcpy(p_scrolltext, 0, screenmemory, screen_width-1);
end;
// Scrolltext color + fades
procedure SetupScrollColors();
begin
moveto(0, scroll_cy, hi(screen_col_loc));
fill(screenmemory, WHITE, screen_width);
moveto(0, scroll_cy, hi(screen_col_loc));
memcpyfast(#F_SCROLL_L, 0, screenmemory, 5);
moveto(screen_width - 6, scroll_cy, hi(screen_col_loc));
memcpyfast(#F_SCROLL_R, 0, screenmemory, 5);
end;
// Set up the static screen elements.
procedure PrintStatics();
begin
Screen::PrintStringColor(#S_TITLE_0, #CX-3, 6, LIGHT_BLUE);
// 1x2 'R A S T E R' text
Screen::PrintStringColor(#S_TITLE_1, #CX-5, 8, WHITE);
p_title_1a := #S_TITLE_1A;
moveto(#CX-5, 9, hi(#screen_char_loc));
memcpy(p_title_1a, 0, screenmemory, 11);
Screen::PrintStringColor(#S_TITLE_2, #CX-3, 11, LIGHT_RED);
Screen::PrintStringColor(#S_BY, #CX-1, 14, GREY);
Screen::PrintStringColor(#S_NJMCODE, #CX-7, 16, RED);
end;
// Set up the bitmap data used by the logo.
procedure SetupBitmap();
begin
copyimagecolordata(#img_color, 1);
SetupScrollColors();
end;
// Plug color memory holes
// after switching from bitmap mode
procedure RefreshText();
begin
moveto(#CX-3, 11, hi(screen_col_loc));
fillfast(screenmemory, LIGHT_RED, 7);
moveto(#CX-1, 14, hi(screen_col_loc));
fillfast(screenmemory, GREY, 3);
end;
// Plug color memory holes
// after mode switching from text mode
procedure RefreshBitmap();
begin
moveto(#CX-3, 11, hi(screen_col_loc));
fillfast(screenmemory, BLUE, 7);
moveto(#CX-1, 14, hi(screen_col_loc));
screenmemory[0] := RED;
screenmemory[1] := BLUE;
screenmemory[2] := RED;
moveto(#CX-7, 16, hi(screen_col_loc));
fillfast(screenmemory, PURPLE, 15);
end;
procedure SpritesTop();
begin
sprite_hi_x := @spritex + sine_table[sine_idx];
spritepos(sprite_hi_x, @spritey, 0);
spritepos(sprite_hi_x + 24, @spritey, 1);
spritepos(sprite_hi_x + 48, @spritey, 2);
spritepos(sprite_hi_x + 72, @spritey, 3);
end;
procedure SpritesBottom();
begin
sprite_lo_x := @spritex2 - sine_table[sine_idx];
spritepos(sprite_lo_x, @spritey2, 0);
spritepos(sprite_lo_x + 24 , @spritey2, 1);
spritepos(sprite_lo_x + 48 , @spritey2, 2);
spritepos(sprite_lo_x + 72 , @spritey2, 3);
end;
// Screen refresh routine, including color cycling
// and soft-scroll of text message
// TODO: optimize this shit
procedure Update();
begin
if (sceneTime = 0) then begin
if (scene = 0) then scene := 1 else scene := 0;
if (scene = 0) then begin
RefreshText();
end;
if (scene = 1) then begin
RefreshBitmap();
end;
sceneTime := 255;
end;
// Scene 0 - color cycling text
if (scene = 0) then begin
// RASTER color cycling w/ individual letter offsets
if (delay1&2=0) then begin
f1cpos := f1pos;
for i := 0 to 6 do begin
moveto(#CX-5 + (i * 2), 8, hi(screen_col_loc));
fill(screenmemory, F_TITLE_1[f1cpos], 1);
moveto(#CX-5 + (i * 2), 9, hi(screen_col_loc));
fill(screenmemory, F_TITLE_1[f1cpos], 1);
f1cpos := f1cpos + 1;
if (f1cpos = 12) then f1cpos := 0;
end;
f1pos := f1pos + 1;
if (f1pos = 12) then f1pos := 0;
end;
// BAR color flickering
if (delay1&7=0) then begin
if (Random() > 128) then begin
moveto(#CX-3, 11, hi(screen_col_loc));
fill(screenmemory, F_TITLE_2[f2pos], 7);
f2pos := f2pos + 1;
if (f2pos = 2) then f2pos := 0;
end
end;
// NJMCODE color cycling
if (delay1&7=0) then begin
moveto(#CX-7, 16, hi(screen_col_loc));
fill(screenmemory, F_NJMCODE[fnpos], 15);
fnpos := fnpos + 1;
if (fnpos = 6) then fnpos := 0;
end;
end;
// Scene 1 - bitmap logo
if (scene = 1) then begin
end;
// Border edge color cycling
if (delay1&7=0) then begin
fbpos := fbpos + 1;
if (fbpos = 6) then fbpos := 0;
end;
// Scroll text refresh
// (hardware scrolling is done in 'Scroller' interrupt)
if (scrollval <= 1) then begin
scrollval := 7;
p_scrolltext += 1;
if (p_scrolltext[39] = 0) then p_scrolltext := #scrolltext;
PrintScrollText();
end
else scrollval := scrollval - 2;
// Sprite movement
sine_idx += 2;
inc(delay1);
dec(sceneTime);
end;
// Forward-declare our interrupts
interrupt MainArea();
interrupt Scroller();
interrupt Bottom();
// Upper blue border section
// Also calls the music-play routine
interrupt Top();
begin
setcharsetlocation(charsetLocation1);
startirq(useKernal);
call(^$1003);
wait(1);
SCREEN_BG_COL := BLUE;
SCREEN_FG_COL := BLUE;
SetBank(vic_bank1);
scrollx(0);
SpritesTop();
rasterirq(MainArea(), 78, useKernal);
closeirq();
end;
// Upper flashing border and static text section.
// Doesn't make any screen updates, just
// charset changes for the 1x2 'R A S T E R' text
interrupt MainArea();
begin
startirq(useKernal);
wait(1);
SCREEN_BG_COL := F_BORDERS[fbpos];
SCREEN_FG_COL := F_BORDERS[fbpos];
waitnoraster(1);
wait(11);
SCREEN_BG_COL := BLACK;
SCREEN_FG_COL := BLACK;
if (scene = 0) then begin
vic_data_loc := orig;
SetBank(vic_bank0);
setregularcolormode();
settextmode();
waitForRaster(108);
setcharsetlocation(charsetLocation3);
waitForRaster(136);
setcharsetlocation(charsetLocation1);
end;
if (scene = 1) then begin
wait(4);
setmulticolormode();
setbitmapmode();
vic_data_loc := $18;
setbank(vic_bank1);
end;
SpritesBottom();
rasterirq(Scroller(), scroll_ry, useKernal);
closeirq();
end;
// Hardware scrolling + scrolltext charset interrupt.
interrupt Scroller();
begin
startirq(useKernal);
wait(5);
if (scene = 1) then begin
wait(5);
vic_data_loc := orig;
SetBank(vic_bank0);
setregularcolormode();
settextmode();
end;
setcharsetlocation(charsetLocation2);
scrollx(scrollval);
rasterirq(Bottom(), 220, useKernal);
closeirq();
end;
// Lower flashing border + blue area.
// Triggers the color cycling etc as well.
interrupt Bottom();
begin
startirq(useKernal);
scrollx(0);
wait(11);
SCREEN_BG_COL := F_BORDERS[fbpos];
SCREEN_FG_COL := F_BORDERS[fbpos];
waitnoraster(1);
wait(10);
SCREEN_BG_COL := BLUE;
SCREEN_FG_COL := BLUE;
SetBank(vic_bank1);
rasterirq(Top(), 0, useKernal);
Update();
closeirq();
end;
// Print all the static screen elements.
procedure SetupScreen();
begin
definescreen();
clearscreen(32, #screen_char_loc);
clearscreen(WHITE, #screen_col_loc);
SCREEN_BG_COL := BLACK;
SCREEN_FG_COL := BLACK;
hideborderx(1);
orig := vic_data_loc;
SetupBitmap();
PrintStatics();
SetupScrollColors();
end;
// Set up the 'njmcode' logo sprites.
procedure InitSprites();
begin
sprite_multicolor := $ff;
sprite_multicolor_reg1 := BLACK;
sprite_multicolor_reg2 := CYAN;
sprite_color[0] := LIGHT_BLUE;
setspriteloc(0, @spriteLocation/64, 1);
togglebit(sprite_bitmask, 0, 1);
sprite_color[1] := LIGHT_BLUE;
setspriteloc(1, @spriteLocation/64 + 1, 1);
togglebit(sprite_bitmask, 1, 1);
sprite_color[2] := LIGHT_BLUE;
setspriteloc(2, @spriteLocation/64 + 2, 1);
togglebit(sprite_bitmask, 2, 1);
sprite_color[3] := LIGHT_BLUE;
setspriteloc(3, @spriteLocation/64 + 3, 1);
togglebit(sprite_bitmask, 3, 1);
end;
// Main program
begin
// Sine calc
for i:=0 to 256 do begin
sine_table[i] := sine[i] / 2;
end;
SetupScreen();
InitSprites();
initsid(^$1000);
disableciainterrupts();
setmemoryconfig(1, useKernal, 0);
p_scrolltext := #scrolltext;
startrasterchain(Top(), 0, useKernal);
loop();
end.