Jump to content

Photo

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


92 replies to this topic

#76 Bruce Abbott OFFLINE  

Bruce Abbott

    Chopper Commander

  • Topic Starter
  • 110 posts

Posted Thu Apr 13, 2017 7:16 PM

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. 

Attached Files


Edited by Bruce Abbott, Thu Apr 13, 2017 7:16 PM.


#77 Bruce Abbott OFFLINE  

Bruce Abbott

    Chopper Commander

  • Topic Starter
  • 110 posts

Posted Sun Apr 23, 2017 5:21 PM

And now... subdirectories!!!

 

 

 

 

Attached Thumbnails

  • rootdir.jpg
  • subdir.jpg
  • subdirs.jpg


#78 Bruce Abbott OFFLINE  

Bruce Abbott

    Chopper Commander

  • Topic Starter
  • 110 posts

Posted Sat Apr 29, 2017 6:23 AM

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.

examples:-

 

CD "subdir"

CD "subdir/subdir2/subdir3"

CD ".."

CD "/"

CD "/subdir"

CD

 

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

CLS

LOCATE

PSG

SCR

GET

PUT

OUT port

IN(port)

JOY()

 

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...

 



#79 Bruce Abbott OFFLINE  

Bruce Abbott

    Chopper Commander

  • Topic Starter
  • 110 posts

Posted Mon Jun 5, 2017 3:07 AM

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).

 

 

 

 

Attached Thumbnails

  • debug.jpg
  • rear.jpg
  • internal.jpg
  • old_vs_new.jpg


#80 Bruce Abbott OFFLINE  

Bruce Abbott

    Chopper Commander

  • Topic Starter
  • 110 posts

Posted Thu Jun 8, 2017 7:36 AM

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. 

 

 

  

 

Attached Thumbnails

  • bom.png


#81 EamonShoot OFFLINE  

EamonShoot

    Space Invader

  • 32 posts

Posted Sat Jun 10, 2017 11:39 AM

Payment sent Bruce. Really looking forward to getting my hands on this great piece of kit! Thank you for the time and effort you have put into this so far.


Sent from my iPad using Tapatalk

#82 mvdsteenoven OFFLINE  

mvdsteenoven

    Chopper Commander

  • 181 posts
  • Location:Netherlands

Posted Thu Jun 15, 2017 1:34 PM

Hi Bruce, I have also send my payment. Can't wait to see it work :) :) :)



#83 Bruce Abbott OFFLINE  

Bruce Abbott

    Chopper Commander

  • Topic Starter
  • 110 posts

Posted Sat Jun 24, 2017 10:18 PM

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?).

 

Attached Thumbnails

  • crimped ribbon cables.jpg
  • D9 top.jpg
  • D9 bottom.jpg
  • Micro-Expander to Aquarius joysticks cable.jpg
  • Astro Smash with joystick.jpg


#84 MattelAquarius OFFLINE  

MattelAquarius

    Moonsweeper

  • 465 posts
  • Location:Washington D.C.

Posted Tue Jul 4, 2017 11:45 AM

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



#85 mvdsteenoven OFFLINE  

mvdsteenoven

    Chopper Commander

  • 181 posts
  • Location:Netherlands

Posted Tue Jul 4, 2017 12:23 PM

Hi Bruce,

 

My micro-expander arrived today!

I'm going to try it tomorrow

Can't wait

 

Regs

Martin



#86 Bruce Abbott OFFLINE  

Bruce Abbott

    Chopper Commander

  • Topic Starter
  • 110 posts

Posted Tue Jul 4, 2017 10:28 PM

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).



#87 Bruce Abbott OFFLINE  

Bruce Abbott

    Chopper Commander

  • Topic Starter
  • 110 posts

Posted Tue Jul 4, 2017 10:37 PM

Hi Bruce,

 

My micro-expander arrived today!

I'm going to try it tomorrow

Can't wait

 

Regs

Martin

Finally! I was beginning to wonder that they might have all been lost in the mail.



#88 EamonShoot OFFLINE  

EamonShoot

    Space Invader

  • 32 posts

Posted Sun Jul 9, 2017 3:07 PM

Finally! I was beginning to wonder that they might have all been lost in the mail.


Mine also arrived a few days ago - can't wait to play now! Thanks Bruce


Sent from my iPad using Tapatalk

#89 MattelAquarius OFFLINE  

MattelAquarius

    Moonsweeper

  • 465 posts
  • Location:Washington D.C.

Posted Tue Jul 11, 2017 4:18 PM

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!



#90 mvdsteenoven OFFLINE  

mvdsteenoven

    Chopper Commander

  • 181 posts
  • Location:Netherlands

Posted Wed Jul 12, 2017 12:09 PM

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!

Thanks,

Martin



#91 Bruce Abbott OFFLINE  

Bruce Abbott

    Chopper Commander

  • Topic Starter
  • 110 posts

Posted Thu Jul 13, 2017 3:37 PM

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.



#92 Bruce Abbott OFFLINE  

Bruce Abbott

    Chopper Commander

  • Topic Starter
  • 110 posts

Posted Mon Jul 24, 2017 10:23 PM

PCBs arrived today.

 

This version fixes a few minor layout issues and the CH376 fits internally without having to cross over any wires, so they should be quicker to assemble.   

 

 

 

Attached Thumbnails

  • pcbs.jpg


#93 Bruce Abbott OFFLINE  

Bruce Abbott

    Chopper Commander

  • Topic Starter
  • 110 posts

Posted Sun Aug 6, 2017 12:48 PM

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)
30 CLOAD*A
40 POKE14340,PEEK(14552)+7
50 POKE14341,PEEK(14553)
60 X=USR(0)

Change line 30 to this:-

30 LOAD"DFEND_A.CAQ",*A

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)
30 CLOAD*A
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)
30 LOAD"VTDEMO_A.CAQ",*A:REM...
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, Sun Aug 6, 2017 12:54 PM.





0 user(s) are browsing this forum

0 members, 0 guests, 0 anonymous users