/* Plus4-specific initialization. */ int machine_specific_init(void) { int delay; plus4_log = log_open("Plus4"); if (mem_load() < 0) return -1; /* Setup trap handling. */ traps_init(); /* 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(); /* 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), 0, 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(); 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); 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)); plus4ui_init(); cs256k_init(); h256k_init(); plus4iec_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("TEDFullscreen", 1); } } #endif return 0; }
/* Plus4-specific initialization. */ int machine_specific_init(void) { plus4_log = log_open("Plus4"); if (mem_load() < 0) return -1; /* Setup trap handling. */ traps_init(); /* 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(); /* Initialize autostart. */ autostart_init((CLOCK)(2 * PLUS4_PAL_RFSH_PER_SEC * PLUS4_PAL_CYCLES_PER_RFSH), 0, 0, 0xc8, 0xca, -40); /* 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); 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)); plus4ui_init(); cs256k_init(); h256k_init(); plus4iec_init(); machine_drive_stub(); 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[]) { int c; struct state *state = NULL; #if TEST_BUILD struct test_case *test_case; #endif prefs_init(); while(1) { int option_index = 0; static struct option long_options[] = { {"cart", required_argument, 0, OPT_CART }, {"force-extreme-disasm", no_argument, 0, OPT_FORCE_EXTREME_DISASM }, {"crop-screen", no_argument, 0, OPT_CROP_SCREEN }, {"loglevels" , required_argument, 0, OPT_LOGLEVELS }, {"audio-device" , required_argument, 0, OPT_AUDIO_DEVICE }, #if TEST_BUILD {"test-case", required_argument, 0, OPT_TEST_MODE}, #endif {0, 0, 0, 0 } }; c = getopt_long(argc, argv, "a:b:c:t:s:hdpyVAMvq", long_options, &option_index); if(c == -1) break; switch(c) { case 'a': prefs_set("diskimage", optarg); break; case 'b': prefs_set("diskimage2", optarg); break; case 'c': prefs_set("hdimage", optarg); break; case 't': prefs_set("tosimage", optarg); break; case 's': prefs_set("stateimage", optarg); break; case OPT_CART: prefs_set("cartimage", optarg); break; case OPT_FORCE_EXTREME_DISASM: cprint_all = 1; break; case OPT_CROP_SCREEN: crop_screen = 1; break; case OPT_LOGLEVELS: diag_set_module_levels(optarg); break; case OPT_AUDIO_DEVICE: if(!strncmp("list", optarg, 4)) { audio_device = -1; } else { audio_device = atoi(optarg); } break; #if TEST_BUILD case OPT_TEST_MODE: test_case_name = xstrdup(optarg); test_mode = 1; break; #endif case 'd': debugger = 1; break; case 'p': ppmoutput = 1; break; case 'y': psgoutput = 1; break; case 'v': verbosity++; break; case 'q': verbosity = MAX(1, verbosity-1); break; case 'V': vsync_delay = 1; break; case 'A': play_audio = 1; break; case 'M': monitor_sm124 = 1; break; case 'h': default: printf("Usage: %s [-AdMpqvVy] [-a diskimage1] [-b diskimage2] [-c hdimage] [-t tosimage] [-s stateimage]\n", argv[0]); exit(-1); break; } } /* Do not crop screen while debugging */ if(debugger) { crop_screen = 0; } if((prefs.diskimage == NULL) && (argv[optind] != NULL)) prefs_set("diskimage", argv[optind]); SDL_Init(SDL_INIT_VIDEO|SDL_INIT_JOYSTICK|SDL_INIT_AUDIO); #if TEST_BUILD if(test_mode) { test_case = test_init(test_case_name); if(test_case) { if(test_case->cartridge_name) { prefs_set("cartimage", test_case->cartridge_name); } if(test_case->floppy_name) { prefs_set("diskimage", test_case->floppy_name); } } else { printf("DEBUG: Could not load test case %s\n", test_case_name); exit(-3); } } #endif /* Must run before hardware module inits */ mmu_init(); /* This must also be run before hardware modules. It gives a dummy area for some memory regions to not cause bus errors */ mmu_fallback_init(); /* Actual hardware */ ram_init(); rom_init(); cpu_init(); if(prefs.cartimage) { cartridge_init(prefs.cartimage); } else { cartridge_init(NULL); } psg_init(); midi_init(); acia_init(); ikbd_init(); #if INCLUDE_RTC rtc_init(); #endif dma_init(); fdc_init(); hdc_init(prefs.hdimage); mfp_init(); screen_disable(0); glue_init(); shifter_init(); if(debugger) { debug_init(); cpu_halt_for_debug(); } screen_init(); floppy_init(prefs.diskimage, prefs.diskimage2); if(prefs.stateimage) { state = state_load(prefs.stateimage); } if(state != NULL) state_restore(state); memset(&reset, 0, sizeof reset); reset.sa_sigaction = reset_action; sigaction(SIGHUP, &reset, NULL); while(cpu_run(CPU_RUN)); return 0; }