diff src/video/nds/SDL_ndsrender.c @ 2671:c3e7c0698cbb gsoc2008_nds

some changes to the dummy driver for debug purposes that should be reverted. most importantly, commenting out a check for an env. var.
author Darren Alton <dalton@stevens.edu>
date Thu, 12 Jun 2008 02:38:49 +0000
parents 6e4669f4db49
children 74ac057679d5
line wrap: on
line diff
--- a/src/video/nds/SDL_ndsrender.c	Tue Jun 10 06:57:57 2008 +0000
+++ b/src/video/nds/SDL_ndsrender.c	Thu Jun 12 02:38:49 2008 +0000
@@ -35,20 +35,20 @@
 /* SDL surface based renderer implementation */
 
 static SDL_Renderer *SDL_NDS_CreateRenderer(SDL_Window * window,
-                                              Uint32 flags);
+                                            Uint32 flags);
 static int SDL_NDS_RenderFill(SDL_Renderer * renderer, Uint8 r, Uint8 g,
-                                Uint8 b, Uint8 a, const SDL_Rect * rect);
+                              Uint8 b, Uint8 a, const SDL_Rect * rect);
 static int SDL_NDS_RenderCopy(SDL_Renderer * renderer,
-                                SDL_Texture * texture,
-                                const SDL_Rect * srcrect,
-                                const SDL_Rect * dstrect);
+                              SDL_Texture * texture,
+                              const SDL_Rect * srcrect,
+                              const SDL_Rect * dstrect);
 static void SDL_NDS_RenderPresent(SDL_Renderer * renderer);
 static void SDL_NDS_DestroyRenderer(SDL_Renderer * renderer);
 
 
 SDL_RenderDriver SDL_NDS_RenderDriver = {
     SDL_NDS_CreateRenderer,
-    { "nds",  SDL_RENDERER_PRESENTCOPY }
+    {"nds", SDL_RENDERER_PRESENTCOPY}
 /*   (SDL_RENDERER_SINGLEBUFFER | SDL_RENDERER_PRESENTCOPY |
       SDL_RENDERER_PRESENTFLIP2 | SDL_RENDERER_PRESENTFLIP3 |
       SDL_RENDERER_PRESENTDISCARD),*/
@@ -73,14 +73,15 @@
     Uint32 Rmask = 0x7C00, Gmask = 0x03E0, Bmask = 0x001F, Amask = 0x8000;
 
     printf("SDL_NDS_CreateRenderer(window, 0x%x)\n", flags);
-    printf(" window: (%d,%d), %dx%d\n", window->x, window->y, window->w, window->h);
+    printf(" window: (%d,%d), %dx%d\n", window->x, window->y, window->w,
+           window->h);
 
     /* hard coded this to ARGB1555 for now
-    if (!SDL_PixelFormatEnumToMasks
-        (displayMode->format, &bpp, &Rmask, &Gmask, &Bmask, &Amask)) {
-        SDL_SetError("Unknown display format");
-        return NULL;
-    }*/
+       if (!SDL_PixelFormatEnumToMasks
+       (displayMode->format, &bpp, &Rmask, &Gmask, &Bmask, &Amask)) {
+       SDL_SetError("Unknown display format");
+       return NULL;
+       } */
 
     renderer = (SDL_Renderer *) SDL_calloc(1, sizeof(*renderer));
     if (!renderer) {
@@ -118,7 +119,8 @@
     }
     for (i = 0; i < n; ++i) {
         data->screens[i] =
-            SDL_CreateRGBSurface(0, 256, 192, bpp, Rmask, Gmask, Bmask, Amask);
+            SDL_CreateRGBSurface(0, 256, 192, bpp, Rmask, Gmask, Bmask,
+                                 Amask);
         if (!data->screens[i]) {
             SDL_NDS_DestroyRenderer(renderer);
             return NULL;
@@ -131,17 +133,11 @@
 #if 0
 #define blarg (data->screens[0])
     printf("hello?\n");
-    if(!data || !(data->screens) || !blarg) {
+    if (!data || !(data->screens) || !blarg) {
         printf("they're null.\n");
     } else {
         printf("not null.\n");
-        printf("%d\n%d\n%d\n%d\n%x\n%x\n%x\n%x\n",
-        blarg->w, blarg->h, blarg->pitch,
-        blarg->format->BitsPerPixel,
-        blarg->format->Rmask,
-        blarg->format->Gmask,
-        blarg->format->Bmask,
-        (u32)(blarg->pixels)); /* ARGH WHY DOESN'T THIS PRINT AT ALL? */
+        printf("%d\n%d\n%d\n%d\n%x\n%x\n%x\n%x\n", blarg->w, blarg->h, blarg->pitch, blarg->format->BitsPerPixel, blarg->format->Rmask, blarg->format->Gmask, blarg->format->Bmask, (u32) (blarg->pixels));     /* ARGH WHY DOESN'T THIS PRINT AT ALL? */
         printf("hurr\n");
     }
 #undef blarg
@@ -151,7 +147,7 @@
 
 static int
 SDL_NDS_RenderFill(SDL_Renderer * renderer, Uint8 r, Uint8 g, Uint8 b,
-                     Uint8 a, const SDL_Rect * rect)
+                   Uint8 a, const SDL_Rect * rect)
 {
     SDL_NDS_RenderData *data = (SDL_NDS_RenderData *) renderer->driverdata;
     SDL_Surface *target = data->screens[data->current_screen];
@@ -164,26 +160,29 @@
 }
 
 /* this is mainly for testing stuff to put a surface where I can see it */
-void sdlds_surf2vram(SDL_Surface *s) {
+void
+sdlds_surf2vram(SDL_Surface * s)
+{
     int i;
-    for(i = 0; i < 256*192; ++i) {
-        ((u16*)VRAM_A)[i] = ((u16*)(s->pixels))[i];
+    for (i = 0; i < 256 * 192; ++i) {
+        ((u16 *) VRAM_A)[i] = ((u16 *) (s->pixels))[i];
     }
 }
 
 static int
 SDL_NDS_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
-                     const SDL_Rect * srcrect, const SDL_Rect * dstrect)
+                   const SDL_Rect * srcrect, const SDL_Rect * dstrect)
 {
-    SDL_NDS_RenderData *data =
-        (SDL_NDS_RenderData *) renderer->driverdata;
+    SDL_NDS_RenderData *data = (SDL_NDS_RenderData *) renderer->driverdata;
     SDL_Window *window = SDL_GetWindowFromID(renderer->window);
     SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window);
     printf("SDL_NDS_RenderCopy(renderer, texture, srcrect, dstrect)\n");
     printf(" renderer: %s\n", renderer->info.name);
     printf(" texture: %dx%d\n", texture->w, texture->h);
-    printf(" srcrect: (%d,%d), %dx%d\n", srcrect->x, srcrect->y, srcrect->w, srcrect->h);
-    printf(" dstrect: (%d,%d), %dx%d\n", dstrect->x, dstrect->y, dstrect->w, dstrect->h);
+    printf(" srcrect: (%d,%d), %dx%d\n", srcrect->x, srcrect->y, srcrect->w,
+           srcrect->h);
+    printf(" dstrect: (%d,%d), %dx%d\n", dstrect->x, dstrect->y, dstrect->w,
+           dstrect->h);
 
     if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) {
         SDL_Surface *target = data->screens[data->current_screen];
@@ -201,37 +200,38 @@
         SDL_Rect real_dstrect = *dstrect;
         printf("Rmask %x Gmask %x Bmask %x Amask %x\n"
                "width %d, height %d, pitch %d\nbpp %d, pixels %x\n",
-            surface->format->Rmask, surface->format->Gmask,
-            surface->format->Bmask, surface->format->Amask,
-            surface->w, surface->h, surface->pitch,
-            surface->format->BitsPerPixel, (u32)(surface->pixels));
+               surface->format->Rmask, surface->format->Gmask,
+               surface->format->Bmask, surface->format->Amask,
+               surface->w, surface->h, surface->pitch,
+               surface->format->BitsPerPixel, (u32) (surface->pixels));
         sdlds_surf2vram(surface);
         return SDL_LowerBlit(surface, &real_srcrect, target, &real_dstrect);
     }
 #if 0
 /* previous attempt to copy it directly to vram */
-        SDL_Surface *surface = (SDL_Surface *) texture->driverdata;
-        int sx = srcrect->x, sy = srcrect->y, sw = srcrect->w, sh = srcrect->h;
-        int dx = dstrect->x, dy = dstrect->y, dw = dstrect->w, dh = dstrect->h;
-        int si,sj, di,dj;
-        /*printf("DEBUG: still alive!\n");*/
-        for(sj=0, dj=0; sj<sh && dj<dh; ++sj, ++dj) {
-            for(si=0, di=0; si<sw && di<dw; ++si, ++di) {
-                ((uint16*)VRAM_A)[(dj+dy)*256 + di+dx]
-                 = ((Uint16*)surface->pixels)[(sj+sy)*(surface->w) + si+sx];
-            }
+    SDL_Surface *surface = (SDL_Surface *) texture->driverdata;
+    int sx = srcrect->x, sy = srcrect->y, sw = srcrect->w, sh = srcrect->h;
+    int dx = dstrect->x, dy = dstrect->y, dw = dstrect->w, dh = dstrect->h;
+    int si, sj, di, dj;
+    /*printf("DEBUG: still alive!\n"); */
+    for (sj = 0, dj = 0; sj < sh && dj < dh; ++sj, ++dj) {
+        for (si = 0, di = 0; si < sw && di < dw; ++si, ++di) {
+            ((uint16 *) VRAM_A)[(dj + dy) * 256 + di + dx]
+                = ((Uint16 *) surface->pixels)[(sj + sy) * (surface->w) + si +
+                                               sx];
         }
-        /*printf("DEBUG: still alive!\n");*/
     }
-    return 0;
+    /*printf("DEBUG: still alive!\n"); */
+}
+
+return 0;
 #endif
 }
 
 static void
 SDL_NDS_RenderPresent(SDL_Renderer * renderer)
 {
-    SDL_NDS_RenderData *data =
-        (SDL_NDS_RenderData *) renderer->driverdata;
+    SDL_NDS_RenderData *data = (SDL_NDS_RenderData *) renderer->driverdata;
 
     printf("SDL_NDS_RenderPresent(renderer)\n");
     printf(" renderer: %s\n", renderer->info.name);
@@ -240,18 +240,25 @@
 #if 0
 /*testing to see if rectangles drawn get copied right*/
     {
-    SDL_Rect ra;
-  	ra.x=0; ra.y=0; ra.w=256; ra.h=192;
-	SDL_FillRect(data->screens[data->current_screen], &ra, 0x250);
-	ra.x=32; ra.y=32; ra.w=192; ra.h=128;
-	SDL_FillRect(data->screens[data->current_screen], &ra,
-	    SDL_MapRGBA(data->screens[data->current_screen]->format,
-	    255,255,255,255));
-	}
+        SDL_Rect ra;
+        ra.x = 0;
+        ra.y = 0;
+        ra.w = 256;
+        ra.h = 192;
+        
SDL_FillRect(data->screens[data->current_screen], &ra, 0x250);
+        ra.x = 32;
+        ra.y = 32;
+        ra.w = 192;
+        ra.h = 128;
+        
SDL_FillRect(data->screens[data->current_screen], &ra,
+                      SDL_MapRGBA(data->screens[data->current_screen]->format,
+                                  255, 255, 255, 255));
+    }
 /*okay so this works but why not when I do it in the main()?
   for some reason the screen I get from screen=SDL_SetVideoMode(...)
   doesn't get copied to renderer->driverdata? */
-    for(i = 0; i < 30; ++i) swiWaitForVBlank(); /* delay for debug purpose */
+    for (i = 0; i < 30; ++i)
+        swiWaitForVBlank();     /* delay for debug purpose */
 #endif
     sdlds_surf2vram(data->screens[data->current_screen]);