Skip to content

Commit

Permalink
Various bug patches/improvements
Browse files Browse the repository at this point in the history
- Speed up opening and closing of menus
- Exit app more cleanly
- Properly handle hiding hidden programs in the shell when the option is selected

Co-Authored-By: RoccoLox Programs <[email protected]>
  • Loading branch information
TIny-Hacker and RoccoLoxPrograms committed Dec 20, 2022
1 parent d821bca commit 98ff8fb
Show file tree
Hide file tree
Showing 11 changed files with 178 additions and 32 deletions.
2 changes: 1 addition & 1 deletion makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
NAME = CEaShell
APP_NAME = CEaShell
APP_VERSION = 5.0.0.0000
CEASHELL_VERSION = 0.81.2
CEASHELL_VERSION = 0.82
ICON = icon.png
DESCRIPTION = (C) 2022 RoccoLox + TIny_Hacker
COMPRESSED = NO
Expand Down
1 change: 1 addition & 0 deletions src/asm/apps.asm
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ _executeApp: ; mostly Cesium's code
ld bc, $fff
call ti.MemClear
; get proper stuff for the app
call ti.DrawStatusBar
push ix
ld ix, 0
add ix, sp
Expand Down
7 changes: 5 additions & 2 deletions src/asm/editProg.asm
Original file line number Diff line number Diff line change
Expand Up @@ -257,12 +257,12 @@ hook_app_change:
.close_editor:
call ti.ClrAppChangeHook
push af, bc, hl
call ti.CursorOff
call ti.CloseEditEqu
ld hl, isAppvar
ld a, edit_appvar
cp a, (hl)
jr z, _restoreAppvar
call ti.CursorOff
call ti.CloseEditEqu
ld hl, backup_prgm_name
call ti.Mov9ToOP1
call ti.ChkFindSym
Expand Down Expand Up @@ -303,6 +303,9 @@ hook_app_change:
jr .exitOS

_restoreAppvar:
ld hl, isAppvar
ld a, 0
ld (hl), a
pop hl, bc, af
ld hl, tempProg
call ti.Mov9ToOP1
Expand Down
82 changes: 82 additions & 0 deletions src/asm/getVATPtrs.asm
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,19 @@ include 'include/ti84pceg.inc'
arrayPtr := ti.appData

_getProgramPtrs:
ld iy, ti.flags
res 0, (iy + ti.asm_Flag1)
push ix
ld ix, 0
add ix, sp
ld hl, (ix + 6) ; get array
ld a, (ix + 9) ; ignore hidden programs?
pop ix
ld (arrayPtr), hl
ld hl, (ti.progPtr)
bit 0, a
jr z, .loop
set 0, (iy + ti.asm_Flag1)

.loop:
ld de, (ti.pTemp)
Expand All @@ -42,6 +48,22 @@ _getProgramPtrs:
jr nz, .skipEntry

.isProgram:
ld de, 7
or a, a
sbc hl, de
ld a, (hl)
add hl, de
push hl
call _checkHasHiddenHeader
pop hl
bit 0, b
jr nz, .skipEntry
bit 0, (iy + ti.asm_Flag1)
jr z, .loadAddress
cp a, 65
jr c, .skipEntry

.loadAddress:
ld de, (arrayPtr)
ex de, hl
ld (hl), de
Expand All @@ -61,6 +83,66 @@ _getProgramPtrs:
sbc hl, de
jr .loop

_checkHasHiddenHeader:
ld b, 0
ld de, 5
or a, a
sbc hl, de
ld a, (hl)
ld (ti.scrapMem + 2), a
ld de, (ti.scrapMem)
inc hl
ld d, (hl)
inc hl
ld e, (hl)
call ti.ChkInRam
jr z, .inRam
ld hl, 9
add hl, de
ex de, hl
ld hl, 0
ld a, (de)
ld l, a
add hl, de
ex de, hl
inc de

