Skip to content

Commit 74d1bb6

Browse files
committed
Back to tabs! (ease of editing)
1 parent d4f71ca commit 74d1bb6

File tree

3 files changed

+23
-24
lines changed

3 files changed

+23
-24
lines changed

src/main/kotlin/rhmodding/tickompiler/api/ExtractCommand.kt

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,21 @@ object ExtractCommand : Command("extract", "e") {
1717

1818
override val commandInfo: CommandInfo =
1919
CommandInfo("[flags] <code file> [output dir]",
20-
listOf("Extract binary files from a decrypted code.bin file and output them to the directory specified.",
21-
"File must be with the file's extension .bin (little-endian)",
22-
"Files will be overwritten without warning.",
23-
"If the output is not specified, the directory will have the same name as the file.",
24-
"A base.bin file will also be created in the output directory. This is a base C00.bin file."),
25-
listOf(
26-
FlagInfo(listOf("-a"),
27-
listOf("Extract all subroutines of game engines, as opposed to only ones used by the games.",
28-
"Note that this potentially includes sequels and prequels to the game.")),
29-
FlagInfo(listOf("-d"),
30-
listOf("Immediately decompile all extracted games, with enhanced features such as meaningful marker names.",
31-
"Will be extracted into a \"decompiled\" directory in the output directory.")),
32-
FlagInfo(listOf("-t"),
33-
listOf("Extract tempo files. These will be written as .tempo files in a \"tempo\" folder in the output directory."))
34-
))
20+
listOf("Extract binary files from a decrypted code.bin file and output them to the directory specified.",
21+
"File must be with the file's extension .bin (little-endian)",
22+
"Files will be overwritten without warning.",
23+
"If the output is not specified, the directory will have the same name as the file.",
24+
"A base.bin file will also be created in the output directory. This is a base C00.bin file."),
25+
listOf(
26+
FlagInfo(listOf("-a"),
27+
listOf("Extract all subroutines of game engines, as opposed to only ones used by the games.",
28+
"Note that this potentially includes sequels and prequels to the game.")),
29+
FlagInfo(listOf("-d"),
30+
listOf("Immediately decompile all extracted games, with enhanced features such as meaningful marker names.",
31+
"Will be extracted into a \"decompiled\" directory in the output directory.")),
32+
FlagInfo(listOf("-t"),
33+
listOf("Extract tempo files. These will be written as .tempo files in a \"tempo\" folder in the output directory."))
34+
))
3535

3636
override fun execute(args: List<String>, flagsObj: Commands.Flags, flags: List<String>, indexOfFirstArgument: Int,
3737
output: PrintStream) {
@@ -41,9 +41,9 @@ object ExtractCommand : Command("extract", "e") {
4141
val codebin = File(args[indexOfFirstArgument])
4242
val codeBuffer = ByteBuffer.wrap(Files.readAllBytes(codebin.toPath())).order(ByteOrder.LITTLE_ENDIAN)
4343
val folder = File(when {
44-
indexOfFirstArgument + 1 < args.size -> args[indexOfFirstArgument + 1]
45-
else -> codebin.nameWithoutExtension
46-
})
44+
indexOfFirstArgument + 1 < args.size -> args[indexOfFirstArgument + 1]
45+
else -> codebin.nameWithoutExtension
46+
})
4747
folder.mkdirs()
4848
val decompiledFolder = File(folder, "decompiled")
4949
if (flags.contains("-d")) {
@@ -65,7 +65,7 @@ object ExtractCommand : Command("extract", "e") {
6565
if (flags.contains("-d")) {
6666
val decompiler = Decompiler(arr, ByteOrder.LITTLE_ENDIAN, MegamixFunctions)
6767
output.println("Decompiling ${codeBuffer.getName(i)}")
68-
val r = decompiler.decompile(CommentType.NORMAL, true, " ", result.first)
68+
val r = decompiler.decompile(CommentType.NORMAL, true, macros = result.first)
6969
val f = FileOutputStream(File(decompiledFolder, codeBuffer.getName(i) + ".tickflow"))
7070
f.write(r.second.toByteArray(Charset.forName("UTF-8")))
7171
f.close()
@@ -87,7 +87,7 @@ object ExtractCommand : Command("extract", "e") {
8787
if (flags.contains("-d")) {
8888
val decompiler = Decompiler(arr, ByteOrder.LITTLE_ENDIAN, MegamixFunctions)
8989
output.println("Decompiling ${codeBuffer.getGateName(i)}")
90-
val r = decompiler.decompile(CommentType.NORMAL, true, " ", result.first)
90+
val r = decompiler.decompile(CommentType.NORMAL, true, macros = result.first)
9191
val f = FileOutputStream(File(decompiledFolder, codeBuffer.getGateName(i) + ".tickflow"))
9292
f.write(r.second.toByteArray(Charset.forName("UTF-8")))
9393
f.close()

src/main/kotlin/rhmodding/tickompiler/api/GrabCommand.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import rhmodding.tickompiler.MegamixFunctions
44
import rhmodding.tickompiler.decompiler.CommentType
55
import rhmodding.tickompiler.decompiler.Decompiler
66
import rhmodding.tickompiler.gameextractor.GameExtractor
7-
import rhmodding.tickompiler.gameextractor.getName
87
import java.io.File
98
import java.io.FileOutputStream
109
import java.io.PrintStream
@@ -54,7 +53,7 @@ object GrabCommand: Command("grab", "g") {
5453
if (flags.contains("-d")) {
5554
val decompiler = Decompiler(arr, ByteOrder.LITTLE_ENDIAN, MegamixFunctions)
5655
output.println("Decompiling ${o.nameWithoutExtension}")
57-
val r = decompiler.decompile(CommentType.NORMAL, true, " ")
56+
val r = decompiler.decompile(CommentType.NORMAL, true)
5857
val f = FileOutputStream(File(o.absolutePath.dropLastWhile { it != File.separatorChar } + o.nameWithoutExtension + ".tickflow"))
5958
f.write(r.second.toByteArray(Charset.forName("UTF-8")))
6059
f.close()

src/main/kotlin/rhmodding/tickompiler/decompiler/Decompiler.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,13 @@ class Decompiler(val array: ByteArray, val order: ByteOrder, val functions: Func
5757
return Pair(result, i)
5858
}
5959

60-
fun decompile(addComments: CommentType, useMetadata: Boolean, indent: String = " ", macros: Map<Int, Int> = mapOf()): Pair<Double, String> {
60+
fun decompile(addComments: CommentType, useMetadata: Boolean, indent: String = "\t", macros: Map<Int, Int> = mapOf()): Pair<Double, String> {
6161
val nanoTime = System.nanoTime()
6262
val builder = StringBuilder()
6363
val state = DecompilerState()
6464

6565
run decompilerInfo@ {
66-
builder.append("// Decompiled using Tickompiler ${VERSION}\n// ${GITHUB}\n")
66+
builder.append("// Decompiled using Tickompiler $VERSION\n// $GITHUB\n")
6767
}
6868
val markers = mutableMapOf<Long, String>()
6969

0 commit comments

Comments
 (0)