-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathfsubs.asm
2050 lines (1711 loc) · 41.6 KB
/
fsubs.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
; assembly language subroutines for faerie tale adventure
; written august 86 by Talin
; AmigaDOS subroutine vectors
Write EQU $FFFFFFD0
Read EQU $FFFFFFD6
Close EQU $FFFFFFDC
Open EQU $FFFFFFE2
Move EQU $FFFFFF10
Text EQU $FFFFFFC4
SetAPen EQU $FFFFFEAA
Draw EQU $FFFFFF0A
BltBitMap EQU $FFFFFFE2
SetRGB4 EQU $FFFFFEE0
WaitBlit EQU $FFFFFF1C
OwnBlitter EQU $FFFFFE38
DisownBlitter EQU $FFFFFE32
ie_X equ 10
ie_Y equ 12
ie_NextEvent equ 0
xwrap macro
btst #6,\1 ; if 0-64, process normally
beq.s 98$
btst #5,\1 ; else wrap in various directions
seq d2 ; if zero, set to all 1's (mask 63)
and.w #63,\1 ; else set to all zero's
98$
endm
ywrap macro
btst #5,\1
beq.s 99$
btst #4,\1
seq \1
and.w #31,\1
99$
endm
public _trapper
_trapper
move.l (sp)+,4(a1)
rte
public _HandlerInterface,_ion,_numbuf,_getkey
RAWKEY equ 1
RAWMOUSE equ 2
POINTERPOS equ 4
TIMER equ 6
DISKIN equ $10
; a0 contains inputevent stream
; a1 contains data area
xsprite equ 0
ysprite equ 2
qualifier equ 4
public _LVOMoveSprite
_HandlerInterface:
movem.l d1-d2/a1-a3,-(sp)
move.l a0,a2 ; save list address
lea keytrans,a3
handloop
; first we check what the actual event was before we mess with it
move.b 4(a0),d0 ; check event type
cmp.b #TIMER,d0 ; is it a raw key?
bne.s checkkey
cmp.w #16,22+128(a1)
beq.s bang
addq.w #1,22+128(a1)
bra.s nomouse
bang move.b #RAWKEY,4(a0) ; make an up shift
move.w #($80+$60),6(a0)
move.w #0,22+128(a1)
bra.s nomouse
checkkey
cmp.b #RAWKEY,d0 ; is it a raw key?
bne.s notrawkey ; check other possibilities
move.w 8(a0),d0 ; get qualifier
btst #9,d0 ; a repeat?
bne.s nomouse ; is so, ignore
move.w 6(a0),d0 ; get raw key code
move.b d0,d1 ; save high bit
and.b #$7f,d0 ; turn off high bit
cmp.b #$5a,d0 ; ignore undefined keys
bhi.s nomouse ; is so, ignore for now
move.w #$0000,4(a0) ; change to null event
move.b (a3,d0),d0 ; translate
and.b #$80,d1 ; isolate old upper bit (up/down)
or.b d1,d0 ; and mark key as up or down
clr.w d1 ; clear upper half d1
move.b 6(a1),d1 ; get laydown pointer
move.b d0,22(a1,d1.w) ; move converted code into buffer
addq.b #1,d1 ; increment buffer
and.b #$7f,d1 ; and limit it
cmp.b 7(a1),d1 ; same as pickup pointer?
beq.s nomouse ; is so, overflow
move.b d1,6(a1) ; otherwise, update buffer
bra.s nomouse
notrawkey
cmp.b #RAWMOUSE,d0
bne.s domouse
move.w 8(a0),d1 ; get qualifier
move.w 4(a1),d0
eor.w d1,d0 ; old xor new
and.w #$4000,d0 ; isolate left button bit
beq.s nobutn ; left button not changed
and.w #$4000,d1 ; test new bit value
bne.s butndown ; if down, goto down trans
move.b 9(a1),d1 ; get old menu value
beq.s nobutn ; if none, no action
or.b #$80,d1 ; set up bit
clr.b 9(a1) ; clear old action
bra.s butn10 ; put it in the que
butndown
clr.l d1
move.w xsprite(a1),d0 ; get current x/y coords
move.w ysprite(a1),d1
cmp.w #215,d0 ; in range for menu activation?
blo.s nobutn
cmp.w #265,d0
bhi.s nobutn
sub.w #144,d1 ; (my - 144)/9 + 'a'
bmi.s nobutn
divu.w #9,d1
add.w d1,d1
add.w #$61,d1
cmp.w #240,d0
blo.s butn10
addq #1,d1
butn10
move.w d1,d0
clr.w d1
move.b 6(a1),d1 ; get laydown pointer
move.b d0,22(a1,d1.w) ; move converted code into buffer
addq.b #1,d1 ; increment buffer
and.b #$7f,d1 ; and limit it
cmp.b 7(a1),d1 ; same as pickup pointer?
beq.s nobutn ; is so, overflow
move.b d1,6(a1) ; otherwise, update buffer
move.b d0,9(a1) ; save menu choice
nobutn
move.w 8(a0),4(a1) ; move qualifier to in_work
domouse
cmp.b #DISKIN,d0
bne.s domouse1
move.b #1,8(a1)
domouse1
move.w xsprite(a1),d0 ; get current coords
move.w ysprite(a1),d1
add.w ie_X(a0),d0 ; add to xsprite
add.w ie_Y(a0),d1 ; add to ysprite
cmp.w #315,d0
blt.s xhi
move.w #315,d0
xhi
cmp.w #5,d0
bgt.s xlo
move.w #5,d0
xlo
cmp.w #195,d1
blt.s yhi
move.w #195,d1
yhi
cmp.w #147,d1
bgt.s ylo
move.w #147,d1
ylo
move.w d0,xsprite(a1)
move.w d1,ysprite(a1)
tst.l 14(a1) ; do we have simplesprite?
beq.s nosprite
movem.l a0/a1/a6,-(sp)
add.w d0,d0
sub.w #143,d1 ; vp_text offset
move.l 10(a1),a6 ; Gfx Base
move.l 18(a1),a0 ; ViewPort
move.l 14(a1),a1 ; simplesprite
jsr _LVOMoveSprite(a6)
movem.l (sp)+,a0/a1/a6
nosprite
nomouse
move.l ie_NextEvent(a0),a0 ; next event in chain
move.l a0,d0 ; set zero flag -- if null, quit
bne.s handloop ; else process next
clr.l d0
movem.l (sp)+,d1-d2/a1-a3
rts
keytrans dc.b "`1234567890-=\?0"
dc.b "QWERTYUIOP{}?",26,25,24
dc.b "ASDFGHJKL:???",27,29,23
dc.b "?ZXCVBNM,.??.",20,21,22
dc.b $20,$08,$09,$0D,$0D,$1B,$7F,0,0,0,$2D,0,1,2,3,4
dc.b 10,11,12,13,14,15,16,17,18,19,0,0,0,0,0,0
XY equ 128 ; then x/2 then y
ETX equ 0
public _ssp,_titletext,_GfxBase
dseg
public _titletext
_titletext dc.b XY,(160-26*4)/2,33,$22,"The Faery Tale Adventure",$22
dc.b XY,(160-30*4)/2,79,"Animation, Programming & Music"
dc.b XY,(160-2*4)/2,90,"by"
dc.b XY,(160-12*4)/2,101,"David Joiner"
dc.b XY,(160-30*4)/2,160,"Copyright 1986 MicroIllusions "
;_titletext dc.b XY,168/2,33,$22,"The Faery Tale Adventure",$22
; dc.b XY,153/2,74,"Animation, Programming & Music"
; dc.b XY,292/2,90,"by"
; dc.b XY,250/2,101,"David Joiner"
; dc.b XY,168/2,160,"Copyright (C) 1986 MicroIllusions "
dc.b ETX
public _hinor,_hivar
_hinor
dc.l $01FFF8FF,$FC038000,$01FF0007,$FC038000
dc.l $07E0F078,$3F038000,$190FE03F,$C4C38000
dc.l $FC7FC01F,$F1FF8000,$F19F800F,$CC7F8000
dc.l $E7E70007,$3F3F8000,$CFF9800C,$FF9F8000
dc.l $9FFE6033,$FFCF8000,$3F0798CF,$C3E78000
dc.l $7001E79F,$00338000,$0000783C,$00038000
dc.l $00001930,$00000000,$0000780C,$00038000
dc.l $7801C7F3,$00338000,$3F87383C,$C3E78000
dc.l $9FFCF01F,$3FCF8000,$CFF3C00F,$CF9F8000
dc.l $E7CF8007,$F33F8000,$F13F800F,$FC7F8000
dc.l $FC7FC01F,$F1308000,$331FE03F,$C7C08000
dc.l $0FE0F078,$3F008000,$03FF0007,$FF008000
dc.l $03FFF8FF,$FFFF0000
_hivar
dc.l $01FFF8FF,$FC038000,$79FF0207,$FCF38000
dc.l $67E0F278,$3F338000,$190FE73F,$C4C38000
dc.l $FC7FCF9F,$F1FF8000,$F19F9FCF,$CC7F8000
dc.l $E7E73FE7,$3F3F8000,$CFF99FCC,$FF9F8000
dc.l $9FFE6733,$FFCF8000,$3F0798CF,$C3E78000
dc.l $70F9E79F,$3C338000,$0FFE783C,$FFC38000
dc.l $FFFF9933,$FFF80000,$07FE780C,$FFC38000
dc.l $7879C7F3,$3C338000,$3F87383C,$C3E78000
dc.l $9FFCF39F,$3FCF8000,$CFF3CFCF,$CF9F8000
dc.l $E7CF9FE7,$F33F8000,$F13F9FCF,$FC7F8000
dc.l $FC7FCF9F,$F1308000,$331FE73F,$C7CC8000
dc.l $CFE0F278,$3F3C8000,$F3FF0207,$FF008000
dc.l $03FFF8FF,$FFFF0000
cseg
public _handler_data
_getkey
movem.l a1/d1,-(sp)
lea _handler_data,a1
clr.l d0
clr.w d1
move.b 7(a1),d1 ; get pickup pointer
cmp.b 6(a1),d1 ; if same as laydown
beq.s getkeyx
move.b 22(a1,d1.w),d0 ; get key from buffer
addq #1,d1
and.b #$7f,d1 ; buffer is 128 long
move.b d1,7(a1)
getkeyx movem.l (sp)+,a1/d1
rts
public _rand,_seed1,_bitrand,_rnd
public _rand2,_rand4,_rand8,_rand64,_rand256
_rand
move.l _seed1,d0
mulu.w #45821,d0
addq.l #1,d0
move.l d0,_seed1
ror.l #6,d0
and.l #$7fffffff,d0
rts
_bitrand bsr.s _rand ; rand() & x
and.l 4(sp),d0
rts
_rand2 bsr.s _rand ; rand() & 1
and.l #1,d0
rts
_rand4 bsr.s _rand ; rand() & 3
and.l #3,d0
rts
_rand8 bsr.s _rand ; rand() & 7
and.l #7,d0
rts
_rand64 bsr.s _rand ; rand() & 63
and.l #63,d0
rts
_rand256 bsr.s _rand ; rand() & 255
and.l #255,d0
rts
_rnd bsr.s _rand ; rand() % x
move.l 4(sp),d1
and.l #$0000ffff,d0
divu.w d1,d0 ; d0 / n
clr.w d0 ; clear bottom half
swap d0 ; get top half
rts
public _prdec
_prdec
movem.l a0-a6/d0-d7,-(sp)
move.l 60+4(sp),d0
bsr.s ion6
add #10,a0
move.l 60+8(sp),d0 ; length
sub.w d0,a0 ; numbuf+10-p
add #1,d0
move.l _rp,a1 ; Rast Port (rp)
move.l _GfxBase,a6
jsr Text(a6)
movem.l (sp)+,a0-a6/d0-d7
rts
_ion
move.l 4(sp),d0
ion6
lea _numbuf,a0
moveq.l #9,d1
bra.s ion5
ion1
tst.w d0
beq.s ion2
ion5
divu.w #10,d0
swap d0
add.b #$30,d0
move.b d0,(a0,d1)
clr.w d0
swap d0
dbf d1,ion1
rts
ion2 move.b #$20,(a0,d1) ; space fill until end
dbf d1,ion2
rts
public _move,_rp,_text,_placard,_rp_map
MOD equ 4
xmod dc.b -MOD,-MOD,-MOD,0,0,0,MOD,MOD,0,-MOD,0,MOD,MOD,0,0,0
ymod dc.b 0,0,0,MOD,MOD,MOD,0,0,-MOD,0,-MOD,0,0,MOD,MOD,MOD
_placard
movem.l d0-d7/a0-a6,-(sp)
lea _rp_map,a1
move.l _GfxBase,a6
moveq #12,d6 ; xorg
moveq #0,d7 ; yorg
moveq #16,d4 ; i
iiloop move.l d4,-(sp)
moveq #15,d5 ; j
lea xmod(pc),a2 ; table of adders
jloop
clr.l d0
move.l d7,d3 ; dy
move.b 16(a2),d0 ; dy + ymod[j]
ext.w d0
ext.l d0
add.w d0,d3
move.l d6,d2 ; dx
move.b (a2)+,d0 ; dx + xmod[j]
ext.w d0
ext.l d0
add.w d0,d2
moveq #4,d4 ; k loop
kloop moveq #1,d0 ; color
tst.w d4
bne.s kloop2
add.w #23,d0
kloop2 jsr SetAPen(a6)
move.l (sp),d0
cmp.l #9,d0
bls.s kloop3
move.l d6,d0 ; xorg
move.l d7,d1 ; yorg
jsr Move(a6)
move.l d2,d0 ; dx
move.l d3,d1 ; dy
jsr Draw(a6)
move.w #284,d0
sub.l d6,d0 ; 287-xorg
move.w #124,d1
sub.l d7,d1 ; 124-yorg
jsr Move(a6)
move.w #284,d0
sub.l d2,d0 ; 287-dx
move.w #124,d1
sub.l d3,d1 ; 124-dy
jsr Draw(a6)
kloop3
moveq #16,d0
add.l d7,d0 ; 16+yorg
moveq #12,d1
sub.l d6,d1 ; 12-xorg
jsr Move(a6)
moveq #16,d0
add.l d3,d0 ; 16+dy
moveq #12,d1
sub.l d2,d1 ; 12-dx
jsr Draw(a6)
move.w #268,d0
sub.l d7,d0 ; 268-yorg
moveq #112,d1
add.l d6,d1 ; 112+xorg
jsr Move(a6)
move.w #268,d0
sub.l d3,d0 ; 268-dy
moveq #112,d1
add.l d2,d1 ; 112+dx
jsr Draw(a6)
dbra d4,kloop
move.l d2,d6 ; xorg = dx
move.l d3,d7 ; yorg = dy
dbra d5,jloop
move.l (sp)+,d4
dbra d4,iiloop
movem.l (sp)+,d0-d7/a0-a6
rts
_move
movem.l a0-a2/d0-d1,-(sp)
move.l 4+20(sp),d0
move.l 8+20(sp),d1
move.l _rp,a1 ; Rast Port (rp)
move.l _GfxBase,a6
jsr Move(a6)
movem.l (sp)+,a0-a2/d0-d1
rts
_text
movem.l a0-a6/d0-d7,-(sp)
move.l 60+4(sp),a0
move.l 60+8(sp),d0
move.l _rp,a1 ; Rast Port (rp)
move.l _GfxBase,a6
jsr Text(a6)
movem.l (sp)+,a0-a6/d0-d7
rts
_ssp
move.l 4(sp),a0
movem.l a0-a2/d0-d1,-(sp)
move.l _rp,a1 ; Rast Port (rp)
ssp10
move.l a0,a2
move.b (a0)+,d0
beq.s sspx
cmp.b #XY,d0
beq.s setxy
; here's where we actually print the text
move.l a2,a0
clr.l d0
ssp20
tst.b (a2)+
beq.s endstring
bmi.s endstring
addq #1,d0 ; add 1 to length
bra.s ssp20
endstring
movem.l a0-a6/d0-d7,-(sp)
move.l _GfxBase,a6
jsr Text(a6)
movem.l (sp)+,a0-a6/d0-d7
add.w d0,a0 ; add length to pointer
bra.s ssp10
setxy clr.l d0
clr.l d1
move.b (a0)+,d0
move.b (a0)+,d1
add.w d0,d0 ; x * 2
move.l _GfxBase,a6
jsr Move(a6)
bra.s ssp10
sspx
movem.l (sp)+,a0-a2/d0-d1
rts
public _px_to_im,_xreg,_yreg,_map_mem,_sector_mem
public _terra_mem
_px_to_im
move.l 4(sp),d0 ; x coord
move.l 8(sp),d1 ; y coord
px_to_im
movem.l d2-d4/a1,-(sp)
move.b #$80,d4 ; 1 bit, high position
btst #3,d0 ; test bit 3 of x
beq.s px01
lsr.b #4,d4 ; select 1-4, 5-8
px01
btst #3,d1 ; test bit 3 of y
beq.s px02
lsr.b #1,d4 ; select 1/2
px02
btst #4,d1 ; test bit 4 of x
beq.s px03
lsr.b #2,d4 ; select 1-2, 3-4
px03
lsr.w #4,d0 ; x / 16 = imx
lsr.w #5,d1 ; y / 32 = imy
move.w d0,d2
lsr.w #4,d2 ; secx = imx / 16 - xreg
sub.w _xreg,d2
btst #6,d2 ; if 0-64, process normally
beq.s px20
btst #5,d2 ; else wrap in varios directions
seq d2 ; if zero, set to all 1's (mask 63)
and.w #63,d2 ; else set to all zero's
px20
move.w d1,d3
lsr.w #3,d3 ; secy = imy / 8 - yreg
sub.w _yreg,d3
bpl.s px30
clr.w d3 ; if secy < 0, secy = 0;
px30 cmp.w #32,d3
blt.s px40
moveq #31,d3 ; if secy > 31, secx = 31
px40
lsl.w #7,d3 ; sec_num = secy * 128 + secx + xreg
add.w d2,d3
add.w _xreg,d3 ; add xreg
move.l _map_mem,a0
move.l _sector_mem,a1
clr.w d2
move.b (a0,d3),d2 ; d2 = sec_num
and.w #15,d0 ; imx & 15
and.w #7,d1 ; imy & 7
lsl.w #7,d2 ; sec_num * 128 + imy * 16 + imx
lsl.w #4,d1
or.w d1,d2
or.w d0,d2
clr.w d1
move.b (a1,d2.w),d1 ; sector_mem[offset]
clr.l d0 ; prepare zero result
add.w d1,d1
add.w d1,d1
move.l _terra_mem,a1
and.b 2(a1,d1.w),d4 ; tbit & tiles[image]
beq.s px99 ; if no tile, return zero
move.b 1(a1,d1.w),d0
lsr.b #4,d0 ; terrain tile type
px99
movem.l (sp)+,d2-d4/a1 ; pop 3 regs
rts
;-----------------------------------------------------------------------
; iff subroutines
;-----------------------------------------------------------------------
; xdefs
public _ReadLength,_ReadHeader
; xrefs
public _file_length,_blocklength,_myfile,_DOSBase,_header
_ReadHeader
movem.l d1-d3/a0-a1,-(sp)
move.l _DOSBase,a6
move.l _myfile,d1
move.l #_header,d2
move.l #4,d3
jsr Read(a6)
sub.l #4,_file_length
movem.l (sp)+,d1-d3/a0-a1
rts
_ReadLength
movem.l d1-d3/a0-a1,-(sp)
move.l _DOSBase,a6
move.l _myfile,d1
move.l #_blocklength,d2
move.l #4,d3
jsr Read(a6)
move.l _blocklength,d1
add.l #4,d1
sub.l d1,_file_length
movem.l (sp)+,d1-d3/a0-a1
rts
; this routine blits the map characters onto the screen
; d1-d4 are offsets
; d5 is screen plane offset
; d7 is character number
; d6 is height and scanline counter
; a6 is address of char data
; a5 is source image data
; a0-a4 are addresses of bitplane areas
IPLAN_SZ equ 16384 ; 16K = 256 * 64
public _map_draw,_image_mem,_minimap,_planes
_map_draw
movem.l d0-d7/a0-a6,-(sp)
; initial register setups
move.l _image_mem,a6
move.l a6,-(sp)
lea _minimap,a6
move.l #IPLAN_SZ,d1 ; 2nd plane offset
move.l #IPLAN_SZ*2,d2 ; 3rd plane offset
move.l #IPLAN_SZ*3,d3 ; 4th plane offset
move.l #IPLAN_SZ*4,d4 ; 5th plane offset
move.l _planes,a4
move.l 0(a4),a0 ; plane 1
move.l 4(a4),a1 ; plane 2
move.l 8(a4),a2 ; plane 3
move.l 12(a4),a3 ; plane 4
move.l 16(a4),a4 ; plane 5
clr.l d7 ; clear upper part
move.w #0,d5
bsr.s next_strip
move.w #2,d5
bsr.s next_strip
move.w #4,d5
bsr.s next_strip
move.w #6,d5
bsr.s next_strip
move.w #8,d5
bsr.s next_strip
move.w #10,d5
bsr.s next_strip
move.w #12,d5
bsr.s next_strip
move.w #14,d5
bsr.s next_strip
move.w #16,d5
bsr.s next_strip
move.w #18,d5
bsr.s next_strip
move.w #20,d5
bsr.s next_strip
move.w #22,d5
bsr.s next_strip
move.w #24,d5
bsr.s next_strip
move.w #26,d5
bsr.s next_strip
move.w #28,d5
bsr.s next_strip
move.w #30,d5
bsr.s next_strip
move.w #32,d5
bsr.s next_strip
move.w #34,d5
bsr.s next_strip
move.w #36,d5
bsr.s next_strip
addq.l #4,sp
movem.l (sp)+,d0-d7/a0-a6
rts
; this will be a long set of in-line code
next_strip
move.w (a6)+,d7 ; character number
bsr.s next_image
move.w (a6)+,d7 ; character number
bsr.s next_image
move.w (a6)+,d7 ; character number
bsr.s next_image
move.w (a6)+,d7 ; character number
bsr.s next_image
move.w (a6)+,d7 ; character number
bsr.s next_image
move.w (a6)+,d7 ; character number
bsr.s next_image
rts
next_image
; rts
; check for zero (no update character)
; beq.s no_image
lsl.l #6,d7 ; char number * 64 bytes per char
move.l 8(sp),a5 ; a5 = image_mem + d7
; add.l d7,a5
lea (a5,d7.w),a5
move.w #15,d6
iloop
move.w (a5,d4.l),(a4,d5.w) ; move 5th bit plane
move.w (a5,d3.l),(a3,d5.w) ; move 4th bit plane
move.w (a5,d2.l),(a2,d5.w) ; move 3rd bit plane
move.w (a5,d1.l),(a1,d5.w) ; move 2nd bit plane
move.w (a5)+,(a0,d5.w) ; move 1st bit plane
add.l #40,d5 ; next scan line
move.w (a5,d4.l),(a4,d5.w) ; move 5th bit plane
move.w (a5,d3.l),(a3,d5.w) ; move 4th bit plane
move.w (a5,d2.l),(a2,d5.w) ; move 3rd bit plane
move.w (a5,d1.l),(a1,d5.w) ; move 2nd bit plane
move.w (a5)+,(a0,d5.w) ; move 1st bit plane
add.l #40,d5 ; next scan line
dbra d6,iloop
clr.l d7
rts
no_image
add.l #1280,d5
clr.l d7
rts
public _strip_draw
_strip_draw
movem.l d0-d7/a0-a6,-(sp)
move.l 64(sp),d5 ; strip number to draw
; initial register setups
move.l _image_mem,a6
move.l a6,-(sp)
lea _minimap,a6
add.l d5,a6 ; add 6*d5 to a6
add.l d5,a6
add.l d5,a6
add.l d5,a6
add.l d5,a6
add.l d5,a6
move.l #IPLAN_SZ,d1 ; 2nd plane offset
move.l #IPLAN_SZ*2,d2 ; 3rd plane offset
move.l #IPLAN_SZ*3,d3 ; 4th plane offset
move.l #IPLAN_SZ*4,d4 ; 5th plane offset
move.l _planes,a4
move.l 0(a4),a0 ; plane 1
move.l 4(a4),a1 ; plane 2
move.l 8(a4),a2 ; plane 3
move.l 12(a4),a3 ; plane 4
move.l 16(a4),a4 ; plane 5
clr.l d7 ; clear upper part
; move.w #0,d5
bsr.s next_strip
addq.l #4,sp
movem.l (sp)+,d0-d7/a0-a6
rts
public _row_draw
_row_draw
movem.l d0-d7/a0-a6,-(sp)
; initial register setups
move.l 64(sp),d0 ; row number to draw
move.l _image_mem,a6
move.l a6,-(sp)
lea _minimap,a6
add.l d0,a6 ; add row # to a6
mulu.w #640,d0 ; offset into bit plane
move.l #IPLAN_SZ,d1 ; 2nd plane offset
move.l #IPLAN_SZ*2,d2 ; 3rd plane offset
move.l #IPLAN_SZ*3,d3 ; 4th plane offset
move.l #IPLAN_SZ*4,d4 ; 5th plane offset
move.l _planes,a4
move.l 0(a4),a0 ; plane 1
move.l 4(a4),a1 ; plane 2
move.l 8(a4),a2 ; plane 3
move.l 12(a4),a3 ; plane 4
move.l 16(a4),a4 ; plane 5
clr.l d7 ; clear upper part
bsr.s next_char
addq.l #2,d0
bsr.s next_char
addq.l #2,d0
bsr.s next_char
addq.l #2,d0
bsr.s next_char
addq.l #2,d0
bsr.s next_char
addq.l #2,d0
bsr.s next_char
addq.l #2,d0
bsr.s next_char
addq.l #2,d0
bsr.s next_char
addq.l #2,d0
bsr.s next_char
addq.l #2,d0
bsr.s next_char
addq.l #2,d0
bsr.s next_char
addq.l #2,d0
bsr.s next_char
addq.l #2,d0
bsr.s next_char
addq.l #2,d0
bsr.s next_char
addq.l #2,d0
bsr.s next_char
addq.l #2,d0
bsr.s next_char
addq.l #2,d0
bsr.s next_char
addq.l #2,d0
bsr.s next_char
addq.l #2,d0
bsr.s next_char
addq.l #4,sp
movem.l (sp)+,d0-d7/a0-a6
rts
; this will be a long set of in-line code
next_char
move.l d0,d5 ; index the index
move.w (a6),d7 ; character number
bsr next_image
add.w #12,a6 ; next character in row
rts
public _maskit,_bmask_mem,_shadow_mem
; maskit(x,y,mod,char);
public _bigdraw,_secx,_secy
public _dbg
_bigdraw
movem.l d1-d7/a0-a6,-(sp) ; save regs
move.l _map_mem,a0
move.l _sector_mem,a1
move.l 60(sp),d0 ; map_x
move.l 64(sp),d1 ; map_y
; move.l #1,_dbg
lsr.w #8,d0
sub.w #9,d0 ; map_x>>8 - 9
sub.w _xreg,d0
lsr.w #8,d1 ; map_y>>8 - 4
sub.w #4,d1
sub.w _yreg,d1
cmp.w #32,d0
bge.s big10
add.w #128,d0
big10 cmp.w #96,d0
ble.s big20
sub.w #128,d0
big20 cmp.w #32,d1
bge.s big30
add.w #128,d1
big30 cmp.w #96,d1
ble.s big40
sub.w #128,d1
big40 cmp.w #0,d0
bge.s big50
clr.w d0
big50 cmp.w #64-18,d0
ble.s big60
move.w #64-18,d0
big60 cmp.w #0,d1
bge.s big70
clr.w d1
big70 cmp.w #32-9,d1
ble.s big80
move.w #32-9,d1
big80
move.l d0,_secx
move.l d1,_secy
clr.l d7 ; d7 is offset
clr.w d2 ; d2 is j
big100
move.w d2,d4 ; d4 is n = (secy+j)*128
add.w d1,d4
lsl.w #7,d4
clr.w d3 ; d3 is i
big110
move.w _xreg,d5 ; d5 is secx+i+xreg+n
add.w d0,d5 ; +secx
add.w d3,d5 ; +i
add.w d4,d5 ; +n
clr.l d6 ; d6 is map_mem[d5]
move.b (a0,d5.w),d6
lsl.w #7,d6 ; * 128
add.l a1,d6 ; d6 is address of sector in memory
bsr plotsect
addq.l #2,d7 ; offset += 2
addq #1,d3
cmp.w #18,d3
blt.s big110
add.l #(40*15)+4,d7 ; add to offset
addq #1,d2
cmp.w #9,d2
blt.s big100
movem.l (sp)+,d1-d7/a0-a6 ; restore regs
rts
plotsect movem.l d0-d7/a0-a6,-(sp) ; save regs
move.l d6,a6 ; sector data address
move.l d7,d0 ; plane offset
move.l _planes,a0
move.l 16(a0),a5 ; plane 5
move.l 12(a0),a3 ; plane 4
move.l 8(a0),a2 ; plane 3
move.l 4(a0),a1 ; plane 2
move.l (a0),a0 ; plane 0
move.l a0,_dbg
add.l d0,a0
add.l d0,a1
add.l d0,a2
add.l d0,a3
add.l d0,a5
move.l _terra_mem,a4
move.w #7,d7
scanlop
move.w #15,d6
colop