diff --git a/src/main/kotlin/rhmodding/tickompiler/Functions.kt b/src/main/kotlin/rhmodding/tickompiler/Functions.kt index 73db4b6..693ea8d 100644 --- a/src/main/kotlin/rhmodding/tickompiler/Functions.kt +++ b/src/main/kotlin/rhmodding/tickompiler/Functions.kt @@ -250,16 +250,25 @@ class BytesFunction : Function(-1, "bytes", 1..Int.MAX_VALUE) { } override fun produceTickflow(state: DecompilerState, opcode: Long, specialArg: Long, args: LongArray, comments: CommentType, specialArgStrings: Map): String { - return this.name + " " + argsToTickflowArgs(args, specialArgStrings) + if (args.size == 0) { + return this.name + } else { + return this.name + " " + argsToTickflowArgs(args, specialArgStrings) + } } } class OpcodeFunction : Function(-1, "opcode", 0..Integer.MAX_VALUE) { override fun produceTickflow(state: DecompilerState, opcode: Long, specialArg: Long, args: LongArray, comments: CommentType, specialArgStrings: Map): String { - return getHex(opcode) + + if (args.size == 0) { + return getHex(opcode) + addSpecialArg(specialArg) + } + else { + return getHex(opcode) + addSpecialArg(specialArg) + " " + argsToTickflowArgs(args, specialArgStrings) + } } override fun produceBytecode(funcCall: FunctionCall): LongArray { @@ -358,7 +367,12 @@ open class AliasedFunction(opcode: Long, alias: String, argsNeeded: IntRange, va comments: CommentType, specialArgStrings: Map): String { state.nextIndentLevel += indentChange state.currentAdjust = currentAdjust - return this.name + addSpecialArg(specialArg) + " " + argsToTickflowArgs(args, specialArgStrings) + if (args.size == 0) { + return this.name + addSpecialArg(specialArg) + } + else { + return this.name + addSpecialArg(specialArg) + " " + argsToTickflowArgs(args, specialArgStrings) + } } override fun produceBytecode(funcCall: FunctionCall): LongArray { diff --git a/src/main/kotlin/rhmodding/tickompiler/decompiler/Decompiler.kt b/src/main/kotlin/rhmodding/tickompiler/decompiler/Decompiler.kt index 40392a4..c6cc5b1 100644 --- a/src/main/kotlin/rhmodding/tickompiler/decompiler/Decompiler.kt +++ b/src/main/kotlin/rhmodding/tickompiler/decompiler/Decompiler.kt @@ -73,8 +73,9 @@ class Decompiler(val array: ByteArray, val order: ByteOrder, val functions: Func if (useMetadata) { builder.append("#index 0x${readInt().toString(16).toUpperCase()}\n") - markers[readInt()] = "start" + val startPos = readInt() markers[readInt()] = "assets" + markers[startPos] = "start" } for ((key, value) in macros) { @@ -93,8 +94,24 @@ class Decompiler(val array: ByteArray, val order: ByteOrder, val functions: Func } if (opint == 0xFFFFFFFF) { val amount = readInt() + var bytes = 0L for (i in 1..amount) { - anns.add(readInt()) + val ann = readInt() + if (ann and 0xFF == 3L) { + bytes = ann ushr 8 + } + else { + anns.add(ann) + } + } + if (bytes != 0L) { + if (bytes % 4 == 0L) + bytes += 4 - bytes % 4 + counter += bytes_padded + for (i in 1..bytes_padded) { + read() + } + continue } opint = readInt() } diff --git a/src/main/kotlin/rhmodding/tickompiler/gameputter/GamePutter.kt b/src/main/kotlin/rhmodding/tickompiler/gameputter/GamePutter.kt index 14fccf8..1c08b76 100644 --- a/src/main/kotlin/rhmodding/tickompiler/gameputter/GamePutter.kt +++ b/src/main/kotlin/rhmodding/tickompiler/gameputter/GamePutter.kt @@ -34,6 +34,12 @@ object GamePutter { if (anncode == 0 || anncode == 1 || anncode == 2) { adjArgs.add(annArg) } + else if (anncode == 3) { + val num_ints = annArg/4 + if (annArg % 4 == 0) 0 else 1 + for (a in 1..num_ints) { + result.add(gameContents.int) + } + } } opint = gameContents.int }