## 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

    math ID = 0
    math NAME = 0
    math TEXT = 0

    get UNKNOWN0 long
    get UNKNOWN1 short
    getdstring ID 0x10
    get BLANK0 byte
    getdstring NAME 0x40
    get BLANK1 byte
    getdstring TEXT 0x1C0

    log MEMORY_FILE3 0 0
    put 0x20 byte MEMORY_FILE3
    put NAME string MEMORY_FILE3
    get MEMORY3_SIZE asize MEMORY_FILE3
    goto 0 MEMORY_FILE3
    getdstring NAME_DP MEMORY3_SIZE MEMORY_FILE3

    if NAME != ""
      math NUM hex i
      put NUM string MEMORY_FILE

      get MEMORY1_SIZE asize MEMORY_FILE
      xmath MEMORY1_SIZE "MEMORY1_SIZE - 1"
      goto MEMORY1_SIZE MEMORY_FILE
      put 0x09 byte MEMORY_FILE

      put ID string MEMORY_FILE

      get MEMORY1_SIZE asize MEMORY_FILE
      xmath MEMORY1_SIZE "MEMORY1_SIZE - 1"
      goto MEMORY1_SIZE MEMORY_FILE
      put 0x09 byte MEMORY_FILE

      put NAME string MEMORY_FILE

      get MEMORY1_SIZE asize MEMORY_FILE
      xmath MEMORY1_SIZE "MEMORY1_SIZE - 1"
      goto MEMORY1_SIZE MEMORY_FILE
      put 0x09 byte MEMORY_FILE

      log MEMORY_FILE2 0 0
      log MEMORY_FILE3 0 0
      put TEXT string MEMORY_FILE2
      get MEMORY2_SIZE asize MEMORY_FILE2
      goto 0 MEMORY_FILE2
      for j = 0 < MEMORY2_SIZE
        get VALUE byte MEMORY_FILE2
        if VALUE == 0x0A
          put 0x2A byte MEMORY_FILE3
        elif VALUE == 0x0D
          put 0x24 byte MEMORY_FILE3
        else
          put VALUE byte MEMORY_FILE3
        endif
      next j
      get MEMORY3_SIZE asize MEMORY_FILE3
      goto 0 MEMORY_FILE3
      getdstring TEXT MEMORY3_SIZE MEMORY_FILE3
      put TEXT string MEMORY_FILE

      get MEMORY1_SIZE asize MEMORY_FILE
      xmath MEMORY1_SIZE "MEMORY1_SIZE - 1"
      goto MEMORY1_SIZE MEMORY_FILE
      put 0x09 byte MEMORY_FILE
      putdstring "//TBL_LINE_END" 0x0E MEMORY_FILE
      put 0x0A0D short MEMORY_FILE

      print "%UNKNOWN0|X% %UNKNOWN1|X% : %ID%%NAME_DP%"
    endif

    for j = 0 < 0x9C
      get VALUE byte
    next j
next i


string EXT_NAME0 = TBL_FILENAME

#log EXT_NAME0 0 TBL_FILESIZE


get MEMORY1_SIZE asize MEMORY_FILE

string EXT_NAME1 = TBL_BASENAME
string EXT_NAME1 += ".txt"

log EXT_NAME1 0 MEMORY1_SIZE MEMORY_FILE


cleanexit
