Shit ball in da house

This commit is contained in:
hap 2015-05-13 18:42:31 +02:00
parent b518d1bfe5
commit a74a444810
5 changed files with 83 additions and 19 deletions

View File

@ -152,7 +152,7 @@ void e0c6200_cpu_device::do_interrupt()
// interrupt handling takes 13* cycles, plus 1 extra if cpu was halted
// *: 12.5 on E0C6200A, does the cpu osc source change polarity or something?
m_icount -= 13;
if (m_halt || m_sleep)
if (m_halt)
m_icount--;
m_halt = m_sleep = false;
@ -181,7 +181,7 @@ void e0c6200_cpu_device::execute_run()
}
}
// cpu halted (peripherals still run)
// core cpu not running (peripherals still work)
if (m_halt || m_sleep)
{
m_icount = 0;

View File

@ -1,5 +1,6 @@
// license:BSD-3-Clause
// copyright-holders:hap
// E0C6200 opcode handlers
enum

View File

@ -64,6 +64,9 @@ void e0c6s46_device::device_start()
m_prgtimer_handle->adjust(attotime::never);
// zerofill
memset(m_port_k, 0xf, sizeof(m_port_k));
m_dfk0 = 0xf;
memset(m_irqflag, 0, sizeof(m_irqflag));
memset(m_irqmask, 0, sizeof(m_irqmask));
m_osc = 0;
@ -89,6 +92,9 @@ void e0c6s46_device::device_start()
m_prgtimer_reload = 0;
// register for savestates
save_item(NAME(m_port_k));
save_item(NAME(m_dfk0));
save_item(NAME(m_irqflag));
save_item(NAME(m_irqmask));
save_item(NAME(m_osc));
@ -125,11 +131,8 @@ void e0c6s46_device::device_reset()
e0c6200_cpu_device::device_reset();
// reset interrupts
for (int i = 0; i < 6; i++)
{
m_data->read_byte(0xf00+i);
m_data->write_byte(0xf10+i, 0);
}
memset(m_irqflag, 0, sizeof(m_irqflag));
memset(m_irqmask, 0, sizeof(m_irqmask));
// reset other i/o
m_data->write_byte(0xf41, 0xf);
@ -186,6 +189,7 @@ bool e0c6s46_device::check_interrupt()
// middle of handling this interrupt, irq vector may be an OR of 2 vectors
m_irq_vector = 2*pri + 2;
int reg = priorder[pri];
m_irq_id = reg;
switch (reg)
{
@ -200,6 +204,18 @@ bool e0c6s46_device::check_interrupt()
return false;
}
void e0c6s46_device::execute_set_input(int line, int state)
{
// only support 8 K input lines at the moment
if (line < 0 || line > 7)
return;
state = (state) ? 1 : 0;
int port = line >> 3 & 1;
UINT8 bit = 1 << (line & 3);
m_port_k[port] = (m_port_k[port] & ~bit) | (state ? bit : 0);
}
void e0c6s46_device::clock_watchdog()
@ -235,7 +251,7 @@ TIMER_CALLBACK_MEMBER(e0c6s46_device::clktimer_cb)
// schedule next timeout (256hz at default clock of 32768hz)
m_clktimer_handle->adjust(attotime::from_ticks(128, unscaled_clock()));
// 1hz timeout also clocks the watchdog timer
// 1hz falling edge also clocks the watchdog timer
if (m_clktimer_count == 0)
clock_watchdog();
}
@ -349,13 +365,13 @@ UINT32 e0c6s46_device::screen_update(screen_device &screen, bitmap_ind16 &bitmap
pixel = vram[offset] >> c & 1;
// 16 COM(common) pins, 40 SEG(segment) pins
int segment = offset / 2;
int common = bank * 8 + (offset & 1) * 4 + c;
int seg = offset / 2;
int com = bank * 8 + (offset & 1) * 4 + c;
if (m_pixel_update_handler != NULL)
m_pixel_update_handler(*this, bitmap, cliprect, m_lcd_contrast, segment, common, pixel);
else if (cliprect.contains(segment, common))
bitmap.pix16(common, segment) = pixel;
m_pixel_update_handler(*this, bitmap, cliprect, m_lcd_contrast, seg, com, pixel);
else if (cliprect.contains(seg, com))
bitmap.pix16(com, seg) = pixel;
}
}
}
@ -372,12 +388,19 @@ READ8_MEMBER(e0c6s46_device::io_r)
{
// irq flags are reset(acked) when read
UINT8 flag = m_irqflag[offset];
m_irqflag[offset] = 0;
if (!space.debugger_access())
m_irqflag[offset] = 0;
return flag;
}
case 0x10: case 0x11: case 0x12: case 0x13: case 0x14: case 0x15:
return m_irqmask[offset-0x10];
// k input ports
case 0x40: case 0x42:
return m_port_k[offset >> 1 & 1];
case 0x41:
return m_dfk0;
// clock timer (lo, hi)
case 0x20: case 0x21:
return m_clktimer_count >> (4 * (offset & 1)) & 0xf;
@ -442,6 +465,12 @@ WRITE8_MEMBER(e0c6s46_device::io_w)
break;
}
// k input ports
case 0x41:
// d0-d3: K0x input port irq on 0: rising edge, 1: falling edge,
m_dfk0 = data;
break;
// OSC circuit
case 0x70:
// d0,d1: CPU operating voltage

