0 Members and 1 Guest are viewing this topic.
#ifdef TI83#undefine DELARCVARS ; bcall(_DelVarArc) not documented in TI83#undefine ZEROANS#endif;Delete Real and Complex Vars from A to Z and ThetadeleteAtoZaTheta:#ifdef ZEROANS bcall(_OP1Set0) ; This will set OP1 to FP 0 ( .db 0,$80,0,0,0,0,0,0,0) bcall(_StoAns) ; Ans will be equal 0 (Ans can be a huge list or string and take huge space)#else bcall(_ZeroOP1) ; OP1 needs to be zeroed or it will not work for some reason#endif call deleteAZ ; (OP1) = RealObj = $00 because OP1 is zeroeddeleteAZcplx: ld a,CplxObj ld (OP1+0),adeleteAZ: ld a,tAdeleteAZloop: push af ld (OP1+1),a bcall(_FindSym) ; look up jr c,sdelarcAZ#ifndef DELARCVARS#ifndef TI83 ; TI-83 does not have flash inc b ;\ dec b ; | if b!=0 (it is in flash), then skip jr nz,sdelarcAZ ;/#endif bcall(_DelVar) ; delete variable only if in RAM#else bcall(_DelVarArc)#endifsdelarcAZ: pop af inc a cp tTheta+1 jr nz,deleteAZloop ret;OPTIMIZE TRY: use ld hl,OP1, push and pop hl in deleAZloop;and other changes but is exactly the same sizedeleteAtoZaThetaEnd: .echo "code size: ",deleteAtoZaThetaEnd-deleteAtoZaTheta
;Clean Up Basic Variables;all numbers A-Z and /theta/, lists L1 to L6, matrices [A]-[J], Ans, graphics functions;detects real and complex numbers or listsCleanUpBASICvars:#ifndef TI83 bcall(_CleanAll) ; delete all temp variables#endif#ifdef ZEROANS bcall(_OP1Set0) ; This will set OP1 to FP 0 ( .db 0,$80,0,0,0,0,0,0,0) bcall(_StoAns) ; Ans will be equal 0 (Ans can be a huge list or string and take huge space)#else bcall(_ZeroOP1) ; OP1 needs to be zeroed or it will not work for some reason#endif ld ix,OP1 ; the pointer ld d,0 ; a flag for activate equ create with 0 bytes (needed to not crash TI-OS) ; it is preserved in deletevars2 ld c,d ; c = RealObj = $00 ld a,tA ; (OP1+0) = $00 = RealObj, already ld b,tTheta+1 call deletevars2 ld c,CplxObj ld a,tA; ld b,tTheta+1 ; it was preserved! call deletevars2;these vars have 3 bytes, so a smart solution is coded inc ix ld e,d ; e = RealObj = $00 ld c,tVarLst ld a,tL1 ld b,tL6+1 call deletevars3 ld e,CListObj; ld c,tVarLst ; it was preserved! ld a,tL1; ld b,tL6+1 ; it was preserved! call deletevars3 ld e,MatObj ld c,tVarMat ld a,tMatA ld b,tMatJ+1 call deletevars3 inc d ; activate bcall(_Create0Equ) ld e,EquObj ld c,tVarEqu ld a,tY1 ld b,tY0+1 call deletevars3; ld e,EquObj; ld c,tVarEqu ; it was preserved! ld a,tX1T ;\tX1T to tX6T ld b,tY6T+1 ;/tY1T to tY6T call deletevars2; ld e,EquObj; ld c,tVarEqu ; it was preserved! ld a,tR1 ld b,tR6+1 call deletevars2; ld e,EquObj; ld c,tVarEqu ; it was preserved! ld a,tun ld b,twn+1;fall backdeletevars3: ld (ix-1),edeletevars2: ld (ix+0),cdeletevarloop: push af push bc push de ; all preserved ld (ix+1),a bcall(_FindSym) ; look up jr c,sdelarc ; if doesn't exist, then skip#ifndef DELARCVARS#ifndef TI83 ; TI-83 does not have flash inc b ;\ dec b ; | if b!=0 (it is in flash), then skip jr nz,sdelarc ;/#endif bcall(_DelVar) ; delete variable only if in RAM#else bcall(_DelVarArc) ; delete variable archived or not#endifsdelarc: pop de inc d ;\ dec d ; | if d=0, then we don't need to recreate the equation var jr z,notequvar ;/ bcall(_Create0Equ) ; OP1 destroyed, OP4 has variable name bcall(_OP4toOP1) ; restore OP1 ^^notequvar: pop bc pop af inc a cp b ; b holds the end value jr nz,deletevarloop ; if we arrived b, then return ret; ld hl,OPFomarts; rst 20h ; rMov9ToOP1 ; OP1 is variable;OPFomarts:; .db RealObj,tA,0,0,0,0,0,0,0; .db CplxObj,tTheta,0,0; .db RealObj,tVarLst,tL1,0; .db CListObj,tVarLst,tL6,0; .db MatObj, tVarMat, tMatA, 0; .db MatObj, tVarMat, tMatJ, 0; .db EquObj, tVarEqu, tY1, 0; tY1 to tY9 and tY0, tX1T to tX6T, tY1T to tY6T, tR1 to tR6, tun, tvn, twn; if graph equations do not exist, TI-OS will crash;delete with bcall(_DelVar) and bcall(_Create0Equ); NewEquObj, what it does???;ToDo:;ClearEntries;clear GDBs, Pics, Strs;LRESID;http://wikiti.brandonw.net/?title=83Plus:BCALLs:5041cleanupBASICvarsend: .echo "code size: ",cleanupBASICvarsend-cleanupBASICvars
interesting, I wonder how fast will it be compared to using several dozens of delvar commands, since it is actually larger than those delvar commands? (81 bytes total for all 27 vars). Does it also delete archived vars?
ahh okay. Yeah, it's something about searching through the whole program list to find the asm program, right? So if you have a lot of programs, than it takes long time to load the program... Got it^^
Maybe this could be integrated in future Celtic III versions too? In hook form, it would eliminate the slowness of the Asm() command and be blazing fast. Celtic III games could run this when exiting so all unused vars are cleared
;Clean Up Basic Variables;all numbers A-Z /theta/, lists L1 to L6, matrices [A]-[Z], Ans, graphics functionscleanupBASICvars: bcall(_CleanAll) ; delete all temp variables bcall(_OP1Set0) ; This will set OP1 to 0,$80,0,0,0,0,0,0,0 bcall(_StoAns) ; Ans will be equal 0 (Ans can be a huge list or string and take huge space) ; b_call(_ZeroOP1) ; OP1 needs to be zeroed or it will not work for some reason ld ix,OP1 ; the pointer ld d,0 ; a flag for activate equ create with 0 bytes (needed to not crash TI-OS) ; it is preserved in deletevars2 ld c,RealObj ld a,tA ; (OP1+0) = $00 = RealObj, already ld b,tTheta+1 call deletevars2 ld c,CplxObj ld a,tA; ld b,tTheta+1 ; it was preserved! call deletevars2;these vars have 3 bytes, so a smart solution is coded inc ix ld e,RealObj ld c,tVarLst ld a,tL1 ld b,tL6+1 call deletevars3 ld e,CListObj; ld c,tVarLst ; it was preserved! ld a,tL1; ld b,tL6+1 ; it was preserved! call deletevars3 ld e,MatObj ld c,tVarMat ld a,tMatA ld b,tMatJ+1 call deletevars3 ld d,1 ; activate bcall(_Create0Equ) ld e,EquObj ld c,tVarEqu ld a,tY1 ld b,tY0+1 call deletevars3; ld e,EquObj; ld c,tVarEqu ; it was preserved! ld a,tX1T ;\tX1T to tX6T ld b,tY6T+1 ;/tY1T to tY6T call deletevars2; ld e,EquObj; ld c,tVarEqu ; it was preserved! ld a,tR1 ld b,tR6+1 call deletevars2; ld e,EquObj; ld c,tVarEqu ; it was preserved! ld a,tun ld b,twn+1;fall backdeletevars3: ld (ix-1),edeletevars2: ld (ix+0),cdeletevarloop: push af push bc push de ld (ix+1),a bcall(_FindSym) ; look up jr c,cdelarc ; if doesn't exist, then skip inc b ;\ dec b ; | if b!=0 (it is in flash), then skip jr nz,cdelarc ;/ bcall(_DelVar) ; delete variablecdelarc: pop de inc d dec d jr z,notequvar bcall(_Create0Equ) ;OP1 destroyed, OP4 has variable name bcall(_OP4toOP1) ;restore OP1 ^^notequvar: pop bc pop af inc a cp b jr nz,deletevarloop retcleanupBASICvarsend: .echo "code and data size: ",cleanupBASICvarsend-cleanupBASICvars;
Mhmm strange I wonder if someone could help
I commented even more the source code and optimized further in size. (I think there is still some ways)I cleaned the source, added the defines and final tested.Now write the readme, do the batch files to compile , decide the program names and upload. The interesting now would be someone help me debug the TI-83 build. For the TI-83 there is few documentation on bcalls, but I will try to compare to TI-83+ to see what differences come out. Debugging on calculator and watch the entire bcall disassembly is a thing I won't do. Maybe it is not worth to put on TI-83 nowadays.