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; }
void PA_Init(void) { s32 i; for (i = 0; i < 130000>>2; i++) Blank[i] = 0; REG_IPC_FIFO_CR = IPC_FIFO_ENABLE | IPC_FIFO_SEND_CLEAR; // enable & clear FIFO PA_Init2D(); pa_checklid = 1; // Autochecklid by default pa_update_padtimes = 0; // Don't update pad-times by default gh_update_padtimes = 0; // Don't update GuitarHero-pad-times by default Pad.Uptime.Up = 0; Pad.Downtime.Up = 0; Pad.Uptime.Down = 0; Pad.Downtime.Down = 0; Pad.Uptime.Left = 0; Pad.Downtime.Left = 0; Pad.Uptime.Right = 0; Pad.Downtime.Right = 0; Pad.Uptime.A = 0; Pad.Downtime.A = 0; Pad.Uptime.B = 0; Pad.Downtime.B = 0; Pad.Uptime.X = 0; Pad.Downtime.X = 0; Pad.Uptime.Y = 0; Pad.Downtime.Y = 0; Pad.Uptime.L = 0; Pad.Downtime.L = 0; Pad.Uptime.R = 0; Pad.Downtime.R = 0; Pad.Uptime.Start = 0; Pad.Downtime.Start = 0; Pad.Uptime.Select = 0; Pad.Downtime.Select = 0; Pad.Uptime.Anykey = 0; Pad.Downtime.Anykey = 0; //WAIT_CR &= ~(1 << 7); PA_VBLCountersReset(); Stylus.X = 128; Stylus.Y = 96; PA_VBLFunctionReset(); irqInit(); //PA_ResetInterrupts(); IPC->mailData = (u32)(&PA_IPC); for (i = 0; i < 2; i++){ PA_SetBrightness(i, 0); // On affiche les écrans PA_font[i] = 0; // #ifndef TEXT_ALLCHARACTERS PA_textmap[i] = (u16*)PA_text_Map; PA_texttiles[i] = (u8*)PA_text_Tiles; PA_textpal[i] = (u16*)PA_text_Pal; // #endif /* #ifdef TEXT_ALLCHARACTERS PA_textmap[i] = (u16*)PA_text2_Map; PA_texttiles[i] = (u8*)PA_text2_Tiles; PA_textpal[i] = (u16*)PA_text2_Pal; #endif */ } PA_UpdateUserInfo(); PA_ResetRecoSys(); // Reco system init PA_SetScreenSpace(48); // Default spacing PA_GifInfo.StartFrame = 0; // start from the beginning PA_GifInfo.EndFrame = 10000; // random high number MotionVBL = PA_Nothing; PaddleVBL = PA_Nothing; GHPadVBL = PA_Nothing; PA_UpdateRTC(); PA_InitRand(); }
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); s32 i; // will be used in for loops to cycle through the frisbees... PA_InitRand(); // Init the random stuff... for (i = 0; i < 10; i++){ // Sprite initial position... frisbee[i].x = (PA_Rand()%256)-16; // random position on the screen frisbee[i].y = 192+SCREENHOLE + (PA_Rand()%192)-16; // random position on the bottom screen; // Speed of frisbee in both ways frisbee[i].vx = 0; frisbee[i].vy = 0; frisbee[i].angle = 0; // Create the sprite on both screens... PA_DualCreateSprite(FRISBEE+i, (void*)frisbee_Sprite, OBJ_SIZE_32X32, 1, 0, frisbee[i].x-16, frisbee[i].y-16); PA_DualSetSpriteRotEnable(FRISBEE+i, i); // Enable rotation/zoom, rotset 0 } while(1) { for (i = 0; i < 10; i++){ // Move with the stylus, or move on... if (PA_MoveSprite(FRISBEE+i)){ frisbee[i].x = PA_MovedSprite.X; frisbee[i].y = PA_MovedSprite.Y + 192 + SCREENHOLE; frisbee[i].vx = PA_MovedSprite.Vx; frisbee[i].vy = PA_MovedSprite.Vy; } else{ // Now, the frisbee's fixed point position will be updated according to the speed... frisbee[i].x += frisbee[i].vx; frisbee[i].y += frisbee[i].vy; // If the sprite touches the left or right border, flip the horizontal speed if ((frisbee[i].x - 16 <= 0) && (frisbee[i].vx < 0)) frisbee[i].vx = -frisbee[i].vx; else if ((frisbee[i].x + 16 >= 256)&&(frisbee[i].vx > 0)) frisbee[i].vx = - frisbee[i].vx; // Same thing, for top and bottom limits... if ((frisbee[i].y - 16 <= 0) && (frisbee[i].vy < 0)) frisbee[i].vy = -frisbee[i].vy; else if ((frisbee[i].y + 16 >= 192 + 192 + SCREENHOLE)&& (frisbee[i].vy > 0)) frisbee[i].vy = - frisbee[i].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+i, frisbee[i].x-16, frisbee[i].y-16); } frisbee[i].angle+=4; // Make the frisbee turn... PA_DualSetRotsetNoZoom(i, frisbee[i].angle); } PA_WaitForVBL(); // Synch to the framerate... } return 0; }