From 489bf63a89932df529698ec10b8ddf2b5722b939 Mon Sep 17 00:00:00 2001 From: AJR Date: Sat, 29 Oct 2022 19:18:14 -0400 Subject: bus/ata: Add alternate CS0/CS1 handlers with built-in byte swapping for big-endian host systems * konami/3dom2.cpp: Fix malformed logerror --- src/devices/bus/ata/ataintf.h | 5 +++++ src/mame/amiga/amiga.cpp | 22 ++++------------------ src/mame/konami/3dom2.cpp | 2 +- src/mame/konami/cobra.cpp | 43 ++----------------------------------------- src/mame/konami/firebeat.cpp | 39 ++------------------------------------- src/mame/konami/konamim2.cpp | 12 +----------- 6 files changed, 15 insertions(+), 108 deletions(-) diff --git a/src/devices/bus/ata/ataintf.h b/src/devices/bus/ata/ataintf.h index 423a8165d35..8fef178553d 100644 --- a/src/devices/bus/ata/ataintf.h +++ b/src/devices/bus/ata/ataintf.h @@ -137,6 +137,11 @@ public: uint16_t cs1_r(offs_t offset, uint16_t mem_mask = 0xffff) { return internal_read_cs1(offset, mem_mask); } void cs0_w(offs_t offset, uint16_t data, uint16_t mem_mask = 0xffff) { internal_write_cs0(offset, data, mem_mask); } void cs1_w(offs_t offset, uint16_t data, uint16_t mem_mask = 0xffff) { internal_write_cs1(offset, data, mem_mask); } + + uint16_t cs0_swap_r(offs_t offset, uint16_t mem_mask = 0xffff) { return swapendian_int16(internal_read_cs0(offset, swapendian_int16(mem_mask))); } + uint16_t cs1_swap_r(offs_t offset, uint16_t mem_mask = 0xffff) { return swapendian_int16(internal_read_cs1(offset, swapendian_int16(mem_mask))); } + void cs0_swap_w(offs_t offset, uint16_t data, uint16_t mem_mask = 0xffff) { internal_write_cs0(offset, swapendian_int16(data), swapendian_int16(mem_mask)); } + void cs1_swap_w(offs_t offset, uint16_t data, uint16_t mem_mask = 0xffff) { internal_write_cs1(offset, swapendian_int16(data), swapendian_int16(mem_mask)); } }; DECLARE_DEVICE_TYPE(ATA_INTERFACE, ata_interface_device) diff --git a/src/mame/amiga/amiga.cpp b/src/mame/amiga/amiga.cpp index 9d2adfe5833..7bfc1bd5d44 100644 --- a/src/mame/amiga/amiga.cpp +++ b/src/mame/amiga/amiga.cpp @@ -970,25 +970,15 @@ void a4000_state::scsi_w(offs_t offset, u32 data, u32 mem_mask) u16 a4000_state::ide_r(offs_t offset, u16 mem_mask) { - u16 data = 0xffff; - // ide interrupt register if (offset == 0x1010) return m_ide_interrupt << 15; - // swap - mem_mask = (mem_mask << 8) | (mem_mask >> 8); - // this very likely doesn't respond to all the addresses, figure out which ones if (BIT(offset, 12)) - data = m_ata->cs1_r((offset >> 1) & 0x07, mem_mask); + return m_ata->cs1_swap_r((offset >> 1) & 0x07, mem_mask); else - data = m_ata->cs0_r((offset >> 1) & 0x07, mem_mask); - - // swap - data = (data << 8) | (data >> 8); - - return data; + return m_ata->cs0_swap_r((offset >> 1) & 0x07, mem_mask); } void a4000_state::ide_w(offs_t offset, u16 data, u16 mem_mask) @@ -997,15 +987,11 @@ void a4000_state::ide_w(offs_t offset, u16 data, u16 mem_mask) if (offset == 0x1010) return; - // swap - mem_mask = (mem_mask << 8) | (mem_mask >> 8); - data = (data << 8) | (data >> 8); - // this very likely doesn't respond to all the addresses, figure out which ones if (BIT(offset, 12)) - m_ata->cs1_w((offset >> 1) & 0x07, data, mem_mask); + m_ata->cs1_swap_w((offset >> 1) & 0x07, data, mem_mask); else - m_ata->cs0_w((offset >> 1) & 0x07, data, mem_mask); + m_ata->cs0_swap_w((offset >> 1) & 0x07, data, mem_mask); } WRITE_LINE_MEMBER( a4000_state::ide_interrupt_w ) diff --git a/src/mame/konami/3dom2.cpp b/src/mame/konami/3dom2.cpp index a93fdf1acab..22d6162b4c5 100644 --- a/src/mame/konami/3dom2.cpp +++ b/src/mame/konami/3dom2.cpp @@ -592,7 +592,7 @@ void m2_powerbus_device::write(offs_t offset, uint32_t data) break; } default: - logerror("%s: POWERBUS W: [%x] %x (PC:%x)\n", machine().describe_context(), byte_offs, data); + logerror("%s: POWERBUS W: [%x] %x\n", machine().describe_context(), byte_offs, data); } } diff --git a/src/mame/konami/cobra.cpp b/src/mame/konami/cobra.cpp index 11a259457b3..390f8091534 100644 --- a/src/mame/konami/cobra.cpp +++ b/src/mame/konami/cobra.cpp @@ -759,10 +759,6 @@ public: void sub_config_w(offs_t offset, uint32_t data, uint32_t mem_mask = ~0); uint32_t sub_mainbd_r(offs_t offset, uint32_t mem_mask = ~0); void sub_mainbd_w(offs_t offset, uint32_t data, uint32_t mem_mask = ~0); - uint16_t sub_ata0_r(offs_t offset, uint16_t mem_mask = ~0); - void sub_ata0_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0); - uint16_t sub_ata1_r(offs_t offset, uint16_t mem_mask = ~0); - void sub_ata1_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0); uint32_t sub_psac2_r(); void sub_psac2_w(uint32_t data); void sub_psac_palette_w(offs_t offset, uint32_t data, uint32_t mem_mask = ~0); @@ -1904,41 +1900,6 @@ void cobra_state::sub_config_w(offs_t offset, uint32_t data, uint32_t mem_mask) { } -uint16_t cobra_state::sub_ata0_r(offs_t offset, uint16_t mem_mask) -{ - mem_mask = ( mem_mask << 8 ) | ( mem_mask >> 8 ); - - uint32_t data = m_ata->cs0_r(offset, mem_mask); - data = ( data << 8 ) | ( data >> 8 ); - - return data; -} - -void cobra_state::sub_ata0_w(offs_t offset, uint16_t data, uint16_t mem_mask) -{ - mem_mask = ( mem_mask << 8 ) | ( mem_mask >> 8 ); - data = ( data << 8 ) | ( data >> 8 ); - - m_ata->cs0_w(offset, data, mem_mask); -} - -uint16_t cobra_state::sub_ata1_r(offs_t offset, uint16_t mem_mask) -{ - mem_mask = ( mem_mask << 8 ) | ( mem_mask >> 8 ); - - uint32_t data = m_ata->cs1_r(offset, mem_mask); - - return ( data << 8 ) | ( data >> 8 ); -} - -void cobra_state::sub_ata1_w(offs_t offset, uint16_t data, uint16_t mem_mask) -{ - mem_mask = ( mem_mask << 8 ) | ( mem_mask >> 8 ); - data = ( data << 8 ) | ( data >> 8 ); - - m_ata->cs1_w(offset, data, mem_mask); -} - uint32_t cobra_state::sub_comram_r(offs_t offset) { int page = m_comram_page ^ 1; @@ -2041,8 +2002,8 @@ void cobra_state::cobra_sub_map(address_map &map) map(0x70000000, 0x7003ffff).rw(FUNC(cobra_state::sub_comram_r), FUNC(cobra_state::sub_comram_w)); // Double buffered shared RAM between Main and Sub // map(0x78000000, 0x780000ff).noprw(); // SCSI controller (unused) map(0x78040000, 0x7804ffff).rw("rfsnd", FUNC(rf5c400_device::rf5c400_r), FUNC(rf5c400_device::rf5c400_w)); - map(0x78080000, 0x7808000f).rw(FUNC(cobra_state::sub_ata0_r), FUNC(cobra_state::sub_ata0_w)); - map(0x780c0010, 0x780c001f).rw(FUNC(cobra_state::sub_ata1_r), FUNC(cobra_state::sub_ata1_w)); + map(0x78080000, 0x7808000f).rw(m_ata, FUNC(ata_interface_device::cs0_swap_r), FUNC(ata_interface_device::cs0_swap_w)); + map(0x780c0010, 0x780c001f).rw(m_ata, FUNC(ata_interface_device::cs1_swap_r), FUNC(ata_interface_device::cs1_swap_w)); map(0x78200000, 0x782000ff).rw(m_k001604, FUNC(k001604_device::reg_r), FUNC(k001604_device::reg_w)); // PSAC registers map(0x78210000, 0x78217fff).ram().w(FUNC(cobra_state::sub_psac_palette_w)).share("paletteram"); // PSAC palette RAM map(0x78220000, 0x7823ffff).rw(m_k001604, FUNC(k001604_device::tile_r), FUNC(k001604_device::tile_w)); // PSAC tile RAM diff --git a/src/mame/konami/firebeat.cpp b/src/mame/konami/firebeat.cpp index 989f46bcb47..0bfd15aaa41 100644 --- a/src/mame/konami/firebeat.cpp +++ b/src/mame/konami/firebeat.cpp @@ -454,12 +454,6 @@ private: void control_w(offs_t offset, uint8_t data); - uint16_t ata_command_r(offs_t offset, uint16_t mem_mask = ~0); - void ata_command_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0); - - uint16_t ata_control_r(offs_t offset, uint16_t mem_mask = ~0); - void ata_control_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0); - // uint32_t comm_uart_r(offs_t offset, uint32_t mem_mask = ~ 0); // void comm_uart_w(offs_t offset, uint32_t data, uint32_t mem_mask = ~0); @@ -792,8 +786,8 @@ void firebeat_state::firebeat_map(address_map &map) map(0x7e000100, 0x7e00013f).rw("rtc", FUNC(rtc65271_device::xram_r), FUNC(rtc65271_device::xram_w)); map(0x7e800000, 0x7e8000ff).rw(m_gcu, FUNC(k057714_device::read), FUNC(k057714_device::write)); map(0x7e800100, 0x7e8001ff).noprw(); // Secondary GCU, only used by Keyboardmania but is written to during the bootloader of other games - map(0x7fe00000, 0x7fe0000f).rw(FUNC(firebeat_state::ata_command_r), FUNC(firebeat_state::ata_command_w)); - map(0x7fe80000, 0x7fe8000f).rw(FUNC(firebeat_state::ata_control_r), FUNC(firebeat_state::ata_control_w)); + map(0x7fe00000, 0x7fe0000f).rw(m_ata, FUNC(ata_interface_device::cs0_swap_r), FUNC(ata_interface_device::cs0_swap_w)); + map(0x7fe80000, 0x7fe8000f).rw(m_ata, FUNC(ata_interface_device::cs1_swap_r), FUNC(ata_interface_device::cs1_swap_w)); map(0x7ff80000, 0x7fffffff).rom().region("user1", 0); /* System BIOS */ } @@ -1057,35 +1051,6 @@ void firebeat_state::control_w(offs_t offset, uint8_t data) m_control = data; } -/*****************************************************************************/ -/* ATA Interface */ - -uint16_t firebeat_state::ata_command_r(offs_t offset, uint16_t mem_mask) -{ -// printf("ata_command_r: %08X, %08X\n", offset, mem_mask); - uint16_t r = m_ata->cs0_r(offset, swapendian_int16(mem_mask)); - return swapendian_int16(r); -} - -void firebeat_state::ata_command_w(offs_t offset, uint16_t data, uint16_t mem_mask) -{ -// printf("ata_command_w: %08X, %08X, %08X\n", data, offset, mem_mask); - m_ata->cs0_w(offset, swapendian_int16(data & 0xffff), swapendian_int16(mem_mask & 0xffff)); -} - - -uint16_t firebeat_state::ata_control_r(offs_t offset, uint16_t mem_mask) -{ -// printf("ata_control_r: %08X, %08X\n", offset, mem_mask); - uint16_t r = m_ata->cs1_r(offset, swapendian_int16(mem_mask)); - return swapendian_int16(r); -} - -void firebeat_state::ata_control_w(offs_t offset, uint16_t data, uint16_t mem_mask) -{ - m_ata->cs1_w(offset, swapendian_int16(data & 0xffff), swapendian_int16(mem_mask & 0xffff)); -} - /*****************************************************************************/ diff --git a/src/mame/konami/konamim2.cpp b/src/mame/konami/konamim2.cpp index 4304c0a314d..095f292caf7 100644 --- a/src/mame/konami/konamim2.cpp +++ b/src/mame/konami/konamim2.cpp @@ -329,16 +329,6 @@ public: } } - uint16_t konami_ide_r(offs_t offset, uint16_t mem_mask = ~0) - { - return swapendian_int16(m_ata->cs0_r(offset, mem_mask)); - } - - void konami_ide_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0) - { - m_ata->cs0_w(offset, swapendian_int16(data), mem_mask); - } - private: void install_ymz280b(); void install_m48t58(); @@ -753,7 +743,7 @@ void konamim2_state::m2_map(address_map &map) map(0x37a00020, 0x37a0003f).rw(FUNC(konamim2_state::konami_io0_r), FUNC(konamim2_state::konami_io0_w)); map(0x37c00010, 0x37c0001f).rw(FUNC(konamim2_state::konami_sio_r), FUNC(konamim2_state::konami_sio_w)); map(0x37e00000, 0x37e0000f).rw(FUNC(konamim2_state::konami_io1_r), FUNC(konamim2_state::konami_io1_w)); - map(0x3f000000, 0x3fffffff).rw(FUNC(konamim2_state::konami_ide_r), FUNC(konamim2_state::konami_ide_w)); + map(0x3f000000, 0x3fffffff).rw(m_ata, FUNC(ata_interface_device::cs0_swap_r), FUNC(ata_interface_device::cs0_swap_w)); } -- cgit v1.2.3