mirror of
https://github.com/holub/mame
synced 2025-10-09 17:53:01 +03:00
upd7725.c: Implementation of the p0 and p1 output
bits as device lines; preliminary implementation of INT input line. [Lord Nightmare]
This commit is contained in:
parent
6e0083a8d7
commit
258be9aad6
@ -114,7 +114,7 @@ UINT32 necdsp_device_config::execute_max_cycles() const
|
||||
|
||||
UINT32 necdsp_device_config::execute_input_lines() const
|
||||
{
|
||||
return 0;
|
||||
return 3; // TODO: there should be 11: INT, SCK, /SIEN, /SOEN, SI, and /DACK, plus SO, /SORQ and DRQ; for now, just INT, P0, and P1 are enough.
|
||||
}
|
||||
|
||||
|
||||
@ -151,7 +151,35 @@ UINT32 necdsp_device_config::disasm_max_opcode_bytes() const
|
||||
return 4;
|
||||
}
|
||||
|
||||
//-------------------------------------------------
|
||||
// device_config_complete - perform any
|
||||
// operations now that the configuration is
|
||||
// complete
|
||||
//-------------------------------------------------
|
||||
|
||||
void necdsp_device_config::device_config_complete()
|
||||
{
|
||||
// inherit a copy of the static data
|
||||
const necdsp_interface *intf = reinterpret_cast<const necdsp_interface *>(static_config());
|
||||
if (intf != NULL)
|
||||
*static_cast<necdsp_interface *>(this) = *intf;
|
||||
|
||||
// or initialize to defaults if none provided
|
||||
else
|
||||
{
|
||||
memset(&m_in_int_func, 0, sizeof(m_in_int_func));
|
||||
//memset(&m_in_si_func, 0, sizeof(m_in_si_func));
|
||||
//memset(&m_in_sck_func, 0, sizeof(m_in_sck_func));
|
||||
//memset(&m_in_sien_func, 0, sizeof(m_in_sien_func));
|
||||
//memset(&m_in_soen_func, 0, sizeof(m_in_soen_func));
|
||||
//memset(&m_in_dack_func, 0, sizeof(m_in_dack_func));
|
||||
memset(&m_out_p0_func, 0, sizeof(m_out_p0_func));
|
||||
memset(&m_out_p1_func, 0, sizeof(m_out_p1_func));
|
||||
//memset(&m_out_so_func, 0, sizeof(m_out_so_func));
|
||||
//memset(&m_out_sorq_func, 0, sizeof(m_out_sorq_func));
|
||||
//memset(&m_out_drq_func, 0, sizeof(m_out_drq_func));
|
||||
}
|
||||
}
|
||||
|
||||
//**************************************************************************
|
||||
// DEVICE INTERFACE
|
||||
@ -159,9 +187,11 @@ UINT32 necdsp_device_config::disasm_max_opcode_bytes() const
|
||||
|
||||
necdsp_device::necdsp_device(running_machine &_machine, const necdsp_device_config &config)
|
||||
: cpu_device(_machine, config),
|
||||
m_irq(0),
|
||||
m_program(NULL),
|
||||
m_data(NULL),
|
||||
m_direct(NULL)
|
||||
m_direct(NULL),
|
||||
m_config(config)
|
||||
{
|
||||
}
|
||||
|
||||
@ -207,6 +237,19 @@ void necdsp_device::device_start()
|
||||
state_add(UPD7725_SO, "SO", regs.so);
|
||||
state_add(UPD7725_IDB, "IDB", regs.idb);
|
||||
|
||||
// resolve callbacks
|
||||
devcb_resolve_read_line(&m_in_int_func, &m_config.m_in_int_func, this);
|
||||
//devcb_resolve_read8(&m_in_si_func, &m_config.m_in_si_func, this);
|
||||
//devcb_resolve_read_line(&m_in_sck_func, &m_config.m_in_sck_func, this);
|
||||
//devcb_resolve_read_line(&m_in_sien_func, &m_config.m_in_sien_func, this);
|
||||
//devcb_resolve_read_line(&m_in_soen_func, &m_config.m_in_soen_func, this);
|
||||
//devcb_resolve_read_line(&m_in_dack_func, &m_config.m_in_dack_func, this);
|
||||
devcb_resolve_write_line(&m_out_p0_func, &m_config.m_out_p0_func, this);
|
||||
devcb_resolve_write_line(&m_out_p1_func, &m_config.m_out_p1_func, this);
|
||||
//devcb_resolve_write8(&m_out_so_func, &m_config.m_out_so_func, this);
|
||||
//devcb_resolve_write_line(&m_out_sorq_func, &m_config.m_out_sorq_func, this);
|
||||
//devcb_resolve_write_line(&m_out_drq_func, &m_config.m_out_drq_func, this);
|
||||
|
||||
// save state registrations
|
||||
save_item(NAME(regs.pc));
|
||||
save_item(NAME(regs.rp));
|
||||
@ -323,6 +366,21 @@ void necdsp_device::state_string_export(const device_state_entry &entry, astring
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------
|
||||
// execute_set_input -
|
||||
//-------------------------------------------------
|
||||
|
||||
void necdsp_device::execute_set_input(int inputnum, int state)
|
||||
{
|
||||
switch (inputnum)
|
||||
{
|
||||
case NECDSP_INPUT_LINE_INT:
|
||||
//TODO: detect rising edge; if rising edge found AND IE = 1, push PC, pc = 0x100; else do nothing
|
||||
m_irq = state; // set old state to current state
|
||||
break;
|
||||
// add more when needed
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------
|
||||
// disasm_disassemble - call the disassembly
|
||||
@ -571,7 +629,10 @@ void necdsp_device::exec_ld(UINT32 opcode) {
|
||||
case 4: regs.dp = id; break;
|
||||
case 5: regs.rp = id; break;
|
||||
case 6: regs.dr = id; regs.sr.rqm = 1; break;
|
||||
case 7: regs.sr = (regs.sr & 0x907c) | (id & ~0x907c); break;
|
||||
case 7: regs.sr = (regs.sr & 0x907c) | (id & ~0x907c);
|
||||
devcb_call_write_line(&m_out_p0_func, regs.sr&0x1);
|
||||
devcb_call_write_line(&m_out_p1_func, (regs.sr&0x2)>>1);
|
||||
break;
|
||||
case 8: regs.so = id; break; //LSB
|
||||
case 9: regs.so = id; break; //MSB
|
||||
case 10: regs.k = id; break;
|
||||
|
@ -11,6 +11,17 @@
|
||||
#ifndef __UPD7725_H__
|
||||
#define __UPD7725_H__
|
||||
|
||||
//**************************************************************************
|
||||
// ENUMERATIONS
|
||||
//**************************************************************************
|
||||
|
||||
// input lines
|
||||
enum
|
||||
{
|
||||
NECDSP_INPUT_LINE_INT = 0
|
||||
// add more here as needed
|
||||
};
|
||||
|
||||
//**************************************************************************
|
||||
// TYPE DEFINITIONS
|
||||
//**************************************************************************
|
||||
@ -19,9 +30,29 @@ class necdsp_device;
|
||||
class upd7725_device;
|
||||
class upd96050_device;
|
||||
|
||||
// ======================> necdsp_interface
|
||||
|
||||
struct necdsp_interface
|
||||
{
|
||||
devcb_read_line m_in_int_func;
|
||||
//devcb_read8 m_in_si_func;
|
||||
//devcb_read_line m_in_sck_func;
|
||||
//devcb_read_line m_in_sien_func;
|
||||
//devcb_read_line m_in_soen_func;
|
||||
//devcb_read_line m_in_dack_func;
|
||||
devcb_write_line m_out_p0_func;
|
||||
devcb_write_line m_out_p1_func;
|
||||
//devcb_write8 m_out_so_func;
|
||||
//devcb_write_line m_out_sorq_func;
|
||||
//devcb_write_line m_out_drq_func;
|
||||
};
|
||||
|
||||
#define NECDSP_INTERFACE(name) \
|
||||
const necdsp_interface (name) =
|
||||
|
||||
// ======================> necdsp_device_config
|
||||
|
||||
class necdsp_device_config : public cpu_device_config
|
||||
class necdsp_device_config : public cpu_device_config, public necdsp_interface
|
||||
{
|
||||
friend class necdsp_device;
|
||||
|
||||
@ -35,6 +66,9 @@ public:
|
||||
virtual device_t *alloc_device(running_machine &machine) const;
|
||||
|
||||
protected:
|
||||
// device_config overrides
|
||||
virtual void device_config_complete();
|
||||
|
||||
// device_config_execute_interface overrides
|
||||
virtual UINT32 execute_min_cycles() const;
|
||||
virtual UINT32 execute_max_cycles() const;
|
||||
@ -98,6 +132,7 @@ protected:
|
||||
|
||||
// device_execute_interface overrides
|
||||
virtual void execute_run();
|
||||
virtual void execute_set_input(int inputnum, int state);
|
||||
|
||||
// device_state_interface overrides
|
||||
virtual void state_import(const device_state_entry &entry);
|
||||
@ -179,9 +214,26 @@ private:
|
||||
void stack_pull();
|
||||
|
||||
int m_icount;
|
||||
int m_irq; // old irq line state, for detecting rising edges.
|
||||
|
||||
address_space *m_program, *m_data;
|
||||
direct_read_data *m_direct;
|
||||
|
||||
protected:
|
||||
// device callbacks
|
||||
devcb_resolved_read_line m_in_int_func;
|
||||
//devcb_resolved_read8 m_in_si_func;
|
||||
//devcb_resolved_read_line m_in_sck_func;
|
||||
//devcb_resolved_read_line m_in_sien_func;
|
||||
//devcb_resolved_read_line m_in_soen_func;
|
||||
//devcb_resolved_read_line m_in_dack_func;
|
||||
devcb_resolved_write_line m_out_p0_func;
|
||||
devcb_resolved_write_line m_out_p1_func;
|
||||
//devcb_resolved_write8 m_out_so_func;
|
||||
//devcb_resolved_write_line m_out_sorq_func;
|
||||
//devcb_resolved_write_line m_out_drq_func;
|
||||
|
||||
const necdsp_device_config &m_config;
|
||||
};
|
||||
|
||||
class upd7725_device : public necdsp_device
|
||||
@ -236,4 +288,4 @@ enum
|
||||
UPD7725_IDB
|
||||
};
|
||||
|
||||
#endif // UPD7725
|
||||
#endif /* __UPD7725_H__ */
|
||||
|
Loading…
Reference in New Issue
Block a user