Page 1 of 3

Developing new ZX81 Video Driver

Posted: Thu Apr 01, 2010 7:40 pm
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.

Re: Developing new ZX81 Video Driver

Posted: Fri Apr 02, 2010 10:02 am
by bobs
Haven't looked at the file yet, but very interested to learn more about this too.

Re: Developing new ZX81 Video Driver

Posted: Sat Apr 03, 2010 6:30 pm
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.

Re: Developing new ZX81 Video Driver

Posted: Sun Apr 04, 2010 9:37 am
by sirmorris
Great stuff - keep it up!

Re: Developing new ZX81 Video Driver

Posted: Wed Apr 07, 2010 4:58 pm
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.

Re: Developing new ZX81 Video Driver

Posted: Fri Apr 16, 2010 5:05 pm
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.

Re: Developing new ZX81 Video Driver

Posted: Tue Apr 20, 2010 3:48 pm
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.

Re: Developing new ZX81 Video Driver

Posted: Tue Apr 20, 2010 3:55 pm
by thewiz
Attached driver.

Re: Developing new ZX81 Video Driver

Posted: Tue May 11, 2010 5:46 pm
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.

Re: Developing new ZX81 Video Driver

Posted: Tue Jun 01, 2010 6:48 pm
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: