mirror of
https://github.com/holub/mame
synced 2025-04-23 00:39:36 +03:00
mips/o2dprintf.hxx, pinball/wpc_pic.cpp, shared/isbc_215g.cpp, sound/asc.cpp: Use multibyte.h helpers
This commit is contained in:
parent
66c0252a03
commit
7e92448efa
@ -1,6 +1,8 @@
|
||||
// license:BSD-3-Clause
|
||||
// copyright-holders:Ryan Holtz
|
||||
|
||||
#include "multibyte.h"
|
||||
|
||||
static char digit[] = "0123456789abcdef";
|
||||
|
||||
static void dprintdec(int64_t val, bool zeropad, int size)
|
||||
@ -175,32 +177,31 @@ void dprintoct(uint64_t val, bool zeropad, int pos)
|
||||
#define Ioct 30
|
||||
#define Loct 63
|
||||
|
||||
static uint64_t dprintf_get_arg64(uint8_t *buf, uint32_t &curr)
|
||||
static uint64_t dprintf_get_arg64(const uint8_t *buf, uint32_t &curr)
|
||||
{
|
||||
curr = (curr + 3) & ~3;
|
||||
const uint64_t ret = ((uint64_t)buf[curr+0] << 56) | ((uint64_t)buf[curr+1] << 48) | ((uint64_t)buf[curr+2] << 40) | ((uint64_t)buf[curr+3] << 32) |
|
||||
((uint64_t)buf[curr+4] << 24) | ((uint64_t)buf[curr+5] << 16) | ((uint64_t)buf[curr+6] << 8) | buf[curr+7];
|
||||
const uint64_t ret = get_u64be(&buf[curr]);
|
||||
curr += 8;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static uint32_t dprintf_get_arg32(uint8_t *buf, uint32_t &curr)
|
||||
static uint32_t dprintf_get_arg32(const uint8_t *buf, uint32_t &curr)
|
||||
{
|
||||
curr = (curr + 3) & ~3;
|
||||
const uint32_t ret = ((uint32_t)buf[curr+0] << 24) | ((uint32_t)buf[curr+1] << 16) | ((uint32_t)buf[curr+2] << 8) | buf[curr+3];
|
||||
const uint32_t ret = get_u32be(&buf[curr]);
|
||||
curr += 4;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static uint16_t dprintf_get_arg16(uint8_t *buf, uint32_t &curr)
|
||||
static uint16_t dprintf_get_arg16(const uint8_t *buf, uint32_t &curr)
|
||||
{
|
||||
curr = (curr + 1) & ~1;
|
||||
const uint16_t ret = ((uint16_t)buf[curr+0] << 8) | buf[curr+1];
|
||||
const uint16_t ret = get_u16be(&buf[curr]);
|
||||
curr += 2;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static uint8_t dprintf_get_arg8(uint8_t *buf, uint32_t &curr)
|
||||
static uint8_t dprintf_get_arg8(const uint8_t *buf, uint32_t &curr)
|
||||
{
|
||||
const uint8_t ret = buf[curr++];
|
||||
return ret;
|
||||
@ -213,18 +214,9 @@ void mips3_device::do_o2_dprintf(uint32_t fmt_addr, uint32_t a1, uint32_t a2, ui
|
||||
int idx = 0;
|
||||
uint8_t byte_val = 0;
|
||||
fmt_addr &= 0x1fffffff;
|
||||
argbuf[0] = (uint8_t)(a1 >> 24);
|
||||
argbuf[1] = (uint8_t)(a1 >> 16);
|
||||
argbuf[2] = (uint8_t)(a1 >> 8);
|
||||
argbuf[3] = (uint8_t)a1;
|
||||
argbuf[4] = (uint8_t)(a2 >> 24);
|
||||
argbuf[5] = (uint8_t)(a2 >> 16);
|
||||
argbuf[6] = (uint8_t)(a2 >> 8);
|
||||
argbuf[7] = (uint8_t)a2;
|
||||
argbuf[8] = (uint8_t)(a3 >> 24);
|
||||
argbuf[9] = (uint8_t)(a3 >> 16);
|
||||
argbuf[10] = (uint8_t)(a3 >> 8);
|
||||
argbuf[11] = (uint8_t)a3;
|
||||
put_u32be(&argbuf[0], a1);
|
||||
put_u32be(&argbuf[4], a2);
|
||||
put_u32be(&argbuf[8], a3);
|
||||
stack &= 0x1fffffff;
|
||||
for (int i = 0; i < 4096-12; i++)
|
||||
{
|
||||
|
@ -40,6 +40,8 @@
|
||||
#include "emu.h"
|
||||
#include "asc.h"
|
||||
|
||||
#include "multibyte.h"
|
||||
|
||||
// device type definition
|
||||
DEFINE_DEVICE_TYPE(ASC, asc_device, "asc", "ASC")
|
||||
|
||||
@ -408,33 +410,17 @@ uint8_t asc_device::read(offs_t offset)
|
||||
// WT inc/phase registers - rebuild from "live" copies"
|
||||
if ((offset >= 0x810) && (offset <= 0x82f))
|
||||
{
|
||||
m_regs[0x11] = m_phase[0]>>16;
|
||||
m_regs[0x12] = m_phase[0]>>8;
|
||||
m_regs[0x13] = m_phase[0];
|
||||
m_regs[0x15] = m_incr[0]>>16;
|
||||
m_regs[0x16] = m_incr[0]>>8;
|
||||
m_regs[0x17] = m_incr[0];
|
||||
put_u24be(&m_regs[0x11], m_phase[0]);
|
||||
put_u24be(&m_regs[0x15], m_incr[0]);
|
||||
|
||||
m_regs[0x19] = m_phase[1]>>16;
|
||||
m_regs[0x1a] = m_phase[1]>>8;
|
||||
m_regs[0x1b] = m_phase[1];
|
||||
m_regs[0x1d] = m_incr[1]>>16;
|
||||
m_regs[0x1e] = m_incr[1]>>8;
|
||||
m_regs[0x1f] = m_incr[1];
|
||||
put_u24be(&m_regs[0x19], m_phase[1]);
|
||||
put_u24be(&m_regs[0x1d], m_incr[1]);
|
||||
|
||||
m_regs[0x21] = m_phase[2]>>16;
|
||||
m_regs[0x22] = m_phase[2]>>8;
|
||||
m_regs[0x23] = m_phase[2];
|
||||
m_regs[0x25] = m_incr[2]>>16;
|
||||
m_regs[0x26] = m_incr[2]>>8;
|
||||
m_regs[0x27] = m_incr[2];
|
||||
put_u24be(&m_regs[0x21], m_phase[2]);
|
||||
put_u24be(&m_regs[0x25], m_incr[2]);
|
||||
|
||||
m_regs[0x29] = m_phase[3]>>16;
|
||||
m_regs[0x2a] = m_phase[3]>>8;
|
||||
m_regs[0x2b] = m_phase[3];
|
||||
m_regs[0x2d] = m_incr[3]>>16;
|
||||
m_regs[0x2e] = m_incr[3]>>8;
|
||||
m_regs[0x2f] = m_incr[3];
|
||||
put_u24be(&m_regs[0x29], m_phase[3]);
|
||||
put_u24be(&m_regs[0x2d], m_incr[3]);
|
||||
}
|
||||
|
||||
if (offset >= 0x1000)
|
||||
|
@ -4,6 +4,8 @@
|
||||
#include "emu.h"
|
||||
#include "wpc_pic.h"
|
||||
|
||||
#include "multibyte.h"
|
||||
|
||||
DEFINE_DEVICE_TYPE(WPC_PIC, wpc_pic_device, "wpc_pic", "Williams Pinball Controller PIC Security")
|
||||
|
||||
wpc_pic_device::wpc_pic_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
|
||||
@ -45,7 +47,7 @@ uint8_t wpc_pic_device::read()
|
||||
|
||||
void wpc_pic_device::check_game_id()
|
||||
{
|
||||
uint32_t cmp = (cmpchk[0] << 16) | (cmpchk[1] << 8) | cmpchk[2];
|
||||
uint32_t cmp = get_u24be(cmpchk);
|
||||
for(int i=0; i<1000; i++) {
|
||||
uint32_t v = (i >> 8) * 0x3133 + (i & 0xff) * 0x3231;
|
||||
v = v & 0xffffff;
|
||||
@ -116,9 +118,7 @@ void wpc_pic_device::serial_to_pic()
|
||||
|
||||
v = 100*no[0] + 10*no[1] + no[2];
|
||||
v = (v >> 8) * ((serial[17] << 8) | serial[19]) + (v & 0xff) * ((serial[18] << 8) | serial[17]);
|
||||
chk[0] = v >> 16;
|
||||
chk[1] = v >> 8;
|
||||
chk[2] = v;
|
||||
put_u24be(chk, v);
|
||||
}
|
||||
|
||||
void wpc_pic_device::device_start()
|
||||
|
@ -9,6 +9,8 @@
|
||||
#include "emu.h"
|
||||
#include "isbc_215g.h"
|
||||
|
||||
#include "multibyte.h"
|
||||
|
||||
DEFINE_DEVICE_TYPE(ISBC_215G, isbc_215g_device, "isbc_215g", "ISBC 215G Winchester Disk Controller")
|
||||
|
||||
isbc_215g_device::isbc_215g_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
|
||||
@ -32,7 +34,7 @@ void isbc_215g_device::find_sector()
|
||||
// 1: cyl low
|
||||
// 2: head
|
||||
// 3: sector
|
||||
uint16_t cyl = ((m_idcompare[0] & 0xf) << 8) | m_idcompare[1];
|
||||
uint16_t cyl = get_u16be(&m_idcompare[0]) & 0xfff;
|
||||
uint16_t bps = 128 << ((m_idcompare[0] >> 4) & 3);
|
||||
|
||||
if(!m_geom[m_drive])
|
||||
@ -280,13 +282,11 @@ void isbc_215g_device::io_w(offs_t offset, uint16_t data)
|
||||
break;
|
||||
case 0x18:
|
||||
//sector id/format
|
||||
m_idcompare[1] = data & 0xff;
|
||||
m_idcompare[0] = data >> 8;
|
||||
put_u16be(&m_idcompare[0], data);
|
||||
break;
|
||||
case 0x1c:
|
||||
//sector id low
|
||||
m_idcompare[3] = data & 0xff;
|
||||
m_idcompare[2] = data >> 8;
|
||||
put_u16be(&m_idcompare[2], data);
|
||||
break;
|
||||
default:
|
||||
logerror("isbc_215g: invalid port write 0x80%02x\n", offset*2);
|
||||
|
Loading…
Reference in New Issue
Block a user