#---------------------------------------------------------------------- # NaomiLib | Models Extractor Ver 1.3 # # *Script by VincentNL # # # Credits: DKDave & Chrrox for their awesome QBMS input! # #---------------------------------------------------------------------- get XXX FILENAME #print "%NAME%" Math MVAR = 0 Math A = 1 #Filename number FOR START if MVAR = 0 FindLoc FILE_START String "\x01\x00\x00\x00\x01\x00\x00\x00" 0 "" If FILE_START == "" Math MVAR = 1 #print "MAGIC TYPE A NOT FOUND!" endif endif if MVAR = 1 FindLoc FILE_START String "\x01\x00\x00\x00\x03\x00\x00\x00" 0 "" If FILE_START == "" Math MVAR = 2 #print "MAGIC TYPE B NOT FOUND!" endif endif if MVAR = 2 FindLoc FILE_START String "\x01\x00\x00\x00\x05\x00\x00\x00" 0 "" If FILE_START == "" Math MVAR = 3 #print "MAGIC TYPE C NOT FOUND!" endif endif if MVAR = 3 FindLoc FILE_START String "\x00\x00\x00\x00\x05\x00\x00\x00" 0 "" If FILE_START == "" Math MVAR = 4 #print "MAGIC TYPE D NOT FOUND!" endif endif if MVAR = 4 FindLoc FILE_START String "\x00\x00\x00\x00\x01\x00\x00\x00" 0 "" If FILE_START == "" Math MVAR = 5 #print "MAGIC TYPE E NOT FOUND!" endif endif if MVAR = 5 print "MODELS NOT FOUND!" break endif get FILE_END asize Xmath FILE_END "FILE_END-0x8" # Last Mesh in a model archive is always at -0x8 from file end goto 0x0 #-------------------------------- # MAIN LOOP1 #-------------------------------- For LOOP1 if MVAR = 0 FindLoc MODEL_START String "\x01\x00\x00\x00\x01\x00\x00\x00" 0 "" endif if MVAR = 1 FindLoc MODEL_START String "\x01\x00\x00\x00\x03\x00\x00\x00" 0 "" endif if MVAR = 2 FindLoc MODEL_START String "\x01\x00\x00\x00\x05\x00\x00\x00" 0 "" endif if MVAR = 3 FindLoc MODEL_START String "\x00\x00\x00\x00\x05\x00\x00\x00" 0 "" endif if MVAR = 4 FindLoc MODEL_START String "\x00\x00\x00\x00\x01\x00\x00\x00" 0 "" endif if MVAR = 5 break endif #------------------------------------- # MAGIC A TYPE #------------------------------------- If MODEL_START == "" && MVAR = 4 break endif If MODEL_START == "" && MVAR != 4 goto 0x0 Xmath MVAR "MVAR + 1" Else #------------------------ # CHECK IF NAOMILIB MODEL #------------------------ Xmath MODEL_TEST "MODEL_START + 0x1B" goto MODEL_TEST get TEST byte XMath MODEL_CHECK "MODEL_START + 0x68" goto MODEL_CHECK get CHECK_VALUE long If CHECK_VALUE > 0x09 && CHECK_VALUE <= 0x01FF && TEST >= 0x80 && TEST <= 0x82 # If value is in range #-------------------- # YES! NAOMI LIB MODEL #-------------------- Math CHECK = 1 Xmath MESH_END_POINTER "MODEL_START+0x64" goto MESH_END_POINTER get MESH_SIZE long Xmath MESH_END "MESH_SIZE+MESH_END_POINTER+0x4" if MESH_END <= FILE_END && MESH_END > 0 && MESH_SIZE >= 0 # Mesh is within file offset, valid model goto MESH_END get NEXT_HEADER long goto MESH_END Else # Mesh is out of bounds, not a valid model goto MODEL_START get JUNK longlong break Endif Else #-------------------------- # NO! NOT A NAOMILIB MODEL #-------------------------- Math CHECK = 2 goto MODEL_START get JUNK longlong Endif For LOOP2 If CHECK = 1 #-------------------------------- # NEW MESH: LOOP2 #-------------------------------- #-------------------- # NEW MESH #-------------------- if NEXT_HEADER != 0 Xmath MESH_END_POINTER "MESH_END+0x48+0x4" goto MESH_END_POINTER get MESH_SIZE long Xmath MESH_END "MESH_SIZE+MESH_END_POINTER+0x4" if MESH_END <= FILE_END && MESH_END > 0 && MESH_SIZE >= 0 # Mesh is within file offset, valid model goto MESH_END get NEXT_HEADER long Else # Mesh is out of bounds, not a valid model goto MODEL_START get JUNK longlong break Endif Else Xmath MESH_END "MESH_END+8" # Add endstring 8 bytes Xmath MODEL_SIZE "MESH_END-MODEL_START" String NAME P "%XXX%_MODEL_%A%.bin" log NAME MODEL_START MODEL_SIZE # Log the model with detected meshes so far XMath A "A+1" goto MODEL_START get JUNK longlong break Endif Next LOOP2 Endif Endif Next LOOP1