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

Hardware Hacking, Programming and Game Solutions/Cheats
User avatar
tormod
Posts: 416
Joined: Sat Apr 27, 2013 12:06 pm
Location: Switzerland
Contact:

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

Post 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
zephyr
Posts: 1474
Joined: Mon Jul 21, 2008 1:18 am

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

Post 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.
User avatar
tormod
Posts: 416
Joined: Sat Apr 27, 2013 12:06 pm
Location: Switzerland
Contact:

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

Post 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.
zephyr
Posts: 1474
Joined: Mon Jul 21, 2008 1:18 am

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

Post 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.
Last edited by zephyr on Sat Dec 14, 2013 2:20 am, edited 1 time in total.
User avatar
tormod
Posts: 416
Joined: Sat Apr 27, 2013 12:06 pm
Location: Switzerland
Contact:

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

Post 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
Last edited by tormod on Thu Dec 12, 2013 7:53 pm, edited 1 time in total.
KenH
Posts: 182
Joined: Fri Oct 12, 2012 9:50 am

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

Post by KenH »

Thanks Tormod,
This could be a time saver for various applications :D
zephyr
Posts: 1474
Joined: Mon Jul 21, 2008 1:18 am

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

Post 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
User avatar
tormod
Posts: 416
Joined: Sat Apr 27, 2013 12:06 pm
Location: Switzerland
Contact:

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

Post 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.
zephyr
Posts: 1474
Joined: Mon Jul 21, 2008 1:18 am

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

Post 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
User avatar
tormod
Posts: 416
Joined: Sat Apr 27, 2013 12:06 pm
Location: Switzerland
Contact:

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

Post 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 :)
Post Reply