Electromagnet8 wrote:
While trying to produce the Error: ? bug, I found another. I will detail the steps below to produce it to see if it can be replicated by another calculator.
Nice catch! I suspect that will be fixed if I fix whatever launching issues are weighing me down, though, since you use ON-PRGM there too. The following is mostly at the illustrious BrandonW as well as at my own debugging efforts.
Crashes at Input: Code: res 2,(iy+44h) ;MathPrint things <- currow used as pencol
set 6,(iy+49h) ;MathPrint things ; was bit 7??
ld hl,MyAppName+1
ld de,progToEdit
ld bc,8
ldir
ld a,cxExtApps
bjump(_NewContext)
ERR:Memory on _NewContext: Code: res 2,(iy+44h) ;MathPrint things <- currow used as pencol
res 5,(iy+45h) ;MathPrint things
set 6,(iy+49h) ;MathPrint things ; was bit 7??
ld hl,MyAppName+1
ld de,progToEdit
ld bc,8
ldir
ld a,cxExtApps
bjump(_NewContext)
Occasionally crashes: Code: bcall(_CloseEditEqu)
xor a
ld (menuCurrent),a
ld hl,MyAppName+1
ld de,progToEdit
ld bc,8
ldir
ld a,cxExtApps
bjump(_NewContext)
Leaks memory:Code: ld hl,MyAppName+1
ld de,progToEdit
ld bc,8
ldir
bcall(_ExecuteApp)
ERR:Memory on _ExecuteApp: Code: res 2,(iy+44h) ;MathPrint things <- currow used as pencol
set 6,(iy+49h) ;MathPrint things ; was bit 7??
ld hl,MyAppName+1
ld de,progToEdit
ld bc,8
ldir
bcall(_ExecuteApp)
ERR:Memory on _ExecuteApp: Code: res 2,(iy+44h) ;MathPrint things <- currow used as pencol
res 5,(iy+45h) ;MathPrint things
set 6,(iy+49h) ;MathPrint things ; was bit 7??
ld hl,MyAppName+1
ld de,progToEdit
ld bc,8
ldir
bcall(_ExecuteApp)
Edit: I spent my train and shuttle ride this morning tracing through how launching an App from the Apps menu proceeds. So far I have the following: Code: Most OS BCALL definitions (LUT) on page $05
ExecuteApp (4c3c) -> $7AFE on page $05
NewContext (4030) -> $585F on page $03
NewContext0 (4033) > $5874 on page $03
Running an App from the Apps menu:
- Check against $b4 with a=$90 at $535
- res 1,iy+$28
- res 2,iy+28
- bit 5,iy+34 -> because nz, $3f3e called
-
- Something happens start from $55C, which also triggers on [Apps] (but the rest doesn't)
- a=$90
- Carry not set from call $3f44, but a=$58
- b=a=%48 after call $3f4a
- a loaded from cxCurApp, but not $58, so no jp to $61f
- NO CLEANUP or calls from here until NetContext0
- Call into NewContext0 driver starts at $5A4
- NewContext0 kick starts at $06B0 -> $06D7 -> $06E6 -> $06EB -> $06F6
_ NewContext0 (5874/03) sp=ffe7 called from $06FF
Edit #2: Thanks to comparing Prosus' source for page 0 with IDAPro's disassembly of page 0 while stepping through the code to launch a new app in jsTIfied, I have determined that pretty much no sort of cleanup code is called up until _NewContext0, and that never returns. Therefore, whatever cleanup I'm missing is called from _NewContext0, unless there's a flaw in my logic. Then again, _NewContext and _NewContext0 should be roughly equivalent if I'm not crazy, so I'm not sure what else I'm missing.
Edit #3: The following code works (ie, launch DCSE via ON-PRGM, run RADICAL, run RADICAL, quit DCSE) and does not leak memory if the homescreen is empty. If the homescreen has something like "456^-1" on it with MathPrint enabled (I haven't tested with it disabled) and you ON-PRGM launch DCSE, then Input from RADICAL dies in a variety of spectacular ways. I'm really having a hard time detecting what is different with how the OS launches Apps, other than that they bcall _NewContext0. Code: ld hl,MyAppName+1
ld de,progToEdit
ld bc,8
ldir
ld a,cxExtApps
bjump(_NewContext)