DSKTOOL - A tool for creating Spectrum +3 game loaders

ZX80, ZX 81, ZX Spectrum, TS2068 and other clones
Post Reply
User avatar
jorgegv
Well known member
Posts: 312
Joined: Wed Nov 18, 2020 5:08 pm

DSKTOOL - A tool for creating Spectrum +3 game loaders

Post by jorgegv »

Hi guys,

I have been lately creating the +3 disk version of Cesare the Somnambule and due to the really tight that everything was laid out in memory at load time, using +3DOS for loading it was not really an option. So I set up to create my own loader in assembler, talking directly to the Floppy Controller with interrupts disabled.

The result of this is a tool to create a disk loader for games or programs which uses a specialized disk format (not +3DOS) and a couple of small ASM stubs which are provided.

For those interested, here is the document that describes the design.

A short extract from that document:

"The motivation behind DSKTOOL is to allow creating disk versions of ZX games for the Spectrum +3 as easily as TAP versions, and reusing the same game binaries from the TAP version. The easies way to achieve this is to use the disk as a sort of "virtual tape", or VTAPE, in which the game data is stored and read sequentially, the same way as a real tape would be used.

VTAPE is just a way to format the disk and data inside it, and a convention for accessing that data in an easy way from the game loader.

This tool generates the VTAPE disk image file (in standard DSK format) that can be later used to boot the game in +3 emulators, or used as a master for physical media generation.

A loader API is also provided to access the VTAPE disk and load the game data."
User avatar
dom
Well known member
Posts: 2287
Joined: Sun Jul 15, 2007 10:01 pm

Re: DSKTOOL - A tool for creating Spectrum +3 game loaders

Post by dom »

Interesting, would be fun to add support for that into appmake etc

I can understand that using a filesystem would cause a few memory problems. However, I always thought that DD_READ_SECTOR didn't use any extra memory - you provide it with the XDPB and it just reads the sector.

The benefit of using the ROM would be that the .dsk file would be supported on the Next - the FDC hardware isn't supported directly.

Edit: I might be wrong about FDC calls not being intercepted. Apologies if so.
Timmy
Well known member
Posts: 424
Joined: Sat Mar 10, 2012 4:18 pm

Re: DSKTOOL - A tool for creating Spectrum +3 game loaders

Post by Timmy »

I just want to say that it's a great idea! I have no use myself, but it's nice to have if I ever want to do anything with it in the future.
pjshumphreys
Member
Posts: 83
Joined: Sat Feb 06, 2021 2:32 pm

Re: DSKTOOL - A tool for creating Spectrum +3 game loaders

Post by pjshumphreys »

Same. Something that'll be useful for future projects. :)
User avatar
jorgegv
Well known member
Posts: 312
Joined: Wed Nov 18, 2020 5:08 pm

Re: DSKTOOL - A tool for creating Spectrum +3 game loaders

Post by jorgegv »

Just a comment for those early birds that have already looked at the code (are there any? :-) ):

I found some problems with Gotek drives that in turn were symptoms of deficient FDC emulation in most emulators: everything worked fine except in Gotek drives, and RetroVirtualMachine and Es.Pectrum emulators. It turned out that those emulators had much more faithful FDC emulation, and showed real errors in my code, which other emulators did not catch.

Those errors have been fixed, just in case someone is using the code I published a couple of days ago. Pull again from the repo for updated code.
jordi
Member
Posts: 63
Joined: Sun Oct 28, 2018 3:35 pm

Re: DSKTOOL - A tool for creating Spectrum +3 game loaders

Post by jordi »

how it actually works?
I do have this compilation script
https://github.com/jsmolina/z88dk-tutor ... r/build.sh

and i tried (without success) to move the banking and everything to many files using appmake.

How you can actually create a dsk from an app like this?
User avatar
jorgegv
Well known member
Posts: 312
Joined: Wed Nov 18, 2020 5:08 pm

Re: DSKTOOL - A tool for creating Spectrum +3 game loaders

Post by jorgegv »

hey jordi,

you are very close to the Cesare situation I solved with this tool, so it should be easy. You have a BASIC loader that loads the screen, loads main code, then bank 6, and then starts execution.

First I would do would be to convert the BASIC loader to a simple assembler loader that does the same. Just a routine for bank switching, and a few calls to ROM's LD_BYTES routine. So a new minimalist BASIC loader would load the ASM loader, which in turn loads the binaries that you already have. This still would be in TAP format.

When everything works fine with the new ASM loader in TAP format, you can try to modify that ASM loader to include the diskapi.asm and replace the calls to LD_BYTES with calls to fdc_load_bytes, which is the only public function in diskapi.asm. The register values for the latter are exactly the same as for LD_BYTES, so it should be just a matter of replacing the call destinations in your new ASM loader.

When you have the new loader using diskapi.asm, you can then use the dsktool.pl script to create the final DSK from the loader and all your previous binaries (which you already have used for the TAP). The original minimalist BASIC loader that you created for the ASM loader is not needed any more. The bootloader already knows how to load you ASM loader and run it.
User avatar
jorgegv
Well known member
Posts: 312
Joined: Wed Nov 18, 2020 5:08 pm

Re: DSKTOOL - A tool for creating Spectrum +3 game loaders

Post by jorgegv »

But again: I did this tool because I was _really_ tight on memory, and needed to use all available RAM, I could not dedicate a single byte to +3DOS. But if you are not so tight, I would definitely explore first the +3DOS way, since Z88DK works out of the box with it, even when using banking in the official way (i.e. __banked decorators)
jordi
Member
Posts: 63
Joined: Sun Oct 28, 2018 3:35 pm

Re: DSKTOOL - A tool for creating Spectrum +3 game loaders

Post by jordi »

I tried your approach as it would work also for Misifu Remeow, and it's a 2x1, but right now I don't succeed to use the loaders.

I should translate the code to these banked decorators, but I guess it would take time to do it so


lot of thanks!!
Post Reply