diff src/video/nds/SDL_ndsrender.c @ 2698:e1da92da346c gsoc2008_nds

Clean up.
author Darren Alton <dalton@stevens.edu>
date Wed, 27 Aug 2008 04:23:38 +0000
parents 0b395a60deff
children
line wrap: on
line diff
--- a/src/video/nds/SDL_ndsrender.c	Thu Aug 21 12:38:21 2008 +0000
+++ b/src/video/nds/SDL_ndsrender.c	Wed Aug 27 04:23:38 2008 +0000
@@ -34,23 +34,20 @@
 #include "../SDL_yuv_sw_c.h"
 #include "../SDL_renderer_sw.h"
 
-#define TRACE
-//#define TRACE printf
-
 /* NDS sprite-related functions */
 #define SPRITE_DMA_CHANNEL 3
 #define SPRITE_ANGLE_MASK 0x01FF
 
 void
-NDS_OAM_Update(tOAM *oam, int sub)
+NDS_OAM_Update(tOAM * oam, int sub)
 {
     DC_FlushAll();
-    dmaCopyHalfWords(SPRITE_DMA_CHANNEL, oam->spriteBuffer, sub?OAM_SUB:OAM,
-                     SPRITE_COUNT * sizeof(SpriteEntry));
+    dmaCopyHalfWords(SPRITE_DMA_CHANNEL, oam->spriteBuffer,
+                     sub ? OAM_SUB : OAM, SPRITE_COUNT * sizeof(SpriteEntry));
 }
 
 void
-NDS_OAM_RotateSprite(SpriteRotation *spriteRotation, u16 angle)
+NDS_OAM_RotateSprite(SpriteRotation * spriteRotation, u16 angle)
 {
     s16 s = SIN[angle & SPRITE_ANGLE_MASK] >> 4;
     s16 c = COS[angle & SPRITE_ANGLE_MASK] >> 4;
@@ -62,15 +59,15 @@
 }
 
 void
-NDS_OAM_Init(tOAM *oam, int sub)
+NDS_OAM_Init(tOAM * oam, int sub)
 {
     int i;
-    for(i = 0; i < SPRITE_COUNT; i++) {
+    for (i = 0; i < SPRITE_COUNT; i++) {
         oam->spriteBuffer[i].attribute[0] = ATTR0_DISABLED;
         oam->spriteBuffer[i].attribute[1] = 0;
         oam->spriteBuffer[i].attribute[2] = 0;
     }
-    for(i = 0; i < MATRIX_COUNT; i++) {
+    for (i = 0; i < MATRIX_COUNT; i++) {
         NDS_OAM_RotateSprite(&(oam->matrixBuffer[i]), 0);
     }
     swiWaitForVBlank();
@@ -78,14 +75,14 @@
 }
 
 void
-NDS_OAM_HideSprite(SpriteEntry *spriteEntry)
+NDS_OAM_HideSprite(SpriteEntry * spriteEntry)
 {
     spriteEntry->isRotoscale = 0;
     spriteEntry->isHidden = 1;
 }
 
 void
-NDS_OAM_ShowSprite(SpriteEntry *spriteEntry, int affine, int double_bound)
+NDS_OAM_ShowSprite(SpriteEntry * spriteEntry, int affine, int double_bound)
 {
     if (affine) {
         spriteEntry->isRotoscale = 1;
@@ -103,85 +100,83 @@
 static int NDS_DisplayModeChanged(SDL_Renderer * renderer);
 static int NDS_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture);
 static int NDS_QueryTexturePixels(SDL_Renderer * renderer,
-                                 SDL_Texture * texture, void **pixels,
-                                 int *pitch);
+                                  SDL_Texture * texture, void **pixels,
+                                  int *pitch);
 static int NDS_SetTexturePalette(SDL_Renderer * renderer,
-                                SDL_Texture * texture,
-                                const SDL_Color * colors, int firstcolor,
-                                int ncolors);
+                                 SDL_Texture * texture,
+                                 const SDL_Color * colors, int firstcolor,
+                                 int ncolors);
 static int NDS_GetTexturePalette(SDL_Renderer * renderer,
-                                SDL_Texture * texture, SDL_Color * colors,
-                                int firstcolor, int ncolors);
+                                 SDL_Texture * texture, SDL_Color * colors,
+                                 int firstcolor, int ncolors);
 static int NDS_SetTextureColorMod(SDL_Renderer * renderer,
-                                 SDL_Texture * texture);
+                                  SDL_Texture * texture);
 static int NDS_SetTextureAlphaMod(SDL_Renderer * renderer,
-                                 SDL_Texture * texture);
+                                  SDL_Texture * texture);
 static int NDS_SetTextureBlendMode(SDL_Renderer * renderer,
-                                  SDL_Texture * texture);
+                                   SDL_Texture * texture);
 static int NDS_SetTextureScaleMode(SDL_Renderer * renderer,
-                                  SDL_Texture * texture);
+                                   SDL_Texture * texture);
 static int NDS_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
-                          const SDL_Rect * rect, const void *pixels,
-                          int pitch);
+                             const SDL_Rect * rect, const void *pixels,
+                             int pitch);
 static int NDS_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
-                          const SDL_Rect * rect, int markDirty, void **pixels,
-                          int *pitch);
+                           const SDL_Rect * rect, int markDirty,
+                           void **pixels, int *pitch);
 static void NDS_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture);
 static void NDS_DirtyTexture(SDL_Renderer * renderer,
-                            SDL_Texture * texture, int numrects,
-                            const SDL_Rect * rects);
+                             SDL_Texture * texture, int numrects,
+                             const SDL_Rect * rects);
 static int 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 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 NDS_RenderPresent(SDL_Renderer * renderer);
-static void NDS_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture);
+static void NDS_DestroyTexture(SDL_Renderer * renderer,
+                               SDL_Texture * texture);
 static void NDS_DestroyRenderer(SDL_Renderer * renderer);
 
 
 SDL_RenderDriver NDS_RenderDriver = {
     NDS_CreateRenderer,
-    {   "nds", /* char* name */
-        (SDL_RENDERER_SINGLEBUFFER |
-         SDL_RENDERER_ACCELERATED |
-         SDL_RENDERER_PRESENTDISCARD |
-         SDL_RENDERER_PRESENTVSYNC), /* u32 flags */
-        (SDL_TEXTUREMODULATE_NONE), /* u32 mod_modes */
-        (SDL_TEXTUREBLENDMODE_MASK), /* u32 blend_modes */
-        (SDL_TEXTURESCALEMODE_FAST), /* u32 scale_modes */
-        3, /* u32 num_texture_formats */
-        {
-            SDL_PIXELFORMAT_INDEX8,
-            SDL_PIXELFORMAT_ABGR1555,
-            SDL_PIXELFORMAT_BGR555,
-        }, /* u32 texture_formats[20] */
-        (256), /* int max_texture_width */
-        (256), /* int max_texture_height */
-    }
+    {"nds",                     /* char* name */
+     (SDL_RENDERER_SINGLEBUFFER | SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTDISCARD | SDL_RENDERER_PRESENTVSYNC),  /* u32 flags */
+     (SDL_TEXTUREMODULATE_NONE),        /* u32 mod_modes */
+     (SDL_TEXTUREBLENDMODE_MASK),       /* u32 blend_modes */
+     (SDL_TEXTURESCALEMODE_FAST),       /* u32 scale_modes */
+     3,                         /* u32 num_texture_formats */
+     {
+      SDL_PIXELFORMAT_INDEX8,
+      SDL_PIXELFORMAT_ABGR1555,
+      SDL_PIXELFORMAT_BGR555,
+      },                        /* u32 texture_formats[20] */
+     (256),                     /* int max_texture_width */
+     (256),                     /* int max_texture_height */
+     }
 };
 
 typedef struct
 {
-    bg_attribute *bg; /* backgrounds */
-    tOAM oam_copy; /* sprites */
+    bg_attribute *bg;           /* backgrounds */
+    tOAM oam_copy;              /* sprites */
     u8 bg_taken[4];
     int sub;
 } NDS_RenderData;
 
 typedef struct
 {
-    enum { NDSTX_BG, NDSTX_SPR } type; /* represented in a bg or sprite. */
-    int hw_index; /* sprite: index in the OAM. /  bg: 2 or 3. */
+    enum
+    { NDSTX_BG, NDSTX_SPR } type;       /* represented in a bg or sprite. */
+    int hw_index;               /* sprite: index in the OAM. /  bg: 2 or 3. */
     struct
     {
         int hdx, hdy, vdx, vdy; /* affine transformation, used for scaling. */
-        int pitch, bpp; /* some useful info */
+        int pitch, bpp;         /* some useful info */
     } dim;
-    u16 *vram_pixels; /* where the pixel data is stored (a pointer into VRAM) */
-    u16 *vram_palette; /* where the palette data is stored if it's indexed.*/
-    /*int size;*/
+    u16 *vram_pixels;           /* where the pixel data is stored (a pointer into VRAM) */
+    u16 *vram_palette;          /* where the palette data is stored if it's indexed. */
+    /*int size; */
 } NDS_TextureData;
 
 
@@ -197,26 +192,25 @@
     int bpp;
     Uint32 Rmask, Gmask, Bmask, Amask;
 
-    TRACE("+NDS_CreateRenderer\n");
     if (!SDL_PixelFormatEnumToMasks(displayMode->format, &bpp,
                                     &Rmask, &Gmask, &Bmask, &Amask)) {
         SDL_SetError("Unknown display format");
         return NULL;
     }
-    switch(displayMode->format) {
-        case SDL_PIXELFORMAT_INDEX8:
-        case SDL_PIXELFORMAT_ABGR1555:
-        case SDL_PIXELFORMAT_BGR555:
-            /* okay */
-            break;
-        case SDL_PIXELFORMAT_RGB555:
-        case SDL_PIXELFORMAT_RGB565:
-        case SDL_PIXELFORMAT_ARGB1555:
-            /* we'll take these too for now */
-            break;
-        default:
-            printf("DEBUG: wrong display format!\n");
-            break;
+    switch (displayMode->format) {
+    case SDL_PIXELFORMAT_INDEX8:
+    case SDL_PIXELFORMAT_ABGR1555:
+    case SDL_PIXELFORMAT_BGR555:
+        /* okay */
+        break;
+    case SDL_PIXELFORMAT_RGB555:
+    case SDL_PIXELFORMAT_RGB565:
+    case SDL_PIXELFORMAT_ARGB1555:
+        /* we'll take these too for now */
+        break;
+    default:
+        SDL_SetError("Warning: wrong display format for NDS!\n");
+        break;
     }
 
     renderer = (SDL_Renderer *) SDL_calloc(1, sizeof(*renderer));
@@ -268,10 +262,10 @@
     renderer->info.max_texture_height =
         NDS_RenderDriver.info.max_texture_height;
 
-    data->sub = 0; /* TODO: this is hard-coded to the "main" screen.
-                            figure out how to detect whether to set it to
-                            "sub" screen.  window->id, perhaps? */
-    if(!data->sub) {
+    data->sub = 0;              /* TODO: this is hard-coded to the "main" screen.
+                                   figure out how to detect whether to set it to
+                                   "sub" screen.  window->id, perhaps? */
+    if (!data->sub) {
         data->bg = &BACKGROUND;
     } else {
         data->bg = &BACKGROUND_SUB;
@@ -280,7 +274,6 @@
 
     NDS_OAM_Init(&(data->oam_copy), data->sub); /* init sprites. */
 
-    TRACE("-NDS_CreateRenderer\n");
     return renderer;
 }
 
@@ -288,7 +281,7 @@
 NDS_ActivateRenderer(SDL_Renderer * renderer)
 {
     NDS_RenderData *data = (NDS_RenderData *) renderer->driverdata;
-    TRACE("!NDS_ActivateRenderer\n");
+
     return 0;
 }
 
@@ -296,7 +289,7 @@
 NDS_DisplayModeChanged(SDL_Renderer * renderer)
 {
     NDS_RenderData *data = (NDS_RenderData *) renderer->driverdata;
-    TRACE("!NDS_DisplayModeChanged\n");
+
     return 0;
 }
 
@@ -309,7 +302,6 @@
     int bpp;
     Uint32 Rmask, Gmask, Bmask, Amask;
 
-    TRACE("+NDS_CreateTexture\n");
     if (!SDL_PixelFormatEnumToMasks
         (texture->format, &bpp, &Rmask, &Gmask, &Bmask, &Amask)) {
         SDL_SetError("Unknown texture format");
@@ -318,44 +310,45 @@
 
     /* conditional statements on w/h to place it as bg/sprite
        depending on which one it fits. */
-    if(texture->w <= 64 && texture->h <= 64) {
+    if (texture->w <= 64 && texture->h <= 64) {
         int whichspr = -1;
         printf("Tried to make a sprite.\n");
         txdat->type = NDSTX_SPR;
-        for(i = 0; i < SPRITE_COUNT; ++i) {
-            if(data->oam_copy.spriteBuffer[i].attribute[0] & ATTR0_DISABLED) {
+        for (i = 0; i < SPRITE_COUNT; ++i) {
+            if (data->oam_copy.spriteBuffer[i].attribute[0] & ATTR0_DISABLED) {
                 whichspr = i;
                 break;
             }
         }
-        if(whichspr >= 0) {
+        if (whichspr >= 0) {
             SpriteEntry *sprent = &(data->oam_copy.spriteBuffer[whichspr]);
             int maxside = texture->w > texture->h ? texture->w : texture->h;
             int pitch;
 
             texture->driverdata = SDL_calloc(1, sizeof(NDS_TextureData));
-            txdat = (NDS_TextureData*)texture->driverdata;
-            if(!txdat) {
+            txdat = (NDS_TextureData *) texture->driverdata;
+            if (!txdat) {
                 SDL_OutOfMemory();
                 return -1;
             }
 
             sprent->objMode = OBJMODE_BITMAP;
-            sprent->posX = 0; sprent->posY = 0;
-            sprent->colMode = OBJCOLOR_16; /* OBJCOLOR_256 for INDEX8 */
+            sprent->posX = 0;
+            sprent->posY = 0;
+            sprent->colMode = OBJCOLOR_16;      /* OBJCOLOR_256 for INDEX8 */
 
             /* the first 32 sprites get transformation matrices.
                first come, first served */
-            if(whichspr < MATRIX_COUNT) {
+            if (whichspr < MATRIX_COUNT) {
                 sprent->isRotoscale = 1;
                 sprent->rsMatrixIdx = whichspr;
             }
 
             /* containing shape (square or 2:1 rectangles) */
             sprent->objShape = OBJSHAPE_SQUARE;
-            if(texture->w/2 >= texture->h) {
+            if (texture->w / 2 >= texture->h) {
                 sprent->objShape = OBJSHAPE_WIDE;
-            } else if(texture->h/2 >= texture->w) {
+            } else if (texture->h / 2 >= texture->w) {
                 sprent->objShape = OBJSHAPE_TALL;
             }
 
@@ -363,13 +356,13 @@
             /* FIXME: "pitch" is hardcoded for 2bytes per pixel. */
             sprent->objSize = OBJSIZE_64;
             pitch = 128;
-            if(maxside <= 8) {
+            if (maxside <= 8) {
                 sprent->objSize = OBJSIZE_8;
                 pitch = 16;
-            } else if(maxside <= 16) {
+            } else if (maxside <= 16) {
                 sprent->objSize = OBJSIZE_16;
                 pitch = 32;
-            } else if(maxside <= 32) {
+            } else if (maxside <= 32) {
                 sprent->objSize = OBJSIZE_32;
                 pitch = 64;
             }
@@ -382,28 +375,29 @@
             /* now for the texture data */
             txdat->type = NDSTX_SPR;
             txdat->hw_index = whichspr;
-            txdat->dim.hdx = 0x100; txdat->dim.hdy = 0;
-            txdat->dim.vdx = 0;     txdat->dim.vdy = 0x100;
+            txdat->dim.hdx = 0x100;
+            txdat->dim.hdy = 0;
+            txdat->dim.vdx = 0;
+            txdat->dim.vdy = 0x100;
             txdat->dim.pitch = pitch;
             txdat->dim.bpp = bpp;
-            txdat->vram_pixels = (u16*)(data->sub ?
-                SPRITE_GFX_SUB : SPRITE_GFX); /* FIXME: use tileIdx*boundary
-                                                 to point to proper location */
+            txdat->vram_pixels = (u16 *) (data->sub ? SPRITE_GFX_SUB : SPRITE_GFX);     /* FIXME: use tileIdx*boundary
+                                                                                           to point to proper location */
         } else {
             SDL_SetError("Out of NDS sprites.");
         }
-    } else if(texture->w <= 256 && texture->h <= 256) {
+    } else if (texture->w <= 256 && texture->h <= 256) {
         int whichbg = -1, base = 0;
-        if(!data->bg_taken[2]) {
+        if (!data->bg_taken[2]) {
             whichbg = 2;
-        } else if(!data->bg_taken[3]) {
+        } else if (!data->bg_taken[3]) {
             whichbg = 3;
             base = 4;
         }
-        if(whichbg >= 0) {
+        if (whichbg >= 0) {
             texture->driverdata = SDL_calloc(1, sizeof(NDS_TextureData));
-            txdat = (NDS_TextureData*)texture->driverdata;
-            if(!txdat) {
+            txdat = (NDS_TextureData *) texture->driverdata;
+            if (!txdat) {
                 SDL_OutOfMemory();
                 return -1;
             }
@@ -419,14 +413,17 @@
 
             txdat->type = NDSTX_BG;
             txdat->hw_index = whichbg;
-            txdat->dim.hdx = 0x100; txdat->dim.hdy = 0;
-            txdat->dim.vdx = 0;     txdat->dim.vdy = 0x100;
+            txdat->dim.hdx = 0x100;
+            txdat->dim.hdy = 0;
+            txdat->dim.vdx = 0;
+            txdat->dim.vdy = 0x100;
             txdat->dim.pitch = 512;
             txdat->dim.bpp = bpp;
-            txdat->vram_pixels = (u16*)(data->sub ?
-                BG_BMP_RAM_SUB(base) : BG_BMP_RAM(base));
+            txdat->vram_pixels = (u16 *) (data->sub ?
+                                          BG_BMP_RAM_SUB(base) :
+                                          BG_BMP_RAM(base));
 
-            /*txdat->size = txdat->dim.pitch * texture->h;*/
+            /*txdat->size = txdat->dim.pitch * texture->h; */
         } else {
             SDL_SetError("Out of NDS backgrounds.");
         }
@@ -434,7 +431,6 @@
         SDL_SetError("Texture too big for NDS hardware.");
     }
 
-    TRACE("-NDS_CreateTexture\n");
     if (!texture->driverdata) {
         return -1;
     }
@@ -444,35 +440,33 @@
 
 static int
 NDS_QueryTexturePixels(SDL_Renderer * renderer, SDL_Texture * texture,
-                      void **pixels, int *pitch)
+                       void **pixels, int *pitch)
 {
     NDS_TextureData *txdat = (NDS_TextureData *) texture->driverdata;
-    TRACE("+NDS_QueryTexturePixels\n");
     *pixels = txdat->vram_pixels;
     *pitch = txdat->dim.pitch;
-    TRACE("-NDS_QueryTexturePixels\n");
     return 0;
 }
 
 static int
 NDS_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
-                 const SDL_Rect * rect, const void *pixels, int pitch)
+                  const SDL_Rect * rect, const void *pixels, int pitch)
 {
     NDS_TextureData *txdat;
     Uint8 *src, *dst;
-    int row; size_t length;
-    TRACE("+NDS_UpdateTexture\n");
+    int row;
+    size_t length;
 
     txdat = (NDS_TextureData *) texture->driverdata;
 
     src = (Uint8 *) pixels;
     dst =
         (Uint8 *) txdat->vram_pixels + rect->y * txdat->dim.pitch +
-        rect->x * ((txdat->dim.bpp+1)/8);
-    length = rect->w * ((txdat->dim.bpp+1)/8);
+        rect->x * ((txdat->dim.bpp + 1) / 8);
+    length = rect->w * ((txdat->dim.bpp + 1) / 8);
 
-    if(rect->w == texture->w) {
-        dmaCopy(src, dst, length*rect->h);
+    if (rect->w == texture->w) {
+        dmaCopy(src, dst, length * rect->h);
     } else {
         for (row = 0; row < rect->h; ++row) {
             dmaCopy(src, dst, length);
@@ -481,68 +475,62 @@
         }
     }
 
-    TRACE("-NDS_UpdateTexture\n");
     return 0;
 }
 
 static int
 NDS_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
-               const SDL_Rect * rect, int markDirty, void **pixels,
-               int *pitch)
+                const SDL_Rect * rect, int markDirty, void **pixels,
+                int *pitch)
 {
     NDS_TextureData *txdat = (NDS_TextureData *) texture->driverdata;
-    TRACE("+NDS_LockTexture\n");
 
-    *pixels = (void *) ((u8 *)txdat->vram_pixels + rect->y
-                        * txdat->dim.pitch + rect->x * ((txdat->dim.bpp+1)/8));
+    *pixels = (void *) ((u8 *) txdat->vram_pixels + rect->y
+                        * txdat->dim.pitch +
+                        rect->x * ((txdat->dim.bpp + 1) / 8));
     *pitch = txdat->dim.pitch;
 
-    TRACE("-NDS_LockTexture\n");
     return 0;
 }
 
 static void
 NDS_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture)
 {
-    TRACE("+NDS_UnlockTexture\n");
-    TRACE("-NDS_UnlockTexture\n");
+    /* stub! */
 }
 
 static void
 NDS_DirtyTexture(SDL_Renderer * renderer, SDL_Texture * texture,
-                int numrects, const SDL_Rect * rects)
+                 int numrects, const SDL_Rect * rects)
 {
-    /* stub */
-    TRACE("!NDS_DirtyTexture\n");
+    /* stub! */
 }
 
 static int
 NDS_RenderFill(SDL_Renderer * renderer, Uint8 r, Uint8 g, Uint8 b,
-                   Uint8 a, const SDL_Rect * rect)
+               Uint8 a, const SDL_Rect * rect)
 {
     NDS_RenderData *data = (NDS_RenderData *) renderer->driverdata;
     SDL_Rect real_rect = *rect;
     u16 color;
     int i, j;
 
-    TRACE("+NDS_RenderFill\n");
-    color = RGB8(r,g,b); /* <-- macro in libnds that makes an ARGB1555 pixel */
+    color = RGB8(r, g, b);      /* <-- macro in libnds that makes an ARGB1555 pixel */
     /* TODO: make a single-color sprite and stretch it.
        calculate the "HDX" width modifier of the sprite by:
-         let S be the actual sprite's width (like, 32 pixels for example)
-         let R be the rectangle's width (maybe 50 pixels)
-         HDX = (R<<8) / S;
-         (it's fixed point, hence the bit shift.  same goes for vertical.
-         be sure to use 32-bit int's for the bit shift before the division!)
+       let S be the actual sprite's width (like, 32 pixels for example)
+       let R be the rectangle's width (maybe 50 pixels)
+       HDX = (R<<8) / S;
+       (it's fixed point, hence the bit shift.  same goes for vertical.
+       be sure to use 32-bit int's for the bit shift before the division!)
      */
 
-    TRACE("-NDS_RenderFill\n");
     return 0;
 }
 
 static int
 NDS_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
-                   const SDL_Rect * srcrect, const SDL_Rect * dstrect)
+               const SDL_Rect * srcrect, const SDL_Rect * dstrect)
 {
     NDS_RenderData *data = (NDS_RenderData *) renderer->driverdata;
     NDS_TextureData *txdat = (NDS_TextureData *) texture->driverdata;
@@ -552,8 +540,7 @@
     int bpp = SDL_BYTESPERPIXEL(texture->format);
     int pitch = txdat->dim.pitch;
 
-    TRACE("+NDS_RenderCopy\n");
-    if(txdat->type == NDSTX_BG) {
+    if (txdat->type == NDSTX_BG) {
         bg_rotation *bgrot = (txdat->hw_index == 2) ?
             &(data->bg->bg2_rotation) : &(data->bg->bg3_rotation);
         bgrot->xdx = txdat->dim.hdx;
@@ -570,16 +557,15 @@
         SpriteEntry *spr = &(data->oam_copy.spriteBuffer[txdat->hw_index]);
         spr->posX = dstrect->x;
         spr->posY = dstrect->y;
-        if(txdat->hw_index < MATRIX_COUNT && spr->isRotoscale) {
-            SpriteRotation *sprot = &(data->oam_copy.matrixBuffer[txdat->hw_index]);
+        if (txdat->hw_index < MATRIX_COUNT && spr->isRotoscale) {
+            SpriteRotation *sprot =
+                &(data->oam_copy.matrixBuffer[txdat->hw_index]);
             sprot->hdx = txdat->dim.hdx;
             sprot->hdy = txdat->dim.hdy;
             sprot->vdx = txdat->dim.vdx;
             sprot->vdy = txdat->dim.vdy;
         }
-        printf("tried to RenderCopy a sprite.\n");
     }
-    TRACE("-NDS_RenderCopy\n");
 
     return 0;
 }
@@ -592,25 +578,20 @@
     SDL_Window *window = SDL_GetWindowFromID(renderer->window);
     SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window);
 
-    TRACE("+NDS_RenderPresent\n");
     /* update sprites */
     NDS_OAM_Update(&(data->oam_copy), data->sub);
     /* vsync for NDS */
     if (renderer->info.flags & SDL_RENDERER_PRESENTVSYNC) {
         swiWaitForVBlank();
     }
-    TRACE("-NDS_RenderPresent\n");
 }
 
 static void
 NDS_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture)
 {
     NDS_TextureData *txdat = texture->driverdata;
-    TRACE("+NDS_DestroyTexture\n");
     /* free anything else allocated for texture */
-    /*SDL_FreeDirtyRects(&txdat->dirty);*/
     SDL_free(txdat);
-    TRACE("-NDS_DestroyTexture\n");
 }
 
 static void
@@ -621,49 +602,36 @@
     SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window);
     int i;
 
-    TRACE("+NDS_DestroyRenderer\n");
     if (data) {
-        /* TODO: free anything else relevant. */
-        /*if (data->surface.format) {
-            SDL_SetSurfacePalette(&data->surface, NULL);
-            SDL_FreeFormat(data->surface.format);
-        }
-        if (display->palette) {
-            SDL_DelPaletteWatch(display->palette, DisplayPaletteChanged,
-                                data);
-        }*/
-        /*SDL_FreeDirtyRects(&data->dirty);*/
+        /* free anything else relevant if anything else is allocated. */
         SDL_free(data);
     }
     SDL_free(renderer);
-    TRACE("-NDS_DestroyRenderer\n");
 }
 
 static int
 NDS_SetTexturePalette(SDL_Renderer * renderer, SDL_Texture * texture,
-                     const SDL_Color * colors, int firstcolor, int ncolors)
+                      const SDL_Color * colors, int firstcolor, int ncolors)
 {
     NDS_TextureData *txdat = (NDS_TextureData *) texture->driverdata;
-    TRACE("+NDS_SetTexturePalette\n");
     /* set 8-bit modes in the background control registers
        for backgrounds, BGn_CR |= BG_256_COLOR */
-    TRACE("-NDS_SetTexturePalette\n");
+
     return 0;
 }
 
 static int
 NDS_GetTexturePalette(SDL_Renderer * renderer, SDL_Texture * texture,
-                     SDL_Color * colors, int firstcolor, int ncolors)
+                      SDL_Color * colors, int firstcolor, int ncolors)
 {
     NDS_TextureData *txdat = (NDS_TextureData *) texture->driverdata;
-    TRACE("!NDS_GetTexturePalette\n");
+    /* stub! */
     return 0;
 }
 
 static int
 NDS_SetTextureColorMod(SDL_Renderer * renderer, SDL_Texture * texture)
 {
-    TRACE("!NDS_SetTextureColorMod\n");
     /* stub! */
     return 0;
 }
@@ -671,7 +639,6 @@
 static int
 NDS_SetTextureAlphaMod(SDL_Renderer * renderer, SDL_Texture * texture)
 {
-    TRACE("!NDS_SetTextureAlphaMod\n");
     /* stub! */
     return 0;
 }
@@ -679,7 +646,6 @@
 static int
 NDS_SetTextureBlendMode(SDL_Renderer * renderer, SDL_Texture * texture)
 {
-    TRACE("!NDS_SetTextureBlendMode\n");
     /* stub! */
     return 0;
 }
@@ -687,7 +653,6 @@
 static int
 NDS_SetTextureScaleMode(SDL_Renderer * renderer, SDL_Texture * texture)
 {
-    TRACE("!NDS_SetTextureScaleMode\n");
     /* stub! (note: NDS hardware scaling is nearest neighbor.) */
     return 0;
 }