Esempio n. 1
0
static unsigned int mon_register_get_val(int mem, int reg_id)
{
    mos6510dtv_regs_t *reg_ptr;

    if (monitor_diskspace_dnr(mem) >= 0)
        if (!check_drive_emu_level_ok(monitor_diskspace_dnr(mem) + 8))
            return 0;

    reg_ptr = mon_interfaces[mem]->dtv_cpu_regs;

    switch(reg_id) {
      case e_A:
        return MOS6510DTV_REGS_GET_A(reg_ptr);
      case e_X:
        return MOS6510DTV_REGS_GET_X(reg_ptr);
      case e_Y:
        return MOS6510DTV_REGS_GET_Y(reg_ptr);
      case e_PC:
        return MOS6510DTV_REGS_GET_PC(reg_ptr);
      case e_SP:
        return MOS6510DTV_REGS_GET_SP(reg_ptr);
      case e_FLAGS:
          return MOS6510DTV_REGS_GET_FLAGS(reg_ptr)
              | MOS6510DTV_REGS_GET_SIGN(reg_ptr)
              | (MOS6510DTV_REGS_GET_ZERO(reg_ptr) << 1);
      case e_R3:
        return MOS6510DTV_REGS_GET_R3(reg_ptr);
      case e_R4:
        return MOS6510DTV_REGS_GET_R4(reg_ptr);
      case e_R5:
        return MOS6510DTV_REGS_GET_R5(reg_ptr);
      case e_R6:
        return MOS6510DTV_REGS_GET_R6(reg_ptr);
      case e_R7:
        return MOS6510DTV_REGS_GET_R7(reg_ptr);
      case e_R8:
        return MOS6510DTV_REGS_GET_R8(reg_ptr);
      case e_R9:
        return MOS6510DTV_REGS_GET_R9(reg_ptr);
      case e_R10:
        return MOS6510DTV_REGS_GET_R10(reg_ptr);
      case e_R11:
        return MOS6510DTV_REGS_GET_R11(reg_ptr);
      case e_R12:
        return MOS6510DTV_REGS_GET_R12(reg_ptr);
      case e_R13:
        return MOS6510DTV_REGS_GET_R13(reg_ptr);
      case e_R14:
        return MOS6510DTV_REGS_GET_R14(reg_ptr);
      case e_R15:
        return MOS6510DTV_REGS_GET_R15(reg_ptr);
      case e_ACM:
        return MOS6510DTV_REGS_GET_ACM(reg_ptr);
      case e_YXM:
        return MOS6510DTV_REGS_GET_YXM(reg_ptr);
      default:
        log_error(LOG_ERR, "Unknown register!");
    }
    return 0;
}
Esempio n. 2
0
DWORD traps_handler(void)
{
    traplist_t *p = traplist;
    unsigned int pc;
    int result;

    if (machine_class == VICE_MACHINE_C64DTV) {
        pc = MOS6510DTV_REGS_GET_PC(&maincpu_regs);
    } else if (machine_class == VICE_MACHINE_SCPU64) {
        /* FIXME: PBR also needed ?? */
        pc = WDC65816_REGS_GET_PC(&maincpu_regs);
    } else {
        pc = MOS6510_REGS_GET_PC(&maincpu_regs);
    }

    while (p) {
        if (p->trap->address == pc) {
            /* This allows the trap function to remove traps.  */
            WORD resume_address = p->trap->resume_address;

            result = (*p->trap->func)();
            if (!result) {
                return (p->trap->check[0] | (p->trap->check[1] << 8) | (p->trap->check[2] << 16));
            }
            /* XXX ALERT!  `p' might not be valid anymore here, because
               `p->trap->func()' might have removed all the traps.  */
            if (machine_class == VICE_MACHINE_C64DTV) {
                MOS6510DTV_REGS_SET_PC(&maincpu_regs, resume_address);
            } else {
                MOS6510_REGS_SET_PC(&maincpu_regs, resume_address);
            }
            return 0;
        }
        p = p->next;
    }

    return (DWORD)-1;
}