aboutsummaryrefslogtreecommitdiff
path: root/devtools/tasmrecover/dreamweb/keypad.asm
blob: 29542937c19575add3dd44e1ec6074e3b16cd400 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
;Copyright (c) 1990-2012 by Neil Dodwell
;Released with permission from Neil Dodwell under GPLv2
;See LICENSE file for full license text
Entercode	proc	near

	mov	keypadax,ax
	mov	keypadcx,cx
	call	getridofreels
	call	loadkeypad
	call	createpanel
	call	showicon
	call	showouterpad
	call	showkeypad
	call	readmouse
	call	showpointer
	call	worktoscreen
	call	delpointer
	mov	presspointer,0
	mov	getback,0

keypadloop:
	cmp quitrequested, 0
	jnz numberright

	call	delpointer
	call	readmouse
	call	showkeypad
	call	showpointer
	call	vsync
	cmp	presscount,0
	jz	nopresses
	dec	presscount
	jmp	afterpress
nopresses:	mov	pressed,255
	mov	graphicpress,255
	call	vsync

afterpress:	call	dumppointer
	call	dumpkeypad
	call	dumptextline
	mov	bx,offset cs:keypadlist
	call	checkcoords
	cmp	getback,1
	jz	numberright

	cmp	lightcount,1
	jnz	notendkey
	cmp	lockstatus,0
	jz	numberright
	jmp	keypadloop

notendkey:	cmp	presscount,40
	jnz	keypadloop
	call	addtopresslist
	cmp	pressed,11
	jnz	keypadloop
	mov	ax,keypadax
	mov	cx,keypadcx
	call	isitright
	jnz	incorrect
	mov	lockstatus,0
	mov	al,11
	call	playchannel1
	mov	lightcount,120
	mov	presspointer,0
	jmp	keypadloop
incorrect:	mov	al,11
	call	playchannel1
	mov	lightcount,120
	mov	presspointer,0
	jmp	keypadloop

numberright:	mov	manisoffscreen,0
	call	getridoftemp
	call	restorereels
	call	redrawmainscrn
	call	worktoscreenm
	ret

keypadlist:	dw	keypadx+9,keypadx+30,keypady+9,keypady+22,buttonone
	dw	keypadx+31,keypadx+52,keypady+9,keypady+22,buttontwo
	dw	keypadx+53,keypadx+74,keypady+9,keypady+22,buttonthree
	dw	keypadx+9,keypadx+30,keypady+23,keypady+40,buttonfour
	dw	keypadx+31,keypadx+52,keypady+23,keypady+40,buttonfive
	dw	keypadx+53,keypadx+74,keypady+23,keypady+40,buttonsix
	dw	keypadx+9,keypadx+30,keypady+41,keypady+58,buttonseven
	dw	keypadx+31,keypadx+52,keypady+41,keypady+58,buttoneight
	dw	keypadx+53,keypadx+74,keypady+41,keypady+58,buttonnine
	dw	keypadx+9,keypadx+30,keypady+59,keypady+73,buttonnought
	dw	keypadx+31,keypadx+74,keypady+59,keypady+73,buttonenter
	dw	keypadx+72,keypadx+86,keypady+80,keypady+94,quitkey
	dw	0,320,0,200,blank
	dw	0ffffh

	endp








Loadkeypad	proc	near
	
	mov	dx,offset cs:extragraphics1
	call	loadintotemp
	ret

	endp




Quitkey	proc	near

	cmp	commandtype,222
	jz	alreadyqk
	mov	commandtype,222
	mov	al,4
	call	commandonly
alreadyqk:	mov	ax,mousebutton
	cmp	ax,oldbutton
	jz	notqk
	and	ax,1
	jnz	doqk
notqk:	ret

doqk:	 mov	getback,1
	ret

	endp


















Addtopresslist	proc	near

	cmp	presspointer,5
	jz	nomorekeys
	mov	al,pressed
	cmp	al,10
	jnz	not10
	mov	al,0
not10:	mov	bx,presspointer
	mov	dx,seg presslist
	mov	es,dx
	add	bx,offset es:presslist
	mov	[es:bx],al
	inc	presspointer
nomorekeys:	ret

	endp




Buttonone	proc	near

	mov	cl,1
	call	buttonpress
	ret

	endp


