void machine_change_timing(int timeval) { int border_mode; switch (timeval) { default: case MACHINE_SYNC_PAL ^ VICII_BORDER_MODE(VICII_NORMAL_BORDERS): case MACHINE_SYNC_NTSC ^ VICII_BORDER_MODE(VICII_NORMAL_BORDERS): timeval ^= VICII_BORDER_MODE(VICII_NORMAL_BORDERS); border_mode = VICII_NORMAL_BORDERS; break; case MACHINE_SYNC_PAL ^ VICII_BORDER_MODE(VICII_FULL_BORDERS): case MACHINE_SYNC_NTSC ^ VICII_BORDER_MODE(VICII_FULL_BORDERS): timeval ^= VICII_BORDER_MODE(VICII_FULL_BORDERS); border_mode = VICII_FULL_BORDERS; break; case MACHINE_SYNC_PAL ^ VICII_BORDER_MODE(VICII_DEBUG_BORDERS): case MACHINE_SYNC_NTSC ^ VICII_BORDER_MODE(VICII_DEBUG_BORDERS): timeval ^= VICII_BORDER_MODE(VICII_DEBUG_BORDERS); border_mode = VICII_DEBUG_BORDERS; break; } switch (timeval) { case MACHINE_SYNC_PAL: machine_timing.cycles_per_sec = C128_PAL_CYCLES_PER_SEC; machine_timing.cycles_per_rfsh = C128_PAL_CYCLES_PER_RFSH; machine_timing.rfsh_per_sec = C128_PAL_RFSH_PER_SEC; machine_timing.cycles_per_line = C128_PAL_CYCLES_PER_LINE; machine_timing.screen_lines = C128_PAL_SCREEN_LINES; break; case MACHINE_SYNC_NTSC: machine_timing.cycles_per_sec = C128_NTSC_CYCLES_PER_SEC; machine_timing.cycles_per_rfsh = C128_NTSC_CYCLES_PER_RFSH; machine_timing.rfsh_per_sec = C128_NTSC_RFSH_PER_SEC; machine_timing.cycles_per_line = C128_NTSC_CYCLES_PER_LINE; machine_timing.screen_lines = C128_NTSC_SCREEN_LINES; break; default: log_error(c128_log, "Unknown machine timing."); } vsync_set_machine_parameter(machine_timing.rfsh_per_sec, machine_timing.cycles_per_sec); sound_set_machine_parameter(machine_timing.cycles_per_sec, machine_timing.cycles_per_rfsh); debug_set_machine_parameter(machine_timing.cycles_per_line, machine_timing.screen_lines); drive_set_machine_parameter(machine_timing.cycles_per_sec); serial_iec_device_set_machine_parameter(machine_timing.cycles_per_sec); sid_set_machine_parameter(machine_timing.cycles_per_sec); clk_guard_set_clk_base(maincpu_clk_guard, machine_timing.cycles_per_rfsh); vicii_change_timing(&machine_timing, border_mode); cia1_set_timing(machine_context.cia1, machine_timing.cycles_per_rfsh); cia2_set_timing(machine_context.cia2, machine_timing.cycles_per_rfsh); machine_trigger_reset(MACHINE_RESET_MODE_HARD); }
void machine_change_timing(int timeval, int border_mode) { switch (timeval) { case MACHINE_SYNC_PAL: machine_timing.cycles_per_sec = C64_PAL_CYCLES_PER_SEC; machine_timing.cycles_per_rfsh = C64_PAL_CYCLES_PER_RFSH; machine_timing.rfsh_per_sec = C64_PAL_RFSH_PER_SEC; machine_timing.cycles_per_line = C64_PAL_CYCLES_PER_LINE; machine_timing.screen_lines = C64_PAL_SCREEN_LINES; machine_timing.power_freq = 50; break; case MACHINE_SYNC_NTSC: machine_timing.cycles_per_sec = C64_NTSC_CYCLES_PER_SEC; machine_timing.cycles_per_rfsh = C64_NTSC_CYCLES_PER_RFSH; machine_timing.rfsh_per_sec = C64_NTSC_RFSH_PER_SEC; machine_timing.cycles_per_line = C64_NTSC_CYCLES_PER_LINE; machine_timing.screen_lines = C64_NTSC_SCREEN_LINES; machine_timing.power_freq = 60; break; case MACHINE_SYNC_NTSCOLD: machine_timing.cycles_per_sec = C64_NTSCOLD_CYCLES_PER_SEC; machine_timing.cycles_per_rfsh = C64_NTSCOLD_CYCLES_PER_RFSH; machine_timing.rfsh_per_sec = C64_NTSCOLD_RFSH_PER_SEC; machine_timing.cycles_per_line = C64_NTSCOLD_CYCLES_PER_LINE; machine_timing.screen_lines = C64_NTSCOLD_SCREEN_LINES; machine_timing.power_freq = 60; break; case MACHINE_SYNC_PALN: machine_timing.cycles_per_sec = C64_PALN_CYCLES_PER_SEC; machine_timing.cycles_per_rfsh = C64_PALN_CYCLES_PER_RFSH; machine_timing.rfsh_per_sec = C64_PALN_RFSH_PER_SEC; machine_timing.cycles_per_line = C64_PALN_CYCLES_PER_LINE; machine_timing.screen_lines = C64_PALN_SCREEN_LINES; machine_timing.power_freq = 50; break; default: log_error(c64_log, "Unknown machine timing."); } vsync_set_machine_parameter(machine_timing.rfsh_per_sec, machine_timing.cycles_per_sec); sound_set_machine_parameter(machine_timing.cycles_per_sec, machine_timing.cycles_per_rfsh); debug_set_machine_parameter(machine_timing.cycles_per_line, machine_timing.screen_lines); sid_set_machine_parameter(machine_timing.cycles_per_sec); clk_guard_set_clk_base(maincpu_clk_guard, machine_timing.cycles_per_rfsh); vicii_change_timing(&machine_timing); cia1_set_timing(machine_context.cia1, machine_timing.cycles_per_sec, machine_timing.power_freq); cia2_set_timing(machine_context.cia2, machine_timing.cycles_per_sec, machine_timing.power_freq); machine_trigger_reset(MACHINE_RESET_MODE_HARD); }
void cia2_setup_context(machine_context_t *machine_ctx) { cia_context_t *cia; machine_ctx->cia2 = lib_calloc(1, sizeof(cia_context_t)); cia = machine_ctx->cia2; cia->prv = NULL; cia->context = NULL; cia->rmw_flag = &maincpu_rmw_flag; cia->clk_ptr = &maincpu_clk; cia2_set_timing(cia, C64_PAL_CYCLES_PER_SEC, 50); ciacore_setup_context(cia); cia->model = cia2_model; cia->debugFlag = 0; cia->irq_line = IK_NMI; cia->myname = lib_msprintf("CIA2"); cia->undump_ciapa = undump_ciapa; cia->undump_ciapb = undump_ciapb; cia->store_ciapa = store_ciapa; cia->store_ciapb = store_ciapb; cia->store_sdr = store_sdr; cia->read_ciapa = read_ciapa; cia->read_ciapb = read_ciapb; cia->read_ciaicr = read_ciaicr; cia->read_sdr = read_sdr; cia->cia_set_int_clk = cia_set_int_clk; cia->cia_restore_int = cia_restore_int; cia->do_reset_cia = do_reset_cia; cia->pulse_ciapc = pulse_ciapc; cia->pre_store = pre_store; cia->pre_read = pre_read; cia->pre_peek = pre_peek; }