Ejemplo n.º 1
0
void mode__intro__credits___idle(void) {
  //
  // handle fadeout
  //
  if (mode != next_mode) {
    if (((mode_ms - exit_mode_ms) > INTRO__CREDITS__TOP_BG_FADE_OUT_DURATION_MS) &&
	((mode_ms - exit_mode_ms) > INTRO__CREDITS__BOT_BG_FADE_OUT_DURATION_MS) &&
	((mode_ms - exit_mode_ms) > INTRO__CREDITS__BOT_TXT_FADE_OUT_DURATION_MS)) {

      dmaFillHalfWords(0,
		       (u16*)bgGetGfxPtr(bg3),
		       256 * 256 * 2);
      //      memptr = (u16*)bgGetGfxPtr(bg3);
      //      for (i = 0 ; i < (256 * 256) ; i++) memptr[i] = (u16)0;
      
      dmaFillHalfWords(0,
		       (u16*)bgGetGfxPtr(bgs3),
		       256 * 256);

      dmaFillHalfWords(0,
		       (u16*)bgGetGfxPtr(bgs2),
		       256 * 256);

      dmaFillHalfWords(0,
		       (u16*)bgGetGfxPtr(bgs0),
		       256 * 256 / 2);

      system_xmode_real();
    }
  }
}
Ejemplo n.º 2
0
void iconTitleInit (void) {
	// initialize video mode
	videoSetMode(MODE_4_2D);

	// initialize VRAM banks
	vramSetPrimaryBanks(VRAM_A_MAIN_BG,
	                    VRAM_B_MAIN_SPRITE,
	                    VRAM_C_LCD,
	                    VRAM_D_LCD);

	// initialize bg2 as a rotation background and bg3 as a bmp background
	// http://mtheall.com/vram.html#T2=3&RNT2=96&MB2=3&TB2=0&S2=2&T3=6&MB3=1&S3=1
	bg2 = bgInit(2, BgType_Rotation, BgSize_R_512x512,   3, 0);
	bg3 = bgInit(3, BgType_Bmp16,    BgSize_B16_256x256, 1, 0);

	// initialize rotate, scale, and scroll
	bgSetRotateScale(bg3, 0, 1<<8, 1<<8);
	bgSetScroll(bg3, 0, 0);
	bgSetRotateScale(bg2, 0, 8*(1<<8)/6, 1<<8);
	bgSetScroll(bg2, -TITLE_POS_X, -TITLE_POS_Y);

	// clear bg2's map: 512x512 pixels is 64x64 tiles is 4KB
	dmaFillHalfWords(0, bgGetMapPtr(bg2), 4096);
	// load compressed font into bg2's tile data
	decompress(font6x8Tiles, bgGetGfxPtr(bg2), LZ77Vram);

	// load compressed bitmap into bg3
	decompress(hbmenu_bannerBitmap, bgGetGfxPtr(bg3), LZ77Vram);

	// load font palette
	dmaCopy(font6x8Pal, BG_PALETTE, font6x8PalLen);

	// apply the bg changes
	bgUpdate();

	// initialize OAM
	oamInit(&oamMain, SpriteMapping_1D_128, false);
	sprite = oamAllocateGfx(&oamMain, SpriteSize_32x32, SpriteColorFormat_16Color);
	dmaFillHalfWords(0, sprite, sizeof(banner.icon));
	oamSet(&oamMain, 0, ICON_POS_X, ICON_POS_Y, 0, 0,
	       SpriteSize_32x32, SpriteColorFormat_16Color, sprite,
	       -1, 0, 0, 0, 0, 0);

	// oam can only be updated during vblank
	swiWaitForVBlank();
	oamUpdate(&oamMain);

	// everything's ready :)
	writeRow (0,"...initializing...");
	writeRow (1,"===>>> HBMenu+ <<<===");
	writeRow (2,"(this text should disappear...");
	writeRow (3,"...otherwise, trouble!)");
}
Ejemplo n.º 3
0
SpriteScraperRect *HwSpriteScraper::allocRect(OamState *oam)
{
    /*
     * Look for a free sprite rect
     */
    for (int i=0; i < NUM_SPRITES; i++) {
        SpriteScraperRect *rect = &rects[i];
        if (rect->buffer == NULL) {

            rect->oam = oam;
            rect->buffer = oamAllocateGfx(oam, SpriteSize_64x64,
                                          SpriteColorFormat_16Color);

            /*
             * Do one full clear/render cycle before showing a frame.
             * Until that cycle is finished, we'll show a blank sprite.
             */
            rect->live = true;
            rect->livePrev = false;
            dmaFillHalfWords(0, rect->buffer, rect->width * rect->height / 2);

            return rect;
        }
    }
    sassert(false, "Out of SpriteScraperRects");
    return NULL;
}
Ejemplo n.º 4
0
Enemy::Enemy(int i, s16 x, s16 y, s32 vx, s32 vy) : Sprite(i, SpriteSize_8x8, SpriteColorFormat_Bmp, x, y) {
	/*u16 enemyData[8 * 8] = {
		0,1,0,1,1,0,1,0,
		1,1,1,1,1,1,1,1,
		0,1,0,1,1,0,1,0,
		1,1,1,1,1,1,1,1,
		1,1,1,0,0,1,1,1,
		0,1,0,1,1,0,1,0,
		1,1,1,1,1,1,1,1,
		0,1,0,1,1,0,1,0
	};
	
	u16 u;
	for(u = 0 ; u < 8 * 8 ; u++) {
		if(enemyData[u]) {
			s_gfx[u] = ARGB16(1,31,0,0);
		}
	}*/
	
	dmaFillHalfWords(ARGB16(1,31,0,0), s_gfx, 8*8*2); // Copy player data into sprite gfx
	
	// Initialize initial members ( for reset )
	s_ix = x;
	s_iy = y;
	s_ivx = vx;
	s_ivy = vy;
	
	// Initialize other members
	s_ax = x;
	s_ay = y;
	s_vx = vx;
	s_vy = vy;
	
	nbEnemies++;
}
Ejemplo n.º 5
0
void evaluate(tlmmProgram *prog) {
  int x;
  dmaFillHalfWords(0, bgGetGfxPtr(3), 256*192*2);

  for(x = 0; x < 256; x++) {
#define SCALE 16
    float v = 192/2 - tlmmGetValue(prog, (float)(x-128)/SCALE)*SCALE;
    if(v >= 0 && v < 192)
      bgGetGfxPtr(3)[(int)v * 256 + x] = ARGB16(1, 31, 31, 31);
  }
}
Ejemplo n.º 6
0
void clearConsole(void)
{
	dmaFillHalfWords(0, consoleMap, 32*32*2);
	row = col = 0;
}
Ejemplo n.º 7
0
// Program entrypoint
int main()
{	
	if (!mmIsARM7Loaded())
	{
		printf("Couldn't load Maxmod!\n");
		return 1;
	}

	// Init Maxmod with default settings (loading from FAR)
	mmInitDefaultFAR(hFar, "/soundbank.bin");
	
	FeOS_DirectMode();

	videoSetMode(MODE_0_2D);
	videoSetModeSub(0);
	vramSetBankA(VRAM_A_MAIN_SPRITE);

	// Initialize the sprite engine with 1D mapping 128 byte boundary
	// aand no external palette support
	oamInit(&oamMain, SpriteMapping_1D_32, false);

	int i;
	for (i = 0; i < 5; i ++)
	{
		// Allocate some space for the sprite graphics
		sprites[i].gfx = oamAllocateGfx(&oamMain, sprites[i].size, sprites[i].format);

		// Fill each sprite with a different index (2 pixels at a time)
		dmaFillHalfWords(((i+1) << 8) | (i+1), sprites[i].gfx, 32*32);
	}

	// Set indexes to different colours
	SPRITE_PALETTE[1] = RGB15(31,0,0);
	SPRITE_PALETTE[2] = RGB15(0,31,0);
	SPRITE_PALETTE[3] = RGB15(0,0,31);
	SPRITE_PALETTE[4] = RGB15(31,0,31);
	SPRITE_PALETTE[5] = RGB15(0,31,31);

	mmSetEventHandler(myEventHandler);
	mmLoad(MOD_EXAMPLE2);
	mmStart(MOD_EXAMPLE2, MM_PLAY_LOOP);

	for(;;)
	{
		swiWaitForVBlank();
		if (keysDown() & KEY_START)
			break;

		for (i = 0; i < 5; i ++)
		{
			// Constantly increase the sprite's y velocity
			sprites[i].dy += 1;
		
			// Update the sprite's y position with its y velocity
			sprites[i].y += sprites[i].dy;
		
			// Clamp the sprite's y position
			if (sprites[i].y<72) sprites[i].y = 72;
			if (sprites[i].y>96) sprites[i].y = 96;
		
			oamSet(&oamMain,                 // Main graphics engine context
			       i,                        // OAM index (0 to 127)  
			       sprites[i].x,             // X and Y pixel location of the sprite
			       sprites[i].y, 			
			       0,                        // Priority, lower renders last (on top)
			       sprites[i].paletteAlpha,  // Palette index 
			       sprites[i].size,
			       sprites[i].format,
			       sprites[i].gfx,           // Pointer to the loaded graphics
			       sprites[i].rotationIndex, // Sprite rotation data  
			       false,                    // Double the size when rotating?
			       false,                    // Hide the sprite?
			       false, false,             // VFlip, HFlip
			       false);                   // Apply mosaic
		}
	}

	mmStop();
	mmUnload(MOD_EXAMPLE2);
	mmUnloadSoundbank();

	FeOS_ConsoleMode();

	return 0;
}
Ejemplo n.º 8
0
static inline void clearIcon (void) {
	dmaFillHalfWords(0, sprite, sizeof(banner.icon));
}
Ejemplo n.º 9
0
void clearBmpLines(int start, int nlines)
{
	dmaFillHalfWords(Colors::Transparent, bmpBuf + start*256, nlines*256*2);
}
Ejemplo n.º 10
0
void clearBitmap()
{
	dmaFillHalfWords(Colors::Transparent, bmpBuf, 256*192*2);
}
Ejemplo n.º 11
0
//---------------------------------------------------------------------------------
int main(void) {
//---------------------------------------------------------------------------------

	int i = 0;
	
	videoSetMode(MODE_0_2D);
	videoSetModeSub(0);   // not using subscreen

	lcdMainOnBottom();
	
	//initialize the sprite engine with 1D mapping 128 byte boundary
	//and no external palette support
	oamInit(&oamMain, SpriteMapping_1D_32, false);

	vramSetBankA(VRAM_A_MAIN_SPRITE);
	
	for (i = 0; i < 5; i++) {
		//allocate some space for the sprite graphics
		sprites[i].gfx = oamAllocateGfx(&oamMain, sprites[i].size, sprites[i].format);

		//fill each sprite with a different index (2 pixels at a time)
		dmaFillHalfWords( ((i+1)<<8)|(i+1), sprites[i].gfx, 32*32);
	}

	//set indexes to different colours
	SPRITE_PALETTE[1] = RGB15(31,0,0);
	SPRITE_PALETTE[2] = RGB15(0,31,0);
	SPRITE_PALETTE[3] = RGB15(0,0,31);
	SPRITE_PALETTE[4] = RGB15(31,0,31);
	SPRITE_PALETTE[5] = RGB15(0,31,31);

	// initialise maxmod using default settings, and enable interface for soundbank that is loaded into memory
	mmInitDefaultMem( (mm_addr)mmsolution_bin );

	// setup maxmod to use the song event handler
	mmSetEventHandler( myEventHandler );
	
	// load song
	// values for this function are in the solution header
	mmLoad( MOD_EXAMPLE2 );

	// start song playing
	mmStart( MOD_EXAMPLE2, MM_PLAY_LOOP );

	while(1) {
		for (i=0; i < 5; i++) {
			// constantly increase the sprite's y velocity
			sprites[i].dy += 1;
		
			// update the sprite's y position with its y velocity
			sprites[i].y += sprites[i].dy;
		
			// clamp the sprite's y position
			if ( sprites[i].y<72 ) sprites[i].y = 72;
			if ( sprites[i].y>96 ) sprites[i].y = 96;
		
			oamSet(	&oamMain, 					//main graphics engine context
					i,           				//oam index (0 to 127)  
					sprites[i].x,				//x and y pixel location of the sprite
					sprites[i].y, 			
					0,							//priority, lower renders last (on top)
					sprites[i].paletteAlpha,	//palette index 
					sprites[i].size,
					sprites[i].format,
					sprites[i].gfx,				//pointer to the loaded graphics
					sprites[i].rotationIndex,	//sprite rotation data  
					false,						//double the size when rotating?
					false,			//hide the sprite?
					false, false, //vflip, hflip
					false	//apply mosaic
					);              
			}

		swiWaitForVBlank();
		
		//send the updates to the hardware
		oamUpdate(&oamMain);
	}

	return 0;
}
Ejemplo n.º 12
0
int main(int argc, char** argv) {
	
   //three sprites of differing color format
   MySprite sprites[] = {
      {0, SpriteSize_32x32, SpriteColorFormat_Bmp, 0, 15, 20, 15},
      {0, SpriteSize_32x32, SpriteColorFormat_256Color, -1, 0, 20, 80},
      {0, SpriteSize_32x32, SpriteColorFormat_16Color, -1, 1, 20, 136}
   };

   videoSetModeSub(MODE_0_2D);

   consoleDemoInit();
   
   //initialize the sub sprite engine with 1D mapping 128 byte boundary
   //and no external palette support
   oamInit(&oamSub, SpriteMapping_Bmp_1D_128, false);

  
   vramSetBankD(VRAM_D_SUB_SPRITE);
   
   //allocate some space for the sprite graphics
   for(int i = 0; i < 3; i++)
      sprites[i].gfx = oamAllocateGfx(&oamSub, sprites[i].size, sprites[i].format);
   
   //ugly positional printf
   iprintf("\x1b[1;1HDirect Bitmap:");
   iprintf("\x1b[9;1H256 color:");
   iprintf("\x1b[16;1H16 color:");
   
   //fill bmp sprite with the color red
   dmaFillHalfWords(ARGB16(1,31,0,0), sprites[0].gfx, 32*32*2);
   //fill the 256 color sprite with index 1 (2 pixels at a time)
   dmaFillHalfWords((1<<8)|1, sprites[1].gfx, 32*32);
   //fill the 16 color sprite with index 1 (4 pixels at a time)
   dmaFillHalfWords((1<<12)|(1<<8)|(1<<4)|1, sprites[2].gfx, 32*32 / 2);

   //set index 1 to blue...this will be the 256 color sprite
   SPRITE_PALETTE_SUB[1] = RGB15(0,31,0);
   //set index 17 to green...this will be the 16 color sprite
   SPRITE_PALETTE_SUB[16 + 1] = RGB15(0,0,31);

   int angle = 0;

   while(1) {
      for(int i = 0; i < 3; i++) {
         oamSet(
         &oamSub, //sub display 
         i,       //oam entry to set
         sprites[i].x, sprites[i].y, //position 
         0, //priority
		 sprites[i].paletteAlpha, //palette for 16 color sprite or alpha for bmp sprite
         sprites[i].size, 
		 sprites[i].format, 
		 sprites[i].gfx, 
		 sprites[i].rotationIndex, 
         true, //double the size of rotated sprites
         false, //don't hide the sprite
		 false, false, //vflip, hflip
		 false //apply mosaic
         );
      }

      oamRotateScale(&oamSub, 0, angle, (1 << 8), (1<<8));

	  angle += 64;

      swiWaitForVBlank();

      //send the updates to the hardware
      oamUpdate(&oamSub);
   }
   return 0;
}