# Xanadu Next
# script for QuickBMS http://quickbms.aluigi.org
#
# modified script by 누구야

get BASENAME basename
get EXTENSION extension
get FILESIZE asize
if EXTENSION != DIR
    open FDDE DIR 0
endif
open FDDE ARC 1

xmath FILES_OFFSET "FILESIZE - 4"
goto FILES_OFFSET
get FILES long
#xmath FILES "FILESIZE / 108"

goto 0
math OFFSET = 0
for i = 0 < FILES
    codepage 932

    getdstring NAME 100
    get SIZE long
    get COMP_TYPE long

    string FILE_EXTENSION = NAME
    string FILE_EXTENSION & .
    #print "FILE_EXTENSION=%FILE_EXTENSION%"

    #string EXT_NAME = BASENAME
    #string EXT_NAME += \
    string EXT_NAME = NAME

    if COMP_TYPE == 0
      log EXT_NAME OFFSET SIZE 1
    elif COMP_TYPE == 1
      comtype falcom
      xmath EXT_SIZE "SIZE * 1000"
      #math EXT_SIZE = 0xFFFFFF
      clog EXT_NAME OFFSET SIZE EXT_SIZE 1
    else
      print "COMP_TYPE=%COMP_TYPE% : %EXT_NAME%"
    endif

    math OFFSET += SIZE
next i
