## SCRIPT BY 누구야

get TBL_FILENAME filename
get TBL_BASENAME basename
get TBL_EXTENSION extension
get TBL_FILESIZE asize

xmath LINES "TBL_FILESIZE / 0x2B4"

log MEMORY_FILE 0 0
log MEMORY_FILE2 0 0
log MEMORY_FILE3 0 0

for i = 0 < LINES
    codepage 932

    get UNKNOWN0 long
    get UNKNOWN1 short
    getdstring ID 0x10
    get BLANK byte
    getdstring NAME 0x40
    get BLANK byte
    getdstring TEXT 0x1E0
    get UNKNOWN long
    getdstring UNKNOWN 0x78

    if ID != ""
    if NAME != ""

      log MEMORY_FILE 0 0
      put 0x00 byte MEMORY_FILE
      putdstring NAME 0x40 MEMORY_FILE
      put 0x00 byte MEMORY_FILE
      get MEMORY1_SIZE asize MEMORY_FILE
      goto 0 MEMORY_FILE
      for j = 0 < MEMORY1_SIZE
        get VALUE byte MEMORY_FILE
        if VALUE == 0x00
          #put 0x24 byte MEMORY_FILE2
          put 0x7B byte MEMORY_FILE2
          put 0x30307830 long MEMORY_FILE2
          put 0x7D byte MEMORY_FILE2
        elif VALUE == 0x0A
          #put 0x7C byte MEMORY_FILE2
          put 0x7B byte MEMORY_FILE2
          put 0x41307830 long MEMORY_FILE2
          put 0x7D byte MEMORY_FILE2
        elif VALUE == 0x0D
          #put 0x40 byte MEMORY_FILE2
          put 0x7B byte MEMORY_FILE2
          put 0x44307830 long MEMORY_FILE2
          put 0x7D byte MEMORY_FILE2
        else
          put VALUE byte MEMORY_FILE2
        endif
      next j
      put 0x0A0D short MEMORY_FILE2
      log MEMORY_FILE 0 0
      put 0x00 byte MEMORY_FILE
      putdstring TEXT 0x1E0 MEMORY_FILE
      put 0x00 byte MEMORY_FILE
      get MEMORY1_SIZE asize MEMORY_FILE
      goto 0 MEMORY_FILE
      for j = 0 < MEMORY1_SIZE
        get VALUE byte MEMORY_FILE
        if VALUE == 0x00
          #put 0x24 byte MEMORY_FILE2
          put 0x7B byte MEMORY_FILE2
          put 0x30307830 long MEMORY_FILE2
          put 0x7D byte MEMORY_FILE2
        elif VALUE == 0x0A
          #put 0x7C byte MEMORY_FILE2
          put 0x7B byte MEMORY_FILE2
          put 0x41307830 long MEMORY_FILE2
          put 0x7D byte MEMORY_FILE2
        elif VALUE == 0x0D
          #put 0x40 byte MEMORY_FILE2
          put 0x7B byte MEMORY_FILE2
          put 0x44307830 long MEMORY_FILE2
          put 0x7D byte MEMORY_FILE2
        else
          put VALUE byte MEMORY_FILE2
        endif
      next j
      put 0x0A0D short MEMORY_FILE2




      log MEMORY_FILE 0 0
      put 0x00 byte MEMORY_FILE
      put NAME string MEMORY_FILE
      #put 0x00 byte MEMORY_FILE
      get MEMORY1_SIZE asize MEMORY_FILE
      goto 0 MEMORY_FILE
      for j = 0 < MEMORY1_SIZE
        get VALUE byte MEMORY_FILE
        if VALUE == 0x00
          put 0x24 byte MEMORY_FILE3
        elif VALUE == 0x0A
          put 0x7C byte MEMORY_FILE3
        elif VALUE == 0x0D
          put 0x40 byte MEMORY_FILE3
        else
          put VALUE byte MEMORY_FILE3
        endif
      next j
      put 0x0A0D short MEMORY_FILE3
      log MEMORY_FILE 0 0
      put 0x00 byte MEMORY_FILE
      put TEXT string MEMORY_FILE
      #put 0x00 byte MEMORY_FILE
      get MEMORY1_SIZE asize MEMORY_FILE
      goto 0 MEMORY_FILE
      for j = 0 < MEMORY1_SIZE
        get VALUE byte MEMORY_FILE
        if VALUE == 0x00
          put 0x24 byte MEMORY_FILE3
        elif VALUE == 0x0A
          put 0x7C byte MEMORY_FILE3
        elif VALUE == 0x0D
          put 0x40 byte MEMORY_FILE3
        else
          put VALUE byte MEMORY_FILE3
        endif
      next j
      put 0x0A0D short MEMORY_FILE3





      print "%i% : %UNKNOWN0% %UNKNOWN1% - %ID% %NAME%"
    endif
    endif
next i


string EXT_NAME0 = "TBL-A\"
string EXT_NAME0 += TBL_BASENAME
string EXT_NAME0 += ".txt"

get MEMORY2_SIZE asize MEMORY_FILE2

log EXT_NAME0 0 MEMORY2_SIZE MEMORY_FILE2



string EXT_NAME1 = "TBL-B\"
string EXT_NAME1 += TBL_BASENAME
string EXT_NAME1 += ".txt"

get MEMORY3_SIZE asize MEMORY_FILE3

log EXT_NAME1 0 MEMORY3_SIZE MEMORY_FILE3



cleanexit




log MEMORY_FILE 0 0

putDstring TBL_FILENAME 32 MEMORY_FILE

string EXT_NAME = QUICKBMS_ARG1
string EXT_NAME += ".dirLIST"

get MEMORY1_SIZE asize MEMORY_FILE

#print "%TBL_FILENAME% -> %EXT_NAME%"

append
log EXT_NAME 0 MEMORY1_SIZE MEMORY_FILE
append











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
