uroof: cosmetix
[urasm.git] / dox / dmbdump.d
blob544ce58af6ec437131a8ddb19ba4164a34486bcf
1 #!/usr/bin/env rdmd
2 import std.stdio;
4 import iv.stream;
7 void dumpDMB (File fl) {
8 auto sign = fl.readNum!uint();
9 if (sign != 0x30424D44u && sign != 0x31424D44u) throw new Exception("invalid signature");
10 bool v1 = (((sign>>24)&0xff) == 0x31);
11 auto pc = fl.readNum!ushort();
12 if (pc) writefln("run from: #%04x (%s)", pc, pc);
13 if (v1) {
14 auto clr = fl.readNum!ushort();
15 if (clr) writefln("CLEAR #%04x (%s)", clr, clr);
17 auto count = fl.readNum!ushort();
18 while (count--) {
19 auto size = fl.readNum!ushort();
20 auto addr = fl.readNum!ushort();
21 if (addr != 0) {
22 writefln("#%04x %s (%s)", addr, size, addr);
23 } else {
24 addr = fl.readNum!ushort();
25 auto page = fl.readNum!ubyte();
26 writefln("%02s #%04x %s (%s)", page, addr, size, addr);
28 fl.seek(size, SEEK_CUR);
33 void main (string[] args) {
34 foreach (auto fn; args[1..$]) {
35 writeln("=== ", fn, " ===");
36 dumpDMB(File(fn));