Buttontwo	proc	near

	mov	cl,2
	call	buttonpress
	ret

	endp



Buttonthree	proc	near

	mov	cl,3
	call	buttonpress
	ret

	endp



Buttonfour	proc	near

	mov	cl,4
	call	buttonpress
	ret

	endp


Buttonfive	proc	near

	mov	cl,5
	call	buttonpress
	ret

	endp



Buttonsix	proc	near

	mov	cl,6
	call	buttonpress
	ret

	endp


Buttonseven	proc	near

	mov	cl,7
	call	buttonpress
	ret

	endp


Buttoneight	proc	near

	mov	cl,8
	call	buttonpress
	ret

	endp

Buttonnine	proc	near

	mov	cl,9
	call	buttonpress
	ret

	endp



Buttonnought	proc	near

	mov	cl,10
	call	buttonpress
	ret

	endp






Buttonenter	proc	near

	mov	cl,11
	call	buttonpress
	ret

	endp



Buttonpress	proc	near

	mov	ch,cl
	add	ch,100
	cmp	commandtype,ch
	jz	alreadyb
	mov	commandtype,ch
	mov	al,cl
	add	al,4
	push	cx
	call	commandonly
	pop	cx
alreadyb:	mov	ax,mousebutton
	cmp	ax,oldbutton
	jz	notb
	and	ax,1
	jnz	dob
notb:	ret

dob: 	mov	pressed,cl
	add	cl,21
	mov	graphicpress,cl
	mov	presscount,40
	cmp	cl,32
	jz	nonoise
	mov	al,10
	call	playchannel1
nonoise:	ret

	endp














Showouterpad	proc	near

	mov	di,keypadx-3
	mov	bx,keypady-4
	mov	ds,tempgraphics
	mov	al,1
	mov	ah,0
	call	showframe
	mov	di,keypadx+74
	mov	bx,keypady+76
	mov	ds,tempgraphics
	mov	al,37
	mov	ah,0
	call	showframe
	ret

	endp










Showkeypad	proc	near

	mov	al,22
	mov	di,keypadx+9
	mov	bx,keypady+5
	call	singlekey
	mov	al,23
	mov	di,keypadx+31
	mov	bx,keypady+5
	call	singlekey
	mov	al,24
	mov	di,keypadx+53
	mov	bx,keypady+5
	call	singlekey

	mov	al,25
	mov	di,keypadx+9
	mov	bx,keypady+23
	call	singlekey
	mov	al,26
	mov	di,keypadx+31
	mov	bx,keypady+23
	call	singlekey
	mov	al,27
	mov	di,keypadx+53
	mov	bx,keypady+23
	call	singlekey

	mov	al,28
	mov	di,keypadx+9
	mov	bx,keypady+41
	call	singlekey
	mov	al,29
	mov	di,keypadx+31
	mov	bx,keypady+41
	call	singlekey
	mov	al,30
	mov	di,keypadx+53
	mov	bx,keypady+41
	call	singlekey

	mov	al,31
	mov	di,keypadx+9
	mov	bx,keypady+59
	call	singlekey
	mov	al,32
	mov	di,keypadx+31
	mov	bx,keypady+59
	call	singlekey

	cmp	lightcount,0
	jz	notenter
	dec	lightcount
	mov	al,36
	mov	bx,keypady-1+63
	cmp	lockstatus,0
	jnz	changelight
	mov	al,41
	mov	bx,keypady+4+63
changelight:	cmp	lightcount,60
	jc	gotlight
	cmp	lightcount,100
	jnc	gotlight
	dec	al
gotlight:	mov	ds,tempgraphics
	mov	ah,0
	mov	di,keypadx+60
	call	showframe

notenter:	ret

	endp





Singlekey	proc	near

	cmp	graphicpress,al
	jnz	gotkey
	add	al,11
	cmp	presscount,8
	jnc	gotkey
	sub	al,11
;	cmp	presscount,10
;	jnc	gotkey
;	sub	al,11
gotkey:	mov	ds,tempgraphics
	sub	al,20
	mov	ah,0
	call	showframe
	ret

	endp









Dumpkeypad	proc	near

	mov	di,keypadx-3
	mov	bx,keypady-4
	mov	cl,120
	mov	ch,90
	call	multidump
	ret

	endp





