コード例 #1
0
ファイル: PA_IO.c プロジェクト: troy56/palibds
int PA_WriteTextFile(char* pathname, char* text) {

  FILE* pFile;
  u32 bytesTransferred;
  
  pFile = fopen ( "/test.txt" , write_binary_mode );
  PA_WaitForVBL();
  
  if (pFile==NULL) {
 
  }
	
	bytesTransferred=fwrite(text,1,strlen(text),pFile);   //write the data to file and save the amount of bytes written.
			  
			  
	if(bytesTransferred<1) {   //check for success
		
		rewind(pFile);
		fclose (pFile);
		return 0; //no bytes written, error
	}
	
	rewind(pFile);
	fclose (pFile);
		
	PA_WaitForVBL();
	

  // terminate
 PA_OutputText(0,0,0,"%s  ", text);

  return bytesTransferred;
	
}
コード例 #2
0
ファイル: splash.cpp プロジェクト: jrgrafton/pucka-ds
/**
**Splash run function
**/
void Splash::run(){
	s16 i;
	// Transition to normal visible background
	for(i = 160; i >= 0; i--){
		PA_SetBrightness(0, i/5); 
		PA_SetBrightness(1, i/5); 
		PA_WaitForVBL();		   
	}   

	s16 time = 180; // 180 frames = 3 seconds
	while(time && (!Pad.Newpress.Anykey) && (!Stylus.Newpress)){ // Display until time over or keys pressed
		time--; // time goes by
		PA_WaitForVBL();
	}		
	
	// Transition to white
	for(i = 0; i < 160; i++){
		PA_SetBrightness(0, i/5); 
		PA_SetBrightness(1, i/5); 
		PA_WaitForVBL();		   
	}  	

	// Now that it's all white, clean all that and you're ready to go !
	PA_ResetBgSys();
	PA_SetBrightness(0, 0); // normal
	PA_SetBrightness(1, 0); // normal
	
	//Switch to main game state 
	delete mainState;
	mainState = new Menu();
}
コード例 #3
0
ファイル: menu.cpp プロジェクト: jrgrafton/pucka-ds
/**
**Splash run function
**/
void Menu::run(){
	s8 i;

	for (i = TRANS_LENGTH; i >= 0; i--) { // Fade length...
		PA_BgTransCenter(0, // screen
					  2, // fade type, from 0 to 4, test them out !				  
					  0, // invert
					  i); // Time, 0 being the screen completely visible, 32 completely out
		PA_WaitForVBL(); // To slow down the fades, we wait a frame...
	}
	PA_PlaySoundRepeat(0, main_music);
	while(!Stylus.Newpress){ // Display until keys pressed
		PA_WaitForVBL();
	}
	
	for (i = 0; i <= TRANS_LENGTH; i++) {
		PA_BgTransCenter(0, 2, 0, i);// same thing...
		PA_WaitForVBL(); // To slow down the fades, we wait a frame...
	}	

	PA_ResetBgSys();
	PA_WaitForVBL();

	//Switch to level splash
	delete mainState;
	mainState = currentLevelSplash;
}
コード例 #4
0
ファイル: main.c プロジェクト: troy56/palibds
// 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()
コード例 #5
0
ファイル: ds_global.c プロジェクト: Hugobros3/knyttds
void ds_global_breakpoint(char *where, int X) {
char error[255];
char memused[100];

	sprintf(memused,"U: %d / F: %d   ", getMemUsed(), getMemFree());       				
	sprintf(error,"<Breakpoint> \n %s \n %s",where,memused);
	
	
	// Prepare JSOB
	//PA_Reset3DSprites2Banks();
	//PA_3DProcess();
	ds_global_fillScreen(0,ds_global_getScreen1(),PA_RGB(0,0,16));
	ds_global_fillScreen(1,ds_global_getScreen0(),PA_RGB(0,0,16));
	
	// Fill JSOB
	PA_SmartText16bBuf_DS(ds_global_getScreen(0), 
										80, 48,  // base
										255 - 32, 191, // max
										"          -- Breakpoint!!!\n         /\n    MMMM\n   MMMMMM\n  MMMMMMM\n MDMM===M\n MDM=X=X\n MDM====M\n MDMM===M\n MNNM-MM\n  MNM-M\n  MM--M",
										PA_RGB(31,31,31), 1, 1, 255); // Features
	PA_CenterSmartText16bBuf_DS(ds_global_getScreen(1), 
										0, 0,  // base
										255, 64, // max
										"KSDS Breakpoint",PA_RGB(31,31,31), 3, 1); // Features
   PA_CenterSmartText16bBuf_DS(ds_global_getScreen(1), 
										0, 0,  // base
										255, 191, // max
										error,PA_RGB(31,31,31), 2, 1); // Features
  	if (X) {
		PA_CenterSmartText16bBuf_DS(ds_global_getScreen(1), 
										0, 191 - 32,  // base
										255, 191, // max
										"Please press X...",PA_RGB(31,31,31), 1, 1); // Features	
	} else {
		PA_CenterSmartText16bBuf_DS(ds_global_getScreen(1), 
										0, 191 - 32,  // base
										255, 191, // max
										"Please press Y...",PA_RGB(31,31,31), 1, 1); // Features	
	}   	

	// Show JSOB
   ds_global_paintScreen(1,ds_global_getScreen1(),0,0);
   ds_global_paintScreen(0,ds_global_getScreen0(),0,0);
   
	// Wait...
   PA_DisableSpecialFx(0);
  	PA_DisableSpecialFx(1);
  	if (X) {
	   while (!Pad.Newpress.X) {
	      PA_WaitForVBL();
		}
	} else {
	   while (!Pad.Newpress.Y) {
	      PA_WaitForVBL();
		}
	}   	
}
コード例 #6
0
ファイル: main.c プロジェクト: troy56/palibds
// 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()
コード例 #7
0
ファイル: main.c プロジェクト: troy56/palibds
// 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()
コード例 #8
0
ファイル: main.c プロジェクト: acidrain42/misc
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();
}
コード例 #9
0
ファイル: screen.c プロジェクト: hl1itj/Team7
void initScreen() {

	PA_Init();
	PA_LoadBackground(DOWN_SCREEN, BACKGROUND_DOWN, &start);
	PA_WaitForVBL();

}
コード例 #10
0
ファイル: main.c プロジェクト: troy56/palibds
// 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()
コード例 #11
0
ファイル: main.c プロジェクト: troy56/palibds
// 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()
コード例 #12
0
ファイル: main.c プロジェクト: deanrather/pong-ds
/**
 * Entry point of program.
 */
