From ea27878f48922ffa96878c2880dcae82093415e0 Mon Sep 17 00:00:00 2001 From: smf- Date: Fri, 6 Sep 2013 02:05:53 +0000 Subject: [PATCH] Added 8/16 bit data bus configuration to TLCS900H. Default is 16bit, neogeo pocket is 8 bit [smf] --- src/emu/cpu/tlcs900/tlcs900.c | 70 ++++++++++++----- src/emu/cpu/tlcs900/tlcs900.h | 19 ++++- src/mame/drivers/taitopjc.c | 6 +- src/mame/drivers/taitotz.c | 136 +++++++--------------------------- src/mess/drivers/ngp.c | 1 + 5 files changed, 101 insertions(+), 131 deletions(-) diff --git a/src/emu/cpu/tlcs900/tlcs900.c b/src/emu/cpu/tlcs900/tlcs900.c index cd3ad39159e..db55b567bc9 100644 --- a/src/emu/cpu/tlcs900/tlcs900.c +++ b/src/emu/cpu/tlcs900/tlcs900.c @@ -22,24 +22,32 @@ const device_type TMP95C061 = &device_creator; const device_type TMP95C063 = &device_creator; -static ADDRESS_MAP_START( tmp95c061_mem, AS_PROGRAM, 8, tmp95c061_device ) +static ADDRESS_MAP_START( tmp95c061_mem8, AS_PROGRAM, 8, tmp95c061_device ) AM_RANGE( 0x000000, 0x00007f ) AM_READWRITE( internal_r, internal_w ) ADDRESS_MAP_END - -static ADDRESS_MAP_START(tmp95c063_mem, AS_PROGRAM, 8, tmp95c063_device ) - AM_RANGE( 0x000000, 0x00009f ) AM_READWRITE( internal_r, internal_w ) +static ADDRESS_MAP_START( tmp95c061_mem16, AS_PROGRAM, 16, tmp95c061_device ) + AM_RANGE( 0x000000, 0x00007f ) AM_READWRITE8( internal_r, internal_w, 0xffff ) ADDRESS_MAP_END -tlcs900h_device::tlcs900h_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, address_map_constructor internal_map) - : cpu_device(mconfig, type, name, tag, owner, clock, shortname, __FILE__) - , m_program_config("program", ENDIANNESS_LITTLE, 8, 24, 0, internal_map) +static ADDRESS_MAP_START(tmp95c063_mem8, AS_PROGRAM, 8, tmp95c063_device ) + AM_RANGE( 0x000000, 0x00009f ) AM_READWRITE( internal_r, internal_w ) +ADDRESS_MAP_END + +static ADDRESS_MAP_START(tmp95c063_mem16, AS_PROGRAM, 16, tmp95c063_device ) + AM_RANGE( 0x000000, 0x00009f ) AM_READWRITE8( internal_r, internal_w, 0xffff ) +ADDRESS_MAP_END + + +tlcs900h_device::tlcs900h_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname) + : cpu_device(mconfig, type, name, tag, owner, clock, shortname, __FILE__), + m_am8_16(0) { } tmp95c061_device::tmp95c061_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) - : tlcs900h_device(mconfig, TMP95C061, "TMP95C061", tag, owner, clock, "tmp95c061", ADDRESS_MAP_NAME(tmp95c061_mem) ), + : tlcs900h_device(mconfig, TMP95C061, "TMP95C061", tag, owner, clock, "tmp95c061" ), m_port1_read(*this), m_port1_write(*this), m_port2_write(*this), @@ -59,10 +67,26 @@ tmp95c061_device::tmp95c061_device(const machine_config &mconfig, const char *ta { } +//------------------------------------------------- +// device_config_complete - perform any +// operations now that the configuration is +// complete +//------------------------------------------------- +void tmp95c061_device::device_config_complete() +{ + if (m_am8_16 == 0) + { + m_program_config = address_space_config("program", ENDIANNESS_LITTLE, 16, 24, 0, ADDRESS_MAP_NAME(tmp95c061_mem16)); + } + else + { + m_program_config = address_space_config("program", ENDIANNESS_LITTLE, 8, 24, 0, ADDRESS_MAP_NAME(tmp95c061_mem8)); + } +} tmp95c063_device::tmp95c063_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) - : tlcs900h_device(mconfig, TMP95C063, "TMP95C063", tag, owner, clock, "tmp95c063", ADDRESS_MAP_NAME(tmp95c063_mem) ), + : tlcs900h_device(mconfig, TMP95C063, "TMP95C063", tag, owner, clock, "tmp95c063"), m_port1_read(*this), m_port1_write(*this), m_port2_write(*this), @@ -88,6 +112,24 @@ tmp95c063_device::tmp95c063_device(const machine_config &mconfig, const char *ta { } +//------------------------------------------------- +// device_config_complete - perform any +// operations now that the configuration is +// complete +//------------------------------------------------- + +void tmp95c063_device::device_config_complete() +{ + if (m_am8_16 == 0) + { + m_program_config = address_space_config("program", ENDIANNESS_LITTLE, 16, 24, 0, ADDRESS_MAP_NAME(tmp95c063_mem16)); + } + else + { + m_program_config = address_space_config("program", ENDIANNESS_LITTLE, 8, 24, 0, ADDRESS_MAP_NAME(tmp95c063_mem8)); + } +} + offs_t tlcs900h_device::disasm_disassemble(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram, UINT32 options) { @@ -215,14 +257,6 @@ offs_t tlcs900h_device::disasm_disassemble(char *buffer, offs_t pc, const UINT8 #define FLAG_SF 0x80 -#define RDMEM(addr) m_program->read_byte( addr ) -#define WRMEM(addr,data) m_program->write_byte( addr, data ) -#define RDMEMW(addr) ( RDMEM(addr) | ( RDMEM(addr+1) << 8 ) ) -#define RDMEML(addr) ( RDMEMW(addr) | ( RDMEMW(addr+2) << 16 ) ) -#define WRMEMW(addr,data) { UINT16 dw = data; WRMEM(addr,dw & 0xff); WRMEM(addr+1,(dw >> 8 )); } -#define WRMEML(addr,data) { UINT32 dl = data; WRMEMW(addr,dl); WRMEMW(addr+2,(dl >> 16)); } - - inline UINT8 tlcs900h_device::RDOP() { UINT8 data; @@ -1101,7 +1135,7 @@ READ8_MEMBER( tmp95c061_device::internal_r ) case TMP95C061_P8: m_reg[offset] = m_port8_read(0); break; case TMP95C061_P9: m_reg[offset] = m_port9_read(0); break; case TMP95C061_PA: m_reg[offset] = m_porta_read(0); break; - case TMP95C061_PB: m_reg[offset] = m_porta_read(0); break; + case TMP95C061_PB: m_reg[offset] = m_portb_read(0); break; } return m_reg[ offset ]; } diff --git a/src/emu/cpu/tlcs900/tlcs900.h b/src/emu/cpu/tlcs900/tlcs900.h index 52f3365e043..9170301f553 100644 --- a/src/emu/cpu/tlcs900/tlcs900.h +++ b/src/emu/cpu/tlcs900/tlcs900.h @@ -41,12 +41,17 @@ extern const device_type TMP95C061; extern const device_type TMP95C063; +#define MCFG_TLCS900H_AM8_16( am8_16 ) tlcs900h_device::set_am8_16( *device, am8_16 ); + class tlcs900h_device : public cpu_device { public: // construction/destruction tlcs900h_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); - tlcs900h_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, address_map_constructor internal_map); + tlcs900h_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname); + + // static configuration helpers + static void set_am8_16(device_t &device, int am8_16) { downcast(device).m_am8_16 = am8_16; } protected: // device-level overrides @@ -73,8 +78,16 @@ protected: virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram, UINT32 options); protected: + int m_am8_16; address_space_config m_program_config; + UINT8 RDMEM(offs_t addr) { return m_program->read_byte( addr ); } + UINT16 RDMEMW(offs_t addr) { return m_program->read_word( addr ); } + UINT32 RDMEML(offs_t addr) { return m_program->read_dword( addr ); } + void WRMEM(offs_t addr, UINT8 data) { m_program->write_byte( addr, data ); } + void WRMEMW(offs_t addr,UINT16 data) { m_program->write_word( addr, data ); } + void WRMEML(offs_t addr,UINT32 data) { m_program->write_dword( addr, data ); } + /* registers */ PAIR m_xwa[4]; PAIR m_xbc[4]; @@ -645,8 +658,10 @@ public: DECLARE_WRITE8_MEMBER( internal_w ); protected: + virtual void device_config_complete(); virtual void device_start(); virtual void device_reset(); + virtual void execute_set_input(int inputnum, int state); virtual void tlcs900_check_hdma(); virtual void tlcs900_check_irqs(); @@ -762,8 +777,10 @@ public: template static devcb2_base &set_porte_write(device_t &device, _Object object) { return downcast(device).m_porte_write.set_callback(object); } protected: + virtual void device_config_complete(); virtual void device_start(); virtual void device_reset(); + virtual void execute_set_input(int inputnum, int state); virtual void tlcs900_check_hdma(); virtual void tlcs900_check_irqs(); diff --git a/src/mame/drivers/taitopjc.c b/src/mame/drivers/taitopjc.c index 9c6fd6c89f1..d975af80374 100644 --- a/src/mame/drivers/taitopjc.c +++ b/src/mame/drivers/taitopjc.c @@ -376,10 +376,10 @@ WRITE8_MEMBER(taitopjc_state::tlcs_sound_w) // 0xfc0fb5: INTRX1 // 0xfc0f41: INTTX1 -static ADDRESS_MAP_START( tlcs900h_mem, AS_PROGRAM, 8, taitopjc_state ) +static ADDRESS_MAP_START( tlcs900h_mem, AS_PROGRAM, 16, taitopjc_state ) AM_RANGE(0x010000, 0x02ffff) AM_RAM // Work RAM - AM_RANGE(0x040000, 0x0400ff) AM_READWRITE(tlcs_sound_r, tlcs_sound_w) - AM_RANGE(0x060000, 0x061fff) AM_READWRITE(tlcs_common_r, tlcs_common_w) + AM_RANGE(0x040000, 0x0400ff) AM_READWRITE8(tlcs_sound_r, tlcs_sound_w, 0xffff) + AM_RANGE(0x060000, 0x061fff) AM_READWRITE8(tlcs_common_r, tlcs_common_w, 0xffff) AM_RANGE(0xfc0000, 0xffffff) AM_ROM AM_REGION("io_cpu", 0) ADDRESS_MAP_END diff --git a/src/mame/drivers/taitotz.c b/src/mame/drivers/taitotz.c index 867366ac455..bdfaf371e95 100644 --- a/src/mame/drivers/taitotz.c +++ b/src/mame/drivers/taitotz.c @@ -551,7 +551,7 @@ public: required_device m_maincpu; required_device m_iocpu; required_shared_ptr m_work_ram; - required_shared_ptr m_mbox_ram; + required_shared_ptr m_mbox_ram; required_device m_ata; DECLARE_READ64_MEMBER(ppc_common_r); @@ -608,10 +608,8 @@ public: virtual void video_start(); UINT32 screen_update_taitotz(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect); INTERRUPT_GEN_MEMBER(taitotz_vbi); - DECLARE_READ8_MEMBER(tlcs_ide0_r); - DECLARE_WRITE8_MEMBER(tlcs_ide0_w); - DECLARE_READ8_MEMBER(tlcs_ide1_r); - DECLARE_WRITE8_MEMBER(tlcs_ide1_w); + DECLARE_READ16_MEMBER(tlcs_ide0_r); + DECLARE_READ16_MEMBER(tlcs_ide1_r); DECLARE_WRITE_LINE_MEMBER(ide_interrupt); void taitotz_exit(); void draw_tile(taitotz_state *state, UINT32 pos, UINT32 tile); @@ -2304,102 +2302,22 @@ WRITE8_MEMBER(taitotz_state::tlcs_rtc_w) } } -READ8_MEMBER(taitotz_state::tlcs_ide0_r) +READ16_MEMBER(taitotz_state::tlcs_ide0_r) { - int reg = offset >> 1; - - if (reg == 0) - { - if ((offset & 1) == 0) - { - ide_cs0_latch_r = m_ata->read_cs0(space, reg, 0xffff); - return (ide_cs0_latch_r & 0xff); - } - else - { - return (ide_cs0_latch_r >> 8) & 0xff; - } - } - else - { - if (offset & 1) - fatalerror("tlcs_ide0_r: %02X, odd offset\n", offset); - - UINT8 d = m_ata->read_cs0(space, reg, 0xff); - if (reg == 7) - d &= ~0x2; // Type Zero doesn't like the index bit. It's defined as vendor-specific, so it probably shouldn't be up... - // The status check explicitly checks for 0x50 (drive ready, seek complete). - return d; - } -} - -WRITE8_MEMBER(taitotz_state::tlcs_ide0_w) -{ - int reg = offset >> 1; - - if (reg == 7 || reg == 0) - { - if ((offset & 1) == 0) - { - ide_cs0_latch_w &= 0xff00; - ide_cs0_latch_w |= data; - } - else - { - ide_cs0_latch_w &= 0x00ff; - ide_cs0_latch_w |= (UINT16)(data) << 8; - m_ata->write_cs0(space, reg, ide_cs0_latch_w, 0xffff); - } - } - else - { - if (offset & 1) - fatalerror("tlcs_ide0_w: %02X, %02X, odd offset\n", offset, data); - m_ata->write_cs0(space, reg, data, 0xff); - } -} - -READ8_MEMBER(taitotz_state::tlcs_ide1_r) -{ - int reg = offset >> 1; - - if (reg != 6) - fatalerror("tlcs_ide1_r: %02X\n", offset); - - if ((offset & 1) == 0) - { - UINT8 d = m_ata->read_cs1(space, reg, 0xff); + UINT16 d = m_ata->read_cs0(space, offset, mem_mask); + if (offset == 7) d &= ~0x2; // Type Zero doesn't like the index bit. It's defined as vendor-specific, so it probably shouldn't be up... // The status check explicitly checks for 0x50 (drive ready, seek complete). - return d; - } - else - { - //fatalerror("tlcs_ide1_r: %02X, odd offset\n", offset); - UINT8 d = m_ata->read_cs1(space, reg, 0xff); - d &= ~0x2; - return d; - } + return d; } -WRITE8_MEMBER(taitotz_state::tlcs_ide1_w) +READ16_MEMBER(taitotz_state::tlcs_ide1_r) { - int reg = offset >> 1; - - if (reg != 6) - fatalerror("tlcs_ide1_w: %02X, %02X\n", offset, data); - - if ((offset & 1) == 0) - { - ide_cs1_latch_w &= 0xff00; - ide_cs1_latch_w |= data; - } - else - { - ide_cs1_latch_w &= 0x00ff; - ide_cs1_latch_w |= (UINT16)(data) << 16; - m_ata->write_cs1(space, reg, ide_cs1_latch_w, 0xffff); - } + UINT16 d = m_ata->read_cs1(space, offset, mem_mask); + if (offset == 6) + d &= ~0x2; // Type Zero doesn't like the index bit. It's defined as vendor-specific, so it probably shouldn't be up... + // The status check explicitly checks for 0x50 (drive ready, seek complete). + return d; } // TLCS900 interrupt vectors @@ -2427,25 +2345,25 @@ WRITE8_MEMBER(taitotz_state::tlcs_ide1_w) // 0xfc0d55: INTRX1 Serial 1 receive // 0xfc0ce1: INTTX1 Serial 1 transmit -static ADDRESS_MAP_START( tlcs900h_mem, AS_PROGRAM, 8, taitotz_state) +static ADDRESS_MAP_START( tlcs900h_mem, AS_PROGRAM, 16, taitotz_state) AM_RANGE(0x010000, 0x02ffff) AM_RAM // Work RAM AM_RANGE(0x040000, 0x041fff) AM_RAM AM_SHARE("nvram") // Backup RAM - AM_RANGE(0x044000, 0x04400f) AM_READWRITE(tlcs_rtc_r, tlcs_rtc_w) - AM_RANGE(0x060000, 0x061fff) AM_READWRITE(tlcs_common_r, tlcs_common_w) + AM_RANGE(0x044000, 0x04400f) AM_READWRITE8(tlcs_rtc_r, tlcs_rtc_w, 0xffff) + AM_RANGE(0x060000, 0x061fff) AM_READWRITE8(tlcs_common_r, tlcs_common_w, 0xffff) AM_RANGE(0x064000, 0x064fff) AM_RAM AM_SHARE("mbox_ram") // MBox - AM_RANGE(0x068000, 0x06800f) AM_READWRITE(tlcs_ide0_r, tlcs_ide0_w) - AM_RANGE(0x06c000, 0x06c00f) AM_READWRITE(tlcs_ide1_r, tlcs_ide1_w) + AM_RANGE(0x068000, 0x06800f) AM_DEVWRITE("ata", ata_interface_device, write_cs0) AM_READ(tlcs_ide0_r) + AM_RANGE(0x06c000, 0x06c00f) AM_DEVWRITE("ata", ata_interface_device, write_cs1) AM_READ(tlcs_ide1_r) AM_RANGE(0xfc0000, 0xffffff) AM_ROM AM_REGION("io_cpu", 0) ADDRESS_MAP_END -static ADDRESS_MAP_START( landhigh_tlcs900h_mem, AS_PROGRAM, 8, taitotz_state) +static ADDRESS_MAP_START( landhigh_tlcs900h_mem, AS_PROGRAM, 16, taitotz_state) AM_RANGE(0x200000, 0x21ffff) AM_RAM // Work RAM AM_RANGE(0x400000, 0x401fff) AM_RAM AM_SHARE("nvram") // Backup RAM - AM_RANGE(0x404000, 0x40400f) AM_READWRITE(tlcs_rtc_r, tlcs_rtc_w) - AM_RANGE(0x900000, 0x901fff) AM_READWRITE(tlcs_common_r, tlcs_common_w) + AM_RANGE(0x404000, 0x40400f) AM_READWRITE8(tlcs_rtc_r, tlcs_rtc_w, 0xffff) + AM_RANGE(0x900000, 0x901fff) AM_READWRITE8(tlcs_common_r, tlcs_common_w, 0xffff) AM_RANGE(0x910000, 0x910fff) AM_RAM AM_SHARE("mbox_ram") // MBox - AM_RANGE(0x908000, 0x90800f) AM_READWRITE(tlcs_ide0_r, tlcs_ide0_w) - AM_RANGE(0x918000, 0x91800f) AM_READWRITE(tlcs_ide1_r, tlcs_ide1_w) + AM_RANGE(0x908000, 0x90800f) AM_DEVWRITE("ata", ata_interface_device, write_cs0) AM_READ(tlcs_ide0_r) + AM_RANGE(0x918000, 0x91800f) AM_DEVWRITE("ata", ata_interface_device, write_cs1) AM_READ(tlcs_ide1_r) AM_RANGE(0xfc0000, 0xffffff) AM_ROM AM_REGION("io_cpu", 0) ADDRESS_MAP_END @@ -2758,10 +2676,10 @@ static MACHINE_CONFIG_START( taitotz, taitotz_state ) /* TMP95C063F I/O CPU */ MCFG_CPU_ADD("iocpu", TMP95C063, 25000000) - MCFG_TMP95C063_PORT9_READ(IOPORT("INPUTS1")) - MCFG_TMP95C063_PORTB_READ(IOPORT("INPUTS2")) - MCFG_TMP95C063_PORTD_READ(IOPORT("INPUTS3")) - MCFG_TMP95C063_PORTE_READ(IOPORT("INPUTS4")) + MCFG_TMP95C063_PORT9_WRITE(IOPORT("INPUTS1")) + MCFG_TMP95C063_PORTB_WRITE(IOPORT("INPUTS2")) + MCFG_TMP95C063_PORTD_WRITE(IOPORT("INPUTS3")) + MCFG_TMP95C063_PORTE_WRITE(IOPORT("INPUTS4")) MCFG_CPU_PROGRAM_MAP(tlcs900h_mem) MCFG_CPU_VBLANK_INT_DRIVER("screen", taitotz_state, taitotz_vbi) diff --git a/src/mess/drivers/ngp.c b/src/mess/drivers/ngp.c index feb4354082c..8232e96e395 100644 --- a/src/mess/drivers/ngp.c +++ b/src/mess/drivers/ngp.c @@ -807,6 +807,7 @@ void ngp_state::nvram_write(emu_file &file) static MACHINE_CONFIG_START( ngp_common, ngp_state ) MCFG_CPU_ADD( "maincpu", TMP95C061, XTAL_6_144MHz ) + MCFG_TLCS900H_AM8_16(1) MCFG_CPU_PROGRAM_MAP( ngp_mem) MCFG_TMP95C061_PORTA_WRITE(WRITE8(ngp_state,ngp_tlcs900_porta))