 |
forums.ps2dev.org Homebrew PS2, PSP & PS3 Development Discussions
|
| View previous topic :: View next topic |
| Author |
Message |
AnonymousTipster
Joined: 01 Jul 2005 Posts: 197
|
Posted: Mon Jul 04, 2005 4:12 am Post subject: PSP colour not working right... Possible Bit Shift problems |
|
|
I thought I had sorted this out, but obviously not.
To blit RGB values to the PSP vram, I am using the following Macro
| Code: | | #define RGB16(r, g, b) ((r & 31) + ((g & 31)<<5) + ((b & 31)<<10)) |
(I am using 16bit for the moment to get it running correctly)
I am then doing a 1-255 RGB sweep, using this code:
| Code: | for(y=1;y<256;y++){
for(x=1;x<256;x++){
PutPixelRGB(x,y, x, x, x);
}
} |
This should draw a 255pixel wide gradient from black to white, but it doesn't. What it draws is a 255pixel wide set of 8 black to white gradients. So you have several pixels of black fading to white, then suddenly to black which fades to white...etc. It is as though the rage is going from 1-2040 in the space of 255pixels.
I have tried everything I can think of, but something is wrong, and I can only pray that you can help me.... |
|
| Back to top |
|
 |
maddogjt1
Joined: 27 Jun 2005 Posts: 13
|
Posted: Mon Jul 04, 2005 4:25 am Post subject: |
|
|
it has to do with your RGB16 macro. Instead of taking the five most significant bits of each color, you're taking the five least. You should use
#define RGB(r,g,b) ((((b>>3) & 0x1F)<<10)|(((g>>3) & 0x1F)<<5)|(((r>>3) & 0x1F)<<0)|0x8000) |
|
| Back to top |
|
 |
Hippo
Joined: 25 Jun 2005 Posts: 19
|
Posted: Mon Jul 04, 2005 4:26 am Post subject: |
|
|
Looks like RGB16 is wrong. Use this instead (or modify yours :P):
| Quote: | // stolen from some other thread...
#define RGB16(r, g, b) ((((b>>3) & 0x1F)<<10)+(((g>>3) & 0x1F)<<5)+(((r>>3) & 0x1F)<<0)+0x8000) |
EDIT: I am the lose. |
|
| Back to top |
|
 |
AnonymousTipster
Joined: 01 Jul 2005 Posts: 197
|
Posted: Mon Jul 04, 2005 5:01 am Post subject: |
|
|
Well, I tried that, in video modes 1,2,3 but I get something worse:
4 gradient bars, one from black to brown/green, then one from dark red to a slightly brownier red, then medium red to pale orange, and then red to light red. Also, the gradients aren't smooth, they are broken into 8 blocks per gradient.
Has anybody else got a macro like this working fully on the PSP yet?
This is very odd, any help appreciated. |
|
| Back to top |
|
 |
Harold
Joined: 30 Jun 2005 Posts: 7
|
|
| Back to top |
|
 |
XenuPSP
Joined: 04 Apr 2005 Posts: 3
|
Posted: Mon Jul 04, 2005 5:12 am Post subject: |
|
|
| What mode are you in? Are you sure the color isn't mapped as 5:6:5? I'm wondering if your shift for blue shouldn't be 11 bits instead of 10, and your green mask should be 0x3F instead of 0x1F. |
|
| Back to top |
|
 |
AnonymousTipster
Joined: 01 Jul 2005 Posts: 197
|
Posted: Mon Jul 04, 2005 5:23 am Post subject: |
|
|
I found that thread when the problem arised, but that Macro (the one I am using to get me the really strange results) doesn't seem to work.
Also, I tried using the 5.6.5 macro and that still doesn't work, and that would only tweak the colour somewhat, ATM the colour should be black to white, but is black to dark green to red to orange...etc.
I am using Nem's code as follows:
| Code: | //constants
#define PIXELSIZE 1 //in short
#define PIXELMODE 1 //The bit depth
/*------------------------------*/
void pgScreenFrame(long mode,long frame)
{
pg_screenmode=mode;
frame=(frame?1:0);
pg_showframe=frame;
if (mode==0) {
//screen off
pg_drawframe=frame;
sceDisplaySetFrameBuf(0,0,PIXELMODE,1);
} else if (mode==1) {
//show/draw same
pg_drawframe=frame;
sceDisplaySetFrameBuf(pg_vramtop+(pg_showframe?FRAMESIZE:0),LINESIZE,PIXELMODE,1);
} else if (mode==2) {
//show/draw different
pg_drawframe=(frame?0:1);
sceDisplaySetFrameBuf(pg_vramtop+(pg_showframe?FRAMESIZE:0),LINESIZE,PIXELMODE,1);
}
}
void pgScreenFlip()
{
pg_showframe=(pg_showframe?0:1);
pg_drawframe=(pg_drawframe?0:1);
sceDisplaySetFrameBuf(pg_vramtop+(pg_showframe?FRAMESIZE:0),LINESIZE, 0,1);
}
|
And I'm still having problems, which is very odd, because that Macro seems to work for other people.
And thanks for the help so far. |
|
| Back to top |
|
 |
AnonymousTipster
Joined: 01 Jul 2005 Posts: 197
|
Posted: Mon Jul 04, 2005 5:32 am Post subject: |
|
|
I have done a bit more research into it, and instead of plotting black to white, I tried it with black to red, black to green and black to blue.
Black - Red worked perfectly: black to red over 255 pixels
Black - Green displayed 4 black - dark green gradients
Black - Blue displayed nothing at all.
So, the Red element seems to be working, the green is incorrect and the blue is completely off. |
|
| Back to top |
|
 |
AnonymousTipster
Joined: 01 Jul 2005 Posts: 197
|
Posted: Mon Jul 04, 2005 5:41 am Post subject: |
|
|
FWIW, I found out that
(((b>>3) & 0x1F)<<8) is where it goes black, and
(((b>>3) & 0x1F)<<7) displays dark green stripes |
|
| Back to top |
|
 |
AnonymousTipster
Joined: 01 Jul 2005 Posts: 197
|
Posted: Tue Jul 05, 2005 2:12 am Post subject: |
|
|
Still having problems, has anybody used the
| Quote: | | #define RGB16(r, g, b) ((((b>>3) & 0x1F)<<10)+(((g>>3) & 0x1F)<<5)+(((r>>3) & 0x1F)<<0)+0x8000) |
Macro sucessfully with a multitude of colours (i.e, not just black)? |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|