-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathBank $84.asm
15138 lines (12942 loc) · 612 KB
/
Bank $84.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
;;; $8000..86B3: Routines ;;;
{
;;; $8000: Golden Torizo health-based palette handling ;;;
{
;; Parameter:
;; A: Health. Assumed to be less than 8000h
; This is a great way to start the PLM bank
$84:8000 DA PHX
$84:8001 5A PHY
$84:8002 8B PHB
$84:8003 4B PHK ;\
$84:8004 AB PLB ;} DB = $84
$84:8005 EB XBA ;\
$84:8006 29 78 00 AND #$0078 ;|
$84:8009 89 40 00 BIT #$0040 ;|
$84:800C F0 03 BEQ $03 [$8011] ;|
$84:800E A9 38 00 LDA #$0038 ;|
;} Y = min(7, [A] / 800h) * 20h + 1Eh (source index)
$84:8011 0A ASL A ;|
$84:8012 0A ASL A ;|
$84:8013 09 1E 00 ORA #$001E ;|
$84:8016 A8 TAY ;/
$84:8017 A2 1E 00 LDX #$001E ; X = 1Eh (destination index)
; LOOP
$84:801A B9 32 81 LDA $8132,y[$84:8210] ;\
$84:801D 9F 40 C1 7E STA $7EC140,x[$7E:C15E];} Sprite palette 2 + [X] = [$8132 + [Y]]
$84:8021 B9 32 80 LDA $8032,y[$84:8110] ;\
$84:8024 9F 20 C1 7E STA $7EC120,x[$7E:C13E];} Sprite palette 1 + [X] = [$8032 + [Y]]
$84:8028 88 DEY ;\
$84:8029 88 DEY ;} Y -= 2
$84:802A CA DEX ;\
$84:802B CA DEX ;} X -= 2
$84:802C 10 EC BPL $EC [$801A] ; If [X] >= 0: go to LOOP
$84:802E AB PLB
$84:802F 7A PLY
$84:8030 FA PLX
$84:8031 6B RTL
; Golden Torizo palette 1
$84:8032 dw 1000, 56BA, 41B2, 1447, 0403, 4E15, 3570, 24CB, 1868, 6F7F, 51F8, 410E, 031F, 01DA, 00F5, 0C63, ; 0..7FFh
1000, 56DB, 39D3, 1047, 0403, 4636, 2D91, 20EC, 1489, 6F9B, 5215, 3D2C, 133B, 0DF6, 0CF2, 0C63, ; 800h..FFFh
1000, 52FB, 31F4, 1067, 0402, 3E76, 25B2, 192D, 10A9, 6F96, 5251, 396A, 2756, 1A13, 190F, 0863, ; 1000h..17FFh
1000, 531C, 2A15, 0C67, 0402, 3697, 1DD3, 154E, 0CCA, 6FB2, 526E, 3588, 3772, 262F, 250C, 0863, ; 1800h..1FFFh
1000, 4F5C, 1E56, 0888, 0001, 2EB8, 1A13, 116F, 0CEB, 73AD, 4EAA, 35A6, 4B8D, 364B, 3509, 0443, ; 2000h..27FFh
1000, 4F7D, 1677, 0488, 0001, 26D9, 1234, 0D90, 090C, 73C9, 4EC7, 31C4, 5BA9, 4267, 4106, 0443, ; 2800h..2FFFh
1000, 4B9D, 0E98, 04A8, 0000, 1F19, 0A55, 05D1, 052C, 73C4, 4F03, 2E02, 6FC4, 4E84, 4D23, 0043, ; 3000h..37FFh
0000, 4BBE, 06B9, 00A8, 0000, 173A, 0276, 01F2, 014D, 73E0, 4F20, 2A20, 7FE0, 5AA0, 5920, 0043 ; 3800h+
; Golden Torizo palette 2
$84:8132 dw 1000, 4215, 2D0D, 0002, 0000, 3970, 20CB, 0C26, 0403, 463A, 28B3, 1809, 6F7F, 51FD, 4113, 0C63, ; 0..7FFh
1000, 4236, 252E, 0002, 0000, 3191, 1CEC, 0C47, 0424, 4656, 28D0, 1428, 6F7B, 51F9, 40F0, 0C63, ; 800h..FFFh
1000, 3E56, 214F, 0002, 0000, 29D1, 190D, 0888, 0424, 4693, 290E, 1046, 6F76, 4DF5, 40EE, 0842, ; 1000h..17FFh
1000, 3E77, 1970, 0002, 0000, 21F2, 152E, 08A9, 0445, 46AF, 292B, 0C65, 6F72, 4DF1, 40CB, 0842, ; 1800h..1FFFh
1000, 3AB7, 15B1, 0003, 0000, 1A13, 0D6E, 04CA, 0066, 4ACB, 2568, 0C84, 6B4D, 4A0C, 44C8, 0421, ; 2000h..27FFh
1000, 3AD8, 0DD2, 0003, 0000, 1234, 098F, 04EB, 0087, 4AE7, 2585, 08A3, 6B49, 4A08, 44A5, 0421, ; 2800h..2FFFh
1000, 36F8, 09F3, 0003, 0000, 0A74, 05B0, 012C, 0087, 4B24, 25C3, 04C1, 6B44, 4604, 44A3, 0000, ; 3000h..37FFh
1000, 3719, 0214, 0003, 0000, 0295, 01D1, 014D, 00A8, 4B40, 25E0, 00E0, 6B40, 4600, 4480, 0000 ; 3800h+
}
;;; $8232: Load room PLM GFX ;;;
{
; Called as part of unpausing
; The call to $8764 *should* be done with the PLM index in X,
; which is where the PLM's $7E:DF0C variable is written
; In the case of unpausing, this variable doesn't need to be written again,
; but this does mean that the PLM with indexes 0/2/4/6 get their $7E:DF0C variable clobbered
$84:8232 08 PHP
$84:8233 8B PHB
$84:8234 C2 30 REP #$30
$84:8236 4B PHK ;\
$84:8237 AB PLB ;} DB = $84
$84:8238 9C 2D 1C STZ $1C2D [$7E:1C2D] ; PLM item GFX index = 0
$84:823B A2 00 00 LDX #$0000 ; X = 0 (item PLM index)
; LOOP
$84:823E DA PHX
$84:823F BC 2F 1C LDY $1C2F,x[$7E:1C2F] ; Y = [item PLM GFX pointers]
$84:8242 20 64 87 JSR $8764 [$84:8764] ; Load item PLM GFX
$84:8245 FA PLX
$84:8246 E8 INX ;\
$84:8247 E8 INX ;} X += 2 (next item PLM)
$84:8248 E0 08 00 CPX #$0008 ;\
$84:824B D0 F1 BNE $F1 [$823E] ;} If [X] != 8: go to LOOP
$84:824D AB PLB
$84:824E 28 PLP
$84:824F 6B RTL
}
;;; $8250: Clear sounds when going through door ;;;
{
; Called at start of door transition
$84:8250 A9 1D 00 LDA #$001D ;\
$84:8253 22 84 F0 90 JSL $90F084[$90:F084] ;} Run Samus command - clear sounds when going through door
$84:8257 6B RTL
}
;;; $8258: Unused. Clear spin jump sound when going through door ;;;
{
$84:8258 AD 1E 0A LDA $0A1E [$7E:0A1E] ;\
$84:825B 29 00 FF AND #$FF00 ;|
$84:825E C9 00 03 CMP #$0300 ;} If not spin jumping:
$84:8261 F0 05 BEQ $05 [$8268] ;/
$84:8263 C9 00 14 CMP #$1400 ;\
$84:8266 D0 07 BNE $07 [$826F] ;} If not wall jumping: return
$84:8268 A9 32 00 LDA #$0032 ;\
$84:826B 22 21 90 80 JSL $809021[$80:9021] ;} Queue sound 32h, sound library 1, max queued sounds allowed = 15 (spin jump end)
$84:826F 6B RTL
}
;;; $8270: Play spin jump sound if spin jumping ;;;
{
; Called at end of door transition
$84:8270 A9 1C 00 LDA #$001C ;\
$84:8273 22 84 F0 90 JSL $90F084[$90:F084] ;} Run Samus command - play spin jump sound if spin jumping
$84:8277 6B RTL
}
;;; $8278: Unused. Play resumed spin jump sound ;;;
{
$84:8278 AD 1E 0A LDA $0A1E [$7E:0A1E] ;\
$84:827B 29 00 FF AND #$FF00 ;|
$84:827E C9 00 03 CMP #$0300 ;} If not spin jumping:
$84:8281 F0 05 BEQ $05 [$8288] ;/
$84:8283 C9 00 14 CMP #$1400 ;\
$84:8286 D0 07 BNE $07 [$828F] ;} If not wall jumping: return
$84:8288 A9 30 00 LDA #$0030 ;\
$84:828B 22 21 90 80 JSL $809021[$80:9021] ;} Queue sound 30h, sound library 1, max queued sounds allowed = 15 (resumed spin jump)
$84:828F 6B RTL
}
;;; $8290: Calculate PLM block co-ordinates ;;;
{
;; Parameters:
;; X: PLM index
$84:8290 BD 87 1C LDA $1C87,x[$7E:1CD3] ;\
$84:8293 4A LSR A ;|
$84:8294 8D 04 42 STA $4204 ;|
$84:8297 E2 20 SEP #$20 ;|
$84:8299 AD A5 07 LDA $07A5 [$7E:07A5] ;|
$84:829C 8D 06 42 STA $4206 ;|
$84:829F C2 20 REP #$20 ;|
$84:82A1 EA NOP ;} PLM Y block = [PLM block index] / 2 / [room width in blocks]
$84:82A2 EA NOP ;|
$84:82A3 EA NOP ;|
$84:82A4 EA NOP ;|
$84:82A5 EA NOP ;|
$84:82A6 EA NOP ;|
$84:82A7 AD 14 42 LDA $4214 ;|
$84:82AA 8D 2B 1C STA $1C2B [$7E:1C2B] ;/
$84:82AD AD 16 42 LDA $4216 ;\
$84:82B0 8D 29 1C STA $1C29 [$7E:1C29] ;} PLM X block = [PLM block index] / 2 % [room width in blocks]
$84:82B3 6B RTL
}
;;; $82B4: Write level data block type and BTS ;;;
{
;; Parameter:
;; A low: BTS
;; A high: High byte of level data
;; X: PLM block index
$84:82B4 DA PHX
$84:82B5 85 12 STA $12 [$7E:0012] ;\
$84:82B7 E2 20 SEP #$20 ;|
$84:82B9 BF 03 00 7F LDA $7F0003,x[$7F:2D3F];|
$84:82BD 29 0F AND #$0F ;} (PLM block type) = [A high] / 10h
$84:82BF 05 13 ORA $13 [$7E:0013] ;|
$84:82C1 9F 03 00 7F STA $7F0003,x[$7F:2D3F];|
$84:82C5 C2 20 REP #$20 ;/
$84:82C7 8A TXA ;\
$84:82C8 4A LSR A ;|
$84:82C9 AA TAX ;|
$84:82CA E2 20 SEP #$20 ;} PLM BTS = [A low]
$84:82CC A5 12 LDA $12 [$7E:0012] ;|
$84:82CE 9F 02 64 7F STA $7F6402,x[$7F:7AA0];|
$84:82D2 C2 20 REP #$20 ;/
$84:82D4 FA PLX
$84:82D5 60 RTS
}
;;; $82D6: Write row of level data block and BTS ;;;
{
;; Parameters:
;; X: PLM index
;; [[S] + 1] + 1: Level data block
;; [[S] + 1] + 3: BTS
;; [[S] + 1] + 5: Number of blocks
$84:82D6 DA PHX
$84:82D7 5A PHY
$84:82D8 A0 01 00 LDY #$0001 ;\
$84:82DB B3 05 LDA ($05,s),y[$84:AD46];} $12 = [(return address) + 1] (level data block)
$84:82DD 85 12 STA $12 [$7E:0012] ;/
$84:82DF C8 INY ;\
$84:82E0 C8 INY ;|
$84:82E1 B3 05 LDA ($05,s),y[$84:AD48];} $14 = [(return address) + 3] (BTS)
$84:82E3 85 14 STA $14 [$7E:0014] ;/
$84:82E5 C8 INY ;\
$84:82E6 C8 INY ;|
$84:82E7 B3 05 LDA ($05,s),y[$84:AD4A];} $16 = [(return address) + 5] (number of blocks)
$84:82E9 85 16 STA $16 [$7E:0016] ;/
$84:82EB A3 05 LDA $05,s [$7E:1FEE] ;\
$84:82ED 18 CLC ;|
$84:82EE 69 06 00 ADC #$0006 ;} (Return address) += 6
$84:82F1 83 05 STA $05,s [$7E:1FEE] ;/
$84:82F3 BD 87 1C LDA $1C87,x[$7E:1CD5] ;\
$84:82F6 AA TAX ;} X = [PLM block index]
$84:82F7 4A LSR A
$84:82F8 48 PHA
$84:82F9 A5 12 LDA $12 [$7E:0012]
$84:82FB A4 16 LDY $16 [$7E:0016] ; Y = (number of blocks)
; LOOP_LEVEL_DATA
$84:82FD 9F 02 00 7F STA $7F0002,x[$7F:048A]; $7F:0002 + [X] = (level data block)
$84:8301 E8 INX ;\
$84:8302 E8 INX ;} X += 2 (next block)
$84:8303 88 DEY ; Decrement Y
$84:8304 D0 F7 BNE $F7 [$82FD] ; If [Y] != 0: go to LOOP_LEVEL_DATA
$84:8306 E2 20 SEP #$20
$84:8308 FA PLX ; X = [PLM block index] / 2
$84:8309 A5 14 LDA $14 [$7E:0014]
$84:830B A4 16 LDY $16 [$7E:0016] ; Y = (number of blocks)
; LOOP_BTS
$84:830D 9F 02 64 7F STA $7F6402,x[$7F:6646]; $7F:6402 + [X] = (BTS)
$84:8311 E8 INX ; Increment X (next block)
$84:8312 88 DEY ; Decrement Y
$84:8313 D0 F8 BNE $F8 [$830D] ; If [Y] != 0: go to LOOP_BTS
$84:8315 C2 20 REP #$20
$84:8317 7A PLY
$84:8318 FA PLX
$84:8319 60 RTS
}
;;; $831A: Load item x-ray blocks (also load room special x-ray blocks) ;;;
{
; Note that any new PLMs created in the free space in this bank will be considered to be an "item PLM",
; meaning the PLM argument specified in the PLM populations will be used as a unique ID in the picked up items table ($7E:D870)
; and won't show an x-ray block if they've been "picked up".
; Note that these same PLMs are expected to have $7E:DF0C,x set to a 'PLM item GFX index',
; which is an index (2k for k in 0..7) to the table of draw instruction pointers responsible for drawing the x-ray tile
$84:831A 08 PHP
$84:831B 8B PHB
$84:831C C2 30 REP #$30
$84:831E DA PHX
$84:831F 5A PHY
$84:8320 4B PHK ;\
$84:8321 AB PLB ;} DB = $84
$84:8322 A2 4E 00 LDX #$004E ; X = 4Eh (PLM index)
; LOOP_PLM
$84:8325 BD 37 1C LDA $1C37,x[$7E:1C85] ;\
$84:8328 C9 89 DF CMP #$DF89 ;} If not an item PLM: go to BRANCH_NEXT
$84:832B 90 32 BCC $32 [$835F] ;/
$84:832D DA PHX
$84:832E BD C7 1D LDA $1DC7,x[$7E:1E0F] ;\
$84:8331 30 2C BMI $2C [$835F] ;} If [PLM room argument] is negative: go to BRANCH_NEXT (doesn't PLX, will crash)
$84:8333 22 8E 81 80 JSL $80818E[$80:818E] ;\
$84:8337 BF 70 D8 7E LDA $7ED870,x[$7E:D870];|
$84:833B FA PLX ;} If nth item is picked up (n = [PLM room argument]): go to BRANCH_NEXT
$84:833C 2D E7 05 AND $05E7 [$7E:05E7] ;|
$84:833F D0 1E BNE $1E [$835F] ;/
$84:8341 DA PHX
$84:8342 22 90 82 84 JSL $848290[$84:8290] ; Calculate PLM block co-ordinates
$84:8346 BF 0C DF 7E LDA $7EDF0C,x[$7E:DF52];\
$84:834A A8 TAY ;|
$84:834B BE 9D 83 LDX $839D,y[$84:83A7] ;} A = [[$839D + [PLM item GFX index]] + 2] & FFFh
$84:834E BD 02 00 LDA $0002,x[$84:A2F3] ;|
$84:8351 29 FF 0F AND #$0FFF ;/
$84:8354 AE 29 1C LDX $1C29 [$7E:1C29] ;\
$84:8357 AC 2B 1C LDY $1C2B [$7E:1C2B] ;} Load block [A] to x-ray BG2 tilemap at ([PLM X block], [PLM Y block])
$84:835A 22 4C D0 91 JSL $91D04C[$91:D04C] ;/
$84:835E FA PLX
; BRANCH_NEXT
$84:835F CA DEX ;\
$84:8360 CA DEX ;} X -= 2
$84:8361 10 C2 BPL $C2 [$8325] ; If [X] >= 0: go to LOOP_PLM
$84:8363 AE BB 07 LDX $07BB [$7E:07BB] ;\
$84:8366 BF 10 00 8F LDA $8F0010,x[$8F:941B];} If (special x-ray blocks pointer) = 0: return
$84:836A F0 2C BEQ $2C [$8398] ;/
$84:836C AA TAX ; X = (special x-ray blocks pointer)
; LOOP_ROOMVAR
$84:836D BF 00 00 8F LDA $8F0000,x ;\
$84:8371 F0 25 BEQ $25 [$8398] ;} If [$8F:0000 + [X]] = 0: return
$84:8373 29 FF 00 AND #$00FF ;\
$84:8376 85 12 STA $12 [$7E:0012] ;} $12 = [$8F:0000 + [X]] & FFh
$84:8378 BF 01 00 8F LDA $8F0001,x ;\
$84:837C 29 FF 00 AND #$00FF ;} $14 = [$8F:0000 + [X] + 1] & FFh
$84:837F 85 14 STA $14 [$7E:0014] ;/
$84:8381 DA PHX
$84:8382 BF 02 00 8F LDA $8F0002,x ; A = [$8F:0000 + [X] + 2]
$84:8386 A6 12 LDX $12 [$7E:0012] ;\
$84:8388 A4 14 LDY $14 [$7E:0014] ;} Load block [A] to x-ray BG2 tilemap at ([$12], [$14])
$84:838A 22 4C D0 91 JSL $91D04C[$91:D04C] ;/
$84:838E FA PLX
$84:838F 8A TXA ;\
$84:8390 18 CLC ;|
$84:8391 69 04 00 ADC #$0004 ;} X += 4
$84:8394 AA TAX ;/
$84:8395 4C 6D 83 JMP $836D [$84:836D] ; Go to LOOP_ROOMVAR
$84:8398 7A PLY
$84:8399 FA PLX
$84:839A AB PLB
$84:839B 28 PLP
$84:839C 6B RTL
; Pointers to x-ray block drawing instructions
$84:839D dw A30F, ;\
A31B, ;|
A327, ;} Misc. items in loaded order
A333, ;/
A2DF, ; Energy tank
A2F1, ; Missile tank
A2FD, ; Super missile tank
A303 ; Power bomb tank
}
;;; $83AD: Enable PLMs ;;;
{
$84:83AD 08 PHP
$84:83AE C2 20 REP #$20
$84:83B0 A9 00 80 LDA #$8000
$84:83B3 0C 23 1C TSB $1C23 [$7E:1C23]
$84:83B6 28 PLP
$84:83B7 6B RTL
}
;;; $83B8: Disable PLMs ;;;
{
$84:83B8 08 PHP
$84:83B9 C2 20 REP #$20
$84:83BB A9 00 80 LDA #$8000
$84:83BE 1C 23 1C TRB $1C23 [$7E:1C23]
$84:83C1 28 PLP
$84:83C2 6B RTL
}
;;; $83C3: Clear PLMs ;;;
{
$84:83C3 08 PHP
$84:83C4 C2 30 REP #$30
$84:83C6 DA PHX
$84:83C7 A2 4E 00 LDX #$004E ;\
;|
$84:83CA 9E 37 1C STZ $1C37,x[$7E:1C85] ;|
$84:83CD CA DEX ;} PLM IDs = 0
$84:83CE CA DEX ;|
$84:83CF 10 F9 BPL $F9 [$83CA] ;/
$84:83D1 9C 2D 1C STZ $1C2D [$7E:1C2D] ; PLM item GFX index = 0
$84:83D4 FA PLX
$84:83D5 28 PLP
$84:83D6 6B RTL
}
;;; $83D7: Spawn hard-coded PLM ;;;
{
;; Parameters:
;; [[S] + 1] + 1: X position
;; [[S] + 1] + 2: Y position
;; [[S] + 1] + 3: PLM ID
;; Returns:
;; Carry: set if PLM could not be spawned
; Must be called from lorom bank
$84:83D7 8B PHB
$84:83D8 5A PHY
$84:83D9 DA PHX
$84:83DA 4B PHK ;\
$84:83DB AB PLB ;} DB = $84
$84:83DC A0 4E 00 LDY #$004E ; Y = 4Eh (PLM index)
; LOOP
$84:83DF B9 37 1C LDA $1C37,y[$7E:1C85] ;\
$84:83E2 F0 11 BEQ $11 [$83F5] ;} If [PLM ID] = 0: go to BRANCH_FOUND
$84:83E4 88 DEY ;\
$84:83E5 88 DEY ;} Y -= 2
$84:83E6 10 F7 BPL $F7 [$83DF] ; If [Y] >= 0: go to LOOP
$84:83E8 A3 06 LDA $06,s ;\
$84:83EA 18 CLC ;|
$84:83EB 69 04 00 ADC #$0004 ;} (Return address) += 4
$84:83EE 83 06 STA $06,s ;/
$84:83F0 FA PLX
$84:83F1 7A PLY
$84:83F2 AB PLB
$84:83F3 38 SEC ;\
$84:83F4 6B RTL ;} Return carry set
; BRANCH_FOUND
$84:83F5 E2 20 SEP #$20
$84:83F7 A3 08 LDA $08,s [$7E:1FF6] ;\
$84:83F9 48 PHA ;} DB = (caller bank)
$84:83FA AB PLB ;/
$84:83FB BB TYX ;\
$84:83FC A0 02 00 LDY #$0002 ;|
$84:83FF B3 06 LDA ($06,s),y[$80:A11F];|
$84:8401 8D 02 42 STA $4202 ;|
$84:8404 AD A5 07 LDA $07A5 [$7E:07A5] ;|
$84:8407 8D 03 42 STA $4203 ;|
$84:840A A0 01 00 LDY #$0001 ;|
$84:840D B3 06 LDA ($06,s),y[$80:A11E];} PLM block index = ([(return address) + 1] * [room width] + [(return address) + 2]) * 2
$84:840F C2 20 REP #$20 ;|
$84:8411 29 FF 00 AND #$00FF ;|
$84:8414 18 CLC ;|
$84:8415 6D 16 42 ADC $4216 ;|
$84:8418 0A ASL A ;|
$84:8419 9D 87 1C STA $1C87,x[$7E:1CD5] ;/
$84:841C A0 03 00 LDY #$0003 ;\
$84:841F B3 06 LDA ($06,s),y[$80:A120];} A = [(return address) + 3] (PLM ID)
$84:8421 9B TXY
$84:8422 AA TAX
$84:8423 A3 06 LDA $06,s [$7E:1FF4] ;\
$84:8425 18 CLC ;|
$84:8426 69 04 00 ADC #$0004 ;} Adjust return address
$84:8429 83 06 STA $06,s [$7E:1FF4] ;/
$84:842B 4B PHK ;\
$84:842C AB PLB ;} DB = $84
$84:842D 8A TXA
$84:842E 99 37 1C STA $1C37,y[$7E:1C85] ; PLM ID = [A]
$84:8431 BB TYX
$84:8432 A8 TAY
$84:8433 A9 00 00 LDA #$0000
$84:8436 9D C7 1D STA $1DC7,x[$7E:1E15] ; PLM room argument = 0
$84:8439 9F 0C DF 7E STA $7EDF0C,x[$7E:DF5A]; PLM $7E:DF0C = 0
$84:843D A9 69 84 LDA #$8469 ;\
$84:8440 9D D7 1C STA $1CD7,x[$7E:1D25] ;} PLM pre-instruction = RTS
$84:8443 B9 02 00 LDA $0002,y[$84:B7ED] ;\
$84:8446 9D 27 1D STA $1D27,x[$7E:1D75] ;} PLM instruction list pointer = [[PLM ID] + 2]
$84:8449 A9 01 00 LDA #$0001 ;\
$84:844C 9F 1C DE 7E STA $7EDE1C,x[$7E:DE6A];} PLM instruction timer = 1
$84:8450 A9 A0 8D LDA #$8DA0 ;\
$84:8453 9F 6C DE 7E STA $7EDE6C,x[$7E:DEBA];} PLM draw instruction pointer = $8DA0
$84:8457 9E 77 1D STZ $1D77,x[$7E:1DC5] ; PLM $1D77 = 0
$84:845A 8E 27 1C STX $1C27 [$7E:1C27] ;\
$84:845D BB TYX ;} PLM index = [Y]
$84:845E AC 27 1C LDY $1C27 [$7E:1C27] ;/
$84:8461 FC 00 00 JSR ($0000,x)[$84:B7C3]; Execute [[PLM ID]] (PLM setup)
$84:8464 FA PLX
$84:8465 7A PLY
$84:8466 AB PLB
$84:8467 18 CLC ;\
$84:8468 6B RTL ;} Return carry clear
$84:8469 60 RTS
}
;;; $846A: Spawn room PLM ;;;
{
;; Parameters:
;; X: Pointer to room PLM entry
;; [X]: PLM ID
;; [X] + 2: PLM X block
;; [X] + 3: PLM Y block
;; [X] + 4: PLM room argument
;; Returns:
;; Carry: set if PLM could not be spawned
$84:846A 08 PHP
$84:846B 8B PHB
$84:846C 5A PHY
$84:846D DA PHX
$84:846E 4B PHK ;\
$84:846F AB PLB ;} DB = $84
$84:8470 A0 4E 00 LDY #$004E ; Y = 4Eh (PLM index)
; LOOP
$84:8473 B9 37 1C LDA $1C37,y[$7E:1C85] ;\
$84:8476 F0 0A BEQ $0A [$8482] ;} If [PLM ID] = 0: go to BRANCH_FOUND
$84:8478 88 DEY ;\
$84:8479 88 DEY ;} Y -= 2
$84:847A 10 F7 BPL $F7 [$8473] ; If [Y] >= 0: go to LOOP
$84:847C FA PLX
$84:847D 7A PLY
$84:847E AB PLB
$84:847F 28 PLP
$84:8480 38 SEC ;\
$84:8481 6B RTL ;} Return carry set
; BRANCH_FOUND
$84:8482 E2 20 SEP #$20
$84:8484 BF 03 00 8F LDA $8F0003,x[$8F:8003];\
$84:8488 8D 02 42 STA $4202 ;|
$84:848B AD A5 07 LDA $07A5 [$7E:07A5] ;|
$84:848E 8D 03 42 STA $4203 ;|
$84:8491 BF 02 00 8F LDA $8F0002,x[$8F:8002];|
$84:8495 C2 20 REP #$20 ;} PLM block index = [$8F:0003 + [X]] * [room width] + [$8F:8002 + [X]]
$84:8497 29 FF 00 AND #$00FF ;|
$84:849A 18 CLC ;|
$84:849B 6D 16 42 ADC $4216 ;|
$84:849E 0A ASL A ;|
$84:849F 99 87 1C STA $1C87,y[$7E:1CD5] ;/
$84:84A2 BF 04 00 8F LDA $8F0004,x[$8F:8004];\
$84:84A6 99 C7 1D STA $1DC7,y[$7E:1E15] ;} PLM room argument = [$8F:0004 + [X]]
$84:84A9 BF 00 00 8F LDA $8F0000,x[$8F:8000];\
$84:84AD 99 37 1C STA $1C37,y[$7E:1C85] ;} PLM ID = [$8F:0000 + [X]]
$84:84B0 BB TYX
$84:84B1 A8 TAY
$84:84B2 A9 00 00 LDA #$0000 ;\
$84:84B5 9F 0C DF 7E STA $7EDF0C,x[$7E:DF5A];} PLM $7E:DF0C = 0
$84:84B9 A9 E6 84 LDA #$84E6 ;\
$84:84BC 9D D7 1C STA $1CD7,x[$7E:1D25] ;} PLM pre-instruction = RTS
$84:84BF B9 02 00 LDA $0002,y[$84:B705] ;\
$84:84C2 9D 27 1D STA $1D27,x[$7E:1D75] ;} PLM instruction list pointer = [[PLM ID] + 2]
$84:84C5 A9 01 00 LDA #$0001 ;\
$84:84C8 9F 1C DE 7E STA $7EDE1C,x[$7E:DE6A];} PLM instruction timer = 1
$84:84CC A9 A0 8D LDA #$8DA0 ;\
$84:84CF 9F 6C DE 7E STA $7EDE6C,x[$7E:DEBA];} PLM draw instruction pointer = $8DA0
$84:84D3 9E 77 1D STZ $1D77,x[$7E:1DC5] ; PLM $1D77 = 0
$84:84D6 8E 27 1C STX $1C27 [$7E:1C27] ;\
$84:84D9 BB TYX ;} PLM index = [Y]
$84:84DA AC 27 1C LDY $1C27 [$7E:1C27] ;/
$84:84DD FC 00 00 JSR ($0000,x)[$84:B371]; Execute [[PLM ID]] (PLM setup)
$84:84E0 FA PLX
$84:84E1 7A PLY
$84:84E2 AB PLB
$84:84E3 28 PLP
$84:84E4 18 CLC ;\
$84:84E5 6B RTL ;} Return carry clear
$84:84E6 60 RTS
}
;;; $84E7: Spawn PLM (to current block index) ;;;
{
;; Parameter:
;; A: PLM ID
;; Returns:
;; Carry: If PLM is not spawned, carry is unchanged. Otherwise set according to PLM setup, or clear if PLM setup doesn't change the carry (thanks to the lucky ASL at $8500)
$84:84E7 8B PHB
$84:84E8 5A PHY
$84:84E9 DA PHX
$84:84EA 4B PHK ;\
$84:84EB AB PLB ;} DB = $84
$84:84EC A8 TAY ; Y = [A]
$84:84ED A2 4E 00 LDX #$004E ; X = 4Eh (PLM index)
; LOOP
$84:84F0 BD 37 1C LDA $1C37,x[$7E:1C85] ;\
$84:84F3 F0 08 BEQ $08 [$84FD] ;} If [PLM ID] = 0: go to BRANCH_FOUND
$84:84F5 CA DEX ;\
$84:84F6 CA DEX ;} X -= 2
$84:84F7 10 F7 BPL $F7 [$84F0] ; If [X] >= 0: go to LOOP
$84:84F9 FA PLX
$84:84FA 7A PLY
$84:84FB AB PLB
$84:84FC 6B RTL ; Return
; BRANCH_FOUND
$84:84FD AD C4 0D LDA $0DC4 [$7E:0DC4] ;\
$84:8500 0A ASL A ;} PLM block index = [current block index] * 2
$84:8501 9D 87 1C STA $1C87,x[$7E:1CCF] ;/
$84:8504 98 TYA ;\
$84:8505 9D 37 1C STA $1C37,x[$7E:1C7F] ;} PLM ID = [Y]
$84:8508 A9 3D 85 LDA #$853D ;\
$84:850B 9D D7 1C STA $1CD7,x[$7E:1D1F] ;} PLM pre-instruction = RTS
$84:850E B9 02 00 LDA $0002,y[$84:C8AA] ;\
$84:8511 9D 27 1D STA $1D27,x[$7E:1D6F] ;} PLM instruction list pointer = [[PLM ID] + 2]
$84:8514 A9 01 00 LDA #$0001 ;\
$84:8517 9F 1C DE 7E STA $7EDE1C,x[$7E:DE64];} PLM instruction timer = 1
$84:851B A9 A0 8D LDA #$8DA0 ;\
$84:851E 9F 6C DE 7E STA $7EDE6C,x[$7E:DEB4];} PLM draw instruction pointer = $8DA0
$84:8522 A9 00 00 LDA #$0000
$84:8525 9D 77 1D STA $1D77,x[$7E:1DBF] ; PLM $1D77 = 0
$84:8528 9D C7 1D STA $1DC7,x[$7E:1E0F] ; PLM room argument = 0
$84:852B 9F 0C DF 7E STA $7EDF0C,x[$7E:DF54]; PLM $7E:DF0C = 0
$84:852F 8E 27 1C STX $1C27 [$7E:1C27] ;\
$84:8532 BB TYX ;} PLM index = [Y]
$84:8533 AC 27 1C LDY $1C27 [$7E:1C27] ;/
$84:8536 FC 00 00 JSR ($0000,x)[$84:C7BB]; Execute [[PLM ID]] (PLM setup)
$84:8539 FA PLX
$84:853A 7A PLY
$84:853B AB PLB
$84:853C 6B RTL
$84:853D 60 RTS
}
;;; $853E: Unused. Spawn enemy PLM ;;;
{
;; Parameters:
;; A: PLM ID
;; X: Enemy index
$84:853E 8B PHB
$84:853F 5A PHY
$84:8540 DA PHX
$84:8541 4B PHK ;\
$84:8542 AB PLB ;} DB = $84
$84:8543 9B TXY ; Y = [X]
$84:8544 48 PHA
$84:8545 A2 4E 00 LDX #$004E ; X = 4Eh (PLM index)
; LOOP
$84:8548 BD 37 1C LDA $1C37,x ;\
$84:854B F0 09 BEQ $09 [$8556] ;} If [PLM ID] = 0: go to BRANCH_FOUND
$84:854D CA DEX ;\
$84:854E CA DEX ;} X -= 2
$84:854F 10 F7 BPL $F7 [$8548] ; If [X] >= 0: go to LOOP
$84:8551 68 PLA
$84:8552 FA PLX
$84:8553 7A PLY
$84:8554 AB PLB
$84:8555 6B RTL ; Return
; BRANCH_FOUND
$84:8556 B9 7E 0F LDA $0F7E,y ;\
$84:8559 4A LSR A ;|
$84:855A 4A LSR A ;|
$84:855B 4A LSR A ;|
$84:855C 4A LSR A ;|
$84:855D E2 20 SEP #$20 ;|
$84:855F 8D 02 42 STA $4202 ;|
$84:8562 AD A5 07 LDA $07A5 [$7E:07A5] ;|
$84:8565 8D 03 42 STA $4203 ;|
$84:8568 C2 20 REP #$20 ;} PLM block index = [enemy Y position] / 10h * [room width] + [enemy X position] / 10h
$84:856A B9 7A 0F LDA $0F7A,y ;|
$84:856D 4A LSR A ;|
$84:856E 4A LSR A ;|
$84:856F 4A LSR A ;|
$84:8570 4A LSR A ;|
$84:8571 18 CLC ;|
$84:8572 6D 16 42 ADC $4216 ;|
$84:8575 0A ASL A ;|
$84:8576 9D 87 1C STA $1C87,x ;/
$84:8579 68 PLA
$84:857A 9D 37 1C STA $1C37,x ; PLM ID = [A]
$84:857D A8 TAY
$84:857E A9 B3 85 LDA #$85B3 ;\
$84:8581 9D D7 1C STA $1CD7,x ;} PLM pre-instruction = RTS
$84:8584 B9 02 00 LDA $0002,y ;\
$84:8587 9D 27 1D STA $1D27,x ;} PLM instruction list pointer = [[PLM ID] + 2]
$84:858A A9 01 00 LDA #$0001 ;\
$84:858D 9F 1C DE 7E STA $7EDE1C,x ;} PLM instruction timer = 1
$84:8591 A9 A0 8D LDA #$8DA0 ;\
$84:8594 9F 6C DE 7E STA $7EDE6C,x ;} PLM draw instruction pointer = $8DA0
$84:8598 A9 00 00 LDA #$0000
$84:859B 9D 77 1D STA $1D77,x ; PLM $1D77 = 0
$84:859E 9D C7 1D STA $1DC7,x ; PLM room argument = 0
$84:85A1 9F 0C DF 7E STA $7EDF0C,x ; PLM $7E:DF0C = 0
$84:85A5 8E 27 1C STX $1C27 [$7E:1C27] ;\
$84:85A8 BB TYX ;} PLM index = [Y]
$84:85A9 AC 27 1C LDY $1C27 [$7E:1C27] ;/
$84:85AC FC 00 00 JSR ($0000,x) ; Execute [[PLM ID]] (PLM setup)
$84:85AF FA PLX
$84:85B0 7A PLY
$84:85B1 AB PLB
$84:85B2 6B RTL
$84:85B3 60 RTS
}
;;; $85B4: PLM handler ;;;
{
$84:85B4 08 PHP
$84:85B5 8B PHB
$84:85B6 4B PHK ;\
$84:85B7 AB PLB ;} DB = $84
$84:85B8 C2 30 REP #$30
$84:85BA 2C 23 1C BIT $1C23 [$7E:1C23] ;\
$84:85BD 10 18 BPL $18 [$85D7] ;} If PLMs not enabled: return
$84:85BF 9C 25 1C STZ $1C25 [$7E:1C25] ; PLM draw tilemap index = 0
$84:85C2 A2 4E 00 LDX #$004E ; X = 4Eh (PLM index)
; LOOP
$84:85C5 8E 27 1C STX $1C27 [$7E:1C27] ; PLM index = [X]
$84:85C8 BD 37 1C LDA $1C37,x[$7E:1C85] ;\
$84:85CB F0 06 BEQ $06 [$85D3] ;} If [PLM ID] != 0:
$84:85CD 20 DA 85 JSR $85DA [$84:85DA] ; Process PLM
$84:85D0 AE 27 1C LDX $1C27 [$7E:1C27] ; X = [PLM index]
$84:85D3 CA DEX ;\
$84:85D4 CA DEX ;} X -= 2
$84:85D5 10 EE BPL $EE [$85C5] ; If [X] >= 0: go to LOOP
$84:85D7 AB PLB
$84:85D8 28 PLP
$84:85D9 6B RTL
}
;;; $85DA: Process PLM ;;;
{
;; Parameter:
;; X: PLM index
; Some instructions (e.g. sleep) pop the return address pushed to the stack by $85F7 to return out of *this* routine
; (marked "terminate processing PLM")
$84:85DA FC D7 1C JSR ($1CD7,x)[$84:B7DD]; Execute PLM pre-instruction
$84:85DD AE 27 1C LDX $1C27 [$7E:1C27] ; X = [PLM index]
$84:85E0 BF 1C DE 7E LDA $7EDE1C,x[$7E:DE6A];\
$84:85E4 3A DEC A ;} Decrement PLM instruction timer
$84:85E5 9F 1C DE 7E STA $7EDE1C,x[$7E:DE6A];/
$84:85E9 D0 32 BNE $32 [$861D] ; If [PLM instruction timer] != 0: return
$84:85EB BC 27 1D LDY $1D27,x[$7E:1D75] ; Y = [PLM instruction list pointer]
; LOOP
$84:85EE B9 00 00 LDA $0000,y[$84:B7E9] ;\
$84:85F1 10 0A BPL $0A [$85FD] ;} If [[Y]] & 8000h != 0:
$84:85F3 85 12 STA $12 [$7E:0012] ; $12 = [[Y]] (ASM instruction pointer)
$84:85F5 C8 INY ;\
$84:85F6 C8 INY ;} Y += 2
$84:85F7 F4 ED 85 PEA $85ED ; Return to LOOP
$84:85FA 6C 12 00 JMP ($0012)[$84:86B4] ; Execute (ASM instruction pointer)
$84:85FD 9F 1C DE 7E STA $7EDE1C,x[$7E:DE68]; PLM instruction timer = [[Y]] (draw timer)
$84:8601 B9 02 00 LDA $0002,y[$84:C1AA] ;\
$84:8604 9F 6C DE 7E STA $7EDE6C,x[$7E:DEB8];} PLM draw instruction pointer = [[Y] + 2]
$84:8608 98 TYA ;\
$84:8609 18 CLC ;|
$84:860A 69 04 00 ADC #$0004 ;} PLM instruction list pointer = [Y] + 4
$84:860D 9D 27 1D STA $1D27,x[$7E:1D73] ;/
$84:8610 20 1E 86 JSR $861E [$84:861E] ; Process PLM draw instruction
$84:8613 AE 27 1C LDX $1C27 [$7E:1C27] ; X = [PLM index]
$84:8616 22 90 82 84 JSL $848290[$84:8290] ; Calculate PLM block co-ordinates
$84:861A 20 AA 8D JSR $8DAA [$84:8DAA] ; Draw PLM
$84:861D 60 RTS
}
;;; $861E: Process PLM draw instruction ;;;
{
;; Parameter:
;; X: PLM index
$84:861E BF 6C DE 7E LDA $7EDE6C,x[$7E:DEB8];\
$84:8622 A8 TAY ;} Y = [PLM draw instruction pointer]
$84:8623 BD 87 1C LDA $1C87,x[$7E:1CD3] ;\
$84:8626 85 12 STA $12 [$7E:0012] ;} X = $12 = [PLM block index]
$84:8628 AA TAX ;/
; LOOP_DRAW_ENTRY
$84:8629 B9 00 00 LDA $0000,y[$84:A827] ;\
$84:862C 30 19 BMI $19 [$8647] ;} If [[Y]] & 8000h: go to BRANCH_COLUMN
$84:862E 29 FF 00 AND #$00FF ;\
$84:8631 85 16 STA $16 [$7E:0016] ;} $16 = [[Y]] & FFh (number of blocks)
$84:8633 C8 INY ;\
$84:8634 C8 INY ;} Y += 2
; LOOP_ROW
$84:8635 B9 00 00 LDA $0000,y[$84:AA39] ;\
$84:8638 9F 02 00 7F STA $7F0002,x[$7F:304E];} $7F:0002 + [X] = [[Y]] (write level data)
$84:863C C8 INY ;\
$84:863D C8 INY ;} Y += 2
$84:863E E8 INX ;\
$84:863F E8 INX ;} X += 2
$84:8640 C6 16 DEC $16 [$7E:0016] ; Decrement $16
$84:8642 D0 F1 BNE $F1 [$8635] ; If [$16] != 0: go to LOOP_ROW
$84:8644 4C 64 86 JMP $8664 [$84:8664] ; Go to BRANCH_NEXT
; BRANCH_COLUMN
$84:8647 29 FF 00 AND #$00FF ;\
$84:864A 85 16 STA $16 [$7E:0016] ;} $16 = [[Y]] & FFh (number of blocks)
$84:864C C8 INY ;\
$84:864D C8 INY ;} Y += 2
; LOOP_COLUMN
$84:864E B9 00 00 LDA $0000,y[$84:A829] ;\
$84:8651 9F 02 00 7F STA $7F0002,x[$7F:4FDE];} $7F:0002 + [X] = [[Y]] (write level data)
$84:8655 C8 INY ;\
$84:8656 C8 INY ;} Y += 2
$84:8657 8A TXA ;\
$84:8658 18 CLC ;|
$84:8659 6D A5 07 ADC $07A5 [$7E:07A5] ;} X += [room width] * 2
$84:865C 6D A5 07 ADC $07A5 [$7E:07A5] ;|
$84:865F AA TAX ;/
$84:8660 C6 16 DEC $16 [$7E:0016] ; Decrement $16
$84:8662 D0 EA BNE $EA [$864E] ; If [$16] != 0: go to LOOP_COLUMN
; BRANCH_NEXT
$84:8664 B9 00 00 LDA $0000,y[$84:A831] ;\
$84:8667 D0 01 BNE $01 [$866A] ;} If [[Y]] = 0: return
$84:8669 60 RTS ;/
$84:866A 88 DEY ; Decrement Y
$84:866B B9 00 00 LDA $0000,y[$84:9F28] ;\
$84:866E EB XBA ;|
$84:866F 10 05 BPL $05 [$8676] ;|
$84:8671 09 00 FF ORA #$FF00 ;|
$84:8674 80 03 BRA $03 [$8679] ;|
;|
$84:8676 29 FF 00 AND #$00FF ;} $14 = [PLM block index] + ±[[Y] + 1] * 2
;|
$84:8679 0A ASL A ;|
$84:867A 18 CLC ;|
$84:867B 65 12 ADC $12 [$7E:0012] ;|
$84:867D 85 14 STA $14 [$7E:0014] ;/
$84:867F B9 01 00 LDA $0001,y[$84:9F29] ;\
$84:8682 EB XBA ;|
$84:8683 10 14 BPL $14 [$8699] ;|
$84:8685 09 00 FF ORA #$FF00 ;|
$84:8688 49 FF FF EOR #$FFFF ;|
$84:868B 1A INC A ;|
$84:868C AA TAX ;|
$84:868D A9 00 00 LDA #$0000 ;|
;|
$84:8690 38 SEC ;|
$84:8691 ED A5 07 SBC $07A5 [$7E:07A5] ;|
$84:8694 CA DEX ;|
$84:8695 D0 F9 BNE $F9 [$8690] ;|
$84:8697 80 10 BRA $10 [$86A9] ;|
;} $14 += ±[[Y] + 2] * [room width] * 2
$84:8699 29 FF 00 AND #$00FF ;|
$84:869C F0 0B BEQ $0B [$86A9] ;|
$84:869E AA TAX ;|
$84:869F A9 00 00 LDA #$0000 ;|
;|
$84:86A2 18 CLC ;|
$84:86A3 6D A5 07 ADC $07A5 [$7E:07A5] ;|
$84:86A6 CA DEX ;|
$84:86A7 D0 F9 BNE $F9 [$86A2] ;|
;|
$84:86A9 0A ASL A ;|
$84:86AA 18 CLC ;|
$84:86AB 65 14 ADC $14 [$7E:0014] ;/
$84:86AD AA TAX ; X = [$14]
$84:86AE C8 INY ;\
$84:86AF C8 INY ;} Y += 3
$84:86B0 C8 INY ;/
$84:86B1 4C 29 86 JMP $8629 [$84:8629] ; Go to LOOP_DRAW_ENTRY
}
}
;;; $86B4..8D96: Instructions ;;;
{
;;; $86B4: Instruction - sleep ;;;
{
;; Parameters:
;; X: PLM index
;; Y: Pointer to after this instruction
$84:86B4 88 DEY ;\
$84:86B5 88 DEY ;|
$84:86B6 98 TYA ;} PLM instruction list pointer = [Y] - 2
$84:86B7 9D 27 1D STA $1D27,x[$7E:1D75] ;/
$84:86BA 68 PLA ; Terminate processing PLM
$84:86BB 60 RTS
}
;;; $86BC: Instruction - delete ;;;
{
;; Parameters:
;; X: PLM index
$84:86BC 9E 37 1C STZ $1C37,x[$7E:1C85] ; PLM ID = 0
$84:86BF 68 PLA ; Terminate processing PLM
$84:86C0 60 RTS
}
;;; $86C1: Instruction - pre-instruction = [[Y]] ;;;
{
;; Parameters:
;; X: PLM index
;; Y: Pointer to instruction arguments
;; Returns:
;; Y: Pointer to next instruction
$84:86C1 B9 00 00 LDA $0000,y[$84:C1A6]
$84:86C4 9D D7 1C STA $1CD7,x[$7E:1D23]
$84:86C7 C8 INY
$84:86C8 C8 INY
$84:86C9 60 RTS
}
;;; $86CA: Instruction - clear pre-instruction ;;;
{
;; Parameters:
;; X: PLM index
$84:86CA A9 D0 86 LDA #$86D0
$84:86CD 9D D7 1C STA $1CD7,x[$7E:1D25]
$84:86D0 60 RTS
}
;;; $86D1: Unused. Instruction - call function [[Y]] ;;;
{
;; Parameters:
;; Y: Pointer to instruction arguments
;; Returns:
;; Y: Pointer to next instruction
$84:86D1 B9 00 00 LDA $0000,y
$84:86D4 85 12 STA $12 [$7E:0012]
$84:86D6 B9 01 00 LDA $0001,y
$84:86D9 85 13 STA $13 [$7E:0013]
$84:86DB 5A PHY
$84:86DC 22 E8 86 84 JSL $8486E8[$84:86E8]
$84:86E0 7A PLY
$84:86E1 AE 27 1C LDX $1C27 [$7E:1C27]
$84:86E4 C8 INY
$84:86E5 C8 INY
$84:86E6 C8 INY
$84:86E7 60 RTS
$84:86E8 DC 12 00 JML [$0012]
}
;;; $86EB: Unused. Instruction - call function [[Y]] with A = [[Y] + 3] ;;;
{
;; Parameters:
;; Y: Pointer to instruction arguments
;; Returns:
;; Y: Pointer to next instruction
$84:86EB B9 00 00 LDA $0000,y
$84:86EE 85 12 STA $12 [$7E:0012]
$84:86F0 B9 01 00 LDA $0001,y
$84:86F3 85 13 STA $13 [$7E:0013]
$84:86F5 B9 03 00 LDA $0003,y
$84:86F8 5A PHY
$84:86F9 22 08 87 84 JSL $848708[$84:8708]
$84:86FD 7A PLY
$84:86FE AE 27 1C LDX $1C27 [$7E:1C27]
$84:8701 98 TYA
$84:8702 18 CLC
$84:8703 69 05 00 ADC #$0005
$84:8706 A8 TAY
$84:8707 60 RTS
$84:8708 DC 12 00 JML [$0012]
}
;;; $870B: Instruction - call function [[Y]] ;;;
{
;; Parameters:
;; Y: Pointer to instruction arguments
;; Returns:
;; Y: Pointer to next instruction
$84:870B B9 00 00 LDA $0000,y[$84:E72C]
$84:870E 85 12 STA $12 [$7E:0012]
$84:8710 B9 01 00 LDA $0001,y[$84:E72D]
$84:8713 85 13 STA $13 [$7E:0013]
$84:8715 DA PHX
$84:8716 5A PHY
$84:8717 22 21 87 84 JSL $848721[$84:8721]
$84:871B 7A PLY
$84:871C FA PLX
$84:871D C8 INY
$84:871E C8 INY
$84:871F C8 INY
$84:8720 60 RTS
$84:8721 DC 12 00 JML [$0012][$91:D4E4]
}
;;; $8724: Instruction - go to [[Y]] ;;;
{
;; Parameters:
;; Y: Pointer to instruction arguments
;; Returns:
;; Y: Pointer to next instruction
$84:8724 B9 00 00 LDA $0000,y[$84:AF90]
$84:8727 A8 TAY
$84:8728 60 RTS
}
;;; $8729: Unused. Instruction - go to [Y] + ±[[Y]] ;;;
{
;; Parameters:
;; Y: Pointer to instruction arguments
;; Returns:
;; Y: Pointer to next instruction
$84:8729 84 12 STY $12 [$7E:0012]
$84:872B 88 DEY
$84:872C B9 00 00 LDA $0000,y
$84:872F EB XBA
$84:8730 30 05 BMI $05 [$8737]
$84:8732 29 FF 00 AND #$00FF
$84:8735 80 03 BRA $03 [$873A]
$84:8737 09 00 FF ORA #$FF00
$84:873A 18 CLC
$84:873B 65 12 ADC $12 [$7E:0012]