aboutsummaryrefslogtreecommitdiff
path: root/devtools/tasmrecover/dreamweb/backdrop.asm
blob: 5dfe20bf5d2e82368cb25dcd3ade4b82df08474c (plain)
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
;Copyright (c) 1990-2011 by Neil Dodwell
;Released with permission from Neil Dodwell under GPLv2
;See LICENSE file for full license text
;----------------------------------------------Code to draw floor and panel----

Blockget	proc	near

	mov	ah,al
	mov	al,0
	mov	ds,backdrop
	mov	si,blocks
	add	si,ax
	ret

	endp
















;--------------------------------------------------------Background display----








Drawfloor	proc	near

	push	es bx      	;in case this was called during
	call	eraseoldobs	;some sprite update.
	call	drawflags
	call	calcmapad
	call	doblocks
	call	showallobs
	call	showallfree
	call	showallex
	call	paneltomap
	call	initrain
	mov	newobs,0
	pop	bx es
	ret

	endp


















Calcmapad	proc	near

	call	getdimension

	push	cx dx

	mov	al,11
	sub	al,dl
	sub	al,cl
	sub	al,cl
	cbw
	mov	bx,8
	mul	bx
	add	ax,mapoffsetx
	mov	mapadx,ax
	pop	dx cx

	mov	al,10
	sub	al,dh
	sub	al,ch
	sub	al,ch
	cbw
	mov	bx,8
	mul	bx
	add	ax,mapoffsety
	mov	mapady,ax
	ret

	endp









Getdimension	proc	near	;Routine finds width, length
			;and top corner of room
	
	mov	es,buffers
	mov	bx,mapflags
	mov	ch,0
dimloop1:	call	addalong
	cmp	al,0
	jnz	finishdim1
	inc	ch
	jmp	dimloop1	;ch holds y of top corner

finishdim1:	mov	bx,mapflags
	mov	cl,0
dimloop2:	push	bx
	call	addlength
	pop	bx
	cmp	al,0
	jnz	finishdim2
	inc	cl
	add	bx,3
	jmp	dimloop2	;cl holds x of top corner

finishdim2:	mov	bx,mapflags+(11*3*9)
	mov	dh,10
dimloop3:	push	bx
	call	addalong
	pop	bx
	cmp	al,0
	jnz	finishdim3
	dec	dh
	sub	bx,11*3
	jmp	dimloop3	;dh holds y of bottom corner

finishdim3:	mov	bx,mapflags+(3*10)
	mov	dl,11
dimloop4:	push	bx
	call	addlength
	pop	bx
	cmp	al,0
	jnz	finishdim4
	dec	dl
	sub	bx,3
	jmp	dimloop4	;dl holds x of bottom corner

finishdim4:	mov	al,cl	;cl holds x start
	mov	ah,0
	shl	ax,1
	shl	ax,1
	shl	ax,1
	shl	ax,1
	mov	mapxstart,ax
	mov	al,ch	;ch holds y start
	mov	ah,0
	shl	ax,1
	shl	ax,1
	shl	ax,1
	shl	ax,1
	mov	mapystart,ax

	sub	dl,cl
	sub	dh,ch
				;dx holds x and y size of room
	mov	al,dl	;dl holds x size
	mov	ah,0
	shl	ax,1
	shl	ax,1
	shl	ax,1
	shl	ax,1
	mov	mapxsize,al
	mov	al,dh	;dh holds y size
	mov	ah,0
	shl	ax,1
	shl	ax,1
	shl	ax,1
	shl	ax,1
	mov	mapysize,al	;cx still holds top left corner
	ret

	endp












Addalong	proc	near

	mov	ah,11
addloop:	cmp	byte ptr [es:bx],0
	jnz	gotalong
	add	bx,3
	dec	ah
	jnz	addloop
	mov	al,0
	ret
gotalong:	mov	al,1
	ret

	endp





Addlength	proc	near

	mov	ah,10
addloop2:	cmp	byte ptr [es:bx],0
	jnz	gotlength
	add	bx,3*11
	dec	ah
	jnz	addloop2
	mov	al,0
	ret
gotlength:	mov	al,1
	ret

	endp




















Drawflags	proc	near

	mov	es,buffers
	mov	di,mapflags
	mov	al,mapy
	mov	ah,0
	mov	cx,mapwidth
	mul	cx
	mov	bl,mapx
	mov	bh,0
	add	ax,bx
	mov	si,map
	add	si,ax

	mov	cx,10
$28:	push	cx
	mov	cx,11
$28a:	mov	ds,mapdata
	lodsb
	mov	ds,backdrop
	push	si ax
	mov	ah,0
	add	ax,ax
	mov	si,flags
	add	si,ax
	movsw
	pop	ax
	stosb
	pop	si
	loop	$28a
	add	si,mapwidth-11
	pop	cx
	loop	$28
	ret

	endp














