Close
0%
0%

ZX80 with 40 column text

40-column text, and square pixels mean 45 degree lines look right. Runs 13% faster as well!

Similar projects worth following
Features:

Take a ZX80
Change 6.5 MHz resonator to 7.375 MHz (ideally), though 7.3728 MHz is near enough.
Fit a ZX81 BASIC with modified firmware which gives
40 character columns instead of 32.
Seems to work okay when just printing text

Not done yet:

Plotting routines
Tape routines
Working with G007 graphics

Note:

Will not work with ZX81 in slow mode, because the interrupt generator inside the ULA divides 6.5 MHz to get the frame rate. If you have a ZX80 with an add-on slow-mode generator, it will need the divisor changing from 208 to 236.

I started off just wanting square pixels, which requires the 6.5 MHz master clock to become 7.375 MHz. In practice, the baud-rate generator frequency 7.3728 MHz is near enough. 

This then requires modification to the software-generated video signal. 
When done, there is room for 40 characters instead of 32. 
This requires modification to the text routines. And plotting routines. I haven't modified the tape routines but who uses tape these days? 
I don't have time to check this out thoroughly, and it is unlikely that people are going to start writing code for a modified ZX80. Existing software will be messed up. 
However, I'm recording the achievement for anyone who might be amused by it. 
The photo is of an old 5-inch monochrome portable, modified to take baseband video. 
It would probably look better on a bigger, better telly. 

Will not work with ZX81 in slow mode, because the interrupt generator inside the ULA divides 6.5 MHz to get the frame rate.

ZX81_dual_2018-02-09.htm

This looks like the last documentation I had for this project. The filename means it is ZX81 BASIC, dual-purpose; i.e. 32 or 40 column operation. Adam Klotblixt has got it working with 8 MHz and 40 columns, and corrected SCROLL.

HyperText Markup Language (HTML) - 394.06 kB - 02/09/2018 at 13:43

Download

ZX81_BASIC_SG_32_and_40_columns.bin

ZX81 BASIC, based on Shoulders of Giants improved code, hacked for operation at 7.375 MHz. Contains two versions, one with normal 32-column text, another with experimental 40-column text. This is a 32K ROM, use lower or upper 16K in the bottom 16K of the ZX80 memory map. Both versions include a 2K monitor at 3800 hex. 0000 8K ZX BASIC 2000 2K blank (FF) 2800 2K G007 graphics 3000 2K blank (FF) 3800 2K ZX81 monitor 4000 As first 16K but with alternative display width. Connect the ROM A14 to a 1P2T switch, to select display width at reset. The G007 graphics does not work without the G007 hardware. I just put it there for later experiments.

octet-stream - 32.00 kB - 01/10/2018 at 21:27

Download

ZX81_BASIC_SG_32_and_40_columns.hex

Hex version of binary file.

hex - 77.03 kB - 01/10/2018 at 21:27

Download

ZX81_sg.rom.bin

Shoulders of giants ROM

octet-stream - 8.00 kB - 01/10/2018 at 00:49

Download

K8081.pdf

A ZX81 implemented in TTL chips. With a few improvements. Not tested! SLOW mode interrupt generator on final page assumes normal (32-column) mode.

Adobe Portable Document Format - 62.84 kB - 01/09/2018 at 12:11

Preview
Download

