 |
forums.ps2dev.org Homebrew PS2, PSP & PS3 Development Discussions
|
| View previous topic :: View next topic |
| Author |
Message |
crazyc
Joined: 17 Jun 2005 Posts: 410
|
Posted: Sat Aug 27, 2005 7:07 am Post subject: 8bit sdl surfaces |
|
|
Here's a patch to add support for 8bit software surfaces in SDL.
| Code: | --- SDL_pspvideo.c.orig Fri Aug 26 15:58:10 2005
+++ SDL_pspvideo.c Fri Aug 26 15:54:56 2005
@@ -35,6 +35,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <malloc.h>
#include "SDL.h"
#include "SDL_error.h"
@@ -205,7 +206,13 @@
sceGuInit();
sceGuStart(GU_DIRECT, list);
sceGuDispBuffer(SCREEN_WIDTH, SCREEN_HEIGHT, (void*)0, PSP_LINE_SIZE);
- sceGuDrawBuffer(gu_format, (void*)0, PSP_LINE_SIZE);
+ if(gu_format == GU_PSM_T8)
+ {
+ sceGuDrawBuffer(GU_PSM_8888, (void*)0, PSP_LINE_SIZE);
+ sceGuClutMode(GU_PSM_8888, 0, 255, 0);
+ }
+ else
+ sceGuDrawBuffer(gu_format, (void*)0, PSP_LINE_SIZE);
sceGuClear(GU_COLOR_BUFFER_BIT | GU_DEPTH_BUFFER_BIT);
sceGuDepthBuffer((void*) 0x110000, PSP_LINE_SIZE);
sceGuOffset(2048 - (SCREEN_WIDTH / 2), 2048 - (SCREEN_HEIGHT / 2));
@@ -236,6 +243,13 @@
}
switch(bpp) {
+ case 8:
+ Amask = 0;
+ Rmask = 0;
+ Gmask = 0;
+ Bmask = 0;
+ pixel_format = PSP_DISPLAY_PIXEL_FORMAT_8888;
+ gu_format = GU_PSM_T8;
case 15: /* 5-5-5-1 */
pitch = 512 * 2;
Amask = 0x00008000;
@@ -301,6 +315,8 @@
this->hidden->gu_format = gu_format;
this->UpdateRects = PSP_GuUpdateRects;
+ if(bpp == 8 && !this->hidden->gu_palette)
+ this->hidden->gu_palette = memalign(16, 4 * 256);
}
this->hidden->pixel_format = pixel_format;
@@ -448,8 +464,20 @@
int PSP_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors)
{
- /* do nothing of note. */
- return(1);
+ int i, j;
+ unsigned int *palette = this->hidden->gu_palette;
+
+ if (this->hidden->gu_format != GU_PSM_T8) return 0;
+
+ for (i=firstcolor, j=0; j < ncolors; i++, j++)
+ palette[i] = (colors[j].b << 16) | (colors[j].g << 8) | (colors[j].r);
+
+ sceKernelDcacheWritebackAll();
+ sceGuStart(GU_DIRECT, list);
+ sceGuClutLoad(32, this->hidden->gu_palette);
+ sceGuFinish();
+
+ return 1;
}
/* Note: If we are terminated, this could be called in the middle of
|
Also "unsigned int *gu_palette" should be added to the SDL_PrivateVideoData struct |
|
| Back to top |
|
 |
stefan
Joined: 14 Nov 2004 Posts: 10
|
Posted: Sat Aug 27, 2005 10:42 am Post subject: |
|
|
| Applied with minor changes. Untested. |
|
| Back to top |
|
 |
vtrucco
Joined: 05 Aug 2005 Posts: 1
|
Posted: Tue Aug 30, 2005 10:51 am Post subject: |
|
|
Doesn't work for me. I tested with /SDL/test/testsprite.c
"8-bit surfaces are only supported on software surfaces." |
|
| Back to top |
|
 |
urchin
Joined: 02 Jun 2005 Posts: 121
|
Posted: Thu Oct 27, 2005 6:57 am Post subject: |
|
|
| If you specify double buffering when setting the video mode to 8bit, it will be forced into hardware surface mode and fail. |
|
| 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
|