ccpu.c: Modernized cpu core. (nw)

This commit is contained in:
Wilbert Pol 2013-07-06 12:06:50 +00:00
parent 3ac1d4a0ec
commit c4a9fa50e3
5 changed files with 414 additions and 508 deletions

File diff suppressed because it is too large Load Diff

View File

@ -33,30 +33,97 @@ enum
};
typedef device_delegate<void (INT16, INT16, INT16, INT16, UINT8)> ccpu_vector_delegate;
/***************************************************************************
CONFIG STRUCTURE
***************************************************************************/
typedef UINT8 (*ccpu_input_func)(device_t *device);
typedef void (*ccpu_vector_func)(device_t *device, INT16 sx, INT16 sy, INT16 ex, INT16 ey, UINT8 shift);
#define MCFG_CCPU_EXTERNAL_FUNC(_devcb) \
ccpu_cpu_device::set_external_func(*device, DEVCB2_##_devcb);
struct ccpu_config
#define MCFG_CCPU_VECTOR_FUNC(d) \
ccpu_cpu_device::set_vector_func(*device, d);
class ccpu_cpu_device : public cpu_device
{
ccpu_input_func external_input; /* if NULL, assume JMI jumper is present */
ccpu_vector_func vector_callback;
public:
// construction/destruction
ccpu_cpu_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
// static configuration helpers
template<class _Object> static devcb2_base &set_external_func(device_t &device, _Object object) { return downcast<ccpu_cpu_device &>(device).m_external_input.set_callback(object); }
static void set_vector_func(device_t &device, ccpu_vector_delegate callback) { downcast<ccpu_cpu_device &>(device).m_vector_callback = callback; }
DECLARE_READ8_MEMBER( read_jmi );
void wdt_timer_trigger();
protected:
// device-level overrides
virtual void device_start();
virtual void device_reset();
// device_execute_interface overrides
virtual UINT32 execute_min_cycles() const { return 1; }
virtual UINT32 execute_max_cycles() const { return 1; }
virtual UINT32 execute_input_lines() const { return 0; }
virtual void execute_run();
// device_memory_interface overrides
virtual const address_space_config *memory_space_config(address_spacenum spacenum = AS_0) const
{
switch (spacenum)
{
case AS_PROGRAM: return &m_program_config;
case AS_IO: return &m_io_config;
case AS_DATA: return &m_data_config;
default: return NULL;
}
}
// device_state_interface overrides
void state_string_export(const device_state_entry &entry, astring &string);
// device_disasm_interface overrides
virtual UINT32 disasm_min_opcode_bytes() const { return 1; }
virtual UINT32 disasm_max_opcode_bytes() const { return 3; }
virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram, UINT32 options);
address_space_config m_program_config;
address_space_config m_data_config;
address_space_config m_io_config;
UINT16 m_PC;
UINT16 m_A;
UINT16 m_B;
UINT8 m_I;
UINT16 m_J;
UINT8 m_P;
UINT16 m_X;
UINT16 m_Y;
UINT16 m_T;
UINT16 * m_acc;
UINT16 m_a0flag, m_ncflag, m_cmpacc, m_cmpval;
UINT16 m_miflag, m_nextmiflag, m_nextnextmiflag;
UINT16 m_drflag;
devcb2_read8 m_external_input;
ccpu_vector_delegate m_vector_callback;
UINT8 m_waiting;
UINT8 m_watchdog;
int m_icount;
address_space *m_program;
direct_read_data *m_direct;
address_space *m_data;
address_space *m_io;
UINT16 m_flags;
};
extern const device_type CCPU;
/***************************************************************************
PUBLIC FUNCTIONS
***************************************************************************/
DECLARE_LEGACY_CPU_DEVICE(CCPU, ccpu);
void ccpu_wdt_timer_trigger(device_t *device);
CPU_DISASSEMBLE( ccpu );
#endif /* __CCPU_H__ */

View File

