Plotting desktop sprites in mode 15

bbc micro/electron/atom/risc os coding queries and routines
Post Reply
pdjstone
Posts: 7
Joined: Sun Feb 23, 2020 10:02 am
Contact:

Plotting desktop sprites in mode 15

Post by pdjstone » Thu Sep 03, 2020 5:30 pm

I'm trying to plot some of the standard WIMP desktop sprites in mode 15, but I seem to be misunderstanding how to use ColourTrans_SelectTable. My reading of the documentation is that it should 'do the right thing' and map the sprite palette to the current mode. Am I using ColourTrans in the wrong way or should I be doing this in some other way? Is it something to do with using a 256-colour mode?

Here's my code:

Code: Select all

10 MODE 15
15 size%=&85e8
20 DIM area% size%
30 DIM name% 13
40 DIM trans% 160
50 area%!0=size%:area%!8=16
60 SYS "OS_SpriteOp",9+256,area%
70 SYS "OS_SpriteOp",10+256,area%,"resources:$.resources.wimp.sprites"
80 SYS "OS_SpriteOp",8+256,area% TO ,,,n%
90 PRINT "Num sprites:", n%
100 FOR i%=1 TO n%
110 x%=(i% MOD 15)*78
120 y%=(i% DIV 15)*78+78
130 SYS "OS_SpriteOp",13+256,area%,name%,13,i%
140 SYS "ColourTrans_SelectTable",area%,name%,-1,-1,trans%,0 
150 SYS "OS_SpriteOp",52+256,area%,name%,x%,y%,0,0,trans%
160 NEXT

markdryan
Posts: 159
Joined: Sun Aug 20, 2017 11:37 pm
Contact:

Re: Plotting desktop sprites in mode 15

Post by markdryan » Thu Sep 03, 2020 10:45 pm

There's a related question here:

https://www.riscosopen.org/forum/forums/11/topics/8980

The issue seems to be with 16 colour mode WIMP sprites without a palette. For these sprites, ColourTrans_SelectTable will return the wrong palette. Apparently, it returns the kernel palette and you want the Wimp Palette (the two being different in 4 and 16 colour modes). You need to use Wimp_ReadPixTrans instead. Try replacing line 140 with

SYS "Wimp_ReadPixTrans", 256, area%, name%, ,,, 0, trans%

Most but not all the sprites ( I think the ones that are already in mode 15 ) display properly when I do this.

pdjstone
Posts: 7
Joined: Sun Feb 23, 2020 10:02 am
Contact:

Re: Plotting desktop sprites in mode 15

Post by pdjstone » Fri Sep 04, 2020 9:03 am

Thanks! I didn't realise that some Wimp_ SWI's would work when the desktop was not active.

markdryan
Posts: 159
Joined: Sun Aug 20, 2017 11:37 pm
Contact:

Re: Plotting desktop sprites in mode 15

Post by markdryan » Fri Sep 04, 2020 9:14 am

> Thanks! I didn't realise that some Wimp_ SWI's would work when the desktop was not active.

Neither did I. Thanks for posting the code example. It was good fun playing around with it.

Post Reply

Return to “programming”