Sunday, 26 November 2023

ZX80 BASIC on a Minstrel 4D - Part 1

Yes, you read that right, ZX80 4K Integer BASIC running on a Minstrel 4D.

This is the first part in a series of posts where I will be starting with building a modified version of ZX80 BASIC and later moving on to a version of ZX81 BASIC that will run on the Minstrel 4D hardware. The final goal will be to get it running as a ZX81, and capable of running an unmodified version of 3D Monster Maze.

I will talk about the practicalities of how that works in a later post, in this post I talk about the initial idea and getting it running.


It was one of those occasions where a silly idea crept into my head and I had to give it a go.

Back in the dim and distant part, one of the original plans for the Minstrel 4th / 4D is that as well as the standard Forth, it would include other language and utility ROMs.

There are two jumpers on the 4th and two DIP switches on the Minstrel 4D to select alternate ROM images, although none were supplied as standard. The memory map of the Minstrel also has an 5K extra space available, meaning these language ROMs could be up to 13K.

I worked for quite a while on a version of Microsoft BASIC, adapted from NASOM BASIC, but I never quite got that right.

I should maybe go back and try that again, but it has been such a long time, I would probably end up starting all over again.

The main issue was the screen editor. The version of BASIC is designed to work with a serial terminal, as seen with things like the RC2014.

I tried to adapt the Ace screen editor, but that is a bit odd with the bottom one or two rows also effectively being the keyboard buffer.

I also looked at adapting the NASCOM screen editor, but that was also problematic due to the way it had a 48 column display in the middle of 64 byte screen lines.

Anyway, that didn't happen so got shelved.

....

And then, two years later, I had an idea. Hey, why not use the screen editor from the Spectrum.

But wait, why use the NASCOM BASIC, why not use the Spectrum BASIC as well.

Hey, why not make the Spectrum ROM run on the Minstrel 4th.

Well. That was last Sunday (*at the time of writing this post which went to Patreon about a month ago)

I spent a while working on the Spectrum version, but it was clear that it was going to require a lot of work to simplify the pixel based display with colour attributes to one that was character based.

Hey, what about the ZX81? That was character based, let's use that.

So I started again, but this time with the ZX81 ROM. That version is almost working, but there were some issues with slow mode that I need to rethink.

Hey, what about the ZX80? That doesn't have slow mode.

So, I started again, this time with the ZX80 4K Integer BASIC ROM.

And well, it works. There will be a full blog post explaining how I modified it to work, but for the moment, suffice to say I have it running on the Minstrel 4D.

There are various things to deal with to make it usable. The first is the keyboard, the Ace has it's bottom row of keys shifted around compared to the Sinclair machines, so I needed to adjust the key tables to cope with the new layout (for the moment, the Symbol Shift key will be the ZX80's full stop and comma key). I may look at remapping to match the symbols and maybe even a tokeniser for BASIC so you type in P R I N T rather than pressing O (yes, it was on O on the 4K BASIC, not P).

The next thing to tackle was loading. And this is where I initially got stuck. I needed to load programs to test things further, but was having no luck loading.

Hardware wise, the ZX80 and the Ace have very similar hardware for reading the keyboard and the tape. I have redrawn them in the same way, to highlight the difference. Can you spot it?

Yes, the tape input is on D5 on the Ace, rather than D7 on the Sinclair machines. D7 is handy as you can use the RLA instruction to move bit 7 into the carry flag, where it can be easily tested. In bit 5, you either have to do three RLA instructions, or use BIT 5,A to test it.

I did some clever shuffling around to make that work and keep the same number of bytes and T-states, and tried it out.

And it didn't work.

And two days later, after trying all sorts of stuff, it still doesn't work.

I am not sure why yet. It seems to be doing all the right things, but it's just not reading the bits.

Here yellow shows the reads from the port and green shows the signal from the tape. I will probably write a long blog post on this at some point on the ZX80/81 tape loading, but basically 4 pulses then a gap means a 0, 9 pulses then a gap means a 1.

This is very different from the way the Ace did it with different length pulses for 0 and 1 See an annotated listing by George Beckett:

https://github.com/markgbeckett/jupiter_ace/blob/master/mpf-i/jupiter_ace_tape_interface.asm

The full ZX80 disassembly by Geoff Wearmouth can be found here for those playing along at home:

https://web.archive.org/web/20050207050627/http://www.wearmouth.demon.co.uk/zx80.htm

