/* called by machine_specific_reset() */ void drive_reset(void) { unsigned int dnr; drive_t *drive; for (dnr = 0; dnr < DRIVE_NUM; dnr++) { drive = drive_context[dnr]->drive; if (drive->type == DRIVE_TYPE_2000 || drive->type == DRIVE_TYPE_4000) { drivecpu65c02_reset(drive_context[dnr]); } else { drivecpu_reset(drive_context[dnr]); } drive->led_last_change_clk = *(drive->clk); drive->led_last_uiupdate_clk = *(drive->clk); drive->led_active_ticks = 0; } }
int drivecpu_snapshot_read_module(drive_context_t *drv, snapshot_t *s) { BYTE major, minor; snapshot_module_t *m; BYTE a, x, y, sp, status; WORD pc; drivecpu_context_t *cpu; cpu = drv->cpu; m = snapshot_module_open(s, drv->cpu->snap_module_name, &major, &minor); if (m == NULL) { return -1; } /* Before we start make sure all devices are reset. */ drivecpu_reset(drv); /* XXX: Assumes `CLOCK' is the same size as a `DWORD'. */ if (0 || SMR_DW(m, drv->clk_ptr) < 0 || SMR_B(m, &a) < 0 || SMR_B(m, &x) < 0 || SMR_B(m, &y) < 0 || SMR_B(m, &sp) < 0 || SMR_W(m, &pc) < 0 || SMR_B(m, &status) < 0 || SMR_DW_UINT(m, &(cpu->last_opcode_info)) < 0 || SMR_DW(m, &(cpu->last_clk)) < 0 || SMR_DW(m, &(cpu->cycle_accum)) < 0 || SMR_DW(m, &(cpu->last_exc_cycles)) < 0 || SMR_DW(m, &(cpu->stop_clk)) < 0 ) { goto fail; } MOS6510_REGS_SET_A(&(cpu->cpu_regs), a); MOS6510_REGS_SET_X(&(cpu->cpu_regs), x); MOS6510_REGS_SET_Y(&(cpu->cpu_regs), y); MOS6510_REGS_SET_SP(&(cpu->cpu_regs), sp); MOS6510_REGS_SET_PC(&(cpu->cpu_regs), pc); MOS6510_REGS_SET_STATUS(&(cpu->cpu_regs), status); log_message(drv->drive->log, "RESET (For undump)."); interrupt_cpu_status_reset(cpu->int_status); machine_drive_reset(drv); if (interrupt_read_snapshot(cpu->int_status, m) < 0) { goto fail; } if (drv->drive->type == DRIVE_TYPE_1540 || drv->drive->type == DRIVE_TYPE_1541 || drv->drive->type == DRIVE_TYPE_1541II || drv->drive->type == DRIVE_TYPE_1551 || drv->drive->type == DRIVE_TYPE_1570 || drv->drive->type == DRIVE_TYPE_1571 || drv->drive->type == DRIVE_TYPE_1571CR || drv->drive->type == DRIVE_TYPE_2031) { if (SMR_BA(m, drv->drive->drive_ram, 0x800) < 0) { goto fail; } } if (drv->drive->type == DRIVE_TYPE_1581 || drv->drive->type == DRIVE_TYPE_2000 || drv->drive->type == DRIVE_TYPE_4000) { if (SMR_BA(m, drv->drive->drive_ram, 0x2000) < 0) { goto fail; } } if (drive_check_old(drv->drive->type)) { if (SMR_BA(m, drv->drive->drive_ram, 0x1100) < 0) { goto fail; } } /* Update `*bank_base'. */ JUMP(reg_pc); if (interrupt_read_new_snapshot(drv->cpu->int_status, m) < 0) { goto fail; } return snapshot_module_close(m); fail: if (m != NULL) { snapshot_module_close(m); } return -1; }
void drivecpu_init(drive_context_t *drv, int type) { drivemem_init(drv, type); drivecpu_reset(drv); }