;---------------------------------




Usemenu	proc	near

	call	getridofreels
	call	loadmenu
	call	createpanel
	call	showpanel
	call	showicon
	mov	newobs,0
	call	drawfloor
	call	printsprites

	mov	al,4
	mov	ah,0
	mov	di,menux-48
	mov	bx,menuy-4
	mov	ds,tempgraphics2
	call	showframe
	call	getundermenu
	mov	al,5
	mov	ah,0
	mov	di,menux+54
	mov	bx,menuy+72
	mov	ds,tempgraphics2
	call	showframe


	call	worktoscreenm
	mov	getback,0

menuloop:	call	delpointer
	call	putundermenu
	call	showmenu
	call	readmouse
	call	showpointer
	call	vsync
	call	dumppointer
	call	dumpmenu
	call	dumptextline
	mov	bx,offset cs:menulist
	call	checkcoords
	cmp	getback,1
	jnz	menuloop

	mov	manisoffscreen,0
	call	redrawmainscrn
	call	getridoftemp
	call	getridoftemp2
	call	restorereels
	call	worktoscreenm
	ret

menulist:	dw	menux+54,menux+68,menuy+72,menuy+88,quitkey
	dw	0,320,0,200,blank
	dw	0ffffh

	ret

	endp







Dumpmenu	proc	near

	mov	di,menux
	mov	bx,menuy
	mov	cl,48
	mov	ch,48
	call	multidump
	ret

	endp






Getundermenu	proc	near

	mov	di,menux
	mov	bx,menuy
	mov	cl,48
	mov	ch,48
	mov	ds,buffers
	mov	si,undertimedtext
	call	multiget
	ret

	endp








Putundermenu	proc	near

	mov	di,menux
	mov	bx,menuy
	mov	cl,48
	mov	ch,48
	mov	ds,buffers
	mov	si,undertimedtext
	call	multiput
	ret

	endp



Showoutermenu	proc	near

	mov	al,40
	mov	ah,0
	mov	di,menux-34
	mov	bx,menuy-40
	mov	ds,tempgraphics
	call	showframe
	mov	al,41
	mov	ah,0
	mov	di,menux+64-34
	mov	bx,menuy-40
	mov	ds,tempgraphics
	call	showframe
	mov	al,42
	mov	ah,0
	mov	di,menux-26
	mov	bx,menuy+57-40
	mov	ds,tempgraphics
	call	showframe
	mov	al,43
	mov	ah,0
	mov	di,menux+64-26
	mov	bx,menuy+57-40
	mov	ds,tempgraphics
	call	showframe
	ret

	endp








Showmenu	proc	near

	inc	menucount
	cmp	menucount,37*2
	jnz	menuframeok
	mov	menucount,0
menuframeok:	mov	al,menucount
	shr	al,1
	mov	ah,0
	mov	di,menux
	mov	bx,menuy
	mov	ds,tempgraphics
	call	showframe
	ret

	endp



Loadmenu	proc	near

	mov	dx,offset cs:spritename3
	call	loadintotemp
	mov	dx,offset cs:mongraphics2
	call	loadintotemp2
	ret

	endp
















Viewfolder	proc	near

	mov	manisoffscreen,1
	call	getridofall
	call	loadfolder
	mov	folderpage,0
	call	showfolder
	call	worktoscreenm
	mov	getback,0

folderloop:	call	delpointer
	call	readmouse
	call	showpointer
	call	vsync
	call	dumppointer
	call	dumptextline
	mov	bx,offset cs:folderlist
	call	checkcoords
	cmp	getback,0
	jz	folderloop

	mov	manisoffscreen,0
	call	getridoftemp
	call	getridoftemp2
	call	getridoftemp3
	call	getridoftempcharset
	call	restoreall
	call	redrawmainscrn
	call	worktoscreenm
	ret

folderlist:	dw	280,320,160,200,quitkey
	dw	143,300,6,194,nextfolder
	dw	0,143,6,194,lastfolder
	dw	0,320,0,200,blank
	dw	0ffffh

	endp




Nextfolder	proc	near

	cmp	folderpage,12
	jnz	cannextf
	call	blank
	ret
cannextf:	cmp	commandtype,201
	jz	alreadynextf
	mov	commandtype,201
	mov	al,16
	call	commandonly
