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
Color graphics?
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
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
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...
> 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...
Re: Color graphics?
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.
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?
Oh, I missed this... About UDG's, is exactly in the "..." where I need help:
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?
Code: Select all
unsigned char udgs[] = { .... }
void *param = &udgs;
console_ioctl(IOCTL_GENCON_SET_UDGS, ¶m);
-
- Member
- Posts: 121
- Joined: Mon Mar 26, 2018 1:49 pm
Re: Color graphics?
An 8x8 UDG is just 8 bytes. Example here.