Пример #1
0
void postRound()
{
	if(ball.vy > 0) game.lives--;
	if(game.lives)
	{
		if(ball.vy > 0) // I lose
		{
			PA_OutputSimpleText(SCREEN_TOP,0,6,"YOU LOSE THIS ROUND");
			if(game.lives>1) PA_OutputText(SCREEN_TOP,0,7,"ONLY %d BALLS LEFT!", game.lives);
			else PA_OutputSimpleText(SCREEN_TOP,0,7,"LAST BALL");
		}else{ // They lose
			game.score++;
			if(game.lives<5) game.lives++;
			PA_OutputSimpleText(SCREEN_TOP,0,6,"YOU WIN THIS ROUND");
			if(game.score>1) PA_OutputText(SCREEN_TOP,0,7,"YOU HAVE %d POINTS!", game.score);
			else PA_OutputSimpleText(SCREEN_TOP,0,7,"YOU EARNED A POINT & A BALL!");
		}
		
		PA_OutputSimpleText(SCREEN_TOP,0,12,"Press A to Play Again");
		while(!Pad.Newpress.A && !Stylus.Newpress)
		{
			if(Pad.Newpress.X) PA_SetDSLBrightness(0);
			if(Pad.Newpress.Y) PA_SetDSLBrightness(1);
			if(Pad.Newpress.B) PA_SetDSLBrightness(2);
			if(Pad.Newpress.Start) PA_SetDSLBrightness(3);
			
			// Sleep
			PA_CheckLid();
			PA_WaitForVBL();
		}
	}
}
Пример #2
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;
}
Пример #3
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;
}
Пример #4
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()
Пример #5
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;
}
Пример #6
0
void get_players_name(int nb_players, char **names) {
    s32 pos = 0;
    char letter = 0;
    int player = 0;

    PA_InitKeyboard(1);
    PA_KeyboardIn(25, 100);

    while (player < nb_players) {
        clear_screen(1);

        letter = PA_CheckKeyboard();

        if (letter > 31 && pos < 7) {
            names[player][pos] = letter;
            pos++;
        } else if ((letter == PA_BACKSPACE) && pos) {
            pos--;
            names[player][pos] = ' ';
        } else if (letter == '\n') {
            names[player][8] = '\0';
            player++;
            pos = 0;
        }

        PA_OutputSimpleText(1, 8, 11, names[player]);
        PA_OutputText(1, 0, 0, "Player %d/%d", player+1, nb_players);

        PA_WaitForVBL();
    }

    clear_screen(1);

    PA_KeyboardOut();
}
Пример #7
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;
}
Пример #8
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()
Пример #9
0
/* ************************************************************************* */
void debug()
{
	PA_OutputSimpleText(1, 0, 0, "Lets go online...");
	PA_InitWifi();
    PA_ConnectWifiWFC();
	
	char* buffer = malloc(256*256);
	PA_GetHTTP(buffer,"http://delfare.pizz.biz/getip.php3");
	PA_OutputSimpleText(1, 0, 1, buffer);
	
	PA_GetHTTP(buffer,"http://deanrather.com/index.php");
	PA_OutputSimpleText(1, 0, 2, buffer);
	
	PA_GetHTTP(buffer,"http://deanrather.com/highscores/");
	PA_OutputSimpleText(1, 0, 3, buffer);
	
	PA_OutputSimpleText(1, 0, 4, "Wow, That was fun!!");
	PA_WaitFor(Pad.Newpress.Start);
}
Пример #10
0
void MyCustomVBL(void) { // VBL function to play while gif is on...

	if(Pad.Newpress.Start){
		pause = !pause; // if 1 returns 0, if 0 returns 1
		if (pause == 1) {
			PA_GifAnimPause();  // pause animation
			PA_OutputSimpleText(0, 10, 11, "PAUSE !");
		}
		else {
			PA_GifAnimPlay();   // unpause...
			PA_OutputSimpleText(0, 10, 11, "       ");
		}
	}
	
	// Change speed according to keys
	if (Pad.Held.Up) speed += 0.02; 
	if (Pad.Held.Down && (speed > 0.02)) speed -= 0.02;
	
	PA_GifAnimSpeed(speed);  // Gif speed command :)
	
	PA_OutputText(0, 10, 11, "Speed : %f2     ", speed);	

// Change starting frame...
	if (Pad.Newpress.B) StartFrame += 1; 
	if (Pad.Newpress.A && (StartFrame > 0)) StartFrame -= 1;
	PA_OutputText(0, 2, 13, "Start Frame : %d     ", StartFrame);	
	PA_GifSetStartFrame(StartFrame); // Set the starting frame number...

// Change ending frame...
	if (Pad.Newpress.Y) EndFrame += 1; 
	if (Pad.Newpress.X && (EndFrame > 0)) EndFrame -= 1;
	PA_OutputText(0, 2, 14, "End Frame  : %d     ", EndFrame);	
		PA_GifSetEndFrame(EndFrame); // Set the ending frame number...

	PA_OutputText(0, 4, 16, "Current Frame  : %d     ", PA_GifGetFrame());	

}
Пример #11
0
// Function: main()
int main(int argc, char ** argv){

	PA_Init();    // PA Init...
	PA_InitVBL();	// VBL Init...
	
	PA_Init8bitBg(1, 3); 	// Init a 8 bit Bg on screen 1	
	
	
	PA_InitText(0, 0); // Text on bottom screen
		
	PA_OutputSimpleText(0, 1, 6, "Press Start to pause/unpause");
	PA_OutputSimpleText(0, 1, 7, "Press Up/Down to change speed");
	PA_OutputSimpleText(0, 1, 8, "Press A/B to change StartFrame");
	PA_OutputSimpleText(0, 1, 9, "Press X/Y to change EndFrame");	
	PA_VBLFunctionInit(MyCustomVBL); // start the function to play during gif file !

  while(1)  {
 		PA_LoadGif(	1, (void*)bartman); // Gif File to play over and over again
 		PA_Clear8bitBg(1); // Clear the screen after use
		PA_WaitForVBL();
	}
		
	return 0;
} // End of main()
Пример #12
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()
Пример #13
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(1, 0);