alreadynextf:	mov	ax,mousebutton
	cmp	ax,oldbutton
	jz	notnextf
	cmp	ax,1
	jz	donextf
notnextf:	ret
donextf:	inc	folderpage
	call	folderhints
	call	delpointer
	call	showfolder
	mov	mousebutton,0
	mov	bx,offset cs:folderlist
	call	checkcoords
	call	worktoscreenm
	ret

	endp




Folderhints	proc	near

	cmp	folderpage,5
	jnz	notaideadd
	cmp	aidedead,1
	jz	notaideadd
	mov	al,13
	call	getlocation
	cmp	al,1
	jz	notaideadd
	mov	al,13
	call	setlocation
	call	showfolder
	mov	al,30
	call	findtext1
	mov	di,0
	mov	bx,86
	mov	dl,141
	mov	ah,16
	call	printdirect
	call	worktoscreenm
	mov	cx,200
	call	hangonp
	ret

notaideadd:	cmp	folderpage,9
	jnz	notaristoadd
	mov	al,7
	call	getlocation
	cmp	al,1
	jz	notaristoadd
	mov	al,7
	call	setlocation
	call	showfolder
	mov	al,31
	call	findtext1
	mov	di,0
	mov	bx,86
	mov	dl,141
	mov	ah,16
	call	printdirect
	call	worktoscreenm
	mov	cx,200
	call	hangonp
notaristoadd:	ret

	endp



Lastfolder	proc	near
	
	cmp	folderpage,0
	jnz	canlastf
	call	blank
	ret
canlastf:	cmp	commandtype,202
	jz	alreadylastf
	mov	commandtype,202
	mov	al,17
	call	commandonly
alreadylastf:	cmp	folderpage,0
	jz	notlastf
	mov	ax,mousebutton
	cmp	ax,oldbutton
	jz	notlastf
	cmp	ax,1
	jz	dolastf
notlastf:	ret
dolastf:	dec	folderpage
	call	delpointer
	call	showfolder
	mov	mousebutton,0
	mov	bx,offset cs:folderlist
	call	checkcoords
	call	worktoscreenm
	ret

	endp



Loadfolder	proc	near

	mov	dx,offset cs:foldergraphic1
	call	loadintotemp
	mov	dx,offset cs:foldergraphic2
	call	loadintotemp2
	mov	dx,offset cs:foldergraphic3
	call	loadintotemp3
	mov	dx,offset cs:characterset3
	call	loadtempcharset
	mov	dx,offset cs:foldertext
	call	loadtemptext
	ret

	endp




Showfolder	proc	near

	mov	commandtype,255
	cmp	folderpage,0
	jz	closedfolder
	call	usetempcharset
	call	createpanel2
	mov	ds,tempgraphics
	mov	di,0
	mov	bx,0
	mov	al,0
	mov	ah,0
	call	showframe
	mov	ds,tempgraphics
	mov	di,143
	mov	bx,0
	mov	al,1
	mov	ah,0
	call	showframe
	mov	ds,tempgraphics
	mov	di,0
	mov	bx,92
	mov	al,2
	mov	ah,0
	call	showframe
	mov	ds,tempgraphics
	mov	di,143
	mov	bx,92
	mov	al,3
	mov	ah,0
	call	showframe
	call	folderexit
	
	cmp	folderpage,1
	jz	noleftpage
	call	showleftpage
noleftpage:	cmp	folderpage,12
	jz	norightpage
	call	showrightpage
norightpage:	call	usecharset1
	call	undertextline
	ret

closedfolder:	call	createpanel2
	mov	ds,tempgraphics3
	mov	di,143-28
	mov	bx,0
	mov	al,0
	mov	ah,0
	call	showframe
	mov	ds,tempgraphics3
	mov	di,143-28
	mov	bx,92
	mov	al,1
	mov	ah,0
	call	showframe
	call	folderexit
	call	undertextline
	ret

	endp








Folderexit	proc	near

	mov	ds,tempgraphics2
	mov	di,296
	mov	bx,178
	mov	al,6
	mov	ah,0
	call	showframe
	ret

	endp





