Fix more (de)compilation errors

This commit is contained in:
JoshuaMK 2022-01-26 06:47:34 -06:00
parent 820b98b4a9
commit ba1a0d6df3
6 changed files with 45 additions and 35 deletions

BIN
lib/arookas.dll Normal file

Binary file not shown.

BIN
lib/arookas.pdb Normal file

Binary file not shown.

View file

@ -158,8 +158,8 @@ namespace arookas {
} }
case 0x03: sWriter.Write(" ${0:X8}", sReader.Read32()); break; case 0x03: sWriter.Write(" ${0:X8}", sReader.Read32()); break;
case 0x04: WriteVar(); break; case 0x04: WriteVar(); break;
case 0x06: WriteVar(); break; case 0x06: break;
case 0x07: WriteVar(); break; case 0x07: break;
case 0x0D: { case 0x0D: {
sReader.Read8(); // TSpcInterp skips this byte sReader.Read8(); // TSpcInterp skips this byte
WriteVar(); WriteVar();
@ -294,7 +294,7 @@ namespace arookas {
} }
case 0x01: //flt case 0x01: //flt
{ {
Stack.Push(sReader.ReadF32().ToString()); Stack.Push(sReader.ReadF32().ToString("0.0###############"));
break; break;
} }
case 0x02: //str case 0x02: //str
@ -302,12 +302,12 @@ namespace arookas {
var data = sReader.ReadS32(); var data = sReader.ReadS32();
var value = FetchDataValue(data); var value = FetchDataValue(data);
Stack.Push("\"" + value +"\""); Stack.Push("\"" + value.Replace("\n", "\\n") +"\"");
break; break;
} }
case 0x03: //adr case 0x03: //adr
{ {
Stack.Push(sReader.ReadS32().ToString("X8")); Stack.Push("$" + sReader.ReadS32().ToString("X8"));
break; break;
} }
case 0x04: //var case 0x04: //var
@ -317,20 +317,32 @@ namespace arookas {
switch (display) switch (display)
{ {
case 0: Stack.Push(FetchSymbolName(FetchSymbol(i => i.Type == SymbolType.Variable && i.Data == data))); break; 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; break;
} }
case 0x06: //inc case 0x06: //inc
{ {
string Op = Stack.Pop(); sReader.ReadS8(); // Ignore inline var
Stack.Push("(" + Op + "+1)"); 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; break;
} }
case 0x07: //dec case 0x07: //dec
{ {
string Op = Stack.Pop(); sReader.ReadS8(); // Ignore inline var
Stack.Push("(" + Op + "-1)"); 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; break;
} }
case 0x08: //add case 0x08: //add
@ -342,8 +354,8 @@ namespace arookas {
} }
case 0x09: //sub case 0x09: //sub
{ {
string Op1 = Stack.Pop();
string Op2 = Stack.Pop(); string Op2 = Stack.Pop();
string Op1 = Stack.Pop();
Stack.Push("(" + Op1 + " - " + Op2 + ")"); Stack.Push("(" + Op1 + " - " + Op2 + ")");
break; break;
} }
@ -356,15 +368,15 @@ namespace arookas {
} }
case 0x0B: //div case 0x0B: //div
{ {
string Op1 = Stack.Pop();
string Op2 = Stack.Pop(); string Op2 = Stack.Pop();
string Op1 = Stack.Pop();
Stack.Push("(" + Op1 + " / " + Op2 + ")"); Stack.Push("(" + Op1 + " / " + Op2 + ")");
break; break;
} }
case 0x0C: //mod case 0x0C: //mod
{ {
string Op1 = Stack.Pop();
string Op2 = Stack.Pop(); string Op2 = Stack.Pop();
string Op1 = Stack.Pop();
Stack.Push("(" + Op1 + " % " + Op2 + ")"); Stack.Push("(" + Op1 + " % " + Op2 + ")");
break; break;
} }
@ -376,8 +388,8 @@ namespace arookas {
string VariableName = ""; string VariableName = "";
switch (display) switch (display)
{ {
case 0: VariableName = FetchSymbolName(FetchSymbol(i => i.Type == SymbolType.Variable && i.Data == data)); break; case 0: VariableName = "var " + FetchSymbolName(FetchSymbol(i => i.Type == SymbolType.Variable && i.Data == data)); break;
case 1: VariableName = "local" + data.ToString(); break; case 1: VariableName = "var local " + data.ToString(); break;
} }
CodeVertex NewLine = new CodeVertex(VertexType.CodeBlock , -1, VariableName + " = " + Stack.Pop() + ";", pos); CodeVertex NewLine = new CodeVertex(VertexType.CodeBlock , -1, VariableName + " = " + Stack.Pop() + ";", pos);
FuncCodeGraph.AddVertex(NewLine); FuncCodeGraph.AddVertex(NewLine);
@ -399,29 +411,29 @@ namespace arookas {
} }
case 0x10: //gt case 0x10: //gt
{ {
string Op1 = Stack.Pop();
string Op2 = Stack.Pop(); string Op2 = Stack.Pop();
string Op1 = Stack.Pop();
Stack.Push("(" + Op1 + " > " + Op2 + ")"); Stack.Push("(" + Op1 + " > " + Op2 + ")");
break; break;
} }
case 0x11: //lt case 0x11: //lt
{ {
string Op1 = Stack.Pop();
string Op2 = Stack.Pop(); string Op2 = Stack.Pop();
string Op1 = Stack.Pop();
Stack.Push("(" + Op1 + " < " + Op2 + ")"); Stack.Push("(" + Op1 + " < " + Op2 + ")");
break; break;
} }
case 0x12: //ge case 0x12: //ge
{ {
string Op1 = Stack.Pop();
string Op2 = Stack.Pop(); string Op2 = Stack.Pop();
string Op1 = Stack.Pop();
Stack.Push("(" + Op1 + " >= " + Op2 + ")"); Stack.Push("(" + Op1 + " >= " + Op2 + ")");
break; break;
} }
case 0x13: //le case 0x13: //le
{ {
string Op1 = Stack.Pop();
string Op2 = Stack.Pop(); string Op2 = Stack.Pop();
string Op1 = Stack.Pop();
Stack.Push("(" + Op1 + " <= " + Op2 + ")"); Stack.Push("(" + Op1 + " <= " + Op2 + ")");
break; break;
} }
@ -439,43 +451,43 @@ namespace arookas {
} }
case 0x16: //and case 0x16: //and
{ {
string Op1 = Stack.Pop();
string Op2 = Stack.Pop(); string Op2 = Stack.Pop();
string Op1 = Stack.Pop();
Stack.Push("(" + Op1 + " && " + Op2 + ")"); Stack.Push("(" + Op1 + " && " + Op2 + ")");
break; break;
} }
case 0x17: //or case 0x17: //or
{ {
string Op1 = Stack.Pop();
string Op2 = Stack.Pop(); string Op2 = Stack.Pop();
string Op1 = Stack.Pop();
Stack.Push("(" + Op1 + " || " + Op2 + ")"); Stack.Push("(" + Op1 + " || " + Op2 + ")");
break; break;
} }
case 0x18: //band case 0x18: //band
{ {
string Op1 = Stack.Pop();
string Op2 = Stack.Pop(); string Op2 = Stack.Pop();
string Op1 = Stack.Pop();
Stack.Push("(" + Op1 + " & " + Op2 + ")"); Stack.Push("(" + Op1 + " & " + Op2 + ")");
break; break;
} }
case 0x19: //bor case 0x19: //bor
{ {
string Op1 = Stack.Pop();
string Op2 = Stack.Pop(); string Op2 = Stack.Pop();
string Op1 = Stack.Pop();
Stack.Push("(" + Op1 + " ^ " + Op2 + ")"); Stack.Push("(" + Op1 + " ^ " + Op2 + ")");
break; break;
} }
case 0x1A: //shl case 0x1A: //shl
{ {
string Op1 = Stack.Pop();
string Op2 = Stack.Pop(); string Op2 = Stack.Pop();
string Op1 = Stack.Pop();
Stack.Push("(" + Op1 + " << " + Op2 + ")"); Stack.Push("(" + Op1 + " << " + Op2 + ")");
break; break;
} }
case 0x1B: //shr case 0x1B: //shr
{ {
string Op1 = Stack.Pop();
string Op2 = Stack.Pop(); string Op2 = Stack.Pop();
string Op1 = Stack.Pop();
Stack.Push("(" + Op1 + " >> " + Op2 + ")"); Stack.Push("(" + Op1 + " >> " + Op2 + ")");
break; break;
} }

