Skip to content

Commit 7bd14b3

Browse files
add potential fix for stop token with os_RunPrgm
1 parent bd89485 commit 7bd14b3

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

src/ce/runprgm.src

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,15 @@ namespace ti?
1414
?PopRealO1 := 00205DCh
1515
?ErrNotEnoughMem := 002072Ch
1616
?ErrMemory := 0020768h
17+
?JError := 0020790h
1718
?PushErrorHandler := 0020798h
1819
?PopErrorHandler := 002079Ch
1920
?ParseInp := 0020F00h
2021
?GetParse := 0020F0Ch
2122
?SaveParse := 0020F10h
2223
?DisableAPD := 0021134h
24+
?SetParserHook := 002149Ch
25+
?ClrParserHook := 00214A0h
2326
?DeleteTempPrograms := 00214C0h
2427
?ForceFullScreen := 0021528h
2528
?LoadDEInd_s := 0021D9Ch
@@ -30,6 +33,7 @@ namespace ti?
3033
?OP1 := 0D005F8h
3134
?errNo := 0D008DFh
3235
?appErr2 := 0D025B6h
36+
?parserHookPtr := 0D025F9h
3337
?pixelShadow := 0D031F6h
3438
?asm_prgm_size := 0D0118Ch
3539
?userMem := 0D1A881h
@@ -39,6 +43,9 @@ namespace ti?
3943
?tAsm84CeCmp := 07Bh
4044
?tAsm84CePrgm := 07Ah
4145

46+
?hookflags4 := 36h
47+
?parserHookActive := 1
48+
4249
?ParsFlag2 := 7h
4350
?numOP1 := 0
4451
?newDispF := 08h
@@ -224,6 +231,23 @@ launch_basic_prgm:
224231
setup_prgm_state:
225232
xor a,a
226233
ld (ti.kbdGetKy),a
234+
bit ti.parserHookActive,(iy + ti.hookflags4)
235+
jr nz,.chain_hook
236+
.no_chain:
237+
ld hl,stub.chain
238+
ld (hl),$af ; xor a,a
239+
inc hl
240+
ld (hl),$c9 ; ret
241+
jr .check_flags
242+
.chain_hook:
243+
ld hl,(ti.parserHookPtr)
244+
ld a,(hl)
245+
cp a,$83
246+
jr nz,.no_chain ; ensure the hook is valid
247+
ld (stub.chain + 1),hl
248+
ld (stub.prev_hook),hl
249+
;jr .check_flags
250+
.check_flags:
227251
ld a,$ce ; set
228252
bit ti.allowProgTokens,(iy + ti.newDispF)
229253
jr nz,.setAllowProgTokens
@@ -273,6 +297,11 @@ push_stub:
273297
add hl,bc
274298
ld (.stub_error_handler),hl
275299
pop hl
300+
push hl
301+
ld bc,stub.hook_parser - stub.normal
302+
add hl,bc
303+
call ti.SetParserHook
304+
pop hl
276305
ex de,hl
277306
ld hl,stub
278307
ld bc,stub.len
@@ -339,6 +368,12 @@ stub:
339368
res ti.textInverse,(iy + ti.textFlags)
340369
res ti.onInterrupt,(iy + ti.onFlags)
341370
res ti.numOP1,(iy + ti.ParsFlag2)
371+
call ti.ClrParserHook
372+
ld hl,0
373+
.prev_hook := $-3
374+
ld a,(hl)
375+
cp a,$83
376+
call z,ti.SetParserHook
342377
ld hl,(ti.asm_prgm_size)
343378
add hl,de
344379
or a,a
@@ -365,6 +400,16 @@ stub:
365400
add hl,bc
366401
ld sp,hl ; os should delete created program
367402
ret
403+
.hook_parser:
404+
db $83 ; hook signifier
405+
cp a,2
406+
jr nz,.chain
407+
ld a,$d9 - $ce ; check if stop token
408+
sub a,b
409+
jp z,ti.JError
410+
ld a,2
411+
.chain:
412+
jp 0 ; xor a,a \ ret if not chaining
368413
.found:
369414
call ti.ChkInRam
370415
ex de,hl

0 commit comments

Comments
 (0)