Use swapendian_int16/int32 in more devices

This commit is contained in:
AJR 2020-07-29 17:16:15 -04:00
parent 5de0896497
commit b5bbf672f0
8 changed files with 48 additions and 76 deletions

View File

@ -248,8 +248,8 @@ void buddha_device::ide_interrupt_enable_w(offs_t offset, uint16_t data, uint16_
uint16_t buddha_device::ide_0_cs0_r(offs_t offset, uint16_t mem_mask)
{
uint16_t data = m_ata_0->cs0_r((offset >> 1) & 0x07, (mem_mask << 8) | (mem_mask >> 8));
data = (data << 8) | (data >> 8);
uint16_t data = m_ata_0->cs0_r((offset >> 1) & 0x07, swapendian_int16(mem_mask));
data = swapendian_int16(data);
LOG("ide_0_cs0_r(%04x) %04x [mask = %04x]\n", offset, data, mem_mask);
@ -260,16 +260,16 @@ void buddha_device::ide_0_cs0_w(offs_t offset, uint16_t data, uint16_t mem_mask)
{
LOG("ide_0_cs0_w(%04x) %04x [mask = %04x]\n", offset, data, mem_mask);
mem_mask = (mem_mask << 8) | (mem_mask >> 8);
data = (data << 8) | (data >> 8);
mem_mask = swapendian_int16(mem_mask);
data = swapendian_int16(data);
m_ata_0->cs0_w((offset >> 1) & 0x07, data, mem_mask);
}
uint16_t buddha_device::ide_0_cs1_r(offs_t offset, uint16_t mem_mask)
{
uint16_t data = m_ata_0->cs1_r((offset >> 1) & 0x07, (mem_mask << 8) | (mem_mask >> 8));
data = (data << 8) | (data >> 8);
uint16_t data = m_ata_0->cs1_r((offset >> 1) & 0x07, swapendian_int16(mem_mask));
data = swapendian_int16(data);
LOG("ide_0_cs1_r(%04x) %04x [mask = %04x]\n", offset, data, mem_mask);
@ -280,16 +280,16 @@ void buddha_device::ide_0_cs1_w(offs_t offset, uint16_t data, uint16_t mem_mask)
{
LOG("ide_0_cs1_w(%04x) %04x [mask = %04x]\n", offset, data, mem_mask);
mem_mask = (mem_mask << 8) | (mem_mask >> 8);
data = (data << 8) | (data >> 8);
mem_mask = swapendian_int16(mem_mask);
data = swapendian_int16(data);
m_ata_0->cs1_w((offset >> 1) & 0x07, data, mem_mask);
}
uint16_t buddha_device::ide_1_cs0_r(offs_t offset, uint16_t mem_mask)
{
uint16_t data = m_ata_1->cs0_r((offset >> 1) & 0x07, (mem_mask << 8) | (mem_mask >> 8));
data = (data << 8) | (data >> 8);
uint16_t data = m_ata_1->cs0_r((offset >> 1) & 0x07, swapendian_int16(mem_mask));
data = swapendian_int16(data);
LOG("ide_1_cs0_r(%04x) %04x [mask = %04x]\n", offset, data, mem_mask);
@ -300,16 +300,16 @@ void buddha_device::ide_1_cs0_w(offs_t offset, uint16_t data, uint16_t mem_mask)
{
LOG("ide_1_cs0_w(%04x) %04x [mask = %04x]\n", offset, data, mem_mask);
mem_mask = (mem_mask << 8) | (mem_mask >> 8);
data = (data << 8) | (data >> 8);
mem_mask = swapendian_int16(mem_mask);
data = swapendian_int16(data);
m_ata_1->cs0_w((offset >> 1) & 0x07, data, mem_mask);
}
uint16_t buddha_device::ide_1_cs1_r(offs_t offset, uint16_t mem_mask)
{
uint16_t data = m_ata_1->cs1_r((offset >> 1) & 0x07, (mem_mask << 8) | (mem_mask >> 8));
data = (data << 8) | (data >> 8);
uint16_t data = m_ata_1->cs1_r((offset >> 1) & 0x07, swapendian_int16(mem_mask));
data = swapendian_int16(data);
LOG("ide_1_cs1_r(%04x) %04x [mask = %04x]\n", offset, data, mem_mask);
@ -320,8 +320,8 @@ void buddha_device::ide_1_cs1_w(offs_t offset, uint16_t data, uint16_t mem_mask)
{
LOG("ide_1_cs1_w(%04x) %04x [mask = %04x]\n", offset, data, mem_mask);
mem_mask = (mem_mask << 8) | (mem_mask >> 8);
data = (data << 8) | (data >> 8);
mem_mask = swapendian_int16(mem_mask);
data = swapendian_int16(data);
m_ata_1->cs1_w((offset >> 1) & 0x07, data, mem_mask);
}

View File

@ -2199,11 +2199,6 @@ uint64_t newport_base_device::rex3_r(offs_t offset, uint64_t mem_mask)
return ret;
}
uint32_t newport_base_device::do_endian_swap(uint32_t color)
{
return (color >> 24) | (color << 24) | ((color >> 8) & 0x0000ff00) | ((color << 8) & 0x00ff0000);
}
uint32_t newport_base_device::get_host_color()
{
static const uint32_t s_color_masks[4] = { 0xf, 0xff, 0xfff, 0xffffffff };
@ -2259,7 +2254,7 @@ uint32_t newport_base_device::get_host_color()
break;
}
if (BIT(m_rex3.m_draw_mode1, 11))
color = do_endian_swap(color);
color = swapendian_int32(color);
return color;
}

View File

@ -476,8 +476,6 @@ protected:
uint32_t convert_8bpp_bgr_to_24bpp_rgb(uint8_t pix_in);
uint32_t convert_12bpp_bgr_to_24bpp_rgb(uint16_t pix_in);
uint32_t do_endian_swap(uint32_t color);
struct bresenham_octant_info_t
{
int16_t incrx1;

View File

@ -315,7 +315,7 @@ void nubus_image_device::file_data_w(uint32_t data)
std::uint32_t count = 4;
std::uint32_t actualcount = 0;
data = ((data & 0xff) << 24) | ((data & 0xff00) << 8) | ((data & 0xff0000) >> 8) | ((data & 0xff000000) >> 24);
data = swapendian_int32(data);
if(filectx.fd) {
//data = big_endianize_int32(data);
if((filectx.bytecount + count) > filectx.filelen) count = filectx.filelen - filectx.bytecount;
@ -345,7 +345,7 @@ uint32_t nubus_image_device::file_data_r()
void nubus_image_device::file_len_w(uint32_t data)
{
data = ((data & 0xff) << 24) | ((data & 0xff00) << 8) | ((data & 0xff0000) >> 8) | ((data & 0xff000000) >> 24);
data = swapendian_int32(data);
filectx.filelen = big_endianize_int32(data);
}

View File

@ -5,22 +5,16 @@
National Semiconductor HPC disassembler
Note that though all 16-bit fields in instructions have the MSB first,
the HPC's memory organization is in fact little-endian. This is why r16
is not used to read them.
the HPC's memory organization is in fact little-endian (including
vector and JIDW tables). This is why r16 is always swapped here.
***************************************************************************/
#include "emu.h"
#include "util/disasmintf.h"
#include "hpcdasm.h"
#include "util/strformat.h"
#include <cctype>
using osd::u32;
using util::BIT;
using offs_t = u32;
const char *const hpc16083_disassembler::s_regs[128] =
{
"psw", nullptr, "SP", "PC", "A", "K", "B", "X",
@ -270,7 +264,7 @@ offs_t hpc_disassembler::disassemble(std::ostream &stream, offs_t pc, const hpc_
if (BIT(opcode, 1))
imm = true;
src = (opcodes.r8(pc + 1) << 8) | opcodes.r8(pc + 2);
src = swapendian_int16(opcodes.r16(pc + 1));
reg = opcodes.r8(pc + 3);
opcode = opcodes.r8(pc + 4);
bytes = 5;
@ -284,7 +278,7 @@ offs_t hpc_disassembler::disassemble(std::ostream &stream, offs_t pc, const hpc_
imm = true;
src = opcodes.r8(pc + 1);
reg = (opcodes.r8(pc + 2) << 8) | opcodes.r8(pc + 3);
reg = swapendian_int16(opcodes.r16(pc + 2));
opcode = opcodes.r8(pc + 4);
bytes = 5;
break;
@ -304,15 +298,15 @@ offs_t hpc_disassembler::disassemble(std::ostream &stream, offs_t pc, const hpc_
if (BIT(opcode, 1))
imm = true;
src = (opcodes.r8(pc + 1) << 8) | opcodes.r8(pc + 2);
reg = (opcodes.r8(pc + 3) << 8) | opcodes.r8(pc + 4);
src = swapendian_int16(opcodes.r16(pc + 1));
reg = swapendian_int16(opcodes.r16(pc + 3));
opcode = opcodes.r8(pc + 5);
bytes = 6;
break;
case 0xa6:
idx = true;
reg = (opcodes.r8(pc + 1) << 8) | opcodes.r8(pc + 2);
reg = swapendian_int16(opcodes.r16(pc + 1));
src = opcodes.r8(pc + 3);
opcode = opcodes.r8(pc + 4);
bytes = 5;
@ -389,8 +383,8 @@ offs_t hpc_disassembler::disassemble(std::ostream &stream, offs_t pc, const hpc_
case 0xa7:
imm = true;
src = (opcodes.r8(pc + 1) << 8) | opcodes.r8(pc + 2);
reg = (opcodes.r8(pc + 3) << 8) | opcodes.r8(pc + 4);
src = swapendian_int16(opcodes.r16(pc + 1));
reg = swapendian_int16(opcodes.r16(pc + 3));
bytes = 5;
break;
@ -403,33 +397,33 @@ offs_t hpc_disassembler::disassemble(std::ostream &stream, offs_t pc, const hpc_
case 0xb0: case 0xb1: case 0xb2: case 0xb3:
imm = true;
reg = 0x00c8 | ((opcode & 0x03) << 1);
src = (opcodes.r8(pc + 1) << 8) | opcodes.r8(pc + 2);
src = swapendian_int16(opcodes.r16(pc + 1));
bytes = 3;
break;
case 0xb8: case 0xb9: case 0xba: case 0xbb:
case 0xbc: case 0xbd: case 0xbe: case 0xbf:
imm = true;
src = (opcodes.r8(pc + 1) << 8) | opcodes.r8(pc + 2);
src = swapendian_int16(opcodes.r16(pc + 1));
bytes = 3;
break;
case 0xb4: case 0xb5:
jmp = true;
src = pc + 3 + ((opcodes.r8(pc + 1) << 8) | opcodes.r8(pc + 2));
src = pc + 3 + swapendian_int16(opcodes.r16(pc + 1));
bytes = 3;
break;
case 0xb6:
indir = false;
src = (opcodes.r8(pc + 1) << 8) | opcodes.r8(pc + 2);
src = swapendian_int16(opcodes.r16(pc + 1));
opcode = opcodes.r8(pc + 3);
bytes = 4;
break;
case 0xb7:
imm = true;
src = (opcodes.r8(pc + 1) << 8) | opcodes.r8(pc + 2);
src = swapendian_int16(opcodes.r16(pc + 1));
reg = opcodes.r8(pc + 3);
bytes = 4;
break;

View File

@ -57,21 +57,6 @@ enum {
};
/* TODO: THESE WILL BE REPLACED BY MAME FUNCTIONS
#define BYTE_REV32(t) \
do { \
(t) = ((uint32_t)(t) >> 16) | ((uint32_t)(t) << 16); \
(t) = (((uint32_t)(t) >> 8) & 0x00ff00ff) | (((uint32_t)(t) << 8) & 0xff00ff00); \
} while (0);
#define BYTE_REV16(t) \
do { \
(t) = (((uint16_t)(t) >> 8) & 0x00ff) | (((uint16_t)(t) << 8) & 0xff00); \
} while (0);
#endif
*/
/* Get/set general register value -- watch for r0 on writes. */
#define get_iregval(gr) (m_iregs[(gr)])
#define set_iregval(gr, val) (m_iregs[(gr)] = ((gr) == 0 ? 0 : (val)))
@ -352,7 +337,7 @@ uint32_t i860_cpu_device::ifetch (uint32_t pc)
the BE bit), we need to adjust the instruction below on MSB hosts. */
w1 = m_program->read_dword(phys_pc);
#ifdef HOST_MSB
BYTE_REV32 (w1);
w1 = swapendian_int32(w1);
#endif /* HOST_MSB. */
return w1;
}
@ -390,7 +375,7 @@ uint32_t i860_cpu_device::get_address_translation (uint32_t vaddr, int is_datare
pg_dir_entry_a = dtb | (vdir << 2);
pg_dir_entry = m_program->read_dword(pg_dir_entry_a);
#ifdef HOST_MSB
BYTE_REV32 (pg_dir_entry);
pg_dir_entry = swapendian_int32(pg_dir_entry);
#endif
/* Check for non-present PDE. */
@ -438,7 +423,7 @@ uint32_t i860_cpu_device::get_address_translation (uint32_t vaddr, int is_datare
pg_tbl_entry_a = pfa1 | (vpage << 2);
pg_tbl_entry = m_program->read_dword(pg_tbl_entry_a);
#ifdef HOST_MSB
BYTE_REV32 (pg_tbl_entry);
pg_tbl_entry = swapendian_int32(pg_tbl_entry);
#endif
/* Check for non-present PTE. */
@ -483,8 +468,8 @@ uint32_t i860_cpu_device::get_address_translation (uint32_t vaddr, int is_datare
ttpde = pg_dir_entry | 0x20;
ttpte = pg_tbl_entry | 0x20;
#ifdef HOST_MSB
BYTE_REV32 (ttpde);
BYTE_REV32 (ttpte);
ttpde = swapendian_int32(ttpde);
ttpte = swapendian_int32(ttpte);
#endif
m_program->write_dword(pg_dir_entry_a, ttpde);
m_program->write_dword(pg_tbl_entry_a, ttpte);
@ -555,7 +540,7 @@ uint32_t i860_cpu_device::readmemi_emu (uint32_t addr, int size)
{
uint32_t ret = m_program->read_word(addr);
#ifdef HOST_MSB
BYTE_REV16 (ret);
ret = swapendian_int16(ret);
#endif
return ret & 0xffff;
}
@ -563,7 +548,7 @@ uint32_t i860_cpu_device::readmemi_emu (uint32_t addr, int size)
{
uint32_t ret = m_program->read_dword(addr);
#ifdef HOST_MSB
BYTE_REV32 (ret);
ret = swapendian_int32(ret);
#endif
return ret;
}
@ -615,14 +600,14 @@ void i860_cpu_device::writememi_emu (uint32_t addr, int size, uint32_t data)
else if (size == 2)
{
#ifdef HOST_MSB
BYTE_REV16 (data);
data = swapendian_int16(data);
#endif
m_program->write_word(addr, data);
}
else if (size == 4)
{
#ifdef HOST_MSB
BYTE_REV32 (data);
data = swapendian_int32(data);
#endif
m_program->write_dword(addr, data);
}
@ -4523,7 +4508,7 @@ void i860_cpu_device::disasm (uint32_t addr, int len)
fprintf (stderr, " (%s) 0x%08x: ", m_device->tag(), addr);
insn = m_program->read_dword(phys_addr);
#ifdef HOST_MSB
BYTE_REV32 (insn);
insn = swapendian_int32(insn);
#endif /* HOST_MSB. */
disasm_i860 (buf, addr, insn); fprintf (stderr, "%s", buf);
fprintf (stderr, "\n");

View File

@ -3,7 +3,7 @@
#include "emu.h"
#include "dp8390.h"
#define DP8390_BYTE_ORDER(w) ((m_regs.dcr & 3) == 3 ? ((data << 8) | (data >> 8)) : data)
#define DP8390_BYTE_ORDER(w) ((m_regs.dcr & 3) == 3 ? swapendian_int16(data) : data)
#define LOOPBACK (!(m_regs.dcr & 8) && (m_regs.tcr & 6))
DEFINE_DEVICE_TYPE(DP8390D, dp8390d_device, "dp8390d", "DP8390D NIC")

View File

@ -86,7 +86,7 @@ uint16_t gayle_device::gayle_r(offs_t offset, uint16_t mem_mask)
offset <<= 1;
// swap
mem_mask = (mem_mask << 8) | (mem_mask >> 8);
mem_mask = swapendian_int16(mem_mask);
if (BIT(offset, 15))
{
@ -113,7 +113,7 @@ uint16_t gayle_device::gayle_r(offs_t offset, uint16_t mem_mask)
logerror("gayle_r(%06x): %04x & %04x\n", offset, data, mem_mask);
// swap data
data = (data << 8) | (data >> 8);
data = swapendian_int16(data);
return data;
}
@ -123,8 +123,8 @@ void gayle_device::gayle_w(offs_t offset, uint16_t data, uint16_t mem_mask)
offset <<= 1;
// swap
mem_mask = (mem_mask << 8) | (mem_mask >> 8);
data = ((data << 8) | (data >> 8)) & mem_mask;
mem_mask = swapendian_int16(mem_mask);
data = swapendian_int16(data) & mem_mask;
if (VERBOSE)
logerror("gayle_w(%06x): %04x & %04x\n", offset, data, mem_mask);