mirror of
https://github.com/holub/mame
synced 2025-06-22 12:28:33 +03:00
Rough C++ modernization of CoCo cartridge infrastructure (usage of 'enum class', scoping etc)
This commit is contained in:
parent
6b83b0dbee
commit
dbf61f379d
@ -252,12 +252,12 @@ void coco_fdc_device::update_lines()
|
|||||||
m_dskreg &= ~0x80; /* clear halt enable */
|
m_dskreg &= ~0x80; /* clear halt enable */
|
||||||
|
|
||||||
/* set the NMI line */
|
/* set the NMI line */
|
||||||
m_owner->cart_set_line(COCOCART_LINE_NMI,
|
m_owner->cart_set_line(cococart_slot_device::line::NMI,
|
||||||
((m_intrq != 0) && (m_dskreg & 0x20)) ? COCOCART_LINE_VALUE_ASSERT : COCOCART_LINE_VALUE_CLEAR);
|
((m_intrq != 0) && (m_dskreg & 0x20)) ? cococart_slot_device::line_value::ASSERT : cococart_slot_device::line_value::CLEAR);
|
||||||
|
|
||||||
/* set the HALT line */
|
/* set the HALT line */
|
||||||
m_owner->cart_set_line(COCOCART_LINE_HALT,
|
m_owner->cart_set_line(cococart_slot_device::line::HALT,
|
||||||
((m_drq == 0) && (m_dskreg & 0x80)) ? COCOCART_LINE_VALUE_ASSERT : COCOCART_LINE_VALUE_CLEAR);
|
((m_drq == 0) && (m_dskreg & 0x80)) ? cococart_slot_device::line_value::ASSERT : cococart_slot_device::line_value::CLEAR);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*-------------------------------------------------
|
/*-------------------------------------------------
|
||||||
@ -497,12 +497,12 @@ const tiny_rom_entry *dragon_fdc_device::device_rom_region() const
|
|||||||
void dragon_fdc_device::update_lines()
|
void dragon_fdc_device::update_lines()
|
||||||
{
|
{
|
||||||
/* set the NMI line */
|
/* set the NMI line */
|
||||||
m_owner->cart_set_line(COCOCART_LINE_NMI,
|
m_owner->cart_set_line(cococart_slot_device::line::NMI,
|
||||||
((m_intrq != 0) && (m_dskreg & 0x20)) ? COCOCART_LINE_VALUE_ASSERT : COCOCART_LINE_VALUE_CLEAR);
|
((m_intrq != 0) && (m_dskreg & 0x20)) ? cococart_slot_device::line_value::ASSERT : cococart_slot_device::line_value::CLEAR);
|
||||||
|
|
||||||
/* set the CART line */
|
/* set the CART line */
|
||||||
m_owner->cart_set_line(COCOCART_LINE_CART,
|
m_owner->cart_set_line(cococart_slot_device::line::CART,
|
||||||
(m_drq != 0) ? COCOCART_LINE_VALUE_ASSERT : COCOCART_LINE_VALUE_CLEAR);
|
(m_drq != 0) ? cococart_slot_device::line_value::ASSERT : cococart_slot_device::line_value::CLEAR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -88,13 +88,14 @@ const tiny_rom_entry *coco_pak_device::device_rom_region() const
|
|||||||
|
|
||||||
void coco_pak_device::device_reset()
|
void coco_pak_device::device_reset()
|
||||||
{
|
{
|
||||||
if (m_cart->exists()) {
|
if (m_cart->exists())
|
||||||
cococart_line_value cart_line = m_autostart.read_safe(0x01)
|
{
|
||||||
? COCOCART_LINE_VALUE_Q
|
auto cart_line = m_autostart.read_safe(0x01)
|
||||||
: COCOCART_LINE_VALUE_CLEAR;
|
? cococart_slot_device::line_value::Q
|
||||||
|
: cococart_slot_device::line_value::CLEAR;
|
||||||
|
|
||||||
/* normal CoCo PAKs tie their CART line to Q - the system clock */
|
// normal CoCo PAKs tie their CART line to Q - the system clock
|
||||||
m_owner->cart_set_line(COCOCART_LINE_CART,cart_line);
|
m_owner->cart_set_line(cococart_slot_device::line::CART, cart_line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,7 +61,7 @@ void cococart_slot_device::device_start()
|
|||||||
|
|
||||||
m_cart_line.timer_index = 0;
|
m_cart_line.timer_index = 0;
|
||||||
m_cart_line.delay = 0;
|
m_cart_line.delay = 0;
|
||||||
m_cart_line.value = COCOCART_LINE_VALUE_CLEAR;
|
m_cart_line.value = line_value::CLEAR;
|
||||||
m_cart_line.line = 0;
|
m_cart_line.line = 0;
|
||||||
m_cart_line.q_count = 0;
|
m_cart_line.q_count = 0;
|
||||||
m_cart_callback.resolve();
|
m_cart_callback.resolve();
|
||||||
@ -70,7 +70,7 @@ void cococart_slot_device::device_start()
|
|||||||
m_nmi_line.timer_index = 0;
|
m_nmi_line.timer_index = 0;
|
||||||
/* 12 allowed one more instruction to finished after the line is pulled */
|
/* 12 allowed one more instruction to finished after the line is pulled */
|
||||||
m_nmi_line.delay = 12;
|
m_nmi_line.delay = 12;
|
||||||
m_nmi_line.value = COCOCART_LINE_VALUE_CLEAR;
|
m_nmi_line.value = line_value::CLEAR;
|
||||||
m_nmi_line.line = 0;
|
m_nmi_line.line = 0;
|
||||||
m_nmi_line.q_count = 0;
|
m_nmi_line.q_count = 0;
|
||||||
m_nmi_callback.resolve();
|
m_nmi_callback.resolve();
|
||||||
@ -79,7 +79,7 @@ void cococart_slot_device::device_start()
|
|||||||
m_halt_line.timer_index = 0;
|
m_halt_line.timer_index = 0;
|
||||||
/* 6 allowed one more instruction to finished after the line is pulled */
|
/* 6 allowed one more instruction to finished after the line is pulled */
|
||||||
m_halt_line.delay = 6;
|
m_halt_line.delay = 6;
|
||||||
m_halt_line.value = COCOCART_LINE_VALUE_CLEAR;
|
m_halt_line.value = line_value::CLEAR;
|
||||||
m_halt_line.line = 0;
|
m_halt_line.line = 0;
|
||||||
m_halt_line.q_count = 0;
|
m_halt_line.q_count = 0;
|
||||||
m_halt_callback.resolve();
|
m_halt_callback.resolve();
|
||||||
@ -113,15 +113,15 @@ void cococart_slot_device::device_timer(emu_timer &timer, device_timer_id id, in
|
|||||||
switch(id)
|
switch(id)
|
||||||
{
|
{
|
||||||
case TIMER_CART:
|
case TIMER_CART:
|
||||||
set_line("CART", m_cart_line, (cococart_line_value) param);
|
set_line("CART", m_cart_line, (line_value) param);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TIMER_NMI:
|
case TIMER_NMI:
|
||||||
set_line("NMI", m_nmi_line, (cococart_line_value) param);
|
set_line("NMI", m_nmi_line, (line_value) param);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TIMER_HALT:
|
case TIMER_HALT:
|
||||||
set_line("HALT", m_halt_line, (cococart_line_value) param);
|
set_line("HALT", m_halt_line, (line_value) param);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -157,18 +157,18 @@ WRITE8_MEMBER(cococart_slot_device::write)
|
|||||||
// line_value_string
|
// line_value_string
|
||||||
//-------------------------------------------------
|
//-------------------------------------------------
|
||||||
|
|
||||||
static const char *line_value_string(cococart_line_value value)
|
const char *cococart_slot_device::line_value_string(line_value value)
|
||||||
{
|
{
|
||||||
const char *s;
|
const char *s;
|
||||||
switch(value)
|
switch(value)
|
||||||
{
|
{
|
||||||
case COCOCART_LINE_VALUE_CLEAR:
|
case line_value::CLEAR:
|
||||||
s = "CLEAR";
|
s = "CLEAR";
|
||||||
break;
|
break;
|
||||||
case COCOCART_LINE_VALUE_ASSERT:
|
case line_value::ASSERT:
|
||||||
s = "ASSERT";
|
s = "ASSERT";
|
||||||
break;
|
break;
|
||||||
case COCOCART_LINE_VALUE_Q:
|
case line_value::Q:
|
||||||
s = "Q";
|
s = "Q";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -183,28 +183,29 @@ static const char *line_value_string(cococart_line_value value)
|
|||||||
// set_line
|
// set_line
|
||||||
//-------------------------------------------------
|
//-------------------------------------------------
|
||||||
|
|
||||||
void cococart_slot_device::set_line(const char *line_name, coco_cartridge_line &line, cococart_line_value value)
|
void cococart_slot_device::set_line(const char *line_name, coco_cartridge_line &line, cococart_slot_device::line_value value)
|
||||||
{
|
{
|
||||||
if ((line.value != value) || (value == COCOCART_LINE_VALUE_Q))
|
if ((line.value != value) || (value == line_value::Q))
|
||||||
{
|
{
|
||||||
line.value = value;
|
line.value = value;
|
||||||
|
|
||||||
if (LOG_LINE)
|
if (LOG_LINE)
|
||||||
logerror("[%s]: set_line(): %s <= %s\n", machine().describe_context(), line_name, line_value_string(value));
|
logerror("[%s]: set_line(): %s <= %s\n", machine().describe_context(), line_name, line_value_string(value));
|
||||||
/* engage in a bit of gymnastics for this odious 'Q' value */
|
|
||||||
|
// engage in a bit of gymnastics for this odious 'Q' value
|
||||||
switch(line.value)
|
switch(line.value)
|
||||||
{
|
{
|
||||||
case COCOCART_LINE_VALUE_CLEAR:
|
case line_value::CLEAR:
|
||||||
line.line = 0x00;
|
line.line = 0x00;
|
||||||
line.q_count = 0;
|
line.q_count = 0;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case COCOCART_LINE_VALUE_ASSERT:
|
case line_value::ASSERT:
|
||||||
line.line = 0x01;
|
line.line = 0x01;
|
||||||
line.q_count = 0;
|
line.q_count = 0;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case COCOCART_LINE_VALUE_Q:
|
case line_value::Q:
|
||||||
line.line = line.line ? 0x00 : 0x01;
|
line.line = line.line ? 0x00 : 0x01;
|
||||||
if (line.q_count++ < 4)
|
if (line.q_count++ < 4)
|
||||||
set_line_timer(line, value);
|
set_line_timer(line, value);
|
||||||
@ -223,9 +224,9 @@ void cococart_slot_device::set_line(const char *line_name, coco_cartridge_line &
|
|||||||
// set_line_timer()
|
// set_line_timer()
|
||||||
//-------------------------------------------------
|
//-------------------------------------------------
|
||||||
|
|
||||||
void cococart_slot_device::set_line_timer(coco_cartridge_line &line, cococart_line_value value)
|
void cococart_slot_device::set_line_timer(coco_cartridge_line &line, cococart_slot_device::line_value value)
|
||||||
{
|
{
|
||||||
/* calculate delay; delay dependant on cycles per second */
|
// calculate delay; delay dependant on cycles per second
|
||||||
attotime delay = (line.delay != 0)
|
attotime delay = (line.delay != 0)
|
||||||
? machine().firstcpu->cycles_to_attotime(line.delay)
|
? machine().firstcpu->cycles_to_attotime(line.delay)
|
||||||
: attotime::zero;
|
: attotime::zero;
|
||||||
@ -242,10 +243,10 @@ void cococart_slot_device::set_line_timer(coco_cartridge_line &line, cococart_li
|
|||||||
|
|
||||||
void cococart_slot_device::twiddle_line_if_q(coco_cartridge_line &line)
|
void cococart_slot_device::twiddle_line_if_q(coco_cartridge_line &line)
|
||||||
{
|
{
|
||||||
if (line.value == COCOCART_LINE_VALUE_Q)
|
if (line.value == line_value::Q)
|
||||||
{
|
{
|
||||||
line.q_count = 0;
|
line.q_count = 0;
|
||||||
set_line_timer(line, COCOCART_LINE_VALUE_Q);
|
set_line_timer(line, line_value::Q);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -268,23 +269,23 @@ void cococart_slot_device::twiddle_q_lines()
|
|||||||
// coco_cartridge_set_line
|
// coco_cartridge_set_line
|
||||||
//-------------------------------------------------
|
//-------------------------------------------------
|
||||||
|
|
||||||
void cococart_slot_device::cart_set_line(cococart_line line, cococart_line_value value)
|
void cococart_slot_device::cart_set_line(cococart_slot_device::line which, cococart_slot_device::line_value value)
|
||||||
{
|
{
|
||||||
switch (line)
|
switch (which)
|
||||||
{
|
{
|
||||||
case COCOCART_LINE_CART:
|
case line::CART:
|
||||||
set_line_timer(m_cart_line, value);
|
set_line_timer(m_cart_line, value);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case COCOCART_LINE_NMI:
|
case line::NMI:
|
||||||
set_line_timer(m_nmi_line, value);
|
set_line_timer(m_nmi_line, value);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case COCOCART_LINE_HALT:
|
case line::HALT:
|
||||||
set_line_timer(m_halt_line, value);
|
set_line_timer(m_halt_line, value);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case COCOCART_LINE_SOUND_ENABLE:
|
case line::SOUND_ENABLE:
|
||||||
// do nothing for now
|
// do nothing for now
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -14,45 +14,10 @@
|
|||||||
#include "softlist_dev.h"
|
#include "softlist_dev.h"
|
||||||
|
|
||||||
|
|
||||||
/***************************************************************************
|
|
||||||
CONSTANTS
|
|
||||||
***************************************************************************/
|
|
||||||
|
|
||||||
/* TIMER_POOL: Must be power of two */
|
|
||||||
#define TIMER_POOL 2
|
|
||||||
|
|
||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
TYPE DEFINITIONS
|
TYPE DEFINITIONS
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
/* output lines on the CoCo cartridge slot */
|
|
||||||
enum cococart_line
|
|
||||||
{
|
|
||||||
COCOCART_LINE_CART, /* connects to PIA1 CB1 */
|
|
||||||
COCOCART_LINE_NMI, /* connects to NMI line on CPU */
|
|
||||||
COCOCART_LINE_HALT, /* connects to HALT line on CPU */
|
|
||||||
COCOCART_LINE_SOUND_ENABLE /* sound enable */
|
|
||||||
};
|
|
||||||
|
|
||||||
/* since we have a special value "Q" - we have to use a special enum here */
|
|
||||||
enum cococart_line_value
|
|
||||||
{
|
|
||||||
COCOCART_LINE_VALUE_CLEAR,
|
|
||||||
COCOCART_LINE_VALUE_ASSERT,
|
|
||||||
COCOCART_LINE_VALUE_Q
|
|
||||||
};
|
|
||||||
|
|
||||||
struct coco_cartridge_line
|
|
||||||
{
|
|
||||||
emu_timer *timer[TIMER_POOL];
|
|
||||||
int timer_index;
|
|
||||||
int delay;
|
|
||||||
cococart_line_value value;
|
|
||||||
int line;
|
|
||||||
int q_count;
|
|
||||||
devcb_write_line *callback;
|
|
||||||
};
|
|
||||||
|
|
||||||
// ======================> cococart_base_update_delegate
|
// ======================> cococart_base_update_delegate
|
||||||
|
|
||||||
// direct region update handler
|
// direct region update handler
|
||||||
@ -76,6 +41,23 @@ class cococart_slot_device : public device_t,
|
|||||||
public device_image_interface
|
public device_image_interface
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
// output lines on the CoCo cartridge slot
|
||||||
|
enum class line
|
||||||
|
{
|
||||||
|
CART, // connects to PIA1 CB1
|
||||||
|
NMI, // connects to NMI line on CPU
|
||||||
|
HALT, // connects to HALT line on CPU
|
||||||
|
SOUND_ENABLE // sound enable
|
||||||
|
};
|
||||||
|
|
||||||
|
// since we have a special value "Q" - we have to use a special enum here
|
||||||
|
enum class line_value
|
||||||
|
{
|
||||||
|
CLEAR,
|
||||||
|
ASSERT,
|
||||||
|
Q
|
||||||
|
};
|
||||||
|
|
||||||
// construction/destruction
|
// construction/destruction
|
||||||
cococart_slot_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
|
cococart_slot_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
|
||||||
|
|
||||||
@ -110,7 +92,7 @@ public:
|
|||||||
DECLARE_WRITE8_MEMBER(write);
|
DECLARE_WRITE8_MEMBER(write);
|
||||||
|
|
||||||
// sets a cartridge line
|
// sets a cartridge line
|
||||||
void cart_set_line(cococart_line line, cococart_line_value value);
|
void cart_set_line(line line, line_value value);
|
||||||
|
|
||||||
// hack to support twiddling the Q line
|
// hack to support twiddling the Q line
|
||||||
void twiddle_q_lines();
|
void twiddle_q_lines();
|
||||||
@ -120,6 +102,9 @@ public:
|
|||||||
void set_cart_base_update(cococart_base_update_delegate update);
|
void set_cart_base_update(cococart_base_update_delegate update);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
// TIMER_POOL: Must be power of two
|
||||||
|
static constexpr int TIMER_POOL = 2;
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
TIMER_CART,
|
TIMER_CART,
|
||||||
@ -127,6 +112,17 @@ private:
|
|||||||
TIMER_HALT
|
TIMER_HALT
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct coco_cartridge_line
|
||||||
|
{
|
||||||
|
emu_timer *timer[TIMER_POOL];
|
||||||
|
int timer_index;
|
||||||
|
int delay;
|
||||||
|
line_value value;
|
||||||
|
int line;
|
||||||
|
int q_count;
|
||||||
|
devcb_write_line * callback;
|
||||||
|
};
|
||||||
|
|
||||||
// configuration
|
// configuration
|
||||||
coco_cartridge_line m_cart_line;
|
coco_cartridge_line m_cart_line;
|
||||||
coco_cartridge_line m_nmi_line;
|
coco_cartridge_line m_nmi_line;
|
||||||
@ -140,9 +136,10 @@ private:
|
|||||||
device_cococart_interface *m_cart;
|
device_cococart_interface *m_cart;
|
||||||
|
|
||||||
// methods
|
// methods
|
||||||
void set_line(const char *line_name, coco_cartridge_line &line, cococart_line_value value);
|
void set_line(const char *line_name, coco_cartridge_line &line, line_value value);
|
||||||
void set_line_timer(coco_cartridge_line &line, cococart_line_value value);
|
void set_line_timer(coco_cartridge_line &line, line_value value);
|
||||||
void twiddle_line_if_q(coco_cartridge_line &line);
|
void twiddle_line_if_q(coco_cartridge_line &line);
|
||||||
|
static const char *line_value_string(line_value value);
|
||||||
};
|
};
|
||||||
|
|
||||||
// device type definition
|
// device type definition
|
||||||
@ -181,4 +178,4 @@ private:
|
|||||||
#define MCFG_COCO_CARTRIDGE_REMOVE(_tag) \
|
#define MCFG_COCO_CARTRIDGE_REMOVE(_tag) \
|
||||||
MCFG_DEVICE_REMOVE(_tag)
|
MCFG_DEVICE_REMOVE(_tag)
|
||||||
|
|
||||||
#endif /* __COCOCART_H__ */
|
#endif // __COCOCART_H__
|
||||||
|
@ -708,7 +708,9 @@ void coco_state::update_sound(void)
|
|||||||
m_cassette->change_state(cas_sound, CASSETTE_MASK_SPEAKER);
|
m_cassette->change_state(cas_sound, CASSETTE_MASK_SPEAKER);
|
||||||
|
|
||||||
/* determine the cartridge sound status */
|
/* determine the cartridge sound status */
|
||||||
m_cococart->cart_set_line(COCOCART_LINE_SOUND_ENABLE, bCartSoundEnable ? COCOCART_LINE_VALUE_ASSERT : COCOCART_LINE_VALUE_CLEAR);
|
m_cococart->cart_set_line(
|
||||||
|
cococart_slot_device::line::SOUND_ENABLE,
|
||||||
|
bCartSoundEnable ? cococart_slot_device::line_value::ASSERT : cococart_slot_device::line_value::CLEAR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user