mirror of
https://github.com/holub/mame
synced 2025-04-22 16:31:49 +03:00
added i/o port macros
This commit is contained in:
parent
e8acdc9b96
commit
56850f4b84
@ -6,8 +6,8 @@
|
||||
|
||||
TODO:
|
||||
- K input interrupts
|
||||
- finish i/o ports
|
||||
- serial interface
|
||||
- output ports
|
||||
|
||||
*/
|
||||
|
||||
@ -46,6 +46,9 @@ e0c6s46_device::e0c6s46_device(const machine_config &mconfig, const char *tag, d
|
||||
, m_vram1(*this, "vram1")
|
||||
, m_vram2(*this, "vram2")
|
||||
, m_pixel_update_handler(NULL)
|
||||
, m_write_r0(*this), m_write_r1(*this), m_write_r2(*this), m_write_r3(*this), m_write_r4(*this)
|
||||
, m_read_p0(*this), m_read_p1(*this), m_read_p2(*this), m_read_p3(*this)
|
||||
, m_write_p0(*this), m_write_p1(*this), m_write_p2(*this), m_write_p3(*this)
|
||||
{ }
|
||||
|
||||
|
||||
@ -58,6 +61,22 @@ void e0c6s46_device::device_start()
|
||||
{
|
||||
e0c6200_cpu_device::device_start();
|
||||
|
||||
// find ports
|
||||
m_write_r0.resolve_safe();
|
||||
m_write_r1.resolve_safe();
|
||||
m_write_r2.resolve_safe();
|
||||
m_write_r3.resolve_safe();
|
||||
m_write_r4.resolve_safe();
|
||||
|
||||
m_read_p0.resolve_safe(0);
|
||||
m_read_p1.resolve_safe(0);
|
||||
m_read_p2.resolve_safe(0);
|
||||
m_read_p3.resolve_safe(0);
|
||||
m_write_p0.resolve_safe();
|
||||
m_write_p1.resolve_safe();
|
||||
m_write_p2.resolve_safe();
|
||||
m_write_p3.resolve_safe();
|
||||
|
||||
// create timers
|
||||
m_clktimer_handle = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(e0c6s46_device::clktimer_cb), this));
|
||||
m_clktimer_handle->adjust(attotime::from_ticks(128, unscaled_clock()));
|
||||
@ -65,8 +84,15 @@ void e0c6s46_device::device_start()
|
||||
m_stopwatch_handle->adjust(attotime::from_ticks(64, unscaled_clock()));
|
||||
m_prgtimer_handle = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(e0c6s46_device::prgtimer_cb), this));
|
||||
m_prgtimer_handle->adjust(attotime::never);
|
||||
m_buzzer_handle = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(e0c6s46_device::buzzer_cb), this));
|
||||
m_buzzer_handle->adjust(attotime::never);
|
||||
|
||||
// zerofill
|
||||
memset(m_port_r, 0x0, sizeof(m_port_r));
|
||||
m_r_dir = 0;
|
||||
memset(m_port_p, 0x0, sizeof(m_port_p));
|
||||
m_p_dir = 0;
|
||||
m_p_pullup = 0;
|
||||
memset(m_port_k, 0xf, sizeof(m_port_k));
|
||||
m_dfk0 = 0xf;
|
||||
|
||||
@ -95,6 +121,11 @@ void e0c6s46_device::device_start()
|
||||
m_prgtimer_reload = 0;
|
||||
|
||||
// register for savestates
|
||||
save_item(NAME(m_port_r));
|
||||
save_item(NAME(m_r_dir));
|
||||
save_item(NAME(m_port_p));
|
||||
save_item(NAME(m_p_dir));
|
||||
save_item(NAME(m_p_pullup));
|
||||
save_item(NAME(m_port_k));
|
||||
save_item(NAME(m_dfk0));
|
||||
|
||||
@ -359,6 +390,13 @@ TIMER_CALLBACK_MEMBER(e0c6s46_device::prgtimer_cb)
|
||||
}
|
||||
|
||||
|
||||
// buzzer
|
||||
|
||||
TIMER_CALLBACK_MEMBER(e0c6s46_device::buzzer_cb)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// LCD Driver
|
||||
@ -426,11 +464,21 @@ READ8_MEMBER(e0c6s46_device::io_r)
|
||||
case 0x10: case 0x11: case 0x12: case 0x13: case 0x14: case 0x15:
|
||||
return m_irqmask[offset-0x10];
|
||||
|
||||
// k input ports
|
||||
// K input ports
|
||||
case 0x40: case 0x42:
|
||||
return m_port_k[offset >> 1 & 1];
|
||||
case 0x41:
|
||||
return m_dfk0;
|
||||
|
||||
// R output ports
|
||||
case 0x7b:
|
||||
return m_r_dir;
|
||||
|
||||
// P i/o ports
|
||||
case 0x7d:
|
||||
return m_p_dir;
|
||||
case 0x7e:
|
||||
return m_p_pullup;
|
||||
|
||||
// clock timer (lo, hi)
|
||||
case 0x20: case 0x21:
|
||||
@ -496,12 +544,28 @@ WRITE8_MEMBER(e0c6s46_device::io_w)
|
||||
break;
|
||||
}
|
||||
|
||||
// k input ports
|
||||
// K input ports
|
||||
case 0x41:
|
||||
// d0-d3: K0x input port irq on 0: rising edge, 1: falling edge,
|
||||
// d0-d3: K0x irq on 0: rising edge, 1: falling edge
|
||||
m_dfk0 = data;
|
||||
break;
|
||||
|
||||
// R output ports
|
||||
case 0x7b:
|
||||
// d0-d3: Rx* direction 0: high impedance, 1: output
|
||||
m_r_dir = data;
|
||||
break;
|
||||
|
||||
// P i/o ports
|
||||
case 0x7d:
|
||||
// d0-d3: Px* direction 0: input, 1: output
|
||||
m_p_dir = data;
|
||||
break;
|
||||
case 0x7e:
|
||||
// d0-d3: Px* pull up resistor on/off
|
||||
m_p_pullup = data;
|
||||
break;
|
||||
|
||||
// OSC circuit
|
||||
case 0x70:
|
||||
// d0,d1: CPU operating voltage
|
||||
|
@ -11,20 +11,80 @@
|
||||
|
||||
#include "e0c6200.h"
|
||||
|
||||
|
||||
// I/O ports setup
|
||||
|
||||
// 5 4-bit R output ports
|
||||
#define MCFG_E0C6S46_WRITE_R_CB(R, _devcb) \
|
||||
e0c6s46_device::set_write_r##R##_callback(*device, DEVCB_##_devcb);
|
||||
|
||||
enum
|
||||
{
|
||||
E0C6S46_PORT_R0X = 0,
|
||||
E0C6S46_PORT_R1X,
|
||||
E0C6S46_PORT_R2X,
|
||||
E0C6S46_PORT_R3X,
|
||||
E0C6S46_PORT_R4X
|
||||
};
|
||||
|
||||
// 4 4-bit P ports
|
||||
#define MCFG_E0C6S46_READ_P_CB(R, _devcb) \
|
||||
hmcs40_cpu_device::set_read_r##P##_callback(*device, DEVCB_##_devcb);
|
||||
#define MCFG_E0C6S46_WRITE_P_CB(R, _devcb) \
|
||||
e0c6s46_device::set_write_r##P##_callback(*device, DEVCB_##_devcb);
|
||||
|
||||
enum
|
||||
{
|
||||
E0C6S46_PORT_P0X = 0,
|
||||
E0C6S46_PORT_P1X,
|
||||
E0C6S46_PORT_P2X,
|
||||
E0C6S46_PORT_P3X
|
||||
};
|
||||
|
||||
// for the 2 K input ports, use set_input_line(line, state)
|
||||
enum
|
||||
{
|
||||
E0C6S46_LINE_K00 = 0,
|
||||
E0C6S46_LINE_K01,
|
||||
E0C6S46_LINE_K02,
|
||||
E0C6S46_LINE_K03,
|
||||
E0C6S46_LINE_K10,
|
||||
E0C6S46_LINE_K11,
|
||||
E0C6S46_LINE_K12,
|
||||
E0C6S46_LINE_K13
|
||||
};
|
||||
|
||||
|
||||
// lcd driver
|
||||
#define MCFG_E0C6S46_PIXEL_UPDATE_CB(_cb) \
|
||||
e0c6s46_device::static_set_pixel_update_cb(*device, _cb);
|
||||
|
||||
|
||||
typedef void (*e0c6s46_pixel_update_func)(device_t &device, bitmap_ind16 &bitmap, const rectangle &cliprect, int contrast, int seg, int com, int state);
|
||||
#define E0C6S46_PIXEL_UPDATE_CB(name) void name(device_t &device, bitmap_ind16 &bitmap, const rectangle &cliprect, int contrast, int seg, int com, int state)
|
||||
|
||||
|
||||
|
||||
class e0c6s46_device : public e0c6200_cpu_device
|
||||
{
|
||||
public:
|
||||
e0c6s46_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
|
||||
|
||||
// static configuration helpers
|
||||
template<class _Object> static devcb_base &set_write_r0_callback(device_t &device, _Object object) { return downcast<e0c6s46_device &>(device).m_write_r0.set_callback(object); }
|
||||
template<class _Object> static devcb_base &set_write_r1_callback(device_t &device, _Object object) { return downcast<e0c6s46_device &>(device).m_write_r1.set_callback(object); }
|
||||
template<class _Object> static devcb_base &set_write_r2_callback(device_t &device, _Object object) { return downcast<e0c6s46_device &>(device).m_write_r2.set_callback(object); }
|
||||
template<class _Object> static devcb_base &set_write_r3_callback(device_t &device, _Object object) { return downcast<e0c6s46_device &>(device).m_write_r3.set_callback(object); }
|
||||
template<class _Object> static devcb_base &set_write_r4_callback(device_t &device, _Object object) { return downcast<e0c6s46_device &>(device).m_write_r4.set_callback(object); }
|
||||
|
||||
template<class _Object> static devcb_base &set_read_p0_callback(device_t &device, _Object object) { return downcast<e0c6s46_device &>(device).m_read_p0.set_callback(object); }
|
||||
template<class _Object> static devcb_base &set_read_p1_callback(device_t &device, _Object object) { return downcast<e0c6s46_device &>(device).m_read_p1.set_callback(object); }
|
||||
template<class _Object> static devcb_base &set_read_p2_callback(device_t &device, _Object object) { return downcast<e0c6s46_device &>(device).m_read_p2.set_callback(object); }
|
||||
template<class _Object> static devcb_base &set_read_p3_callback(device_t &device, _Object object) { return downcast<e0c6s46_device &>(device).m_read_p3.set_callback(object); }
|
||||
template<class _Object> static devcb_base &set_write_p0_callback(device_t &device, _Object object) { return downcast<e0c6s46_device &>(device).m_write_p0.set_callback(object); }
|
||||
template<class _Object> static devcb_base &set_write_p1_callback(device_t &device, _Object object) { return downcast<e0c6s46_device &>(device).m_write_p1.set_callback(object); }
|
||||
template<class _Object> static devcb_base &set_write_p2_callback(device_t &device, _Object object) { return downcast<e0c6s46_device &>(device).m_write_p2.set_callback(object); }
|
||||
template<class _Object> static devcb_base &set_write_p3_callback(device_t &device, _Object object) { return downcast<e0c6s46_device &>(device).m_write_p3.set_callback(object); }
|
||||
|
||||
static void static_set_pixel_update_cb(device_t &device, e0c6s46_pixel_update_func _cb) { downcast<e0c6s46_device &>(device).m_pixel_update_handler = _cb; }
|
||||
|
||||
DECLARE_READ8_MEMBER(io_r);
|
||||
@ -46,19 +106,30 @@ protected:
|
||||
private:
|
||||
required_shared_ptr<UINT8> m_vram1;
|
||||
required_shared_ptr<UINT8> m_vram2;
|
||||
|
||||
|
||||
UINT8 m_irqflag[6];
|
||||
UINT8 m_irqmask[6];
|
||||
UINT8 m_osc;
|
||||
UINT8 m_svd;
|
||||
|
||||
UINT8 m_port_k[2];
|
||||
UINT8 m_dfk0;
|
||||
|
||||
UINT8 m_lcd_control;
|
||||
UINT8 m_lcd_contrast;
|
||||
e0c6s46_pixel_update_func m_pixel_update_handler;
|
||||
|
||||
// i/o ports
|
||||
devcb_write8 m_write_r0, m_write_r1, m_write_r2, m_write_r3, m_write_r4;
|
||||
devcb_read8 m_read_p0, m_read_p1, m_read_p2, m_read_p3;
|
||||
devcb_write8 m_write_p0, m_write_p1, m_write_p2, m_write_p3;
|
||||
|
||||
UINT8 m_port_r[5];
|
||||
UINT8 m_r_dir;
|
||||
UINT8 m_port_p[4];
|
||||
UINT8 m_p_dir;
|
||||
UINT8 m_p_pullup;
|
||||
UINT8 m_port_k[2];
|
||||
UINT8 m_dfk0;
|
||||
|
||||
// timers
|
||||
int m_watchdog_count;
|
||||
void clock_watchdog();
|
||||
|
||||
@ -86,6 +157,9 @@ private:
|
||||
TIMER_CALLBACK_MEMBER(prgtimer_cb);
|
||||
bool prgtimer_reset_prescaler();
|
||||
void clock_prgtimer();
|
||||
|
||||
emu_timer *m_buzzer_handle;
|
||||
TIMER_CALLBACK_MEMBER(buzzer_cb);
|
||||
};
|
||||
|
||||
|
||||
|
@ -96,9 +96,9 @@ INPUT_CHANGED_MEMBER(tamag1_state::input_changed)
|
||||
|
||||
static INPUT_PORTS_START( tama )
|
||||
PORT_START("K0")
|
||||
PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_CHANGED_MEMBER(DEVICE_SELF, tamag1_state, input_changed, (void *)0)
|
||||
PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_CHANGED_MEMBER(DEVICE_SELF, tamag1_state, input_changed, (void *)1)
|
||||
PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_CHANGED_MEMBER(DEVICE_SELF, tamag1_state, input_changed, (void *)2)
|
||||
PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_CHANGED_MEMBER(DEVICE_SELF, tamag1_state, input_changed, (void *)E0C6S46_LINE_K00)
|
||||
PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_CHANGED_MEMBER(DEVICE_SELF, tamag1_state, input_changed, (void *)E0C6S46_LINE_K01)
|
||||
PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_CHANGED_MEMBER(DEVICE_SELF, tamag1_state, input_changed, (void *)E0C6S46_LINE_K02)
|
||||
PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNUSED )
|
||||
INPUT_PORTS_END
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user