Developing new ZX81 Video Driver

Any discussions related to the creation of new hardware or software for the ZX80 or ZX81
User avatar
thewiz
Posts: 58
Joined: Sun Aug 16, 2009 8:36 pm
Location: Crewe

Developing new ZX81 Video Driver

Post by thewiz »

Hi all,

One of the areas of the ZX81 I have always wanted to understand better is the way the screen is generated. There's a lot of info available now, thanks to the ROM disassembly and along with Wilf's, and others, work.

So I've decided to write my own text only driver.

Why I here you cry! Well my aim is to develop a driver specifically for games on the ZX81:
  • Remove checks for FAST mode and ZX80 compatibility.
  • Incompatible with BASIC.
  • Allow IY register and System Variable memory to be used.
  • Remove need for HALTS embedded in D-FILE ala NOVA.
  • Interrupt routines either at FRAME start or end and possibly specific raster line.
  • Transitions between to D-FILES.
  • Scroll display down or up from top or bottom margin.
  • Document what is happening to my satisfaction.
My first stab at this is heavily based on what the ROM is doing however instead of a display it outputs another 192 blank lines. The main code should then be a lot quicker then in SLOW mode but with a stable white screen, and a bit slower then FAST mode.
Attachments
Display Driver.rar
ZX81 Video Driver WIP
(4.78 KiB) Downloaded 470 times
Memotech rules
User avatar
bobs
Posts: 325
Joined: Thu Aug 27, 2009 10:49 pm
Location: UK
Contact:

Re: Developing new ZX81 Video Driver

Post by bobs »

Haven't looked at the file yet, but very interested to learn more about this too.
User avatar
thewiz
Posts: 58
Joined: Sun Aug 16, 2009 8:36 pm
Location: Crewe

Re: Developing new ZX81 Video Driver

Post by thewiz »

Right, loads more info and timings.

This version displays two lines in the middle of the screen, the rest is top/bottom margin. Gives roughly 2.4Mhz of CPU. A standard screen is equiv to 0.902Mhz and an alternate frame only display gives 1.7Mhz.

Doesn't use IY
Doesn't use system variables.
No fast , zx80 compat check or basic compat any more.
Doesn't use HALTS in the display however the consequence is each line has to be 34 chars long. Unfortunately the value thats put into the R register that triggers the IM1 Interrupt is in the ROM. There are other options but they basically replace the HALT in D-File with RET, JP or similar. NOVA is 34 chars wide.
Doesn't read the keyboard. Should be easy to add and store the keyboard scan results.
The VSYNC is only 1300 cycles long so don't know if thats enough for a blitter routine for tile based games.

See source for lots of comments and figures. My next version will be for a full display I hope.
Attachments
Display Driver.rar
(3.9 KiB) Downloaded 434 times
Memotech rules
sirmorris
Posts: 2811
Joined: Thu May 08, 2008 5:45 pm

Re: Developing new ZX81 Video Driver

Post by sirmorris »

Great stuff - keep it up!
User avatar
thewiz
Posts: 58
Joined: Sun Aug 16, 2009 8:36 pm
Location: Crewe

Re: Developing new ZX81 Video Driver

Post by thewiz »

Ok, new version of the video driver. More comments added and some corrected.

Now outputs 34x24 as no HALTS are used in the display.
An interrupt routine is tagged into the bottom border NMI.
Toggles between normal frame and blank frame for the hell of it.

The main program now counts up on screen while the ISR scrolls the top two lines. Note with adding the blank frames, the count it noticably quicker.

Added some figures for raster timings.

Next version, I will be mostly be playing around with top and bottom margin manipulation.


Have fun.
Attachments
Display Driver.rar
Display driver files for WLA_DX.
(4.74 KiB) Downloaded 423 times
Memotech rules
Sdw
Posts: 17
Joined: Mon Nov 09, 2009 1:39 pm

Re: Developing new ZX81 Video Driver

Post by Sdw »

This is very interesting stuff!I took a quick peek at the code, but I guess it will take a while to grasp how it all works.
I've been having thoughts on trying to create modes such as 32x16 text or 256x128 pseudo hires for my demos to try to get a bit more processing time compared to "normal" modes, and if I understand this correctly, that should be possible. And you say that you free up the IY register as well? Having an index register to play with would be great.
User avatar
thewiz
Posts: 58
Joined: Sun Aug 16, 2009 8:36 pm
Location: Crewe

Re: Developing new ZX81 Video Driver

Post by thewiz »

Hi there,

Finally finished a driver that scrolls up and down into the bottom border. Took more then expected. Points to note:

1. LCNTR, a counter in the ULA. This is used by the ULA to determine which line of 8 in a character cell is to be outputted. It can be reset using "IN A, ($FE) / OUT ($FF),A" sequence but only when NMI interrupts are turned off. Also it resets the point HSYNC pulses are triggered.

2. This version isn't too precise and as I am losing some bottom border rasters when the display is dropped by more then 55 rasters.

Some of the ideas I originally had for this driver I don't think are possible due to lack of control over LCNTR. I do think a driver that allows the screen to scroll into view from the top is possible and possibly a driver that allows the screen to start at raster -240 to + 240.

I will now work on creating a self contained driver covering everything I've learnt what has a clean interface that anyone can use.

Enjoy.
Memotech rules
User avatar
thewiz
Posts: 58
Joined: Sun Aug 16, 2009 8:36 pm
Location: Crewe

Re: Developing new ZX81 Video Driver

Post by thewiz »

Attached driver.
Attachments
Display Driver.rar
(3.87 KiB) Downloaded 440 times
Memotech rules
User avatar
thewiz
Posts: 58
Joined: Sun Aug 16, 2009 8:36 pm
Location: Crewe

Re: Developing new ZX81 Video Driver

Post by thewiz »

Ok everybody, here is the new video driver, currently in Beta.

It give you the following features:

* Turn on or off alternate frames.
* Have different DFILES for alternate frames.
* Change number of character lines for each alternate frame.
* Add Interrupt routine to top or bottom margin.

Current problems:

* Still uses IM1 in the ROM so system variable D_FILE still used. Fixable.
* Should possibly have a graphic library with sprites, tiles, scrolling, etc that takes into account the alternate frames.
* Should also have some kind of keyboard scanning in VSYNC.
* VSYNC has to be a fixed period of time.

Notes:

* There isn't provision to add an interrupt routine on blank frames. Not sure what would be required but its easy to add your own. A blank frame is just 192 raster lines, similar to top and bottom margin raster lines, e.g. with NMIs.

Screen shots
title.png
Demo title screen.
(4.96 KiB) Downloaded 2485 times
Would be very interested in feedback as it stands plus if you think it should have anything else. Also if anyone could try it on a real zx81 and let me know what its like I would appreciate it.

And of course, the £64000 question. Would anyone use it?

Cheers.
Attachments
main.p
Demo using video driver.
(3.19 KiB) Downloaded 465 times
Display Driver.rar
Video Driver in WLA DX assembler format.
(7.3 KiB) Downloaded 467 times
Memotech rules
pterodactyl
Posts: 10
Joined: Fri Nov 21, 2008 3:47 am

Re: Developing new ZX81 Video Driver

Post by pterodactyl »

OK I downloaded the files and I hope to try them soon on my souped up zx-81!

I think I could use this for some pseudo-gui app I'm writing to use in the electronics lab! :mrgreen:
Post Reply