mirror of
https://github.com/holub/mame
synced 2025-04-22 16:31:49 +03:00
m6502: mcu capabilities [O. Galibert]
This commit is contained in:
parent
dc59de3351
commit
afdcf4dcec
@ -107,6 +107,7 @@ void m6502_device::init()
|
||||
inst_state_base = 0;
|
||||
sync = false;
|
||||
inhibit_interrupts = false;
|
||||
count_before_instruction_step = 0;
|
||||
}
|
||||
|
||||
void m6502_device::device_reset()
|
||||
@ -554,5 +555,65 @@ uint8_t m6502_device::mi_default_nd::read_arg(uint16_t adr)
|
||||
return program->read_byte(adr);
|
||||
}
|
||||
|
||||
m6502_mcu_device::m6502_mcu_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock) :
|
||||
m6502_device(mconfig, type, tag, owner, clock)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void m6502_mcu_device::recompute_bcount(uint64_t event_time)
|
||||
{
|
||||
if(!event_time || event_time >= total_cycles() + icount) {
|
||||
bcount = 0;
|
||||
return;
|
||||
}
|
||||
bcount = total_cycles() + icount - event_time;
|
||||
}
|
||||
|
||||
void m6502_mcu_device::execute_run()
|
||||
{
|
||||
internal_update(total_cycles());
|
||||
|
||||
icount -= count_before_instruction_step;
|
||||
if(icount < 0) {
|
||||
count_before_instruction_step = -icount;
|
||||
icount = 0;
|
||||
} else
|
||||
count_before_instruction_step = 0;
|
||||
|
||||
while(bcount && icount <= bcount)
|
||||
internal_update(total_cycles() + icount - bcount);
|
||||
|
||||
if(icount > 0 && inst_substate)
|
||||
do_exec_partial();
|
||||
|
||||
while(icount > 0) {
|
||||
while(icount > bcount) {
|
||||
if(inst_state < 0x10000) {
|
||||
PPC = NPC;
|
||||
debugger_instruction_hook(NPC);
|
||||
}
|
||||
do_exec_full();
|
||||
}
|
||||
if(icount > 0)
|
||||
while(bcount && icount <= bcount)
|
||||
internal_update(total_cycles() + icount - bcount);
|
||||
if(icount > 0 && inst_substate)
|
||||
do_exec_partial();
|
||||
}
|
||||
if(icount < 0) {
|
||||
count_before_instruction_step = -icount;
|
||||
icount = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void m6502_mcu_device::add_event(uint64_t &event_time, uint64_t new_event)
|
||||
{
|
||||
if(!new_event)
|
||||
return;
|
||||
if(!event_time || event_time > new_event)
|
||||
event_time = new_event;
|
||||
}
|
||||
|
||||
|
||||
#include "cpu/m6502/m6502.hxx"
|
||||
|
@ -126,7 +126,7 @@ protected:
|
||||
|
||||
std::unique_ptr<memory_interface> mintf;
|
||||
int inst_state, inst_substate;
|
||||
int icount;
|
||||
int icount, bcount, count_before_instruction_step;
|
||||
bool nmi_state, irq_state, apu_irq_state, v_state;
|
||||
bool irq_taken, sync, cache_disabled, inhibit_interrupts;
|
||||
|
||||
@ -271,6 +271,17 @@ protected:
|
||||
#undef O
|
||||
};
|
||||
|
||||
class m6502_mcu_device : public m6502_device {
|
||||
protected:
|
||||
m6502_mcu_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock);
|
||||
|
||||
virtual void internal_update(uint64_t current_time) = 0;
|
||||
void recompute_bcount(uint64_t event_time);
|
||||
static void add_event(uint64_t &event_time, uint64_t new_event);
|
||||
|
||||
virtual void execute_run() override;
|
||||
};
|
||||
|
||||
enum {
|
||||
M6502_PC = 1,
|
||||
M6502_A,
|
||||
|
Loading…
Reference in New Issue
Block a user