Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved Receive Variables list #491

Merged
merged 8 commits into from
Aug 25, 2024
4 changes: 3 additions & 1 deletion core/debug/debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,9 @@ void debug_open(int reason, uint32_t data) {
(mem_peek_byte(DBG_BASIC_CMDFLAGS) & DBG_BASIC_CMDEXEC_BIT)) {

// check current pc for instruction "bit 1,(iy+$36)"
if(*(uint32_t*)phys_mem_ptr(cpu.registers.PC - 4, 4) == 0x4E36CBFD) {
static const uint8_t instr[] = { 0xFD, 0xCB, 0x36, 0x4E };
const void *ptr = phys_mem_ptr(cpu.registers.PC - sizeof(instr), sizeof(instr));
if(ptr && !memcmp(ptr, instr, sizeof(instr))) {
reason = DBG_BASIC_CURPC_WRITE;
}
} else {
Expand Down
72 changes: 58 additions & 14 deletions core/vat.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const char *calc_var_type_names[0x40] = {
"Temp Program",
"Group",
"Real Fraction",
"Unknown #1",
"Mixed Fraction",
"Image",
"Complex Fraction",
"Real Radical",
Expand All @@ -40,14 +40,17 @@ const char *calc_var_type_names[0x40] = {
"Complex Pi Fraction",
"Real Pi",
"Real Pi Fraction",
"Unknown #2",
"Unknown #1",
"Operating System",
"Flash App",
"Certificate",
"Unknown #3",
"AppID List",
"Certificate Memory",
"Unknown #4",
"Unit Certificate",
"Clock",
"Unknown #2",
"Unknown #3",
"Unknown #4",
"Unknown #5",
"Unknown #6",
"Unknown #7",
Expand All @@ -65,11 +68,8 @@ const char *calc_var_type_names[0x40] = {
"Unknown #19",
"Unknown #20",
"Unknown #21",
"Unknown #22",
"Unknown #23",
"Unknown #24",
"Flash License",
"Unknown #25",
"Unknown #22",
};

static char hex_char(uint8_t nibble) {
Expand All @@ -81,7 +81,7 @@ static void hex_byte(char **dest, uint8_t byte) {
*(*dest)++ = hex_char(byte >> 0);
}

const char *calc_var_name_to_utf8(uint8_t name[8], uint8_t namelen, bool named) {
const char *calc_var_name_to_utf8(const uint8_t name[8], uint8_t namelen, bool named) {
static char buffer[26];
char *dest = buffer;
uint8_t i = 0;
Expand Down Expand Up @@ -426,19 +426,63 @@ bool vat_search_next(calc_var_t *var) {
}

bool vat_search_find(const calc_var_t *target, calc_var_t *result) {
/* Ignore linked formula when comparing list names */
bool isList = calc_var_is_list(target);
vat_search_init(result);
while (vat_search_next(result)) {
if (result->type == target->type &&
result->namelen == target->namelen &&
!memcmp(result->name, target->name, target->namelen - isList)) {
if (0 == calc_var_compare_names(target, result)) {
return true;
}
}
return false;
}

int calc_var_compare_names(const calc_var_t *left, const calc_var_t *right) {
bool leftIsAns = !left->named & (left->name[0] == 0x72);
bool rightIsAns = !right->named & (right->name[0] == 0x72);
if (leftIsAns || rightIsAns) {
return leftIsAns - rightIsAns;
}
/* Ignore linked formula when comparing list names */
uint8_t leftNameLen = left->namelen - calc_var_is_list(left);
uint8_t rightNameLen = right->namelen - calc_var_is_list(right);
int cmp = memcmp(left->name, right->name, leftNameLen < rightNameLen ? leftNameLen : rightNameLen);
if (cmp != 0) {
return cmp;
}
cmp = leftNameLen - rightNameLen;
if (cmp != 0) {
return cmp;
}
if (likely(left->type == right->type)) {
return 0;
}
return calc_var_normalized_type(left->type) - calc_var_normalized_type(right->type);
}

calc_var_type_t calc_var_normalized_type(calc_var_type_t type) {
switch (type) {
case CALC_VAR_TYPE_REAL:
case CALC_VAR_TYPE_REAL_FRAC:
case CALC_VAR_TYPE_MIXED_FRAC:
case CALC_VAR_TYPE_REAL_RADICAL:
case CALC_VAR_TYPE_REAL_PI:
case CALC_VAR_TYPE_REAL_PI_FRAC:
case CALC_VAR_TYPE_CPLX:
case CALC_VAR_TYPE_CPLX_FRAC:
case CALC_VAR_TYPE_CPLX_RADICAL:
case CALC_VAR_TYPE_CPLX_PI:
case CALC_VAR_TYPE_CPLX_PI_FRAC:
return CALC_VAR_TYPE_REAL;
case CALC_VAR_TYPE_REAL_LIST:
case CALC_VAR_TYPE_CPLX_LIST:
return CALC_VAR_TYPE_REAL_LIST;
case CALC_VAR_TYPE_PROG:
case CALC_VAR_TYPE_PROT_PROG:
return CALC_VAR_TYPE_PROG;
default:
return type;
}
}

bool calc_var_is_list(const calc_var_t *var) {
return var && (var->type == CALC_VAR_TYPE_REAL_LIST || var->type == CALC_VAR_TYPE_CPLX_LIST);
}
Expand Down
4 changes: 3 additions & 1 deletion core/vat.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ typedef enum calc_var_type {
} calc_var_type_t;

extern const char *calc_var_type_names[0x40];
const char *calc_var_name_to_utf8(uint8_t name[8], uint8_t namelen, bool named);
const char *calc_var_name_to_utf8(const uint8_t name[8], uint8_t namelen, bool named);

typedef struct calc_var {
uint32_t vat, address;
Expand All @@ -68,6 +68,8 @@ void vat_search_init(calc_var_t *);
bool vat_search_next(calc_var_t *);
bool vat_search_find(const calc_var_t *, calc_var_t *);

int calc_var_compare_names(const calc_var_t *, const calc_var_t *);
calc_var_type_t calc_var_normalized_type(calc_var_type_t);
bool calc_var_is_list(const calc_var_t *);
bool calc_var_is_prog(const calc_var_t *);
bool calc_var_is_asmprog(const calc_var_t *);
Expand Down
2 changes: 2 additions & 0 deletions gui/qt/CEmu.pro
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,7 @@ SOURCES += \
tivars_lib_cpp/src/TypeHandlers/STH_ExactRadical.cpp \
tivars_lib_cpp/src/TypeHandlers/STH_ExactPi.cpp \
tivars_lib_cpp/src/TypeHandlers/STH_FP.cpp \
vartablemodel.cpp \
visualizerwidget.cpp \
debugger/visualizerdisplaywidget.cpp \
memorywidget.cpp \
Expand Down Expand Up @@ -368,6 +369,7 @@ HEADERS += \
tivars_lib_cpp/src/TIVarType.h \
tivars_lib_cpp/src/TIVarTypes.h \
tivars_lib_cpp/src/TypeHandlers/TypeHandlers.h \
vartablemodel.h \
visualizerwidget.h \
debugger/visualizerdisplaywidget.h \
archive/extractor.h \
Expand Down
1 change: 1 addition & 0 deletions gui/qt/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ set(CEmu_Sources
tivars_lib_cpp/src/TypeHandlers/TypeHandlers.h
tivars_lib_cpp/src/tivarslib_utils.cpp tivars_lib_cpp/src/tivarslib_utils.h
utils.cpp utils.h
vartablemodel.cpp vartablemodel.h
visualizerwidget.cpp visualizerwidget.h
${CEmu_Resources}
)
Expand Down
8 changes: 5 additions & 3 deletions gui/qt/basicdebugger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,6 @@ void MainWindow::debugBasic(bool enable) {

// disable other debugger / var list
ui->buttonSend->setEnabled(!enable);
ui->buttonReceiveFiles->setEnabled(!enable);
ui->buttonReceiveFile->setEnabled(!enable);
ui->buttonResendFiles->setEnabled(!enable);
ui->buttonRun->setEnabled(!enable);
}
Expand All @@ -79,7 +77,7 @@ void MainWindow::debugBasicDisable() {
void MainWindow::debugBasicToggle() {
bool state = guiDebugBasic;

if (guiDebug || guiReceive || guiSend) {
if (guiDebug || guiSend) {
return;
}

Expand Down Expand Up @@ -388,6 +386,10 @@ MainWindow::debug_basic_status_t MainWindow::debugBasicUpdate(bool force) {
return DBG_BASIC_NO_EXECUTING_PRGM;
}

if (guiReceive) {
varShow();
}

const int begPC = static_cast<int>(mem_peek_long(DBG_BASIC_BEGPC));
const int curPC = static_cast<int>(mem_peek_long(DBG_BASIC_CURPC));
const int endPC = static_cast<int>(mem_peek_long(DBG_BASIC_ENDPC));
Expand Down
12 changes: 4 additions & 8 deletions gui/qt/debugger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -638,11 +638,7 @@
ui->fpStack->setEnabled(state && m_normalOs);

ui->buttonSend->setEnabled(!state);
ui->buttonRefreshList->setEnabled(!state);
ui->emuVarView->setEnabled(!state);
ui->buttonResendFiles->setEnabled(!state);
ui->buttonReceiveFiles->setEnabled(!state && guiReceive);
ui->buttonReceiveFile->setEnabled(!state && guiReceive);

QList<QDockWidget*> docks = findChildren<QDockWidget*>();
foreach (QDockWidget* dock, docks) {
Expand Down Expand Up @@ -676,10 +672,6 @@
return;
}

if (guiReceive) {
varToggle();
}

if (state) {
debugSync();
debugDisable();
Expand Down Expand Up @@ -870,6 +862,10 @@
disasmUpdateAddr(m_prevDisasmAddr = cpu.registers.PC, true);

memUpdate();

if (guiReceive) {
varShow();
}
}

// ------------------------------------------------
Expand Down Expand Up @@ -2023,7 +2019,7 @@
if (memWidget == Q_NULLPTR) {
for (HexWidget *edit : ui->debugMemoryWidget->findChildren<HexWidget*>()) {
uint32_t offset = address - edit->getBase();
if (offset < edit->getSize()) {

Check warning on line 2022 in gui/qt/debugger.cpp

View workflow job for this annotation

GitHub Actions / Build: ubuntu-20.04 - Qt6-Dynamic

comparison of integer expressions of different signedness: ‘uint32_t’ {aka ‘unsigned int’} and ‘int’ [-Wsign-compare]

Check warning on line 2022 in gui/qt/debugger.cpp

View workflow job for this annotation

GitHub Actions / Build: ubuntu-20.04 - Qt6

comparison of integer expressions of different signedness: ‘uint32_t’ {aka ‘unsigned int’} and ‘int’ [-Wsign-compare]

Check warning on line 2022 in gui/qt/debugger.cpp

View workflow job for this annotation

GitHub Actions / Build: macos-12 Qt5_intel

comparison of integers of different signs: 'uint32_t' (aka 'unsigned int') and 'int' [-Wsign-compare]

Check warning on line 2022 in gui/qt/debugger.cpp

View workflow job for this annotation

GitHub Actions / Build: macos-13 Qt6_intel

comparison of integers of different signs: 'uint32_t' (aka 'unsigned int') and 'int' [-Wsign-compare]
edit->setOffset(offset);
memWidget = edit;
didGoto = true;
Expand Down Expand Up @@ -2210,7 +2206,7 @@
if (name == QStringLiteral("rregView"))
t = QStringLiteral("r:\t") + val;

QToolTip::showText(static_cast<QMouseEvent*>(e)->globalPos(), t, widget, widget->rect());

Check warning on line 2209 in gui/qt/debugger.cpp

View workflow job for this annotation

GitHub Actions / Build: ubuntu-20.04 - Qt6-Dynamic

‘QPoint QMouseEvent::globalPos() const’ is deprecated: Use globalPosition() [-Wdeprecated-declarations]

Check warning on line 2209 in gui/qt/debugger.cpp

View workflow job for this annotation

GitHub Actions / Build: ubuntu-20.04 - Qt6

‘QPoint QMouseEvent::globalPos() const’ is deprecated: Use globalPosition() [-Wdeprecated-declarations]

Check warning on line 2209 in gui/qt/debugger.cpp

View workflow job for this annotation

GitHub Actions / Build: macos-13 Qt6_intel

'globalPos' is deprecated: Use globalPosition() [-Wdeprecated-declarations]
}
return QMainWindow::eventFilter(obj, e);
}
Expand Down
Binary file modified gui/qt/i18n/es_ES.qm
Binary file not shown.
Loading
Loading