Created
September 25, 2015 04:12
-
-
Save isomorphism/6def39f8d99d7ab2e005 to your computer and use it in GitHub Desktop.
parsing with annotated hex dump
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
---------------------------------------------------------------------- | |
vertex group | |
0x00004394 - 0x000043c3 | |
0x4394 flags: 1073741826 | |
0x4398 (16 bytes skipped): | |
0x43a8 vertex array bytes array, # entries: 135800 | |
0x43ac vertex array bytes array offset: 0x47178 | |
0x43b0 (8 bytes skipped): | |
0x43b8 vertex array stride bytes: 40 | |
0x43bc vertex component declaration list, # entries: 5 | |
0x43c0 vertex component declaration list offset: 0x43c4 | |
0x00004390| 02 00 00 40 15 00 00 00 02 00 00 00 ...@........ | |
0x000043a0| 00 00 00 00 00 00 00 00 78 12 02 00 cc 2d 04 00 ........x....-.. | |
0x000043b0| 00 00 00 00 00 00 00 00 28 00 00 00 05 00 00 00 ........(....... | |
0x000043c0| 04 00 00 00 .... | |
---------------------------------------------------------------------- | |
vertex component declaration list (5 entries) | |
0x000043c4 - 0x000043d7 | |
0x43c4 listEntry: 0x43d8 | |
0x43c8 listEntry: 0x440c | |
0x43cc listEntry: 0x4440 | |
0x43d0 listEntry: 0x4474 | |
0x43d4 listEntry: 0x44a8 | |
0x000043c0| 14 00 00 00 44 00 00 00 74 00 00 00 ....D...t... | |
0x000043d0| a4 00 00 00 d4 00 00 00 ........ | |
---------------------------------------------------------------------- | |
component declaration | |
0x000043d8 - 0x0000440b | |
0x43d8 flags: 1000 0000 0000 0000 0000 0000 0000 0010 | |
0x43dc component type: Just CmpPos | |
0x43e0 (28 bytes skipped): | |
0x43fc component data type: Just CDFloat | |
0x43fd (3 bytes skipped): | |
0x4400 # of component values: 3 | |
0x4404 component value multiplier: 1.0 | |
0x4408 component position: 0 | |
0x000043d0| 01 00 00 40 00 00 00 00 ...@.... | |
0x000043e0| 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ | |
0x000043f0| 00 00 00 00 00 00 00 00 00 00 00 00 06 14 00 00 ................ | |
0x00004400| 03 00 00 00 00 00 80 3f 00 00 00 00 .......?.... |
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
parseVertexGroup :: (Applicative m, Monad m) => StructParser m VertexGroup | |
parseVertexGroup = struct "vertex group" $ do | |
fl <- named "vertex group flags" bitflags | |
vgDetail <- parseVertexGroupDetail fl | |
return $ VertexGroup fl vgDetail | |
parseVertexGroupDetail 0x40000002 = do | |
_ <- named "usage (?)" uint32 | |
_ <- named "flags (?)" uint32 | |
_ <- named "buffer object (?)" uint32 | |
_ <- named "location flag (?)" uint32 | |
vArrSz <- named "vertex array byte size" uint32 | |
vArrOffset <- named "vertex array offset" relOffset | |
_ <- named "location address (?)" $ expect 0 uint32 | |
_ <- named "memory area (?)" $ expect 0 uint32 | |
vStride <- named "vertex array stride" offset32 | |
vcmps <- parseList "vertex component" parseVertexComponent | |
vArray <- runStruct . atOffset vArrOffset . struct "vertex array" $ do | |
displayAs "" . named "vertex data" $ bytes (fromIntegral vArrSz) | |
return $ VertexStream vArray vStride vcmps | |
parseVertexGroupDetail 0x80000000 = do | |
cmpTy <- named "component type" componentType | |
_ <- named "flags (?)" uint32 | |
cmpDT <- named "format type" componentDataType | |
expect 0x14 uint8 | |
skipZeros8 2 | |
_ <- named "# of components" uint32 | |
_ <- named "scale" float32 | |
attrArr <- parseArray "vertex param attribute" float32 | |
return $ VertexParamAttrs cmpTy cmpDT attrArr | |
parseVertexGroupDetail fl = do | |
parseWarning $ "unknown vertex group detail type :" ++ show fl | |
return VertexGroupDetailUnknown | |
parseVertexComponent :: (Applicative m, Monad m) => StructParser m ComponentDesc | |
parseVertexComponent = struct "vertex component description" $ do | |
fl <- named "vertex component flags" $ expect 0x40000001 bitflags | |
cmpTy <- named "component type" componentType | |
skipZeros32 7 | |
cmpDT <- named "component data type" componentDataType | |
expect 0x14 uint8 | |
skipZeros8 2 | |
cmpVals <- named "# of component values" uint32 | |
cmpScale <- named "component scale factor" float32 | |
cmpPos <- named "component position" offset32 | |
return $ ComponentDesc fl cmpTy cmpDT cmpVals cmpScale cmpPos | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment