int sc_main(int argc,char ** argv) { try { wireworld_common::wireworld_configuration l_config; wireworld_common::wireworld_types::t_cell_list l_copper_cells; wireworld_common::wireworld_types::t_cell_list l_tail_cells; wireworld_common::wireworld_types::t_cell_list l_electron_cells; wireworld_common::wireworld_types::t_cell_list l_inactive_cells; wireworld_common::wireworld_types::t_neighbours l_neighbours; uint32_t l_x_max = 0; uint32_t l_y_max = 0; wireworld_common::wireworld_prepare::prepare(argc,argv, l_config, l_copper_cells, l_tail_cells, l_electron_cells, l_inactive_cells, l_neighbours, l_x_max, l_y_max); wireworld_systemc::top l_top("top",l_copper_cells,l_tail_cells,l_electron_cells,l_config,l_x_max,l_y_max,l_inactive_cells,l_neighbours); sc_start(); } catch(quicky_exception::quicky_logic_exception & e) { std::cout << "ERROR : Runtime exception : " << e.what() << std::endl ; return -1; } catch(quicky_exception::quicky_runtime_exception & e) { std::cout << "ERROR : Runtime exception : " << e.what() << std::endl ; return -1; } return 0; }
/* draw_thread This is the drawing-thread. You have a valid presentation space handle (hps), a valid window handle (hwndSaver) and the configuration_data structure is loaded. The screen size is stored in "screenSizeX" and "screenSizeY". IMPORTANT NOTE 1: You must check the "stop_draw_thread" flag regularly. If it is set, free all resources you have allocated and call _endthread (or just return) to end the drawing-thread. IMPORTANT NOTE 2: If the "low_priority" flag is NOT set (that means you run with regular priority, sharing CPU usage with other programs), you should call DosSleep(x) with "x" set at least to 1 as often as possible, to allow other programs to do their work. A screen saver should not eat up other program's CPU time! IMPORTANT NOTE 3: For some of the PM calls to work properly, your thread needs an own HAB and maybe even a message queue. You have to get and release both of them here if you use such PM calls. The following sample code is from the "Pyramids" module that comes with the ScreenSaver distribution. It selects a random color and a random point on the screen, then draws lines in the selected color from each corner of the screen to the selected point (looks somewhat like a pyramid). It remembers a number of points (this number can be set in the configuration dialog). Having filled the point memory, it redraws the "oldest" visible pyramid in black. This has the effect that more and more pixels on the screen get black, only a few constantly changing colored lines remain. */ void draw_thread(void *args) { POINTL BitmapPoints[4] = { 1, 1, screenSizeX + 2, screenSizeY + 2, -1, -1, screenSizeX, screenSizeY }; POINTL l_b = { 0, 0 }, l_t = { 0, screenSizeY - 1 }, r_b = { screenSizeX - 1, 0 }, r_t = { screenSizeX - 1, screenSizeY - 1 }; INT i, step; VOID l_left() { GpiMove( hps, &l_b ); GpiLine( hps, &l_t ); } VOID l_right() { GpiMove( hps, &r_b ); GpiLine( hps, &r_t ); } VOID l_top() { GpiMove( hps, &l_t ); GpiLine( hps, &r_t ); } VOID l_bottom() { GpiMove( hps, &l_b ); GpiLine( hps, &r_b ); } srand(WinGetCurrentTime( hab )); GpiSetColor( hps, CLR_BLACK ); l_left(); while(!stop_draw_thread){ if( configuration_data.drunken ){ step = (unsigned)rand() % 8; switch ( step ){ case 0: BitmapPoints[0].x = -1; BitmapPoints[0].y = 0; BitmapPoints[1].x = screenSizeX; BitmapPoints[1].y = screenSizeY + 1; l_bottom(); break; case 1: BitmapPoints[0].x = 0; BitmapPoints[0].y = 0; BitmapPoints[1].x = screenSizeX + 1; BitmapPoints[1].y = screenSizeY + 1; l_bottom(); l_left(); break; case 2: BitmapPoints[0].x = 0; BitmapPoints[0].y = -1; BitmapPoints[1].x = screenSizeX + 1; BitmapPoints[1].y = screenSizeY; l_left(); break; case 3: BitmapPoints[0].x = 0; BitmapPoints[0].y = -2; BitmapPoints[1].x = screenSizeX + 1; BitmapPoints[1].y = screenSizeY - 1; l_left(); l_top(); break; case 4: BitmapPoints[0].x = -1; BitmapPoints[0].y = -2; BitmapPoints[1].x = screenSizeX; BitmapPoints[1].y = screenSizeY - 1; l_top(); break; case 5: BitmapPoints[0].x = -2; BitmapPoints[0].y = -2; BitmapPoints[1].x = screenSizeX - 1; BitmapPoints[1].y = screenSizeY - 1; l_top(); l_right(); break; case 6: BitmapPoints[0].x = -2; BitmapPoints[0].y = -1; BitmapPoints[1].x = screenSizeX - 1; BitmapPoints[1].y = screenSizeY; l_right(); break; case 7: BitmapPoints[0].x = -2; BitmapPoints[0].y = 0; BitmapPoints[1].x = screenSizeX - 1; BitmapPoints[1].y = screenSizeY + 1; l_right(); l_bottom(); break; } } for( i = 1; i < 5; i++){ GpiBitBlt( hps, hps, 3, BitmapPoints, ROP_SRCCOPY, BBO_IGNORE ); if( stop_draw_thread) i = 10; } // sleep if necessary if(low_priority == FALSE) DosSleep(1); // sleep if user requests slower animation switch(configuration_data.animation_speed){ case 4: break; case 3: DosSleep(10); break; case 2: DosSleep(30); break; case 1: DosSleep(50); break; case 0: DosSleep(70); break; } } // free resources _endthread(); }