Skip to content

Commit

Permalink
Bug fixes + optimizations
Browse files Browse the repository at this point in the history
Co-Authored-By: RoccoLox Programs <[email protected]>
  • Loading branch information
TIny-Hacker and RoccoLoxPrograms committed Nov 14, 2024
1 parent 792be1f commit 4d28e7f
Show file tree
Hide file tree
Showing 10 changed files with 56 additions and 74 deletions.
14 changes: 13 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,18 @@

All notable changes to CEaShell will be documented in this file.

## [2.0.2] - 2024-11-13

### Changed
- Update to C toolchain version 12.1.
- Files can now be created when selecting folders.
- Save space by using ti.asm_data_ptr1 to preserve data pointers rather than recalculating them.

### Fixed
- Correct alpha jump behavior when selecting hidden files.
- Cursor goes off screen when pressing <kbd>up</kbd> and selecting the top-left most file.
- Wait for key press when programs exit with text on screen.

## [2.0.1] - 2024-09-11

### Added
Expand All @@ -24,7 +36,7 @@ All notable changes to CEaShell will be documented in this file.
- Using `expr(` or storing a string variable with an error to an equation no longer crashes after going to the error.
- Block running and editing of system variables in obscure contexts.
- Editing an archived program when a scrolling Ans value is freshly displayed on the homescreen.
- Conflict with GetCSC hook and apps that use ti.appData like ProbSim
- Conflict with GetCSC hook and apps that use ti.appData like ProbSim.

## [2.0.0] - 2024-07-08

Expand Down
2 changes: 1 addition & 1 deletion app_tools
Submodule app_tools updated 1 files
+1 −2 linker_script
2 changes: 1 addition & 1 deletion makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ NAME = CEaShell
APP_NAME = CEaShell
APP_INST_NAME = CEASHELL
APP_VERSION = 5.0.0.0000
CEASHELL_VERSION = 2.0.1
CEASHELL_VERSION = 2.0.2
APPVAR_VERSION = 0
DESCRIPTION = "(C) 2022-2024 RoccoLox & TIny_Hacker"
COMPRESSED = NO
Expand Down
19 changes: 2 additions & 17 deletions src/asm/editProgram.asm
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@ editProgram_prepAppVar:

.inRam:
ex de, hl
ld (ti.asm_data_ptr1), hl
ld de, 0
ld e, (hl)
inc hl
Expand All @@ -263,25 +264,9 @@ editProgram_prepAppVar:
ld a, ti.E_Memory
jp c, _asm_runProgram_error
call ti.CreateProg
push de
ld hl, backupAppVarName
call ti.Mov9ToOP1
call ti.ChkFindSym ; the AppVar could've moved if it was in RAM
call ti.ChkInRam
jr z, .inRam2
ld hl, 10
add hl, de
ld a, c
ld bc, 0
ld c, a
add hl, bc
ex de, hl

.inRam2:
ex de, hl
ld hl, (ti.asm_data_ptr1)
inc hl
inc hl
pop de
inc de
inc de
pop bc
Expand Down
12 changes: 4 additions & 8 deletions src/asm/fileOps.asm
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ _asm_fileOps_copyFile:
ld hl, (iy + 3) ; get name of prog to copy from
push af
call _asm_utils_findVar
ld (ti.asm_data_ptr1), de
or a, a
sbc hl, hl
ld a, (de)
Expand All @@ -155,14 +156,9 @@ _asm_fileOps_copyFile:
call ti.CreateVar
inc de
inc de
push de
ld a, (iy + 9)
ld hl, (iy + 3)
call _asm_utils_findVar
inc de
inc de
ex de, hl
pop de
ld hl, (ti.asm_data_ptr1)
inc hl
inc hl
pop bc
ld a, b
or a, c
Expand Down
55 changes: 22 additions & 33 deletions src/asm/runProgram.asm
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ include 'include/equates.inc'

extern _asm_apps_reloadApp
extern _asm_editProgram_goto
extern _asm_fileOps_getPrgmType
extern _asm_hooks_installStopHook
extern _asm_hooks_removeStopHook
extern _asm_hooks_installGetCSCHookCont
Expand Down Expand Up @@ -95,6 +96,7 @@ _asm_runProgram_main:
ld hl, ti.userMem
call ti.DelMem
call _asm_utils_findVar + 4
ld (ti.asm_data_ptr1), de
ld bc, 0
ld a, (de)
ld c, a
Expand Down Expand Up @@ -132,23 +134,11 @@ _asm_runProgram_main:
ld hl, ti.userMem
push hl
call ti.MemSet
call ti.ChkFindSym
call ti.ChkInRam
jr z, .inRamASM
ld hl, 10
add hl, de
ld a, c
ld bc, 0
ld c, a
add hl, bc
ex de, hl

.inRamASM:
inc de ; skip size + $EF7B
inc de
inc de
inc de
ex de, hl
ld hl, (ti.asm_data_ptr1)
inc hl ; skip size + $EF7B
inc hl
inc hl
inc hl
pop de
pop bc
ld a, b
Expand Down Expand Up @@ -277,20 +267,7 @@ _asm_runProgram_main:
ld hl, ti.userMem
push hl
call ti.MemSet
ld hl, backupPrgmName
call ti.Mov9ToOP1
call ti.ChkFindSym
call ti.ChkInRam
ex de, hl
jr z, .inRam2
ld de, 10
add hl, de
ld a, c
ld bc, 0
ld c, a
add hl, bc

