Skip to content

Commit

Permalink
[core] remove gui_console_err_printf
Browse files Browse the repository at this point in the history
  • Loading branch information
mateoconlechuga committed Oct 4, 2024
1 parent 6172664 commit 45658ee
Show file tree
Hide file tree
Showing 10 changed files with 26 additions and 34 deletions.
2 changes: 1 addition & 1 deletion core/asic.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ static asic_rev_t report_reset(asic_rev_t loaded_rev, bool* python) {
}
}
else {
gui_console_err_printf("[CEmu] Could not determine boot code version.\n");
gui_console_printf("[CEmu] Could not determine boot code version.\n");
}
gui_console_printf("[CEmu] Default ASIC revision is Rev %c.\n", "AIM"[(int)default_rev - 1]);

Expand Down
2 changes: 1 addition & 1 deletion core/cpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ static uint8_t cpu_read_in(uint16_t pio) {
static void cpu_write_out(uint16_t pio, uint8_t value) {
if (unprivileged_code()) {
control.protectionStatus |= 2;
gui_console_err_printf("[CEmu] NMI reset cause by an out instruction in unprivileged code.\n");
gui_console_printf("[CEmu] NMI reset cause by an out instruction in unprivileged code.\n");
cpu_nmi();
}
port_write_byte(pio, value);
Expand Down
22 changes: 11 additions & 11 deletions core/emu.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,22 +70,22 @@ emu_state_t emu_load(emu_data_t type, const char *path) {
gui_console_printf("[CEmu] Loading Emulator Image...\n");

if (!file) {
gui_console_err_printf("[CEmu] Image file nonexistent.\n");
gui_console_printf("[CEmu] Image file nonexistent.\n");
goto rerr;
}

if (fread(&version, sizeof(version), 1, file) != 1) goto rerr;

if (version != IMAGE_VERSION) {
gui_console_err_printf("[CEmu] Error in versioning.\n");
gui_console_printf("[CEmu] Error in versioning.\n");
goto rerr;
}

asic_free();
asic_init();

if (!asic_restore(file)) {
gui_console_err_printf("[CEmu] Error reading image.\n");
gui_console_printf("[CEmu] Error reading image.\n");
goto rerr;
}

Expand All @@ -109,14 +109,14 @@ emu_state_t emu_load(emu_data_t type, const char *path) {
file = fopen_utf8(path, "rb");

if (!file) {
gui_console_err_printf("[CEmu] ROM file nonexistent.\n");
gui_console_printf("[CEmu] ROM file nonexistent.\n");
goto rerr;
}

if (fseek(file, 0L, SEEK_END) < 0) goto rerr;
size = (size_t)ftell(file);
if (size > SIZE_FLASH) {
gui_console_err_printf("[CEmu] Invalid ROM size (%u bytes | max %u bytes)\n", (unsigned int)size, SIZE_FLASH);
gui_console_printf("[CEmu] Invalid ROM size (%u bytes | max %u bytes)\n", (unsigned int)size, SIZE_FLASH);
goto rerr;
}
rewind(file);
Expand All @@ -125,7 +125,7 @@ emu_state_t emu_load(emu_data_t type, const char *path) {
asic_init();

if (fread(mem.flash.block, size, 1, file) != 1) {
gui_console_err_printf("[CEmu] Error reading ROM image\n");
gui_console_printf("[CEmu] Error reading ROM image\n");
goto rerr;
}

Expand Down Expand Up @@ -189,7 +189,7 @@ emu_state_t emu_load(emu_data_t type, const char *path) {
set_device_type(device_type);
} else {
set_device_type(TI84PCE);
gui_console_err_printf("[CEmu] Could not determine device device_type.\n");
gui_console_printf("[CEmu] Could not determine device device_type.\n");
state = EMU_STATE_NOT_A_CE;
}

Expand All @@ -198,7 +198,7 @@ emu_state_t emu_load(emu_data_t type, const char *path) {
size_t size;

if (mem.ram.block == NULL) {
gui_console_err_printf("[CEmu] Emulator inactive, cannot load RAM file.\n");
gui_console_printf("[CEmu] Emulator inactive, cannot load RAM file.\n");
goto rerr;
}

Expand All @@ -207,19 +207,19 @@ emu_state_t emu_load(emu_data_t type, const char *path) {

file = fopen_utf8(path, "rb");
if (!file) {
gui_console_err_printf("[CEmu] RAM file nonexistent.\n");
gui_console_printf("[CEmu] RAM file nonexistent.\n");
goto rerr;
}
if (fseek(file, 0L, SEEK_END) < 0) goto rerr;
size = (size_t)ftell(file);
if (size > SIZE_RAM) {
gui_console_err_printf("[CEmu] Invalid RAM size (%u bytes | max %u bytes)\n", (unsigned int)size, SIZE_RAM);
gui_console_printf("[CEmu] Invalid RAM size (%u bytes | max %u bytes)\n", (unsigned int)size, SIZE_RAM);
goto rerr;
}
rewind(file);

if (fread(mem.ram.block, 1, size, file) != size) {
gui_console_err_printf("[CEmu] Error reading RAM image.\n", (unsigned int)size, SIZE_RAM);
gui_console_printf("[CEmu] Error reading RAM image.\n", (unsigned int)size, SIZE_RAM);
goto rerr;
}

Expand Down
1 change: 0 additions & 1 deletion core/emu.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ void emu_exit(void); /* exit emulation */
/* if you want debugging support, don't forget about the debug callbacks as well */
void gui_console_clear(void); /* sent to clear the console */
void gui_console_printf(const char *format, ...); /* printf from the core to stdout */
void gui_console_err_printf(const char *format, ...); /* printf from the core to stderr */

/* called at reset or state load, indicates hardware info and allows specifying a revision on reset
* params:
Expand Down
2 changes: 1 addition & 1 deletion core/lcd.c
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,7 @@ static void lcd_write(const uint16_t pio, const uint8_t value, bool poke) {
} else if (index == 0x010) {
write8(lcd.upbase, bit_offset, value);
if (lcd.upbase & 7) {
gui_console_err_printf("[CEmu] Warning: Aligning LCD panel\n");
gui_console_printf("[CEmu] Warning: Aligning LCD panel\n");
}
lcd.upbase &= ~7U;
lcd_update();
Expand Down
8 changes: 4 additions & 4 deletions core/link.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ int EMSCRIPTEN_KEEPALIVE emu_send_variables(const char *const *files, int num, i
const size_t argv_size = (1+num) * sizeof(char *);
char **argv = malloc(argv_size);
if (!argv) {
gui_console_err_printf("[CEmu] Transfer Error: can't allocate transfer commands... wut\n");
gui_console_printf("[CEmu] Transfer Error: can't allocate transfer commands... wut\n");
return LINK_ERR;
}

Expand All @@ -42,15 +42,15 @@ int EMSCRIPTEN_KEEPALIVE emu_send_variables(const char *const *files, int num, i
const size_t arg_size = 7 + strlen(files[i]) + 1;
argv[i+1] = malloc(arg_size);
if (!argv[i+1]) {
gui_console_err_printf("[CEmu] Transfer Error: can't allocate transfer command... wut\n");
gui_console_printf("[CEmu] Transfer Error: can't allocate transfer command... wut\n");
num = i;
goto alloc_err;
}
snprintf(argv[i+1], arg_size, "send%s:%s", locations[location], files[i]);
}
err = usb_plug_device(1+num, (const char *const *)argv, progress_handler, progress_context);
if (err != 0) {
gui_console_err_printf("[CEmu] USB transfer error code %d.\n", err);
gui_console_printf("[CEmu] USB transfer error code %d.\n", err);
}
else {
gui_console_printf("[CEmu] USB transfer(s) starting...\n");
Expand Down Expand Up @@ -128,7 +128,7 @@ int emu_receive_variable(const char *file, const calc_var_t *vars, int count) {
w_err:
(void)fclose(fd);
if(remove(file)) {
gui_console_err_printf("[CEmu] Transfer Error: Please contact the developers\n");
gui_console_printf("[CEmu] Transfer Error: Please contact the developers\n");
}
return LINK_ERR;
}
8 changes: 4 additions & 4 deletions core/mem.c
Original file line number Diff line number Diff line change
Expand Up @@ -736,13 +736,13 @@ void mem_write_cpu(uint32_t addr, uint8_t value) {

if (addr == control.stackLimit) {
control.protectionStatus |= 1;
gui_console_err_printf("[CEmu] NMI reset caused by writing to the stack limit at address %#06x. Hint: Probably a stack overflow (aka too much recursion).\n", addr);
gui_console_printf("[CEmu] NMI reset caused by writing to the stack limit at address %#06x. Hint: Probably a stack overflow (aka too much recursion).\n", addr);
cpu_nmi();
} /* writes to stack limit succeed */

if (addr >= control.protectedStart && addr <= control.protectedEnd && unprivileged_code()) {
control.protectionStatus |= 2;
gui_console_err_printf("[CEmu] NMI reset caused by writing to protected memory (%#06x through %#06x) at address %#06x from unprivileged code.\n", control.protectedStart, control.protectedEnd, addr);
gui_console_printf("[CEmu] NMI reset caused by writing to protected memory (%#06x through %#06x) at address %#06x from unprivileged code.\n", control.protectedStart, control.protectedEnd, addr);
cpu_nmi();
} else { /* writes to protected memory are ignored */
switch((addr >> 20) & 0xF) {
Expand All @@ -751,7 +751,7 @@ void mem_write_cpu(uint32_t addr, uint8_t value) {
case 0x4: case 0x5: case 0x6: case 0x7:
if (unprivileged_code()) {
control.protectionStatus |= 2;
gui_console_err_printf("[CEmu] NMI reset caused by writing to flash at address %#06x from unprivileged code. Hint: Possibly a null pointer dereference.\n", addr);
gui_console_printf("[CEmu] NMI reset caused by writing to flash at address %#06x from unprivileged code. Hint: Possibly a null pointer dereference.\n", addr);
cpu_nmi();
} else {
mem_write_flash(addr, value);
Expand Down Expand Up @@ -796,7 +796,7 @@ void mem_write_cpu(uint32_t addr, uint8_t value) {
debug.bufferErr[debug.bufErrPos] = (char)value;
debug.bufErrPos = (debug.bufErrPos + 1) % SIZEOF_DBG_BUFFER;
if (!value) {
gui_console_err_printf("%s", debug.bufferErr);
gui_console_printf("%s", debug.bufferErr);
debug.bufErrPos = 0;
}
break;
Expand Down
2 changes: 1 addition & 1 deletion core/os/os-emscripten.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ void gui_console_printf(const char *fmt, ...) {
va_end(ap);
}

void gui_console_err_printf(const char *fmt, ...) {
void gui_console_printf(const char *fmt, ...) {
va_list ap;
va_start(ap, fmt);
vfprintf(stderr, fmt, ap);
Expand Down
6 changes: 3 additions & 3 deletions core/usb/dusb.c
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@ static dusb_state_t dusb_detect(dusb_context_t *context) {
return DUSB_VAR_NEXT_STATE;
}
invalid:
gui_console_err_printf("[CEmu] Transfer warning: file parsing failed\n");
gui_console_printf("[CEmu] Transfer warning: file parsing failed\n");
return DUSB_NEXT_COMMAND_STATE;
}

Expand Down Expand Up @@ -1031,15 +1031,15 @@ static int dusb_transition(usb_event_t *event, dusb_state_t state) {
if (context->command->vartype == CALC_VAR_TYPE_FLASH_APP || context->start == context->command->file_length - 2) {
state = DUSB_NEXT_COMMAND_STATE;
} else if (!dusb_detect_var(context)) {
gui_console_err_printf("[CEmu] Transfer warning: variable parsing failed\n");
gui_console_printf("[CEmu] Transfer warning: variable parsing failed\n");
state = DUSB_NEXT_COMMAND_STATE;
} else {
gui_console_printf("[CEmu] Transferring variable: %.*s\n", context->command->varname_utf8_length, context->command->varname_utf8);
state = DUSB_VAR_PING_WAIT_STATE;
}
continue;
case DUSB_INVALID_STATE:
gui_console_err_printf("[CEmu] USB transfer failed, stopping activity\n");
gui_console_printf("[CEmu] USB transfer failed, stopping activity\n");
event->type = USB_DESTROY_EVENT;
break;
}
Expand Down
7 changes: 0 additions & 7 deletions gui/qt/emuthread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,6 @@ void gui_console_printf(const char *format, ...) {
va_end(args);
}

void gui_console_err_printf(const char *format, ...) {
va_list args;
va_start(args, format);
emu->writeConsole(EmuThread::ConsoleErr, format, args);
va_end(args);
}

void gui_debug_open(int reason, uint32_t data) {
emu->debugOpen(reason, data);
}
Expand Down

0 comments on commit 45658ee

Please sign in to comment.