-
Notifications
You must be signed in to change notification settings - Fork 1
/
knight3.c
3002 lines (2602 loc) · 65.5 KB
/
knight3.c
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
// lda $5351 is a problem
int main()
{
uint joystickdata=NULL;
uint buttonpress=NULL;
uint joystickenabled=NULL;
uint JSportA=NULL;
uint JSbtnPressA=NULL;
uint JSnorth=NULL;
uint JSsouth=NULL;
uint JSeast=NULL;
uint JSwest=NULL;
data mapfn = {'M','A','P','?',',','S',',','R' };
asmcomment( "Bitmap Graphics Definitions" );
data sdoor = { 213, 213, 253, 255, 255, 255, 255, 255, 85, 85, 85, 245, 255, 255, 255, 255, 85, 85, 85, 95, 255, 255, 255, 255, 87, 87, 127, 255, 255, 255, 255, 255 };
data empty2 = { 170, 170, 170, 170, 170, 170, 170, 170 };
data steal1 = {0, 0, 0, 1, 1, 7, 7, 23, 0, 63, 122, 234, 234, 170, 170, 170, 0, 252, 174, 151, 183, 181, 253, 245, 0, 0, 0, 128, 128, 224, 224, 232};
data steal3 = {30, 30, 94, 94, 94, 94, 94, 94, 171, 171, 171, 171, 175, 191, 175, 191, 253, 245, 245, 245, 245, 213, 245, 213, 120, 122, 122, 122, 122, 122, 122, 122 };
data steal5 = {95, 87, 87, 87, 87, 87, 23, 23, 175, 175, 173, 253, 213, 245, 255, 235, 85, 85, 85, 87, 87, 95, 255, 235, 250, 234, 234, 234, 234, 234, 232, 232 };
data steal7 = {21, 5, 5, 1, 1, 0, 0, 0, 255, 255, 127, 95, 95, 95, 23, 0, 255, 255, 254, 250, 250, 250, 232, 0, 168, 160, 160, 128, 128, 0, 0, 0 };
data wall2 = { 106, 106, 106, 106, 106, 106, 106, 85, 170, 170, 170, 170, 170, 170, 170, 85 };
data door1to4 = { 255, 255, 255, 255, 255, 255, 255, 255 };
data door0topL = { 3, 3, 15, 15, 63, 63, 255, 255 };
data door0topR = { 192, 192, 240, 240, 252, 252, 255, 255 };
data armour0 = { 0, 0, 0, 0, 3, 3, 3, 3, 63, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
data armour1 = { 3, 3, 3, 3, 3, 3, 3, 3, 255, 255, 255, 255, 255, 255, 255, 255, 192, 0, 0, 0, 0, 0, 0, 255, 3, 3, 3, 3, 3, 3, 3, 255 };
data armour2 = { 63, 255, 195, 195, 195, 195, 195, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 3, 3, 3, 3, 3, 3, 3, 3 };
data armour3 = { 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 192, 192, 192, 192, 192, 192, 192, 192, 3, 3, 3, 3, 3, 3, 3, 3 };
data armour4 = { 3, 3, 3, 3, 3, 3, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 192, 192, 192, 192, 192, 192, 255, 255, 3, 3, 3, 3, 3, 3, 3, 3 };
data torch0 = { 1, 5, 26, 25, 6, 6, 63, 15, 0, 128, 144, 96, 64, 128, 240, 192 };
data torch1 = { 3, 3, 3, 3, 3, 3, 3, 3 };
data allThrees = { 255, 255, 255, 255, 255, 255, 255, 255 };
data maponWallTop = {
255, 192, 197, 198, 205, 205, 205, 205,
255, 0, 85, 170, 151, 151, 191, 93,
255, 0, 85, 170, 93, 93, 255, 117,
255, 3, 87, 167, 103, 83, 147, 167 };
data maponWallBot = {
198, 198, 198, 218, 213, 192, 192, 255,
93, 181, 181, 170, 85, 0, 15, 255,
117, 255, 215, 150, 85, 0, 240, 255,
167, 167, 167, 167, 83, 3, 3, 255
};
data cuff0 = { 149, 157, 157, 140, 140, 176, 176, 186, 1, 1, 1, 0, 0, 0, 0, 170, 80, 208, 208, 192, 192, 48, 48, 186 };
data cuff1 = { 176, 192, 192, 192, 192, 240, 192, 170, 0, 0, 0, 0, 0, 0, 0, 170, 48, 12, 12, 12, 12, 51, 12, 170 };
data window0 = { 64, 64, 64, 67, 78, 78, 122, 122, 0, 0, 255, 170, 170, 170, 170, 170, 64, 64, 255, 170, 170, 170, 170, 170, 0, 0, 192, 176, 172, 172, 171, 171 };
data window1L = { 122, 122, 122, 122, 122, 122, 122, 122 };
data window1R = { 171, 171, 171, 171, 171, 171, 171, 171 };
data window3L = { 122, 122, 122, 122, 122, 122, 122, 127 };
data window3M = { 170, 170, 170, 170, 170, 170, 170, 255 };
data window3R = { 171, 171, 171, 171, 171, 171, 171, 255 };
data paintingtop = { 10, 8, 8, 8, 11, 8, 10, 10, 170, 255, 255, 255, 255, 165, 151, 149, 170, 0, 0, 0, 240, 0, 64, 80, 160, 32, 32, 32, 32, 32, 32, 32 };
data paintingbot = { 8, 8, 8, 11, 11, 11, 11, 10, 93, 23, 253, 255, 255, 255, 255, 170, 1, 1, 67, 255, 252, 192, 192, 170, 96, 96, 224, 224, 32, 32, 32, 160 };
data painting2top = {170, 128, 128, 128, 128, 128, 128, 128, 170, 0, 0, 63, 253, 245, 246, 245, 170, 0, 0, 240, 112, 92, 108, 156, 170, 2, 2, 2, 2, 2, 2, 2 };
data painting2bot = { 128, 128, 128, 130, 130, 130, 138, 170, 245, 253, 250, 250, 186, 186, 250, 170, 80, 64, 168, 106, 170, 110, 174, 170, 2, 2, 2, 2, 130, 130, 130, 170 };
data closedDoor00 = {
64, 64, 64, 67, 78, 122, 122, 122,
0, 0, 63, 234, 170, 170, 255, 204,
64, 64, 255, 170, 170, 170, 255, 204,
0, 0, 0, 240, 172, 171, 235, 235
};
data closedDoor01 = {
122, 122, 122, 122, 122, 122, 122, 122,
204, 204, 204, 204, 204, 255, 170, 170,
204, 204, 204, 204, 204, 255, 170, 170,
235, 235, 235, 235, 235, 235, 171, 171 };
data closedDoor02 = {
122, 122, 122, 122, 122, 122, 122, 122,
170, 170, 170, 170, 170, 170, 170, 170,
170, 170, 170, 170, 170, 170, 170, 170,
171, 171, 171, 171, 75, 27, 171, 171 };
data closedDoor03 = {
122, 122, 122, 122, 122, 122, 122, 127,
170, 170, 170, 170, 170, 170, 170, 255,
170, 170, 170, 170, 170, 170, 170, 255,
171, 171, 171, 171, 171, 171, 171, 255
};
data shop01 = { 67, 76, 112, 192, 192, 192, 192, 192 };
data shop02 = { 255, 0, 15, 63, 61, 55, 53, 2, 255, 0, 192, 240, 240, 112, 112, 0, 192, 48, 12, 3, 3, 3, 3, 3 };
data shop03 = { 192, 192, 255, 79, 79, 79, 64, 85, 42, 170, 191, 191, 239, 250, 0, 85, 160, 168, 251, 251, 175, 255, 64, 85, 3, 3, 255, 240, 240, 240, 0, 85 };
//data leftWallTop = { 252, 240, 192, 192, 192, 192, 192, 192 };
data leftWallTop = { 253, 245, 213, 213, 213, 213, 213, 213 };
data leftWallMid = { 213, 213, 213, 213, 213, 213, 213, 213 };
data leftWallBot = { 213, 213, 213, 213, 213, 213, 245, 253 };
data rightWallTop = { 127, 95, 87, 87, 87, 87, 87, 87 };
data rightWallMid = { 87, 87, 87, 87, 87, 87, 87, 87 };
data rightWallBot = { 87, 87, 87, 87, 87, 87, 95, 127 };
data fleurdelistop = { 255, 234, 234, 234, 234, 214, 214, 213, 255, 150, 150, 85, 85, 85, 85, 150, 255, 171, 171, 171, 171, 151, 151, 87 };
data fleurdelisbot = { 217, 218, 234, 234, 234, 234, 234, 255, 85, 85, 150, 150, 150, 105, 170, 255, 103, 167, 171, 171, 171, 171, 171, 255 };
data shieldtop = { 192, 255, 192, 192, 200, 194, 200, 192, 48, 207, 168, 32, 32, 170, 32, 32, 76, 252, 12, 12, 140, 12, 140, 12 };
data shieldbot = { 112, 112, 112, 76, 76, 67, 64, 85, 32, 32, 32, 32, 168, 3, 204, 117, 48, 48, 48, 192, 192, 64, 64, 85 };
data keyonwall = { 215, 125, 125, 215, 247, 215, 247, 215 };
asmcomment( "Text Definitions" );
data levelText = {'L','E','V','E','L',':',0x00 };
data shopText = {'S', 'H', 'O', 'P', 0x00 };
data scoreText = {'E', 'X', 'P', ':', 0x20, 0x00 };
data healthText = {'H', 'E', 'A', 'L', 'T', 'H', ':', 0x20, 0x00 };
data monsterHealthText = {'E', 'N', 'E', 'M', 'Y', ':' };
data livesText = {'L', 'I', 'V', 'E', 'S', ':' };
data spacesText = { ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' };
data zeroText = {'0'};
data goldText = {'G', 'O', 'L', 'D', ':', 0x20, 0x00 };
data youDiedText = {'Y', 'O', 'U', ' ', 'H', 'A', 'V', 'E', ' ', 'P', 'E', 'R', 'I', 'S', 'H', 'E', 'D' };
// 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
data pakText = {'P', 'R', 'E', 'S', 'S', ' ', 'A', 'N', 'Y', ' ', 'K', 'E', 'Y', ' ', 'T', 'O', ' ', 'C', 'O', 'N', 'T', 'I', 'N', 'U', 'E' };
// 17 chars
data lastTimeText = { 'F', 'O', 'R', ' ', 'T', 'H', 'E', ' ', 'L', 'A', 'S', 'T', ' ', 'T', 'I', 'M', 'E' };
data pressyText = {'P', 'R', 'E', 'S', 'S', ' ', 'Y', ' ', 'T', 'O', ' ', 'P', 'L', 'A', 'Y', ' ', 'A', 'G', 'A', 'I', 'N' };
data quitText = {'P', 'R', 'E', 'S', 'S', ' ', 'Q', ' ', 'T', 'O', ' ', 'Q', 'U', 'I', 'T' };
data levelUpText0 = { 'C', 'O', 'N', 'G', 'R', 'A', 'T', 'U', 'L', 'A', 'T', 'I', 'O', 'N', 'S', 0x00 };
//data levelUpText1 = { 'Y', 'O', 'U', ' ', 'H', 'A', 'V', 'E', ' ', 'S', 'A', 'V', 'E', 'D', ' ', 'T', 'H', 'E', ' ', 'P', 'R', 'I', 'N', 'C', 'E', 'S', 'S', 0x00 };
data levelUpText1 = { 'Y', 'O', 'U', ' ', 'H', 'A', 'V', 'E', ' ', 'C', 'O', 'M', 'P', 'L', 'E', 'T', 'E', 'D', ' ', 'T', 'H', 'E', ' ', 'L', 'E', 'V', 'E', 'L', 0x00 };
asmcomment( "LETTER/DIGIT DEFINITIONS" );
// digits
data digits =
{
255, 223, 119, 119, 119, 119, 119, 223,
255, 223, 223, 223, 223, 223, 223, 223,
255, 223, 119, 247, 223, 127, 127, 87,
255, 223, 119, 247, 223, 247, 119, 223,
255, 247, 119, 119, 87, 247, 247, 247,
255, 87, 127, 127, 95, 247, 119, 223,
255, 223, 119, 127, 95, 119, 119, 223,
255, 87, 247, 247, 247, 223, 223, 223,
255, 223, 119, 119, 223, 119, 119, 223,
255, 223, 119, 119, 215, 247, 247, 247,
// space
255, 255, 255, 255, 255, 255, 255, 255
};
// letters
data letters =
{
255, 223, 119, 119, 87, 119, 119, 119,
255, 95, 119, 119, 95, 119, 119, 95,
255, 223, 119, 127, 127, 127, 119, 223,
255, 95, 119, 119, 119, 119, 119, 95,
255, 87, 127, 127, 95, 127, 127, 87,
255, 87, 127, 127, 95, 127, 127, 127,
255, 223, 119, 127, 87, 119, 119, 223,
255, 119, 119, 119, 87, 119, 119, 119,
255, 87, 223, 223, 223, 223, 223, 87,
255, 247, 247, 247, 119, 119, 119, 223,
255, 119, 119, 95, 119, 119, 119, 119,
255, 127, 127, 127, 127, 127, 127, 87,
255, 119, 87, 87, 119, 119, 119, 119,
255, 255, 255, 127, 87, 119, 119, 119,
255, 223, 119, 119, 119, 119, 119, 223,
255, 95, 119, 119, 95, 127, 127, 127,
255, 223, 119, 119, 119, 119, 119, 221,
255, 95, 119, 119, 95, 119, 119, 119,
255, 223, 119, 127, 223, 247, 119, 223,
255, 87, 223, 223, 223, 223, 223, 223,
255, 119, 119, 119, 119, 119, 119, 223,
255, 119, 119, 119, 119, 119, 223, 223,
255, 119, 119, 119, 87, 87, 119, 119,
255, 119, 119, 119, 223, 119, 119, 119,
255, 119, 119, 119, 223, 223, 223, 223,
255, 87, 247, 247, 223, 127, 127, 87,
// space
255, 255, 255, 255, 255, 255, 255, 255,
// colon
255, 255, 223, 223, 255, 223, 223, 255,
// period
255, 255, 255, 255, 255, 255, 127, 127,
// (
247, 223, 223, 223, 223, 223, 223, 247,
// )
223, 247, 247, 247, 247, 247, 247, 223,
// , comma
255, 255, 255, 255, 255, 255, 223, 127
};
word plotDigitAddr = digits;
// the background colour could be controlled by a raster int
// from 0-32 bg should be blue
// from 33 - 120 bg should be grey
// from 121 - bottom of floor it should be brown
// and then i don't care ... black maybe
// setup background colours
//irq( ptr(irqfunc1), 0x00, 1 );
saveregs();
poke( 0xD020, 0x0B );
poke( 0xD021, 0x0B );
// directions
// 0
// 3 1
// 2
lda( 0x00 );
uint direction;
uint dieRoll;
uint Adirection;
uint prevdirection;
uint Aprevdirection;
uint currentupframe;
uint currentdownframe;
uint Acurrentupframe;
uint Acurrentdownframe;
uint Acurrentleftframe;
uint Acurrentrightframe;
uint general8bit;
uint roomIndex;
uint goN;
uint goE;
uint goS;
uint goW;
uint plotDigitBindex;
uint plotDigitX;
uint plotDigitY;
uint wordSize;
uint rndinit;
uint myTextBG;
uint readyToLevelUp;
uint isCursed;
//uint escapeDoorIsInRoom;
uint thing;
uint thing2;
uint whichsprites;
uint currentRoom;
uint currentleftframe;
uint currentrightframe;
uint specialBitFlag;
uint monsterisinroom;
uint treasureinroom;
uint mapinroom;
uint healthpackinroom;
uint princessisinroom;
uint keyinroom;
uint treasurey;
uint keyy;
uint healthpacky;
uint princessy;
uint playerdied;
uint keepPlaying;
uint maxHP;
uint playerHasKey;
uint playerAttackFlag;
uint doorLocked;
uint status;
// Blue and Red
uint plotshapeColourValue0110;
// White
uint plotshapeColourValue11;
uint textColour = 0x01;
uint homeRoom;
// start at this level
uint level = 0x01;
// 0
// 3 1
// 2
uint door0=NULL;
uint door1=NULL;
uint door2=NULL;
uint door3=NULL;
word nDoor = 0x0000;
word expPts;
word playerGold;
word sDoor;
word general16bit;
word clock;
word plotNum;
word treasurex;
word healthpackx;
word keyx;
word princessx;
word hpTimer;
word wordToPrint;
word mapx;
// start in room #1
//inc( currentRoom );
currentRoom = homeRoom;
// number of remaining lives;
uint lives = 0x03;
word playerx = 0x0020;
//uint playery = 0x40;
uint playery = 0x80;
word monster0x = 0x0064;
uint monster0y = 0xC8;
// create and init the torch locations
uint torchlocation[5];
for( general8bit = 0; general8bit < 5; inc(general8bit) )
{
torchlocation[general8bit] = 0;
}
general8bit = 0x00;
uint playerHP = myRand();
playerHP = playerHP & 0x03;
uint playerAC = myRand();
playerAC = playerAC & 0x03;
uint monsterHP = myRand();
monsterHP = monsterHP & 0x03;
uint monsterAC = myRand();
monsterAC = monsterAC & 0x03;
playerHP = playerHP + 13;
playerAC = playerAC + 13;
bank( 2 );
// multicolour bitmap mode
uint currentD011 = peek( 0xD011 );
poke( 0xD011, currentD011 | 0x30 );
//poke( 0xD011, 0x38 );
poke( 0xD016, 0x18 );
poke( 0xD018, 0x18 );
romout(6);
word bmpaddr = getbmp_addr();
word bmpaddrX = bmpaddr + 0x1FF8;
word scraddr = getscr_addr();
word scraddrX = scraddr + 0x03EF;
screen(0x00);
poke( 0xD021, 0x00 );
asmcomment( "LOAD THE SPLASH SCREEN INTO MEMORY" );
setfilename( "SPLASH,S,R" );
setlfs( 3, 8, 3 );
fopen();
fchkin( 3 );
for( word i = 0xA000; i < 0xBF40; i = i + 0x0001 )
{
poke( i, fchrin() );
}
for( i = 0x8400; i < 0x87E8; i = i + 0x0001 )
{
poke( i, fchrin() );
}
for( i = 0xD800; i < 0xDBE8; i = i + 0x0001 )
{
poke( i, fchrin() );
}
fclose(3);
fclrchn();
myTextBG = 0x00;
wordToPrint = pakText;
wordSize = 25;
plotDigitX = 8;
plotDigitY = 24;
printWord();
screen(0x01);
asmcomment("seed the RNG by repeatedly calling rnd until player presses a key" );
seed();
while( general8bit == 0 )
{
// it doesn't matter that this is sDoor...
// it's just an unused (at the moment)
// memory location to put the new random value
sDoor=rnd(1);
general8bit = getchar();
buttonpress = peek(0xDC00) & 0x10;
if( buttonpress == 0x00 )
{
inc( general8bit );
}
}
mySeed();
// 2024 04 19 - mkpellegrino
//asmcomment( "shift the screen back down a pixel" );
//poke( 0xD011, 0x3B );
screen(0x00);
poke( 0xD021, 0x0C );
// setup music
asmcomment("load the SID data into memory from disk" );
setfilename( "2VOICES,S,R" );
setlfs( 3, 8, 3 );
fopen();
fchkin( 3 );
for( general8bit = 0; general8bit < 0x7E; inc(general8bit) )
{
// reuse uint dieRoll because it's not
// being used for anything yet
dieRoll = fchrin();
}
//read in the SID data
for( general16bit = 0xC000; general16bit < 0xC873; general16bit = general16bit + 0x0001 )
{
poke( general16bit, fchrin() );
}
asmcomment( "close the file" );
fclose(3);
fclrchn();
asmcomment( "init SID play" );
jsr( 0xC000 );
// setup sound
irq( ptr(irqfunc1), 0x00, 1 );
// 2024 04 19 - mkpellegrino
//asmcomment( "shift the screen back down a pixel" );
//poke( 0xD011, 0x3B );
word sprptr0 = scraddr + 0x03F8;
word sprptr1 = scraddr + 0x03F9;
word sprptr2 = scraddr + 0x03FA;
word sprptr3 = scraddr + 0x03FB;
word sprptr4 = scraddr + 0x03FC;
word sprptr5 = scraddr + 0x03FD;
word sprptr6 = scraddr + 0x03FE;
word sprptr7 = scraddr + 0x03FF;
asmcomment( "WORLD DEFINITION" );
// N, E, S, W, Wall0, Wall1, Wall2, Wall3, Wall4, Wall5 (front 1-5),
//
// 1 - haven't visited yet (0x80)
// 1 - monster is in room
// 1 - treasure
// 1 - healthpack
// 1 - key
// 1 -
// 1 -
// 1 - princess (0x01)
// 0 = nothing
// 1 = door
// 2 = armour
// 3 = torches
// 4 = window
// 5 =
// 6 = steal your face
// 7 = painting
// 11 - painting 2
data world =
{
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
loadWorld();
initGame();
loadSprites();
// Sprite Memory starts at 0x8040
// multicolour for sprites 00110111
//poke( 0xD01C, 0x37 );
// colours for all sprites (Light grey)
// poke( 0xD025, 0x0F );
// Black for all sprites
//poke( 0xD026, 0x00 );
// Brown for sprite 1
//spritecolour( 0x01, 0x09 );
// Brown for sprite 0 and 2 (the monster)
//spritecolour( 0x00, 0x09 );
//spritecolour( 0x02, 0x09 );
// Yellow for sprite 3 (the coins)
//spritecolour( 0x03, 0x07 );
// Red for sprite 4 (the healthpack)
//spritecolour( 0x04, 0x02 );
// Pink for sprite 5 (the princess)
//spritecolour( 0x05, 0x0A );
// Grey for sprite 6 (the key)
//spritecolour( 0x06, 0x0C );
// turn on sprites (b11111111 = 0xFF = all)
spriteon( 0xFF );
positionMOBS();
uint walkupframe[6];
walkupframe[0] = 33;
walkupframe[1] = 34;
walkupframe[2] = 35;
walkupframe[3] = 36;
walkupframe[4] = 35;
walkupframe[5] = 34;
uint walkdownframe[6];
walkdownframe[0] = 37;
walkdownframe[1] = 38;
walkdownframe[2] = 39;
walkdownframe[3] = 40;
walkdownframe[4] = 39;
walkdownframe[5] = 38;
uint walklframe[4];
walklframe[0] = 41;
walklframe[1] = 42;
walklframe[2] = 43;
walklframe[3] = 42;
uint walkrframe[4];
walkrframe[0] = 44;
walkrframe[1] = 45;
walkrframe[2] = 46;
walkrframe[3] = 45;
uint Awalkingrightframe[4];
Awalkingrightframe[0] = 49;
Awalkingrightframe[1] = 50;
Awalkingrightframe[2] = 51;
Awalkingrightframe[3] = 50;
uint Awalkingleftframe[4];
Awalkingleftframe[0] = 52;
Awalkingleftframe[1] = 53;
Awalkingleftframe[2] = 54;
Awalkingleftframe[3] = 53;
uint Awalkupframe[2];
Awalkupframe[0] = 55;
Awalkupframe[1] = 56;
uint Awalkdownframe[2];
Awalkdownframe[0] = 57;
Awalkdownframe[1] = 58;
//clearhires();
asmcomment("create scenery");
// treasure
poke( sprptr3, 61 );
// healthpack
poke( sprptr4, 62 );
// princess
poke( sprptr5, 63 );
// key
//poke( sprptr6, 64 );
poke( sprptr6, 0 );
putStuffOnTheScreen();
// after this screen should be back on
//pause();
uint c = getin();
// ==========
while( keepPlaying != 0x01 )
{
if( clock == 0x0000 )
{
//debug( 0x0003, 0x08, playerx, 0x08 );
animate();
getJS();
asmcomment( "convert keypresses into joystick button-presses");
if( c == 60 )
{
JSbtnPressA = 0x00;
}
if( c == 33 )
{
// UP
JSnorth = 0x00;
}
if( c == 37 )
{
// DOWN
JSsouth = 0x00;
}
if( c == 30 )
{
// LEFT
JSwest = 0x00;
}
if( c == 38 )
{
// RIGHT
JSeast = 0x00;
}
if( c == 12 )
{
// LEVEL UP
levelUp();
loadSprites();
putStuffOnTheScreen();
}
direction = 0x05;
if( JSbtnPressA == 0x00 )
{
// spacebar
playerAttackFlag = 0x01;
if( prevdirection == 3 )
{
direction = 6;
}
else
{
direction = 7;
}
JSnorth = 0x01;
JSsouth = 0x01;
JSeast = 0x01;
JSwest = 0x01;
}
if( isCursed == 0x01 )
{
uint tmpCurse = JSwest;
JSwest = JSeast;
JSeast = tmpCurse;
tmpCurse = JSnorth;
JSnorth = JSsouth;
JSsouth = tmpCurse;
inc( 0xD020 );
}
if( JSwest == 0x00 )
{
// left
direction = 3;
prevdirection = 3;
if( playerx > 0x0017 )
{
playerx = playerx - 0x0003;
}
}
if( playerx < 0x0018 )
{
if( goW != 0 )
{
// MOVE TO NEXT ROOM
currentRoom = goW;
playerx = 0x0140;
putStuffOnTheScreen();
}
}
if( playerx > 0x0142 )
{
if( goE != 0 )
{
currentRoom = goE;
playerx = 0x0020;
putStuffOnTheScreen();
}
}
if( JSeast == 0x00 )
{
// right
prevdirection = 1;
if( playerx < 0x0143 )
{
playerx = playerx + 0x0003;
}
direction = 1;
}
if( JSnorth == 0x00 )
{
// updateY();
// NORTH
direction = 0;
// 2024 04 20 - mkpellegrino
if( playery >= 113 )
{
dec(playery);
dec(playery);
dec(playery);
}
if( playery < 113 )
{
if( goN != 0 )
{
if( playerx > nDoor )
{
//if( playerx < nDoor + 0x0040 ) swapped for efficiency
if( nDoor + 0x0040 >= playerx )
{
if( doorLocked == 0x01 )
{
if( playerHasKey != 0x00 )
{
dec( playerHasKey );
unlockDoor();
currentRoom = goN;
playery = 202;
doorLocked = 0x00;
putStuffOnTheScreen();
}
}
else
{
// MOVE TO NEXT ROOM
currentRoom = goN;
playery = 202;
putStuffOnTheScreen();
}
}
}
}
if( mapx != 0x0000 )
{
if( playerx > mapx )
{
if( playerx < mapx + 40 )
{
//plotDigitX = 2;
//plotDigitY = 10;
//plotNum = playerx;
//plotNumber();
//plotDigitX = 2;
//plotDigitY = 11;
//plotNum = mapx;
//plotNumber();
// this is where we can display the map
loadMap();
//noMonsters();
putStuffOnTheScreen();
}
}
}
}
}
if( JSsouth == 0x00 )
{
// SOUTH
direction = 2;
if( playery < 204 )
{
inc(playery);
inc(playery);
inc(playery);
}
if( playery >= 204 )
{
if( goS != 0 )
{
if( playerx > sDoor )
{
//if( playerx < sDoor + 0x0020 ) // swapping for efficiency
if( sDoor + 0x0020 >= playerx )
{
// MOVE TO NEXT ROOM
currentRoom = goS;
playery = 116;
putStuffOnTheScreen();
}
}
}
}
}
if( c == 62 )
{
pauseGameSequence();
}
if( princessisinroom != 0x00 )
{
if( playerHasKey != 0x00 )
{
uint tmpProx1 = proximity( princessx, princessy, 0x000A );
if( tmpProx1 != 0x00 )
{
// This should make the player go to the next level
// in the next level the healthpack should increase
// hit points by more than the previous level.
// monsters should have more hitpoints (and should be faster)
// there should be something like spells or shields or some new item
princessisinroom = 0x00;
//princess
clearSpecialBit( 0x00 );
// key bit
// 2024 04 19 - mkpellegrino
clearSpecialBit( 0x07 );
//clearSpecialBit( 0x08 );
spriteoff( 0x20 );
expPts = expPts + 0x0100;
updateScore();
dec( playerHasKey );
//playerHasKey = 0x00;
putThing( 0xA0, 0x00 );
// NOW ESCAPE!
escapePhase();
}
}
}
if( monsterisinroom != 0x00 )
{
tmpProx1 = proximity( monster0x, monster0y, 0x000A );
if( tmpProx1 != 0x00 )
{
//if( c == 60 )
if( JSbtnPressA == 0x00 )
{
playerAttack();
if( monsterHP > 0x00 )
{
monsterAttack();
}
}
else
{
monsterAttack();
}
tmpProx1 = 0x00;
}
}
// if monster is within proximity of player
// monster can attack
// ... not ALWAYS, but maybe, if rand() <= 0x20
// there could also be a "currently-in-a-fight" flag
// so if the player has started attacking, then
// the monster goes on the offensive
}
poke( 0xD01E, 0 );
poke( 0xD019, 0 );
//animate();
clock = clock + 0x0001;
hpTimer = hpTimer + 0x0001;
if( hpTimer == 0x0000 )
{
inc(playerHP);
updateHealth();
}
//if( clock > 0x007F )
//{
// clock = 0x0000;
//}
//clock = clock & 0x003F;
clock = clock & 0x007F;
c = getin();
}
//sidoff(0x0000);
clearkb();
asmcomment( "turn off all sprites" );
spriteset(0x00);
asmcomment( "restore rom settings" );
romin();
asmcomment( "go back to vic bank 0" );
bank(0);
asmcomment( "Restore $0314/$0315 IRQ Vector" );
//irq( ptr(irqrestore), 0x00, 1 );
restoreregs();
shortcls();
printf( "GAME OVER\n\nSTATS:\n" );
prints( levelText );
printf( level );
cr();
prints( scoreText );
printf( expPts );
cr();
prints( goldText );
printf( playerGold );
cr();
prints( healthText );
printf( playerHP );
cr();
return;
}
void animate()
{
// later on, when the memory bank configuration is finalised,
// use the immediate value of sprptr0 (which is a WordID).
// that will make the animate function execute a little bit faster.
//if( clock == 0x0000 )
// {
if( monsterisinroom != 0 )
{
calcMonster0Position();
if( Adirection == 0)
{
poke( sprptr0, Awalkupframe[Acurrentupframe] );
poke( sprptr2, Awalkupframe[Acurrentupframe] );
inc(Acurrentupframe);
Acurrentupframe = Acurrentupframe & 0x01;
}
if( Adirection == 2 )
{
poke( sprptr0, Awalkdownframe[Acurrentdownframe] );
poke( sprptr2, Awalkdownframe[Acurrentdownframe] );
inc(Acurrentdownframe);
Acurrentdownframe = Acurrentdownframe & 0x01;
}
if( Adirection == 1 )
{
poke( sprptr0, Awalkingrightframe[Acurrentrightframe] );
poke( sprptr2, Awalkingrightframe[Acurrentrightframe] );
inc(Acurrentrightframe);
Acurrentrightframe = Acurrentrightframe & 0x03;
}
if( Adirection == 3 )
{
poke( sprptr0, Awalkingleftframe[Acurrentleftframe] );
poke( sprptr2, Awalkingleftframe[Acurrentleftframe] );
inc(Acurrentleftframe);
Acurrentleftframe = Acurrentleftframe & 0x03;
}
}
if( direction == 0 )
{