void unload_modules(){ //if(module_flag & 3) // SysUnloadModule(SYSMODULE_NET); if(module_flag & 2) SysUnloadModule(SYSMODULE_PNGDEC); if(module_flag & 1) SysUnloadModule(SYSMODULE_FS); }
void unload_modules() { VideoModule::getVideoModule()->stop(); if(module_flag & 2) SysUnloadModule(SYSMODULE_PNGDEC); if(module_flag & 1) SysUnloadModule(SYSMODULE_FS); }
int netDeinitialize() { netFinalizeNetwork(); if (__netMemory) free(__netMemory); __netMemory = NULL; SysUnloadModule(SYSMODULE_NET); return 0; }
void exiting() { SysUnloadModule(SYSMODULE_PNGDEC); }
int main(int argc, char *argv[]) { int list_s; /* listening socket */ int conn_s; /* connection socket */ short int port; /* port number */ struct sockaddr_in servaddr; /* socket address structure */ char buffer[MAX_LINE]; /* character buffer */ char *endptr; /* for strtol() */ fprintf(stdout, "Starting ECHOServer.\n"); /* Get port number from the command line, and set to default port if no arguments were supplied */ if ( argc == 2 ) { port = strtol(argv[1], &endptr, 0); if ( *endptr ) { fprintf(stderr, "ECHOSERV: Invalid port number.\n"); exit(EXIT_FAILURE); } }else if ( argc < 2 ) { port = ECHO_PORT; }else{ fprintf(stderr, "ECHOSERV: Invalid arguments.\n"); exit(EXIT_FAILURE); } printf("SysLoadModule(NET)=%d\n", SysLoadModule(SYSMODULE_NET)); printf("net_init()=%d\n", net_initialize_network()); /* Create the listening socket */ if ( (list_s = socket(AF_INET, SOCK_STREAM, 0)) < 0 ) { fprintf(stderr, "ECHOSERV: Error creating listening socket.\n"); printf("errno: %d\n", errno); exit(EXIT_FAILURE); } /* Set all bytes in socket address structure to zero, and fill in the relevant data members */ memset(&servaddr, 0, sizeof(servaddr)); servaddr.sin_family = AF_INET; servaddr.sin_addr.s_addr = htonl(INADDR_ANY); servaddr.sin_port = htons(port); /* Bind our socket addresss to the listening socket, and call listen() */ if ( bind(list_s, (struct sockaddr *) &servaddr, sizeof(servaddr)) < 0 ) { fprintf(stderr, "ECHOSERV: Error calling bind()\n"); exit(EXIT_FAILURE); } if ( listen(list_s, LISTENQ) < 0 ) { fprintf(stderr, "ECHOSERV: Error calling listen()\n"); exit(EXIT_FAILURE); } char* message = "Welcome to ECHOServer test.\nType exit and hit enter to close app, otherwise type anything you want and hit enter and I will replay it back to you free of charge. :)"; /* Enter an infinite loop to respond to client requests and echo input */ int run = 1; while ( run ) { /* Wait for a connection, then accept() it */ if ( (conn_s = accept(list_s, NULL, NULL) ) < 0 ) { fprintf(stderr, "ECHOSERV: Error calling accept()\n"); exit(EXIT_FAILURE); } Writeline(conn_s, message, strlen(message)); /* Retrieve an input line from the connected socket then simply write it back to the same socket. */ Readline(conn_s, buffer, MAX_LINE-1); if(strncmp("exit", buffer, 4) == 0) run = 0; Writeline(conn_s, buffer, strlen(buffer)); /* Close the connected socket */ if ( closesocket(conn_s) < 0 ) { fprintf(stderr, "ECHOSERV: Error calling closesocket()\n"); exit(EXIT_FAILURE); } } net_finalize_network(); SysUnloadModule(SYSMODULE_NET); }
s32 main(s32 argc, const char* argv[]) { PadInfo padinfo; PadData paddata; int i; tiny3d_Init(1024*1024); ioPadInit(7); SysLoadModule(SYSMODULE_PNGDEC); // Load texture LoadTexture(); /* data for the ghost */ ghost[0].x = 0.0f; ghost[0].y = 0.0f; ghost[0].dx = 1.5f; ghost[0].dy = 1.5f; ghost[0].frame = 0; ghost[0].color = 0xffffff80; ghost[1].x = (847.0f - 64.0f); ghost[1].y = 0.0f; ghost[1].dx = -1.5f; ghost[1].dy = 1.5f; ghost[1].frame = 0; ghost[1].color = 0x8f8fff80; ghost[2].x = 0.0f; ghost[2].y = (511.0f - 64.0f); ghost[2].dx = 1.5f; ghost[2].dy = -1.5f; ghost[2].frame = 0; ghost[2].color = 0xff8f8f80; ghost[3].x = (847.0f - 64.0f); ghost[3].y = (511.0f - 64.0f); ghost[3].dx = -1.5f; ghost[3].dy = -1.5f; ghost[3].frame = 0; ghost[3].color = 0x8fff8f80; // Ok, everything is setup. Now for the main loop. while(1) { /* DRAWING STARTS HERE */ // clear the screen, buffer Z and initializes environment to 2D tiny3d_Clear(0xff000000, TINY3D_CLEAR_ALL); // Enable alpha Test tiny3d_AlphaTest(1, 0x10, TINY3D_ALPHA_FUNC_GEQUAL); // Enable alpha blending. tiny3d_BlendFunc(1, TINY3D_BLEND_FUNC_SRC_RGB_SRC_ALPHA | TINY3D_BLEND_FUNC_SRC_ALPHA_SRC_ALPHA, NV30_3D_BLEND_FUNC_DST_RGB_ONE_MINUS_SRC_ALPHA | NV30_3D_BLEND_FUNC_DST_ALPHA_ZERO, TINY3D_BLEND_RGB_FUNC_ADD | TINY3D_BLEND_ALPHA_FUNC_ADD); // Check the pads. ioPadGetInfo(&padinfo); for(i = 0; i < MAX_PADS; i++){ if(padinfo.status[i]){ ioPadGetData(i, &paddata); if(paddata.BTN_CROSS){ return 0; } } } drawScene(); // Draw /* DRAWING FINISH HERE */ tiny3d_Flip(); } SysUnloadModule(SYSMODULE_PNGDEC); return 0; }