/** **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(); }
/** **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; }
// Fonction d'affichage du splashscreen void splash() { int i; // Timer //splash 1 : palib,devkitpro,"plus ou moins ds" PA_LoadBackground(1, 1, &splashtop); PA_LoadBackground(0, 1, &splashbottom); fonduentree(); for (i = 0; i < 60*3; i++) { if(Pad.Newpress.A || Stylus.Newpress) break; PA_WaitForVBL(); } fondusortie(); PA_ResetBgSys(); PA_ResetSpriteSys(); }
void PA_Init2D(void){ // Turn on the screens and 2D cores and switch to mode 0 powerON(POWER_ALL); // POWER_CR = POWER_ALL_2D; REG_POWERCNT &= ~SWITCH_SCREENS; // on s'assure que l'écran est bien /* VRAM_A_CR=VRAM_ENABLE|VRAM_A_MAIN_BG; VRAM_B_CR=VRAM_ENABLE|VRAM_B_MAIN_SPRITE; VRAM_C_CR=VRAM_ENABLE|VRAM_C_SUB_BG; VRAM_D_CR=VRAM_ENABLE|VRAM_D_SUB_SPRITE; */ videoSetMode( MODE_0_2D | DISPLAY_SPR_ACTIVE | //turn on sprites DISPLAY_SPR_1D | //this is used when in tile mode DISPLAY_SPR_1D_SIZE_128| DISPLAY_SPR_1D_BMP //and this in bitmap mode ); videoSetModeSub( MODE_0_2D | DISPLAY_SPR_ACTIVE | //turn on sprites DISPLAY_SPR_1D | //this is used when in tile mode DISPLAY_SPR_1D_SIZE_128| DISPLAY_SPR_1D_BMP //and this in bitmap mode ); // DISPLAY_CR = MODE_0_2D | DISPLAY_SPR_1D_LAYOUT | DISPLAY_SPR_ACTIVE|DISPLAY_SPR_1D_SIZE_128|DISPLAY_SPR_1D_BMP; // SUB_DISPLAY_CR = MODE_0_2D | DISPLAY_SPR_1D_LAYOUT | DISPLAY_SPR_ACTIVE|DISPLAY_SPR_1D_SIZE_128|DISPLAY_SPR_1D_BMP; vramSetMainBanks(VRAM_A_MAIN_SPRITE,VRAM_B_MAIN_BG_0x06000000,VRAM_C_SUB_BG,VRAM_D_SUB_SPRITE); // Sprite inits... PA_ResetSpriteSys(); // Init's the sprite system PA_InitSpriteExtPal(); // Init's sprite extended palettes PA_ResetBgSys(); PA_InitBgExtPal(); // Init's bg extended palettes // VBL Inits SpriteVBL = PA_UpdateSpriteVBL; }
//------------------------------------------------------------ //------------------------------------------------------------ void resetAllGraphics() { // reset everything Sprite::freeAllSprites(); PA_ResetSpriteSys(); #ifndef DEBUG PA_ResetBgSys(); // attempting to clear VRAM memset(VRAM_A, 0, 0x20000); memset(VRAM_B, 0, 0x40000); memset(VRAM_C, 0, 0x60000); memset(VRAM_D, 0, 0x80000); memset(VRAM_E, 0, 0x90000); memset(VRAM_F, 0, 0x94000); memset(VRAM_G, 0, 0x98000); memset(VRAM_H, 0, 0xA0000); memset(VRAM_I, 0, 0x98000); #endif }
void LAN() { PA_ResetBgSys(); PA_ResetSpriteSys(); PA_InitText(MAIN_SCREEN, 0); PA_SetTextCol(MAIN_SCREEN, 31, 31, 31); if(!IPC_Init()) { PA_OutputText(MAIN_SCREEN, 0, 0, "IPC INIT FAILED"); while(true) {} } IPC_SetChannelCallback(0, &LWIFI_IPC_Callback); PA_VBLFunctionInit(customVBL); // inits/preps DS <-> DS PA_OutputText(MAIN_SCREEN, 1, 3, "Start Game = Start/nJoin Game = Select"); fadeIn(); while(playernumber == -1) { if(!lobbyinited) { LOBBY_Init(); LOBBY_SetStreamHandler(0x0001, &receive); lobbyinited = true; } // inits liblobby else if(Pad.Newpress.Start) { playernumber = 0; LOBBY_SetOwnName("Host"); LOBBY_CreateRoom(ROOM_NAME, MAX_PLAYERS, GAME_CODE, GAME_VER); } // creates a new game else if(Pad.Newpress.Select) { playernumber = 1; LOBBY_SetOwnName("Client"); LOBBY_JoinRoom(LOBBY_GetRoomByGame(0, GAME_CODE)); } // joins a created game PA_WaitForVBL(); } int max = LOBBY_GetUsercountInRoom(LOBBY_GetRoomByUser(LOBBY_GetUserByID(USERID_MYSELF))); PA_OutputText(MAIN_SCREEN, 1, 3, " "); PA_OutputText(MAIN_SCREEN, 1, 4, " "); PA_OutputText(MAIN_SCREEN, 1, 3, "Waiting for connection"); while(max < 2) { max = LOBBY_GetUsercountInRoom(LOBBY_GetRoomByUser(LOBBY_GetUserByID(USERID_MYSELF))); PA_OutputText(MAIN_SCREEN, 1, 4, "%d", max); PA_WaitForVBL(); } players.push_back(new Kirby(512/2 -96 -32, 256/3 -32, 1, players, &display)); Stage stage = setStage(FINALDESTINATION); PA_InitText(MAIN_SCREEN, 1); // inits text on the main screen (displays time) PA_SetTextCol(MAIN_SCREEN, 31, 31, 31); // text color = white PA_OutputText(MAIN_SCREEN, 1, 3, " "); PA_OutputText(MAIN_SCREEN, 1, 4, " "); while(true) { if(playernumber == 0) { players[0] -> act(); dat[0] = (int)(players[0] -> x); dat[1] = (int)(players[0] -> y); dat[2] = PA_GetSpriteAnimFrame(MAIN_SCREEN, players[0] -> SPRITENUM); LOBBY_SendToUser(LOBBY_GetUserByID(0), 0x0001, (unsigned char *)dat, 10); } scrollScreen(); PA_WaitForVBL(); } }
Board::Board(int m):root_story(-1, -1, 0) { #ifdef CKM_STORED // pIgs = NULL; #endif size = 19; // UI = new FlBoard(); // time_color = UI->black_time->text_background(); //time_color2 = UI->black_time->text_color(); //UI->b = this; set_size(size); cur_player = BLACK; for (int i=0; i<19; i++) for (int j=0; j<19; j++) { b[i][j] = EMPTY; root_story.b[i][j] = EMPTY; } s = &root_story; pos = 0; root_story.score[0] = score[0] = 0; root_story.score[1] = score[1] = 0.5; mode = 0; set_mode(m); // owner = 0; //< pointer on the possibly associated IGS game memset(inib, EMPTY, 19*19); memset(dead, EMPTY, 19*19); memset(territory, EMPTY, 19*19); memset(b, EMPTY, 19*19); // memset(old_c, 0, sizeof(old_c)); //time color next = first; first = this; if (!stn) { stn = new Stone(); stn->set_size(20); // stn->init_image(); } // UI->black_box->image(stn->img[0]); // UI->white_box->image(stn->img[1]); // UI->black_name->hide(); // UI->white_name->hide(); // UI->black_time->hide(); //UI->white_time->hide(); // UI->moves_browser->board = this; // UI->observer_browser->callback(observer_cb, this); // UI->moves_browser->type(Fl_Browser::VERTICAL | Fl_Browser::MULTI_BROWSER); strcpy(blackname, ""); strcpy(blackrank, ""); strcpy(whitename, ""); strcpy(whiterank, ""); filename = 0; title = 0; PA_ResetBgSys(); PA_ResetSpriteSys(); PA_Init3D(); PA_Reset3DSprites(); PA_LoadTiledBg(0, 3, board19); PA_LoadTiledBg(1, 1, bgscoreigs); PA_Init16cBg(1, 0); PA_16cText(1, 120, 10, 255, 192, "chris28ttttt [17k]", 1, 2, 100); // PA_LoadSpritePal(0, 1, (void*)pass_Pal); PA_3DProcess(); // Update sprites PA_WaitForVBL(); if (!ptn) { ptn = new Pointer(); } u16 gfx[6]; gfx[PASSBUTTON] = PA_3DCreateTex((void*)pass_Texture, 64, 32, TEX_256COL); PA_3DCreateSpriteFromTex(PASSBUTTON, gfx[PASSBUTTON], 64, 32, 2, 33, 164); PA_3DProcess(); // Update sprites PA_WaitForVBL(); // while (COND_PLAY_MOVE) { while(!(mode&BOARD_OBSERVE)) { ptn->move(); //add_move(ptn->xpointer, ptn->ypointer); if (mode&BOARD_SCORING) { // if (s->nbvariants) return 1; if (mode&BOARD_PLAYING) { if (!dead[ptn->xpointer][ptn->ypointer]) { char c = 'a'+ptn->xpointer; if (c>='i') c++; char s[10]; // sprintf(s, "%c%d", c, this->size-my); // owner->igs->send(s); } } else { if (0)//(mk == 1) event button remove(ptn->xpointer,ptn->ypointer, cur_board->b[ptn->xpointer][ptn->ypointer], !dead[ptn->xpointer][ptn->ypointer]); else { if (b[ptn->xpointer][ptn->ypointer] == EMPTY) dead[ptn->xpointer][ptn->ypointer] = dead[ptn->xpointer][ptn->ypointer] == 2? 0:2; } // cur_board->dead[mx][my] = !cur_board->dead[mx][my]; // refresh(); // redraw(); update_territory(); } } else if (b[ptn->xpointer][ptn->ypointer] == EMPTY) { if (mode&BOARD_PLAYING) { //IGS char s[10]; char c = 'a'+ptn->xpointer; if (c>='i') c++; //sprintf(s, "%c%d", c, this->size-my); //owner->igs->send(s); } else { // edit mode add_move(ptn->xpointer, ptn->ypointer); // refresh(); update_pos(); } } // sprintf(debug,"player : %d",cur_player); // PA_16cText(1, 10, 30, 255, 192, debug, 1, 2, 100); // refresh(); // update_pos(); } // PA_CreateSprite(0, 1, (void*)pass_Sprite, OBJ_SIZE_64X32, 1, 1, 1, 60); }
void CMenu::displayMenu(void) { u16 position_castle(36); s8 l_i; // Reset the background system PA_ResetBgSys(); // Initialize the text at the top and bottom screens PA_InitText(1,0); PA_Init16cBg(1, 1); //PA_Init16cBg(1, 1); //PA_InitCustomText(1, 0, PA_Text); //PA_InitText(0,0); PA_Init16cBg(0, 1); // Load the grass background at the top screen PA_EasyBgLoad(1, 2, grass); // Set the screens' brightness to white PA_SetBrightness(1, 31); PA_SetBrightness(0, 31); // Load the title background at the top screen PA_EasyBgLoad(1, 3, title); // Change the brightness of the top screen to neutral (fading) for (l_i = 31; l_i >= 0; l_i--) { PA_SetBrightness(1, l_i); PA_WaitForVBL(); PA_WaitForVBL(); } // Create the sprites for the two castles below the grass level PA_DualCreateSprite(SPRITE_NB_CASTLE1_PART1, (void*)topcastle_Sprite, OBJ_SIZE_64X64, 1, PALETTE_NB_CASTLE, 69, 192-position_castle); PA_DualCreateSprite(SPRITE_NB_CASTLE1_PART2, (void*)castle_Sprite, OBJ_SIZE_64X64, 1, PALETTE_NB_CASTLE, 69, 192+64-position_castle); PA_DualCreateSprite(SPRITE_NB_CASTLE2_PART1, (void*)topcastle_Sprite, OBJ_SIZE_64X64, 1, PALETTE_NB_CASTLE, 151, 192-position_castle); PA_DualCreateSprite(SPRITE_NB_CASTLE2_PART2, (void*)castle_Sprite, OBJ_SIZE_64X64, 1, PALETTE_NB_CASTLE, 151, 192+64-position_castle); // Display the castle sprites behind the grass PA_DualSetSpritePrio (SPRITE_NB_CASTLE1_PART1, 3); PA_DualSetSpritePrio (SPRITE_NB_CASTLE1_PART2, 3); PA_DualSetSpritePrio (SPRITE_NB_CASTLE2_PART1, 3); PA_DualSetSpritePrio (SPRITE_NB_CASTLE2_PART2, 3); // Move gradually the castle sprites above the grass for (position_castle = 36; position_castle <= 90; position_castle++) { PA_WaitForVBL(); PA_DualSetSpriteXY(SPRITE_NB_CASTLE1_PART1, 69, 192-position_castle); PA_DualSetSpriteXY(SPRITE_NB_CASTLE1_PART2, 69, 192+64-position_castle); PA_DualSetSpriteXY(SPRITE_NB_CASTLE2_PART1, 151, 192-position_castle); PA_DualSetSpriteXY(SPRITE_NB_CASTLE2_PART2, 151, 192+64-position_castle); } // Display the main menu PA_EasyBgLoad(0, 0, menu2); PA_SetBrightness(0, 0); // Wait for a player's action m_itemTouched = NO_MODE; while ((m_itemTouched == NO_MODE) || (m_itemTouched == MODE_TWOPLAYERS) || (m_itemTouched == BACK)) { m_itemTouched = itemTouched(); if (m_itemTouched == MODE_INSTRUCTIONS) displayInstructions(); if (m_itemTouched == MODE_TWOPLAYERS) { PA_DeleteBg (0, 0); PA_EasyBgLoad(0, 0, hotseat_wifi); } if (m_itemTouched == BACK) { PA_DeleteBg (0, 0); PA_EasyBgLoad(0, 0, menu2); } PA_WaitForVBL(); } // Delete the castle sprites PA_DualDeleteSprite(SPRITE_NB_CASTLE1_PART1); PA_DualDeleteSprite(SPRITE_NB_CASTLE1_PART2); PA_DualDeleteSprite(SPRITE_NB_CASTLE2_PART1); PA_DualDeleteSprite(SPRITE_NB_CASTLE2_PART2); // Load the empty bottom screen PA_EasyBgLoad(0, 3, bottomscreen); // Activate the Wifi if (m_itemTouched == MODE_WIFI) { PA_DeleteBg (0, 0); PA_EasyBgLoad(1, 2, opponentchoice); l_wifi.goToState(WIFI_STATE_ACTIVE); m_playerOrder = l_wifi.connection(); } // Fading to white at the top screen for (l_i = 0; l_i <=31; l_i++) { PA_SetBrightness(1, l_i); PA_WaitForVBL(); PA_WaitForVBL(); } // Start to play the music #ifndef DEBUG AS_SetMP3Loop(true); AS_SetMP3Volume(m_musicVolume); AS_MP3DirectPlay((u8*)sound9, (u32)sound9_size); #endif CGame l_game; // Main game object // Initialise the game object where m_itemTouched corresponds to the game mode l_game.initGame(m_musicVolume, m_cardSpeed, m_itemTouched, m_playerOrder); // Infinite loop to keep the program running bool finish = false; while(!finish) { // Play the game finish = l_game.play(&m_musicVolume, &m_cardSpeed); PA_WaitForVBL(); } // Stop the music #ifndef DEBUG AS_MP3Stop(); #endif }