Enhanced ARX True High Resolution Display Driver

Any discussions related to the creation of new hardware or software for the ZX80 or ZX81
Fruitcake
Posts: 351
Joined: Wed Sep 01, 2010 10:53 pm

Enhanced ARX True High Resolution Display Driver

Post by Fruitcake »

The ARX display technique devised by Andy Rea in 2006 is fascinating in that it could have given true high resolution graphics back in the day using an off-the-shelf 64K RAM pack if only someone had thought to write a suitable display driver [*Correction* - See comment in post from kmurta lower down]. When trying out the technique using the few programs that now support it I encountered an issue whereby the character rows could be vertically rotated, the amount of which could vary depending on the external hardware connected. I set about determining what the causes for this were and ended up creating an enhanced version of the ARX display driver to resolve them. You'll find it at the end of this post and I recommend it be used for all future programs using the ARX technique to ensure compatibility for different hardware scenarios.

The program I first noticed the problem with was Hangman , which displayed on EightyOne as follows:

HangmanRotated.png
HangmanRotated.png (8.32 KiB) Viewed 1386 times

When ZXpand+ is enabled in EightyOne (but without WRX enabled since it is not compatible with ARX) then the characters became rotated by 2 lines:

HangmanRotatedZXpand.png
HangmanRotatedZXpand.png (7.85 KiB) Viewed 1386 times

I was able to verify these results on real hardware (using other RAM in the 8K-16K region since the RAM ZXpand+ provides is WRX enabled). I was able to prove it was not ULA version related nor ROM edition related.

The ARX display driver used in Hangman calls into the ROM to generate the VSync pulse and then returns immediately back into the display driver. The NMI generator is now back on and so when the next HSync time is reached, an NMI will be generated. Upon the return into the display driver, a call is made into the ROM to read the BREAK key. This does not take into account the fact that the routine is at different address in the edition 1 ROM but fortunately it harmlessly returns. However, it does mean that the BREAK key functionality will not work in Hangman when using the edition 1 ROM. However, the ROM edition alone was not the cause of the rotation issue.

After reading the BREAK key, the display driver reads MARGIN and adjusts the value to compensate for the 8 line delay that the display driver performs prior to outputting the main picture area. If ZXpand+ is connected then it takes longer to reach the code that reads MARGIN and the next HSync position is reached. This causes a NMI to occur before MARGIN is read. This extra NMI does not get factored into the number of border lines to output and so an additional one gets generated. This increments the LNCTR one extra time and hence results in the character being displayed rotated.

That explained the impact of connecting ZXpand+, but why did EightyOne without having ZXpand+ selected show the characters of Hangman rotated? It wasn't due to EightyOne since I able to prove the rotation happened on a variety of real ZX81s. This makes me wonder whether Andy had developed the driver using one of the early versions of EightyOne which back then was not clock accurate. Or perhaps he was testing using the replacement ZX81 ULA he was developing back then but it wasn't clock accurate at that stage. Whatever the reason, the issue at hand was how to modify the display driver so that it was not susceptible to these issues. That lead to the development of a revised ARX display driver.

The new display driver forces the LNCTR to reset prior to outputting the main picture area and so the characters can now never be rotated. Forcing LNCTR to 0 also means I could remove the 8 line delay, and that has the benefit that the user program has more border lines in which it can run in parallel with. That means the user program gains a performance boost. These changes also mean the reading of MARGIN after the VSYNC is no longer necessary and that avoids the potential for the number of border lines that are output to change based on what external hardware is connected.

The original display driver generated its VSync pulse non-aligned to the HSync pulses, as Eightyone shows (VSync is red, HSync is blue), and notice how the display driver only outputs 303 scanlines:

HangmanVSync.png
HangmanVSync.png (9.5 KiB) Viewed 1386 times

The new display driver now nicely aligns the VSync to the HSyncs, and this has a benefit since good alignment has been found to increase picture stability when using HDMI converters. It also outputs 310 scanlines, which is the same as the number output by the standard ROM display driver.

The new display driver also has the advantage of allowing the I and IY registers to be used by the user program.

To prove the new ARX display driver works as intended, I've created a small test program. This program simply draws a series of lines and demonstrates how the unusual ARX display file structure can be easily converted to from logical display coordinates. This not only makes manipulation of the screen easier but also means the a program can be more easily ported to/from WRX high resolution. In the following screenshot you can see the VSync pulse is aligned with the backporch period (black) and the HSync pulse (blue):

NewDriverVSync.png
NewDriverVSync.png (10.73 KiB) Viewed 1386 times


The new display driver is of comparable size to the original and so I don't believe there are any downsides to using it in favour over the original.
Last edited by Fruitcake on Mon Mar 18, 2024 4:07 pm, edited 1 time in total.
Fruitcake
Posts: 351
Joined: Wed Sep 01, 2010 10:53 pm

Re: Enhanced ARX True High Resolution Display Driver

Post by Fruitcake »

Here is the source code for the new ARX display driver and demo program, along with the demo program .p file:
ARX_Driver.asm
(12.32 KiB) Downloaded 36 times
ARX_Demo.asm
(21.13 KiB) Downloaded 42 times
Arx_Demo.p
(498 Bytes) Downloaded 49 times
Last edited by Fruitcake on Tue Mar 19, 2024 1:37 am, edited 1 time in total.
dr beep
Posts: 2080
Joined: Thu Jun 16, 2011 8:35 am
Location: Boxmeer

Re: Enhanced ARX True High Resolution Display Driver

Post by dr beep »

Great read, now I need to take a look at the code.
Moggy
Posts: 3267
Joined: Wed Jun 18, 2008 2:00 pm

Re: Enhanced ARX True High Resolution Display Driver

Post by Moggy »

Works with SZ-81 ok.
User avatar
kmurta
Posts: 305
Joined: Tue Sep 01, 2009 5:04 am
Location: Belo Horizonte - BR
Contact:

Re: Enhanced ARX True High Resolution Display Driver

Post by kmurta »

Excellent! ARX is a great option to use with Brazilian TKs clones, which do not tolerate WRX very well. As soon as I have time I will test it on my TK85.

Fruitcake wrote: Mon Mar 18, 2024 2:35 am The ARX display technique devised by Andy Rea in 2006 is fascinating in that it could have given true high resolution graphics back in the day using an off-the-shelf 64K RAM pack if only someone had thought to write a suitable display driver.
Hmm, I don't think so... as ARX is based on UDG, it is necessary that the RAM address lines A0~A8 are generated by the ULA, which is not the case with memory expansions connected to the rear expansion bus.
1 x ZX81, 2 x TK85 , 1 TK82C, 1 TK95, 1 x Alphacom 32 printer, 1 x ZXpand
ZeXtender board, Joy81 - Programmable Joystick Controller, Turbo Sound 81
http://zx81.eu5.org
https://toddysoftware.itch.io/
Fruitcake
Posts: 351
Joined: Wed Sep 01, 2010 10:53 pm

Re: Enhanced ARX True High Resolution Display Driver

Post by Fruitcake »

kmurta wrote: Mon Mar 18, 2024 3:09 pm Hmm, I don't think so... as ARX is based on UDG, it is necessary that the RAM address lines A0~A8 are generated by the ULA, which is not the case with memory expansions connected to the rear expansion bus.
Yes, good point! :oops:

If I had a 64K RAM pack then this would have been obvious during my testing but I had to rely on the 8K RAM provided by Chroma 81 which does support UDGs. So it is possible to have UDGs in an external RAM pack but very unlikely original 64K RAM packs would have supported this ability.

Hmm, that gets me thinking I wonder if EIghtyOne's 8K-16K RAM option should have a means to differentiate how that RAM is connected. At present, it is just implied it supports UDGs...
Fruitcake
Posts: 351
Joined: Wed Sep 01, 2010 10:53 pm

Re: Enhanced ARX True High Resolution Display Driver

Post by Fruitcake »

Moggy wrote: Mon Mar 18, 2024 11:57 am Works with SZ-81 ok.
Thanks, good to know. I used EightyOne to get perfect timing in the display driver but there is of course a chance its emulation is still not 100% accurate. So it is good if other emulators that have been written independently agree with the results from EightyOne.
Fruitcake
Posts: 351
Joined: Wed Sep 01, 2010 10:53 pm

Re: Enhanced ARX True High Resolution Display Driver

Post by Fruitcake »

I recall there was an UDG4ZXpand board (which I think Andy created also but correct me if I am wrong). I'm wondering if this will make the 8K-16K RAM provide by the ZXpand ARX compatible. Does anyone know?
User avatar
kmurta
Posts: 305
Joined: Tue Sep 01, 2009 5:04 am
Location: Belo Horizonte - BR
Contact:

Re: Enhanced ARX True High Resolution Display Driver

Post by kmurta »

Fruitcake wrote: Mon Mar 18, 2024 4:18 pm I recall there was an UDG4ZXpand board (which I think Andy created also but correct me if I am wrong). I'm wondering if this will make the 8K-16K RAM provide by the ZXpand ARX compatible. Does anyone know?
Yes, all external RAM connected to UDG4ZXPAND is capable of providing UDG xor WRX. Selection is made by a jumper on the board. I have one and plan to test it with the TK85 as soon as I can.
1 x ZX81, 2 x TK85 , 1 TK82C, 1 TK95, 1 x Alphacom 32 printer, 1 x ZXpand
ZeXtender board, Joy81 - Programmable Joystick Controller, Turbo Sound 81
http://zx81.eu5.org
https://toddysoftware.itch.io/
Moggy
Posts: 3267
Joined: Wed Jun 18, 2008 2:00 pm

Re: Enhanced ARX True High Resolution Display Driver

Post by Moggy »

Fruitcake wrote: Mon Mar 18, 2024 4:18 pm I recall there was an UDG4ZXpand board (which I think Andy created also but correct me if I am wrong). I'm wondering if this will make the 8K-16K RAM provide by the ZXpand ARX compatible. Does anyone know?
I have tried the demo on Andy's UDG4ZXpand board on an issue one ZX81 with an issue three ZXpand and got the following results.

The last picture, although not obvious, has a top two lines of black blocks moving side to side whilst the barely perceptible dots are moving in a rain like fashion.

Apologies for poor camera work but I think the point is obvious.
Attachments
UDG4ZXPAND  JUMPER SET FOR 64 MODE
UDG4ZXPAND JUMPER SET FOR 64 MODE
UDG4ZXPAND  JUMPER SET FOR 128 MODE
UDG4ZXPAND JUMPER SET FOR 128 MODE
UDG4ZXPAND JUMPER OFF NO UDG.
UDG4ZXPAND JUMPER OFF NO UDG.
Post Reply