More work and some bugfixes on the graphics driver. gsoc2008_nds
authorDarren Alton <dalton@stevens.edu>
Sat, 16 Aug 2008 07:44:35 +0000
branchgsoc2008_nds
changeset 2690ca01c20274c0
parent 2689 e065c9f6a393
child 2691 87cfb5fde5db
More work and some bugfixes on the graphics driver.
src/video/nds/SDL_ndsrender.c
src/video/nds/SDL_ndsvideo.c
     1.1 --- a/src/video/nds/SDL_ndsrender.c	Fri Aug 15 10:44:31 2008 +0000
     1.2 +++ b/src/video/nds/SDL_ndsrender.c	Sat Aug 16 07:44:35 2008 +0000
     1.3 @@ -34,7 +34,8 @@
     1.4  #include "../SDL_yuv_sw_c.h"
     1.5  #include "../SDL_renderer_sw.h"
     1.6  
     1.7 -
     1.8 +#define TRACE
     1.9 +//#define TRACE printf
    1.10  
    1.11  /* NDS sprite-related functions */
    1.12  #define SPRITE_DMA_CHANNEL 3
    1.13 @@ -145,8 +146,8 @@
    1.14      {   "nds", /* char* name */
    1.15          (SDL_RENDERER_SINGLEBUFFER|SDL_RENDERER_ACCELERATED), /* u32 flags */
    1.16          (SDL_TEXTUREMODULATE_NONE), /* u32 mod_modes */
    1.17 -        (SDL_TEXTUREBLENDMODE_NONE), /* u32 blend_modes */
    1.18 -        (SDL_TEXTURESCALEMODE_NONE), /* u32 scale_modes */
    1.19 +        (SDL_TEXTUREBLENDMODE_MASK), /* u32 blend_modes */
    1.20 +        (SDL_TEXTURESCALEMODE_FAST), /* u32 scale_modes */
    1.21          3, /* u32 num_texture_formats */
    1.22          {
    1.23              SDL_PIXELFORMAT_INDEX8,
    1.24 @@ -168,16 +169,42 @@
    1.25  
    1.26  typedef struct
    1.27  {
    1.28 -    enum { NDSTX_BG, NDSTX_SPR } type;
    1.29 -    int hw_index;
    1.30 -    struct { int hdx, hdy, vdx, vdy, pitch, bpp; } dim;
    1.31 -    u16 *vram;
    1.32 -    u16 *system_ram_copy;
    1.33 -    int size;
    1.34 +    enum { NDSTX_BG, NDSTX_SPR } type; /* represented in a bg or sprite. */
    1.35 +    int hw_index; /* sprite: index in the OAM.  bg: 2 or 3. */
    1.36 +    struct
    1.37 +    {
    1.38 +        int hdx, hdy, vdx, vdy; /* affine transformation, used for scaling. */
    1.39 +        int pitch, bpp; /* some useful info */
    1.40 +    } dim;
    1.41 +    u16 *vram_pixels; /* where the pixel data is stored (a pointer into VRAM) */
    1.42 +    u16 *vram_palette; /* where the palette data is stored if it's indexed.*/
    1.43 +    /*int size;*/
    1.44  } NDS_TextureData;
    1.45  
    1.46  
    1.47  
    1.48 +void sdlds_splash() {
    1.49 +    int i;
    1.50 +    printf("splash!\n");
    1.51 +	BG3_CR = BG_BMP16_256x256|BG_BMP_BASE(0);
    1.52 +    BG3_XDX = 1 << 8; BG3_XDY = 0 << 8;
    1.53 +    BG3_YDX = 0 << 8; BG3_YDY = 1 << 8;
    1.54 +    BG3_CX = 0 << 8;  BG3_CY = 0 << 8;
    1.55 +    for(i = 0; i < 256*192; ++i) {
    1.56 +        ((u16*)BG_BMP_RAM(0))[i] = i|0x8000;
    1.57 +    }
    1.58 +    printf("one... two...\n");
    1.59 +    for(i = 0; i < 120; ++i) {
    1.60 +        swiWaitForVBlank();
    1.61 +    }
    1.62 +    for(i = 0; i < 256*192; ++i) {
    1.63 +        ((u16*)BG_BMP_RAM(0))[i] = 0;
    1.64 +    }
    1.65 +    BG3_CR = 0;
    1.66 +    printf("done splash!\n");
    1.67 +}
    1.68 +
    1.69 +
    1.70  SDL_Renderer *
    1.71  NDS_CreateRenderer(SDL_Window * window, Uint32 flags)
    1.72  {
    1.73 @@ -189,7 +216,7 @@
    1.74      int bpp;
    1.75      Uint32 Rmask, Gmask, Bmask, Amask;
    1.76  
    1.77 -printf("+NDS_CreateRenderer\n");
    1.78 +    TRACE("+NDS_CreateRenderer\n");
    1.79      if (!SDL_PixelFormatEnumToMasks(displayMode->format, &bpp,
    1.80                                      &Rmask, &Gmask, &Bmask, &Amask)) {
    1.81          SDL_SetError("Unknown display format");
    1.82 @@ -249,20 +276,26 @@
    1.83          NDS_RenderDriver.info.num_texture_formats;
    1.84      SDL_memcpy(renderer->info.texture_formats,
    1.85                 NDS_RenderDriver.info.texture_formats,
    1.86 -               sizeof(renderer->info.texture_formats));;
    1.87 -    renderer->info.max_texture_width = NDS_RenderDriver.info.max_texture_width;
    1.88 +               sizeof(renderer->info.texture_formats));
    1.89 +    renderer->info.max_texture_width =
    1.90 +        NDS_RenderDriver.info.max_texture_width;
    1.91      renderer->info.max_texture_height =
    1.92          NDS_RenderDriver.info.max_texture_height;
    1.93  
    1.94 -    data->bg = &BACKGROUND; /* BACKGROUND_SUB for second screen. */
    1.95 -    data->bg_taken[2] = data->bg_taken[3] = 0;
    1.96 -    NDS_OAM_Init(&(data->oam_copy)); /* init sprites. */
    1.97 -
    1.98      data->sub = 0; /* TODO: this is hard-coded to the "main" screen.
    1.99                              figure out how to detect whether to set it to
   1.100                              "sub" screen.  window->id, perhaps? */
   1.101 +    if(!data->sub) {
   1.102 +        data->bg = &BACKGROUND;
   1.103 +    } else {
   1.104 +        data->bg = &BACKGROUND_SUB;
   1.105 +    }
   1.106 +    data->bg_taken[2] = data->bg_taken[3] = 0;
   1.107 +    NDS_OAM_Init(&(data->oam_copy)); /* init sprites. */
   1.108  
   1.109 -printf("-NDS_CreateRenderer\n");
   1.110 +    sdlds_splash();
   1.111 +
   1.112 +    TRACE("-NDS_CreateRenderer\n");
   1.113      return renderer;
   1.114  }
   1.115  
   1.116 @@ -270,7 +303,7 @@
   1.117  NDS_ActivateRenderer(SDL_Renderer * renderer)
   1.118  {
   1.119      NDS_RenderData *data = (NDS_RenderData *) renderer->driverdata;
   1.120 -    printf("!NDS_ActivateRenderer\n");
   1.121 +    TRACE("!NDS_ActivateRenderer\n");
   1.122      return 0;
   1.123  }
   1.124  
   1.125 @@ -278,7 +311,7 @@
   1.126  NDS_DisplayModeChanged(SDL_Renderer * renderer)
   1.127  {
   1.128      NDS_RenderData *data = (NDS_RenderData *) renderer->driverdata;
   1.129 -    printf("!NDS_DisplayModeChanged\n");
   1.130 +    TRACE("!NDS_DisplayModeChanged\n");
   1.131      return 0;
   1.132  }
   1.133  
   1.134 @@ -291,7 +324,7 @@
   1.135      int bpp;
   1.136      Uint32 Rmask, Gmask, Bmask, Amask;
   1.137  
   1.138 -    printf("+NDS_CreateTexture\n");
   1.139 +    TRACE("+NDS_CreateTexture\n");
   1.140      if (!SDL_PixelFormatEnumToMasks
   1.141          (texture->format, &bpp, &Rmask, &Gmask, &Bmask, &Amask)) {
   1.142          SDL_SetError("Unknown texture format");
   1.143 @@ -306,31 +339,43 @@
   1.144             (hdx,hdy,vdx,vdy) as the backgrounds, so it should
   1.145             be similar enough to handle with the same driverdata. */
   1.146          printf("Tried to make a sprite.\n");
   1.147 +        txdat->type = NDSTX_SPR;
   1.148      } else if(texture->w <= 256 && texture->h <= 256) {
   1.149 -        int whichbg = -1;
   1.150 +        int whichbg = -1, base = 0;
   1.151          if(!data->bg_taken[2]) {
   1.152              whichbg = 2;
   1.153          } else if(!data->bg_taken[3]) {
   1.154              whichbg = 3;
   1.155 +            base = 4;
   1.156          }
   1.157          if(whichbg >= 0) {
   1.158 +            texture->driverdata = SDL_calloc(1, sizeof(NDS_TextureData));
   1.159 +            txdat = (NDS_TextureData*)texture->driverdata;
   1.160 +            if(!txdat) {
   1.161 +                SDL_OutOfMemory();
   1.162 +                return -1;
   1.163 +            }
   1.164 +
   1.165              /* TODO: maybe this should be in RenderPresent or RenderCopy
   1.166                 instead, copying from a malloc'd system RAM pixel buffer. */
   1.167 +            /* this is hard-coded to being 256x256 for now. */
   1.168              data->bg->control[whichbg] = (bpp == 8) ?
   1.169                  BG_BMP8_256x256 : BG_BMP16_256x256;
   1.170 +
   1.171 +            data->bg->control[whichbg] |= BG_BMP_BASE(base);
   1.172 +
   1.173              data->bg->scroll[whichbg].x = 0;
   1.174              data->bg->scroll[whichbg].y = 0;
   1.175 -            texture->driverdata = SDL_calloc(1, sizeof(NDS_TextureData));
   1.176 -            txdat = (NDS_TextureData*)texture->driverdata;
   1.177 +
   1.178              txdat->type = NDSTX_BG;
   1.179              txdat->hw_index = whichbg;
   1.180              txdat->dim.hdx = 0x100; txdat->dim.hdy = 0;
   1.181              txdat->dim.vdx = 0;     txdat->dim.vdy = 0x100;
   1.182              txdat->dim.pitch = 256 * (bpp/8);
   1.183              txdat->dim.bpp = bpp;
   1.184 -            txdat->vram = (u16*)(data->sub ?
   1.185 -                BG_BMP_RAM_SUB(whichbg) : BG_BMP_RAM(whichbg));
   1.186 -            txdat->size = txdat->dim.pitch * texture->h;
   1.187 +            txdat->vram_pixels = (u16*)(data->sub ?
   1.188 +                BG_BMP_RAM_SUB(base) : BG_BMP_RAM(base));
   1.189 +            /*txdat->size = txdat->dim.pitch * texture->h;*/
   1.190          } else {
   1.191              SDL_SetError("Out of NDS backgrounds.");
   1.192              printf("ran out.\n");
   1.193 @@ -339,7 +384,7 @@
   1.194          SDL_SetError("Texture too big for NDS hardware.");
   1.195      }
   1.196  
   1.197 -    printf("-NDS_CreateTexture\n");
   1.198 +    TRACE("-NDS_CreateTexture\n");
   1.199      if (!texture->driverdata) {
   1.200          SDL_SetError("Couldn't create NDS render driver data.");
   1.201          return -1;
   1.202 @@ -353,10 +398,10 @@
   1.203                        void **pixels, int *pitch)
   1.204  {
   1.205      NDS_TextureData *txdat = (NDS_TextureData *) texture->driverdata;
   1.206 -    printf("+NDS_QueryTexturePixels\n");
   1.207 -    *pixels = txdat->vram;
   1.208 +    TRACE("+NDS_QueryTexturePixels\n");
   1.209 +    *pixels = txdat->vram_pixels;
   1.210      *pitch = txdat->dim.pitch;
   1.211 -    printf("-NDS_QueryTexturePixels\n");
   1.212 +    TRACE("-NDS_QueryTexturePixels\n");
   1.213      return 0;
   1.214  }
   1.215  
   1.216 @@ -367,11 +412,11 @@
   1.217      NDS_TextureData *txdat = (NDS_TextureData *) texture->driverdata;
   1.218      Uint8 *src, *dst;
   1.219      int row; size_t length;
   1.220 -    printf("+NDS_UpdateTexture\n");
   1.221 +    TRACE("+NDS_UpdateTexture\n");
   1.222  
   1.223      src = (Uint8 *) pixels;
   1.224      dst =
   1.225 -        (Uint8 *) txdat->system_ram_copy + rect->y * txdat->dim.pitch +
   1.226 +        (Uint8 *) txdat->vram_pixels + rect->y * txdat->dim.pitch +
   1.227          rect->x * (txdat->dim.bpp/8);
   1.228      length = rect->w * (txdat->dim.bpp/8);
   1.229      for (row = 0; row < rect->h; ++row) {
   1.230 @@ -380,7 +425,7 @@
   1.231          dst += txdat->dim.pitch;
   1.232      }
   1.233  
   1.234 -    printf("-NDS_UpdateTexture\n");
   1.235 +    TRACE("-NDS_UpdateTexture\n");
   1.236      return 0;
   1.237  }
   1.238  
   1.239 @@ -391,29 +436,29 @@
   1.240  {
   1.241      NDS_TextureData *txdat = (NDS_TextureData *) texture->driverdata;
   1.242      int i;
   1.243 -    printf("+NDS_LockTexture\n");
   1.244 +    TRACE("+NDS_LockTexture\n");
   1.245      if (markDirty) {
   1.246          printf("wanted to mark dirty\n");
   1.247          /* TODO: figure out how to handle this! */
   1.248          /*SDL_AddDirtyRect(&txdat->dirty, rect);*/
   1.249      }
   1.250  
   1.251 -    *pixels = (void *) ((u8 *)txdat->vram + rect->y
   1.252 +    *pixels = (void *) ((u8 *)txdat->vram_pixels + rect->y
   1.253                          * txdat->dim.pitch + rect->x * (txdat->dim.bpp/8));
   1.254      *pitch = txdat->dim.pitch;
   1.255      printf("  pixels = %08x\n", (u32)*pixels);
   1.256 -    printf("  vram = %08x\n", (u32)(txdat->vram));
   1.257 -    printf("-NDS_LockTexture\n");
   1.258 +    printf("  vram = %08x\n", (u32)(txdat->vram_pixels));
   1.259 +    TRACE("-NDS_LockTexture\n");
   1.260      return 0;
   1.261  }
   1.262  
   1.263  static void
   1.264  NDS_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture)
   1.265  {
   1.266 -    printf("+NDS_UnlockTexture\n");
   1.267 +    TRACE("+NDS_UnlockTexture\n");
   1.268      /* TODO: should I be doing something here, somehow, now that the pixels
   1.269               should have been "written" between LockTexture and this? */
   1.270 -    printf("-NDS_UnlockTexture\n");
   1.271 +    TRACE("-NDS_UnlockTexture\n");
   1.272  }
   1.273  
   1.274  static void
   1.275 @@ -421,7 +466,7 @@
   1.276                  int numrects, const SDL_Rect * rects)
   1.277  {
   1.278      /* stub */
   1.279 -    printf("!NDS_DirtyTexture\n");
   1.280 +    TRACE("!NDS_DirtyTexture\n");
   1.281  }
   1.282  
   1.283  static int
   1.284 @@ -433,7 +478,7 @@
   1.285      u16 color;
   1.286      int i, j;
   1.287  
   1.288 -    printf("+NDS_RenderFill\n");
   1.289 +    TRACE("+NDS_RenderFill\n");
   1.290      color = RGB8(r,g,b); /* <-- macro in libnds that makes an ARGB1555 pixel */
   1.291      /* TODO: make a single-color sprite and stretch it.
   1.292         calculate the "HDX" width modifier of the sprite by:
   1.293 @@ -444,7 +489,7 @@
   1.294           be sure to use 32-bit int's for the bit shift before the division!)
   1.295       */
   1.296  
   1.297 -    printf("-NDS_RenderFill\n");
   1.298 +    TRACE("-NDS_RenderFill\n");
   1.299      return 0;
   1.300  }
   1.301  
   1.302 @@ -459,7 +504,8 @@
   1.303      int i;
   1.304      int bpp = SDL_BYTESPERPIXEL(texture->format);
   1.305      int pitch = txdat->dim.pitch;
   1.306 -    printf("+NDS_RenderCopy\n");
   1.307 +
   1.308 +    TRACE("+NDS_RenderCopy\n");
   1.309      if(txdat->type == NDSTX_BG) {
   1.310          bg_rotation *tmpbg = (txdat->hw_index == 2) ?
   1.311              &(data->bg->bg2_rotation) : &(data->bg->bg3_rotation);
   1.312 @@ -473,7 +519,8 @@
   1.313          /* sprites not implemented yet */
   1.314      }
   1.315      printf("  txdat->hw_index = %d\n", txdat->hw_index);
   1.316 -    printf("-NDS_RenderCopy\n");
   1.317 +    TRACE("-NDS_RenderCopy\n");
   1.318 +
   1.319      return 0;
   1.320  }
   1.321  
   1.322 @@ -485,7 +532,7 @@
   1.323      SDL_Window *window = SDL_GetWindowFromID(renderer->window);
   1.324      SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window);
   1.325      int i;
   1.326 -    printf("+NDS_RenderPresent\n");
   1.327 +    TRACE("+NDS_RenderPresent\n");
   1.328  
   1.329      {
   1.330          SDL_Texture * tx = display->textures[i];
   1.331 @@ -501,23 +548,22 @@
   1.332      if (renderer->info.flags & SDL_RENDERER_PRESENTVSYNC) {
   1.333          swiWaitForVBlank();
   1.334      }
   1.335 -    printf("-NDS_RenderPresent\n");
   1.336 +    TRACE("-NDS_RenderPresent\n");
   1.337  }
   1.338  
   1.339  static void
   1.340  NDS_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture)
   1.341  {
   1.342 -    printf("+NDS_DestroyTexture\n");
   1.343 +    TRACE("+NDS_DestroyTexture\n");
   1.344      if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) {
   1.345          SDL_SetError("Unsupported texture format");
   1.346      } else {
   1.347          /* free anything else allocated for texture */
   1.348          NDS_TextureData *txdat = texture->driverdata;
   1.349          /*SDL_FreeDirtyRects(&txdat->dirty);*/
   1.350 -        SDL_free(txdat->system_ram_copy);
   1.351          SDL_free(txdat);
   1.352      }
   1.353 -    printf("-NDS_DestroyTexture\n");
   1.354 +    TRACE("-NDS_DestroyTexture\n");
   1.355  }
   1.356  
   1.357  static void
   1.358 @@ -528,7 +574,7 @@
   1.359      SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window);*/
   1.360      int i;
   1.361  
   1.362 -    printf("+NDS_DestroyRenderer\n");
   1.363 +    TRACE("+NDS_DestroyRenderer\n");
   1.364      if (data) {
   1.365          /* TODO: free anything else relevant. */
   1.366          /*for (i = 0; i < SDL_arraysize(data->texture); ++i) {
   1.367 @@ -548,7 +594,7 @@
   1.368          SDL_free(data);
   1.369      }
   1.370      SDL_free(renderer);
   1.371 -    printf("-NDS_DestroyRenderer\n");
   1.372 +    TRACE("-NDS_DestroyRenderer\n");
   1.373  }
   1.374  
   1.375  static int
   1.376 @@ -556,10 +602,10 @@
   1.377                       const SDL_Color * colors, int firstcolor, int ncolors)
   1.378  {
   1.379      NDS_TextureData *txdat = (NDS_TextureData *) texture->driverdata;
   1.380 -    printf("+NDS_SetTexturePalette\n");
   1.381 +    TRACE("+NDS_SetTexturePalette\n");
   1.382      /* set 8-bit modes in the background control registers
   1.383         for backgrounds, BGn_CR |= BG_256_COLOR */
   1.384 -    printf("-NDS_SetTexturePalette\n");
   1.385 +    TRACE("-NDS_SetTexturePalette\n");
   1.386      return 0;
   1.387  }
   1.388  
   1.389 @@ -567,16 +613,16 @@
   1.390  NDS_GetTexturePalette(SDL_Renderer * renderer, SDL_Texture * texture,
   1.391                       SDL_Color * colors, int firstcolor, int ncolors)
   1.392  {
   1.393 -    printf("+NDS_GetTexturePalette\n");
   1.394 +    TRACE("+NDS_GetTexturePalette\n");
   1.395      NDS_TextureData *txdat = (NDS_TextureData *) texture->driverdata;
   1.396 -    printf("-NDS_GetTexturePalette\n");
   1.397 +    TRACE("-NDS_GetTexturePalette\n");
   1.398      return 0;
   1.399  }
   1.400  
   1.401  static int
   1.402  NDS_SetTextureColorMod(SDL_Renderer * renderer, SDL_Texture * texture)
   1.403  {
   1.404 -    printf("!NDS_SetTextureColorMod\n");
   1.405 +    TRACE("!NDS_SetTextureColorMod\n");
   1.406      /* stub! */
   1.407      return 0;
   1.408  }
   1.409 @@ -584,7 +630,7 @@
   1.410  static int
   1.411  NDS_SetTextureAlphaMod(SDL_Renderer * renderer, SDL_Texture * texture)
   1.412  {
   1.413 -printf("!NDS_SetTextureAlphaMod\n");
   1.414 +    TRACE("!NDS_SetTextureAlphaMod\n");
   1.415      /* stub! */
   1.416      return 0;
   1.417  }
   1.418 @@ -592,7 +638,7 @@
   1.419  static int
   1.420  NDS_SetTextureBlendMode(SDL_Renderer * renderer, SDL_Texture * texture)
   1.421  {
   1.422 -printf("!NDS_SetTextureBlendMode\n");
   1.423 +    TRACE("!NDS_SetTextureBlendMode\n");
   1.424      /* stub! */
   1.425      return 0;
   1.426  }
   1.427 @@ -600,7 +646,7 @@
   1.428  static int
   1.429  NDS_SetTextureScaleMode(SDL_Renderer * renderer, SDL_Texture * texture)
   1.430  {
   1.431 -printf("!NDS_SetTextureScaleMode\n");
   1.432 +    TRACE("!NDS_SetTextureScaleMode\n");
   1.433      /* stub! (note: NDS hardware scaling is nearest neighbor.) */
   1.434      return 0;
   1.435  }
     2.1 --- a/src/video/nds/SDL_ndsvideo.c	Fri Aug 15 10:44:31 2008 +0000
     2.2 +++ b/src/video/nds/SDL_ndsvideo.c	Sat Aug 16 07:44:35 2008 +0000
     2.3 @@ -43,6 +43,13 @@
     2.4  #include "SDL_ndsevents_c.h"
     2.5  #include "SDL_ndsrender_c.h"
     2.6  
     2.7 +
     2.8 +
     2.9 +#define TRACE
    2.10 +//#define TRACE printf
    2.11 +
    2.12 +
    2.13 +
    2.14  #define NDSVID_DRIVER_NAME "nds"
    2.15  
    2.16  /* Initialization/Query functions */
    2.17 @@ -72,7 +79,7 @@
    2.18      SDL_VideoDevice *device;
    2.19      /*printf("NDS_CreateDevice(%d)\n", devindex); */
    2.20  
    2.21 -printf("+NDS_CreateDevice\n");
    2.22 +    TRACE("+NDS_CreateDevice\n");
    2.23      /* Initialize all variables that we clean on shutdown */
    2.24      device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice));
    2.25      if (!device) {
    2.26 @@ -93,7 +100,7 @@
    2.27  
    2.28      device->free = NDS_DeleteDevice;
    2.29  
    2.30 -printf("-NDS_CreateDevice\n");
    2.31 +    TRACE("-NDS_CreateDevice\n");
    2.32      return device;
    2.33  }
    2.34  
    2.35 @@ -108,7 +115,7 @@
    2.36      SDL_DisplayMode mode;
    2.37      int i;
    2.38  
    2.39 -    printf("+NDS_VideoInit\n");
    2.40 +    TRACE("+NDS_VideoInit\n");
    2.41      /* simple 256x192x16x60 for now */
    2.42      mode.w = 256;
    2.43      mode.h = 192;
    2.44 @@ -128,14 +135,15 @@
    2.45      powerON(POWER_ALL_2D);
    2.46     irqInit();
    2.47      irqEnable(IRQ_VBLANK);
    2.48      NDS_SetDisplayMode(_this, &mode);
    2.49 -    printf("-NDS_VideoInit\n");
    2.50 +
    2.51 +    TRACE("-NDS_VideoInit\n");
    2.52      return 0;
    2.53  }
    2.54  
    2.55  static int
    2.56  NDS_SetDisplayMode(_THIS, SDL_DisplayMode * mode)
    2.57  {
    2.58 -    printf("+NDS_SetDisplayMode\n");
    2.59 +    TRACE("+NDS_SetDisplayMode\n");
    2.60      /* right now this function is just hard-coded for 256x192 ABGR1555 */
    2.61      videoSetMode(MODE_5_2D |
    2.62                   DISPLAY_BG2_ACTIVE |
    2.63 @@ -163,14 +171,14 @@
    2.64                                                          when multi-head is
    2.65                                                          introduced in render */
    2.66  
    2.67 -    printf("-NDS_SetDisplayMode\n");
    2.68 +    TRACE("-NDS_SetDisplayMode\n");
    2.69      return 0;
    2.70  }
    2.71  
    2.72  void
    2.73  NDS_VideoQuit(_THIS)
    2.74  {
    2.75 -    printf("+NDS_VideoQuit\n");
    2.76 +    TRACE("+NDS_VideoQuit\n");
    2.77      videoSetMode(DISPLAY_SCREEN_OFF);
    2.78      videoSetModeSub(DISPLAY_SCREEN_OFF);
    2.79      vramSetMainBanks(VRAM_A_LCD, VRAM_B_LCD, VRAM_C_LCD, VRAM_D_LCD);
    2.80 @@ -179,7 +187,7 @@
    2.81      vramSetBankG(VRAM_G_LCD);
    2.82      vramSetBankH(VRAM_H_LCD);
    2.83      vramSetBankI(VRAM_I_LCD);
    2.84 -    printf("-NDS_VideoQuit\n");
    2.85 +    TRACE("-NDS_VideoQuit\n");
    2.86  }
    2.87  
    2.88  /* vi: set ts=4 sw=4 expandtab: */