Page 1 of 1
Color graphics?
Posted: Tue Apr 14, 2020 7:21 pm
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
Posted: Tue Apr 14, 2020 10:38 pm
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
Posted: Wed Apr 15, 2020 8:59 am
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...
Posted: Wed Apr 15, 2020 9:05 am
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.
Posted: Wed Apr 15, 2020 10:49 pm
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.
Re: Color graphics?
Posted: Fri May 06, 2022 8:02 am
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.
Re: Color graphics?
Posted: Fri May 06, 2022 8:20 am
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, ¶m);
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?
Re: Color graphics?
Posted: Fri May 06, 2022 11:21 am
by derekfountain
An 8x8 UDG is just 8 bytes. Example
here.