Created
June 27, 2023 04:57
-
-
Save donnaken15/1d004445dc576e96873a29e58297e9ad to your computer and use it in GitHub Desktop.
Extract GH3 SCN for buildtex2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// :/ | |
namecrc dummy 0 "names.txt" | |
endian big | |
get magic_check long # 0x00 | |
if magic_check != 0 | |
exit | |
endif | |
for i = 1 < 8 | |
get magic_check long | |
if magic_check != 0xFAAABACA | |
exit | |
endif | |
next i | |
get ver byte # 0x20 | |
if ver != 4 | |
exit | |
endif | |
goto 1 0 SEEK_CUR | |
get count short | |
get lsz long | |
goto 8 0 SEEK_CUR # 0x28 | |
//savepos test | |
//string tmp p "%08X" test | |
//print "%tmp%" | |
// 0x30 - material entries | |
log "__config.ini" 0 0 | |
open "." "__config.ini" 1 | |
string config = "" | |
savepos startpos | |
math count + 1 | |
for i = 1 < count | |
savepos entrypos | |
get key long | |
callfunction getdbgname 1 key | |
string config p "%s[%s]%c" config dbgname 0xD | |
callfunction pad 1 0x9C | |
get key long | |
callfunction getdbgname 1 key | |
callfunction pad 1 4 | |
get prePropCount long | |
get prePropOffset long | |
get postPropCount long | |
get postPropOffset long | |
get texCount long | |
get texOffset long | |
callfunction pad 1 4 | |
get matSize long | |
get technique long | |
string config p "%s;PrePropsOffset=%04X%c" config prePropOffset 0xD | |
string config p "%s;PostPropsOffset=%04X%c" config postPropOffset 0xD | |
string config p "%s;TexOffset=%04X%c" config texOffset 0xD | |
string config p "%s;MatSize=%04X%c" config matSize 0xD | |
string config p "%sTemplate=%s%c" config dbgname 0xD | |
get matFlags long | |
callfunction pad 1 4 | |
get alphaMaybe long // :ok_bud: | |
string tmp p "%f" alphaMaybe | |
get blend long | |
string config p "%sBlend=%u%c" config blend 0xD | |
get bloom long | |
callfunction pad 1 4 | |
get matSize2 long | |
get flagsMaybe2 long | |
if texCount > 0 | |
xmath curpos "entrypos + texOffset" | |
goto curpos 0 SEEK_SET | |
if texCount > 1 | |
for j = 0 < texCount | |
get texSamps[k] long | |
callfunction getdbgname 1 texSamps[k] | |
string config p "%sTexture%d=%s%c" config j dbgname 0xD | |
next j | |
else | |
get tex long | |
callfunction getdbgname 1 tex | |
string config p "%sTexture=%s%c" config dbgname 0xD | |
endif | |
padding 0x10 | |
endif | |
if key == 0x98d259f8 // animated | |
math colored = 1 | |
math anim = 1 | |
elif key == 0x18564175 // immediate | |
math colored = 1 | |
elif key == 0x274943ee // immediate alphafade | |
math colored = 1 | |
endif | |
if prePropCount > 0 | |
xmath curpos "entrypos + prePropOffset" | |
goto curpos 0 SEEK_SET | |
for j = 0 < prePropCount | |
string animprop p "PreProps%d" j | |
if anim == 1 | |
if j == 0 // why | |
string animprop = "UCells" | |
elif j == 1 | |
string animprop = "VCells" | |
elif j == 2 | |
string animprop = "FPS" | |
elif j == 3 | |
string animprop = "Offset" | |
elif j == 4 | |
string animprop = "StartFade" | |
elif j == 5 | |
string animprop = "EndFade" | |
endif | |
// array didnt work | |
endif | |
string config p "%s%s=" config animprop | |
if anim == 0 | |
for k = 0 < 4 | |
get preProps[k] float | |
string tmp p "%f" preProps[k] // WTF | |
// ALUIGIIIIIIIIIIIII | |
string config p "%s%s" config tmp | |
if k < 3 | |
string config p "%s," config | |
endif | |
next k | |
else | |
get prop float | |
string tmp p "%f" prop // WTF | |
string config p "%s%s" config tmp | |
callfunction pad 1 12 | |
endif | |
string config p "%s%c" config 0xD | |
next j | |
endif | |
// TODO: somehow merge these | |
if postPropCount > 0 | |
xmath curpos "entrypos + postPropOffset" | |
goto curpos 0 SEEK_SET | |
math colored = 0 | |
math anim = 0 | |
if postPropCount > 1 | |
for j = 0 < postPropCount | |
string config p "%sPostProps%d=" config j | |
for k = 0 < 4 | |
get postProps[k] long | |
string tmp p "%f" postProps[k] | |
string config p "%s%s" config tmp | |
if k < 3 | |
string config p "%s," config | |
endif | |
next k | |
string config p "%s%c" config 0xD | |
next j | |
else | |
string config p "%sColor=" config | |
for k = 0 < 4 | |
get postProps[k] long | |
string tmp p "%f" postProps[k] | |
string config p "%s%s" config tmp | |
if k < 3 | |
string config p "%s," config | |
endif | |
next k | |
string config p "%s%c" config 0xD | |
endif | |
endif | |
if technique != 0 | |
string config p "%sTechnique=%s%c" config technique 0xD | |
endif | |
if bloom != 0 | |
string config p "%sBloom=%u%c" config bloom 0xD | |
endif | |
if alphaMaybe != 0 | |
string config p "%sUnk=%s%c" config tmp 0xD | |
endif | |
string config p "%sFlags=%08X%c" config matFlags 0xD | |
string config p "%sFlags2=%08X%c" config flagsMaybe2 0xD | |
xmath curpos "entrypos + matSize" | |
//callfunction debugint 1 curpos | |
//string config p "%s%c" config 0xD | |
goto curpos 0 SEEK_SET | |
next i | |
savepos endpos | |
xmath scannedsize "endpos - startpos + 0x10" | |
if scannedsize != lsz | |
print "Materials list size mismatch!!!!!!" | |
string tmp p "(scanned) %08X == %08X (generated)" scannedsize lsz | |
print "%tmp%" | |
endif | |
strlen cfglen config | |
putdstring config cfglen 1 | |
startfunction getdbgname | |
namecrc dbgname getdbgname_arg1 | |
if dbgname strncmp "0x" | |
string dbgname p "%08X" getdbgname_arg1 | |
endif | |
endfunction | |
startfunction pad | |
goto pad_arg1 0 SEEK_CUR | |
endfunction | |
startfunction debugint | |
string tmp p "%08X" debugint_arg1 | |
print "%tmp%" | |
endfunction |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment