]> Chaos Git - corbenik/corbenik.git/commitdiff
Fix up some stuff. Again. A lot is going wrong here.
authorchaoskagami <chaos.kagami@gmail.com>
Tue, 7 Jun 2016 16:03:19 +0000 (12:03 -0400)
committerchaoskagami <chaos.kagami@gmail.com>
Tue, 7 Jun 2016 16:04:34 +0000 (12:04 -0400)
host/bytecode_asm.py
patch/memexec.pco
source/interp.c
source/menu.c

index e5e2c385315792c105b4d4550e8fb2ddc63f8aac..27d1c3587d9f8ad84cd26d7286b9201cd47d108b 100755 (executable)
@@ -149,7 +149,9 @@ def parse_op(token_list, instr_offs):
                else:
                        tok = bytearray.fromhex(token_list[1])
                        num = struct.unpack(">H", tok)[0]
-                       return bytearray.fromhex("07") + struct.pack(">H", instr_offs[num])
+                       val = bytearray(struct.pack(">H", instr_offs[num]))
+                       val.reverse()
+                       return bytearray.fromhex("07") + val
        elif token_list[0] == "rewind":
                return bytearray.fromhex("08")
        elif token_list[0] == "and":
@@ -186,7 +188,9 @@ def parse_op(token_list, instr_offs):
                if s != 2:
                        syn_err("invalid number of arguments")
 
-               return bytearray.fromhex("0F") + bytearray.fromhex(token_list[1])
+               val = bytearray.fromhex(token_list[1])
+               val.reverse()
+               return bytearray.fromhex("0F") + val
        elif token_list[0] == "jmpeq":
                if s != 2:
                        syn_err("invalid number of arguments")
@@ -196,7 +200,8 @@ def parse_op(token_list, instr_offs):
                else:
                        tok = bytearray.fromhex(token_list[1])
                        num = struct.unpack(">H", tok)[0]
-                       return bytearray.fromhex("17") + struct.pack(">H", instr_offs[num])
+                       val = bytearray(struct.pack(">H", instr_offs[num]))
+                       return bytearray.fromhex("17") + val
        elif token_list[0] == "jmpne":
                if s != 2:
                        syn_err("invalid number of arguments")
@@ -206,7 +211,8 @@ def parse_op(token_list, instr_offs):
                else:
                        tok = bytearray.fromhex(token_list[1])
                        num = struct.unpack(">H", tok)[0]
-                       return bytearray.fromhex("27") + struct.pack(">H", instr_offs[num])
+                       val = bytearray(struct.pack(">H", instr_offs[num]))
+                       return bytearray.fromhex("27") + val
        elif token_list[0] == "jmplt":
                if s != 2:
                        syn_err("invalid number of arguments")
@@ -216,7 +222,8 @@ def parse_op(token_list, instr_offs):
                else:
                        tok = bytearray.fromhex(token_list[1])
                        num = struct.unpack(">H", tok)[0]
-                       return bytearray.fromhex("37") + struct.pack(">H", instr_offs[num])
+                       val = bytearray(struct.pack(">H", instr_offs[num]))
+                       return bytearray.fromhex("37") + val
        elif token_list[0] == "jmpgt":
                if s != 2:
                        syn_err("invalid number of arguments")
@@ -226,7 +233,8 @@ def parse_op(token_list, instr_offs):
                else:
                        tok = bytearray.fromhex(token_list[1])
                        num = struct.unpack(">H", tok)[0]
-                       return bytearray.fromhex("47") + struct.pack(">H", instr_offs[num])
+                       val = bytearray(struct.pack(">H", instr_offs[num]))
+                       return bytearray.fromhex("47") + val
        elif token_list[0] == "jmple":
                if s != 2:
                        syn_err("invalid number of arguments")
@@ -236,7 +244,8 @@ def parse_op(token_list, instr_offs):
                else:
                        tok = bytearray.fromhex(token_list[1])
                        num = struct.unpack(">H", tok)[0]
-                       return bytearray.fromhex("57") + struct.pack(">H", instr_offs[num])
+                       val = bytearray(struct.pack(">H", instr_offs[num]))
+                       return bytearray.fromhex("57") + val
        elif token_list[0] == "jmpge":
                if s != 2:
                        syn_err("invalid number of arguments")
@@ -246,7 +255,8 @@ def parse_op(token_list, instr_offs):
                else:
                        tok = bytearray.fromhex(token_list[1])
                        num = struct.unpack(">H", tok)[0]
-                       return bytearray.fromhex("67") + struct.pack(">H", instr_offs[num])
+                       val = bytearray(struct.pack(">H", instr_offs[num]))
+                       return bytearray.fromhex("67") + val
 
 def pad_zero_r(x, c):
        while len(x) < c:
