Color graphics?

ZX80, ZX 81, ZX Spectrum, TS2068 and other clones
Post Reply
baltasarq
Member
Posts: 26
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: 1185
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: 26
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: 1185
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: 1185
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.
Post Reply