Showleftpage	proc	near

	mov	ds,tempgraphics2
	mov	di,0
	mov	bx,12
	mov	al,3
	mov	ah,0
	call	showframe

	mov	bx,12+5
	mov	cx,9
leftpageloop:	push	cx bx	
	mov	ds,tempgraphics2
	mov	di,0
	mov	al,4
	mov	ah,0
	call	showframe
	pop	bx cx
	add	bx,16
	loop	leftpageloop

	mov	ds,tempgraphics2
	mov	di,0
	mov	al,5
	mov	ah,0
	call	showframe

	mov	linespacing,8
	mov	charshift,91
	mov	kerning,1
	mov	bl,folderpage
	dec	bl
	dec	bl
	add	bl,bl
	mov	bh,0
	add	bx,bx
	mov	es,textfile1
	mov	si,[es:bx]
	add	si,66*2
	mov	di,2
	mov	bx,48
	mov	dl,140
	mov	cx,2
twolotsleft:	push	cx
contleftpage:	call	printdirect
	add	bx,linespacing
	cmp	al,0
	jnz	contleftpage
	pop	cx
	loop	twolotsleft

	mov	kerning,0
	mov	charshift,0
	mov	linespacing,10

	mov	es,workspace
	mov	ds,workspace
	mov	di,(48*320)+2
	mov	si,(48*320)+2+130
	mov	cx,120
flipfolder:	push	cx di si
	mov	cx,65
flipfolderline:	mov	al,[es:di]
	mov	ah,[es:si]
	mov	[es:di],ah
	mov	[es:si],al
	dec	si
	inc	di
	loop	flipfolderline
	pop	si di cx
	add	si,320
	add	di,320
	loop	flipfolder
	ret
	
	endp



Showrightpage	proc	near

	mov	ds,tempgraphics2
	mov	di,143
	mov	bx,12
	mov	al,0
	mov	ah,0
	call	showframe

	mov	bx,12+37
	mov	cx,7
rightpageloop:	push	cx bx	
	mov	ds,tempgraphics2
	mov	di,143
	mov	al,1
	mov	ah,0
	call	showframe
	pop	bx cx
	add	bx,16
	loop	rightpageloop

	mov	ds,tempgraphics2
	mov	di,143
	mov	al,2
	mov	ah,0
	call	showframe

	mov	linespacing,8
	mov	kerning,1
	mov	bl,folderpage
	dec	bl
	add	bl,bl
	mov	bh,0
	add	bx,bx
	mov	es,textfile1
	mov	si,[es:bx]
	add	si,66*2
	mov	di,152
	mov	bx,48
	mov	dl,140
	mov	cx,2
twolotsright:	push	cx
contrightpage:	call	printdirect
	add	bx,linespacing
	cmp	al,0
	jnz	contrightpage
	pop	cx
	loop	twolotsright

	mov	kerning,0
	mov	linespacing,10
	ret

	endp









Entersymbol	proc	near

	mov	manisoffscreen,1
	call	getridofreels
	mov	dx,offset cs:symbolgraphic
	call	loadintotemp
	mov	symboltopx,24
	mov	symboltopdir,0
	mov	symbolbotx,24
	mov	symbolbotdir,0
	call	redrawmainscrn
	call	showsymbol
	call	undertextline
	call	worktoscreenm
	mov	getback,0

symbolloop:	call	delpointer
	call	updatesymboltop
	call	updatesymbolbot
	call	showsymbol
	call	readmouse
	call	showpointer
	call	vsync
	call	dumppointer
	call	dumptextline
	call	dumpsymbol
	mov	bx,offset cs:symbollist
	call	checkcoords
	cmp	getback,0
	jz	symbolloop

	cmp	symbolbotnum,3
	jnz	symbolwrong
	cmp	symboltopnum,5
	jnz	symbolwrong
	mov	al,43
	call	removesetobject
	mov	al,46
	call	placesetobject
	mov	ah,roomnum
	add	ah,12
	mov	al,0
	call	turnanypathon
	mov	manisoffscreen,0
	call	redrawmainscrn
	call	getridoftemp
	call	restorereels
	call	worktoscreenm
	mov	al,13
	call	playchannel1
	ret

