DLOAD resurrected for Dragon 32 (at 57600 baud)

A place to discuss everything Dragon related that doesn't fall into the other categories.
Post Reply
User avatar
tormod
Posts: 416
Joined: Sat Apr 27, 2013 12:06 pm
Location: Switzerland
Contact:

DLOAD resurrected for Dragon 32 (at 57600 baud)

Post by tormod » Wed Aug 21, 2013 9:55 pm

tl;dr: DLOAD is for loading programs from a computer to the Dragon over a serial port. Now it works on the Dragon 32, and fast!

The DLOAD command

Back in the eighties I was intrigued by the DLOAD BASIC command that was there in the ROM, undocumented and mysterious, but all it did was giving IO error. Later I have learned that it uses a simple protocol for loading files onto the CoCo/Dragon from another computer over a serial line. However there is not much related information or software to be found.

It turns out DLOAD is buggy or unusable on several CoCo versions. I don't know whether it works on Dragon 64 with its serial port. On the Dragon 32 the low-level drivers are missing. Since it has no serial port, there was no use for including the serial port drivers (whether using ACIA as on Dragon 64 or bit-banger as on CoCo). However, the command itself and much of its code still sits in the ROM nonetheless. Probably because it shares much code with CLOAD, and the Dragon ROM designers did not want - or did not have time - to get rid of the unused code at the risk of modifying proven, CoCo-compatible CLOAD code.

DriveWire inspiration

Seeing that people were able to run DriveWire on the Dragon hardware using CoCo ROMs, I started playing with DriveWire myself. I ported DWDOS (a small program for booting Nitros-9 from BASIC via DriveWire) to my Dragon 32, but without the possibility of running Nitros-9 it merely served to see that the lower-level DriveWire code (including the bit-banging code shared between DWDOS and HDB-DOS) actually worked fine with my DriveWire adapter.

Now what? Make DWDOS more flexible and make it load arbitrary files from the DriveWire server? The server only serves disk sectors, so it would
need much hacking on the server to make it serve files instead. So this led to porting HDB-DOS to the Dragon instead. However, running HDB-DOS
or any other DOS for Dragon, the Dragon itself keeps track of drives, tracks, sectors and file fragments and directories. If you principally just wants to load files into your Dragon (and faster and more convenient than the tape interface), all that means a lot of memory-eating overhead. Especially if, in lack of a cartridge, you have HDB-DOS itself sitting in RAM...

DLOAD back from the digital graveyard

Originally I was thinking of reusing the unused DLOAD command name for an extended DWDOS file loader. But after studying and disassembling the DLOAD code in the Dragon 32 ROM and realizing how complete it was, I thought it would be a fun project to see if I could hook up the DriveWire low-level drivers where the serial drivers were missing.

I searched for places in the code where new low-level drivers could be hooked up. The code properly calls the same SERIN and SEROUT vectors
as on the Dragon 64, but where the latter has low-level code to talk with the ACIA, the Dragon 32 just jumps to an RTS. And no cleverly
prepared RAM hooks for future use. The "console_in" routine is used, and calls back into the DLOAD code if DEVNUM = -3 (DLOAD/serial). So this must be intercepted. But DLOAD also calls SERIN directly many places, and anyway needs to set up DEVNUM and other things.

So I ended up copying the whole DLOAD dispatch routine. It simply needed recompiling to call my own SERIN/SEROUT/SERSET routines instead. These provide the minimal glue to use the DriveWire DWRead and DWWrite routines. And to much delight and surprise it worked! So there we have it:

Original DLOAD code missing low-level drivers + Low-level drivers from DriveWire = working DLOAD

Obviouosly it also requires a DLOAD server on the other computer. I have massaged a DLOAD server from 1997 that I found on the internets to deal with today's realities (faster server CPUs and the need for speed - 57600 baud). And to serve the file that the Dragon asks for, not only a predefined one.

Where to get the code?

The Dragon code is at https://gitorious.org/m6809-computer-tools/dload-dragon . Since I don't want to distribute Dragon ROM code (nobody seems to do?), there is a bit of convolution taken care of by the Makefile. It requires you to have your (legally acquired) ROM dump in the folder, and to have Ciaran's "6809dasm.pl" disassembler from http://www.6809.org.uk/dragon/ there too. It will disassemble the ROM and reassemble the DLOAD code part together with the DriveWire and glue code.

