-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathrunprog.asm
1418 lines (1380 loc) · 24.4 KB
/
runprog.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: runprog.asm
; Long name: Run ASM and BASIC programs
; Author: Kerm Martian aka Christopher Mitchell
; Last Update: Unknown
;
; Code necessary to set up, execute, and clean up after
; assembly and BASIC programs. Also handles some things with
; HomeRun and the properties menu.
;
;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.
;-----------------------------------------------------------
RunProgDeny:
ld a,(LastClick)
sub 2
jp nz,MainMouseLoop
push ix
pop hl
ld bc,5
add hl,bc
xor a
ld (hl),a
ld b,a
jp PropMenu
mj_RunProg:
RunProgFromHook:
;takes VAT location in hl
res graphDraw,(iy+graphFlags) ;make BASIC programs *NOT* clear the graphscreen
push hl
call DAVLCheck
pop hl
ld de,VFAT
push de
push hl
ld a,l
ld (de),a
inc de
ld a,h
ld (de),a
inc de
dec hl
ld a,(hl)
dec hl
dec hl
ld a,(hl)
ld (de),a
inc de
dec hl
ld a,(hl)
ld (de),a
inc de
dec hl
ld a,(hl)
ld (de),a
inc de
pop hl
push de
xor a
ld (iy+dcsProgFlags),a
ld (CurFldr),a ;used for the fldr of current prog, 0 means don't check it
call DetectType
pop de
ld (de),a
xor a
ld (LastClick),a ;don't trigger the prop menu
pop ix
cp $ff
ret z
ld (iy+dcsProgFlags),a
jr RunProgImmediate
RunProgFromDesktop:
set graphDraw,(iy+graphFlags) ;make BASIC programs clear the graphscreen
RunProg:
ld a,(ProgsDone)
ld c,a
ld a,(TotalProgs)
sub c
bit 7,a
jr nz,RunProgContinue
inc b
sub b
jp c,RunProgDeny
inc a
RunProgContinue:
push af
push bc ;save screen index
push ix
push ix
push ix
pop hl
call RunNameCopy
bcall(_PushOp1)
call FldSave
bcall(_PopOp1)
bcall(_ChkFindSym)
ex de,hl
push hl
pop bc
pop ix
pop hl
ld (hl),e
inc hl
ld (hl),d
inc hl
; push bc
; pop de
ld (hl),c
inc hl
ld (hl),b
pop bc
pop af ;recall run offset!
RunProgFromDesktop_NoFldBack:
call RunProgImmediate
;jp c,RenderDesktop
jp RealStart
RunProgImmediate:
call SPSave
ld (IconSpace8b),hl ;save VFAT entry for future use
ld b,1
ld a,(LastClick)
sub 2
jp z,PropMenu ;deal with rightclick
push ix ;put ix...
call PushProgChain ;push the previous program run upwards
;in case we are running nested programs
pop hl ;...into hl (==VFAT+6(N-1))
ld b,1
push hl
bcall(_ldhlind)
dec hl
dec hl
dec hl
ld d,(hl)
dec hl
ld e,(hl) ;de = VAR entry
ex de,hl
ld (ScratchWord),hl ;save it
ex de,hl
pop hl
push hl
ld de,4
add hl,de
ld a,(hl)
ld (CurROMPage),a ;should be correct for PropDelete routine
inc hl
ld a,(hl) ;get prog type flags
ld (iy+dcsProgFlags),a
ld hl,(45*256)+32 ;initialize mouse coordinates
ld (MseY),hl ;x=45,y=32
#ifdef false
ld hl,textshadow;cmdshadow
ld (hl),' '
ld e,l
ld d,h
inc de
ld bc,128-1
ldir
#endif
pop hl
and $7e ;mask out lock/unlock bit
or a
jr z,RunBasicProg ;Regular BASIC program
cp 2
jr z,RunBasicProgDCS ;Doors CS BASIC program
cp $30
jp z,RunTIOSASM ;TI-OS program
cp $08
jp z,RunTIOSASM ;Compressed TI-OS ASM program
cp $24
jp z,RunIonProg ;either Ion type
cp $2A
jp z,RunDCSasmProg
cp $3E
jp z,RunMOSasmProg
cp $0A
jp z,RunAssociatedProg
#ifdef Folders
cp %01001000
jp z,RunFldr
#endif
ld hl,501
call DCSError
jp PopProgChainOrAAndRet
; call PopProgChain
; or a ;set carry flag
; ret
ArcUnarcProgA:
call RunNameCopy
ArcUnarcProgA_Op1: ;Op1 is still intact after the chkfindsym bcall
push hl
push de
push bc
bcall(_pushop1) ;all destroyed
call GetProgChainTop
pop bc
ret c ;I hope this doesn't happen; I don't think it would be graceful
ld de,10
add hl,de
ld a,b
ld (hl),a ;store the page at A2
ld (CurROMPage),a
pop de
pop hl
RuninRAM:
call GetProgChainTop
push hl
bcall(_popOp1) ;_ all destroyed
pop de
inc de ;Past A1
ld hl,Op1
; ex de,hl ;Copy from Op1 to B1,C1
ld bc,9
ldir
ret
RunBasicProgDCS:
RunBASICProg:
call ArcUnarcProgA ;this sets up the appvar
call GetArcstatus
or a
jr z,RunBASICProgUseOrig ;it's not archived!!
call GetProgChainTop
inc hl ;B1
rst 20h
bcall(_chkfindsym)
ret c
push bc
ex de,hl
push hl
call SetUpROM ;CurROMPage is set by ArcUnarcProgA
call GetArcProgWord
ld a,h
or l
jp z,RunBASICEmptyProg
push hl
ld hl,TmpProgName
push hl
push hl
call GetProgChainTop
ld de,11
add hl,de
pop de
ex de,hl
ld bc,9
ldir
pop hl
rst 20h
bcall(_chkfindsym)
bcallnc(_delvararc)
ld hl,TmpProgName
rst 20h
pop hl
push hl
bcall(_enoughmem)
jp c,TmpMemErr
ex de,hl
bcall(_createprog)
inc de
inc de
pop bc
pop hl
call SetUpROM
inc hl
inc hl
pop af
or a
jr z,RunBASICProgNoPageInc
bit 7,h
jr z,RunBASICProgNoPageInc
inc a
res 7,h
set 6,h
RunBASICProgNoPageInc:
bcall(_flashtoram)
RunBASICProgUseOrig:
call GetRAMName ;this chunk of code deals with Axe source editing
rst 20h
bcall(_ChkFindSym)
inc de
inc de
ld a,(de)
cp $3A ;the '.' symbol in TI tokens
jr nz,RunBASICProg_NotAxeSrc
inc de
ld a,(de)
cp '0'
jr c,RunBASICProg_IsAxeSrc
cp '9'+1
jr c,RunBASICProg_NotAxeSrc
RunBASICProg_IsAxeSrc:
ld hl,TmpProgName
rst 20h
bcall(_chkfindsym)
bcallnc(_delvar)
xor a
ld (EditorMode),a ;offset into program - no Goto mode
call GetProgChainTop
inc hl
rst 20h
bcall(_ChkFindSym)
call EditorJumpIn
call PopProgChain
scf ;force Homerun to reset context from the editor
ret
RunBASICProg_NotAxeSrc:
xor a
call ArcUnarcDCSBASIC
or a ;rcf
ret z ;z is an error from ArcUnarcDCSBASIC
bcall(_getK) ;this eliminates any residual keypresses
bit graphDraw,(iy+graphFlags)
jr z,RunBASICProg_SkipClean
bcall(_grbufclr)
bcall(_clrlcdfull)
ld hl,TextShadow
push hl
pop de
ld (hl),' '
inc de
ld bc,127
ldir
xor a
ld h,a \ ld l,a
ld (currow),hl ;currow = curcol = 0 (much better than homeup!)
RunBASICProg_SkipClean:
bcall(_runindicon) ;turn off the run indicator
bcall(_cleanall) ;clear out tempvars
;set apptextsave,(iy+appflags) ;text goes to textshadow
res TextWrite,(iy+sgrFlags) ;Make text go to screen
call GetArcStatus
push af
call GetProgChainTop
inc hl ;at B1
pop af
ld de,0 ;jump to B2?
or a
jr z,RunBASICCopy
RunBASICCopyTmp:
ld de,10
RunBASICCopy:
add hl,de ;add 0 (B1) or 10 (B2)
rst 20h
bcall(_ChkFindSym)
#ifdef enablecn2
di
im 1
ei
#endif
call RunBASICProgram ;<---- FOR TEST
res 4,(iy+9) ;reset [ON] register
push bc
ld a,b
or a
jr z,RunBASICPost_Valid
call SetErrOffset
jr nz,RunBASICPost_Valid
ld hl,0
ld (errOffset),hl
RunBASICPost_Valid:
; ld hl,($965D) ;nextParse
; ld de,(basic_start)
; or a
; sbc hl,de
; ld (ScratchWord),hl ;No longer used.
RunBASICDebounce:
bcall(_getk)
jr nz,RunBASICDebounce ;if there was a keypress, ignore it and continue debouncing
res IndicRun,(iy+IndicFlags) ;turn off the run indicator
xor a
out (20h),a ;Reset execution speed?
ld a,$ff
call ArcUnarcDCSBASIC
ld hl,TmpProgName
rst 20h
bcall(_chkfindsym)
bcallnc(_delvar)
pop bc
#ifdef showbasicerrors ;otherwise residual keys were cleared
ld a,b
cp %01111111
scf
jr z,RunBASICFinishErrorSilent
or a
jr nz,RunBASICFinishError
#endif
RunBASICFinished:
PopProgChainOrAAndRet:
call PopProgChain ;remove the BASIC program that was just run
or a ;cleared carry -> RealStartNoReset
ret
#ifdef showbasicerrors
RunBASICFinishError:
call BASICErrorParse
set graphDraw,(iy+graphFlags)
RunBASICFinishErrorSilent:
push af
call PopProgChain
pop af
ret
#endif
GetArcStatus:
push hl
push de
call GetProgChainTop
ld de,10
add hl,de
ld a,(hl) ;ld the A2 byte
pop de
pop hl
ret
GetRAMName:
call GetArcStatus
push af
call GetProgChainTop
inc hl
pop af
or a
ret z
ld de,10
add hl,de
ret
GetRAMNameAP:
call GetProgChainSize
cp 2
ret c ;Don't bother if less than 2
call GetProgChainTop
ld de,-20
add hl,de
ld a,(hl) ;at A1 byte of PREVIOUS stack entry
or a
scf
ret z ;Don't bother if not an AP file
ld de,10 ;at A2 byte of PREVIOUS stack entry
add hl,de
ld a,(hl)
inc hl ;at B2 byte of PREVIOUS stack entry
or a
scf
ccf
ret nz
ld de,-10
add hl,de ;at B1 byte of PREVIOUS stack entry
or a ;rcf
ret
RunBASICEmptyProg:
pop hl
pop hl
jr RunBASICFinished
BASICErrorParse:
and $7F
ld l,a
ld h,0
ld de,506
add hl,de
jp DCSError
; or a ;reset carry flag
;ret
ErrUndefined:
ld hl,503
call DCSError
or a ;rcf
ret
#ifdef Folders
RunFldr:
push ix
pop hl
bcall(_ldhlind)
ld de,-11
add hl,de
ld a,(hl)
ld (CurFldr),a
call PopProgChain
jp RealStartNoReset
#endif
;-----------------------------------------------
ArcUnarcDCSBASIC:
ld (ScratchVar),a
call GetArcStatus
push af
call GetProgChainTop
inc hl ;B1
pop af
or a
jr z,ArcUnarcDCSBASIC2
ld de,10
add hl,de ;B2
ArcUnarcDCSBASIC2:
rst 20h
bcall(_ChkFindSym)
jr c,ErrUndefined
inc de
inc de
inc de
ld a,(de) ;get second byte of program
cp $22
jr nz,ArcUnarcDCSBASIC3
ArcUnarcDCSBASIC2L:
inc de
ld a,(de)
cp $3f
jr nz,ArcUnarcDCSBASIC2L
ld hl,5
jr ArcUnarcDCSBASIC4
ArcUnarcDCSBASIC3:
ld hl,3
ArcUnarcDCSBASIC4:
add hl,de
ld a,(hl)
cp '6'
push af
jr nz,ArcUnarcDBLR0
inc hl
ArcUnarcDBLR0:
inc hl
ld a,(hl)
cp $2a ;double-quote
jr nz,ArcUnarcDBLR1
inc hl
ArcUnarcDBLR1:
pop af
jr nz,ArcUnarcDBLR
ld de,48d
add hl,de
ArcUnarcDBLR:
ld de,17d
add hl,de
ld a,(hl)
cp $3E
jr nz,ArcUnarcRetNZ ;should never be zero, exit status=OK
inc hl
ld a,(hl)
cp 'A'
jr nz,ArcUnarcRetNZ ;should never be zero, exit status=OK
inc hl
ld a,(hl)
cp $3F ;line return
jr nz,ArcUnarcRetNZ ;should never be zero, exit status=OK
inc hl
ArcUnarcDCSBASICloop:
push hl
bcall(_ZeroOp1)
pop hl
push hl
ld bc,0
ArcUnarcDBL1:
inc bc
inc hl
ld a,(hl)
cp $3F
jr nz,ArcUnarcDBL1
pop de
ld hl,Op1
ld (hl),5
inc hl
ex de,hl
ldir
inc hl
push hl
bcall(_ChkFindSym)
jr c,ArcUnarcDBErr
ld de,-5
add hl,de
call GetArcStatus
or a
jr nz,ArcUnarcDB2
ld a,(hl)
or a
jr z,ArcUnarcDB3
ArcUnarcDB2:
bcall(_ChkFindSym)
ld a,b
or a
jr z,ArcUnarcDB22
ld a,$ff
ArcUnarcDB22:
ld c,a
ld a,(ScratchVar)
xor c
bcallnz(_arc_unarc)
ArcUnarcDB3:
pop hl
ld a,(hl)
; inc hl ;wouldn't this be important???
cp $3E
jr nz,ArcUnarcDCSBASICloop
ArcUnarcRetNZ:
ld a,1
ret ;exit status==OK
ArcUnarcDBErr:
; pop hl
pop hl
ld hl,503d
call DCSError
ld hl,TmpProgName ;ld hl,ProgNameSpace
rst 20h
bcall(_ChkFindSym)
bcallnc(_delvar)
call PopProgChain ;all done
;jp RenderDesktop
xor a ;says this FAILED
ret
;-----------------------------------------------
RunAssociatedProg:
push ix
ld hl,TmpProgname2
ld (ScratchWord),hl
; call PushProgChain ;insert new entry for AP before its viewer
pop hl
; ret c ;die if failure
call ArcUnarcProgA
call GetProgChainTop
ld (hl),1 ;A1
ld de,10
add hl,de
ld a,(hl) ;A2
or a
call nz,initTmpASM
call PushProgChain ;Push the program entry on top of the AP file
call GetRAMNameAP
rst 20h
bcall(_chkfindsym) ;get the AP name in RAM
ld hl,7
add hl,de
ld b,(hl)
inc hl
ld c,(hl)
inc hl
ld d,(hl)
call DCSAPGetType
jr z,RAP_Fail
bcall(_chkfindsym)
jr c,RAP_Fail
dec hl
ld a,(hl)
ld (Op6),a
inc hl
call ArcUnarcProgA_Op1
jp RunDCSasmProgAP
RAP_Fail:
bcall(_grbufclr)
ld hl,(2*256)+2
ld (pencol),hl
ld hl,RAPFailTxt
call VPutsApp
ld hl,(8*256)+2
ld (pencol),hl
ld hl,RAPFailTxt2
call VPutsApp
call iFastCopy
call Pause
call PopProgChain ;the main program
call asmcheckwriteback ;the AP file
jp PopProgChainOrAAndRet
;call PopProgChain
;or a ;rcf
;ret
RAPFailTxt:
.db "No handler for this file.",0
RAPFailTxt2:
.db "See dcs.cemetech.net",0
;-----------------------------------------------
RunTIOSASM:
push ix
ld hl,TmpProgname
ld (ScratchWord),hl
pop hl
call ArcUnarcProgA
call GetArcStatus
or a
call nz,initTmpASM
jp ASMContinueAll
RunDCSasmProg:
push ix
pop hl
call ArcUnarcProgA
RunDCSasmProgAP:
ld hl,TmpProgname
ld (ScratchWord),hl
call GetArcStatus
or a
call nz,initTmpASMOp1
;call FixLibs ;redundant
call RunDCSIon
ld hl,ScratchWord
push hl
pop ix
push hl
call GetRAMName
RunDCSasmOrig:
rst 20h
bcall(_ChkFindSym)
pop hl
; push hl
inc hl
inc hl ;de points to size byte of program
ld (hl),e ;hl == FreeRAM (?)
inc hl
ld (hl),d ;hl == FreeRAM+1
ex de,hl
push hl
ld de,14 ;bypass extra 'ret' & $BB,$6D
add hl,de
bcall(_ldhlind)
pop de
ld a,l
or h ;check if we have any ALEs
jp z,ASMContinueAll
add hl,de ;at lib table
ld de,-$9D95+2
add hl,de
ld ix,ALEVectorStart ;blank vector entry
DCSLibLoop:
dec hl
rst 20h
ld a,5
ld (op1),a
push hl
bcall(_chkfindsym)
inc de
inc de
inc de
inc de
ld (ScratchWord),de
inc de
inc de
pop hl
jp c,LibErr ;fix pop(s)?
push hl
ex de,hl
ld b,(hl)
DCSLibLoadLoop:
inc hl
push hl
bcall(_ldhlind)
push de
ld de,(scratchWord)
add hl,de
pop de
ld a,$C3
ld (ix),a
inc ix
ld (ix),l
inc ix
ld (ix),h
inc ix
pop hl
inc hl
djnz DCSLibLoadLoop
pop hl
ld a,(hl)
cp $ff
jr nz,DCSLibLoop
jp ASMContinueAll
RunIonProg:
push ix
ld hl,TmpProgname
ld (ScratchWord),hl
pop hl
call ArcUnarcProgA
call GetArcStatus
or a
call nz,initTmpASM
;call FixLibs ;redundant
call RunDCSIon
jp ASMContinueAll
RunDcsIon:
FixLibs:
ld de,ionVectors
ld hl,IonJumpmap
ld bc,8*3
push bc
ldir
ld hl,dcsLibAdditions
pop bc
ldir
ret
RunMOSasmProg:
;first we need to do any pointer correction necessary...
;...which is none
jp RunIonProg
initTmpASMOp1:
bcall(_chkfindsym)
dec hl
ld a,(hl)
ld (Op6),a
inc hl
jr initTmpASMOp12
initTmpASM:
push ix
pop hl
call RunNameCopy
initTmpASMOp12:
ld a,b
push hl
push de
push bc
call GetProgChainTop ;A1
ld de,10
add hl,de ;A2
pop bc
ld a,b
ld (hl),a
ld (CurROMPage),a
pop de
pop hl ;this should properly set up SafeArcFlags for the DCS BASIC routine
push bc
ex de,hl
push hl
call SetUpROM
call GetArcProgWord
;ld a,h
;or l
;jp z,RunBASICEmptyProg
push hl
call GetProgChainTop ;A1
inc hl ;B1
ld d,(hl)
ld b,0 ;was 0 with dec bc later
initTmpAsmNLL:
ld a,(hl) ;\- get name length
or a ;|
jr z,initTmpAsmNLLDone ;/
inc hl ;
inc b
ld a,b
cp 9
jr nz,initTmpAsmNLL
initTmpAsmNLLDone:
ld c,b
ld b,0
push bc
ld a,d ;prog type
ld de,Op1
ld (de),a ;store it as first byte of Op1
ld hl,(ScratchWord)
push de
inc de
inc hl
ldir ;copy from scratchword to op1
call GetProgChainTop
ld de,10+1 ;to A2, then B2
add hl,de
pop de
pop bc
push hl ;hl = progchain, de = op1
ld a,c
cp 9
jr z,initTmpAsm_NoZTerm
add hl,bc
ld (hl),0
initTmpAsm_NoZTerm:
pop hl
ex de,hl
push de
ldir ;copy RAM name
call GetProgChainSize
pop de
inc de ;pointing to Op1+1
ld b,a
ld a,(de)
add a,b
ld (de),a ;add size of progchain to this to make it unique
bcall(_chkfindsym)
jr c,RunAProgNoneToDel
bcall(_delvararc)
RunAProgNoneToDel:
call GetProgChainTop
ld de,10+1 ;to A2, then B2
add hl,de
rst 20h
pop hl ;recall and resave size
push hl
bcall(_enoughmem)
jr c,TmpMemErr
ex de,hl
ld a,(op1)
sub 5
jr nz,InitTmpASMMakeProt
bcall(_createprog)
jr InitTmpASMMake
InitTmpASMMakeProt:
bcall(_createprotprog)
InitTmpASMMake:
dec hl
ld a,(Op6)
ld (hl),a
inc de
inc de
pop bc
pop hl
call SetUpROM
inc hl
inc hl
pop af
or a
jr z,RunAProgNoPageInc
bit 7,h
jr z,RunAProgNoPageInc
inc a
res 7,h
set 6,h
RunAProgNoPageInc:
bcall(_flashtoram)
ret
TmpMemErr:
pop af
pop af
pop af
ld hl,$0000 ;restore stack
add hl,sp
push hl
ld hl,(AppVarLoc)
ld de,AVOff_SPSave
add hl,de
bcall(_ldhlind)
ex de,hl
pop hl
ex de,hl
or a
sbc hl,de
TmpMemErrL:
pop de
dec hl
dec hl ;each stack entry is *TWO* bytes!!!!
ld a,h
or l
jr nz,TmpMemErrL
MemError:
ld hl,504
call DCSError
jp PopProgChainOrAAndRet
;call PopProgChain
;or a ;reset carry flag
;ret
;--------------------------------------------------------------
ASMContinueAll:
ld hl,AVOff_ASMExecActive
call DAVLCheckOffset
ld (hl),1
call GetRAMName
rst 20h
bcall(_chkfindsym)
ex de,hl
res TextWrite,(iy+sgrFlags)
push hl
;bcall(_ldhlind)
;push hl
; pop bc
ld c,(hl)
inc hl
ld b,(hl)
dec bc
dec bc ;the $BB,$6D
pop de
push de ;save progstart for unarc of pendfile main
inc de
inc de
inc de
inc de ;size & ASM token (4 bytes)
ld a,(de)
push af
inc de
ld a,(de)
dec de
push af