Plot function in z88dk

Any discussions related to the creation of new hardware or software for the ZX80 or ZX81
User avatar
RobertK
Posts: 52
Joined: Tue Dec 19, 2017 4:29 pm
Location: Vienna

Plot function in z88dk

Post by RobertK »

Sorry for this beginner’s question, but how would you implement a Plot() function in z88dk, allowing you to set or clear each block of the 64x48 screen?

The trick is obviously to fill the right parts of the screen memory.

I have made my first little experiments with Z88DK, and the speed of the resulting program (compared to Basic) gives me motivation for further work...
Last edited by RobertK on Wed Jan 31, 2018 3:54 pm, edited 1 time in total.

User avatar
siggi
Posts: 910
Joined: Thu May 08, 2008 9:30 am
Location: Dauernheim, Germany
Contact:

Re: Plot function in Z88DK

Post by siggi »

If you want to plot in LOWRES, you could call the BASIC PLOT routine from Z88DK to plot using BASIC:
an expample for PLOT is here:

https://www.z88dk.org/wiki/doku.php?id= ... 1&s[]=plot


If you want to plot in HIRES, use the "graphic"-library:

https://www.z88dk.org/wiki/doku.php?id= ... []=graphic

HTH Siggi
My ZX81 web-server: online since 2007
http://zx81-siggi.endoftheinternet.org/index.html

User avatar
RobertK
Posts: 52
Joined: Tue Dec 19, 2017 4:29 pm
Location: Vienna

Re: Plot function in Z88DK

Post by RobertK »

Thanks. I have tried the first method and it works, but unfortunately its speed is exactly the same as if it was done entirely in BASIC. About six seconds for plotting a border around the screen like this:

Code: Select all

10 FOR X=0 TO 63
20 PLOT X,43
30 PLOT X,0
40 NEXT X
50 FOR Y=1 TO 42
60 PLOT 0,Y
70 PLOT 63,Y
80 NEXT Y
Is there a more efficient way to implement PLOT() in low-res? Maybe by writing directly to the appropriate address of the video memory?

The hires functions in graphics.h look very interesting as well, but I assume that this requires WRX, right?

User avatar
mrtinb
Posts: 1202
Joined: Fri Nov 06, 2015 5:44 pm
Location: Denmark
Contact:

Re: Plot function in Z88DK

Post by mrtinb »

Seems there is MID-RES if you have UDG capable hardware. Unfortunately it seems pseudo HIRES is not supported.
Martin
ZX81, Lambda 8300, Commodore 64, Mac G4 Cube

User avatar
siggi
Posts: 910
Joined: Thu May 08, 2008 9:30 am
Location: Dauernheim, Germany
Contact:

Re: Plot function in Z88DK

Post by siggi »

RobertK wrote:
Mon Jan 29, 2018 10:39 pm
The hires functions in graphics.h look very interesting as well, but I assume that this requires WRX, right?
Yes, your hardware (or EO ;-) ) needs to support a HIRES modification. WRX is one of the easiest modifications:

https://www.z88dk.org/wiki/doku.php?id= ... ersion_1.8
My ZX81 web-server: online since 2007
http://zx81-siggi.endoftheinternet.org/index.html

User avatar
RobertK
Posts: 52
Joined: Tue Dec 19, 2017 4:29 pm
Location: Vienna

Re: Plot function in Z88DK

Post by RobertK »

Thanks, I will try writing WRX programs later, but back to my initial question: the target machine for my first program would be an unmodified 16K ZX81/TS1000, and I would like to plot/unplot blocks in low-res 64x48 mode. Any suggestions how this could be achieved efficiently in Z88DK?

I had a look at the source of the Z8048 game, and there the drawGrid() function fills the appropriate parts of the screen memory to display the grid, however using "text mode". Maybe the same can be achieved in low-res graphics?

User avatar
Andy Rea
Posts: 1553
Joined: Fri May 09, 2008 2:48 pm

Re: Plot function in Z88DK

Post by Andy Rea »

It can be done fairly quickly BUT... you have to ensure that the d-file is fully expanded i.e. 24 rows of 33 bytes each, that way the screen position can be calculated quite easily and the. Some jiggery pokery with bit manipulation can set / unset a quarter block for you.... Will sort out some assembler code later for you.
AFK

User avatar
Andy Rea
Posts: 1553
Joined: Fri May 09, 2008 2:48 pm

Re: Plot function in Z88DK

Post by Andy Rea »

right then.... as promised.... i dont really do the Z88dk thing.... but i know that you can run native Z80 code so you should be able to adapt this code.

anyway HTH

Andy
fastplot.zip
(47.96 KiB) Downloaded 153 times

p.s just re-read previous post.... working on unplot now hahaha
AFK

User avatar
RobertK
Posts: 52
Joined: Tue Dec 19, 2017 4:29 pm
Location: Vienna

Re: Plot function in Z88DK

Post by RobertK »

Thanks Andy, the speed is impressive!
I may seem entirely hopeless, but can anyone please assist me in wrapping this ASM code into a C function? I know that you need to put the ASM code between #asm and #endasm, but everything else regarding ASM in z88dk is currently trial and error for me.

I should have checked the z88dk forums first, because here is a discussion on exactly this PLOT topic. I have tried using the final "CALLEE" function from there, and it compiles ok, but for some reason the plotted blocks just don't appear on the screen. Maybe I will post that later as well.

User avatar
Andy Rea
Posts: 1553
Joined: Fri May 09, 2008 2:48 pm

Re: Plot function in z88dk

Post by Andy Rea »

i'll have a look with the Z88dk thing....
AFK

Post Reply