/********************************************************** **Name: KeyScan **Function: Key scan **Input: none **Output: keyValue, key value **********************************************************/ u8 KeyScan(void) { u8 temp; u8 keyValue=0; temp=KeyRead(); if(temp!=C_KeyNone) { if(gb_KeyDownFlag==0) { gw_KeyDebounceTimer=50; gb_KeyDownFlag=1; gb_KeyValue=temp; } else if(gw_KeyDebounceTimer==0 && gb_KeyValue==temp) { gb_KeyDownFlag=2; //debounce } } else if(gb_KeyDownFlag==2) { keyValue=gb_KeyValue; //release gb_KeyDownFlag=0; } else { gb_KeyDownFlag=0; } return keyValue; }
///////////////////////////////////////////////////////////////////////// /// /// KeyProcess /// @param 无 /// @author xuliang<*****@*****.**> /// @date 2010-08-23 ////////////////////////////////////////////////////////////////////////// void KeyProcess(void) { BYTE ch, ret; if(KeyRead(&ch)) { if(KeyAnalyze(ch, &ret)) { KeyCmdDone(ret); } } }
void KeyScane(uint32_t Time) { if (Time - KeyCreatTrm >= KEY_CREATTRM_INTERVAL) { KeyCreatTrm = Time; KeyRead(); KeyProc(); } }
int scene_CommandMenu(int index, int lastAction) { char buffy[255]; u8 actioncursors[8] = { 16,35, 23,35, 16,37, 23,37 }; //cursor positions int bfrInt = 0; sprintf(buffy, strBattleWhatToDo, fighters_This(index)); vwClearLine(1,8); vwClearLine(1,12); vwWriteG(0,4,buffy); scene_SetLine(actioncursors[lastAction*2],1,actioncursors[(lastAction*2)+1],255,15); btlWindowShifts[2] = 160; while(1) { DoVBlank(); KeyRead(); if((Trg & KEY_LEFT) || (Trg & KEY_RIGHT)) { scene_SetLine(actioncursors[lastAction*2],1,actioncursors[(lastAction*2)+1],319,15); bfrInt = lastAction; lastAction = wrap(lastAction + key_tri_horz(), 0, 4); if(lastAction == 3 && ThisBattle.trainer) lastAction = bfrInt; scene_SetLine(actioncursors[lastAction*2],1,actioncursors[(lastAction*2)+1],255,15); } if((Trg & KEY_UP) || (Trg & KEY_DOWN)) { scene_SetLine(actioncursors[lastAction*2],1,actioncursors[(lastAction*2)+1],319,15); bfrInt = lastAction; lastAction = wrap(lastAction + (key_tri_vert()*2), 0, 4); if(lastAction == 3 && ThisBattle.trainer) lastAction = bfrInt; scene_SetLine(actioncursors[lastAction*2],1,actioncursors[(lastAction*2)+1],255,15); } if(Trg & A_BUTTON) { scene_SetLine(actioncursors[lastAction*2],1,actioncursors[(lastAction*2)+1],319,15); break; } } return lastAction+1; }
/** \brief Edited version of ShowDexEntry. */ void ShowNewlyCaught(u16 index) { signed int omgdutch; char data[64]; int dexnum = GetDexNumber(index); BUP buh; u8 flasher = 0, flashtimer = 0; AGBPrintf("ShowNewlyCaught: showing species #%d...\n", index); CleanUpCrap(); //DmaArrayCopy(dexinfo1Tiles, MEM_VRAM + 0x0000); //DmaArrayCopy(dexinfo1Pal, MEM_PAL_BG + 0x0000); //DmaCopy(dexinfo1Map, MEM_VRAM + 0xE800, 1280 ); buh.src_len = 32; buh.src_len = 1; buh.dst_bpp = 4; buh.dst_ofs = 0; OamBak[1].HPos = 208; OamBak[1].VPos = 16; OamBak[1].Size = 1; OamBak[1].CharNo = 64; OamBak[1].Pltt = 1; OamBak[2].HPos = 208; OamBak[2].VPos = 48; OamBak[2].Size = 1; OamBak[2].CharNo = 128; OamBak[2].Pltt = 4; OamBak[3].HPos = 208; OamBak[3].VPos = 32; OamBak[3].Size = 1; OamBak[3].CharNo = 132; OamBak[3].Pltt = 5; *(u16*)0x05000222 = 0x318C; SetupPokemonSprite(0); OamBak[0].HPos = 8; OamBak[0].VPos = 8; OamBak[0].HFlip = 1; REG_BG1HOFS= 8; REG_BG1VOFS= 0; REG_BG2HOFS= 0; REG_BG2VOFS= 0; REG_BG3HOFS= 0; REG_BG3VOFS= 0; vwSetLine(11,20,2,96,15); vwSetLine(11,20,4,160,15); vwSetLine(11,20,6,224,15); vwSetLine(1,30,11,288,15); vwSetLine(1,30,13,352,15); vwSetLine(1,30,15,416,15); vwBlackTransparentLUT(); vwClear(0); sprintf(data, "No.%d - %s", dexnum, (char*)GetPokemonName(index)); vwWrite(0,0,data); sprintf(data, "%s "POKEMON"\nHt: %ddm, Wt: %dhg", (char*)GetPokemonSpecies(dexnum), DexEntries[dexnum].height, DexEntries[dexnum].weight); vw_SetSmall(); vwWrite(0,18,data); vw_SetBig(); vwWrite(1,6<<3,(char*)GetPokemonDescription(dexnum)); LoadPokemonPic(index,0,MEM_VRAM_OBJ,pal_obj_bank[0],0); BitUnPack((void*)PokePrints[index], (void*)MEM_VRAM_OBJ + 0x800, &buh); PokeDex_LoadType(BaseStats[index].Type1, 0); if(BaseStats[index].Type2 != BaseStats[index].Type1) PokeDex_LoadType(BaseStats[index].Type2, 1); else PokeDex_LoadType(tpNormal, 1); for(omgdutch=24; omgdutch >= 0; omgdutch--) { BG1MAP[omgdutch+0x241] = BG1MAP[omgdutch+0x242]; BG1MAP[omgdutch+0x261] = BG1MAP[omgdutch+0x262]; } *(u16*)0x05000016 = regflash[flasher]; FadeIn(); while(1) { DoVBlank(); KeyRead(); flashtimer++; if(flashtimer == 7) { flashtimer=0; flasher++; if(flasher == 6) flasher = 0; *(u16*)0x05000016 = regflash[flasher]; } if(Trg & B_BUTTON) { FadeOut(); vwNormalLUT(); ClearOamBak(); return; } } }
/** \brief Displays the Pokedex entry for the given species. Assumes it's at least seen, and allows switching to the other page and browsing to the other seen species. */ void ShowDexEntry(int index) { BUP buh; int blendnow = 0, blendi = 0, page = 0, flavorpage = 0; int upidx, dnidx; int dexnum = GetDexNumber(index); ClearOamBak(); CleanUpCrap(); REG_BG1CNT |= BG_SIZE1; //DmaArrayCopy(dexinfo1Tiles, MEM_VRAM + 0x0000); //DmaArrayCopy(dexinfo1Pal, MEM_PAL_BG + 0x0000); //DmaArrayCopy(dexinfo1Map, MEM_VRAM + 0xE800); //*(u16*)0x05000016 = dexinfo1Pal[3]; //DmaClear(0x318C318C, MEM_PAL_OBJ + 0xE0, 32); //*(u16*)0x050002E0 = 0x7FFF; buh.src_len = 32; buh.src_bpp = 1; buh.dst_bpp = 4; buh.dst_ofs = 0; OamBak[1].HPos = 208; OamBak[1].VPos = 16; OamBak[1].Size = 1; OamBak[1].CharNo = 64; OamBak[1].Pltt = 1; OamBak[2].HPos = 208; OamBak[2].VPos = 48; OamBak[2].Size = 1; OamBak[2].CharNo = 128; OamBak[2].Pltt = 4; OamBak[3].HPos = 208; OamBak[3].VPos = 32; OamBak[3].Size = 1; OamBak[3].CharNo = 132; OamBak[3].Pltt = 5; *(u16*)(MEM_PAL+0x222) = 0x318C; OamBak[4].Pltt = 7; OamBak[4].CharNo = 0; OamBak[4].Size = 3; OamBak[4].HPos = -80; OamBak[4].VPos = 8; OamBak[4].AffineMode = 1; OamBak[4].AffineParamNo_L = 1; OamBak[5].Pltt = 7; OamBak[5].CharNo = 160; OamBak[5].Size = 3; OamBak[5].HPos = -80; OamBak[5].VPos = 8; OamBak[5].AffineMode = 1; OamBak[5].AffineParamNo_L = 2; SetupPokemonSprite(0); OamBak[0].HPos = 8; OamBak[0].VPos = 8; OamBak[0].HFlip = 1; REG_BG1HOFS= 8; REG_BG1VOFS= 0; REG_BG2HOFS= 0; REG_BG2VOFS= 0; REG_BG3HOFS= 0; REG_BG3VOFS= 0; vwSetLine(11,20,2,96,15); vwSetLine(11,20,4,160,15); vwSetLine(11,20,6,224,15); vwSetLine(1,30,11,288,15); vwSetLine(1,30,13,352,15); vwSetLine(1,30,15,416,15); //DmaCopy((u8*)TrainerPics[CardPics[MyPlayer.gender]<<1], MEM_VRAM_OBJ + 0x1400, 0x800); if(MyPlayer.gender) LZ77UnCompVram((u8*)TrainerPics[tpDani<<1], (u16*)MEM_VRAM_OBJ + 0xA00); else LZ77UnCompVram((u8*)TrainerPics[tpDanny<<1], (u16*)MEM_VRAM_OBJ + 0xA00); vwBlackTransparentLUT(); RedrawMonData: if(GETBIT(MyDex.caught,index)) AGBPrint("Seen this one.\n"); vwSetLine(0,20,18, 608, 15); PokeDex_ShowData(index,page,flavorpage); LoadPokemonPic(index,0,MEM_VRAM_OBJ,pal_obj_bank[0],0); AGBPrintf("Print at 0x%x.\n",PokePrints[index]); BitUnPack((void*)PokePrints[index], (void*)MEM_VRAM_OBJ + 0x800, &buh); PokeDex_LoadType(BaseStats[index].Type1, 0); if(BaseStats[index].Type2 != BaseStats[index].Type1) PokeDex_LoadType(BaseStats[index].Type2, 1); else PokeDex_LoadType(tpNormal, 1); OamBak[4].AffineParam = 0x14+ DexEntries[dexnum].mscale; OamBak[5].AffineParam = 0x0; OamBak[6].AffineParam = 0x0; OamBak[7].AffineParam = 0x14+DexEntries[dexnum].mscale; OamBak[8].AffineParam = 0x14+DexEntries[dexnum].tscale; OamBak[9].AffineParam = 0x0; OamBak[10].AffineParam = 0x0; OamBak[11].AffineParam = 0x28+DexEntries[dexnum].tscale; OamBak[4].VPos = 8 + DexEntries[dexnum].toffset; OamBak[5].VPos = 4 + 32 - (32*0x10000/(DexEntries[dexnum].tscale+0x14)>>8); if(blendnow==1) { REG_BLDCNT = BLD_BOT(BLD_BG1) | BLD_STD | BLD_OBJ | BLD_BG0; for(blendi = 0; blendi < 0x11; blendi += DEXFADESPEED) { REG_BLDALPHA = ((0x10 - blendi) << 8) + blendi; DoVBlank(); } } else { FadeIn(); } upidx = wrap(dexnum-1, 1, DexList[0]+1); while(!GETBIT(MyDex.seen, DexList[upidx])) upidx = wrap(upidx-1, 1, DexList[0]+1); dnidx = wrap(dexnum+1, 1, DexList[0]+1); while(!GETBIT(MyDex.seen, DexList[dnidx])) dnidx = wrap(dnidx+1, 1, DexList[0]+1); sndPlayCry(index,60); while(1) { DoVBlank(); KeyRead(); if(Trg & A_BUTTON) sndPlayCry(index,60); if(Cont & U_KEY) { index = DexList[upidx]; dexnum = GetDexNumber(index); blendnow = 1; goto FadeMon; } if(Cont & D_KEY) { index = DexList[dnidx]; dexnum = GetDexNumber(index); blendnow = 1; goto FadeMon; } if(Trg & B_BUTTON) { FadeOut(); vwNormalLUT(); ClearOamBak(); REG_DISPCNT |= DCNT_BG0; REG_BG1HOFS = 8; return; } if((Trg & R_KEY) && (page == 0)) { OamBak[0].HPos = -80; OamBak[1].HPos = -80; OamBak[2].HPos = -80; OamBak[3].HPos = -80; REG_DISPCNT &= ~DCNT_BG0; for(blendi = 1; blendi < 9; blendi++) { DoVBlank(); REG_BG1HOFS = 8 + (blendi*32); } PokeDex_ShowData(index,1,flavorpage); REG_DISPCNT |= DCNT_BG0; OamBak[4].HPos = 136; OamBak[5].HPos = 176; page = 1; } if((Trg & L_KEY) && (page == 1)) { OamBak[4].HPos = -80; OamBak[5].HPos = -80; REG_DISPCNT &= ~DCNT_BG0; for(blendi = 8; blendi > 0; blendi--) { DoVBlank(); REG_BG1HOFS = 8 + ((blendi-1)*32); } OamBak[0].HPos = 8; OamBak[1].HPos = 208; OamBak[2].HPos = 208; OamBak[3].HPos = 208; PokeDex_ShowData(index, 0, flavorpage); REG_DISPCNT |= DCNT_BG0; page = 0; } if(Trg & KEY_SELECT && page == 0 && *DexEntries[dexnum].text2) { flavorpage ^= 1; PokeDex_ShowData(index, 0, flavorpage); } } FadeMon: REG_BLDCNT = BLD_BOT(BLD_BG2) | BLD_STD | BLD_OBJ | BLD_BG0; for(blendi = 0; blendi < 0x10; blendi+=DEXFADESPEED) { REG_BLDALPHA = (blendi << 8) + (0x10 - blendi); DoVBlank(); } flavorpage = 0; //DmaArrayCopy(dexinfo1Map, MEM_VRAM + 0xE800); goto RedrawMonData; }
/** \brief Displays the list of all known species. Calls ShowDexEntry when the user wants to. */ void openPokeDex() { int cX = 0; int cY = 0; int cursor = (cX * 5) + cY; int scroll = 0; int species = 0; char daah[32]; Redraw: vwBlackTransparentLUT(); CleanUpCrap(); ClearOamBak(); DmaArrayCopy(dexlist_gsPal, MEM_PAL_BG + 0x0000); DmaArrayCopy(dexlist_gsTiles, MEM_VRAM + 0x0000); DmaArrayCopy(dexlist_gsMap, MEM_VRAM + 0xE000); REG_BG0CNT = BG_4BPP | BG_SIZE0 | BG_PRIO(0) | 31 << BG_SBB_SHIFT | 2 << BG_CBB_SHIFT; REG_BG1CNT = BG_4BPP | BG_SIZE0 | BG_PRIO(1) | 28 << BG_SBB_SHIFT | 0 << BG_CBB_SHIFT; REG_BG2CNT = BG_4BPP | BG_SIZE2 | BG_PRIO(2) | 29 << BG_SBB_SHIFT | 0 << BG_CBB_SHIFT; REG_DISPCNT = DCNT_MODE0 | DCNT_OBJ | DCNT_BG0 | DCNT_BG1 | DCNT_BG2 | DCNT_OBJ_1D; pal_bg_mem[0] = 0x7FFF; REG_BG2VOFS = 23; REG_BG2HOFS = 21; vwWhiteTransparentLUT(); vw_SetSmall(); vwWrite(4,129,"¥PICK ¢OK £CANCEL °±²OPTIONS"); vwSetLine(0,20,0, 608, 15); vw_SetBig(); vwSetLine(8,20,17, 96, 15); vwSetLine(8,20,18,128, 15); vwBlackTransparentLUT(); PokeDex_WriteList(scroll, cursor, 1); FadeIn(); REG_BLDCNT = BLD_BUILD(BLD_OBJ, BLD_BG2 | BLD_BD, 0); REG_BLDALPHA = BLDA_BUILD(8, 8); while(1) { species = DexList[cursor + scroll + 1]; DoVBlank(); KeyRead(); if(Trg & A_BUTTON) { if(GETBIT(MyDex.seen, DexList[cursor+scroll]) == 0) { //error buzz? } else { FadeOut(); ShowDexEntry(DexList[cursor+scroll]); goto Redraw; } } if(Trg & B_BUTTON) { break; } if(Trg & U_KEY) { if (cX == 0) { if(scroll > 0) { scroll--; } } else cX--; cursor = (cX * 5) + cY; PokeDex_WriteList(scroll, cursor, 0); } else if(Trg & D_KEY) { if (cX == 2) { if(scroll < 42) { scroll++; } } else cX++; cursor = (cX * 5) + cY; PokeDex_WriteList(scroll, cursor, 0); } else if(Trg & L_KEY) { cY--; if(cY == -1) { cY = 4; cX--; if(cX == -1) { scroll--; cX = 0; if(scroll == -1) { scroll = 0; cY = 0; } } } cursor = (cX * 5) + cY; PokeDex_WriteList(scroll, cursor, 0); } else if(Trg & R_KEY) { cY++; if(cY == 5) { cY = 0; cX++; if (cX == 3) { scroll++; cX = 2; } } cursor = (cX * 5) + cY; PokeDex_WriteList(scroll, cursor, 0); } else if(Trg & KEY_SELECT) { PokeSearch(); goto Redraw; } } FadeOut(); vwNormalLUT(); ClearOamBak(); ResetBackgrounds(); }
void PokeSearch() { int i, cursor = 0, color = 0, type1 = 0, type2 = 0, letter = 0, dexid = PokeSearchGetDexID(), sort = 0; signed int j; u16 *SortSourceDex = (u16*)PokeDexes[0]; CleanUpCrap(); ClearOamBak(); DmaArrayCopy(dexfilterTiles, MEM_VRAM + 0x0000); DmaArrayCopy(dexfilterPal, MEM_PAL_BG + 0x0000); DmaArrayCopy(dexfilterMap, MEM_VRAM + 0xE800); vwClear(1); vwNormalLUT(); vwSetLine(15,16,2,96,15); vwSetLine(15,16,4,160,15); vwSetLine(15,16,6,224,15); vwSetLine(15,16,8,288,15); vwSetLine(15,16,10,352,15); vwSetLine(15,16,12,416,15); PokeSearchDrawStuff(cursor, dexid, sort, letter, color, type1, type2); while(1) { DoVBlank(); KeyRead(); if(Trg & KEY_UP || Trg & KEY_DOWN) { cursor = wrap(cursor + key_tri_vert(), 0, (dexid == 2) ? 6 : 2); PokeSearchDrawStuff(cursor, dexid, sort, letter, color, type1, type2); } if(Trg & KEY_LEFT || Trg & KEY_RIGHT) { switch(cursor) { case 0: dexid = wrap(dexid + key_tri_horz(), 0, 3); break; case 1: sort = wrap(sort + key_tri_horz(), 0, 2); break; case 2: letter = wrap(letter + key_tri_horz(), 0, 27); break; case 3: type1 = wrap(type1 + key_tri_horz(), 0, 19); if(type1 == 10) type1 += key_tri_horz(); break; case 4: type2 = wrap(type2 + key_tri_horz(), 0, 19); if(type2 == 10) type2 += key_tri_horz(); break; case 5: color = wrap(color + key_tri_horz(), 0, 11); break; } PokeSearchDrawStuff(cursor, dexid, sort, letter, color, type1, type2); } if(Trg & B_BUTTON) { return; } if(Trg & A_BUTTON) { if(dexid==2 && (color == 0 && type1 == 0 && type2 == 0 && letter == 0)) { AGBPrint("PokeSearch: No filters specified...\n"); dexid = PokeSearchGetDexID(); } if(dexid==2) //didn't get caught on not filtering? { DmaArrayClear(0, FilteredDex); j = 1; SortSourceDex = (u16*)PokeDexes[sort * 2]; for(i = 1; i < SortSourceDex[0]; i++) { int takeit = 1; if(!GETBIT(MyDex.seen, SortSourceDex[i])) takeit = 0; if(color && BaseStats[SortSourceDex[i]].Color != color-1) takeit = 0; if(type1 && BaseStats[SortSourceDex[i]].Type1 != type1-1) takeit = 0; if(type2 && BaseStats[SortSourceDex[i]].Type2 != type2-1) takeit = 0; if(letter && PokeNames[SortSourceDex[i]][0] != 'A'+letter-1) takeit = 0; if(takeit) { FilteredDex[j] = SortSourceDex[i]; j++; } } if(j == 1) { AGBPrint("PokeSearch: nothing found.\n"); return; } FilteredDex[0] = j; DexList = (void*)FilteredDex; AGBPrint("PokeSearch: Pokédex set to Filtered mode.\n"); return; } else { if(sort == 1) { AGBPrintf("PokeSearch: alphabetical sort? Okay.\n"); DmaArrayClear(0, FilteredDex); j = 1; SortSourceDex = (u16*)PokeDexes[2]; for(i = 1; i < SortSourceDex[0]; i++) { if(GETBIT(MyDex.seen, SortSourceDex[i])) { FilteredDex[j] = SortSourceDex[i]; j++; } } FilteredDex[0] = j; DexList = (void*)FilteredDex; } else { DexList = (void*)PokeDexes[dexid]; AGBPrintf("PokeSearch: Pokédex set to #%d.\n",dexid); } return; } } } }
/* Function to choose a move in a battle */ int scene_FightMenu(int fighterIndex) { u8 moveCursors[8] = { 1,55, 10,55, 1,57, 10,57 }; int lastmove = fighters[fighterIndex].lastused; AGBPrintf("scene_FightMenu(%d)\n", fighterIndex); vwClearLine(1,16); vwClearLine(1,20); vwClearLine(1,24); vwClearLine(1,28); vw_SetSmall(); // Write attack names to the screen vwWriteG(0,8, moveNames[GetMonsterStats(fighters[fighterIndex].mon, pMove1)]); vwWriteG(0,10,moveNames[GetMonsterStats(fighters[fighterIndex].mon, pMove2)]); vwWriteG(0,12,moveNames[GetMonsterStats(fighters[fighterIndex].mon, pMove3)]); vwWriteG(0,14,moveNames[GetMonsterStats(fighters[fighterIndex].mon, pMove4)]); // Make the font bigger vw_SetBig(); // Draw cursor scene_SetLine(moveCursors[lastmove*2],1,moveCursors[(lastmove*2)+1],255,15); // Shows type and PP scene_DrawMoveData(fighters[fighterIndex].mon, lastmove); btlWindowShifts[2] = 320; while(1) { DoVBlank(); KeyRead(); // Move cursor sideways if((Trg & KEY_LEFT) || (Trg & KEY_RIGHT)) { scene_SetLine(moveCursors[lastmove*2], 1, moveCursors[(lastmove*2)+1], 319, 15); lastmove = wrap(lastmove + key_tri_horz(), 0, 4); scene_SetLine(moveCursors[lastmove*2], 1, moveCursors[(lastmove*2)+1], 255, 15); scene_DrawMoveData(fighters[fighterIndex].mon, lastmove); } // Move cursor up- and downwards if((Trg & KEY_UP) || (Trg & KEY_DOWN)) { scene_SetLine(moveCursors[lastmove*2],1,moveCursors[(lastmove*2)+1],319,15); lastmove = wrap(lastmove + (key_tri_vert()*2), 0, 4); scene_SetLine(moveCursors[lastmove*2],1,moveCursors[(lastmove*2)+1],255,15); scene_DrawMoveData(fighters[fighterIndex].mon, lastmove); } if(Trg & A_BUTTON) { // If move is != 0 if(GetMonsterStats(fighters[0].mon, pPP1 + lastmove)) { fighters[0].lastused = lastmove; scene_SetLine(moveCursors[lastmove*2],1,moveCursors[(lastmove*2)+1],319,15); return lastmove; } // Else do nothing else { //Beep! } } else if(Trg & B_BUTTON) { scene_SetLine(moveCursors[lastmove*2],1,moveCursors[(lastmove*2)+1],319,15); btlWindowShifts[2] = 160; return -1; } } }
void scene_StartWildBattle() { // Which Pokémon will join the battle? int chosenPkmn = 0; if(MyPlayer.gender == 0) { DmaArrayCopy(dannybackPal, MEM_PAL_OBJ + 0x40); DmaArrayCopy(dannybackTiles, MEM_VRAM_OBJ + 0x4000); } else { DmaArrayCopy(danibackPal, MEM_PAL_OBJ + 0x40); DmaArrayCopy(danibackTiles, MEM_VRAM_OBJ + 0x4000); } #ifdef WITH_SHIRTCOLORS *(u16*)0x0500025C= shirtcolors[(MyPlayer.shirtColor*2) + ((MyPlayer.gender%2)*16)]; *(u16*)0x0500025E = shirtcolors[(MyPlayer.shirtColor*2)+1+((MyPlayer.gender%2)*16)]; #endif if(demo==1) //are we running a demo? { DmaArrayCopy(demobackPal, MEM_PAL_OBJ + 0x40); DmaArrayCopy(demobackTiles, MEM_VRAM_OBJ + 0x4000); } //char buffy[255]; int i=0; OamBak[0].CharNo = 512; OamBak[0].Pltt = 2; OamBak[0].HPos = 24; OamBak[0].VPos = 54; OamBak[0].Priority = 1; //sndPlaySound(6,SOUND_NORESTART); fighters_Initialize(1,0); battle_SendOut(1,0,0); OamBak[1].Priority = 1; battle_OpenAnimation(); battle_SendOut(1,0,SEND_SCROLLCRY); btlWindowShifts[1] = 0; scene_BuildPlayerPartyWin(); // Displays message until A or B is pressed btlsays(strBattleFooAppeared, fighters_This(1)); while(!(Trg & KEY_A || Trg & KEY_B)) { KeyRead(); DoVBlank(); } //KAWA - This part is for the demo game. if(GetPartySize(&MyParty)==0) { OamBak[0].CharNo = 832; btlsays(strBattleDemoNoParty); ThisBattle.decision = 10; return; } // </demo> //Runaway hack if( demo == 0 && Cont & KEY_A && Cont & KEY_B) { int run = battle_Run(i,0); if(run > 0) { ThisBattle.decision = 3; return; } } if(demo==1) { btlsays(strBattleDemoSendOut, MyParty[0].Personal.Nickname); } else { // Check for fainted Pokémon. // If all of them fainted, return while( MyParty[chosenPkmn].Status.CurrentHP == 0 && chosenPkmn < GetPartySize()) chosenPkmn++; if(chosenPkmn >= GetPartySize()) { AGBPrintf("*scene_StartWildBattle: chosenPkmn has an invalid value!"); return; } btlsays(strBattleIChooseYou, MyParty[chosenPkmn].Personal.Nickname); //fighters_This(0)); } for(i = 0; i < 64; i++) { DoVBlank(); OamBak[0].HPos = 24 - i*2; if(i < 48) OamBak[0].CharNo = 512 + (64 * (i/10)); } // OamBak[0].CharNo = 0; // OamBak[0].Pltt = 0; // OamBak[0].HPos = 24; fighters_Initialize(0,0); battle_SendOut(0,chosenPkmn,SEND_ALL); ThisBattle.duringBattle = 1; ThisBattle.trainer = 0; ThisBattle.runCommand = 0; ThisBattle.doublebattle = 0; ThisBattle.internalbattle = 1; ThisBattle.decision = 0; ThisBattle.roamer = 0; }
void TitleScreen(int skip) { int i, f = 0; int t = 0, buildstep = 0,buildt = 0; int particleX[MAXTITLEPARTICLES]; int particleY[MAXTITLEPARTICLES]; int particleS[MAXTITLEPARTICLES]; int particleT[MAXTITLEPARTICLES]; ClearOamBak(); REG_BG3CNT |= 1 << BG_CBB_SHIFT; DmaArrayCopy(titlebackPal, MEM_PAL_BG + 0x0000); DmaArrayCopy(titlebackTiles, MEM_VRAM + 0x4000); DmaArrayCopy(titlebackMap, MEM_VRAM + 0xf000); DmaArrayCopy(titlemonTiles, MEM_VRAM + 0x0000); DmaArrayCopy(titlemonMap, MEM_VRAM + 0xe800); for(i = 0; i < MAXTITLEPARTICLES; i++) { particleX[i] = rrand(32) * 8; particleY[i] = 170; particleS[i] = rrand(3) + 1; particleT[i] = rrand(2); } REG_BG0HOFS = 0; REG_BG0VOFS = -2; REG_BG1HOFS = 0; REG_BG1VOFS = -32; REG_BG2HOFS = 0; REG_BG2VOFS = 0; REG_BG3HOFS = 0; REG_BG3VOFS = 0; DmaArrayCopy(titlelogoTiles, MEM_VRAM + 0x8000); DmaArrayCopy(titlelogoPal, MEM_PAL_BG + 0x0020); for(i=0;i<320;i++) BG0MAP[i] = titlelogoMap[i] | 0x1000; DmaArrayCopy(titleflavorTiles, MEM_VRAM_OBJ + 0x0000); DmaArrayCopy(titleflavorPal, MEM_PAL_OBJ + 0x0000); DmaArrayCopy(titletextsTiles, MEM_VRAM_OBJ + 0x0800); DmaArrayCopy(titleparticlesTiles, MEM_VRAM_OBJ + 0x0c00); DmaArrayCopy(titleparticlesPal, MEM_PAL_OBJ + 0x0020); OamBak[0].Size = 3; OamBak[0].Shape = 1; OamBak[0].HPos = 63; OamBak[0].VPos = 55; OamBak[0].CharNo = 0; OamBak[0].ObjMode = 1; OamBak[1].Size = 3; OamBak[1].Shape = 1; OamBak[1].HPos = 63+64; OamBak[1].VPos = 55; OamBak[1].CharNo = 32; OamBak[1].ObjMode = 1; for(i=0; i<7; i++) { OamBak[2+i].Size = 1; OamBak[2+i].Shape = 1; OamBak[2+i].Pltt = 0; OamBak[2+i].CharNo = 64 + (i<<2); } for(i=0; i<7; i++) { OamBak[2+i].HPos = 8 + (i<<5); OamBak[2+i].VPos = 152; } for(i=0; i<2; i++) { OamBak[6+i].VPos = 152; OamBak[6+i].HPos = 169 + (i<<5); } REG_DISPCNT = DCNT_MODE0 | DCNT_BG2 | DCNT_BG3; REG_BLDCNT = BLD_WHITE | BLD_BG3; if(skip) { REG_DISPCNT = DCNT_MODE0 | DCNT_OBJ | DCNT_BG0 | DCNT_BG1 | DCNT_BG2 | DCNT_BG3 | DCNT_OBJ_1D; REG_BLDCNT = 0; buildstep = 3; REG_BG1VOFS = 0; } sndPlaySound(80,SOUND_NORESTART); while(1) { DoVBlank(); KeyRead(); if(Trg & A_BUTTON) break; if(Trg & START_BUTTON) break; if(buildstep == 0) { REG_BLDY = 16 - (buildt>>2); buildt++; if(buildt==64) { REG_DISPCNT |= DCNT_BG1; buildstep++; buildt=0; } } else if(buildstep == 1)
void sndTest() { char buf[80]; // int i, vol, numchans; int selectedTrack = 0; //MusicPlayerTrack * t; LoadFrame(); DrawFrame(1,28,1,18); vwClear(1); vwWrite(0,0,"\x80\x1A\x80\x1B"); sprintf(buf, "%d. %s",selectedTrack,songNames[selectedTrack]); vwWrite(24,0,buf); /* vwWrite(0,16,"Song header"); vwWrite(80,16,"Not playing"); vwWrite(0,32,"Tracks"); vwWrite(0,48,"Mix channels"); vwWrite(0,64,"Volume"); */ vwSetLine(3,24,2,96,15); vwSetLine(3,24,6,160,15); vwSetLine(3,24,8,224,15); vwSetLine(3,24,10,288,15); vwSetLine(3,24,12,352,15); vw_SetSmall(); vwWrite(4,129,"¦SELECT ¢PLAY £STOP"); vwSetLine(2,18,16, 608, 15); vw_SetBig(); while(1) { DoVBlank(); KeyRead(); if(Trg & KEY_START) { *(u16*)0x05000000 = 0x7FFF; sndWaitForCry(315, 30); *(u16*)0x05000000 = 0x0000; } if(Trg & KEY_SELECT) sndWaitForCry(25, 30); //sndPlayFanfare(12); if((Trg & L_KEY) || (Trg & R_KEY)) { selectedTrack = wrap(selectedTrack + key_tri_horz(), 0, (const)( sizeof(songNames) / sizeof(const char*) ) ); vwClearLine(1,0); vwClearLine(1,1); vwWrite(0,0,"\x80\x1A\x80\x1B"); sprintf(buf, "%d. %s",selectedTrack,songNames[selectedTrack]); vwWrite(24,0,buf); } if(Trg & A_BUTTON) { sndPlaySound(selectedTrack, 0); //sprintf(buf, "0x%08x", (unsigned int)mplay_table[0].ma->song); //vwWrite(80,16, buf); } if(Trg & B_BUTTON) { if(sndIsMusicPlaying()) sndPauseSound(); else SoftReset(); } } }
void rt_thread_entry_Door(void* parameter) { //modbus µØÖ·ÊÇ10 PB8=1;//´ò¿ª¼ÌµçÆ÷ usSRegHoldBuf[20]=0x00;//¿ØÖƼ̵çÆ÷¼Ä´æÆ÷ΪĬÈÏÖµ¼·²»¿ªÒ²²»¹Ø usSRegHoldBuf[22]=0x01;//¼ÌµçÆ÷״̬´ò¿ª while(1) { if(PB10==0) //ÃÅ´Å״̬ { usSRegHoldBuf[21]=0x01; //ÃÅ´Å״̬ } else if(PB10==1) { usSRegHoldBuf[21]=0x00; //ÃÅ´Å״̬ } if(usSRegHoldBuf[20]==0x1)//Èç¹û485¿ØÖÆÏ { PD15=0;//ָʾ¼ÌµçÆ÷״̬ PB8=1;//´ò¿ª¼ÌµçÆ÷ usSRegHoldBuf[22]=0x01; //¼ÌµçÆ÷״̬ usSRegHoldBuf[20]=0; //¹éλ } else if (usSRegHoldBuf[20]==0x2) { PD15=1;//ָʾ¼ÌµçÆ÷״̬ PB8=0;//¹Ø±Õ¼ÌµçÆ÷ usSRegHoldBuf[22]=0x00; //¼ÌµçÆ÷״̬ usSRegHoldBuf[20]=0; //¹éλ } KeyRead(); KeyProc(); rt_thread_delay(50); // Ïß³ÌCPUÖ÷¶¯Èóö } }