forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

8bit sdl surfaces

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development
View previous topic :: View next topic  
Author Message
crazyc



Joined: 17 Jun 2005
Posts: 410

PostPosted: Sat Aug 27, 2005 7:07 am    Post subject: 8bit sdl surfaces Reply with quote

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
View user's profile Send private message
stefan



Joined: 14 Nov 2004
Posts: 10

PostPosted: Sat Aug 27, 2005 10:42 am    Post subject: Reply with quote

Applied with minor changes. Untested.
Back to top
View user's profile Send private message
vtrucco



Joined: 05 Aug 2005
Posts: 1

PostPosted: Tue Aug 30, 2005 10:51 am    Post subject: Reply with quote

Doesn't work for me. I tested with /SDL/test/testsprite.c

"8-bit surfaces are only supported on software surfaces."
Back to top
View user's profile Send private message
urchin



Joined: 02 Jun 2005
Posts: 121

PostPosted: Thu Oct 27, 2005 6:57 am    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
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