diff --git a/makefile b/makefile index 76aa2a1..39dbfd1 100644 --- a/makefile +++ b/makefile @@ -10,9 +10,9 @@ NAME = CEaShell APP_NAME = CEaShell APP_VERSION = 5.0.0.0000 -CEASHELL_VERSION = 1.0 +CEASHELL_VERSION = 1.02 APPVAR_VERSION = 0 -DESCRIPTION = "(C) 2022 - 2023 RoccoLox & TIny_Hacker" +DESCRIPTION = "(C) 2022-2023 RoccoLox & TIny_Hacker" COMPRESSED = NO ARCHIVED = YES diff --git a/src/asm/apps.asm b/src/asm/apps.asm index 619b3d0..64c33b8 100644 --- a/src/asm/apps.asm +++ b/src/asm/apps.asm @@ -20,6 +20,7 @@ include 'include/ti84pceg.inc' public _executeApp public _deleteApp public _exitDefrag + extern _removeAppChangeHook appNamePtr := ti.appData @@ -128,7 +129,7 @@ _executeApp: ; mostly Cesium's code ld hl, 0 ld (ti.asm_prgm_size), hl ld iy, ti.flags - call ti.ClrAppChangeHook + call _removeAppChangeHook res ti.useTokensInString, (iy + ti.clockFlags) res ti.onInterrupt, (iy + ti.onFlags) set ti.graphDraw, (iy + ti.graphFlags) diff --git a/src/asm/editProg.asm b/src/asm/editProg.asm index 9c93d53..5e9fd2d 100644 --- a/src/asm/editProg.asm +++ b/src/asm/editProg.asm @@ -38,6 +38,7 @@ include 'include/ti84pceg.inc' public edit_basic_program_goto public edit_basic_program public _editBasicProg + public _removeAppChangeHook extern _reloadApp extern _arcUnarc extern _reinstallGetCSCHook @@ -101,9 +102,7 @@ edit_basic_program: ld (edit_status),a call _arcUnarc .not_archived: - ld hl,hook_app_change - ld iy, ti.flags ; C toolchain messes up this - call ti.SetAppChangeHook + call _setupAppChangeHook xor a,a ld (ti.menuCurrent),a call ti.CursorOff @@ -261,7 +260,7 @@ hook_app_change: jr z, .exitOS ret .close_editor: - call ti.ClrAppChangeHook + call _removeAppChangeHook push af, bc, hl call ti.CursorOff call ti.CloseEditEqu @@ -374,5 +373,68 @@ _restoreAppvar: call ti.ChkFindSym jp ti.DelVar +_setupAppChangeHook: ; handle preservation of hooks (From Cesium) + xor a, a + ld (ti.appErr1), a + ld iy, ti.flags + bit ti.appChangeHookActive, (iy + ti.hookflags4) + jr z, .noChain + ld hl, (ti.appChangeHookPtr) + ld de, hook_app_change + or a, a + sbc hl, de + add hl, de + jr z, .checkIfBadExit + +.chainHooks: + ld a, (hl) + cp a, $83 + jr nz, .noChain + ex de, hl + inc de + ld hl, ti.appErr1 + ld (hl), $7f + inc hl + ld (hl), de + jr .noChain + +.checkIfBadExit: + ld hl, ti.appErr1 + ld a, (hl) + cp a, $7f + jr nz, .noChain + inc hl + ld hl, (hl) + dec hl + jr .chainHooks + +.noChain: + ld hl, hook_app_change + jp ti.SetAppChangeHook + +_removeAppChangeHook: ; also from Cesium + ld iy, ti.flags + bit ti.appChangeHookActive, (iy + ti.hookflags4) + jr z, .clearAppChange + ld hl, (ti.appChangeHookPtr) + ld de, hook_app_change + or a, a + sbc hl, de + add hl, de + ret nz + ld hl, ti.appErr1 + ld a, (hl) + cp a, $7f + jr nz, .clearAppChange + inc hl + ld hl, (hl) + dec hl + xor a, a + ld (ti.appErr1), a + jp ti.SetAppChangeHook + +.clearAppChange: + jp ti.ClrAppChangeHook + tempProg: db ti.ProgObj, "appvar", 0 diff --git a/src/asm/runProgram.asm b/src/asm/runProgram.asm index 4675d11..5382e2c 100644 --- a/src/asm/runProgram.asm +++ b/src/asm/runProgram.asm @@ -47,6 +47,7 @@ include 'include/ti84pceg.inc' extern _installGetCSCHookCont extern _isGetCSCHookInstalled extern _removeStopHook + extern _removeAppChangeHook backupPrgmName := ti.appData returnIsAsm := backupPrgmName + 9 @@ -142,7 +143,12 @@ _asmProgram: inc hl ld bc, (ti.asm_prgm_size) ld de, ti.userMem - ldir + +.copy: + call ti.ChkBCIs0 + jr z, _asmProgram.run + ldi + jr .copy _asmProgram.run: call ti.DisableAPD @@ -310,9 +316,12 @@ _basicProgram: pop hl ; get data pointer inc hl inc hl + +.copy: + call ti.ChkBCIs0 + jr z, .inRom ldi - jp po, .inRom - ldir + jr .copy .inRom: call ti.OP4ToOP1 @@ -654,7 +663,7 @@ _showError: _reloadApp: ld sp, (ti.onSP) ; Don't bork the stack - call ti.ClrAppChangeHook + call _removeAppChangeHook res ti.useTokensInString, (iy + ti.clockFlags) res ti.onInterrupt, (iy + ti.onFlags) set ti.graphDraw, (iy + ti.graphFlags) diff --git a/src/main.c b/src/main.c index 0e9f73d..1a31870 100644 --- a/src/main.c +++ b/src/main.c @@ -6,7 +6,7 @@ * Copyright 2022 - 2023 * License: GPL-3.0 * Last Build: January 1, 2023 - * Version: 1.0 + * Version: 1.02 * * -------------------------------------- **/