1;Copyright (c) 1990-2012 by Neil Dodwell
2;Released with permission from Neil Dodwell under GPLv2
3;See LICENSE file for full license text
4
5
6
7
8
9
10
11
12
13;�������������������������������������������������������������������Ŀ
14;�			              �
15;�	DREAMWEB16;�			              �
17;�			              �
18;�			              �
19;�			              �
20;�	Written by Neil Dodwell. Graphics by Dave Dew.    �
21;�			              �
22;�	Started on Friday 28 December 1990 at 1:20 pm23;�			              �
24;�	Copyright 1990/1991 Creative Reality              �	�
25;�			              �
26;�			              �
27;���������������������������������������������������������������������
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43;----------------------------------------------------------Assembly options----
44
45JUMPS
46
47playback	equ	0
48recording	equ	0
49debuglevel1	equ	0	;memory debug on
50debuglevel2	equ	0	;debug keys on+shouts
51demo	equ	0
52CD	equ	1
53Foreign	equ	1
54Spanish	equ	0
55German	equ	0
56
57;----------------------------------------------------------------Code start----
58
59DREAMWEBPROG	segment para public 'CODE'
60
61	assume	cs:DREAMWEBPROG,ss:STACKSPACE
62
63
64
65
66;------------------------------------------------------------------Includes----
67
68include \pc\dreamweb\vars.asm	;variables and equates
69include \pc\dreamweb\sprite.asm	;sprite routines
70include \pc\dreamweb\vgagrafx.asm	;screen routines for vga
71include \pc\dreamweb\vgafades.asm	;fade routines
72include \pc\dreamweb\titles.asm	;guess!
73include \pc\dreamweb\print.asm	;text printing routines
74include \pc\dreamweb\object.asm	;pickup
75include \pc\dreamweb\backdrop.asm	;draws floor etc.
76include \pc\dreamweb\look.asm	;look command
77include \pc\dreamweb\talk.asm	;conversations
78include \pc\dreamweb\newplace.asm	;travel
79include \pc\dreamweb\monitor.asm	;network machine
80include \pc\dreamweb\use.asm	;individual use routines
81include \pc\dreamweb\keypad.asm	;accept code with keypad
82include \pc\dreamweb\saveload.asm	;in game options
83include \pc\dreamweb\sblaster.asm
84	if	debuglevel1
85include \pc\dreamweb\debug.asm
86	else
87	if	debuglevel2
88include \pc\dreamweb\debug.asm
89	endif
90	endif
91
92;-----------------------------------------------------------------Main loop----
93
94
95Dreamweb	proc	near
96
97	call	seecommandtail
98
99	call	checkbasemem
100	call	soundstartup
101	call	setkeyboardint
102	call	setupemm
103	call	allocatebuffers
104	call	setmouse
105	call	fadedos
106	call	gettime
107
108	call	clearbuffers
109	call	clearpalette
110	call	set16colpalette
111	call	readsetdata
112	if	demo
113	call	changeroomnums
114	endif
115	mov	wongame,0
116
117	mov	dx,offset cs:basicsample
118	call	loadsample
119	call	setsoundoff
120
121	if	demo
122	else
123	call	scanfornames
124           	cmp	al,0
125	jnz	dodecisions
126	endif
127
128	call	setmode
129	call	loadpalfromiff
130
131	call	titles
132	call	credits
133	jmp	playgame
134
135dodecisions:	call	cls
136	call	setmode
137	call	decide
138
139	cmp quitrequested, 0
140	jnz exitgame
141
142	cmp	getback,4
143	jz	mainloop
144
145	call	titles
146
147	cmp quitrequested, 0
148	jnz exitgame
149
150	call	credits
151
152playgame:
153	cmp quitrequested, 0
154	jnz exitgame
155	call	clearchanges
156	call	setmode
157	call	loadpalfromiff
158	mov	location,255
159	mov	roomafterdream,1
160	if	demo
161	mov	newlocation,5
162	else
163	mov	newlocation,35
164	endif
165	mov	volume,7
166	call	loadroom
167	call	clearsprites
168	call	initman
169	call	entrytexts
170	call	entryanims
171	mov	destpos,3
172	call	initialinv
173	mov	lastflag,32
174	call	startup1
175	mov	volumeto,0
176	mov	volumedirection,-1
177	mov	commandtype,255
178	jmp	mainloop
179
180loadnew:	if	demo
181	cmp	newlocation,27
182	jnz	not27
183      	call	fadescreendowns
184	mov	cx,260
185	call	hangon
186	call	clearbeforeload
187	jmp	playgame
188not27:
189	endif
190	call	clearbeforeload
191	call	loadroom
192	call	clearsprites
193	call	initman
194	call	entrytexts
195	call	entryanims
196	mov	newlocation,255
197	call	startup
198	mov	commandtype,255
199	call	worktoscreenm
200	jmp	mainloop
201
202alreadyloaded:	mov	newlocation,255
203	call	clearsprites
204	call	initman
205	call	startup
206	mov	commandtype,255
207
208mainloop:
209	cmp quitrequested, 0
210	jnz exitgame
211
212	call	screenupdate
213	cmp	wongame,0
214	jnz	endofgame
215	cmp	mandead,1
216	jz	gameover
217	cmp	mandead,2
218	jz	gameover
219	cmp	watchingtime,0
220	jz	notwatching
221	mov	al,finaldest
222	cmp	al,manspath
223	jnz	mainloop
224	dec	watchingtime
225	jnz	mainloop
226
227notwatching:	cmp	mandead,4
228	jz	gameover
229	cmp	newlocation,255
230	jnz	loadnew
231	jmp	mainloop
232
233gameover:	if	demo
234      	call	fadescreendowns
235	mov	cx,260
236	call	hangon
237	call	clearbeforeload
238	jmp	playgame
239	endif
240	call	clearbeforeload
241	call	showgun
242	call	fadescreendown
243	mov	cx,100
244	call	hangon
245	jmp	dodecisions
246
247endofgame:	call	clearbeforeload
248	call	fadescreendowns
249	mov	cx,200
250	call	hangon
251	call	endgame
252	jmp	quickquit2
253
254exitgame:
255	ret
256	endp
257
258
259
260
261	endp
262
263
264
265	if	demo
266
267Changeroomnums	proc	near
268
269	mov	di,offset cs:roomdata+10
270	mov	cx,50
271changenumloop:	mov	al,[cs:di]
272	cmp	al,"0"
273	jnz	nochange
274	mov	al,[cs:di+1]
275	cmp	al,"5"
276	jnz	nochange
277	mov	al,"6"
278	mov	ah,"0"
279	mov	[cs:di],ax
280nochange: 	add	di,32
281	loop	changenumloop
282	ret
283
284	endp
285
286	endif
287
288
289
290
291Entrytexts	proc	near
292
293	cmp	location,21
294	jnz	notloc15
295	mov	al,28
296	mov	cx,60
297	mov	dx,11
298	mov	bl,68
299	mov	bh,64
300	call	setuptimeduse
301	ret
302notloc15:	cmp	location,30
303	jnz	notloc43
304	mov	al,27
305	mov	cx,60
306	mov	dx,11
307	mov	bl,68
308	mov	bh,64
309	call	setuptimeduse
310	ret
311notloc43:	cmp	location,23
312	jnz	notloc23
313	mov	al,29
314	mov	cx,60
315	mov	dx,11
316	mov	bl,68
317	mov	bh,64
318	call	setuptimeduse
319	ret
320notloc23:	cmp	location,31
321	jnz	notloc44
322	mov	al,30
323	mov	cx,60
324	mov	dx,11
325	mov	bl,68
326	mov	bh,64
327	call	setuptimeduse
328	ret
329notloc44:	cmp	location,20
330	jnz	notsarters2
331	mov	al,31
332	mov	cx,60
333	mov	dx,11
334	mov	bl,68
335	mov	bh,64
336	call	setuptimeduse
337	ret
338notsarters2:	cmp	location,24
339	jnz	notedenlob
340	mov	al,32
341	mov	cx,60
342	mov	dx,3
343	mov	bl,68
344	mov	bh,64
345	call	setuptimeduse
346	ret
347notedenlob:	cmp	location,34
348	jnz	noteden2
349	mov	al,33
350	mov	cx,60
351	mov	dx,3
352	mov	bl,68
353	mov	bh,64
354	call	setuptimeduse
355	ret
356noteden2:	ret
357
358	endp
359
360
361
362
363
364
365
366
367Entryanims	proc	near
368
369	mov	reeltowatch,-1
370	mov	watchmode,-1
371	cmp	location,33
372	jnz	notinthebeach
373	call	switchryanoff
374	mov	watchingtime,76*2
375	mov	reeltowatch,0
376	mov	endwatchreel,76
377	mov	watchspeed,1
378	mov	speedcount,1
379	ret
380notinthebeach:	cmp	location,44
381	jnz	notsparkys
382	mov	al,8
383	call	resetlocation
384	mov	watchingtime,50*2
385	mov	reeltowatch,247
386	mov	endwatchreel,297
387	mov	watchspeed,1
388	mov	speedcount,1
389	call	switchryanoff
390	ret
391notsparkys:	cmp	location,22
392	jnz	notinthelift
393	mov	watchingtime,31*2
394	mov	reeltowatch,0
395	mov	endwatchreel,30
396	mov	watchspeed,1
397	mov	speedcount,1
398	call	switchryanoff
399	ret
400notinthelift:	cmp	location,26
401	jnz	notunderchurch
402	mov	symboltopnum,2
403	mov	symbolbotnum,1
404	ret
405notunderchurch:	cmp	location,45
406	jnz	notenterdream
407	mov	keeperflag,0
408	mov	watchingtime,296
409	mov	reeltowatch,45
410	mov	endwatchreel,198
411	mov	watchspeed,1
412	mov	speedcount,1
413	call	switchryanoff
414	ret
415notenterdream:	cmp	reallocation,46
416	jnz	notcrystal
417	cmp	sartaindead,1
418	jnz	notcrystal
419           	mov	al,0
420	call	removefreeobject
421	ret
422notcrystal:	cmp	location,9
423	jnz	nottopchurch
424	mov	al,2
425	call	checkifpathison
426	jz	nottopchurch
427	cmp	aidedead,0
428	jz	nottopchurch
429	mov	al,3
430	call	checkifpathison
431	jnz	makedoorsopen
432	mov	al,2
433	call	turnpathon
434makedoorsopen:	mov	al,4
435	call	removesetobject
436	mov	al,5
437	call	placesetobject
438	ret
439nottopchurch:	cmp	location,47
440	jnz	notdreamcentre
441	mov	al,4
442	call	placesetobject
443	mov	al,5
444	call	placesetobject
445	ret
446notdreamcentre:	cmp	location,38
447	jnz	notcarpark
448	mov	watchingtime,57*2
449	mov	reeltowatch,4
450	mov	endwatchreel,57
451	mov	watchspeed,1
452	mov	speedcount,1
453	call	switchryanoff
454	ret
455notcarpark:	cmp	location,32
456	jnz	notalley
457	mov	watchingtime,66*2
458	mov	reeltowatch,0
459	mov	endwatchreel,66
460	mov	watchspeed,1
461	mov	speedcount,1
462	call	switchryanoff
463	ret
464notalley:	cmp	location,24
465	jnz	notedensagain
466	mov	al,2
467	mov	ah,roomnum
468	dec	ah
469	call	turnanypathon
470notedensagain:	ret
471
472	endp
473
474
475
476
477
478
479	if	demo
480Initialinv	proc	near
481
482	mov	al,11
483	mov	ah,5
484	call	pickupob
485	mov	al,12
486	mov	ah,6
487	call	pickupob
488	mov	al,13
489	mov	ah,7
490	call	pickupob
491	mov	al,14
492	mov	ah,8
493	call	pickupob
494	mov	al,18
495	mov	ah,0
496	call	pickupob
497	mov	al,19
498	mov	ah,1
499	call	pickupob
500	mov	al,20
501	mov	ah,9
502	call	pickupob
503	mov	al,16
504	mov	ah,2
505	call	pickupob
506
507	mov	al,2
508	mov	ah,4
509	call	pickupob
510
511	mov	al,29
512	mov	ah,10
513	call	pickupob
514	mov	al,33
515	mov	ah,11
516	call	pickupob
517	mov	al,44
518	mov	ah,12
519	call	pickupob
520	mov	card1money,12342
521	ret
522
523	endp
524	else
525Initialinv	proc	near
526
527	cmp	reallocation,24
528	jz	isedens
529	ret
530
531isedens:	mov	al,11
532	mov	ah,5
533	call	pickupob
534	mov	al,12
535	mov	ah,6
536	call	pickupob
537	mov	al,13
538	mov	ah,7
539	call	pickupob
540	mov	al,14
541	mov	ah,8
542	call	pickupob
543	mov	al,18
544	mov	al,18
545	mov	ah,0
546	call	pickupob
547	mov	al,19
548	mov	ah,1
549	call	pickupob
550	mov	al,20
551	mov	ah,9
552	call	pickupob
553	mov	al,16
554	mov	ah,2
555	call	pickupob
556
557	mov	watchmode,1
558	mov	reeltohold,0
559	mov	endofholdreel,6
560	mov	watchspeed,1
561	mov	speedcount,1
562	call	switchryanoff
563	ret
564
565	endp
566
567	endif
568
569
570
571
572
573
574
575
576
577
578
579Pickupob	proc	near
580
581	mov	lastinvpos,ah
582	mov	objecttype,2
583	mov	itemframe,al
584	mov	command,al
585	call	getanyad
586	call	transfertoex
587	ret
588
589	endp
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605;---------------------------------------------------------Memory allocation----
606
607
608
609
610Setupemm	proc	near
611
612	cmp	soundint,255
613	jz	noneedforemm
614	call	checkforemm
615
616	mov	ah,43h	;allocate handle and 160 pages
617	mov	bx,176 	;was 176
618	int	67h
619	cmp	ah,0
620	jnz	emmerror1	;if there's an error drop to DOS
621	mov	emmhandle,dx
622	mov	ah,41h	;get the page frame base address
623	int	67h
624	cmp	ah,0
625	jnz	emmerror1
626	mov	emmpageframe,bx
627 	mov	ax,bx
628	mov	cl,12
629	shr	ax,cl
630	mov	emmhardwarepage,al
631noneedforemm:	ret
632emmerror1:	mov	gameerror,1
633	jmp	quickquit2
634
635	endp
636
637
638
639
640
641
642
643
644Removeemm	proc	near
645
646	cmp	soundint,255
647	jz	noneedtoremove
648	mov	ah,45h
649	mov	dx,emmhandle
650	int	67h
651noneedtoremove:	ret
652
653	endp
654
655
656
657
658
659Checkforemm	proc	near
660
661	ret
662
663	endp
664
665
666
667
668Checkbasemem	proc	near
669
670	mov	bx,howmuchalloc
671	cmp	bx,9360h
672	jnc	enoughmem
673          	mov	gameerror,5
674	jmp	quickquit
675enoughmem:	ret
676
677	endp
678
679
680
681Allocatebuffers	proc	near
682
683	mov	bx,lengthofextra/16
684	call	allocatemem
685	mov	extras,ax
686
687	call	trysoundalloc
688	mov	bx,lengthofmap/16
689	call	allocatemem
690	mov	mapdata,ax
691
692	call	trysoundalloc
693	mov	bx,lengthofbuffer/16
694	call	allocatemem
695	mov	buffers,ax
696
697	call	trysoundalloc
698	mov	bx,freedatlen/16
699	call	allocatemem
700	mov	freedat,ax
701
702	call	trysoundalloc
703	mov	bx,setdatlen/16
704	call	allocatemem
705	mov	setdat,ax
706
707	call	trysoundalloc
708	mov	bx,lenofmapstore/16
709	call	allocatemem
710	mov	mapstore,ax
711
712	if	recording
713	mov	bx,1028
714	call	allocatemem
715	mov	recordspace,ax
716	endif
717
718	if	playback
719	mov	bx,1028
720	call	allocatemem
721	mov	recordspace,ax
722	endif
723
724	call	allocatework
725
726	mov	bx,2048/16
727	call	allocatemem
728	mov	sounddata,ax
729
730	mov	bx,2048/16
731	call	allocatemem
732	mov	sounddata2,ax
733	ret
734
735	endp
736
737
738
739
740
741
742
743
744
745
746Clearbuffers	proc	near
747
748	mov	es,buffers
749	mov	cx,lengthofbuffer/2
750	mov	ax,0
751	mov	di,0
752	rep	stosw
753
754	mov	es,extras
755	mov	cx,lengthofextra/2
756	mov	ax,0ffffh
757	mov	di,0
758	rep	stosw
759
760	mov	es,buffers
761	mov	di,initialreelrouts
762	push	cs
763	pop	ds
764	mov	si,offset cs:reelroutines
765	mov	cx,lenofreelrouts
766	rep	movsb
767
768	mov	es,buffers
769	mov	di,initialvars
770	push	cs
771	pop	ds
772	mov	si,offset cs:startvars
773	mov	cx,lengthofvars
774	rep	movsb
775	call	clearchanges
776	ret
777
778	endp
779
780
781
782
783
784
785Clearchanges	proc	near
786
787	mov	es,buffers
788	mov	cx,numchanges*2
789	mov	ax,0ffffh
790	mov	di,listofchanges
791	rep	stosw
792	mov	ds,buffers
793	mov	si,initialreelrouts
794	push	cs
795	pop	es
796	mov	di,offset cs:reelroutines
797	mov	cx,lenofreelrouts
798	rep	movsb
799
800	mov	ds,buffers
801	mov	si,initialvars
802	push	cs
803	pop	es
804	mov	di,offset cs:startvars
805	mov	cx,lengthofvars
806	rep	movsb
807
808	mov	expos,0
809	mov	exframepos,0
810	mov	extextpos,0
811	mov	es,extras
812	mov	cx,lengthofextra/2
813	mov	ax,0ffffh
814	mov	di,0
815	rep	stosw
816
817	push	cs
818	pop	es
819	mov	di,offset cs:roomscango
820	mov	al,1
821	stosb
822	stosb
823	mov	al,0
824	stosb
825	mov	al,1
826	stosb
827	mov	ax,0
828	mov	cx,6
829	rep	stosw
830	ret
831
832	endp
833
834
835
836
837
838
839
840Clearbeforeload	proc	near	;deallocates variable buffers
841			;and clears out fixed ones
842	cmp	roomloaded,1
843	jnz	noclear
844	call	clearreels
845	call	clearrest
846	mov	roomloaded,0
847noclear:	ret
848
849	endp
850
851
852
853;Clearnoreels	proc	near
854;
855;	cmp	roomloaded,1
856;	jnz	noclear2
857;	call	clearrest
858;	mov	roomloaded,0
859;noclear2:	ret
860;
861;	endp
862
863
864
865
866
867
868Clearreels	proc	near
869
870	mov	es,reel1
871	call	deallocatemem
872	mov	es,reel2
873	call	deallocatemem
874	mov	es,reel3
875	call	deallocatemem
876	ret
877
878	endp
879
880
881
882Clearrest	proc	near
883
884	mov	es,mapdata
885	mov	cx,maplen/2
886	mov	ax,0
887	mov	di,map
888	rep	stosw
889
890	mov	es,backdrop
891	call	deallocatemem
892	mov	es,setframes
893	call	deallocatemem
894	mov	es,reels
895	call	deallocatemem
896	mov	es,people
897	call	deallocatemem
898	mov	es,setdesc
899	call	deallocatemem
900	mov	es,blockdesc
901	call	deallocatemem
902	mov	es,roomdesc
903	call	deallocatemem
904	mov	es,freeframes
905	call	deallocatemem
906	mov	es,freedesc
907	call	deallocatemem
908	ret
909
910	endp
911
912
913
914
915
916
917Deallocatemem	proc	near
918
919	mov	ah,49h
920	int	21h
921	jc	deallerror
922	ret
923deallerror:	mov	gameerror,4
924	jmp	quickquit2
925	ret
926
927	endp
928
929
930
931
932
933
934
935
936Allocatemem	proc	near
937
938	add	bx,2
939	mov	ah,48h
940	int	21h
941	jc	memerror
942	ret
943
944memerror:	mov	gameerror,3
945	jmp	quickquit2
946
947	endp
948
949
950
951
952Seecommandtail	proc	near
953
954	mov	soundbaseadd,220h
955	mov	soundint,5
956	mov	sounddmachannel,1
957	mov	brightness,0
958
959	mov	bx,2
960	mov	ax,[es:bx]
961	mov	dx,es
962	sub	ax,dx
963	mov	howmuchalloc,ax
964
965	mov	bx,02ch
966	mov	ax,[es:bx]
967	push	es bx
968
969	mov	es,ax
970	mov	bx,0
971findblaster:	mov	ax,[es:bx]
972	cmp	ax,0
973	jz	endofenvironment
974	cmp	al,"B"
975	jnz	notblast
976	cmp	ah,"L"
977	jnz	notblast
978	cmp	byte ptr [es:bx+2],"A"
979	jnz	notblast
980	cmp	byte ptr [es:bx+3],"S"
981	jnz	notblast
982	cmp	byte ptr [es:bx+4],"T"
983	jnz	notblast
984	cmp	byte ptr [es:bx+5],"E"
985	jnz	notblast
986	cmp	byte ptr [es:bx+6],"R"
987	jnz	notblast
988	add	bx,7
989	call	parseblaster
990	jmp	endofenvironment
991notblast:	inc	bx
992	jmp	findblaster
993
994endofenvironment:	pop	bx es
995	mov	bx,81h
996	call	parseblaster
997	ret
998
999	endp
1000
1001
1002
1003Parseblaster	proc	near
1004
1005lookattail:	mov	al,[es:bx]
1006	cmp	al,0
1007	jz	endtail
1008	cmp	al,13
1009	jz	endtail
1010	cmp	al,"i"
1011	jz	issoundint
1012	cmp	al,"I"
1013	jz	issoundint
1014	cmp	al,"b"
1015	jz	isbright
1016	cmp	al,"B"
1017	jz	isbright
1018	cmp	al,"a"
1019	jz	isbaseadd
1020	cmp	al,"A"
1021	jz	isbaseadd
1022	cmp	al,"n"
1023	jz	isnosound
1024	cmp	al,"N"
1025	jz	isnosound
1026	cmp	al,"d"
1027	jz	isdma
1028	cmp	al,"D"
1029	jz	isdma
1030	inc	bx
1031	loop	lookattail
1032	ret
1033
1034issoundint:	mov	al,[es:bx+1]
1035	sub	al,"0"
1036	mov	soundint,al
1037	inc	bx
1038	jmp	lookattail
1039isdma:	mov	al,[es:bx+1]
1040	sub	al,"0"
1041	mov	sounddmachannel,al
1042	inc	bx
1043	jmp	lookattail
1044isbaseadd:	push 	cx
1045	mov	al,[es:bx+2]
1046	sub	al,"0"
1047	mov	ah,0
1048	mov	cl,4
1049	shl	ax,cl
1050	add	ax,200h
1051	mov	soundbaseadd,ax
1052	pop	cx
1053	inc	bx
1054	jmp	lookattail
1055isbright:	mov	brightness,1
1056	inc	bx
1057	jmp	lookattail
1058isnosound:	mov	soundint,255
1059	inc	bx
1060	jmp	lookattail
1061endtail: 	ret
1062
1063	endp
1064
1065
1066
1067
1068;-------------------------------------------------------High level routines----
1069
1070Startup	proc	near
1071
1072	mov	currentkey,0
1073	mov	mainmode,0
1074	call	createpanel
1075	mov	newobs,1
1076	call	drawfloor
1077	call	showicon
1078	call	getunderzoom
1079	call	spriteupdate
1080	call	printsprites
1081	call	undertextline
1082	call	reelsonscreen
1083	call	atmospheres
1084	ret
1085
1086	endp
1087
1088
1089
1090
1091Startup1	proc	near
1092
1093
1094	call	clearpalette
1095	mov	throughdoor,0
1096	mov	currentkey,"0"
1097	mov	mainmode,0
1098	call	createpanel
1099	mov	newobs,1
1100	call	drawfloor
1101
1102	call	showicon
1103	call	getunderzoom
1104	call	spriteupdate
1105	call	printsprites
1106	call	undertextline
1107	call	reelsonscreen
1108	call	atmospheres
1109	call	worktoscreen
1110	call	fadescreenup
1111	ret
1112
1113	endp
1114
1115
1116
1117
1118
1119
1120
1121
1122;--------------------------------------------------Scroll location routines----
1123
1124
1125
1126
1127
1128Screenupdate	proc	near
1129
1130	call	newplace
1131	call	mainscreen
1132	cmp quitrequested, 0
1133	jnz finishearly
1134	call	animpointer
1135	call	showpointer
1136	cmp	watchingtime,0
1137	jnz	iswatchingmode
1138	cmp	newlocation,255
1139	jnz	finishearly
1140iswatchingmode:	call	vsync
1141	call	readmouse1
1142	call	dumppointer
1143	call	dumptextline
1144	call	delpointer
1145	call	autolook
1146	call	spriteupdate
1147	call	watchcount
1148	call	zoom
1149	call	showpointer
1150	cmp	wongame,0
1151	jnz	finishearly
1152
1153	call	vsync
1154	call	readmouse2
1155	call	dumppointer
1156	call	dumpzoom
1157	call	delpointer
1158	call	deleverything
1159	call	printsprites
1160	call	reelsonscreen
1161	call	afternewroom
1162	call	showpointer
1163
1164	call	vsync
1165	call	readmouse3
1166	call	dumppointer
1167	call	dumpmap
1168	call	dumptimedtext
1169	call	delpointer
1170	call	showpointer
1171
1172	call	vsync
1173	call	readmouse4
1174	call	dumppointer
1175	call	dumpwatch
1176	call	delpointer
1177
1178finishearly:	ret
1179
1180	endp
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196Watchreel	proc	near
1197
1198	cmp	reeltowatch,-1
1199	jz	notplayingreel
1200	mov	al,manspath
1201	cmp	al,finaldest
1202	jnz	waitstopwalk
1203	mov	al,turntoface
1204	cmp	al,facing
1205	jz	notwatchpath
1206waitstopwalk:	ret
1207
1208notwatchpath:	dec	speedcount
1209	cmp	speedcount,-1
1210	jnz	showwatchreel
1211	mov	al,watchspeed
1212	mov	speedcount,al
1213	mov	ax,reeltowatch
1214	cmp	ax,endwatchreel
1215	jnz	ismorereel
1216	cmp	watchingtime,0
1217	jnz	showwatchreel
1218	mov	reeltowatch,-1
1219	mov	watchmode,-1
1220	cmp	reeltohold,-1
1221	jz	nomorereel
1222	mov	watchmode,1
1223	jmp	notplayingreel
1224ismorereel:	inc	reeltowatch
1225showwatchreel:	mov	ax,reeltowatch
1226	mov	reelpointer,ax
1227	call	plotreel
1228	mov	ax,reelpointer
1229	mov	reeltowatch,ax
1230	call	checkforshake
1231nomorereel:	ret
1232
1233
1234notplayingreel: cmp	watchmode,1
1235	jnz	notholdingreel
1236	mov	ax,reeltohold
1237	mov	reelpointer,ax
1238	call	plotreel
1239	ret
1240
1241notholdingreel: cmp	watchmode,2
1242	jnz	notreleasehold
1243	dec	speedcount
1244	cmp	speedcount,-1
1245	jnz	notlastspeed2
1246	mov	al,watchspeed
1247	mov	speedcount,al
1248	inc	reeltohold
1249notlastspeed2:	mov	ax,reeltohold
1250	cmp	ax,endofholdreel
1251	jnz	ismorereel2
1252	mov	reeltohold,-1
1253	mov	watchmode,-1
1254	mov	al,destafterhold
1255	mov	destination,al
1256	mov	finaldest,al
1257	call	autosetwalk
1258	ret
1259ismorereel2:	mov	ax,reeltohold
1260	mov	reelpointer,ax
1261	call	plotreel
1262	ret
1263
1264notreleasehold:	ret
1265
1266	endp
1267
1268
1269
1270
1271
1272Checkforshake	proc	near
1273
1274	cmp	reallocation,26
1275	jnz	notstartshake
1276          	cmp	ax,104
1277	jnz	notstartshake
1278	mov	shakecounter,-1
1279notstartshake:	ret
1280
1281	endp
1282
1283
1284
1285
1286
1287Watchcount	proc	near
1288
1289	cmp	watchon,0
1290	jz	nowatchworn
1291	inc	timercount
1292	cmp	timercount,9
1293	jz	flashdots
1294	cmp	timercount,18
1295	jz	uptime
1296nowatchworn:	ret
1297
1298flashdots:	mov	ax,91*3+21
1299	mov	di,268+4
1300	mov	bx,21
1301	mov	ds,charset1
1302	call	showframe
1303	jmp	finishwatch
1304
1305uptime: 	mov	timercount,0
1306	add	secondcount,1
1307	cmp	secondcount,60
1308	jnz	finishtime
1309	mov	secondcount,0
1310	inc	minutecount
1311	cmp	minutecount,60
1312	jnz	finishtime
1313	mov	minutecount,0
1314	inc	hourcount
1315	cmp	hourcount,24
1316	jnz	finishtime
1317	mov	hourcount,0
1318
1319finishtime:	call	showtime
1320finishwatch:	mov	watchdump,1
1321	ret
1322
1323	endp
1324
1325
1326
1327Showtime	proc	near
1328
1329	cmp	watchon,0
1330	jz	nowatch
1331
1332	mov	al,secondcount
1333	mov	cl,0
1334	call	twodigitnum
1335	push	ax
1336	mov	al,ah
1337	mov	ah,0
1338	add	ax,91*3+10
1339	mov	ds,charset1
1340	mov	di,282+5
1341	mov	bx,21
1342	call	showframe
1343	pop	ax
1344	mov	ah,0
1345	add	ax,91*3+10
1346	mov	ds,charset1
1347	mov	di,282+9
1348	mov	bx,21
1349	call	showframe
1350
1351	mov	al,minutecount
1352	mov	cl,0
1353	call	twodigitnum
1354	push	ax
1355	mov	al,ah
1356	mov	ah,0
1357	add	ax,91*3
1358	mov	ds,charset1
1359	mov	di,270+5
1360	mov	bx,21
1361	call	showframe
1362	pop	ax
1363	mov	ah,0
1364	add	ax,91*3
1365	mov	ds,charset1
1366	mov	di,270+11
1367	mov	bx,21
1368	call	showframe
1369
1370	mov	al,hourcount
1371	mov	cl,0
1372	call	twodigitnum
1373	push	ax
1374	mov	al,ah
1375	mov	ah,0
1376	add	ax,91*3
1377	mov	ds,charset1
1378	mov	di,256+5
1379	mov	bx,21
1380	call	showframe
1381	pop	ax
1382	mov	ah,0
1383	add	ax,91*3
1384	mov	ds,charset1
1385	mov	di,256+11
1386	mov	bx,21
1387	call	showframe
1388
1389	mov	ax,91*3+20
1390	mov	ds,charset1
1391	mov	di,267+5
1392	mov	bx,21
1393	call	showframe
1394nowatch:	ret
1395
1396
1397	endp
1398
1399
1400
1401
1402Dumpwatch	proc	near
1403
1404	cmp	watchdump,1
1405	jnz	nodumpwatch
1406	mov	di,256
1407	mov	bx,21
1408	mov	cl,40
1409	mov	ch,12
1410	call	multidump
1411	mov	watchdump,0
1412nodumpwatch:	ret
1413
1414	endp
1415
1416
1417
1418
1419Showbyte	proc	near
1420
1421	mov	dl,al
1422	shr	dl,1
1423	shr	dl,1
1424	shr	dl,1
1425	shr	dl,1
1426	call	onedigit
1427	mov	[es:di],dl
1428	mov	dl,al
1429	and	dl,15
1430	call	onedigit
1431	mov	[es:di+1],dl
1432	add	di,3
1433	ret
1434
1435	endp
1436
1437
1438Onedigit	proc	near
1439
1440	cmp	dl,10
1441	jnc	morethan10
1442	add	dl,"0"
1443	ret
1444morethan10:	sub	dl,10
1445	add	dl,"A"
1446	ret
1447
1448	endp
1449
1450
1451
1452
1453
1454Twodigitnum 	proc	near
1455
1456	mov	ah,cl
1457	dec	ah
1458numloop1:	inc	ah
1459	sub	al,10
1460	jnc	numloop1
1461	add	al,10
1462	add	al,cl
1463	ret
1464
1465	endp
1466
1467
1468
1469
1470
1471Showword	proc	near
1472
1473	mov	ch,0
1474	mov	bx,10000
1475	mov	cl,47
1476word1:	inc	cl
1477	sub	ax,bx
1478	jnc	word1
1479	add	ax,bx
1480	call	convnum
1481	mov	[cs:di],cl
1482	mov	bx,1000
1483	mov	cl,47
1484word2:	inc	cl
1485	sub	ax,bx
1486	jnc	word2
1487	add	ax,bx
1488	call	convnum
1489	mov	[cs:di+1],cl
1490	mov	bx,100
1491	mov	cl,47
1492word3:	inc	cl
1493	sub	ax,bx
1494	jnc	word3
1495	add	ax,bx
1496	call	convnum
1497	mov	[cs:di+2],cl
1498	mov	bx,10
1499	mov	cl,47
1500word4:	inc	cl
1501	sub	ax,bx
1502	jnc	word4
1503	add	ax,bx
1504	call	convnum
1505	mov	[cs:di+3],cl
1506	add	al,48
1507	mov	cl,al
1508	call	convnum
1509	mov	[cs:di+4],cl
1510	ret
1511
1512	endp
1513
1514
1515
1516
1517Convnum 	proc	near
1518
1519	cmp	ch,0
1520	jnz	noconvnum
1521	cmp	cl,"0"
1522	jnz	notzeronum
1523	mov	cl,32
1524	jmp	noconvnum
1525notzeronum:	mov	ch,1
1526noconvnum:	ret
1527
1528	endp
1529
1530
1531
1532
1533
1534
1535
1536
1537;---------------------------------------------Handling of pointer on screen----
1538
1539Mainscreen	proc	near
1540
1541	mov	inmaparea,0
1542	mov	bx,offset cs:mainlist
1543	cmp	watchon,1
1544	jz	checkmain
1545	mov	bx,offset cs:mainlist2
1546checkmain:	call	checkcoords
1547	cmp	walkandexam,0
1548	jz	finishmain
1549	call	walkandexamine
1550finishmain:	ret
1551
1552mainlist:	dw	44,70,32,46,look
1553	dw	0,50,0,180,inventory
1554	dw	226,244,10,26,zoomonoff
1555	dw	226,244,26,40,saveload
1556	dw	240,260,100,124,madmanrun
1557	dw	0,320,0,200,identifyob
1558	dw	0ffffh
1559
1560mainlist2:	dw	44,70,32,46,look
1561	dw	0,50,0,180,inventory
1562	dw	226+48,244+48,10,26,zoomonoff
1563	dw	226+48,244+48,26,40,saveload
1564	dw	240,260,100,124,madmanrun
1565	dw	0,320,0,200,identifyob
1566	dw	0ffffh
1567
1568	endp
1569
1570
1571
1572
1573
1574
1575Madmanrun	proc	near
1576
1577	cmp	location,14
1578	jnz	identifyob
1579	cmp	mapx,22
1580	jnz	identifyob
1581	cmp	pointermode,2
1582	jnz	identifyob
1583	cmp	madmanflag,0
1584	jnz	identifyob
1585
1586	cmp	commandtype,211
1587	jz	alreadyrun
1588	mov	commandtype,211
1589	mov	al,52
1590	call	commandonly
1591alreadyrun:	cmp	mousebutton,1
1592	jnz	norun
1593	mov	ax,mousebutton
1594	cmp	ax,oldbutton
1595	jz	norun
1596	mov	lastweapon,8
1597norun:	ret
1598
1599	endp
1600
1601
1602
1603
1604
1605
1606Checkcoords	proc	near
1607	cmp newlocation,255		;objects keep enumerated even in loading state, fixme
1608	jz loop048
1609	ret
1610
1611loop048:	mov	ax,[cs:bx]
1612	cmp	ax,0ffffh
1613	jz	nonefound
1614	push	bx
1615	cmp	mousex,ax
1616	jl	over045
1617	mov	ax,[cs:bx+2]
1618	cmp	mousex,ax
1619	jge	over045
1620	mov	ax,[cs:bx+4]
1621	cmp	mousey,ax
1622	jl	over045
1623	mov	ax,[cs:bx+6]
1624	cmp	mousey,ax
1625	jge	over045
1626	mov	ax,[cs:bx+8]
1627	call	ax
1628finished:	pop	ax
1629	ret
1630over045:	pop	bx
1631	add	bx,10
1632	jmp	loop048
1633nonefound:	ret
1634
1635	endp
1636
1637
1638
1639
1640
1641;-------------------------------------------Printing of icons during scroll----
1642
1643
1644
1645
1646
1647Identifyob	proc	near
1648
1649	cmp	watchingtime,0
1650	jnz	blank
1651
1652	mov	ax,mousex
1653	sub	ax,mapadx
1654	cmp	ax,22*8
1655	jc	notover1
1656	call	blank
1657	ret
1658
1659notover1:	mov	bx,mousey
1660	sub	bx,mapady
1661	cmp	bx,20*8
1662	jc	notover2
1663	call	blank
1664	ret
1665
1666notover2:	mov	inmaparea,1
1667	mov	ah,bl
1668	push	ax
1669	call	findpathofpoint
1670	mov	pointerspath,dl
1671	pop	ax
1672	push	ax
1673	call	findfirstpath
1674	mov	pointerfirstpath,al
1675	pop	ax
1676
1677	call	checkifex
1678	jnz	finishidentify
1679	call	checkiffree
1680	jnz	finishidentify
1681	call	checkifperson
1682	jnz	finishidentify
1683	call	checkifset
1684	jnz	finishidentify
1685
1686	mov	ax,mousex
1687	sub	ax,mapadx
1688	mov	cl,al
1689	mov	ax,mousey
1690	sub	ax,mapady
1691	mov	ch,al
1692	call	checkone
1693	cmp	al,0
1694	jz	nothingund
1695	;cmp	watchingtime,0
1696	;jnz	nothingund
1697	cmp	mandead,1
1698	jz	nothingund
1699	mov	ah,3
1700	call	obname
1701finishidentify:	ret
1702
1703nothingund:	call	blank
1704	ret
1705
1706	endp
1707
1708
1709
1710
1711
1712
1713
1714
1715Checkifperson	proc	near
1716
1717	mov	es,buffers
1718	mov	bx,peoplelist
1719	mov	cx,12
1720identifyreel:	push	cx
1721
1722	cmp	byte ptr [es:bx+4],255
1723	jz	notareelid
1724
1725	push	es bx ax
1726	mov	ax,[es:bx+0]
1727	mov	reelpointer,ax
1728	call	getreelstart
1729	cmp	[es:si+2],0ffffh
1730	jnz	notblankpers
1731	add	si,5
1732notblankpers:	mov	cx,[es:si+2]	 ;x,y of reel slot
1733	mov	ax,[es:si+0]	 ;frame number
1734	push	cx
1735	call	getreelframeax
1736	pop	cx
1737	add	cl,[es:bx+4]
1738	add	ch,[es:bx+5]
1739	mov	dx,cx
1740	add	dl,[es:bx+0]
1741	add	dh,[es:bx+1]
1742	pop	ax bx es
1743
1744	cmp	al,cl
1745	jc	notareelid
1746	cmp	ah,ch
1747	jc	notareelid
1748	cmp	al,dl
1749	jnc	notareelid
1750	cmp	ah,dh
1751	jnc	notareelid
1752
1753	pop	cx
1754	mov	ax,[es:bx+2]
1755	mov	persondata,ax
1756	mov	al,[es:bx+4]
1757	mov	ah,5
1758	call	obname
1759	mov	al,0
1760	cmp	al,1
1761	ret
1762
1763notareelid:	pop	cx
1764	add	bx,5
1765	dec	cx
1766	jnz	identifyreel
1767	ret
1768
1769	endp
1770
1771
1772
1773
1774
1775
1776
1777
1778Checkifset	proc	near
1779
1780	mov	es,buffers
1781	mov	bx,setlist+(127*5)
1782	mov	cx,127
1783identifyset:	cmp	byte ptr [es:bx+4],255
1784	jz	notasetid
1785	cmp	al,[es:bx]
1786	jc	notasetid
1787	cmp	al,[es:bx+2]
1788	jnc	notasetid
1789	cmp	ah,[es:bx+1]
1790	jc	notasetid
1791	cmp	ah,[es:bx+3]
1792	jnc	notasetid
1793	call	pixelcheckset
1794	jz	notasetid
1795	call	isitdescribed
1796	jz	notasetid
1797	mov	al,[es:bx+4]
1798	mov	ah,1
1799	call	obname
1800	mov	al,0
1801	cmp	al,1
1802	ret
1803notasetid:	sub	bx,5
1804	dec	cx
1805	cmp	cx,-1
1806	jnz	identifyset
1807	ret
1808
1809	endp
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820Checkifex	proc	near
1821
1822	mov	es,buffers
1823	mov	bx,exlist+(99*5)
1824	mov	cx,99
1825identifyex:	cmp	byte ptr [es:bx+4],255
1826	jz	notanexid
1827	cmp	al,[es:bx]
1828	jc	notanexid
1829	cmp	al,[es:bx+2]
1830	jnc	notanexid
1831	cmp	ah,[es:bx+1]
1832	jc	notanexid
1833	cmp	ah,[es:bx+3]
1834	jnc	notanexid
1835	mov	al,[es:bx+4]
1836	mov	ah,4
1837	call	obname
1838	mov	al,1
1839	cmp	al,0
1840	ret
1841notanexid:	sub	bx,5
1842	dec	cx
1843	cmp	cx,-1
1844	jnz	identifyex
1845	ret
1846
1847	endp
1848
1849
1850
1851
1852
1853
1854Checkiffree	proc	near
1855
1856	mov	es,buffers
1857	mov	bx,freelist+(79*5)
1858	mov	cx,79
1859identifyfree:	cmp	byte ptr [es:bx+4],255
1860	jz	notafreeid
1861	cmp	al,[es:bx]
1862	jc	notafreeid
1863	cmp	al,[es:bx+2]
1864	jnc	notafreeid
1865	cmp	ah,[es:bx+1]
1866	jc	notafreeid
1867	cmp	ah,[es:bx+3]
1868	jnc	notafreeid
1869	mov	al,[es:bx+4]
1870	mov	ah,2
1871	call	obname
1872	mov	al,0
1873	cmp	al,1
1874	ret
1875notafreeid:	sub	bx,5
1876	dec	cx
1877	cmp	cx,-1
1878	jnz	identifyfree
1879	ret
1880
1881	endp
1882
1883
1884
1885
1886
1887
1888Isitdescribed	proc	near
1889
1890	push	ax cx es bx
1891	mov	al,[es:bx+4]		;get object number
1892	mov	ah,0
1893	add	ax,ax
1894	mov	bx,ax
1895	mov	es,setdesc
1896	add	bx,settextdat
1897	mov	ax,[es:bx]
1898	add	ax,settext
1899	mov	bx,ax
1900	mov	dl,[es:bx]
1901	pop	bx es cx ax
1902	cmp	dl,0
1903	ret
1904
1905	endp
1906
1907
1908
1909
1910
1911
1912
1913
1914;Getcurrentpath	proc	near		;routine finds out which path
1915;				;block the pointer is in.
1916;	push	ax		;used to see if an object is
1917;	call	findpathofpoint	;close or not
1918;	pop	ax
1919;	mov	pointerspath,dl
1920;	ret
1921;
1922;	endp
1923
1924
1925
1926
1927
1928Findpathofpoint	proc	near
1929
1930	push	ax
1931	mov	bx,pathdata
1932	mov	es,reels
1933	mov	al,roomnum
1934	mov	ah,0
1935	mov	cx,144
1936	mul	cx
1937	add	bx,ax
1938	pop	cx
1939
1940	mov	dl,0
1941pathloop:	mov	al,[es:bx+6]
1942	cmp	al,255
1943	jnz	flunkedit
1944	mov	ax,[es:bx+2]
1945	cmp	ax,0ffffh
1946	jz	flunkedit
1947	cmp	cl,al
1948	jc	flunkedit
1949	cmp	ch,ah
1950	jc	flunkedit
1951	mov	ax,[es:bx+4]
1952	cmp	cl,al
1953	jnc	flunkedit
1954	cmp	ch,ah
1955	jnc	flunkedit
1956	jmp	gotvalidpath
1957flunkedit:	add	bx,8
1958	inc	dl
1959	cmp	dl,12
1960	jnz	pathloop
1961	mov	dl,255
1962gotvalidpath:	ret
1963
1964	endp
1965
1966
1967
1968
1969
1970Findfirstpath	proc	near	;similar to last routine, but it
1971			;searches each path to see if
1972	push	ax	;pointer is within it, regardless
1973	mov	bx,pathdata	;of whether the path is on or off
1974	mov	es,reels	;it returns the on or off state in
1975	mov	al,roomnum	;al (255=on 0=off) 0 if no path
1976	mov	ah,0
1977	mov	cx,144
1978	mul	cx
1979	add	bx,ax
1980	pop	cx
1981
1982	mov	dl,0
1983fpathloop:	mov	ax,[es:bx+2]
1984	cmp	ax,0ffffh
1985	jz	nofirst
1986	cmp	cl,al
1987	jc	nofirst
1988	cmp	ch,ah
1989	jc	nofirst
1990	mov	ax,[es:bx+4]
1991	cmp	cl,al
1992	jnc	nofirst
1993	cmp	ch,ah
1994	jnc	nofirst
1995	jmp	gotfirst
1996nofirst:	add	bx,8
1997	inc	dl
1998	cmp	dl,12
1999	jnz	fpathloop
2000	mov	al,0
2001	ret
2002gotfirst:	mov	al,[es:bx+6]
2003	ret
2004
2005	endp
2006
2007
2008
2009
2010
2011
2012
2013
2014Turnpathon	proc	near		;turns path on permanently
2015
2016	push	ax ax
2017	mov	cl,255
2018	mov	ch,roomnum
2019	add	ch,100
2020	call	findormake
2021	pop	ax
2022	call	getroomspaths
2023	pop	ax
2024	cmp	al,255
2025	jz	nopathon
2026	mov	ah,0
2027	add	ax,ax
2028	add	ax,ax
2029	add	ax,ax
2030	add	bx,ax
2031	mov	al,255
2032	mov	[es:bx+6],al
2033nopathon:	ret
2034
2035	endp
2036
2037
2038
2039
2040
2041
2042
2043Turnpathoff	proc	near		;turns path on permanently
2044
2045	push	ax ax
2046	mov	cl,0
2047	mov	ch,roomnum
2048	add	ch,100
2049	call	findormake
2050	pop	ax
2051	call	getroomspaths
2052	pop	ax
2053	cmp	al,255
2054	jz	nopathoff
2055	mov	ah,0
2056	add	ax,ax
2057	add	ax,ax
2058	add	ax,ax
2059	add	bx,ax
2060	mov	al,0
2061	mov	[es:bx+6],al
2062nopathoff:	ret
2063
2064	endp
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080Turnanypathon	proc	near
2081
2082	push	ax ax
2083	mov	cl,255
2084	mov	ch,ah
2085	add	ch,100
2086	call	findormake
2087	pop	ax
2088	mov	al,ah
2089	mov	ah,0
2090	mov	cx,144
2091	mul	cx
2092	mov	es,reels
2093	mov	bx,pathdata
2094	add	bx,ax
2095	pop	ax
2096	mov	ah,0
2097	add	ax,ax
2098	add	ax,ax
2099	add	ax,ax
2100	add	bx,ax
2101	mov	al,255
2102	mov	[es:bx+6],al
2103	ret
2104
2105	endp
2106
2107
2108
2109
2110
2111
2112Turnanypathoff	proc	near
2113
2114	push	ax ax
2115	mov	cl,0
2116	mov	ch,ah
2117	add	ch,100
2118	call	findormake
2119	pop	ax
2120	mov	al,ah
2121	mov	ah,0
2122	mov	cx,144
2123	mul	cx
2124	mov	es,reels
2125	mov	bx,pathdata
2126	add	bx,ax
2127	pop	ax
2128	mov	ah,0
2129	add	ax,ax
2130	add	ax,ax
2131	add	ax,ax
2132	add	bx,ax
2133	mov	al,0
2134	mov	[es:bx+6],al
2135	ret
2136
2137	endp
2138
2139
2140
2141
2142
2143Checkifpathison	proc	near
2144
2145	push	ax
2146	call	getroomspaths
2147	pop	ax
2148	mov	ah,0
2149	add	ax,ax
2150	add	ax,ax
2151	add	ax,ax
2152	add	bx,ax
2153	mov	al,[es:bx+6]
2154	cmp	al,255
2155	ret
2156
2157	endp
2158
2159
2160
2161
2162
2163Afternewroom	proc	near
2164
2165	cmp	nowinnewroom,0
2166	jz	notnew
2167	mov	timecount,0
2168	call	createpanel
2169	mov	commandtype,0
2170	call	findroominloc
2171
2172	cmp	ryanon,1
2173	jz	ryansoff
2174
2175	mov	al,ryanx
2176	add	al,12
2177	mov	ah,ryany
2178	add	ah,12
2179	call	findpathofpoint
2180	mov	manspath,dl
2181	call	findxyfrompath
2182	mov	resetmanxy,1
2183
2184ryansoff:	mov	newobs,1
2185	call	drawfloor
2186	mov	lookcounter,160
2187	mov	nowinnewroom,0
2188
2189	call	showicon
2190	call	spriteupdate
2191	call	printsprites
2192	call	undertextline
2193	call	reelsonscreen
2194	call	mainscreen
2195	call	getunderzoom
2196	call	zoom
2197	call	worktoscreenm
2198	call	walkintoroom
2199	call	reminders
2200	call	atmospheres
2201notnew:	ret
2202
2203	endp
2204
2205
2206
2207
2208
2209
2210Atmospheres	proc	near
2211
2212	mov	cl,mapx
2213	mov	ch,mapy
2214	mov	bx,offset cs:atmospherelist
2215nextatmos:	mov	al,[cs:bx]
2216	cmp	al,255
2217	jz	nomoreatmos
2218	cmp	al,reallocation
2219	jnz	wrongatmos
2220	mov	ax,[cs:bx+1]
2221	cmp	ax,cx
2222	jnz	wrongatmos
2223	mov	ax,[cs:bx+3]
2224	cmp	al,ch0playing
2225	jz	playingalready
2226	cmp	location,45
2227	jnz	notweb
2228	cmp	reeltowatch,45
2229	jz	wrongatmos
2230notweb:	call	playchannel0
2231	cmp	reallocation,2
2232	cmp	mapy,0
2233	jz	fullvol
2234	jnz	notlouisvol
2235	cmp	mapy,10
2236	jnz	notlouisvol
2237	cmp	mapx,22
2238            	jnz	notlouisvol
2239	mov	volume,5
2240notlouisvol:	if	cd
2241	cmp	reallocation,14
2242	jnz	notmad1
2243	cmp	mapx,33
2244	jz	ismad2
2245	cmp	mapx,22
2246	jnz	notmad1
2247	mov	volume,5
2248	ret
2249ismad2:	mov	volume,0
2250	ret
2251notmad1:	endif
2252playingalready:	cmp	reallocation,2
2253	jnz	notlouisvol2
2254	cmp	mapx,22
2255	jz	louisvol
2256             	cmp	mapx,11
2257	jnz	notlouisvol2
2258fullvol:	mov	volume,0
2259notlouisvol2:	ret
2260louisvol:	mov	volume,5
2261	ret
2262wrongatmos:	add	bx,5
2263	jmp	nextatmos
2264nomoreatmos:	call	cancelch0
2265	ret
2266
2267atmospherelist:	db	0,33,10,15,255
2268	db	0,22,10,15,255
2269	db	0,22,0,15,255
2270	db	0,11,0,15,255
2271	db	0,11,10,15,255
2272	db	0,0,10,15,255
2273
2274	db	1,44,10,6,255	;location,map x,y,sound,repeat
2275	db	1,44,0,13,255
2276
2277	db	2,33,0,6,255
2278	db	2,22,0,5,255
2279	db	2,22,10,16,255
2280	db	2,11,10,16,255
2281
2282	db	3,44,0,15,255
2283	db	3,33,10,6,255
2284	db	3,33,0,5,255
2285
2286	db	4,11,30,6,255
2287	db	4,22,30,5,255
2288	db	4,22,20,13,255
2289
2290	db	10,33,30,6,255
2291	db	10,22,30,6,255
2292
2293	db	9,22,10,6,255
2294	db	9,22,20,16,255
2295	db	9,22,30,16,255
2296	db	9,22,40,16,255
2297	db	9,22,50,16,255
2298
2299	db	6,11,30,6,255
2300	db	6,0,10,15,255
2301	db	6,0,20,15,255
2302	db	6,11,20,15,255
2303	db	6,22,20,15,255
2304
2305	db	7,11,20,6,255
2306	db	7,0,20,6,255
2307	db	7,0,30,6,255
2308
2309	db	55,44,0,5,255
2310	db	55,44,10,5,255
2311
2312	db	5,22,30,6,255
2313	if	demo
2314	db	5,22,20,16,255
2315	db	5,22,10,16,255
2316	else
2317	db	5,22,20,15,255
2318	db	5,22,10,15,255
2319	endif
2320
2321	db	24,22,0,15,255
2322	db	24,33,0,15,255
2323	db	24,44,0,15,255
2324	db	24,33,10,15,255
2325
2326	db	8,0,10,6,255
2327	db	8,11,10,6,255
2328	db	8,22,10,6,255
2329	db	8,33,10,6,255
2330	db	8,33,20,6,255
2331	db	8,33,30,6,255
2332	db	8,33,40,6,255
2333	db	8,22,40,6,255
2334	db	8,11,40,6,255
2335
2336	db	11,11,20,12,255
2337	db	11,11,30,12,255
2338	db	11,22,20,12,255
2339	db	11,22,30,12,255
2340
2341	db	12,22,20,12,255
2342	db	13,22,20,12,255
2343	db	13,33,20,12,255
2344
2345	db	14,44,20,12,255
2346	db	14,33,0,12,255
2347	db	14,33,10,12,255
2348	db	14,33,20,12,255
2349	db	14,33,30,12,255
2350	db	14,33,40,12,255
2351	db	14,22,0,16,255
2352
2353	db	19,0,0,12,255
2354
2355	db	20,0,20,16,255
2356	db	20,0,30,16,255
2357	db	20,11,30,16,255
2358	db	20,0,40,16,255
2359	db	20,11,40,16,255
2360
2361	if	demo
2362	db	21,11,10,16,255
2363	db	21,11,20,16,255
2364	db	21,0,20,16,255
2365	db	21,22,20,16,255
2366	db	21,33,20,16,255
2367	db	21,44,20,16,255
2368	db	21,44,10,16,255
2369	else
2370	db	21,11,10,15,255
2371	db	21,11,20,15,255
2372	db	21,0,20,15,255
2373	db	21,22,20,15,255
2374	db	21,33,20,15,255
2375	db	21,44,20,15,255
2376	db	21,44,10,15,255
2377	endif
2378
2379	db	22,22,10,16,255
2380	db	22,22,20,16,255
2381
2382	db	23,22,30,13,255
2383	db	23,22,40,13,255
2384	db	23,33,40,13,255
2385	db	23,11,40,13,255
2386	db	23,0,40,13,255
2387	db	23,0,50,13,255
2388
2389	db	25,11,40,16,255
2390	db	25,11,50,16,255
2391	db	25,0,50,16,255
2392
2393	db	27,11,20,16,255
2394	db	27,11,30,16,255
2395
2396	db	29,11,10,16,255
2397
2398	db	45,22,30,12,255
2399	db	45,22,40,12,255
2400	db	45,22,50,12,255
2401
2402	db	46,22,40,12,255
2403	db	46,11,50,12,255
2404	db	46,22,50,12,255
2405	db	46,33,50,12,255
2406
2407	db	47,0,0,12,255
2408
2409	db	26,22,20,16,255
2410	db	26,33,10,16,255
2411	db	26,33,20,16,255
2412	db	26,33,30,16,255
2413	db	26,44,30,16,255
2414	db	26,22,30,16,255
2415	db	26,11,30,16,255
2416	db	26,11,20,16,255
2417	db	26,0,20,16,255
2418	db	26,11,40,16,255
2419	db	26,0,40,16,255
2420	db	26,22,40,16,255
2421	db	26,11,50,16,255
2422
2423	db	28,0,30,15,255
2424	db	28,0,20,15,255
2425	db	28,0,40,15,255
2426	db	28,11,30,15,255
2427	db	28,11,20,15,255
2428	db	28,22,30,15,255
2429	db	28,22,20,15,255
2430
2431	db	255
2432
2433	endp
2434
2435
2436
2437
2438
2439
2440Walkintoroom	proc	near
2441
2442	cmp	location,14
2443	jnz	notlair
2444	cmp	mapx,22
2445	jnz	notlair
2446	mov	destination,1
2447	mov	finaldest,1
2448	call	autosetwalk
2449notlair:	ret
2450
2451	endp
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464Afterintroroom	proc	near
2465
2466	cmp	nowinnewroom,0
2467	jz	notnewintro
2468	call	clearwork
2469	call	findroominloc
2470	mov	newobs,1
2471	call	drawfloor
2472	call	reelsonscreen
2473	call	spriteupdate
2474	call	printsprites
2475	call	worktoscreen
2476	mov	nowinnewroom,0
2477notnewintro:	ret
2478
2479	endp
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491Obname	proc	near
2492
2493	cmp	reasseschanges,0
2494	jz	notnewpath
2495	mov	reasseschanges,0
2496	jmp	diff
2497
2498notnewpath:	cmp	ah,commandtype
2499	jz	notdiffob
2500	jmp	diff
2501notdiffob:	cmp	al,command
2502	jnz	diff
2503	cmp	walkandexam,1
2504	jz	walkandexamine
2505	cmp	mousebutton,0
2506	jz	noobselect
2507	cmp	commandtype,3
2508	jnz	isntblock
2509	cmp	lastflag,2
2510	jc	noobselect
2511isntblock:	mov	bl,manspath
2512	cmp	bl,pointerspath
2513	jnz	wantstowalk
2514	cmp	commandtype,3
2515	jz	wantstowalk
2516	call	finishedwalking
2517	jnz	noobselect
2518	cmp	commandtype,5
2519	jz	wantstotalk
2520	cmp	watchingtime,0
2521	jnz	noobselect
2522	call	examineob
2523	ret
2524wantstotalk:	cmp	watchingtime,0
2525	jnz	noobselect
2526	call	talk
2527	ret
2528walkandexamine:	call	finishedwalking
2529	jnz	noobselect
2530	mov	al,walkexamtype
2531	mov	commandtype,al
2532	mov	al,walkexamnum
2533	mov	command,al
2534	mov	walkandexam,0
2535	cmp	commandtype,5
2536	jz	noobselect
2537	call	examineob
2538	ret
2539wantstowalk:	call	setwalk
2540	mov	reasseschanges,1
2541noobselect:	ret
2542
2543
2544diff:	mov	command,al
2545	mov	commandtype,ah
2546diff2:	cmp	linepointer,254
2547	jnz	middleofwalk
2548	cmp	watchingtime,0
2549	jnz	middleofwalk
2550	mov	al,facing
2551	cmp	al,turntoface
2552	jnz	middleofwalk
2553	cmp	commandtype,3
2554	jnz	notblock
2555	mov	bl,manspath
2556	cmp	bl,pointerspath
2557	jnz	dontcheck
2558	mov	cl,ryanx		;look under feet to see if
2559	add	cl,12		;any flags are there
2560	mov	ch,ryany
2561	add	ch,12
2562	call	checkone
2563	cmp	cl,2
2564	jc	isblock
2565dontcheck:	call	getflagunderp
2566	cmp	lastflag,2
2567	jc	isblock
2568	cmp	lastflag,128
2569	jnc	isblock
2570	jmp	toofaraway ; only here for turning on doorstep
2571notblock:	mov	bl,manspath
2572	cmp	bl,pointerspath
2573	jnz	toofaraway
2574	cmp	commandtype,3
2575	jz	isblock
2576	cmp	commandtype,5
2577	jz	isaperson
2578	call	examineobtext
2579	ret
2580middleofwalk:	call	blocknametext
2581	ret
2582isblock:	call	blocknametext
2583	ret
2584isaperson:	call	personnametext
2585	ret
2586toofaraway:	call	walktotext
2587	ret
2588
2589	endp
2590
2591
2592
2593
2594
2595
2596
2597Finishedwalking proc	near
2598
2599	cmp	linepointer,254
2600	jnz	iswalking
2601	mov	al,facing
2602	cmp	al,turntoface
2603iswalking:	ret
2604
2605	endp
2606
2607
2608
2609
2610
2611
2612
2613Examineobtext	proc	near
2614
2615	mov	bl,command
2616	mov	bh,commandtype
2617	mov	al,1
2618	call	commandwithob
2619	ret
2620
2621	endp
2622
2623
2624
2625
2626
2627Commandwithob	proc	near
2628
2629	push	ax
2630	push	ax bx cx dx es ds si di
2631	call	deltextline
2632	pop	di si ds es dx cx bx ax
2633
2634	push	bx
2635	mov	ah,0
2636	add	ax,ax
2637	mov	bx,ax
2638	mov	es,commandtext
2639	mov	ax,[es:bx]
2640	add	ax,textstart
2641	mov	si,ax
2642
2643	mov	di,textaddressx
2644	mov	bx,textaddressy
2645	mov	dl,textlen
2646	mov	al,0
2647	mov	ah,0
2648	call	printdirect
2649
2650	pop	ax
2651	mov	di,offset cs:commandline
2652	call	copyname
2653	pop	ax
2654
2655	mov	di,lastxpos
2656	cmp	al,0
2657	jz	noadd
2658	add	di,5
2659noadd:	mov	bx,textaddressy
2660	push	cs
2661	pop	es
2662	mov	si,offset cs:commandline
2663	mov	dl,textlen
2664	mov	al,0
2665	mov	ah,0
2666	call	printdirect
2667	mov	newtextline,1
2668	ret
2669
2670commandline:	db	"OBJECT NAME ONE                         ",0
2671
2672	endp
2673
2674
2675
2676
2677Commandonly	proc	near
2678
2679	push	ax bx cx dx es ds si di
2680	call	deltextline
2681	pop	di si ds es dx cx bx ax
2682
2683	mov	ah,0
2684	add	ax,ax
2685	mov	bx,ax
2686	mov	es,commandtext
2687	mov	ax,[es:bx]
2688	add	ax,textstart
2689	mov	si,ax
2690
2691	mov	di,textaddressx
2692	mov	bx,textaddressy
2693	mov	dl,textlen
2694	mov	al,0
2695	mov	ah,0
2696	call	printdirect
2697	mov	newtextline,1
2698	ret
2699
2700	endp
2701
2702
2703
2704
2705
2706Printmessage	proc	near
2707
2708	push 	dx bx di
2709	mov	ah,0
2710	add	ax,ax
2711	mov	bx,ax
2712	mov	es,commandtext
2713	mov	ax,[es:bx]
2714	add	ax,textstart
2715	mov	si,ax
2716	pop	di bx dx
2717	mov	al,0
2718	mov	ah,0
2719	call	printdirect
2720	ret
2721
2722	endp
2723
2724
2725
2726Printmessage2	proc	near
2727
2728	push 	dx bx di
2729	push	ax
2730	mov	ah,0
2731	add	ax,ax
2732	mov	bx,ax
2733	mov	es,commandtext
2734	mov	ax,[es:bx]
2735	add	ax,textstart
2736	mov	si,ax
2737	pop	ax
2738
2739searchmess:	push	ax
2740	call	findnextcolon
2741	pop	ax
2742	dec	ah
2743	jnz	searchmess
2744
2745	pop	di bx dx
2746	mov	al,0
2747	mov	ah,0
2748	call	printdirect
2749	ret
2750
2751	endp
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761Blocknametext	proc	near
2762
2763	mov	bl,command
2764	mov	bh,commandtype
2765	mov	al,0
2766	call	commandwithob
2767	ret
2768
2769	endp
2770
2771
2772
2773
2774Personnametext	proc	near
2775
2776	mov	bl,command
2777	and	bl,127
2778	mov	bh,commandtype
2779	mov	al,2
2780	call	commandwithob
2781	ret
2782
2783	endp
2784
2785
2786
2787
2788
2789
2790
2791Walktotext	proc	near
2792
2793	mov	bl,command
2794	mov	bh,commandtype
2795	mov	al,3
2796	call	commandwithob
2797	ret
2798
2799	endp
2800
2801
2802
2803
2804
2805Getflagunderp	proc	near
2806
2807	mov	cx,mousex
2808	sub	cx,mapadx
2809	mov	ax,mousey
2810	sub	ax,mapady
2811	mov	ch,al
2812	call	checkone
2813	mov	lastflag,cl
2814	mov	lastflagex,ch
2815	ret
2816
2817	endp
2818
2819
2820
2821
2822
2823Setwalk 	proc	near
2824
2825	cmp	linepointer,254
2826	jnz	alreadywalking
2827	mov	al,pointerspath
2828	cmp	al,manspath
2829	jz	cantwalk2
2830	cmp	watchmode,1
2831	jz	holdingreel
2832	cmp	watchmode,2
2833	jz	cantwalk
2834	mov	destination,al
2835	mov	finaldest,al
2836	cmp	mousebutton,2
2837	jnz	notwalkandexam
2838	cmp	commandtype,3
2839	jz	notwalkandexam
2840	mov	walkandexam,1
2841	mov	al,commandtype
2842	mov	walkexamtype,al
2843	mov	al,command
2844	mov	walkexamnum,al
2845notwalkandexam:	call	autosetwalk
2846cantwalk:	ret
2847cantwalk2:	call	facerightway
2848	ret
2849alreadywalking:	mov	al,pointerspath
2850	mov	finaldest,al
2851	ret
2852
2853holdingreel:	mov	destafterhold,al
2854	mov	watchmode,2
2855	ret
2856
2857	endp
2858
2859
2860
2861
2862
2863
2864
2865Autosetwalk	proc	near
2866
2867	mov	al,manspath
2868	cmp	finaldest,al
2869	jnz	notsamealready
2870	ret
2871notsamealready:	call	getroomspaths
2872	call	checkdest
2873	push	bx
2874	mov	al,manspath
2875	mov	ah,0
2876	add	ax,ax
2877	add	ax,ax
2878	add	ax,ax
2879	add	bx,ax
2880	mov	al,[es:bx]
2881	mov	ah,0
2882	sub	ax,12
2883	mov	linestartx,ax
2884	mov	al,[es:bx+1]
2885	mov	ah,0
2886	sub	ax,12
2887	mov	linestarty,ax
2888	pop	bx
2889
2890	mov	al,destination
2891	mov	ah,0
2892	add	ax,ax
2893	add	ax,ax
2894	add	ax,ax
2895	add	bx,ax
2896	mov	al,[es:bx]
2897	mov	ah,0
2898	sub	ax,12
2899	mov	lineendx,ax
2900	mov	al,[es:bx+1]
2901	mov	ah,0
2902	sub	ax,12
2903	mov	lineendy,ax
2904	call	bresenhams
2905
2906	cmp	linedirection,0
2907	jz	normalline
2908	mov	al,linelength
2909	dec	al
2910	mov	linepointer,al
2911	mov	linedirection,1
2912	ret
2913
2914normalline:	mov	linepointer,0
2915	ret
2916
2917	endp
2918
2919
2920
2921
2922
2923
2924
2925
2926Checkdest	proc	near
2927
2928	push	bx
2929	add	bx,12*8
2930	mov	ah,manspath
2931	mov	cl,4
2932	shl	ah,cl
2933	mov	al,destination
2934
2935	mov	cl,24
2936	mov	ch,destination
2937checkdestloop:	mov	dh,[es:bx]
2938	and	dh,11110000b
2939	mov	dl,[es:bx]
2940	and	dl,00001111b
2941	cmp	ax,dx
2942	jnz	nextcheck
2943	mov	al,[es:bx+1]
2944	and	al,15
2945	mov	destination,al
2946	pop	bx
2947	ret
2948nextcheck:	mov	dl,[es:bx]
2949	and	dl,11110000b
2950	shr	dl,1
2951	shr	dl,1
2952	shr	dl,1
2953	shr	dl,1
2954	mov	dh,[es:bx]
2955	and	dh,00001111b
2956	shl	dh,1
2957	shl	dh,1
2958	shl	dh,1
2959	shl	dh,1
2960	cmp	ax,dx
2961	jnz	nextcheck2
2962	mov	ch,[es:bx+1]
2963	and	ch,15
2964nextcheck2:	add	bx,2
2965	dec	cl
2966	jnz	checkdestloop
2967	mov	destination,ch
2968	pop	bx
2969	ret
2970
2971	endp
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986Bresenhams	proc	near
2987
2988	call	workoutframes
2989
2990	mov	dx,seg linedata
2991	mov	es,dx
2992	mov	di,offset es:linedata
2993	mov	si,1
2994	mov	linedirection,0
2995
2996	mov	cx,lineendx
2997	sub	cx,linestartx
2998	jz	vertline
2999	jns	line1
3000
3001	neg	cx
3002	mov	bx,lineendx
3003	xchg	bx,linestartx
3004	mov	lineendx,bx
3005
3006	mov	bx,lineendy
3007	xchg	bx,linestarty
3008	mov	lineendy,bx
3009	mov	linedirection,1
3010
3011line1:	mov	bx,lineendy
3012	sub	bx,linestarty
3013	jz	horizline
3014	jns	line3
3015
3016	neg	bx
3017	neg	si
3018
3019line3:	push	si
3020	mov	lineroutine,0 ; means lo slope
3021	cmp	bx,cx
3022	jle	line4
3023	mov	lineroutine,1 ; means hi slope
3024	xchg	bx,cx
3025
3026line4:	shl	bx,1
3027	mov	increment1,bx
3028	sub	bx,cx
3029	mov	si,bx
3030	sub	bx,cx
3031	mov	increment2,bx
3032
3033	mov	ax,linestartx
3034	mov	bx,linestarty
3035	mov	ah,bl
3036	inc	cx
3037	pop	bx
3038	cmp	lineroutine,1
3039	jz	hislope
3040	jmp	loslope
3041
3042vertline:	mov	ax,linestarty
3043	mov	bx,lineendy
3044	mov	cx,bx
3045	sub	cx,ax
3046	jge	line31
3047
3048	neg	cx
3049	mov	ax,bx
3050	mov	linedirection,1
3051
3052line31: 	inc	cx
3053	mov	bx,linestartx
3054	xchg	ax,bx
3055	mov	ah,bl
3056	mov	bx,si
3057line32: 	stosw
3058	add	ah,bl
3059	loop	line32
3060	jmp	lineexit
3061
3062
3063horizline:	mov	ax,linestartx
3064	mov	bx,linestarty
3065	mov	ah,bl
3066	inc	cx
3067horizloop:	stosw
3068	inc	al
3069	loop	horizloop
3070	jmp	lineexit
3071
3072
3073loslope:
3074loloop: 	stosw
3075	inc	al
3076	or	si,si
3077	jns	line12
3078	add	si,increment1
3079	loop	loloop
3080	jmp	lineexit
3081
3082line12: 	add	si,increment2
3083	add	ah,bl
3084	loop	loloop
3085	jmp	lineexit
3086
3087
3088
3089hislope:
3090hiloop: 	stosw
3091	add	ah,bl
3092	or	si,si
3093	jns	line23
3094	add	si,increment1
3095	loop	hiloop
3096	jmp	lineexit
3097
3098line23: 	add	si,increment2
3099	inc	al
3100	loop	hiloop
3101
3102lineexit:	sub	di,offset es:linedata
3103	mov	ax,di
3104	shr	ax,1
3105	mov	linelength,al
3106	ret
3107
3108	endp
3109
3110
3111
3112
3113
3114
3115
3116Workoutframes	proc	near
3117
3118	mov	bx,linestartx
3119	add	bx,32
3120	mov	ax,lineendx
3121	add	ax,32
3122	sub	bx,ax
3123	jnc	notneg1
3124	neg	bx
3125notneg1:	mov	cx,linestarty
3126	add	cx,32
3127	mov	ax,lineendy
3128	add	ax,32
3129	sub	cx,ax
3130	jnc	notneg2
3131	neg	cx
3132notneg2:	cmp	bx,cx
3133	jnc	tendstohoriz
3134	mov	dl,2
3135	mov	ax,cx
3136	shr	ax,1
3137	cmp	bx,ax
3138	jc	gotquad
3139	mov	dl,1
3140	jmp	gotquad
3141tendstohoriz:	mov	dl,0
3142	mov	ax,bx
3143	shr	ax,1
3144	cmp	cx,ax
3145	jc	gotquad
3146	mov	dl,1
3147	jmp	gotquad
3148
3149gotquad:	mov	bx,linestartx
3150	add	bx,32
3151	mov	ax,lineendx
3152	add	ax,32
3153	sub	bx,ax
3154	jc	isinright
3155isinleft:	mov	cx,linestarty
3156	add	cx,32
3157	mov	ax,lineendy
3158	add	ax,32
3159	sub	cx,ax
3160	jnc	topleft
3161	cmp	dl,1
3162	jz	noswap1
3163	xor	dl,2
3164noswap1:	add	dl,4
3165	jmp	success
3166topleft:	add	dl,6
3167	jmp	success
3168
3169isinright:	mov	cx,linestarty
3170	add	cx,32
3171	mov	ax,lineendy
3172	add	ax,32
3173	sub	cx,ax
3174	jnc	botright
3175	add	dl,2
3176	jmp	success
3177botright:	cmp	dl,1
3178	jz	noswap2
3179	xor	dl,2
3180noswap2:
3181
3182success:	and	dl,7
3183	mov	turntoface,dl
3184	mov	turndirection,0
3185	ret
3186
3187	endp
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206;Multiply8	proc	near
3207;
3208;	mov	ah,0
3209;	mov	cx,8
3210;	mul	cx
3211;	ret
3212;
3213;	endp
3214
3215
3216
3217
3218
3219
3220Getroomspaths	proc	near
3221
3222	mov	al,roomnum
3223	mov	ah,0
3224	mov	cx,144
3225	mul	cx
3226	mov	es,reels
3227	mov	bx,pathdata
3228	add	bx,ax
3229	ret
3230
3231	endp
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248Copyname	proc	near
3249
3250	push	di
3251	call	findobname
3252	pop	di
3253	push	cs
3254	pop	es
3255
3256copytext:	mov	cx,28
3257make:	lodsb
3258	cmp	al,":"
3259	jz	finishmakename
3260	cmp	al,0
3261	jz	finishmakename
3262	stosb
3263	loop	make
3264
3265finishmakename:	inc	cx
3266	mov	al,0
3267	stosb
3268	ret
3269	mov	al,255
3270	rep	stosb
3271	ret
3272
3273	endp
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283Findobname	proc	near
3284
3285	push	ax
3286	mov	ah,0
3287	add	ax,ax
3288	mov	bx,ax
3289	pop	ax
3290
3291	cmp	ah,5
3292	jnz	notpersonname
3293
3294	push	ax
3295	and	al,127
3296	mov	ah,0
3297	mov	bx,64*2
3298	mul	bx
3299	mov	si,ax
3300	mov	ds,people
3301	add	si,persontxtdat
3302	mov	cx,persontext
3303	mov	ax,[si]
3304	add	ax,cx
3305	mov	si,ax
3306	pop	ax
3307	ret
3308
3309notpersonname:	cmp	ah,4
3310	jnz	notextraname
3311	mov	ds,extras
3312	add	bx,extextdat
3313	mov	ax,[bx]
3314	add	ax,extext
3315	mov	si,ax
3316	ret
3317
3318notextraname:	cmp	ah,2
3319	jnz	notfreename
3320	mov	ds,freedesc
3321	add	bx,freetextdat
3322	mov	ax,[bx]
3323	add	ax,freetext
3324	mov	si,ax
3325	ret
3326
3327notfreename:	cmp	ah,1
3328	jnz	notsetname
3329	mov	ds,setdesc
3330	add	bx,settextdat
3331	mov	ax,[bx]
3332	add	ax,settext
3333	mov	si,ax
3334	ret
3335
3336notsetname:	mov	ds,blockdesc
3337	add	bx,blocktextdat
3338	mov	ax,[bx]
3339	add	ax,blocktext
3340	mov	si,ax
3341	ret
3342
3343	endp
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357;-------------------------------------------Printing of non scrolling icons----
3358
3359Showicon	proc	near
3360
3361	cmp	reallocation,50
3362	jnc	isdream1
3363	call	showpanel
3364	call	showman
3365	call	roomname
3366	call	panelicons1
3367	call	zoomicon
3368	ret
3369
3370isdream1:	mov	ds,tempsprites
3371	mov	di,72
3372	mov	bx,2
3373	mov	al,45
3374	mov	ah,0
3375	call	showframe
3376	mov	ds,tempsprites
3377	mov	di,72+47
3378	mov	bx,2
3379	mov	al,46
3380	mov	ah,0
3381	call	showframe
3382	mov	ds,tempsprites
3383	mov	di,69-10
3384	mov	bx,21
3385	mov	al,49
3386	mov	ah,0
3387	call	showframe
3388
3389	mov	ds,tempsprites
3390	mov	di,160+88
3391	mov	bx,2
3392	mov	al,45
3393	mov	ah,4
3394	call	showframe
3395	mov	ds,tempsprites
3396	mov	di,160+43
3397	mov	bx,2
3398	mov	al,46
3399	mov	ah,4
3400	call	showframe
3401	mov	ds,tempsprites
3402	mov	di,160+101
3403	mov	bx,21
3404	mov	al,49
3405	mov	ah,4
3406	call	showframe
3407	call	middlepanel
3408	ret
3409
3410	endp
3411
3412
3413
3414
3415
3416Middlepanel	proc	near
3417
3418	mov	ds,tempsprites
3419	mov	di,72+47+20
3420	mov	bx,0
3421	mov	al,48
3422	mov	ah,0
3423	call	showframe
3424	mov	ds,tempsprites
3425	mov	di,72+19
3426	mov	bx,21
3427	mov	al,47
3428	mov	ah,0
3429	call	showframe
3430	mov	ds,tempsprites
3431	mov	di,160+23
3432	mov	bx,0
3433	mov	al,48
3434	mov	ah,4
3435	call	showframe
3436	mov	ds,tempsprites
3437	mov	di,160+71
3438	mov	bx,21
3439	mov	al,47
3440	mov	ah,4
3441	call	showframe
3442	ret
3443
3444	endp
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455Showman 	proc	near
3456
3457	mov	ds,icons1
3458	mov	di,0
3459	mov	bx,0
3460	mov	al,0
3461	mov	ah,0
3462	call	showframe
3463	mov	ds,icons1
3464	mov	di,0
3465	mov	bx,114
3466	mov	al,1
3467	mov	ah,0
3468	call	showframe
3469
3470	cmp	shadeson,0
3471	jz	notverycool
3472
3473	mov	ds,icons1
3474	mov	di,28
3475	mov	bx,25
3476	mov	al,2
3477	mov	ah,0
3478	call	showframe
3479notverycool:	ret
3480
3481	endp
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501Showpanel	proc	near
3502
3503	mov	ds,icons1
3504	mov	di,72
3505	mov	bx,0
3506	mov	al,19
3507	mov	ah,0
3508	call	showframe
3509	mov	ds,icons1
3510	mov	di,192
3511	mov	bx,0
3512	mov	al,19
3513	mov	ah,0
3514	call	showframe
3515	ret
3516
3517	endp
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540Roomname	proc	near
3541
3542	mov	di,88
3543	mov	bx,18
3544	mov	al,53
3545	mov	dl,240
3546	call	printmessage
3547
3548	mov	bl,roomnum
3549	cmp	bl,32
3550	jc	notover32
3551	sub	bl,32
3552
3553notover32:	mov	bh,0
3554	add	bx,bx
3555	mov	es,roomdesc
3556	add	bx,intextdat
3557	mov	ax,[es:bx]
3558	add	ax,intext
3559	mov	si,ax
3560
3561	mov	linespacing,7
3562	mov	di,88
3563	mov	bx,25
3564	mov	dl,120
3565	cmp	watchon,1
3566	jz	gotpl
3567	mov	dl,160
3568gotpl:	mov	al,0
3569	mov	ah,0
3570	call	printdirect
3571	mov	linespacing,10
3572
3573	call	usecharset1
3574	ret
3575
3576	endp
3577
3578
3579
3580
3581
3582
3583Usecharset1	proc	near
3584
3585	mov	ax,charset1
3586	mov	currentset,ax
3587	ret
3588
3589	endp
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601Usetempcharset	proc	near
3602
3603	mov	ax,tempcharset
3604	mov	currentset,ax
3605	ret
3606
3607	endp
3608
3609
3610
3611
3612
3613Showexit	proc	near
3614
3615	mov	ds,icons1
3616	mov	di,274
3617	mov	bx,154
3618	mov	al,11
3619	mov	ah,0
3620	call	showframe
3621	ret
3622
3623	endp
3624
3625
3626
3627
3628Panelicons1	proc	near
3629
3630	mov	di,0
3631	cmp	watchon,1
3632	jz	watchison
3633	mov	di,48
3634watchison:	push	di
3635	mov	ds,icons2
3636	add	di,204
3637	mov	bx,4
3638	mov	al,2
3639	mov	ah,0
3640	call	showframe
3641	pop	di
3642	push	di
3643	cmp	zoomon,1
3644	jz	zoomisoff
3645	mov	ds,icons1
3646	add	di,228
3647	mov	bx,8
3648	mov	al,5
3649	mov	ah,0
3650	call	showframe
3651zoomisoff:	pop	di
3652	call	showwatch
3653	ret
3654
3655	endp
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668Showwatch	proc	near
3669
3670	cmp	watchon,0
3671	jz	nowristwatch
3672	mov	ds,icons1
3673	mov	di,250
3674	mov	bx,1
3675	mov	al,6
3676	mov	ah,0
3677	call	showframe
3678	call	showtime
3679nowristwatch:	ret
3680
3681	endp
3682
3683
3684Gettime	proc	near
3685
3686	mov	ah,2ch
3687	int	21h
3688	mov	secondcount,dh
3689	mov	minutecount,cl
3690	mov	hourcount,ch
3691	ret
3692
3693	endp
3694
3695
3696
3697
3698
3699Zoomicon	proc	near
3700
3701	cmp	zoomon,0
3702	jz	nozoom1
3703	mov	ds,icons1
3704	mov	di,zoomx
3705	mov	bx,zoomy-1
3706	mov	al,8
3707	mov	ah,0
3708	call	showframe
3709nozoom1:	ret
3710
3711	endp
3712
3713
3714
3715
3716
3717
3718Showblink	proc	near
3719
3720	cmp	manisoffscreen,1
3721	jz	finblink1
3722	inc	blinkcount
3723	cmp	shadeson,0
3724	jnz	finblink1
3725	cmp	reallocation,50
3726	jnc	eyesshut
3727	mov	al,blinkcount
3728	cmp	al,3
3729	jnz	finblink1
3730	mov	blinkcount,0
3731	mov	al,blinkframe
3732	inc	al
3733	mov	blinkframe,al
3734	cmp	al,6
3735	jc	nomorethan6
3736	mov	al,6
3737nomorethan6:	mov	ah,0
3738	mov	bx,offset cs:blinktab
3739	add	bx,ax
3740
3741	mov	al,[cs:bx]
3742	mov	ds,icons1
3743	mov	di,44
3744	mov	bx,32
3745	mov	ah,0
3746	call	showframe
3747finblink1:	ret
3748
3749eyesshut:	;mov	al,32
3750	;mov	ds,icons1
3751	;mov	di,44
3752	;mov	bx,32
3753	;mov	ah,0
3754	;call	showframe
3755	ret
3756
3757blinktab:	db	16,18,18,17,16,16,16
3758
3759	endp
3760
3761
3762
3763
3764
3765
3766Dumpblink	proc	near
3767
3768	cmp	shadeson,0
3769	jnz	nodumpeye
3770	cmp	blinkcount,0
3771	jnz	nodumpeye
3772	mov	al,blinkframe
3773	cmp	al,6
3774	jnc	nodumpeye
3775	push	ds
3776	mov	di,44
3777	mov	bx,32
3778	mov	cl,16
3779	mov	ch,12
3780	call	multidump
3781	pop	ds
3782nodumpeye:	ret
3783
3784	endp
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803Worktoscreenm	proc	near
3804
3805	call	animpointer
3806	call	readmouse
3807	call	showpointer
3808	call	vsync
3809	call	worktoscreen
3810	call	delpointer
3811	ret
3812
3813	endp
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827;-------------------------------------------------------------Blank routine----
3828
3829
3830
3831
3832Blank	proc	near
3833
3834	cmp	commandtype,199
3835	jz	alreadyblnk
3836	mov	commandtype,199
3837	mov	al,0
3838	call	commandonly
3839alreadyblnk:	ret
3840
3841	endp
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864;---------------------------------------------------------Standard routines----
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878Allpointer	proc	near
3879
3880	call	readmouse
3881	call	showpointer
3882	call	dumppointer
3883	ret
3884
3885	endp
3886
3887
3888
3889
3890
3891
3892
3893Hangonp 	proc	near
3894
3895	push	cx
3896	add	cx,cx
3897	pop	ax
3898	add	cx,ax
3899	mov	maintimer,0
3900	mov	al,pointerframe
3901	mov	ah,pickup
3902	push	ax
3903	mov	pointermode,3
3904	mov	pickup,0
3905	push	cx
3906	mov	commandtype,255
3907	call	readmouse
3908	call	animpointer
3909	call	showpointer
3910	call	vsync
3911	call	dumppointer
3912	pop	cx
3913
3914hangloop:	push	cx
3915	call	delpointer
3916	call	readmouse
3917	call	animpointer
3918	call	showpointer
3919	call	vsync
3920	call	dumppointer
3921	pop	cx
3922	mov	ax,mousebutton
3923	cmp	ax,0
3924	jz	notpressed
3925	cmp	ax,oldbutton
3926	jnz	getoutofit
3927notpressed:	loop	hangloop
3928
3929getoutofit:	call	delpointer
3930	pop	ax
3931	mov	pointerframe,al
3932	mov	pickup,ah
3933	mov	pointermode,0
3934	ret
3935
3936	endp
3937
3938
3939
3940
3941
3942Hangonw	proc	near
3943
3944hangloopw:	push	cx
3945	call	delpointer
3946	call	readmouse
3947	call	animpointer
3948	call	showpointer
3949	call	vsync
3950	call	dumppointer
3951	pop	cx
3952	loop	hangloopw
3953	ret
3954
3955	endp
3956
3957
3958
3959
3960Hangoncurs	proc	near
3961
3962monloop1:	push	cx
3963	call	printcurs
3964	call	vsync
3965	call	delcurs
3966	pop	cx
3967	loop	monloop1
3968	ret
3969
3970	endp
3971
3972
3973
3974
3975
3976
3977
3978
3979Getunderzoom	proc	near
3980
3981	mov	di,zoomx+5
3982	mov	bx,zoomy+4
3983	mov	ds,buffers
3984	mov	si,zoomspace
3985	mov	cl,46
3986	mov	ch,40
3987	call	multiget
3988	ret
3989
3990	endp
3991
3992
3993
3994
3995
3996Dumpzoom	proc	near
3997
3998	cmp	zoomon,1
3999	jnz	notzoomon
4000	mov	di,zoomx+5
4001	mov	bx,zoomy+4
4002	mov	cl,46
4003	mov	ch,40
4004	call	multidump
4005notzoomon:	ret
4006
4007	endp
4008
4009
4010
4011
4012
4013
4014
4015Putunderzoom	proc	near
4016
4017	mov	di,zoomx+5
4018	mov	bx,zoomy+4
4019	mov	ds,buffers
4020	mov	si,zoomspace
4021	mov	cl,46
4022	mov	ch,40
4023	call	multiput
4024	ret
4025
4026	endp
4027
4028
4029
4030
4031
4032Crosshair	proc	near
4033
4034	cmp	commandtype,3
4035	jz	nocross
4036	cmp	commandtype,10
4037	jnc	nocross
4038
4039	mov	es,workspace
4040	mov	ds,icons1
4041	mov	di,zoomx+24
4042	mov	bx,zoomy+19
4043	mov	al,9
4044	mov	ah,0
4045	call	showframe
4046	ret
4047
4048nocross:	mov	es,workspace
4049	mov	ds,icons1
4050	mov	di,zoomx+24
4051	mov	bx,zoomy+19
4052	mov	al,29
4053	mov	ah,0
4054	call	showframe
4055	ret
4056
4057	endp
4058
4059
4060
4061
4062
4063
4064Showpointer	proc	near
4065
4066	call	showblink
4067	mov	di,mousex
4068	mov	oldpointerx,di
4069	mov	bx,mousey
4070	mov	oldpointery,bx
4071	cmp	pickup,1
4072	jz	itsanobject
4073
4074	push	bx di
4075	mov	ds,icons1
4076	mov	al,pointerframe
4077	add	al,20
4078	mov	ah,0
4079	add	ax,ax
4080	mov	si,ax
4081	add	ax,ax
4082	add	si,ax
4083	mov	cx,[si]
4084	cmp	cl,12
4085	jnc	notsmallx
4086	mov	cl,12
4087notsmallx:	cmp	ch,12
4088	jnc	notsmally
4089	mov	ch,12
4090notsmally:	mov	pointerxs,cl
4091	mov	pointerys,ch
4092	push	ds
4093	mov	ds,buffers
4094	mov	si,pointerback
4095	call	multiget
4096	pop	ds di bx
4097	push	di bx
4098	mov	al,pointerframe
4099	add	al,20
4100	mov	ah,0
4101	call	showframe
4102	pop	bx di
4103	ret
4104
4105itsanobject:	mov	al,itemframe
4106	mov	ds,extras
4107	cmp	objecttype,4
4108	jz	itsfrominv
4109	mov	ds,freeframes
4110itsfrominv:	mov	cl,al
4111	add	al,al
4112	add	al,cl
4113	inc	al
4114	mov	ah,0
4115
4116	push	ax
4117	add	ax,ax
4118	mov	si,ax
4119	add	ax,ax
4120	add	si,ax
4121	mov	ax,2080
4122	mov	cx,[si]
4123	cmp	cl,12
4124	jnc	notsmallx2
4125	mov	cl,12
4126notsmallx2:	cmp	ch,12
4127	jnc	notsmally2
4128	mov	ch,12
4129notsmally2:	mov	pointerxs,cl
4130	mov	pointerys,ch
4131	pop	ax
4132
4133	push	di bx
4134	push	ax bx di ds
4135	mov	al,cl
4136	mov	ah,0
4137	shr	ax,1
4138	sub	oldpointerx,ax
4139	sub	di,ax
4140	mov	al,ch
4141	shr	ax,1
4142	sub	oldpointery,ax
4143	sub	bx,ax
4144	mov	ds,buffers
4145	mov	si,pointerback
4146	call	multiget
4147	pop	ds di bx ax
4148	mov	ah,128
4149	call	showframe
4150	pop	bx di
4151	mov	ds,icons1
4152	mov	al,3
4153	mov	ah,128
4154	call	showframe
4155	ret
4156
4157	endp
4158
4159
4160
4161
4162
4163
4164
4165Delpointer	proc		near
4166
4167	mov	ax,oldpointerx
4168	cmp	ax,0ffffh
4169	jz	nevershown
4170	mov	delherex,ax
4171	mov	ax,oldpointery
4172	mov	delherey,ax
4173	mov	cl,pointerxs
4174	mov	delxs,cl
4175	mov	ch,pointerys
4176	mov	delys,ch
4177	mov	ds,buffers
4178	mov	si,pointerback
4179	mov	di,delherex
4180	mov	bx,delherey
4181	call	multiput
4182nevershown:	ret
4183
4184	endp
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194Dumppointer	proc	near
4195
4196	call	dumpblink
4197	mov	cl,delxs
4198	mov	ch,delys
4199	mov	di,delherex
4200	mov	bx,delherey
4201	call	multidump
4202
4203	mov	bx,oldpointery
4204	mov	di,oldpointerx
4205	cmp	di,delherex
4206	jnz	difffound
4207	cmp	bx,delherey
4208	jz	notboth
4209difffound:	mov	cl,pointerxs
4210	mov	ch,pointerys
4211	call	multidump
4212notboth:	ret
4213
4214	endp
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226Undertextline	proc	near
4227
4228	mov	di,textaddressx
4229	mov	bx,textaddressy
4230	cmp	foreignrelease, 0
4231	jz $1
4232	sub	bx,3
4233$1:
4234	mov	ds,buffers
4235	mov	si,textunder
4236	mov	cl,undertextsizex
4237	mov	ch,undertextsizey
4238	call	multiget
4239	ret
4240
4241	endp
4242
4243
4244
4245
4246
4247
4248
4249
4250Deltextline	proc	near
4251
4252	mov	di,textaddressx
4253	mov	bx,textaddressy
4254	cmp	foreignrelease, 0
4255	jz $1
4256	sub	bx,3
4257$1:
4258	mov	ds,buffers
4259	mov	si,textunder
4260	mov	cl,undertextsizex
4261	mov	ch,undertextsizey
4262	call	multiput
4263	ret
4264
4265	endp
4266
4267
4268
4269
4270
4271Dumptextline	proc	near
4272
4273	cmp	newtextline,1
4274	jnz	nodumptextline
4275	mov	newtextline,0
4276	mov	di,textaddressx
4277	mov	bx,textaddressy
4278	cmp	foreignrelease, 0
4279	jz $1
4280	sub	bx,3
4281$1:
4282	mov	cl,undertextsizex
4283	mov	ch,undertextsizey
4284	call	multidump
4285nodumptextline:	ret
4286
4287	endp
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305Animpointer	proc	near
4306
4307	cmp	pointermode,2
4308	jz	combathand
4309	cmp	pointermode,3
4310	jz	mousehand
4311
4312	cmp	watchingtime,0
4313	jz	notwatchpoint
4314	mov	pointerframe,11
4315	ret
4316notwatchpoint:	mov	pointerframe,0
4317	cmp	inmaparea,0
4318	jz	gothand
4319	cmp	pointerfirstpath,0
4320	jz	gothand
4321arrow:	call	getflagunderp
4322	cmp	cl,2
4323	jc	gothand
4324	cmp	cl,128
4325	jnc	gothand
4326	mov	pointerframe,3
4327	test	cl,4
4328	jnz	gothand
4329	mov	pointerframe,4
4330	test	cl,16
4331	jnz	gothand
4332	mov	pointerframe,5
4333	test	cl,2
4334	jnz	gothand
4335	mov	pointerframe,6
4336	test	cl,8
4337	jnz	gothand
4338	mov	pointerframe,8
4339gothand:	ret
4340
4341mousehand:	cmp	pointerspeed,0
4342	jz	rightspeed3
4343	dec	pointerspeed
4344	jmp	finflashmouse
4345rightspeed3:	mov	pointerspeed,5
4346	inc	pointercount
4347	cmp	pointercount,16
4348	jnz	finflashmouse
4349	mov	pointercount,0
4350finflashmouse:	mov	al,pointercount
4351	mov	ah,0
4352	mov	bx,offset cs:flashmousetab
4353	add	bx,ax
4354	mov	al,[cs:bx]
4355	mov	pointerframe,al
4356	ret
4357
4358combathand:	mov	pointerframe,0
4359	cmp	reallocation,14
4360	jnz	notarrow
4361         	cmp	commandtype,211
4362	jnz	notarrow
4363	mov	pointerframe,5
4364notarrow:	ret
4365
4366flashmousetab:	db	1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2
4367
4368	endp
4369
4370
4371
4372
4373;------------------------------------------------Mouse and keyboard-readers----
4374
4375Setmouse	proc	near
4376
4377	if	recording
4378	mov	recordpos,-8
4379	mov	dx,seg recname
4380	mov	ds,dx
4381	mov	dx,offset recname
4382	mov	cx,0
4383	mov	ah,3ch
4384	mov	al,2
4385	int	21h
4386	mov	rechandle,ax
4387	endif
4388
4389	if	playback
4390	mov	dx,seg recname
4391	mov	ds,dx
4392	mov	dx,offset recname
4393	mov	ah,3dh
4394	mov	al,2
4395	int	21h
4396	mov	rechandle,ax
4397	call	loadrec
4398	endif
4399
4400	mov	oldpointerx,0ffffh
4401
4402	mov	ax,0
4403	int	33h
4404	mov	ax,8
4405	mov	cx,15
4406	mov	dx,184
4407	int	33h
4408	mov	ax,7
4409	mov	cx,15
4410	mov	dx,298*2
4411	int	33h
4412	ret
4413
4414	endp
4415
4416
4417
4418
4419
4420Readmouse	proc	near
4421
4422	mov	ax,mousebutton
4423	mov	oldbutton,ax
4424	mov	ax,mousex
4425	mov	oldx,ax
4426	mov	ax,mousey
4427	mov	oldy,ax
4428	call	mousecall
4429	mov	mousex,cx
4430	mov	mousey,dx
4431	mov	mousebutton,bx
4432	ret
4433
4434	endp
4435
4436
4437
4438
4439
4440
4441
4442Mousecall	proc	near
4443
4444	if	playback
4445	call	playmouse
4446	ret
4447	endif
4448
4449	mov	ax,3
4450	int	33h
4451	shr	cx,1
4452	cmp	cx,298
4453	jc	notxover
4454	mov	cx,298
4455notxover:	cmp	cx,15
4456	jnc	notxover2
4457	mov	cx,15
4458notxover2:	cmp	dx,184
4459	jc	notyover
4460	mov	dx,184
4461notyover:	cmp	dx,15
4462	jnc	notyover2
4463	mov	dx,15
4464notyover2:
4465	if	recording
4466	call	recmouse
4467	endif
4468	ret
4469
4470	endp
4471
4472
4473
4474
4475
4476
4477	if	playback
4478
4479Playmouse	proc	near
4480
4481	mov	es,recordspace
4482	mov	di,recordpos
4483	cmp	word ptr [es:di+6],0
4484	jnz	isthisplay
4485	add	di,8
4486	add	recordpos,8
4487	cmp	di,16384
4488	jnz	isthisplay
4489	call	loadrec
4490isthisplay:	mov	cx,[es:di]
4491	mov	dx,[es:di+2]
4492	mov	bx,[es:di+4]
4493	dec	word ptr [es:di+6]
4494	ret
4495
4496	endp
4497
4498	endif
4499
4500	if	recording
4501
4502Recmouse	proc	near
4503
4504	mov	es,recordspace
4505	mov	di,recordpos
4506	cmp	di,-8
4507	jz	diffrec
4508	cmp	[es:di],cx
4509	jnz	diffrec
4510	cmp	[es:di+2],dx
4511	jnz	diffrec
4512	cmp	[es:di+4],bx
4513	jnz	diffrec
4514	inc	word ptr [es:di+6]
4515	cmp	word ptr [es:di+5],0ffffh
4516	jz	diffrec
4517	ret
4518diffrec:	add	recordpos,8
4519	add	di,8
4520	cmp	di,16384
4521	jnz	notsaverec
4522	push	cx dx bx
4523	call	saverec
4524	pop	bx dx cx
4525notsaverec:	mov	[es:di],cx
4526	mov	[es:di+2],dx
4527	mov	[es:di+4],bx
4528	mov	word ptr [es:di+6],1
4529	ret
4530
4531	endp
4532
4533
4534
4535
4536
4537Saverec	proc	near
4538
4539	mov	bx,rechandle
4540	mov	ds,recordspace
4541	mov	dx,0
4542	mov	cx,recordpos
4543	add	cx,8
4544	mov	ah,40h
4545	int	21h
4546	mov	di,0
4547	mov	recordpos,0
4548	ret
4549
4550	endp
4551
4552
4553
4554
4555
4556
4557Loadrec	proc	near
4558
4559	mov	bx,rechandle
4560	mov	ds,recordspace
4561	mov	dx,0
4562	mov	cx,16384+8
4563	mov	ah,3fh
4564	int	21h
4565	mov	di,0
4566	mov	recordpos,0
4567	ret
4568
4569	endp
4570
4571
4572	endif
4573
4574
4575
4576
4577
4578
4579
4580Readmouse1	proc	near
4581
4582	mov	ax,mousex
4583	mov	oldx,ax
4584	mov	ax,mousey
4585	mov	oldy,ax
4586	call	mousecall
4587	mov	mousex,cx
4588	mov	mousey,dx
4589	mov	mousebutton1,bx
4590	ret
4591
4592	endp
4593
4594
4595
4596Readmouse2	proc	near
4597
4598	mov	ax,mousex
4599	mov	oldx,ax
4600	mov	ax,mousey
4601	mov	oldy,ax
4602	call	mousecall
4603	mov	mousex,cx
4604	mov	mousey,dx
4605	mov	mousebutton2,bx
4606	ret
4607
4608	endp
4609
4610
4611Readmouse3	proc	near
4612
4613	mov	ax,mousex
4614	mov	oldx,ax
4615	mov	ax,mousey
4616	mov	oldy,ax
4617	call	mousecall
4618	mov	mousex,cx
4619	mov	mousey,dx
4620	mov	mousebutton3,bx
4621	ret
4622
4623	endp
4624
4625
4626
4627
4628
4629
4630Readmouse4	proc	near
4631
4632	mov	ax,mousebutton
4633	mov	oldbutton,ax
4634	mov	ax,mousex
4635	mov	oldx,ax
4636	mov	ax,mousey
4637	mov	oldy,ax
4638	call	mousecall
4639	mov	mousex,cx
4640	mov	mousey,dx
4641	mov	ax,mousebutton1
4642	or	ax,mousebutton2
4643	or	ax,mousebutton3
4644	or	bx,ax
4645	mov	mousebutton,bx
4646	ret
4647
4648	endp
4649
4650
4651
4652
4653
4654Readkey 	proc	near
4655
4656	mov	bx,bufferout
4657	cmp	bx,bufferin
4658	jz	nokey
4659	inc	bx
4660	and	bx,15
4661	mov	bufferout,bx
4662      	mov	di,offset cs:keybuffer
4663	add	di,bx
4664	mov	al,[cs:di]
4665	mov	currentkey,al
4666	ret
4667nokey:	mov	currentkey,0
4668	ret
4669
4670
4671	endp
4672
4673keybuffer:	db	16 dup (0)
4674
4675
4676
4677Convertkey	proc	near
4678
4679	and	al,127
4680	mov	ah,0
4681	mov	di,offset cs:keyconverttab
4682	add	di,ax
4683	mov	al,[cs:di]
4684	ret
4685
4686keyconverttab:	db	0,0,"1","2","3","4","5","6","7","8","9","0","-",0,8,0
4687	db	"Q","W","E","R","T","Y","U","I","O","P",0,0,13,0,"A","S"
4688	db	"D","F","G","H","J","K","L",0,0,0,0,0,"Z","X","C","V","B","N","M"
4689	db	0,0,0,0,0,0,32,0,0,0,0,0,0,0,0,0
4690	db	0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
4691	db	0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
4692	db	0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
4693	db	0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
4694
4695	endp
4696
4697
4698
4699
4700;-------------------------------------------------------------Miscellaneous----
4701
4702Randomnum1	proc	near
4703
4704	push	ds es di bx cx
4705	call	randomnumber
4706	pop	cx bx di es ds
4707	ret
4708
4709	endp
4710
4711
4712
4713
4714
4715Randomnum2	proc	near
4716
4717	push	ds es di bx ax
4718	call	randomnumber
4719	mov	cl,al
4720	pop	ax bx di es ds
4721	ret
4722
4723	endp
4724
4725
4726
4727
4728
4729Randomnumber	proc	near
4730
4731	mov	al,seed
4732	and	al,48h
4733	add	al,38h
4734	sal	al,1
4735	sal	al,1
4736	rcl	seed+2,1
4737	rcl	seed+1,1
4738	rcl	seed+0,1
4739	mov	al,seed
4740	and	al,48h
4741	add	al,38h
4742	sal	al,1
4743	sal	al,1
4744	rcl	seed+2,1
4745	rcl	seed+1,1
4746	rcl	seed+0,1
4747	mov	al,seed
4748	and	al,48h
4749	add	al,38h
4750	sal	al,1
4751	sal	al,1
4752	rcl	seed+2,1
4753	rcl	seed+1,1
4754	rcl	seed+0,1
4755	mov	al,seed
4756	and	al,48h
4757	add	al,38h
4758	sal	al,1
4759	sal	al,1
4760	rcl	seed+2,1
4761	rcl	seed+1,1
4762	rcl	seed+0,1
4763	mov	al,seed
4764	and	al,48h
4765	add	al,38h
4766	sal	al,1
4767	sal	al,1
4768	rcl	seed+2,1
4769	rcl	seed+1,1
4770	rcl	seed+0,1
4771	mov	al,seed
4772	and	al,48h
4773	add	al,38h
4774	sal	al,1
4775	sal	al,1
4776	rcl	seed+2,1
4777	rcl	seed+1,1
4778	rcl	seed+0,1
4779	mov	al,seed
4780	and	al,48h
4781	add	al,38h
4782	sal	al,1
4783	sal	al,1
4784	rcl	seed+2,1
4785	rcl	seed+1,1
4786	rcl	seed+0,1
4787	mov	al,seed
4788	and	al,48h
4789	add	al,38h
4790	sal	al,1
4791	sal	al,1
4792	rcl	seed+2,1
4793	rcl	seed+1,1
4794	rcl	seed+0,1
4795
4796	mov	al,seed
4797	ret
4798
4799	endp
4800
4801
4802
4803
4804
4805
4806Hangon	proc	near
4807
4808hangonloop:	push	cx
4809	call	vsync
4810	pop	cx
4811	loop	hangonloop
4812	ret
4813
4814	endp
4815
4816
4817
4818
4819
4820;-------------------------------------------------------------Disc handling----
4821
4822
4823Loadtraveltext	proc	near
4824
4825	mov	dx,offset cs:traveltextname
4826	call	standardload
4827	mov	traveltext,ax
4828	ret
4829
4830	endp
4831
4832
4833
4834
4835
4836
4837Loadintotemp	proc	near
4838
4839	push	cs
4840	pop	ds
4841	call	standardload
4842	mov	tempgraphics,ax
4843	ret
4844
4845	endp
4846
4847
4848
4849
4850
4851
4852Loadintotemp2	proc	near
4853
4854	push	cs
4855	pop	ds
4856	call	standardload
4857	mov	tempgraphics2,ax
4858	ret
4859
4860	endp
4861
4862
4863
4864
4865Loadintotemp3	proc	near
4866
4867	push	cs
4868	pop	ds
4869	call	standardload
4870	mov	tempgraphics3,ax
4871	ret
4872
4873	endp
4874
4875
4876
4877Loadtempcharset	proc	near
4878
4879	call	standardload
4880	mov	tempcharset,ax
4881	ret
4882
4883	endp
4884
4885
4886
4887
4888
4889
4890Standardload	proc	near
4891
4892	call	openfile
4893	call	readheader
4894	mov	bx,[es:di]
4895	push	bx
4896	mov	cl,4
4897	shr	bx,cl
4898	call	allocatemem
4899	mov	ds,ax
4900	pop	cx
4901	push	ax
4902	mov	dx,0
4903	call	readfromfile
4904	call	closefile
4905	pop	ax
4906	ret
4907
4908	endp
4909
4910
4911
4912
4913
4914
4915Loadtemptext	proc	near
4916
4917	call	standardload
4918	mov	textfile1,ax
4919	ret
4920
4921	endp
4922
4923
4924
4925
4926
4927
4928
4929Loadroom	proc	near
4930
4931	mov	roomloaded,1
4932	mov	timecount,0
4933	mov	maintimer,0
4934	mov	mapoffsetx,104
4935	mov	mapoffsety,38
4936	mov	textaddressx,13
4937	mov	textaddressy,182
4938	mov	textlen,240
4939	mov	al,newlocation
4940	mov	location,al
4941	call	getroomdata
4942	call	startloading
4943	call	loadroomssample
4944	call	switchryanon
4945	call	drawflags
4946	call	getdimension
4947	ret
4948
4949	endp
4950
4951
4952
4953
4954Loadroomssample	proc	near
4955
4956	mov	al,roomssample
4957	cmp	al,255
4958	jz	loadedalready
4959	cmp	al,currentsample
4960	jz	loadedalready
4961	mov	currentsample,al
4962	mov	al,currentsample
4963	mov	cl,"0"
4964	call	twodigitnum
4965	mov	di,offset cs:samplename
4966	xchg	al,ah
4967	mov	[cs:di+10],ax
4968	mov	dx,di
4969	call	loadsecondsample
4970loadedalready:	ret
4971
4972	endp
4973
4974
4975
4976
4977
4978Getridofreels	proc	near
4979
4980	cmp	roomloaded,0
4981	jz	dontgetrid
4982	mov	es,reel1
4983	call	deallocatemem
4984	mov	es,reel2
4985	call	deallocatemem
4986	mov	es,reel3
4987	call	deallocatemem
4988dontgetrid:	ret
4989
4990	endp
4991
4992
4993
4994
4995
4996Getridofall	proc	near
4997
4998	mov	es,backdrop
4999	call	deallocatemem
5000	mov	es,setframes
5001	call	deallocatemem
5002	mov	es,reel1
5003	call	deallocatemem
5004	mov	es,reel2
5005	call	deallocatemem
5006	mov	es,reel3
5007	call	deallocatemem
5008	mov	es,reels
5009	call	deallocatemem
5010	mov	es,people
5011	call	deallocatemem
5012	mov	es,setdesc
5013	call	deallocatemem
5014	mov	es,blockdesc
5015	call	deallocatemem
5016	mov	es,roomdesc
5017	call	deallocatemem
5018	mov	es,freeframes
5019	call	deallocatemem
5020	mov	es,freedesc
5021	call	deallocatemem
5022	ret
5023
5024	endp
5025
5026
5027
5028
5029
5030Restorereels	proc	near
5031
5032	cmp	roomloaded,0
5033	jz	dontrestore
5034	mov	al,reallocation
5035	call	getroomdata
5036	mov	dx,bx
5037	call	openfile
5038	call	readheader
5039
5040	call	dontloadseg
5041	call	dontloadseg
5042	call	dontloadseg
5043	call	dontloadseg
5044
5045	call	allocateload
5046	mov	reel1,ax
5047	mov	ds,ax
5048	mov	dx,0
5049	call	loadseg
5050	call	allocateload
5051	mov	reel2,ax
5052	mov	ds,ax
5053	mov	dx,0
5054	call	loadseg
5055	call	allocateload
5056	mov	reel3,ax
5057	mov	ds,ax
5058	mov	dx,0
5059	call	loadseg
5060	call	closefile
5061dontrestore:	ret
5062
5063	endp
5064
5065
5066
5067
5068
5069
5070
5071Restoreall	proc	near
5072
5073	mov	al,location
5074	call	getroomdata
5075	mov	dx,bx
5076	call	openfile
5077	call	readheader
5078
5079	call	allocateload
5080	mov	ds,ax
5081	mov	backdrop,ax
5082	mov	dx,flags
5083	call	loadseg
5084
5085	mov	ds,workspace ;mapdata
5086	mov	dx,map
5087	mov	cx,132*66 ;maplen
5088	mov	al,0
5089	call	fillspace
5090	call	loadseg
5091	call	sortoutmap
5092
5093	call	allocateload
5094	mov	setframes,ax
5095	mov	ds,ax
5096	mov	dx,framedata
5097	call	loadseg
5098
5099	;mov	ds,setdat
5100	;mov	dx,0
5101	;mov	cx,setdatlen
5102	;mov	al,255
5103	;call	fillspace
5104	call	dontloadseg
5105
5106	call	allocateload
5107	mov	reel1,ax
5108	mov	ds,ax
5109	mov	dx,0
5110	;call	bloc
5111	;BIG FIXME: undefined bloc, replaced with loadseg. dunno!
5112	call	loadseg
5113	call	allocateload
5114	mov	reel2,ax
5115	mov	ds,ax
5116	mov	dx,0
5117	call	loadseg
5118	call	allocateload
5119	mov	reel3,ax
5120	mov	ds,ax
5121	mov	dx,0
5122	call	loadseg
5123
5124	call	allocateload
5125	mov	reels,ax
5126	mov	ds,ax
5127	mov	dx,0
5128	call	loadseg
5129
5130	call	allocateload
5131	mov	people,ax
5132	mov	ds,ax
5133	mov	dx,0
5134	call	loadseg
5135
5136	call	allocateload
5137	mov	setdesc,ax
5138	mov	ds,ax
5139	mov	dx,0
5140	call	loadseg
5141
5142	call	allocateload
5143	mov	blockdesc,ax
5144	mov	ds,ax
5145	mov	dx,0
5146	call	loadseg
5147
5148	call	allocateload
5149	mov	roomdesc,ax
5150	mov	ds,ax
5151	mov	dx,0
5152	call	loadseg
5153
5154	call	allocateload
5155	mov	freeframes,ax
5156	mov	ds,ax
5157	mov	dx,0
5158	call	loadseg
5159
5160	;mov	ds,freedat
5161	;mov	dx,0
5162	;mov	cx,freedatlen
5163	;mov	al,255
5164	;call	fillspace
5165	call	dontloadseg
5166
5167	call	allocateload
5168	mov	freedesc,ax
5169	mov	ds,ax
5170	mov	dx,freetextdat
5171	call	loadseg
5172
5173	call	closefile
5174
5175	call	setallchanges
5176	ret
5177
5178	endp
5179
5180
5181
5182Sortoutmap	proc	near
5183
5184	push	es di
5185	mov	ds,workspace
5186	mov	si,0
5187	mov	es,mapdata
5188	mov	di,0
5189
5190	mov	cx,maplength
5191blimey:	push	cx si
5192	mov	cx,mapwidth
5193	rep	movsb
5194	pop	si cx
5195	add	si,132
5196	loop	blimey
5197	pop	di es
5198	ret
5199
5200	endp
5201
5202
5203
5204
5205Startloading	proc	near
5206
5207	mov	combatcount,0
5208	mov	al,[cs:bx+13]
5209	mov	roomssample,al
5210	mov	al,[cs:bx+15]
5211	mov	mapx,al
5212	mov	al,[cs:bx+16]
5213	mov	mapy,al
5214
5215	mov	al,[cs:bx+20]		; start path pos
5216	mov	liftflag,al
5217	mov	al,[cs:bx+21]		; start path pos
5218	mov	manspath,al
5219	mov	destination,al
5220	mov	finaldest,al
5221	mov	al,[cs:bx+22]
5222	mov	facing,al
5223	mov	turntoface,al
5224	mov	al,[cs:bx+23]
5225	mov	counttoopen,al
5226	mov	al,[cs:bx+24]
5227	mov	liftpath,al
5228	mov	al,[cs:bx+25]
5229	mov	doorpath,al
5230	mov	lastweapon,-1
5231	mov	al,[cs:bx+27]
5232	push	ax
5233
5234	mov	al,[cs:bx+31]
5235	mov	ah,reallocation
5236	mov	reallocation,al
5237
5238	mov	dx,bx
5239	call	openfile
5240	call	readheader
5241
5242	call	allocateload
5243	mov	ds,ax
5244	mov	backdrop,ax
5245	mov	dx,flags
5246	call	loadseg
5247
5248	mov	ds,workspace ;mapdata
5249	mov	dx,map
5250	mov	cx,132*66 ;maplen
5251	mov	al,0
5252	call	fillspace
5253	call	loadseg
5254	call	sortoutmap
5255
5256	call	allocateload
5257	mov	setframes,ax
5258	mov	ds,ax
5259	mov	dx,framedata
5260	call	loadseg
5261
5262	mov	ds,setdat
5263	mov	dx,0
5264	mov	cx,setdatlen
5265	mov	al,255
5266	call	fillspace
5267	call	loadseg
5268
5269	call	allocateload
5270	mov	reel1,ax
5271	mov	ds,ax
5272	mov	dx,0
5273	call	loadseg
5274	call	allocateload
5275	mov	reel2,ax
5276	mov	ds,ax
5277	mov	dx,0
5278	call	loadseg
5279	call	allocateload
5280	mov	reel3,ax
5281	mov	ds,ax
5282	mov	dx,0
5283	call	loadseg
5284
5285	call	allocateload
5286	mov	reels,ax
5287	mov	ds,ax
5288	mov	dx,0
5289	call	loadseg
5290
5291	call	allocateload
5292	mov	people,ax
5293	mov	ds,ax
5294	mov	dx,0
5295	call	loadseg
5296
5297	call	allocateload
5298	mov	setdesc,ax
5299	mov	ds,ax
5300	mov	dx,0
5301	call	loadseg
5302
5303	call	allocateload
5304	mov	blockdesc,ax
5305	mov	ds,ax
5306	mov	dx,0
5307	call	loadseg
5308
5309	call	allocateload
5310	mov	roomdesc,ax
5311	mov	ds,ax
5312	mov	dx,0
5313	call	loadseg
5314
5315	call	allocateload
5316	mov	freeframes,ax
5317	mov	ds,ax
5318	mov	dx,0
5319	call	loadseg
5320
5321	mov	ds,freedat
5322	mov	dx,0
5323	mov	cx,freedatlen
5324	mov	al,255
5325	call	fillspace
5326	call	loadseg
5327
5328	call	allocateload
5329	mov	freedesc,ax
5330	mov	ds,ax
5331	mov	dx,freetextdat
5332	call	loadseg
5333
5334	call	closefile
5335
5336
5337	call	findroominloc
5338	call	deletetaken
5339	call	setallchanges
5340	call	autoappear
5341	mov	al,newlocation
5342	call	getroomdata
5343	mov	lastweapon,-1
5344	mov	mandead,0
5345	mov	lookcounter,160
5346	mov	newlocation,255
5347	mov	linepointer,254
5348	pop	ax
5349	cmp	al,255
5350	jz	dontwalkin
5351           	mov	manspath,al
5352	push	bx
5353	call	autosetwalk
5354	pop	bx
5355dontwalkin:	call	findxyfrompath
5356	ret
5357
5358	endp
5359
5360
5361
5362
5363
5364
5365
5366
5367
5368
5369Disablepath	proc	near		;needs al,ah map x,y cl=path
5370
5371	push	cx
5372	xchg	al,ah
5373	mov	cx,-6
5374looky2: 	add	cx,6
5375	sub	al,10
5376	jnc	looky2
5377	mov	al,ah
5378	dec	cx
5379lookx2: 	inc	cx
5380	sub	al,11
5381	jnc	lookx2
5382	mov	al,cl
5383	mov	ah,0
5384	mov	cx,144
5385	mul	cx
5386	mov	es,reels
5387	mov	bx,pathdata
5388	add	bx,ax
5389	pop	ax
5390	mov	ah,0
5391	add	ax,ax
5392	add	ax,ax
5393	add	ax,ax
5394	add	bx,ax
5395	mov	al,0
5396	mov	[es:bx+6],al
5397	ret
5398
5399	endp
5400
5401
5402
5403
5404
5405
5406
5407
5408Findxyfrompath	proc	near		;path number was found from
5409				;room data. Fill ryanxy from
5410	call	getroomspaths		;the pathdata.
5411	mov	al,manspath
5412	mov	ah,0
5413	add	ax,ax
5414	add	ax,ax
5415	add	ax,ax
5416	add	bx,ax
5417	mov	ax,[es:bx]
5418	sub	al,12
5419	sub	ah,12
5420	mov	ryanx,al
5421	mov	ryany,ah
5422	ret
5423
5424	endp
5425
5426
5427
5428
5429
5430Findroominloc	proc	near
5431
5432	mov	al,mapy
5433	mov	cx,-6
5434looky:	add	cx,6
5435	sub	al,10
5436	jnc	looky
5437	mov	al,mapx
5438	dec	cx
5439lookx:	inc	cx
5440	sub	al,11
5441	jnc	lookx
5442	mov	roomnum,cl
5443	ret
5444
5445	endp
5446
5447
5448
5449
5450
5451
5452Getroomdata	proc	near
5453
5454	mov	ah,0
5455	mov	cx,32
5456	mul	cx
5457	mov	bx,offset cs:roomdata
5458	add	bx,ax
5459	ret
5460
5461	endp
5462
5463
5464
5465
5466
5467
5468
5469
5470
5471
5472
5473
5474
5475Readheader	proc	near
5476
5477	push	cs
5478	pop	ds
5479	mov	dx,offset cs:fileheader
5480	mov	cx,headerlen
5481	call	readfromfile
5482	push	cs
5483	pop	es
5484	mov	di,offset cs:filedata
5485	ret
5486
5487	endp
5488
5489
5490
5491
5492
5493
5494
5495
5496Dontloadseg	proc	neqr
5497
5498	mov	ax,[es:di]
5499	add	di,2
5500	push	bx di es
5501	mov	cx,0
5502	mov	dx,ax
5503	mov	al,1
5504	mov	ah,42h
5505	int	21h
5506	pop	es di bx
5507	ret
5508
5509	endp
5510
5511
5512
5513
5514
5515
5516Allocateload	proc	near
5517
5518	push	es di
5519	mov	bx,[es:di]
5520	mov	cl,4
5521	shr	bx,cl
5522	call	allocatemem
5523	pop	di es
5524	ret
5525
5526	endp
5527
5528
5529
5530
5531Fillspace	proc	near
5532
5533	push	es ds dx di bx
5534	mov	di,dx
5535	push	ds
5536	pop	es
5537	rep	stosb
5538	pop	bx di dx ds es
5539	ret
5540
5541	endp
5542
5543
5544
5545
5546
5547
5548
5549Getridoftemp	proc	near
5550
5551	mov	es,tempgraphics
5552	call	deallocatemem
5553	ret
5554
5555	endp
5556
5557
5558
5559
5560
5561Getridoftemptext	proc	near
5562
5563	mov	es,textfile1
5564	call	deallocatemem
5565	ret
5566
5567	endp
5568
5569
5570
5571
5572
5573Getridoftemp2	proc	near
5574
5575	mov	es,tempgraphics2
5576	call	deallocatemem
5577	ret
5578
5579	endp
5580
5581
5582
5583Getridoftemp3	proc	near
5584
5585	mov	es,tempgraphics3
5586	call	deallocatemem
5587	ret
5588
5589	endp
5590
5591
5592
5593Getridoftempcharset	proc	near
5594
5595	mov	es,tempcharset
5596	call	deallocatemem
5597	ret
5598
5599	endp
5600
5601
5602
5603Getridoftempsp	proc	near
5604
5605	mov	es,tempsprites
5606	call	deallocatemem
5607	ret
5608
5609	endp
5610
5611
5612
5613
5614
5615
5616
5617
5618
5619
5620
5621
5622
5623
5624
5625
5626
5627
5628
5629
5630
5631
5632
5633Readsetdata	proc	near
5634
5635	mov	dx,offset cs:characterset1
5636	call	standardload
5637	mov	charset1,ax
5638
5639	mov	dx,offset cs:icongraphics0
5640	call	standardload
5641	mov	icons1,ax
5642
5643	mov	dx,offset cs:icongraphics1
5644	call	standardload
5645	mov	icons2,ax
5646
5647	mov	dx,offset cs:spritename1
5648	call	standardload
5649	mov	mainsprites,ax
5650
5651	mov	dx,offset cs:puzzletextname
5652	call	standardload
5653	mov	puzzletext,ax
5654
5655	mov	dx,offset cs:commandtextname
5656	call	standardload
5657	mov	commandtext,ax
5658
5659	mov	ax,charset1
5660	mov	currentset,ax
5661
5662	cmp	soundint,255
5663	jz	novolumeload
5664	mov	dx,offset cs:volumetabname
5665	call	openfile
5666	mov	cx,2048-256
5667	mov	ds,soundbuffer
5668	mov	dx,16384
5669	call	readfromfile
5670	call	closefile
5671novolumeload:	ret
5672
5673	endp
5674
5675
5676
5677
5678
5679
5680
5681
5682
5683
5684
5685Createfile	proc	near
5686
5687	mov	ah,3ch
5688	mov	cx,0
5689	int	21h
5690	mov	bx,ax
5691	ret
5692
5693	endp
5694
5695
5696
5697
5698
5699
5700
5701Openfile	proc	near
5702
5703	if	cd
5704	call	makename
5705	endif
5706	push	cs
5707	pop	ds
5708	mov	ah,3dh
5709	mov	al,2
5710	push	dx
5711	int	21h
5712	pop	dx
5713	jc	fileerror
5714	mov	handle,ax
5715	ret
5716fileerror:	mov	gameerror,8
5717	jmp	quickquit2
5718
5719	endp
5720
5721
5722	if	cd
5723Openfilefromc	proc	near
5724
5725	push	cs
5726	pop	ds
5727	mov	ah,3dh
5728	mov	al,2
5729	push	dx
5730	int	21h
5731	pop	dx
5732	mov	handle,ax
5733	ret
5734
5735	endp
5736	endif
5737
5738
5739	if	cd
5740Makename	proc	near
5741
5742	if	demo
5743	ret
5744	endif
5745	mov	si,dx
5746	mov	di,offset cs:place
5747transfer:	mov	al,[cs:si]
5748	mov	[cs:di],al
5749	inc	si
5750	inc	di
5751	cmp	al,0
5752	jnz	transfer
5753	mov	dx,offset cs:id
5754	ret
5755id:	db	"D:\"
5756place:	db	30 dup (0)
5757
5758	endp
5759	endif
5760
5761
5762
5763
5764
5765Openfilenocheck	proc	near
5766
5767	if	cd
5768	call	makename
5769	endif
5770	push	cs
5771	pop	ds
5772	mov	ah,3dh
5773	mov	al,2
5774	int	21h
5775	mov	handle,ax
5776	ret
5777
5778	endp
5779
5780
5781
5782Openforsave	proc	near
5783
5784	mov	cx,0
5785	mov	ah,3ch
5786	mov	al,2
5787	int	21h
5788	mov	handle,ax
5789	ret
5790
5791	endp
5792
5793
5794
5795Closefile	proc	near
5796
5797	mov	bx,handle
5798	mov	ah,3eh
5799	int	21h
5800	ret
5801
5802	endp
5803
5804
5805
5806
5807Readfromfile	proc	near
5808
5809	mov	bx,handle
5810	mov	ah,3fh
5811	int	21h
5812	ret
5813
5814	endp
5815
5816
5817
5818
5819Setkeyboardint	proc	near
5820
5821	mov	ah,35h
5822	mov	al,9
5823	int	21h
5824	mov	oldint9seg,es		; Save es:bx to temp memory
5825	mov	oldint9add,bx
5826	push	cs
5827	pop	ds
5828	mov	dx,offset cs:keyboardread
5829	mov	ah,25h
5830	mov	al,9
5831	int	21h		; Set to new
5832	ret
5833
5834	endp
5835
5836
5837
5838
5839Resetkeyboard	proc	near
5840
5841	cmp	oldint9add,-1
5842	jz	noreset
5843	mov	dx,oldint9add		;Restore old interupt vector
5844	mov	ax,oldint9seg		;for keys
5845	mov	ds,ax
5846	mov	ah,25h
5847	mov	al,9
5848	int	21h
5849noreset:	ret
5850
5851	endp
5852
5853
5854
5855
5856
5857
5858
5859
5860
5861
5862
5863
5864
5865
5866
5867
5868
5869
5870
5871
5872
5873
5874Keyboardread	proc	near
5875
5876	push	ax dx di ds es
5877	in	al,60h
5878	cmp	al,lasthardkey
5879	jz	same
5880	mov	lasthardkey,al
5881	cmp	al,128
5882	jnc	same
5883	mov	dx,bufferin
5884	inc	dx
5885	and	dx,15
5886	cmp	dx,bufferout
5887	jz	same	;buffer is full
5888	mov	bufferin,dx
5889	call	convertkey
5890	mov	di,offset cs:keybuffer
5891	mov	dx,bufferin
5892	add	di,dx
5893	mov	[cs:di],al
5894same:	in	al,61h
5895	mov	ah,al
5896	or	al,80h		; Mask for Akn
5897	out	61h,al		; Set Akn.
5898	and	al,7fh
5899	out	61h,al
5900	cli
5901	mov	al,20h		; 8259 end of interrupt
5902	out	20h,al
5903	pop	es ds di dx ax
5904	iret
5905
5906	endp
5907
5908
5909
5910;------------------------------------------------------Text and tables data----
5911
5912
5913
5914Fileheader	db	"DREAMWEB DATA FILE "
5915	db	"COPYRIGHT 1992 "
5916	db	"CREATIVE REALITY"
5917Filedata	dw	20 dup (0)
5918Extradata	db	6 dup (0)
5919Headerlen	equ	96   ; $-Fileheader
5920
5921
5922Roomdata	db	"DREAMWEB.R00",0	;Ryan's apartment
5923	db	5,255,33,10
5924	db	255,255,255,0
5925	db	1,6,2,255,3,255,255,255,255,255,0
5926
5927	db	"DREAMWEB.R01",0
5928	db	1,255,44,10
5929	db	255,255,255,0
5930	db	7,2,255,255,255,255,6,255,255,255,1
5931
5932	db	"DREAMWEB.R02",0
5933	db	2,255,33,0
5934	db	255,255,255,0
5935	db	1,0,255,255,1,255,3,255,255,255,2
5936
5937	db	"DREAMWEB.R03",0
5938	db	5,255,33,10
5939	db	255,255,255,0
5940	db	2,2,0,2,4,255,0,255,255,255,3
5941
5942	db	"DREAMWEB.R04",0
5943	db	23,255,11,30
5944	db	255,255,255,0
5945	db	1,4,0,5,255,255,3,255,255,255,4
5946
5947	db	"DREAMWEB.R05",0
5948	if	demo
5949	db	22,255,22,30
5950	else
5951	db	5,255,22,30
5952	endif
5953	db	255,255,255,0
5954	db	1,2,0,4,255,255,3,255,255,255,5
5955
5956	db	"DREAMWEB.R06",0
5957	db	5,255,11,30
5958	db	255,255,255,0
5959	db	1,0,0,1,2,255,0,255,255,255,6
5960
5961	db	"DREAMWEB.R07",0
5962	db	255,255,0,20
5963	db	255,255,255,0
5964	db	2,2,255,255,255,255,0,255,255,255,7
5965
5966	db	"DREAMWEB.R08",0
5967	db	8,255,0,10
5968	db	255,255,255,0
5969	db	1,2,255,255,255,255,0,11,40,0,8
5970
5971	db	"DREAMWEB.R09",0
5972	db	9,255,22,10
5973	db	255,255,255,0
5974	db	4,6,255,255,255,255,0,255,255,255,9
5975
5976	db	"DREAMWEB.R10",0
5977	db	10,255,33,30
5978	db	255,255,255,0
5979	db	2,0,255,255,2,2,4,22,30,255,10	;22,30,0 switches
5980				;off path 0 in skip
5981	db	"DREAMWEB.R11",0
5982	db	11,255,11,20
5983	db	255,255,255,0
5984	db	0,4,255,255,255,255,255,255,255,255,11
5985
5986	db	"DREAMWEB.R12",0
5987	db	12,255,22,20
5988	db	255,255,255,0
5989	db	1,4,255,255,255,255,255,255,255,255,12
5990
5991	db	"DREAMWEB.R13",0
5992	db	12,255,22,20
5993	db	255,255,255,0
5994	db	1,4,255,255,255,255,255,255,255,255,13
5995
5996	db	"DREAMWEB.R14",0
5997	db	14,255,44,20
5998	db	255,255,255,0
5999	db	0,6,255,255,255,255,255,255,255,255,14
6000
6001	db	32 dup (0)
6002	db	32 dup (0)
6003	db	32 dup (0)
6004	db	32 dup (0)
6005
6006	db	"DREAMWEB.R19",0
6007	db	19,255,0,0
6008	db	255,255,255,0
6009	db	0,4,255,255,255,255,255,255,255,255,19
6010
6011	db	"DREAMWEB.R20",0
6012	db	22,255,0,20
6013	db	255,255,255,0
6014	db	1,4,2,15,255,255,255,255,255,255,20
6015
6016	db	"DREAMWEB.R21",0
6017	if	demo
6018	db	22,255,11,10
6019	else
6020	db	5,255,11,10
6021	endif
6022	db	255,255,255,0
6023	db	1,4,2,15,1,255,255,255,255,255,21
6024
6025	db	"DREAMWEB.R22",0
6026	db	22,255,22,10
6027	db	255,255,255,0
6028	db	0,4,255,255,1,255,255,255,255,255,22
6029
6030	db	"DREAMWEB.R23",0
6031	db	23,255,22,30
6032	db	255,255,255,0
6033	db	1,4,2,15,3,255,255,255,255,255,23
6034
6035	db	"DREAMWEB.R24",0
6036	db	5,255,44,0
6037	db	255,255,255,0
6038	db	1,6,2,15,255,255,255,255,255,255,24
6039
6040	db	"DREAMWEB.R25",0
6041	db	22,255,11,40
6042	db	255,255,255,0
6043	db	1,0,255,255,255,255,255,255,255,255,25
6044
6045	db	"DREAMWEB.R26",0
6046	db	9,255,22,20
6047	db	255,255,255,0
6048	db	4,2,255,255,255,255,255,255,255,255,26
6049
6050	db	"DREAMWEB.R27",0
6051	db	22,255,11,20
6052	db	255,255,255,0
6053	db	0,6,255,255,255,255,255,255,255,255,27
6054
6055	db	"DREAMWEB.R28",0
6056	db	5,255,11,30
6057	db	255,255,255,0
6058	db	0,0,255,255,2,255,255,255,255,255,28
6059
6060	db	"DREAMWEB.R29",0
6061	db	22,255,11,10
6062	db	255,255,255,0
6063	db	0,2,255,255,255,255,255,255,255,255,29
6064
6065
6066
6067	db	"DREAMWEB.R05",0	;Duplicate of hotel lobby,
6068	if	demo
6069	db	22,255,22,10 	;but emerging from the lift.
6070	else
6071	db	5,255,22,10
6072	endif
6073	db	255,255,255,0
6074	db	1,4,1,15,255,255,255,255,255,255,5
6075
6076	db	"DREAMWEB.R04",0	;Duplicate of pool hall lobby,
6077	db	23,255,22,20 	;but emerging from the lift.
6078	db	255,255,255,0
6079	db	1,4,2,15,255,255,255,255,255,255,4
6080
6081	db	"DREAMWEB.R10",0	;entering alley via skip
6082	db	10,255,22,30
6083	db	255,255,255,0
6084	db	3,6,255,255,255,255,255,255,255,255,10
6085
6086	db	"DREAMWEB.R12",0	;on the beach, getting up.
6087	db	12,255,22,20
6088	db	255,255,255,0
6089	db	0,2,255,255,255,255,255,255,255,255,12
6090
6091	db	"DREAMWEB.R03",0	;Duplicate of Eden's lobby
6092	db	5,255,44,0   	;but emerging from the lift
6093	db	255,255,255,0
6094	db	1,6,2,255,4,255,255,255,255,255,3
6095
6096	db	"DREAMWEB.R24",0	;Duplicate of Eden's flat
6097	db	5,255,22,0	 ;but starting on the bed
6098	db	255,255,255,0
6099	db	3,6,0,255,255,255,255,33,0,3,24	; 33,0,3 turns off
6100					; path for lift
6101	db	"DREAMWEB.R22",0	;Duplicate
6102	db	22,255,22,20	;of hotel but in pool room
6103	db	255,255,255,0
6104	db	1,4,255,255,255,255,255,255,255,255,22
6105
6106	db	"DREAMWEB.R22",0	;Duplicate
6107	db	22,255,22,20	;of hotel but in pool room
6108	db	255,255,255,0	;coming out of bedroom
6109	db	0,2,255,255,255,255,255,255,255,255,22
6110
6111	db	"DREAMWEB.R11",0	;Duplicate
6112	db	11,255,22,30	;of carpark but getting
6113	db	255,255,255,0	;up off the floor
6114	db	0,0,255,255,255,255,255,255,255,255,11
6115
6116	db	"DREAMWEB.R28",0
6117	db	5,255,11,20
6118	db	255,255,255,0
6119	db	0,6,255,255,2,255,255,255,255,255,28
6120
6121	db	"DREAMWEB.R21",0
6122	if	demo
6123	db	22,255,11,10
6124	else
6125	db	5,255,11,10
6126	endif
6127	db	255,255,255,0
6128	db	1,4,2,15,1,255,255,255,255,255,21
6129
6130	db	"DREAMWEB.R26",0
6131	db	9,255,0,40
6132	db	255,255,255,0
6133	db	0,0,255,255,255,255,255,255,255,255,26
6134
6135	db	"DREAMWEB.R19",0
6136	db	19,255,0,0
6137	db	255,255,255,0
6138	db	2,2,255,255,255,255,255,255,255,255,19
6139
6140	db	"DREAMWEB.R08",0		;leaving tvstudio into street
6141	db	8,255,11,40
6142	db	255,255,255,0
6143	db	0,4,255,255,255,255,255,255,255,255,8
6144
6145	db	"DREAMWEB.R01",0
6146	db	1,255,44,10
6147	db	255,255,255,0
6148	db	3,6,255,255,255,255,255,255,255,255,1
6149
6150
6151
6152	db	"DREAMWEB.R45",0	;Dream room
6153 	db	35,255,22,30
6154	db	255,255,255,0
6155	db	0,6,255,255,255,255,255,255,255,255,45
6156
6157	db	"DREAMWEB.R46",0	;Dream room
6158	db	35,255,22,40
6159	db	255,255,255,0
6160	db	0,4,255,255,255,255,255,255,255,255,46
6161
6162	db	"DREAMWEB.R47",0	;Dream room
6163	db	35,255,0,0
6164	db	255,255,255,0
6165	db	0,0,255,255,255,255,255,255,255,255,47
6166
6167	db	"DREAMWEB.R45",0	;Dream room
6168	db	35,255,22,30
6169	db	255,255,255,0
6170	db	4,0,255,255,255,255,255,255,255,255,45
6171
6172	db	"DREAMWEB.R46",0	;Dream room
6173	db	35,255,22,50
6174	db	255,255,255,0
6175	db	0,4,255,255,255,255,255,255,255,255,46
6176
6177
6178
6179	db	"DREAMWEB.R50",0 ; Intro sequence one
6180	db	35,255,22,30
6181	db	255,255,255,0
6182	db	0,0,255,255,255,255,255,255,255,255,50
6183
6184	db	"DREAMWEB.R51",0 ; Intro sequence two
6185	db	35,255,11,30
6186	db	255,255,255,0
6187	db	0,0,255,255,255,255,255,255,255,255,51
6188
6189	db	"DREAMWEB.R52",0 ; Intro sequence three
6190	db	35,255,22,30
6191	db	255,255,255,0
6192	db	0,0,255,255,255,255,255,255,255,255,52
6193
6194	db	"DREAMWEB.R53",0 ; Intro sequence four
6195	db	35,255,33,0
6196	db	255,255,255,0
6197	db	0,0,255,255,255,255,255,255,255,255,53
6198
6199	db	"DREAMWEB.R54",0 ; Intro sequence five - wasteland
6200	db	35,255,0,0
6201	db	255,255,255,0
6202	db	0,0,255,255,255,255,255,255,255,255,54
6203
6204	db	"DREAMWEB.R55",0 ; End sequence
6205	db	14,255,44,0
6206	db	255,255,255,0
6207	db	0,0,255,255,255,255,255,255,255,255,55
6208
6209
6210Madeuproomdat	db	32 dup (0)
6211
6212Roomscango	db	1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0
6213
6214Roompics	db	5,0,3,2,4,1,10,9,8,6,11,4,7,7,0
6215
6216Oplist	db	3 dup (0)
6217
6218Inputline	db	128 dup (0)
6219
6220linedata	dw	200 dup (0ffffh)
6221
6222presslist	db	6 dup (255)
6223
6224savenames	db	2,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
6225	db	2,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
6226	db	2,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
6227	db	2,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
6228	db	2,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
6229	db	2,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
6230	db	2,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
6231
6232
6233
6234savefiles	db	"DREAMWEB.D00",0
6235	db	"DREAMWEB.D01",0
6236	db	"DREAMWEB.D02",0
6237	db	"DREAMWEB.D03",0
6238	db	"DREAMWEB.D04",0
6239	db	"DREAMWEB.D05",0
6240	db	"DREAMWEB.D06",0
6241
6242Recname	db	"DREAMWEB.DEM",0
6243
6244Quitrequested	db 0
6245Subtitles		db 0
6246ForeignRelease	db 0
6247
6248
6249;-------------------------------------------------------End of code segment----
6250
6251DREAMWEBPROG	ends
6252
6253
6254
6255
6256;---------------------------------------------------------------Stack space----s
6257
6258STACKSPACE	segment para stack 'STACK'
6259
6260stak	db	256 dup (?)
6261
6262STACKSPACE	ends
6263
6264
6265
6266;-----------------------------------------------------------End of all code----
6267
6268	end	Dreamweb
6269