You can see my modified ZX80 ROM it is sampling multiple times per pulse, as expected.

Compare that to the ZX80(ignore the slow rise on the green pulse, it is fine at a logic level, and this is the cleaned up version)

Here I have added the blue trace showing writes to RAM as each bit is read. I didn't include that on the shots of my modified version is it isn't writing to RAM, so imagine a flat blue line doing nothing.

Looking at the code, it seems that rather than counting pulses as I expected, it is actually looking for the long period without a change.

A count is started after a bit has been read, and it waits until the signal goes flat. If that is after X counts, it is a 0, if it has reached Y counts and it is a 1, anything over that is an error.

I have spent quite a while probing around at various different machines loading, but no success on the 4D with the modified ZX80 ROM.

I also tried on a Minstrel 4th, which should be pretty much the same other than it does not have the Minstrel SD cleaning up the tape signal, but that proved to be the same.

I even tried going back to the original LOAD routines and modified the hardware to use D7, in case it was my changes at fault.

Summing up where I currently am:

  • Is it the signal processing on the 4D? No. Tried a Minstrel 4th.
  • Is it the D5/D7 swap? No. Tried to swap it in hardware.
  • Does the TZXduino produce the correct output? Yes, it loads into a Minstrel 2.
  • Does the 4D board work with the Ace ROM loading from the same source? Yes.
  • Are there interrupts going off during loading to affect the timing? No.
  • Is it down to something else you have changed? Maybe, but I don't know what.
  • Have you tried turning it off and then on again. Yes.

So I am confused. I may try to write an alternate tape loading routine, or adapt the one from the ZX81 or ZX Spectrum, but I do not understand why the original does not work.

The remainder of the BASIC seems to work as expected. Thanks to George Beckett for trying out typing in a longer BASIC test program which ran fine.

Today is Saturday, in case you needed to know.(* well, it was)

That is running in the Eighty One emulator, set to Jupiter Ace, as I can't load it yet.

Lots of things still to do, I might look at a tokeniser, and adding some extra commands, like IN and OUT, and maybe JOYSTICK to return the value read by the joystick port, and a version of the Spectrum's BEEP command. And then possibly a machine code monitor.......

Any other suggestions?

And then, I need to do all that again for the ZX81 ROM, but I think it is best to keep working on the ZX80 version for the moment as there is loads of space and the lack of slow mode just makes things easier whilst I get these things sorted.

Oh, and then I need to adapt the Minstrel SD and menu etc. so it will work with these new ROMs as well as the Ace one......

But, first I need to get the loading sorted. Spoilers, the next part is titled "Writing a new tape LOADing routine".

http://blog.tynemouthsoftware.co.uk/2023/12/zx80-basic-on-the-minstrel-4d-part-2.html


Advertisements

Minstrel 4D

Minstrel 4D kits and ready built units are available from thefuturewas8bit.com

https://www.thefuturewas8bit.com/shop/tynemouth-products/minstrel4d.html


Patreon

You can support me via Patreon, and get access to advance previews of blog posts and behind the scenes updates. These are often in more detail than I can fit in here. This also includes access to my Patreon only Discord server for even more regular updates.

https://www.patreon.com/tynemouthsoftware

Sunday, 19 November 2023

December shipping times

I am shipping to the USA and to Europe from my SellMyRetro store, but this is currently taking 1-2 weeks, and my have additional customs fees to pay.

https://www.sellmyretro.com/store/tynemouth-software

This is likely to take longer as things get busier into December, so if you want to order anything to arrive for Christmas, you would be advised to order as soon as possible.

UK shipping should still be OK up to mid December, but it would be advisable to use the Special Delivery option later on to be safe.

What can you buy there?

Well, I am pleased you asked.

There are Minstrel and Mini PET PCBs, kits and assembled units.

Stocks of Minstrel boards are starting to run a bit low, and I doubt I will be getting more until the new year.

Stocks of the original Mini PET boards are also starting to run out, not sure if I will be getting any more of those. We will see.

There are various PCBs for other DIY projects, such as 1541 to 2031 conversion, 6532 to 6530 conversion, joystick emulation etc.

There are built versions of some diagnostic tools, such as the large PET ROM/RAM board and the new revision of the PET IEEE-4888 diagnostics board (also available in kit form).

USB keyboard controllers are also still available for various machines. I keep trying to discontinue those, but people keep asking for them.

What was the link again?

