summaryrefslogtreecommitdiffstatshomepage
path: root/src/emu
diff options
context:
space:
mode:
author Curt Coder <curtcoder@mail.com>2009-08-21 08:19:17 +0000
committer Curt Coder <curtcoder@mail.com>2009-08-21 08:19:17 +0000
commitb2dcbb3b688c0c49bfd2000d485e6527731a2db8 (patch)
tree4d5ea024e18c05c1b470a915dfb721c7b5c03229 /src/emu
parentac3d58fad59e55421c8cc272c4aa69d48a1a3ebb (diff)
Intel 8085:
- refactored callbacks to use devcb - added 8080A variant
Diffstat (limited to 'src/emu')
-rw-r--r--src/emu/cpu/i8085/i8085.c74
-rw-r--r--src/emu/cpu/i8085/i8085.h31
2 files changed, 76 insertions, 29 deletions
diff --git a/src/emu/cpu/i8085/i8085.c b/src/emu/cpu/i8085/i8085.c
index 7758bb3a15e..b5b858876c5 100644
--- a/src/emu/cpu/i8085/i8085.c
+++ b/src/emu/cpu/i8085/i8085.c
@@ -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;
}
diff --git a/src/emu/cpu/i8085/i8085.h b/src/emu/cpu/i8085/i8085.h
index 6db8ecfa82f..f6b077ec198 100644
--- a/src/emu/cpu/i8085/i8085.h
+++ b/src/emu/cpu/i8085/i8085.h
@@ -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 )