-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathdcsblibs.asm
2244 lines (2185 loc) · 41.7 KB
/
dcsblibs.asm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
;-----------------------------------------------------------
; Filename: dcsblibs.asm
; Long name: DCSB hybrid libraries for TI-BASIC programs
; Author: Kerm Martian aka Christopher Mitchell
; Last Update: Unknown
;
; Tab functions, mouse hook for GUI, InfoPop and MemoryPop-related
; code, and similar.
;
;Please consult license.txt for the fair use agreement
;implicitly binding by you continuing to read past this
;point. Close and delete this file if you do not agree
;to the terms of the agreement.
;-----------------------------------------------------------
; Doors CS BASIC Libraries
;================================
;dbfStringWidth: COMPLETE
;dbfPxScan: COMPLETE
;dbfHometoGraph: COMPLETE
;dbfUsedPicList: COMPLETE
;dbfArcUnarcPic: COMPLETE
;dbfDCSLibVersion: COMPLETE
;dbfSimpleGUIMouse: COMPLETE
;dbfPushGUIStack: COMPLETE
;dbfPopGUIStack: COMPLETE
;dbfOpenGUIStack: COMPLETE
;dbfCloseGUIStack: COMPLETE
;dbfRenderGUIStack: COMPLETE
;dbfGUIMouse: COMPLETE
;dbfMenu: COMPLETE
;dbfCn2BASICSend: INCOMPLETE
;dbfCn2BASICGet: INCOMPLETE
;dbfCn2BASICStop: Mostly Complete
;================================
#define bjump(xxxx) call 50h \ .dw xxxx
dbfStringWidth:
ld hl,sc1
call getsourcestring
ld de,0
jp z,dbfStringWidth_Finish ;zero-length string
dbfStringWidthLoopOuter:
push hl
push bc
push de
bcall(_Get_Tok_Strng)
ld hl,Op3
pop de
dbfStringWidthLoopInner:
push hl
push bc
ld a,(hl)
push de
bcall(_GetVarWidth)
ld l,d
ld h,0
pop de
add hl,de
ex de,hl
pop bc
pop hl
inc hl
dec bc
ld a,b
or c
jr nz,dbfStringWidthLoopInner
pop bc
pop hl
ld a,(hl)
inc hl
dec bc
bcall(_IsA2ByteTok)
jr nz,dbfStringWidthLoopOuter2
inc hl
dec bc
dbfStringWidthLoopOuter2:
ld a,b
or c
jr nz,dbfStringWidthLoopOuter
dbfStringWidth_Finish:
ex de,hl
bcall(_setxxxxop2)
bcall(_op2toop1)
ret
;================================
dbfPxScan:
ld a,(var2)
ld e,a
ld a,(var1)
ld d,a
push de
call immGetPixel
pop de
ld c,a
ld a,(var3)
dec a
jr z,dbfPxScanUp
dec a
jr z,dbfPxScanDown
dec a
jr z,dbfPxScanLeft
dbfPxScanRight:
ld a,96
sub d
ld b,a
ld a,(hl)
and c
ld d,a
;-------------------------------
; b: number of iterations
; d: pixel to xor with
; hl: address
; c: current mask
dbfPxScanRightLoop:
ld a,b
or a
jr z,dbfPxScanRightEnd
dec b
rrc d
rrc c
jr nc,dbfPxScanRightNoInc
inc hl
dbfPxScanRightNoInc:
ld a,(hl)
and c
xor d
jr z,dbfPxScanRightLoop
dbfPxScanRightEnd:
ld a,96
sub b
dbfPxScanRightEndSet:
bit 7,a
jr nz,dbfPxScanRightEndSetNeg
bcall(_SetXXOp1)
ret
dbfPxScanRightEndSetNeg:
neg
bcall(_SetXXOp1)
bcall(_InvOp1S)
ret
dbfPxScanLeft:
ld b,d
inc b
ld a,(hl)
and c
ld d,a
;-------------------------------
; b: number of iterations
; d: pixel to xor with
; hl: address
; c: current mask
dbfPxScanLeftLoop:
ld a,b
or a
jr z,dbfPxScanLeftEnd
dec b
rlc d
rlc c
jr nc,dbfPxScanLeftNoInc
dec hl
dbfPxScanLeftNoInc:
ld a,(hl)
and c
xor d
jr z,dbfPxScanLeftLoop
dbfPxScanLeftEnd:
dec b
ld a,b
jr dbfPxScanRightEndSet
dbfPxScanDown:
ld a,64
sub e
ld b,a
ld a,(hl)
and c
ld d,a
;-------------------------------
; b: number of iterations
; d: pixel to xor with
; hl: address
; c: current mask
dbfPxScanDownLoop:
ld a,b
or a
jr z,dbfPxScanDownEnd
dec b
push de
ld de,12
add hl,de
pop de
ld a,(hl)
and c
xor d
jr z,dbfPxScanDownLoop
dbfPxScanDownEnd:
ld a,64
sub b
jr dbfPxScanRightEndSet
dbfPxScanUp:
ld b,e
inc b
ld a,(hl)
and c
ld d,a
;-------------------------------
; b: number of iterations
; d: pixel to xor with
; hl: address
; c: current mask
dbfPxScanUpLoop:
ld a,b
or a
jr z,dbfPxScanUpEnd
dec b
push de
ld de,-12
add hl,de
pop de
ld a,(hl)
and c
xor d
jr z,dbfPxScanUpLoop
dbfPxScanUpEnd:
dec b
ld a,b
jr dbfPxScanRightEndSet
;================================
dbfHometoGraph:
ld hl,textShadow
ld a,(iy+FontFlags)
push af
ld a,(iy+sGrFlags)
push af
set textWrite,(iy+sGrFlags)
set fracDrawLFont,(iy+fontFlags)
set fullScrnDraw,(iy+apiflg4)
set 4,(iy+24h)
ld b,8
xor a
bit grfSplit,(iy+SGrFlags)
jr z,dbfHometoGraphBegin
ld b,4
ld hl,textShadow+4*16
ld a,32
dbfHometoGraphBegin:
ld (penrow),a
dbfHometoGraphOuter:
xor a
ld (pencol),a
ld c,16
dbfHometoGraphInner:
ld a,(hl) ;vputsmap destroys neither HL nor BC
bcall(_VPutMap)
inc hl
dec c
jr nz,dbfHometoGraphInner
push hl
ld hl,penrow
ld a,8
add a,(hl)
ld (hl),a
pop hl
djnz dbfHometoGraphOuter
ld a,(var1)
or a
call nz,fastcopy
pop af
ld (iy+sGrFlags),a
pop af
ld (iy+FontFlags),a
jp xLIBEndNoOut
;================================
dbfUsedPicList:
ld bc,0
ld de,-9
ld hl,SymTable
dbfUsedPicList_Enumerate:
push de
ld de,(progptr)
bcall(_mos_cphlde)
pop de
jr z,dbfUsedPicList_Store
ld a,(hl)
and $1f
cp 7 ;pic obj
jr nz,dbfUsedPicList_EnumNotPic
inc bc
dbfUsedPicList_EnumNotPic:
add hl,de
jr dbfUsedPicList_Enumerate
dbfUsedPicList_Store:
push bc
push bc
pop hl
ld a,h
or l
jr z,dbfUsedPicList_Empty
bcall(_CreateTRList) ;create an hl-element list
inc de
inc de
pop bc
ld hl,SymTable
dbfUsedPicList_StoreLoop:
ld a,b
or c
jr z,dbfUsedPicList_Finish
push de
ld de,(progptr)
bcall(_mos_cphlde)
pop de
jr z,dbfUsedPicList_Finish
ld a,(hl)
push de
ld de,-9
add hl,de
pop de
and $1f
cp 7 ;pic obj
jr nz,dbfUsedPicList_StoreLoop
push hl
push bc
push de
inc hl
inc hl
ld a,(hl)
inc hl
inc hl
ld b,(hl)
push bc
inc a
ld l,a
ld h,0
bcall(_SetXXXXOp2)
pop af
or a
jr z,dbfUsedPicList_StoreLoopNoNegate
bcall(_InvOP2S)
dbfUsedPicList_StoreLoopNoNegate:
ld hl,Op2
pop de
ld bc,9
ldir
pop bc
pop hl
dec bc
jr dbfUsedPicList_StoreLoop
dbfUsedPicList_Empty:
inc hl
bcall(_CreateTRList) ;create an hl-element list
inc de
inc de
pop bc
push de
bcall(_Op1Set0)
ld hl,Op1
pop de
ld bc,9
ldir
dbfUsedPicList_Finish:
bcall(_Op4ToOp1)
ret
;================================
dbfArcUnarcPic:
ld hl,Op1
ld (hl),7 ;tPictObj
inc hl
ld (hl),60h ;tVarPict
inc hl
ld a,(var1)
dec a
ld (hl),a
inc hl
ld (hl),0
bcall(_FindSym)
jr c,dbfArcUnarcPic_End
push bc
ld a,b
or a
jr z,dbfArcUnarcPicRAM
ld b,1
dbfArcUnarcPicRAM
ld a,(var2)
cp b
pop bc
jr z,dbfArcUnarcPic_End
bcall(_Arc_Unarc)
dbfArcUnarcPic_End:
jp xLIBEndNoOut
;================================
dbfDCSLibVersion:
ld a,5
bcall(_setxxop1)
ret
;================================
dbfMouseCoordSet:
ld a,(var1) ;X
bit 7,a
jr z,dbfSimpleGUIMouse_Chk1
xor a
dbfSimpleGUIMouse_Chk1:
cp 96
jr c,dbfSimpleGUIMouse_Chk2
ld a,95
dbfSimpleGUIMouse_Chk2:
ld h,a
ld a,(var2) ;Y
bit 7,a
jr z,dbfSimpleGUIMouse_Chk3
xor a
dbfSimpleGUIMouse_Chk3:
cp 64
jr c,dbfSimpleGUIMouse_Chk4
ld a,63
dbfSimpleGUIMouse_Chk4:
ld l,a
ld (MseY),hl
ret
;================================
dbfSimpleGUIMouse:
call dbfMouseCoordSet
bcall(_OpenGUIStack)
push bc
ld hl,SimpleGUIMouseData
bcall(_PushGUIStacks)
ld hl,(stack)
push hl
ld hl,$0000
bcall(_GUIMouse)
dbfSimpleGUIMouse_Process:
pop hl
ld (stack),hl
ld hl,3
bcall(_CreateTRList)
ex de,hl
inc hl
inc hl
ld a,(MseX)
call AtoRealAtHL
ld a,(MseY)
call AtoRealAtHL
ld a,(lastclick)
call AtoRealAtHL
ld b,2
bcall(_PopGUIStacks)
pop bc
ld a,c
or a
jr nz,dbfSimpleGUIMouse_Finish
bcall(_CloseGUIStack)
dbfSimpleGUIMouse_Finish:
bcall(_Op4ToOp1)
ret
;================================
dbfPushGUIStack:
ld hl,xLIBEndNoOut
push hl
ld a,(var1) ;get type int
cp 23d
ret z
cp 25d
ret nc ;24 is the highest allowed
ld h,0
ld l,a
add hl,hl
ld de,dbfPushGUIStack_EntryTable
add hl,de
push af ;save type
ld a,(hl)
inc hl
ld h,(hl)
ld l,a
pop af
jp (hl)
dbfPushGUIStack_EntryTable:
.dw dbfPGS_GUIRNull
.dw dbfPGS_GUIRLargeWin
.dw dbfPGS_GUIRSmallWin
.dw dbfPGS_GUIRFullScreenImg
.dw dbfPGS_GUIRText
.dw dbfPGS_GUIRWinButtons
.dw dbfPGS_GUIRWrappedText
.dw dbfPGS_GUIRButtonText
.dw dbfPGS_GUIRButtonImg
.dw dbfPGS_GUIRTextLineIn
.dw dbfPGS_GUIRRadio
.dw dbfPGS_GUIRCheckBox
.dw dbfPGS_GUIRByteInt
.dw dbfPGS_GUIRWordInt
.dw dbfPGS_GUIRHotspot
.dw dbfPGS_GUIRTextMultiline
.dw dbfPGS_GUIRSprite
.dw dbfPGS_GUIRLargeSprite
.dw dbfPGS_GUIRPassIn
.dw dbfPGS_GUIRScrollVert
.dw dbfPGS_GUIRScrollHoriz
.dw dbfPGS_GUIRBorder
.dw dbfPGS_GUIRRect
.dw 0000
.dw dbfPGS_GUIRMouseCursor
;================================
dbfPGS_GUIRNull:
ld de,1
bcall(_PushGUIStack) ;a is set up, hl doesn't matter
ld a,(var2)
ld (hl),a
ret
dbfPGS_GUIRLargeWin:
ld hl,sc2
ld de,5+1 ;one of these is the zero term
call dbfPGS_GetStrlenToDE_SaveA
dbfPGS_GUIRWinFinish:
push hl
ld hl,sc1
call getsourcestring
pop de
ex de,hl
ld bc,5
push hl
push bc
call HexStringToBin
pop bc
pop hl
add hl,bc ;bc=5 is already set up here
ld de,sc2
jp copysourcestring_plain_zt
dbfPGS_GUIRSmallWin:
ld hl,sc2
ld de,5+1+1+1 ;one of these is the zero term
call dbfPGS_GetStrlenToDE_SaveA
ld b,2
call dbfPGS_LoadVarsToHL
jr dbfPGS_GUIRWinFinish
dbfPGS_GUIRFullScreenImg:
ld hl,var2
dec (hl) ;Pic1 = 0, Pic9=8, Pic0=9, etc
ld a,(hl)
call SearchForPic
ret c
ld a,b
or a
ret nz
ld a,03
ld de,768
bcall(_PushGUIStack)
ld a,(var2)
push hl
call SearchForPic
pop hl
inc de
inc de
ex de,hl
ld bc,768-12
ldir
push de
pop hl
ld (hl),0
inc de
ld bc,11
ldir
ret
dbfPGS_GUIRText:
ld hl,sc1
ld de,1+1+1+1 ;one of these is the zero term
call dbfPGS_GetStrlenToDE_SaveA
ld b,3
call dbfPGS_LoadVarsToHL
ld de,sc1
jp copysourcestring_plain_zt
dbfPGS_GUIRWinButtons:
ld de,7
ld hl,dbfPGS_Template_GUIRWinButtons
bcall(_PushGUIStack)
ld a,(var2)
ld (hl),a
inc hl
ld b,3
dbfPGS_GUIRWinButtons_ClearLoop:
push af
and %10000000
jr nz,dbfPGS_GUIRWinButtons_ClearLoopEnd
;a is already zero!
ld (hl),a
inc hl
ld (hl),a
dec hl
dbfPGS_GUIRWinButtons_ClearLoopEnd:
inc hl
inc hl
pop af
sla a
djnz dbfPGS_GUIRWinButtons_ClearLoop
ret
dbfPGS_GUIRWrappedText:
ld hl,sc1
ld de,4+1 ;one of these is the zero term
call dbfPGS_GetStrlenToDE_SaveA
ld b,4
call dbfPGS_LoadVarsToHL
ld de,sc1
jp copysourcestring_plain_zt
dbfPGS_GUIRButtonText:
ld hl,sc1
ld de,4+1 ;one of these is the zero term
call dbfPGS_GetStrlenToDE_SaveA
ld b,2
call dbfPGS_LoadVarsToHL
call dbfPGS_InsGMRPtr
ld de,sc1
jp copysourcestring_plain_zt
dbfPGS_GUIRButtonImg:
ld a,(var4)
push af
add a,a
add a,a
pop bc
add a,b
ld l,a
ld h,0
push hl
ld de,6
add hl,de
ld a,8
ex de,hl
bcall(_PushGUIStack)
ld b,2
call dbfPGS_LoadVarsToHL
call dbfPGS_InsGMRPtr
ld a,(var4)
ld (hl),a
inc hl
ld a,(var5)
ld (hl),a
inc hl
push hl
ld hl,sc1
call getsourcestring
pop de
ex de,hl
pop bc
jp HexStringToBin ;de->hl for bc target bytes
dbfPGS_GUIRTextLineIn:
ld hl,sc1
ld de,7+1 ;one of these is the zero term
call dbfPGS_GetStrlenToDE_SaveA
ld b,3
call dbfPGS_LoadVarsToHL
ld de,(var5)
ld (hl),e
inc hl
ld (hl),d
xor a
inc hl
ld (hl),a
inc hl
ld (hl),a
inc hl
ld de,sc1
jp copysourcestring_plain_zt
dbfPGS_GUIRRadio:
dbfPGS_GUIRCheckBox:
ld hl,sc1
ld de,7+1 ;one of these is the zero term
call dbfPGS_GetStrlenToDE_SaveA
ld b,4
call dbfPGS_LoadVarsToHL
ld de,sc1
jp copysourcestring_plain_zt
dbfPGS_GUIRByteInt:
ld de,5
bcall(_PushGUIStack)
ld b,5
jp dbfPGS_LoadVarsToHL
dbfPGS_GUIRWordInt:
ld de,10
bcall(_PushGUIStack)
ld b,2
call dbfPGS_LoadVarsToHL
ld de,var4
ld bc,3*2
ex de,hl
ldir
ret
dbfPGS_GUIRHotspot:
ld de,6
bcall(_PushGUIStack)
ld b,4
call dbfPGS_LoadVarsToHL
jp dbfPGS_InsGMRPtr
dbfPGS_GUIRTextMultiline:
ld hl,sc1
ld de,6+1 ;one of these is the zero term
call dbfPGS_GetStrlenToDE_SaveA
ld b,4
call dbfPGS_LoadVarsToHL
xor a
ld (hl),a
inc hl
ld (hl),a
inc hl
ld de,sc1
jp copysourcestring_plain_zt
dbfPGS_GUIRSprite:
push af
ld a,(var4)
ld e,a
ld d,0
ld hl,3
add hl,de
pop af
ex de,hl
bcall(_PushGUIStack)
ld b,3
call dbfPGS_LoadVarsToHL
push hl
ld hl,sc1
call getsourcestring
pop de
ex de,hl
ld a,(var4)
ld c,a
ld b,0
jp HexStringToBin ;de->hl for bc target bytes
dbfPGS_GUIRLargeSprite:
push af
ld a,(var4)
ld e,a
ld d,0
ld a,(var5)
bcall(_MultADE)
pop af
push hl
ld de,4
add hl,de
ex de,hl
bcall(_PushGUIStack)
ld b,4
call dbfPGS_LoadVarsToHL
push hl
ld hl,sc1
call getsourcestring
pop de
ex de,hl
pop bc
jp HexStringToBin ;de->hl for bc target bytes
dbfPGS_GUIRPassIn:
ld hl,sc1
ld de,7+1 ;one of these is the zero term
call dbfPGS_GetStrlenToDE_SaveA
ld b,3
call dbfPGS_LoadVarsToHL
ld de,(var5)
ld (hl),e
inc hl
ld (hl),d
inc hl
xor a
ld (hl),a
inc hl
ld (hl),a
inc hl
ld de,sc1
jp copysourcestring_plain_zt
dbfPGS_GUIRScrollVert:
dbfPGS_GUIRScrollHoriz:
ld de,16
bcall(_PushGUIStack)
ld b,4
call dbfPGS_LoadVarsToHL
ld de,var6
ld bc,8
ex de,hl
ldir
ex de,hl
call dbfPGS_InsGMRPtr
jp dbfPGS_InsGMRPtr
dbfPGS_GUIRBorder:
dbfPGS_GUIRRect:
ld de,5
bcall(_PushGUIStack)
ld b,5
jp dbfPGS_LoadVarsToHL
dbfPGS_GUIRMouseCursor:
ld de,2+2+8+8
bcall(_PushGUIStack)
ld de,var2
ld bc,4
ex de,hl
ldir
push de
ld hl,sc1
call getsourcestring
pop de
ex de,hl
ld bc,8
push bc
call HexStringToBin ;de->hl for bc target bytes
push hl
ld hl,sc2
call getsourcestring
pop de
ex de,hl
pop bc
jp HexStringToBin ;de->hl for bc target bytes
;================================
dbfPGS_LoadVarsToHL: ;13-byte routine
push de
ld de,var2
dbfPGS_LoadVarsLoop:
ld a,(de)
ld (hl),a
inc de \ inc de
inc hl
djnz dbfPGS_LoadVarsLoop
pop de
ret
dbfPGS_InsGMRPtr:
ld de,dbfGUIMouse_Return
ld (hl),e
inc hl
ld (hl),d
inc hl
ret
dbfPGS_GetStrlenToDE_SaveA:
push de
push af
call getsourcestring_plain
; ld a,d
; or e
pop bc
pop hl
; jr z,dbfPGS_GetStrlenToDE_SaveA_Ret
ld a,b
add hl,de
ex de,hl
bcall(_PushGUIStack)
ret
;dbfPGS_GetStrlenToDE_SaveA_Ret:
; pop hl ;the call from the function
; ret
;================================
dbfPopGUIStack:
ld a,(var1)
or a
jr z,dbfPopGUIStackFinish
ld b,a
bcall(_PopGUIStacks)
dbfPopGUIStackFinish:
jp xLIBEndNoOut
;================================
dbfOpenGUIStack:
bcall(_OpenGUIStack)
jp xLIBEndNoOut
;================================
dbfCloseGUIStack:
bcall(_CloseGUIStack)
jp xLIBEndNoOut
;================================
dbfRenderGUIStack:
ld a,(nargs)
sub 2
ld b,a
ld a,(var1)
or b
push af
bcall(_RenderGUISub)
pop af
call nz,immFastCopy
jp xLIBEndNoOut
;================================
dbfGUIMouse:
call dbfMouseCoordSet
ld hl,(stack)
push hl
ld hl,(var3)
push hl
ld hl,sum12MouseHookHotspot
ld de,6
ld a,$0E
bcall(_PushGUIStack)
ld hl,sum12MouseHook
bcall(_GUIMouse)
dbfGUIMouse_ReturnP2:
bcall(_PopGUIStack)
pop hl
ld (var3),hl
pop hl
ld (stack),hl
xor a
ld (ScratchVar),a
push ix ;save trigger item for the end of this routine
;create output string for data
;first pass: size
bcall(_GUIFindFirst)
ld bc,0
dbfGUIMouse_StringSizeLoop:
bcall(_mos_cphlde)
jp z,dbfGUIMouse_StringSave
push hl
push hl
pop ix
push de
push bc
inc hl
inc hl
ld a,(hl)
sub 9
jr c,dbfGUIMouse_StringSizeContinue
cp 18+1-9
jr nc,dbfGUIMouse_StringSizeContinue
ld l,a
ld h,0
add hl,hl
ld de,dbfGUIMouseRet_StringDataVecT
add hl,de
ld a,(hl)
inc hl
ld h,(hl)
ld l,a
or h
jr z,dbfGUIMouse_StringSizeContinue
ld a,(ScratchVar)
or a
jr z,dbfGUIMouse_StringSize_NoDelimitYet
pop bc
ld a,$80 ;tCrossIcon
ld (bc),a
inc bc
push bc
dbfGUIMouse_StringSize_NoDelimitYet:
ld de,dbfGUIMouse_StringReturn
push de
jp (hl)
dbfGUIMouse_StringReturn: ;hl = data loc, de=data size
ld a,(ScratchVar)
or a
jr z,dbfGUIMouse_StringReturn_Count
ld a,e
or d
jr z,dbfGUIMouse_StringSizeContinue
ex de,hl
push hl
pop bc ;size in bc, location in de
pop hl ;destination location in hl
ex de,hl ;size in bc, source in hl, destination in de
dbfGUIMouse_StringReturnStoreLoop:
ld a,(hl)
cp $D6
jr nz,dbfGUIMouse_StringReturnStoreLoop1
inc hl ;the extra byte after the CRLF byte
dec bc
dbfGUIMouse_StringReturnStoreLoop1:
push hl
;the following routine needs to preserve de, bc
call Get_Strng_Tok ;token in h,l; z set if one-byte tok (in l only)
ex de,hl
jr z,dbfGUIMouse_StringReturnStoreLoop_Single
ld (hl),d
inc hl
dbfGUIMouse_StringReturnStoreLoop_Single:
ld (hl),e
ex de,hl
inc de
pop hl
inc hl
dec bc
ld a,b
or c
jr nz,dbfGUIMouse_StringReturnStoreLoop
push de
jr dbfGUIMouse_StringSizeContinue
dbfGUIMouse_StringReturn_Count:
ld a,e
or d
jr z,dbfGUIMouse_StringSizeContinueIncBC
ld bc,0