diff --git a/lib/arookas.dll b/lib/arookas.dll new file mode 100644 index 0000000..057de47 Binary files /dev/null and b/lib/arookas.dll differ diff --git a/lib/arookas.pdb b/lib/arookas.pdb new file mode 100644 index 0000000..37d8ad5 Binary files /dev/null and b/lib/arookas.pdb differ diff --git a/sbdump/main.cs b/sbdump/main.cs index 1ed902e..f6308ed 100644 --- a/sbdump/main.cs +++ b/sbdump/main.cs @@ -158,8 +158,8 @@ namespace arookas { } case 0x03: sWriter.Write(" ${0:X8}", sReader.Read32()); break; case 0x04: WriteVar(); break; - case 0x06: WriteVar(); break; - case 0x07: WriteVar(); break; + case 0x06: break; + case 0x07: break; case 0x0D: { sReader.Read8(); // TSpcInterp skips this byte WriteVar(); @@ -294,7 +294,7 @@ namespace arookas { } case 0x01: //flt { - Stack.Push(sReader.ReadF32().ToString()); + Stack.Push(sReader.ReadF32().ToString("0.0###############")); break; } case 0x02: //str @@ -302,12 +302,12 @@ namespace arookas { var data = sReader.ReadS32(); var value = FetchDataValue(data); - Stack.Push("\"" + value +"\""); + Stack.Push("\"" + value.Replace("\n", "\\n") +"\""); break; } case 0x03: //adr { - Stack.Push(sReader.ReadS32().ToString("X8")); + Stack.Push("$" + sReader.ReadS32().ToString("X8")); break; } case 0x04: //var @@ -317,20 +317,32 @@ namespace arookas { switch (display) { case 0: Stack.Push(FetchSymbolName(FetchSymbol(i => i.Type == SymbolType.Variable && i.Data == data))); break; - case 1: Stack.Push("local" + data.ToString()); break; + case 1: Stack.Push("local " + data.ToString()); break; } break; } case 0x06: //inc { - string Op = Stack.Pop(); - Stack.Push("(" + Op + "+1)"); + sReader.ReadS8(); // Ignore inline var + var display = sReader.ReadS32(); + var data = sReader.ReadS32(); + switch (display) + { + case 0: Stack.Push("++" + FetchSymbolName(FetchSymbol(i => i.Type == SymbolType.Variable && i.Data == data))); break; + case 1: Stack.Push("++" + data.ToString()); break; + } break; } case 0x07: //dec { - string Op = Stack.Pop(); - Stack.Push("(" + Op + "-1)"); + sReader.ReadS8(); // Ignore inline var + var display = sReader.ReadS32(); + var data = sReader.ReadS32(); + switch (display) + { + case 0: Stack.Push("--" + FetchSymbolName(FetchSymbol(i => i.Type == SymbolType.Variable && i.Data == data))); break; + case 1: Stack.Push("--" + data.ToString()); break; + } break; } case 0x08: //add @@ -342,8 +354,8 @@ namespace arookas { } case 0x09: //sub { - string Op1 = Stack.Pop(); string Op2 = Stack.Pop(); + string Op1 = Stack.Pop(); Stack.Push("(" + Op1 + " - " + Op2 + ")"); break; } @@ -356,15 +368,15 @@ namespace arookas { } case 0x0B: //div { - string Op1 = Stack.Pop(); string Op2 = Stack.Pop(); + string Op1 = Stack.Pop(); Stack.Push("(" + Op1 + " / " + Op2 + ")"); break; } case 0x0C: //mod { - string Op1 = Stack.Pop(); string Op2 = Stack.Pop(); + string Op1 = Stack.Pop(); Stack.Push("(" + Op1 + " % " + Op2 + ")"); break; } @@ -376,8 +388,8 @@ namespace arookas { string VariableName = ""; switch (display) { - case 0: VariableName = FetchSymbolName(FetchSymbol(i => i.Type == SymbolType.Variable && i.Data == data)); break; - case 1: VariableName = "local" + data.ToString(); break; + case 0: VariableName = "var " + FetchSymbolName(FetchSymbol(i => i.Type == SymbolType.Variable && i.Data == data)); break; + case 1: VariableName = "var local " + data.ToString(); break; } CodeVertex NewLine = new CodeVertex(VertexType.CodeBlock , -1, VariableName + " = " + Stack.Pop() + ";", pos); FuncCodeGraph.AddVertex(NewLine); @@ -399,29 +411,29 @@ namespace arookas { } case 0x10: //gt { - string Op1 = Stack.Pop(); string Op2 = Stack.Pop(); + string Op1 = Stack.Pop(); Stack.Push("(" + Op1 + " > " + Op2 + ")"); break; } case 0x11: //lt { - string Op1 = Stack.Pop(); string Op2 = Stack.Pop(); + string Op1 = Stack.Pop(); Stack.Push("(" + Op1 + " < " + Op2 + ")"); break; } case 0x12: //ge { - string Op1 = Stack.Pop(); string Op2 = Stack.Pop(); + string Op1 = Stack.Pop(); Stack.Push("(" + Op1 + " >= " + Op2 + ")"); break; } case 0x13: //le { - string Op1 = Stack.Pop(); string Op2 = Stack.Pop(); + string Op1 = Stack.Pop(); Stack.Push("(" + Op1 + " <= " + Op2 + ")"); break; } @@ -439,43 +451,43 @@ namespace arookas { } case 0x16: //and { - string Op1 = Stack.Pop(); string Op2 = Stack.Pop(); + string Op1 = Stack.Pop(); Stack.Push("(" + Op1 + " && " + Op2 + ")"); break; } case 0x17: //or { - string Op1 = Stack.Pop(); string Op2 = Stack.Pop(); + string Op1 = Stack.Pop(); Stack.Push("(" + Op1 + " || " + Op2 + ")"); break; } case 0x18: //band { - string Op1 = Stack.Pop(); string Op2 = Stack.Pop(); + string Op1 = Stack.Pop(); Stack.Push("(" + Op1 + " & " + Op2 + ")"); break; } case 0x19: //bor { - string Op1 = Stack.Pop(); string Op2 = Stack.Pop(); + string Op1 = Stack.Pop(); Stack.Push("(" + Op1 + " ^ " + Op2 + ")"); break; } case 0x1A: //shl { - string Op1 = Stack.Pop(); string Op2 = Stack.Pop(); + string Op1 = Stack.Pop(); Stack.Push("(" + Op1 + " << " + Op2 + ")"); break; } case 0x1B: //shr { - string Op1 = Stack.Pop(); string Op2 = Stack.Pop(); + string Op1 = Stack.Pop(); Stack.Push("(" + Op1 + " >> " + Op2 + ")"); break; } diff --git a/sbdump/settings.cs b/sbdump/settings.cs index 7d2eb4c..9bf873f 100644 --- a/sbdump/settings.cs +++ b/sbdump/settings.cs @@ -38,10 +38,6 @@ namespace arookas { case "-sun": mDecomp = true; continue; } } - ///Debug/// - mInput = "C:\\Users\\August\\Downloads\\Sunshine ROM hacking\\ssc\\Decompile\\talkevent.sb"; - mDecomp = true; - ///Debug/// if (mInput == null) { throw new Exception("Missing input file setting."); } diff --git a/ssc/binary.cs b/ssc/binary.cs index 98eed39..7a7d7dc 100644 --- a/ssc/binary.cs +++ b/ssc/binary.cs @@ -184,18 +184,14 @@ namespace arookas { TraceInstruction("inc {0} {1}", display, index); #endif mText.Writer.Write8(0x06); - mText.Writer.Write8(0x04); - mText.Writer.WriteS32(display); - mText.Writer.WriteS32(index); + WriteVAR(display, index); } public override void WriteDEC(int display, int index) { #if DEBUG TraceInstruction("dec {0} {1}", display, index); #endif mText.Writer.Write8(0x07); - mText.Writer.Write8(0x04); - mText.Writer.WriteS32(display); - mText.Writer.WriteS32(index); + WriteVAR(display, index); } public override void WriteADD() { #if DEBUG diff --git a/ssc/symbol.cs b/ssc/symbol.cs index 0de4e71..da776ea 100644 --- a/ssc/symbol.cs +++ b/ssc/symbol.cs @@ -333,10 +333,16 @@ namespace arookas { public override void CompileGet(sunCompiler compiler) { mExpression.Compile(compiler); } + public override void CompileSet(sunCompiler compiler) { // checks against this have to be implemented at a higher level throw new InvalidOperationException(); } + + public override void CompilePop(sunCompiler compiler) + { + throw new InvalidOperationException(); + } } public enum sunSymbolType {