static void wifi_cleanup(void) { if (listen_socket >= 0) closesocket(listen_socket); #ifdef _WIN32 // if any, do something after close socket // WSA Cleanup #else Wifi_DisconnectAP(); Wifi_DisableWifi(); #endif }
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(); } }
// note: int execv(const char *path, char *const argv[]); // - where the array of strings is terminated with a null string // - i.e. this is a bit different for now int execz(const char* filename, int argc, const char** argv) { struct stat st; char filePath[MAXPATHLEN * 2]; int pathLen; const char* args[1]; int i; if (stat (filename, &st) < 0) { return 1; } if (argc <= 0 || !argv) { // Construct a command line if we weren't supplied with one if (!getcwd (filePath, MAXPATHLEN)) { return 2; } pathLen = strlen (filePath); strcpy (filePath + pathLen, filename); args[0] = filePath; argv = args; } // shutdown sound subsystem // note: EffectCancelAll seems to fail to stop // the current sample mmEffectCancelAll(); mmStop(); while (mmActive()) { swiWaitForVBlank(); } // shutdown network subsystem Wifi_DisconnectAP(); Wifi_DisableWifi(); // wait a bit: race condition?? for (i = 0 ; i < 42 ; i++) { swiWaitForVBlank(); } return runNds (load_bin, load_bin_size, st.st_ino, false, true, argc, argv); }
int main(int argc, char *argv[]) { int rc; defaultExceptionHandler(); consoleDemoInit(); irqInit(); irqEnable(IRQ_VBLANK); if(fatInitDefault() != 1) { return -1; } arm9_wifiConnect(); rc = test_main(); Wifi_DisconnectAP(); Wifi_DisableWifi(); return rc; }
void disableNifi() { Wifi_DisableWifi(); nifiEnabled = false; }
//--------------------------------------------------------------------------------- int loadNDS(int socket, u32 remote) { //--------------------------------------------------------------------------------- int len; int i=0; ioctl(socket,FIONBIO,&i); len = recvall(socket,__NDSHeader,512,0); if (len != 512) { kprintf("Error reading header.\n"); return 1; } int arm7dest = __NDSHeader->arm7destination; int arm7size = __NDSHeader->arm7binarySize; int arm9dest = __NDSHeader->arm9destination; int arm9size = __NDSHeader->arm9binarySize; volatile int response = 0; if (arm9dest + arm9size > (int)_start) response = 1; if (arm7dest >= 0x02000000 && arm7dest < 0x03000000 && arm7dest + arm7size > (int)_start) response = 2; send(socket,(int *)&response,sizeof(response),0); if(response) return 1; kprintf("Reading arm7 binary: "); if (progressRead(socket,(char *)memUncached((void*)0x02000000),arm7size)) { kprintf("\nReceive error.\n"); return 1; } fifoSendValue32(FIFO_USER_01,1); while(!fifoCheckValue32(FIFO_USER_01)) { swiIntrWait(1,IRQ_FIFO_NOT_EMPTY); } fifoGetValue32(FIFO_USER_01); kprintf("Reading arm9 binary: "); if(progressRead(socket,(char *)arm9dest,arm9size)) { kprintf("\nReceive error.\n"); return 1; } volatile int cmdlen=0; char *cmdline; if (arm9size != 0){ cmdline = (char*)(arm9dest+arm9size); } else { cmdline = (char*)(arm7dest+arm7size); } len = recvall(socket,(char*)&cmdlen,4,0); if (cmdlen) { len = recvall(socket,cmdline,cmdlen,0); __system_argv->argvMagic = ARGV_MAGIC; __system_argv->commandLine = cmdline; __system_argv->length = cmdlen; __system_argv->host = remote; } Wifi_DisableWifi(); DC_FlushAll(); REG_IPC_SYNC = 0; fifoSendValue32(FIFO_USER_01,2); fifoSendValue32(FIFO_USER_01,__NDSHeader->arm9executeAddress); irqDisable(IRQ_ALL); REG_IME = 0; //clear out ARM9 DMA channels for (i=0; i<4; i++) { DMA_CR(i) = 0; DMA_SRC(i) = 0; DMA_DEST(i) = 0; TIMER_CR(i) = 0; TIMER_DATA(i) = 0; } u16 *mainregs = (u16*)0x04000000; u16 *subregs = (u16*)0x04001000; for (i=0; i<43; i++) { mainregs[i] = 0; subregs[i] = 0; } REG_DISPSTAT = 0; dmaFillWords(0, BG_PALETTE, (2*1024)); VRAM_A_CR = 0x80; dmaFillWords(0, VRAM, 128*1024); VRAM_A_CR = 0; VRAM_B_CR = 0; // Don't mess with the ARM7's VRAM // VRAM_C_CR = 0; VRAM_D_CR = 0; VRAM_E_CR = 0; VRAM_F_CR = 0; VRAM_G_CR = 0; VRAM_H_CR = 0; VRAM_I_CR = 0; REG_POWERCNT = 0x820F; //set shared ram to ARM7 WRAM_CR = 0x03; // Return to passme loop *((vu32*)0x02FFFE04) = (u32)0xE59FF018; // ldr pc, 0x02FFFE24 *((vu32*)0x02FFFE24) = (u32)0x02FFFE04; // Set ARM9 Loop address REG_IPC_SYNC = 0x500; arm9Reset(); while(1); }