summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/bus
diff options
context:
space:
mode:
Diffstat (limited to 'src/devices/bus')
-rw-r--r--src/devices/bus/a2bus/agat7langcard.cpp19
-rw-r--r--src/devices/bus/a2bus/agat7langcard.h4
-rw-r--r--src/devices/bus/a2bus/agat7ram.cpp27
-rw-r--r--src/devices/bus/a2bus/agat7ram.h4
-rw-r--r--src/devices/bus/a2bus/agat840k_hle.cpp449
-rw-r--r--src/devices/bus/a2bus/agat840k_hle.h103
-rw-r--r--src/devices/bus/c64/silverrock.cpp4
-rw-r--r--src/devices/bus/c64/stardos.cpp2
-rw-r--r--src/devices/bus/c64/vizastar.cpp4
-rw-r--r--src/devices/bus/c64/vw64.cpp4
-rw-r--r--src/devices/bus/c64/warp_speed.cpp4
-rw-r--r--src/devices/bus/cbmiec/c1541.cpp2
-rw-r--r--src/devices/bus/chanf/rom.cpp2
-rw-r--r--src/devices/bus/coco/coco_fdc.cpp23
-rw-r--r--src/devices/bus/coco/coco_fdc.h2
-rw-r--r--src/devices/bus/gameboy/mbc.cpp16
-rw-r--r--src/devices/bus/msx_cart/dooly.cpp2
-rw-r--r--src/devices/bus/neogeo/boot_kof10th.cpp2
-rw-r--r--src/devices/bus/neogeo/prot_cmc.cpp6
-rw-r--r--src/devices/bus/neogeo/prot_cthd.cpp4
-rw-r--r--src/devices/bus/neogeo/prot_kof2k3bl.cpp4
-rw-r--r--src/devices/bus/neogeo/prot_misc.cpp28
-rw-r--r--src/devices/bus/neogeo/prot_pcm2.cpp2
-rw-r--r--src/devices/bus/neogeo/prot_pvc.cpp30
-rw-r--r--src/devices/bus/neogeo/prot_sma.cpp30
-rw-r--r--src/devices/bus/neogeo/sbp.cpp2
-rw-r--r--src/devices/bus/nes/jy.cpp2
-rw-r--r--src/devices/bus/nes/mmc3_clones.cpp2
-rw-r--r--src/devices/bus/nes/waixing.cpp4
-rw-r--r--src/devices/bus/nubus/nubus_spec8.cpp2
-rw-r--r--src/devices/bus/nubus/pds30_procolor816.cpp2
-rw-r--r--src/devices/bus/s100/wunderbus.cpp2
-rw-r--r--src/devices/bus/saturn/sat_slot.cpp2
-rw-r--r--src/devices/bus/sega8/rom.cpp2
-rw-r--r--src/devices/bus/snes/rom.cpp6
-rw-r--r--src/devices/bus/snes_ctrl/pachinko.cpp2
-rw-r--r--src/devices/bus/ss50/interface.cpp4
-rw-r--r--src/devices/bus/ss50/mpc.cpp194
-rw-r--r--src/devices/bus/ss50/mpc.h14
-rw-r--r--src/devices/bus/ti99x/990_hd.cpp2
-rw-r--r--src/devices/bus/vcs/dpc.cpp4
-rw-r--r--src/devices/bus/vic20/exp.cpp1
-rw-r--r--src/devices/bus/vic20/vic1112.cpp4
43 files changed, 897 insertions, 131 deletions
diff --git a/src/devices/bus/a2bus/agat7langcard.cpp b/src/devices/bus/a2bus/agat7langcard.cpp
index 9bb00b38c60..b4d2a168f38 100644
--- a/src/devices/bus/a2bus/agat7langcard.cpp
+++ b/src/devices/bus/a2bus/agat7langcard.cpp
@@ -10,6 +10,9 @@
#include "agat7langcard.h"
+//#define VERBOSE 1
+#include "logmacro.h"
+
/***************************************************************************
PARAMETERS
***************************************************************************/
@@ -30,7 +33,7 @@ DEFINE_DEVICE_TYPE(A2BUS_AGAT7LANGCARD, a2bus_agat7langcard_device, "a7lang", "A
a2bus_agat7langcard_device::a2bus_agat7langcard_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock) :
device_t(mconfig, type, tag, owner, clock),
- device_a2bus_card_interface(mconfig, *this), m_inh_state(0), m_last_offset(0), m_dxxx_bank(0), m_main_bank(0)
+ device_a2bus_card_interface(mconfig, *this), m_inh_state(0), m_dxxx_bank(0), m_main_bank(0), m_csr(0)
{
}
@@ -48,13 +51,13 @@ void a2bus_agat7langcard_device::device_start()
// set_a2bus_device makes m_slot valid
set_a2bus_device();
- memset(m_ram, 0, 32*1024);
+ memset(m_ram, 0, 32 * 1024);
save_item(NAME(m_inh_state));
save_item(NAME(m_ram));
save_item(NAME(m_dxxx_bank));
save_item(NAME(m_main_bank));
- save_item(NAME(m_last_offset));
+ save_item(NAME(m_csr));
}
void a2bus_agat7langcard_device::device_reset()
@@ -62,7 +65,7 @@ void a2bus_agat7langcard_device::device_reset()
m_inh_state = INH_NONE;
m_dxxx_bank = 0;
m_main_bank = 0;
- m_last_offset = -1;
+ m_csr = 0;
m_mode = 0;
}
@@ -70,7 +73,7 @@ void a2bus_agat7langcard_device::do_io(int offset)
{
int old_inh_state = m_inh_state;
- m_last_offset = offset;
+ m_csr = offset & 0x7f;
m_inh_state = INH_WRITE;
m_dxxx_bank = 0;
@@ -91,13 +94,11 @@ void a2bus_agat7langcard_device::do_io(int offset)
recalc_slot_inh();
}
-#if 1
- logerror("LC: (ofs %02x) new state %c%c dxxx=%04x main=%05x\n",
+ LOG("LC: (ofs %02x) new state %c%c dxxx=%04x main=%05x\n",
offset,
(m_inh_state & INH_READ) ? 'R' : 'x',
(m_inh_state & INH_WRITE) ? 'W' : 'x',
m_dxxx_bank, m_main_bank);
-#endif
}
@@ -107,7 +108,7 @@ void a2bus_agat7langcard_device::do_io(int offset)
uint8_t a2bus_agat7langcard_device::read_cnxx(address_space &space, uint8_t offset)
{
- return m_last_offset < 0 ? 0x80 : (0x80 | m_last_offset);
+ return (0x80 | m_csr);
}
diff --git a/src/devices/bus/a2bus/agat7langcard.h b/src/devices/bus/a2bus/agat7langcard.h
index 13647abfb11..be3a650a222 100644
--- a/src/devices/bus/a2bus/agat7langcard.h
+++ b/src/devices/bus/a2bus/agat7langcard.h
@@ -47,11 +47,11 @@ private:
void do_io(int offset);
int m_inh_state;
- int m_last_offset;
int m_dxxx_bank;
int m_main_bank;
- uint8_t m_ram[32*1024];
+ uint8_t m_ram[32 * 1024];
uint8_t m_mode;
+ uint8_t m_csr;
};
// device type definition
diff --git a/src/devices/bus/a2bus/agat7ram.cpp b/src/devices/bus/a2bus/agat7ram.cpp
index dde0260db3f..51bbabb792c 100644
--- a/src/devices/bus/a2bus/agat7ram.cpp
+++ b/src/devices/bus/a2bus/agat7ram.cpp
@@ -10,6 +10,9 @@
#include "agat7ram.h"
+//#define VERBOSE 1
+#include "logmacro.h"
+
/***************************************************************************
PARAMETERS
***************************************************************************/
@@ -30,7 +33,7 @@ DEFINE_DEVICE_TYPE(A2BUS_AGAT7RAM, a2bus_agat7ram_device, "a7ram", "Agat-7 32K R
a2bus_agat7ram_device::a2bus_agat7ram_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock) :
device_t(mconfig, type, tag, owner, clock),
- device_a2bus_card_interface(mconfig, *this), m_inh_state(0), m_last_offset(0), m_main_bank(0)
+ device_a2bus_card_interface(mconfig, *this), m_inh_state(0), m_main_bank(0), m_csr(0)
{
}
@@ -48,32 +51,32 @@ void a2bus_agat7ram_device::device_start()
// set_a2bus_device makes m_slot valid
set_a2bus_device();
- memset(m_ram, 0, 32*1024);
+ memset(m_ram, 0, 32 * 1024);
save_item(NAME(m_inh_state));
save_item(NAME(m_ram));
save_item(NAME(m_main_bank));
- save_item(NAME(m_last_offset));
+ save_item(NAME(m_csr));
}
void a2bus_agat7ram_device::device_reset()
{
m_inh_state = INH_NONE;
m_main_bank = 0;
- m_last_offset = -1;
+ m_csr = 0;
}
void a2bus_agat7ram_device::do_io(int offset)
{
int old_inh_state = m_inh_state;
- m_last_offset = offset;
+ m_csr = offset & 0x7f;
m_inh_state = INH_NONE;
m_main_bank = 0;
if (offset & 0x8)
{
- m_inh_state = INH_READ|INH_WRITE;
+ m_inh_state = INH_READ | INH_WRITE;
}
if (offset & 0x1)
@@ -86,13 +89,11 @@ void a2bus_agat7ram_device::do_io(int offset)
recalc_slot_inh();
}
-#if 1
- logerror("RAM: (ofs %02x) new state %c%c main=%05x\n",
+ LOG("RAM: (ofs %02x) new state %c%c main=%05x\n",
offset,
(m_inh_state & INH_READ) ? 'R' : 'x',
(m_inh_state & INH_WRITE) ? 'W' : 'x',
m_main_bank);
-#endif
}
@@ -102,7 +103,7 @@ void a2bus_agat7ram_device::do_io(int offset)
uint8_t a2bus_agat7ram_device::read_cnxx(address_space &space, uint8_t offset)
{
- return m_last_offset < 0 ? 0 : (m_last_offset & 0x7f);
+ return m_csr;
}
@@ -125,12 +126,10 @@ uint8_t a2bus_agat7ram_device::read_inh_rom(address_space &space, uint16_t offse
void a2bus_agat7ram_device::write_inh_rom(address_space &space, uint16_t offset, uint8_t data)
{
// are writes enabled?
- if (!(m_inh_state & INH_WRITE))
+ if ((m_inh_state & INH_WRITE) && !BIT(m_csr, 4))
{
- return;
+ m_ram[(offset & 0x3fff) + m_main_bank] = data;
}
-
- m_ram[(offset & 0x3fff) + m_main_bank] = data;
}
int a2bus_agat7ram_device::inh_type()
diff --git a/src/devices/bus/a2bus/agat7ram.h b/src/devices/bus/a2bus/agat7ram.h
index e30aaf7b94b..3476e738179 100644
--- a/src/devices/bus/a2bus/agat7ram.h
+++ b/src/devices/bus/a2bus/agat7ram.h
@@ -47,9 +47,9 @@ private:
void do_io(int offset);
int m_inh_state;
- int m_last_offset;
int m_main_bank;
- uint8_t m_ram[32*1024];
+ uint8_t m_ram[32 * 1024];
+ uint8_t m_csr;
};
// device type definition
diff --git a/src/devices/bus/a2bus/agat840k_hle.cpp b/src/devices/bus/a2bus/agat840k_hle.cpp
new file mode 100644
index 00000000000..72217fbe464
--- /dev/null
+++ b/src/devices/bus/a2bus/agat840k_hle.cpp
@@ -0,0 +1,449 @@
+// license:BSD-3-Clause
+// copyright-holders:Sergey Svishchev
+/*********************************************************************
+
+ agat840k_hle.cpp
+
+ High-level simulation of the Agat 840K floppy controller card
+
+ http://agatcomp.ru/Reading/docs/es5323.txt
+ https://github.com/sintech/AGAT/blob/master/docs/agat-840k-format.txt
+ http://www.torlus.com/floppy/forum/viewtopic.php?f=19&t=1385
+
+*********************************************************************/
+
+#include "emu.h"
+#include "agat840k_hle.h"
+
+#include "formats/agat840k_hle_dsk.h"
+
+//#define VERBOSE 1
+#include "logmacro.h"
+
+
+/***************************************************************************
+ PARAMETERS
+***************************************************************************/
+
+//**************************************************************************
+// GLOBAL VARIABLES
+//**************************************************************************
+
+DEFINE_DEVICE_TYPE(A2BUS_AGAT840K_HLE, a2bus_agat840k_hle_device, "agat840k_hle", "Agat 840K floppy card")
+
+#define AGAT840K_ROM_REGION "agat840k_hle_rom"
+
+
+ROM_START( agat840k_hle )
+ ROM_REGION(0x100, AGAT840K_ROM_REGION, 0)
+ // "Zagorsk" variant
+ ROM_LOAD( "teac.rom", 0x0000, 0x0100, CRC(94266928) SHA1(5d369bad6cdd6a70b0bb16480eba69640de87a2e) )
+ROM_END
+
+//-------------------------------------------------
+// device_add_mconfig - add device configuration
+//-------------------------------------------------
+
+static const floppy_interface agat840k_hle_floppy_interface =
+{
+ FLOPPY_STANDARD_5_25_DSHD,
+ LEGACY_FLOPPY_OPTIONS_NAME(agat840k_hle),
+ "floppy_5_25"
+};
+
+MACHINE_CONFIG_MEMBER( a2bus_agat840k_hle_device::device_add_mconfig )
+ MCFG_DEVICE_ADD(FLOPPY_0, LEGACY_FLOPPY, 0)
+ MCFG_LEGACY_FLOPPY_CONFIG(agat840k_hle_floppy_interface)
+ MCFG_LEGACY_FLOPPY_IDX_CB(WRITELINE(a2bus_agat840k_hle_device, index_0_w))
+ MCFG_DEVICE_ADD(FLOPPY_1, LEGACY_FLOPPY, 0)
+ MCFG_LEGACY_FLOPPY_CONFIG(agat840k_hle_floppy_interface)
+ MCFG_LEGACY_FLOPPY_IDX_CB(WRITELINE(a2bus_agat840k_hle_device, index_1_w))
+
+ MCFG_DEVICE_ADD("d14", I8255, 0)
+ // PA not connected
+ MCFG_I8255_IN_PORTB_CB(READ8(a2bus_agat840k_hle_device, d14_i_b)) // status signals from drive
+ MCFG_I8255_OUT_PORTC_CB(WRITE8(a2bus_agat840k_hle_device, d14_o_c)) // control
+
+ MCFG_DEVICE_ADD("d15", I8255, 0)
+ MCFG_I8255_IN_PORTA_CB(READ8(a2bus_agat840k_hle_device, d15_i_a)) // read data
+// MCFG_I8255_OUT_PORTB_CB(WRITE8(a2bus_agat840k_hle_device, d15_o_b)) // write data
+ MCFG_I8255_IN_PORTC_CB(READ8(a2bus_agat840k_hle_device, d15_i_c))
+ MCFG_I8255_OUT_PORTC_CB(WRITE8(a2bus_agat840k_hle_device, d15_o_c))
+MACHINE_CONFIG_END
+
+//-------------------------------------------------
+// rom_region - device-specific ROM region
+//-------------------------------------------------
+
+const tiny_rom_entry *a2bus_agat840k_hle_device::device_rom_region() const
+{
+ return ROM_NAME(agat840k_hle);
+}
+
+//**************************************************************************
+// LIVE DEVICE
+//**************************************************************************
+
+a2bus_agat840k_hle_device::a2bus_agat840k_hle_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock)
+ : device_t(mconfig, type, tag, owner, clock)
+ , device_a2bus_card_interface(mconfig, *this)
+ , m_d14(*this, "d14")
+ , m_d15(*this, "d15")
+ , m_rom(nullptr)
+{
+}
+
+a2bus_agat840k_hle_device::a2bus_agat840k_hle_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
+ a2bus_agat840k_hle_device(mconfig, A2BUS_AGAT840K_HLE, tag, owner, clock)
+{
+}
+
+WRITE_LINE_MEMBER(a2bus_agat840k_hle_device::index_0_w)
+{
+ index_callback(0, state);
+}
+
+WRITE_LINE_MEMBER(a2bus_agat840k_hle_device::index_1_w)
+{
+ index_callback(1, state);
+}
+
+void a2bus_agat840k_hle_device::index_callback(int unit, int state)
+{
+ if (unit != m_unit) return;
+
+ LOG("index: unit %d state %d (%s)\n", unit, state, m_seen_magic ? "MAGIC" : "magic");
+
+#if 0
+ if (!state && !m_seen_magic)
+ {
+ m_seen_magic = true;
+ m_count_read = 0;
+ m_count_write = 0;
+ m_d15->pc4_w(0); // latch data into port A
+ m_d15->pc4_w(1);
+ m_timer_wait->adjust(attotime::from_usec(m_waittime), 0, attotime::from_usec(m_waittime));
+ }
+#endif
+}
+
+//-------------------------------------------------
+// device_start - device-specific startup
+//-------------------------------------------------
+
+void a2bus_agat840k_hle_device::device_start()
+{
+ // set_a2bus_device makes m_slot valid
+ set_a2bus_device();
+
+ m_rom = device().machine().root_device().memregion(this->subtag(AGAT840K_ROM_REGION).c_str())->base();
+
+ m_mxcs = MXCSR_SYNC;
+
+ m_timer_wait = timer_alloc(TIMER_ID_WAIT);
+ m_timer_seek = timer_alloc(TIMER_ID_SEEK);
+
+ m_seektime = 6000; // 6 ms, per es5323.txt
+ m_waittime = 32; // 16 bits x 2 us
+}
+
+void a2bus_agat840k_hle_device::device_reset()
+{
+ u8 buf[256];
+
+ for (int i = 0; i < 2; i++)
+ {
+ legacy_floppy_image_device *img = floppy_image(i);
+ if (img)
+ {
+ img->floppy_drive_set_ready_state(FLOPPY_DRIVE_READY, 0);
+ img->floppy_drive_set_rpm(300.);
+ img->floppy_drive_seek(-img->floppy_drive_get_current_track());
+ }
+ }
+ m_floppy = floppy_image(0);
+
+ // generate track images in memory, using default volume ID and gap padding bytes
+ int t = 0;
+ for (auto &elem : m_tracks)
+ {
+ elem = std::make_unique<uint16_t[]>(6250);
+
+ for (int i = 0; i < 13; i++)
+ {
+ elem[i] = 0xaa;
+ }
+ for (int j = 0; j < 21; j++)
+ {
+ const int s = (j * 1) % 21;
+ int cksum = 0;
+
+ m_floppy->floppy_drive_read_sector_data(t & 1, s, buf, 256);
+
+ enum
+ {
+ BAUX = 22,
+ BLOB = 256 + 19 + BAUX
+ };
+
+ for (int k = 0; k < 256; k++)
+ {
+ if (cksum > 255) { cksum++; cksum &= 255; }
+ cksum += buf[k];
+ elem[13 + (BLOB * j) + 17 + k] = buf[k];
+ }
+ cksum &= 255;
+
+ elem[13 + (BLOB * j) + 0] = 0xa4;
+ elem[13 + (BLOB * j) + 1] = 0x80ff; // desync
+ elem[13 + (BLOB * j) + 2] = 0x95;
+ elem[13 + (BLOB * j) + 3] = 0x6a;
+ elem[13 + (BLOB * j) + 4] = 0x40fe; // volume id
+ elem[13 + (BLOB * j) + 5] = t;
+ elem[13 + (BLOB * j) + 6] = s;
+ elem[13 + (BLOB * j) + 7] = 0x5a;
+ elem[13 + (BLOB * j) + 8] = 0xaa;
+ elem[13 + (BLOB * j) + 9] = 0xaa;
+ elem[13 + (BLOB * j) + 10] = 0xaa;
+ elem[13 + (BLOB * j) + 11] = 0xaa;
+ elem[13 + (BLOB * j) + 12] = 0xaa;
+ elem[13 + (BLOB * j) + 13] = 0xa4;
+ elem[13 + (BLOB * j) + 14] = 0x80ff; // desync
+ elem[13 + (BLOB * j) + 15] = 0x6a;
+ elem[13 + (BLOB * j) + 16] = 0x95;
+ elem[13 + (BLOB * j) + 17 + 256] = cksum + 0x2000;
+ elem[13 + (BLOB * j) + 17 + 257] = 0x5a;
+
+ // gap3
+ for (int k = 0; k < BAUX; k++)
+ {
+ elem[13 + (BLOB * j) + 17 + 258 + k] = 0xaa;
+ }
+ }
+
+ t++;
+ if ((t & 1) == 0)
+ {
+ m_floppy->floppy_drive_seek(1);
+ }
+ }
+ m_floppy->floppy_drive_seek(-m_floppy->floppy_drive_get_current_track());
+
+ m_mxcs |= MXCSR_SYNC;
+ m_mxcs &= ~MXCSR_TR;
+}
+
+void a2bus_agat840k_hle_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
+{
+ switch (id)
+ {
+ case TIMER_ID_WAIT:
+ {
+ m_count_read++;
+ m_count_read %= 6250;
+ m_d15->pc4_w(0);
+ m_d15->pc4_w(1);
+ if (BIT(m_tracks[(2 * m_floppy->floppy_drive_get_current_track()) + m_side][m_count_read], 15))
+ m_mxcs &= ~MXCSR_SYNC;
+ }
+ break;
+
+ case TIMER_ID_SEEK:
+ m_floppy->floppy_stp_w(1);
+ m_floppy->floppy_stp_w(0);
+ break;
+ }
+}
+
+
+/*-------------------------------------------------
+ read_c0nx - called for reads from this card's c0nx space
+-------------------------------------------------*/
+
+uint8_t a2bus_agat840k_hle_device::read_c0nx(address_space &space, uint8_t offset)
+{
+ u8 data;
+
+ switch (offset)
+ {
+ case 0: case 1: case 2: case 3:
+ data = m_d14->read(space, offset);
+ break;
+
+ case 4: case 5: case 6: case 7:
+ data = m_d15->read(space, offset - 4);
+ break;
+
+ default:
+ data = 0xff;
+ break;
+ }
+
+ return data;
+}
+
+
+/*-------------------------------------------------
+ write_c0nx - called for writes to this card's c0nx space
+-------------------------------------------------*/
+
+void a2bus_agat840k_hle_device::write_c0nx(address_space &space, uint8_t offset, uint8_t data)
+{
+ switch (offset)
+ {
+ case 0: case 1: case 2: case 3:
+ m_d14->write(space, offset, data);
+ break;
+
+ case 4: case 5: case 6: case 7:
+ m_d15->write(space, offset - 4, data);
+ break;
+
+ case 8: // write desync
+ break;
+
+ case 9: // step
+ LOG("step at %11.6f\n", machine().time().as_double());
+ m_seen_magic = false;
+ m_timer_wait->adjust(attotime::from_usec(m_seektime), 0, attotime::from_usec(m_waittime));
+ m_floppy->floppy_stp_w(1);
+ m_floppy->floppy_stp_w(0);
+ break;
+
+ case 10: // reset desync flipflop
+ m_mxcs |= MXCSR_SYNC;
+ break;
+
+ default:
+ break;
+ }
+}
+
+/*-------------------------------------------------
+ read_cnxx - called for reads from this card's c0nx space
+-------------------------------------------------*/
+
+uint8_t a2bus_agat840k_hle_device::read_cnxx(address_space &space, uint8_t offset)
+{
+ return m_rom[offset];
+}
+
+legacy_floppy_image_device *a2bus_agat840k_hle_device::floppy_image(int drive)
+{
+ const char *floppy_name = nullptr;
+
+ switch (drive)
+ {
+ case 0:
+ floppy_name = FLOPPY_0;
+ break;
+ case 1:
+ floppy_name = FLOPPY_1;
+ break;
+ }
+ return subdevice<legacy_floppy_image_device>(floppy_name);
+}
+
+// all signals active low. write support not implemented; WPT is always active.
+READ8_MEMBER(a2bus_agat840k_hle_device::d14_i_b)
+{
+ u8 data = 0x03; // one drive present, because drive select is broken
+
+ m_floppy->floppy_drive_set_ready_state(FLOPPY_DRIVE_READY, 1);
+
+ data |= (m_floppy->floppy_index_r() << 4) ^ 0x10;
+// data |= m_floppy->floppy_wpt_r() << 5;
+ data |= m_floppy->floppy_tk00_r() << 6;
+ data |= m_floppy->floppy_ready_r() << 7;
+
+ LOG("status A: %s %s (t %d) %s %s\n", BIT(data, 7) ? "ready" : "READY", BIT(data, 6) ? "tk00" : "TK00",
+ m_floppy->floppy_drive_get_current_track(),
+ BIT(data, 5) ? "wpt" : "WPT", BIT(data, 4) ? "index" : "INDEX");
+
+ return data;
+}
+
+/*
+ * b0 AH strong write precomp
+ * b1 -- NC
+ * b2 -- step direction (1 - inward, 0 - outward)
+ * b3 -- drive select (0 - drive 1, 1 - drive 2)
+ * b4 -- head select (0 - bottom, 1 - top)
+ * b5 AH write precomp off
+ * b6 AH write enable
+ * b7 AH motor on
+ *
+ * C0x2
+ */
+WRITE8_MEMBER(a2bus_agat840k_hle_device::d14_o_c)
+{
+ // drive select is broken in legacy flopdrv.cpp -- floppy_get_drive
+ m_unit = BIT(data, 3);
+ m_floppy = floppy_image(m_unit);
+ if (m_unit)
+ m_floppy->floppy_ds1_w(m_unit != 1);
+ else
+ m_floppy->floppy_ds0_w(m_unit != 0);
+
+ m_floppy->floppy_drtn_w(!BIT(data, 2));
+ m_side = BIT(data, 4);
+ m_floppy->floppy_wtg_w(!BIT(data, 6));
+ m_floppy->floppy_mon_w(!BIT(data, 7)); // tied to 'drive select', 'motor on' and 'head load'
+
+ if (!BIT(data, 7))
+ {
+ m_seen_magic = false;
+ m_timer_wait->adjust(attotime::never);
+ }
+ else
+ {
+ m_d15->pc4_w(0);
+ m_d15->pc4_w(1);
+ m_timer_wait->adjust(attotime::from_usec(m_waittime), 0, attotime::from_usec(m_waittime));
+ }
+
+ LOG("D14 C <- %02X (unit %d side %d drtn %d wtg %d mon %d)\n",
+ data, m_unit, m_side, !BIT(data, 2), !BIT(data, 6), !BIT(data, 7));
+}
+
+// data are latched in by write to PC4
+READ8_MEMBER(a2bus_agat840k_hle_device::d15_i_a)
+{
+ const u16 data = m_tracks[(2 * m_floppy->floppy_drive_get_current_track()) + m_side][m_count_read];
+ LOG("sector data: %02x @ %4d (head %d track %2d)%s\n", data & 0xff, m_count_read,
+ m_side, m_floppy->floppy_drive_get_current_track(),
+ BIT(data, 14) ? " volume" : (BIT(data, 13) ? " cksum" : ""));
+
+ return data & 0xff;
+}
+
+// C0x6
+//
+// b6 AL desync detected
+// b7 AH read or write data ready
+READ8_MEMBER(a2bus_agat840k_hle_device::d15_i_c)
+{
+ LOG("status B: @ %4d %s %s (%s)\n", m_count_read,
+ BIT(m_mxcs, 7) ? "ready" : "READY", BIT(m_mxcs, 6) ? "SYNC" : "sync",
+ m_seen_magic ? "MAGIC" : "magic");
+
+ return m_mxcs;
+}
+
+// C0x7
+//
+// b0 -- connected to b7, set if m_intr[PORT_B]
+// b2 AH b7 = ready for write data
+// b3 -- connected to b7, set if m_intr[PORT_A]
+// b4 AH b7 = read data ready
+WRITE8_MEMBER(a2bus_agat840k_hle_device::d15_o_c)
+{
+ if (BIT(data, 0) || BIT(data, 3))
+ {
+ m_mxcs |= MXCSR_TR;
+ }
+ else
+ {
+ m_mxcs &= ~MXCSR_TR;
+ }
+}
diff --git a/src/devices/bus/a2bus/agat840k_hle.h b/src/devices/bus/a2bus/agat840k_hle.h
new file mode 100644
index 00000000000..cab186c2c62
--- /dev/null
+++ b/src/devices/bus/a2bus/agat840k_hle.h
@@ -0,0 +1,103 @@
+// license:BSD-3-Clause
+// copyright-holders:Sergey Svishchev
+/*********************************************************************
+
+ agat840k_hle.h
+
+ High-level simulation of the Agat 840K floppy controller card
+
+*********************************************************************/
+
+#ifndef MAME_BUS_A2BUS_AGAT840K_HLE_H
+#define MAME_BUS_A2BUS_AGAT840K_HLE_H
+
+#pragma once
+
+#include "a2bus.h"
+#include "imagedev/flopdrv.h"
+#include "machine/i8255.h"
+
+
+
+//**************************************************************************
+// TYPE DEFINITIONS
+//**************************************************************************
+
+class a2bus_agat840k_hle_device:
+ public device_t,
+ public device_a2bus_card_interface
+{
+public:
+ enum : u8
+ {
+ MXCSR_SYNC = 0x40,
+ MXCSR_TR = 0x80
+ };
+
+ // construction/destruction
+ a2bus_agat840k_hle_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
+
+ DECLARE_READ8_MEMBER(d14_i_b);
+ DECLARE_READ8_MEMBER(d15_i_a);
+ DECLARE_READ8_MEMBER(d15_i_c);
+ DECLARE_WRITE8_MEMBER(d14_o_c);
+ DECLARE_WRITE8_MEMBER(d15_o_b);
+ DECLARE_WRITE8_MEMBER(d15_o_c);
+
+ DECLARE_WRITE_LINE_MEMBER(index_0_w);
+ DECLARE_WRITE_LINE_MEMBER(index_1_w);
+
+ void index_callback(int unit, int state);
+
+protected:
+ // construction/destruction
+ a2bus_agat840k_hle_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock);
+
+ virtual void device_start() override;
+ virtual void device_reset() override;
+ virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override;
+ virtual void device_add_mconfig(machine_config &config) override;
+ virtual const tiny_rom_entry *device_rom_region() const override;
+
+ // overrides of standard a2bus slot functions
+ virtual uint8_t read_c0nx(address_space &space, uint8_t offset) override;
+ virtual void write_c0nx(address_space &space, uint8_t offset, uint8_t data) override;
+ virtual uint8_t read_cnxx(address_space &space, uint8_t offset) override;
+
+ enum
+ {
+ TIMER_ID_WAIT = 0,
+ TIMER_ID_SEEK
+ };
+
+ required_device<i8255_device> m_d14;
+ required_device<i8255_device> m_d15;
+
+private:
+ legacy_floppy_image_device *floppy_image(int drive);
+ legacy_floppy_image_device *m_floppy;
+ bool m_side;
+
+ std::unique_ptr<uint16_t[]> m_tracks[160];
+ int m_count_read;
+ int m_count_write;
+ bool m_seen_magic;
+ int m_current_track;
+
+ u8 m_mxcs;
+ int m_unit;
+ int m_state;
+
+ int m_seektime;
+ int m_waittime;
+
+ emu_timer *m_timer_wait = nullptr;
+ emu_timer *m_timer_seek = nullptr;
+
+ uint8_t *m_rom;
+};
+
+// device type definition
+DECLARE_DEVICE_TYPE(A2BUS_AGAT840K_HLE, a2bus_agat840k_hle_device)
+
+#endif // MAME_BUS_A2BUS_AGAT840K_HLE_H
diff --git a/src/devices/bus/c64/silverrock.cpp b/src/devices/bus/c64/silverrock.cpp
index 2260b82738a..a34f21d17a7 100644
--- a/src/devices/bus/c64/silverrock.cpp
+++ b/src/devices/bus/c64/silverrock.cpp
@@ -37,10 +37,10 @@
//**************************************************************************
#define UNSCRAMBLE_ADDRESS(_offset) \
- BITSWAP16(_offset,15,14,13,12,1,0,2,3,11,10,9,8,7,6,5,4)
+ bitswap<16>(_offset,15,14,13,12,1,0,2,3,11,10,9,8,7,6,5,4)
#define UNSCRAMBLE_DATA(_data) \
- BITSWAP8(_data,7,6,5,4,0,1,2,3)
+ bitswap<8>(_data,7,6,5,4,0,1,2,3)
diff --git a/src/devices/bus/c64/stardos.cpp b/src/devices/bus/c64/stardos.cpp
index ce3d19f0b9b..c8e47d300e8 100644
--- a/src/devices/bus/c64/stardos.cpp
+++ b/src/devices/bus/c64/stardos.cpp
@@ -142,7 +142,7 @@ uint8_t c64_stardos_cartridge_device::c64_cd_r(address_space &space, offs_t offs
{
if (!roml || !romh)
{
- // TODO BITSWAP8(7,6,5,4,3,1,2,0) ?
+ // TODO bitswap<8>(7,6,5,4,3,1,2,0) ?
data = m_roml[offset & 0x3fff];
}
else if (!io1)
diff --git a/src/devices/bus/c64/vizastar.cpp b/src/devices/bus/c64/vizastar.cpp
index 03043e7de93..444ff656b68 100644
--- a/src/devices/bus/c64/vizastar.cpp
+++ b/src/devices/bus/c64/vizastar.cpp
@@ -36,10 +36,10 @@
//**************************************************************************
#define UNSCRAMBLE_ADDRESS(_offset) \
- BITSWAP16(_offset,15,14,13,12,5,0,7,10,11,9,8,6,4,3,2,1)
+ bitswap<16>(_offset,15,14,13,12,5,0,7,10,11,9,8,6,4,3,2,1)
#define UNSCRAMBLE_DATA(_data) \
- BITSWAP8(_data,7,6,0,5,1,4,2,3)
+ bitswap<8>(_data,7,6,0,5,1,4,2,3)
diff --git a/src/devices/bus/c64/vw64.cpp b/src/devices/bus/c64/vw64.cpp
index f6ed996765a..ea0d3c3dac2 100644
--- a/src/devices/bus/c64/vw64.cpp
+++ b/src/devices/bus/c64/vw64.cpp
@@ -40,10 +40,10 @@
//**************************************************************************
#define UNSCRAMBLE_ADDRESS(_offset) \
- BITSWAP16(_offset,15,14,13,12,6,2,8,10,11,9,7,5,4,3,1,0)
+ bitswap<16>(_offset,15,14,13,12,6,2,8,10,11,9,7,5,4,3,1,0)
#define UNSCRAMBLE_DATA(_data) \
- BITSWAP8(_data,7,6,0,5,1,4,2,3)
+ bitswap<8>(_data,7,6,0,5,1,4,2,3)
// 74LS122 tW=0.45*R*C = 1.1844s
diff --git a/src/devices/bus/c64/warp_speed.cpp b/src/devices/bus/c64/warp_speed.cpp
index e9098dadb44..3c266e3618d 100644
--- a/src/devices/bus/c64/warp_speed.cpp
+++ b/src/devices/bus/c64/warp_speed.cpp
@@ -38,10 +38,10 @@
//**************************************************************************
#define UNSCRAMBLE_ADDRESS(_offset) \
- BITSWAP16(_offset,15,14,12,13,5,2,7,9,11,10,8,6,4,3,1,0)
+ bitswap<16>(_offset,15,14,12,13,5,2,7,9,11,10,8,6,4,3,1,0)
#define UNSCRAMBLE_DATA(_data) \
- BITSWAP8(_data,7,6,5,0,1,4,2,3)
+ bitswap<8>(_data,7,6,5,0,1,4,2,3)
diff --git a/src/devices/bus/cbmiec/c1541.cpp b/src/devices/bus/cbmiec/c1541.cpp
index 4d0f9748966..427cebe1e31 100644
--- a/src/devices/bus/cbmiec/c1541.cpp
+++ b/src/devices/bus/cbmiec/c1541.cpp
@@ -1071,7 +1071,7 @@ void fsd2_device::device_start()
for (offs_t offset = 0; offset < 0x4000; offset++)
{
- uint8_t data = BITSWAP8(rom[offset], 7, 6, 5, 3, 4, 2, 1, 0);
+ uint8_t data = bitswap<8>(rom[offset], 7, 6, 5, 3, 4, 2, 1, 0);
rom[offset] = data;
}
diff --git a/src/devices/bus/chanf/rom.cpp b/src/devices/bus/chanf/rom.cpp
index 3dc509a29d9..a3a213ba7ed 100644
--- a/src/devices/bus/chanf/rom.cpp
+++ b/src/devices/bus/chanf/rom.cpp
@@ -192,7 +192,7 @@ void chanf_rom_device::common_write_2102(uint32_t offset, uint8_t data)
m_latch[1] = data;
// all bits but 2,3 come from this write, but they are shuffled
// notice that data is 8bits, so when swapping bit8 & bit9 are always 0!
- m_addr_latch = (m_addr_latch & 0x0c) | (BITSWAP16((uint16_t) data, 15, 14, 13, 12, 11, 10, 7, 6, 5, 3, 2, 1, 9, 8, 4, 0));
+ m_addr_latch = (m_addr_latch & 0x0c) | (bitswap<16>((uint16_t) data, 15, 14, 13, 12, 11, 10, 7, 6, 5, 3, 2, 1, 9, 8, 4, 0));
}
}
diff --git a/src/devices/bus/coco/coco_fdc.cpp b/src/devices/bus/coco/coco_fdc.cpp
index 64268c8b17b..01f91976db2 100644
--- a/src/devices/bus/coco/coco_fdc.cpp
+++ b/src/devices/bus/coco/coco_fdc.cpp
@@ -494,22 +494,27 @@ namespace
DEFINE_DEVICE_TYPE(COCO3_HDB1, coco3_hdb1_device, "coco3_hdb1", "CoCo3 HDB-DOS")
//**************************************************************************
-// CP400 FDC
+// Prológica CP-450 BASIC Disco V. 1.0 (1984)
+//
+// There is a photo of the CP-450 disk controller unit at:
+// https://datassette.org/softwares/tandy-trs-color/cp-450-basic-disco-v-10
+// http://files.datassette.org/softwares/img/wp_20141212_22_08_26_pro.jpg
+//
//**************************************************************************
-ROM_START(cp400_fdc)
+ROM_START(cp450_fdc)
ROM_REGION(0x4000, "eprom", ROMREGION_ERASE00)
- ROM_LOAD("cp400dsk.rom", 0x0000, 0x2000, CRC(e9ad60a0) SHA1(827697fa5b755f5dc1efb054cdbbeb04e405405b))
+ ROM_LOAD("cp450_basic_disco_v1.0.rom", 0x0000, 0x2000, CRC(e9ad60a0) SHA1(827697fa5b755f5dc1efb054cdbbeb04e405405b))
ROM_END
namespace
{
- class cp400_fdc_device : public coco_fdc_device_base
+ class cp450_fdc_device : public coco_fdc_device_base
{
public:
// construction/destruction
- cp400_fdc_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
- : coco_fdc_device_base(mconfig, CP400_FDC, tag, owner, clock)
+ cp450_fdc_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
+ : coco_fdc_device_base(mconfig, CP450_FDC, tag, owner, clock)
{
}
@@ -517,12 +522,12 @@ namespace
// optional information overrides
virtual const tiny_rom_entry *device_rom_region() const override
{
- return ROM_NAME(cp400_fdc);
+ return ROM_NAME(cp450_fdc);
}
};
}
-DEFINE_DEVICE_TYPE(CP400_FDC, cp400_fdc_device, "cp400_fdc", "CP400 FDC")
+DEFINE_DEVICE_TYPE(CP450_FDC, cp450_fdc_device, "cp450_fdc", "Prológica CP-450 BASIC Disco V. 1.0 (1984)")
//**************************************************************************
// Codimex CD-6809 FDC (1986)
@@ -556,4 +561,4 @@ namespace
};
}
-DEFINE_DEVICE_TYPE(CD6809_FDC, cd6809_fdc_device, "cd6809_fdc", "CD6809 FDC")
+DEFINE_DEVICE_TYPE(CD6809_FDC, cd6809_fdc_device, "cd6809_fdc", "Codimex CD-6809 Disk BASIC (1986)")
diff --git a/src/devices/bus/coco/coco_fdc.h b/src/devices/bus/coco/coco_fdc.h
index 11343ec2610..7ca2ca9e6fe 100644
--- a/src/devices/bus/coco/coco_fdc.h
+++ b/src/devices/bus/coco/coco_fdc.h
@@ -64,7 +64,7 @@ private:
extern const device_type COCO_FDC;
extern const device_type COCO_FDC_V11;
extern const device_type COCO3_HDB1;
-extern const device_type CP400_FDC;
+extern const device_type CP450_FDC;
extern const device_type CD6809_FDC;
#endif // MAME_BUS_COCO_COCO_FDC_H
diff --git a/src/devices/bus/gameboy/mbc.cpp b/src/devices/bus/gameboy/mbc.cpp
index de71f483779..4a48d896a94 100644
--- a/src/devices/bus/gameboy/mbc.cpp
+++ b/src/devices/bus/gameboy/mbc.cpp
@@ -1057,26 +1057,26 @@ WRITE8_MEMBER(gb_rom_sintax_device::write_bank)
switch (m_sintax_mode & 0x0f)
{
case 0x0d:
- data = BITSWAP8(data, 1,0,7,6,5,4,3,2);
+ data = bitswap<8>(data, 1,0,7,6,5,4,3,2);
break;
case 0x09:
- //data = BITSWAP8(data, 3,2,5,4,0,1,6,7); // Monkey..no
- data = BITSWAP8(data, 4,5,2,3,0,1,6,7);
+ //data = bitswap<8>(data, 3,2,5,4,0,1,6,7); // Monkey..no
+ data = bitswap<8>(data, 4,5,2,3,0,1,6,7);
break;
case 0x00: // 0x10=lion 0x00 hmmmmm // 1 and 0 unconfirmed
- data = BITSWAP8(data, 7,0,5,6,3,4,1,2);
+ data = bitswap<8>(data, 7,0,5,6,3,4,1,2);
break;
case 0x01:
- data = BITSWAP8(data, 0,1,6,7,4,5,2,3);
+ data = bitswap<8>(data, 0,1,6,7,4,5,2,3);
break;
case 0x05:
- data = BITSWAP8(data, 7,6,1,0,3,2,5,4); // Not 100% on this one
+ data = bitswap<8>(data, 7,6,1,0,3,2,5,4); // Not 100% on this one
break;
case 0x07:
- data = BITSWAP8(data, 2,0,3,1,5,4,7,6); // 5 and 7 unconfirmed
+ data = bitswap<8>(data, 2,0,3,1,5,4,7,6); // 5 and 7 unconfirmed
break;
case 0x0b:
- data = BITSWAP8(data, 2,3,0,1,6,7,4,5); // 5 and 6 unconfirmed
+ data = bitswap<8>(data, 2,3,0,1,6,7,4,5); // 5 and 6 unconfirmed
break;
}
m_latch_bank2 = (m_latch_bank2 & 0x100) | data;
diff --git a/src/devices/bus/msx_cart/dooly.cpp b/src/devices/bus/msx_cart/dooly.cpp
index 389e0c3da77..d1d3ad9ff39 100644
--- a/src/devices/bus/msx_cart/dooly.cpp
+++ b/src/devices/bus/msx_cart/dooly.cpp
@@ -45,7 +45,7 @@ READ8_MEMBER(msx_cart_dooly_device::read_cart)
switch (m_prot)
{
case 0x04:
- data = BITSWAP8(data, 7, 6, 5, 4, 3, 1, 0, 2);
+ data = bitswap<8>(data, 7, 6, 5, 4, 3, 1, 0, 2);
break;
}
return data;
diff --git a/src/devices/bus/neogeo/boot_kof10th.cpp b/src/devices/bus/neogeo/boot_kof10th.cpp
index 6f31cf6717a..167692f986d 100644
--- a/src/devices/bus/neogeo/boot_kof10th.cpp
+++ b/src/devices/bus/neogeo/boot_kof10th.cpp
@@ -102,7 +102,7 @@ WRITE16_MEMBER(neogeo_kof10th_cart_device::protection_w)
if (!m_cart_ram[0xffe])
COMBINE_DATA(&m_cart_ram2[(0x00000/2) + (offset & 0xffff)]); // Write to RAM bank A
else
- m_fixed[offset] = BITSWAP8(data, 7,6,0,4,3,2,1,5); // Write S data on-the-fly
+ m_fixed[offset] = bitswap<8>(data, 7,6,0,4,3,2,1,5); // Write S data on-the-fly
}
else if (offset >= 0xfe000/2)
{
diff --git a/src/devices/bus/neogeo/prot_cmc.cpp b/src/devices/bus/neogeo/prot_cmc.cpp
index 336bb543a21..77591827f54 100644
--- a/src/devices/bus/neogeo/prot_cmc.cpp
+++ b/src/devices/bus/neogeo/prot_cmc.cpp
@@ -689,15 +689,15 @@ int cmc_prot_device::m1_address_scramble(int address, uint16_t key)
int block = (address >> 16) & 7;
int aux = address & 0xffff;
- aux ^= BITSWAP16(key,12,0,2,4,8,15,7,13,10,1,3,6,11,9,14,5);
- aux = BITSWAP16(aux,
+ aux ^= bitswap<16>(key,12,0,2,4,8,15,7,13,10,1,3,6,11,9,14,5);
+ aux = bitswap<16>(aux,
p1[block][15], p1[block][14], p1[block][13], p1[block][12],
p1[block][11], p1[block][10], p1[block][9], p1[block][8],
p1[block][7], p1[block][6], p1[block][5], p1[block][4],
p1[block][3], p1[block][2], p1[block][1], p1[block][0]);
aux ^= m1_address_0_7_xor[(aux >> 8) & 0xff];
aux ^= m1_address_8_15_xor[aux & 0xff] << 8;
- aux = BITSWAP16(aux, 7,15,14,6,5,13,12,4,11,3,10,2,9,1,8,0);
+ aux = bitswap<16>(aux, 7,15,14,6,5,13,12,4,11,3,10,2,9,1,8,0);
return (block << 16) | aux;
}
diff --git a/src/devices/bus/neogeo/prot_cthd.cpp b/src/devices/bus/neogeo/prot_cthd.cpp
index dd641e64537..d2c427d6ac7 100644
--- a/src/devices/bus/neogeo/prot_cthd.cpp
+++ b/src/devices/bus/neogeo/prot_cthd.cpp
@@ -189,7 +189,7 @@ void cthd_prot_device::ct2k3sp_sx_decrypt( uint8_t* fixedrom, uint32_t fixedrom_
for (int i = 0; i < rom_size; i++)
{
- int ofst = BITSWAP24((i & 0x1ffff), 23, 22, 21, 20, 19, 18, 17, 3,
+ int ofst = bitswap<24>((i & 0x1ffff), 23, 22, 21, 20, 19, 18, 17, 3,
0, 1, 4, 2, 13, 14, 16, 15,
5, 6, 11, 10, 9, 8, 7, 12 );
ofst += (i >> 17) << 17;
@@ -275,7 +275,7 @@ void cthd_prot_device::patch_ct2k3sa(uint8_t* cpurom, uint32_t cpurom_size)
/* Matrimelee / Shin Gouketsuji Ichizoku Toukon (bootleg) */
-#define MATRIMBLZ80(i) (i ^ (BITSWAP8(i & 0x3,4,3,1,2,0,7,6,5) << 8))
+#define MATRIMBLZ80(i) (i ^ (bitswap<8>(i & 0x3,4,3,1,2,0,7,6,5) << 8))
void cthd_prot_device::matrimbl_decrypt(uint8_t* sprrom, uint32_t sprrom_size, uint8_t* audiorom, uint32_t audiorom_size)
{
diff --git a/src/devices/bus/neogeo/prot_kof2k3bl.cpp b/src/devices/bus/neogeo/prot_kof2k3bl.cpp
index 5afe9a0e548..456f164c042 100644
--- a/src/devices/bus/neogeo/prot_kof2k3bl.cpp
+++ b/src/devices/bus/neogeo/prot_kof2k3bl.cpp
@@ -102,7 +102,7 @@ void kof2k3bl_prot_device::pl_px_decrypt(uint8_t* cpurom, uint32_t cpurom_size)
{
memcpy(&tmp[0], &rom16[i], 0x100000);
for (int j = 0; j < 0x100000/2; j++)
- rom16[i+j] = tmp[BITSWAP24(j,23,22,21,20,19,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18)];
+ rom16[i+j] = tmp[bitswap<24>(j,23,22,21,20,19,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18)];
}
/* patched by Altera protection chip on PCB */
@@ -124,7 +124,7 @@ void kof2k3bl_prot_device::upl_px_decrypt(uint8_t* cpurom, uint32_t cpurom_size)
uint8_t *buf = cpurom + 0xd0610;
for (int i = 0; i < 0x2000 / 2; i++)
{
- int ofst = (i & 0xff00) + BITSWAP8((i & 0x00ff), 7, 6, 0, 4, 3, 2, 1, 5);
+ int ofst = (i & 0xff00) + bitswap<8>((i & 0x00ff), 7, 6, 0, 4, 3, 2, 1, 5);
memcpy(&rom[i * 2], &buf[ofst * 2], 2);
}
diff --git a/src/devices/bus/neogeo/prot_misc.cpp b/src/devices/bus/neogeo/prot_misc.cpp
index 54b9c5b8792..47150bbabee 100644
--- a/src/devices/bus/neogeo/prot_misc.cpp
+++ b/src/devices/bus/neogeo/prot_misc.cpp
@@ -77,7 +77,7 @@ void neoboot_prot_device::sx_decrypt(uint8_t* fixed, uint32_t fixed_size, int va
else if (value == 2)
{
for (int i = 0; i < sx_size; i++)
- rom[i] = BITSWAP8(rom[i], 7, 6, 0, 4, 3, 2, 1, 5);
+ rom[i] = bitswap<8>(rom[i], 7, 6, 0, 4, 3, 2, 1, 5);
}
}
@@ -139,7 +139,7 @@ void neoboot_prot_device::kf2k5uni_px_decrypt(uint8_t* cpurom, uint32_t cpurom_s
{
for (int j = 0; j < 0x80; j += 2)
{
- int ofst = BITSWAP8(j, 0, 3, 4, 5, 6, 1, 2, 7);
+ int ofst = bitswap<8>(j, 0, 3, 4, 5, 6, 1, 2, 7);
memcpy(&dst[j], src + i + ofst, 2);
}
memcpy(src + i, &dst[0], 0x80);
@@ -154,7 +154,7 @@ void neoboot_prot_device::kf2k5uni_sx_decrypt(uint8_t* fixedrom, uint32_t fixedr
uint8_t *srom = fixedrom;
for (int i = 0; i < 0x20000; i++)
- srom[i] = BITSWAP8(srom[i], 4, 5, 6, 7, 0, 1, 2, 3);
+ srom[i] = bitswap<8>(srom[i], 4, 5, 6, 7, 0, 1, 2, 3);
}
void neoboot_prot_device::kf2k5uni_mx_decrypt(uint8_t* audiorom, uint32_t audiorom_size)
@@ -162,7 +162,7 @@ void neoboot_prot_device::kf2k5uni_mx_decrypt(uint8_t* audiorom, uint32_t audior
uint8_t *mrom = audiorom;
for (int i = 0; i < 0x30000; i++)
- mrom[i] = BITSWAP8(mrom[i], 4, 5, 6, 7, 0, 1, 2, 3);
+ mrom[i] = bitswap<8>(mrom[i], 4, 5, 6, 7, 0, 1, 2, 3);
}
@@ -187,7 +187,7 @@ void neoboot_prot_device::lans2004_vx_decrypt(uint8_t* ymsndrom, uint32_t ymsndr
{
uint8_t *rom = ymsndrom;
for (int i = 0; i < 0xA00000; i++)
- rom[i] = BITSWAP8(rom[i], 0, 1, 5, 4, 3, 2, 6, 7);
+ rom[i] = bitswap<8>(rom[i], 0, 1, 5, 4, 3, 2, 6, 7);
}
void neoboot_prot_device::lans2004_decrypt_68k(uint8_t* cpurom, uint32_t cpurom_size)
@@ -239,7 +239,7 @@ void neoboot_prot_device::samsho5b_px_decrypt(uint8_t* cpurom, uint32_t cpurom_s
for (int i = 0; i < px_size / 2; i++)
{
- int ofst = BITSWAP8((i & 0x000ff), 7, 6, 5, 4, 3, 0, 1, 2);
+ int ofst = bitswap<8>((i & 0x000ff), 7, 6, 5, 4, 3, 0, 1, 2);
ofst += (i & 0xfffff00);
ofst ^= 0x060005;
@@ -259,7 +259,7 @@ void neoboot_prot_device::samsho5b_vx_decrypt(uint8_t* ymsndrom, uint32_t ymsndr
uint8_t *rom = ymsndrom;
for (int i = 0; i < vx_size; i++)
- rom[i] = BITSWAP8(rom[i], 0, 1, 5, 4, 3, 2, 6, 7);
+ rom[i] = bitswap<8>(rom[i], 0, 1, 5, 4, 3, 2, 6, 7);
}
@@ -381,7 +381,7 @@ void neoboot_prot_device::svcboot_px_decrypt(uint8_t* cpurom, uint32_t cpurom_si
for (int i = 0; i < size / 2; i++)
{
- int ofst = BITSWAP8((i & 0x0000ff), 7, 6, 1, 0, 3, 2, 5, 4);
+ int ofst = bitswap<8>((i & 0x0000ff), 7, 6, 1, 0, 3, 2, 5, 4);
ofst += (i & 0xffff00);
memcpy(&src[i * 2], &dst[ofst * 2], 0x02);
}
@@ -410,7 +410,7 @@ void neoboot_prot_device::svcboot_cx_decrypt(uint8_t* sprrom, uint32_t sprrom_si
int bit1 = bitswap4_tbl[idx][1];
int bit2 = bitswap4_tbl[idx][2];
int bit3 = bitswap4_tbl[idx][3];
- int ofst = BITSWAP8((i & 0x0000ff), 7, 6, 5, 4, bit3, bit2, bit1, bit0);
+ int ofst = bitswap<8>((i & 0x0000ff), 7, 6, 5, 4, bit3, bit2, bit1, bit0);
ofst += (i & 0xfffff00);
memcpy(&src[i * 0x80], &dst[ofst * 0x80], 0x80);
}
@@ -429,7 +429,7 @@ void neoboot_prot_device::svcplus_px_decrypt(uint8_t* cpurom, uint32_t cpurom_si
memcpy(&dst[0], src, size);
for (int i = 0; i < size / 2; i++)
{
- int ofst = BITSWAP24((i & 0xfffff), 0x17, 0x16, 0x15, 0x14, 0x13, 0x00, 0x01, 0x02,
+ int ofst = bitswap<24>((i & 0xfffff), 0x17, 0x16, 0x15, 0x14, 0x13, 0x00, 0x01, 0x02,
0x0f, 0x0e, 0x0d, 0x0c, 0x0b, 0x0a, 0x09, 0x08,
0x07, 0x06, 0x05, 0x04, 0x03, 0x10, 0x11, 0x12);
ofst ^= 0x0f0007;
@@ -478,7 +478,7 @@ void neoboot_prot_device::svcsplus_px_decrypt(uint8_t* cpurom, uint32_t cpurom_s
memcpy(&dst[0], src, size);
for (int i = 0; i < size / 2; i++)
{
- int ofst = BITSWAP16((i & 0x007fff), 0x0f, 0x00, 0x08, 0x09, 0x0b, 0x0a, 0x0c, 0x0d,
+ int ofst = bitswap<16>((i & 0x007fff), 0x0f, 0x00, 0x08, 0x09, 0x0b, 0x0a, 0x0c, 0x0d,
0x04, 0x03, 0x01, 0x07, 0x06, 0x02, 0x05, 0x0e);
ofst += (i & 0x078000);
@@ -524,7 +524,7 @@ void neoboot_prot_device::kof2002b_gfx_decrypt(uint8_t *src, int size)
for (int j = 0; j < 0x200; j++)
{
int n = (j & 0x38) >> 3;
- int ofst = BITSWAP16(j, 15, 14, 13, 12, 11, 10, 9, t[n][0], t[n][1], t[n][2], 5, 4, 3, t[n][3], t[n][4], t[n][5]);
+ int ofst = bitswap<16>(j, 15, 14, 13, 12, 11, 10, 9, t[n][0], t[n][1], t[n][2], 5, 4, 3, t[n][3], t[n][4], t[n][5]);
memcpy(src + i + ofst * 128, &dst[j * 128], 128);
}
}
@@ -544,7 +544,7 @@ void neoboot_prot_device::kf2k2mp_decrypt(uint8_t* cpurom, uint32_t cpurom_size)
{
for (int j = 0; j < 0x80 / 2; j++)
{
- int ofst = BITSWAP8( j, 6, 7, 2, 3, 4, 5, 0, 1 );
+ int ofst = bitswap<8>( j, 6, 7, 2, 3, 4, 5, 0, 1 );
memcpy(dst + j * 2, src + i + ofst * 2, 2);
}
memcpy(src + i, dst, 0x80);
@@ -580,7 +580,7 @@ void neoboot_prot_device::kof10th_decrypt(uint8_t* cpurom, uint32_t cpurom_size)
for (int i = 0; i < 0x900000; i++)
{
- int j = BITSWAP24(i,23,22,21,20,19,18,17,16,15,14,13,12,11,2,9,8,7,1,5,4,3,10,6,0);
+ int j = bitswap<24>(i,23,22,21,20,19,18,17,16,15,14,13,12,11,2,9,8,7,1,5,4,3,10,6,0);
src[j] = dst[i];
}
diff --git a/src/devices/bus/neogeo/prot_pcm2.cpp b/src/devices/bus/neogeo/prot_pcm2.cpp
index 80fa21eafe0..82f3175eb8b 100644
--- a/src/devices/bus/neogeo/prot_pcm2.cpp
+++ b/src/devices/bus/neogeo/prot_pcm2.cpp
@@ -82,7 +82,7 @@ void pcm2_prot_device::swap(uint8_t* ymrom, uint32_t ymsize, int value)
for (int i = 0; i < 0x1000000; i++)
{
- j = BITSWAP24(i,23,22,21,20,19,18,17,0,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,16);
+ j = bitswap<24>(i,23,22,21,20,19,18,17,0,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,16);
j ^= addrs[value][1];
d = ((i + addrs[value][0]) & 0xffffff);
src[j] = buf[d] ^ xordata[value][j & 0x7];
diff --git a/src/devices/bus/neogeo/prot_pvc.cpp b/src/devices/bus/neogeo/prot_pvc.cpp
index 99c70142222..8e290596576 100644
--- a/src/devices/bus/neogeo/prot_pvc.cpp
+++ b/src/devices/bus/neogeo/prot_pvc.cpp
@@ -112,7 +112,7 @@ void pvc_prot_device::mslug5_decrypt_68k(uint8_t* rom, uint32_t size)
for (int i = 0x100000; i < 0x0800000; i += 4)
{
uint16_t rom16 = rom[BYTE_XOR_LE(i+1)] | rom[BYTE_XOR_LE(i+2)] << 8;
- rom16 = BITSWAP16(rom16, 15, 14, 13, 12, 10, 11, 8, 9, 6, 7, 4, 5, 3, 2, 1, 0);
+ rom16 = bitswap<16>(rom16, 15, 14, 13, 12, 10, 11, 8, 9, 6, 7, 4, 5, 3, 2, 1, 0);
rom[BYTE_XOR_LE(i+1)] = rom16 & 0xff;
rom[BYTE_XOR_LE(i+2)] = rom16 >> 8;
}
@@ -120,12 +120,12 @@ void pvc_prot_device::mslug5_decrypt_68k(uint8_t* rom, uint32_t size)
memcpy(&buf[0], rom, rom_size);
for (int i = 0; i < 0x0100000 / 0x10000; i++)
{
- int ofst = (i & 0xf0) + BITSWAP8((i & 0x0f), 7, 6, 5, 4, 1, 0, 3, 2);
+ int ofst = (i & 0xf0) + bitswap<8>((i & 0x0f), 7, 6, 5, 4, 1, 0, 3, 2);
memcpy(&rom[i * 0x10000], &buf[ofst * 0x10000], 0x10000);
}
for (int i = 0x100000; i < 0x800000; i += 0x100)
{
- int ofst = (i & 0xf000ff) + ((i & 0x000f00) ^ 0x00700) + (BITSWAP8(((i & 0x0ff000) >> 12), 5, 4, 7, 6, 1, 0, 3, 2) << 12);
+ int ofst = (i & 0xf000ff) + ((i & 0x000f00) ^ 0x00700) + (bitswap<8>(((i & 0x0ff000) >> 12), 5, 4, 7, 6, 1, 0, 3, 2) << 12);
memcpy(&rom[i], &buf[ofst], 0x100);
}
@@ -151,7 +151,7 @@ void pvc_prot_device::svc_px_decrypt(uint8_t* rom, uint32_t size)
for (int i = 0x100000; i < 0x0800000; i += 4)
{
uint16_t rom16 = rom[BYTE_XOR_LE(i+1)] | rom[BYTE_XOR_LE(i+2)] << 8;
- rom16 = BITSWAP16(rom16, 15, 14, 13, 12, 10, 11, 8, 9, 6, 7, 4, 5, 3, 2, 1, 0);
+ rom16 = bitswap<16>(rom16, 15, 14, 13, 12, 10, 11, 8, 9, 6, 7, 4, 5, 3, 2, 1, 0);
rom[BYTE_XOR_LE(i+1)] = rom16 & 0xff;
rom[BYTE_XOR_LE(i+2)] = rom16 >> 8;
}
@@ -159,13 +159,13 @@ void pvc_prot_device::svc_px_decrypt(uint8_t* rom, uint32_t size)
memcpy(&buf[0], rom, rom_size);
for (int i = 0; i < 0x0100000 / 0x10000; i++)
{
- int ofst = (i & 0xf0) + BITSWAP8((i & 0x0f), 7, 6, 5, 4, 2, 3, 0, 1);
+ int ofst = (i & 0xf0) + bitswap<8>((i & 0x0f), 7, 6, 5, 4, 2, 3, 0, 1);
memcpy(&rom[i * 0x10000], &buf[ofst * 0x10000], 0x10000);
}
for (int i = 0x100000; i < 0x800000; i += 0x100)
{
- int ofst = (i & 0xf000ff) + ((i & 0x000f00) ^ 0x00a00) + (BITSWAP8(((i & 0x0ff000) >> 12), 4, 5, 6, 7, 1, 0, 3, 2) << 12);
+ int ofst = (i & 0xf000ff) + ((i & 0x000f00) ^ 0x00a00) + (bitswap<8>(((i & 0x0ff000) >> 12), 4, 5, 6, 7, 1, 0, 3, 2) << 12);
memcpy(&rom[i], &buf[ofst], 0x100);
}
memcpy(&buf[0], rom, rom_size );
@@ -189,20 +189,20 @@ void pvc_prot_device::kf2k3pcb_decrypt_68k(uint8_t* rom, uint32_t size)
for (int i = 0x100000; i < 0x800000; i += 4)
{
uint16_t rom16 = rom[BYTE_XOR_LE(i+1)] | rom[BYTE_XOR_LE(i+2)] << 8;
- rom16 = BITSWAP16(rom16, 15, 14, 13, 12, 4, 5, 6, 7, 8, 9, 10, 11, 3, 2, 1, 0);
+ rom16 = bitswap<16>(rom16, 15, 14, 13, 12, 4, 5, 6, 7, 8, 9, 10, 11, 3, 2, 1, 0);
rom[BYTE_XOR_LE(i+1)] = rom16 & 0xff;
rom[BYTE_XOR_LE(i+2)] = rom16 >> 8;
}
for (int i = 0; i < 0x0100000 / 0x10000; i++)
{
- int ofst = (i & 0xf0) + BITSWAP8((i & 0x0f), 7, 6, 5, 4, 1, 0, 3, 2);
+ int ofst = (i & 0xf0) + bitswap<8>((i & 0x0f), 7, 6, 5, 4, 1, 0, 3, 2);
memcpy(&buf[i * 0x10000], &rom[ofst * 0x10000], 0x10000);
}
for (int i = 0x100000; i < 0x900000; i += 0x100)
{
- int ofst = (i & 0xf000ff) + ((i & 0x000f00) ^ 0x00300) + (BITSWAP8(((i & 0x0ff000) >> 12), 4, 5, 6, 7, 1, 0, 3, 2) << 12);
+ int ofst = (i & 0xf000ff) + ((i & 0x000f00) ^ 0x00300) + (bitswap<8>(((i & 0x0ff000) >> 12), 4, 5, 6, 7, 1, 0, 3, 2) << 12);
memcpy(&buf[i], &rom[ofst], 0x100);
}
memcpy(&rom[0x000000], &buf[0x000000], 0x100000);
@@ -230,20 +230,20 @@ void pvc_prot_device::kof2003_decrypt_68k(uint8_t* rom, uint32_t size)
for (int i = 0x100000; i < 0x800000; i += 4)
{
uint16_t rom16 = rom[BYTE_XOR_LE(i+1)] | rom[BYTE_XOR_LE(i+2)] << 8;
- rom16 = BITSWAP16(rom16, 15, 14, 13, 12, 5, 4, 7, 6, 9, 8, 11, 10, 3, 2, 1, 0);
+ rom16 = bitswap<16>(rom16, 15, 14, 13, 12, 5, 4, 7, 6, 9, 8, 11, 10, 3, 2, 1, 0);
rom[BYTE_XOR_LE(i+1)] = rom16 & 0xff;
rom[BYTE_XOR_LE(i+2)] = rom16 >> 8;
}
for (int i = 0; i < 0x0100000 / 0x10000; i++)
{
- int ofst = (i & 0xf0) + BITSWAP8((i & 0x0f), 7, 6, 5, 4, 0, 1, 2, 3);
+ int ofst = (i & 0xf0) + bitswap<8>((i & 0x0f), 7, 6, 5, 4, 0, 1, 2, 3);
memcpy(&buf[i * 0x10000], &rom[ofst * 0x10000], 0x10000);
}
for (int i = 0x100000; i < 0x900000; i += 0x100)
{
- int ofst = (i & 0xf000ff) + ((i & 0x000f00) ^ 0x00800) + (BITSWAP8(((i & 0x0ff000) >> 12), 4, 5, 6, 7, 1, 0, 3, 2) << 12);
+ int ofst = (i & 0xf000ff) + ((i & 0x000f00) ^ 0x00800) + (bitswap<8>(((i & 0x0ff000) >> 12), 4, 5, 6, 7, 1, 0, 3, 2) << 12);
memcpy(&buf[i], &rom[ofst], 0x100);
}
memcpy(&rom[0x000000], &buf[0x000000], 0x100000);
@@ -271,19 +271,19 @@ void pvc_prot_device::kof2003h_decrypt_68k(uint8_t* rom, uint32_t size)
for (int i = 0x100000; i < 0x800000; i += 4)
{
uint16_t rom16 = rom[BYTE_XOR_LE(i+1)] | rom[BYTE_XOR_LE(i+2)] << 8;
- rom16 = BITSWAP16(rom16, 15, 14, 13, 12, 10, 11, 8, 9, 6, 7, 4, 5, 3, 2, 1, 0);
+ rom16 = bitswap<16>(rom16, 15, 14, 13, 12, 10, 11, 8, 9, 6, 7, 4, 5, 3, 2, 1, 0);
rom[BYTE_XOR_LE(i+1)] = rom16 & 0xff;
rom[BYTE_XOR_LE(i+2)] = rom16 >> 8;
}
for (int i = 0; i < 0x0100000 / 0x10000; i++)
{
- int ofst = (i & 0xf0) + BITSWAP8((i & 0x0f), 7, 6, 5, 4, 1, 0, 3, 2);
+ int ofst = (i & 0xf0) + bitswap<8>((i & 0x0f), 7, 6, 5, 4, 1, 0, 3, 2);
memcpy(&buf[i * 0x10000], &rom[ofst * 0x10000], 0x10000);
}
for (int i = 0x100000; i < 0x900000; i += 0x100)
{
- int ofst = (i & 0xf000ff) + ((i & 0x000f00) ^ 0x00400) + (BITSWAP8(((i & 0x0ff000) >> 12), 6, 7, 4, 5, 0, 1, 2, 3) << 12);
+ int ofst = (i & 0xf000ff) + ((i & 0x000f00) ^ 0x00400) + (bitswap<8>(((i & 0x0ff000) >> 12), 6, 7, 4, 5, 0, 1, 2, 3) << 12);
memcpy(&buf[i], &rom[ofst], 0x100);
}
memcpy(&rom[0x000000], &buf[0x000000], 0x100000);
diff --git a/src/devices/bus/neogeo/prot_sma.cpp b/src/devices/bus/neogeo/prot_sma.cpp
index 1b6e2322cd9..bfd15ab208a 100644
--- a/src/devices/bus/neogeo/prot_sma.cpp
+++ b/src/devices/bus/neogeo/prot_sma.cpp
@@ -398,7 +398,7 @@ void sma_prot_device::kof99_decrypt_68k(uint8_t* base)
// swap data lines on the whole ROMs
for (int i = 0; i < 0x800000/2; i++)
- rom[i] = BITSWAP16(rom[i],13,7,3,0,9,4,5,6,1,12,8,14,10,11,2,15);
+ rom[i] = bitswap<16>(rom[i],13,7,3,0,9,4,5,6,1,12,8,14,10,11,2,15);
// swap address lines for the banked part
for (int i = 0; i < 0x600000/2; i += 0x800/2)
@@ -406,13 +406,13 @@ void sma_prot_device::kof99_decrypt_68k(uint8_t* base)
uint16_t buffer[0x800/2];
memcpy(buffer, &rom[i], 0x800);
for (int j = 0; j < 0x800/2; j++)
- rom[i+j] = buffer[BITSWAP24(j,23,22,21,20,19,18,17,16,15,14,13,12,11,10,6,2,4,9,8,3,1,7,0,5)];
+ rom[i+j] = buffer[bitswap<24>(j,23,22,21,20,19,18,17,16,15,14,13,12,11,10,6,2,4,9,8,3,1,7,0,5)];
}
// swap address lines & relocate fixed part
rom = (uint16_t *)base;
for (int i = 0; i < 0x0c0000/2; i++)
- rom[i] = rom[0x700000/2 + BITSWAP24(i,23,22,21,20,19,18,11,6,14,17,16,5,8,10,12,0,4,3,2,7,9,15,13,1)];
+ rom[i] = rom[0x700000/2 + bitswap<24>(i,23,22,21,20,19,18,11,6,14,17,16,5,8,10,12,0,4,3,2,7,9,15,13,1)];
}
@@ -423,12 +423,12 @@ void sma_prot_device::garou_decrypt_68k(uint8_t* base)
// swap data lines on the whole ROMs
for (int i = 0; i < 0x800000/2; i++)
- rom[i] = BITSWAP16(rom[i],13,12,14,10,8,2,3,1,5,9,11,4,15,0,6,7);
+ rom[i] = bitswap<16>(rom[i],13,12,14,10,8,2,3,1,5,9,11,4,15,0,6,7);
// swap address lines & relocate fixed part
rom = (uint16_t *)base;
for (int i = 0; i < 0x0c0000/2; i++)
- rom[i] = rom[0x710000/2 + BITSWAP24(i,23,22,21,20,19,18,4,5,16,14,7,9,6,13,17,15,3,1,2,12,11,8,10,0)];
+ rom[i] = rom[0x710000/2 + bitswap<24>(i,23,22,21,20,19,18,4,5,16,14,7,9,6,13,17,15,3,1,2,12,11,8,10,0)];
// swap address lines for the banked part
rom = (uint16_t *)(base + 0x100000);
@@ -437,7 +437,7 @@ void sma_prot_device::garou_decrypt_68k(uint8_t* base)
uint16_t buffer[0x8000/2];
memcpy(buffer, &rom[i], 0x8000);
for (int j = 0; j < 0x8000/2; j++)
- rom[i+j] = buffer[BITSWAP24(j,23,22,21,20,19,18,17,16,15,14,9,4,8,3,13,6,2,7,0,12,1,11,10,5)];
+ rom[i+j] = buffer[bitswap<24>(j,23,22,21,20,19,18,17,16,15,14,9,4,8,3,13,6,2,7,0,12,1,11,10,5)];
}
}
@@ -449,12 +449,12 @@ void sma_prot_device::garouh_decrypt_68k(uint8_t* base)
// swap data lines on the whole ROMs
for (int i = 0; i < 0x800000/2; i++)
- rom[i] = BITSWAP16(rom[i],14,5,1,11,7,4,10,15,3,12,8,13,0,2,9,6);
+ rom[i] = bitswap<16>(rom[i],14,5,1,11,7,4,10,15,3,12,8,13,0,2,9,6);
// swap address lines & relocate fixed part
rom = (uint16_t *)base;
for (int i = 0; i < 0x0c0000/2; i++)
- rom[i] = rom[0x7f8000/2 + BITSWAP24(i,23,22,21,20,19,18,5,16,11,2,6,7,17,3,12,8,14,4,0,9,1,10,15,13)];
+ rom[i] = rom[0x7f8000/2 + bitswap<24>(i,23,22,21,20,19,18,5,16,11,2,6,7,17,3,12,8,14,4,0,9,1,10,15,13)];
// swap address lines for the banked part
rom = (uint16_t *)(base + 0x100000);
@@ -463,7 +463,7 @@ void sma_prot_device::garouh_decrypt_68k(uint8_t* base)
uint16_t buffer[0x8000/2];
memcpy(buffer, &rom[i], 0x8000);
for (int j = 0; j < 0x8000/2; j++)
- rom[i+j] = buffer[BITSWAP24(j,23,22,21,20,19,18,17,16,15,14,12,8,1,7,11,3,13,10,6,9,5,4,0,2)];
+ rom[i+j] = buffer[bitswap<24>(j,23,22,21,20,19,18,17,16,15,14,12,8,1,7,11,3,13,10,6,9,5,4,0,2)];
}
}
@@ -475,12 +475,12 @@ void sma_prot_device::mslug3_decrypt_68k(uint8_t* base)
// swap data lines on the whole ROMs
for (int i = 0; i < 0x800000/2; i++)
- rom[i] = BITSWAP16(rom[i],4,11,14,3,1,13,0,7,2,8,12,15,10,9,5,6);
+ rom[i] = bitswap<16>(rom[i],4,11,14,3,1,13,0,7,2,8,12,15,10,9,5,6);
// swap address lines & relocate fixed part
rom = (uint16_t *)base;
for (int i = 0; i < 0x0c0000/2; i++)
- rom[i] = rom[0x5d0000/2 + BITSWAP24(i,23,22,21,20,19,18,15,2,1,13,3,0,9,6,16,4,11,5,7,12,17,14,10,8)];
+ rom[i] = rom[0x5d0000/2 + bitswap<24>(i,23,22,21,20,19,18,15,2,1,13,3,0,9,6,16,4,11,5,7,12,17,14,10,8)];
// swap address lines for the banked part
rom = (uint16_t *)(base + 0x100000);
@@ -489,7 +489,7 @@ void sma_prot_device::mslug3_decrypt_68k(uint8_t* base)
uint16_t buffer[0x10000/2];
memcpy(buffer, &rom[i], 0x10000);
for (int j = 0; j < 0x10000/2; j++)
- rom[i+j] = buffer[BITSWAP24(j,23,22,21,20,19,18,17,16,15,2,11,0,14,6,4,13,8,9,3,10,7,5,12,1)];
+ rom[i+j] = buffer[bitswap<24>(j,23,22,21,20,19,18,17,16,15,2,11,0,14,6,4,13,8,9,3,10,7,5,12,1)];
}
}
@@ -501,7 +501,7 @@ void sma_prot_device::kof2000_decrypt_68k(uint8_t* base)
// swap data lines on the whole ROMs
for (int i = 0; i < 0x800000/2; i++)
- rom[i] = BITSWAP16(rom[i],12,8,11,3,15,14,7,0,10,13,6,5,9,2,1,4);
+ rom[i] = bitswap<16>(rom[i],12,8,11,3,15,14,7,0,10,13,6,5,9,2,1,4);
// swap address lines for the banked part
for (int i = 0; i < 0x63a000/2; i += 0x800/2)
@@ -509,11 +509,11 @@ void sma_prot_device::kof2000_decrypt_68k(uint8_t* base)
uint16_t buffer[0x800/2];
memcpy(buffer, &rom[i], 0x800);
for (int j = 0; j < 0x800/2; j++)
- rom[i+j] = buffer[BITSWAP24(j,23,22,21,20,19,18,17,16,15,14,13,12,11,10,4,1,3,8,6,2,7,0,9,5)];
+ rom[i+j] = buffer[bitswap<24>(j,23,22,21,20,19,18,17,16,15,14,13,12,11,10,4,1,3,8,6,2,7,0,9,5)];
}
// swap address lines & relocate fixed part
rom = (uint16_t *)base;
for (int i = 0; i < 0x0c0000/2; i++)
- rom[i] = rom[0x73a000/2 + BITSWAP24(i,23,22,21,20,19,18,8,4,15,13,3,14,16,2,6,17,7,12,10,0,5,11,1,9)];
+ rom[i] = rom[0x73a000/2 + bitswap<24>(i,23,22,21,20,19,18,8,4,15,13,3,14,16,2,6,17,7,12,10,0,5,11,1,9)];
}
diff --git a/src/devices/bus/neogeo/sbp.cpp b/src/devices/bus/neogeo/sbp.cpp
index f5c25a2210a..6b6920cb5e8 100644
--- a/src/devices/bus/neogeo/sbp.cpp
+++ b/src/devices/bus/neogeo/sbp.cpp
@@ -36,7 +36,7 @@ READ16_MEMBER( neogeo_sbp_cart_device::protection_r )
{
uint16_t* rom = (get_rom_size()) ? get_rom_base() : get_region_rom_base();
uint16_t origdata = rom[offset + (0x200/2)];
- uint16_t data = BITSWAP16(origdata, 11,10,9,8,15,14,13,12,3,2,1,0,7,6,5,4);
+ uint16_t data = bitswap<16>(origdata, 11,10,9,8,15,14,13,12,3,2,1,0,7,6,5,4);
int realoffset = 0x200 + (offset * 2);
logerror("sbp_lowerrom_r offset %08x data %04x\n", realoffset, data);
diff --git a/src/devices/bus/nes/jy.cpp b/src/devices/bus/nes/jy.cpp
index 38a30848859..191892ef544 100644
--- a/src/devices/bus/nes/jy.cpp
+++ b/src/devices/bus/nes/jy.cpp
@@ -296,7 +296,7 @@ READ8_MEMBER(nes_jy_typea_device::read_m)
inline uint8_t nes_jy_typea_device::unscramble(uint8_t bank)
{
- return BITSWAP8(bank & 0x7f,7,0,1,2,3,4,5,6);
+ return bitswap<8>(bank & 0x7f,7,0,1,2,3,4,5,6);
}
void nes_jy_typea_device::update_prg()
diff --git a/src/devices/bus/nes/mmc3_clones.cpp b/src/devices/bus/nes/mmc3_clones.cpp
index 5d776c5d86c..5c578c0fcbd 100644
--- a/src/devices/bus/nes/mmc3_clones.cpp
+++ b/src/devices/bus/nes/mmc3_clones.cpp
@@ -2565,7 +2565,7 @@ void nes_a9746_device::pcb_reset()
void nes_a9746_device::update_banks(uint8_t value)
{
- uint8_t bank = BITSWAP8(value & 0x3c,7,6,0,1,2,3,4,5);
+ uint8_t bank = bitswap<8>(value & 0x3c,7,6,0,1,2,3,4,5);
switch (m_reg[0])
{
diff --git a/src/devices/bus/nes/waixing.cpp b/src/devices/bus/nes/waixing.cpp
index f4d9c338f48..7e95102c029 100644
--- a/src/devices/bus/nes/waixing.cpp
+++ b/src/devices/bus/nes/waixing.cpp
@@ -929,7 +929,7 @@ READ8_MEMBER(nes_waixing_sh2_device::chr_r)
void nes_waixing_sec_device::prg_cb(int start, int bank)
{
if (m_reg)
- bank = BITSWAP8(bank & 0x1f,7,6,5,2,1,3,4,0);
+ bank = bitswap<8>(bank & 0x1f,7,6,5,2,1,3,4,0);
prg8_x(start, bank);
}
@@ -937,7 +937,7 @@ void nes_waixing_sec_device::prg_cb(int start, int bank)
void nes_waixing_sec_device::chr_cb(int start, int bank, int source)
{
if (m_reg)
- bank = BITSWAP8(bank, 5,4,2,6,7,3,1,0);
+ bank = bitswap<8>(bank, 5,4,2,6,7,3,1,0);
chr1_x(start, bank, source);
}
diff --git a/src/devices/bus/nubus/nubus_spec8.cpp b/src/devices/bus/nubus/nubus_spec8.cpp
index a8289667de6..1cc905670a6 100644
--- a/src/devices/bus/nubus/nubus_spec8.cpp
+++ b/src/devices/bus/nubus/nubus_spec8.cpp
@@ -257,7 +257,7 @@ WRITE32_MEMBER( nubus_spec8s3_device::spec8s3_w )
if (m_count == 3)
{
- int actual_color = BITSWAP8(m_clutoffs, 0, 1, 2, 3, 4, 5, 6, 7);
+ int actual_color = bitswap<8>(m_clutoffs, 0, 1, 2, 3, 4, 5, 6, 7);
// printf("RAMDAC: color %d = %02x %02x %02x (PC=%x)\n", actual_color, m_colors[0], m_colors[1], m_colors[2], space.device().safe_pc() );
m_palette[actual_color] = rgb_t(m_colors[0], m_colors[1], m_colors[2]);
diff --git a/src/devices/bus/nubus/pds30_procolor816.cpp b/src/devices/bus/nubus/pds30_procolor816.cpp
index 366eb8eb1b3..869e91986c0 100644
--- a/src/devices/bus/nubus/pds30_procolor816.cpp
+++ b/src/devices/bus/nubus/pds30_procolor816.cpp
@@ -272,7 +272,7 @@ WRITE32_MEMBER( nubus_procolor816_device::procolor816_w )
if (mem_mask == 0x00ff0000)
{
// printf("%08x to DAC control (PC=%x)\n", data, space.device().safe_pc());
- m_clutoffs = BITSWAP8((data>>16)&0xff, 0, 1, 2, 3, 4, 5, 6, 7);
+ m_clutoffs = bitswap<8>((data>>16)&0xff, 0, 1, 2, 3, 4, 5, 6, 7);
}
else if (mem_mask == 0x000000ff)
{
diff --git a/src/devices/bus/s100/wunderbus.cpp b/src/devices/bus/s100/wunderbus.cpp
index e0eec1b3b4f..1bd7df7cb2a 100644
--- a/src/devices/bus/s100/wunderbus.cpp
+++ b/src/devices/bus/s100/wunderbus.cpp
@@ -345,7 +345,7 @@ uint8_t s100_wunderbus_device::s100_sinp_r(address_space &space, offs_t offset)
*/
- data = BITSWAP8(m_10a->read(),0,1,2,3,4,5,6,7) & 0xfc;
+ data = bitswap<8>(m_10a->read(),0,1,2,3,4,5,6,7) & 0xfc;
break;
case 2: // R.T. Clock IN/RESET CLK. Int.
diff --git a/src/devices/bus/saturn/sat_slot.cpp b/src/devices/bus/saturn/sat_slot.cpp
index 13f69c8ba92..defdd4d025b 100644
--- a/src/devices/bus/saturn/sat_slot.cpp
+++ b/src/devices/bus/saturn/sat_slot.cpp
@@ -156,7 +156,7 @@ image_init_result sat_cart_slot_device::call_load()
// fix endianness....
for (int i = 0; i < len/4; i ++)
- ROM[i] = BITSWAP32(ROM[i],7,6,5,4,3,2,1,0,15,14,13,12,11,10,9,8,23,22,21,20,19,18,17,16,31,30,29,28,27,26,25,24);
+ ROM[i] = bitswap<32>(ROM[i],7,6,5,4,3,2,1,0,15,14,13,12,11,10,9,8,23,22,21,20,19,18,17,16,31,30,29,28,27,26,25,24);
// {
// uint8_t tempa = ROM[i+0];
// uint8_t tempb = ROM[i+1];
diff --git a/src/devices/bus/sega8/rom.cpp b/src/devices/bus/sega8/rom.cpp
index 9006cc1f013..e3fa290489c 100644
--- a/src/devices/bus/sega8/rom.cpp
+++ b/src/devices/bus/sega8/rom.cpp
@@ -871,7 +871,7 @@ READ8_MEMBER(sega8_janggun_device::read_cart)
if (m_rom_bank_base[bank] < 0x80)
return m_rom[(m_rom_bank_base[bank] & 0x3f) * 0x2000 + (offset & 0x1fff)];
else
- return BITSWAP8(m_rom[(m_rom_bank_base[bank] & 0x3f) * 0x2000 + (offset & 0x1fff)], 0, 1, 2, 3, 4, 5, 6, 7);
+ return bitswap<8>(m_rom[(m_rom_bank_base[bank] & 0x3f) * 0x2000 + (offset & 0x1fff)], 0, 1, 2, 3, 4, 5, 6, 7);
}
diff --git a/src/devices/bus/snes/rom.cpp b/src/devices/bus/snes/rom.cpp
index 628ab1a212d..bae27f21fad 100644
--- a/src/devices/bus/snes/rom.cpp
+++ b/src/devices/bus/snes/rom.cpp
@@ -291,7 +291,7 @@ WRITE8_MEMBER( sns_rom_obc1_device::chip_write )
// Address range for read/write depends on the game (check snes.xml)
READ8_MEMBER( sns_rom_pokemon_device::chip_read )
{
- return BITSWAP8(m_latch,0,6,7,1,2,3,4,5);
+ return bitswap<8>(m_latch,0,6,7,1,2,3,4,5);
}
WRITE8_MEMBER( sns_rom_pokemon_device::chip_write )
@@ -488,7 +488,7 @@ WRITE8_MEMBER( sns_rom_20col_device::chip_write )
READ8_MEMBER( sns_rom_banana_device::chip_read )
{
- return BITSWAP8(m_latch[0xf],0,6,7,1,2,3,4,5);
+ return bitswap<8>(m_latch[0xf],0,6,7,1,2,3,4,5);
}
WRITE8_MEMBER( sns_rom_banana_device::chip_write )
@@ -499,7 +499,7 @@ WRITE8_MEMBER( sns_rom_banana_device::chip_write )
READ8_MEMBER( sns_rom_bugs_device::chip_read )
{
- return BITSWAP8(m_latch[offset & 0xff],0,6,7,1,2,3,4,5);
+ return bitswap<8>(m_latch[offset & 0xff],0,6,7,1,2,3,4,5);
}
WRITE8_MEMBER( sns_rom_bugs_device::chip_write )
diff --git a/src/devices/bus/snes_ctrl/pachinko.cpp b/src/devices/bus/snes_ctrl/pachinko.cpp
index 44d81066d83..010385e6459 100644
--- a/src/devices/bus/snes_ctrl/pachinko.cpp
+++ b/src/devices/bus/snes_ctrl/pachinko.cpp
@@ -83,7 +83,7 @@ void snes_pachinko_device::device_reset()
void snes_pachinko_device::port_poll()
{
- uint8_t dial = BITSWAP8(m_dial->read() ^ 0xff,7,6,5,4,3,2,1,0);
+ uint8_t dial = bitswap<8>(m_dial->read() ^ 0xff,7,6,5,4,3,2,1,0);
m_latch = m_button->read() | (dial << 25) | 0xee7000; // add ID
}
diff --git a/src/devices/bus/ss50/interface.cpp b/src/devices/bus/ss50/interface.cpp
index e5f2620b0a8..3d51f76ba53 100644
--- a/src/devices/bus/ss50/interface.cpp
+++ b/src/devices/bus/ss50/interface.cpp
@@ -79,7 +79,7 @@
#include "emu.h"
#include "bus/ss50/interface.h"
-//#include "bus/ss50/mpc.h"
+#include "bus/ss50/mpc.h"
//#include "bus/ss50/mpl.h"
//#include "bus/ss50/mpr.h"
#include "bus/ss50/mps.h"
@@ -214,7 +214,7 @@ ss50_card_interface::ss50_card_interface(const machine_config &mconfig, device_t
}
SLOT_INTERFACE_START(ss50_default_2rs_devices)
- //SLOT_INTERFACE("mpc", SS50_MPC)
+ SLOT_INTERFACE("mpc", SS50_MPC)
//SLOT_INTERFACE("mpl", SS50_MPL)
//SLOT_INTERFACE("mpn", SS50_MPN)
SLOT_INTERFACE("mps", SS50_MPS)
diff --git a/src/devices/bus/ss50/mpc.cpp b/src/devices/bus/ss50/mpc.cpp
new file mode 100644
index 00000000000..8a1ac577a5e
--- /dev/null
+++ b/src/devices/bus/ss50/mpc.cpp
@@ -0,0 +1,194 @@
+// license:BSD-3-Clause
+// copyright-holders:AJR
+/**********************************************************************
+
+ SWTPC MP-C Serial Control Interface
+
+**********************************************************************/
+
+#include "emu.h"
+#include "bus/ss50/mpc.h"
+#include "bus/ss50/interface.h"
+
+#include "bus/rs232/rs232.h"
+#include "machine/6821pia.h"
+#include "machine/input_merger.h"
+#include "machine/ripple_counter.h"
+
+//**************************************************************************
+// TYPE DEFINITIONS
+//**************************************************************************
+
+// ======================> ss50_mpc_device
+
+class ss50_mpc_device : public device_t, public ss50_card_interface
+{
+public:
+ // construction/destruction
+ ss50_mpc_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock)
+ : device_t(mconfig, SS50_MPC, tag, owner, clock),
+ ss50_card_interface(mconfig, *this),
+ m_pia(*this, "pia"),
+ m_loopback(*this, "loopback"),
+ m_counter(*this, "counter"),
+ m_baud_jumper(*this, "BAUD"),
+ m_count_select(false)
+ {
+ }
+
+protected:
+ // device-specific overrides
+ virtual ioport_constructor device_input_ports() const override;
+ virtual void device_add_mconfig(machine_config &config) override;
+ virtual void device_start() override;
+
+ // interface-specific overrides
+ virtual DECLARE_READ8_MEMBER(register_read) override;
+ virtual DECLARE_WRITE8_MEMBER(register_write) override;
+ virtual DECLARE_WRITE_LINE_MEMBER(f110_w) override;
+ virtual DECLARE_WRITE_LINE_MEMBER(f300_w) override;
+
+private:
+ DECLARE_WRITE_LINE_MEMBER(serial_input_w);
+ DECLARE_WRITE_LINE_MEMBER(reader_control_w);
+ DECLARE_READ_LINE_MEMBER(count_r);
+ DECLARE_WRITE_LINE_MEMBER(count_select_w);
+
+ required_device<pia6821_device> m_pia;
+ required_device<input_merger_device> m_loopback;
+ required_device<ripple_counter_device> m_counter;
+ required_ioport m_baud_jumper;
+
+ bool m_count_select;
+};
+
+
+static INPUT_PORTS_START( mpc )
+ PORT_START("BAUD")
+ PORT_DIPNAME(1, 0, "Baud Rate")
+ PORT_DIPSETTING(1, "110")
+ PORT_DIPSETTING(0, "300")
+
+ PORT_START("STOP")
+ PORT_DIPNAME(1, 0, "Stop Bits")
+ PORT_DIPSETTING(0, "1")
+ PORT_DIPSETTING(1, "2")
+INPUT_PORTS_END
+
+
+//-------------------------------------------------
+// input_ports - device-specific input ports
+//-------------------------------------------------
+
+ioport_constructor ss50_mpc_device::device_input_ports() const
+{
+ return INPUT_PORTS_NAME(mpc);
+}
+
+
+static DEVICE_INPUT_DEFAULTS_START( terminal )
+ DEVICE_INPUT_DEFAULTS("RS232_RXBAUD", 0xff, RS232_BAUD_300)
+ DEVICE_INPUT_DEFAULTS("RS232_TXBAUD", 0xff, RS232_BAUD_300)
+ DEVICE_INPUT_DEFAULTS("RS232_STARTBITS", 0xff, RS232_STARTBITS_1)
+ DEVICE_INPUT_DEFAULTS("RS232_DATABITS", 0xff, RS232_DATABITS_8)
+ DEVICE_INPUT_DEFAULTS("RS232_PARITY", 0xff, RS232_PARITY_NONE)
+ DEVICE_INPUT_DEFAULTS("RS232_STOPBITS", 0xff, RS232_STOPBITS_1)
+DEVICE_INPUT_DEFAULTS_END
+
+
+//-------------------------------------------------
+// device_add_mconfig - add device-specific
+// machine configuration
+//-------------------------------------------------
+
+MACHINE_CONFIG_MEMBER(ss50_mpc_device::device_add_mconfig)
+ MCFG_DEVICE_ADD("pia", PIA6821, 0) // actually MC6820
+ MCFG_PIA_WRITEPA_HANDLER(DEVWRITELINE("outgate", input_merger_device, in_w<0>)) MCFG_DEVCB_BIT(0)
+ MCFG_PIA_CB2_HANDLER(WRITELINE(ss50_mpc_device, reader_control_w))
+ MCFG_PIA_READPB_HANDLER(IOPORT("STOP")) MCFG_DEVCB_BIT(6)
+ MCFG_DEVCB_CHAIN_INPUT(READLINE(ss50_mpc_device, count_r)) MCFG_DEVCB_BIT(7)
+ MCFG_PIA_WRITEPB_HANDLER(WRITELINE(ss50_mpc_device, count_select_w)) MCFG_DEVCB_BIT(2)
+ MCFG_DEVCB_CHAIN_OUTPUT(DEVWRITELINE("counter", ripple_counter_device, reset_w)) MCFG_DEVCB_BIT(0)
+ //MCFG_PIA_IRQA_HANDLER(WRITELINE(ss50_mpc_device, pia_irq_w))
+ //MCFG_PIA_IRQB_HANDLER(WRITELINE(ss50_mpc_device, pia_irq_w))
+
+ MCFG_RS232_PORT_ADD("rs232", default_rs232_devices, "terminal")
+ MCFG_RS232_RXD_HANDLER(WRITELINE(ss50_mpc_device, serial_input_w))
+ MCFG_DEVICE_CARD_DEVICE_INPUT_DEFAULTS("terminal", terminal)
+
+ MCFG_INPUT_MERGER_ALL_HIGH("outgate")
+ MCFG_INPUT_MERGER_OUTPUT_HANDLER(DEVWRITELINE("rs232", rs232_port_device, write_txd))
+
+ MCFG_INPUT_MERGER_ANY_HIGH("loopback")
+ MCFG_INPUT_MERGER_OUTPUT_HANDLER(DEVWRITELINE("outgate", input_merger_device, in_w<1>))
+
+ MCFG_DEVICE_ADD("counter", RIPPLE_COUNTER, 0) // CD4024AE (IC3)
+ MCFG_RIPPLE_COUNTER_STAGES(7) // only Q5 (÷32) and Q4 (÷16) are actually used
+MACHINE_CONFIG_END
+
+
+//-------------------------------------------------
+// device_start - device-specific startup
+//-------------------------------------------------
+
+void ss50_mpc_device::device_start()
+{
+ save_item(NAME(m_count_select));
+}
+
+WRITE_LINE_MEMBER(ss50_mpc_device::serial_input_w)
+{
+ m_pia->set_a_input(state << 7, 0x7f);
+ m_loopback->in_w<0>(state);
+}
+
+
+WRITE_LINE_MEMBER(ss50_mpc_device::reader_control_w)
+{
+ m_loopback->in_w<1>(state);
+}
+
+READ_LINE_MEMBER(ss50_mpc_device::count_r)
+{
+ return BIT(m_counter->count(), m_count_select ? 4 : 3);
+}
+
+WRITE_LINE_MEMBER(ss50_mpc_device::count_select_w)
+{
+ m_count_select = bool(state);
+}
+
+
+//-------------------------------------------------
+// register_read - read from a port register
+//-------------------------------------------------
+
+READ8_MEMBER(ss50_mpc_device::register_read)
+{
+ return m_pia->read(space, offset & 3, 0);
+}
+
+//-------------------------------------------------
+// register_write - write to a port register
+//-------------------------------------------------
+
+WRITE8_MEMBER(ss50_mpc_device::register_write)
+{
+ m_pia->write(space, offset & 3, data);
+}
+
+WRITE_LINE_MEMBER(ss50_mpc_device::f110_w)
+{
+ if (m_baud_jumper->read())
+ m_counter->clock_w(state);
+}
+
+WRITE_LINE_MEMBER(ss50_mpc_device::f300_w)
+{
+ if (!m_baud_jumper->read())
+ m_counter->clock_w(state);
+}
+
+
+// device type definition
+DEFINE_DEVICE_TYPE(SS50_MPC, ss50_mpc_device, "ss50_mpc", "MP-C Serial Control Interface")
diff --git a/src/devices/bus/ss50/mpc.h b/src/devices/bus/ss50/mpc.h
new file mode 100644
index 00000000000..2e769932b0c
--- /dev/null
+++ b/src/devices/bus/ss50/mpc.h
@@ -0,0 +1,14 @@
+// license:BSD-3-Clause
+// copyright-holders:AJR
+/**********************************************************************
+
+ SWTPC MP-C Serial Control Interface
+
+**********************************************************************/
+
+#ifndef MAME_DEVICE_BUS_SS50_MPC_H
+#define MAME_DEVICE_BUS_SS50_MPC_H
+
+extern const device_type SS50_MPC;
+
+#endif // MAME_DEVICE_BUS_SS50_MPC_H
diff --git a/src/devices/bus/ti99x/990_hd.cpp b/src/devices/bus/ti99x/990_hd.cpp
index 0bb3b475086..9c2ce32ae51 100644
--- a/src/devices/bus/ti99x/990_hd.cpp
+++ b/src/devices/bus/ti99x/990_hd.cpp
@@ -241,7 +241,7 @@ DEVICE_IMAGE_LOAD_MEMBER( ti990_hdc_device, ti990_hd )
*/
DEVICE_IMAGE_UNLOAD_MEMBER( ti990_hdc_device, ti990_hd )
{
- int id = get_id_from_device( image );
+ int id = get_id_from_device(&image.device());
hd_unit_t *d;
d = &m_d[id];
diff --git a/src/devices/bus/vcs/dpc.cpp b/src/devices/bus/vcs/dpc.cpp
index f15e426fec7..bcddc3e96ae 100644
--- a/src/devices/bus/vcs/dpc.cpp
+++ b/src/devices/bus/vcs/dpc.cpp
@@ -160,10 +160,10 @@ READ8_MEMBER(dpc_device::read)
data = m_df[data_fetcher].flag ? display_data : 0x00;
break;
case 0x18: // display data AND'd w/flag, nibbles swapped
- data = m_df[data_fetcher].flag ? BITSWAP8(display_data,3,2,1,0,7,6,5,4) : 0x00;
+ data = m_df[data_fetcher].flag ? bitswap<8>(display_data,3,2,1,0,7,6,5,4) : 0x00;
break;
case 0x20: // display data AND'd w/flag, byte reversed
- data = m_df[data_fetcher].flag ? BITSWAP8(display_data,0,1,2,3,4,5,6,7) : 0x00;
+ data = m_df[data_fetcher].flag ? bitswap<8>(display_data,0,1,2,3,4,5,6,7) : 0x00;
break;
case 0x28: // display data AND'd w/flag, rotated right
data = m_df[data_fetcher].flag ? (display_data >> 1) : 0x00;
diff --git a/src/devices/bus/vic20/exp.cpp b/src/devices/bus/vic20/exp.cpp
index 535375536be..e70bda544bc 100644
--- a/src/devices/bus/vic20/exp.cpp
+++ b/src/devices/bus/vic20/exp.cpp
@@ -219,5 +219,6 @@ SLOT_INTERFACE_START( vic20_expansion_cards )
// the following need ROMs from the software list
SLOT_INTERFACE_INTERNAL("standard", VIC20_STD)
SLOT_INTERFACE_INTERNAL("ieee488", VIC1112)
+ MCFG_SLOT_OPTION_CLOCK("ieee488", DERIVED_CLOCK(1, 1))
SLOT_INTERFACE_INTERNAL("megacart", VIC20_MEGACART)
SLOT_INTERFACE_END
diff --git a/src/devices/bus/vic20/vic1112.cpp b/src/devices/bus/vic20/vic1112.cpp
index a38bf02eb7f..25e6b6d6804 100644
--- a/src/devices/bus/vic20/vic1112.cpp
+++ b/src/devices/bus/vic20/vic1112.cpp
@@ -98,12 +98,12 @@ WRITE_LINE_MEMBER( vic1112_device::via1_irq_w )
//-------------------------------------------------
MACHINE_CONFIG_MEMBER( vic1112_device::device_add_mconfig )
- MCFG_DEVICE_ADD(M6522_0_TAG, VIA6522, 0)
+ MCFG_DEVICE_ADD(M6522_0_TAG, VIA6522, DERIVED_CLOCK(1, 1))
MCFG_VIA6522_READPB_HANDLER(READ8(vic1112_device, via0_pb_r))
MCFG_VIA6522_WRITEPB_HANDLER(WRITE8(vic1112_device, via0_pb_w))
MCFG_VIA6522_IRQ_HANDLER(WRITELINE(vic1112_device, via0_irq_w))
- MCFG_DEVICE_ADD(M6522_1_TAG, VIA6522, 0)
+ MCFG_DEVICE_ADD(M6522_1_TAG, VIA6522, DERIVED_CLOCK(1, 1))
MCFG_VIA6522_READPB_HANDLER(DEVREAD8(IEEE488_TAG, ieee488_device, dio_r))
MCFG_VIA6522_WRITEPA_HANDLER(DEVWRITE8(IEEE488_TAG, ieee488_device, dio_w))
MCFG_VIA6522_CA2_HANDLER(DEVWRITELINE(IEEE488_TAG, ieee488_device, atn_w))