src/video/nds/SDL_ndsvideo.c
branchgsoc2008_nds
changeset 2671 c3e7c0698cbb
parent 2670 6e4669f4db49
child 2672 74ac057679d5
     1.1 --- a/src/video/nds/SDL_ndsvideo.c	Tue Jun 10 06:57:57 2008 +0000
     1.2 +++ b/src/video/nds/SDL_ndsvideo.c	Thu Jun 12 02:38:49 2008 +0000
     1.3 @@ -63,7 +63,7 @@
     1.4  NDS_Available(void)
     1.5  {
     1.6      const char *envr = SDL_getenv("SDL_VIDEODRIVER");
     1.7 -	printf("NDS_Available()\n");
     1.8 +    printf("NDS_Available()\n");
     1.9      return (1);
    1.10  }
    1.11  
    1.12 @@ -77,7 +77,7 @@
    1.13  NDS_CreateDevice(int devindex)
    1.14  {
    1.15      SDL_VideoDevice *device;
    1.16 -	printf("NDS_CreateDevice(%d)\n", devindex);
    1.17 +    printf("NDS_CreateDevice(%d)\n", devindex);
    1.18  
    1.19      /* Initialize all variables that we clean on shutdown */
    1.20      device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice));
    1.21 @@ -95,7 +95,7 @@
    1.22      device->SetDisplayMode = NDS_SetDisplayMode;
    1.23      device->PumpEvents = NDS_PumpEvents;
    1.24  
    1.25 -    device->num_displays = 2; /* DS = dual screens */
    1.26 +    device->num_displays = 2;   /* DS = dual screens */
    1.27  
    1.28      device->free = NDS_DeleteDevice;
    1.29  
    1.30 @@ -114,7 +114,8 @@
    1.31      int i;
    1.32  
    1.33      /* simple 256x192x16x60 for now */
    1.34 -    mode.w = 256;  mode.h = 192;
    1.35 +    mode.w = 256;
    1.36 +    mode.h = 192;
    1.37      mode.format = SDL_PIXELFORMAT_ARGB1555;
    1.38      mode.refresh_rate = 60;
    1.39      mode.driverdata = NULL;
    1.40 @@ -125,43 +126,49 @@
    1.41      SDL_zero(mode);
    1.42      SDL_AddDisplayMode(0, &mode);
    1.43  
    1.44 -	/* hackish stuff to get things up and running for now, and for a console */
    1.45 -	powerON(POWER_ALL);
    1.46 -	videoSetMode(MODE_FB0);
    1.47 -	videoSetModeSub(MODE_0_2D | DISPLAY_BG0_ACTIVE); /* debug text on sub */
    1.48 -	vramSetBankA(VRAM_A_LCD);
    1.49 -	vramSetBankC(VRAM_C_SUB_BG);
    1.50 -	irqInit();
    1.51 -	irqEnable(IRQ_VBLANK);
    1.52 +    /* hackish stuff to get things up and running for now, and for a console */
    1.53 +    powerON(POWER_ALL);
    1.54 +    videoSetMode(MODE_FB0);
    1.55 +    videoSetModeSub(MODE_0_2D | DISPLAY_BG0_ACTIVE);    /* debug text on sub */
    1.56 +    
    1.57     vramSetBankA(VRAM_A_LCD);
    1.58 +    vramSetBankC(VRAM_C_SUB_BG);
    1.59 +    
    1.60     irqInit();
    1.61 +    irqEnable(IRQ_VBLANK);
    1.62      /* set up console for debug text 'n stuff */
    1.63 -    SUB_BG0_CR = BG_MAP_BASE(31); BG_PALETTE_SUB[255] = RGB15(31,31,31);
    1.64 -	consoleInitDefault((u16*)SCREEN_BASE_BLOCK_SUB(31),
    1.65 -	                   (u16*)CHAR_BASE_BLOCK_SUB(0), 16);
    1.66 -    for(i = 0; i < 256*192; ++i) {
    1.67 -		((u16*)VRAM_A)[i] = i;
    1.68 -	}
    1.69 -	for(i = 0; i < 60; ++i) swiWaitForVBlank();
    1.70 -    /*NDS_SetDisplayMode(_this, &mode);*/
    1.71 +    SUB_BG0_CR = BG_MAP_BASE(31);
    1.72 +    BG_PALETTE_SUB[255] = RGB15(31, 31, 31);
    1.73 +    consoleInitDefault((u16 *) SCREEN_BASE_BLOCK_SUB(31),
    1.74 +                       (u16 *) CHAR_BASE_BLOCK_SUB(0), 16);
    1.75 +    for (i = 0; i < 256 * 192; ++i) {
    1.76 +        ((u16 *) VRAM_A)[i] = i;
    1.77 +    }
    1.78 +    for (i = 0; i < 60; ++i)
    1.79 +        swiWaitForVBlank();
    1.80 +    
    1.81 +    /*NDS_SetDisplayMode(_this, &mode); */
    1.82      return 0;
    1.83  }
    1.84  
    1.85  static int
    1.86  NDS_SetDisplayMode(_THIS, SDL_DisplayMode * mode)
    1.87  {
    1.88 -	/* right now this function is just hard-coded for 256x192 ARGB1555 */
    1.89 +    /* right now this function is just hard-coded for 256x192 ARGB1555 */
    1.90  #if 0
    1.91 -	videoSetMode(MODE_5_2D | DISPLAY_BG3_ACTIVE); /* display on main core */
    1.92 -    videoSetModeSub(MODE_0_2D | DISPLAY_BG0_ACTIVE); /* debug text on sub */
    1.93 +    videoSetMode(MODE_5_2D | DISPLAY_BG3_ACTIVE);       /* display on main core */
    1.94 +    videoSetModeSub(MODE_0_2D | DISPLAY_BG0_ACTIVE);    /* debug text on sub */
    1.95      vramSetMainBanks(VRAM_A_MAIN_BG_0x06000000, VRAM_B_LCD,
    1.96                       VRAM_C_SUB_BG, VRAM_D_LCD);
    1.97  
    1.98      /* maps well to the 256x192 screen anyway.  note: need VRAM_B for bigger */
    1.99      BG3_CR = BG_BMP16_256x256;
   1.100      /* affine transformation matrix.  nothing too fancy here */
   1.101 -	BG3_XDX = 0x100;    BG3_XDY = 0;
   1.102 -	BG3_YDX = 0;        BG3_YDY = 0x100;
   1.103 -	/* x/y position */
   1.104 -	BG3_CX = 0;         BG3_CY = 0;
   1.105 +    BG3_XDX = 0x100;
   1.106 +    BG3_XDY = 0;
   1.107 +    BG3_YDX = 0;
   1.108 +    BG3_YDY = 0x100;
   1.109 +    /* x/y position */
   1.110 +    BG3_CX = 0;
   1.111 +    BG3_CY = 0;
   1.112  #endif
   1.113      return 0;
   1.114  }