Skip to content

Commit

Permalink
Fix two bugs reported by LogicalJoe
Browse files Browse the repository at this point in the history
- Fix an issue with preserving the app change hook
- Fix a crash when running empty programs from the homescreen

Co-Authored-By: RoccoLox Programs <[email protected]>
  • Loading branch information
TIny-Hacker and RoccoLoxPrograms committed Jan 1, 2023
1 parent ca89338 commit 4010b78
Show file tree
Hide file tree
Showing 5 changed files with 84 additions and 12 deletions.
4 changes: 2 additions & 2 deletions makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 2 additions & 1 deletion src/asm/apps.asm
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ include 'include/ti84pceg.inc'
public _executeApp
public _deleteApp
public _exitDefrag
extern _removeAppChangeHook

appNamePtr := ti.appData

Expand Down Expand Up @@ -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)
Expand Down
70 changes: 66 additions & 4 deletions src/asm/editProg.asm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
17 changes: 13 additions & 4 deletions src/asm/runProgram.asm
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ include 'include/ti84pceg.inc'
extern _installGetCSCHookCont
extern _isGetCSCHookInstalled
extern _removeStopHook
extern _removeAppChangeHook

backupPrgmName := ti.appData
returnIsAsm := backupPrgmName + 9
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Copyright 2022 - 2023
* License: GPL-3.0
* Last Build: January 1, 2023
* Version: 1.0
* Version: 1.02
*
* --------------------------------------
**/
Expand Down

0 comments on commit 4010b78

Please sign in to comment.