#!/usr/bin/ruby -Ks $KCODE = 's' if ARGV.empty? then $stderr.print "Usage: #{$0} PRG001.PGI\n" exit -1 end def parse_me(buf) b = buf.dup while b.size > 0 do head = b.slice!(0, 7) tag, size, type = head.unpack("nNC") printf("tag %04xh, size %d (%08xh), type %02xh\n", tag, size, size, type) body = b.slice!(0, size - 7) puts body end end b = File.read(ARGV.shift) b.slice!(0, 0x28) parse_me(b)