08-10-2011, 03:07 PM
Code:
--filein (scriptsPath + "Fatduck\\Big_Endian.ms")
fn readBinString f nChar = (
txt = ""
for j = 1 to nChar do txt += bit.intAschar (readbyte f #unsigned)
return txt
)--end fn readBinString
fn test f = (
clearlistener()
UVary = #()
for i = 1 to 557 do (
readlong f
tu = readBEFloat f ; tv = readBEFloat f
append UVary [tu,tv,0]
tu = readBEFloat f ; tv = readBEFloat f
--format "% % % %\n" (readBEFloat f) (readBEFloat f) (readBEFloat f) (readBEFloat f)
)
format "Here @ [%]\n" (d2h8 (ftell f))
mm = undefined
do (
f1 = readBEword f
if f1 != 0xFFFF then mm = boundary mm f1
) while (ftell f) < 0x34CC
format "MM: %\n Here @ [%]\n" mm (d2h8 (ftell f))
msh = mesh vertices:UVary faces:#([1,2,3])
)
fn test2 f debugmode = (
ChunkID = readBEDword f --0x200
ChunkSize = readBEDword f
ukn01 = readBEDword f
ukn02 = readBEDword f
ukn03 = readBEDword f
ukn04 = readBEDword f
ukn05 = readBEDword f
ukn06 = readBEDword f
nVerts = readBEDword f
ukn08 = readBEDword f --padding??
ukn09 = readBEDword f --padding??
ukn10 = readBEDword f --padding??
ukn11 = readBEDword f --padding??
ukn12 = readBEDword f
ukn13 = readBEDword f
ofsUV = readBEDword f
ofsFcIdx = readBEDword f
ukn16 = readBEDword f --padding??
ukn17 = readBEDword f --padding??
ukn18 = readBEDword f --padding??
ukn19 = readBEDword f --padding??
ukn20 = readBEDword f --padding??
bx1 = readBEFloat f ; by1 = readBEFloat f ; bz1 = readBEFloat f
bx2 = readBEFloat f ; by2 = readBEFloat f ; bz2 = readBEFloat f
ukn27 = readBEDword f
ukn28 = readBEDword f
ofsName = readBEDword f
ukn30 = readBEDword f
ofsEndTerm = readBEDword f
if debugmode==true then (
format "ID:% Size:%\n" (d2h8 ChunkID) (d2h8 ChunkSize)
format "% % % %\n" ukn01 ukn02 ukn03 ukn04
format "% % VT:% %\n" ukn05 ukn06 nVerts ukn08
format "% % % %\n" ukn09 ukn10 ukn11 ukn12
format "% ofsUV:% ofsFC:% %\n" ukn13 (d2h8 ofsUV) (d2h8 ofsFcIdx) ukn16
format "% % % %\n" ukn17 ukn18 ukn19 ukn20
format "% - %\n" [bx1,by1,bz1] [bx2,by2,bz2]
format "% % ofsName:% % ofsEnd:%\n" ukn27 ukn28 (d2h8 ofsName) ukn20 (d2h8 ofsEndTerm)
format "Here @ [%]\n" (d2h8 (ftell f))
)
)--end debugmode
struct Res (
ofs, blacksize, len, ofsname, name, type
)
fn readVesperiaMan f fscale debugmode = (
FPS4Start = ftell f
xxx = (readBinString f 4)
format "%\n" xxx
if xxx != "FPS4" then (
messagebox "Not a valid Tales of Vesperia file!"
return undefined
)--end if
nRes = readBEDword f
ofsTbl = readBEDword f
ofsBaseData = readBEDword f
if debugmode==true then (
clearlistener()
format "FPS4 Res:% \tofs:%[%]\n" nRes ofsBaseData (FPS4Start+ofsBaseData)
)--end debugmode
fseek f (FPS4Start+ofsTbl) #seek_set
RESary = #()
for i = 1 to nRes do (
ofsData = readBEDword f
DataBlock = readBEDword f
RealSize = readBEDword f
ofsName = readBEDword f
append RESary (Res ofs:ofsData blacksize:DataBlock len:RealSize ofsname:ofsName)
)
if debugmode==true then format "after Indices Table @ [%]\n" (d2h8 (ftell f))
for r in RESary do (
if r.ofsname > 0 then (
fseek f (FPS4Start+r.ofsname) #seek_set
r.name = readstring f
) else r.name = ""
if r.len > 0 then (
fseek f (FPS4Start+r.ofs) #seek_set
r.type = readBEDword f
) else r.type = 0x0BAD0BAD
)
if debugmode==true then (
for j = 1 to nRes do
format "% \tofs:%[%] len:% type:% Name:%\n" j (d2h8 RESary[j].ofs) (d2h8 (FPS4Start+RESary[j].ofs)) (d2h8 RESary[j].len) (d2h8 RESary[j].type) RESary[j].name
)--end debugmode
)--end fn readVesperiaMan
fn nouse = (
fname = "C:\\GameFiles\\TaleOfVesperiaX360\\chara\\npc\\MM_C000\\HEAD\\MM_C000_HEAD_7"
f = fopen fname "rb"
clearlistener()
fseek f 0x50 #seek_set
test2 f true
fseek f 0x8CC #seek_set
test2 f true
fseek f 0x1BB0 #seek_set
test2 f true
fseek f 0x2C6C #seek_set
test2 f true
fclose f
)
/*
fname = "C:\\GameFiles\\TaleOfVesperiaX360\\Test\\AHO_C_01.DAT"
f = fopen fname "rb"
readVesperiaMan f 1 true
fclose f
*/