open FDDE XWH 0
open FDDE XWB 1

idstring RXWS
get RXWSsz long   # minus 16byte header
get UNKNOWN long   # 0x200
get NULL long
idstring FORM
get FORMsz long   # -16
get UNKNOWN long   # 0x100
get NULL long
get STREAMS long

set FTXT_LOC long FORMsz
math FTXT_LOC += 0x20
goto FTXT_LOC
idstring FTXT
get FTXTsz long
get UNKNOWN long   # 0x100
get NULL long
savepos FTXT_LOC
log MEMORY_FILE FTXT_LOC FTXTsz
get STREAMS2 long MEMORY_FILE   # synonymous with 'STREAMS' value

goto 0x24

for i = 0 < STREAMS
   get UNK1 short   # 0x1c00
   get UNK2 short   # 2/3
   get UNK3 long   # 0x7f7f
   get UNK4 short   # 0x200
   get FREQUENCY short
   get NULL long
   get OFFSET long
   get SIZE long
   get LOOP_POS long
   
   get STPOS long MEMORY_FILE
   savepos MFPOS MEMORY_FILE
   goto STPOS MEMORY_FILE
   get NAME string MEMORY_FILE
   string NAME += .RXW
   goto MFPOS MEMORY_FILE
   
   set MEMORY_FILE2 binary \x52\x58\x57\x53\x30\x00\x00\x00\x00\x02\x00\x00\x00\x00\x00\x00\x46\x4F\x52\x4D\x20\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00
   
   putvarchr MEMORY_FILE2 0x24 UNK1 short
   putvarchr MEMORY_FILE2 0x26 UNK2 short
   putvarchr MEMORY_FILE2 0x28 UNK3 long
   putvarchr MEMORY_FILE2 0x2c UNK4 short
   putvarchr MEMORY_FILE2 0x2e FREQUENCY short
   putvarchr MEMORY_FILE2 0x38 SIZE long
   putvarchr MEMORY_FILE2 0x3c LOOP_POS long
   
   append
   log MEMORY_FILE2 OFFSET SIZE 1
   append
   
   math SIZE += 0x40
   log NAME 0 SIZE MEMORY_FILE2
next i