View File

@ -15,8 +15,8 @@
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 segment, int common, int state);
#define E0C6S46_PIXEL_UPDATE_CB(name) void name(device_t &device, bitmap_ind16 &bitmap, const rectangle &cliprect, int contrast, int segment, int common, int state)
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
@ -38,6 +38,8 @@ protected:
virtual void device_reset();
// device_execute_interface overrides
virtual UINT32 execute_input_lines() const { return 8; }
virtual void execute_set_input(int line, int state);
virtual void execute_one();
virtual bool check_interrupt();
@ -49,9 +51,12 @@ private:
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;
int m_watchdog_count;

View File

@ -26,6 +26,7 @@ public:
required_device<speaker_sound_device> m_speaker;
DECLARE_PALETTE_INIT(tama);
DECLARE_INPUT_CHANGED_MEMBER(input_changed);
};
@ -37,18 +38,46 @@ PALETTE_INIT_MEMBER(tamag1_state, tama)
}
static E0C6S46_PIXEL_UPDATE_CB(tama_pixel_update)
{
static const int seg2x[0x28] =
{
0, 1, 2, 3, 4, 5, 6, 7,
35, 8, 9,10,11,12,13,14,
15,34,33,32,31,30,29,28,
27,26,25,24,36,23,22,21,
20,19,18,17,16,37,38,39
};
bitmap.pix16(com, seg2x[seg]) = state;
}
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( 0x08, IP_ACTIVE_LOW, IPT_UNUSED )
INPUT_PORTS_END
INPUT_CHANGED_MEMBER(tamag1_state::input_changed)
{
// Inputs are hooked up backwards here, because MCU input
// ports are all tied to its interrupt controller.
int line = (int)(FPTR)param;
int state = newval ? ASSERT_LINE : CLEAR_LINE;
m_maincpu->set_input_line(line, state);
}
static MACHINE_CONFIG_START( tama, tamag1_state )
/* basic machine hardware */
MCFG_CPU_ADD("maincpu", E0C6S46, XTAL_32_768kHz)
// MCFG_E0C6S46_PIXEL_UPDATE_CB(tama_pixel_update)
MCFG_E0C6S46_PIXEL_UPDATE_CB(tama_pixel_update)
/* video hardware */
MCFG_SCREEN_ADD("screen", LCD)
@ -79,7 +108,7 @@ MACHINE_CONFIG_END
ROM_START( tama )
ROM_REGION( 0x3000, "maincpu", 0 )
// ROM_LOAD( "test.b", 0x0000, 0x3000, CRC(4372220e) SHA1(6e13d015113e16198c0059b9d0c38d7027ae7324) )
ROM_LOAD( "test.b", 0x0000, 0x3000, CRC(4372220e) SHA1(6e13d015113e16198c0059b9d0c38d7027ae7324) )
ROM_LOAD( "tama.b", 0x0000, 0x3000, CRC(5c864cb1) SHA1(4b4979cf92dc9d2fb6d7295a38f209f3da144f72) )
ROM_END