]> Chaos Git - corbenik/corbenik.git/commitdiff
Fixups to the VM for AGB/TWL
authorchaoskagami <chaos.kagami@gmail.com>
Tue, 7 Jun 2016 14:46:37 +0000 (10:46 -0400)
committerchaoskagami <chaos.kagami@gmail.com>
Tue, 7 Jun 2016 14:52:57 +0000 (10:52 -0400)
host/bytecode_asm.py
source/firm/firm.c
source/interp.c
source/menu.c
source/std/abort.h

index a32945a9f58f2745b35becfd48c06f78d8db909e..e5e2c385315792c105b4d4550e8fb2ddc63f8aac 100755 (executable)
@@ -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")
index ec9de2e8116bc1d983813b3cbbd60a144cf3bdc9..bb09de9b861fe76c33ffa2c9b00ab20eddce9318 100644 (file)
@@ -331,6 +331,7 @@ boot_firm()
     wait();
 
     clear_disp(BOTTOM_SCREEN);
+       set_cursor(BOTTOM_SCREEN, 0, 0);
 
     fumount(); // Unmount SD. No longer needed.
 
index 6310d6bffec29b7ed0f5b299c03676b6e5619f5c..0eb06da012f57527f90cc01c34511731518f4ec2 100644 (file)
@@ -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");
                 }
index 676806ffb855c74cc7995da01f1e61fe3c38aa40..04b0eeeefc704b430c3b108b163fa38e34c24bf5 100644 (file)
@@ -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");
index 7cd45580ea39af48aa5dcc18f3ffc77bea2f0f87..f6e085f722ec52b333c8e55fff3065d27c83f465 100644 (file)
@@ -11,6 +11,7 @@ uint32_t wait_key();
         fprintf(stderr, x);                                                                                                                                    \
         wait_key();                                                                                                                                            \
         clear_disp(stderr);                                                                                                                                    \
+               set_cursor(stderr, 0, 0);                                                                                                                              \
         menu_poweroff();                                                                                                                                       \
     }