Exemple #1
0
int main(int argc, char** argv) {
	PA_Init();
	PA_InitVBL();
	
	defaultExceptionHandler();

	PA_SetScreenSpace(0);

	player = new ship();

	PA_DualLoadSpritePal(ENEMIES, (void*)ikaruga_Pal);
	for(int n = ENEMIES; n < BULLETS; n++) {
		PA_DualCreateSprite(n, (void*)ikaruga_Sprite, OBJ_SIZE_32X32, COLOR256, ENEMIES, -32, -32);
		PA_DualSetSpriteVflip(n, true);
	}
	PA_DualLoadSpritePal(BULLETS, (void*)bullets_Pal);
	for(int n = BULLETS; n < 128; n++) PA_DualCreateSprite(n, (void*)bullets_Sprite, OBJ_SIZE_8X8, COLOR256, BULLETS, -8, -8);

	for(int x = 32; x < 224; x+=32)
		for(int y = 0; y < 32; y+=32)
			enemies.push_back(new enemy(x, y));

	while(true) {
		player->update();
		std::vector<enemy*> temp;
		for(int n = 0; n < (int)enemies.size(); n++) if(enemies[n]->update()) temp.push_back(enemies[n]);
		enemies = temp;
				
		PA_WaitForVBL();
	}
	
	return 0;
}
Exemple #2
0
int main(void){

	PA_Init();
	PA_InitVBL();
	
	PA_InitText(1,0); // On the top screen

	PA_LoadSpritePal(0, 0, (void*)sprite0_Pal);
	
	// This'll be the movable sprite...
	PA_CreateSprite(0, 0,(void*)circle_Sprite, OBJ_SIZE_32X32,1, 0, 16, 16); 	
	s32 x = 16; s32 y = 16; // Sprite's center position
	
	// This will be the fixed circle
	PA_CreateSprite(0, 1,(void*)circle_Sprite, OBJ_SIZE_32X32,1, 0, 128-16, 96-16); 
	
	while(1)
	{
		if (PA_MoveSprite(0)){
			x = PA_MovedSprite.X;
			y = PA_MovedSprite.Y;
		}
		
		// Collision ?
		if (PA_Distance(x, y, 128, 96) < 32*32) PA_OutputText(1, 2, 10, "Collision !!");
		else PA_OutputText(1, 2, 10, "            ");

		PA_WaitForVBL();
	}
	return 0;
}
Exemple #3
0
//Fonction principale du code
int main(void){

	PA_Init(); //Initialision of PAlib
	PA_InitVBL();
	
	PA_InitText(0,0);
	
	PA_LoadSpritePal(0, // Screen
					0, // Palette number
					(void*)sprite0_Pal);	// Palette name
	
	//Create the sprite
	PA_CreateSprite(0, 0,(void*)vaisseau_Sprite, OBJ_SIZE_32X32,1, 0, 0, 0);
	
	
	while(1){ // Main loop
		
		// Update the position according to the keypad...
		x += Pad.Held.Right - Pad.Held.Left;
		y += Pad.Held.Down - Pad.Held.Up;
		
		// Set the sprite's position
		PA_SetSpriteXY(0, // screen
					   0, // sprite
					   x, // x position
					   y); // y...
		
		PA_WaitForVBL();
	}
	return 0;
}
Exemple #4
0
int main(void){

	PA_Init(); //PAlib inits
	PA_InitVBL();
	
	PA_InitText(1, 0);
	
	PA_OutputSimpleText(1, 2, 6, "BinFile example");
	
	PA_LoadSpritePal(0, // Screen
					0, // Palette number
					(void*)sprite0_Pal);	// Palette name
					
	PA_CreateSprite(0, // Screen
					0, // Sprite number
					(void*)vaisseau_Sprite, // Sprite name
					OBJ_SIZE_32X32, // Sprite size
					1, // 256 color mode
					0, // Sprite palette number
					50, 50); // X and Y position on the screen
				

	while (1) // Infinite loop
	{
		PA_WaitForVBL();
	}
	
return 0;
}
Exemple #5
0
int main(int argc, char ** argv) {  
  // General initializations
  PA_Init();
  PA_InitVBL();
  PA_InitRand();
#ifndef DEBUG
  // Sound init to play mp3 and/or sfx
  PA_InitASLibForMP3(AS_MODE_MP3 | AS_MODE_SURROUND | AS_MODE_16CH);
#endif
  // Initialize the Wifi handler
  l_wifi.initialize();
#ifndef DEBUG
  // Set the sound settings
  AS_SetDefaultSettings(AS_PCM_8BIT, 44100, AS_SURROUND);
#endif
  // Initialize the background transitions
  PA_InitBgTrans(0);
  PA_BgTransDiag(0, TRANSITION_TYPE, 0, 1, 0);
  // Load sprite palettes
  PA_LoadSpritePal(1, PALETTE_NB_CASTLE, (void*)castle_Pal);
  PA_LoadSpritePal(1, PALETTE_NB_ITEM, (void*)item_Pal);
  // Enable alpha blending at the bottom and top screens
  PA_EnableSpecialFx(0, SFX_ALPHA, 0, SFX_BG0 | SFX_BG1 | SFX_BG2 | SFX_BG3 | SFX_BD);
  PA_SetSFXAlpha(0,	7, 15);
  PA_EnableSpecialFx(1, SFX_ALPHA, 0, SFX_BG0 | SFX_BG1 | SFX_BG2 | SFX_BG3 | SFX_BD);
  PA_SetSFXAlpha(1,	7, 15);
  // Main menu object
  CMenu l_menu;
  while(1) {
    // Display the menu
    l_menu.displayMenu();
  }
  return 0;
}
Exemple #6
0
// Function: main()
int main(int argc, char ** argv)
{
	PA_Init();    // Initializes PA_Lib
	PA_InitVBL(); // Initializes a standard VBL

	PA_Init16cBg(0, 2);  //Initializes a 16 color bg
	PA_LoadPal16c(PAL_BG0, ropes_Pal); //And loads its palette
	PA_16cErase(0);	//Clear bg before start drawing

	u8 i=0;	// position of our rope, from bottom
	u8 j=0;  // step of our animation
	u8 frames=0; //frames rendered, usefull to do animation timing

	// Infinite loop to keep the program running
	while (1)
	{	
		i+=1; //Move the rope up 1 pixels
		if (i>192) i=0; //If the rope has hit the top of the screen, start again from bottom

		if (++frames==20) //If we have render 20 consecutive frames
		{
			j=j+64;			//Change animation to next frame
			// ropes_Sprite has three 8x16 pixels frames, so each frame is (8x16)/2 = 64 bytes (since each pixels is 4bits)
			// so our stride on the animation image is 64.
			if (j>128) j=0;//Check frame limit (only 3 frames on this animation)
			frames=0;		//Reset frame counter
		}

		PA_WaitForVBL(); //Typical wait for vertical blank...
		PA_16cErase(0);  //Erase background (if there is only one row like in this example, you should erase only the space ocupped by the row).
		PA_16c8Xi(0,125,192-i,(u32*)(ropes_Sprite+j),i); //Draw the row.
	}

	return 0;
} // End of main()
Exemple #7
0
// Function: main()
int main(int argc, char ** argv){
	PA_Init();    // Initializes PA_Lib
	PA_InitVBL(); // Initializes a standard VBL
		
	PA_InitText(1, 0); // Init text on the top screen, background 0...
	
	// Load Backgrounds and their palettes...
	PA_EasyBgLoad(0, 3, BG3);	
	PA_EasyBgLoad(1, 3, BG3);	
	
	s32 scrollx = 0; // No X scroll by default...
	s32 scrolly = 0; // No Y scroll by default...

	// Infinite loop to keep the program running
	while (1)
	{
		// We'll modify scrollx and scrolly according to the keys pressed
		scrollx += (Pad.Held.Left - Pad.Held.Right) * 4; // Move 4 pixels per press
		scrolly += (Pad.Held.Up - Pad.Held.Down) * 4; // Move 4 pixels per press

		// Scroll the background to scrollx, scrolly...
		PA_BGScrollXY(0, // Screen
					3, // Background number
					scrollx, // X scroll
					scrolly); // Y scroll
		
		// Display the X and Y scrolls :
		PA_OutputText(1, 0, 0, "x : %d   \ny : %d   ", scrollx, scrolly);
		
		PA_WaitForVBL();
	}
	
	return 0;
} // End of main()
Exemple #8
0
// Function: main()
int main(int argc, char ** argv)
{
	u8 i;
	
	PA_Init();    // Initializes PA_Lib
	PA_InitVBL(); // Initializes a standard VBL
	
	
	// Load 8bit palettes for sprites...
	PA_LoadSpritePal(0,0,(void*)ds_Pal);
	PA_LoadSpritePal(0,1,(void*)giz_Pal);
	PA_LoadSpritePal(0,2,(void*)gp_Pal);
	PA_LoadSpritePal(0,3,(void*)psp_Pal);
	
	// Create sprites
	PA_CreateSprite(0,0,(void*)ds_Sprite,OBJ_SIZE_64X64,1,0,PA_Rand()%192,PA_Rand()%128);
	PA_CreateSprite(0,1,(void*)giz_Sprite,OBJ_SIZE_64X64,1,1,PA_Rand()%192,PA_Rand()%128);
	PA_CreateSprite(0,2,(void*)gp_Sprite,OBJ_SIZE_64X64,1,2,PA_Rand()%192,PA_Rand()%128);
	PA_CreateSprite(0,3,(void*)psp_Sprite,OBJ_SIZE_64X64,1,3,PA_Rand()%192,PA_Rand()%128);
	
	//Set the main palette
	BG_PALETTE[0] = PA_RGB(27,27,27); 
	// Infinite loop to keep the program running
	while (1)
	{
		PA_WaitForVBL();

		for(i=0;i<4;i++) PA_MoveSprite(i);
		
	}
	
	return 0;
} // End of main()
Exemple #9
0
// Function: main()
int main(int argc, char ** argv)
{
	PA_Init();    // Initializes PA_Lib
	PA_InitVBL(); // Initializes a standard VBL
	
	PA_InitText(1, 0);
	
	//PA_LoadSplash();  // PA_Lib splash screen
	
	// Load a large scrolling background converted with PAGfx... InfiniteMap
	PA_DualEasyBgLoad(3, //background number (0-3)
						Town); // Name
	
	// Next we'll scroll, here are the variables...
	s32 scrollx = 0; 
	s32 scrolly = 0;
	

// Infinite loop to keep the program running
while (1)
{

	// We need to change the scroll according to the held keys...
	scrollx += (Pad.Held.Right - Pad.Held.Left)*4; // scroll 4 pixels at a time
	scrolly += (Pad.Held.Down - Pad.Held.Up)*4; // Same thing
	PA_DualEasyBgScrollXY(3, scrollx, scrolly);	

	PA_WaitForVBL();
}
	
	return 0;
} // End of main()
Exemple #10
0
// Function: main()
int main(int argc, char ** argv)
{
	PA_Init();    // Initializes PA_Lib
	PA_InitVBL(); // Initializes a standard VBL
	
	//PA_LoadSplash();  // PA_Lib splash screen
	
	// Load on both screens at once...
	PA_DualLoadPAGfxLargeBg(3, //background number (0-3)
						Large); // Name
	
	// Next we'll scroll, here are the variables...
	s32 scrollx = 0; 
	s32 scrolly = 0;
	
	// Infinite loop to keep the program running
while (1)
{

	// We need to change the scroll according to the held keys...
	scrollx += (Pad.Held.Right - Pad.Held.Left)*4; // scroll 4 pixels at a time
	scrolly += (Pad.Held.Down - Pad.Held.Up)*4; // Same thing
	
	PA_DualInfLargeScrollXY(3, // background number
							scrollx, // X scroll
							scrolly); // and Y scroll
	PA_WaitForVBL();
}
	
	return 0;
} // End of main()
Exemple #11
0
int main(void)
{

// Initialise the lib...
PA_Init();
PA_InitVBL(); 

PA_InitText(1, 0);

// Load the palettes for the sprites on both screens
PA_DualLoadSpritePal(0, (void*)sprite0_Pal);

// Create the sprite on both screens...
PA_DualCreateSprite(FRISBEE, (void*)frisbee_Sprite, OBJ_SIZE_32X32, 1, 0, 96, 300); // Bottom screen
PA_DualSetSpriteRotEnable(FRISBEE, 0); // Enable rotation/zoom, rotset 0

// Sprite initial position...
frisbee.x = 96+16; 
frisbee.y = 300+16; // on the bottom screen

// Speed of frisbee in both ways
frisbee.vx = 0;
frisbee.vy = 0;

	while(1)
	{
		// Move with the stylus, or move on...
		if (PA_MoveSprite(FRISBEE)){
			frisbee.x = PA_MovedSprite.X;
			frisbee.y = PA_MovedSprite.Y + 192 + SCREENHOLE;
			frisbee.vx = PA_MovedSprite.Vx;		frisbee.vy = PA_MovedSprite.Vy; 
		}
		else{
			// Now, the frisbee's fixed point position will be updated according to the speed...
			frisbee.x += frisbee.vx;
			frisbee.y += frisbee.vy;
		
			// If the sprite touches the left or right border, flip the horizontal speed
			if ((frisbee.x -16 <= 0) && (frisbee.vx < 0)) frisbee.vx = -frisbee.vx; 
			else if ((frisbee.x + 16 >= 256)&&(frisbee.vx > 0)) frisbee.vx = - frisbee.vx;
	
			// Same thing, for top and bottom limits...
			if ((frisbee.y -16 <= 0) && (frisbee.vy < 0)) frisbee.vy = -frisbee.vy;
			else if ((frisbee.y + 16 >= 192 + 192 + SCREENHOLE)&& (frisbee.vy > 0)) frisbee.vy = - frisbee.vy;		
			// The bottom limit is at the bottom of the bottom screen, so that would be 2 screen heights, plus the space in between...
			PA_DualSetSpriteXY(FRISBEE, frisbee.x-16, frisbee.y-16);
	
		}
		
		PA_OutputText(1, 2, 10, "SpeedX : %d    ", frisbee.vx);
		PA_OutputText(1, 2, 11, "SpeedY : %d    ", frisbee.vy);		
		frisbee.angle+=4; // Make the frisbee turn...
		PA_DualSetRotsetNoZoom(0, frisbee.angle);
		
	
	PA_WaitForVBL();  // Synch to the framerate...
	}

return 0;
}
Exemple #12
0
// Function: main()
int main(int argc, char ** argv)
{
	PA_Init();    // Initializes PA_Lib
	PA_InitVBL(); // Initializes a standard VBL
	

	
	// Let's not load any backgrounds :p
	PA_SetBgPalCol(0, 0, PA_RGB(31, 31, 31)); // Set the bottom screen color to white
	PA_SetBgPalCol(1, 0, PA_RGB(0, 0, 0));	// set the top screen color to black
	
	// This will initialise a 16 bit background on each screen. This must be loaded before any other background.
	// If you need to load this after a backgrounds, you'll have to use PA_ResetBgSys, PA_Init8bit, then reload
	// your backgrounds...
	PA_Init16bitBg(0, 3);
	PA_Init16bitBg(1, 3);
		
	// Infinite loop to keep the program running
	while (1)
	{
		// Simple draw function, draws on the screen...
		PA_16bitDraw(0, // Screen
					PA_RGB(31, 0, 0));  // Color : full red...
		// (The first shooting line on emu is a bug from the emu, I don't have it on DS)	
					
		PA_Put16bitPixel(1, Stylus.X, Stylus.Y, PA_RGB(0, 31, 0)); // Draws a pixel on the top screen, corresponding to the stylus's position
		PA_WaitForVBL();
	}
	
	return 0;
} // End of main()
Exemple #13
0
// Function: main()
int main(int argc, char ** argv)
{
	PA_Init();    // Initializes PA_Lib
	PA_InitVBL(); // Initializes a standard VBL
	

	
	PA_Init16cBg(0, 3); 	PA_Init16cBg(1, 3);  // 16 color background init with default colors for text
	


	
	// Infinite loop to keep the program running
	while (1)
	{
		sprintf(text,  // string to use
					"%02d/%02d/%02d", PA_RTC.Day, PA_RTC.Month, PA_RTC.Year);  // String to transform
		PA_16cText(0, 10, 20, 255, 40, text, 1, 3, 100);  // Display the text transformed :)

	// And the time...
		sprintf(text,  "%02d:%02d  %02d seconds", PA_RTC.Hour, PA_RTC.Minutes, PA_RTC.Seconds);
		PA_16cText(0, 10, 40, 255, 60, text, 1, 3, 100);	// Display the text transformed :)

		PA_WaitForVBL();
		PA_16cErase(0);
	}
	
	return 0;
} // End of main()
Exemple #14
0
// Main function
int main(void)	{

	PA_Init();
	PA_InitVBL();
	
	PA_InitText(1, 0);
	
	PA_LoadSpritePal(0, 0, (void*)sprite0_Pal);	// Load the sprite palette
	
	// Load a few sprites...
	u8 i = 0; 
	for (i = 0; i < 16; i++) PA_CreateSprite(0, i,(void*)mollusk_Sprite, OBJ_SIZE_32X32,1, 0, i << 3, i << 3);
	
	
	PA_InitSpriteExtPrio(1); // Enable extended priorities
	
	
	PA_OutputSimpleText(1, 0, 10, "Please move the sprites to see how their priorities change");
	
	while(1)
	{	
		// Now we'll test every sprite to see if we touch it...
		for (i = 0; i < 16; i++) {
			PA_MoveSprite(i);  // move the sprites. 
			s16 y = PA_GetSpriteY(0, i);  if (y > 192) y-=256; // if higher than 0...
			PA_SetSpriteExtPrio(0, i, 192-y); // Top priority when at the bottom !
		}

	
		PA_WaitForVBL();	
	}
	return 0;
}
Exemple #15
0
// Function: main()
int main(int argc, char ** argv)
{
	PA_Init();    // Initializes PA_Lib
	PA_InitVBL(); // Initializes a standard VBL


	PA_InitText(1, 0);	
	
	// Load Backgrounds with their palettes !
	PA_EasyBgLoad(0, // screen
					3, // background number (0-3)
					bg0); // Background name, used by PAGfx...
	
	PA_OutputSimpleText(1, 2, 10, "Touch the screen to display   the color on top screen");	

	// Infinite loop to keep the program running
	while (1)
	{
		PA_OutputText(1, 2, 5, "Palette Color : %d   ", PA_EasyBgGetPixel(0, 3, Stylus.X, Stylus.Y)); // Screen, Bg_number, X/Y position
		// Returns the palette number (0-255)
		
		PA_SetBgColor(1, PA_EasyBgGetPixelCol(0, 3, Stylus.X, Stylus.Y));  // Same thing, but returns Color value...
		PA_WaitForVBL();

	}
	
	return 0;
} // End of main()
Exemple #16
0
// Function: main()
int main(int argc, char ** argv)
{
	PA_Init();    // Initializes PA_Lib
	PA_InitVBL(); // Initializes a standard VBL
	
	// Initialise the text system on the top screen
	PA_InitText(0,0);
	PA_InitText(1, 0);
	
	PA_OutputText(0, 1, 1, "PA_InitWifi() ...");
    PA_InitWifi();
	PA_OutputText(0, 1, 2, "done!\nPA_ConnectWifiWFC() ...");
    if (!PA_ConnectWifiWFC())
	{
		PA_OutputText(0, 1, 4, "error!");
		return 1;
	}
    PA_OutputText(0, 1, 4, "done!\nWIFI is now ready!");

	while (1)
	{
		PA_WaitForVBL();
	}
	
	return 0;
} // End of main()
Exemple #17
0
// Function: main()
int main(int argc, char ** argv){

	PA_Init();    // PA Init...
	PA_InitVBL();	// VBL Init...
	
	// Init the sound system
	AS_Init(AS_MODE_SURROUND | AS_MODE_16CH);
	AS_SetDefaultSettings(AS_PCM_8BIT, 11025, AS_SURROUND);
	
	PA_SetBgColor(0, PA_RGB(31, 31, 31)); // White background color

	// First, convert the gif to a sprite format...
	u8 *spritegfx = PA_GifToTiles((void*)Mollusk, // Gif file
											spritepal); // our palette
	
	// Next, load the sprite...
	PA_CreateSprite(0, 0, spritegfx, OBJ_SIZE_64X64, 1, 0, 64, 64);  // Just like plain sprites !
	PA_LoadSpritePal(0, 0, spritepal);  // Just like plain palettes !

	// spritegfx can be used over and over again to load other sprites... 
	// If you do not need it anymore, use free(spritegfx); to free the memory it uses !

	s32 spritex = -64;  // Sprite position
	s32 pan = 0;   // Audio panning
	
	PA_SetSpriteHflip(0, 0, 1); // Turn sprite around...	again...	
	
  while(1)  {  
  		int channel0 = PA_PlaySimpleSound(Zoom); // Play sound...

		for (spritex = -64; spritex < 256; spritex +=2){
			pan = spritex/2; 
			if (pan < 0) pan = 0; if (pan > 127) pan = 127; // Limit range...
			
			PA_SetSpriteX(0, 0, spritex);
			PA_SetSoundChannelPan(channel0, pan);
			PA_WaitForVBL();
		}
		
		PA_SetSpriteHflip(0, 0, 0); // Turn sprite around...
		
		int channel1 = PA_PlaySimpleSound(Zoom);
 
 		for (spritex = 256; spritex > -65; spritex -=2){
			pan = spritex/2; 
			if (pan < 0) pan = 0; if (pan > 127) pan = 127; // Limit range...
			
			PA_SetSpriteX(0, 0, spritex);
			PA_SetSoundChannelPan(channel1, pan);
			PA_WaitForVBL();
		} 
		
		PA_SetSpriteHflip(0, 0, 1); // Turn sprite around...	again...	
  
	}
		
	return 0;
} // End of main()
Exemple #18
0
int main(int argc, char ** argv)
{
  PA_Init();
  PA_InitVBL();

  PA_Init3D(); // Regular init for the 3D sprite system
  PA_Reset3DSprites();

  PA_InitText(0, 1);

  PA_OutputSimpleText(0, 4, 1, "Create texture from FAT");

  fatInitDefault(); // Init for libfat. Automatically sets up DLDI and everything else you need for basic FAT access.

  PA_FatInitAllBuffers(); // Initialize all the memory buffers used by the FAT loading system

  PA_FatSetBasePath("/DemoFiles/data");  // Set a base path from the card root to load your asset files from
                              // Within this base asset folder:
                              //      all background binaries should be in /bg/
                              //      sprite and sprite palette binaries in /sprites/
                              //      and RAW format sound files in /sfx/


// Load a sprite image from FAT to VRAM. It works just like PA_3DCreateTex!
  u16 gfx = PA_FatEasy3DCreateTex("pokekun", // Name of a texture binary created with PAGfx (without "_Texture.bin")
                                  32, // Texture width
                                  64, // Texture height
                                  TEX_256COL); // 256 color texture (see TEX_16COL, TEX_4COL, etc.)


// Create a palette for the 3D sprites that will be created later. It works just like PA_Load3DSpritePal!
  PA_FatEasyLoad3DSpritePal(0, // Sprite palette number
                            "pokekun"); // Name of a palette binary in EFS created by PAGfx (without the "_Pal.bin")


  PA_OutputSimpleText(0, 1, 22, "Press A to create a 3D sprite!");

  u16 nsprites0 = 0; // Number of 3D sprites created

  while(1)
  {

    if (Pad.Newpress.A && nsprites0 < 1024) // You can have 1024 3D sprites!!!
    {
// Since the sprite is already in VRAM you can just use the normal PA_3DCreateSpriteFromTex function
      PA_3DCreateSpriteFromTex(nsprites0, // Next sprite to load...
                               gfx, // texture in VRAM to use, no image copying !
                               32, 64, 0, PA_RandMax(240), PA_RandMax(160)); // The rest is like normal 3D sprites

      ++nsprites0; // Next time, load the next sprite number
    }

    PA_WaitForVBL();
    PA_3DProcess();
  }

  return 0;
}
Exemple #19
0
// Function: main()
int main(int argc, char ** argv)
{
	PA_Init();    // Initializes PA_Lib
	PA_InitVBL(); // Initializes a standard VBL
	
	PA_InitText(1, 0);  // Initialise the text system
	
	PA_InitCustomKeyboard(2, keyboardcustom); // Load the keyboard on background 2...
	
	PA_KeyboardIn(20, 95); // This scrolls the keyboard from the bottom, until it's at the right position
	// PA_KeyboardOut() can be used to scroll the Keyboard out
	// PA_ScrollKeyboardXY(x, y) can be used to set the keyboards position
	
	
	PA_OutputSimpleText(1, 7, 10, "Text : "); 

	s32 nletter = 0; // Next letter to right. 0 since no letters are there yet
	char letter = 0; // New letter to write.
	
	// Infinite loop to keep the program running
	while (1)
	{
		// We'll check first for color changes, with A, B, and X
		if (Pad.Newpress.A) PA_SetKeyboardColor(0, 1); // Blue and Red
		if (Pad.Newpress.B) PA_SetKeyboardColor(1, 0); // Red and Blue
		if (Pad.Newpress.X) PA_SetKeyboardColor(2, 1); // Green and Red
		if (Pad.Newpress.Y) PA_SetKeyboardColor(0, 2); // Blue and Green
		
		letter = PA_CheckKeyboard();
		
		if (letter > 31) { // there is a new letter
			text[nletter] = letter;
			nletter++;
		}
		else if(letter == PA_TAB){// TAB Pressed...
			u8 i;
			for (i = 0; i < 4; i++){ // put 4 spaces...
				text[nletter] = ' ';
				nletter++;
			}
	
		}
		else if ((letter == PA_BACKSPACE)&&nletter) { // Backspace pressed
			nletter--;
			text[nletter] = ' '; // Erase the last letter
		}
		else if (letter == '\n'){ // Enter pressed
			text[nletter] = letter;
			nletter++;
		}
		
		PA_OutputSimpleText(1, 8, 11, text); // Write the text
		PA_WaitForVBL();
	}
	
	return 0;
} // End of main()
Exemple #20
0
int main(int argc, char ** argv)
{
  PA_Init();
  PA_InitVBL();

  PA_InitText(0, 0);

  PA_OutputSimpleText(0, 5, 1, "FAT loading of sounds");

// Init ASlib before you play sounds
  AS_Init(AS_MODE_SURROUND | AS_MODE_16CH);
  AS_SetDefaultSettings(AS_PCM_8BIT, 11025, AS_NO_DELAY);

  fatInitDefault(); // Init for libfat. Automatically sets up DLDI and everything else you need for basic FAt access.

  PA_FatInitAllBuffers(); // Initialize all the memory buffers used by the FAT loading system

  PA_FatSetBasePath("DemoFiles/data");  // Set a base path from the card root to load your asset files from
                              // Within this base asset folder:
                              //      all background binaries should be in /bg/
                              //      2D and 3D sprite and palette binaries in /sprites/
                              //      and RAW format sound files in /sfx/


// Load a couple RAW format sounds from card FAT into memory for playback later.
  PA_FatLoadSfx("SFX_1", // A reference name for the loaded sound
                "saberoff"); // The name of sound effect in EFS to load (minus the ".RAW" extension)
  PA_FatLoadSfx("SFX_2", "sfxb");


  while(1)
  {
    PA_OutputSimpleText(0, 0, 4, "Press A/B to play loaded sounds.");

    PA_OutputSimpleText(0, 0, 6, "Or press R to load other sounds.");

    if(Pad.Newpress.A) PA_FatPlaySfx("SFX_1"); // Play a sound file loaded with PA_FatLoadSfx using its reference name
    if(Pad.Newpress.B) PA_FatPlaySfx("SFX_2");

    if(Pad.Newpress.R)
    {
// You can unload a previously loaded sound file to free its slot in memory.
      PA_FatUnloadSfx("SFX_1"); // Unload a sound file using the reference name assigned with PA_FatLoadSfx
      PA_FatUnloadSfx("SFX_2");

// Now you can load some more.
      PA_FatLoadSfx("SFX_1", "laserpower");
      PA_FatLoadSfx("SFX_2", "boi-oing");
// Actually, since you have 32 sound slots, we didn't need to unload the previous ones, but this is a demo!

    }

    PA_WaitForVBL();
  }

  return 0;
}
Exemple #21
0
// Function: main()
int main(int argc, char ** argv)
{
    PA_Init();    // Initializes PA_Lib
    PA_InitVBL(); // Initializes a standard VBL

    PA_InitText(1, 0);

    PA_EasyBgLoad(0, 1, pasplash); // Load your backgrounds...

    PA_InitBgTrans(0); // Init BgTransition system, uses background 0 but little memory...
    // If you want it to hide your sprites, set your sprites' priorities to 1 or more...

    u8 transtype = 0;

    s8 i;
    u8 vflip;

    // Infinite loop to keep the program running
    while (1)
    {
        vflip = PA_Rand()&1; // random
        transtype = PA_Rand()%5; // random

        PA_OutputText(1, 8, 8, "Transition : %d ", transtype);
        PA_OutputText(1, 10, 9, "Vflip : %d ", vflip);

        // Transition out...
        for (i = 0; i <= TRANS_LENGTH; i++) { // Fade length...
            PA_BgTransUpDown(0, // screen
                             transtype, // fade type, from 0 to 4, test them out !
                             vflip, // vertical flip
                             i); // Time, 0 being the screen completely visible, 32 completely out
            PA_WaitForVBL(); // To slow down the fades, we wait a frame...
        }

        vflip = PA_Rand()&1; // random
        transtype = PA_Rand()%5; // random

        PA_OutputText(1, 8, 8, "Transition : %d ", transtype);
        PA_OutputText(1, 10, 9, "Vflip : %d ", vflip);

        // Transition back in...
        for (i = TRANS_LENGTH; i >= 0; i--) { // Fade length...
            PA_BgTransUpDown(0, // screen
                             transtype, // fade type, from 0 to 4, test them out !
                             vflip, // vertical flip
                             i); // Time, 0 being the screen completely visible, 32 completely out
            PA_WaitForVBL(); // To slow down the fades, we wait a frame...
        }


        PA_WaitForVBL();
    }

    return 0;
} // End of main()
Exemple #22
0
int main(void) {

    PA_Init();
    PA_InitVBL();

    PA_InitText(1,0); // On the top screen

    PA_DualLoadSpritePal(0, (void*)sprite0_Pal);

    // This'll be the movable sprite...
    PA_CreateSprite(0, 0,(void*)circle_Sprite, OBJ_SIZE_32X32,1, 0, 16, 16);
    s32 x = 16;
    s32 y = 16; // Sprite's center position

    // This will be the hit circle
    PA_DualCreateSprite(1,(void*)circle_Sprite, OBJ_SIZE_32X32,1, 0, 128-16, 96-16);
    puck.x = 128;
    puck.y = 96+192+SCREENHOLE; // central position on bottom screen
    puck.vx = 0;
    puck.vy = 0; // No speed


    while(1)
    {
        if (PA_MoveSprite(0)) {
            x = PA_MovedSprite.X;
            y = PA_MovedSprite.Y;
        }

        // Collision ?
        if (PA_Distance(x, y, puck.x, puck.y-192-SCREENHOLE) < 32*32) {
            // Collision, so we'l change the pucks speed to move it out of our 'raquette'
            u16 angle = PA_GetAngle(x, y, puck.x, puck.y-192-SCREENHOLE); // New direction angle
            u16 speed = (32*32-PA_Distance(x, y, puck.x, puck.y-192-SCREENHOLE))/32; // The closer they are, the harder the hit was...
            puck.vx = (PA_Cos(angle)*speed)>>8;
            puck.vy = -(PA_Sin(angle)*speed)>>8;
        }

        puck.x += puck.vx;
        puck.y += puck.vy;

        // If the sprite touches the left or right border, flip the horizontal speed
        if ((puck.x -16 <= 0) && (puck.vx < 0)) puck.vx = -puck.vx;
        else if ((puck.x + 16 >= 256)&&(puck.vx > 0)) puck.vx = - puck.vx;

        // Same thing, for top and bottom limits...
        if ((puck.y -16 <= 0) && (puck.vy < 0)) puck.vy = -puck.vy;
        else if ((puck.y + 16 >= 192 + 192 + SCREENHOLE)&& (puck.vy > 0)) puck.vy = - puck.vy;
        // The bottom limit is at the bottom of the bottom screen, so that would be 2 screen heights, plus the space in between...
        PA_DualSetSpriteXY(1, puck.x-16, puck.y-16);



        PA_WaitForVBL();
    }
Exemple #23
0
void init() {
    PA_Init();
    PA_InitVBL();

    PA_InitText(0, 0);
    PA_InitText(1, 0);

    PA_LoadSpritePal(0, // Screen
            0, // Palette number
			(void*)btn_palette);	// Palette name
}
Exemple #24
0
// Function: main()
int main(int argc, char ** argv)
{
    PA_Init();    // Initializes PA_Lib
    PA_InitVBL(); // Initializes a standard VBL
    PA_InitText(1,1);
    Drawable cursor(0,0,0);
    cursor.Load(0, 0, (void*)pal_cursor, (void*)gfx_cursor, OBJ_SIZE_16X16, 1);
    setupRotations();
    u8 c = 0;
    u8 x = 0;
    u8 y = 0;
    for (y = 0; y != 8; ++y) {
        for (x = 0; x != 8; ++x) {
            u16 i = y*8+x;
            if (grid[i] == 1) {
                Tower tower = Tower(SPRITE_TOWER_BASE+c, x*16, y*16);
                tower.Load(0, 1, (void*)pal_tower, (void*)gfx_tower, OBJ_SIZE_16X16, 1);
                tower_list.push_back(tower);
                PA_SetSpriteRotEnable(0, tower.sprite, c);
                ++c;
            }
        }
    }

    s16 angle = 0;

	// Infinite loop to keep the program running
	while (1)
	{
	    u8 i = 0;
        for (tlist_it it = tower_list.begin(); it != tower_list.end(); ++it) {
            angle = (*it).GetAngleTo(cursor);
            PA_SetRotsetNoZoom(0, i, angle);
            ++i;
        }
        PA_OutputText(1, 0, 0, "Angle: %03d", angle);
        PA_OutputText(1, 0, 1, "Angle2: %03d", angle);
        PA_OutputText(1, 0, 2, "Cursor: %03d,%03d", cursor.position.x, cursor.position.y);
        if (Stylus.Held) {
            cursor.position.x = Stylus.X;
            cursor.position.y = Stylus.Y;
        } else {
            cursor.position.x += (Pad.Held.Right - Pad.Held.Left);
            cursor.position.y += (Pad.Held.Down - Pad.Held.Up);
        }
        cursor.Draw();
        PA_WaitForVBL();
	}

	return 0;
} // End of main()
Exemple #25
0
/* 게임 오버 */
void scr_Gameover() {
	PA_Init();
	PA_InitVBL();
	UnLoad_Screen();

	PA_LoadBackground(DOWN_SCREEN, BG1, &game_over);	/* 종료스크린 출력*/

	while (1) {
		if (Stylus.Newpress) {
			newGame = TRUE; // 새로운 게임.
			return;
		}
		PA_WaitForVBL(); // while문 안에 꼭 있어야함. 중요!
	}
}
Exemple #26
0
// Function: main()
int main(int argc, char ** argv)
{
    PA_Init();    // Initializes PA_Lib
    PA_InitVBL(); // Initializes a standard VBL

    PA_InitText(1, 0);

    PA_EasyBgLoad(0, 1, pasplash); // Load your backgrounds...

    u8 fadetype0 = 0;

    s8 i;

    // Infinite loop to keep the program running
    while (1)
    {


        // First we fade out... to fade out, move the time from 0 to 32, 32 included !
        for (i = 0; i <= 32; i++) {
            PA_WindowFade(0, // screen
                          fadetype0, // fade type, from 0 to 7, test them out !
                          i); // Time, 0 being the screen completely visible, 32 completely out
            PA_WaitForVBL(); // To slow down the fades, we wait a frame...
        }


        fadetype0 = PA_Rand()&7; // Random fade type for screen 0... from 0 to 7
        PA_OutputText(1, 8, 9, "Window Fade : %d  ", fadetype0);


        // To fade in, same thing, but from 32 to 0 included...
        for (i = 32; i >= 0; i--) {
            PA_WindowFade(0, fadetype0, i);
            PA_WaitForVBL(); // To slow down the fades, we wait a frame...
        }

        fadetype0 = PA_Rand()&7; // Random fade type for screen 0...
        PA_OutputText(1, 8, 9, "Window Fade : %d  ", fadetype0);



        PA_WaitForVBL();
    }

    return 0;
} // End of main()
Exemple #27
0
// Function: main()
int main(int argc, char ** argv)
{
	PA_Init();    // Initializes PA_Lib
	PA_InitVBL(); // Initializes a standard VBL
	
	PA_Init3D(); // Uses Bg0, Init 3D...
	PA_Reset3DSprites(); // Init or Reset 3D Sprites
	
	
	// Initialise the text system on the top screen
	PA_InitText(1, 1);  // Initialise the text system on the top screen	
						
	PA_OutputSimpleText(1, 0, 8, "Move 3DSprite to change priority");	
	
	// First, create the gfx with the corresponding images and sizes. Images converted as 256colors textures in PAGfx
	gfx[0] = PA_3DCreateTex((void*)mollusk_Texture,  // Texture
									64, 64,						// Width, Height
									TEX_256COL );				// Texture Format

	
	// Load the Palettes !
	PA_Load3DSpritePal(0, // Slot
							(void*)mollusk_Pal); // Palette

	// Create a few sprites
	PA_3DCreateSpriteFromTex(0, gfx[0], 	64, 64, 	0, 	128, 96);

	u8 i;
	for(i = 0; i < 24; i++){
	   PA_3DCreateSpriteFromTex(i+1, gfx[0], 	64, 64, 	0, 	32, i*8);
	   PA_3DSetSpritePrio(i+1, 1024 + i*8); // Priority... (default is 1024)
	}   

	while(1) {
		if(Stylus.Held) {
		   PA_3DSetSpriteXY(0, Stylus.X, Stylus.Y);
		   PA_3DSetSpritePrio(0, 1024 + Stylus.Y); // Priority depending on Y position...
		}   

		PA_WaitForVBL();
		PA_3DProcess();  // Update sprites
	}


	
	return 0;
} // End of main()
Exemple #28
0
// Function: main()
int main(int argc, char ** argv)
{
	PA_Init();    // Initializes PA_Lib
	PA_InitVBL(); // Initializes a standard VBL
	
	PA_InitText(1, 0);
	PA_OutputText(1,3,2, "--- BG Alpha Example ---");
	PA_OutputText(1,3,4, "D-Pad Left :    Alpha1--");
	PA_OutputText(1,3,5, "D-Pad Right:    Alpha1++");
	PA_OutputText(1,3,6, "D-Pad Up   :    Alpha2--");
	PA_OutputText(1,3,7, "D-Pad Down :    Alpha2++");

	//turn on alpha....
	PA_EnableSpecialFx(0, SFX_ALPHA, SFX_BG0 | SFX_BG1 | SFX_BG2 | SFX_BG3 | SFX_OBJ | SFX_BD, SFX_BG0 | SFX_BG1 | SFX_BG2 | SFX_BG3 | SFX_OBJ | SFX_BD);

	// Load the Backgrounds
	PA_EasyBgLoad(0, 0, bg0);	
	PA_EasyBgLoad(0, 1, bg1);	
	
	int alpha1 = 15;
	int alpha2 = 15;
	PA_SetSFXAlpha(0, alpha1, alpha2);
	// Infinite loop to keep the program running
	while (1)
	{
      
		if (Pad.Newpress.Left && alpha1 > 0) alpha1--;
		else if (Pad.Newpress.Right && alpha1 < 31) alpha1++;

		if (Pad.Newpress.Down && alpha2 > 0) alpha2--;
		else if (Pad.Newpress.Up && alpha2 < 31) alpha2++;

		//update the alpha values
		PA_SetSFXAlpha(0, alpha1, alpha2);
		
		PA_OutputText(1,2,9, "Alpha 1: %d   ", alpha1);
		PA_OutputText(1,2,10, "Alpha 2: %d   ", alpha2);

		PA_WaitForVBL();
      
      
      
	}
	
	return 0;
} // End of main()
Exemple #29
0
// Main function
int main(void)	{
	// PAlib init
	PA_Init();
	PA_InitVBL();
	
	PA_Init3D();
	PA_Reset3DSprites();
	
	PA_InitText(1, 0);

	PA_Load3DSpritePal(0, (void*)som_Pal);	// Palette....	

	s32 x = 128; s32 y = 96;

	PA_3DCreateSprite(0,(void*)som_Texture, 32, 32, TEX_256COL, 0, x, y); // Sprite
	
	while(1)
	{
		// Animation code...
		if(Pad.Newpress.Up) PA_3DStartSpriteAnim(0, 0, 3, 6);
		if(Pad.Newpress.Down) PA_3DStartSpriteAnim(0, 8, 11, 6);		
		
		if(Pad.Newpress.Right) {
			PA_3DStartSpriteAnim(0, 4, 7, 6);	
			PA_3DSetSpriteHflip(0, 0);
		}
		if(Pad.Newpress.Left) {
			PA_3DStartSpriteAnim(0, 4, 7, 6);	
			PA_3DSetSpriteHflip(0, 1);
		}

		
		if(!((Pad.Held.Left)||(Pad.Held.Up)||(Pad.Held.Down)||(Pad.Held.Right))) PA_3DSpriteAnimPause(0, 1);
	
	
		// Moving Code
		y += Pad.Held.Down - Pad.Held.Up;
		x += Pad.Held.Right - Pad.Held.Left;		
		PA_3DSetSpriteXY(0, x, y);
	
		PA_WaitForVBL();
		PA_3DProcess(); // Update 3D...
	}
	
	return 0;
}
Exemple #30
0
/* 게임메인 */
int scr_Main() {
	/* 화면초기화  및 갱신 */
	UnLoad_Screen();
	PA_Init();
	PA_InitVBL();
	PA_LoadBackground(UP_SCREEN, BG1, &up_main); // 상단 디스플레이-타이틀화면 설정.
	PA_LoadBackground(DOWN_SCREEN, BG1, &down_main); // 하단 디스플레이-타이틀화면 설정.

	PA_LoadSpritePal(UP_SCREEN, BG2, (void*) GameName_Pal);
	PA_CreateSprite(UP_SCREEN, BG2, (void*) GameName_Sprite, OBJ_SIZE_64X32, 1,
			BG2, 74, 135);
	PA_StartSpriteAnim(UP_SCREEN, BG2, 0, 1, 1);

	PA_LoadSpritePal(DOWN_SCREEN, BG2, (void*) START_Pal);
	PA_CreateSprite(DOWN_SCREEN, BG2, (void*) START_Sprite, OBJ_SIZE_64X32, 1,
			BG2, 50, 100);

	PA_LoadSpritePal(DOWN_SCREEN, BG3, (void*) EXIT_Pal);
	PA_CreateSprite(DOWN_SCREEN, BG3, (void*) EXIT_Sprite, OBJ_SIZE_64X32, 1,
			BG3, 140, 100);

	if ( ismain==FALSE ) {
			AS_SoundDefaultPlay((u8*)start, (u32)start_size, 127, 64, TRUE, 0);
			ismain = TRUE;
		}

	while (1) {
		if (Stylus.Newpress) {
			if (PA_SpriteTouched(BG2)) {
				PA_DeleteBg(UP_SCREEN, BG1);
				PA_DeleteBg(DOWN_SCREEN, BG1);
				PA_DeleteSprite(DOWN_SCREEN, BG2);
				PA_DeleteSprite(DOWN_SCREEN, BG3);
				PA_DeleteSprite(UP_SCREEN, BG2);
				PA_LoadBackground(UP_SCREEN, BG1, &up);
				PA_LoadBackground(DOWN_SCREEN, BG1, &down);
				break;
			}
			if (PA_SpriteTouched(BG3)) {
				return GAMEEXIT;
			}
		}
		PA_WaitForVBL();
	}
	return 0;
}