-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathENGINE.BAS
executable file
·1937 lines (1846 loc) · 47 KB
/
ENGINE.BAS
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
DECLARE SUB SObjRoll (x%, y%, f%, zd&)
DECLARE SUB SwapAllBrk (b1%, b2%)
DECLARE SUB InObj (n%)
DECLARE SUB OutObj (n%)
DECLARE SUB DoSwitch (x%, y%)
DECLARE SUB ShootSmallCannon (x%, y%)
DECLARE SUB DoSObjLandOn (x%, y%, o%)
DECLARE FUNCTION CheckIfWin% ()
DECLARE SUB DoSObjWarp (x%, y%, zz%)
DECLARE SUB PushSObj ()
DECLARE SUB PushSteelie ()
DECLARE SUB TurnObjAround (i%)
DECLARE SUB Splash (sp%, x%, y%)
DECLARE SUB CalculateWaitTime ()
DECLARE SUB UAllObj ()
DECLARE SUB DoAnim (Seq%, w%)
DECLARE SUB UAnim ()
DECLARE FUNCTION Hex4% (v$)
DECLARE FUNCTION Hex2% (v$)
DECLARE FUNCTION Hex1% (v$)
DECLARE SUB SteelieRoll (x%, y%, f%, zd&)
DECLARE SUB Roll (f%)
DECLARE SUB Slip (f%)
DECLARE SUB DoLandOn (zd&)
DECLARE SUB Jump (f%, zd&)
DECLARE SUB walk (f%)
DECLARE SUB Push (f%, zd&)
DECLARE SUB Stand (f%)
DECLARE FUNCTION ChkAheadBrk% ()
DECLARE SUB DoWarp ()
DECLARE SUB ChkCannon ()
DECLARE SUB Inc (x%, b%, t%)
DECLARE FUNCTION GetBrickType% (x%, y%)
DECLARE SUB DoSound (snd%)
DECLARE SUB Delay (x&)
DECLARE SUB DoPlayer ()
DECLARE SUB DoEnemy ()
DECLARE FUNCTION ChkKey% ()
DECLARE SUB Uplayer ()
DECLARE FUNCTION GetItem% (x%, y%)
DECLARE SUB InitLevel ()
DECLARE SUB Intro ()
DECLARE SUB boop ()
DECLARE SUB ReplaceBrick (x%, y%)
DECLARE FUNCTION GetClick% ()
DECLARE SUB LoadMap (file$)
DECLARE SUB Init ()
DECLARE SUB PutBrick (x%, y%, b%)
DECLARE FUNCTION GetBrick% (x%, y%)
DECLARE SUB PutItem (x%, y%, i%)
DECLARE SUB ClrObj (n%)
DECLARE SUB Objite (n%, x%, y%, i%)
DECLARE SUB SetObj (n%, x%, y%, i%)
DECLARE SUB ClrAllObj ()
DECLARE SUB DAllObj ()
DECLARE SUB DObj (n%)
DECLARE SUB LoadImg (file$)
DEFINT A-Z
COMMON SHARED w, s, SoundOn, WaitTime&, RollDir, GameOver
CLEAR , , 16384
TYPE ObjType
Frame AS INTEGER ' Which Image
mx AS INTEGER ' Map Coors
my AS INTEGER
sx AS INTEGER ' Screen Coors
sy AS INTEGER
ox AS INTEGER ' Old Screen Coors
oy AS INTEGER
oFrame AS INTEGER ' Old Anim Frame
ObjOn AS INTEGER
Update AS INTEGER ' Update Flag
f AS INTEGER ' Facing.. 1up,2dn,3lt,4rt
t AS INTEGER ' Obj Type.. 0Player,1Steelie,2Weight,3Switch
evt AS INTEGER ' Switch event number.
item AS INTEGER ' Holding a Map Item 0=None
END TYPE
TYPE PlayerT
'PowerUP?
k AS INTEGER
'Will he move automatically next DoPlayer?
WillMove AS INTEGER
Standing AS INTEGER
Dead AS INTEGER
Holding AS INTEGER
END TYPE
TYPE LevelT
'Player Starting Coors
psx AS INTEGER
psy AS INTEGER
'Exit Coors
ex AS INTEGER
ey AS INTEGER
'Exit Objite Frame
ef AS INTEGER
'Level is Complete
Won AS INTEGER
'Warp type 0Link 1Circular
wt AS INTEGER
'Hole Info
MaxHole AS INTEGER
HoleCnt AS INTEGER
END TYPE
TYPE AnimType
Seq AS INTEGER
inUse AS INTEGER
Delay AS INTEGER
p AS INTEGER
o AS INTEGER
f AS INTEGER
END TYPE
CONST MaxObj = 20
CONST MaxAnim = 10
CONST MaxSeq = 49
CONST True = -1
CONST Flase = 0
DIM SHARED ObjImg(67, 119, 1) AS INTEGER
DIM SHARED ObjBkg(67, MaxObj) AS INTEGER
DIM SHARED Obj(MaxObj) AS ObjType
DIM SHARED Map(19, 10, 5, 9)
DIM SHARED MapData(9, 1, 5, 9)
DIM SHARED Warp(9, 1)
DIM SHARED Anim(MaxAnim) AS AnimType
DIM SHARED Seq$(MaxSeq)
DIM SHARED Player AS PlayerT
DIM SHARED Level AS LevelT
CONST debug = -1
' Init Game
Init
LoadImg "mac.spr"
SoundOn = False
SoundOn = True
w = 0: s = 0
' Read Sequence Data
RESTORE AnimData
FOR i = 0 TO MaxSeq
READ Seq$(i)
NEXT i
CalculateWaitTime
' Main Game Routine
IF NOT debug THEN Intro
GameOver = False
DO
LoadMap "mac"
IF debug THEN
CLS
INPUT "World"; w: w = w - 1
INPUT "Stage"; s: s = s - 1
END IF
CLS
IF NOT debug THEN
LOCATE 10, 15: PRINT "World "; MID$(STR$(w + 1), 2, 1); "-"; MID$(STR$(s + 1), 2)
SLEEP 3
END IF
' Setup and Draw Level
InitLevel
Player.Dead = False
DO
'Checks things like cannons
DoEnemy
'Work with Player
DoPlayer
UAnim
LOOP UNTIL Player.Dead OR Level.Won
ClrAllObj
IF Level.Won THEN
s = s + 1
IF s = 10 THEN
s = 0
w = w + 1
END IF
END IF
LOOP UNTIL GameOver
SYSTEM
'Animation Sequence Data
' D are in 4-digit hex
' # are in 2-digit hex
' S are 1-digit hex
'
'IN OP Desc
'-- -- ----
'u S Moves # Pixels up
'd S Moves # Pixels down
'l S Moves # Pixels left
'r S Moves # Pixels right
'f # Displays Anim Frame #
'w S Wait S tenths of a second
'U S Moves # Tiles up
'D S Moves # Tiles down
'L S Moves # Tiles left
'R S Moves # Tiles right
'o S Select Object Number # 0Player,1Effect,2Effect,3Mover
's Set the Current Object down
'p Pick Up Current Obect off the map
'c # Call Anim Routine #
'x # Do sfx #
'v S Set Visibility 0Hide 1Show
't? S S Transfer Properties from S to S
' x Xcoor
' y Ycoor
' p Position
' f Anim frame
'a? S D Assign S's Property to D
' x Xcoor
' y Ycoor
AnimData:
' Walk Anims
DATA "o0f03u4x00w7 f04u4x00w7 f05u4x00w7 f04u4x00w7U1"
DATA "o0f00d4x00w7 f01d4x00w7 f02d4x00w7 f01d4x00w7D1"
DATA "o0f09l4x00w7 f0al4x00w7 f0bl4x00w7 f0al4x00w7L1"
DATA "o0f06r4x00w7 f07r4x00w7 f08r4x00w7 f07r4x00w7R1"
' Roll Anims
DATA "o0f61u4x00w4 f62u4x00w4 f63u4x00w6 f64u4x00w6 U1"
DATA "o0f65d4x00w4 f66d4x00w4 f67d4x00w6 f68d4x00w6 D1"
DATA "o0f6dl4x00w4 f6el4x00w4 f6fl4x00w6 f70l4x00w6 L1"
DATA "o0f69r4x00w4 f6ar4x00w4 f6br4x00w6 f6cr4x00w6 R1"
' Slip Anims
DATA "o0f26u4x0dw5 f27u4w5 f26u4w5 f27u4w5 U1"
DATA "o0f24d4x0dw5 f25d4w5 f24d4w5 f25d4w5 D1"
DATA "o0f22l4x0dw5 f23l4w5 f22l4w5 f23l4w5 L1"
DATA "o0f1er4x0dw5 f1fr4w5 f1er4w5 f1fr4w5 R1"
' Jump Anims
DATA "o1v0tp01u2f2bv1 o0u4f2cw2 o1u3o0f19u7w2 o1u2o0u6w2 o1u3o0u5w2 o1u2o0u4w2 o1u3o0u4w2 U1 o1u2o0u2w2 o1u3o0u1w2 o1u3w2 o1u2o0u1w2 o1u3o0d1w2 o1v0o0d1w2 U1"
DATA "o1v0tp01u2f2bv1 o0u1f18w2 o1d3o0f2du1w2 o1d2w2 o1d3o0d1w2 o1d2o0d1w2 o1d3o0d2w2 D1 o1d2o0d4w2 o1d3o0d4w2 o1d3o0d5w2 o1d2o0d6w2 o1u3o0d7w2 o1v0o0d4w2 D1"
DATA "o1v0tp01u2f2bv1 o1l2o0f1bw2f20l2u4w2 o1l3o0l3u4w2 o1l2o0l2u4w2 o1l3o0l3u2w2 o1l2o0l2u2w2 o1l3o0f21l3u1w2 L1 o1l2o0l2d1w2 o1l3o0f22l3d2w2 o1l2o0l2d2w2 o1l3o0l3d4w2 o1l2o0l2d4w2 o1v0o0l3d4w1 f1bl2w1 L1"
DATA "o1v0tp01u2f2bv1 o1r2o0f1aw2f1cr2u4w2 o1r3o0r3u4w2 o1r2o0r2u4w2 o1r3o0r3u2w2 o1r2o0r2u2w2 o1r3o0f1dr3u1w2 R1 o1r2o0r2d1w2 o1r3o0f1er3d2w2 o1r2o0r2d2w2 o1r3o0r3d4w2 o1r2o0r2d4w2 o1v0o0r3d4w1 f1ar2w1 R1"
' Push Against
DATA "o0f19w8"
DATA "o0f18w8"
DATA "o0f1bw8"
DATA "o0f1aw8"
' Stand
DATA "o0f04"
DATA "o0f01"
DATA "o0f0a"
DATA "o0f07"
' Run Anims
DATA "o0f03u4x00w4 f04u4x00w2 f05u4x00w1 f04u4x00w1U1"
DATA "o0f00d4x00w4 f01d4x00w2 f02d4x00w1 f01d4x00w1D1"
DATA "o0f09l4x00w4 f0al4x00w2 f0bl4x00w1 f0al4x00w1L1"
DATA "o0f06r4x00w4 f07r4x00w2 f08r4x00w1 f07r4x00w1R1"
' Warp
DATA "x10tp01tf01o1v1o0f28w2 f29w2 f2aw2 o1v0 o0f2aw2 o0f29w2 f28w2 v0w8"
DATA "x11tp01o0f28v1w2 f29w2 f2aw2 o1v1w2 f29w2 f28w2 tf10o1v0"
' Splash
DATA "x0e o1v1 f77w8 f76w8 f75w8 f74w8 f77w8 f76wa f75wc f74wf v0"
' Drink Ketchup
DATA "o0f2ftp01u8 o1v1f72w8x02wfwfwfwfwf v0tp10 o0f2dx09wfwf"
' Push
DATA "o0f19x01u4w6f58x01u4w6f19x01u4w6f58x01u4w6U1"
DATA "o0f18x01d4w6f57x01d4w6f18x01d4w6f57x01d4w6D1"
DATA "o0f1bx01l4w6f5ax01l4w6f1bx01l4w6f5ax01l4w6L1"
DATA "o0f1ax01r4w6f59x01r4w6f1ax01r4w6f59x01r4w6R1"
' Obj Move
DATA "o3v1u4w6u4w6u4w8u4wav0"
DATA "o3v1d4w6d4w6d4w8d4wav0"
DATA "o3v1l4w6l4w6l4w8l4wav0"
DATA "o3v1r4w6r4w6r4w8r4wav0"
' Obj Bounce
DATA "x04o2tp32u2f2bv1 o3v1u4w2 o2u3o3u7w2 o2u2 o3u6w2 o2u3 o3u5w2 o2u2 o3u4w2 o2u3 o3u4w2 U1 o2u2 o3u2w2 o2u3 o3u1w2 o2u3w2u2 o3u1w2 o2u3 o3d1w2v0 o2v0 o3v1d1w2 U1"
DATA "x04o2tp32u2f2bv1 o3v1u1w2 o2d3o3u1w2 o2d2w2 o2d3 o3d1w2 o2d2 o3d1w2 o2d3 o3d2w2 D1 o2d2 o3d4w2 o2d3 o3d4w2 o2d3 o3d5w2 o2d2 o3d6w2 o2u3 o3d7w2v0 o2v0 o3v1d4w2 D1"
DATA "x04o2tp32u2f2bv1l2 o3v1w2l2u4w2 o2l3 o3l3u4w2 o2l2 o3l2u4w2 o2l3 o3l3u2w2 o2l2 o3l2u2w2 o2l3 o3l3u1w2 L1 o2l2 o3l2d1w2 o2l3 o3l3d2w2 o2l2 o3l2d2w2 o2l3 o3l3d4w2 o2l2 o3l2d4w2v0 o2v0 o3v1l3d4w1l2w1 L1"
DATA "x04o2tp32u2f2bv1r2 o3v1w2r2u4w2 o2r3 o3r3u4w2 o2r2 o3r2u4w2 o2r3 o3r3u2w2 o2r2 o3r2u2w2 o2r3 o3r3u1w2 R1 o2r2 o3r2d1w2 o2r3 o3r3d2w2 o2r2 o3r2d2w2 o2r3 o3r3d4w2 o2r2 o3r2d4w2v0 o2v0 o3v1r3d4w1r2w1 R1"
' Obj Warp
DATA "x10tp32tf32o2v1o3f28v1w2f29w2f2aw2o2v0o3f2aw2f29w2f28w2v0w2"
DATA "x11tp32o3f28v1w2f29w2f2aw2o2v1w2f29w2f28w2tf23o2v0o3v0"
' Cannon Shoot
DATA "o4f36u4w2u4w2u4w2u4w2"
DATA "o4f36d4w2d4w2d4w2d4w2"
DATA "o4f36l4w2l4w2l4w2l4w2"
DATA "o4f36r4w2r4w2r4w2r4w2"
' Pick Up
' Drop
' Hold & Walk
' Hold & Jump
SUB boop
SOUND 300, 1
END SUB
SUB CalculateWaitTime
' x = VAL(MID$(TIME$, 7, 2))
' y& = 0
' z = VAL(MID$(TIME$, 7, 2))
' WHILE z = x
' z = VAL(MID$(TIME$, 7, 2))
' WEND
' IF (z < x) THEN x = -1
' WHILE z = x + 1
' WaitTime& = WaitTime& + 1
' z = VAL(MID$(TIME$, 7, 2))
' WEND
' WaitTime& = WaitTime& * 130
WaitTime& = 200
END SUB
FUNCTION CheckIfWin
zz = (Level.MaxHole = Level.HoleCnt)
IF zz THEN
' Show the Exit
DoSObjWarp Level.ex, Level.ey, Level.ef
END IF
END FUNCTION
'Check The Brick Ahead of the Player 1UP 2DN 3LT 4RT
'
FUNCTION ChkAheadBrk
SELECT CASE Obj(0).f
CASE 1
ChkAheadBrk = GetBrickType(Obj(0).mx, Obj(0).my - 1)
CASE 2
ChkAheadBrk = GetBrickType(Obj(0).mx, Obj(0).my + 1)
CASE 3
ChkAheadBrk = GetBrickType(Obj(0).mx - 1, Obj(0).my)
CASE 4
ChkAheadBrk = GetBrickType(Obj(0).mx + 1, Obj(0).my)
END SELECT
END FUNCTION
SUB ChkCannon
FOR n = 0 TO 19
b = GetBrickType(n, Obj(0).my)
IF b = 18 THEN ShootSmallCannon n, Obj(0).my
NEXT n
FOR i = 0 TO 10
b = GetBrickType(Obj(0).mx, i)
IF b = 18 THEN ShootSmallCannon Obj(0).mx, i
NEXT i
END SUB
FUNCTION ChkKey STATIC
k = 0
k$ = INKEY$
IF debug THEN IF k$ = CHR$(27) THEN END
IF debug THEN IF k$ = "w" THEN Roll Obj(0).f: DoLandOn zd&
IF k$ = "" THEN ChkKey = k: EXIT FUNCTION
IF ASC(k$) = 0 THEN
sc = ASC(RIGHT$(k$, 1))
SELECT CASE sc
CASE 72
k = 1
CASE 80
k = 2
CASE 75
k = 3
CASE 77
k = 4
END SELECT
ELSE
SELECT CASE k$
CASE " "
k = 5
CASE "s"
SoundOn = NOT SoundOn
CASE "-"
WaitTime& = WaitTime& + 1000
CASE "+"
WaitTime& = WaitTime& - 1000
CASE CHR$(27)
OutObj eek
CLS
LOCATE 10, 15: PRINT "[Q]uit"
LOCATE 11, 15: PRINT "[R]etry"
LOCATE 12, 15: PRINT "[C]ontinue"
DO: d$ = INKEY$: LOOP UNTIL d$ = ""
DO
DO: k$ = INKEY$: LOOP UNTIL k$ <> ""
k = INSTR("QRC", UCASE$(k$))
LOOP UNTIL k <> 0
SELECT CASE k
CASE 1
Player.Dead = True
GameOver = True
CASE 2
Player.Dead = True
CASE 3
FOR x = 0 TO 19
sy = 9
FOR y = 0 TO 10
ReplaceBrick x, y
NEXT y
sx = sx + 16
NEXT x
END SELECT
IF eek <> -1 THEN InObj eek
k = 0
END SELECT
END IF
ChkKey = k
'Cleak the rest of the Key Buffer
DO: d$ = INKEY$: LOOP UNTIL d$ = ""
END FUNCTION
SUB ClrAllObj
FOR n = 0 TO MaxObj
IF Obj(n).ObjOn THEN PUT (Obj(n).ox, Obj(n).oy + 9), ObjBkg(0, n), PSET: Obj(n).ObjOn = False
NEXT n
END SUB
SUB ClrObj (n)
IF Obj(n).ObjOn = 0 THEN EXIT SUB
'Clear Objs
FOR z = 0 TO n
IF Obj(z).ObjOn THEN PUT (Obj(z).ox, Obj(z).oy + 9), ObjBkg(0, z), PSET
NEXT z
'Turn Obj off
Obj(n).ObjOn = 0
' Re-Draw Objs
IF n > 0 THEN
FOR z = n - 1 TO 0 STEP -1
IF Obj(z).ObjOn THEN
x = Obj(z).sx
y = Obj(z).sy
i = Obj(z).Frame
Obj(z).ox = x
Obj(z).oy = y
Obj(z).oFrame = i
GET (x, y + 9)-(x + 15, y + 24), ObjBkg(0, z)
PUT (x, y + 9), ObjImg(0, i, 1), AND
PUT (x, y + 9), ObjImg(0, i, 0), OR
END IF
NEXT z
END IF
END SUB
SUB DAllObj
FOR n = MaxObj TO 0 STEP -1
x = Obj(n).sx
y = Obj(n).sy
i = Obj(n).Frame
GET (x, y + 9)-(x + 15, y + 24), ObjBkg(0, n)
PUT (x, y + 9), ObjImg(0, i, 1), AND
PUT (x, y + 9), ObjImg(0, i, 0), OR
Obj(n).ObjOn = -1
NEXT n
END SUB
SUB Dec (x, b, t)
IF x = b THEN x = t ELSE x = x - 1
END SUB
SUB Delay (x&)
FOR i& = 0 TO WaitTime&
NEXT i&
END SUB
SUB DoAnim (Seq, w)
DO
IF Anim(i).inUse = False THEN EXIT DO
i = i + 1
LOOP
Anim(i).inUse = True
Anim(i).Seq = Seq - 1
Anim(i).p = 1
Anim(i).Delay = 0
IF w THEN
DO
UAnim
LOOP UNTIL Anim(i).inUse = False
END IF
END SUB
SUB DObj (n)
'Clear Objs
FOR z = 0 TO n
IF Obj(z).ObjOn THEN PUT (Obj(z).ox, Obj(z).oy + 9), ObjBkg(0, z), PSET
NEXT z
'Turn Obj on
Obj(n).ObjOn = True
' Re-Draw Objs
FOR z = n TO 0 STEP -1
IF Obj(z).ObjOn THEN
x = Obj(z).sx
y = Obj(z).sy
i = Obj(z).Frame
Obj(z).ox = x
Obj(z).oy = y
Obj(z).oFrame = i
GET (x, y + 9)-(x + 15, y + 24), ObjBkg(0, z)
PUT (x, y + 9), ObjImg(0, i, 1), AND
PUT (x, y + 9), ObjImg(0, i, 0), OR
END IF
NEXT z
END SUB
SUB DoEnemy
END SUB
SUB DoLandOn (zd&)
'Check Current Brick
ChkCannon
b = GetBrickType(Obj(0).mx, Obj(0).my)
IF Player.Holding THEN
ELSE
SELECT CASE b
CASE 1, 15
'Wall or CrackBrk ... Fall Back
TurnObjAround 0
Roll Obj(0).f
IF GetBrickType(Obj(0).mx, Obj(0).my) = 1 THEN TurnObjAround 0
DoLandOn zd&
CASE 3
'Warp ... Warp
'Check the Cannons
ChkCannon
'WARP!
DoWarp
CASE 4
' Ice
Slip Obj(0).f
DoLandOn zd&
' Test
CASE 2, 5
ChkCannon
Jump Obj(0).f, zd&
DoLandOn zd&
CASE 9
' Ketchup
PutItem Obj(0).mx, Obj(0).my, 0
ClrObj 0
ReplaceBrick Obj(0).mx, Obj(0).my
DObj 0
DoAnim 32, True
DoLandOn zd&
CASE 7
' Beat The Level
Obj(0).Frame = 45: UAllObj
DoSound 8
Level.Won = True
SLEEP 2
CASE 8
' Weight
Inc RollDir, 1, 4
Obj(0).f = RollDir
Roll Obj(0).f
DoLandOn zd&
CASE 10
' Steelie
Obj(0).f = INT(RND * 4) + 1
Roll Obj(0).f
DoLandOn zd&
CASE 13
'Tree ... Squish it
DoSound 12
PutBrick Obj(0).mx, Obj(0).my, 16
ClrObj 0
ReplaceBrick Obj(0).mx, Obj(0).my
DObj 0
CASE 14
'Water ... Sploosh
Splash 0, Obj(0).mx, Obj(0).my
Player.Dead = True
END SELECT
END IF
END SUB
SUB DoPlayer
k = ChkKey
IF k = 0 THEN
IF Player.WillMove THEN
k = Obj(0).f
ELSE
IF NOT Player.Standing THEN
Stand Obj(0).f
Player.Standing = True
END IF
EXIT SUB
END IF
END IF
IF k = Obj(0).f THEN
IF Player.Holding THEN
ELSE
zd& = 50: ' Delay Length
'Try to move
Player.Standing = False
b = ChkAheadBrk
'Do the Action
SELECT CASE b
CASE 0
'Ground ... Walk Up
walk k
ChkCannon
CASE 1
'Wall ... Try to Push It
Push k, zd&
CASE 2
'Rubber ... ???
CASE 3
'Warp ... Warp
walk k
'Check the Cannons
ChkCannon
'WARP!
DoWarp
CASE 4
' Ice ... Walk then xfer to DoLandOn
Slip k
ChkCannon
DoLandOn zd&
CASE 5
'Trampoline
DoAnim k + 24, True
'Check Cannons
ChkCannon
Jump k, zd&
b = GetBrickType(Obj(0).mx, Obj(0).my): IF b = 1 OR b = 6 OR b = 8 OR b = 15 THEN REM TurnPlayerAround
DoLandOn zd&
CASE 7
'Exit..Beat the Level
walk k
ChkCannon
DoLandOn zd&
CASE 8
'Weight ... Push it!
PushSObj
CASE 9
'Ketchup ... Drink It!
walk k
ChkCannon
DoLandOn zd&
CASE 10
'Steelie ... Push it!
PushSObj
END SELECT
END IF
Player.WillMove = False
ELSE
IF k = 5 THEN
' Try to Flip Switch
xi = 0: yi = 0
SELECT CASE Obj(0).f
CASE 1
yi = -1
CASE 2
yi = 1
CASE 3
xi = -1
CASE 4
xi = 1
END SELECT
b = GetBrickType(Obj(0).mx + xi, Obj(0).my + yi)
IF b = 6 THEN
' It's a Switch
DoSwitch Obj(0).mx + xi, Obj(0).my + yi
END IF
ELSE
'Turn Around
zd& = 50
SELECT CASE Obj(0).f
CASE 1 TO 2
SELECT CASE k
CASE 1
Obj(0).Frame = 10: Uplayer: Delay zd&
Obj(0).Frame = 4: Uplayer: Delay zd&
CASE 2
Obj(0).Frame = 7: Uplayer: Delay zd&
Obj(0).Frame = 1: Uplayer: Delay zd&
CASE 3
Obj(0).Frame = 10: Uplayer: Delay zd&
CASE 4
Obj(0).Frame = 7: Uplayer: Delay zd&
END SELECT
CASE 3 TO 4
SELECT CASE k
CASE 1
Obj(0).Frame = 4: Uplayer: Delay zd&
CASE 2
Obj(0).Frame = 1: Uplayer: Delay zd&
CASE 3
Obj(0).Frame = 1: Uplayer: Delay zd&
Obj(0).Frame = 10: Uplayer: Delay zd&
CASE 4
Obj(0).Frame = 4: Uplayer: Delay zd&
Obj(0).Frame = 7: Uplayer: Delay zd&
END SELECT
END SELECT
Obj(0).f = k
Player.WillMove = True
END IF
END IF
END SUB
SUB DoSObjLandOn (x, y, o)
zz = GetItem(x, y): PutItem x, y, 0
IF o <> 0 THEN PutItem x, y, o
b = GetBrickType(x, y): ReplaceBrick x, y
SELECT CASE b
CASE 1
'Wall ... Roll Back
Obj(3).Frame = 64 - zz
Obj(3).mx = x
Obj(3).my = y
Obj(3).sx = Obj(3).mx * 16
Obj(3).sy = Obj(3).my * 16
TurnObjAround 3
DoAnim 36 + Obj(3).f, True
SELECT CASE Obj(3).f
CASE 1
y = y - 1
CASE 2
y = y + 1
CASE 3
x = x - 1
CASE 4
x = x + 1
END SELECT
oo = GetItem(x, y)
PutItem x, y, zz
ClrObj 3
ReplaceBrick x, y
IF GetBrickType(x, y) = 1 THEN TurnObjAround 3
DoLandOn zd&
DoSObjLandOn x, y, oo
CASE 8
' Weight
Inc RollDir, 1, 4
Obj(3).f = RollDir
Obj(3).Frame = 64 - zz
Obj(3).mx = x
Obj(3).my = y
Obj(3).sx = Obj(3).mx * 16
Obj(3).sy = Obj(3).my * 16
DoAnim 36 + Obj(3).f, True
SELECT CASE Obj(3).f
CASE 1
y = y - 1
CASE 2
y = y + 1
CASE 3
x = x - 1
CASE 4
x = x + 1
END SELECT
oo = GetItem(x, y)
PutItem x, y, zz
ClrObj 3
ReplaceBrick x, y
IF GetBrickType(x, y) = 1 THEN TurnObjAround 3
DoLandOn zd&
DoSObjLandOn x, y, oo
CASE 10
' Steelie
Obj(3).f = INT(RND * 4) + 1
Obj(3).Frame = 64 - zz
Obj(3).mx = x
Obj(3).my = y
Obj(3).sx = Obj(3).mx * 16
Obj(3).sy = Obj(3).my * 16
DoAnim 36 + Obj(3).f, True
SELECT CASE Obj(3).f
CASE 1
y = y - 1
CASE 2
y = y + 1
CASE 3
x = x - 1
CASE 4
x = x + 1
END SELECT
oo = GetItem(x, y)
PutItem x, y, zz
ClrObj 3
ReplaceBrick x, y
IF GetBrickType(x, y) = 1 THEN TurnObjAround 3
DoLandOn zd&
DoSObjLandOn x, y, oo
CASE 3
' Warp ... Warp duh
DoSObjWarp x, y, zz
DoLandOn zd&
CASE 5, 2
' Trampoline ... Bounce
Obj(3).Frame = 64 - zz
Obj(3).mx = x
Obj(3).my = y
Obj(3).sx = Obj(3).mx * 16
Obj(3).sy = Obj(3).my * 16
DoAnim 40 + Obj(3).f, True
SELECT CASE Obj(3).f
CASE 1
y = y - 2
CASE 2
y = y + 2
CASE 3
x = x - 2
CASE 4
x = x + 2
END SELECT
oo = GetItem(x, y)
PutItem x, y, zz
ReplaceBrick x, y
DoLandOn zd&
DoSObjLandOn x, y, oo
CASE 4
' Ice ... Slip
Obj(3).Frame = 64 - zz
Obj(3).mx = x
Obj(3).my = y
Obj(3).sx = Obj(3).mx * 16
Obj(3).sy = Obj(3).my * 16
DoSound 13
DoAnim 36 + Obj(3).f, True
SELECT CASE Obj(3).f
CASE 1
y = y - 1
CASE 2
y = y + 1
CASE 3
x = x - 1
CASE 4
x = x + 1
END SELECT
oo = GetItem(x, y)
PutItem x, y, zz
ClrObj 3
ReplaceBrick x, y
DoLandOn zd&
DoSObjLandOn x, y, oo
CASE 13
'Tree ... Squish it
DoSound 12
PutItem x, y, zz
PutBrick x, y, 16
ClrObj 3
ReplaceBrick x, y
CASE 14
Splash 3, x, y
CASE 17
' Chk if Steelie
IF zz = 1 THEN
' Fill in the hole
oo = GetItem(x, y)
PutBrick x, y, 6
DoSound 1
Level.HoleCnt = Level.HoleCnt + 1
ClrObj 3
ClrObj 2
ReplaceBrick x, y
dummy = CheckIfWin
IF oo <> 0 THEN DoSObjLandOn x, y, oo
ELSE
'Just Sit There
oo = GetItem(x, y)
PutItem x, y, zz
ClrObj 3
ReplaceBrick x, y
IF oo <> 0 THEN DoSObjLandOn x, y, oo
END IF
CASE ELSE
oo = GetItem(x, y)
PutItem x, y, zz
ClrObj 3
ReplaceBrick x, y
IF oo <> 0 THEN DoSObjLandOn x, y, oo
END SELECT
END SUB
SUB DoSObjWarp (x, y, zz)
i = 0
DO
IF Warp(i, 0) = x AND Warp(i, 1) = y THEN EXIT DO
i = i + 1
LOOP UNTIL i = 9
IF i = 9 THEN
WarpIn = True
END IF
Obj(3).Frame = 64 - zz
Obj(3).mx = x
Obj(3).my = y
Obj(3).sx = Obj(3).mx * 16
Obj(3).sy = Obj(3).my * 16
IF WarpIn = False THEN
DoAnim 45, True
'Check the type of warp
IF Level.wt = 0 THEN
even = (i MOD 2) - 1
IF even THEN i = i + 1 ELSE i = i - 1
ELSE
Inc i, 0, 8
END IF
'Warp Coors
wx = Warp(i, 0)
wy = Warp(i, 1)
'Warp Marble If There
b = GetBrickType(wx, wy)
IF b = 8 OR b = 10 THEN
z2 = GetItem(wx, wy): PutItem wx, wy, 0: ReplaceBrick wx, wy
DoSObjWarp (wx), (wy), (z2)
END IF
Obj(3).mx = wx
Obj(3).my = wy
Obj(3).sx = Obj(3).mx * 16
Obj(3).sy = Obj(3).my * 16
x = wx
y = wy
END IF
'Reappear
DoAnim 46, True
PutItem x, y, zz
ReplaceBrick x, y
END SUB
SUB DoSound (snd) STATIC
IF NOT SoundOn THEN EXIT SUB
SELECT CASE snd
CASE 0
' Step
s$ = "T255mso1l64c"
p = 0
CASE 1
' Thump
s$ = "T255L64O1ep32dp32cp32"
p = 1
CASE 2
' Drink
s$ = "T255L16O1aa#b a#b>c <b>cc# cc#d c#dd# dd#e a"
p = 100
CASE 3
' Pick Up
s$ = "t255l64o1cp64cp64cp64cp64cp64cp64cp64cp64cp4l32>cc#dd#eff#"
p = 100
CASE 4
' Bounce
s$ = "t255l32p16o1cc#dd#eff#gg#"
p = 50
CASE 5
' Drop
s$ = "t225l32o2d#dc#c<ba#ap12l64o1cp64cp64cp64cp64c"
p = 50
CASE 6
' Chink (Change Switch)
s$ = "t255l64o1co3co6d#o3ao1co3co4d#o3a"
p = 50
CASE 7
' Walk Down
s$ = "t222l64o1d#p32d#p32d#p32d#p8dp32dp32dp32dp8c#p32c#p32c#p32c#p8cp32cp32cp32cp32"
p = 100
CASE 8
' End
s$ = "t90 l16o2c l32d# l16e l24a# l16g l24f l16f# l24g l16>c l8<b >c"
p = 150
CASE 9
' Item
s$ = "t190l16o3efg>l8c<g"
p = 100
CASE 10
' Bump
s$ = "t255l32o1cc#dd#ecc#d"
p = 1
CASE 11
' Walk Up
s$ = "t222l64o1cp32cp32cp32cp8c#p32c#p32c#p32c#p8dp32dp32dp32dp8d#p32d#p32d#p32d#p32"
p = 100
CASE 12
' Smash
s$ = "t255l64o2cn0c#n0dn0c#n2cn0<dn0c#n2cn0dn0c#n2cn0"
p = 1
CASE 13
' Slip
s$ = "t255l24o2c>c#<d>d#<e>f<f#>g<g#"
p = 1
CASE 14
' Splash
s$ = "t255l64ms"
FOR i = 0 TO 20
s$ = s$ + "N" + STR$(INT(RND * 84))
NEXT i
p = 150
CASE 15
'Cannon Shoot
s$ = "t255l64ms"
FOR i = 0 TO 20
s$ = s$ + "N" + STR$(INT(RND * 30))
NEXT i
p = 1
CASE 16
'Warp In
s$ = "t255l64o3p60cegb>c#fg#>cegb"