View all 6 files

  • Slow mode counter circuit

    Keith09/30/2023 at 15:08 0 comments

    There are designs on the net for this, but they all seem based on a design with a fundamental error.

    They asynchronously reset the 8-bit counter when it reaches 207. 

    This means it cycles through states 0 to 206, then very briefly becomes state 207 before settling in state 0.

    Thus you get a divide by 207 counter, which is one count too short.

    http://searle.x10host.com/zx80/ZX80nmiVer4.1.jpg

    PAL video lines are 64 microseconds long, so the line rate should be 15625 Hz.

    The ZX81 CPU clock is 3.25 MHz, so 3,250,000/15,625 = 208.

    Detecting 207 is correct for synchronous counters, because they won't change until the end of state 207.

    For synchronous counters like the 74HC393, you need to detect state 208, which is actually simpler to do.

    207 = CF hex = 1100 1111 binary
    208 = D0 hex = 1101 0000 binary

    So all you really need to do is detect 1101 on the four most significant bits, because it won't happen until the lower bits have rippled back to zero.

    When using the square-pixel 40-column modification, the CPU clock is 14.75/4 = 3.6875 MHz, and the divider must be 236. That is EC hex, 1110 1100 binary.

    Rather than build a circuit from simple AND and OR gates, it is much more convenient to use a 74HC688 comparator:

    CLK1 is the inverted CPU clock, and CLK2 is driven by 1Qd.

    The divisor rate can be made switchable by having comparator input Q4 = 1 for square pixels and 0 for normal pixels.
    Inputs Q2,3,5 are 0 for square pixels and 1 for normal pixels.

    If you wish to be clever, you could mod your firmware to sense the selection and adjust accordingly. You will need a spare input bit, which you have on D5 of the keyboard input port. This is normally high, so it would be wired to comparator inputs Q2,3,5.

    Another bonus is that if you want to run the CPU at any other speed, you simply have to change the comparator inputs Q0-7. 

    If speed is your demon and you run the CPU at 4 MHz, the divisor is 256 and the counter automatically cycles back to 0 and you won't need a comparator at all.

    You will need to check the other logic in the Grant Searle design. Luckily, most tellies are fairly forgiving and will cope with minor deviations from the PAL sync and porch timings.

    As I'm short on free time, I shall be implementing the slow mode generator in a GAL chip, something like this: 

    This will combine the comparator with the sync and porch pulse logic.

    The N/S signal selects which one of two divisors to use.

    If the comparator outputs are synchronous, then it does have to detect values 207 and 235.

  • Memory map

    Keith09/23/2023 at 23:19 0 comments

    ZX81 BASIC, based on Shoulders of Giants improved code, hacked for operation at 7.375 MHz. 

    Contains two versions, one with normal 32-column text, another with experimental 40-column text. 

    This is a 32K ROM, use lower or upper 16K in the bottom 16K of the ZX80 memory map. 

    Both versions include a 2K monitor at 3800 hex. 

    0000 8K ZX BASIC
    2000 2K blank (FF)
    2800 2K G007 graphics
    3000 2K blank (FF) 
    3800 2K ZX81 monitor 
    4000 As first 16K, but with alternative display width. 

     Connect the ROM A14 to a 1P2T switch, to select display width at reset. 

    The G007 graphics does not work without the G007 hardware. I just put it there for later experiments.

  • Construction

    Keith09/16/2023 at 11:51 0 comments

    The ZX80 is more hackable than the ZX81 because all the logic chip signals are accessible.

    I bought a PCB and populated it with good quality turned-pin sockets and new chips.

    I noticed it was still prone to crashing even without an external RAM pack.

    I suspected that socket connections were intermittent, especially when the PCB was being flexed by pressing the keyboard.

    I removed the sockets of the TTL chips and soldered the TTL chips directly to the PCB. This was a great improvement.

    Lessons learnt:

    • Sockets are more trouble that they are worth. Avoid them!
    • Socket contacts fail when PCBs are flexed. Avoid this.
    • Putting the keyboard on the same PCB as socketed chips is a bad idea for the reasons above.

    I fitted a 32K RAM chip, to banish RAM-pack wobble crashes forever.

    I fitted tactile switches salvaged from scrap boards. The buttons are low-profile, so they don't click so well when pressed by a finger. Some kind of key tops, or higher-profile keys, would fix this.

    For square-pixels, the clock was changed from 6.5 to 7.732 MHz. I used a DIP14 oscillator in a metal can, but changing the crystal would also work and look neater. The rest was firmware modding. I added a SPDT switch to select the standard or alternative firmware. I used my modified ZX81 BASIC firmware, but you could just as easily select ZX81 Forth or anything else.

View all 3 project logs

Enjoy this project?

Share

Discussions

Andrew wrote 02/07/2018 at 22:10 point

IIRC hacking the rom for 40 columns wasn't difficult, the CLS routine needs one of the counters initial value changing, the print at needs the bounds check value altering, the PLOT / unplot don't need changing they use the print at routine to find the screen address.

