mirror of
https://github.com/RSDKModding/Sonic-Mania-Decompilation.git
synced 2025-02-17 03:48:13 +00:00
DONT GIVE RDC ACCESS TO PY!!! HE'LL LEARN IT!!
This commit is contained in:
parent
5f50fcd7f4
commit
3533d18819
5
.gitattributes
vendored
Normal file
5
.gitattributes
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
# default behaviour
|
||||
* text=auto
|
||||
|
||||
# I do not like \r\n, \n supremacy
|
||||
*.txt text eol=lf
|
1
.gitignore
vendored
1
.gitignore
vendored
@ -60,6 +60,7 @@ cmake/
|
||||
|
||||
# safety
|
||||
*.rsdk
|
||||
Sonic Mania/Static/*
|
||||
|
||||
#OSX files
|
||||
*.DS_Store
|
||||
|
@ -37,14 +37,16 @@ typedef struct {
|
||||
1592, 1564, 1536, 1509, 1482, 1455, 1429, 1404, 1379, 1354, 1330, 1307, 1283, 1260, 1238, 1216, 1194, 1173, 1152, 1134, 1116, 1099, 1082,
|
||||
1065, 1048, 1032, 1016, 1000, 985, 969, 954, 939, 925, 910, 896, 892, 888, 884, 880, 875, 871, 867, 863, 859, 855, 851,
|
||||
848, 844, 840, 836, 832, 830, 828, 826, 824, 822, 820, 818, 816, 814, 812, 810, 808, 806, 804, 802 });
|
||||
TABLE(int xMultiplierTable[0x70], 134, 131, 128, 125, 123, 121, 119, 117, 115, 114, 112, 111, 109, 108, 106, 104, 104, 102, 100, 98, 97, 96, 94,
|
||||
93, 92, 90, 89, 88, 86, 84, 83, 82, 80, 80, 79, 78, 77, 76, 74, 73, 72, 71, 70, 70, 68, 68, 67, 66, 65, 64, 63, 62, 61, 60, 60, 59, 58, 57,
|
||||
57, 56, 55, 54, 53, 53, 52, 51, 51, 50, 50, 49, 48, 48, 47, 47, 46, 46, 45, 45, 44, 44, 44, 43, 43, 43, 42, 42, 42, 41, 41, 41, 41, 40, 40,
|
||||
40, 40, 39, 39, 39, 39, 39, 38, 38, 38, 38, 38, 37, 37, 37, 37, 37, 36, 36);
|
||||
TABLE(int frameTable[0x80], 31, 31, 31, 31, 31, 31, 31, 30, 30, 30, 30, 30, 30, 29, 29, 29, 29, 29, 28, 28, 28, 28, 27, 27, 27, 26, 26, 26, 26,
|
||||
25, 25, 25, 24, 24, 24, 24, 23, 23, 23, 23, 22, 22, 22, 22, 21, 21, 21, 21, 20, 20, 20, 20, 19, 19, 19, 19, 18, 18, 18, 18, 17, 17, 17, 17,
|
||||
16, 16, 16, 15, 15, 14, 14, 14, 13, 13, 13, 12, 12, 12, 11, 11, 10, 10, 10, 10, 9, 9, 9, 9, 8, 8, 8, 8, 7, 7, 7, 7, 6, 6, 6, 6, 5, 5, 5, 5,
|
||||
4, 4, 3, 3, 2, 2, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
|
||||
TABLE(int xMultiplierTable[0x70],
|
||||
{ 134, 131, 128, 125, 123, 121, 119, 117, 115, 114, 112, 111, 109, 108, 106, 104, 104, 102, 100, 98, 97, 96, 94, 93, 92, 90, 89, 88,
|
||||
86, 84, 83, 82, 80, 80, 79, 78, 77, 76, 74, 73, 72, 71, 70, 70, 68, 68, 67, 66, 65, 64, 63, 62, 61, 60, 60, 59,
|
||||
58, 57, 57, 56, 55, 54, 53, 53, 52, 51, 51, 50, 50, 49, 48, 48, 47, 47, 46, 46, 45, 45, 44, 44, 44, 43, 43, 43,
|
||||
42, 42, 42, 41, 41, 41, 41, 40, 40, 40, 40, 39, 39, 39, 39, 39, 38, 38, 38, 38, 38, 37, 37, 37, 37, 37, 36, 36 });
|
||||
TABLE(int frameTable[0x80],
|
||||
{ 31, 31, 31, 31, 31, 31, 31, 30, 30, 30, 30, 30, 30, 29, 29, 29, 29, 29, 28, 28, 28, 28, 27, 27, 27, 26, 26, 26, 26, 25, 25, 25,
|
||||
24, 24, 24, 24, 23, 23, 23, 23, 22, 22, 22, 22, 21, 21, 21, 21, 20, 20, 20, 20, 19, 19, 19, 19, 18, 18, 18, 18, 17, 17, 17, 17,
|
||||
16, 16, 16, 15, 15, 14, 14, 14, 13, 13, 13, 12, 12, 12, 11, 11, 10, 10, 10, 10, 9, 9, 9, 9, 8, 8, 8, 8, 7, 7, 7, 7,
|
||||
6, 6, 6, 6, 5, 5, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 });
|
||||
Vector2 offsetTable[0x100];
|
||||
int offsetRadiusTable[0x100];
|
||||
int frustumCount[2];
|
||||
|
@ -9,10 +9,10 @@ typedef struct {
|
||||
int waterFadeAmount;
|
||||
STATIC(int delayA, 30);
|
||||
int frameA;
|
||||
TABLE(int delayListA[8], 30, 2, 2, 2, 30, 2, 2, 2);
|
||||
TABLE(int delayListA[8], { 30, 2, 2, 2, 30, 2, 2, 2 });
|
||||
STATIC(int delayB, 60);
|
||||
int frameB;
|
||||
TABLE(int delayListB[16], 120, 2, 2, 2, 8, 2, 2, 2, 120, 2, 2, 2, 8, 2, 2, 2);
|
||||
TABLE(int delayListB[16], { 120, 2, 2, 2, 8, 2, 2, 2, 120, 2, 2, 2, 8, 2, 2, 2 });
|
||||
ushort aniTiles;
|
||||
} ObjectGHZSetup;
|
||||
|
||||
|
@ -7,8 +7,8 @@
|
||||
// Object Class
|
||||
typedef struct {
|
||||
RSDK_OBJECT
|
||||
Entity* loadEntity;
|
||||
void(*loadCallback)(bool32);
|
||||
Entity *loadEntity;
|
||||
void (*loadCallback)(bool32);
|
||||
Entity *saveEntity;
|
||||
void (*saveCallback)(bool32);
|
||||
Entity *deleteEntity;
|
||||
|
@ -7,7 +7,7 @@
|
||||
typedef struct {
|
||||
RSDK_OBJECT
|
||||
Entity *activeTransition;
|
||||
const char *newTag;
|
||||
char *newTag;
|
||||
} ObjectUITransition;
|
||||
|
||||
// Entity Class
|
||||
|
@ -214,7 +214,7 @@ typedef struct {
|
||||
ushort sfx_MightyUnspin;
|
||||
int raySwoopTimer;
|
||||
int rayDiveTimer;
|
||||
bool32 gotHit[PLAYER_MAX];
|
||||
bool32 gotHit[4];
|
||||
void (*configureGhost_CB)(void);
|
||||
bool32 (*canSuper)(bool32);
|
||||
int superDashCooldown;
|
||||
|
@ -1,5 +1,5 @@
|
||||
import os, sys, re
|
||||
from typing import IO, Dict, Iterable, Iterator, List, Tuple
|
||||
from typing import IO, BinaryIO, Dict, Iterable, Iterator, List, Tuple
|
||||
from pathlib import Path
|
||||
|
||||
USE64 = False
|
||||
@ -14,7 +14,7 @@ TYPEMAP = {
|
||||
"byte": 1,
|
||||
"ushort": 2,
|
||||
"uint": 4,
|
||||
"char": 1,
|
||||
"sbyte": 1,
|
||||
"short": 2,
|
||||
"int": 4,
|
||||
"bool32": 4,
|
||||
@ -33,7 +33,6 @@ lastpos = 0
|
||||
errflag = 0
|
||||
path = ""
|
||||
|
||||
|
||||
def relseek(where):
|
||||
currentfile.seek(currentfile.tell() + where, 0)
|
||||
|
||||
@ -52,7 +51,7 @@ def readlines() -> Iterator[str]:
|
||||
r = currentfile.readline()
|
||||
if not r:
|
||||
break
|
||||
curpos += len(r)
|
||||
curpos = currentfile.tell()
|
||||
if r.strip() == "" or r.strip().startswith("//"):
|
||||
continue
|
||||
yield r[:-1]
|
||||
@ -83,7 +82,6 @@ def readuntiltext():
|
||||
r += c
|
||||
return r
|
||||
|
||||
|
||||
def infront():
|
||||
r = currentfile.read(1)
|
||||
relseek(-1)
|
||||
@ -100,8 +98,17 @@ def deduce(delim):
|
||||
global errflag, path
|
||||
readuntiltext()
|
||||
type = readuntil(" ")
|
||||
|
||||
if infront() == "*":
|
||||
type = "ptr"
|
||||
if type.endswith("*"):
|
||||
type = "ptr"
|
||||
type.replace("*", "")
|
||||
|
||||
if infront() == "(":
|
||||
type = "ptr"
|
||||
readuntil("*") #da name!!!
|
||||
|
||||
if type in ("color", "colour"):
|
||||
type = "uint"
|
||||
if type not in TYPEMAP:
|
||||
@ -123,16 +130,30 @@ def deduce(delim):
|
||||
|
||||
name = name[:(sp - curpos - 1)]
|
||||
backward()
|
||||
readuntil(delim) #readjust to be sure
|
||||
readuntil(delim) #read just to be sure
|
||||
t.append((name, tuple(TYPEMAP.keys()).index(type), asize, []))
|
||||
|
||||
plus = len(sys.argv) < 3 or sys.argv[2] == "plus"
|
||||
for path in Path(sys.argv[1]).rglob("*.h"):
|
||||
mode = 0
|
||||
# print(f"{path} STARTED")
|
||||
prepare(path)
|
||||
for l in readlines():
|
||||
if errflag:
|
||||
break
|
||||
if l.strip() == "typedef struct {":
|
||||
|
||||
if ("".join(l.split()).startswith("#ifRETRO_USE_PLUS") and not plus) or ("".join(l.split()).startswith("#if!RETRO_USE_PLUS") and plus):
|
||||
mode = 5
|
||||
continue
|
||||
elif ("".join(l.split()).startswith("#ifRETRO_USE_PLUS") and plus) or ("".join(l.split()).startswith("#if!RETRO_USE_PLUS") and not plus):
|
||||
continue #ok idc
|
||||
elif "".join(l.split()).startswith("#endif"):
|
||||
continue #ok idc
|
||||
elif "".join(l.split()).startswith("#else"):
|
||||
mode = 5
|
||||
continue #ok do care
|
||||
|
||||
if mode < 5 and l.strip() == "typedef struct {":
|
||||
mode = 1
|
||||
continue
|
||||
if mode == 1 and l.strip() == "RSDK_OBJECT":
|
||||
@ -148,6 +169,8 @@ for path in Path(sys.argv[1]).rglob("*.h"):
|
||||
mode = 4
|
||||
backward()
|
||||
continue
|
||||
if l.strip().startswith("StateMachine"):
|
||||
continue
|
||||
if l.strip().startswith("} "):
|
||||
backward()
|
||||
readuntil(" ")
|
||||
@ -160,10 +183,11 @@ for path in Path(sys.argv[1]).rglob("*.h"):
|
||||
objects[name] = t
|
||||
t = []
|
||||
mode = 0
|
||||
break
|
||||
continue #I changed this specifically because of "SPZSetup" & "SPZ2Setup" sharing a file :LOL:
|
||||
backward()
|
||||
deduce(";")
|
||||
if mode == 3:
|
||||
backward()
|
||||
readuntil("(")
|
||||
deduce(",")
|
||||
if errflag:
|
||||
@ -176,19 +200,20 @@ for path in Path(sys.argv[1]).rglob("*.h"):
|
||||
for i in range(expected - 1):
|
||||
try: t[-1][3].append(int(readuntil(","), 0))
|
||||
except:
|
||||
print(f"INCORRECT INT IN {t[-1][0]} TABLE OR TABLE TOO SMALL IN {os.path.basename(path)}")
|
||||
print(f"INCORRECT INT IN {t[-1][0]} TABLE OR TABLE TOO SMALL IN {os.path.basename(path)}, EXPECTED: {expected}")
|
||||
errflag = 1
|
||||
break
|
||||
if errflag:
|
||||
break
|
||||
try: t[-1][3].append(int(readuntil("}"), 0))
|
||||
except:
|
||||
print(f"INCORRECT INT IN {t[-1][0]} TABLE OR TABLE TOO BIG IN {os.path.basename(path)}")
|
||||
print(f"INCORRECT INT IN {t[-1][0]} TABLE OR TABLE TOO BIG IN {os.path.basename(path)}, EXPECTED: {expected}")
|
||||
break
|
||||
readuntil(";")
|
||||
mode = 2
|
||||
continue
|
||||
if mode == 4:
|
||||
backward()
|
||||
readuntil("(")
|
||||
deduce(",")
|
||||
if t[-1][1] > tuple(TYPEMAP.keys()).index("bool32"):
|
||||
@ -200,7 +225,37 @@ for path in Path(sys.argv[1]).rglob("*.h"):
|
||||
break
|
||||
readuntil(";")
|
||||
mode = 2
|
||||
continue
|
||||
if mode == 5:
|
||||
if l.strip().startswith("#else") or l.strip().startswith("#endif"):
|
||||
mode = 0 #STOP!!!!
|
||||
|
||||
print("\n\n\n\nStatic Objs")
|
||||
for key in objects:
|
||||
b = bytearray([ord('O'), ord('B'), ord('J'), 0])
|
||||
hasVal = False
|
||||
|
||||
for tup in objects[key]:
|
||||
type = tup[1]
|
||||
if tup[3]:
|
||||
hasVal = True
|
||||
type |= 0x80
|
||||
b.append(type)
|
||||
b.extend(tup[2].to_bytes(4, 'little')) #array size
|
||||
if type >= 0x80:
|
||||
b.extend(tup[2].to_bytes(4, 'little')) #data size
|
||||
size = tuple(TYPEMAP.values())[tup[1]]
|
||||
for val in tup[3]:
|
||||
b.extend(val.to_bytes(size, byteorder='little', signed=False if val >= 0 else True)) #val
|
||||
|
||||
if hasVal:
|
||||
name = key
|
||||
if len(sys.argv) < 4 or sys.argv[3] != "debug":
|
||||
name = "00000000000000000000000000000000" #TODO: idk how to do hashes and I cba to learn rn :LOL
|
||||
|
||||
with open(f"Static/{name}.bin", "wb") as file:
|
||||
file.write(b)
|
||||
file.close()
|
||||
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user