Also the hdbdos folder from Toolshed must be around, either copied in or soft-linked, for providing the DriveWire routines. It can be found at
http://sourceforge.net/p/toolshed/code/ ... ee/hdbdos/

The DLOAD server code is at https://gitorious.org/m6809-computer-tools/dload-server
I am running it on Linux, and a quick test on Windows did not work out (patches welcome).

How to use it?

Because the new DLOAD code loads to top of ram, start with CLEAR 200,&H7BFF. Then CLOADM the dload-dw.wav file and run EXEC to "install" the code. Now your DLOAD command is alive and kicking! Simply type DLOADM to fetch the default file from the server, or DLOADM "FILE" to load FILE from the server.

See the README file in the dload server folder for how to start the server. Note that you have to set the baud rate to 57600 baud on the serial
port before running the server. For instance:

Code: Select all

sh dload.stty /dev/ttyUSB0
stty 57600 < /dev/ttyUSB0
./dload test4096.bin B /dev/ttyUSB0 500
And you'll need a Dragon DriveWire adapter to turn the printer port into a serial port, of course!
dload.jpg
Obligatory screenshot (from debug run)
dload.jpg (23.4 KiB) Viewed 3410 times
What's more?

The low-level drivers and glue do not take much space, and can actually fit comfortably in unused spots in the Dragon 32 ROM (oh Dragon Data why why). Especially since the whole DLOAD higher level routine can be used as-is with only the SERIN, SEROUT and SERSET (baud selection routine, replaced by bit-banger initialization) vectors readjusted.

So filling in the holes in an otherwise unmodified BASIC ROM seems only right. Maybe adding an load-and-exec command too (DLOADXM?). Anyway, for this project I would need to partner up with someone who has an EPROM programmer and is willing to test it. Please tell.

A big advantage of a ROM version is that programs can use the whole RAM. Some existing programs will maybe load to top of RAM and overwrite the DLOAD routines in RAM. Not having to run "CLEAR" first would be a bonus, although the RAM version also could be tweaked to avoid this.

Having the DriveWire low-level routines in ROM, there would still be ca 160 free bytes left. It would be cool to squeeze in DWDOS/dwdgnhdb functionality too, so that we can load for instance HDB-DOS over DriveWire directly from power-on. But it might turn out to be be too tight on ROM space. Otherwise one can always load dwdgnhdb via DLOAD then the rest via DriveWire, but it would require switching from DLOAD to DriveWire on the server, fully doable, but less elegant.

As I mentioned, the DLOAD server which I have been modifying allows simple file selection. I have plenty of ideas for extended functionality, but I think rewriting it from scratch would make sense at this point. That has to come later in autumn for what I am concerned.

User avatar
tormod
Posts: 416
Joined: Sat Apr 27, 2013 12:06 pm
Location: Switzerland
Contact:

Re: DLOAD resurrected for Dragon 32 (at 57600 baud)

Post by tormod » Thu Aug 22, 2013 10:57 pm

I have added a DLOADXM command which loads and executes. Here is also a zip with precompiled WAV and linux (x86) binary.
Attachments
dload-dw.zip
binary snapshot 2013-08-22
(8.45 KiB) Downloaded 185 times
Last edited by tormod on Fri Aug 23, 2013 9:05 am, edited 1 time in total.

Rink
Posts: 236
Joined: Mon Sep 05, 2011 7:01 pm

Re: DLOAD resurrected for Dragon 32 (at 57600 baud)

Post by Rink » Fri Aug 23, 2013 8:43 am

Cool!

And some nice commenting in your assembler source which has taught me a few things, so thank you for that too.

User avatar
tormod
Posts: 416
Joined: Sat Apr 27, 2013 12:06 pm
Location: Switzerland
Contact:

Re: DLOAD resurrected for Dragon 32 (at 57600 baud)

Post by tormod » Fri Aug 23, 2013 11:53 pm

I am glad to hear that, Rink! I think heavy commenting belongs to assembler programming, where identifiers and structures often are less obvious than in higher level languages. Although I try to be clear and informative so that other people can follow and even learn from it, the main reason is to be able to understand it myself two weeks later :)

IMNSHO my latest commit is quite instructive, where I add a new command variant in just 13 bytes.

This is maybe food for another thread but I have been thinking of a larger effort to have the ROM demystified to make it easier for people to understand and hack it. Something like the CoCo Unravelled source, and doing it cleanly in legal terms as well.

