Drawing sprites in the desktop colour depth

bbc micro/electron/atom/risc os coding queries and routines
Post Reply
ksattic
Posts: 4
Joined: Sun Jul 01, 2018 9:31 pm
Contact:

Drawing sprites in the desktop colour depth

Post by ksattic » Tue Jul 03, 2018 2:44 pm

Apologies if this has been asked before, I searched.

PRM1 says to avoid using OS_SpriteOp 34 to draw to a mode that doesn't match the sprite. I get that. What's the preferred way to deal with a mismatch? I'm not writing a game so speed isn't important, I'm writing a Wimp app. However, I'd like to avoid writing conversion routines for every combo of sprite and mode format.

I have some app sprites in my own pool and I want to draw them to a window directly rather than using icons. The Wimp seems to be able to do this because it can colour-convert sprites in icons.

Thanks!

User avatar
davidb
Posts: 2842
Joined: Sun Nov 11, 2007 10:11 pm
Contact:

Re: Drawing sprites in the desktop colour depth

Post by davidb » Tue Jul 03, 2018 4:04 pm

Some ancient code of mine calls ColourTrans_SelectTable then OS_SpriteOp with 512+56 as the plot operation (I assume) in cases where the sprites can't just be dumped onto the screen. I imagine it would probably also work in the case where the sprite's mode and palette matched the current screen mode and palette.

Digging around in the OSLib sources might also give you some better solutions.

ksattic
Posts: 4
Joined: Sun Jul 01, 2018 9:31 pm
Contact:

Re: Drawing sprites in the desktop colour depth

Post by ksattic » Thu Jul 05, 2018 7:50 pm

Yes, this works, thanks! I knew there would be some magic sauce somewhere! :D

Phlamethrower
Posts: 121
Joined: Fri Nov 24, 2017 1:35 pm
Contact:

Re: Drawing sprites in the desktop colour depth

Post by Phlamethrower » Thu Jul 05, 2018 8:19 pm

Yep, ColourTrans is the way to go. You just need to make sure you use the right flags to get the best output.

https://www.riscosopen.org/forum/forums ... osts-32646

(The example I give there is ColourTrans_GenerateTable, but for sprites ColourTrans_SelectTable will work exactly the same)

Post Reply

Return to “programming”