Jump to content

[AQUARIUS] Micro-Expander: RAM, ROM, AY-8910 and more!

Bruce Abbott

Recommended Posts

Making good progress tidying up the firmware. The debugger is sorted, USB disk handling is now more robust, and directory listings now pause when the screen is full. I added a HEX$() function to convert 16 bit integers to hexadecimal strings.


I tried to implement subdirectories, but it was harder than I thought. The CH376 changes to the subdirectory when it is opened, but forgets about it after opening a file. So I will have to cache the directory names and traverse the full path every time. I am thinking one directory level will be enough, then I only have to find 8 bytes to store its name (note: long names will not be supported!).


The debugger steals a bit over 2k of RAM for internal use. There's still almost 32k free so this hasn't been a problem for me. However I will provide an option to disable the debugger for those who want the maximum possible RAM available in BASIC. The micro-expander takes a 64k EPROM but only uses 16K of it, so you could have 4 different firmware versions selectable via the jumpers on the board. One pair might be needed to select between NTSC and PAL, then the other two would be debugger on/off. Alternatively the debugger could be disabled from the splash screen or via a BASIC command.


There is still ~1.8k of free space in the 16K ROM, so If anyone has any ideas for improvements or additions, now is the time to speak up!


Attached is a current snapshot of the source code (it totals just under 10,000 lines of Z80 assembly language), and a ROM image which can be run in Virtual Aquarius (note: anything that tries to access USB won't work in the simulator!). Since Virtual Aquarius doesn't have a built-in debugger, this ROM could be quite useful for software development.

aqubasic v09d rom.zip


Edited by Bruce Abbott
  • Like 2
Link to comment
Share on other sites

  • 2 weeks later...

Subdirectories are working well, and the system is now a lot more tolerant of disk errors. Testing showed up a few old bugs which I fixed today. Can't think of much else to add so it's time to wrap up the firmware and write some documentation.


Here's a list of BASIC enhancements:-


File commands:

DIR ["wildcard"] - print disk directory on screen. Optional wildcard filter eg. "*.BAS"

CAT - print list of files on screen, 3 files per line.

LOAD "filename" [address] - load BASIC program or binary data/code

SAVE "filename" [address, length] - save BASIC program or binary data/code

KILL "filename" - delete file from disk

RUN "filename" - run BASIC or machine code program

CD "path" - change directory


LOAD accepts BASIC programs and arrays with CAQ tape file headers (extension ".CAQ"). BASIC programs and arrays are also saved with a CAQ header, but can be named with whatever extension you want (".BAS" recommended for BASIC programs).


RUN accepts a filename without extension. If the file is not found then first ".BAS" and then ".BIN" will be added and another attempt made. This saves some typing when running programs from disk! The closing '"' is not required unless more arguments follow, which saves more typing!


CD accepts a single subdirectory or full path. ".." = up one level. "/" = root directory. CD with no argument shows the current path.



CD "subdir"

CD "subdir/subdir2/subdir3"

CD ".."

CD "/"

CD "/subdir"



NOTE: "\" is not supported!


CTRL-O = ~ (tilde). This character is required for entering MSDOS equivalents of long filenames. Alternatively you can type '=', which will be translated into '~' when the filename is processed.


Other commands and functions:

CALL address - call machine code program

DEBUG - invoke debugger

EDIT line_number - edit BASIC line with insert, delete, cursor movement keys

HEX$(number) - convert 16 bit integer to hexadecimal string


The command line also has enhanced editing. Keys are:-

CTRL-P = cursor left

CTRL-/ = cursor right

CTRL-\ = delete char under cursor

CTL-R = recall last line (no more having to type the whole line again!)


Commands and functions stolen from BLBASIC







OUT port




Many ROM routines can be called by user programs through vectors placed at the beginning of the ROM starting at $C000. These have fixed addresses and so are guaranteed to not move around in future firmware versions.


It's now 12:15am and I've been up since 3:00am yesterday - time to get some sleep! But the Aquarius is playing a nice collection of AY music, and I don't want to stop it...


  • Like 5
Link to comment
Share on other sites

  • 1 month later...

It's taken longer than I thought...


The turned pin connectors joining the boards together were too loose and easily bent. So I hacksawed the connectors off, unsoldered all the pins and replaced them with square pin connectors like those used on Arduino shields - a lot of work but well worth it. With the new connectors the boards are now a bit further apart, which provides more clearance for the CH376 etc.


The CH376 is wired onto the bottom board and connects to the USB socket via a 4 pin plug and socket. The stereo audio socket is mounted on a piece of matrix board under the top board (I will design a small PCB to do this job for the next batch).


Since the positions of the various sockets are now well defined, a case can be designed that is guaranteed to fit. I found a local business that does 3D printing for a good price, so designing a case will be my next project.


On the software side, I developed a 'lite' version of the debugger that reduces RAM usage by not saving the system screen. It appears on the top 10 lines of the screen, which obviously means the program being debugged can't use this area. However that still leaves 14 lines free for output. This will be put in the 2nd ROM bank, which can be selected via a jumper. The ROM now auto-detects PAL/NTSC timing, so there will be 2 banks left for other ROM versions.


Unfortunately I ran out of space in the ROM, so I removed the BLBASIC commands SCR, GET and PUT. A version of the ROM which includes them can be loaded from USB disk if required.


Over the next few days I will work out the unit cost, then I will be ready to take orders. At this time I have two units ready go, and another (which was to be my own) that still needs to have its connectors replaced. These work perfectly on my Aquarius, but there is a possibility they might not work as well on yours. Therefore I would prefer to get some feedback before making any more. Anyone who wants to be a 'beta tester' please pm me!


Note: the USB socket can be mounted horizontally or vertically, so tell me which orientation you want. I think horizontal is better because it keeps the USB stick out of sight at the rear and is safer (can't drop things into the socket).









Link to comment
Share on other sites

Here's the BOM in US$. By buying parts in bulk and 'vintage' chips from eBay I have managed to get the per unit parts cost down to $49. Shipping cost will depend on destination and carrier. NZ Post calculator estimates $15 for airmail to USA.


As promised, I am selling these units at material cost only.






  • Like 1
Link to comment
Share on other sites

  • 2 weeks later...

Aquaman requested a cable to connect Aquarius gamepads to my Micro-Expander. This turned out to be a bit trickier than I thought because the mini-expander schematic doesn't show which pins the port bits are connected to. I managed to figure it out from a photo of the PCB and a post by jaybird3rd. Then I 'just' had to map the Micro-expander's 20 pin connector pins to the D9 joystick socket.

Micro-Expander 20 pin parallel Port Socket (external view)

    .---------------------- KEY -----------------------.     
    | PB0  PB2  PB4  PB6  +5V  PA7  PA5  PA3  PA1  GND |
    |  19   17   15   13   11    9    7    5    3    1 |
    |                                                  |
    |  20   18   16   14   12   10    8    6    4    2 |
    | GND  PB1  PB3  PB5  PB7  +5V  PA6  PA4  PA2  PA0 |

               D9 Socket (external view)

                 \ 1  2  3  4  5  /
                  \  6  7  8  9  /

    D9         D9       20P    20P    PORT A/B    wire
  ATARI     AQUARIUS    JOY1   JOY2   RAD38910    color
  ======    ========    ====   ====   ========    =====
  2 DN      9 P5/DN       2     19      D0        Slate  
  4 RT      8 P1/RT       3     18      D1        White
  1 UP      7 P13/UP      4     17      D2        Black
  3 LT      6 P9/LT       5     16      D3        Brown
    -       5 P2-15       6     15      D4        Red
  5 B IN    4 K4          7     14      D5        Orange
  6 FIRE    3 K1          8     13      D6        Yellow
  9 A IN    2 K2-6        9     12      D7        Green
  8 GND     1 GND         1     20      GND       Violet
  7 +5V       -          10     11      +5V       Blue

Aquarius Joypad #1 to Micro-Expander
Func  D9   Color   UEX 20P  
====  ==   ======  =======       
GND    1   Violet     1
K2-6   2   Green      9  
K1     3   Yellow     8   
K4     4   Orange     7   
P2-15  5   Red        6
LEFT   6   Brown      5   
UP     7   Black      4   
RIGHT  8   White      3
DOWN   9   Slate      2   

Atari Joystick to Micro-Expander  
Func   D9    Color    UEX 20P  
====   ==    ======   =======       
UP      1    Black       4  
DOWN    2    Slate       2  
LEFT    3    Brown       5  
RIGHT   4    White       3  
B IN    5    Green       9  
FIRE    6    Yellow      8  
+5V     7    Blue       10  
GND     8    Violet      1  
A IN    9    Green       7

Wire colors refer to the ribbon cable I used to make the adapter. The cable is reversed on each side of the 20 pin IDC plug, so the colors are the same for both joysticks. If you only have one gamepad or joystick then only the right-hand cable and D9 socket are required. Photos below show the adapter I made for Aquarius gamepads. An Atari joystick cable would be the same except for connections to the D9 sockets.


I also made an Atari joystick adapter with the 20 pin plug and D9 socket connected via a small piece of matrix board. Using this I was able to play some games with my joystick, but Night Stalker needs 4 buttons to fire in different directions (perhaps it can be hacked to work with a single fire button?).







  • Like 3
Link to comment
Share on other sites

  • 2 weeks later...

Oh man! I hope I haven't missed out on the chance to buy one of these gems!

Don't worry, I am making more of them. Still waiting for confirmation of board production from OSHpark. Meanwhile I have just (as of 2 minutes ago) created a page on my website to document the project and store files for download. The page is a bit crude, but functional (hoping to revamp the site soon).

  • Like 1
Link to comment
Share on other sites

Don't worry, I am making more of them. Still waiting for confirmation of board production from OSHpark. Meanwhile I have just (as of 2 minutes ago) created a page on my website to document the project and store files for download. The page is a bit crude, but functional (hoping to revamp the site soon).



Awesome news. The website is great, and makes me anxious for the next run. Thank you!

Link to comment
Share on other sites

The Micro-Expander is working great! It is really easy to transfer files from the PC to the Aquarius and loading files from USB is extremely fast.

I just need to think to the Mattel advert with the arrow poining to the Aquarius bus, saying "Anything that will happen in the future will fit here" :D

You did that!



  • Like 1
Link to comment
Share on other sites

The Micro-Expander is working great! It is really easy to transfer files from the PC to the Aquarius and loading files from USB is extremely fast.

Thanks for the positive feedback. Any other impressions or suggestions are welcome :)


"Anything that will happen in the future will fit here"



I bet they never imagined what the future would bring!


Some good news for those of you who are still waiting for their units - the boards were finally shipping from OSH park today. Should get here in about 2 weeks.

  • Like 1
Link to comment
Share on other sites

  • 2 weeks later...
  • 2 weeks later...

In this post I explain how to run machine code tape (CAQ) programs from disk.


In most cases all you have to do is load the BASIC program and edit the line that loads the machine code array. For example, here is the BASIC program for D-Fender:-

5 U=0
10 X=0
20 DIMA(2429)
40 POKE14340,PEEK(14552)+7
50 POKE14341,PEEK(14553)
60 X=USR(0)

Change line 30 to this:-


Then save the BASIC program as eg. "DFEND.BAS", and you can run the game by simply typing RUN"DFEND


Arrays are stored in memory after the end of BASIC text and variables, so changing anything in the BASIC program may cause the array address to change. Usually this is taken care of by the machine code which relocates itself to a higher address. However some programs expect the array to be at a fixed address, so they crash. Machine code complied with zcc suffers from this issue.


Here is one example, "vtdemo_BAS.CAQ":-

5 U=0
10 X=0
20 DIMA(00953)
40 POKE14340,PEEK(14552)+7
50 POKE14341,PEEK(14553)
60 X=USR(0)

Though lines 40-50 correctly calculate the actual load address, the C code was originally compiled to run at 14712 and does not relocate itself. So the machine code is entered at the correct address, but crashes shortly afterwards because all the fixed addresses in it are wrong. To fix this we need some way to adjust the size of the BASIC program so the array address matches what the code was compiled for. Unfortunately this is not just a simple matter of matching files sizes, because when run the modified BASIC program may allocate a different amount of variable space, which also affects the array address!


By trail and error I have determined that the following code works when the BASIC file size is adjusted to 132 bytes.

5 U=0
10 X=0
20 DIMA(00953)
40 POKE14340,120
50 POKE14341,57
60 X=USR(0)

Lines 40-50 poke a fixed value of 14712 into the USR address. This reduces the size of the BASIC program so we have enough space to add the filename.


Line 30 is modified as usual (change CLOAD to LOAD, add filename etc.). The final file size is then adjusted to 132 bytes by changing the number of dots after the REM statement on the same line (this will vary depending on the filename length).


Save the program with eg. SAVE "VT_DEMO.BAS" and then do DIR to check that the file size is 132 bytes. If not then edit line 30 and change the number of dots after the REM, then save it again.


Note that programs which expect the array to be at a fixed address will also fail if using a version of BASIC which has a different start of BASIC text. BASIC programs are relocated after loading so this is not a problem for them. However machine code programs must either have a relocator built in, or be loaded to a specified address. Unfortunately standard Aquarius BASIC cannot load machine code to a specified address, but my USB BASIC does - with LOAD "filename", <address>. This provides a safer way to load machine code rather than using an array whose address can change. To use this method with CAQ tape files you should first remove (using eg. a HEX editor) the 19 byte CAQ header, then save the file as raw binary.

Edited by Bruce Abbott
  • Like 2
Link to comment
Share on other sites

  • 3 weeks later...
  • 3 weeks later...
  • 1 month later...
  • 1 year later...

Really quiet for long time.


I have bought the PCBs here:


USB CH37S6 module here:


AY have I from here:


(But I haven't tested yet, if they are fakes or not.)


The HOW TO is here:



I will see, if I will be able to put it all together.

  • Like 1
Link to comment
Share on other sites

Wow! This is awesome. This is what I've been waiting decades for, like since I ordered my Aquarius Disk Drive that never arrived.

I get these AtariAge e-mails every week, I never see this thread posted not once.

Somehow years pass and then a Christmas-eve comes along and it's like 1983 all over again.


I'm really happy for all you hardcore Aquarius fans who got your hands on this build...you're all the cool kids on the block now.

Happy Holidays!

Link to comment
Share on other sites

  • 5 months later...

Hi all,


The aquarius ram expander that the OP did, it has the DS1233. I am able to locate it but I don't know the exact reset voltage to buy for. Also, the DS1233 is expensive. Is there a substitute for it?


DigiKey DS1233 search results: https://www.digikey.com/products/en/integrated-circuits-ics/pmic-supervisors/691?k=econo+reset&k=&pkeyword=econo+reset&sv=0&pv1291=714&sf=1&FV=ffe002b3%2Cffec56cc&quantity=&ColumnSort=0&page=1&pageSize=25



Edited by unebonnevie
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...