Refactored the COP400 CPU cores to use the new memory functions.

This commit is contained in:
Curt Coder 2008-11-19 17:47:38 +00:00
parent e0d6d1323d
commit 49a90686e8
5 changed files with 51 additions and 14 deletions

View File

@ -19,6 +19,10 @@ struct _cop400_state
{ {
const cop400_interface *intf; const cop400_interface *intf;
const address_space *program;
const address_space *data;
const address_space *io;
/* registers */ /* registers */
UINT10 pc; /* 11-bit ROM address program counter */ UINT10 pc; /* 11-bit ROM address program counter */
UINT10 prevpc; /* previous value of program counter */ UINT10 prevpc; /* previous value of program counter */
@ -32,6 +36,8 @@ struct _cop400_state
UINT4 sio; /* 4-bit shift register and counter */ UINT4 sio; /* 4-bit shift register and counter */
UINT1 skl; /* 1-bit latch for SK output */ UINT1 skl; /* 1-bit latch for SK output */
UINT8 si; /* serial input */ UINT8 si; /* serial input */
UINT4 h; /* 4-bit general purpose I/O port (COP440 only) */
UINT8 r; /* 8-bit general purpose I/O port (COP440 only) */
/* counter */ /* counter */
UINT8 t; /* 8-bit timer */ UINT8 t; /* 8-bit timer */
@ -77,12 +83,11 @@ typedef struct {
#define INSTRUCTION(mnemonic) INLINE void (mnemonic)(cop400_state *cop400, UINT8 opcode) #define INSTRUCTION(mnemonic) INLINE void (mnemonic)(cop400_state *cop400, UINT8 opcode)
#define ROM(addr) program_decrypted_read_byte(addr) #define ROM(a) memory_decrypted_read_byte(cop400->program, a)
#define RAM_W(addr, value) (data_write_byte_8le(addr, value)) #define RAM_R(a) memory_read_byte_8le(cop400->data, a)
#define RAM_R(addr) (data_read_byte_8le(addr)) #define RAM_W(a, v) memory_write_byte_8le(cop400->data, a, v)
#define IN(a) memory_read_byte_8le(cop400->io, a)
#define IN(addr) io_read_byte_8le(addr) #define OUT(a, v) memory_write_byte_8le(cop400->io, a, v)
#define OUT(addr, value) io_write_byte_8le(addr, value)
#define A cop400->a #define A cop400->a
#define B cop400->b #define B cop400->b

View File

@ -14,13 +14,18 @@
#ifndef __COP400__ #ifndef __COP400__
#define __COP400__ #define __COP400__
#define COP400_PORT_L 0x100 enum
#define COP400_PORT_G 0x101 {
#define COP400_PORT_D 0x102 COP400_PORT_L = 0x100,
#define COP400_PORT_IN 0x103 COP400_PORT_G,
#define COP400_PORT_SK 0x104 COP400_PORT_D,
#define COP400_PORT_SIO 0x105 COP400_PORT_H,
#define COP400_PORT_CKO 0x106 COP400_PORT_R,
COP400_PORT_IN,
COP400_PORT_SK,
COP400_PORT_SIO,
COP400_PORT_CKO
};
enum enum
{ {
@ -29,6 +34,8 @@ enum
COP400_B, COP400_B,
COP400_C, COP400_C,
COP400_G, COP400_G,
COP400_H,
COP400_R,
COP400_EN, COP400_EN,
COP400_Q, COP400_Q,
COP400_SA, COP400_SA,

View File

@ -21,6 +21,8 @@
*/ */
#define NO_LEGACY_MEMORY_HANDLERS 1
#include "driver.h" #include "driver.h"
#include "cpuintrf.h" #include "cpuintrf.h"
#include "debugger.h" #include "debugger.h"
@ -182,6 +184,12 @@ static CPU_INIT( cop410 )
cop400->device = device; cop400->device = device;
cop400->intf = (cop400_interface *) device->static_config; cop400->intf = (cop400_interface *) device->static_config;
/* get address spaces */
cop400->program = cpu_get_address_space(device, ADDRESS_SPACE_PROGRAM);
cop400->data = cpu_get_address_space(device, ADDRESS_SPACE_DATA);
cop400->io = cpu_get_address_space(device, ADDRESS_SPACE_IO);
/* set output pin masks */ /* set output pin masks */
cop400->g_mask = 0x0f; cop400->g_mask = 0x0f;

View File

@ -23,6 +23,8 @@
*/ */
#define NO_LEGACY_MEMORY_HANDLERS 1
#include "driver.h" #include "driver.h"
#include "cpuintrf.h" #include "cpuintrf.h"
#include "debugger.h" #include "debugger.h"
@ -184,6 +186,12 @@ static CPU_INIT( cop420 )
cop400->device = device; cop400->device = device;
cop400->intf = (cop400_interface *) device->static_config; cop400->intf = (cop400_interface *) device->static_config;
/* get address spaces */
cop400->program = cpu_get_address_space(device, ADDRESS_SPACE_PROGRAM);
cop400->data = cpu_get_address_space(device, ADDRESS_SPACE_DATA);
cop400->io = cpu_get_address_space(device, ADDRESS_SPACE_IO);
/* set output pin masks */ /* set output pin masks */
cop400->g_mask = 0x0f; // G0-G3 available cop400->g_mask = 0x0f; // G0-G3 available

View File

@ -13,7 +13,8 @@
TODO: TODO:
- COP441 - rename this file to cop444.c
- COP440/COP441/COP442 (new registers: 4-bit H, 8-bit R; some new opcodes, 2Kx8 ROM, 160x4 RAM)
- COP404 emulation configuration inputs - COP404 emulation configuration inputs
- RAM bus width - RAM bus width
- get rid of LBIOps/InstLen - get rid of LBIOps/InstLen
@ -26,6 +27,8 @@
*/ */
#define NO_LEGACY_MEMORY_HANDLERS 1
#include "driver.h" #include "driver.h"
#include "cpuintrf.h" #include "cpuintrf.h"
#include "debugger.h" #include "debugger.h"
@ -195,6 +198,12 @@ static CPU_INIT( cop444 )
cop400->device = device; cop400->device = device;
cop400->intf = (cop400_interface *) device->static_config; cop400->intf = (cop400_interface *) device->static_config;
/* get address spaces */
cop400->program = cpu_get_address_space(device, ADDRESS_SPACE_PROGRAM);
cop400->data = cpu_get_address_space(device, ADDRESS_SPACE_DATA);
cop400->io = cpu_get_address_space(device, ADDRESS_SPACE_IO);
/* set output pin masks */ /* set output pin masks */
cop400->g_mask = 0x0f; // G0-G3 available cop400->g_mask = 0x0f; // G0-G3 available