From: chaoskagami Date: Tue, 7 Jun 2016 14:46:37 +0000 (-0400) Subject: Fixups to the VM for AGB/TWL X-Git-Tag: v0.0.6~4 X-Git-Url: https://chaos.moe/g/?a=commitdiff_plain;h=e973c86005ff28431a91de9b105bee4ca600a51a;p=corbenik%2Fcorbenik.git Fixups to the VM for AGB/TWL --- diff --git a/host/bytecode_asm.py b/host/bytecode_asm.py index a32945a..e5e2c38 100755 --- a/host/bytecode_asm.py +++ b/host/bytecode_asm.py @@ -186,9 +186,7 @@ def parse_op(token_list, instr_offs): if s != 2: syn_err("invalid number of arguments") - v = bytearray.fromhex(token_list[1]) - v.reverse() - return bytearray.fromhex("0F") + v + return bytearray.fromhex("0F") + bytearray.fromhex(token_list[1]) elif token_list[0] == "jmpeq": if s != 2: syn_err("invalid number of arguments") diff --git a/source/firm/firm.c b/source/firm/firm.c index ec9de2e..bb09de9 100644 --- a/source/firm/firm.c +++ b/source/firm/firm.c @@ -331,6 +331,7 @@ boot_firm() wait(); clear_disp(BOTTOM_SCREEN); + set_cursor(BOTTOM_SCREEN, 0, 0); fumount(); // Unmount SD. No longer needed. diff --git a/source/interp.c b/source/interp.c index 6310d6b..0eb06da 100644 --- a/source/interp.c +++ b/source/interp.c @@ -63,10 +63,10 @@ exec_bytecode(uint8_t *bytecode, uint16_t ver, uint32_t len, int debug) modes[0].size = FCRAM_SPACING; // NATIVE_FIRM modes[1].memory = (uint8_t *)agb_firm_loc; - modes[1].size = FCRAM_SPACING; // AGB_FIRM + modes[1].size = FCRAM_SPACING * 2; // AGB_FIRM modes[2].memory = (uint8_t *)twl_firm_loc; - modes[2].size = FCRAM_SPACING; // TWL_FIRM + modes[2].size = FCRAM_SPACING * 2; // TWL_FIRM // NATIVE_FIRM Process9 (This is also the default mode.) modes[3].memory = (uint8_t *)firm_p9_exefs + sizeof(exefs_h) + firm_p9_exefs->fileHeaders[0].offset; @@ -209,14 +209,14 @@ exec_bytecode(uint8_t *bytecode, uint16_t ver, uint32_t len, int debug) if (debug) log("jmp\n"); code++; - code = bytecode + code[1] + (code[0] * 0x100); + code = bytecode + code[1] + (code[0] << 8); break; case OP_JMPEQ: // Jump to offset if equal if (debug) log("jmpeq\n"); code++; if (eq) - code = bytecode + code[1] + (code[0] * 0x100); + code = bytecode + code[1] + (code[0] << 8); else code += 2; break; @@ -225,7 +225,7 @@ exec_bytecode(uint8_t *bytecode, uint16_t ver, uint32_t len, int debug) log("jmpne\n"); code++; if (!eq) - code = bytecode + code[1] + (code[0] * 0x100); + code = bytecode + code[1] + (code[0] << 8); else code += 2; break; @@ -234,7 +234,7 @@ exec_bytecode(uint8_t *bytecode, uint16_t ver, uint32_t len, int debug) log("jmplt\n"); code++; if (lt) - code = bytecode + code[1] + (code[0] * 0x100); + code = bytecode + code[1] + (code[0] << 8); else code += 2; break; @@ -243,7 +243,7 @@ exec_bytecode(uint8_t *bytecode, uint16_t ver, uint32_t len, int debug) log("jmpgt\n"); code++; if (gt) - code = bytecode + code[1] + (code[0] * 0x100); + code = bytecode + code[1] + (code[0] << 8); else code += 2; break; @@ -252,7 +252,7 @@ exec_bytecode(uint8_t *bytecode, uint16_t ver, uint32_t len, int debug) log("jmple\n"); code++; if (lt || eq) - code = bytecode + code[1] + (code[0] * 0x100); + code = bytecode + code[1] + (code[0] << 8); else code += 2; break; @@ -261,7 +261,7 @@ exec_bytecode(uint8_t *bytecode, uint16_t ver, uint32_t len, int debug) log("jmpge\n"); code++; if (gt || eq) - code = bytecode + code[1] + (code[0] * 0x100); + code = bytecode + code[1] + (code[0] << 8); else code += 2; break; @@ -332,8 +332,11 @@ exec_bytecode(uint8_t *bytecode, uint16_t ver, uint32_t len, int debug) if (debug) log("seek\n"); code++; - offset = code[3] + (code[2] * 0x100) + (code[1] * 0x10000) + (code[0] * 0x1000000); + offset = ( code[3] + (code[2] << 8) + (code[1] << 16) + (code[0] << 24)); if (offset > current_mode->size) { +#ifndef LOADER + fprintf(stderr, "%x", offset); +#endif // Went out of bounds. Error. abort("seeked out of bounds\n"); } diff --git a/source/menu.c b/source/menu.c index 676806f..04b0eee 100644 --- a/source/menu.c +++ b/source/menu.c @@ -303,9 +303,10 @@ menu_poweroff() int menu_main() { + // TODO - Stop using different menu code here. set_cursor(TOP_SCREEN, 0, 0); - const char *list[] = { "Options", "Patches", "Info", "Help/Readme", "Reset", "Power off", "Boot firmware" }; + const char *list[] = { "Options", "Patches", "Info", "Help/Readme", "Reboot", "Power off", "Boot Firmware" }; int menu_max = 7; header("A:Enter DPAD:Nav"); diff --git a/source/std/abort.h b/source/std/abort.h index 7cd4558..f6e085f 100644 --- a/source/std/abort.h +++ b/source/std/abort.h @@ -11,6 +11,7 @@ uint32_t wait_key(); fprintf(stderr, x); \ wait_key(); \ clear_disp(stderr); \ + set_cursor(stderr, 0, 0); \ menu_poweroff(); \ }