Jump to content

Photo

[Aquarius] How to load an Assembly program with the Aquarius

cload assembly

2 replies to this topic

#1 Fabrizio Caruso OFFLINE  

Fabrizio Caruso

    Space Invader

  • 46 posts

Posted Fri Feb 23, 2018 12:03 PM

Hi

I have developed CROSS CHASE,

https://github.com/F...uso/CROSS-CHASE

which is a massively multi-platform 8-bit game that runs on nearly anything with 8 bits including the Mattel Aquarius (+4k and +16k versions supported).

I have done this through Z88DK which produces two files: a BASIC loader and a file containing the actual Assembly code.
The load procedure looks like this:
type CLOAD
Attach loader file 
type RUN
Attach second file

This is a bit inconvenient. I would like to just have one single file to load.

Is there a "good" way to just use a single file?

A "bad" way would be to embed the Assembly into the BASIC with DATA lines because it would eat too much RAM. 

Where in memory does CLOAD load the code?

   Fabrizio



#2 jaybird3rd ONLINE  

jaybird3rd

    Quadrunner

  • 8,854 posts
  • "Excuse me, sir? I have a question ..."
  • Location:806.4616.0110

Posted Sat Feb 24, 2018 9:34 PM

See my response here.  If I remember correctly, the compiler used by Z88DK compiles the code to run from expanded RAM, which on the Aquarius begins at address $4000, and the bootloader simply copies the code from tape into RAM and then jumps to $4000 to begin execution.  If the compiler can be configured to use address $C010 instead, it should be possible to compile a binary which can run directly from the cartridge like Mattel's first-party Aquarius games, which would be much faster (the reason the program can't start at $C000 is because the first 16 bytes of the cartridge are reserved for a simple cartridge validation signature).  If that's not possible, an alternative would be to write a simple cartridge-based bootloader which copies the code from the cartridge into RAM and then jumps into it, as I describe in the other post.  The only problem with that approach is that (on real hardware) it would require a Mini Expander, since you'd need to plug in the program cartridge AND a memory module.



#3 Bruce Abbott OFFLINE  

Bruce Abbott

    Chopper Commander

  • 122 posts

Posted Mon Feb 26, 2018 1:22 PM

You can append binary code to the end of a BASIC tape file and it will be loaded in with the program, but there is a catch - the end of the tape file is marked with 10 zero bytes, so if your code has 10 consecutive zero bytes in it the tape loader will quit at that point. If you can ensure that the binary doesn't have any more than 9 consecutive zero bytes in it then you're fine, otherwise you have to mangle the data and restore it after loading.  

 

CLOAD loads BASIC programs into the memory location stored in $384F,50 (14415,6). In a stock Aquarius this will be $3901, but extended BASIC needs more system variable space so it moves the start of BASIC up to a higher memory location. That means any code you embed in the file will also be moved up, so you can't rely on it being at a fixed memory location. The solution is to compile your code for a location that is guaranteed to be beyond the end of the BASIC loader (eg. $4000), then in your loader move the code to its correct location before jumping into it. 

 

On a real Aquarius loading from tape is very slow and unreliable, so it might be better to put it in a cartridge ROM.







Also tagged with one or more of these keywords: cload, assembly

0 user(s) are browsing this forum

0 members, 0 guests, 0 anonymous users