Disk Masher System (DMS) - radishengine/drowsy GitHub Wiki

http://fileformats.archiveteam.org/wiki/Disk_Masher_System

Reference Code: xDMS (Andre Rodrigues de la Rocha & Heikki Orsila)

RLE Mode

Loop

  • get B
  • if B != 0x90:
    • output B, start again
  • get B
  • if B = 0x00:
    • output 0x90, start again
  • get B(b)
  • if B = 0xFF:
    • get U16BE
    • output B(b) repeated U16BE times, start again
  • else:
    • output B(b) repeated B times, start again

Quick Mode

all output also written to 256-byte ring buffer, initial offset: 251, moved forward 5 bytes at the end
note: RLE Mode always applied after Quick Mode

Loop

  • get b1
  • if b1 = 0:
  • get b8
  • output b8, continue
  • else:
  • get b2, b8
  • output (b2 + 2) bytes from the ring buffer at negative offset (b8 + 1), continue

Medium Mode

all output also written to 16384-byte ring buffer, initial offset: 16318, moved forward 66 bytes at the end
note: RLE Mode always applied after Medium Mode

Loop

  • get b1
  • if b1 = 0:
  • get b8
  • output b8, continue
  • else:
  • get b8
  • X = 3..66 depending on the value of b8
  • get b3..8 depending on value of b8
  • Y = 1..16384 depending on the value of b8 and b3..8
  • output X bytes from the ring buffer at negative offset Y, continue

Deep Mode

all output also written to 16384-byte ring buffer, initial offset: 16324, moved forward 60 bytes at the end
note: RLE Mode always applied after Deep Mode

Loop

  • node = root
  • repeat:
  • get b1
  • if b1 = 0:
    • node = left child of node
  • else:
    • node = right child of node
  • ...until node is a leaf node
  • reconstruct tree if necessary (out of scope for this document)
  • if node value < 256:
  • output node value, continue
  • else:
  • X = node value - 253
  • get b8
  • get b3..8 depending on the value of b8
  • Y = 1..16384 depending on the value of b8 and b3..8
  • output X bytes from the ring buffer at negative offset Y, continue

Heavy Mode

all output also written to ring buffer of length 8192 bytes if flag 0x08 is set, otherwise 4096 bytes
note: RLE Mode only applied after Heavy Mode if flag 0x04 is set

Init

  • if flag 0x02 is set:
  • get b9
  • if b9 > 0:
    • repeat b9 times:
      • get b5
      • init code table depending on the value of b5
  • else:
    • get b9
    • init code table depending on the value of b9
  • get b5
  • if b5 > 0:
    • repeat b5 times:
      • get b4
      • init PT table depending on the value of b5
  • else:
    • get b5
    • init PT table depending on the value of b5

Loop

  • get b12
  • if b12 >= 510:
  • value = b12
  • else:
  • get b16
  • value is derived from b12 and b16
  • if value < 256:
  • output value, continue
  • else:
  • X = value - 253
  • get b8
  • if b8 > 15 or (b8 = 14 and flag 0x08 is unset):
    • get b16
  • depending on b8 and maybe b16:
    • get b?
  • Y is derived from b8, maybe b16, maybe b?
  • output X bytes from the ring buffer at negative offset Y, continue