2
0
mirror of https://github.com/AxioDL/metaforce.git synced 2025-12-09 21:07:42 +00:00

Fix dlist input

This commit is contained in:
2015-08-08 18:12:52 -07:00
parent 2d18e95a91
commit db46dbdfdb
2 changed files with 9 additions and 4 deletions

View File

@@ -270,6 +270,7 @@ bool CMDL::ReadToBlender(HECL::BlenderConnection& conn,
}
/* GX Display List (surface) */
atUint64 start = reader.position();
SurfaceHeader sHead;
sHead.read(reader);
unsigned matUVCount = matUVCounts[0][sHead.matIdx];
@@ -282,14 +283,18 @@ bool CMDL::ReadToBlender(HECL::BlenderConnection& conn,
createdUVLayers = matUVCount;
}
std::unique_ptr<atUint8[]> dlBuf = reader.readUBytes(sHead.dlSize);
atUint32 realDlSize = head.secSizes[s] - (reader.position() - secStart);
std::unique_ptr<atUint8[]> dlBuf = reader.readUBytes(realDlSize);
atUint8* origDl = dlBuf.get();
atUint8* dl = origDl;
while (*dl && (dl-origDl) < sHead.dlSize)
while (*dl && (dl-origDl) < realDlSize)
{
GX::Primitive ptype = GX::Primitive(*dl & 0xf8);
if (ptype == 0)
break;
atUint16 vert_count = HECL::SBig(*(atUint16*)(dl + 1));
os.format("# VAT Type: %u\n", *dl&7);