;-------------------------------------------------------Set object printing----

Eraseoldobs	proc	near

	cmp	newobs,0
	jz	donterase

	mov	es,buffers
	mov	bx,spritetable
	
	mov	cx,16
oberase:	push	cx bx
	mov	ax,[es:bx+20]
	cmp	ax,0ffffh
	jz	notthisob
	mov	di,bx
	mov	al,255
	mov	cx,tablesize
	rep	stosb
notthisob:	pop	bx cx
	add	bx,tablesize
	loop	oberase

donterase:	ret

	endp




















Showallobs	proc	near

	mov	es,buffers
	mov	bx,setlist
	mov	listpos,bx
	mov	di,bx
	mov	cx,128*5
	mov	al,255
	rep	stosb
		
	mov	es,setframes
	mov	frsegment,es
	mov	ax,framedata
	mov	dataad,ax
	mov	ax,frames
	mov	framesad,ax
	mov	currentob,0

	mov	ds,setdat
	mov	si,0
	
	mov	cx,128
showobsloop:	push	cx si

	push	si
	add	si,58
	mov	es,setdat
	call	getmapad
	pop	si
	cmp	ch,0
	jz	blankframe

	mov	al,[es:si+18]
	mov	ah,0
	mov	currentframe,ax
	cmp	al,255
	jz	blankframe

	push	es si
	call	calcfrframe
	call	finalframe
	pop	si es

	mov	al,[es:si+18]
	mov	[es:si+17],al
	cmp	byte ptr [es:si+8],0
	jnz	animating
	cmp	byte ptr [es:si+5],5
	jz	animating
	cmp	byte ptr [es:si+5],6
	jz	animating
	mov	ax,currentframe
	mov	ah,0
	add	di,mapadx
	add	bx,mapady
	call	showframe
	jmp	drawnsetob

animating:	call	makebackob

drawnsetob:	mov	si,listpos
	mov	es,buffers
	mov	al,savex
	mov	ah,savey
	mov	[es:si],ax
	mov	cx,ax
	mov	ax,savesize
	add	al,cl
	add	ah,ch
	mov	[es:si+2],ax
	mov	al,currentob
	mov	[es:si+4],al
	add	si,5
	mov	listpos,si

blankframe:	inc	currentob
	pop	si cx
	add	si,64
	dec	cx
	jz	finishedsetobs
	jmp	showobsloop

finishedsetobs: ret

	endp














Makebackob	proc	near

	cmp	newobs,0
	jz	nomake

	mov	al,[es:si+5]	 ; priority
	mov	ah,[es:si+8]	 ; type - steady, constant,random,door etc.
	push	si ax si
	mov	ax,objectx
	mov	bx,objecty
	mov	ah,bl
	mov	si,ax
	mov	cx,offset cs:backobject
	mov	dx,setframes
	mov	di,framedata
	call	makesprite
	pop	ax
	mov	[es:bx+20],ax
	pop	ax
	cmp	al,255
	jnz	usedpriority	 ; forgotten to specify priority
	mov	al,0
usedpriority:	mov	[es:bx+23],al
	mov	[es:bx+30],ah
	mov	byte ptr [es:bx+16],0
	mov	byte ptr [es:bx+18],0
	mov	byte ptr [es:bx+19],0
	pop	si
nomake: 	ret

	endp




;------------------------------------------------------Free object printing----

Showallfree	proc	near

	mov	es,buffers
	mov	bx,freelist
	mov	listpos,bx
	mov	di,freelist
	mov	cx,80*5
	mov	al,255
	rep	stosb

	mov	es,freeframes
	mov	frsegment,es
	mov	ax,frframedata
	mov	dataad,ax
	mov	ax,frframes
	mov	framesad,ax
	mov	al,0
	mov	currentfree,al

	mov	ds,freedat
	mov	si,2
	
	mov	cx,0
loop127:	push	cx si

	push	si
	mov	es,freedat
	call	getmapad
	pop	si
	cmp	ch,0
	jz	over138

	mov	al,currentfree
	mov	ah,0
	mov	dx,ax
	add	ax,ax
	add	ax,dx
	mov	currentframe,ax
		
	push	es si
	call	calcfrframe
	mov	es,mapstore
	mov	ds,frsegment
	call	finalframe
	pop	si es
	cmp	cx,0
	jz	over138

	mov	ax,currentframe
	mov	ah,0
	add	di,mapadx
	add	bx,mapady
	call	showframe
	mov	si,listpos
	mov	es,buffers
	mov	al,savex
	mov	ah,savey
	mov	[es:si],ax
	mov	cx,ax
	mov	ax,savesize
	add	al,cl
	add	ah,ch
	mov	[es:si+2],ax
	pop	ax cx
	push	cx ax
	mov	[es:si+4],cl
	add	si,5
	mov	listpos,si

