Code: Select all
--- 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