void emu_resume() { emu_run = 1; vid_resume(); pcm_resume(); joy_init(); }
int init(void) { // initialize SDL video if ( SDL_Init( SDL_INIT_VIDEO | SDL_INIT_AUDIO ) < 0 ) { printf( "Unable to init SDL: %s\n", SDL_GetError() ); return 1; } set_led(0); // off by default // make sure SDL cleans up before exit atexit(SDL_Quit); // create a default new window set_mode(VGA_H_PIXELS,VGA_V_PIXELS); #ifndef NO_AUDIO audio_init(); #endif joy_init(); next_time = SDL_GetTicks(); if (!quiet) printf("Screen is now %dx%d with a scale of %d\n",screen_width,screen_height,scale); SDL_ShowCursor(SDL_DISABLE); return 0; }
int init(void) { // initialize SDL video if ( SDL_Init( SDL_INIT_VIDEO | SDL_INIT_AUDIO ) < 0 ) { printf( "Unable to init SDL: %s\n", SDL_GetError() ); return 1; } set_led(0); // off by default // make sure SDL cleans up before exit atexit(SDL_Quit); // create a default new window set_mode(VGA_H_PIXELS,VGA_V_PIXELS); #ifndef NO_AUDIO audio_init(); #endif joy_init(); next_time = SDL_GetTicks(); printf("screen is now %dx%d\n",screen_width,screen_height); #ifdef MICROKERNEL printf("Using 8Bpp interface (micro)"); #endif return 0; }
void arch_init() { // Initialise the library #ifdef __SDL__ arch_sdl_init(); #endif #ifdef __SVGALIB__ arch_svgalib_init(); #endif if (!FindArg( "-nojoystick" )) { if (Inferno_verbose) printf( "\n%s", TXT_VERBOSE_6); joy_init(); } //added 06/09/99 Matt Mueller - fix nonetwork compile #ifdef NETWORK //end addition -MM //added on 10/19/98 by Victor Rachels to add serial support (from DPH) if(!(FindArg("-noserial"))) com_init(); //end this section addition - Victor //added 06/09/99 Matt Mueller - fix nonetwork compile #endif //end addition -MM timer_init(); key_init(); }
int main() { int x; joy_t joy; if ( joy_init(&joy) != 0) { printf("cannot find joystick\n"); return 1; } printf( " Joystick detected : %s \n \t %d axis \n\t %d buttons \n\n" ,joy.name, joy.num_of_axis , joy.num_of_buttons); // fcntl( joy_fd, F_SETFL , O_NONBLOCK ); // use non - blocking methods while(1) // infinite loop { // read the joystick joy_read(&joy); // print the results printf( " X:%6d y:%6d", joy.axis[0] , joy.axis[1]); if( joy.num_of_axis > 2) printf( " z:%6d" , joy.axis[2] ); if( joy.num_of_axis > 3) printf( " R:%6d" , joy.axis [3]); for( x=0 ; x<joy.num_of_buttons ; ++x) printf( " B%d:%d" , x, joy.button [x]); printf("\n"); fflush(stdout); } joy_close(&joy); return 0; }
void vid_init() { int flags; if (!vmode[0] || !vmode[1]) { int scale = rc_getint("scale"); if (scale < 1) scale = 1; vmode[0] = 160 * scale; vmode[1] = 144 * scale; } flags = SDL_ANYFORMAT | SDL_HWPALETTE | SDL_HWSURFACE; if (fullscreen) flags |= SDL_FULLSCREEN; if (SDL_Init(SDL_INIT_VIDEO)) die("SDL: Couldn't initialize SDL: %s\n", SDL_GetError()); if (!(screen = SDL_SetVideoMode(vmode[0], vmode[1], vmode[2], flags))) die("SDL: can't set video mode: %s\n", SDL_GetError()); SDL_ShowCursor(0); joy_init(); overlay_init(); if (fb.yuv) return; SDL_LockSurface(screen); fb.w = screen->w; fb.h = screen->h; fb.pelsize = screen->format->BytesPerPixel; fb.pitch = screen->pitch; fb.indexed = fb.pelsize == 1; fb.ptr = screen->pixels; fb.cc[0].r = screen->format->Rloss; fb.cc[0].l = screen->format->Rshift; fb.cc[1].r = screen->format->Gloss; fb.cc[1].l = screen->format->Gshift; fb.cc[2].r = screen->format->Bloss; fb.cc[2].l = screen->format->Bshift; SDL_UnlockSurface(screen); fb.enabled = 1; fb.dirty = 0; }
int main(void) { // Activate external memory MCUCR |= (1 << SRE); // Initialize USART_init(MYUBRR); joy_init(); oled_init(); can_init(); menu_init(); // Starts the FSM while(1) { menu_fsm(); _delay_ms(20); } }
void arch_init(void) { int t; if (SDL_Init(SDL_INIT_VIDEO) < 0) Error("SDL library initialisation failed: %s.",SDL_GetError()); key_init(); digi_select_system( GameArg.SndDisableSdlMixer ? SDLAUDIO_SYSTEM : SDLMIXER_SYSTEM ); if (!GameArg.SndNoSound) digi_init(); mouse_init(); if (!GameArg.CtlNoJoystick) joy_init(); if ((t = gr_init(0)) != 0) Error("Graphics initialization failed: %u",t); atexit(arch_close); }
void main (void) { unsigned int t1, t2; int i, start, stop, frames; short bd1, bd2, bu1, bu2, b, x, y, bt1, bt2; key_init(); if (!joy_init()) { printf( "No joystick detected.\n" ); key_close(); exit(1); } timer_init( 0, NULL ); printf( "Displaying joystick button transitions and time...any key leaves.\n" ); i = 0; while( !key_inkey() ) { i++; if (i>500000) { i = 0; joy_get_btn_down_cnt( &bd1, &bd2 ); joy_get_btn_up_cnt( &bu1, &bu2 ); joy_get_btn_time( &bt1, &bt2 ); printf( "%d %d %d %d T1:%d T2:%d\n",bd1, bu1, bd2, bu2, bt1, bt2 ); } } printf( "\nPress c to do a deluxe-full-fledged calibration.\n" ); printf( "or any other key to just use the cheap method.\n" ); if (key_getch() == 'c') { printf( "Move stick to center and press any key.\n" ); wait(); joy_set_cen(); printf( "Move stick to Upper Left corner and press any key.\n" ); wait(); joy_set_ul(); printf( "Move stick to Lower Right corner and press any key.\n" ); wait(); joy_set_lr(); } while( !keyd_pressed[KEY_ESC]) { frames++; joy_get_pos( &x, &y ); b = joy_get_btns(); printf( "%d, %d (%d %d)\n", x, y, b & 1, b & 2); } printf( "Testing joystick reading speed...\n" ); t1 = timer_get_microseconds(); joy_get_pos( &x, &y ); t2 = timer_get_microseconds(); printf( "~ %u æsec per reading using Timer Timing\n", t2 - t1 ); joy_close(); key_close(); timer_close(); frames = 1000; start = TICKER; for (i=0; i<frames; i++ ) joy_get_pos( &x, &y ); stop = TICKER; printf( "~ %d æsec per reading using BIOS ticker as a stopwatch.\n", USECS_PER_READING( start, stop, frames ) ); }
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPreInst, LPSTR lpszCmdLine, int nCmdShow) { WNDCLASS wc; MSG msg; HWND hWnd; int i; #ifdef OPENING_WAIT UINT32 tick; #endif _MEM_INIT(); GetModuleFileName(NULL, modulefile, NELEMENTS(modulefile)); dosio_init(); file_setcd(modulefile); np2arg_analize(); initload(); memdbg_readini(); skbdwin_readini(); rand_setseed((unsigned)time(NULL)); if ((hWnd = FindWindow(szClassName, NULL)) != NULL) { ShowWindow(hWnd, SW_RESTORE); SetForegroundWindow(hWnd); dosio_term(); return(FALSE); } hInst = hInstance; hPrev = hPreInst; TRACEINIT(); if (np2oscfg.KEYBOARD >= KEY_TYPEMAX) { // ver0.28 int keytype = GetKeyboardType(1); if ((keytype & 0xff00) == 0x0d00) { np2oscfg.KEYBOARD = KEY_PC98; } else if (!keytype) { np2oscfg.KEYBOARD = KEY_KEY101; } else { np2oscfg.KEYBOARD = KEY_KEY106; } } keystat_initialize(); if (!hPreInst) { wc.style = CS_BYTEALIGNCLIENT | CS_HREDRAW | CS_VREDRAW; wc.lpfnWndProc = WndProc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = hInstance; wc.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_ICON1)); wc.hCursor = LoadCursor(NULL, IDC_ARROW); wc.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH); wc.lpszMenuName = MAKEINTRESOURCE(IDR_MAIN); wc.lpszClassName = szClassName; if (!RegisterClass(&wc)) { return(FALSE); } } memdbg_initialize(hInstance); skbdwin_initialize(hInstance); mousemng_initialize(); hWnd = CreateWindowEx(0, szClassName, szAppCaption, WS_OVERLAPPED | WS_SYSMENU | WS_CAPTION | WS_MINIMIZEBOX, np2oscfg.winx, np2oscfg.winy, 640, 400, NULL, NULL, hInstance, NULL); hWndMain = hWnd; scrnmng_initialize(); xmenu_setroltate(0); xmenu_setdispmode(np2cfg.DISPSYNC); xmenu_setraster(np2cfg.RASTER); xmenu_setwaitflg(np2oscfg.NOWAIT); xmenu_setframe(np2oscfg.DRAW_SKIP); xmenu_setkey(0); xmenu_setxshift(0); xmenu_setf12copy(np2oscfg.F12COPY); xmenu_setbeepvol(np2cfg.BEEP_VOL); xmenu_setsound(np2cfg.SOUND_SW); xmenu_setjastsound(np2oscfg.jastsnd); xmenu_setmotorflg(np2cfg.MOTOR); xmenu_setextmem(np2cfg.EXTMEM); xmenu_setmouse(np2oscfg.MOUSE_SW); xmenu_setbtnmode(np2cfg.BTN_MODE); xmenu_setbtnrapid(np2cfg.BTN_RAPID); xmenu_setmsrapid(np2cfg.MOUSERAPID); ShowWindow(hWnd, nCmdShow); UpdateWindow(hWnd); #ifdef OPENING_WAIT tick = GetTickCount(); #endif sysmenu_initialize(); xmenu_initialize(); DrawMenuBar(hWnd); // ver0.30 if (file_attr_c(np2help) == (short)-1) { EnableMenuItem(GetMenu(hWnd), IDM_HELP, MF_GRAYED); } scrnmode = 0; if (np2arg.fullscreen) { scrnmode |= SCRNMODE_FULLSCREEN; } if (np2cfg.RASTER) { scrnmode |= SCRNMODE_HIGHCOLOR; } if (scrnmng_create(scrnmode) != SUCCESS) { scrnmode ^= SCRNMODE_FULLSCREEN; if (scrnmng_create(scrnmode) != SUCCESS) { MessageBox(hWnd, _T("Couldn't create DirectDraw Object"), szAppCaption, MB_OK | MB_ICONSTOP); return(FALSE); } } soundmng_initialize(); if (np2oscfg.MOUSE_SW) { // ver0.30 mousemng_enable(MOUSEPROC_SYSTEM); } commng_initialize(); sysmng_initialize(); joy_init(); pccore_init(); S98_init(); #ifdef OPENING_WAIT while((GetTickCount() - tick) < OPENING_WAIT); #endif scrndraw_redraw(); pccore_reset(); np2opening = 0; // れじうむ #if defined(SUPPORT_RESUME) if (np2oscfg.resume) { int id; id = flagload(str_sav, str_resume, FALSE); if (id == IDYES) { for (i=0; i<4; i++) np2arg.disk[i] = NULL; } else if (id == IDCANCEL) { DestroyWindow(hWnd); mousemng_disable(MOUSEPROC_WINUI); S98_trash(); pccore_term(); soundmng_deinitialize(); scrnmng_destroy(); TRACETERM(); dosio_term(); return(0); } } #endif // リセットしてから… コマンドラインのディスク挿入。 // ver0.29 for (i=0; i<4; i++) { if (np2arg.disk[i]) { diskdrv_readyfdd((REG8)i, np2arg.disk[i], 0); } } memdbg_create(); skbdwin_create(); while(1) { if (PeekMessage(&msg, 0, 0, 0, PM_NOREMOVE)) { if (!GetMessage(&msg, NULL, 0, 0)) { break; } if ((msg.message != WM_SYSKEYDOWN) && (msg.message != WM_SYSKEYUP)) { TranslateMessage(&msg); } DispatchMessage(&msg); } else { if (np2oscfg.NOWAIT) { joy_flash(); mousemng_sync(); pccore_exec(framecnt == 0); if (np2oscfg.DRAW_SKIP) { // nowait frame skip framecnt++; if (framecnt >= np2oscfg.DRAW_SKIP) { processwait(0); } } else { // nowait auto skip framecnt = 1; if (timing_getcount()) { processwait(0); } } } else if (np2oscfg.DRAW_SKIP) { // frame skip if (framecnt < np2oscfg.DRAW_SKIP) { joy_flash(); mousemng_sync(); pccore_exec(framecnt == 0); framecnt++; } else { processwait(np2oscfg.DRAW_SKIP); } } else { // auto skip if (!waitcnt) { UINT cnt; joy_flash(); mousemng_sync(); pccore_exec(framecnt == 0); framecnt++; cnt = timing_getcount(); if (framecnt > cnt) { waitcnt = framecnt; if (framemax > 1) { framemax--; } } else if (framecnt >= framemax) { if (framemax < 12) { framemax++; } if (cnt >= 12) { timing_reset(); } else { timing_setcount(cnt - framecnt); } framereset(); } } else { processwait(waitcnt); waitcnt = framecnt; } } } } pccore_cfgupdate(); mousemng_disable(MOUSEPROC_WINUI); S98_trash(); #if defined(SUPPORT_RESUME) if (np2oscfg.resume) { flagsave(str_sav); } else { flagdelete(str_sav); } #endif pccore_term(); memdbg_destroy(); skbdwin_destroy(); soundmng_deinitialize(); scrnmng_destroy(); if (sys_updates & (SYS_UPDATECFG | SYS_UPDATEOSCFG)) { initsave(); memdbg_writeini(); skbdwin_writeini(); } skbdwin_deinitialize(); TRACETERM(); _MEM_USED("report.txt"); dosio_term(); return static_cast<int>(msg.wParam); }
void win32_create_window(int x,int y) { int flags; WNDCLASS wcDescentClass; if (!hInst) Error("hInst=NULL\n"); wcDescentClass.lpszClassName = "WinD1X"; wcDescentClass.hInstance = hInst; wcDescentClass.lpfnWndProc = DescentWndProc; wcDescentClass.hCursor = LoadCursor(NULL, IDC_ARROW); //wcDescentClass.hIcon = LoadIcon(NULL, IDI_WINLOGO); wcDescentClass.hIcon = LoadIcon(hInst, MAKEINTRESOURCE(IDI_MAIN_ICON); wcDescentClass.lpszMenuName = NULL; wcDescentClass.hbrBackground = NULL; wcDescentClass.style = CS_OWNDC; wcDescentClass.cbClsExtra = 0; wcDescentClass.cbWndExtra = 0; // Register the class if (!RegisterClass(&wcDescentClass)){ // //printf("RegisterClass==0?\n"); //always seems to return 0 after the first time, yet if you remove the call, it crashes. Heh. } if (gameStates.ogl.bFullScreen) flags=WS_POPUP;//uh.. don't remember if removing sysmenu did anything or not.. but it works. //flags=WS_POPUP | WS_SYSMENU; else flags=WS_OVERLAPPED | WS_BORDER | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX;//let us minimize it. //flags=WS_OVERLAPPED | WS_BORDER | WS_CLIPCHILDREN | WS_CLIPSIBLINGS; if (!gameStates.ogl.bFullScreen){ x+=get_win_x_bs();y+=get_win_y_bs(); }else{ if (FindArg("-gl_test2")){ x=GetSystemMetrics(SM_CXSCREEN); y=GetSystemMetrics(SM_CYSCREEN); } } g_hWnd = CreateWindowEx(0, "WinD1X", "Descent", flags, 0, 0, x,y, NULL, NULL, hInst, NULL ); if (!g_hWnd) Error("no window?\n"); ShowWindow(g_hWnd,SW_SHOWNORMAL); UpdateWindow(g_hWnd); OpenGL_Initialize(); if (gameStates.ogl.bFullScreen){ ShowCursor(FALSE); mouse_hidden = 1; } key_init(); mouse_init(0); joy_init(JOYSTICKID1); if (!FindArg( "-nosound" )) DigiInit(); gameStates.ogl.bInitialized=1; }
void arch_init() { HRESULT ddrval; WNDCLASS wcDescentClass; wcDescentClass.lpszClassName = "WinD1X"; wcDescentClass.hInstance = hInst; wcDescentClass.lpfnWndProc = DescentWndProc; wcDescentClass.hCursor = LoadCursor(NULL, IDC_ARROW); //wcDescentClass.hIcon = LoadIcon(NULL, IDI_WINLOGO); wcDescentClass.hIcon = LoadIcon(hInst, MAKEINTRESOURCE(IDI_MAIN_ICON)); wcDescentClass.lpszMenuName = NULL; wcDescentClass.hbrBackground = NULL; wcDescentClass.style = CS_HREDRAW | CS_VREDRAW; wcDescentClass.cbClsExtra = 0; wcDescentClass.cbWndExtra = 0; // Register the class RegisterClass(&wcDescentClass); g_hWnd = CreateWindowEx(0, "WinD1X", "Descent", WS_OVERLAPPED | WS_BORDER, 0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN), NULL, NULL, hInst, NULL ); if (!g_hWnd) return; // CRAP! ShowWindow(g_hWnd,SW_SHOWNORMAL); UpdateWindow(g_hWnd); ddrval=DirectDrawCreate(NULL,&lpDD,NULL); if(ddrval!=DD_OK) { fprintf(stderr,"DirectDrawCreate() failed!\n"); abort(); } if (FindArg("-semiwin")) ddrval=IDirectDraw_SetCooperativeLevel(lpDD,g_hWnd,DDSCL_NORMAL); else { #ifndef NDEBUG ddrval=IDirectDraw_SetCooperativeLevel(lpDD,g_hWnd, DDSCL_EXCLUSIVE|DDSCL_FULLSCREEN|DDSCL_ALLOWREBOOT); #else ddrval=IDirectDraw_SetCooperativeLevel(lpDD,g_hWnd, DDSCL_EXCLUSIVE|DDSCL_FULLSCREEN|DDSCL_ALLOWREBOOT); #endif } if (ddrval!=DD_OK) { fprintf(stderr,"SetCooperativeLevel() failed\n"); abort(); } ShowCursor(FALSE); mouse_hidden = 1; SetPriorityClass(GetCurrentProcess(),HIGH_PRIORITY_CLASS); key_init(); mouse_init(); //added/changed 3/7/99 Owen Evans (next line) joy_init(JOYSTICKID1); printf("arch_init successfully completed\n"); }
int main() { int i; struct VEngine veng; struct World world; JoyState* joy; v_init(&veng); joy_init(); /* for a random seed, wait for user input */ i = 0; while (1) { vid_vsync(); key_poll(); v_putbgtile(5, 4, 37); v_putbgtile(6, 4, 48); v_putbgtile(7, 4, 51); v_putbgtile(8, 4, 51); v_putbgtile(9, 4, 51); if (key_hit(KEY_A) || key_hit(KEY_START)) { break; } i ++; } /* sqran(i); */ sqran(4); init_world(&world, &veng); /* obj_set_pos(dude, (16 * 7), (16 * 4)); */ v_draw_bg(world.map, &veng, world.map->dudex, world.map->dudey); while(1) { vid_vsync(); joy = joy_poll(); key_poll(); if (key_hit(KEY_A)) { /* v_draw_more_bg(world.map, veng.mapofsx, veng.mapofsy - 4, 15, 4, world.map->dudex - 6 - veng.dudeposx, world.map->dudey - 4 - 4 - veng.dudeposy); */ } if (key_hit(KEY_START)) { v_init(&veng); init_world(&world, &veng); /* obj_set_pos(veng.obj_buffer[veng.spr_dude], (16 * 7), (16 * 4)); */ v_draw_bg(world.map, &veng, world.map->dudex, world.map->dudey); } /* if (key_hit(KEY_LEFT)) { switch (r_move_left(&world)) { case 1: v_move_left(&veng); break; case 2: v_shake_dude(&veng, 1, 0); break; } } else if (key_hit(KEY_RIGHT)) { switch (r_move_right(&world)) { case 1: v_move_right(&veng); break; case 2: v_shake_dude(&veng, 1, 0); break; } } else if (key_hit(KEY_UP)) { switch (r_move_up(&world)) { case 1: v_move_up(&veng); break; case 2: v_shake_dude(&veng, 0, 1); break; } } else if (key_hit(KEY_DOWN)) { switch (r_move_down(&world)) { case 1: v_move_down(&veng); break; case 2: v_shake_dude(&veng, 0, 1); break; } } */ if (joy->moving) { switch (r_move(&world, joy->dx, joy->dy)) { case 1: v_move(&veng, joy->dx, joy->dy); break; case 2: v_shake_dude(&veng, 0, 1); break; } joy_handled(); } v_move_co(&veng); v_scroll_at_edge(&veng, &world); v_draw_dude(&veng); for (i = 0; i < world.monstercount; i ++) { v_draw_monster(&veng, &world, i); } oam_copy(oam_mem, veng.obj_buffer, 1 + world.monstercount); } return 0; }
int main(void) { wdt_enable(WDTO_2S); clock_prescale_set(clock_div_1); // Disable Clock Division // if we had been restarted by watchdog check the REQ BootLoader byte in the // EEPROM ... if (bit_is_set(MCUSR,WDRF) && erb(EE_REQBL)) { ewb( EE_REQBL, 0 ); // clear flag start_bootloader(); } // Setup the timers. Are needed for watchdog-reset OCR0A = 249; // Timer0: 0.008s = 8MHz/256/250 TCCR0B = _BV(CS02); TCCR0A = _BV(WGM01); TIMSK0 = _BV(OCIE0A); TCCR1A = 0; TCCR1B = _BV(CS11) | _BV(WGM12); // Timer1: 1us = 8MHz/8 #ifdef CURV3 // Timer3 is used by the LCD backlight (PWM) TCCR3A = _BV(COM3A1)| _BV(WGM30); // Fast PWM, 8-bit, clear on match TCCR3B = _BV(WGM32) | _BV(CS31); // Prescaler 8MHz/8: 3.9KHz #endif MCUSR &= ~(1 << WDRF); // Enable the watchdog led_init(); spi_init(); eeprom_init(); USB_Init(); fht_init(); tx_init(); joy_init(); // lcd init is done manually from menu_init bat_init(); df_init(&df); fs_init(&fs, df, 0); // needs df_init rtc_init(); // does i2c_init too log_init(); // needs fs_init & rtc_init menu_init(); // needs fs_init input_handle_func = analyze_ttydata; log_enabled = erb(EE_LOGENABLED); display_channel = DISPLAY_USB|DISPLAY_LCD|DISPLAY_RFROUTER; rf_router_init(); checkFrequency(); LED_OFF(); for(;;) { USB_USBTask(); CDC_Task(); RfAnalyze_Task(); Minute_Task(); FastRF_Task(); rf_router_task(); JOY_Task(); } }