symbolwrong:	mov	al,46
	call	removesetobject
	mov	al,43
	call	placesetobject
	mov	ah,roomnum
	add	ah,12
	mov	al,0
	call	turnanypathoff
	mov	manisoffscreen,0
	call	redrawmainscrn
	call	getridoftemp
	call	restorereels
	call	worktoscreenm
	ret

symbollist:	dw	symbolx+40,symbolx+64,symboly+2,symboly+16,quitsymbol
	dw	symbolx,symbolx+52,symboly+20,symboly+50,settopleft
	dw	symbolx+52,symbolx+104,symboly+20,symboly+50,settopright
	dw	symbolx,symbolx+52,symboly+50,symboly+80,setbotleft
	dw	symbolx+52,symbolx+104,symboly+50,symboly+80,setbotright
	dw	0,320,0,200,blank
	dw	0ffffh

	endp
















Quitsymbol	proc	near

	cmp	symboltopx,24
	jnz	blank
	cmp	symbolbotx,24
	jnz	blank
	cmp	commandtype,222
	jz	alreadyqs
	mov	commandtype,222
	mov	al,18
	call	commandonly
alreadyqs:	mov	ax,mousebutton
	cmp	ax,oldbutton
	jz	notqs
	and	ax,1
	jnz	doqs
notqs:	ret

doqs:	 mov	getback,1
	ret

	endp




Settopleft	proc	near

	cmp	symboltopdir,0
	jnz	blank
	cmp	commandtype,210
	jz	alreadytopl
	mov	commandtype,210
	mov	al,19
	call	commandonly
alreadytopl:	cmp	mousebutton,0
	jz	notopleft
	mov	symboltopdir,-1
notopleft:	ret

	endp



Settopright	proc	near

	cmp	symboltopdir,0
	jnz	blank
	cmp	commandtype,211
	jz	alreadytopr
	mov	commandtype,211
	mov	al,20
	call	commandonly
alreadytopr:	cmp	mousebutton,0
	jz	notopright
	mov	symboltopdir,1
notopright:	ret

	endp




Setbotleft	proc	near

	cmp	symbolbotdir,0
	jnz	blank
	cmp	commandtype,212
	jz	alreadybotl
	mov	commandtype,212
	mov	al,21
	call	commandonly
alreadybotl:	cmp	mousebutton,0
	jz	nobotleft
	mov	symbolbotdir,-1
nobotleft:	ret

	endp



Setbotright	proc	near

	cmp	symbolbotdir,0
	jnz	blank
	cmp	commandtype,213
	jz	alreadybotr
	mov	commandtype,213
	mov	al,22
	call	commandonly
alreadybotr:	cmp	mousebutton,0
	jz	nobotright
	mov	symbolbotdir,1
nobotright:	ret

	endp







Dumpsymbol	proc	near

	mov	newtextline,0
	mov	di,symbolx
	mov	bx,symboly+20
	mov	cl,104
	mov	ch,60
	call	multidump
	ret

	endp




Showsymbol	proc	near

	mov	al,12
	mov	ah,0
	mov	di,symbolx
	mov	bx,symboly
	mov	ds,tempgraphics
	call	showframe

	mov	al,symboltopx
	mov	ah,0
	mov	di,ax
	add	di,symbolx-44
	mov	al,symboltopnum
	mov	bx,symboly+20
	mov	ds,tempgraphics
	mov	ah,32
	push	ax di bx ds
	call	showframe
	pop	ds bx di ax
	call	nextsymbol
	add	di,49
	push	ax di bx ds
	call	showframe
	pop	ds bx di ax
	call	nextsymbol
	add	di,49
	call	showframe

	mov	al,symbolbotx
	mov	ah,0
	mov	di,ax
	add	di,symbolx-44
	mov	al,symbolbotnum
	add	al,6
	mov	bx,symboly+49
	mov	ds,tempgraphics
	mov	ah,32
	push	ax di bx ds
	call	showframe
	pop	ds bx di ax
	call	nextsymbol
	add	di,49
	push	ax di bx ds
	call	showframe
	pop	ds bx di ax
	call	nextsymbol
	add	di,49
	call	showframe
	ret

	endp






Nextsymbol	proc	near

	inc	al
	cmp	al,6
	jz	topwrap
	cmp	al,12
	jz	botwrap
	ret
topwrap:	mov	al,0
	ret
botwrap:	mov	al,6
	ret
	
	endp