over138:	inc	currentfree
	pop	si cx
	add	si,16
	inc	cx
	cmp	cx,80
	jz	finfree
	jmp	loop127

finfree:	ret

	endp












Showallex	proc	near

	mov	es,buffers
	mov	bx,exlist
	mov	listpos,bx
	mov	di,exlist
	mov	cx,100*5
	mov	al,255
	rep	stosb

	mov	es,extras
	mov	frsegment,es
	mov	ax,exframedata
	mov	dataad,ax
	mov	ax,exframes
	mov	framesad,ax
	mov	currentex,0

	mov	si,exdata+2
	
	mov	cx,0
exloop:	push	cx si

	mov	es,extras

	push	si
	mov	ch,0
 	cmp	byte ptr [es:si],255
	jz	notinroom
	mov	al,[es:si-2]
	cmp	al,reallocation
	jnz	notinroom
	call	getmapad
notinroom:	pop	si
	cmp	ch,0
	jz	blankex

	mov	al,currentex
	mov	ah,0
	mov	dx,ax
	add	ax,ax
	add	ax,dx
	mov	currentframe,ax
		
	push	es si
	call	calcfrframe
	mov	es,mapstore
	mov	ds,frsegment
	call	finalframe
	pop	si es
	cmp	cx,0
	jz	blankex

	mov	ax,currentframe
	mov	ah,0
	add	di,mapadx
	add	bx,mapady
	call	showframe
	mov	si,listpos
	mov	es,buffers
	mov	al,savex
	mov	ah,savey
	mov	[es:si],ax
	mov	cx,ax
	mov	ax,savesize
	add	al,cl
	add	ah,ch
	mov	[es:si+2],ax
	pop	ax cx
	push	cx ax
	mov	[es:si+4],cl
	add	si,5
	mov	listpos,si

blankex:	inc	currentex
	pop	si cx
	add	si,16
	inc	cx
	cmp	cx,100
	jz	finex
	jmp	exloop

finex:	ret

	endp







Calcfrframe	proc	near
	
	mov	dx,frsegment
	mov	ax,framesad
	push	ax
	mov	cx,dataad
	mov	ax,currentframe
	mov	ds,dx
	mov	bx,6
	mul	bx
	add	ax,cx
	mov	bx,ax
	mov	cx,[bx]
	mov	ax,[bx+2]
	mov	dx,[bx+4]
	pop	bx
	push	dx
	add	ax,bx		 ;ax=source add, cx=x,y
				;need this later
	mov	savesource,ax
	mov	savesize,cx
	pop	ax
	push	ax
	mov	ah,0
	mov	offsetx,ax
	pop	ax
	mov	al,ah
	mov	ah,0
	mov	offsety,ax
	ret
nullframe:	pop	ax
	mov	cx,0
	mov	savesize,cx
	ret

	endp


















Finalframe	proc	near
	
	mov	ax,objecty
	add	ax,offsety
	mov	bx,objectx
	add	bx,offsetx
	mov	savex,bl
	mov	savey,al
	mov	di,objectx
	mov	bx,objecty
	ret

	endp


	










Adjustlen	proc	near

	mov	ah,al
	add	al,ch
	cmp	al,100
	jc	over242
	mov	al,224
	sub	al,ch
	mov	ch,al
over242:	ret

	endp









Getmapad	proc	near

	call	getxad
	cmp	ch,0
	jz	over146
	mov	objectx,ax
	call	getyad
	cmp	ch,0
	jz	over146
	mov	objecty,ax
	mov	ch,1
over146:	ret
	
	endp









Getxad	proc	near

	mov	cl,[es:si]
	inc	si
	mov	al,[es:si]
	inc	si
	mov	ah,[es:si]
	inc	si
	cmp	cl,0
	jnz	over148
	sub	al,mapx
	jc	over148
	cmp	al,11
	jnc	over148
	mov	cl,4
	shl	al,cl
	or	al,ah
	mov	ah,0
	mov	ch,1
	ret
over148:	mov	ch,0
	ret

	endp









Getyad	proc	near

	mov	al,[es:si]
	inc	si
	mov	ah,[es:si]
	inc	si
	sub	al,mapy
	jc	over147
	cmp	al,10
	jnc	over147
	mov	cl,4
	shl	al,cl
	or	al,ah
	mov	ah,0
	mov	ch,1
	ret

over147:	mov	ch,0
	ret

	endp