Intel 8085:

- refactored callbacks to use devcb
- added 8080A variant
This commit is contained in:
Curt Coder 2009-08-21 08:19:17 +00:00
parent ac3d58fad5
commit b2dcbb3b68
8 changed files with 107 additions and 59 deletions

View File

@ -132,6 +132,11 @@
* - renamed flags from Z80 style S Z Y H X V N C to S Z X5 H X3 P V C, and
* fixed X5 / V flags where accidentally broken due to flag names confusion
*
* 21-Aug-2009, Curt Coder
*
* - added 8080A variant
* - refactored callbacks to use devcb
*
*****************************************************************************/
#include "debugger.h"
@ -155,6 +160,12 @@ typedef struct _i8085_state i8085_state;
struct _i8085_state
{
i8085_config config;
devcb_resolved_write8 out_status_func;
devcb_resolved_write_line out_inte_func;
devcb_resolved_read_line in_sid_func;
devcb_resolved_write_line out_sod_func;
int cputype; /* 0 8080, 1 8085A */
PAIR PC,SP,AF,BC,DE,HL,WZ;
UINT8 HALT;
@ -321,14 +332,12 @@ INLINE void set_sod(i8085_state *cpustate, int state)
if (state != 0 && cpustate->sod_state == 0)
{
cpustate->sod_state = 1;
if (cpustate->config.sod != NULL)
(*cpustate->config.sod)(cpustate->device, 1);
devcb_call_write_line(&cpustate->out_sod_func, cpustate->sod_state);
}
else if (state == 0 && cpustate->sod_state != 0)
{
cpustate->sod_state = 0;
if (cpustate->config.sod != NULL)
(*cpustate->config.sod)(cpustate->device, 0);
devcb_call_write_line(&cpustate->out_sod_func, cpustate->sod_state);
}
}
@ -338,22 +347,21 @@ INLINE void set_inte(i8085_state *cpustate, int state)
if (state != 0 && (cpustate->IM & IM_IE) == 0)
{
cpustate->IM |= IM_IE;
if (cpustate->config.inte != NULL)
(*cpustate->config.inte)(cpustate->device, 1);
devcb_call_write_line(&cpustate->out_inte_func, 1);
}
else if (state == 0 && (cpustate->IM & IM_IE) != 0)
{
cpustate->IM &= ~IM_IE;
if (cpustate->config.inte != NULL)
(*cpustate->config.inte)(cpustate->device, 0);
devcb_call_write_line(&cpustate->out_inte_func, 0);
}
}
INLINE void set_status(i8085_state *cpustate, UINT8 status)
{
if (status != cpustate->STATUS && cpustate->config.status != NULL)
(*cpustate->config.status)(cpustate->device, status);
if (status != cpustate->STATUS)
devcb_call_write8(&cpustate->out_status_func, 0, status);
cpustate->STATUS = status;
}
@ -361,6 +369,7 @@ INLINE void set_status(i8085_state *cpustate, UINT8 status)
INLINE UINT8 get_rim_value(i8085_state *cpustate)
{
UINT8 result = cpustate->IM;
int sid = devcb_call_read_line(&cpustate->in_sid_func);
/* copy live RST5.5 and RST6.5 states */
result &= ~(IM_I65 | IM_I55);
@ -370,8 +379,8 @@ INLINE UINT8 get_rim_value(i8085_state *cpustate)
result |= IM_I55;
/* fetch the SID bit if we have a callback */
if (cpustate->config.sid != NULL)
result = (result & 0x7f) | ((*cpustate->config.sid)(cpustate->device) ? 0x80 : 0);
result = (result & 0x7f) | (sid ? 0x80 : 0);
return result;
}
@ -1030,6 +1039,13 @@ static void init_808x_common(const device_config *device, cpu_irq_callback irqca
cpustate->program = memory_find_address_space(device, ADDRESS_SPACE_PROGRAM);
cpustate->io = memory_find_address_space(device, ADDRESS_SPACE_IO);
/* resolve callbacks */
devcb_resolve_write8(&cpustate->out_status_func, &cpustate->config.out_status_func, device);
devcb_resolve_write_line(&cpustate->out_inte_func, &cpustate->config.out_inte_func, device);
devcb_resolve_read_line(&cpustate->in_sid_func, &cpustate->config.in_sid_func, device);
devcb_resolve_write_line(&cpustate->out_sod_func, &cpustate->config.out_sod_func, device);
/* register for state saving */
state_save_register_device_item(device, 0, cpustate->PC.w.l);
state_save_register_device_item(device, 0, cpustate->SP.w.l);
state_save_register_device_item(device, 0, cpustate->AF.w.l);
@ -1118,9 +1134,12 @@ static CPU_EXPORT_STATE( i808x )
switch (entry->index)
{
case I8085_SID:
{
int sid = devcb_call_read_line(&cpustate->in_sid_func);
cpustate->ietemp = ((cpustate->IM & IM_SID) != 0);
if (cpustate->config.sid != NULL)
cpustate->ietemp = ((*cpustate->config.sid)(cpustate->device) != 0);
cpustate->ietemp = (sid != 0);
}
break;
case I8085_INTE:
@ -1226,7 +1245,7 @@ CPU_GET_INFO( i8085 )
/* --- the following bits of info are returned as NULL-terminated strings --- */
case DEVINFO_STR_NAME: strcpy(info->s, "8085A"); break;
case DEVINFO_STR_FAMILY: strcpy(info->s, "Intel 8080"); break;
case DEVINFO_STR_FAMILY: strcpy(info->s, "MCS-85"); break;
case DEVINFO_STR_VERSION: strcpy(info->s, "1.1"); break;
case DEVINFO_STR_SOURCE_FILE: strcpy(info->s, __FILE__); break;
case DEVINFO_STR_CREDITS: strcpy(info->s, "Copyright Juergen Buchmueller, all rights reserved."); break;
@ -1263,6 +1282,31 @@ CPU_GET_INFO( i8080 )
/* --- the following bits of info are returned as NULL-terminated strings --- */
case DEVINFO_STR_NAME: strcpy(info->s, "8080"); break;
case DEVINFO_STR_FAMILY: strcpy(info->s, "MCS-80"); break;
default: CPU_GET_INFO_CALL(i8085); break;
}
}
/***************************************************************************
8080A-SPECIFIC GET INFO
***************************************************************************/
CPU_GET_INFO( i8080a )
{
switch (state)
{
/* --- the following bits of info are returned as 64-bit signed integers --- */
case CPUINFO_INT_CLOCK_DIVIDER: info->i = 1; break;
case CPUINFO_INT_INPUT_LINES: info->i = 1; break;
/* --- the following bits of info are returned as pointers to functions --- */
case CPUINFO_FCT_INIT: info->init = CPU_INIT_NAME(i8080); break;
/* --- the following bits of info are returned as NULL-terminated strings --- */
case DEVINFO_STR_NAME: strcpy(info->s, "8080A"); break;
case DEVINFO_STR_FAMILY: strcpy(info->s, "MCS-80"); break;
default: CPU_GET_INFO_CALL(i8085); break;
}

View File

@ -2,7 +2,7 @@
#define __I8085_H__
#include "cpuintrf.h"
#include "devcb.h"
/***************************************************************************
CONSTANTS
@ -20,33 +20,33 @@ enum
I8085_GENPCBASE = REG_GENPCBASE
};
#define I8085_INTR_LINE 0
#define I8085_RST55_LINE 1
#define I8085_RST65_LINE 2
#define I8085_RST75_LINE 3
#define I8085_STATUS_INTA 0x01
#define I8085_STATUS_WO 0x02
#define I8085_STATUS_STACK 0x04
#define I8085_STATUS_HLTA 0x08
#define I8085_STATUS_OUT 0x10
#define I8085_STATUS_M1 0x20
#define I8085_STATUS_INP 0x40
#define I8085_STATUS_MEMR 0x80
/***************************************************************************
TYPE DEFINITIONS
***************************************************************************/
typedef void (*i8085_sod_func)(const device_config *device, int state);
typedef int (*i8085_sid_func)(const device_config *device);
typedef void (*i8085_inte_func)(const device_config *device, int state);
typedef void (*i8085_status_func)(const device_config *device, UINT8 status);
typedef struct _i8085_config i8085_config;
struct _i8085_config
{
i8085_inte_func inte; /* INTE changed callback */
i8085_status_func status; /* STATUS changed callback */
i8085_sod_func sod; /* SOD changed callback (8085A only) */
i8085_sid_func sid; /* SID changed callback (8085A only) */
devcb_write8 out_status_func; /* STATUS changed callback */
devcb_write_line out_inte_func; /* INTE changed callback */
devcb_read_line in_sid_func; /* SID changed callback (8085A only) */
devcb_write_line out_sod_func; /* SOD changed callback (8085A only) */
};
#define I8085_CONFIG(name) const i8085_config (name) =
/***************************************************************************
FUNCTION PROTOTYPES
@ -55,6 +55,9 @@ struct _i8085_config
CPU_GET_INFO( i8080 );
#define CPU_8080 CPU_GET_INFO_NAME( i8080 )
CPU_GET_INFO( i8080a );
#define CPU_8080A CPU_GET_INFO_NAME( i8080a )
CPU_GET_INFO( i8085 );
#define CPU_8085A CPU_GET_INFO_NAME( i8085 )

View File

@ -168,24 +168,24 @@ WRITE8_HANDLER( redalert_voice_command_w )
}
static void sod_callback(const device_config *device, int data)
static WRITE_LINE_DEVICE_HANDLER( sod_callback )
{
hc55516_digit_w(devtag_get_device(device->machine, "cvsd"), data);
hc55516_digit_w(devtag_get_device(device->machine, "cvsd"), state);
}
static int sid_callback(const device_config *device)
static READ_LINE_DEVICE_HANDLER( sid_callback )
{
return hc55516_clock_state_r(devtag_get_device(device->machine, "cvsd"));
}
static const i8085_config redalert_voice_i8085_config =
static I8085_CONFIG( redalert_voice_i8085_config )
{
NULL, /* INTE changed callback */
NULL, /* STATUS changed callback */
sod_callback, /* SOD changed callback (8085A only) */
sid_callback /* SID changed callback (8085A only) */
DEVCB_NULL, /* STATUS changed callback */
DEVCB_NULL, /* INTE changed callback */
DEVCB_LINE(sid_callback), /* SID changed callback (8085A only) */
DEVCB_LINE(sod_callback) /* SOD changed callback (8085A only) */
};