Rink
Posts: 236
Joined: Mon Sep 05, 2011 7:01 pm

Re: DLOAD resurrected for Dragon 32 (at 57600 baud)

Post by Rink » Sat Aug 24, 2013 11:22 am

tormod wrote: This is maybe food for another thread but I have been thinking of a larger effort to have the ROM demystified to make it easier for people to understand and hack it. Something like the CoCo Unravelled source, and doing it cleanly in legal terms as well.
couldn't agree more. There's a lot of good stuff in that rom, and a lot of ideas crop up that really call for good knowledge of the existing functionality; which is not easy to come by.

I'd be happy to help in any way I could.

KenH
Posts: 177
Joined: Fri Oct 12, 2012 9:50 am

Re: DLOAD resurrected for Dragon 32 (at 57600 baud)

Post by KenH » Mon Aug 26, 2013 10:20 am

The DLOAD experiment looks very promising!

The way I see it, if Drivewire is a virtual floppy drive, DLOAD is essentially an ultra-fast virtual cassette tape.
It could be a great solution for running programs that can't be run from disk due to memory constraints/conflicts.

I think the perfect solution would be to swap the Dragon's internal ROM with an updated DLOAD based rom where all the cassette based commands (CLOAD/CLOADM/CSAVE/CSAVEM) are routed to the DLOAD server through the Drivewire cable.
I this way, you would have a modern fast storage option upon boot, without losing compatibility with any of the existing programs.

One could simply CLOAD the HDB-DOS quick loader to switch to a virtual disk based system, without any disk controller / EPROM cartridge (a perfect solution for a 64k Dragon).

I wonder if the DLOAD server could be integrated into the Drivewire server software (Drivewire is open source), so that the Drivewire server would handle both protocols. That would be the ultimate all in one solution.

For real tape to virtual tape transfer, a new command (named perhaps TAPEON/OFF) could be used to switch back to plain-old-tapes (in a similar way to the HDB-DOS DRIVEON/OFF command).

KenH
Posts: 177
Joined: Fri Oct 12, 2012 9:50 am

Re: DLOAD resurrected for Dragon 32 (at 57600 baud)

Post by KenH » Thu Aug 29, 2013 11:48 am

Here is the DLOAD server binary compiled for running on Mac OS X.
Usage should be same as linux (substitute ttyUSB0 with your Drivewire's Adapter port):

Code: Select all

sh dload.stty /dev/ttyUSB0
stty 57600 < /dev/ttyUSB0
./dload testfile.bin B /dev/ttyUSB0 500
Attachments
dload-dw-OSX.zip
DLOAD server for Mac OSX
(8.95 KiB) Downloaded 153 times

KenH
Posts: 177
Joined: Fri Oct 12, 2012 9:50 am

Re: DLOAD resurrected for Dragon 32 (at 57600 baud)

Post by KenH » Wed Sep 04, 2013 11:56 am

Found an interesting DLOAD related article on the March 1983 issue of 80 Microcomputing Magazine.

The article shows how to set up a TRS-80 model 1 as a DLOAD server for the TRS-80 Color Computer. Turns out Tormod's program is indeed a resurrection as DLOAD was once alive (although only at 1200 baud)...
CC DLOAD by Frank Bogardus
Loading and saving programs via the cassette recorder limits the Color Computer to lighter computing tasks. I needed a faster way to access programs without the expense of disks and without the major program handlers needed in the Color Computer. That amounted to an impossible set of specs, until I discovered DLOAD...
The complete article is attached.
Attachments
DLOAD-80Micro-3-1983-bw.zip
CC DLOAD, 80 Micro March 1983
(1.29 MiB) Downloaded 161 times

User avatar
tormod
Posts: 416
Joined: Sat Apr 27, 2013 12:06 pm
Location: Switzerland
Contact:

Re: DLOAD resurrected for Dragon 32 (at 57600 baud)

Post by tormod » Sun Sep 15, 2013 1:45 pm

Yes, the DLOAD server I found (originally from Burt Mitchell) might have its roots from the 80's as well. I have read somewhere that DLOAD for instance was used in classrooms with a multiplexer switch to connect the teacher's computer to each of the student computers in turns.

The part in this article about saving files by printing to the serial port is very interesting. I will have to check if that "PRINT #-2 filename" procedure works or can be made to work on the Dragon.

Post Reply