Updatesymboltop	proc	near

	cmp	symboltopdir,0
	jz	topfinished
	cmp	symboltopdir,-1
	jz	backwards

	inc	symboltopx
	cmp	symboltopx,49
	jnz	notwrapfor
	mov	symboltopx,0
	dec	symboltopnum
	cmp	symboltopnum,-1
	jnz	topfinished
	mov	symboltopnum,5
	ret
notwrapfor:	cmp	symboltopx,24
	jnz	topfinished
	mov	symboltopdir,0
	ret

backwards:	dec	symboltopx
	cmp	symboltopx,-1
	jnz	notwrapback
	mov	symboltopx,48
	inc	symboltopnum
	cmp	symboltopnum,6
	jnz	topfinished
	mov	symboltopnum,0
	ret
notwrapback:	cmp	symboltopx,24
	jnz	topfinished
	mov	symboltopdir,0
topfinished:	ret

	endp



Updatesymbolbot	proc	near

	cmp	symbolbotdir,0
	jz	botfinished
	cmp	symbolbotdir,-1
	jz	backwardsbot

	inc	symbolbotx
	cmp	symbolbotx,49
	jnz	notwrapforb
	mov	symbolbotx,0
	dec	symbolbotnum
	cmp	symbolbotnum,-1
	jnz	botfinished
	mov	symbolbotnum,5
	ret
notwrapforb:	cmp	symbolbotx,24
	jnz	botfinished
	mov	symbolbotdir,0
	ret

backwardsbot:	dec	symbolbotx
	cmp	symbolbotx,-1
	jnz	notwrapbackb
	mov	symbolbotx,48
	inc	symbolbotnum
	cmp	symbolbotnum,6
	jnz	botfinished
	mov	symbolbotnum,0
	ret
notwrapbackb:	cmp	symbolbotx,24
	jnz	botfinished
	mov	symbolbotdir,0
botfinished:	ret

	endp










Dumpsymbox	proc	near

	cmp	dumpx,-1
	jz	nodumpsym
	mov	di,dumpx
	mov	bx,dumpy
	mov	cl,30
	mov	ch,77;30
	call	multidump
	mov	dumpx,-1
nodumpsym:	ret

	endp







Usediary	proc	near

	call	getridofreels
	mov	dx,offset cs:diarygraphic
	call	loadintotemp
	mov	dx,offset cs:diarytext
	call	loadtemptext

	mov	dx,offset cs:characterset3
	call	loadtempcharset
	call	createpanel
	call	showicon
	call	showdiary
	call	undertextline
	call	showdiarypage
	call	readmouse
	call	showpointer
	call	worktoscreen
	call	delpointer
	mov	getback,0

diaryloop:	call	delpointer
	call	readmouse
	call	showdiarykeys
	call	showpointer
	call	vsync
	call	dumppointer
	call	dumpdiarykeys
	call	dumptextline
	mov	bx,offset cs:diarylist
	call	checkcoords
	cmp	getback,0
	jz	diaryloop

	call	getridoftemp
	call	getridoftemptext
	call	getridoftempcharset
	call	restorereels
	mov	manisoffscreen,0
	call	redrawmainscrn
	call	worktoscreenm
	ret

diarylist:	dw	diaryx+94,diaryx+110,diaryy+97,diaryy+113,diarykeyn
	dw	diaryx+151,diaryx+167,diaryy+71,diaryy+87,diarykeyp
	dw	diaryx+176,diaryx+192,diaryy+108,diaryy+124,quitkey
	dw	0,320,0,200,blank
	dw	0ffffh

	ret

	endp







Showdiary	proc	near

	mov	al,1
	mov	ah,0
	mov	di,diaryx
	mov	bx,diaryy+37
	mov	ds,tempgraphics
	call	showframe
	mov	al,2
	mov	ah,0
	mov	di,diaryx+176
	mov	bx,diaryy+108
	mov	ds,tempgraphics
	call	showframe
	ret

	endp




Showdiarykeys	proc	near

	cmp	presscount,0
	jz	nokeyatall
	dec	presscount
	cmp	presscount,0
	jz	nokeyatall
	cmp	pressed,"N"
	jnz	nokeyn
	mov	al,3
	cmp	presscount,1
	jz	gotkeyn
	mov	al,4