https://www.sellmyretro.com/store/tynemouth-software


Any other options?

Yes, both of the following sites have better and faster shipping options

Z80kits.com

You can get my Minstrel 2 and 3 kits from z80kits.com, as well as exclusively two of my RC2014 modules, the 68B50 serial with clock and the joystick port.

https://z80kits.com/product-category/tynemouth-kits/

The Future Was 8 bit

And you can get Minstrel 4D kits, the small PET ROM/RAM boards and my two PET games on cassette from thefuturewas8bit.com

https://www.thefuturewas8bit.com/shop/tynemouth-products.html


Patreon

You can support me via Patreon, and get access to advance previews of blog posts and behind the scenes updates. These are often in more detail than I can fit in here. This also includes access to my Patreon only Discord server for even more regular updates.

https://www.patreon.com/tynemouthsoftware

Sunday, 12 November 2023

Fixing my Jupiter Ace Clone

I am in the process of writing a post about how the video system on the Jupiter Ace works, and that is coming together nicely, but it would be useful if I had a Jupiter Ace I could wire up to a logic analyser to get some traces.

I do have lots of Minstrel 4th's and Minstrel 4D's, but those have all of the counter logic inside the microcontroller, so I really need something that uses the original schematic that I can poke things at.

Unfortunately, I don't have a real Jupiter Ace, but I remember about 5 years ago (January 2019 I think), I did have a go at building a clone of the Jupiter Ace, with pretty much the original schematic. This would be ideal, if I could just get it to work.......

At the time I had the Minstrel 2 and 3 boards that used the ZX81 form factor, so it seemed a good idea to use the same for this.

It was quite a squeeze to fit it in there, with all the logic chips and half of the worlds supply of 1K resistors.

The original Ace had three pairs of 2114 static RAM chips giving the three 1K blocks, system RAM, video RAM and font RAM. I can't get new 2114 chips, and the used / New Old Stock ones are not always very good, so I decided to replace all of them with three skinny DIP 32K SRAM chips.

(yes, I wired one of the pins wrong on the 74LS166)

You might think that is a bit wasteful, but they are cheaper than 2114s, and they are even cheaper than the 8K versions of the same thing. The two video parts only use 1K, the main RAM provides the 1K system RAM and also a 16K expansion.

I put it all together with a ZX81 replacement keyboard membrane, with an overlay in the style of the Ace keyboard.

When I came to fire it up, it seemed to work, but there were some random characters on the screen, and some of the characters were corrupted.