View File

@ -529,18 +529,18 @@ static VIDEO_UPDATE( dwarfd )
return 0;
}
static void dwarfd_sod_callback(const device_config *device, int nSO)
static WRITE_LINE_DEVICE_HANDLER( dwarfd_sod_callback )
{
crt_access=nSO;
crt_access = state;
}
static const i8085_config dwarfd_i8085_config =
static I8085_CONFIG( dwarfd_i8085_config )
{
NULL, /* INTE changed callback */
NULL, /* STATUS changed callback */
dwarfd_sod_callback, /* SOD changed callback (8085A only) */
NULL /* SID changed callback (8085A only) */
DEVCB_NULL, /* STATUS changed callback */
DEVCB_NULL, /* INTE changed callback */
DEVCB_NULL, /* SID changed callback (8085A only) */
DEVCB_LINE(dwarfd_sod_callback) /* SOD changed callback (8085A only) */
};

View File

@ -81,26 +81,26 @@ static TIMER_DEVICE_CALLBACK( rst2_tick )
cputag_set_input_line_and_vector(timer->machine, "maincpu", INPUT_LINE_IRQ0, state, 0xd7);
}
static void n8080_inte_callback(const device_config *device, int state)
static WRITE_LINE_DEVICE_HANDLER( n8080_inte_callback )
{
inte = state;
}
static void n8080_status_callback(const device_config *device, UINT8 status)
static WRITE8_DEVICE_HANDLER( n8080_status_callback )
{
if (BIT(status, 0))
if (data & I8085_STATUS_INTA)
{
/* interrupt acknowledge */
cpu_set_input_line(device, INPUT_LINE_IRQ0, CLEAR_LINE);
}
}
static const i8085_config n8080_cpu_config =
static I8085_CONFIG( n8080_cpu_config )
{
n8080_inte_callback, /* INTE changed callback */
n8080_status_callback, /* STATUS changed callback */
NULL, /* SOD changed callback (8085A only) */
NULL, /* SID changed callback (8085A only) */
DEVCB_HANDLER(n8080_status_callback), /* STATUS changed callback */
DEVCB_LINE(n8080_inte_callback), /* INTE changed callback */
DEVCB_NULL, /* SID changed callback (8085A only) */
DEVCB_NULL /* SOD changed callback (8085A only) */
};
static MACHINE_DRIVER_START( spacefev )

