-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathterraform.c
1780 lines (1478 loc) · 35.6 KB
/
terraform.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
void main()
{
import( "bin", "roadie3.bin", 0x1DC8 );
import( "sid", "cj.sid", 0x0000 );
lda( 0x00 );
uint general8bit;
// variables that WILL NEED TO get REinitialized
// ZEROES
uint subclock;
uint wordSize;
uint midjump;
uint jerjump;
uint subtimer;
uint timer;
uint lastdirectiontaken;
uint standing;
uint jerstanding;
uint jerrybelow;
uint whichtoblink;
uint blinktoggle;
uint shouldbeblinking;
uint blinktimer;
uint currentlyholding;
uint collidedwith;
word newX;
uint checkNearParamY1;
uint checkNearParamI;
word score = 0x0000;
word general16bit;
word checkNearParamX1;
word wordToPrint;
romout(6);
// INTRO SCREEN HERE!
clearkb();
saveregs();
// create xy arrays
word spritepointer[8];
word xarray[8];
uint yarray[8];
// save voice 3
uint D41B = peek( 0xD418 );
word clock = 257;
//word clock = 840;
//subclock = 0x00;
// initialise variables
//uint randomnessclock;
//word printWordAddr;
word jerrymoveclock = rnd(1);
//uint jerrymoveclock2;
uint plotDigitBindex;
uint plotDigitColourValue1001;
uint shownumParamUINT;
word adr1;
word shownumParamWORD = 0x0000;
lda( 0x01 );
uint jerrydirection;
uint whichsprite;
uint plotDigitX;
uint plotDigitY;
uint plotDigitColourValue11;
lda( 0x02 );
uint gearnumber;
uint plotshapeX;
uint plotshapeY;
uint plotshapeSize;
word plotshapeAddr;
uint plotshapeColourValue11;
uint plotshapeColourValue1001;
uint X0;
uint X1;
uint Y0;
uint Y1;
uint remaininglives = 0x03;
word num;
lda( 100 );
uint y;
uint jy;
word x = 0x0020;
word jx = 0x012C;
word collXVar;
uint collYVar;
// restore voice 3
poke( 0xD41B, D41B );
// steal your face logo
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 };
// digits
data digits =
{
0, 48, 204, 204, 204, 204, 204, 48,
0, 48, 48, 48, 48, 48, 48, 48,
0, 48, 204, 12, 48, 192, 192, 252,
0, 48, 204, 12, 48, 12, 204, 48,
0, 12, 204, 204, 252, 12, 12, 12,
0, 252, 192, 240, 12, 12, 204, 48,
0, 48, 204, 192, 240, 204, 204, 48,
0, 252, 12, 12, 48, 48, 48, 48,
0, 48, 204, 204, 48, 204, 204, 48,
0, 252, 204, 204, 252, 12, 12, 12,
// space
0, 0, 0, 0, 0, 0, 0, 0
};
// letters
data letters =
{
0, 48, 252, 204, 252, 204, 204, 204,
0, 240, 204, 204, 240, 204, 204, 240,
0, 48, 204, 192, 192, 192, 204, 48,
0, 240, 204, 204, 204, 204, 204, 240,
0, 252, 192, 192, 240, 192, 192, 252,
0, 252, 192, 192, 240, 192, 192, 192,
0, 48, 204, 204, 60, 12, 204, 48,
0, 204, 204, 204, 252, 204, 204, 204,
0, 252, 48, 48, 48, 48, 48, 252,
0, 252, 12, 12, 12, 204, 204, 48,
0, 204, 204, 204, 240, 204, 204, 204,
0, 192, 192, 192, 192, 192, 192, 252,
0, 204, 252, 252, 204, 204, 204, 204,
0, 0, 0, 192, 252, 204, 204, 204,
0, 252, 204, 204, 204, 204, 204, 252,
0, 240, 204, 204, 240, 192, 192, 192,
0, 48, 204, 204, 204, 204, 240, 60,
0, 240, 204, 204, 240, 204, 204, 204,
0, 48, 204, 192, 48, 12, 204, 48,
0, 252, 48, 48, 48, 48, 48, 48,
0, 204, 204, 204, 204, 204, 204, 252,
0, 204, 204, 204, 204, 48, 48, 48,
0, 204, 204, 204, 252, 252, 252, 204,
0, 204, 204, 204, 48, 204, 204, 204,
0, 204, 204, 204, 60, 12, 204, 48,
0, 252, 12, 12, 48, 192, 192, 252,
// space
0, 0, 0, 0, 0, 0, 0, 0,
// colon
0, 0, 60, 60, 0, 60, 60, 0
};
//data zero = {'A'};
data clockText = {'C', 'L', 'O', 'C', 'K' };
data scoreText = {'S', 'C', 'O', 'R', 'E' };
data livesText = {'L', 'I', 'V', 'E', 'S', ':' };
data paused = { 'P', 'A', 'U', 'S', 'E', 'D' };
data pak = { 'P', 'R', 'E', 'S', 'S', ' ', 'A', 'N', 'Y', ' ', 'K', 'E', 'Y' };
data spaces = { ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' };
data hitY= { 'H', 'I', 'T', ' ', 'Y', ' ', 'T', 'O', ' ', 'Q', 'U', 'I', 'T'} ;
data directions1 = {'U', ':', ' ', 'L', 'E', 'F', 'T', ' ', ' ', ' ', 'O', ':', ' ', 'R', 'I', 'G', 'H', 'T'};
data directions1a = {'Q', ':', ' ', 'Q', 'U', 'I', 'T', ' ', ' ', ' ', 'W', ':', ' ', 'P', 'A', 'U', 'S', 'E'};
data directions1b = {'S', 'P', 'A', 'C', 'E', ' ', 'B', 'A', 'R', ':', ' ', ' ', 'J', 'U', 'M', 'P' };
data directions2 = {'I', ':', ' ', 'P', 'I', 'C', 'K', ' ', 'U', 'P', ' ', ' ', ' ', 'K', ':', ' ', 'D', 'R', 'O', 'P' };
data directions3 = {'C', 'R', 'E', 'A', 'T', 'E', 'D', ' ', 'B', 'Y', ' ', 'M', 'I', 'C', 'H', 'A', 'E', 'L', ' ', 'P', 'E', 'L', 'L', 'E', 'G', 'R', 'I', 'N', 'O'};
data directions5 = {'P', 'R', 'E', 'S', 'S', ' ', 'A', 'N', 'Y', ' ', 'K', 'E', 'Y', ' ', 'T', 'O', ' ', 'S', 'T', 'A', 'R', 'T' };
data credit1 = { 'C', 'A', 'S', 'E', 'Y', ' ', 'J', 'O', 'N', 'E', 'S', ' ', 'B', 'Y', ' ', 'T', 'H', 'E', ' ', 'G', 'R', 'A', 'T', 'E', 'F', 'U', 'L', ' ', 'D', 'E', 'A', 'D' };
data credit2 = { 'S', 'I', 'D', ' ', 'C', 'R', 'E', 'A', 'T', 'E', 'D', ' ', 'B', 'Y', ' ', 'I', 'V', 'A', 'N', ' ', 'K', 'O', 'H', 'L', 'E', 'R' };
data endscreentext1 = {'G', 'A', 'M', 'E', ' ', 'O', 'V', 'E', 'R' };
data endscreentext2 = {'P', 'R', 'E', 'S', 'S', ' ', 'Y', ' ', 'T', 'O', ' ', 'P', 'L', 'A', 'Y', ' ', 'A', 'G', 'A', 'I', 'N' };
data interscreen1 = {'Y', 'O', 'U', 'R', ' ', 'T', 'I', 'M', 'E', ' ', 'H', 'A', 'S', ' ', 'E', 'X', 'P', 'I', 'R', 'E', 'D' };
data interscreen2 = {'T', 'R', 'I', 'E', 'S', ' ', 'R', 'E', 'M', 'A', 'I', 'N', 'I', 'N', 'G' };
word plotDigitAddr = digits;
// jump table
data jt = { 0x00, 0xFC, 0xFC, 0xFD, 0xFD, 0xFD, 0xFE, 0xFE, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
// down arrow
//data olddownarrow = { 1, 1, 1, 21, 5, 5, 1, 1, 0, 0, 0, 80, 64, 64, 0, 0 };
data downarrow = {169, 169, 169, 149, 165, 165, 169, 169, 170, 170, 170, 90, 106, 106, 170, 170 };
// hotspots
word hotspot[8];
// used to be 0x4...
hotspot[0] = 0x84CA;
hotspot[1] = 0x85BA;
hotspot[2] = 0x86AA;
hotspot[3] = 0x84EC;
hotspot[4] = 0x85DC;
hotspot[5] = 0x86CC;
hotspot[6] = 0x85F3;
hotspot[7] = 0x870B;
word hsX[8];
hsX[0] = 0x0025;
hsX[1] = 0x0025;
hsX[2] = 0x0025;
hsX[3] = 0x0134;
hsX[4] = 0x0134;
hsX[5] = 0x0134;
hsX[6] = 0x00AA;
hsX[7] = 0x00AA;
uint hsY[8];
hsY[0] = 0x55;
hsY[1] = 0x85;
hsY[2] = 0xB5;
hsY[3] = 0x55;
hsY[4] = 0x85;
hsY[5] = 0xB5;
hsY[6] = 0x8E;
hsY[7] = 0xC5;
uint hsScores[8];
hsScores[0] = 42;
hsScores[1] = 21;
hsScores[2] = 7;
hsScores[3] = 42;
hsScores[4] = 21;
hsScores[5] = 7;
hsScores[6] = 84;
hsScores[7] = 7;
// background colours
poke( 0xD020, 9 );
poke( 0xD021, 12 );
bank( 2 );
poke( 0xD011, 59 );
poke( 0xD016, 24 );
poke( 0xD018, 24 );
word bmpaddr = getbmp_addr();
word bmpaddrX = bmpaddr + 0x1FF8;
word scraddr = getscr_addr();
word scraddrX = scraddr + 0x03F0;
clearhires();
//copyStartScreen();
startScreen();
seed();
// pause here
while( general8bit == 0 )
{
subclock=rnd(1);
subclock=rnd(1);
general8bit = getchar();
}
clearhires();
createplatforms();
spritepointer[0] = scraddr + 0x03F8;
for( general8bit = 0; general8bit < 7; inc(general8bit) )
{
spritepointer[general8bit+0x01] = spritepointer[general8bit]+0x0001;
}
mob twr1 = { 0, 1, 0, 168, 0, 2, 170, 0, 3, 213, 0, 3, 213, 0, 0, 252, 0, 0, 32, 0, 0, 168, 0, 2, 34, 0, 2, 34, 0, 8, 32, 128, 8, 32, 128, 16, 48, 16, 0, 48, 0, 0, 48, 0, 0, 48, 0, 0, 204, 0, 0, 195, 0, 3, 3, 0, 12, 3, 48, 48, 0, 192, 12, 0, 192};
mob twr2 = { 0, 2, 0, 168, 0, 2, 170, 0, 3, 213, 0, 3, 213, 0, 0, 252, 0, 0, 32, 0, 0, 168, 0, 2, 34, 0, 2, 34, 0, 8, 32, 128, 8, 32, 128, 16, 48, 16, 0, 48, 0, 0, 48, 0, 0, 48, 0, 0, 48, 0, 0, 204, 0, 0, 204, 0, 3, 12, 0, 3, 12, 0, 3, 207, 0};
mob twr3 = { 0, 3, 0, 168, 0, 2, 170, 0, 3, 213, 0, 3, 213, 0, 0, 252, 0, 0, 32, 0, 0, 168, 0, 2, 34, 0, 2, 34, 0, 8, 32, 128, 8, 32, 128, 16, 48, 16, 0, 48, 0, 0, 48, 0, 0, 48, 0, 0, 252, 0, 0, 252, 0, 0, 252, 0, 0, 204, 0, 3, 12, 0, 3, 207, 0};
mob twr4 = { 0, 4, 0, 168, 0, 2, 170, 0, 3, 213, 0, 3, 213, 0, 0, 252, 0, 0, 32, 0, 0, 168, 0, 2, 34, 0, 2, 34, 0, 8, 32, 128, 8, 32, 128, 16, 48, 16, 0, 48, 0, 0, 48, 0, 0, 48, 0, 0, 48, 0, 0, 204, 0, 0, 204, 0, 3, 12, 0, 3, 12, 0, 3, 207, 0};
mob twl1 = { 0, 6, 0, 168, 0, 2, 170, 0, 1, 95, 0, 1, 95, 0, 0, 252, 0, 0, 32, 0, 0, 168, 0, 2, 34, 0, 2, 34, 0, 8, 32, 128, 8, 32, 128, 16, 48, 16, 0, 48, 0, 0, 48, 0, 0, 48, 0, 0, 204, 0, 0, 204, 0, 0, 204, 0, 0, 204, 0, 0, 195, 0, 3, 207, 0};
mob twl2 = { 0, 7, 0, 168, 0, 2, 170, 0, 1, 95, 0, 1, 95, 0, 0, 252, 0, 0, 32, 0, 0, 168, 0, 2, 34, 0, 2, 34, 0, 8, 32, 128, 8, 32, 128, 16, 48, 16, 0, 48, 0, 0, 48, 0, 0, 48, 0, 0, 48, 0, 0, 204, 0, 0, 204, 0, 0, 195, 0, 0, 195, 0, 3, 207, 0};
mob twl3 = { 0, 8, 0, 168, 0, 2, 170, 0, 1, 95, 0, 1, 95, 0, 0, 252, 0, 0, 32, 0, 0, 168, 0, 2, 34, 0, 2, 34, 0, 8, 32, 128, 8, 32, 128, 16, 48, 16, 0, 48, 0, 0, 48, 0, 0, 48, 0, 0, 252, 0, 0, 252, 0, 0, 252, 0, 0, 204, 0, 0, 195, 0, 3, 207, 0};
//mob twl4 = { 0, 7, 0, 168, 0, 2, 170, 0, 1, 95, 0, 1, 95, 0, 0, 252, 0, 0, 32, 0, 0, 168, 0, 2, 34, 0, 2, 34, 0, 8, 32, 128, 8, 32, 128, 16, 48, 16, 0, 48, 0, 0, 48, 0, 0, 48, 0, 0, 48, 0, 0, 204, 0, 0, 204, 0, 0, 195, 0, 0, 195, 0, 3, 207, 0};
mob jerry = { 1, 5, 0, 255, 0, 3, 255, 192, 15, 247, 240, 15, 213, 240, 15, 85, 112, 13, 255, 240, 13, 247, 240, 15, 85, 112, 3, 255, 195, 0, 255, 11, 0, 170, 58, 2, 186, 250, 10, 159, 232, 41, 87, 160, 233, 87, 128, 218, 94, 128, 214, 122, 128, 53, 122, 128, 15, 226, 128, 2, 162, 160, 10, 162, 168};
// these are the gear items bandmembers can drop
mob mic1 = { 2, 9, 0, 0, 96,0, 31, 240,0, 2, 96,0, 4, 0,0, 4, 0,0, 8, 0,0, 8, 0,0, 24, 0,0, 24, 0,0, 40, 0,0, 40, 0,0, 72, 0,0, 72, 0,0, 136, 0,0, 136, 0,0, 8, 0,0, 8, 0,0, 8, 0,0, 127, 0,3, 128, 224,28, 0, 28};
mob amplifier = { 3, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 0, 63, 255, 252, 234, 170, 171, 234, 171, 251, 234, 170, 171, 234, 170, 171, 234, 170, 171, 234, 170, 171, 234, 170, 171, 234, 170, 171, 234, 170, 171, 255, 255, 255};
mob acousticguitar = { 4, 11, 0, 252, 0, 0, 252, 0, 0, 48, 0, 0, 48, 0, 0, 48, 0, 0, 48, 0, 0, 48, 0, 3, 255, 0, 14, 170, 192, 14, 170, 192, 14, 170, 192, 3, 171, 0, 14, 186, 192, 58, 254, 176, 58, 254, 176, 58, 186, 176, 58, 170, 176, 14, 254, 192, 14, 170, 192, 3, 171, 0, 0, 252, 0};
mob drums = { 5, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 21, 3, 255, 85, 67, 171, 12, 3, 171, 15, 195, 255, 58, 176, 48, 234, 172, 48, 234, 172, 48, 234, 172, 48, 234, 172, 48, 234, 172, 48, 58, 176, 48, 207, 204, 252};
mob electricguitar = { 6, 13, 0, 192, 0, 0, 240, 0, 0, 240, 0, 0, 48, 0, 0, 48, 0, 0, 48, 0, 0, 48, 0, 0, 48, 0, 3, 48, 0, 14, 240, 192, 14, 243, 192, 14, 190, 192, 3, 170, 192, 3, 155, 0, 3, 171, 0, 14, 171, 0, 14, 154, 192, 14, 170, 192, 14, 254, 192, 3, 170, 192, 0, 255, 0};
// mob mic2 = { 7, 14, 0, 0, 96,0, 31, 240,0, 2, 96,0, 4, 0,0, 4, 0,0, 8, 0,0, 8, 0,0, 24, 0,0, 24, 0,0, 40, 0,0, 40, 0,0, 72, 0,0, 72, 0,0, 136, 0,0, 136, 0,0, 8, 0,0, 8, 0,0, 8, 0,0, 127, 0,3, 128, 224,28, 0, 28};
// multicolour sprite mode for some of the sprites %0111 1011
poke( 0xD01C, 0x7B );
// turn all of the sprites on
spriteon( 255 );
// 01 = Yellow for all sprites
poke( 0xD025, 7 );
// 11 = black for all sprites
poke( 0xD026, 0 );
// set the individual sprite colours
data spritecolours = { 2, 9, 0, 11, 9, 1, 2 };
for( general8bit = 0; general8bit < 7; inc(general8bit) )
{
spritecolour( general8bit, (spritecolours)[general8bit] );
}
// start the music located at $1000 (4096)
// the main loop
// ???
//poke( 0x87F9, 5 );
uint c = getin();
uint keepPlaying = 1;
sidirq( 0x1000, 0x1003 );
while( keepPlaying == 1 )
{
if( clock < 0x001E )
{
// border colour flicker
poke( 0xD020, rnd(1) );
}
if( clock == 0x0000 )
{
// if time runs out & no more lives - show the end-screen
dec(remaininglives);
if( remaininglives == 0 )
{
endscreen();
}
else
{
interscreen();
}
}
if( timer == 0 )
{
checkIfStanding();
// ====================================
// AI
// ====================================
if( jerjump >= 1 )
{
calculatejerjump();
}
else
{
if( jerstanding == 0 )
{
inc(jy);
if( jy > 219 )
{
jy = 219;
}
}
else
{
checkIfBelow();
calculateai();
}
}
//positionai();
spritey( 1, jy );
spritex( 1, jx );
// ====================================
if( standing == 0 )
{
if( midjump != 0 )
{
calculatejump();
}
else
{
inc(y);
if( y > 219 )
{
y = 219;
}
// wiggle player's legs
moveLegs();
}
}
else
{
if( midjump != 0 )
{
calculatejump();
}
else
{
checkLeft();
checkRight();
checkJump();
checkI();
checkK();
checkW();
checkQ();
}
}
positionplayer();
// position the equipment too
// (if there is any in the player's
// hands)
if( currentlyholding != 0 )
{
xarray[currentlyholding] = x;
yarray[currentlyholding] = y;
spritex( currentlyholding, x );
spritey( currentlyholding, y );
}
if( subclock == 0 )
{
shownum();
dec(clock);
}
inc(subclock);
subclock = subclock & 3;
}
inc( timer );
timer = timer & 0x3F;
if( shouldbeblinking == 1 )
{
if( blinktimer == 0x00 )
{
if( blinktoggle == 0 )
{
inc(blinktoggle);
poke( adr1, 0xCC );
poke( adr1+1, 0xCC );
}
else
{
dec( blinktoggle );
poke( adr1, 0x2C );
poke( adr1+1, 0x2C );
}
}
inc( blinktimer );
}
c = getin();
}
bank(0);
romin();
spriteoff( 255 );
restoreregs();
clearkb();
//sidoff( 0x1000 );
nosid();
//sidoff(0x1000);
return;
}
//void positionai()
//{
// spritey( 1, jy );
// spritex( 1, jx );
// return;
//}
void positionplayer()
{
if( x < 0x0017 )
{
x = 0x0017;
}
if( x > 320 )
{
x = 320;
}
spritey( 0, y );
spritex( 0, x );
return;
}
// "returns" cnNear (uint)
void checkNear()
{
lda( 0x00 );
uint cnNear;
if( checkNearParamX1 < hsX[checkNearParamI] + 0x000A )
{
if( checkNearParamX1 > hsX[checkNearParamI] - 0x000A )
{
if( checkNearParamY1 < hsY[checkNearParamI] + 5 )
{
if( checkNearParamY1 > hsY[checkNearParamI] - 5 )
{
cnNear = 0x01;
checkNearParamI = 8;
}
}
}
}
return;
}
// this is the function that
// figures out which direction
// jerry should move in
void calculateai()
{
if( jerrymoveclock == 0x0000 )
{
jerjump = 1;
if( jerrydirection == 1 )
{
jerrydirection = 0xFF;
}
else
{
jerrydirection = 1;
}
jerrymoveclock = rnd(1);
jerrymoveclock = jerrymoveclock / 2;
//asl( jerrymoveclock );
//asl( jerrymoveclock );
// drop some gear
if( gearnumber != currentlyholding )
{
checkNearParamX1 = jx;
checkNearParamY1 = jy;
for( checkNearParamI = 2; checkNearParamI < 8; inc(checkNearParamI) )
{
checkNear();
}
if( cnNear == 0 )
{
spritex( gearnumber, jx );
spritey( gearnumber, jy );
xarray[gearnumber] = jx;
yarray[gearnumber] = jy;
}
}
inc( gearnumber );
if( gearnumber == 7 )
{
gearnumber = 2;
}
}
else
{
word newJX;
if( jerrydirection == 1 )
{
newJX = jx + 0x0002;
//if( x != newJX )
// {
jx = newJX;
// }
}
else
{
newJX = jx - 0x0002;
//if( x != newJX )
// {
jx = newJX;
// }
}
// TODO: move jerry's legs here!
if( jx < 0x0017 )
{
jerrydirection = 1;
jx = 0x0017;
}
if( jx > 320 )
{
jerrydirection = 0xFF;
jx = 320;
}
dec( jerrymoveclock );
}
return;
}
void clearhires()
{
screen(0);
for( general16bit = 0xD800; general16bit < 0xDBFF; general16bit = general16bit + 1 )
{
poke( general16bit, 0 );
}
for( general16bit = scraddr; general16bit < scraddrX; general16bit = general16bit + 1 )
{
poke( general16bit, 0x26 );
}
for( general16bit = bmpaddr; general16bit < bmpaddrX; general16bit = general16bit + 1 )
{
poke( general16bit, 0x00 );
}
screen(1);
return;
}
void checkW()
{
if( c == 9 )
{
pausescreen();
clearkb();
}
return;
}
void checkQ()
{
if( c == 62 )
{
quitscreen();
}
return;
}
void checkI()
{
// Pick up a piece of equipment
if( c == 33 )
{
if( currentlyholding == 0 )
{
uint sc = 1 & spritecollision();
//sc = sc & 1;
if( sc != 0 )
{
checkCollision();
currentlyholding = collidedwith;
if( currentlyholding != 0 )
{
//inc(whichtoblink);
//whichtoblink = whichtoblink & 0x07;
whichtoblink = 0x07 & rnd(1);
adr1 = hotspot[whichtoblink];
shouldbeblinking = 1;
allArrowsOff();
}
}
}
}
return;
}
void checkK()
{
// Drop a piece of equipment
if( c == 37 )
{
if( currentlyholding != 0 )
{
checkNearParamX1 = x;
checkNearParamY1 = y;
checkNearParamI = whichtoblink;
checkNear();
if( cnNear == 0x01 )
{
score = score + hsScores[whichtoblink];
clock = clock + 42;
// update score vvv
// erase old score
plotDigitY = 1;
for( general8bit = 11; general8bit < 15; inc( general8bit ) )
{
plotDigitX = general8bit;
plotDigitBindex = 0x50;
plotDigit();
}
// update score vvv
num = score;
plotDigitX = 0x0F;
plotDigitY = 0x01;
plotNumber();
// update score ^^^
currentlyholding = 0;
shouldbeblinking = 0;
allArrowsOff();
}
}
}
return;
}
void plotNumber()
{
if( num == 0x0000 )
{
printWord();
plotDigitBindex = 0;
plotDigit();
}
else
{
while( num > 0x0000 )
{
num = num / 0x0A;
plotDigitBindex = asl(asl(asl(peek(0x02))));
plotDigit();
dec(plotDigitX);
}
}
return;
}
void shownum()
{
// erase xy
plotDigitY = 1;
for( general8bit = 26; general8bit > 23; dec( general8bit ) )
{
plotDigitX = general8bit;
plotDigitBindex = 0x50;
plotDigit();
}
num = clock;
plotDigitX = 26;
plotNumber();
return;
}
void checkLeft()
{
// move left if "u" is pressed and x > 23
if( c == 30 )
{
lastdirectiontaken=1;
if( x > 0x0017 )
{
newX = x - 1;
if( jx != newX )
{
x = newX;
moveLegs();
}
else
{
if( jy != y )
{
x = newX;
moveLegs();
}
}
}
}
return;
}
void checkRight()
{
// move right if "o" is pressed and x < 320
if( c == 38 )
{
lastdirectiontaken=2;
if( x < 320 )
{
newX = x + 1;
if( jx != newX)
{
x = newX;
moveLegs();
}
else
{
if( jy != y )
{
x = newX;
moveLegs();
}
}
}
}
return;
}
void checkJump()
{
// space bar
if( c == 60 )
{
if( midjump == 0 )
{
midjump = 1;
}
}
return;
}
// animate the legs during movement
void moveLegs()
{
inc( subtimer );
if( subtimer == 5 )
{
// this is for sprite number 1
//poke( 0x87F8, whichsprite );
poke( spritepointer[0], whichsprite );
inc( whichsprite );
if( whichsprite == 5 )
{
whichsprite = 1;
}
subtimer = 0;
}
return;
}
void checkIfStanding()
{
standing = getxy( lsr(x - 12), y - 29);
if( standing != 0xFF )
{
standing = 0;
}
jerstanding = getxy( lsr(jx - 12), jy - 29 );
if( jerstanding != 0xFF )
{
jerstanding = 0;
}
return;
}
void checkIfBelow()
{
word myX = lsr(jx - 12);
uint myY = jy - 49;
word myXp = myX + 8;
word myXm = myX - 8;
jerrybelow = getxy( myX, myY);
jerrybelow = jerrybelow | getxy( myXp, myY );
jerrybelow = jerrybelow | getxy( myXm, myY );
inc(myY);
jerrybelow = jerrybelow | getxy( myXp, myY);
jerrybelow = jerrybelow | getxy( myXm, myY);
dec(myY);
dec(myY);
jerrybelow = jerrybelow | getxy( myXp, myY);
jerrybelow = jerrybelow | getxy( myXm, myY);
return;
}
void calculatejump()
{
if( lastdirectiontaken == 2 )
{
x = x + 2;
}
else
{
x = x - 2;
}
y = y + (jt)[ midjump ];
checkIfStanding();
inc( midjump );
if( standing != 0 )
{
midjump = 0;
}
if( midjump == 25 )
{
midjump = 0;
}
return;
}
void calculatejerjump()
{
if( jerrydirection == 0xFF )
{
if( jx > 0x0017 )
{
jx = jx + 1;
}
else
{
jx = 0x0017;
}
}
else
{
if( jx < 320 )
{
jx = jx - 1;
}
else
{
jx = 320;
}
}
if( jx < 0x0017 )
{
jx = 0x0017;
}
if( jx > 320 )
{
jx = 320;
}
jy = jy + (jt)[ jerjump ];
checkIfStanding();
inc( jerjump );
if( jerjump == 25 )
{
jerjump = 0;
}
return;
}
void createplatforms()
{
screen(0);
//sidoff( 0x1000 );
//nosid();
// Draw the "X"'s on the Scaffolding
data scafX = {192, 192, 48, 48, 12, 12, 3, 3};
data scafX2 = {3, 3, 12, 12, 48, 48, 192, 192};
plotshapeAddr = scafX;
plotshapeSize = 1;
plotshapeColourValue1001 = 0x00;
plotshapeColourValue11 = 0x00;
plotshapeY = 1;
for(uint cpI = 0; cpI < 4; inc( cpI ))
{
plotshapeX = 0;