int main(int argc, char ** argv)
{
	init();
	while(true) // Keep app running
	{
		setupGame();
		while(game.lives) // New Round
		{
			setupRound();
			while(!game.gameover) // Neither player missed the ball
			{
				getInput();
				processAI();
				moveBall();
				displayOutput();
				
				// Sleep
				PA_CheckLid();
				PA_WaitForVBL();
			}
			postRound();
		}
		postGame();
	}
	return 0;
}
コード例 #13
0
ファイル: main.c プロジェクト: troy56/palibds
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;
}
コード例 #14
0
ファイル: main.cpp プロジェクト: ComputerDruid/IkarugaDS
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;
}
コード例 #15
0
ファイル: main.c プロジェクト: troy56/palibds
//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;
}
コード例 #16
0
ファイル: main.c プロジェクト: troy56/palibds
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;
}
コード例 #17
0
ファイル: main.c プロジェクト: troy56/palibds
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;
}
コード例 #18
0
ファイル: main.c プロジェクト: troy56/palibds
// 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()
コード例 #19
0
ファイル: main.c プロジェクト: deanrather/pong-ds
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();
		}
	}
}
コード例 #20
0
ファイル: main.c プロジェクト: troy56/palibds
// 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()
コード例 #21
0
ファイル: main.c プロジェクト: troy56/palibds
// 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;
}
コード例 #22
0
void PlayerBrowser::draw(){
	
	s8 i = 0;
	
	PA_SetBrightness(0, -31); // all black
	PA_SetBrightness(1, -31); // all black	
  	
	PA_ResetSpriteSys();
	PA_Init16cBg(1, 0);
	PA_Init16cBg(0, 0);
	PA_LoadTiledBg(1, 1, bgplayer1);  
	PA_LoadTiledBg(0, 1, bgplayer0);  
	PA_LoadSpritePal(0, 1, (void*)pbutton_Pal); 
	PA_KeyboardOut();

	PA_CreateSprite(0, TERM_SCREEN, (void*)term_Sprite, OBJ_SIZE_64X32, 1, 1, 0, 0);  
	PA_CreateSprite(0, PLAYERS_SCREEN, (void*)players_Sprite, OBJ_SIZE_64X32, 1, 1, 64, 0);  
	PA_CreateSprite(0, GAMES_SCREEN, (void*)games_Sprite, OBJ_SIZE_64X32, 1, 1, 128, 0);  
	PA_CreateSprite(0, OPTIONS_SCREEN, (void*)options_Sprite, OBJ_SIZE_64X32, 1, 1, 192, 0);  

	PA_SetSpriteAnim(0, 11, 1);
	
	for(i = -31; i < 0 ; i++){
		PA_SetBrightness(0, i); 
		PA_SetBrightness(1, i); 
		PA_WaitForVBL();		   
	}  	
	PA_16cText(0, 6, 85, 80, 95, "NAMEXXXXXX", 1, 1, 100);
	PA_16cText(0, 88, 85, 127, 95, "[12k*]", 1, 1, 100);
	PA_16cText(0, 128, 85, 136, 95, "X", 1, 1, 100);
	
	PA_16cText(0, 6, 95, 80, 115, "NAMEXXXXXX", 1, 1, 100);
	PA_16cText(0, 88, 95, 127, 115, "[12k*]", 1, 1, 100);
	PA_16cText(0, 128, 95, 136, 115, "X", 1, 1, 100);	 
}
コード例 #23
0
ファイル: main.c プロジェクト: troy56/palibds
// 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()
コード例 #24
0
ファイル: main.c プロジェクト: troy56/palibds
// 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()
コード例 #25
0
ファイル: main.c プロジェクト: acidrain42/misc
int get_nb_players() {
    int i, nb=0, ok=false;

    PA_CreateSprite(0, // Screen
			0, // Sprite number
			(void*)btn_2_players, // Sprite name
			OBJ_SIZE_64X32, // Sprite size
			1, // 256 color mode
			0, // Sprite palette number
			16, 80); // X and Y position on the screen
    PA_CreateSprite(0, 1, (void*)btn_3_players, OBJ_SIZE_64X32, 1, 0, 96, 80);
    PA_CreateSprite(0, 2, (void*)btn_4_players, OBJ_SIZE_64X32, 1, 0, 176, 80);

    PA_OutputText(0, 7, 0, "Nombre de joueurs");

    while (!ok) {
        for (i=0; i<3; i++) {
            if (PA_SpriteTouched(i)) {
                nb = i+2;
                ok = true;
            }
        }

        PA_WaitForVBL();
    }

    PA_DeleteSprite(0, 0);
    PA_DeleteSprite(0, 1);
    PA_DeleteSprite(0, 2);
    clear_screen(0);

    return nb;
}
コード例 #26
0
ファイル: main.c プロジェクト: hl1itj/Team2
void StartScreen() {
	PA_LoadBackground(UP_SCREEN, BACKGROUND_UP, &UPSTARTSCREEN);
	PA_LoadSpritePal(DOWN_SCREEN, START_NUM, (void*) START_Pal);
	PA_CreateSprite(DOWN_SCREEN, START_NUM, (void*) START_Sprite,
		OBJ_SIZE_64X32, 1, START_NUM, 96, 50);
	PA_StartSpriteAnim(DOWN_SCREEN, START_NUM, 0, 1, 2);
	while (1) {
		PA_WaitForVBL();
		if (Stylus.Newpress) {
			if (PA_SpriteTouched(START_NUM)) {
				PA_DeleteBg(UP_SCREEN, BACKGROUND_UP);
				PA_DeleteSprite(DOWN_SCREEN, START_NUM);
				PA_LoadBackground(UP_SCREEN, BACKGROUND_UP, &UPGAMESCREEN);
				PA_LoadBackground(DOWN_SCREEN, BACKGROUND_DOWN,
						&DOWNGAMESCREEN);
				break;
			}
		}
		if (Pad.Newpress.Start) {
			PA_DeleteBg(UP_SCREEN, BACKGROUND_UP);
			PA_DeleteSprite(DOWN_SCREEN, START_NUM);
			PA_LoadBackground(UP_SCREEN, BACKGROUND_UP, &UPGAMESCREEN);
			PA_LoadBackground(DOWN_SCREEN, BACKGROUND_DOWN, &DOWNGAMESCREEN);
			break;
		}
	}
	AS_SoundDefaultPlay((u8*)bgm, (u32)bgm_size, 127, 64, true, 0);
}
コード例 #27
0
ファイル: main.c プロジェクト: troy56/palibds
// 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()
コード例 #28
0
ファイル: main.c プロジェクト: troy56/palibds
// 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()
コード例 #29
0
ファイル: main.c プロジェクト: troy56/palibds
// 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()
コード例 #30
0
ファイル: main.cpp プロジェクト: kuntae/Team1
void ret_next() // �ƹ����� Touch�� ���� ����ȭ������ ��ȯ
{
	while (1) {
		if ( Stylus.Newpress )
			return;
		PA_WaitForVBL();
	}
}