changeset 2681:c15b6c758be5 gsoc2008_nds

Some small bug fixes and more work on video
author Darren Alton <dalton@stevens.edu>
date Fri, 25 Jul 2008 23:39:14 +0000
parents 4135aa9c5645
children f7594fc66bda
files src/video/nds/SDL_ndsrender.c src/video/nds/SDL_ndsvideo.c
diffstat 2 files changed, 39 insertions(+), 26 deletions(-) [+]
line wrap: on
line diff
--- a/src/video/nds/SDL_ndsrender.c	Sat Jul 19 17:37:19 2008 +0000
+++ b/src/video/nds/SDL_ndsrender.c	Fri Jul 25 23:39:14 2008 +0000
@@ -87,8 +87,8 @@
         3, /* u32 num_texture_formats */
         {
             SDL_PIXELFORMAT_INDEX8,
-            SDL_PIXELFORMAT_RGB555,
-            SDL_PIXELFORMAT_RGB565
+            SDL_PIXELFORMAT_ABGR1555,
+            SDL_PIXELFORMAT_BGR555,
         }, /* u32 texture_formats[20] */
         (256), /* int max_texture_width */
         (256), /* int max_texture_height */
@@ -100,6 +100,7 @@
     bg_attribute *bg;
     u8 bg_taken[4];
     int sub;
+    SDL_DirtyRectList dirty;
 } NDS_RenderData;
 
 typedef struct
@@ -437,6 +438,10 @@
     } else {
         NDS_TextureData *txdat = (NDS_TextureData *) texture->driverdata;
 
+        if (markDirty) {
+            SDL_AddDirtyRect(&txdat->dirty, rect);
+        }
+
         *pixels = (void *) ((u8 *)txdat->vram + rect->y * txdat->dim.pitch
                             + rect->x * (txdat->dim.bpp/8));
         *pitch = txdat->dim.pitch;
@@ -488,30 +493,34 @@
                    const SDL_Rect * srcrect, const SDL_Rect * dstrect)
 {
     NDS_RenderData *data = (NDS_RenderData *) renderer->driverdata;
-    SDL_Window *window = SDL_GetWindowFromID(renderer->window);
-    SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window);
+    NDS_TextureData *txdat = (NDS_TextureData *) texture->driverdata;
+//    SDL_Window *window = SDL_GetWindowFromID(renderer->window);
+//    SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window);
 
 printf("+NDS_RenderCopy\n");
-#if 0
-    if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) {
-        SDL_Surface *target = data->screens[data->current_screen];
-        void *pixels =
-            (Uint8 *) target->pixels + dstrect->y * target->pitch +
-            dstrect->x * target->format->BytesPerPixel;
-        return SDL_SW_CopyYUVToRGB((SDL_SW_YUVTexture *) texture->driverdata,
-                                   srcrect, display->current_mode.format,
-                                   dstrect->w, dstrect->h, pixels,
-                                   target->pitch);
-    } else {
-        SDL_Surface *surface = (SDL_Surface *) texture->driverdata;
-        SDL_Surface *target = data->screens[data->current_screen];
-        SDL_Rect real_srcrect = *srcrect;
-        SDL_Rect real_dstrect = *dstrect;
-        return SDL_LowerBlit(surface, &real_srcrect, target, &real_dstrect);
+
+    if (txdat->dirty.list) {
+        SDL_DirtyRect *dirty;
+        void *pixels;
+        int bpp = SDL_BYTESPERPIXEL(texture->format);
+        int pitch = txdat->pitch;
+/* below was borrowed from SDL_renderer_gl.c.  doesn't work, obv.
+   figure out how to get the graphics data into VRAM. */
+
+        for (dirty = txdat->dirty.list; dirty; dirty = dirty->next) {
+            SDL_Rect *rect = &dirty->rect;
+            /*pixels =
+                (void *) ((Uint8 *) txdat->vram + rect->y * pitch +
+                          rect->x * bpp);
+            data->glTexSubImage2D(texturedata->type, 0, rect->x, rect->y,
+                                  rect->w, rect->h, texturedata->format,
+                                  texturedata->formattype, pixels);*/
+        }
+        SDL_ClearDirtyRects(&txdat->dirty);
     }
-#endif
+
 printf("-NDS_RenderCopy\n");
-    return 0;
+    return status;
 }
 
 
@@ -537,7 +546,9 @@
         SDL_SetError("Unsupported texture format");
     } else {
         /* free anything else allocated for texture */
-        SDL_free(texture->driverdata);
+        NDS_TextureData *txdat = texture->driverdata;
+        SDL_FreeDirtyRects(&txdat->dirty);
+        SDL_free(txdat);
     }
 printf("-NDS_DestroyTexture\n");
 }
--- a/src/video/nds/SDL_ndsvideo.c	Sat Jul 19 17:37:19 2008 +0000
+++ b/src/video/nds/SDL_ndsvideo.c	Fri Jul 25 23:39:14 2008 +0000
@@ -198,10 +198,12 @@
 {
 printf("+NDS_SetDisplayMode\n");
     /* right now this function is just hard-coded for 256x192 ABGR1555 */
-    videoSetMode(MODE_5_2D | DISPLAY_BG3_ACTIVE);       /* display on main core */
-    videoSetModeSub(MODE_0_2D | DISPLAY_BG0_ACTIVE);    /* debug text on sub */
+    videoSetMode(MODE_5_2D |
+        DISPLAY_BG2_ACTIVE | DISPLAY_BG3_ACTIVE
+        DISPLAY_SPR_1D_LAYOUT | DISPLAY_SPR_ACTIVE); /* display on main core */
+    videoSetModeSub(MODE_0_2D | DISPLAY_BG0_ACTIVE); /* debug text on sub */
     vramSetMainBanks(VRAM_A_MAIN_BG_0x06000000, VRAM_B_MAIN_BG_0x06020000,
-                     VRAM_C_SUB_BG_0x06200000,  VRAM_C_SUB_BG_0x06220000);
+                     VRAM_C_SUB_BG_0x06200000,  VRAM_D_SUB_BG_0x06220000);
     vramSetBankE(VRAM_E_MAIN_SPRITE);
     /* set up console for debug text 'n stuff */
     SUB_BG0_CR = BG_MAP_BASE(31);