@@ -295,11 +305,7 @@ with open(in_file, "r") as ins:
                for line in ins:
                        lines += 1
                        tokens = re.split("\s+", line.strip("\n")) # Split by whitespace.
-                       try:
-                               bytes = parse_op(tokens, None) # Parse.
-                       except:
-                               print("Error on line " + str(lines))
-                               exit(1)
+                       bytes = parse_op(tokens, None) # Parse.
                        if bytes:
                                offsets += [size]
                                size += len(bytes)
@@ -312,11 +318,7 @@ with open(in_file, "r") as ins:
                for line in ins:
                        lines += 1
                        tokens = re.split("\s+", line.strip("\n")) # Split by whitespace.
-                       try:
-                               bytes = parse_op(tokens, offsets) # Parse.
-                       except:
-                               print("Error on line " + str(lines))
-                               exit(1)
+                       bytes = parse_op(tokens, offsets) # Parse.
                        if bytes:
                                bytecode += bytes
 
index a61e1ab22e4c3e34373609fe77bdc45b02afe246..37ceca35a097f11b0ab8e1991967f0e631cb92ac 100644 (file)
@@ -4,16 +4,14 @@
 # $uuid 06
 # $flags devmode
 
-# Status: needs assembler to be fixed
-
-# Relative to NATIVE_FIRM, section index [1]
+# 0: Relative to NATIVE_FIRM, section index [1]
 rel native_s1
 
-# Find this byte string.
+# 1: Find this byte string.
 find 9705000015E40000
 
 # Move backwards until we find what we want.
-# LOOP:
+# LOOP (2):
 back   04
 test   16640100
 jmpne  0002
index 0eb06da012f57527f90cc01c34511731518f4ec2..24926c973d3e6e77d4ffdc6415a11074b7fe7f94 100644 (file)
@@ -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] << 8);
+                   code = bytecode + (code[0] + (code[1] << 8));
                 break;
             case OP_JMPEQ: // Jump to offset if equal
                 if (debug)
                     log("jmpeq\n");
                    code++;
                                if (eq)
-                       code = bytecode + code[1] + (code[0] << 8);
+                           code = bytecode + (code[0] + (code[1] << 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] << 8);
+                           code = bytecode + (code[0] + (code[1] << 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] << 8);
+                           code = bytecode + (code[0] + (code[1] << 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] << 8);
+                           code = bytecode + (code[0] + (code[1] << 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] << 8);
+                           code = bytecode + (code[0] + (code[1] << 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] << 8);
+                           code = bytecode + (code[0] + (code[1] << 8));
                                else
                                        code += 2;
                 break;
@@ -332,16 +332,15 @@ exec_bytecode(uint8_t *bytecode, uint16_t ver, uint32_t len, int debug)
                 if (debug)
                     log("seek\n");
                    code++;
-                   offset = ( code[3] + (code[2] << 8) + (code[1] << 16) + (code[0] << 24));
-                if (offset > current_mode->size) {
+                   offset = code[0] + (code[1] << 8) + (code[2] << 16) + (code[3] << 24);
+                if (offset > current_mode->size) { // Went out of bounds. Error.
 #ifndef LOADER
                                        fprintf(stderr, "%x", offset);
 #endif
-                    // Went out of bounds. Error.
                     abort("seeked out of bounds\n");
-                }
-                               else
-                                       code += 4;
+                               }
+
+                               code += 4;
                 break;
             case OP_NEXT:
                 if (debug)
index 04b0eeeefc704b430c3b108b163fa38e34c24bf5..488cabdb31b5ef11b776aa5dad21c525633bb9c5 100644 (file)
@@ -56,9 +56,6 @@ static struct options_s options[] = {
     { OPTION_OVERLY_VERBOSE, "Verbose", "Output more debug information than the average user needs.", boolean_val, 0, 0 },
     { OPTION_SAVE_LOGS, "Logging", "Save logs to the corbenik folder. Slows operation a bit.", boolean_val, 0, 0 },
 
-    { OPTION_RECONFIGURED, "Reconfigured (DO NOT UNCHECK)", "If patches were reconfigured, this will be set. Do not untick this if ticked.", boolean_val, 0,
-      0 },
-
     //    { OPTION_ARM9THREAD,        "ARM9 Thread", boolean_val, 0, 0 },
     //    { IGNORE_PATCH_DEPS,   "Ignore dependencies", boolean_val, 0, 0 },
     //    { IGNORE_BROKEN_SHIT,  "Allow unsafe options", boolean_val, 0, 0 },