gotkeyn:	mov	ah,0
	mov	di,diaryx+94
	mov	bx,diaryy+97
	mov	ds,tempgraphics
	call	showframe
	cmp	presscount,1
	jnz	notshown
	call	showdiarypage	
notshown:	ret

nokeyn:	mov	al,5
	cmp	presscount,1
	jz	gotkeyp
	mov	al,6
gotkeyp:	mov	ah,0
	mov	di,diaryx+151
	mov	bx,diaryy+71
	mov	ds,tempgraphics
	call	showframe
	cmp	presscount,1
	jnz	notshowp
	call	showdiarypage
notshowp:	ret

nokeyatall:	ret

	endp






Dumpdiarykeys	proc	near

	cmp	presscount,1
	jnz	notdumpdiary
	cmp	sartaindead,1
	jz	notsartadd
	cmp	diarypage,5
	jnz	notsartadd
	cmp	diarypage,5
	jnz	notsartadd
	mov	al,6
	call	getlocation
	cmp	al,1
	jz	notsartadd
	mov	al,6
	call	setlocation
	
	call	delpointer
	mov	al,12
	call	findtext1
	mov	di,70  ;diaryx+48
	mov	bx,106 ;diaryy+16
	mov	dl,241
	mov	ah,16
	call	printdirect

	call	worktoscreenm
	mov	cx,200
	call	hangonp
	call	createpanel
	call	showicon
	call	showdiary
	call	showdiarypage
	call	worktoscreenm
	call	showpointer
	ret
		             
notsartadd:	mov	di,diaryx+48
	mov	bx,diaryy+15
	mov	cl,200
	mov	ch,16
	call	multidump
notdumpdiary:	mov	di,diaryx+94
	mov	bx,diaryy+97
	mov	cl,16
	mov	ch,16
	call	multidump
	mov	di,diaryx+151
	mov	bx,diaryy+71
	mov	cl,16
	mov	ch,16
	call	multidump
	ret

	endp



Diarykeyp	proc	near

	cmp	commandtype,214
	jz	alreadykeyp
	mov	commandtype,214
	mov	al,23
	call	commandonly
alreadykeyp:	cmp	mousebutton,0
	jz	notkeyp
	mov	ax,oldbutton
	cmp	ax,mousebutton
	jz	notkeyp
	cmp	presscount,0
	jnz	notkeyp
	mov	al,16
	call	playchannel1
	mov	presscount,12
	mov	pressed,"P"
	dec	diarypage
	cmp	diarypage,-1
	jnz	notkeyp
	mov	diarypage,11
notkeyp:	ret

	endp



Diarykeyn	proc	near

	cmp	commandtype,213
	jz	alreadykeyn
	mov	commandtype,213
	mov	al,23
	call	commandonly
alreadykeyn:	cmp	mousebutton,0
	jz	notkeyn
	mov	ax,oldbutton
	cmp	ax,mousebutton
	jz	notkeyn
	cmp	presscount,0
	jnz	notkeyn
	mov	al,16
	call	playchannel1
	mov	presscount,12
	mov	pressed,"N"
	inc	diarypage
	cmp	diarypage,12
	jnz	notkeyn
	mov	diarypage,0
notkeyn:	ret

	endp






Showdiarypage	proc	near

	mov	al,0
	mov	ah,0
	mov	di,diaryx
	mov	bx,diaryy
	mov	ds,tempgraphics
	call	showframe

	mov	al,diarypage
	call	findtext1

	mov	kerning,1
	call	usetempcharset
	mov	di,diaryx+48
	mov	bx,diaryy+16
	mov	dl,240
	mov	ah,16
	mov	charshift,91+91
	call	printdirect

	mov	di,diaryx+129
	mov	bx,diaryy+16
	mov	dl,240
	mov	ah,16
	call	printdirect

	mov	di,diaryx+48
	mov	bx,diaryy+23
	mov	dl,240
	mov	ah,16
	call	printdirect

	mov	kerning,0
	mov	charshift,0
	call	usecharset1
	ret

	endp





Findtext1	proc	near

	mov	ah,0
	mov	si,ax
	add	si,si
	mov	es,textfile1
	mov	ax,[es:si]
	add	ax,textstart
	mov	si,ax
	ret

	endp