436
TI Z80 / Re: zStart - an app that runs on ram clears
« on: December 19, 2011, 03:28:09 pm »
(I was gone)
If you can get me a savestate that crashes, I can fix the glitch in 5 minutes.
If it's oversized, I believe it will Err:Memory since I just use bcall(_createProg).
The code is rather large, but you can probably duplicate some of it with your own code. In any case, here's everything you need to make it work:
If nothing else, I read your post
Yup. The first RAM Clear was from 2nd / Mem / Clear RAM, while the second one was not voluntary. Let me try to reproduce it right now.Oh, thepenguin, earlier today I had a random-ish RAM Clear when trying to edit a program in archive after triggering a regular RAM Clear and then trying to edit an archived program (by pressing a number, if that matters). I ran zStart after the second RAM clear, toggled zStart Off, then On again, and then tried editing the same program. That worked just fine.
Not to burst your bubble (bug-ble?) or anything...
So, to clarify. You cleared ram, then when you went to edit a program, it crashed again? If that's true, then...
Edit: I can reproduce it on my calc by doing the exact same thing as before.
Edit 2: It looks like all I have to do to fix it is run zStart - I don't even have to toggle it on/off like I did earlier.
If you can get me a savestate that crashes, I can fix the glitch in 5 minutes.
I had a quick question about editing programs in archive. I assume that what it does is make a copy in RAM and then copy it back if changes were made. But what happens if there's not enough room in RAM to hold the copy? Are other programs temporarily archived to make space or will it not let you edit the program?
You mentioned you had an entry point in zStart so Axe errors could be shown in archived programs, but the routine sounds like it could be small enough to just include it in the app since I still have a lot of space. But I don't know how you're implementing it so maybe I'm wrong or there are other advantages to calling it through zStart that I'm forgetting.
If it's oversized, I believe it will Err:Memory since I just use bcall(_createProg).
The code is rather large, but you can probably duplicate some of it with your own code. In any case, here's everything you need to make it work:
Code: [Select]
;############################
editProgram:
ld hl, 0
ld (errOffset), hl
editProgramCustomOffset:
bcall(_chkFindSym)
ret c
ld a, b
or a
jr nz, itIsArchived
ld hl, op1
call getLastLetter
bit 7, (hl)
jr z, doTheEdit
jr setTheHook ;idiot
itIsArchived:
call findStartInRom
bcall(_loadDEIndPaged)
inc hl
call fast_bhl
push hl
ld a, e
or d
ld a, b
push af
push de
ld a, 3
out ($20), a
ld hl, op1
call getLastLetter
set 7, (hl)
call pushOp1
bcall(_chkFindSym)
jr c, notThisFoundz
bcall(_delVarArc)
notThisFoundz:
call popOp1
pop hl
push hl
call pushOp1
bcall(_createProg)
call popOp1
inc de
inc de
pop bc
pop af
pop hl
jr z, zeroSizes
bcall(_flashToRam)
zeroSizes:
setTheHook:
ld hl, appChangeHook
in a, (06)
bcall(_enableAppChangeHook)
doTheEdit:
ld hl, op1
ld de, varType
push hl
bcall(_mov9B)
ld a, 3
ld (menuCurrent), a
ld a, 1
ld ($85DF), a
ld a, kEnter
bcall(_pullDownChk)
bcall(_clrTR)
pop hl
ld de, progToEdit-1
bcall(_mov9B)
push af
ld a, kError
ld (cxCurApp), a
pop af
bcall(_newContext0)
bcall(_mon)
;###########################################
appChangeHook:
add a, e
cp kPrgmEd ;these are all part of editing
ret z
cp kMode
ret z
cp kTblSet
ret z
cp kFormat
ret z
finishEditing:
push af
push bc
push hl
ld a, b
cp $46
jr nz, killAppChangeHook ;this is in case a weird switch happens
ld hl, varType
call getLastLetter
bit 7, (hl)
jr z, killAppChangeHook
ld a, 3
out ($20), a
bcall(_runIndicOn)
ld hl, varType
rst 20h
call pushOP1
ld hl, op1
call getLastLetter
res 7, (hl)
bcall(_chkFindSym)
jr c, cantFindProga ;these things never seem possible until it crashes
bcall(_delVarArc)
cantFindProga:
call popOp1
ld hl, op1
call getLastLetter
ld de, -op1-1+7
add hl, de
push hl
bcall(_chkFindSym) ;if this is gone, we let it crash
pop de
or a
sbc hl, de
res 7, (hl)
ld hl, op1
call getLastLetter
res 7, (hl)
call pushOp1
bcall(_chkFindSym)
bcall(_arc_unarc)
call popOp1 ;this is for ON + STO
killAppChangeHook:
bcall(_disableAppChangeHook)
pop hl
pop bc
pop af
ret
;#######################################
;input: hl = start of op1, or similar
getLastLetter:
push af
push bc
ld bc, 10
xor a
cpir
dec hl
dec hl
pop bc
pop af
ret
;#########################################
pushOP1:
push af
push bc
push de
push hl
ld hl, -12
add hl, sp
ld sp, hl
ex de, hl
ld hl, 12
add hl, sp
ld bc, 10
ldir
ld hl, op1
ld bc, 12
ldir
pop hl
pop de
pop bc
pop af
ret
;##########################################
popOP1:
push af
push bc
push de
push hl
ld hl, 10
add hl, sp
ld de, op1
ld bc, 12
ldir
ld hl, 10+12-1
add hl, sp
ex de, hl
ld hl, 10-1
add hl, sp
ld bc, 10
lddr
inc de
ex de, hl
ld sp, hl
pop hl
pop de
pop bc
pop af
ret
;##################################
;Move to start of data in Rom
;Input: Output of _ChkFindSym
;Output: HL = start
; B = rom page
;Destroys: C DE
FindStartInRom:
ex de, hl
LD de, 9
add hl, de
call fast_bhl
bcall(_LoadCIndPaged)
inc c
ld e, c
add hl, de
call fast_bhl
ret
;########################################
;faster bhl
;only checks for going over
fast_bhl:
ld a, h
res 7, h
set 6, h
cp h
ret z
inc b
ret
Iirc I've gotten an ERR:MEMORY trying to edit an archived program from home (well, I run it from the homescreen and take advantage of the ERR:SYNTAX ). Hasn't happened lately tho, either because I keep a lot of ram free or it's been fixed somehow.
If nothing else, I read your post