.inRam2:
ld hl, (ti.asm_data_ptr1)
inc hl
inc hl
inc hl
Expand Down Expand Up @@ -338,6 +315,7 @@ runProgram_return:
inc hl
ld a, b
or a, c
dec bc
jr nz, .chkHomescreen
jr .chkDone

Expand Down Expand Up @@ -479,12 +457,23 @@ runProgram_showError:
ld hl, ti.basic_prog
ld a, (hl)
cp a, ti.ProtProgObj
ld hl, lockOnExit
ld (hl), false
ld a, false
ld (lockOnExit), a
jr nz, .notProtected
ld a, (isASM)
or a, a
jp nz, .onlyAllowQuit
call ti.Mov9ToOP1
call ti.ChkFindSym
push hl
call _asm_fileOps_getPrgmType
pop hl
cp a, typeBasic
jr z, .checkAllowLock
cp a, typeSrc
jp nz, .onlyAllowQuit

.checkAllowLock:
ld a, (editLockProgs)
bit 0, a
jp z, .onlyAllowQuit
Expand Down
8 changes: 4 additions & 4 deletions src/files.c
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ void files_Main(struct preferences_t *shellPrefs, struct context_t *shellContext
asm_editProgram_edit(fileInfo.name, fileInfo.shellType == CELTIC_TYPE, shellPrefs);
} else if (kb_IsDown(kb_KeyDel)) {
menu_DeleteFile(shellPrefs, shellContext, &fileInfo);
} else if (kb_IsDown(kb_KeyMode)) {
} else if (kb_IsDown(kb_KeyMode) && shellContext->directory != APPS_FOLDER) {
menu_CopyFile(shellPrefs, shellContext, &fileInfo);
} else if (kb_IsDown(kb_KeyStat)) {
gfx_SetColor(shellPrefs->bgColor);
Expand All @@ -193,11 +193,11 @@ void files_Main(struct preferences_t *shellPrefs, struct context_t *shellContext

if (kb_IsDown(kb_KeyUp)) {
if(shellContext->fileSelected) {
shellContext->fileSelected--;

if (!(shellContext->fileSelected % rows) && shellContext->fileSelected < shellContext->fileStartLoc && shellContext->fileStartLoc) {
if (shellContext->fileSelected == shellContext->fileStartLoc) {
shellContext->fileStartLoc -= rows;
}

shellContext->fileSelected--;
}
} else if (kb_IsDown(kb_KeyDown)) {
if ((shellContext->fileSelected + 1) % rows) {
Expand Down
4 changes: 2 additions & 2 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 - 2024
* License: GPL-3.0
* Last Build: October 6, 2024
* Version: 2.0.1
* Last Build: November 13, 2024
* Version: 2.0.2
*
* --------------------------------------
**/
Expand Down
6 changes: 1 addition & 5 deletions src/menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -422,10 +422,6 @@ bool menu_RenameFile(struct preferences_t *shellPrefs, struct context_t *shellCo
void menu_CopyFile(struct preferences_t *shellPrefs, struct context_t *shellContext, struct file_t *fileInfo) {
unsigned int *fileCount = &(shellContext->programCount) + shellContext->directory;

if (fileInfo->shellType == DIR_TYPE) {
return;
}

gfx_SetColor(shellPrefs->bgColor);
shapes_RoundRectangleFill(9, 56, 205, 208, 20);
#ifdef FR
Expand All @@ -434,7 +430,7 @@ void menu_CopyFile(struct preferences_t *shellPrefs, struct context_t *shellCont
bool createNew = menu_YesNo(shellPrefs, shellContext, 80, 79, "Copy", "Create New");
#endif

if (kb_IsDown(kb_KeyClear) || kb_IsDown(kb_KeyMode)) {
if (kb_IsDown(kb_KeyClear) || kb_IsDown(kb_KeyMode) || (!createNew && fileInfo->shellType == DIR_TYPE)) {
while (kb_AnyKey());
return;
}
Expand Down
8 changes: 6 additions & 2 deletions src/utility.c
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,8 @@ void util_AlphaSearch(struct preferences_t *shellPrefs, struct context_t *shellC
memcpy(currentName, asm_utils_getFileName(filePtrs[shellContext->fileSelected - dirCount]), 9);
}

*currentName += 64 * (*currentName < 'A'); // Ensure no issue with hidden files

bool reverse = (targetLetter <= *currentName);

while (!((shellContext->fileSelected - dirCount == 0 && reverse) || (shellContext->fileSelected == fileCount - 1 && !reverse))) {
Expand All @@ -355,8 +357,10 @@ void util_AlphaSearch(struct preferences_t *shellPrefs, struct context_t *shellC
memcpy(currentName, asm_utils_getFileName(filePtrs[shellContext->fileSelected - dirCount]), 9);
}

*currentName += 64 * (*currentName < 'A');

if (reverse) {
if ((*currentName + 64 * (*currentName < 'A')) < targetLetter) {
if (*currentName < targetLetter) {
reverse = false;
} else {
if (!(shellContext->fileSelected + 1 - shellContext->fileStartLoc)) {
Expand All @@ -366,7 +370,7 @@ void util_AlphaSearch(struct preferences_t *shellPrefs, struct context_t *shellC
shellContext->fileSelected -= 1;
}
} else {
if ((*currentName + 64 * (*currentName < 'A')) >= targetLetter) {
if (*currentName >= targetLetter) {
break;
} else {
if (shellContext->fileSelected - shellContext->fileStartLoc == rows * columns) {
Expand Down

0 comments on commit 4d28e7f

Please sign in to comment.