This repository has been archived by the owner on Oct 4, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathjmain.asm
15249 lines (12438 loc) · 372 KB
/
jmain.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
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
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
;compile to this filename
!to "jmain.prg",cbm
;memory layout
;screen back color $C400 to $C7FF
;screen back char $C800 to $CBFF
;screen $CC00 to $CFFF
;sprites $D000 to $EFFF
;charset $F000 to $FFFF
;TEST
;screen back color $BC00 to $BFFF
;sprites $D000 to $F7FF
;charset $F800 to $FFFF
;charset2 $C000 to $C800
;define constants here
KERNAL_GETIN = $ffe4
KERNAL_SETMSG = $ff90
KERNAL_SETLFS = $ffba
KERNAL_SETNAM = $ffbd
KERNAL_LOAD = $ffd5
VIC_SPRITE_X_POS = $d000
VIC_SPRITE_Y_POS = $d001
VIC_SPRITE_X_EXTEND = $d010
VIC_CONTROL_MODE = $d011
VIC_SPRITE_ENABLE = $d015
VIC_CONTROL = $d016
VIC_SPRITE_EXPAND_Y = $d017
VIC_MEMORY_CONTROL = $d018
VIC_SPRITE_PRIORITY = $d01b
VIC_SPRITE_MULTICOLOR = $d01c
VIC_SPRITE_EXPAND_X = $d01d
VIC_SPRITE_MULTICOLOR_1 = $d025
VIC_SPRITE_MULTICOLOR_2 = $d026
VIC_SPRITE_COLOR = $d027
VIC_BORDER_COLOR = $d020
VIC_BACKGROUND_COLOR = $d021
VIC_CHARSET_MULTICOLOR_1= $d022
VIC_CHARSET_MULTICOLOR_2= $d023
JOYSTICK_PORT_II = $dc00
CIA_PRA = $dd00
PROCESSOR_PORT = $01
START_LEVEL = 0
;START_LEVEL = 71
MUSIC_IN_GAME_TUNE = $00
MUSIC_TITLE_TUNE = $01
MUSIC_GET_READY_GAME_OVER_TUNE = $02 ;Also use this for Game Over!
MUSIC_GAME_END_TUNE = $03
MUSIC_PLAYER_SHOOT = $04
MUSIC_PLAYER_DIE = $05
MUSIC_PICKUP = $06
MUSIC_ENEMY_DIE = $07
;placeholder for various temp parameters
PARAM1 = $03
PARAM2 = $04
PARAM3 = $05
PARAM4 = $06
PARAM5 = $07
PARAM6 = $08
PARAM7 = $09
PARAM8 = $0A
PARAM9 = $0B
PARAM10 = $0C
;placeholder for zero page pointers
ZEROPAGE_POINTER_1 = $17
ZEROPAGE_POINTER_2 = $19
ZEROPAGE_POINTER_3 = $21
ZEROPAGE_POINTER_4 = $23
;address of the screen buffer
SCREEN_CHAR = $CC00
;address of color ram
SCREEN_COLOR = $D800
;address of the screen backbuffer
SCREEN_BACK_CHAR = $C800
;address of the screen backbuffer
;SCREEN_BACK_COLOR = $C400
SCREEN_BACK_COLOR = $BC00
;address of sprite pointers
SPRITE_POINTER_BASE = SCREEN_CHAR + 1016
;number of sprites divided by four
NUMBER_OF_SPRITES_DIV_4 = 160 / 4
;sprite number constant
SPRITE_BASE = 64
SPRITE_PLAYER = SPRITE_BASE + 0
SPRITE_BAT_1 = SPRITE_BASE + 1
SPRITE_PLAYER_STAND_R = SPRITE_BASE + 2
SPRITE_PLAYER_STAND_L = SPRITE_BASE + 3
SPRITE_PLAYER_STAND_RECOIL_R = SPRITE_BASE + 4
SPRITE_PLAYER_STAND_RECOIL_L = SPRITE_BASE + 5
SPRITE_PLAYER_WALK_R_1 = SPRITE_BASE + 6
SPRITE_PLAYER_WALK_L_1 = SPRITE_BASE + 7
SPRITE_PLAYER_WALK_R_2 = SPRITE_BASE + 8
SPRITE_PLAYER_WALK_L_2 = SPRITE_BASE + 9
SPRITE_PLAYER_WALK_R_3 = SPRITE_BASE + 10
SPRITE_PLAYER_WALK_L_3 = SPRITE_BASE + 11
SPRITE_PLAYER_WALK_R_4 = SPRITE_BASE + 12
SPRITE_PLAYER_WALK_L_4 = SPRITE_BASE + 13
SPRITE_PLAYER_JUMP_R = SPRITE_BASE + 6
SPRITE_PLAYER_JUMP_L = SPRITE_BASE + 7
SPRITE_PLAYER_FALL_R = SPRITE_BASE + 12
SPRITE_PLAYER_FALL_L = SPRITE_BASE + 13
SPRITE_PLAYER_JUMP_RECOIL_R = SPRITE_BASE + 14
SPRITE_PLAYER_JUMP_RECOIL_L = SPRITE_BASE + 15
SPRITE_PLAYER_FALL_RECOIL_R = SPRITE_BASE + 20
SPRITE_PLAYER_FALL_RECOIL_L = SPRITE_BASE + 21
SPRITE_BAT_2 = SPRITE_BASE + 22
SPRITE_BAT_3 = SPRITE_BASE + 23
SPRITE_MUMMY_R_1 = SPRITE_BASE + 24
SPRITE_MUMMY_L_1 = SPRITE_BASE + 25
SPRITE_MUMMY_R_2 = SPRITE_BASE + 26
SPRITE_MUMMY_L_2 = SPRITE_BASE + 27
SPRITE_MUMMY_ATTACK_R = SPRITE_BASE + 28
SPRITE_MUMMY_ATTACK_L = SPRITE_BASE + 29
SPRITE_PLAYER_RELOAD_R = SPRITE_BASE + 30
SPRITE_PLAYER_RELOAD_L = SPRITE_BASE + 31
SPRITE_ZOMBIE_WALK_R_1 = SPRITE_BASE + 32
SPRITE_ZOMBIE_WALK_L_1 = SPRITE_BASE + 33
SPRITE_ZOMBIE_WALK_R_2 = SPRITE_BASE + 34
SPRITE_ZOMBIE_WALK_L_2 = SPRITE_BASE + 35
SPRITE_ZOMBIE_COLLAPSE_R_1 = SPRITE_BASE + 36
SPRITE_ZOMBIE_COLLAPSE_L_1 = SPRITE_BASE + 37
SPRITE_ZOMBIE_COLLAPSE_R_2 = SPRITE_BASE + 38
SPRITE_ZOMBIE_COLLAPSE_L_2 = SPRITE_BASE + 39
SPRITE_INVISIBLE = SPRITE_BASE + 40
SPRITE_BAT_VANISH = SPRITE_BASE + 41
SPRITE_ZOMBIE_JUMP_R = SPRITE_BASE + 42
SPRITE_ZOMBIE_JUMP_L = SPRITE_BASE + 43
SPRITE_SPIDER_STAND = SPRITE_BASE + 44
SPRITE_SPIDER_WALK_1 = SPRITE_BASE + 45
SPRITE_SPIDER_WALK_2 = SPRITE_BASE + 46
SPRITE_WOLF_WALK_L_1 = SPRITE_BASE + 47
SPRITE_WOLF_WALK_L_2 = SPRITE_BASE + 48
SPRITE_WOLF_WALK_L_3 = SPRITE_BASE + 49
SPRITE_WOLF_JUMP_L = SPRITE_BASE + 50
SPRITE_PLAYER_SAM_STAND_R = SPRITE_BASE + 51
SPRITE_PLAYER_SAM_STAND_L = SPRITE_BASE + 52
SPRITE_FLY_1 = SPRITE_BASE + 53
SPRITE_FLY_2 = SPRITE_BASE + 54
SPRITE_PLAYER_DEAD = SPRITE_BASE + 87
SPRITE_PLAYER_SAM_WALK_R_1 = SPRITE_BASE + 55
SPRITE_PLAYER_SAM_WALK_L_1 = SPRITE_BASE + 56
SPRITE_PLAYER_SAM_WALK_R_2 = SPRITE_BASE + 57
SPRITE_PLAYER_SAM_WALK_L_2 = SPRITE_BASE + 58
SPRITE_PLAYER_SAM_WALK_R_3 = SPRITE_BASE + 59
SPRITE_PLAYER_SAM_WALK_L_3 = SPRITE_BASE + 60
SPRITE_PLAYER_SAM_WALK_R_4 = SPRITE_BASE + 61
SPRITE_PLAYER_SAM_WALK_L_4 = SPRITE_BASE + 62
SPRITE_PLAYER_SAM_JUMP_R = SPRITE_BASE + 55
SPRITE_PLAYER_SAM_JUMP_L = SPRITE_BASE + 56
SPRITE_PLAYER_SAM_FALL_R = SPRITE_BASE + 61
SPRITE_PLAYER_SAM_FALL_L = SPRITE_BASE + 62
SPRITE_PLAYER_SAM_POWER_R = SPRITE_BASE + 63
SPRITE_PLAYER_SAM_POWER_L = SPRITE_BASE + 64
SPRITE_GHOST_SKELETON_1 = SPRITE_BASE + 65
SPRITE_GHOST_SKELETON_2 = SPRITE_BASE + 66
SPRITE_GHOST_SKELETON_3 = SPRITE_BASE + 67
SPRITE_JUMPING_TOAD_1 = SPRITE_BASE + 68
SPRITE_JUMPING_TOAD_2 = SPRITE_BASE + 69
SPRITE_JUMPING_TOAD_3 = SPRITE_BASE + 70
SPRITE_JUMPING_TOAD_4 = SPRITE_BASE + 71
SPRITE_EXPLOSION_1 = SPRITE_BASE + 72
SPRITE_EXPLOSION_2 = SPRITE_BASE + 73
SPRITE_EXPLOSION_3 = SPRITE_BASE + 74
SPRITE_EXPLOSION_4 = SPRITE_BASE + 75
SPRITE_EXPLOSION_5 = SPRITE_BASE + 76
SPRITE_EXPLOSION_6 = SPRITE_BASE + 77
SPRITE_EXPLOSION_7 = SPRITE_BASE + 78
SPRITE_EXPLOSION_8 = SPRITE_BASE + 79
SPRITE_WOLF_WALK_R_1 = SPRITE_BASE + 80
SPRITE_WOLF_WALK_R_2 = SPRITE_BASE + 81
SPRITE_WOLF_WALK_R_3 = SPRITE_BASE + 82
SPRITE_WOLF_JUMP_R = SPRITE_BASE + 83
SPRITE_FLOATING_GHOST_1 = SPRITE_BASE + 84
SPRITE_FLOATING_GHOST_2 = SPRITE_BASE + 85
SPRITE_FLOATING_GHOST_3 = SPRITE_BASE + 86
SPRITE_SLIME_R_1 = SPRITE_BASE + 88
SPRITE_SLIME_L_1 = SPRITE_BASE + 89
SPRITE_SLIME_R_2 = SPRITE_BASE + 90
SPRITE_SLIME_L_2 = SPRITE_BASE + 91
SPRITE_SLIME_R_3 = SPRITE_BASE + 92
SPRITE_SLIME_L_3 = SPRITE_BASE + 93
SPRITE_SLIME_R_4 = SPRITE_BASE + 94
SPRITE_SLIME_L_4 = SPRITE_BASE + 95
SPRITE_FRANKIE_RISE_R_1 = SPRITE_BASE + 96
SPRITE_FRANKIE_RISE_L_1 = SPRITE_BASE + 97
SPRITE_FRANKIE_RISE_R_2 = SPRITE_BASE + 98
SPRITE_FRANKIE_RISE_L_2 = SPRITE_BASE + 99
SPRITE_FRANKIE_RISE_R_3 = SPRITE_BASE + 100
SPRITE_FRANKIE_RISE_L_3 = SPRITE_BASE + 101
SPRITE_FRANKIE_JUMP_R = SPRITE_BASE + 102
SPRITE_FRANKIE_JUMP_L = SPRITE_BASE + 103
SPRITE_FRANKIE_WALK_R_1 = SPRITE_BASE + 104
SPRITE_FRANKIE_WALK_L_1 = SPRITE_BASE + 105
SPRITE_FRANKIE_WALK_R_2 = SPRITE_BASE + 106
SPRITE_FRANKIE_WALK_L_2 = SPRITE_BASE + 107
SPRITE_FRANKIE_WALK_R_3 = SPRITE_BASE + 108
SPRITE_FRANKIE_WALK_L_3 = SPRITE_BASE + 109
SPRITE_FRANKIE_WALK_R_4 = SPRITE_BASE + 110
SPRITE_FRANKIE_WALK_L_4 = SPRITE_BASE + 111
SPRITE_EYE_1 = SPRITE_BASE + 112
SPRITE_EYE_2 = SPRITE_BASE + 113
SPRITE_EYE_3 = SPRITE_BASE + 114
SPRITE_EYE_4 = SPRITE_BASE + 115
SPRITE_HAND_1 = SPRITE_BASE + 116
SPRITE_HAND_2 = SPRITE_BASE + 117
SPRITE_HAND_3 = SPRITE_BASE + 118
SPRITE_HAND_4 = SPRITE_BASE + 119
SPRITE_HAND_5 = SPRITE_BASE + 120
SPRITE_HAND_6 = SPRITE_BASE + 121
SPRITE_DEVIL_WALK_R_1 = SPRITE_BASE + 122
SPRITE_DEVIL_WALK_L_1 = SPRITE_BASE + 123
SPRITE_DEVIL_WALK_R_2 = SPRITE_BASE + 124
SPRITE_DEVIL_WALK_L_2 = SPRITE_BASE + 125
SPRITE_DEVIL_WALK_R_3 = SPRITE_BASE + 126
SPRITE_DEVIL_WALK_L_3 = SPRITE_BASE + 127
SPRITE_IMPALA_1 = SPRITE_BASE + 128
SPRITE_IMPALA_2 = SPRITE_BASE + 129
SPRITE_IMPALA_3 = SPRITE_BASE + 130
SPRITE_DRIVERS = SPRITE_BASE + 131
SPRITE_DEBRIS_1 = SPRITE_BASE + 132
SPRITE_DEBRIS_2 = SPRITE_BASE + 133
SPRITE_SPAWN_1 = SPRITE_BASE + 134
SPRITE_SPAWN_2 = SPRITE_BASE + 135
SPRITE_BOSS_FOOT_R = SPRITE_BASE + 136
SPRITE_BOSS_FOOT_L = SPRITE_BASE + 137
SPRITE_BOSS_ARM_R = SPRITE_BASE + 138
SPRITE_BOSS_ARM_L = SPRITE_BASE + 139
SPRITE_BOSS_TORSO_R = SPRITE_BASE + 140
SPRITE_BOSS_TORSO_L = SPRITE_BASE + 141
SPRITE_BOSS_HEAD = SPRITE_BASE + 142
SPRITE_BOSS_HEAD_HURT = SPRITE_BASE + 143
SPRITE_G = SPRITE_BASE + 144
SPRITE_E = SPRITE_BASE + 145
SPRITE_T = SPRITE_BASE + 146
SPRITE_R = SPRITE_BASE + 147
SPRITE_A = SPRITE_BASE + 148
SPRITE_D = SPRITE_BASE + 149
SPRITE_Y = SPRITE_BASE + 150
SPRITE_M = SPRITE_BASE + 151
SPRITE_O = SPRITE_BASE + 152
SPRITE_V = SPRITE_BASE + 153
SPRITE_IMPALA_BACK_1 = SPRITE_BASE + 154
SPRITE_IMPALA_BACK_2 = SPRITE_BASE + 155
SPRITE_IMPALA_BACK_SMALL = SPRITE_BASE + 156
;offset from calculated char pos to true sprite pos
SPRITE_CENTER_OFFSET_X = 8
SPRITE_CENTER_OFFSET_Y = 11
;entries of jump table
JUMP_TABLE_SIZE = 10
TOAD_JUMP_TABLE_SIZE = 12
;entries of fall table
FALL_TABLE_SIZE = 10
;bytes (digits) per score entry
HIGHSCORE_ENTRY_COUNT = 8
HIGHSCORE_SCORE_SIZE = 8
HIGHSCORE_NAME_SIZE = 12
;level data constants
LD_END = 0
LD_LINE_H = 1 ;data contains x,y,width,char,color
LD_LINE_V = 2 ;data contains x,y,height,char,color
LD_OBJECT = 3 ;data contains x,y,type
LD_AREA = 4 ;data contains x,y,width,height,char,color
LD_LINE_H_ALT = 5 ;data contains x,y,width,char,color
LD_LINE_V_ALT = 6 ;data contains x,y,height,char,color
LD_QUAD = 7 ;data contains x,y,quad_id
LD_SPAWN_SPOT = 8 ;data contains x,y,type,count
LD_ELEMENT = 9 ;single element block
LD_ELEMENT_LINE_H = 10 ;element block line H
LD_ELEMENT_LINE_V = 11 ;element block line V
LD_ELEMENT_AREA = 12 ;element block area
LD_LEVEL_CONFIG = 13 ;level config byte
;object type constants
TYPE_INVALID = 0
TYPE_PLAYER_DEAN = 1
TYPE_BAT_DIAG = 2
TYPE_BAT_UD = 3
TYPE_BAT_ATTACKING = 4
TYPE_MUMMY = 5
TYPE_ZOMBIE = 6
TYPE_BAT_VANISH = 7
TYPE_SPIDER = 8
TYPE_EXPLOSION = 9
TYPE_PLAYER_SAM = 10
TYPE_WOLFMAN = 11
TYPE_GHOST_SKELETON = 12
TYPE_JUMPING_TOAD = 13
TYPE_EYE = 14
TYPE_FLOATING_GHOST = 15
TYPE_FLY = 16
TYPE_SLIME = 17
TYPE_FRANKENSTEIN = 18
TYPE_HAND = 19
TYPE_DEVIL = 20
TYPE_IMPALA_1 = 21
TYPE_IMPALA_2 = 22
TYPE_IMPALA_3 = 23
TYPE_IMPALA_DRIVER = 24
TYPE_IMPALA_DEBRIS = 25
TYPE_SPAWN = 26
TYPE_BOSS = 27
TYPE_BOSS2 = 28
TYPE_BOSS3 = 29
TYPE_GETREADY = 30
TYPE_BOSS4 = 31
TYPE_BOSS5 = 32
TYPE_BOSS6 = 33
TYPE_BOSS7 = 34
TYPE_BOSS_PART = 35
OBJECT_HEIGHT = 8 * 2
;item type constants
ITEM_BULLET = 0
ITEM_HEALTH = 1
ITEM_FAST_RELOAD = 2
ITEM_INVINCIBLE = 3
ITEM_FORCE_RANGE = 4
ITEM_SUPER_BULLET = 5
ITEM_DEMON_BLOOD = 6
ITEM_MAX = 7
ITEM_NONE = 255
;number of possible items
ITEM_COUNT = 8
;number of possible spawn spots
SPAWN_SPOT_COUNT = 10
;game mode types
GT_SINGLE_PLAYER_DEAN = 0
GT_SINGLE_PLAYER_SAM = 1
GT_COOP = 2
BEAM_TYPE_DARK = 0
BEAM_TYPE_MEDIUM = 1
BEAM_TYPE_LIGHT = 2
BEAM_TYPE_LIGHT2 = 3
;this creates a basic start
*=$0801
;SYS 2064
!byte $0C,$08,$0A,$00,$9E,$20,$32,$30,$36,$34,$00,$00,$00,$00,$00
;init sprite registers
;no visible sprites
lda #0
sta VIC_SPRITE_ENABLE
;set charset
lda #$3e
sta VIC_MEMORY_CONTROL
;VIC bank
lda CIA_PRA
and #$fd
sta CIA_PRA
;check last used drive (or set to default)
lda $ba
sta DRIVE_NUMBER
bne .NoDefaultDriveNeeded
lda #8
sta DRIVE_NUMBER
.NoDefaultDriveNeeded
jsr LoadScores
;----------------------------------
;copy charset and sprites to target
;----------------------------------
;block interrupts
;since we turn ROMs off this would result in crashes if we didn't
sei
;only RAM
;to copy under the IO rom
lda #%00110000
sta PROCESSOR_PORT
!ifndef CRUNCHED {
;take source address from CHARSET
LDA #<CHARSET
STA ZEROPAGE_POINTER_1
LDA #>CHARSET
STA ZEROPAGE_POINTER_1 + 1
;now copy
jsr CopyCharSet
;take source address from CHARSET 2
LDA #<CHARSET_2
STA ZEROPAGE_POINTER_1
LDA #>CHARSET_2
STA ZEROPAGE_POINTER_1 + 1
;now copy
jsr CopyCharSet2
;take source address from SPRITES
lda #<SPRITES
sta ZEROPAGE_POINTER_1
lda #>SPRITES
sta ZEROPAGE_POINTER_1 + 1
jsr CopySprites
}
;store water tile bytes
ldx #0
lda $F800 + 111 * 8
sta PARAM1
lda $F800 + 111 * 8 + 1
sta PARAM2
-
lda PARAM1
lsr
ror PARAM1
lda PARAM1
sta ANIM_TILE_BYTES,x
lda PARAM2
lsr
ror PARAM2
lda PARAM2
sta ANIM_TILE_BYTES + 8,x
inx
cpx #8
bne -
ldx #0
-
lda $F800 + 143 * 8,x
sta ANIM_TILE2_BYTES,x
sta ANIM_TILE2_BYTES + 8,x
inx
dey
cpx #8
bne -
;restore ROMs
;lda PARAM1
lda #$36
sta PROCESSOR_PORT
cli
;background black
lda #0
sta VIC_BORDER_COLOR
sta VIC_BACKGROUND_COLOR
;set charset multi colors
lda #12
sta VIC_CHARSET_MULTICOLOR_1
lda #8
sta VIC_CHARSET_MULTICOLOR_2
;enable multi color charset
lda VIC_CONTROL
ora #$10
sta VIC_CONTROL
;set sprite flags
lda #0
sta VIC_SPRITE_X_EXTEND
sta VIC_SPRITE_ENABLE
sta VIC_SPRITE_MULTICOLOR
;sprite multi colors
lda #11
sta VIC_SPRITE_MULTICOLOR_1
lda #1
sta VIC_SPRITE_MULTICOLOR_2
;bitmap multicolor
lda #$18
sta VIC_CONTROL
;------------------------------------------------------------
;the title screen game loop
;------------------------------------------------------------
!zone TitleScreen
TitleScreen
jsr InitTitleIRQ
TitleScreenWithoutIRQ
!ifdef MUSIC_PLAYING{
;initialise music player
ldx #0
ldy #0
lda SFX_MODE
bne +
lda #MUSIC_TITLE_TUNE
jsr MUSIC_PLAYER
+
}
ldx #0
stx BUTTON_PRESSED
stx BUTTON_RELEASED
stx VIC_SPRITE_ENABLE
;clear screen
lda #32
ldy #1
jsr ClearScreen
;display start text
lda #<TEXT_FIRE_TO_START
sta ZEROPAGE_POINTER_1
lda #>TEXT_FIRE_TO_START
sta ZEROPAGE_POINTER_1 + 1
lda #11
sta PARAM1
lda #23
sta PARAM2
jsr DisplayText
ldx GAME_MODE
lda TEXT_GAME_MODE_LO,x
sta ZEROPAGE_POINTER_1
lda TEXT_GAME_MODE_HI,x
sta ZEROPAGE_POINTER_1 + 1
lda #11
sta PARAM1
lda #21
sta PARAM2
jsr DisplayText
jsr DisplaySfxMode
;display high scores
;x,y pos of name
lda #6
sta PARAM1
lda #10
sta PARAM2
lda #<HIGHSCORE_NAME
sta ZEROPAGE_POINTER_1
lda #>HIGHSCORE_NAME
sta ZEROPAGE_POINTER_1 + 1
jsr DisplayText
;x,y pos of score
lda #25
sta PARAM1
lda #10
sta PARAM2
lda #<HIGHSCORE_SCORE
sta ZEROPAGE_POINTER_1
lda #>HIGHSCORE_SCORE
sta ZEROPAGE_POINTER_1 + 1
jsr DisplayText
ldx #0
.FillColor
lda TITLE_LOGO_COLORRAM,x
sta SCREEN_COLOR,x
inx
bne .FillColor
.FillColor2
lda TITLE_LOGO_COLORRAM + 256,x
sta SCREEN_COLOR + 256,x
inx
cpx #( 320 - 256 )
bne .FillColor2
;init color fade counter
lda #0
sta COLOR_FADE_POS
.TitleLoop
jsr WaitFrame
;apply color fade
inc COLOR_FADE_POS
lda COLOR_FADE_POS
and #( COLOR_FADE_LENGTH - 1 )
sta COLOR_FADE_POS
lda #0
sta PARAM1
.FadeLine
lda PARAM1
clc
adc #10
tay
lda SCREEN_LINE_OFFSET_TABLE_LO,y
sta ZEROPAGE_POINTER_1
lda SCREEN_LINE_OFFSET_TABLE_HI,y
clc
adc #( ( ( SCREEN_COLOR - SCREEN_CHAR ) & $ff00 ) >> 8 )
sta ZEROPAGE_POINTER_1 + 1
ldy #6
lda COLOR_FADE_POS
clc
adc PARAM1
and #( COLOR_FADE_LENGTH - 1 )
tax
.FadeColorNextChar
lda COLOR_FADE_1,x
sta (ZEROPAGE_POINTER_1),y
iny
cpy #35
beq .FadeColorLineDone
inx
cpx #COLOR_FADE_LENGTH
bne .FadeColorNextChar
ldx #0
jmp .FadeColorNextChar
.FadeColorLineDone
inc PARAM1
lda PARAM1
cmp #8
bne .FadeLine
;switch through music/sfx mode
lda #$04
bit JOYSTICK_PORT_II
bne .NotLeftPressed
lda LEFT_RELEASED
beq .LeftPressed
lda SFX_MODE
eor #$01
sta SFX_MODE
jsr DisplaySfxMode
lda SFX_MODE
beq +
lda #MUSIC_PICKUP
jmp ++
+
lda #MUSIC_TITLE_TUNE
++
jsr MUSIC_PLAYER
lda #0
jmp .LeftPressed
.NotLeftPressed
lda #1
.LeftPressed
sta LEFT_RELEASED
lda #$08
bit JOYSTICK_PORT_II
bne .NotRightPressed
lda RIGHT_RELEASED
beq .RightPressed
lda SFX_MODE
eor #$01
sta SFX_MODE
jsr DisplaySfxMode
lda SFX_MODE
beq +
lda #MUSIC_PICKUP
jmp ++
+
lda #MUSIC_TITLE_TUNE
++
jsr MUSIC_PLAYER
lda #0
jmp .RightPressed
.NotRightPressed
lda #1
.RightPressed
sta RIGHT_RELEASED
lda #$01
bit JOYSTICK_PORT_II
bne .NotUpPressed
lda UP_RELEASED
beq .UpPressed
inc GAME_MODE
lda GAME_MODE
cmp #3
bne .NoGameModeWrap
lda #0
sta GAME_MODE
.NoGameModeWrap
;redisplay game mode
ldx GAME_MODE
lda TEXT_GAME_MODE_LO,x
sta ZEROPAGE_POINTER_1
lda TEXT_GAME_MODE_HI,x
sta ZEROPAGE_POINTER_1 + 1
lda #11
sta PARAM1
lda #21
sta PARAM2
jsr DisplayText
lda #0
jmp .UpPressed
.NotUpPressed
lda #1
.UpPressed
sta UP_RELEASED
lda #$02
bit JOYSTICK_PORT_II
bne .NotDownPressed
lda DOWN_RELEASED
beq .DownPressed
lda GAME_MODE
bne .NoGameModeWrap2
lda #3
sta GAME_MODE
.NoGameModeWrap2
dec GAME_MODE
;redisplay game mode
ldx GAME_MODE
lda TEXT_GAME_MODE_LO,x
sta ZEROPAGE_POINTER_1
lda TEXT_GAME_MODE_HI,x
sta ZEROPAGE_POINTER_1 + 1
lda #11
sta PARAM1
lda #21
sta PARAM2
jsr DisplayText
lda #0
jmp .DownPressed
.NotDownPressed
lda #1
.DownPressed
sta DOWN_RELEASED
lda #$10
bit JOYSTICK_PORT_II
bne .ButtonNotPressed
;button pushed
lda BUTTON_RELEASED
bne .Restart
jmp .TitleLoop
.ButtonNotPressed
lda #1
sta BUTTON_RELEASED
jmp .TitleLoop
.Restart
jsr WaitFrame
jsr SetGameIRQ
!ifdef MUSIC_PLAYING{
;initialise music player
lda SFX_MODE
bne +
lda #MUSIC_GET_READY_GAME_OVER_TUNE
jsr MUSIC_PLAYER
+
}
lda #0
sta VIC_SPRITE_EXPAND_X
sta VIC_SPRITE_EXPAND_Y
sta CHAPTER
jsr ShowChapter
;game start values
lda #3
sta PLAYER_LIVES
sta PLAYER_LIVES + 1
lda #0
sta PLAYER_RELOAD_SPEED
sta SUPER_BULLET
sta DEMON_BLOOD
lda #5
sta PLAYER_FORCE_RANGE
lda #2
sta PLAYER_SHELLS
sta PLAYER_SHELLS_MAX
lda #48
sta PLAYER_SCORE
sta PLAYER_SCORE + 1
sta PLAYER_SCORE + 2
sta PLAYER_SCORE + 3
sta PLAYER_SCORE + 4
sta PLAYER_SCORE + 5
sta PLAYER_SCORE + 6
sta PLAYER_SCORE + 7
;setup level
lda #$0b
sta VIC_CONTROL_MODE
jsr StartLevel
lda #START_LEVEL
sta LEVEL_NR
jsr BuildScreen
jsr CopyLevelToBackBuffer
lda #40
sta LEVEL_START_DELAY
lda #0
sta SPRITE_JUMP_POS
jsr DisplayGetReady
DisplayScoreDisplay
;score display according to game mode
lda GAME_MODE
cmp #GT_SINGLE_PLAYER_DEAN
beq .DeanOnly
cmp #GT_SINGLE_PLAYER_SAM
beq .SamOnly
lda #<TEXT_DISPLAY_DEAN_AND_SAM
sta ZEROPAGE_POINTER_1
lda #>TEXT_DISPLAY_DEAN_AND_SAM
sta ZEROPAGE_POINTER_1 + 1
ldx #0
jsr DisplayLiveNumber
ldx #1
jsr DisplayLiveNumber
jmp .DisplayDisplay
.DeanOnly
lda #0
sta PLAYER_LIVES + 1
lda #<TEXT_DISPLAY_DEAN_ONLY
sta ZEROPAGE_POINTER_1
lda #>TEXT_DISPLAY_DEAN_ONLY
sta ZEROPAGE_POINTER_1 + 1
ldx #0
jsr DisplayLiveNumber
jmp .DisplayDisplay
.SamOnly
lda #0
sta PLAYER_LIVES
lda #<TEXT_DISPLAY_SAM_ONLY
sta ZEROPAGE_POINTER_1
lda #>TEXT_DISPLAY_SAM_ONLY
sta ZEROPAGE_POINTER_1 + 1
ldx #1
jsr DisplayLiveNumber
jmp .DisplayDisplay
.DisplayDisplay
lda #0
sta PARAM1
lda #23
sta PARAM2
jsr DisplayText
jsr DisplayLevelNumber
;settings per game mode
;default ports
lda #0
sta PLAYER_JOYSTICK_PORT
lda #1
sta PLAYER_JOYSTICK_PORT + 1
;set two player mode active flag
lda #0
sta TWO_PLAYER_MODE_ACTIVE
lda GAME_MODE
cmp #GT_COOP
bne +
inc TWO_PLAYER_MODE_ACTIVE
+
lda GAME_MODE
cmp #GT_SINGLE_PLAYER_SAM
bne .NoPortChange
lda #0
sta PLAYER_JOYSTICK_PORT + 1
.NoPortChange
;full shells
ldy #0
.RefillShellImage
lda #2
sta SCREEN_COLOR + 23 * 40 + 19,y
lda #7
sta SCREEN_COLOR + 24 * 40 + 19,y
iny
cpy PLAYER_SHELLS_MAX
bne .RefillShellImage
!ifdef MUSIC_PLAYING{
;initialise music player
lda SFX_MODE
bne +
lda #MUSIC_IN_GAME_TUNE
jsr MUSIC_PLAYER
+
}
lda #$1b
sta VIC_CONTROL_MODE
jmp GameLoop