#!/usr/bin/env python3

import sys

def strip(b: bytes) -> bytearray:
    r = bytearray(b)
    while r[-1] == 0: del r[-1]
    return r

inb = open(sys.argv[1],'rb').read()

main = inb[0x200:0x2ff]
hbl  = inb[0x400:0x4ff]

open(sys.argv[1]+'.main','wb').write(strip(main))
open(sys.argv[1]+'.hbl' ,'wb').write(strip(hbl ))