i think.....

regards Andy

  Are you sure? yes | no

Keith wrote 02/08/2018 at 01:28 point

Thanks for the tips. Sounds like you have already done this project.

  Are you sure? yes | no

adam.klotblixt wrote 02/07/2018 at 19:35 point

Just did the first test with an 8MHz crystal, changed 3 ROM locations and it worked perfectly! Next step will be to reassemble the complete ROM with all changes for a proper wide-line editing BASIC :D

Thanks to your commented ROM-listing it was a breeze to test this.

It is tempting to build a complete counter/comparator NMI-board too, for that extra ZX81++ goodness.

  Are you sure? yes | no

Keith wrote 02/07/2018 at 20:59 point

One is glad to be of service.  It took a long time to find out which locations to change, and to what values! :-)  I recall it largely seems to work - if I keep typing then the text continues for 40 chars and wraps onto the next line. However there are probably many things that need fixing e.g PRINT AT.

Also note that my mods assume 14.75 MHz / 2 = 7.735 MHz. This is exactly right for UK PAL square pixels. With your surname, I'd guess you are in one of our ex colonies :-P so for NTSC the square pixel frequency is 12.272727 MHz / 2 = 6.1363635 MHz which is actually _slower_ than the standard ZX81 clock. We both have 64 microseconds per line, so 32-columns at 6.5 MHz = 39.4 us (let's call it 40). Now 40 columns at 8 MHz is exactly 40 us. You will have the same width screen, but non-square pixels. PAL 40 column square pixels = 43.39 us. This will be the same width for you but being NTSC the pixels won't be square. But if that bugs you, there's probably a TV control knob to adjust picture height.

Anyway, have fun. 8 MHz is a common frequency, but 14.7456 / 2 = 7.3728 MHz is a common baud-rate crystal and is close enough to ideal. Your 8 MHz system will be running about 8.5% faster than TV standards dictate, your lines will be only 59 microseconds instead of 64.

  Are you sure? yes | no

adam.klotblixt wrote 02/08/2018 at 08:51 point

PAL country here in Sweden, no problem :) Square pixel is nice, but speed is my demon. And higher resolution.

I do change the ROM so that the line length is kept at 64us. 40 characters with more border or 44 characters per line, will see what I end up using...

  Are you sure? yes | no

Keith wrote 02/07/2018 at 21:02 point

I am working on the dual clock frequency NMI generator right now. I'll be experimenting with GAL chips. If you don't have a GAL programmer then I can come up with a design based on an LS393 and LS688.

  Are you sure? yes | no

adam.klotblixt wrote 02/08/2018 at 09:06 point

I do have a programmer but lack GALs in my parts bin. Will have to shop.

  Are you sure? yes | no

Keith wrote 01/07/2018 at 19:33 point

It depends whether you want processing power or proper proportions on screen.

The ZX80/81 is never going to give you much processing power, but it can give you proper proportions. I do not want squares and circles to be rectangles and ellipses. 

Sure it is easy to divide by a power of two but it isn't that hard to do anything else. I originally planned to have an 8-bit counter wired to an 8-bit comparator (the 74LS688). You can easily set the comparison value to 207, 236, or any experimental value you like.

I now have a programmer that can program the Atmel 22V10 and 16V8 GAL chips, so I can combine the counter and comparator into one chip.

With an 8 MHz clock, you should be able to fit 43 characters on screen, and run 8% faster than the 7.325 MHz system, which is not much better.

Adding slow mode to my ZX80 is on my to-do list but I have more interesting projects on the list (as you can see). I have eight Z180 chips daring me to design a CPU board.

  Are you sure? yes | no

adam.klotblixt wrote 01/07/2018 at 16:45 point

Great! I was just about to do this with my Minstrel ZX80-clone, with the difference of using an 8 MHz clock to maximize the performance and clocks available to do some more calculations during the screen drawing. Easier to get hold of that oscillator. It is also MUCH easier to divide by 256 to get a correct 15625 Hz raster frequency for PAL.

  Are you sure? yes | no

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates