-
Notifications
You must be signed in to change notification settings - Fork 0
/
chaos.ctl
4771 lines (4359 loc) · 159 KB
/
chaos.ctl
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
; define macros
@ $7D00 expand=#DEF(#DPEEK(a) #EVAL(((#PEEK($a+1))*$100)+#PEEK$a))
@ $7D00 expand=#DEF(#SIGNED(a) #IF($a>127)(-#EVAL(256-$a),$a))
@ $7D00 expand=#DEF(#MPRINTLINK(a) #R#(#DPEEK(#EVAL($CDD3+($a*4)))))
@ $7D00 expand=#DEF(#MTWOPRINTLINK(a) #R#(#DPEEK(#EVAL($8809+($a*4)))))
@ $7D00 expand=#DEF(#SPRITE(a) #UDGARRAY#(2,#PEEK($a+2),4;#DPEEK($a)-#EVAL(#DPEEK($a)+$1F)-8))
@ $7D00 expand=#DEF(#SOUNDEFFECT()(a) #AUDIO(/sounds/$a))
@ $7D00 label=start
c $7D00 Start.
C $7D00 Jump to main game routine.
@ $7D03 label=unknown01
g $7D03 unknown01
@ $7D04 label=routine01
c $7D04 routine01
C $7D04 Return if #R$7D03 is less than 6.
C $7D0A Temporarily store address of #R$E01F(map area object code table) in #R$AC12 variable.
C $7D10 Load B with 159 as loop counter.
C $7D12 Stack loop counter.
C $7D13 Load byte from cell in #R$E01F(map area object code table) into A.
C $7D14 Jump to #R$7D3B if byte is less than 2 or greater than 33.
C $7D1E Add $0281 to address to get address of same cell in #R$E2A0.
C $7D22 Load byte from #R$E2A0 into A.
C $7D23 Subtract 41 from byte read.
C $7D25 Jump to #R$7D3B if result is equal to #R$AC0E variable.
C $7D2B Load address of cell in #R$E01F(map area object code table) back into HL from #R$AC12 variable and add $01E1 to get address of same cell in #R$E200.
C $7D32 Load byte from #R$E200 into A.
C $7D33 Mod 8.
C $7D35 Jump to #R$7D52 if result is equal to #R$AC0E variable.
C $7D3B Pop loop counter.
C $7D3C Increment #R$AC12 variable.
C $7D43 Loop back to #R$7D12 158 times.
C $7D45 Set HL to address of #R$AC1E.
C $7D48 Add value of #R$AC0E variable as offset.
C $7D4F Store $14 in byte pointed to by HL and return.
C $7D52 Pop loop counter.
C $7D53 Set HL to address of #R$AC1E.
C $7D5B Add value of #R$AC0E variable as offset.
C $7D5D Store $00 in byte pointed to by HL and return.
; macro to print out spell data
@ $E440 expand=#DEF(#SPELLDATA Message $#N(#PEEK(#PC)) (#MPRINTLINK(#PEEK(#PC))), Casting chance=#PEEK(#PC+1), Max distance=#EVAL(#PEEK(#PC+2)/2), Chaos/Law=#SIGNED(#PEEK(#PC+3)), ???=#PEEK(#PC+4))
@ $7D60 label=spells_table
b $7D60 Spells table.
D $7D60 5 bytes of spell data followed by address of spell routine.
B $7D60,5 Spell $01: #SPELLDATA
W $7D65,2
B $7D67,5 Spell $02: #SPELLDATA
W $7D6C,2
B $7D6E,5 Spell $03: #SPELLDATA
W $7D73,2
B $7D75,5 Spell $04: #SPELLDATA
W $7D7A,2
B $7D7C,5 Spell $05: #SPELLDATA
W $7D81,2
B $7D83,5 Spell $06: #SPELLDATA
W $7D88,2
B $7D8A,5 Spell $07: #SPELLDATA
W $7D8F,2
B $7D91,5 Spell $08: #SPELLDATA
W $7D96,2
B $7D98,5 Spell $09: #SPELLDATA
W $7D9D,2
B $7D9F,5 Spell $0A: #SPELLDATA
W $7DA4,2
B $7DA6,5 Spell $0B: #SPELLDATA
W $7DAB,2
B $7DAD,5 Spell $0C: #SPELLDATA
W $7DB2,2
B $7DB4,5 Spell $0D: #SPELLDATA
W $7DB9,2
B $7DBB,5 Spell $0E: #SPELLDATA
W $7DC0,2
B $7DC2,5 Spell $0F: #SPELLDATA
W $7DC7,2
B $7DC9,5 Spell $10: #SPELLDATA
W $7DCE,2
B $7DD0,5 Spell $11: #SPELLDATA
W $7DD5,2
B $7DD7,5 Spell $12: #SPELLDATA
W $7DDC,2
B $7DDE,5 Spell $13: #SPELLDATA
W $7DE3,2
B $7DE5,5 Spell $14: #SPELLDATA
W $7DEA,2
B $7DEC,5 Spell $15: #SPELLDATA
W $7DF1,2
B $7DF3,5 Spell $16: #SPELLDATA
W $7DF8,2
B $7DFA,5 Spell $17: #SPELLDATA
W $7DFF,2
B $7E01,5 Spell $18: #SPELLDATA
W $7E06,2
B $7E08,5 Spell $19: #SPELLDATA
W $7E0D,2
B $7E0F,5 Spell $1A: #SPELLDATA
W $7E14,2
B $7E16,5 Spell $1B: #SPELLDATA
W $7E1B,2
B $7E1D,5 Spell $1C: #SPELLDATA
W $7E22,2
B $7E24,5 Spell $1D: #SPELLDATA
W $7E29,2
B $7E2B,5 Spell $1E: #SPELLDATA
W $7E30,2
B $7E32,5 Spell $1F: #SPELLDATA
W $7E37,2
B $7E39,5 Spell $20: #SPELLDATA
W $7E3E,2
B $7E40,5 Spell $21: #SPELLDATA
W $7E45,2
B $7E47,5 Spell $22: #SPELLDATA
W $7E4C,2
B $7E4E,5 Spell $23: #SPELLDATA
W $7E53,2
B $7E55,5 Spell $24: #SPELLDATA
W $7E5A,2
B $7E5C,5 Spell $25: #SPELLDATA
W $7E61,2
B $7E63,5 Spell $26: #SPELLDATA
W $7E68,2
B $7E6A,5 Spell $27: #SPELLDATA
W $7E6F,2
B $7E71,5 Spell $28: #SPELLDATA
W $7E76,2
B $7E78,5 Spell $29: #SPELLDATA
W $7E7D,2
B $7E7F,5 Spell $2A: #SPELLDATA
W $7E84,2
B $7E86,5 Spell $2B: #SPELLDATA
W $7E8B,2
B $7E8D,5 Spell $2C: #SPELLDATA
W $7E92,2
B $7E94,5 Spell $2D: #SPELLDATA
W $7E99,2
B $7E9B,5 Spell $2E: #SPELLDATA
W $7EA0,2
B $7EA2,5 Spell $2F: #SPELLDATA
W $7EA7,2
B $7EA9,5 Spell $30: #SPELLDATA
W $7EAE,2
B $7EB0,5 Spell $31: #SPELLDATA
W $7EB5,2
B $7EB7,5 Spell $32: #SPELLDATA
W $7EBC,2
B $7EBE,5 Spell $33: #SPELLDATA
W $7EC3,2
B $7EC5,5 Spell $34: #SPELLDATA
W $7ECA,2
B $7ECC,5 Spell $35: #SPELLDATA
W $7ED1,2
B $7ED3,5 Spell $36: #SPELLDATA
W $7ED8,2
B $7EDA,5 Spell $37: #SPELLDATA
W $7EDF,2
B $7EE1,5 Spell $38: #SPELLDATA
W $7EE6,2
B $7EE8,5 Spell $39: #SPELLDATA
W $7EED,2
B $7EEF,5 Spell $3A: #SPELLDATA
W $7EF4,2
B $7EF6,5 Spell $3B: #SPELLDATA
W $7EFB,2
B $7EFD,5 Spell $3C: #SPELLDATA
W $7F02,2
B $7F04,5 Spell $3D: #SPELLDATA
W $7F09,2
B $7F0B,5 Spell $3E: #SPELLDATA
W $7F10,2
B $7F12,5 Spell $3F: #SPELLDATA
W $7F17,2
B $7F19,5 Spell $40: #SPELLDATA
W $7F1E,2
B $7F20,5 Spell $41: #SPELLDATA
W $7F25,2
@ $7F27 label=s_cursor_sprite
b $7F27 S cursor sprite data.
B $7F27,$20,8 #HTML(#UDGARRAY2,,4;$7F27-$7F46-8(scursorsprite) )S cursor.
@ $7F47 label=possesssed_spell_tables
g $7F47 Table of possessed spells.
D $7F47 20 pairs of bytes containing ??? followed by spell number.
B $7F47,$28 wizard 1
B $7F6F,$28 wizard 2
B $7F97,$28 wizard 3
B $7FBF,$28 wizard 4
B $7FE7,$28 wizard 5
B $800F,$28 wizard 6
B $8037,$28 wizard 7
B $805F,$28 wizard 8
u $8087
b $80B0 Modified wizard sprites data.
@ $80B0 label=modwizardsprite0
B $80B0,$20 #HTML(#UDGARRAY2,,4;$80B0-$80CF-8(modwizardsprite0*)) modwizardsprite0.
@ $80D0 label=modwizardsprite1
B $80D0,$20 #HTML(#UDGARRAY2,,4;$80D0-$80EF-8(modwizardsprite1*)) modwizardsprite1.
@ $80F0 label=modwizardsprite2
B $80F0,$20 #HTML(#UDGARRAY2,,4;$80F0-$810F-8(modwizardsprite2*)) modwizardsprite2.
@ $8110 label=modwizardsprite3
B $8110,$20 #HTML(#UDGARRAY2,,4;$8110-$812F-8(modwizardsprite3*)) modwizardsprite3.
@ $8130 label=modwizardsprite4
B $8130,$20 #HTML(#UDGARRAY2,,4;$8130-$814F-8(modwizardsprite4*)) modwizardsprite4.
@ $8150 label=modwizardsprite5
B $8150,$20 #HTML(#UDGARRAY2,,4;$8150-$816F-8(modwizardsprite5*)) modwizardsprite5.
@ $8170 label=modwizardsprite6
B $8170,$20 #HTML(#UDGARRAY2,,4;$8170-$818F-8(modwizardsprite6*)) modwizardsprite6.
@ $8190 label=modwizardsprite7
B $8190,$20 #HTML(#UDGARRAY2,,4;$8190-$81AF-8(modwizardsprite7*)) modwizardsprite7.
@ $81B0 label=modwizardsprite8
B $81B0,$20 #HTML(#UDGARRAY2,,4;$81B0-$81CF-8(modwizardsprite8*)) modwizardsprite8.
@ $81D0 label=modwizardsprite9
B $81D0,$20 #HTML(#UDGARRAY2,,4;$81D0-$81EF-8(modwizardsprite9*)) modwizardsprite9.
@ $81F0 label=modwizardspriteA
B $81F0,$20 #HTML(#UDGARRAY2,,4;$81F0-$820F-8(modwizardspriteA*)) modwizardspriteA.
@ $8210 label=modwizardspriteB
B $8210,$20 #HTML(#UDGARRAY2,,4;$8210-$822F-8(modwizardspriteB*)) modwizardspriteB.
@ $8230 label=modwizardspriteC
B $8230,$20 #HTML(#UDGARRAY2,,4;$8230-$824F-8(modwizardspriteC*)) modwizardspriteC.
@ $8250 label=modwizardspriteD
B $8250,$20 #HTML(#UDGARRAY2,,4;$8250-$826F-8(modwizardspriteD*)) modwizardspriteD.
@ $8270 label=modwizardspriteE
B $8270,$20 #HTML(#UDGARRAY2,,4;$8270-$828F-8(modwizardspriteE*)) modwizardspriteE.
w $8290 Table of pointers to modified wizard sprites.
@ $8290 label=modwizard_pointers_1
W $8290 #HTML(#UDGARRAY*modwizardsprite0;modwizardsprite1;modwizardsprite2;modwizardsprite1(modwizard0121)) Animation cycle modwizard 0,1,2,1.
@ $8298 label=modwizard_pointers_2
W $8298 #HTML(#UDGARRAY*modwizardsprite3;modwizardsprite4;modwizardsprite5;modwizardsprite4(modwizard3454)) Animation cycle modwizard 3,4,5,4.
@ $82A0 label=modwizard_pointers_3
W $82A0 #HTML(#UDGARRAY*modwizardsprite6(modwizardsprite6)) Animation cycle modwizard 6,6,6,6.
@ $82A8 label=modwizard_pointers_4
W $82A8 #HTML(#UDGARRAY*modwizardsprite7(modwizardsprite7)) Animation cycle modwizard 7,7,7,7.
@ $82B0 label=modwizard_pointers_5
W $82B0 #HTML(#UDGARRAY*modwizardsprite8;modwizardsprite9;modwizardspriteA;modwizardsprite9(modwizard89A9)) Animation cycle modwizard 8,9,A,9.
@ $82B8 label=modwizard_pointers_6
W $82B8 #HTML(#UDGARRAY*modwizardspriteB;modwizardspriteC;modwizardspriteD;modwizardspriteE(modwizardBCDE)) Animation cycle modwizard B,C,D,E.
w $82C0 Table of pointers to character sprite data.
@ $82C0 label=character_1_sprite_pointers
W $82C0 Character 1.
@ $82C8 label=character_2_sprite_pointers
W $82C8 Character 2.
@ $82D0 label=character_3_sprite_pointers
W $82D0 Character 3.
@ $82D8 label=character_4_sprite_pointers
W $82D8 Character 4.
@ $82E0 label=character_5_sprite_pointers
W $82E0 Character 5.
@ $82E8 label=character_6_sprite_pointers
W $82E8 Character 6.
@ $82F0 label=character_7_sprite_pointers
W $82F0 Character 7.
@ $82F8 label=character_8_sprite_pointers
W $82F8 Character 8.
@ $8300 label=get_wizard_object
c $8300 Get address of the wizard object data of the current player.
C $8300 Preserve contents of HL.
C $8301 Add 40 to #R$AC0E variable.
C $8308 Multiply by two.
C $830A Add to address of #R$E3E0(object address table) to give address of current player's object pointer in HL.
C $830F Read address of wizard object into DE.
C $8312 Swap address into HL and store in #R$89AA.
C $8319 Add $17 to address and store in #R$8321.
C $831D Restore contents of HL and return.
@ $831F label=current_character_pointer
g $831F current_character_pointer
W $831F Pointer to current character in #R$82C0(table of pointers to character sprite data).
@ $8321 label=temp_pointer
g $8321 temp_pointer
W $8321 Temporary pointer used by multiple routines.
@ $8323 label=no_less_than_2_flag
g $8323 no_less_than_2_flag
B $8323 Flag that prevents entering a number less than 2.
@ $8324 label=routine02
c $8324 routine02
C $8324 Get address of first sprite pointer in wizard object data of current player.
C $8327 Set B to four as a loop counter and push to stack.
C $832A Set B to two as another counter and push to stack.
C $832D Load #R$831F into HL.
C $8330 Read low byte of sprite data pointer to A first time, high byte on second time around loop.
C $8331 Increment HL and store back in #R$831F.
C $8335 Store the low byte of sprite data pointer in wizard data object at the address held in #R$8321. Second time around loop high byte is stored.
C $8339 Increment HL and store back in #R$8321.
C $833D Pop loop counter and repeat inner loop.
C $8340 Increment address in #R$8321 because there is a byte gap between each sprite pointer in wizard object data.
C $8347 Pop loop counter and repeat outer loop three times before returning.
c $834B routine03
@ $834B label=routine03
C $834B Add #R$AC0E variable to address of #R$AC16.
C $8355 Read byte from that address into A and Return.
@ $8357 label=routine04
c $8357 routine04
C $8357 If player is human, display wizard name, spell being cast, and spell casting range.
C $8360 Call #R$9760 ???
C $8363 Call #R$97D1 ???
C $8366 Call #R$A18A ??? and return.
# spell names from comments on chaos
@ $836A label=magic_armour_spell
c $836A MagicArmour spell.
C $836A Jump to #R$837D if player is human.
C $8370 Else call #R$834B to get byte from #R$AC16.
C $8373 Jump to #R$83AF if bit 7 is clear.
C $8377 Set #R$975F variable to zero and return.
C $837D Call #R$8357 ???
C $8380 Jump to #R$8395 if #R$9167 is clear.
C $8386 Set #R$831F to #R$82A0.
C $838C Copy sprite pointers to wizard data.
C $838F Get byte from #R$AC16.
C $8392 Set bits 6 and 7.
C $8394 Store result back in #R$AC16.
C $8395 Call #R$C0DD ???
C $8398 Display SPELL FAILS or SPELL SUCCEEDS message and return.
@ $839C label=magic_sword_spell
c $839C MagicSword spell.
C $839C Jump to #R$83AF if player is human.
C $83A2 Else call #R$834B to get byte from #R$AC16.
C $83A5 Jump to #R$83AF if bit 2 is clear.
C $83A9 Set #R$975F variable to zero and return.
C $83AF Call #R$8357 ???
C $83B2 Jump to #R$83C9 if #R$9167 is clear.
C $83B8 Set #R$831F to #R$8290.
C $83BE Copy sprite pointers to wizard data.
C $83C1 Get byte from #R$AC16.
C $83C4 Clear bits 0 and 1, and set bit 2.
C $83C8 Store result back in #R$AC16.
C $83C9 Call #R$C0DD ???
C $83CC Display SPELL FAILS or SPELL SUCCEEDS message and return.
@ $83D0 label=magic_knife_spell
c $83D0 MagicKnife spell.
C $83D0 Jump to #R$83E3 if player is human.
C $83D6 Else call #R$834B to get byte from #R$AC16.
C $83D9 Jump to #R$83E3 if lowest three bits are clear.
C $83DD Set #R$975F variable to zero and return.
C $83E3 Call #R$8357 ???
C $83E6 Jump to #R$83FD if #R$9167 is clear.
C $83EC Set #R$831F to #R$8298.
C $83F2 Copy sprite pointers to wizard data.
C $83F5 Get byte from #R$AC16.
C $83F8 Clear bits 0 and 2, and set bit 1.
C $83FC Store result back in #R$AC16.
C $83FD Call #R$C0DD ???
C $8400 Display SPELL FAILS or SPELL SUCCEEDS message and return.
@ $8404 label=magic_shield_spell
c $8404 MagicShield spell.
C $8404 Jump to #R$8417 if player is human.
C $840A Else call #R$834B to get byte from #R$AC16.
C $840D Jump to #R$8417 if bit 6 is clear.
C $8411 Set #R$975F variable to zero and return.
C $8417 Call #R$8357 ???
C $841A Jump to #R$8431 if #R$9167 is clear.
C $8420 Set #R$831F to #R$82A8.
C $8426 Copy sprite pointers to wizard data.
C $8429 Get byte from #R$AC16.
C $842C Clear bit 7 and set bit 6.
C $8430 Store result back in #R$AC16.
C $8431 Call #R$C0DD ???
C $8434 Display SPELL FAILS or SPELL SUCCEEDS message and return.
@ $8438 label=magic_wings_spell
c $8438 MagicWings spell.
C $8438 Jump to #R$844B if player is human.
C $843E Else call #R$834B to get byte from #R$AC16.
C $8441 Jump to #R$844B if bit 5 is clear.
C $8445 Set #R$975F variable to zero and return.
C $844B Call #R$8357 ???
C $844E Jump to #R$8463 if #R$9167 is clear.
C $8454 Set #R$831F to #R$82B0.
C $845A Copy sprite pointers to wizard data.
C $845D Get byte from #R$AC16.
C $8460 Set bit 5
C $8462 Store result back in #R$AC16.
C $8463 Call #R$C0DD ???
C $8466 Display SPELL FAILS or SPELL SUCCEEDS message and return.
@ $846A label=magic_bow_spell
c $846A MagicBow spell.
C $846A Jump to #R$8486 if player is human.
C $8470 Else call #R$8300 to get address of the wizard object data of the current player.
C $8473 Ensure the carry flag is clear.
C $8474 Load address from #R$8321 into HL and subtract $0009.
C $847C If byte at resulting address is zero then jump to #R$8486.
C $8480 Set #R$975F variable to zero and return.
C $8486 Call #R$8357 ???
C $8489 Jump to #R$84A9 if #R$9167 is clear.
C $848F Set #R$831F to #R$82B8.
C $8495 Copy sprite pointers to wizard data.
C $8498 Get address of the wizard object data of the current player.
C $849B Load address from #R$8321 into HL and subtract $0009.
C $84A4 Store $03 at resulting address ???
C $84A6 Increment address and store $06 ???
C $84A9 Call #R$C0DD ???
C $84AC Display SPELL FAILS or SPELL SUCCEEDS message and return.
@ $84B0 label=chaos_law_spell
c $84B0 ChaosOrLawSpell.
C $84B0 Jump to #R$84B9 if player is human.
C $84B6 Else display wizard name, spell being cast, and spell casting range.
C $84B9 Call #R$9760 ???
C $84BC Display SPELL FAILS or SPELL SUCCEEDS message and return.
@ $84C0 label=shadow_form_spell
c $84C0 ShadowForm spell.
C $84C0 Jump to #R$84D3 if player is human.
C $84C6 Else call #R$834B to get byte from #R$AC16.
C $84C9 Jump to #R$84D3 if bit 5 zero.
C $84CD Set #R$975F variable to zero and return.
C $84D3 Call #R$8357 ???
C $84D6 Display SPELL FAILS or SPELL SUCCEEDS message.
C $84D9 Return if #R$9167 is clear.
C $84DE Get address of the wizard object data of the current player.
C $84E1 Load address from #R$8321 into HL and add $0005.
C $84E8 Store zero at resulting address ???
C $84EA Add $0006 to address and store zero at resulting address ???
C $84F0 Get byte from #R$AC16.
C $84F3 Set bit 3.
C $84F5 Store result back in #R$AC16 and return.
@ $84F7 label=subversion_spell
c $84F7 Subversion spell.
C $84F7 Jump to #R$853B if player is not human.
C $84FD Clear bottom row of screen.
C $8500 Set P-FLAGS to 3 (OVER mode).
C $8505 Call #R$BC96 ???
C $8508 Call KEYBOARD routine in Spectrum ROM.
C $850B If keypress is 'S' jump to #R$851B.
C $850F Else if keypress is not 'K' loop back to #R$8508.
@ $8513 label=subversion_pressed_k
C $8513 Play #R$C2B1.
C $8519 Enable interrupts and return.
@ $851B label=subversion_pressed_s
C $851B
@ $853B label=subversion_computer
@ $8557 label=BART_L
@ $8567 label=OK_SUB
@ $859C label=SUB_DO
@ $85A5 label=BALSUP
@ $85CA label=TOFAIL
@ $85F6 label=raise_dead_spell
c $85F6 RaiseDead spell.
@ $85D3 label=YESSUB
@ $8604 label=RAILOO
@ $861A label=RAI_CH
@ $8639 label=RASART
@ $8647 label=RASLOO
@ $8676 label=RASBAK
@ $868D label=LOORAS
@ $869A label=OK_RAS
@ $86C3 label=RAISDO
c $86C3 RAISDO
@ $86EB label=ENDRAS
# spell name from comments on chaos
@ $86EF label=turmoil_spell
c $86EF Turmoil spell.
C $86EF Jump to #R$86F9 if player is human.
C $86F5 Else call #R$8741 and return.
@ $86F9 label=TURART
C $86F9 Copy #R$AC14 into #R$C78B.
C $86FF Call #R$C7BC.
C $8702 Copy #R$C78B to #R$AC14.
C $8708 Set #R$CD86 to address of #R$D3F2.
C $870E Load #R$C7BB to A and add 1.
C $8712 Call #R$C64C.
C $8715 Set #R$A172 to zero.
@ $871A label=LOOTUR
C $871A Load #R$CD86 into HL.
C $871D Load byte from address in #R$CD86.
C $871E Increment address in #R$CD86.
C $8722 If byte read is not zero jump to #R$872B.
C $8725 Else set #R$975F to zero and return.
@ $872B label=ADD_ON
C $872B Add value in A to #R$872B.
C $8730 If #R$872B < 30 then jump back to #R$871A.
C $8735 Display wizard name, spell being cast, and spell casting range.
C $8738 Call #R$8741 and return.
@ $873C label=CRE000
g $873C CRE000
@ $873D label=FLA481
g $873D FLA481
@ $873E label=HID641
g $873E HID641
@ $873F label=BOD801
g $873F BOD801
@ $8740 label=FRA321
g $8740 FRA321
@ $8741 label=TUR_DO
c $8741 TUR_DO
@ $8756 label=MOLLOO
@ $8784 label=RANMOL
@ $87DF label=MOLEND
@ $87EB label=FUCKIT
@ $87EF label=M2PRIN
c $87EF Print a message from #R$8809(game messages table 2).
R $87EF A Message number
R $87EF BC Coordinates
C $87EF Preserve HL, DE, and BC.
C $87F2 Set HL to value in A (message number).
C $87F5 Multiply HL by four because each row is 4 bytes.
C $87F7 Add address of #R$8809 to get address of desired row in #R$8809(game messages table 2).
C $87FB Load address of message into DE.
C $87FE Load message length into C.
C $8800 Swap DE into HL.
C $8801 Copy message length into E.
C $8802 Restore coordinates in BC.
C $8803 Print string.
C $8806 Restore DE and HL, and return.
@ $8809 label=M2ESAG
b $8809 Game messages table 2
D $8809 Address,Length
W $8809,$50,4
t $8859 Game message strings 2
@ $8859 label=M_1
T $8859 M_1
@ $8875 label=M_2
T $8875 M_2
@ $8885 label=M_3
T $8885 M_3
@ $8897 label=M_4
T $8897 M_4
@ $88A6 label=M_5
T $88A6 M_5
@ $88AD label=M_6
T $88AD M_6
@ $88C2 label=M_7
T $88C2 M_7
@ $88C5 label=M_8
T $88C5 M_8
@ $88C7 label=M_9
T $88C7 M_9
@ $88E2 label=M_10
T $88E2 M_10
@ $88FE label=M_11
T $88FE M_11
@ $890C label=M_12
T $890C M_12
@ $891A label=M_13
T $891A M_13
@ $892B label=M_14
T $892B M_14
@ $8941 label=M_15
T $8941 M_15
@ $894F label=M_16
T $894F M_16
@ $895D label=M_17
T $895D M_17
@ $8979 label=M_18
T $8979 M_18
@ $8987 label=M_19
B $8987 M_19
@ $8997 label=M_20
B $8997 M_20
@ $89A7 label=LEVEL
g $89A7 LEVEL
@ $89A8 label=NUM
g $89A8 NUM
@ $89A9 label=GAMTUN
g $89A9 GAMTUN
@ $89AA label=player_name_string
g $89AA player name string pointer
@ $89AC label=POSPRI
g $89AC POSPRI
@ $89AE label=string_length
g $89AE string length
@ $89AF label=KEY_P
g $89AF KEY_P
@ $89B0 label=CHONUM
c $89B0 CHONUM
D $89B0 Get a number from user between 1-8 or 2-8 depending on state of flag, print it at coordinates in BC, and return number-1 in A.
C $89B0 Preserve coordinates.
@ $89B1 label=KEYIT
C $89B1 Call KEYBOARD routine in Spectrum ROM.
C $89B4 Jump back to #R$89B1 until a number between 1 and 9 is pressed.
C $89BE Store key code in #R$89A8.
C $89C1 If #R$8323 is clear jump to #R$89CF.
C $89C7 Else load #R$89A8 into A (key code of key pressed).
C $89CA Jump back to #R$89B1 if the number was less than 2.
@ $89CF label=NOADD
C $89CF Restore coordinates.
C $89D0 Set ATTR-T to $47 (bright white on black).
C $89D5 Load #R$89A8 into A and call #R$BAD6 to print it at coordinates in BC.
C $89DB Play key bloop sound effect.
C $89E1 Call #R$907B.
C $89E4 Clear flag byte that prevents entering a number less than 2.
C $89E9 Load #R$89A8 into A and subtract $31 so that A = number pressed-1 and return.
@ $89EF label=S60
b $89EF Key bloop sound effect.
B $89EF #SOUNDEFFECT(S60.mp3)
@ $89F9 label=main_routine
c $89F9 The main game routine.
C $89F9 Set border to black.
C $89FC Set ATTR-T to black.
C $89FF Set ATTR-P to black.
C $8A02 Set MASK-P to all transparent.
C $8A07 Set P-FLAGS to 3 (OVER mode).
C $8A0C Disable interrupts.
C $8A0D Clear the screen.
C $8A10 Zero out #R$AC16, #R$AC1E, #R$AC26, #R$AC2E, #R$AC2F, #R$AC30, #R$AC31, #R$AC32, #R$AC33, #R$AC34, and #R$AC35.
C $8A1D Zero out #R$7F47.
C $8A2A Zero out #R$E01F.
C $8A37 Zero out #R$E0C0, #R$E160, #R$E200, #R$E2A0, and #R$E340.
C $8A44 Set #R$C3A4 to zero.
C $8A49 Set ATTR-T to $5A (bright red on magenta) and draw border.
C $8A51 Set ATTR-T to $43 (bright magenta on black).
C $8A56 Print message #MTWOPRINTLINK($00) at coordinates (2,2).
C $8A5E Set ATTR-T to $42 (bright red on black).
C $8A63 Print message #MTWOPRINTLINK($01) at coordinates (8,4).
C $8A6B Set ATTR-T to $46 (bright yellow on black).
C $8A70 Print message #MTWOPRINTLINK($02) at coordinates (2,9).
C $8A78 Set ATTR-T to $44 (bright green on black).
C $8A7D Print message #MTWOPRINTLINK($0E) at coordinates (2,11).
C $8A85 Set BC to coordinates (20,9).
C $8A88 Set the flag to prevent numbers less than 2 in input.
C $8A8D Get number input from 2 to 8. This also appends 4 semi-random bytes to #R$D3F2. When the game is loaded #R$CD86 is pointing at the fourth byte in the buffer.
C $8A90 Increment the number input and store in #R$AC0F.
C $8A94 Set ATTR-T to $46 (bright yellow on black).
C $8A99 Print message #MTWOPRINTLINK($08) at coordinates (2,14).
C $8AA1 Set ATTR-T to $43 (bright magenta on black).
C $8AA6 Print message #MTWOPRINTLINK($03) at coordinates (2,16).
C $8AAE Set coordinates (29,14) and get number input from 1 to 8. This also appends 4 semi-random bytes to #R$D3F2.
C $8AB4 Store input in #R$89A7.
C $8AB7 Multiply level by four and add fifteen.
C $8ABD Store the result in #R$89A9.
C $8AC0 Set B to ten as a loop counter.
@ $8AC2 label=REPWAT
C $8AC2 Call #R$96E6 ten times to delay for approximately 1.5 seconds.
C $8AC9 Set #R$AC0E to zero.
C $8ACE Get #R$AC0F into B as loop counter.
C $8AD2 Reset #R$CD86 to beginning of #R$D3F2. As each user makes selections at the following prompts, semi-random bytes are stored in #R$D3F2. This is then used a source of randomness when assigning spells. The bytes generated above are overwritten.
N $8AD8 This is the wizard creation loop where the user enters the wizard name, whether it is a human or computer player, and selects the appearance. The wizard's attributes are then generated randomly.
@ $8AD8 label=STALOO
C $8AD8 Preserve loop counter.
C $8AD9 Clear the screen.
C $8ADC Set ATTR-T to $69 (bright blue on cyan) and draw border.
C $8AE4 Set ATTR-T to $46 (bright yellow on black) and print message #MTWOPRINTLINK($04) at coordinates (2,2).
C $8AF1 Print current player number.
C $8AF9 Set ATTR-T to $43 (bright magenta on black) and print message #MTWOPRINTLINK($09) at coordinates (2,4).
C $8B06 Get address of wizard object data for current player.
C $8B09 Set #R$89AE to zero.
C $8B0E Set #R$89AC to coordinates (2,6) and set ATTR-T to $45 (bright cyan on black).
@ $8B19 label=INPLOO
C $8B19 Call KEYBOARD in Spectrum ROM.
C $8B1C Store keypress in #R$89AF.
C $8B1F If key is 'enter' jump to #R$8B95.
C $8B24 If key is not 'delete' jump to #R$8B56.
C $8B28 If #R$89AE is zero jump back to #R$8B19.
C $8B2E Load #R$89AC into BC and decrement (move cursor left over letter to delete).
C $8B33 Print space character to blank out letter under cursor.
C $8B38 Decrement #R$89AC again ready for next letter.
C $8B3F Decrement #R$89AE.
C $8B43 Decrement #R$89AA pointer (move back over last character).
C $8B4A Play key bloop sound effect.
C $8B50 Pause for approximately 0.15 seconds then jump back to #R$8B19.
@ $8B56 label=NO_DEL
C $8B56 If string length equals 11 jump back to #R$8B19.
C $8B5E If #R$89AF is 'space' jump to #R$8B6F.
C $8B65 If #R$89AF is less than 'A' or greater than 'z' jump back to #R$8B19.
@ $8B6F label=SPACE
C $8B6F Store space character at the position given by the #R$89AA pointer.
C $8B73 Advance the #R$89AA pointer and store.
C $8B77 Increment #R$89AE.
C $8B7B Load #R$89AC into BC and call #R$BAD6 to print character still in A (space) at those coordinates.
C $8B82 Increment #R$89AC.
C $8B89 Play key bloop sound effect.
C $8B8F Append 4 semi-random bytes to #R$D3F2 then jump back to #R$8B19.
@ $8B95 label=ENTER
C $8B95 Read string length into A. If zero jump back to #R$8B19.
C $8B9C Set HL = #R$AC0E + $29.
C $8BA4 Multiply result by four.
C $8BA6 Add result to address of #R$CDD3(game messages table 1) to point at offset to relevant wizard data.
C $8BAA Move past address word in table to wizard name length.
C $8BAC Read #R$89AE variable again and write into table.
C $8BB0 Append 4 semi-random bytes to #R$D3F2.
C $8BB3 Set ATTR-T to $43 (bright magenta on black) and print message #MTWOPRINTLINK($05) at coordinates (2,9).
C $8BC0 Set ATTR-T to $46 (bright yellow on black).
C $8BC5 Clear #R$AC2E (current player is human).
@ $8BCA label=Y_OR_N
C $8BCA Call KEYBOARD in Spectrum ROM.
C $8BCD If keypress is 'Y' jump to #R$8BDF.
C $8BD1 If keypress is not 'N' jump back to #R$8BCA.
C $8BD5 Print message #MTWOPRINTLINK($07) at coordinates (23,9).
C $8BDD Jump to #R$8BF8.
@ $8BDF label=YES_CC
C $8BDF Print message #MTWOPRINTLINK($08) at 23,9.
C $8BE7 Set HL to #R$AC26 + #R$AC0E.
C $8BF1 Write $01 to #R$AC26 + #R$AC0E.
C $8BF3 Set #R$AC2E.
@ $8BF8 label=NOT_CC
C $8BF8 Play key bloop sound effect.
C $8BFE Append 4 semi-random bytes to #R$D3F2.
C $8C01 Set ATTR-T to $43 (bright magenta on black) and print message #MTWOPRINTLINK($0C) at coordinates (2,11).
C $8C0E Set ATTR-T to $45 (bright cyan on black) and print message #MTWOPRINTLINK($0D) at coordinates (2,13).
C $8C1B Set #R$89AC to coordinates (3,13).
C $8C22 Set #R$89A8 to zero.
C $8C27 Set B to eight as a loop counter.
@ $8C29 label=P_WIZL
C $8C29 Preserve the loop counter.
C $8C2A Copy #R$89A8 to #R$90DF.
C $8C30 Increment #R$89A8.
C $8C34 Call #R$90F0 (print character sprite).
C $8C37 Add three to #R$89AC.
C $8C42 Restore loop counter.
C $8C43 Loop back to #R$8C29 for eight iterations.
C $8C45 Call #R$89B0 with coordinates (19,11).
C $8C4B Store number returned in #R$90DF.
C $8C4E Set #R$89AC to coordinates (20,11) and call #R$90F0.
C $8C58 Set HL to unknown data block at #R$82C0.
C $8C5B Multiply #R$90DF by eight and add to #R$82C0 to give address of pointer to sprite data for selected character.
C $8C68 Store result at address in #R$831F.
C $8C6B Copy pointers to sprite data of chosen character to wizard object data for current player.
C $8C6E Set ATTR-T to $43 (bright magenta on black) and print message #MTWOPRINTLINK($0B) at coordinates (2,16).
C $8C7B Set ATTR-T to $46 (bright yellow on black) and print message #MTWOPRINTLINK($0D) at coordinates (2,18).
C $8C88 Set #R$89AC to coordinates (3,18).
C $8C8F Set #R$8321 to address of #R$90D7 (attribute table).
C $8C95 Set B to eight as loop counter.
@ $8C97 label=COLOO
C $8C97 Preserve the loop counter.
C $8C98 Read byte from address held in #R$8321.
C $8C9C Store in ATTR-T.
C $8C9F Increment HL and store back in #R$8321.
C $8CA3 Print character sprite.
C $8CA6 Add three to #R$89AC.
C $8CB0 Restore loop counter from stack.
C $8CB1 Loop back to #R$8C97 for eight iterations.
C $8CB3 Set coordinates to (16,16) and get number input from 1 to 8. This also appends 4 semi-random bytes to #R$D3F2.
C $8CB9 Add number returned to address of #R$90D7 giving address of byte in attribute table corresponding to chosen colour.
C $8CC0 Read attribute byte from attribute table and set ATTR-T.
C $8CC4 Set #R$89AC to coordinates (17,16) and print character sprite.
C $8CCE Get address of first sprite pointer in wizard object data of the current player).
C $8CD1 load address of first sprite pointer in wizard object data from #R$8321 into HL and decrement (HL = address of first sprite pointer - 1).
C $8CD5 Set DE to three.
C $8CD8 Read ATTR-T onto A.
C $8CDB Set B to four as a loop counter.
@ $8CDD label=PUTATL
C $8CDD Add three to HL to point at next attribute byte in wizard data.
C $8CDE Write attribute byte to wizard data.
C $8CDF Loop back to #R$8CDD for four iterations.
C $8CE1 Set #R$9049 to zero.
C $8CE6 If player is human then jump to #R$8CF2.
C $8CEC Else copy #R$89A7 to #R$9049.
@ $8CF2 label=MAKCHR
C $8CF2 Get address of first sprite pointer in wizard object data of the current player.
C $8CF5 Read #R$89AA into HL.
C $8CF8 Move past player name string to player stats.
C $8CFD Get a random number in the range 0-9.
C $8D00 Halve it and add 1.
C $8D03 Add #R$9049 divided by 2.
C $8D0A Store calculated value in first byte of wizard stats (combat).
C $8D0B Set second and third bytes of wizard stats to zero (ranged combat and range).
C $8D11 Get a random number in the range 0-9.
C $8D14 Halve it and add 1.
C $8D17 Add #R$9049 divided by 2.
C $8D1E Store in fourth byte of wizard stats (defence).
C $8D20 Set fifth byte of wizard stats to 1 (movement allowance).
C $8D23 Get a random number in the range 0-9.
C $8D26 Halve it and add 3.
C $8D2A Add #R$9049 divided by 4.
C $8D33 Store in sixth byte of wizard stats (manoeuvre rating).
C $8D35 Get a random number in the range 0-9.
C $8D38 Divide it by 4 and add 6.
C $8D3E Store in seventh byte of wizard stats (magic resistance).
C $8D40 Get a random number in the range 0-9.
C $8D43 Halve it and add 11.
C $8D47 Add #R$9049.
C $8D4C Cap the value at 20.
@ $8D53 label=NOTMOR
C $8D53 Store value in #R$904A and in eighth byte of wizard stats (spells).
C $8D58 Set ninth byte in wizard stats to zero (ability).
C $8D5B Halve #R$9049 and subtract from 5.
C $8D64 Store result in #R$A172.
C $8D67 Get a random number in the range 0-9.
C $8D6A If less than #R$A172 jump to #R$8D7A.
C $8D72 Get a random number in the range 0-9.
C $8D75 Halve it and store in ninth byte of wizard stats (ability).
@ $8D7A label=NOABIL
C $8D7A Get address of current player's first spell in #R$7F47.
C $8D7D Decrement #R$9154 to first byte in wizard's spells ???
C $8D84 Get a random number in the range 0-9.
C $8D87 Add 12 to value and store at address in #R$9154 ???
C $8D8D Set first spell to $01 (disbelieve).
C $8D90 Set #R$9154 to next address.
C $8D94 Reset #R$CD86 to beginning of #R$D3F2.
C $8D9A Set B to #R$904A as loop counter.
@ $8D9E label=INSPLO
C $8D9E Preserve BC.
@ $8D9F label=RIND
C $8D9F Copy R register into A.
C $8DA1 Select lowest three bits.
C $8DA3 Copy to H.
C $8DA4 Get R register into L.
C $8DA7 Read byte from a semi-random address in first 2kB of ROM.
C $8DA8 Add semi-random byte from address in #R$CD86.
C $8DAC Select lowest 6 bits.
C $8DAE Jump back to #R$8D9F unless value in the range $02 to $41. This selects any valid spell number excluding disbelieve. The preceding mask also #LINK:Facts#turmoil_spell(excludes spells $40 and $41 (turmoil)) rendering the upper range check unnecessary.
C $8DB8 Increment #R$CD86 to next semi-random byte.
C $8DBC Store spell number in #R$937B.
C $8DBF Get address of spell table entry in IX.
C $8DC2 Read fourth byte from spell entry ???
C $8DC5 Store at address in #R$9154.
C $8DC9 Increment address and copy #R$937B there.
C $8DCE Increment address and #R$9154 pointer.
C $8DD2 Restore loop counter.
C $8DD3 Loop back to #R$8D9E for #R$904A iterations.
C $8DD5 If player is human, jump to #R$8E08.
C $8DDB Get address of spells for current player.
C $8DDE Set HL to address of wizard's first spell number.
C $8DE1 Decrement to address of first entry in possessed spell table.
C $8DE2 Set B to 19 as outer loop counter.
@ $8DE4 label=OUTL_
C $8DE4 Preserve outer loop counter and address in possessed spell table.
C $8DE6 Set B to 19 as inner loop counter.
@ $8DE8 label=INL_
C $8DE8 Preserve inner loop counter.
C $8DE9 Read ??? and spell number from entry address in HL into E and D.
C $8DED Move forward and read next entry into C and B.
C $8DF0 Move pointer back to the ??? of the second entry.
C $8DF1 If first ??? is not greater than or equal to second ??? jump to #R$8E01.
C $8DF7 Else swap table entries.
C $8DFF Move pointer back to ??? of the second entry.
@ $8E01 label=NOBIGA
C $8E01 Restore inner loop counter and loop back to #R$8DE8 for 19 iterations.
C $8E04 Restore address of first table entry and outer loop counter and loop back to #R$8DE4 for 19 iterations.
@ $8E08 label=DONSOR
C $8E08 Increment #R$AC0E variable.
C $8E0F Restore loop counter and jump back to #R$8AD8 for #R$AC0F iterations.
N $8E14 Next the program sets the starting position of each wizard which depends on the number of players.
C $8E14 Read #R$AC0F into A.
C $8E17 Subtract two.
C $8E19 Multiply by eight.
C $8E1F And add result to address of #R$909F get starting positions for selected number of players.
C $8E26 Store this address in variable at #R$8321.
C $8E29 Set #R$AC0E variable to zero.
C $8E2E Read #R$AC0F into B as loop counter.
@ $8E32 label=PUTIBO
C $8E32 Read byte from address held in #R$8321 into A.
C $8E36 Increment address in temporary variable at #R$8321.
C $8E3A Set HL to #R$E01F.
C $8E3D Calculate address in table by adding the value just read from current player offset in #R$909F table.
C $8E41 Add $29 to #R$AC0E to get object number of wizard and store at calculated address.
C $8E47 Store #R$AC0E at corresponding entry in #R$E200.
C $8E4F Increment #R$AC0E variable.
C $8E53 Loop back to #R$8E32 for #R$AC0F iterations.
C $8E55 Set #R$7D03 to zero ???
C $8E5A Read #R$AC0F into A, double it, add 15 and copy the result to B as a loop counter.
N $8E62 This is the main game loop. A loop counter ends the game in a tie after a certain number of turns, which is the number of players multiplied by 2, plus 15.
@ $8E62 label=TURLOO
C $8E62 Preserve loop counter.
C $8E63 Each player in turn selects their spell, and then the spells are cast.
C $8E66 If only one wizard is alive jump to #R$8E93.
C $8E70 Call #R$9F50 ???
C $8E73 Call #R$8F9A ???
C $8E76 Call #R$A173 ???
C $8E79 Call #R$AC36 ???
C $8E7C Switch to interrupt mode 2.
C $8E7F Set B to ten as loop counter.
@ $8E81 label=PAUS_L
C $8E81 Preserve BC, call #R$96E6, Restore BC.
C $8E86 Loop back to #R$8E81 for ten iterations.
C $8E88 Switch to interrupt mode 1.
C $8E8B Compare #R$AC34 +1 with #R$AC0F.
@ $8E93 label=GO_END
C $8E93 Restore loop counter.
C $8E94 If only one wizard is alive jump to #R$8F04.
C $8E96 Increment variable #R$7D03.
C $8E9A Loop back to #R$8E62 for (#R$AC0F * 2) + 15 iterations.
C $8E9C Call #R$C5EE ???
C $8E9F Set ATTR-T to $01 (dark blue on black).
@ $8EA4 label=LOOPY
C $8EA4 Call #R$8F8B ???
C $8EA7 Draw border.
C $8EAA Call #R$8F8B ???
C $8EAD Print message #MTWOPRINTLINK($10) at coordinates (2,2).
C $8EB5 Set HL to #R$AC16.
C $8EB8 Set #R$89AC to coordinates (10,3).
C $8EBF Set #R$AC0E to $29 (the first wizard's name #R$CDD3).
C $8EC4 Load #R$AC0F into B as loop counter.
@ $8EC8 label=ZAPEM
C $8EC8 Preserve BC and HL.
C $8ECA Jump to #R$8EE2 if bit 4 of byte at address in HL is not zero.
C $8ECE Call #R$8F8B ???
C $8ED1 Load #R$AC0E variable back into A (message in message table 1).
C $8ED5 Load BC with #R$89AC and increment twice (move two columns right).
C $8EDF Print the wizard name.
@ $8EE2 label=DEDED
C $8EE2 Restore address and advance to next entry in #R$AC16.
C $8EE4 Increment #R$AC0E variable (next row in game message table 1).
C $8EEB Restore loop counter from stack.
C $8EEC Loop back to #R$8EC8 for #R$AC0F iterations.
C $8EEE Call #R$8F8B ???
C $8EF1 Print #MPRINTLINK($3D) at coordinates (0,22).
C $8EF9 Call #R$96E6 ???
C $8EFC Call KEY-SCAN in Spectrum ROM.
C $8EFF Jump back to #R$8EA4 if no key is pressed else return.
@ $8F04 label=ENDGAM
C $8F04 Call #R$C5EE ???
C $8F07 Set ATTR-T to $01 (dark blue on black).
@ $8F0C label=LOPY2
C $8F0C Call #R$8F8B ???
C $8F0F Draw border.
C $8F12 Call #R$8F8B ???
C $8F15 Print message #MTWOPRINTLINK($11) at coordinates (9,4).
C $8F1D Call #R$8F8B ???
C $8F20 Print message #MTWOPRINTLINK($12) at coordinates (8,8).
C $8F28 Print message #MTWOPRINTLINK($13) at coordinates (8,10).
C $8F30 Print message #MTWOPRINTLINK($13) at coordinates (8,12).
C $8F38 Print message #MTWOPRINTLINK($13) at coordinates (8,14).
C $8F40 Print message #MTWOPRINTLINK($12) at coordinates (8,16).
C $8F48 Call #R$8F8B ???
C $8F4B Set HL to address #R$AC16.
C $8F4E Set B to eight as loop counter.
@ $8F50 label=GRONK
C $8F50 Jump to #R$8F57 if bit 4 of byte at address in HL is set.
C $8F54 Else move on to next byte.
C $8F55 Loop back to #R$8F50 for eight iterations.
@ $8F57 Label=FOUDIM
C $8F57 Subtract loop counter from $31 to get row of wizard in #R$CDD3.
C $8F5A Preserve AF.
C $8F5B Load BC with coordinates (10,12).
C $8F5E Set HL to four times the value in A.
C $8F63 Add offset to the address of #R$CDD3(game messages table 1).
C $8F67 Add two to resulting address to move to length byte.
C $8F69 Read byte into A.
C $8F6A Divide by two and copy result to E.
C $8F6D Subtract E from sixteen and copy result to C.
C $8F71 Restore row of #R$CDD3(game messages table 1).
C $8F72 Print wizard name centred in box.
C $8F75 Call #R$8F8B ???
C $8F78 Print #MPRINTLINK($3D) at coordinates (0,22).
C $8F80 Call #R$96E6 ???
C $8F83 Call KEY-SCAN in ROM to see if a key was pressed.
C $8F88 Loop back to #R$8F0C if no key was pressed.
C $8F8A Else return (to BASIC).
@ $8F8B label=ATTRDO
c $8F8B ATTRDO
C $8F8B Increment ATTR-T.
C $8F92 If ATTR-T is not $08 return.
C $8F95 Else set ATTR-T to $01 (dark blue on black) and fall through to #R$8F9A.
@ $8F9A label=TREPUT
c $8F9A TREPUT
C $8F9A Set HL to address of #R$E01F.
C $8F9D Store in #R$AC12.
C $8FA0 Set B to 159 as loop counter.
@ $8FA2 label=TRFILO
C $8FA2 Preserve loop counter.
C $8FA3 If object is not $24 (Magic Wood) jump to #R$9031.
C $8FA9 Add $0281 to address to get corresponding entry in #R$E2A0.
C $8FAD Load entry from #R$E2A0.
C $8FAE If zero jump to #R$9031.
C $8FB2 Store in #R$A172 ???
C $8FB5 Get a random number from 0 to 9.
C $8FB8 If greater than 4 jump to #R$9031.
C $8FBD Else subtract 41 from value in #R$A172 to get wizard number and store result in #R$AC0E.
C $8FC5 Set ATTR-T to $46 (bright yellow on black) and print message #MTWOPRINTLINK($0F) at coordinates (0,22).
C $8FD2 Increment column coordinate to leave a space.
C $8FD3 Print wizard name.
C $8FD9 Play #R$903E sound effect.
C $8FDF Enable interrupts.
C $8FE0 Set B to 10 as a loop counter.
@ $8FE2 label=WAYLOO
C $8FE2 Call #R$96E6 ten times to pause for approximately 1.5 seconds.
C $8FE7 Clear bottom row.
@ $8FEA label=RUNDY
C $8FEA Get a random number with lower nibble less than 10 in #R$907A.
C $8FED Jump back to #R$8FEA if #R$907A is less than $02 or greater than $41.
C $8FFA Else store in #R$937B.
C $8FFD Calculate address of spell table for player.
C $9000 Load address of first spell into HL.
C $9003 Add two to skip over first spell (always Disbelieve).