View File

@ -513,12 +513,12 @@ MACHINE_DRIVER_END
/* Same as Phoenix, but uses an AY8910 and an extra visible line (column) */
static const i8085_config survival_i8085_config =
static I8085_CONFIG( survival_i8085_config )
{
NULL, /* INTE changed callback */
NULL, /* STATUS changed callback */
NULL, /* SOD changed callback (8085A only) */
survival_sid_callback /* SID changed callback (8085A only) */
DEVCB_NULL, /* STATUS changed callback */
DEVCB_NULL, /* INTE changed callback */
DEVCB_LINE(survival_sid_callback), /* SID changed callback (8085A only) */
DEVCB_NULL /* SOD changed callback (8085A only) */
};
static MACHINE_DRIVER_START( survival )

View File

@ -1,3 +1,4 @@
#include "devcb.h"
#include "sound/discrete.h"
@ -73,5 +74,5 @@ CUSTOM_INPUT( pleiads_protection_r );
READ8_HANDLER( survival_input_port_0_r );
READ8_DEVICE_HANDLER( survival_protection_r );
int survival_sid_callback( const device_config *device );
READ_LINE_DEVICE_HANDLER( survival_sid_callback );

View File

@ -435,7 +435,7 @@ READ8_DEVICE_HANDLER( survival_protection_r )
return survival_protection_value;
}
int survival_sid_callback( const device_config *device )
READ_LINE_DEVICE_HANDLER( survival_sid_callback )
{
return survival_sid_value;
}