Page 1 of 2

Tools for converting Dragon DOS <-> DECB and CAS->DECB

Posted: Wed Dec 11, 2013 9:01 pm
by tormod
Tada! Some tools I have written and would like to share with you:
  • ddb2decb - convert Dragon Dos binary to DECB binary
  • decb2ddb - the other way around (duh)
  • cas2decb - parse a CAS file and write out a DECB binary
  • image-patcher - binary patching tool, can use either a DECB binary as a patch file, or its own simple ascii format
It is all at https://gitorious.org/m6809-computer-tools/conv-tools and patches and comments are very welcome.

These are all simple C programs with no dependencies, can probably be easily built on Windows using e.g. MinGW.

image-patcher takes arguments, the other three simply reads from standard input and writes to standard output, for instance:

Code: Select all

./image-patcher original.rom 0xC000 my-patches.bin
./ddb2decb < program.ddb > program.bin
Note that cas2decb only works for straight-forward CAS files, and not if there are for instance load-execute-load tricks or copy protection schemes involved.

The ascii patch format for image-patcher is:

Code: Select all

address1 byte1 [byte2 [...]]
address2 byte1 [byte2 [...]]
[...]
for example:

Code: Select all

602C A0 23
6049 39
6004 7E 60 32

Re: Tools for converting Dragon DOS <-> DECB and CAS->DECB

Posted: Wed Dec 11, 2013 11:28 pm
by zephyr
Thanks, Tormod. :) The only one I can't compile with gcc is cas2decb.
cas2decb.c:24:17: fatal error: err.h: No such file or directory
compilation terminated.

Re: Tools for converting Dragon DOS <-> DECB and CAS->DECB

Posted: Thu Dec 12, 2013 12:08 am
by tormod
Right, Windows does not have err.h. If you want to compile it, you can paste in my replacement implementations of the err.h functions from here: https://gitorious.org/dfu-util/dfu-util ... able.h#L23 or you can just replace "errx()" in the code with printf() and exit() - until I get this fixed up.

Re: Tools for converting Dragon DOS <-> DECB and CAS->DECB

Posted: Thu Dec 12, 2013 12:28 pm
by zephyr
It compiles OK now. But its not working correctly.
C:\cas2decb <formx9.cas >formx9.bin
Program "FORMX9 a?@" loads at 0x3F00, execs at 0x3F00 Could not read next byte after offset 0x02E6
The modified source code and compiled win32 binary are attached.

EDIT Attachment (cas2decb_test1.zip) removed.

Re: Tools for converting Dragon DOS <-> DECB and CAS->DECB

Posted: Thu Dec 12, 2013 3:09 pm
by tormod
I think reading from stdin on Windows needs special attention. stdin is by default opened as a text stream, so various conversions would happen on Windows. Try adding this to the top of main():

Code: Select all

freopen(NULL, "rb", stdin);
EDIT: Added to git

Re: Tools for converting Dragon DOS <-> DECB and CAS->DECB

Posted: Thu Dec 12, 2013 5:37 pm
by KenH
Thanks Tormod,
This could be a time saver for various applications :D

Re: Tools for converting Dragon DOS <-> DECB and CAS->DECB

Posted: Thu Dec 12, 2013 10:52 pm
by zephyr
tormod wrote:I think reading from stdin on Windows needs special attention. stdin is by default opened as a text stream, so various conversions would happen on Windows. Try adding this to the top of main():

Code: Select all

freopen(NULL, "rb", stdin);
EDIT: Added to git
Its still not working correctly.
C:\cas2decb <formx9.cas >formx9.bin
Could not read next byte after offset 0x0000

Re: Tools for converting Dragon DOS <-> DECB and CAS->DECB

Posted: Fri Dec 13, 2013 11:16 pm
by tormod
cas2decb should work fine on Windows now (I did some tests on MinGW). freopen() did not work so I use _setmode() instead. This should probably be added to ddb2decb and decb2ddb as well.

Re: Tools for converting Dragon DOS <-> DECB and CAS->DECB

Posted: Sat Dec 14, 2013 12:13 am
by zephyr
Cas2decb seems to be working perfectly now. :)

I added your changes to decb2ddb. It compiles OK; but does not seem to be working correctly. I tried it with the file created with cas2decb (which loads and runs ok under xroar) and a few others with the same result every time.
C:\decb2ddb <formx9.bin >zz.bin
Wrong DECB tail magic
Segmented files not supported

Re: Tools for converting Dragon DOS <-> DECB and CAS->DECB

Posted: Sat Dec 14, 2013 12:58 am
by tormod
decb2ddb does not support segmented binaries (because Dragon Dos binaries does not support it, so simple header conversion would not be enough).

And cas2decb generates segmented DECB binaries, because that it the simplest streaming conversion from CAS files (each tape block becomes a DECB segment).

So not all combinations will work...

Otherwise cas2decb must be rewritten to buffer the whole file before spitting out one DECB segment. Should not be difficult, it is just that I wrote cas2decb for a particular (streaming) application in mind and I don't need DDBs, I only wrote decb2ddb for symmetry reasons :)