Color graphics?

ZX80, ZX 81, ZX Spectrum, TS2068 and other clones
Post Reply
baltasarq
Member
Posts: 35
Joined: Wed May 11, 2016 7:53 pm

Color graphics?

Post by baltasarq »

I'm asking this here since I was not able to find it in the docs or the .h files.

How can I do color graphics?

In graphics.h there is a comment that says that you can do color and that the ZX Spectrum has its own implementation, but I was not able to find it... apart from lowgfx.h, which... well, does not cover my needs.

Aside from that, how can I create and UDG? I think you can create in chars above from 127, so I could easily display them with fputc_cons(i), but... how to set the bits on/off?

Thanks!
-- Baltasar
User avatar
dom
Well known member
Posts: 2072
Joined: Sun Jul 15, 2007 10:01 pm

Post by dom »

At present I don't think there is a way apart from lowgfx for +zx. As luck would have it though, I updated +ts2068 and +zxn to support colour graphics at the weekend. However, I've not added it to +zx as of yet - I'm looking at +zxn still at the moment, so I'll move onto +zx next.

The way I've been adding colour graphics is a bit odd at first glance: it uses the values supplied textcolor() and textbackground() for the set/unset colours. Bearing in mind that for a lot of targets, graphics is effectively printing block graphics glyphs via the console then the thought process should be obvious.

So, it's cheating, but I guess you could compile with +ts2068 - there will be a bit of overhead due to code for the extra screenmodes. Alternatively, if you know the coordinates then you can set the attribute - calling zx_pxy2aaddr(px,py) will return the attribute address which can then be assigned: eg *zx_pxy2aaddr(px,py) = 5; will set the paper to black and ink to cyan.

UDGs are much easier, just define them as you would a font and then let the console know the address for them, see https://github.com/z88dk/z88dk/wiki/Cla ... ining-udgs
baltasarq
Member
Posts: 35
Joined: Wed May 11, 2016 7:53 pm

Post by baltasarq »

Thanks for answering.

> Alternatively, if you know the coordinates then you can set the attribute - calling zx_pxy2aaddr(px,py) will return the attribute address which can then be assigned: eg *zx_pxy2aaddr(px,py) = 5; will set the paper to black and ink to cyan.

But... say a draw a line from 10,0 to 10, 255... do I have to "manually" set all the pixels with zx_px2aaddrr(x, y)? Ufff...
User avatar
dom
Well known member
Posts: 2072
Joined: Sun Jul 15, 2007 10:01 pm

Post by dom »

Yeah at the moment, give me a few days and I'll sort out +zx to do colour plotting in the same way as the other targets - you could test the drawing on +ts2068 to make sure the clash isn't too horrendous in the mean time.
User avatar
dom
Well known member
Posts: 2072
Joined: Sun Jul 15, 2007 10:01 pm

Post by dom »

Few days, few hours. I've just merged in support for plotting/drawing in colour. It's not a complete implementation: functions like putsprite() don't change the attributes.

Let me know how you get on.
stefano
Well known member
Posts: 2137
Joined: Mon Jul 16, 2007 7:39 pm

Re: Color graphics?

Post by stefano »

A generic "putsprite" could easily solve it, but I'd like to keep a faster monochrome version.
I know it is less than ideal, but tiny portable games could run fast enough with tuned functions.

e.g. On "microman.c" I used putsprite in "and" mode to clear the pictures because clrarea() was too slow on many targets, but a fast one would have worked better. With the 'invaders' clone I had to give up with the portability and stay on the Spectrum due to speed reasons.
baltasarq
Member
Posts: 35
Joined: Wed May 11, 2016 7:53 pm

Re: Color graphics?

Post by baltasarq »

Oh, I missed this... About UDG's, is exactly in the "..." where I need help:

Code: Select all

unsigned char udgs[] = { .... }

void *param = &udgs;
console_ioctl(IOCTL_GENCON_SET_UDGS, &param);
In the Speccy way, I should give 8bits per row for an 8x8 char, so that's 64bits of information. How do I code that?
derekfountain
Member
Posts: 121
Joined: Mon Mar 26, 2018 1:49 pm

Re: Color graphics?

Post by derekfountain »

An 8x8 UDG is just 8 bytes. Example here.
Post Reply