The video was also very fuzzy, I had based the composite video mixer and amplifier on the Jupiter Ace 4000 version which had composite video out (the original Ace didn't), so I thought I would use that. But it was a bit ropey, so I later adapted it to the same circuit I had used on the Minstrels.

The video signal was much clearer, but the character corruption was still there, and seemed to get worse the more you used it. I couldn't work out what was wrong, but it did seem to be otherwise working.

At the same time, I had designed another board, one which used dual port RAM to simplify things, and that one also just about worked, but seemed a better place to start from for what became the Minstrel 4th and later the Minstrel 4D - read about that here - http://blog.tynemouthsoftware.co.uk/2020/05/minstrel-goes-forth.html

I did return to the original board a few times. At seems at this point I had decided to call it JACK (Jupiter Ace Computer Kit). It seems I decided Minstrel 4th was a better name.

I am not even sure what all this was trying to address, but it didn't seem to fix any problems.

Another few months later, I tried again. I noticed the clock signal was a bit weak, so I tried replacing the transistor based crystal oscillator with one made from two inverters, a more tried and tested solution. Yes, that is a bit of a cut up one of my RC2014 modules. (I later found out that the weak clock was actually down to a bad gate on the 74LS86 that buffered the clock, when I tried to use that spare gate to invert the video)

That seemed to help, and with some of the other modifications, it had reached the point where it would start with a clear screen one reset out of three, but even when it was clear, you could run VLIST and all would look fine until it got to the bottom line and then bits of the screen would get corrupted.

By this point, the Minstrel 4th was going well, so I put this away in a box again and forgot about it.

Roll forward to today, and it would be quite useful if I could get this to it to work, so back out of the box and onto the bench.

I removed most of the previous mods to go back to basically what was in the schematic, with the exception of the alternative oscillator and composite video buffer circuits.

I decided to analyse the problem further, now I have a better scope and a better logic analyser and what passes for a fresh pair of eyes.

My initial thought was that there were unintentional writes happening to the two video RAM chips, so I probed those and looked out for anything unusual.

Because of the way the video system works (see the future blog post), the video RAM and character RAM are both enabled most of the time as they are generating the video signal.

I did see occasional glitches in the chip enable signals. Very short and only a single sample wide when scanning at 50MHz. But the edge that creates could be enough to trigger a write cycle in the RAM chip, if they occurred when write was low.

Ah, there you are, that would trigger an unwanted video RAM write cycle, and would explain the corruption.

That probably wasn't an issue with the slower 2114 SRAM chips originally used, but because the modern 71256 chips I used here were a lot faster, they were treating those glitches as edges and getting corrupted.

Those signals are produced from an assortment of logic gates and a slightly strange loop around buffer based delay.

I decided I wouldn't change any of those, since this was just due to faster RAM, I tried to fix it just before the signal gets to the RAM chips. I tried gating the write signal with the 6.5MHz clock, that moved the write pulses away from the jagged edge where the occasional glitches were occurring. It does mean multiple write pulses, but I don't think that will be a problem. I could maybe use the 3.25MHz clock, but this seems to work nicely as is.

It did mean one more chip was required, but I used a 74LS00, and if I was to do another spin of the board, a single 74LS00 could do both the crystal oscillator, clock buffer and the clock gating of the video RAM write pulse, keeping all the 6.5MHz signals in one place. (would anyone be interested if I was to do another revision of this board to fix the various issues and make it available as a kit?)

Even with the output buffer changed to the circuit I used on the other Minstrels, the video output of this circuit is still not great. It has no back porch to set the black level, but the screen is all black, so it just needs good strong white peaks, but the 74LS series logic never really generates those, so the screen is a bit grey and washed out. I probably need to tweak the resistor values in the buffer circuit to get the levels better.

Ideally I would also add a back porch generation circuit to make it more correct, and maybe switch over the 74HC or 74HCT logic, but this is good enough for the moment.

And there you go, perfect vlist with no corruption.

The 16K expansion is working with the top of RAM showing as 32K, and all the character set seems to be printing correctly with no corruption.

I did not have much luck loading programs from cassette, as seems typical with the Jupiter Ace, so in the end I just wired up the ear input to the mic output of a Minstrel 4D.

I loaded the built-in Tut Tut on the 4D and then typed save TUTTUT on there and load TUTTUT on the Jupiter Ace clone and it loaded first time.

This is a good test as it modifies the character set.

That all looks good.

I always like to play out at least the first level.

All good apart from the sound not working, the speaker is just clicking. I will need to have a look at that, I think it was working, so was maybe damaged when I cleaned the board with IPA. The video side of things is all working which was my main aim, and all I need for now.

Why didn't I wire the ear input to the signal out of the microcontroller on the 4D, then you could have loaded things more easily? Ah well (as I found out after trying that a few too many times before I realised), it always loads in turbo mode, and of course the Ace clone doesn't have a turbo, so has to load at slow speed.

I am not used to running the Ace in it's normal colour scheme. I normally chose black text, white background on the Minstrel 4D. Makes it a sort of "3D Monster maze: Night vision edition".

That also highlights a mistake I made with the keyboard overlays. The up / down / left / right keys are on 5, 6, 7 and 8, the same as the ZX81 etc. But, for reasons best known to themselves, 6 and 7, down and up are reversed. I didn't have a working Jupiter Ace at the time I did those, so I didn't realise, and left the arrow graphics as they had been on the ZX80, which is wrong.

I still managed to find the exit in the end though.

Look out for the "How the Jupiter Ace Generates Video" post coming soon.


Advertisements

Minstrel 4D

The Minstrel 4D is a much more reliable and usable Jupiter Ace compatible computer, with all the extras like a joystick interface, SD card loader, RC2014 expansion bus etc. Available in kit and built form from The Future Was 8 bit.

https://tfw8b.com/product/minstrel-4d-turbo-jupiter-ace-compatible-computer-kit/

More info in a previous post:

http://blog.tynemouthsoftware.co.uk/2022/08/minstrel-4d-overview.html


Patreon

You can support me via Patreon, and get access to advance previews of posts like this and behind the scenes updates. These are often in more detail than I can fit in here, and Patreon is currently getting a lot development logs on a new project at the moment. This also includes access to my Patreon only Discord server for even more regular updates.

https://www.patreon.com/tynemouthsoftware