Friday, October 14, 2022

Part 1h: PCBs and my favorite program converted for Tiny BASIC

Before I get too far with writing bigger programs for my 48K version of Tiny BASIC I need to get PCBs finalised and ordered.

I want to pay homage to the original PCB layout so I started with the original 8" x 8" layout and tried to keep the orientation of parts in a similar layout. That was for the original PIA and PSU components, the RAM and ROM will take up a lot less space.

This is most of the components layed out on the original 8" x 8" PCB:


I didn't bother placing the original tracks as much of that would change in the new layout anyway. I do all my PCB layouts manually because I can control exactly how I want the tracks to route. The original PCB is double sided and so will the new ETA-3400X.

This is my new board layout compared to the original. After a few tweaks I eventually I end up at 3.9" x 5.5", a bit bigger than other clones, but it has more parts on it:

I've kept the same orientation for the large caps at the top. Modern replacements will be much smaller. I also tidied up the analogue serial circuitry which was all over the place on the original, and I've moved most of the external connections to a more accessible location.

At the last minute I decided to add LEDs to the cassette port without too much thought. After three cross checks between the circuit diagram and the PCB layout I was confident that I didn't have any errors (famous last words). This is an image from the Gerber viewer on JLCPCB. It's a good way to see if you have any obvious errors. I often have problems with PCB outline size as I'm using an old program called Protel 99SE which is the only decent program I can run on my aging computers.

I stuck with green solder mask as that's the same colour used on the original ETA-3400. The centre hole is just in case it needs more support in the middle. I won't use it unless I have to.

I ordered boards from JLCPCB which will take about 20ish days to arrive, so now what do I do in the mean time...


I go boldly where no man has gone before...


Well it's true, no one else has written Star Trek for Tiny BASIC on the ETA-3400X.

Yes it's Star Trek time. I looked for a version for Tiny BASIC on the www and that's when I realise that it's not that easy to find a version for Tiny BASIC. Luckily on the ET-3400 group, member Brian Denley came to the rescue with a version of Star Trek for Tiny BASIC that he had kept in his archives but never used in anger.

Unfortunately that's when I find out that Tiny BASIC was written for a lot of computers back in the early days of computers, and each version was somewhat different, supporting different command sets. And this version used arrays, delays, and strings, and handles boolean logic differently, none of which this dialect of Tiny BASIC supported. I didn't want to rewrite the program without those statements because it would be a pretty lame version. However there are work-arounds to every problem, so this is an example of how each of those statements is converted:

ARRAY assignment statement (@):

190 @(I) = -100 * M - 10 * J - RND(8) - 1

changed to USR call in Fantom monitor that does a POKE command to a block of memory reserved for one array. The Q = is just a dummy statement to make Tiny BASIC happy:

190 Q = USR(-5096, Z + I, 100 * J + 10 * M + RND(8) + 1)

Boolean logic IF THEN statements:

480 IF (A = 113) + (A = 27) A = -1
490 IF A > 0 GOTO 350

changed to two IF statements in series and some logic sequence changes:

480 IF A <> 113 IF A <> 27 GOTO 490
481 A = -1
490 IF A > 0 GOTO 350

ARRAY read statement (@) within IF GOTO statement:

940 IF @(8 * I + J + 62) = 2 GOTO 970

changed to USR call to Fantom monitor to do a PEEK command within the reserved array in an IF GOTO statement:

940 IF USR(-5100, Z + 8 * I + J + 62) = 2 GOTO 1030

READ a KEY statement (INKEY):

6780 REM DO
6790 INKEY A
6800 NAP 10
6810 IF A = -1 GOTO 6780

This is changed to read a character from the serial terminal using a USR call in the Fantom II monitor, then convert it to a numerical ASCII equivalent in A:

6790 A = USR(-1823)
6795 A = A - (A / 256 * 256)
6796 IF A < 0 LET A = A + 256
6797 IF A < 96 LET A = A + 32
6810 IF A = -1 GOTO 6790

Delay statement (NAP) in above loop:

6800 NAP 10

I had never heard of this statement in any other dialect of BASICs so it took a while to find out that it was just a delay statement for a certain time. I simply removed this line as it isn't needed.

I also discovered when fixing some bugs in the program, that the arrays in the original program were 16 bit, meaning each element can hold a value from -32768 to +32767. However my arrays are only using an 8-bit memory location so it can only hold values from 0 to 255. Bugger, what to do now ?

I worked out that the main area where 16 bits was used was for the data that represents the contents of each sector within the galaxy. So a value of 416 would mean that that sector had 4x Klingons, 1x Starbase and 6 Stars. There is a maximum of 1 Starbase in each sector, a maximum of 9 Stars and a maximum of 9 Klingons theroetically, although typically it's about 5 maximum that you see in the game. That would mean I the largest number could be 919.

to get around this I swapped around the Klingons and Stars so that the maximum number will now be 199. That will fit in 8-bits, problem solved !. I amend the entire program to reflect the changes.

Saving to Tape a lot

I had been saving this program to tape periodically after about every half hour of typing, so I had a backup if the program crashed or the power failed. This was going great guns and was very reliable. The time taken to save kept creeping up in minutes. Eventually the program was taking about 24 minutes to load a 14K file off tape. Wow that's slow, and it reminds me of my old TRS-80 which took that long to load 16K Star Trek off cassette tape.

Anyway your waiting to see proof of the game running so here is a few screen shots. Since I don't have this connected by serial port to my PC I am unable to capture the text, so it's just pictures from my phone.

Mission and Long Range Scan


Firing Torpedos


Short Range Scan


Galaxy map


Enterprise destroyed

Well, you can't win 'em all Cap'n.

That completes Part 1 just at the halfway mark, I can now move onto Part 2 where I get in over my head and run into more problems...







No comments:

Post a Comment

Part 2o: The future of the ETA-3400X

You can find all the work I've done on the ETA-3400X and 8K ALTAIR 680 BASIC, except for the ETA-3400X Gerber files, on the ET-3400 grou...