progress
This commit is contained in:
parent
973392e649
commit
59586a6f6d
|
|
@ -12,6 +12,16 @@ def read_until_null(indx: int, data: tuple) -> int:
|
||||||
end += 2
|
end += 2
|
||||||
return end
|
return end
|
||||||
|
|
||||||
|
def read_until_space(indx: int, data: tuple) -> int:
|
||||||
|
end = indx
|
||||||
|
while end + 1 < len(data):
|
||||||
|
## Read 2 bytes at a time until null found
|
||||||
|
if data[end:end+2] == b"\x4F\x00":
|
||||||
|
break
|
||||||
|
end += 2
|
||||||
|
return end
|
||||||
|
|
||||||
|
|
||||||
# 8 bytes at a time
|
# 8 bytes at a time
|
||||||
cd_db = {}
|
cd_db = {}
|
||||||
def get_props():
|
def get_props():
|
||||||
|
|
@ -65,6 +75,10 @@ j_name_data = Path(f"YGO_2020/main/howto_db/howtoplay_{language_code}.bin").read
|
||||||
|
|
||||||
print("now what?")
|
print("now what?")
|
||||||
|
|
||||||
|
count_of_items = int.from_bytes(e_name_data[0:4], byteorder='big') # 202
|
||||||
|
## 202 * 8 = 1616 (Thats about where this started)
|
||||||
|
|
||||||
|
|
||||||
help_dump = {}
|
help_dump = {}
|
||||||
i_e = 1624
|
i_e = 1624
|
||||||
i_j = 1624
|
i_j = 1624
|
||||||
|
|
@ -100,6 +114,30 @@ for r in range(0,len(name_data),8):
|
||||||
read_until_null(1624,name_data)
|
read_until_null(1624,name_data)
|
||||||
name_data[1624:read_until_null(1624,name_data)].decode("utf-16be", errors="replace")
|
name_data[1624:read_until_null(1624,name_data)].decode("utf-16be", errors="replace")
|
||||||
|
|
||||||
|
|
||||||
|
language_code = 'E'
|
||||||
|
script_data = Path(f"YGO_2020/main/scriptdata_{language_code}.bin").read_bytes() # Get all the bytes
|
||||||
|
|
||||||
|
|
||||||
|
offset = struct.unpack("<Q", script_data[0:8])[0] # 11914
|
||||||
|
titlecount = struct.unpack("<I", script_data[8:12])[0] # 307
|
||||||
|
scriptblockcount = struct.unpack("<I", script_data[12:16])[0] # 7340
|
||||||
|
|
||||||
|
titleStartPos = list()
|
||||||
|
titleEndPos = list()
|
||||||
|
titleOffset = list()
|
||||||
|
for p in range(titlecount):
|
||||||
|
i = p * 16
|
||||||
|
titleStartPos.append(struct.unpack("<I", script_data[i:i+4])[0])
|
||||||
|
titleEndPos.append(struct.unpack("<I", script_data[i+4:i+8])[0])
|
||||||
|
titleOffset.append(struct.unpack("<Q", script_data[i+8:i+16])[0])
|
||||||
|
## 307 items? Is that good
|
||||||
|
|
||||||
|
for o in range(len(titleOffset)):
|
||||||
|
start = titleOffset[o]
|
||||||
|
end = read_until_space(start,script_data)
|
||||||
|
print( script_data[start:end].decode("utf-8") )
|
||||||
|
|
||||||
## Old attempts at getting dlg file extracted, leaving block for reference
|
## Old attempts at getting dlg file extracted, leaving block for reference
|
||||||
language_code = 'J'
|
language_code = 'J'
|
||||||
offsets_data = Path(f"YGO_2020/bin/DLG_Indx_{language_code}.bin").read_bytes() # Get all the bytes
|
offsets_data = Path(f"YGO_2020/bin/DLG_Indx_{language_code}.bin").read_bytes() # Get all the bytes
|
||||||
|
|
@ -110,3 +148,70 @@ get_props()
|
||||||
# json.dump(cd_db, outfile, ensure_ascii=False, indent=2)
|
# json.dump(cd_db, outfile, ensure_ascii=False, indent=2)
|
||||||
|
|
||||||
print()
|
print()
|
||||||
|
|
||||||
|
### For dialog scripts eventually
|
||||||
|
# Int ReadInt(std::ifstream &file){
|
||||||
|
# Int value;
|
||||||
|
# std::array<Byte,4> bytes;
|
||||||
|
# file.read((char*)(bytes.data()),4);
|
||||||
|
# value = bytes[0] | (bytes[1]<<8) | (bytes[2]<<16) | (bytes[3]<<24);
|
||||||
|
# return value;
|
||||||
|
# }
|
||||||
|
# Long ReadLong(std::ifstream &file){
|
||||||
|
# Long value;
|
||||||
|
# std::array<Byte,8> bytes;
|
||||||
|
# file.read((char*)(bytes.data()),8);
|
||||||
|
# value = bytes[0] | (bytes[1]<<8) | (bytes[2]<<16) | (bytes[3]<<24) | (bytes[4]<<32) | (bytes[5]<<40) | (bytes[6]<<48) | (bytes[7]<<56);
|
||||||
|
# return value;
|
||||||
|
# }
|
||||||
|
|
||||||
|
# if (scriptFile.is_open()){
|
||||||
|
# Long pointerToPointers=ReadLong(scriptFile);
|
||||||
|
# Int titleCount=ReadInt(scriptFile);
|
||||||
|
# Int scriptBlockCount=ReadInt(scriptFile);
|
||||||
|
# std::vector<Int> titleStartPos;
|
||||||
|
# std::vector<Int> titleEndPos;
|
||||||
|
# std::vector<Long> titlePointer;
|
||||||
|
# for (Int i=0; i<titleCount;i++){
|
||||||
|
# titleStartPos.push_back(ReadInt(scriptFile)); # 1
|
||||||
|
# titleEndPos.push_back(ReadInt(scriptFile)); # 2
|
||||||
|
# titlePointer.push_back(ReadLong(scriptFile)); # 3
|
||||||
|
# }
|
||||||
|
# std::vector<std::string> titleNames;
|
||||||
|
# for (Int i=0; i<titleCount;i++){
|
||||||
|
# scriptFile.seekg(titlePointer[i],scriptFile.beg);
|
||||||
|
# titleNames.push_back(ReadByteString(scriptFile));
|
||||||
|
# }
|
||||||
|
|
||||||
|
# std::vector<std::vector<SCRIPT_BLOCK> > script;
|
||||||
|
# for (Int i=0; i< titleCount; i++){
|
||||||
|
# std::vector<SCRIPT_BLOCK> scriptBlocks;
|
||||||
|
# Int blockCount=titleEndPos[i]-titleStartPos[i]+1;
|
||||||
|
# int pointer;
|
||||||
|
# for (Int j=0; j<blockCount;j++){
|
||||||
|
# SCRIPT_BLOCK scriptBlock;
|
||||||
|
# scriptFile.seekg(pointerToPointers+titleStartPos[i]*32+j*32);
|
||||||
|
# pointer=ReadLong(scriptFile);
|
||||||
|
# scriptFile.seekg(pointer,scriptFile.beg);
|
||||||
|
# scriptBlock.chara=ReadByteString(scriptFile);
|
||||||
|
# scriptFile.seekg(pointerToPointers+titleStartPos[i]*32+j*32+8);
|
||||||
|
# pointer=ReadLong(scriptFile);
|
||||||
|
# scriptFile.seekg(pointer,scriptFile.beg);
|
||||||
|
# scriptBlock.arg1=ReadByteString(scriptFile);
|
||||||
|
# scriptFile.seekg(pointerToPointers+titleStartPos[i]*32+j*32+16);
|
||||||
|
# pointer=ReadLong(scriptFile);
|
||||||
|
# scriptFile.seekg(pointer,scriptFile.beg);
|
||||||
|
# scriptBlock.arg2=ReadByteString(scriptFile);
|
||||||
|
# scriptFile.seekg(pointerToPointers+titleStartPos[i]*32+j*32+24);
|
||||||
|
# pointer=ReadLong(scriptFile);
|
||||||
|
# scriptFile.seekg(pointer,scriptFile.beg);
|
||||||
|
# scriptBlock.text=ReadByteString(scriptFile);
|
||||||
|
# scriptBlocks.push_back(scriptBlock);
|
||||||
|
# }
|
||||||
|
# script.push_back(scriptBlocks);
|
||||||
|
# }
|
||||||
|
# scriptFile.close();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user