diff --git a/src/emu/cpu/m6809/6809dasm.c b/src/emu/cpu/m6809/6809dasm.c index 32d26b67eff..c023195af43 100644 --- a/src/emu/cpu/m6809/6809dasm.c +++ b/src/emu/cpu/m6809/6809dasm.c @@ -374,6 +374,8 @@ CPU_DISASSEMBLE( m6809 ) do { opcode = oprom[p++]; +// FIXME if (m68_state->config->encrypt_only_first_byte) we should to this +// opcode = page == 0 ? oprom[p++] : opram[p++]; for (i = 0; i < m6809_numops[page]; i++) if (m6809_pgpointers[page][i].opcode == opcode) break; diff --git a/src/emu/cpu/m6809/6809ops.c b/src/emu/cpu/m6809/6809ops.c index 79612bb639c..0d34e458e4a 100644 --- a/src/emu/cpu/m6809/6809ops.c +++ b/src/emu/cpu/m6809/6809ops.c @@ -12,7 +12,7 @@ HNZVC */ -#define OP_HANDLER(_name) INLINE void _name (m68_state_t *m68_state) +#define OP_HANDLER(_name) INLINE void _name (m68_state_t *m68_state) #ifdef NEW static void illegal ) @@ -2913,7 +2913,7 @@ OP_HANDLER( sts_ex ) /* $10xx opcodes */ OP_HANDLER( pref10 ) { - UINT8 ireg2 = ROP(PCD); + UINT8 ireg2 = m68_state->config->encrypt_only_first_byte ? ROP_ARG(PCD) : ROP(PCD); PC++; switch( ireg2 ) { @@ -2974,7 +2974,7 @@ OP_HANDLER( pref10 ) /* $11xx opcodes */ OP_HANDLER( pref11 ) { - UINT8 ireg2 = ROP(PCD); + UINT8 ireg2 = m68_state->config->encrypt_only_first_byte ? ROP_ARG(PCD) : ROP(PCD); PC++; switch( ireg2 ) { diff --git a/src/emu/cpu/m6809/m6809.c b/src/emu/cpu/m6809/m6809.c index 51afa98f417..bb54d625a29 100644 --- a/src/emu/cpu/m6809/m6809.c +++ b/src/emu/cpu/m6809/m6809.c @@ -98,6 +98,7 @@ struct _m68_state_t int extra_cycles; /* cycles used up by interrupts */ cpu_irq_callback irq_callback; const device_config *device; + const m6809_config *config; UINT8 int_state; /* SYNC and CWAI flags */ UINT8 nmi_state; }; @@ -279,57 +280,57 @@ static void UpdateState(m68_state_t *m68_state) static void CHECK_IRQ_LINES(m68_state_t *m68_state) { - if( m68_state->irq_state[M6809_IRQ_LINE] != CLEAR_LINE || - m68_state->irq_state[M6809_FIRQ_LINE] != CLEAR_LINE ) - m68_state->int_state &= ~M6809_SYNC; /* clear SYNC flag */ - if( m68_state->irq_state[M6809_FIRQ_LINE]!=CLEAR_LINE && !(CC & CC_IF) ) - { - /* fast IRQ */ - /* HJB 990225: state already saved by CWAI? */ - if( m68_state->int_state & M6809_CWAI ) - { - m68_state->int_state &= ~M6809_CWAI; /* clear CWAI */ - m68_state->extra_cycles += 7; /* subtract +7 cycles */ - } - else - { - CC &= ~CC_E; /* save 'short' state */ - PUSHWORD(pPC); - PUSHBYTE(CC); - m68_state->extra_cycles += 10; /* subtract +10 cycles */ - } - CC |= CC_IF | CC_II; /* inhibit FIRQ and IRQ */ - PCD=RM16(0xfff6); - CHANGE_PC; - (void)(*m68_state->irq_callback)(m68_state->device, M6809_FIRQ_LINE); - } - else - if( m68_state->irq_state[M6809_IRQ_LINE]!=CLEAR_LINE && !(CC & CC_II) ) - { - /* standard IRQ */ - /* HJB 990225: state already saved by CWAI? */ - if( m68_state->int_state & M6809_CWAI ) - { - m68_state->int_state &= ~M6809_CWAI; /* clear CWAI flag */ - m68_state->extra_cycles += 7; /* subtract +7 cycles */ - } - else - { - CC |= CC_E; /* save entire state */ - PUSHWORD(pPC); - PUSHWORD(pU); - PUSHWORD(pY); - PUSHWORD(pX); - PUSHBYTE(DP); - PUSHBYTE(B); - PUSHBYTE(A); - PUSHBYTE(CC); - m68_state->extra_cycles += 19; /* subtract +19 cycles */ - } - CC |= CC_II; /* inhibit IRQ */ - PCD=RM16(0xfff8); - CHANGE_PC; - (void)(*m68_state->irq_callback)(m68_state->device, M6809_IRQ_LINE); + if( m68_state->irq_state[M6809_IRQ_LINE] != CLEAR_LINE || + m68_state->irq_state[M6809_FIRQ_LINE] != CLEAR_LINE ) + m68_state->int_state &= ~M6809_SYNC; /* clear SYNC flag */ + if( m68_state->irq_state[M6809_FIRQ_LINE]!=CLEAR_LINE && !(CC & CC_IF) ) + { + /* fast IRQ */ + /* HJB 990225: state already saved by CWAI? */ + if( m68_state->int_state & M6809_CWAI ) + { + m68_state->int_state &= ~M6809_CWAI; /* clear CWAI */ + m68_state->extra_cycles += 7; /* subtract +7 cycles */ + } + else + { + CC &= ~CC_E; /* save 'short' state */ + PUSHWORD(pPC); + PUSHBYTE(CC); + m68_state->extra_cycles += 10; /* subtract +10 cycles */ + } + CC |= CC_IF | CC_II; /* inhibit FIRQ and IRQ */ + PCD=RM16(0xfff6); + CHANGE_PC; + (void)(*m68_state->irq_callback)(m68_state->device, M6809_FIRQ_LINE); + } + else + if( m68_state->irq_state[M6809_IRQ_LINE]!=CLEAR_LINE && !(CC & CC_II) ) + { + /* standard IRQ */ + /* HJB 990225: state already saved by CWAI? */ + if( m68_state->int_state & M6809_CWAI ) + { + m68_state->int_state &= ~M6809_CWAI; /* clear CWAI flag */ + m68_state->extra_cycles += 7; /* subtract +7 cycles */ + } + else + { + CC |= CC_E; /* save entire state */ + PUSHWORD(pPC); + PUSHWORD(pU); + PUSHWORD(pY); + PUSHWORD(pX); + PUSHBYTE(DP); + PUSHBYTE(B); + PUSHBYTE(A); + PUSHBYTE(CC); + m68_state->extra_cycles += 19; /* subtract +19 cycles */ + } + CC |= CC_II; /* inhibit IRQ */ + PCD=RM16(0xfff8); + CHANGE_PC; + (void)(*m68_state->irq_callback)(m68_state->device, M6809_IRQ_LINE); } } @@ -362,8 +363,16 @@ static CPU_SET_CONTEXT( m6809 ) /****************************************************************************/ static CPU_INIT( m6809 ) { + /* default configuration */ + static const m6809_config default_config = + { + 0 + }; + + const m6809_config *configdata = device->static_config ? device->static_config : &default_config; m68_state_t *m68_state = device->token; - + + m68_state->config = configdata; m68_state->irq_callback = irqcallback; m68_state->device = device; @@ -388,7 +397,7 @@ static CPU_INIT( m6809 ) static CPU_RESET( m6809 ) { m68_state_t *m68_state = device->token; - + m68_state->int_state = 0; m68_state->nmi_state = CLEAR_LINE; m68_state->irq_state[0] = CLEAR_LINE; @@ -467,7 +476,7 @@ static void set_irq_line(m68_state_t *m68_state, int irqline, int state) static CPU_EXECUTE( m6809 ) /* NS 970908 */ { m68_state_t *m68_state = device->token; - + m68_icount = cycles - m68_state->extra_cycles; m68_state->extra_cycles = 0; @@ -1050,7 +1059,7 @@ INLINE void fetch_effective_address( m68_state_t *m68_state ) static CPU_SET_INFO( m6809 ) { m68_state_t *m68_state = device->token; - + switch (state) { /* --- the following bits of info are set as 64-bit signed integers --- */ @@ -1081,7 +1090,7 @@ static CPU_SET_INFO( m6809 ) CPU_GET_INFO( m6809 ) { m68_state_t *m68_state = (device != NULL) ? device->token : NULL; - + switch (state) { /* --- the following bits of info are returned as 64-bit signed integers --- */ diff --git a/src/emu/cpu/m6809/m6809.h b/src/emu/cpu/m6809/m6809.h index f5b72fb2e5f..ab2fa12e37b 100644 --- a/src/emu/cpu/m6809/m6809.h +++ b/src/emu/cpu/m6809/m6809.h @@ -53,4 +53,11 @@ CPU_GET_INFO( m6809e ); CPU_DISASSEMBLE( m6809 ); + +typedef struct _m6809_config m6809_config; +struct _m6809_config +{ + UINT8 encrypt_only_first_byte; /* encrypt only the first byte in 10 xx and 11 xx opcodes */ +}; + #endif /* __M6809_H__ */