MT06888 fix (nw)

This commit is contained in:
AJR 2018-02-26 08:21:20 -05:00
parent fd38b3a520
commit 7a313db6ce
2 changed files with 29 additions and 5 deletions

View File

@ -171,12 +171,15 @@ INPUT_CHANGED_MEMBER(segag80v_state::service_switch)
void segag80v_state::machine_start()
{
m_scrambled_write_pc = 0xffff;
/* register for save states */
save_item(NAME(m_mult_data));
save_item(NAME(m_mult_result));
save_item(NAME(m_spinner_select));
save_item(NAME(m_spinner_sign));
save_item(NAME(m_spinner_count));
save_item(NAME(m_scrambled_write_pc));
}
@ -187,15 +190,28 @@ void segag80v_state::machine_start()
*
*************************************/
READ8_MEMBER(segag80v_state::g80v_opcode_r)
{
// opcodes themselves are not scrambled
uint8_t op = m_maincpu->space(AS_PROGRAM).read_byte(offset);
// writes via opcode $32 (LD $(XXYY),A) get scrambled
if (!machine().side_effects_disabled())
m_scrambled_write_pc = (op == 0x32) ? offset : 0xffff;
return op;
}
offs_t segag80v_state::decrypt_offset(address_space &space, offs_t offset)
{
/* ignore anything but accesses via opcode $32 (LD $(XXYY),A) */
offs_t pc = space.device().safe_pcbase();
if ((uint16_t)pc == 0xffff || space.read_byte(pc) != 0x32)
if (m_scrambled_write_pc == 0xffff)
return offset;
/* fetch the low byte of the address and munge it */
return (offset & 0xff00) | (*m_decrypt)(pc, space.read_byte(pc + 1));
offs_t pc = m_scrambled_write_pc;
m_scrambled_write_pc = 0xffff;
/* munge the low byte of the address */
return (offset & 0xff00) | (*m_decrypt)(pc, offset & 0xff);
}
WRITE8_MEMBER(segag80v_state::mainram_w)
@ -380,6 +396,10 @@ ADDRESS_MAP_START(segag80v_state::main_map)
AM_RANGE(0xe000, 0xefff) AM_RAM_WRITE(vectorram_w) AM_SHARE("vectorram")
ADDRESS_MAP_END
ADDRESS_MAP_START(segag80v_state::opcodes_map)
AM_RANGE(0x0000, 0xffff) AM_READ(g80v_opcode_r)
ADDRESS_MAP_END
/* complete memory map derived from schematics */
ADDRESS_MAP_START(segag80v_state::main_portmap)
@ -875,6 +895,7 @@ MACHINE_CONFIG_START(segag80v_state::g80v_base)
/* basic machine hardware */
MCFG_CPU_ADD("maincpu", Z80, VIDEO_CLOCK/4)
MCFG_CPU_PROGRAM_MAP(main_map)
MCFG_CPU_OPCODES_MAP(opcodes_map)
MCFG_CPU_IO_MAP(main_portmap)
MCFG_CPU_VBLANK_INT_DRIVER("screen", segag80v_state, irq0_line_hold)

View File

@ -41,9 +41,11 @@ public:
uint8_t m_spinner_select;
uint8_t m_spinner_sign;
uint8_t m_spinner_count;
offs_t m_scrambled_write_pc;
segag80_decrypt_func m_decrypt;
int m_min_x;
int m_min_y;
DECLARE_READ8_MEMBER(g80v_opcode_r);
DECLARE_WRITE8_MEMBER(mainram_w);
DECLARE_WRITE8_MEMBER(vectorram_w);
DECLARE_READ8_MEMBER(mangled_ports_r);
@ -83,5 +85,6 @@ public:
void zektor(machine_config &config);
void spacfury(machine_config &config);
void main_map(address_map &map);
void opcodes_map(address_map &map);
void main_portmap(address_map &map);
};