.inRam:
ld hl, 0
ld a, (de)
ld l, a
inc de
ld a, (de)
ld h, a ; get program size
inc de
call ti.ChkHLIs0
ret z
dec hl
call ti.ChkHLIs0
ret z
ex de, hl
ld a, $72 ; Ans token
cp a, (hl)
jr z, .maybeHidden
ld a, $AB ; rand token
cp a, (hl)
jr z, .maybeHidden
ret

.maybeHidden:
inc hl
ld a, $3F ; newline
cp a, (hl)
jr z, .isHidden
ld a, $3E ; colon
cp a, (hl)
jr z, .isHidden
ret

.isHidden:
ld b, 1
ret

_getAppVarPtrs:
push ix
ld ix, 0
Expand Down
4 changes: 3 additions & 1 deletion src/asm/getVATPtrs.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@
#ifndef GETVATPTRS_H
#define GETVATPTRS_H

#include <stdbool.h>

#ifdef __cplusplus
extern "C" {
#endif

void getProgramPtrs(void **programPtrs);
void getProgramPtrs(void **programPtrs, bool hideHiddenPrograms);

void getAppVarPtrs(void **appvarPtrs);

Expand Down
8 changes: 8 additions & 0 deletions src/asm/hooks.asm
Original file line number Diff line number Diff line change
Expand Up @@ -526,6 +526,14 @@ _triggerAPD:
or a, a
sbc hl, hl
ld (ti.asm_prgm_size), hl
ld hl, ti.pixelShadow
ld bc, 8400 * 3
call ti.MemClear
call ti.ClrTxtShd
ld hl, ti.textShadow
ld de, ti.cmdShadow
ld bc, $104
ldir
ld hl, _reloadHook
call ti.SetGetCSCHook
ld a, ti.kClear
Expand Down
46 changes: 30 additions & 16 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
* By RoccoLox Programs and TIny_Hacker
* Copyright 2022
* License: GPL-3.0
* Last Build: December 18, 2022
* Version: 0.81.2
* Last Build: December 19, 2022
* Version: 0.82
*
* --------------------------------------
**/
Expand Down Expand Up @@ -176,7 +176,7 @@ int main(void) {
void **programPtrs = malloc(NOPROGS * 3);
void **appvarPtrs = malloc(NOAPPVARS * 3);

getProgramPtrs(programPtrs);
getProgramPtrs(programPtrs, !showHiddenProg);
getAppVarPtrs(appvarPtrs);

bool infoOps[2] = {false, false}; // This will keep track of whether a program has been deleted or hidden
Expand Down Expand Up @@ -338,7 +338,7 @@ int main(void) {
programPtrs = malloc(NOPROGS * 3);
appvarPtrs = malloc(NOAPPVARS * 3);

getProgramPtrs(programPtrs);
getProgramPtrs(programPtrs, !showHiddenProg);
getAppVarPtrs(appvarPtrs);

ui_DrawAllFiles(colors, programPtrs, appvarPtrs, fileSelected, fileNumbers[directory], fileStartLoc, directory, displayCEaShell, showHiddenProg, showApps, showAppvars);
Expand Down Expand Up @@ -380,14 +380,21 @@ int main(void) {
gfx_Sprite_NoClip(buffer2, 160, 38);
}

gfx_BlitBuffer();
fullRedraw = true;

if (kb_IsDown(kb_KeyClear)) {
continue;
} else { // We write the preferences before exiting, so this is fine
util_WritePrefs(colors, transitionSpeed, is24Hour, displayCEaShell, getCSCHook, editArchivedProg, editLockedProg, showHiddenProg, showFileCount, hideBusyIndicator, lowercase, apdTimer, fileSelected, fileStartLoc, directory, showApps, showAppvars, &programPtrs, &appvarPtrs, fileNumbers, true); // Stores our data to the appvar before exiting
}

fullRedraw = true;
gfx_BlitBuffer();
free(programPtrs);
free(appvarPtrs);

programPtrs = malloc(NOPROGS * 3);
appvarPtrs = malloc(NOAPPVARS * 3);

getProgramPtrs(programPtrs, !showHiddenProg);
getAppVarPtrs(appvarPtrs);
} else if ((kb_IsDown(kb_KeyWindow) || kb_IsDown(kb_KeyZoom) || kb_IsDown(kb_KeyTrace) || kb_IsDown(kb_KeyAlpha)) && fileSelected >= 0 + ((directory == PROGRAMS_FOLDER) * (showApps + showAppvars)) + (directory != PROGRAMS_FOLDER)) { // Info menu
ui_StatusBar(colors[1], is24Hour, batteryStatus, "File Info", fileNumbers[directory], showFileCount);
gfx_BlitBuffer();
Expand Down Expand Up @@ -425,7 +432,7 @@ int main(void) {
programPtrs = malloc(NOPROGS * 3);
appvarPtrs = malloc(NOAPPVARS * 3);

getProgramPtrs(programPtrs);
getProgramPtrs(programPtrs, !showHiddenProg);
getAppVarPtrs(appvarPtrs);

while (kb_AnyKey());
Expand All @@ -436,7 +443,7 @@ int main(void) {
programPtrs = malloc(NOPROGS * 3);
appvarPtrs = malloc(NOAPPVARS * 3);

getProgramPtrs(programPtrs);
getProgramPtrs(programPtrs, !showHiddenProg);
getAppVarPtrs(appvarPtrs);

infoOps[1] = false;
Expand Down Expand Up @@ -479,7 +486,7 @@ int main(void) {
gfx_SetFontSpacing(defaultSpacing);
gfx_SetCharData(91, leftBracket);

menu_Settings(colors, &getCSCHook, &editArchivedProg, &editLockedProg, &showHiddenProg, &showFileCount, &hideBusyIndicator, &lowercase, &apdTimer);
menu_Settings(colors, &fileSelected, &fileStartLoc, &getCSCHook, &editArchivedProg, &editLockedProg, &showHiddenProg, &showFileCount, &hideBusyIndicator, &lowercase, &apdTimer);

defaultSpacing[91] = 8;
gfx_SetFontSpacing(defaultSpacing);
Expand Down Expand Up @@ -515,14 +522,21 @@ int main(void) {
gfx_Sprite_NoClip(buffer2, 160, 38);
}

fullRedraw = true;
gfx_BlitBuffer();

if (kb_IsDown(kb_KeyClear)) {
continue;
} else { // Same as Customize menu
util_WritePrefs(colors, transitionSpeed, is24Hour, displayCEaShell, getCSCHook, editArchivedProg, editLockedProg, showHiddenProg, showFileCount, hideBusyIndicator, lowercase, apdTimer, fileSelected, fileStartLoc, directory, showApps, showAppvars, &programPtrs, &appvarPtrs, fileNumbers, true);
}

fullRedraw = true;
gfx_BlitBuffer();
free(programPtrs);
free(appvarPtrs);

programPtrs = malloc(NOPROGS * 3);
appvarPtrs = malloc(NOAPPVARS * 3);

getProgramPtrs(programPtrs, !showHiddenProg);
getAppVarPtrs(appvarPtrs);
} else if (kb_IsDown(kb_Key2nd) || kb_IsDown(kb_KeyEnter)) {
if (fileSelected == 0 && directory == PROGRAMS_FOLDER) { // Toggle directories
if (showApps) {
Expand Down Expand Up @@ -638,7 +652,7 @@ int main(void) {
programPtrs = malloc(NOPROGS * 3);
appvarPtrs = malloc(NOAPPVARS * 3);

getProgramPtrs(programPtrs);
getProgramPtrs(programPtrs, !showHiddenProg);
getAppVarPtrs(appvarPtrs);
}
}
Expand Down
Loading

0 comments on commit 98ff8fb

Please sign in to comment.