adv_error joystickb_svgalib_init(int joystickb_id) { unsigned i; log_std(("josytickb:svgalib: joystickb_svgalib_init(id:%d)\n", joystickb_id)); if (os_internal_wm_active()) { error_set("Unsupported in X.\n"); return -1; } if (!os_internal_svgalib_get()) { error_set("Not supported without the svgalib library.\n"); return -1; } for(i=0;i<4;++i) { if (joystick_init(i, 0)<=0) { break; } } if (i==0) { error_set("No joystick found.\n"); return -1; } svgalib_state.counter = i; return 0; }
void uos_init (void) { led_init(); joystick_init (); gpanel_init (&display, &font_fixed6x8); gpanel_clear (&display, 0); gpanel_backlight (&display, 1); puts (&display, "Task created.\n\n"); task_create (hello, "Task", "hello", 1, task, sizeof (task)); }
int init_main(void) { signals_init(debug.do_core_dumps); romset_init(); if (!video_disabled_mode) { palette_init(); } if (machine_class != VICE_MACHINE_VSID) { gfxoutput_init(); screenshot_init(); drivecpu_early_init_all(); } machine_bus_init(); machine_maincpu_init(); event_init(); /* Machine-specific initialization. */ if (machine_init() < 0) { log_error(LOG_DEFAULT, "Machine initialization failed."); return -1; } /* FIXME: what's about uimon_init??? */ /* the monitor console MUST be available, because of for example cpujam, or -initbreak from cmdline. */ if (console_init() < 0) { log_error(LOG_DEFAULT, "Console initialization failed."); return -1; } keyboard_init(); if (!video_disabled_mode) { joystick_init(); } if (machine_class != VICE_MACHINE_VSID) { disk_image_init(); vdrive_init(); } ui_init_finalize(); return 0; }
int init_main(void) { //signals_init(debug.do_core_dumps); romset_init(); if (!video_disabled_mode) { palette_init(); } if (!vsid_mode) { gfxoutput_init(); //screenshot_init(); drivecpu_early_init_all(); } machine_bus_init(); machine_maincpu_init(); event_init(); /* Machine-specific initialization. */ if (machine_init() < 0) { //log_error(LOG_DEFAULT, "Machine initialization failed."); return -1; } /* FIXME: what's about uimon_init??? */ if (!vsid_mode && console_init() < 0) { //log_error(LOG_DEFAULT, "Console initialization failed."); return -1; } keyboard_init(); if (!video_disabled_mode) { joystick_init(); } if (!vsid_mode) { disk_image_init(); vdrive_init(); } ui_init_finalize(); return 0; }
int main (void) { TIM_TIMERCFG_Type timerCfg; uint8_t joyState = 0; /* Initialize devices */ // initialize timer TIM_ConfigStructInit(TIM_TIMER_MODE, &timerCfg); TIM_Init(LPC_TIM0, TIM_TIMER_MODE, &timerCfg); console_init(); joystick_init(); while(1) { joyState = joystick_read(); if (joyState & JOYSTICK_UP) { console_sendString((uint8_t*)"Up "); } if (joyState & JOYSTICK_DOWN) { console_sendString((uint8_t*)"Down "); } if (joyState & JOYSTICK_LEFT) { console_sendString((uint8_t*)"Left "); } if (joyState & JOYSTICK_RIGHT) { console_sendString((uint8_t*)"Right "); } if (joyState & JOYSTICK_CENTER) { console_sendString((uint8_t*)"Center "); } if (joyState != 0) { console_sendString((uint8_t*)"\r\n"); } TIM_Waitms(200); } }
static int init_stick( int which ) { if( !joystick_init( which, JOY_CALIB_STDOUT ) ) { ui_error( UI_ERROR_ERROR, "failed to initialise joystick %i: %s", which + 1, errno ? strerror (errno) : "not configured?" ); return 1; } if( joystick_getnumaxes( which ) < 2 || joystick_getnumbuttons( which ) < 1 ) { joystick_close( which ); ui_error( UI_ERROR_ERROR, "sorry, joystick %i is inadequate!", which + 1 ); return 1; } buttons[which] = joystick_getnumbuttons( which ); if( buttons[which] > NUM_JOY_BUTTONS ) buttons[which] = NUM_JOY_BUTTONS; return 0; }
/* CBM-II-specific initialization. */ int machine_specific_init(void) { cbm2_log = log_open("CBM2"); cbm2_init_ok = 1; event_init(); /* Setup trap handling - must be before mem_load() */ traps_init(); if (mem_load() < 0) { return -1; } if (!video_disabled_mode) { joystick_init(); } gfxoutput_init(); rs232drv_init(); /* initialize print devices */ printer_init(); if (vicii_init(VICII_STANDARD) == NULL) { return -1; } /* c500_set_phi1_bank(15); c500_set_phi2_bank(15); */ c500_powerline_clk_alarm = alarm_new(maincpu_alarm_context, "C500PowerlineClk", c500_powerline_clk_alarm_handler, NULL); clk_guard_add_callback(maincpu_clk_guard, c500_powerline_clk_overflow_callback, NULL); machine_timing.cycles_per_sec = C500_PAL_CYCLES_PER_SEC; machine_timing.rfsh_per_sec = C500_PAL_RFSH_PER_SEC; machine_timing.cycles_per_rfsh = C500_PAL_CYCLES_PER_RFSH; cia1_init(machine_context.cia1); acia1_init(); tpi1_init(machine_context.tpi1); tpi2_init(machine_context.tpi2); #ifndef COMMON_KBD /* Initialize the keyboard. */ if (cbm2_kbd_init() < 0) { return -1; } #endif /* Initialize the datasette emulation. */ datasette_init(); /* Fire up the hardware-level 1541 emulation. */ drive_init(); disk_image_init(); cbm2_monitor_init(); /* Initialize vsync and register our hook function. */ vsync_init(machine_vsync_hook); vsync_set_machine_parameter(machine_timing.rfsh_per_sec, machine_timing.cycles_per_sec); /* Initialize native sound chip */ sid_sound_chip_init(); drive_sound_init(); video_sound_init(); /* Initialize sound. Notice that this does not really open the audio device yet. */ sound_init(machine_timing.cycles_per_sec, machine_timing.cycles_per_rfsh); /* Initialize keyboard buffer. This appears to work but doesn't account for banking. */ kbdbuf_init(939, 209, 10, (CLOCK)(machine_timing.rfsh_per_sec * machine_timing.cycles_per_rfsh)); /* Initialize the CBM-II-specific part of the UI. */ cbm5x0ui_init(); cbm2iec_init(); machine_drive_stub(); #if defined (USE_XF86_EXTENSIONS) && (defined(USE_XF86_VIDMODE_EXT) || defined (HAVE_XRANDR)) { /* set fullscreen if user used `-fullscreen' on cmdline */ int fs; resources_get_int("UseFullscreen", &fs); if (fs) { resources_set_int("VICIIFullscreen", 1); } } #endif return 0; }
/* C64-specific initialization. */ int machine_specific_init(void) { int delay; scpu64_log = log_open("SCPU64"); if (mem_load() < 0) { return -1; } event_init(); /* Setup trap handling. */ traps_init(); if (!video_disabled_mode) { joystick_init(); } gfxoutput_init(); /* Initialize serial traps. */ if (serial_init(scpu64_serial_traps) < 0) { return -1; } serial_trap_init(0xa4); serial_iec_bus_init(); /* Initialize RS232 handler. */ rs232drv_init(); c64_rsuser_init(); /* Initialize print devices. */ printer_init(); /* Fire up the hardware-level drive emulation. */ drive_init(); disk_image_init(); resources_get_int("AutostartDelay", &delay); if (delay == 0) { delay = 3; /* default */ } /* Initialize autostart. */ autostart_init((CLOCK)(delay * SCPU64_PAL_RFSH_PER_SEC * SCPU64_PAL_CYCLES_PER_RFSH), 1, 0xcc, 0xd1, 0xd3, 0xd5); #ifdef USE_BEOS_UI /* Pre-init C64-specific parts of the menus before vicii_init() creates a canvas window with a menubar at the top. This could also be used by other ports, e.g. GTK+... */ if (!console_mode) { scpu64ui_init_early(); } #endif if (vicii_init(VICII_STANDARD) == NULL && !video_disabled_mode) { return -1; } scpu64_mem_init(); cia1_init(machine_context.cia1); cia2_init(machine_context.cia2); #ifndef COMMON_KBD /* Initialize the keyboard. */ if (c64_kbd_init() < 0) { return -1; } #endif c64keyboard_init(); scpu64_monitor_init(); /* Initialize vsync and register our hook function. */ vsync_init(machine_vsync_hook); vsync_set_machine_parameter(machine_timing.rfsh_per_sec, machine_timing.cycles_per_sec); /* Initialize native sound chip */ sid_sound_chip_init(); /* Initialize cartridge based sound chips */ cartridge_sound_chip_init(); /* Initialize userport based sound chips */ userport_dac_sound_chip_init(); drive_sound_init(); video_sound_init(); /* Initialize sound. Notice that this does not really open the audio device yet. */ sound_init(machine_timing.cycles_per_sec, machine_timing.cycles_per_rfsh); /* Initialize keyboard buffer. */ kbdbuf_init(631, 198, 10, (CLOCK)(machine_timing.rfsh_per_sec * machine_timing.cycles_per_rfsh)); /* Initialize the C64-specific I/O */ c64io_init(); /* Initialize the C64-specific part of the UI. */ if (!console_mode) { scpu64ui_init(); } /* Initialize glue logic. */ scpu64_glue_init(); #ifdef HAVE_MOUSE /* Initialize mouse support (if present). */ mouse_init(); #ifdef HAVE_LIGHTPEN /* Initialize lightpen support and register VICII callbacks */ lightpen_init(); lightpen_register_timing_callback(vicii_lightpen_timing, 0); lightpen_register_trigger_callback(vicii_trigger_light_pen); #endif #endif c64iec_init(); c64fastiec_init(); cartridge_init(); machine_drive_stub(); #if defined (USE_XF86_EXTENSIONS) && (defined(USE_XF86_VIDMODE_EXT) || defined (HAVE_XRANDR)) { /* set fullscreen if user used `-fullscreen' on cmdline */ int fs; resources_get_int("UseFullscreen", &fs); if (fs) { resources_set_int("VICIIFullscreen", 1); } } #endif return 0; }
/* PET-specific initialization. */ int machine_specific_init(void) { pet_log = log_open("PET"); pet_init_ok = 1; /* used in petmodel_set() */ event_init(); /* Setup trap handling - must be before mem_load() */ traps_init(); if (mem_load() < 0) { return -1; } if (!video_disabled_mode) { joystick_init(); } gfxoutput_init(); log_message(pet_log, "Initializing IEEE488 bus..."); rs232drv_init(); /* initialize print devices */ printer_init(); /* Initialize autostart. FIXME: We could probably use smaller values. */ /* moved to mem_load() as it is kernal-dependant AF 30jun1998 autostart_init(1 * PET_PAL_RFSH_PER_SEC * PET_PAL_CYCLES_PER_RFSH, 0); */ /* Initialize the CRTC emulation. */ if (crtc_init() == NULL) { return -1; } crtc_set_retrace_type(petres.crtc); crtc_set_retrace_callback(pet_crtc_signal); pet_crtc_set_screen(); petcolour_init(); via_init(machine_context.via); pia1_init(); pia2_init(); acia1_init(); #ifndef COMMON_KBD /* Initialize the keyboard. */ if (pet_kbd_init() < 0) { return -1; } #endif /* Initialize the datasette emulation. */ datasette_init(); /* Fire up the hardware-level 1541 emulation. */ drive_init(); disk_image_init(); pet_monitor_init(); /* Initialize vsync and register our hook function. */ vsync_init(machine_vsync_hook); vsync_set_machine_parameter(machine_timing.rfsh_per_sec, machine_timing.cycles_per_sec); /* Initialize the sidcart first */ sidcart_sound_chip_init(); /* Initialize native sound chip */ pet_sound_chip_init(); /* Initialize cartridge based sound chips */ userport_dac_sound_chip_init(); drive_sound_init(); video_sound_init(); /* Initialize sound. Notice that this does not really open the audio device yet. */ sound_init(machine_timing.cycles_per_sec, machine_timing.cycles_per_rfsh); /* Initialize keyboard buffer. FIXME: Is this correct? */ /* moved to mem_load() because it's model specific... AF 30jun1998 kbdbuf_init(631, 198, 10, PET_PAL_CYCLES_PER_RFSH * PET_PAL_RFSH_PER_SEC); */ /* Initialize the PET-specific part of the UI. */ petui_init(); /* Initialize the PET Ram and Expansion Unit. */ petreu_init(); /* Initialize the PET Double-W Hi-Res graphics card. */ petdww_init(); /* Initialize the PET Hi-Res Emulator graphics card. */ pethre_init(); petiec_init(); machine_drive_stub(); #if defined (USE_XF86_EXTENSIONS) && \ (defined(USE_XF86_VIDMODE_EXT) || defined (HAVE_XRANDR)) { /* set fullscreen if user used `-fullscreen' on cmdline */ int fs; resources_get_int("UseFullscreen", &fs); if (fs) { resources_set_int("CRTCFullscreen", 1); } } #endif return 0; }
int main() { lua_State *lua = luaL_newstate(); luaL_openlibs(lua); motor_Config config; l_motor_register(lua); l_audio_register(lua); l_graphics_register(lua); l_image_register(lua); l_keyboard_register(lua); l_mouse_register(lua); l_filesystem_register(lua); l_timer_register(lua); l_math_register(lua); l_event_register(lua); l_joystick_register(lua); chdir("/love"); l_boot(lua, &config); if(config.identity) { filesystem_setIdentity(config.identity, false); } image_init(); joystick_init(); keyboard_init(); graphics_init(config.window.width, config.window.height); audio_init(); math_init(); if(luaL_dofile(lua, "main.lua")) { printf("Error: %s\n", lua_tostring(lua, -1)); } lua_pushcfunction(lua, errorhandler); lua_getglobal(lua, "love"); lua_pushstring(lua, "load"); lua_rawget(lua, -2); /*if(lua_pcall(lua, 0, 0, 1)) { printf("Error in love.load: %s\n", lua_tostring(lua, -1)); } */ pcall(lua, 0); lua_pop(lua, 1); lua_pushcfunction(lua, errorhandler); mainLoopData.luaState = lua; mainLoopData.errhand = luaL_ref(lua, LUA_REGISTRYINDEX); timer_init(); #ifdef EMSCRIPTEN emscripten_set_main_loop_arg(main_loop, &mainLoopData, 0, 1); #else for(;;) { main_loop(&mainLoopData); } #endif }
int main (void) { unsigned pagenum = 0, backlight, contrast = 0x3f; unsigned left_pressed = 0, right_pressed = 0; unsigned up_pressed = 0, down_pressed = 0; extern const gpanel_font_t font_fixed6x8; led_init(); joystick_init (); gpanel_init (&display, &font_fixed6x8); draw (pagenum); backlight = 1; gpanel_backlight (&display, backlight); /* * Poll buttons. */ for (;;) { mdelay (20); draw_next (pagenum); int key = joystick_get(); /* Light LED when a key is pressed. */ if (key > JOYSTICK_IDLE) led_control (1); else led_control (0); if (key != JOYSTICK_LEFT) left_pressed = 0; else if (! left_pressed) { /* Left button: show previous page of symbols. */ left_pressed = 1; pagenum = (pagenum - 1 + NPAGES) % NPAGES; draw (pagenum); } if (key != JOYSTICK_RIGHT) right_pressed = 0; else if (! right_pressed) { /* Right button: show next page of symbols. */ right_pressed = 1; pagenum = (pagenum + 1) % NPAGES; draw (pagenum); } if (key != JOYSTICK_DOWN) down_pressed = 0; else if (! down_pressed) { /* Down button: switch backlight. */ down_pressed = 1; backlight = !backlight; gpanel_backlight (&display, backlight); } if (key != JOYSTICK_UP) up_pressed = 0; else if (! up_pressed) { /* Up button: contrast control. */ up_pressed = 1; contrast++; if (contrast >= 127) contrast = 0; gpanel_contrast (&display, contrast); gpanel_move (&display, 0, 0); printf (&display, "Vop = %-8u\n", contrast); } } }
/* VIC20-specific initialization. */ int machine_specific_init(void) { int delay; vic20_log = log_open("VIC20"); if (mem_load() < 0) { return -1; } event_init(); /* Setup trap handling. */ traps_init(); if (!video_disabled_mode) { joystick_init(); } gfxoutput_init(); /* Initialize serial traps. If user does not want them, or if the ``drive'' emulation is used, do not install them. */ if (serial_init(vic20_serial_traps) < 0) { return -1; } serial_trap_init(0xa4); serial_iec_bus_init(); /* Initialize RS232 handler. */ rs232drv_init(); vic20_rsuser_init(); /* initialize print devices. */ printer_init(); /* Initialize the tape emulation. */ tape_init(&tapeinit); /* Initialize the datasette emulation. */ datasette_init(); /* Fire up the hardware-level drive emulation. */ drive_init(); disk_image_init(); /* Initialize autostart. */ resources_get_int("AutostartDelay", &delay); if (delay == 0) { delay = 3; /* default */ } autostart_init((CLOCK) (delay * VIC20_PAL_RFSH_PER_SEC * VIC20_PAL_CYCLES_PER_RFSH), 1, 0xcc, 0xd1, 0xd3, 0xd5); #ifdef USE_BEOS_UI /* Pre-init VIC20-specific parts of the menus before vic_init() creates a canvas window with a menubar at the top. This could also be used by other ports, e.g. GTK+... */ vic20ui_init_early(); #endif /* Initialize the VIC-I emulation. */ if (vic_init() == NULL) { return -1; } via1_init(machine_context.via1); via2_init(machine_context.via2); ieeevia1_init(machine_context.ieeevia1); ieeevia2_init(machine_context.ieeevia2); #ifndef COMMON_KBD /* Load the default keymap file. */ if (vic20_kbd_init() < 0) { return -1; } #endif vic20_monitor_init(); /* Initialize vsync and register our hook function. */ vsync_init(machine_vsync_hook); vsync_set_machine_parameter(machine_timing.rfsh_per_sec, machine_timing.cycles_per_sec); /* Initialize native sound chip first */ vic_sound_chip_init(); /* Initialize the sidcart */ sidcart_sound_chip_init(); /* Initialize cartridge based sound chips */ cartridge_sound_chip_init(); /* Initialize userport based sound chips */ userport_dac_sound_chip_init(); drive_sound_init(); video_sound_init(); /* Initialize sound. Notice that this does not really open the audio device yet. */ sound_init(machine_timing.cycles_per_sec, machine_timing.cycles_per_rfsh); /* Initialize keyboard buffer. */ kbdbuf_init(631, 198, 10, (CLOCK)(machine_timing.cycles_per_rfsh * machine_timing.rfsh_per_sec)); /* Initialize the VIC20-specific part of the UI. */ vic20ui_init(); vic20iec_init(); cartridge_init(); #ifdef HAVE_MOUSE mouse_init(); #ifdef HAVE_LIGHTPEN /* Initialize lightpen support and register VIC-I callbacks */ lightpen_init(); lightpen_register_timing_callback(vic_lightpen_timing, 0); lightpen_register_trigger_callback(vic_trigger_light_pen); #endif #endif /* Register joystick callback (for lightpen triggering via fire button) */ joystick_register_machine(via2_check_lightpen); #ifdef HAVE_MIDI midi_init(); #endif machine_drive_stub(); #if defined (USE_XF86_EXTENSIONS) && (defined(USE_XF86_VIDMODE_EXT) || defined (HAVE_XRANDR)) { /* set fullscreen if user used `-fullscreen' on cmdline */ int fs; resources_get_int("UseFullscreen", &fs); if (fs) { resources_set_int("VICFullscreen", 1); } } #endif return 0; }
/* Plus4-specific initialization. */ int machine_specific_init(void) { int delay; plus4_log = log_open("Plus4"); if (mem_load() < 0) { return -1; } event_init(); /* Setup trap handling. */ traps_init(); gfxoutput_init(); #ifdef HAVE_MOUSE /* Initialize mouse support (if present). */ mouse_init(); #endif /* Initialize serial traps. */ if (serial_init(plus4_serial_traps) < 0) { return -1; } serial_trap_init(0xa8); serial_iec_bus_init(); rs232drv_init(); /* Initialize print devices. */ printer_init(); /* Initialize the tape emulation. */ tape_init(&tapeinit); /* Initialize the datasette emulation. */ datasette_init(); /* Fire up the hardware-level drive emulation. */ drive_init(); disk_image_init(); /* Initialize autostart. */ resources_get_int("AutostartDelay", &delay); if (delay == 0) { delay = 2; /* default */ } autostart_init((CLOCK)(delay * PLUS4_PAL_RFSH_PER_SEC * PLUS4_PAL_CYCLES_PER_RFSH), 1, 0, 0xc8, 0xca, -40); /* Initialize the sidcart first */ sidcart_sound_chip_init(); /* Initialize native sound chip */ ted_sound_chip_init(); /* Initialize cartridge based sound chips */ digiblaster_sound_chip_init(); speech_sound_chip_init(); /* Initialize userport based sound chips */ userport_dac_sound_chip_init(); drive_sound_init(); video_sound_init(); /* Initialize sound. Notice that this does not really open the audio device yet. */ sound_init(machine_timing.cycles_per_sec, machine_timing.cycles_per_rfsh); #ifdef USE_BEOS_UI /* Pre-init Plus4-specific parts of the menus before ted_init() creates a canvas window with a menubar at the top. This could also be used by other ports, e.g. GTK+... */ plus4ui_init_early(); #endif if (ted_init() == NULL) { return -1; } acia_init(); #ifndef COMMON_KBD if (plus4_kbd_init() < 0) { return -1; } #endif plus4_monitor_init(); /* Initialize vsync and register our hook function. */ vsync_init(machine_vsync_hook); vsync_set_machine_parameter(machine_timing.rfsh_per_sec, machine_timing.cycles_per_sec); /* Initialize keyboard buffer. */ kbdbuf_init(1319, 239, 8, (CLOCK)(machine_timing.rfsh_per_sec * machine_timing.cycles_per_rfsh)); if (!console_mode) { plus4ui_init(); } if (!video_disabled_mode) { joystick_init(); } cs256k_init(); h256k_init(); plus4iec_init(); machine_drive_stub(); /* Initialize the machine specific I/O */ plus4io_init(); #if defined (USE_XF86_EXTENSIONS) && (defined(USE_XF86_VIDMODE_EXT) || defined (HAVE_XRANDR)) { /* set fullscreen if user used `-fullscreen' on cmdline */ int fs; resources_get_int("UseFullscreen", &fs); if (fs) { resources_set_int("TEDFullscreen", 1); } } #endif return 0; }
int main(int argc, char **argv) { struct config conf; const char*config_filename; struct packet pkt = {0,}; char buf[64] = {0,}; int16_t crc; int default_cfg = 0; int bad_pkts_cnt = 0; int pkt_cnt = 0; if(argc == 2 && !strcmp("--help", argv[1])) { puts("Usage: quadcontrol [config_file.cfg]"); exit(1); } if(argc == 2) config_filename = argv[1]; else config_filename = CONFIG_DEFAULT_FILE; if(config_load(config_filename, &conf)) { fputs("WARNING: Could not load configuration file. Reverting to defaults.\n", stderr); config_default(&conf); config_save(CONFIG_DEFAULT_FILE, &conf); default_cfg = 1; } if(signal(SIGINT, sig_handler) == SIG_ERR) { fputs("ERROR: Could not set a signal handler.\n", stderr); exit(1); } if(joystick_init(conf.joystick_device)) { perror("could not open joystick device"); exit(1); } joystick_set_axis_mapping(conf.joystick_mapping); joystick_set_axis_calibration(conf.joystick_calibration); if(default_cfg) { joystick_calibrate(conf.joystick_calibration); config_save(CONFIG_DEFAULT_FILE, &conf); } if(serial_init(conf.serial_device, conf.serial_speed)) { perror("could not open serial port"); exit(1); } link_init(); active = 1; while(active) { // Prepare & send a packet memset(&pkt, 0, PACKET_TOTAL_SIZE); #ifdef REQUEST_REPORTS // Report request if(pkt_cnt % 2 == 0) { pkt.type = PT_REPORT | RPT_IMU; /*printf("\nreport request sent\n");*/ } else #endif { pkt.type = PT_JOYSTICK; pkt.data.joy.throttle = joystick_get_control_val(THROTTLE_AXIS); pkt.data.joy.yaw = joystick_get_control_val(YAW_AXIS); pkt.data.joy.pitch = joystick_get_control_val(PITCH_AXIS); pkt.data.joy.roll = joystick_get_control_val(ROLL_AXIS); pkt.data.joy.buttons = joystick_get_buttons(); #ifdef SHOW_JOY printf("\nthrottle: %6d\tyaw:%6d\tpitch:%6d\troll:%6d\tbuttons:%6d", pkt.data.joy.throttle, pkt.data.joy.yaw, pkt.data.joy.pitch, pkt.data.joy.roll, pkt.data.joy.buttons); #endif } crc = link_crc(&pkt); serial_write((const uint8_t*) &pkt, PACKET_TOTAL_SIZE); serial_write((const uint8_t*) &crc, CRC_SIZE); #ifdef SHOW_SEND_RAW printf("\nsent: "); for(int i = 0; i < PACKET_TOTAL_SIZE; ++i) printf("%.2x ", ((uint8_t*)(&pkt))[i]); printf("\tcrc = %.2x", crc); #endif // Show response from the radio int cnt = serial_read(buf, sizeof(buf)); if(cnt > 0) { #ifdef SHOW_RECV_RAW // HEX version printf("\treceived: "); for(int i = 0; i < cnt; ++i) printf("%.2x ", (uint8_t) buf[i]); // ASCII version printf(" ("); for(int i = 0; i < cnt; ++i) printf("%c", buf[i]); printf(")"); #endif if(cnt == 1 && buf[0] == 'E') printf("\n!!! DRONE IS NOT RESPONDING !!!\n"); // Parse reports if(buf[0] == 'T' && buf[1] == 'R') { struct packet* pkt = (struct packet*) &buf[2]; if(pkt->type & PT_REPORT) { int report_type = pkt->type & ~PT_REPORT; switch(report_type) { case RPT_MOTOR: printf("motors = FL: %d FR:%d BL:%d BR:%d\n", pkt->data.rpt_motor.fl, pkt->data.rpt_motor.fr, pkt->data.rpt_motor.bl, pkt->data.rpt_motor.br); break; case RPT_IMU: printf("imu = yaw: %d pitch:%d roll:%d\n", pkt->data.rpt_imu.yaw, pkt->data.rpt_imu.pitch, pkt->data.rpt_imu.roll); break; default: printf("invalid report type\n"); break; } } } memset(buf, 0, sizeof(buf)); bad_pkts_cnt = 0; } else { if(++bad_pkts_cnt == 10) { printf("\n!!! CONTROLLER IS NOT RESPONDING !!!\n"); //link_init(); } } ++pkt_cnt; fflush(stdout); usleep(45000); } serial_close(); joystick_close(); config_save(CONFIG_DEFAULT_FILE, &conf); return 1; }
/** * @brief The entry point of Naev. * * @param[in] argc Number of arguments. * @param[in] argv Array of argc arguments. * @return EXIT_SUCCESS on success. */ int main( int argc, char** argv ) { char buf[PATH_MAX]; /* Save the binary path. */ binary_path = strdup(argv[0]); /* Print the version */ LOG( " "APPNAME" v%s", naev_version(0) ); #ifdef GIT_COMMIT DEBUG( " git HEAD at " GIT_COMMIT ); #endif /* GIT_COMMIT */ /* Initializes SDL for possible warnings. */ SDL_Init(0); /* Initialize the threadpool */ threadpool_init(); /* Set up debug signal handlers. */ debug_sigInit(); /* Must be initialized before input_init is called. */ if (SDL_InitSubSystem(SDL_INIT_VIDEO) < 0) { WARN("Unable to initialize SDL Video: %s", SDL_GetError()); return -1; } /* Get desktop dimensions. */ #if SDL_VERSION_ATLEAST(1,2,10) const SDL_VideoInfo *vidinfo = SDL_GetVideoInfo(); gl_screen.desktop_w = vidinfo->current_w; gl_screen.desktop_h = vidinfo->current_h; #else /* #elif SDL_VERSION_ATLEAST(1,2,10) */ gl_screen.desktop_w = 0; gl_screen.desktop_h = 0; #endif /* #elif SDL_VERSION_ATLEAST(1,2,10) */ /* We'll be parsing XML. */ LIBXML_TEST_VERSION xmlInitParser(); /* Input must be initialized for config to work. */ input_init(); conf_setDefaults(); /* set the default config values */ /* * Attempts to load the data path from datapath.lua * At this early point in the load process, the binary path * is the only place likely to be checked. */ conf_loadConfigPath(); /* Parse the user data path override first. */ conf_parseCLIPath( argc, argv ); /* Create the home directory if needed. */ if (nfile_dirMakeExist("%s", nfile_configPath())) WARN("Unable to create config directory '%s'", nfile_configPath()); /* Set the configuration. */ nsnprintf(buf, PATH_MAX, "%s"CONF_FILE, nfile_configPath()); #if HAS_UNIX /* TODO get rid of this cruft ASAP. */ int oldconfig = 0; if (!nfile_fileExists( buf )) { char *home, buf2[PATH_MAX]; home = SDL_getenv( "HOME" ); if (home != NULL) { nsnprintf( buf2, PATH_MAX, "%s/.naev/"CONF_FILE, home ); if (nfile_fileExists( buf2 )) oldconfig = 1; } } #endif /* HAS_UNIX */ conf_loadConfig(buf); /* Lua to parse the configuration file */ conf_parseCLI( argc, argv ); /* parse CLI arguments */ /* Enable FPU exceptions. */ #if defined(HAVE_FEENABLEEXCEPT) && defined(DEBUGGING) if (conf.fpu_except) feenableexcept( FE_DIVBYZERO | FE_INVALID | FE_OVERFLOW ); #endif /* defined(HAVE_FEENABLEEXCEPT) && defined(DEBUGGING) */ /* Open data. */ if (ndata_open() != 0) ERR("Failed to open ndata."); /* Load the start info. */ if (start_load()) ERR("Failed to load module start data."); /* Load the data basics. */ LOG(" %s", ndata_name()); DEBUG(); /* Display the SDL Version. */ print_SDLversion(); DEBUG(); /* random numbers */ rng_init(); /* * OpenGL */ if (gl_init()) { /* initializes video output */ ERR("Initializing video output failed, exiting..."); SDL_Quit(); exit(EXIT_FAILURE); } window_caption(); gl_fontInit( NULL, NULL, conf.font_size_def ); /* initializes default font to size */ gl_fontInit( &gl_smallFont, NULL, conf.font_size_small ); /* small font */ /* Display the load screen. */ loadscreen_load(); loadscreen_render( 0., "Initializing subsystems..." ); time_ms = SDL_GetTicks(); /* * Input */ if ((conf.joystick_ind >= 0) || (conf.joystick_nam != NULL)) { if (joystick_init()) WARN("Error initializing joystick input"); if (conf.joystick_nam != NULL) { /* use the joystick name to find a joystick */ if (joystick_use(joystick_get(conf.joystick_nam))) { WARN("Failure to open any joystick, falling back to default keybinds"); input_setDefault(); } free(conf.joystick_nam); } else if (conf.joystick_ind >= 0) /* use a joystick id instead */ if (joystick_use(conf.joystick_ind)) { WARN("Failure to open any joystick, falling back to default keybinds"); input_setDefault(); } } /* * OpenAL - Sound */ if (conf.nosound) { LOG("Sound is disabled!"); sound_disabled = 1; music_disabled = 1; } if (sound_init()) WARN("Problem setting up sound!"); music_choose("load"); /* FPS stuff. */ fps_setPos( 15., (double)(gl_screen.h-15-gl_defFont.h) ); /* Misc graphics init */ if (nebu_init() != 0) { /* Initializes the nebula */ /* An error has happened */ ERR("Unable to initialize the Nebula subsystem!"); /* Weirdness will occur... */ } gui_init(); /* initializes the GUI graphics */ toolkit_init(); /* initializes the toolkit */ map_init(); /* initializes the map. */ cond_init(); /* Initialize conditional subsystem. */ cli_init(); /* Initialize console. */ /* Data loading */ load_all(); /* Generate the CSV. */ if (conf.devcsv) dev_csv(); /* Unload load screen. */ loadscreen_unload(); /* Start menu. */ menu_main(); /* Force a minimum delay with loading screen */ if ((SDL_GetTicks() - time_ms) < NAEV_INIT_DELAY) SDL_Delay( NAEV_INIT_DELAY - (SDL_GetTicks() - time_ms) ); fps_init(); /* initializes the time_ms */ #if HAS_UNIX /* Tell the player to migrate their configuration files out of ~/.naev */ /* TODO get rid of this cruft ASAP. */ if ((oldconfig) && (!conf.datapath)) { char path[PATH_MAX], *script, *home; uint32_t scriptsize; int ret; nsnprintf( path, PATH_MAX, "%s/naev-confupdate.sh", ndata_getDirname() ); home = SDL_getenv("HOME"); ret = dialogue_YesNo( "Warning", "Your configuration files are in a deprecated location and must be migrated:\n" " \er%s/.naev/\e0\n\n" "The update script can likely be found in your Naev data directory:\n" " \er%s\e0\n\n" "Would you like to run it automatically?", home, path ); /* Try to run the script. */ if (ret) { ret = -1; /* Running from ndata. */ if (ndata_getPath() != NULL) { script = ndata_read( "naev-confupdate.sh", &scriptsize ); if (script != NULL) ret = system(script); } /* Running from laid-out files or ndata_read failed. */ if ((nfile_fileExists(path)) && (ret == -1)) { script = nfile_readFile( (int*)&scriptsize, path ); if (script != NULL) ret = system(script); } /* We couldn't find the script. */ if (ret == -1) { dialogue_alert( "The update script was not found at:\n\er%s\e0\n\n" "Please locate and run it manually.", path ); } /* Restart, as the script succeeded. */ else if (!ret) { dialogue_msg( "Update Completed", "Configuration files were successfully migrated. Naev will now restart." ); execv(argv[0], argv); } else { /* I sincerely hope this else is never hit. */ dialogue_alert( "The update script encountered an error. Please exit Naev and move your config and save files manually:\n\n" "\er%s/%s\e0 =>\n \eD%s\e0\n\n" "\er%s/%s\e0 =>\n \eD%s\e0\n\n" "\er%s/%s\e0 =>\n \eD%snebula/\e0\n\n", home, ".naev/conf.lua", nfile_configPath(), home, ".naev/{saves,screenshots}/", nfile_dataPath(), home, ".naev/gen/*.png", nfile_cachePath() ); } } else {
/* CBM-II-specific initialization. */ int machine_specific_init(void) { cbm2_log = log_open("CBM2"); cbm2_init_ok = 1; event_init(); /* Setup trap handling - must be before mem_load() */ traps_init(); if (mem_load() < 0) { return -1; } if (!video_disabled_mode) { joystick_init(); } gfxoutput_init(); rs232drv_init(); /* initialize print devices */ printer_init(); #ifdef USE_BEOS_UI /* Pre-init CBM-II-specific parts of the menus before crtc_init() creates a canvas window with a menubar at the top. This could also be used by other ports, e.g. GTK+... */ cbm2ui_init_early(); #endif if (crtc_init() == NULL) { return -1; } crtc_set_retrace_callback(cbm2_crtc_signal); crtc_set_retrace_type(0); crtc_set_hw_options(1, 0x7ff, 0x1000, 512, -0x2000); cia1_init(machine_context.cia1); acia1_init(); tpi1_init(machine_context.tpi1); tpi2_init(machine_context.tpi2); #ifndef COMMON_KBD /* Initialize the keyboard. */ if (cbm2_kbd_init() < 0) { return -1; } #endif /* Initialize the datasette emulation. */ datasette_init(); /* Fire up the hardware-level 1541 emulation. */ drive_init(); disk_image_init(); cbm2_monitor_init(); /* Initialize vsync and register our hook function. */ vsync_init(machine_vsync_hook); vsync_set_machine_parameter(machine_timing.rfsh_per_sec, machine_timing.cycles_per_sec); /* Initialize native sound chip */ sid_sound_chip_init(); /* Initialize userport based sound chips */ userport_dac_sound_chip_init(); userport_digimax_sound_chip_init(); drive_sound_init(); video_sound_init(); /* Initialize sound. Notice that this does not really open the audio device yet. */ sound_init(machine_timing.cycles_per_sec, machine_timing.cycles_per_rfsh); /* Initialize keyboard buffer. This appears to work but doesn't account for banking. */ kbdbuf_init(939, 209, 10, (CLOCK)(machine_timing.rfsh_per_sec * machine_timing.cycles_per_rfsh)); /* Initialize the CBM-II-specific part of the UI. */ cbm2ui_init(); cbm2iec_init(); #ifdef HAVE_MOUSE /* Initialize mouse support (if present). */ mouse_init(); #endif machine_drive_stub(); /* Initialize the CBM2-specific I/O */ cbm2io_init(); #if defined (USE_XF86_EXTENSIONS) && (defined(USE_XF86_VIDMODE_EXT) || defined (HAVE_XRANDR)) { /* set fullscreen if user used `-fullscreen' on cmdline */ int fs; resources_get_int("UseFullscreen", &fs); if (fs) { resources_set_int("CRTCFullscreen", 1); } } #endif return 0; }
/** * @brief The entry point of NAEV. * * @param[in] argc Number of arguments. * @param[in] argv Array of argc arguments. * @return EXIT_SUCCESS on success. */ int main( int argc, char** argv ) { char buf[PATH_MAX]; /* Save the binary path. */ binary_path = argv[0]; /* Print the version */ LOG( " "APPNAME" v%s", naev_version(0) ); #ifdef GIT_COMMIT DEBUG( " git HEAD at " GIT_COMMIT ); #endif /* GIT_COMMIT */ /* Initializes SDL for possible warnings. */ SDL_Init(0); /* Set up debug signal handlers. */ debug_sigInit(); /* Create the home directory if needed. */ if (nfile_dirMakeExist("%s", nfile_basePath())) WARN("Unable to create naev directory '%s'", nfile_basePath()); /* Must be initialized before input_init is called. */ if (SDL_InitSubSystem(SDL_INIT_VIDEO) < 0) { WARN("Unable to initialize SDL Video: %s", SDL_GetError()); return -1; } /* Get desktop dimensions. */ #if SDL_VERSION_ATLEAST(1,2,10) const SDL_VideoInfo *vidinfo = SDL_GetVideoInfo(); gl_screen.desktop_w = vidinfo->current_w; gl_screen.desktop_h = vidinfo->current_h; #else /* #elif SDL_VERSION_ATLEAST(1,2,10) */ gl_screen.desktop_w = 0; gl_screen.desktop_h = 0; #endif /* #elif SDL_VERSION_ATLEAST(1,2,10) */ /* We'll be parsing XML. */ LIBXML_TEST_VERSION xmlInitParser(); /* Input must be initialized for config to work. */ input_init(); /* Set the configuration. */ snprintf(buf, PATH_MAX, "%s"CONF_FILE, nfile_basePath()); conf_setDefaults(); /* set the default config values */ conf_loadConfig(buf); /* Lua to parse the configuration file */ conf_parseCLI( argc, argv ); /* parse CLI arguments */ /* Enable FPU exceptions. */ #if !(HAS_WIN32) && defined(DEBUGGING) if (conf.fpu_except) feenableexcept( FE_DIVBYZERO | FE_INVALID | FE_OVERFLOW ); #endif /* DEBUGGING */ /* Open data. */ if (ndata_open() != 0) ERR("Failed to open ndata."); /* Load the data basics. */ LOG(" %s", ndata_name()); DEBUG(); /* Display the SDL Version. */ print_SDLversion(); DEBUG(); /* random numbers */ rng_init(); /* * OpenGL */ if (gl_init()) { /* initializes video output */ ERR("Initializing video output failed, exiting..."); SDL_Quit(); exit(EXIT_FAILURE); } window_caption(); gl_fontInit( NULL, NULL, FONT_SIZE ); /* initializes default font to size */ gl_fontInit( &gl_smallFont, NULL, FONT_SIZE_SMALL ); /* small font */ /* Display the load screen. */ loadscreen_load(); loadscreen_render( 0., "Initializing subsystems..." ); time = SDL_GetTicks(); /* * Input */ if ((conf.joystick_ind >= 0) || (conf.joystick_nam != NULL)) { if (joystick_init()) WARN("Error initializing joystick input"); if (conf.joystick_nam != NULL) { /* use the joystick name to find a joystick */ if (joystick_use(joystick_get(conf.joystick_nam))) { WARN("Failure to open any joystick, falling back to default keybinds"); input_setDefault(); } free(conf.joystick_nam); } else if (conf.joystick_ind >= 0) /* use a joystick id instead */ if (joystick_use(conf.joystick_ind)) { WARN("Failure to open any joystick, falling back to default keybinds"); input_setDefault(); } } /* * OpenAL - Sound */ if (conf.nosound) { LOG("Sound is disabled!"); sound_disabled = 1; music_disabled = 1; } if (sound_init()) WARN("Problem setting up sound!"); music_choose("load"); /* Misc graphics init */ if (nebu_init() != 0) { /* Initializes the nebula */ /* An error has happened */ ERR("Unable to initialize the Nebula subsystem!"); /* Weirdness will occur... */ } gui_init(); /* initializes the GUI graphics */ toolkit_init(); /* initializes the toolkit */ map_init(); /* initializes the map. */ cond_init(); /* Initialize conditional subsystem. */ /* Data loading */ load_all(); /* Unload load screen. */ loadscreen_unload(); /* Start menu. */ menu_main(); /* Force a minimum delay with loading screen */ if ((SDL_GetTicks() - time) < NAEV_INIT_DELAY) SDL_Delay( NAEV_INIT_DELAY - (SDL_GetTicks() - time) ); time = SDL_GetTicks(); /* initializes the time */ /* * main loop */ SDL_Event event; /* flushes the event loop since I noticed that when the joystick is loaded it * creates button events that results in the player starting out acceling */ while (SDL_PollEvent(&event)); /* primary loop */ while (!quit) { while (SDL_PollEvent(&event)) { /* event loop */ if (event.type == SDL_QUIT) quit = 1; /* quit is handled here */ input_handle(&event); /* handles all the events and player keybinds */ } main_loop(); } /* Save configuration. */ conf_saveConfig(buf); /* cleanup some stuff */ player_cleanup(); /* cleans up the player stuff */ gui_free(); /* cleans up the player's GUI */ weapon_exit(); /* destroys all active weapons */ pilots_free(); /* frees the pilots, they were locked up :( */ cond_exit(); /* destroy conditional subsystem. */ land_exit(); /* Destroys landing vbo and friends. */ /* data unloading */ unload_all(); /* cleanup opengl fonts */ gl_freeFont(NULL); gl_freeFont(&gl_smallFont); /* Close data. */ ndata_close(); /* Destroy conf. */ conf_cleanup(); /* Frees some memory the configuration allocated. */ /* exit subsystems */ map_exit(); /* destroys the map. */ toolkit_exit(); /* kills the toolkit */ ai_exit(); /* stops the Lua AI magic */ joystick_exit(); /* releases joystick */ input_exit(); /* cleans up keybindings */ nebu_exit(); /* destroys the nebula */ gl_exit(); /* kills video output */ sound_exit(); /* kills the sound */ news_exit(); /* destroys the news. */ /* Free the icon. */ if (naev_icon) free(naev_icon); SDL_Quit(); /* quits SDL */ /* all is well */ exit(EXIT_SUCCESS); }
void corange_init(const char* core_assets_path) { /* Attach signal handlers */ signal(SIGABRT, corange_signal); signal(SIGFPE, corange_signal); signal(SIGILL, corange_signal); signal(SIGINT, corange_signal); signal(SIGSEGV, corange_signal); signal(SIGTERM, corange_signal); logout = fopen("output.log", "w"); at_error(corange_error); at_warning(corange_warning); at_debug(corange_debug); /* Starting Corange */ debug("Starting Corange..."); /* Asset Manager */ debug("Creating Asset Manager..."); debug("Core Assets At '%s' ...", core_assets_path); asset_init(); asset_add_path_variable(P("$CORANGE"), P(core_assets_path)); asset_handler(renderable, "bmf", bmf_load_file, renderable_delete); asset_handler(renderable, "obj", obj_load_file, renderable_delete); asset_handler(renderable, "smd", smd_load_file, renderable_delete); asset_handler(renderable, "ply", ply_load_file, renderable_delete); asset_handler(skeleton, "skl", skl_load_file, skeleton_delete); asset_handler(animation, "ani", ani_load_file, animation_delete); asset_handler(cmesh, "col", col_load_file, cmesh_delete); asset_handler(terrain, "raw", raw_load_file, terrain_delete); asset_handler(texture, "bmp", bmp_load_file, texture_delete); asset_handler(texture, "tga", tga_load_file, texture_delete); asset_handler(texture, "dds", dds_load_file, texture_delete); asset_handler(texture, "lut", lut_load_file, texture_delete); asset_handler(texture, "acv", acv_load_file, texture_delete); asset_handler(shader, "vs" , vs_load_file, shader_delete); asset_handler(shader, "fs" , fs_load_file, shader_delete); asset_handler(shader, "gs" , gs_load_file, shader_delete); asset_handler(shader, "tcs" , tcs_load_file, shader_delete); asset_handler(shader, "tes" , tes_load_file, shader_delete); asset_handler(config, "cfg", cfg_load_file, config_delete); asset_handler(lang, "lang", lang_load_file, lang_delete); asset_handler(font, "fnt", font_load_file, font_delete); asset_handler(material, "mat", mat_load_file, material_delete); asset_handler(effect, "effect" , effect_load_file, effect_delete); asset_handler(sound, "wav", wav_load_file, sound_delete); asset_handler(music, "ogg", ogg_load_file, music_delete); asset_handler(music, "mp3", mp3_load_file, music_delete); /* Entity Manager */ debug("Creating Entity Manager..."); entity_init(); entity_handler(static_object, static_object_new, static_object_delete); entity_handler(animated_object, animated_object_new, animated_object_delete); entity_handler(physics_object, physics_object_new, physics_object_delete); entity_handler(instance_object, instance_object_new, instance_object_delete); entity_handler(camera, camera_new, camera_delete); entity_handler(light, light_new, light_delete); entity_handler(landscape, landscape_new, landscape_delete); entity_handler(particles, particles_new, particles_delete); /* UI Manager */ debug("Creating UI Manager..."); ui_init(); ui_handler(ui_rectangle, ui_rectangle_new, ui_rectangle_delete, ui_rectangle_event, ui_rectangle_update, ui_rectangle_render); ui_handler(ui_text, ui_text_new, ui_text_delete, ui_text_event, ui_text_update, ui_text_render); ui_handler(ui_spinner, ui_spinner_new, ui_spinner_delete, ui_spinner_event, ui_spinner_update, ui_spinner_render); ui_handler(ui_button, ui_button_new, ui_button_delete, ui_button_event, ui_button_update, ui_button_render); ui_handler(ui_textbox, ui_textbox_new, ui_textbox_delete, ui_textbox_event, ui_textbox_update, ui_textbox_render); ui_handler(ui_browser, ui_browser_new, ui_browser_delete, ui_browser_event, ui_browser_update, ui_browser_render); ui_handler(ui_toast, ui_toast_new, ui_toast_delete, ui_toast_event, ui_toast_update, ui_toast_render); ui_handler(ui_dialog, ui_dialog_new, ui_dialog_delete, ui_dialog_event, ui_dialog_update, ui_dialog_render); ui_handler(ui_listbox, ui_listbox_new, ui_listbox_delete, ui_listbox_event, ui_listbox_update, ui_listbox_render); ui_handler(ui_option, ui_option_new, ui_option_delete, ui_option_event, ui_option_update, ui_option_render); ui_handler(ui_slider, ui_slider_new, ui_slider_delete, ui_slider_event, ui_slider_update, ui_slider_render); /* Graphics Manager */ debug("Creating Graphics Manager..."); graphics_init(); /* Audio Manager */ debug("Creating Audio Manager..."); audio_init(); /* Joystick Manager */ debug("Creating Joystick Manager..."); joystick_init(); /* Network Manager */ debug("Creating Network Manager..."); net_init(); debug("Finished!"); }
/* C128-specific initialization. */ int machine_specific_init(void) { int delay; c128_log = log_open("C128"); if (mem_load() < 0) { return -1; } event_init(); if (z80mem_load() < 0) { return -1; } /* Setup trap handling. */ traps_init(); /* Initialize serial traps. */ if (serial_init(c128_serial_traps) < 0) { return -1; } serial_trap_init(0xa4); serial_iec_bus_init(); if (!video_disabled_mode) { joystick_init(); } gfxoutput_init(); /* initialize RS232 handler */ rs232drv_init(); c64_rsuser_init(); /* initialize print devices */ printer_init(); /* Initialize the tape emulation. */ machine_tape_init_c128(); /* Initialize the datasette emulation. */ datasette_init(); /* Fire up the hardware-level drive emulation. */ drive_init(); disk_image_init(); /* Initialize autostart. FIXME: at least 0xa26 is only for 40 cols */ resources_get_int("AutostartDelay", &delay); if (delay == 0) { delay = 3; /* default */ } autostart_init((CLOCK)(delay * C128_PAL_RFSH_PER_SEC * C128_PAL_CYCLES_PER_RFSH), 1, 0xa27, 0xe0, 0xec, 0xee); #ifdef USE_BEOS_UI /* Pre-init C128-specific parts of the menus before vdc_init() and vicii_init() create canvas windows with menubars at the top. This could also be used by other ports, e.g. GTK+... */ c128ui_init_early(); #endif if (vdc_init() == NULL) { return -1; } if (vicii_init(VICII_EXTENDED) == NULL) { return -1; } cia1_init(machine_context.cia1); cia2_init(machine_context.cia2); #ifndef COMMON_KBD /* Initialize the keyboard. */ if (c128_kbd_init() < 0) { return -1; } #endif c64keyboard_init(); c128_monitor_init(); /* Initialize vsync and register our hook function. */ vsync_init(machine_vsync_hook); vsync_set_machine_parameter(machine_timing.rfsh_per_sec, machine_timing.cycles_per_sec); /* Initialize native sound chip */ sid_sound_chip_init(); /* Initialize cartridge based sound chips */ cartridge_sound_chip_init(); drive_sound_init(); video_sound_init(); /* Initialize sound. Notice that this does not really open the audio device yet. */ sound_init(machine_timing.cycles_per_sec, machine_timing.cycles_per_rfsh); /* Initialize keyboard buffer. */ kbdbuf_init(842, 208, 10, (CLOCK)(machine_timing.rfsh_per_sec * machine_timing.cycles_per_rfsh)); /* Initialize the C128-specific I/O */ c128io_init(); /* Initialize the C128-specific part of the UI. */ c128ui_init(); #ifdef HAVE_MOUSE /* Initialize mouse support (if present). */ mouse_init(); #ifdef HAVE_LIGHTPEN /* Initialize lightpen support and register VICII/VDC callbacks */ lightpen_init(); lightpen_register_timing_callback(vicii_lightpen_timing, 1); lightpen_register_timing_callback(vdc_lightpen_timing, 0); lightpen_register_trigger_callback(c128_trigger_light_pen); #endif #endif c64iec_init(); c128fastiec_init(); cartridge_init(); mmu_init(); machine_drive_stub(); #if defined (USE_XF86_EXTENSIONS) && (defined(USE_XF86_VIDMODE_EXT) || defined (HAVE_XRANDR)) { /* set fullscreen if user used `-fullscreen' on cmdline use VICII as default */ int fs; resources_get_int("UseFullscreen", &fs); if (fs) { resources_get_int("40/80ColumnKey", &fs); if (fs == 1) { resources_set_int("VICIIFullscreen", 1); } else { resources_set_int("VDCFullscreen", 1); } } } #endif return 0; }
void initpc() { char *p; // allegro_init(); get_executable_name(pcempath,511); pclog("executable_name = %s\n", pcempath); p=get_filename(pcempath); *p=0; pclog("path = %s\n", pcempath); fdd_init(); keyboard_init(); mouse_init(); joystick_init(); midi_init(); loadconfig(NULL); pclog("Config loaded\n"); loadfont("mda.rom", 0, cga_fontdat, cga_fontdatm); loadfont("roms/pc1512/40078.ic127", 0, pc1512_fontdat, pc1512_fontdatm); loadfont("roms/pc200/40109.bin", 0, pc200_fontdat, pc200_fontdatm); codegen_init(); cpuspeed2=(AT)?2:1; // cpuspeed2=cpuspeed; atfullspeed=0; device_init(); initvideo(); mem_init(); loadbios(); mem_add_bios(); timer_reset(); sound_reset(); fdc_init(); // #ifdef USE_NETWORKING vlan_reset(); //NETWORK network_card_init(network_card_current); // #endif loaddisc(0,discfns[0]); loaddisc(1,discfns[1]); //loadfont(); loadnvr(); sound_init(); resetide(); #if __unix if (cdrom_drive == -1) cdrom_null_open(cdrom_drive); else #endif ioctl_open(cdrom_drive); pit_reset(); /* if (romset==ROM_AMI386 || romset==ROM_AMI486) */fullspeed(); ali1429_reset(); // CPUID=(is486 && (cpuspeed==7 || cpuspeed>=9)); // pclog("Init - CPUID %i %i\n",CPUID,cpuspeed); shadowbios=0; #if __unix if (cdrom_drive == -1) cdrom_null_reset(); else #endif ioctl_reset(); }
void input_init(void) { buttons_init(); joystick_init(); adc_init(); }