View file

@ -38,10 +38,6 @@ namespace arookas {
case "-sun": mDecomp = true; continue; case "-sun": mDecomp = true; continue;
} }
} }
///Debug///
mInput = "C:\\Users\\August\\Downloads\\Sunshine ROM hacking\\ssc\\Decompile\\talkevent.sb";
mDecomp = true;
///Debug///
if (mInput == null) { if (mInput == null) {
throw new Exception("Missing input file setting."); throw new Exception("Missing input file setting.");
} }

View file

@ -184,18 +184,14 @@ namespace arookas {
TraceInstruction("inc {0} {1}", display, index); TraceInstruction("inc {0} {1}", display, index);
#endif #endif
mText.Writer.Write8(0x06); mText.Writer.Write8(0x06);
mText.Writer.Write8(0x04); WriteVAR(display, index);
mText.Writer.WriteS32(display);
mText.Writer.WriteS32(index);
} }
public override void WriteDEC(int display, int index) { public override void WriteDEC(int display, int index) {
#if DEBUG #if DEBUG
TraceInstruction("dec {0} {1}", display, index); TraceInstruction("dec {0} {1}", display, index);
#endif #endif
mText.Writer.Write8(0x07); mText.Writer.Write8(0x07);
mText.Writer.Write8(0x04); WriteVAR(display, index);
mText.Writer.WriteS32(display);
mText.Writer.WriteS32(index);
} }
public override void WriteADD() { public override void WriteADD() {
#if DEBUG #if DEBUG

View file

@ -333,10 +333,16 @@ namespace arookas {
public override void CompileGet(sunCompiler compiler) { public override void CompileGet(sunCompiler compiler) {
mExpression.Compile(compiler); mExpression.Compile(compiler);
} }
public override void CompileSet(sunCompiler compiler) { public override void CompileSet(sunCompiler compiler) {
// checks against this have to be implemented at a higher level // checks against this have to be implemented at a higher level
throw new InvalidOperationException(); throw new InvalidOperationException();
} }
public override void CompilePop(sunCompiler compiler)
{
throw new InvalidOperationException();
}
} }
public enum sunSymbolType { public enum sunSymbolType {