mirror of
https://github.com/holub/mame
synced 2025-04-24 01:11:11 +03:00
lh5801.c: Modernized cpu core(nw)
This commit is contained in:
parent
77fd68733e
commit
abe3d67e34
File diff suppressed because it is too large
Load Diff
@ -54,50 +54,18 @@ enum
|
||||
LH5801_IRQ_STATE
|
||||
};
|
||||
|
||||
struct lh5801_state
|
||||
{
|
||||
const lh5801_cpu_core *config;
|
||||
legacy_cpu_device *device;
|
||||
address_space *program; //ME0
|
||||
address_space *io; //ME1
|
||||
direct_read_data *direct;
|
||||
|
||||
PAIR s, p, u, x, y;
|
||||
int tm; //9 bit
|
||||
|
||||
UINT8 t, a;
|
||||
|
||||
int bf, dp, pu, pv;
|
||||
|
||||
UINT16 oldpc;
|
||||
|
||||
int irq_state;
|
||||
|
||||
UINT8 ir_flipflop[3]; //interrupt request flipflop: IR0, IR1, IR2
|
||||
int lines_status[2]; //MI and NMI lines status
|
||||
|
||||
int idle;
|
||||
int icount;
|
||||
};
|
||||
|
||||
INLINE lh5801_state *get_safe_token(device_t *device)
|
||||
{
|
||||
assert(device != NULL);
|
||||
assert(device->type() == LH5801);
|
||||
return (lh5801_state *)downcast<legacy_cpu_device *>(device)->token();
|
||||
}
|
||||
|
||||
#define P cpustate->p.w.l
|
||||
#define S cpustate->s.w.l
|
||||
#define U cpustate->u.w.l
|
||||
#define UL cpustate->u.b.l
|
||||
#define UH cpustate->u.b.h
|
||||
#define X cpustate->x.w.l
|
||||
#define XL cpustate->x.b.l
|
||||
#define XH cpustate->x.b.h
|
||||
#define Y cpustate->y.w.l
|
||||
#define YL cpustate->y.b.l
|
||||
#define YH cpustate->y.b.h
|
||||
#define P m_p.w.l
|
||||
#define S m_s.w.l
|
||||
#define U m_u.w.l
|
||||
#define UL m_u.b.l
|
||||
#define UH m_u.b.h
|
||||
#define X m_x.w.l
|
||||
#define XL m_x.b.l
|
||||
#define XH m_x.b.h
|
||||
#define Y m_y.w.l
|
||||
#define YL m_y.b.l
|
||||
#define YH m_y.b.h
|
||||
|
||||
#define C 0x01
|
||||
#define IE 0x02
|
||||
@ -105,243 +73,195 @@ INLINE lh5801_state *get_safe_token(device_t *device)
|
||||
#define V 0x08
|
||||
#define H 0x10
|
||||
|
||||
|
||||
const device_type LH5801 = &device_creator<lh5801_cpu_device>;
|
||||
|
||||
|
||||
lh5801_cpu_device::lh5801_cpu_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
|
||||
: cpu_device(mconfig, LH5801, "LH5801", tag, owner, clock, "lh5801", __FILE__)
|
||||
, m_program_config("program", ENDIANNESS_LITTLE, 8, 16, 0)
|
||||
, m_io_config("io", ENDIANNESS_LITTLE, 8, 16, 0)
|
||||
, m_in_func(*this)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/***************************************************************
|
||||
* include the opcode macros, functions and tables
|
||||
***************************************************************/
|
||||
#include "5801tbl.c"
|
||||
|
||||
static CPU_INIT( lh5801 )
|
||||
void lh5801_cpu_device::device_start()
|
||||
{
|
||||
lh5801_state *cpustate = get_safe_token(device);
|
||||
m_program = &space(AS_PROGRAM);
|
||||
m_io = &space(AS_IO);
|
||||
m_direct = &m_program->direct();
|
||||
|
||||
memset(cpustate, 0, sizeof(*cpustate));
|
||||
cpustate->config = (const lh5801_cpu_core *) device->static_config();
|
||||
cpustate->device = device;
|
||||
cpustate->program = &device->space(AS_PROGRAM);
|
||||
cpustate->io = &device->space(AS_IO);
|
||||
cpustate->direct = &cpustate->program->direct();
|
||||
m_in_func.resolve_safe(0);
|
||||
|
||||
m_s.w.l = 0;
|
||||
m_p.w.l = 0;
|
||||
m_u.w.l = 0;
|
||||
m_x.w.l = 0;
|
||||
m_y.w.l = 0;
|
||||
m_tm = 0;
|
||||
m_t = 0;
|
||||
m_a = 0;
|
||||
m_bf = 0;
|
||||
m_dp = 0;
|
||||
m_pu = 0;
|
||||
m_pv = 0;
|
||||
m_oldpc = 0;
|
||||
m_irq_state = 0;
|
||||
memset(m_ir_flipflop, 0, sizeof(m_ir_flipflop));
|
||||
memset(m_lines_status, 0, sizeof(m_lines_status));
|
||||
m_idle = 0;
|
||||
|
||||
save_item(NAME(m_s.w.l));
|
||||
save_item(NAME(m_p.w.l));
|
||||
save_item(NAME(m_u.w.l));
|
||||
save_item(NAME(m_x.w.l));
|
||||
save_item(NAME(m_y.w.l));
|
||||
save_item(NAME(m_tm));
|
||||
save_item(NAME(m_t));
|
||||
save_item(NAME(m_a));
|
||||
save_item(NAME(m_bf));
|
||||
save_item(NAME(m_dp));
|
||||
save_item(NAME(m_pu));
|
||||
save_item(NAME(m_pv));
|
||||
save_item(NAME(m_oldpc));
|
||||
save_item(NAME(m_irq_state));
|
||||
save_item(NAME(m_ir_flipflop));
|
||||
save_item(NAME(m_lines_status));
|
||||
save_item(NAME(m_idle));
|
||||
|
||||
state_add( LH5801_P, "P", m_p.w.l ).formatstr("%04X");
|
||||
state_add( LH5801_S, "S", m_s.w.l ).formatstr("%04X");
|
||||
state_add( LH5801_U, "U", m_u.w.l ).formatstr("%04X");
|
||||
state_add( LH5801_X, "X", m_x.w.l ).formatstr("%04X");
|
||||
state_add( LH5801_Y, "Y", m_y.w.l ).formatstr("%04X");
|
||||
state_add( LH5801_T, "T", m_t ).formatstr("%02X");
|
||||
state_add( LH5801_A, "A", m_a ).formatstr("%02X");
|
||||
state_add( LH5801_TM, "TM", m_tm ).formatstr("%03X");
|
||||
state_add( LH5801_PV, "PV", m_pv ).formatstr("%04X");
|
||||
state_add( LH5801_PU, "PU", m_pu ).formatstr("%04X");
|
||||
state_add( LH5801_BF, "BF", m_bf ).formatstr("%04X");
|
||||
state_add( LH5801_DP, "DP", m_dp ).formatstr("%04X");
|
||||
|
||||
state_add(STATE_GENPC, "GENPC", m_p.w.l).noshow();
|
||||
state_add(STATE_GENFLAGS, "GENFLAGS", m_t).noshow().formatstr("%8s");
|
||||
|
||||
m_icountptr = &m_icount;
|
||||
}
|
||||
|
||||
static CPU_RESET( lh5801 )
|
||||
void lh5801_cpu_device::state_string_export(const device_state_entry &entry, astring &string)
|
||||
{
|
||||
lh5801_state *cpustate = get_safe_token(device);
|
||||
switch (entry.index())
|
||||
{
|
||||
case STATE_GENFLAGS:
|
||||
string.printf("%c%c%c%c%c%c%c%c",
|
||||
m_t&0x80?'1':'0',
|
||||
m_t&0x40?'1':'0',
|
||||
m_t&0x20?'1':'0',
|
||||
m_t&0x10?'H':'.',
|
||||
m_t&0x08?'V':'.',
|
||||
m_t&0x04?'Z':'.',
|
||||
m_t&0x02?'I':'.',
|
||||
m_t&0x01?'C':'.');
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
P = (cpustate->program->read_byte(0xfffe)<<8) | cpustate->program->read_byte(0xffff);
|
||||
void lh5801_cpu_device::device_reset()
|
||||
{
|
||||
P = (m_program->read_byte(0xfffe)<<8) | m_program->read_byte(0xffff);
|
||||
|
||||
cpustate->idle=0;
|
||||
m_idle=0;
|
||||
|
||||
memset(cpustate->ir_flipflop, 0, sizeof(cpustate->ir_flipflop));
|
||||
memset(cpustate->lines_status, 0, sizeof(cpustate->lines_status));
|
||||
memset(m_ir_flipflop, 0, sizeof(m_ir_flipflop));
|
||||
memset(m_lines_status, 0, sizeof(m_lines_status));
|
||||
}
|
||||
|
||||
|
||||
static void check_irq(device_t *device)
|
||||
void lh5801_cpu_device::check_irq()
|
||||
{
|
||||
lh5801_state *cpustate = get_safe_token(device);
|
||||
|
||||
if (cpustate->ir_flipflop[0])
|
||||
if (m_ir_flipflop[0])
|
||||
{
|
||||
//NMI interrupt
|
||||
cpustate->ir_flipflop[0] = 0;
|
||||
lh5801_push(cpustate,cpustate->t);
|
||||
cpustate->t&=~IE;
|
||||
lh5801_push_word(cpustate,P);
|
||||
P = (cpustate->program->read_byte(0xfffc)<<8) | cpustate->program->read_byte(0xfffd);
|
||||
m_ir_flipflop[0] = 0;
|
||||
lh5801_push(m_t);
|
||||
m_t&=~IE;
|
||||
lh5801_push_word(P);
|
||||
P = (m_program->read_byte(0xfffc)<<8) | m_program->read_byte(0xfffd);
|
||||
}
|
||||
else if (cpustate->ir_flipflop[1] && (cpustate->t & IE))
|
||||
else if (m_ir_flipflop[1] && (m_t & IE))
|
||||
{
|
||||
//counter interrupt (counter not yet implemented)
|
||||
cpustate->ir_flipflop[1] = 0;
|
||||
lh5801_push(cpustate,cpustate->t);
|
||||
cpustate->t&=~IE;
|
||||
lh5801_push_word(cpustate,P);
|
||||
P = (cpustate->program->read_byte(0xfffa)<<8) | cpustate->program->read_byte(0xfffb);
|
||||
m_ir_flipflop[1] = 0;
|
||||
lh5801_push(m_t);
|
||||
m_t&=~IE;
|
||||
lh5801_push_word(P);
|
||||
P = (m_program->read_byte(0xfffa)<<8) | m_program->read_byte(0xfffb);
|
||||
}
|
||||
else if (cpustate->ir_flipflop[2] && (cpustate->t & IE))
|
||||
else if (m_ir_flipflop[2] && (m_t & IE))
|
||||
{
|
||||
//MI interrupt
|
||||
cpustate->ir_flipflop[2] = 0;
|
||||
lh5801_push(cpustate, cpustate->t);
|
||||
cpustate->t&=~IE;
|
||||
lh5801_push_word(cpustate, P);
|
||||
P = (cpustate->program->read_byte(0xfff8)<<8) | cpustate->program->read_byte(0xfff9);
|
||||
m_ir_flipflop[2] = 0;
|
||||
lh5801_push(m_t);
|
||||
m_t&=~IE;
|
||||
lh5801_push_word(P);
|
||||
P = (m_program->read_byte(0xfff8)<<8) | m_program->read_byte(0xfff9);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static CPU_EXECUTE( lh5801 )
|
||||
void lh5801_cpu_device::execute_run()
|
||||
{
|
||||
lh5801_state *cpustate = get_safe_token(device);
|
||||
|
||||
do
|
||||
{
|
||||
check_irq(device);
|
||||
check_irq();
|
||||
|
||||
if (cpustate->idle)
|
||||
cpustate->icount = 0;
|
||||
if (m_idle)
|
||||
m_icount = 0;
|
||||
else
|
||||
{
|
||||
cpustate->oldpc = P;
|
||||
m_oldpc = P;
|
||||
|
||||
debugger_instruction_hook(device, P);
|
||||
lh5801_instruction(cpustate);
|
||||
debugger_instruction_hook(this, P);
|
||||
lh5801_instruction();
|
||||
}
|
||||
|
||||
} while (cpustate->icount > 0);
|
||||
} while (m_icount > 0);
|
||||
}
|
||||
|
||||
static void set_irq_line(lh5801_state *cpustate, int irqline, int state)
|
||||
void lh5801_cpu_device::execute_set_input(int irqline, int state)
|
||||
{
|
||||
switch( irqline)
|
||||
{
|
||||
case LH5801_LINE_MI:
|
||||
if (cpustate->lines_status[0] == CLEAR_LINE && state == ASSERT_LINE)
|
||||
if (m_lines_status[0] == CLEAR_LINE && state == ASSERT_LINE)
|
||||
{
|
||||
cpustate->idle = 0;
|
||||
cpustate->ir_flipflop[2] = 1;
|
||||
m_idle = 0;
|
||||
m_ir_flipflop[2] = 1;
|
||||
}
|
||||
|
||||
cpustate->lines_status[0] = state;
|
||||
m_lines_status[0] = state;
|
||||
break;
|
||||
case INPUT_LINE_NMI:
|
||||
if (cpustate->lines_status[1] == CLEAR_LINE && state == ASSERT_LINE)
|
||||
if (m_lines_status[1] == CLEAR_LINE && state == ASSERT_LINE)
|
||||
{
|
||||
cpustate->idle = 0;
|
||||
cpustate->ir_flipflop[0] = 1;
|
||||
m_idle = 0;
|
||||
m_ir_flipflop[0] = 1;
|
||||
}
|
||||
|
||||
cpustate->lines_status[1] = state;
|
||||
m_lines_status[1] = state;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
* Generic set_info
|
||||
**************************************************************************/
|
||||
|
||||
static CPU_SET_INFO( lh5801 )
|
||||
offs_t lh5801_cpu_device::disasm_disassemble(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram, UINT32 options)
|
||||
{
|
||||
lh5801_state *cpustate = get_safe_token(device);
|
||||
switch (state)
|
||||
{
|
||||
/* --- the following bits of info are set as 64-bit signed integers --- */
|
||||
case CPUINFO_INT_INPUT_STATE + LH5801_LINE_MI: set_irq_line(cpustate, LH5801_LINE_MI, info->i); break;
|
||||
case CPUINFO_INT_INPUT_STATE + INPUT_LINE_NMI: set_irq_line(cpustate, INPUT_LINE_NMI, info->i); break;
|
||||
|
||||
case CPUINFO_INT_PC:
|
||||
case CPUINFO_INT_REGISTER + LH5801_P: P = info->i; break;
|
||||
case CPUINFO_INT_SP:
|
||||
case CPUINFO_INT_REGISTER + LH5801_S: S = info->i; break;
|
||||
case CPUINFO_INT_REGISTER + LH5801_U: U = info->i; break;
|
||||
case CPUINFO_INT_REGISTER + LH5801_X: X = info->i; break;
|
||||
case CPUINFO_INT_REGISTER + LH5801_Y: Y = info->i; break;
|
||||
case CPUINFO_INT_REGISTER + LH5801_T: cpustate->t = info->i; break;
|
||||
case CPUINFO_INT_REGISTER + LH5801_TM: cpustate->tm = info->i; break;
|
||||
case CPUINFO_INT_REGISTER + LH5801_BF: cpustate->bf = info->i; break;
|
||||
case CPUINFO_INT_REGISTER + LH5801_PV: cpustate->pv = info->i; break;
|
||||
case CPUINFO_INT_REGISTER + LH5801_PU: cpustate->pu = info->i; break;
|
||||
case CPUINFO_INT_REGISTER + LH5801_DP: cpustate->dp = info->i; break;
|
||||
}
|
||||
extern CPU_DISASSEMBLE( lh5801 );
|
||||
return CPU_DISASSEMBLE_NAME(lh5801)(this, buffer, pc, oprom, opram, options);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
* Generic get_info
|
||||
**************************************************************************/
|
||||
|
||||
CPU_GET_INFO( lh5801 )
|
||||
{
|
||||
lh5801_state *cpustate = (device != NULL && device->token() != NULL) ? get_safe_token(device) : NULL;
|
||||
|
||||
switch (state)
|
||||
{
|
||||
/* --- the following bits of info are returned as 64-bit signed integers --- */
|
||||
case CPUINFO_INT_CONTEXT_SIZE: info->i = sizeof(lh5801_state); break;
|
||||
case CPUINFO_INT_INPUT_LINES: info->i = 2; break;
|
||||
case CPUINFO_INT_DEFAULT_IRQ_VECTOR: info->i = 0; break;
|
||||
case CPUINFO_INT_ENDIANNESS: info->i = ENDIANNESS_LITTLE; break;
|
||||
case CPUINFO_INT_CLOCK_MULTIPLIER: info->i = 1; break;
|
||||
case CPUINFO_INT_CLOCK_DIVIDER: info->i = 1; break;
|
||||
case CPUINFO_INT_MIN_INSTRUCTION_BYTES: info->i = 1; break;
|
||||
case CPUINFO_INT_MAX_INSTRUCTION_BYTES: info->i = 5; break;
|
||||
case CPUINFO_INT_MIN_CYCLES: info->i = 2; break;
|
||||
case CPUINFO_INT_MAX_CYCLES: info->i = 19; break;
|
||||
|
||||
case CPUINFO_INT_DATABUS_WIDTH + AS_PROGRAM: info->i = 8; break;
|
||||
case CPUINFO_INT_ADDRBUS_WIDTH + AS_PROGRAM: info->i = 16; break;
|
||||
case CPUINFO_INT_ADDRBUS_SHIFT + AS_PROGRAM: info->i = 0; break;
|
||||
case CPUINFO_INT_DATABUS_WIDTH + AS_DATA: info->i = 0; break;
|
||||
case CPUINFO_INT_ADDRBUS_WIDTH + AS_DATA: info->i = 0; break;
|
||||
case CPUINFO_INT_ADDRBUS_SHIFT + AS_DATA: info->i = 0; break;
|
||||
case CPUINFO_INT_DATABUS_WIDTH + AS_IO: info->i = 8; break;
|
||||
case CPUINFO_INT_ADDRBUS_WIDTH + AS_IO: info->i = 16; break;
|
||||
case CPUINFO_INT_ADDRBUS_SHIFT + AS_IO: info->i = 0; break;
|
||||
|
||||
case CPUINFO_INT_INPUT_STATE: info->i = cpustate->irq_state; break;
|
||||
|
||||
case CPUINFO_INT_PREVIOUSPC: info->i = cpustate->oldpc; break;
|
||||
|
||||
case CPUINFO_INT_PC:
|
||||
case CPUINFO_INT_REGISTER + LH5801_P: info->i = P; break;
|
||||
case CPUINFO_INT_SP:
|
||||
case CPUINFO_INT_REGISTER + LH5801_S: info->i = S; break;
|
||||
case CPUINFO_INT_REGISTER + LH5801_U: info->i = U; break;
|
||||
case CPUINFO_INT_REGISTER + LH5801_X: info->i = X; break;
|
||||
case CPUINFO_INT_REGISTER + LH5801_Y: info->i = Y; break;
|
||||
case CPUINFO_INT_REGISTER + LH5801_T: info->i = cpustate->t; break;
|
||||
case CPUINFO_INT_REGISTER + LH5801_TM: info->i = cpustate->tm; break;
|
||||
case CPUINFO_INT_REGISTER + LH5801_IN: info->i = cpustate->config->in(device); break;
|
||||
case CPUINFO_INT_REGISTER + LH5801_BF: info->i = cpustate->bf; break;
|
||||
case CPUINFO_INT_REGISTER + LH5801_PV: info->i = cpustate->pv; break;
|
||||
case CPUINFO_INT_REGISTER + LH5801_PU: info->i = cpustate->pu; break;
|
||||
case CPUINFO_INT_REGISTER + LH5801_DP: info->i = cpustate->dp; break;
|
||||
|
||||
/* --- the following bits of info are returned as pointers to data or functions --- */
|
||||
case CPUINFO_FCT_SET_INFO: info->setinfo = CPU_SET_INFO_NAME(lh5801); break;
|
||||
case CPUINFO_FCT_INIT: info->init = CPU_INIT_NAME(lh5801); break;
|
||||
case CPUINFO_FCT_RESET: info->reset = CPU_RESET_NAME(lh5801); break;
|
||||
case CPUINFO_FCT_EXIT: info->exit = NULL; break;
|
||||
case CPUINFO_FCT_EXECUTE: info->execute = CPU_EXECUTE_NAME(lh5801); break;
|
||||
case CPUINFO_FCT_BURN: info->burn = NULL; break;
|
||||
case CPUINFO_FCT_DISASSEMBLE: info->disassemble = CPU_DISASSEMBLE_NAME(lh5801); break;
|
||||
case CPUINFO_PTR_INSTRUCTION_COUNTER: info->icount = &cpustate->icount; break;
|
||||
|
||||
/* --- the following bits of info are returned as NULL-terminated strings --- */
|
||||
case CPUINFO_STR_NAME: strcpy(info->s, "LH5801"); break;
|
||||
case CPUINFO_STR_FAMILY: strcpy(info->s, "LH5801"); break;
|
||||
case CPUINFO_STR_VERSION: strcpy(info->s, "1.0alpha"); break;
|
||||
case CPUINFO_STR_SOURCE_FILE: strcpy(info->s, __FILE__); break;
|
||||
case CPUINFO_STR_CREDITS: strcpy(info->s, "Copyright Peter Trauner, all rights reserved."); break;
|
||||
|
||||
case CPUINFO_STR_FLAGS:
|
||||
sprintf(info->s, "%s%s%s%s%s%s%s%s",
|
||||
cpustate->t&0x80?"1":"0",
|
||||
cpustate->t&0x40?"1":"0",
|
||||
cpustate->t&0x20?"1":"0",
|
||||
cpustate->t&0x10?"H":".",
|
||||
cpustate->t&8?"V":".",
|
||||
cpustate->t&4?"Z":".",
|
||||
cpustate->t&2?"I":".",
|
||||
cpustate->t&1?"C":".");
|
||||
break;
|
||||
|
||||
case CPUINFO_STR_REGISTER + LH5801_P: sprintf(info->s, "P:%04X", cpustate->p.w.l); break;
|
||||
case CPUINFO_STR_REGISTER + LH5801_S: sprintf(info->s, "S:%04X", cpustate->s.w.l); break;
|
||||
case CPUINFO_STR_REGISTER + LH5801_U: sprintf(info->s, "U:%04X", cpustate->u.w.l); break;
|
||||
case CPUINFO_STR_REGISTER + LH5801_X: sprintf(info->s, "X:%04X", cpustate->x.w.l); break;
|
||||
case CPUINFO_STR_REGISTER + LH5801_Y: sprintf(info->s, "Y:%04X", cpustate->y.w.l); break;
|
||||
case CPUINFO_STR_REGISTER + LH5801_T: sprintf(info->s, "T:%02X", cpustate->t); break;
|
||||
case CPUINFO_STR_REGISTER + LH5801_A: sprintf(info->s, "A:%02X", cpustate->a); break;
|
||||
case CPUINFO_STR_REGISTER + LH5801_TM: sprintf(info->s, "TM:%03X", cpustate->tm); break;
|
||||
case CPUINFO_STR_REGISTER + LH5801_IN: sprintf(info->s, "IN:%02X", cpustate->config->in(device)); break;
|
||||
case CPUINFO_STR_REGISTER + LH5801_PV: sprintf(info->s, "PV:%04X", cpustate->pv); break;
|
||||
case CPUINFO_STR_REGISTER + LH5801_PU: sprintf(info->s, "PU:%04X", cpustate->pu); break;
|
||||
case CPUINFO_STR_REGISTER + LH5801_BF: sprintf(info->s, "BF:%04X", cpustate->bf); break;
|
||||
case CPUINFO_STR_REGISTER + LH5801_DP: sprintf(info->s, "DP:%04X", cpustate->dp); break;
|
||||
}
|
||||
}
|
||||
|
||||
DEFINE_LEGACY_CPU_DEVICE(LH5801, lh5801);
|
||||
|
@ -64,21 +64,136 @@ pc 8bit
|
||||
*/
|
||||
|
||||
|
||||
|
||||
typedef UINT8 (*lh5801_in_func)(device_t *device);
|
||||
|
||||
struct lh5801_cpu_core
|
||||
{
|
||||
lh5801_in_func in;
|
||||
};
|
||||
|
||||
// input lines
|
||||
enum
|
||||
{
|
||||
LH5801_LINE_MI, //maskable interrupt
|
||||
};
|
||||
|
||||
DECLARE_LEGACY_CPU_DEVICE(LH5801, lh5801);
|
||||
extern CPU_DISASSEMBLE( lh5801 );
|
||||
|
||||
#define MCFG_LH5801_IN(_devcb) \
|
||||
lh5801_cpu_device::set_in_func(*device, DEVCB2_##_devcb);
|
||||
|
||||
|
||||
class lh5801_cpu_device : public cpu_device
|
||||
{
|
||||
public:
|
||||
// construction/destruction
|
||||
lh5801_cpu_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
|
||||
|
||||
// static configuration helpers
|
||||
template<class _Object> static devcb2_base &set_in_func(device_t &device, _Object object) { return downcast<lh5801_cpu_device &>(device).m_in_func.set_callback(object); }
|
||||
|
||||
protected:
|
||||
// device-level overrides
|
||||
virtual void device_start();
|
||||
virtual void device_reset();
|
||||
|
||||
// device_execute_interface overrides
|
||||
virtual UINT32 execute_min_cycles() const { return 2; }
|
||||
virtual UINT32 execute_max_cycles() const { return 19; }
|
||||
virtual UINT32 execute_input_lines() const { return 2; }
|
||||
virtual UINT32 execute_default_irq_vector() const { return 0; }
|
||||
virtual void execute_run();
|
||||
virtual void execute_set_input(int inputnum, int state);
|
||||
|
||||
// device_memory_interface overrides
|
||||
virtual const address_space_config *memory_space_config(address_spacenum spacenum = AS_0) const { return (spacenum == AS_PROGRAM) ? &m_program_config : ( (spacenum == AS_IO) ? &m_io_config : 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 5; }
|
||||
virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram, UINT32 options);
|
||||
|
||||
private:
|
||||
address_space_config m_program_config;
|
||||
address_space_config m_io_config;
|
||||
|
||||
devcb2_read8 m_in_func;
|
||||
|
||||
address_space *m_program; //ME0
|
||||
address_space *m_io; //ME1
|
||||
direct_read_data *m_direct;
|
||||
|
||||
PAIR m_s;
|
||||
PAIR m_p;
|
||||
PAIR m_u;
|
||||
PAIR m_x;
|
||||
PAIR m_y;
|
||||
int m_tm; //9 bit
|
||||
|
||||
UINT8 m_t, m_a;
|
||||
|
||||
int m_bf;
|
||||
int m_dp;
|
||||
int m_pu;
|
||||
int m_pv;
|
||||
|
||||
UINT16 m_oldpc;
|
||||
|
||||
int m_irq_state;
|
||||
|
||||
UINT8 m_ir_flipflop[3]; //interrupt request flipflop: IR0, IR1, IR2
|
||||
int m_lines_status[2]; //MI and NMI lines status
|
||||
|
||||
int m_idle;
|
||||
int m_icount;
|
||||
|
||||
void check_irq();
|
||||
void lh5801_instruction_fd();
|
||||
void lh5801_instruction();
|
||||
UINT8 lh5801_add_generic(int left, int right, int carry);
|
||||
UINT16 lh5801_readop_word();
|
||||
void lh5801_adc(UINT8 data);
|
||||
void lh5801_add_mem(address_space &space, int addr, UINT8 data);
|
||||
void lh5801_adr(PAIR *reg);
|
||||
void lh5801_sbc(UINT8 data);
|
||||
void lh5801_cpa(UINT8 a, UINT8 b);
|
||||
UINT8 lh5801_decimaladd_generic(int left, int right, int carry);
|
||||
void lh5801_dca(UINT8 data);
|
||||
void lh5801_dcs(UINT8 data);
|
||||
void lh5801_and(UINT8 data);
|
||||
void lh5801_and_mem(address_space &space, int addr, UINT8 data);
|
||||
void lh5801_bit(UINT8 a, UINT8 b);
|
||||
void lh5801_eor(UINT8 data);
|
||||
void lh5801_ora(UINT8 data);
|
||||
void lh5801_ora_mem(address_space &space, int addr, UINT8 data);
|
||||
void lh5801_lda(UINT8 data);
|
||||
void lh5801_lde(PAIR *reg);
|
||||
void lh5801_sde(PAIR *reg);
|
||||
void lh5801_lin(PAIR *reg);
|
||||
void lh5801_sin(PAIR *reg);
|
||||
void lh5801_dec(UINT8 *adr);
|
||||
void lh5801_inc(UINT8 *adr);
|
||||
void lh5801_pop();
|
||||
void lh5801_pop_word(PAIR *reg);
|
||||
void lh5801_rtn();
|
||||
void lh5801_rti();
|
||||
void lh5801_push(UINT8 data);
|
||||
void lh5801_push_word(UINT16 data);
|
||||
void lh5801_jmp(UINT16 adr);
|
||||
void lh5801_branch_plus(int doit);
|
||||
void lh5801_branch_minus(int doit);
|
||||
void lh5801_lop();
|
||||
void lh5801_sjp();
|
||||
void lh5801_vector(int doit, int nr);
|
||||
void lh5801_aex();
|
||||
void lh5801_drl(address_space &space, int adr);
|
||||
void lh5801_drr(address_space &space, int adr);
|
||||
void lh5801_rol();
|
||||
void lh5801_ror();
|
||||
void lh5801_shl();
|
||||
void lh5801_shr();
|
||||
void lh5801_am(int value);
|
||||
void lh5801_ita();
|
||||
|
||||
};
|
||||
|
||||
|
||||
extern const device_type LH5801;
|
||||
|
||||
|
||||
#endif /* __LH5801_H__ */
|
||||
|
@ -40,7 +40,7 @@ public:
|
||||
DECLARE_READ8_MEMBER( port_b_r );
|
||||
DECLARE_WRITE8_MEMBER( port_c_w );
|
||||
|
||||
static UINT8 pc1500_kb_r(device_t *device);
|
||||
DECLARE_READ8_MEMBER( pc1500_kb_r );
|
||||
virtual void palette_init();
|
||||
};
|
||||
|
||||
@ -60,29 +60,28 @@ static ADDRESS_MAP_START( pc1500_mem_io , AS_IO, 8, pc1500_state)
|
||||
AM_RANGE( 0xf000, 0xf00f) AM_DEVREADWRITE("lh5810", lh5810_device, data_r, data_w)
|
||||
ADDRESS_MAP_END
|
||||
|
||||
UINT8 pc1500_state::pc1500_kb_r(device_t *device)
|
||||
READ8_MEMBER( pc1500_state::pc1500_kb_r )
|
||||
{
|
||||
pc1500_state *state = device->machine().driver_data<pc1500_state>();
|
||||
UINT8 data = 0xff;
|
||||
|
||||
if (!device->started()) return 0;
|
||||
if (!started()) return 0;
|
||||
|
||||
if (!(state->m_kb_matrix & 0x01))
|
||||
data &= state->ioport("KEY0")->read();
|
||||
if (!(state->m_kb_matrix & 0x02))
|
||||
data &= state->ioport("KEY1")->read();
|
||||
if (!(state->m_kb_matrix & 0x04))
|
||||
data &= state->ioport("KEY2")->read();
|
||||
if (!(state->m_kb_matrix & 0x08))
|
||||
data &= state->ioport("KEY3")->read();
|
||||
if (!(state->m_kb_matrix & 0x10))
|
||||
data &= state->ioport("KEY4")->read();
|
||||
if (!(state->m_kb_matrix & 0x20))
|
||||
data &= state->ioport("KEY5")->read();
|
||||
if (!(state->m_kb_matrix & 0x40))
|
||||
data &= state->ioport("KEY6")->read();
|
||||
if (!(state->m_kb_matrix & 0x80))
|
||||
data &= state->ioport("KEY7")->read();
|
||||
if (!(m_kb_matrix & 0x01))
|
||||
data &= ioport("KEY0")->read();
|
||||
if (!(m_kb_matrix & 0x02))
|
||||
data &= ioport("KEY1")->read();
|
||||
if (!(m_kb_matrix & 0x04))
|
||||
data &= ioport("KEY2")->read();
|
||||
if (!(m_kb_matrix & 0x08))
|
||||
data &= ioport("KEY3")->read();
|
||||
if (!(m_kb_matrix & 0x10))
|
||||
data &= ioport("KEY4")->read();
|
||||
if (!(m_kb_matrix & 0x20))
|
||||
data &= ioport("KEY5")->read();
|
||||
if (!(m_kb_matrix & 0x40))
|
||||
data &= ioport("KEY6")->read();
|
||||
if (!(m_kb_matrix & 0x80))
|
||||
data &= ioport("KEY7")->read();
|
||||
|
||||
return data;
|
||||
}
|
||||
@ -263,11 +262,6 @@ void pc1500_state::palette_init()
|
||||
palette_set_color(machine(), 1, MAKE_RGB(92, 83, 88));
|
||||
}
|
||||
|
||||
static const lh5801_cpu_core lh5801_pc1500_config =
|
||||
{
|
||||
pc1500_state::pc1500_kb_r
|
||||
};
|
||||
|
||||
static const lh5810_interface lh5810_pc1500_config =
|
||||
{
|
||||
DEVCB_DRIVER_MEMBER(pc1500_state, port_a_r), //port A read
|
||||
@ -282,7 +276,7 @@ static MACHINE_CONFIG_START( pc1500, pc1500_state )
|
||||
MCFG_CPU_ADD("maincpu", LH5801, 1300000) //1.3 MHz
|
||||
MCFG_CPU_PROGRAM_MAP( pc1500_mem )
|
||||
MCFG_CPU_IO_MAP( pc1500_mem_io )
|
||||
MCFG_CPU_CONFIG( lh5801_pc1500_config )
|
||||
MCFG_LH5801_IN(READ8(pc1500_state,pc1500_kb_r))
|
||||
|
||||
MCFG_SCREEN_ADD("screen", LCD)
|
||||
MCFG_SCREEN_REFRESH_RATE(50)
|
||||
|
Loading…
Reference in New Issue
Block a user