/**************************************************************************************************************************** * Function name: main() * Description : Main function of the application. * * Input params: none * Output params: * Return val : none *****************************************************************************************************************************/ int main (int argc, char *argv[]) { WP_status status; app_task *task, a_task; WP_CHAR comm; status = WP_DriverInit (); App_TerminateOnError (status, "WP_DriverInit()"); /* Initialize the Tags */ App_TestInit (); /* Configure the context and initialize the System */ App_SysInit (); /* Commit system resources */ /* Enet Physical ports and UFE Card are initialzed */ App_InitHW (); App_SystemSetup (); App_ResetUfe (); WUFE_SystemInterruptDisable (0); /* Create Enet and emphy ports */ App_PortsCreate (); /* Create Host, Enet devices and allocate IMA(emphy) devices */ App_DevicesAllocCreate (); /* Create Host, Buffer Pools and Qnodes */ App_BufferPoolsCreate (); /* Initialize the Control registers, Create IMA system and Commit the system */ status = WP_SysCommit (); App_TerminateOnError (status, "WP_SysCommit()"); App_enableEmphyPort (); /*Initialize the framer. Configure and create UFE line and phy create */ App_ufeSystem (); /* ASU sheduler Enable */ status = WP_SysAsuEnable (WP_WINPATH (0)); App_TerminateOnError (status, "WP_SysAsuEnable()"); /* Create IMA groups and add links to the group */ App_ImaSetup (); /* IMA group event generate */ App_ImaGroupEvent (); /* Create Host, Enet and Host Channels */ App_ChannelsCreate (); /* Create ATM channels for IMA */ App_ImaChannelsCreate (); /* Sets up ENET --> UFE bridging interworking */ App_CreateEnetUfeIwSystem (); /* Sets up Ufe --> ENET interworking */ App_CreateUfeEnetIwSystem (); /* Enable the ports and devices created earlier */ App_PortsDevicesEnable (); /* Enable the Channels created earlier */ App_ChannelsEnable (); display_events (); WP_Delay (1000000); display_events (); printf ("ready to show MENU\n"); // fflush(stdout); if (argc <= 1) { /*default mode, no parameters */ while (1) { printf ("\n"); printf ("a. Stats & Status\n"); printf ("d. Debug\n"); printf ("p. Send Packet\n"); printf ("s. Simulate Interrupts\n"); printf ("x. Exit\n"); do { comm = getchar (); } while (!('a' <= comm && 'z' >= comm)); switch (comm) { case 'a': App_ShowStats (); break; case 'p': App_DataSend (h_enet1_tx, h_pool_buffer_iw); break; /*Not supported....Added code for future use. case 'd': App_Debug(debug_on); break; case 's': WPI_SimulateInterrupts(); break; */ case 'x': { WP_DriverRelease (); exit (0); } } WPI_SimulateInterrupts (); while ((task = next_task (irq_task_list, &a_task)) != NULL) app_perform_action (task); } } else if ((argc == 3) && (!strcmp (argv[1], "freerun"))) { /*free run mode */ App_perform_freerun (); } else { printf ("Wrong parameter! Only \"go\" or \"go freerun\" supported!"); /*Quit test */ App_Quit (1); } return 0; }
int GameLoop() { Init_Game(); SDL_Event e; MM_Load(); while(!Quit) { while(SDL_PollEvent(&e)) { if(e.type == SDL_TEXTINPUT && TI_FLAG == true) { Returntext.push_back(*e.text.text); TI_Update_Text(); break; } else if(e.type == SDL_MOUSEBUTTONDOWN) { double x = e.button.x; double y = e.button.y; double ax = (x / RES_WIDTH) * 1920; double ay = (y / RES_HEIGHT) * 1080; for(int y = Button_Stack.size() - 1; y >= 0; y--) { for(int x = Button_Stack[y]->size() - 1; x >= 0; x--) { if(ax > Button_Stack.at(y)->at(x)->x && ax < Button_Stack.at(y)->at(x)->x + Button_Stack.at(y)->at(x)->w) { if(ay > Button_Stack.at(y)->at(x)->y && ay < Button_Stack.at(y)->at(x)->y + Button_Stack.at(y)->at(x)->h) { if(Button_Stack.at(y)->at(x)->type == BASIC) { Button_Stack.at(y)->at(x)->funct(); x = 0; y = 0; } else if(Button_Stack.at(y)->at(x)->type == LIST) { Button_Stack.at(y)->at(x)->funct2(Button_Stack.at(y)->at(x)->L_Pos); x = 0; y = 0; } else if(Button_Stack.at(y)->at(x)->type == GRID) { Button_Stack.at(y)->at(x)->funct3(Button_Stack.at(y)->at(x)->G_PosX, Button_Stack.at(y)->at(x)->G_PosY); x = 0; y = 0; } } } } } } else if(e.type == SDL_QUIT) { Quit = true; } else if(e.type == SDL_KEYDOWN && Key_Stack.size() > 0) { for(int x = 0; x < Key_Stack.size(); x++) { if(Key_Stack.at(x)->input == e.key.keysym.sym) Key_Stack.at(x)->funct(); } } } for(int x = 0; x < Tx_Stack.size(); x++) { for(int y = 0; y < Tx_Stack[x]->size(); y++) { RenderTexture(Tx_Stack[x]->at(y)); } } RenderTexture(wally); for(int x = 0; x < Text_Stack.size(); x++) { for(int y = 0; y < Text_Stack[x]->size(); y++) { RenderTexture(Text_Stack[x]->at(y)); } } for(int x = 0; x < Funct_Stack.size(); x++) { Funct_Stack[x](); } SDL_RenderPresent(ren); SDL_RenderClear(ren); SDL_Delay(16); } App_Quit(); return 0; }