## Plot function in z88dk

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

### Plot function in z88dk

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.

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

### Re: Plot function in Z88DK

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

RobertK
Posts: 27
Joined: Tue Dec 19, 2017 4:29 pm
Location: Vienna

### Re: Plot function in Z88DK

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?

mrtinb
Posts: 595
Joined: Fri Nov 06, 2015 5:44 pm
Location: Denmark
Contact:

### Re: Plot function in Z88DK

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

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

### Re: Plot function in Z88DK

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

RobertK
Posts: 27
Joined: Tue Dec 19, 2017 4:29 pm
Location: Vienna

### Re: Plot function in Z88DK

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?

Andy Rea
Posts: 1331
Joined: Fri May 09, 2008 2:48 pm
Location: notts UK

### Re: Plot function in Z88DK

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.
6 x ZX81, 1 x TS1500 , 1 x +3e, 1 x timex 2040 printer, 1 x timex 2020 cassette deck, siclair printer and some spectrum

Andy Rea
Posts: 1331
Joined: Fri May 09, 2008 2:48 pm
Location: notts UK

### Re: Plot function in Z88DK

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

p.s just re-read previous post.... working on unplot now hahaha
6 x ZX81, 1 x TS1500 , 1 x +3e, 1 x timex 2040 printer, 1 x timex 2020 cassette deck, siclair printer and some spectrum

RobertK
Posts: 27
Joined: Tue Dec 19, 2017 4:29 pm
Location: Vienna

### Re: Plot function in Z88DK

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.

Andy Rea
Posts: 1331
Joined: Fri May 09, 2008 2:48 pm
Location: notts UK

### Re: Plot function in z88dk

i'll have a look with the Z88dk thing....
6 x ZX81, 1 x TS1500 , 1 x +3e, 1 x timex 2040 printer, 1 x timex 2020 cassette deck, siclair printer and some spectrum