@ -142,15 +142,14 @@ WRITE8_MEMBER(cinemat_state::mux_select_w)
*
*************************************/
static UINT8 joystick_read(device_t *device)
READ8_MEMBER(cinemat_state::joystick_read)
{
cinemat_state *state = device->machine().driver_data<cinemat_state>();
if (device->machine().phase() != MACHINE_PHASE_RUNNING)
if (machine().phase() != MACHINE_PHASE_RUNNING)
return 0;
else
{
int xval = (INT16)(device->state().state_int(CCPU_X) << 4) >> 4;
return (state->ioport(state->m_mux_select ? "ANALOGX" : "ANALOGY")->read_safe(0) - xval) < 0x800;
int xval = (INT16)(m_maincpu->state_int(CCPU_X) << 4) >> 4;
return (ioport(m_mux_select ? "ANALOGX" : "ANALOGY")->read_safe(0) - xval) < 0x800;
}
}
@ -959,26 +958,6 @@ INPUT_PORTS_END
/*************************************
*
* CPU configurations
*
*************************************/
static const ccpu_config config_nojmi =
{
joystick_read,
cinemat_vector_callback
};
static const ccpu_config config_jmi =
{
NULL,
cinemat_vector_callback
};
/*************************************
*
* Core machine drivers
@ -989,7 +968,8 @@ static MACHINE_CONFIG_START( cinemat_nojmi_4k, cinemat_state )
/* basic machine hardware */
MCFG_CPU_ADD("maincpu", CCPU, MASTER_CLOCK/4)
MCFG_CPU_CONFIG(config_nojmi)
MCFG_CCPU_VECTOR_FUNC(ccpu_vector_delegate(FUNC(cinemat_state::cinemat_vector_callback),(cinemat_state*)owner))
MCFG_CCPU_EXTERNAL_FUNC(READ8(cinemat_state,joystick_read))
MCFG_CPU_PROGRAM_MAP(program_map_4k)
MCFG_CPU_DATA_MAP(data_map)
MCFG_CPU_IO_MAP(io_map)
@ -1009,7 +989,8 @@ MACHINE_CONFIG_END
static MACHINE_CONFIG_DERIVED( cinemat_jmi_4k, cinemat_nojmi_4k )
MCFG_CPU_MODIFY("maincpu")
MCFG_CPU_CONFIG(config_jmi)
MCFG_CCPU_VECTOR_FUNC(ccpu_vector_delegate(FUNC(cinemat_state::cinemat_vector_callback),(cinemat_state*)owner))
MCFG_CCPU_EXTERNAL_FUNC(DEVREAD8("maincpu",ccpu_cpu_device,read_jmi))
MACHINE_CONFIG_END

View File

@ -52,6 +52,7 @@ public:
DECLARE_WRITE8_MEMBER(cinemat_vector_control_w);
DECLARE_WRITE8_MEMBER(cinemat_sound_control_w);
DECLARE_WRITE8_MEMBER(qb3_sound_w);
DECLARE_READ8_MEMBER(joystick_read);
DECLARE_INPUT_CHANGED_MEMBER(coin_inserted);
DECLARE_DRIVER_INIT(speedfrk);
DECLARE_DRIVER_INIT(boxingb);
@ -71,7 +72,8 @@ public:
DECLARE_READ8_MEMBER(sound_portb_r);
DECLARE_WRITE8_MEMBER(sound_portb_w);
DECLARE_WRITE8_MEMBER(sound_output_w);
required_device<cpu_device> m_maincpu;
required_device<ccpu_cpu_device> m_maincpu;
void cinemat_vector_callback(INT16 sx, INT16 sy, INT16 ex, INT16 ey, UINT8 shift);
};
/*----------- defined in audio/cinemat.c -----------*/
@ -92,6 +94,3 @@ MACHINE_CONFIG_EXTERN( wotwc_sound );
MACHINE_CONFIG_EXTERN( demon_sound );
MACHINE_CONFIG_EXTERN( qb3_sound );
/*----------- defined in video/cinemat.c -----------*/
void cinemat_vector_callback(device_t *device, INT16 sx, INT16 sy, INT16 ex, INT16 ey, UINT8 shift);

View File

@ -33,10 +33,9 @@ enum
*
*************************************/
void cinemat_vector_callback(device_t *device, INT16 sx, INT16 sy, INT16 ex, INT16 ey, UINT8 shift)
void cinemat_state::cinemat_vector_callback(INT16 sx, INT16 sy, INT16 ex, INT16 ey, UINT8 shift)
{
cinemat_state *state = device->machine().driver_data<cinemat_state>();
const rectangle &visarea = device->machine().primary_screen->visible_area();
const rectangle &visarea = machine().primary_screen->visible_area();
int intensity = 0xff;
/* adjust for slop */
@ -50,15 +49,15 @@ void cinemat_vector_callback(device_t *device, INT16 sx, INT16 sy, INT16 ex, INT
intensity = 0x1ff * shift / 8;
/* move to the starting position if we're not there already */
if (sx != state->m_lastx || sy != state->m_lasty)
vector_add_point(device->machine(), sx << 16, sy << 16, 0, 0);
if (sx != m_lastx || sy != m_lasty)
vector_add_point(machine(), sx << 16, sy << 16, 0, 0);
/* draw the vector */
vector_add_point(device->machine(), ex << 16, ey << 16, state->m_vector_color, intensity);
vector_add_point(machine(), ex << 16, ey << 16, m_vector_color, intensity);
/* remember the last point */
state->m_lastx = ex;
state->m_lasty = ey;
m_lastx = ex;
m_lasty = ey;
}
@ -212,7 +211,7 @@ UINT32 cinemat_state::screen_update_cinemat(screen_device &screen, bitmap_rgb32
SCREEN_UPDATE32_CALL(vector);
vector_clear_list();
ccpu_wdt_timer_trigger(m_maincpu);
m_maincpu->wdt_timer_trigger();
return 0;
}