// This'll put a green color on the bottom screen... Color component (red, green, blue) range from 0 to 31
  PA_SetTextCol(0, 0, 31, 0);

// The same old PA_OutputSimpleText, but now with newline support
  PA_OutputSimpleText(1, 1, 1, "          ATTENTION:\n\nPA_OutputSimpleText now has\nsupport for line breaking in\nthe body of the text. So it's\nmuch easier to place a lot of\ntext on the screen.\n\nThis should be really useful\nif you need to parse a text\nfile loaded from FAT!");

// It works with PA_OutputText, as well
  PA_OutputText(1, 1, 13, "But wait, that's not all! It\nalso works with variables in\nPA_OutputText.\n\nWhat do you think of that,\n%s?\n\nIt's %d:%02d, do you know\nwhere your text is?", PA_UserInfo.Name, PA_RTC.Hour, PA_RTC.Minutes);

  while (1) {PA_WaitForVBL();}

  return 0;
} // End of main()
Пример #14
0
// Function: main()
int main(int argc, char ** argv)
{
	PA_Init();    // Initializes PA_Lib
	PA_InitVBL(); // Initializes a standard VBL
	
	PA_Init3D(); // Uses Bg0
	PA_Reset3DSprites();
	
	// Initialise the text system on the top screen
	PA_InitText(0, 1);
	PA_InitText(1, 1);  // Initialise the text system on the top screen	
						
	PA_OutputSimpleText(1, 0, 6, "Move the Sprite with the stylus");	
	
	// First, create the gfx with the corresponding images and sizes. Images converted as 16bit sprites in PAGfx
	gfx[0] = PA_3DCreateTex((void*)mollusk_Texture, 64, 64, TEX_16BITS);	
	
	// Create 4 sprites for the different flips......
	PA_3DCreateSpriteFromTex(0, gfx[0], 64, 64, 	0,		80, 48); // X, Y SPRITE CENTER !
	PA_3DCreateSpriteFromTex(1, gfx[0], 64, 64, 	0,		80+96, 48); // X, Y SPRITE CENTER !	
	PA_3DCreateSpriteFromTex(2, gfx[0], 64, 64, 	0,		80, 80+64); // X, Y SPRITE CENTER !
	PA_3DCreateSpriteFromTex(3, gfx[0], 64, 64, 	0,		80+96, 80+64); // X, Y SPRITE CENTER !
	
	// Set the flips
	PA_3DSetSpriteHflip(0, 0);		PA_3DSetSpriteVflip(0, 0);
	PA_3DSetSpriteHflip(1, 1);		PA_3DSetSpriteVflip(1, 0);	
	PA_3DSetSpriteHflip(2, 0);		PA_3DSetSpriteVflip(2, 1);
	PA_3DSetSpriteHflip(3, 1);		PA_3DSetSpriteVflip(3, 1);	
		
	while(1) {


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


	
	return 0;
} // End of main()
Пример #15
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, // Bootom screen
				0);  	// Background number, from 0-3, on which to load the text system
	PA_InitText(1, 0);  // Initialise the text system on the top screen

	PA_SetTextCol(0, // Bottom screen
				0, // No red
				31, // Maximum green
				0); // No blue
	// This'll put a green color on the bottom screen... Color component (red, green, blue) range from 0 to 31

	u32 nletters = 0; // Number of letter to output...
	u32 letter = 0; // Current letter written...
	
	while (letter == nletters){ // Do this until the function outputs all the text
		++nletters; // Next frame, one more letter...	
		// This text function outputs a given number of letters... This way, it can do as if you were typing !
		letter = PA_BoxText(1, 2, 2, 29, 15, "Hi there :p  Cool, the function works perfectly ! So you see the text being typed...", nletters);
		PA_WaitForVBL(); // You can set more WaitForVBL if you want to slow down the text output...
	}

	PA_OutputSimpleText(0, 10, 10, "Finished !"); // Finished...


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

		PA_WaitForVBL();
		
	}
	
	return 0;
} // End of main()
Пример #16
0
// Function: main()
int main(int argc, char ** argv)
{
	PA_Init();    // Initializes PA_Lib
	PA_InitVBL(); // Initializes a standard VBL
	PA_InitText(0, 0);
	
	
	// Init the sound system
	AS_Init(AS_MODE_SURROUND | AS_MODE_16CH);
	AS_SetDefaultSettings(AS_PCM_8BIT, 11025, AS_SURROUND);
	
	PA_OutputSimpleText(0, 1, 10, "Close the lid and see what     happens...");

	// Infinite loop to keep the program running
	while (1)
	{	
		PA_CloseLidSound2(Babye, HereWeGo); // Sound to play when lid closes and opens

		PA_WaitForVBL();
	}
	
	return 0;
} // End of main()
Пример #17
0
// Function: main()
int main(int argc, char ** argv) {
    PA_Init();    // Initializes PA_Lib
    PA_InitVBL(); // Initializes a standard VBL

    PA_SetVideoMode(0, 2);  //screen, mode

    PA_LoadPAGfxRotBg(0, //screen
                      3, // background number
                      Rot, // background name in PAGfx
                      1); // wraparound !

    PA_InitText(1, 0);

    // Infinite loop to keep the program running
    s32 scrollx = 0;
    s32 scrolly = 0;
    s32 rotcenterx = 0;
    s32 rotcentery = 0;
    s16 angle = 0;
    s32 zoom = 256;

    PA_OutputSimpleText(1, 2, 2, "Zoom       : Start/Select");
    PA_OutputSimpleText(1, 2, 3, "ScrollX    : Left/Right");
    PA_OutputSimpleText(1, 2, 4, "Scrolly    : Up/Down");
    PA_OutputSimpleText(1, 2, 5, "RotCenterX : A/Y");
    PA_OutputSimpleText(1, 2, 6, "RotCenterY : B/X");
    PA_OutputSimpleText(1, 2, 7, "Angle      : R/L");


    while (1)
    {
        zoom += Pad.Held.Start - Pad.Held.Select;
        scrollx += Pad.Held.Right - Pad.Held.Left;
        scrolly += Pad.Held.Down - Pad.Held.Up;
        rotcenterx += Pad.Held.A - Pad.Held.Y;
        rotcentery += Pad.Held.B - Pad.Held.X;
        angle += Pad.Held.R - Pad.Held.L;

        PA_SetBgRot(0, 3, scrollx, scrolly, rotcenterx, rotcentery, angle, zoom);

        PA_WaitForVBL();
    }

    return 0;
} // End of main()
Пример #18
0
// Function: main()
int main(int argc, char ** argv)
{
	PA_Init();    // Initializes PA_Lib
	PA_InitVBL(); // Initializes a standard VBL
	
	PA_SplashBlue();
	
	PA_InitText(0, 0);
	
	PA_OutputSimpleText(0, 2, 10, "Splash Screen Ended");
	
	
	
	// Infinite loop to keep the program running
	while (1)
	{


		
		PA_WaitForVBL();
	}
	
	return 0;
} // End of main()
Пример #19
0
void postGame()
{
	PA_PauseMod(1);
	bool submitted = false;
	while(!Pad.Newpress.Start && !Stylus.DblClick && !submitted)
	{
		PA_ClearTextBg(SCREEN_TOP);
		PA_OutputSimpleText(SCREEN_TOP,0,0,"GAME OVER");
		PA_OutputText(SCREEN_TOP,0,1,"YOUR SCORE: %d", game.score);
		
		if(game.score<highscore.points)
		{
			PA_OutputText(SCREEN_TOP,0,2,"%s's High Score: %d", highscore.name, highscore.points);
			PA_OutputSimpleText(SCREEN_TOP,0,4,"Press Start to Play Again");
		}else{
			PA_OutputText(SCREEN_TOP,0,2,"NEW HIGH SCORE!!!");
			highscore.points=game.score;
			highscore.name=(char*)PA_UserInfo.Name;
			PA_OutputSimpleText(SCREEN_TOP,0,3,"Press Y To submit score online.");
			PA_OutputSimpleText(SCREEN_TOP,0,4,"Press Start to Play Again");
			if(Pad.Newpress.Y)
			{
				PA_OutputSimpleText(SCREEN_TOP,0,5,"Ranking globally...");
				
				// Init Network
				PA_InitWifi();
			    if(PA_ConnectWifiWFC())
			    {
			    	submitScore();
					getHighScores();
					submitted=true;
					Wifi_DisconnectAP();
			    }else{
			    	PA_OutputSimpleText(SCREEN_TOP,0,6,"Wifi Connection Failed.");
			    }
				Wifi_DisableWifi();
			}
		}
		// Sleep
		PA_CheckLid();
		PA_WaitForVBL();
	}
}
Пример #20
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
	
	// Let's put some colors... in the background palettes
	PA_SetBgPalCol(0, 1, PA_RGB(31, 31, 31));
	PA_SetBgPalCol(0, 2, PA_RGB(31, 0, 0));	
	PA_SetBgPalCol(0, 3, PA_RGB(0, 0, 31));
	PA_SetBgPalCol(0, 4, PA_RGB(0, 31, 0));

	// Let's not load any backgrounds :p
	
	// This will initialise an  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_Init8bitBg(0, 3);

	PA_SmartText(0, 0, 80, 255, 100, "Hello World", 1, 4, 1, 100);


	// Let's have some rotated text :p
	// X and Y positions are taken as if the DS was turned
	PA_SmartText(0, 1, 1, 190, 20, "Hello World", 3, 3, 3, 100);

	// And a centered text, to check if it works
	PA_CenterSmartText(0, 0, 100, 255, 120, "Hello World", 2, 4, 1); // Same as Smart text, but no letter limit
	
	
	
	PA_InitText(1, 0);
	
		// Infinite loop to keep the program running
	s32 scrollx = 0;
	s32 scrolly = 0;
	s32 rotcenterx = 0;
	s32 rotcentery = 0;
	s16 angle = 0;
	s32 zoom = 256;
	
	PA_OutputSimpleText(1, 2, 2, "Zoom       : Start/Select");
	PA_OutputSimpleText(1, 2, 3, "ScrollX    : Left/Right");
	PA_OutputSimpleText(1, 2, 4, "Scrolly    : Up/Down");
	PA_OutputSimpleText(1, 2, 5, "RotCenterX : A/Y");
	PA_OutputSimpleText(1, 2, 6, "RotCenterY : B/X");
	PA_OutputSimpleText(1, 2, 7, "Angle      : R/L");


	while (1)
	{
		zoom += Pad.Held.Start - Pad.Held.Select;
		scrollx += Pad.Held.Right - Pad.Held.Left;
		scrolly += Pad.Held.Down - Pad.Held.Up;
		rotcenterx += Pad.Held.A - Pad.Held.Y;
		rotcentery += Pad.Held.B - Pad.Held.X;	
		angle += Pad.Held.R - Pad.Held.L;
		
		PA_SetBgRot(0, 3, scrollx, scrolly, rotcenterx, rotcentery, angle, zoom);
		
		PA_WaitForVBL();
	}
	

	return 0;
} // End of main()
Пример #21
0
// Main function
int main(void)	{
	// PAlib init
	PA_Init();
	PA_InitVBL();
	
	PA_InitText(0, 0);  // Initialise the text system on the top screen	
	PA_InitText(1, 0);  // Initialise the text system on the top screen

	PA_OutputSimpleText(1, 0, 5, "Please insert your DS Motion and press any key"); // Ask to insert the DS Motion...

	PA_WaitFor(Pad.Newpress.Anykey);  // Wait for any key to be pressed before continuing...
	PA_ClearTextBg(1);		// Erase text screen...
	
	 // Turn on the DS Motion...
	 PA_MotionInit();
	 
	while ( !PA_CheckDSMotion()) { // Checks for the DS Motion, continues looking for it until it actually finds it...
		PA_WaitForVBL();
		
		// If no DSMotion found...
		PA_OutputText(1, 0, 5, "      DS Motion not found ! \nPlease insert your DS Motion and press any key"); // Ask to insert the DS Motion... again...
		
		PA_WaitFor(Pad.Newpress.Anykey);  // Wait for any key to be pressed before continuing...
		PA_MotionInit();
	}
	
	PA_ClearTextBg(1); // erase the text...
	
	PA_MotionToPad(1); // Overrides the pad keys and puts the DS Motion instead

	PA_LoadSpritePal(0, 0, (void*)sprite0_Pal);	// Palette....	

	s32 x = 120; s32 y = 64;

	PA_CreateSprite(0, 0,(void*)som_Sprite, OBJ_SIZE_16X32,1, 0, x, y); // Sprite
	
	while(1)
	{
		// Animation code...
		if(Pad.Newpress.Up) PA_StartSpriteAnim(0, 0, 0, 3, 6);
		if(Pad.Newpress.Down) PA_StartSpriteAnim(0, 0, 8, 11, 6);		
		
		if(Pad.Newpress.Right) {
			PA_StartSpriteAnim(0, 0, 4, 7, 6);	
			PA_SetSpriteHflip(0, 0, 0);
		}
		if(Pad.Newpress.Left) {
			PA_StartSpriteAnim(0, 0, 4, 7, 6);	
			PA_SetSpriteHflip(0, 0, 1);
		}

		
		if(!((Pad.Held.Left)||(Pad.Held.Up)||(Pad.Held.Down)||(Pad.Held.Right))) PA_SpriteAnimPause(0, 0, 1);
	
	
		// Moving Code
		y += Pad.Held.Down - Pad.Held.Up;
		x += Pad.Held.Right - Pad.Held.Left;		
		PA_SetSpriteXY(0, 0, x, y);
		
		PA_OutputText(1, 3, 7, "Up     : %d-%d-%d", Pad.Newpress.Up, Pad.Held.Up, Pad.Released.Up);
		PA_OutputText(1, 3, 8, "Down   : %d-%d-%d", Pad.Newpress.Down, Pad.Held.Down, Pad.Released.Down);
		PA_OutputText(1, 3, 9, "Left   : %d-%d-%d", Pad.Newpress.Left, Pad.Held.Left, Pad.Released.Left);		
		PA_OutputText(1, 3, 10, "Right  : %d-%d-%d", Pad.Newpress.Right, Pad.Held.Right, Pad.Released.Right);	
	
		PA_WaitForVBL();
	}
	
	return 0;
}
Пример #22
0
int main(int argc, char ** argv)
{
  PA_Init();
  PA_InitVBL();

  PA_InitText(0, 0);

  PA_OutputSimpleText(0, 6, 1, "Create GFX 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/


  u16 gfx[2];

// Load a sprite image from FAT to VRAM. It works just like PA_CreateGfx!
  gfx[0] = PA_FatEasyCreateGfx(0, // Screen
                               "pokekun", // Name of a sprite binary created with PAGfx (without the "_Sprite.bin")
                               OBJ_SIZE_32X64, // Sprite size macro
                               1); // 256 color sprite

// Let's make another one for the top screen 
  gfx[1] = PA_FatEasyCreateGfx(1, "pokekun", OBJ_SIZE_32X64, 1);


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

// for the top screen, too
  PA_FatEasyLoadSpritePal(1, 0, "pokekun");


  PA_OutputSimpleText(0, 0, 20, "Press A to create a sprite on\nthe bottom screen, B for one on\nthe top screen");

  u8 nsprites0 = 0; // Number of sprites on the bottom screen
  u8 nsprites1 = 0; // Top screen

  while(1)
  {

    if (Pad.Newpress.A && nsprites0 < 128)
    {
// Since the sprite is already in VRAM you can just the normal PA_CreateSpriteFromGfx
      PA_CreateSpriteFromGfx(0, // screen
                             nsprites0, // Next sprite to load...
                             gfx[0], // image to use in memory, no image copying !
                             OBJ_SIZE_32X64, 1, 0, PA_RandMax(224), PA_RandMax(128)); // The rest is like normal sprites

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

    if (Pad.Newpress.B && nsprites1 < 128)
    {
      PA_CreateSpriteFromGfx(1, nsprites1, gfx[1], OBJ_SIZE_32X64, 1, 0, PA_RandMax(224), PA_RandMax(128));
      ++nsprites1;
    }

    PA_WaitForVBL();

  }

  return 0;
}
Пример #23
0
int main(void) {

    // init PA_Lib
    PA_Init();
    PA_InitVBL();
	
    PA_InitText(1, 0);
    PA_InitText(0, 0);
    
    // init EFSlib & libfat
    if(EFS_Init(EFS_AND_FAT | EFS_DEFAULT_DEVICE, NULL)) {
        PA_OutputSimpleText(1, 0, 0, "EFS init ok");
        PA_OutputText(1, 0, 1, "found NDS path: %s", efs_path);    
        
        DIR_ITER* dir;
        struct stat st;
        s8 nb;
        FILE* file;
        u8* buffer;
        int i, size;

        // open a text file and read its contents
        file = fopen("/test.txt", "rb");
        if(file != NULL) {
            // get file size using stat            
            stat("/test.txt", &st);
            size = st.st_size;
            
            buffer = (u8*)malloc(size);
            fread(buffer, 1, size, file);
            buffer[size-1] = '\0';
            PA_OutputText(1, 0, 4, "/test.txt content: '%s'", buffer);
            PA_OutputText(1, 10, 5, "size: %d bytes", size);
            free(buffer);
            fclose(file); 
        }

        // open another file, read its content
        file = fopen("/folder/test.txt", "rb");
        if(file != NULL) {
            // get file size
            fseek(file, 0, SEEK_END);
            size = ftell(file); 
            fseek(file, 0, SEEK_SET);

            buffer = (u8*)malloc(size);
            fread(buffer, 1, size, file);
            buffer[size-1] = '\0';
            PA_OutputText(1, 0, 7, "/folder/test.txt content:\n%s", buffer);
            free(buffer); 
            fclose(file);
        }
            
        // reopen the file, modify its content
        file = fopen("/folder/test.txt", "rb+");
        if(file != NULL) {
            nb = fwrite("16b Written OK!", 1, 16, file);
            PA_OutputText(1, 0, 10, "write test done! : %d bytes", nb);
            fclose(file);
        }

        // reopen another file, read its content again, 1 byte at a time
        file = fopen("/folder/dummy/.././test.txt", "rb");  // funky path to test relative path parsing
        if(file != NULL) {
            // get file size
            fseek(file, 0, SEEK_END);
            size = ftell(file); 
            fseek(file, 0, SEEK_SET);

            buffer = (u8*)malloc(size);
            
            i = 0;
            while(i < size) {
                fread(&buffer[i], 1, 1, file);
                i++;
            }
            
            buffer[size-1] = '\0';
            PA_OutputText(1, 0, 12, "/folder/test.txt new content:\n%s", buffer);
            free(buffer); 
            fclose(file);
        }

        PA_OutputSimpleText(1, 0, 15, "Press A for directory tests.");
        PA_WaitFor(Pad.Newpress.A);

        // open root directory then list its content
        PA_OutputText(0, 0, 0, "Listing '/' directory:");
        dir = diropen(".");
        
        if(dir != NULL) {
            i = 0;
            buffer = (u8*)malloc(EFS_MAXNAMELEN);

            while(!(dirnext(dir, (char*)buffer, &st))) {
                if(st.st_mode & S_IFDIR)
                    PA_OutputText(0, 0, i++, "DIR : %s", buffer);
                else
                    PA_OutputText(0, 0, i++, "FILE: %s, %d bytes", buffer, st.st_size);
            }
            
            PA_OutputSimpleText(0, 0, i++, "end of directory.");
            PA_OutputSimpleText(0, 0, i++, "directory reset, first file is:");
            
            dirreset(dir);
            dirnext(dir, (char*)buffer, &st);
            if(st.st_mode & S_IFDIR)
                PA_OutputText(0, 0, i++, "DIR : %s", buffer);
            else
                PA_OutputText(0, 0, i++, "FILE: %s, %d bytes", buffer, st.st_size);
            
            dirclose(dir);
            free(buffer);
        }

        // chdir to a directory then list its content
        PA_OutputSimpleText(0, 0, i++, "Listing '/list/' directory:");
        chdir("/list/");
        dir = diropen("./");
        
        if(dir != NULL) {
            buffer = (u8*)malloc(EFS_MAXNAMELEN);
            
            while(!(dirnext(dir, (char*)buffer, &st))) {
                if(st.st_mode & S_IFDIR)
                    PA_OutputText(0, 0, i++, "DIR : %s", buffer);
                else
                    PA_OutputText(0, 0, i++, "FILE: %s, %d bytes", buffer, st.st_size);
            }
            
            PA_OutputSimpleText(0, 0, i++, "end of directory.");
            dirclose(dir);
            free(buffer);
        }

    } else {
        PA_OutputSimpleText(1, 0, 0, "EFS init error!");
    }

    while(1) {
        PA_WaitForVBL();
    }

    return 0;
}