summaryrefslogtreecommitdiffstatshomepage
path: root/src/mame/machine
diff options
context:
space:
mode:
Diffstat (limited to 'src/mame/machine')
-rw-r--r--src/mame/machine/3dom2.cpp6
-rw-r--r--src/mame/machine/3dom2.h6
-rw-r--r--src/mame/machine/6883sam.cpp2
-rw-r--r--src/mame/machine/abc1600mac.cpp351
-rw-r--r--src/mame/machine/abc1600mac.h24
-rw-r--r--src/mame/machine/alpha8201.cpp8
-rw-r--r--src/mame/machine/amiga.cpp8
-rw-r--r--src/mame/machine/amstrad.cpp17
-rw-r--r--src/mame/machine/apexc.cpp6
-rw-r--r--src/mame/machine/apexc.h25
-rw-r--r--src/mame/machine/apollo.cpp6
-rw-r--r--src/mame/machine/apple2common.cpp13
-rw-r--r--src/mame/machine/archimedes_keyb.cpp152
-rw-r--r--src/mame/machine/archimedes_keyb.h22
-rw-r--r--src/mame/machine/asic65.cpp2
-rw-r--r--src/mame/machine/asic65.h2
-rw-r--r--src/mame/machine/atarigen.cpp10
-rw-r--r--src/mame/machine/atarigen.h2
-rw-r--r--src/mame/machine/atariscom.cpp2
-rw-r--r--src/mame/machine/atariscom.h2
-rw-r--r--src/mame/machine/badlands.cpp4
-rw-r--r--src/mame/machine/bbc.cpp6
-rw-r--r--src/mame/machine/bebox.cpp6
-rw-r--r--src/mame/machine/bingoct.cpp2
-rw-r--r--src/mame/machine/bublbobl.cpp2
-rw-r--r--src/mame/machine/cdicdic.cpp1843
-rw-r--r--src/mame/machine/cdicdic.h193
-rw-r--r--src/mame/machine/cdislavehle.cpp119
-rw-r--r--src/mame/machine/cdislavehle.h24
-rw-r--r--src/mame/machine/cmi_mkbd.cpp2
-rw-r--r--src/mame/machine/cmi_mkbd.h2
-rw-r--r--src/mame/machine/coco.cpp3
-rw-r--r--src/mame/machine/coco_vhd.h5
-rw-r--r--src/mame/machine/cuda.cpp6
-rw-r--r--src/mame/machine/cuda.h2
-rw-r--r--src/mame/machine/dc.cpp183
-rw-r--r--src/mame/machine/dc_g2if.cpp538
-rw-r--r--src/mame/machine/dc_g2if.h105
-rw-r--r--src/mame/machine/dccons.cpp113
-rw-r--r--src/mame/machine/dec0.cpp19
-rw-r--r--src/mame/machine/dec_lk201.cpp2
-rw-r--r--src/mame/machine/dec_lk201.h2
-rw-r--r--src/mame/machine/decopincpu.cpp2
-rw-r--r--src/mame/machine/decopincpu.h2
-rw-r--r--src/mame/machine/dgn_beta.cpp26
-rw-r--r--src/mame/machine/digilog320_kbd.cpp309
-rw-r--r--src/mame/machine/digilog320_kbd.h64
-rw-r--r--src/mame/machine/dmac_0266.cpp2
-rw-r--r--src/mame/machine/dmac_0266.h2
-rw-r--r--src/mame/machine/dmac_0448.cpp4
-rw-r--r--src/mame/machine/dmac_0448.h4
-rw-r--r--src/mame/machine/e22_kbd.cpp9
-rw-r--r--src/mame/machine/egret.cpp4
-rw-r--r--src/mame/machine/egret.h2
-rw-r--r--src/mame/machine/elan_eu3a05commonsys.cpp2
-rw-r--r--src/mame/machine/elan_eu3a05commonsys.h2
-rw-r--r--src/mame/machine/electron.cpp13
-rw-r--r--src/mame/machine/esqpanel.cpp3
-rw-r--r--src/mame/machine/esqpanel.h2
-rw-r--r--src/mame/machine/esqvfd.cpp2
-rw-r--r--src/mame/machine/esqvfd.h2
-rw-r--r--src/mame/machine/f5220_kbd.cpp300
-rw-r--r--src/mame/machine/f5220_kbd.h60
-rw-r--r--src/mame/machine/fidel_clockdiv.cpp2
-rw-r--r--src/mame/machine/fm_scsi.cpp2
-rw-r--r--src/mame/machine/fm_scsi.h2
-rw-r--r--src/mame/machine/fmt_icmem.cpp2
-rw-r--r--src/mame/machine/fmt_icmem.h10
-rw-r--r--src/mame/machine/gaelco3d.h1
-rw-r--r--src/mame/machine/gaelcrpt.cpp64
-rw-r--r--src/mame/machine/gaelcrpt.h36
-rw-r--r--src/mame/machine/gb.cpp25
-rw-r--r--src/mame/machine/gdrom.cpp154
-rw-r--r--src/mame/machine/hds200_kbd.cpp407
-rw-r--r--src/mame/machine/hds200_kbd.h66
-rw-r--r--src/mame/machine/hp2640_tape.cpp2
-rw-r--r--src/mame/machine/hp2640_tape.h2
-rw-r--r--src/mame/machine/hp48_port.h7
-rw-r--r--src/mame/machine/hp80_optrom.cpp2
-rw-r--r--src/mame/machine/hp80_optrom.h10
-rw-r--r--src/mame/machine/hp9825_optrom.cpp2
-rw-r--r--src/mame/machine/hp9825_optrom.h10
-rw-r--r--src/mame/machine/hp9845_optrom.cpp2
-rw-r--r--src/mame/machine/hp9845_optrom.h10
-rw-r--r--src/mame/machine/hp9845_printer.cpp2
-rw-r--r--src/mame/machine/hp9845_printer.h2
-rw-r--r--src/mame/machine/hp_ipc_optrom.cpp2
-rw-r--r--src/mame/machine/hp_ipc_optrom.h10
-rw-r--r--src/mame/machine/hpc3.cpp4
-rw-r--r--src/mame/machine/hpc3.h4
-rw-r--r--src/mame/machine/hyperscan_card.cpp9
-rw-r--r--src/mame/machine/hyperscan_card.h10
-rw-r--r--src/mame/machine/ibm6580_fdc.cpp2
-rw-r--r--src/mame/machine/ibm6580_fdc.h6
-rw-r--r--src/mame/machine/ibm6580_kbd.cpp103
-rw-r--r--src/mame/machine/ibm6580_kbd.h13
-rw-r--r--src/mame/machine/imm6_76.h6
-rw-r--r--src/mame/machine/intv.cpp4
-rw-r--r--src/mame/machine/iteagle_fpga.cpp4
-rw-r--r--src/mame/machine/iteagle_fpga.h2
-rw-r--r--src/mame/machine/jaleco_ms32_sysctrl.cpp2
-rw-r--r--src/mame/machine/jaleco_ms32_sysctrl.h2
-rw-r--r--src/mame/machine/k573dio.cpp80
-rw-r--r--src/mame/machine/k573dio.h14
-rw-r--r--src/mame/machine/k573kara.cpp2
-rw-r--r--src/mame/machine/k573kara.h2
-rw-r--r--src/mame/machine/k573mcr.cpp13
-rw-r--r--src/mame/machine/k7659kb.cpp2
-rw-r--r--src/mame/machine/k7659kb.h2
-rw-r--r--src/mame/machine/kaneko_calc3.cpp2
-rw-r--r--src/mame/machine/kaneko_calc3.h2
-rw-r--r--src/mame/machine/kc_keyb.cpp2
-rw-r--r--src/mame/machine/kc_keyb.h2
-rw-r--r--src/mame/machine/lynx.cpp903
-rw-r--r--src/mame/machine/m1comm.h2
-rw-r--r--src/mame/machine/m24_kbd.cpp2
-rw-r--r--src/mame/machine/m24_kbd.h6
-rw-r--r--src/mame/machine/m2comm.h2
-rw-r--r--src/mame/machine/m3comm.cpp2
-rw-r--r--src/mame/machine/m3comm.h2
-rw-r--r--src/mame/machine/macadb.cpp34
-rw-r--r--src/mame/machine/macadb.h5
-rw-r--r--src/mame/machine/mace.cpp2
-rw-r--r--src/mame/machine/mace.h2
-rw-r--r--src/mame/machine/macrtc.cpp2
-rw-r--r--src/mame/machine/macrtc.h2
-rw-r--r--src/mame/machine/maple-dc.cpp2
-rw-r--r--src/mame/machine/maple-dc.h2
-rw-r--r--src/mame/machine/mapledev.cpp2
-rw-r--r--src/mame/machine/mapledev.h2
-rw-r--r--src/mame/machine/mct_adr.cpp2
-rw-r--r--src/mame/machine/megadriv.cpp4
-rw-r--r--src/mame/machine/micro3d.cpp4
-rw-r--r--src/mame/machine/midikbd.cpp2
-rw-r--r--src/mame/machine/midikbd.h2
-rw-r--r--src/mame/machine/mie.cpp2
-rw-r--r--src/mame/machine/mie.h2
-rw-r--r--src/mame/machine/mm1kb.cpp2
-rw-r--r--src/mame/machine/mm1kb.h2
-rw-r--r--src/mame/machine/mpu4.cpp6
-rw-r--r--src/mame/machine/n64.cpp2
-rw-r--r--src/mame/machine/namco06.cpp89
-rw-r--r--src/mame/machine/namco06.h6
-rw-r--r--src/mame/machine/namco50.cpp9
-rw-r--r--src/mame/machine/namco50.h1
-rw-r--r--src/mame/machine/namco51.cpp9
-rw-r--r--src/mame/machine/namco51.h1
-rw-r--r--src/mame/machine/naomi.cpp407
-rw-r--r--src/mame/machine/naomig1.cpp2
-rw-r--r--src/mame/machine/naomig1.h2
-rw-r--r--src/mame/machine/naomigd.cpp4
-rw-r--r--src/mame/machine/nb1412m2.cpp2
-rw-r--r--src/mame/machine/nb1412m2.h2
-rw-r--r--src/mame/machine/nb1413m3.cpp4
-rw-r--r--src/mame/machine/nb1413m3.h2
-rw-r--r--src/mame/machine/nes.cpp38
-rw-r--r--src/mame/machine/nextkbd.cpp2
-rw-r--r--src/mame/machine/nextkbd.h2
-rw-r--r--src/mame/machine/ng_memcard.cpp2
-rw-r--r--src/mame/machine/ng_memcard.h9
-rw-r--r--src/mame/machine/p2000t_mdcr.cpp2
-rw-r--r--src/mame/machine/p2000t_mdcr.h2
-rw-r--r--src/mame/machine/pc1512kb.cpp2
-rw-r--r--src/mame/machine/pc1512kb.h2
-rw-r--r--src/mame/machine/pc80s31k.cpp2
-rw-r--r--src/mame/machine/pc80s31k.h2
-rw-r--r--src/mame/machine/pc9801_kbd.cpp2
-rw-r--r--src/mame/machine/pc9801_kbd.h2
-rw-r--r--src/mame/machine/pce220_ser.cpp2
-rw-r--r--src/mame/machine/pce220_ser.h8
-rw-r--r--src/mame/machine/pgm2_memcard.cpp2
-rw-r--r--src/mame/machine/pgm2_memcard.h10
-rw-r--r--src/mame/machine/pmd85.cpp4
-rw-r--r--src/mame/machine/pocketc.cpp2
-rw-r--r--src/mame/machine/psion_pack.cpp14
-rw-r--r--src/mame/machine/psion_pack.h13
-rw-r--r--src/mame/machine/psxcd.cpp15
-rw-r--r--src/mame/machine/psxcd.h3
-rw-r--r--src/mame/machine/qx10kbd.cpp2
-rw-r--r--src/mame/machine/qx10kbd.h2
-rw-r--r--src/mame/machine/rmnimbus.cpp290
-rw-r--r--src/mame/machine/rtpc_iocc.cpp1
-rw-r--r--src/mame/machine/rtpc_iocc.h6
-rw-r--r--src/mame/machine/s32comm.cpp4
-rw-r--r--src/mame/machine/s32comm.h2
-rw-r--r--src/mame/machine/saa7191.cpp2
-rw-r--r--src/mame/machine/saa7191.h2
-rw-r--r--src/mame/machine/seicopbl.cpp2
-rw-r--r--src/mame/machine/sgi.cpp2
-rw-r--r--src/mame/machine/sgi.h2
-rw-r--r--src/mame/machine/snes.cpp71
-rw-r--r--src/mame/machine/snescx4.cpp18
-rw-r--r--src/mame/machine/sorcerer.cpp6
-rw-r--r--src/mame/machine/stfight.cpp2
-rw-r--r--src/mame/machine/tatsumi.cpp8
-rw-r--r--src/mame/machine/thomson.cpp2
-rw-r--r--src/mame/machine/ti85.cpp2
-rw-r--r--src/mame/machine/tsconf.cpp653
-rw-r--r--src/mame/machine/upd65031.cpp2
-rw-r--r--src/mame/machine/upd65031.h2
-rw-r--r--src/mame/machine/vectrex.cpp21
-rw-r--r--src/mame/machine/victor9k_fdc.cpp2
-rw-r--r--src/mame/machine/victor9k_fdc.h2
-rw-r--r--src/mame/machine/vino.cpp2
-rw-r--r--src/mame/machine/vino.h2
-rw-r--r--src/mame/machine/vsnes.cpp157
-rw-r--r--src/mame/machine/wpc.cpp2
-rw-r--r--src/mame/machine/wpc.h2
-rw-r--r--src/mame/machine/wpc_lamp.cpp2
-rw-r--r--src/mame/machine/wpc_lamp.h2
-rw-r--r--src/mame/machine/wpc_out.cpp2
-rw-r--r--src/mame/machine/wpc_out.h2
-rw-r--r--src/mame/machine/x68k_hdc.cpp3
-rw-r--r--src/mame/machine/x68k_hdc.h16
-rw-r--r--src/mame/machine/xbox.cpp40
-rw-r--r--src/mame/machine/xbox_pci.cpp6
-rw-r--r--src/mame/machine/xbox_usb.cpp2
-rw-r--r--src/mame/machine/z80ne.cpp2
-rw-r--r--src/mame/machine/znmcu.cpp2
-rw-r--r--src/mame/machine/znmcu.h2
-rw-r--r--src/mame/machine/zx.cpp76
-rw-r--r--src/mame/machine/zx8302.cpp2
-rw-r--r--src/mame/machine/zx8302.h2
223 files changed, 5624 insertions, 3287 deletions
diff --git a/src/mame/machine/3dom2.cpp b/src/mame/machine/3dom2.cpp
index 4e3927f72f5..bbe7638ad46 100644
--- a/src/mame/machine/3dom2.cpp
+++ b/src/mame/machine/3dom2.cpp
@@ -314,7 +314,7 @@ void m2_bda_device::device_add_mconfig(machine_config &config)
// device_timer - device-specific timers
//-------------------------------------------------
-void m2_bda_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
+void m2_bda_device::device_timer(emu_timer &timer, device_timer_id id, int param)
{
switch (id)
{
@@ -864,7 +864,7 @@ void m2_vdu_device::device_reset()
// device_timer - device-specific timers
//-------------------------------------------------
-void m2_vdu_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
+void m2_vdu_device::device_timer(emu_timer &timer, device_timer_id id, int param)
{
switch (id)
{
@@ -1571,7 +1571,7 @@ void m2_cde_device::device_post_load()
// device_timer - a timer
//-------------------------------------------------
-void m2_cde_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
+void m2_cde_device::device_timer(emu_timer &timer, device_timer_id id, int param)
{
switch (id)
{
diff --git a/src/mame/machine/3dom2.h b/src/mame/machine/3dom2.h
index 3326afe4c74..b4eac8df956 100644
--- a/src/mame/machine/3dom2.h
+++ b/src/mame/machine/3dom2.h
@@ -164,7 +164,7 @@ protected:
virtual void device_reset() override;
virtual void device_post_load() override;
virtual void device_add_mconfig(machine_config &config) override;
- virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override;
+ virtual void device_timer(emu_timer &timer, device_timer_id id, int param) override;
private:
enum base_addr
@@ -400,7 +400,7 @@ public:
protected:
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_timer(emu_timer &timer, device_timer_id id, int param) override;
private:
enum timer_id
@@ -525,7 +525,7 @@ protected:
virtual void device_start() override;
virtual void device_reset() override;
virtual void device_post_load() override;
- virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override;
+ virtual void device_timer(emu_timer &timer, device_timer_id id, int param) override;
private:
diff --git a/src/mame/machine/6883sam.cpp b/src/mame/machine/6883sam.cpp
index e9ddb12b170..73b37c50c09 100644
--- a/src/mame/machine/6883sam.cpp
+++ b/src/mame/machine/6883sam.cpp
@@ -149,6 +149,8 @@ void sam6883_device::device_start()
// save state support
save_item(NAME(m_sam_state));
+ save_item(NAME(m_divider));
+ save_item(NAME(m_counter_mask));
save_item(NAME(m_counter));
save_item(NAME(m_counter_xdiv));
save_item(NAME(m_counter_ydiv));
diff --git a/src/mame/machine/abc1600mac.cpp b/src/mame/machine/abc1600mac.cpp
index a09ef28bf5f..03bba2be8fa 100644
--- a/src/mame/machine/abc1600mac.cpp
+++ b/src/mame/machine/abc1600mac.cpp
@@ -45,10 +45,6 @@
#define PAGE_WP BIT(page_data, 14)
#define PAGE_NONX BIT(page_data, 15)
-#define BOOTE BIT(m_task, 6)
-#define MAGIC BIT(m_task, 7)
-#define READ_MAGIC !MAGIC
-
//**************************************************************************
@@ -66,6 +62,14 @@ void abc1600_mac_device::map(address_map &map)
void abc1600_mac_device::program_map(address_map &map)
{
+ map(0x80000, 0x80000).mirror(0x006f8).select(0x7f900).rw(FUNC(abc1600_mac_device::page_hi_r), FUNC(abc1600_mac_device::page_hi_w));
+ map(0x80001, 0x80001).mirror(0x006f8).select(0x7f900).rw(FUNC(abc1600_mac_device::page_lo_r), FUNC(abc1600_mac_device::page_lo_w));
+ map(0x80002, 0x80002).mirror(0x7fff8).noprw();
+ map(0x80003, 0x80003).mirror(0x07ef8).select(0x78100).rw(FUNC(abc1600_mac_device::segment_r), FUNC(abc1600_mac_device::segment_w));
+ map(0x80004, 0x80004).mirror(0x7fff8).noprw();
+ map(0x80005, 0x80005).mirror(0x7fff8).nopr().w(FUNC(abc1600_mac_device::task_w));
+ map(0x80006, 0x80006).mirror(0x7fff8).noprw();
+ map(0x80007, 0x80007).mirror(0x7fff8).r(FUNC(abc1600_mac_device::cause_r)).nopw();
}
@@ -117,6 +121,9 @@ abc1600_mac_device::abc1600_mac_device(const machine_config &mconfig, const char
m_watchdog(*this, "watchdog"),
m_read_fc(*this),
m_write_buserr(*this),
+ m_ifc2(0),
+ m_boote(0),
+ m_magic(0),
m_task(0),
m_cause(0)
{
@@ -152,6 +159,8 @@ void abc1600_mac_device::device_start()
void abc1600_mac_device::device_reset()
{
// clear task register
+ m_boote = 0;
+ m_magic = 0;
m_task = 0;
}
@@ -170,197 +179,69 @@ device_memory_interface::space_config_vector abc1600_mac_device::memory_space_co
//-------------------------------------------------
-// get_current_task -
+// translate_address -
//-------------------------------------------------
-int abc1600_mac_device::get_current_task(offs_t offset)
+offs_t abc1600_mac_device::translate_address(offs_t offset, int &nonx, int &wp)
{
+ // segment
int force_task0 = !(m_ifc2 || A19);
- int t0 = !(BIT(m_task, 0) || force_task0);
- int t1 = !(BIT(m_task, 1) || force_task0);
- int t2 = !(BIT(m_task, 2) || force_task0);
- int t3 = !(BIT(m_task, 3) || force_task0);
-
- return (t3 << 3) | (t2 << 2) | (t1 << 1) | t0;
-}
-
-
-//-------------------------------------------------
-// get_segment_address -
-//-------------------------------------------------
-
-offs_t abc1600_mac_device::get_segment_address(offs_t offset)
-{
+ int task = force_task0 ? 0 : m_task;
int sega19 = !(!(A8 || m_ifc2) || !A19);
- int task = get_current_task(offset);
-
- return (task << 5) | (sega19 << 4) | ((offset >> 15) & 0x0f);
-}
-
-//-------------------------------------------------
-// get_page_address -
-//-------------------------------------------------
-
-offs_t abc1600_mac_device::get_page_address(offs_t offset, uint8_t segd)
-{
- return ((segd & 0x3f) << 4) | ((offset >> 11) & 0x0f);
-}
-
-
-//-------------------------------------------------
-// translate_address -
-//-------------------------------------------------
-
-offs_t abc1600_mac_device::translate_address(offs_t offset, int *nonx, int *wp)
-{
- // segment
- offs_t sega = get_segment_address(offset);
+ offs_t sega = (task << 5) | (sega19 << 4) | ((offset >> 15) & 0x0f);
uint8_t segd = m_segment_ram[sega];
// page
- offs_t pga = get_page_address(offset, segd);
+ offs_t pga = ((segd & 0x3f) << 4) | ((offset >> 11) & 0x0f);
uint16_t page_data = m_page_ram[pga];
offs_t virtual_offset = ((page_data & 0x3ff) << 11) | (offset & 0x7ff);
if (PAGE_NONX)
{
- //logerror("Bus error %06x : %06x\n", offset, virtual_offset);
- //m_write_buserr(ASSERT_LINE);
- //m_write_buserr(CLEAR_LINE);
+ logerror("Bus error %06x : %06x\n", offset, virtual_offset);
+ m_write_buserr(ASSERT_LINE);
+ m_write_buserr(CLEAR_LINE);
}
- *nonx = PAGE_NONX;
- *wp = PAGE_WP;
+ nonx = PAGE_NONX;
+ wp = PAGE_WP;
- if (LOG_MAC && offset != virtual_offset) logerror("%s MAC %05x:%06x (SEGA %03x SEGD %02x PGA %03x PGD %04x NONX %u WP %u TASK %u FC %u)\n", machine().describe_context(), offset, virtual_offset, sega, segd, pga, m_page_ram[pga], *nonx, *wp, get_current_task(offset), get_fc());
+ if (LOG_MAC && offset != virtual_offset) logerror("%s MAC %05x:%06x (SEGA %03x SEGD %02x PGA %03x PGD %04x NONX %u WP %u TASK %u FC %u)\n", machine().describe_context(), offset, virtual_offset, sega, segd, pga, m_page_ram[pga], nonx, wp, task, m_read_fc());
return virtual_offset;
}
//-------------------------------------------------
-// read_user_memory -
-//-------------------------------------------------
-
-uint8_t abc1600_mac_device::read_user_memory(offs_t offset)
-{
- int nonx = 0, wp = 0;
- offs_t virtual_offset = translate_address(offset, &nonx, &wp);
- uint8_t data = space().read_byte(virtual_offset);
-
- if (LOG_IO && virtual_offset >= 0x1fe000) logerror("%s user read %06x:%02x\n", machine().describe_context(), virtual_offset, data);
-
- return data;
-}
-
-
-//-------------------------------------------------
-// write_user_memory -
-//-------------------------------------------------
-
-void abc1600_mac_device::write_user_memory(offs_t offset, uint8_t data)
-{
- int nonx = 0, wp = 0;
- offs_t virtual_offset = translate_address(offset, &nonx, &wp);
-
- //if (nonx || !wp) return;
-
- if (LOG_IO && virtual_offset >= 0x1fe000) logerror("%s user write %06x:%02x\n", machine().describe_context(), virtual_offset, data);
-
- space().write_byte(virtual_offset, data);
-}
-
-
-//-------------------------------------------------
-// read_supervisor_memory -
-//-------------------------------------------------
-
-uint8_t abc1600_mac_device::read_supervisor_memory(offs_t offset)
-{
- uint8_t data = 0;
-
- if (!A2 && !A1)
- {
- // _EP
- data = page_r(offset);
- }
- else if (!A2 && A1 && A0)
- {
- // _ES
- data = segment_r(offset);
- }
- else if (A2 && A1 && A0)
- {
- // _CAUSE
- data = cause_r();
- }
-
- return data;
-}
-
-
-//-------------------------------------------------
-// write_supervisor_memory -
-//-------------------------------------------------
-
-void abc1600_mac_device::write_supervisor_memory(offs_t offset, uint8_t data)
-{
- if (!A2 && !A1)
- {
- // _WEP
- page_w(offset, data);
- }
- else if (!A2 && A1 && A0)
- {
- // _WES
- segment_w(offset, data);
- }
- else if (A2 && !A1 && A0)
- {
- // W(C)
- task_w(offset, data);
- }
-}
-
-
-//-------------------------------------------------
-// get_fc -
-//-------------------------------------------------
-
-int abc1600_mac_device::get_fc()
-{
- uint16_t fc = m_read_fc();
-
- m_ifc2 = !(!(MAGIC || FC0) || FC2);
-
- return fc;
-}
-
-
-//-------------------------------------------------
// read -
//-------------------------------------------------
uint8_t abc1600_mac_device::read(offs_t offset)
{
- int fc = get_fc();
+ uint16_t fc = m_read_fc();
+ m_ifc2 = !(!(m_magic || FC0) || FC2);
uint8_t data = 0;
- if (!BOOTE && !A19 && !A18 && !A17)
+ if (!m_boote && (offset < 0x20000))
{
// _BOOTCE
data = m_rom->base()[offset & 0x3fff];
}
- else if (A19 && !m_ifc2 && !FC1)
+ else if ((offset & 0x80000) && !m_ifc2 && !FC1)
{
- data = read_supervisor_memory(offset);
+ data = space(AS_PROGRAM).read_byte(offset);
}
else
{
- data = read_user_memory(offset);
+ int nonx = 0, wp = 0;
+ offs_t virtual_offset = translate_address(offset, nonx, wp);
+
+ data = space().read_byte(virtual_offset);
+
+ if (LOG_IO && virtual_offset >= 0x1fe000) logerror("%s user read %06x:%02x\n", machine().describe_context(), virtual_offset, data);
}
return data;
@@ -373,15 +254,23 @@ uint8_t abc1600_mac_device::read(offs_t offset)
void abc1600_mac_device::write(offs_t offset, uint8_t data)
{
- int fc = get_fc();
+ uint16_t fc = m_read_fc();
+ m_ifc2 = !(!(m_magic || FC0) || FC2);
- if (A19 && !m_ifc2 && !FC1)
+ if ((offset & 0x80000) && !m_ifc2 && !FC1)
{
- write_supervisor_memory(offset, data);
+ space(AS_PROGRAM).write_byte(offset, data);
}
else
{
- write_user_memory(offset, data);
+ int nonx = 0, wp = 0;
+ offs_t virtual_offset = translate_address(offset, nonx, wp);
+
+ if (nonx || !wp) return;
+
+ if (LOG_IO && virtual_offset >= 0x1fe000) logerror("%s user write %06x:%02x\n", machine().describe_context(), virtual_offset, data);
+
+ space().write_byte(virtual_offset, data);
}
}
@@ -439,10 +328,12 @@ void abc1600_mac_device::task_w(offs_t offset, uint8_t data)
*/
- m_task = data ^ 0xff;
+ m_task = data & 0x0f;
+ m_boote = !BIT(data, 6);
+ m_magic = !BIT(data, 7);
if (LOG) logerror("%s TASK %05x:%02x (TASK %u BOOTE %u MAGIC %u)\n", machine().describe_context(), offset, data,
- get_current_task(offset), BOOTE, MAGIC);
+ m_task, m_boote, m_magic);
}
@@ -467,10 +358,10 @@ uint8_t abc1600_mac_device::segment_r(offs_t offset)
*/
- offs_t sega = get_segment_address(offset);
+ offs_t sega = (m_task << 5) | A8 << 4 | ((offset >> 15) & 0xf);
uint8_t segd = m_segment_ram[sega];
- return (READ_MAGIC << 7) | (segd & 0x7f);
+ return (!m_magic << 7) | (segd & 0x7f);
}
@@ -495,20 +386,19 @@ void abc1600_mac_device::segment_w(offs_t offset, uint8_t data)
*/
- offs_t sega = get_segment_address(offset);
-
+ offs_t sega = (m_task << 5) | A8 << 4 | ((offset >> 15) & 0xf);
m_segment_ram[sega] = data & 0x7f;
if (LOG) logerror("%s %05x:%02x TASK %u SEGMENT %u MEM %05x-%05x\n", machine().describe_context(), offset, data,
- get_current_task(offset), sega & 0x1f, (sega & 0x1f) * 0x8000, ((sega & 0x1f) * 0x8000) + 0x7fff);
+ m_task, sega & 0x1f, (sega & 0x1f) * 0x8000, ((sega & 0x1f) * 0x8000) + 0x7fff);
}
//-------------------------------------------------
-// page_r -
+// page_lo_r -
//-------------------------------------------------
-uint8_t abc1600_mac_device::page_r(offs_t offset)
+uint8_t abc1600_mac_device::page_lo_r(offs_t offset)
{
/*
@@ -523,47 +413,60 @@ uint8_t abc1600_mac_device::page_r(offs_t offset)
6 X17
7 X18
- 8 X19
- 9 X20
- 10 X20
- 11 X20
- 12 X20
- 13 X20
- 14 _WP
- 15 NONX
-
*/
// segment
- offs_t sega = get_segment_address(offset);
+ offs_t sega = (m_task << 5) | A8 << 4 | ((offset >> 15) & 0xf);
uint8_t segd = m_segment_ram[sega];
// page
- offs_t pga = get_page_address(offset, segd);
+ offs_t pga = ((segd & 0x3f) << 4) | ((offset >> 11) & 0xf);
uint16_t pgd = m_page_ram[pga];
- uint8_t data = 0;
+ return pgd & 0xff;
+}
- if (A0)
- {
- data = pgd & 0xff;
- }
- else
- {
- int x20 = BIT(pgd, 9);
- data = (pgd >> 8) | (x20 << 2) | (x20 << 3) | (x20 << 4) | (x20 << 5);
- }
+//-------------------------------------------------
+// page_hi_r -
+//-------------------------------------------------
- return data;
+uint8_t abc1600_mac_device::page_hi_r(offs_t offset)
+{
+ /*
+
+ bit description
+
+ 0 X19
+ 1 X20
+ 2 X20
+ 3 X20
+ 4 X20
+ 5 X20
+ 6 _WP
+ 7 NONX
+
+ */
+
+ // segment
+ offs_t sega = (m_task << 5) | A8 << 4 | ((offset >> 15) & 0xf);
+ uint8_t segd = m_segment_ram[sega];
+
+ // page
+ offs_t pga = ((segd & 0x3f) << 4) | ((offset >> 11) & 0xf);
+ uint16_t pgd = m_page_ram[pga];
+
+ int x20 = BIT(pgd, 9);
+
+ return (pgd >> 8) | (x20 << 2) | (x20 << 3) | (x20 << 4) | (x20 << 5);
}
//-------------------------------------------------
-// page_w -
+// page_lo_w -
//-------------------------------------------------
-void abc1600_mac_device::page_w(offs_t offset, uint8_t data)
+void abc1600_mac_device::page_lo_w(offs_t offset, uint8_t data)
{
/*
@@ -578,40 +481,54 @@ void abc1600_mac_device::page_w(offs_t offset, uint8_t data)
6 X17
7 X18
- 8 X19
- 9 X20
- 10
- 11
- 12
- 13
- 14 _WP
- 15 NONX
-
*/
// segment
- offs_t sega = get_segment_address(offset);
+ offs_t sega = (m_task << 5) | A8 << 4 | ((offset >> 15) & 0xf);
uint8_t segd = m_segment_ram[sega];
// page
- offs_t pga = get_page_address(offset, segd);
-
- if (A0)
- {
- m_page_ram[pga] = (m_page_ram[pga] & 0xff00) | data;
- }
- else
- {
- m_page_ram[pga] = ((data & 0xc3) << 8) | (m_page_ram[pga] & 0xff);
- }
+ offs_t pga = ((segd & 0x3f) << 4) | ((offset >> 11) & 0xf);
+ m_page_ram[pga] = (m_page_ram[pga] & 0xff00) | data;
if (LOG) logerror("%s %05x:%02x TASK %u SEGMENT %u PAGE %u MEM %05x-%05x %06x\n", machine().describe_context(), offset, data,
- get_current_task(offset), sega & 0x1f, ((offset >> 11) & 0x0f), ((sega & 0x1f) * 0x8000) + ((offset >> 11) & 0x0f) * 0x800,
+ m_task, sega & 0x1f, ((offset >> 11) & 0x0f), ((sega & 0x1f) * 0x8000) + ((offset >> 11) & 0x0f) * 0x800,
((sega & 0x1f) * 0x8000) + (((offset >> 11) & 0x0f) * 0x800) + 0x7ff, (m_page_ram[pga] & 0x3ff) << 11);
}
//-------------------------------------------------
+// page_hi_w -
+//-------------------------------------------------
+
+void abc1600_mac_device::page_hi_w(offs_t offset, uint8_t data)
+{
+ /*
+
+ bit description
+
+ 0 X19
+ 1 X20
+ 2
+ 3
+ 4
+ 5
+ 6 _WP
+ 7 NONX
+
+ */
+
+ // segment
+ offs_t sega = (m_task << 5) | A8 << 4 | ((offset >> 15) & 0xf);
+ uint8_t segd = m_segment_ram[sega];
+
+ // page
+ offs_t pga = ((segd & 0x3f) << 4) | ((offset >> 11) & 0xf);
+ m_page_ram[pga] = ((data & 0xc3) << 8) | (m_page_ram[pga] & 0xff);
+}
+
+
+//-------------------------------------------------
// get_dma_address -
//-------------------------------------------------
@@ -635,7 +552,7 @@ uint8_t abc1600_mac_device::dma_mreq_r(int index, uint16_t offset)
{
offs_t virtual_offset = get_dma_address(index, offset);
- if (LOG_DMA)logerror("%s DMA R %04x:%06x\n", machine().describe_context(), offset, virtual_offset);
+ if (LOG_DMA) logerror("%s DMA MEM R %04x:%06x\n", machine().describe_context(), offset, virtual_offset);
return space().read_byte(virtual_offset);
}
@@ -649,7 +566,7 @@ void abc1600_mac_device::dma_mreq_w(int index, uint16_t offset, uint8_t data)
{
offs_t virtual_offset = get_dma_address(index, offset);
- if (LOG_DMA)logerror("%s DMA W %04x:%06x\n", machine().describe_context(), offset, virtual_offset);
+ if (LOG_DMA) logerror("%s DMA MEM W %04x:%06x\n", machine().describe_context(), offset, virtual_offset);
space().write_byte(virtual_offset, data);
}
@@ -663,7 +580,7 @@ uint8_t abc1600_mac_device::dma_iorq_r(int index, uint16_t offset)
{
offs_t virtual_offset = 0x1fe000 | get_dma_address(index, offset);
- if (LOG_DMA)logerror("%s DMA R %04x:%06x\n", machine().describe_context(), offset, virtual_offset);
+ if (LOG_DMA) logerror("%s DMA I/O R %04x:%06x\n", machine().describe_context(), offset, virtual_offset);
return space().read_byte(virtual_offset);
}
@@ -677,7 +594,7 @@ void abc1600_mac_device::dma_iorq_w(int index, uint16_t offset, uint8_t data)
{
offs_t virtual_offset = 0x1fe000 | get_dma_address(index, offset);
- if (LOG_DMA)logerror("%s DMA W %04x:%06x\n", machine().describe_context(), offset, virtual_offset);
+ if (LOG_DMA) logerror("%s DMA I/O W %04x:%06x\n", machine().describe_context(), offset, virtual_offset);
space().write_byte(virtual_offset, data);
}
diff --git a/src/mame/machine/abc1600mac.h b/src/mame/machine/abc1600mac.h
index eea39efcb25..ff6343a97e0 100644
--- a/src/mame/machine/abc1600mac.h
+++ b/src/mame/machine/abc1600mac.h
@@ -44,8 +44,10 @@ public:
void task_w(offs_t offset, uint8_t data);
uint8_t segment_r(offs_t offset);
void segment_w(offs_t offset, uint8_t data);
- uint8_t page_r(offs_t offset);
- void page_w(offs_t offset, uint8_t data);
+ uint8_t page_lo_r(offs_t offset);
+ void page_lo_w(offs_t offset, uint8_t data);
+ uint8_t page_hi_r(offs_t offset);
+ void page_hi_w(offs_t offset, uint8_t data);
void dmamap_w(offs_t offset, uint8_t data);
uint8_t dma0_mreq_r(offs_t offset) { return dma_mreq_r(DMAMAP_R0_LO, offset); }
@@ -61,7 +63,6 @@ public:
uint8_t dma2_iorq_r(offs_t offset) { return dma_iorq_r(DMAMAP_R2_LO, offset); }
void dma2_iorq_w(offs_t offset, uint8_t data) { dma_iorq_w(DMAMAP_R2_LO, offset, data); }
- void program_map(address_map &map);
protected:
// device-level overrides
virtual void device_start() override;
@@ -88,21 +89,14 @@ private:
uint8_t read(offs_t offset);
void write(offs_t offset, uint8_t data);
- int get_current_task(offs_t offset);
- offs_t get_segment_address(offs_t offset);
- offs_t get_page_address(offs_t offset, uint8_t segd);
- offs_t translate_address(offs_t offset, int *nonx, int *wp);
- uint8_t read_user_memory(offs_t offset);
- void write_user_memory(offs_t offset, uint8_t data);
- int get_fc();
- uint8_t read_supervisor_memory(offs_t offset);
- void write_supervisor_memory(offs_t offset, uint8_t data);
+ offs_t translate_address(offs_t offset, int &nonx, int &wp);
offs_t get_dma_address(int index, uint16_t offset);
uint8_t dma_mreq_r(int index, uint16_t offset);
void dma_mreq_w(int index, uint16_t offset, uint8_t data);
uint8_t dma_iorq_r(int index, uint16_t offset);
void dma_iorq_w(int index, uint16_t offset, uint8_t data);
+ void program_map(address_map &map);
const address_space_config m_program_config;
required_memory_region m_rom;
@@ -114,8 +108,10 @@ private:
devcb_read8 m_read_fc;
devcb_write_line m_write_buserr;
- int m_ifc2;
- uint8_t m_task;
+ bool m_ifc2;
+ bool m_boote;
+ bool m_magic;
+ bool m_task;
uint8_t m_dmamap[8];
uint8_t m_cause;
};
diff --git a/src/mame/machine/alpha8201.cpp b/src/mame/machine/alpha8201.cpp
index bd9a6c95e7a..0f3da510f57 100644
--- a/src/mame/machine/alpha8201.cpp
+++ b/src/mame/machine/alpha8201.cpp
@@ -6,9 +6,9 @@
----------------------------------------------------------------------------
-The Alpha-8201/830x isn't a real CPU. It is a Hitachi HD44801 4-bit MCU,
-programmed to interpret an external program using a custom instruction set.
-Alpha-8301 has an expanded instruction set, backwards compatible with Alpha-8201.
+The Alpha-8x0x isn't a real CPU. It is a Hitachi HD44801 4-bit MCU, programmed
+to interpret an external program using a custom instruction set. Alpha-8302
+has an expanded instruction set, backwards compatible with Alpha-8201.
Game Year MCU
@@ -185,7 +185,7 @@ opcode mnemonic function flags
1111--xx mirror for the above
Notes:
-[1] bug: the Z flag is not updated correctly after a LD A,Rn instruction. Fixed in 8302 (possibly 8301).
+[1] bug: the Z flag is not updated correctly after a LD A,Rn instruction. Fixed in 8302.
8302 CONFIRMED OPCODES:
diff --git a/src/mame/machine/amiga.cpp b/src/mame/machine/amiga.cpp
index 62da9267548..2a5d6a39702 100644
--- a/src/mame/machine/amiga.cpp
+++ b/src/mame/machine/amiga.cpp
@@ -227,18 +227,18 @@ uint32_t amiga_state::rom_mirror32_r(offs_t offset, uint32_t mem_mask)
return m_maincpu->space(AS_PROGRAM).read_dword(offset + 0xf80000, mem_mask);
}
-void amiga_state::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
+void amiga_state::device_timer(emu_timer &timer, device_timer_id id, int param)
{
switch (id)
{
case TIMER_SCANLINE:
- scanline_callback(ptr, param);
+ scanline_callback(param);
break;
case TIMER_AMIGA_IRQ:
- amiga_irq_proc(ptr, param);
+ amiga_irq_proc(param);
break;
case TIMER_AMIGA_BLITTER:
- amiga_blitter_proc(ptr, param);
+ amiga_blitter_proc(param);
break;
case TIMER_SERIAL:
serial_shift();
diff --git a/src/mame/machine/amstrad.cpp b/src/mame/machine/amstrad.cpp
index 5e11defce14..696e824892a 100644
--- a/src/mame/machine/amstrad.cpp
+++ b/src/mame/machine/amstrad.cpp
@@ -221,18 +221,18 @@ TIMER_CALLBACK_MEMBER(amstrad_state::amstrad_pc2_low)
}
-void amstrad_state::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
+void amstrad_state::device_timer(emu_timer &timer, device_timer_id id, int param)
{
switch (id)
{
case TIMER_PC2_LOW:
- amstrad_pc2_low(ptr, param);
+ amstrad_pc2_low(param);
break;
case TIMER_VIDEO_UPDATE:
- amstrad_video_update_timer(ptr, param);
+ amstrad_video_update_timer(param);
break;
case TIMER_SET_RESOLUTION:
- cb_set_resolution(ptr, param);
+ cb_set_resolution(param);
break;
default:
throw emu_fatalerror("Unknown id in amstrad_state::device_timer");
@@ -843,7 +843,7 @@ WRITE_LINE_MEMBER(amstrad_state::amstrad_hsync_changed)
{
amstrad_update_video();
- /* The gate array reacts to de-assertion of the hsycnc 6845 line */
+ /* The gate array reacts to de-assertion of the hsync 6845 line */
if ( m_gate_array.hsync && !state )
{
m_gate_array.hsync_counter++;
@@ -2341,7 +2341,7 @@ void amstrad_state::amstrad_reset_machine()
/* set ram config 0 */
amstrad_GateArray_write(0x0c0);
- // Get manufacturer name and TV refresh rate from PCB link (dipswitch for mess emulation)
+ // Get manufacturer name and TV refresh rate from PCB link (dipswitch for MAME emulation)
m_ppi_port_inputs[amstrad_ppi_PortB] = (((m_io_solder_links->read()&MANUFACTURER_NAME)<<1) | (m_io_solder_links->read()&TV_REFRESH_RATE));
if ( m_system_type == SYSTEM_PLUS || m_system_type == SYSTEM_GX4000 )
@@ -2503,6 +2503,7 @@ void amstrad_state::update_psg()
{
case 0:
{/* Inactive */
+ m_ppi_port_inputs[amstrad_ppi_PortA] = 0xff;
} break;
case 1:
{/* b6 = 1 ? : Read from selected PSG register and make the register data available to PPI Port A */
@@ -2552,8 +2553,8 @@ Bit Description
7 Cassette read data
6 Parallel/Printer port ready signal ("1" = not ready, "0" = Ready)
5 /EXP signal on expansion port (note 6)
-4 50/60 Hz (link on PCB. For this MESS driver I have used the dipswitch feature) (note 5)
-3 | PCB links to define manufacturer name. For this MESS driver I have used the dipswitch feature. (note 1) (note 4)
+4 50/60 Hz (link on PCB. For this MAME driver I have used the dipswitch feature) (note 5)
+3 | PCB links to define manufacturer name. For this MAME driver I have used the dipswitch feature. (note 1) (note 4)
2 | (note 2)
1 | (note 3)
0 VSYNC State from 6845. "1" = VSYNC active, "0" = VSYNC inactive
diff --git a/src/mame/machine/apexc.cpp b/src/mame/machine/apexc.cpp
index f002b2ff7f1..9f6fff31fb9 100644
--- a/src/mame/machine/apexc.cpp
+++ b/src/mame/machine/apexc.cpp
@@ -66,8 +66,7 @@ void apexc_cylinder_image_device::call_unload()
apexc_tape_puncher_image_device::apexc_tape_puncher_image_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
- : device_t(mconfig, APEXC_TAPE_PUNCHER, tag, owner, clock)
- , device_image_interface(mconfig, *this)
+ : paper_tape_punch_device(mconfig, APEXC_TAPE_PUNCHER, tag, owner, clock)
{
}
@@ -85,8 +84,7 @@ void apexc_tape_puncher_image_device::write(uint8_t data)
}
apexc_tape_reader_image_device::apexc_tape_reader_image_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
- : device_t(mconfig, APEXC_TAPE_READER, tag, owner, clock)
- , device_image_interface(mconfig, *this)
+ : paper_tape_reader_device(mconfig, APEXC_TAPE_READER, tag, owner, clock)
{
}
diff --git a/src/mame/machine/apexc.h b/src/mame/machine/apexc.h
index 9b11f185a7c..4c009d857fd 100644
--- a/src/mame/machine/apexc.h
+++ b/src/mame/machine/apexc.h
@@ -12,6 +12,8 @@
#define MAME_MACHINE_APEXC
#pragma once
+
+#include "imagedev/papertape.h"
#include "softlist_dev.h"
@@ -33,14 +35,13 @@ public:
apexc_cylinder_image_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock = 0);
// image-level overrides
- virtual iodevice_t image_type() const noexcept override { return IO_CYLINDER; }
-
virtual bool is_readable() const noexcept override { return true; }
virtual bool is_writeable() const noexcept override { return true; }
virtual bool is_creatable() const noexcept override { return false; }
- virtual bool must_be_loaded() const noexcept override { return false; }
virtual bool is_reset_on_load() const noexcept override { return true; }
virtual const char *file_extensions() const noexcept override { return "apc"; }
+ virtual const char *image_type_name() const noexcept override { return "cylinder"; }
+ virtual const char *image_brief_type_name() const noexcept override { return "cyln"; }
virtual image_init_result call_load() override;
virtual void call_unload() override;
@@ -98,20 +99,13 @@ private:
11111 Letters
*/
-class apexc_tape_puncher_image_device : public device_t, public device_image_interface
+class apexc_tape_puncher_image_device : public paper_tape_punch_device
{
public:
// construction/destruction
apexc_tape_puncher_image_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock = 0);
// image-level overrides
- virtual iodevice_t image_type() const noexcept override { return IO_PUNCHTAPE; }
-
- virtual bool is_readable() const noexcept override { return false; }
- virtual bool is_writeable() const noexcept override { return true; }
- virtual bool is_creatable() const noexcept override { return true; }
- virtual bool must_be_loaded() const noexcept override { return false; }
- virtual bool is_reset_on_load() const noexcept override { return false; }
virtual const char *file_extensions() const noexcept override { return "tap"; }
void write(uint8_t data);
@@ -120,7 +114,7 @@ private:
virtual void device_start() override { }
};
-class apexc_tape_reader_image_device : public device_t, public device_image_interface
+class apexc_tape_reader_image_device : public paper_tape_reader_device
{
public:
// construction/destruction
@@ -132,13 +126,6 @@ public:
apexc_tape_reader_image_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
// image-level overrides
- virtual iodevice_t image_type() const noexcept override { return IO_PUNCHTAPE; }
-
- virtual bool is_readable() const noexcept override { return true; }
- virtual bool is_writeable() const noexcept override { return false; }
- virtual bool is_creatable() const noexcept override { return false; }
- virtual bool must_be_loaded() const noexcept override { return false; }
- virtual bool is_reset_on_load() const noexcept override { return false; }
virtual const char *file_extensions() const noexcept override { return "tap"; }
uint8_t read();
diff --git a/src/mame/machine/apollo.cpp b/src/mame/machine/apollo.cpp
index 03ee565f5e4..1b4f63013f1 100644
--- a/src/mame/machine/apollo.cpp
+++ b/src/mame/machine/apollo.cpp
@@ -35,7 +35,7 @@
#include "bus/isa/sc499.h"
#include "bus/isa/3c505.h"
-#include "softlist.h"
+#include "softlist_dev.h"
#define APOLLO_IRQ_VECTOR 0xa0
#define APOLLO_IRQ_PTM 0
@@ -1307,10 +1307,10 @@ void apollo_stdio_device::device_reset()
}
void apollo_stdio_device::device_timer(emu_timer &timer, device_timer_id id,
- int param, void *ptr)
+ int param)
{
// FIXME?
-// device_serial_interface::device_timer(timer, id, param, ptr);
+// device_serial_interface::device_timer(timer, id, param);
}
void apollo_stdio_device::rcv_complete() // Rx completed receiving byte
diff --git a/src/mame/machine/apple2common.cpp b/src/mame/machine/apple2common.cpp
index 6ac4845dd00..317f4061cc6 100644
--- a/src/mame/machine/apple2common.cpp
+++ b/src/mame/machine/apple2common.cpp
@@ -453,9 +453,16 @@ static const struct dasm_data gs_tools[] =
{ 0x1A23, "MIDIMessage(Dest,nBytes,Message,Byte1,Byte2)" }, { 0x1B23, "LocateEnd(@seqBuffer):@End" }, { 0x1C23, "Merge(@Buffer1,@Buffer2)" }, { 0x1D23, "DeleteTrack(TrackNum,@Seq)" },
{ 0x1E23, "SetMetro(Volume,Freq,@Wave)" }, { 0x1F23, "GetMSData():Reserved/4,@DirPage" }, { 0x2023, "ConvertToTime(TkPerBt,BtPerMsr,BeatNum,MsrNum):Ticks/4" }, { 0x2123, "ConvertToMeasure(TkPerBt,BtPerMsr,Ticks/4):Ticks,Beat,Msr" },
{ 0x2223, "MSSuspend()" }, { 0x2323, "MSResume()" }, { 0x2423, "SetTuningTable(@Table)" }, { 0x2523, "GetTuningTable(@Buffer)" }, { 0x2623, "SetTrackOut(TrackNum,PathVal)" },
- { 0x2723, "InitMIDIDriver(Slot,Internal,UserID,@Driver)" }, { 0x2823, "RemoveMIDIDriver()" }, { 0x0126, "MCBootInit()" }, { 0x0226, "MCStartUp(MemID)" }, { 0x0326, "MCShutDown()" },
- { 0x0426, "MCVersion():Vers" }, { 0x0526, "MCReset()" }, { 0x0626, "MCStatus():ActFlg" }, { 0x0926, "MCGetErrorMsg(mcErrorNo,@PStringBuff)" }, { 0x0A26, "MCLoadDriver(mcChannelNo)" },
- { 0x0B26, "MCUnLoadDriver(mcChannelNo)" }, { 0x0C26, "MCTimeToBin(mcTimeValue/4):result/4" }, { 0x0D26, "MCBinToTime(mcBinVal/4):result/4" }, { 0x0E26, "MCGetTrackTitle(mcDiskID/4,mcTrackNo,@PStringBuff)" },
+ { 0x2723, "InitMIDIDriver(Slot,Internal,UserID,@Driver)" }, { 0x2823, "RemoveMIDIDriver()" }, { 0x0125, "AnimBootInit()" }, { 0x0225, "AnimStartUp(MemID,DPage,ModeFlag,@PatchTbl)" },
+ { 0x0325, "AnimShutDown()" }, { 0x0425, "AnimVersion():Vers" }, { 0x0525, "AnimReset()" }, { 0x0625, "AnimStatus():Status" },
+ { 0x0725, "CleanExit() "}, { 0x0825, "AnimIdleDebug()" }, { 0x0925, "StartScene(Mode, @Rect)" }, { 0x0A25, "StopScene()" }, { 0x0B25, "StartFrameTimer(Interval)" },
+ { 0x0C25, "StopFrameTimer()" }, { 0x0D25, "SetBackGndPort()" }, { 0x0E25, "RefreshBackCall()" }, { 0x0F25, "StartCharCall(PassX, PassY, PassMaxP/PassFlag, PassMinP/PassDir, LPassChar)" },
+ { 0x1025, "MoveCharCall(PassIter, PassDY/PassIter, PassDX/PassFlag, LPassChar)" }, { 0x1125, "GetCharRecPtr(CharNum):CharRecPtr" },
+ { 0x1225, "KillCharCall(CharNum)" }, { 0x1325, "LoadActor(@ActorPtr, CharNum)" }, { 0x1425, "SetCharScript(@theScript, CharNum)" }, { 0x1525, "RunAnimScripts()" },
+ { 0x1625, "FillAddressTbl(@TablePtr)" }, { 0x1725, "CreateReblitCode(@RectPtr, GenFlags)" }, { 0x1825, "StartTockTask(thePtr, theData, theID, theCount)" }, { 0x1925, "FireTockTask()" },
+ { 0x0126, "MCBootInit()" }, { 0x0226, "MCStartUp(MemID)" }, { 0x0326, "MCShutDown()" }, { 0x0426, "MCVersion():Vers" }, { 0x0526, "MCReset()" }, { 0x0626, "MCStatus():ActFlg" },
+ { 0x0926, "MCGetErrorMsg(mcErrorNo,@PStringBuff)" }, { 0x0A26, "MCLoadDriver(mcChannelNo)" }, { 0x0B26, "MCUnLoadDriver(mcChannelNo)" }, { 0x0C26, "MCTimeToBin(mcTimeValue/4):result/4" },
+ { 0x0D26, "MCBinToTime(mcBinVal/4):result/4" }, { 0x0E26, "MCGetTrackTitle(mcDiskID/4,mcTrackNo,@PStringBuff)" },
{ 0x0F26, "MCSetTrackTitle(mcDiskID/4,TrackNum,@title)" }, { 0x1026, "MCGetProgram(mcDiskID/4,@resultBuff)" }, { 0x1126, "MCSetProgram(mcDiskID/4,@mcProg)" },
{ 0x1226, "MCGetDiscTitle(mcDiskID/4,@PStringBuff)" }, { 0x1326, "MCSetDiscTitle(mcDiskID/4,@title)" }, { 0x1426, "MCDStartUp(mcChannelNo,@portName,userID)" },
{ 0x1526, "MCDShutDown(mcChannelNo)" }, { 0x1626, "MCGetFeatures(mcChannelNo,mcFeatSel):result/4" }, { 0x1726, "MCPlay(mcChannelNo)" }, { 0x1826, "MCPause(mcChannelNo)" },
diff --git a/src/mame/machine/archimedes_keyb.cpp b/src/mame/machine/archimedes_keyb.cpp
index a50b7cea07a..6b1a2e55f6a 100644
--- a/src/mame/machine/archimedes_keyb.cpp
+++ b/src/mame/machine/archimedes_keyb.cpp
@@ -2,7 +2,23 @@
// copyright-holders:Angelo Salese, Sandro Ronco
/**********************************************************************
- Acorn Archimedes keyboard
+ Acorn Archimedes keyboard (A5000)
+
+ Keyboard variants:
+ A500 (external) 6500/11 MCU w/ 2732 ROM (dumped), see A500 Hardware Guide.
+ A3x0 (external) 8031 MCU w/ 2764 ROM (dumped), not documented.
+ A4x0 (external) 8031 MCU w/ 2764 ROM (dumped), same as A3x0.
+ A680 (external) unknown.
+ A3000 (internal) 8051 MCU (part 0280,022) w/ internal ROM (dumped), see A3000TRM.
+ A540 (external) 8051 MCU (part 0280,022) w/ internal ROM, see A500/R200TRM, same as A3000.
+ A5000 (external) 8051 MCU (part 0280,022) w/ internal ROM, see A5000TRM, same as A3000.
+ A4 (internal) 8051 MCU (part 0290,031) w/ internal ROM, see A4TRM. Supports PS/2 keyboard.
+ A30x0 (internal) 8051 MCU (part 0294,031) w/ internal ROM, see A3010TRM.
+ A4000 (external) likely same as A30x0, but not confirmed.
+
+ TODO:
+ - convert to slot device and move to bus/archimedes/keyboard.
+ - add other variants.
*********************************************************************/
@@ -188,15 +204,15 @@ static INPUT_PORTS_START( archimedes_keyboard )
PORT_BIT(0xfeff, IP_ACTIVE_LOW, IPT_UNUSED)
PORT_START("MOUSE.0")
- PORT_BIT(0xffff, IP_ACTIVE_HIGH, IPT_MOUSE_X) PORT_SENSITIVITY(50) PORT_KEYDELTA(0) PORT_RESET PORT_CODE(MOUSECODE_X) PORT_CHANGED_MEMBER(DEVICE_SELF, archimedes_keyboard_device, update_mouse_input, 0)
+ PORT_BIT(0xffff, IP_ACTIVE_HIGH, IPT_MOUSE_X) PORT_SENSITIVITY(100)
PORT_START("MOUSE.1")
- PORT_BIT(0xffff, IP_ACTIVE_HIGH, IPT_MOUSE_Y) PORT_SENSITIVITY(50) PORT_KEYDELTA(0) PORT_RESET PORT_CODE(MOUSECODE_Y) PORT_CHANGED_MEMBER(DEVICE_SELF, archimedes_keyboard_device, update_mouse_input, 1) PORT_REVERSE
+ PORT_BIT(0xffff, IP_ACTIVE_HIGH, IPT_MOUSE_Y) PORT_SENSITIVITY(100)
PORT_START("MOUSE.2")
PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(MOUSECODE_BUTTON1) PORT_NAME("Mouse Left")
- PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(MOUSECODE_BUTTON2) PORT_NAME("Mouse Center")
- PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(MOUSECODE_BUTTON3) PORT_NAME("Mouse Right")
+ PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(MOUSECODE_BUTTON3) PORT_NAME("Mouse Center")
+ PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(MOUSECODE_BUTTON2) PORT_NAME("Mouse Right")
INPUT_PORTS_END
@@ -242,7 +258,8 @@ void archimedes_keyboard_device::device_start()
save_item(NAME(m_mouse_x));
save_item(NAME(m_mouse_y));
- save_item(NAME(m_mouse_phase));
+ save_item(NAME(m_mouse_xphase));
+ save_item(NAME(m_mouse_yphase));
save_item(NAME(m_mouse_xref));
save_item(NAME(m_mouse_xdir));
save_item(NAME(m_mouse_yref));
@@ -256,14 +273,15 @@ void archimedes_keyboard_device::device_start()
void archimedes_keyboard_device::device_reset()
{
- m_mouse_x = 0;
- m_mouse_y = 0;
- m_mouse_phase = 1;
- m_mouse_xref = 1;
- m_mouse_xdir = 1;
- m_mouse_yref = 1;
- m_mouse_ydir = 1;
- m_mux = 0;
+ m_mouse_x = 0;
+ m_mouse_y = 0;
+ m_mouse_xphase = 1;
+ m_mouse_xref = 1;
+ m_mouse_xdir = 1;
+ m_mouse_yphase = 1;
+ m_mouse_yref = 1;
+ m_mouse_ydir = 1;
+ m_mux = 0;
transmit_register_reset();
receive_register_reset();
@@ -278,11 +296,11 @@ void archimedes_keyboard_device::device_reset()
void archimedes_keyboard_device::device_add_mconfig(machine_config &config)
{
I8051(config, m_mcu, 12_MHz_XTAL); // Philips 8051AH-2
- m_mcu->port_in_cb<0>().set([this]() { return m_keyboard[m_mux & 0x0f]->read() & 0xff; });
- m_mcu->port_in_cb<1>().set([this]() { return (m_keyboard[m_mux & 0x0f]->read() >> 8) & 0xff; });
+ m_mcu->port_in_cb<0>().set([this]() { return m_keyboard[m_mux]->read() & 0xff; });
+ m_mcu->port_in_cb<1>().set([this]() { return (m_keyboard[m_mux]->read() >> 8) & 0xff; });
m_mcu->port_in_cb<2>().set(FUNC(archimedes_keyboard_device::mouse_r));
m_mcu->port_in_cb<3>().set([this]() { return m_mouse[2]->read() & 0xff; });
- m_mcu->port_out_cb<2>().set([this](uint8_t data) { m_mux = data; });
+ m_mcu->port_out_cb<2>().set([this](uint8_t data) { m_mux = data & 0x0f; });
m_mcu->port_out_cb<3>().set(FUNC(archimedes_keyboard_device::leds_w));
m_mcu->serial_rx_cb().set([this]() { return get_received_char(); });
m_mcu->serial_tx_cb().set(FUNC(archimedes_keyboard_device::tx_w));
@@ -319,7 +337,7 @@ void archimedes_keyboard_device::tra_callback()
m_kout(transmit_register_get_data_bit());
}
-void archimedes_keyboard_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
+void archimedes_keyboard_device::device_timer(emu_timer &timer, device_timer_id id, int param)
{
// Mouse quadrature signals
// Increase Decrease
@@ -329,35 +347,72 @@ void archimedes_keyboard_device::device_timer(emu_timer &timer, device_timer_id
// 0 0 0 0
// 0 1 1 0
- switch (m_mouse_phase)
+ int16_t x = m_mouse[0]->read();
+ int16_t y = m_mouse[1]->read();
+
+ int16_t dx = x - m_mouse_x;
+ int16_t dy = y - m_mouse_y;
+
+ if (dx)
+ {
+ // Set the output pins according to the current phase
+ switch (m_mouse_xphase)
+ {
+ case 0:
+ m_mouse_xref = 1;
+ break;
+ case 1:
+ m_mouse_xdir = 1;
+ break;
+ case 2:
+ m_mouse_xref = 0;
+ break;
+ case 3:
+ m_mouse_xdir = 0;
+ break;
+ }
+
+ // Change phase
+ if (dx > 0)
+ m_mouse_xphase--;
+ else
+ m_mouse_xphase++;
+
+ // Range check the phase
+ m_mouse_xphase &= 3;
+ }
+
+ if (dy)
{
- case 0:
- m_mouse_xdir = m_mouse_xref = 1;
- m_mouse_ydir = m_mouse_yref = 1;
- break;
- case 1:
- m_mouse_xref = m_mouse_x < 0 ? 0 : 1;
- m_mouse_xdir = m_mouse_x > 0 ? 0 : 1;
- m_mouse_yref = m_mouse_y < 0 ? 0 : 1;
- m_mouse_ydir = m_mouse_y > 0 ? 0 : 1;
- break;
- case 2:
- m_mouse_xdir = m_mouse_xref = m_mouse_x != 0 ? 0 : 1;
- m_mouse_ydir = m_mouse_yref = m_mouse_y != 0 ? 0 : 1;
- break;
- case 3:
- m_mouse_xref = m_mouse_x > 0 ? 0 : 1;
- m_mouse_xdir = m_mouse_x < 0 ? 0 : 1;
- m_mouse_yref = m_mouse_y > 0 ? 0 : 1;
- m_mouse_ydir = m_mouse_y < 0 ? 0 : 1;
- if (m_mouse_x > 0) m_mouse_x--;
- if (m_mouse_x < 0) m_mouse_x++;
- if (m_mouse_y > 0) m_mouse_y--;
- if (m_mouse_y < 0) m_mouse_y++;
- break;
+ // Set the output pins according to the current phase
+ switch (m_mouse_yphase)
+ {
+ case 3:
+ m_mouse_yref = 0;
+ break;
+ case 2:
+ m_mouse_ydir = 0;
+ break;
+ case 1:
+ m_mouse_yref = 1;
+ break;
+ case 0:
+ m_mouse_ydir = 1;
+ break;
+ }
+
+ // Change phase
+ if (dy > 0)
+ m_mouse_yphase--;
+ else
+ m_mouse_yphase++;
+
+ // Range check the phase
+ m_mouse_yphase &= 3;
}
- m_mouse_phase = (m_mouse_phase + 1) & 3;
+ m_mouse_x = x;
+ m_mouse_y = y;
}
void archimedes_keyboard_device::leds_w(uint8_t data)
@@ -381,12 +436,3 @@ void archimedes_keyboard_device::tx_w(uint8_t data)
if (is_transmit_register_empty())
transmit_register_setup(data);
}
-
-INPUT_CHANGED_MEMBER(archimedes_keyboard_device::update_mouse_input)
-{
- if (param == 0)
- m_mouse_x = (int16_t)m_mouse[0]->read();
-
- if (param == 1)
- m_mouse_y = (int16_t)m_mouse[1]->read();
-}
diff --git a/src/mame/machine/archimedes_keyb.h b/src/mame/machine/archimedes_keyb.h
index 08207f0f6b8..821d929bd07 100644
--- a/src/mame/machine/archimedes_keyb.h
+++ b/src/mame/machine/archimedes_keyb.h
@@ -30,14 +30,13 @@ public:
auto kout() { return m_kout.bind(); }
DECLARE_WRITE_LINE_MEMBER(kin_w) { rx_w(state); }
- DECLARE_INPUT_CHANGED_MEMBER(update_mouse_input);
protected:
// device-level overrides
virtual void device_resolve_objects() override;
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_timer(emu_timer &timer, device_timer_id id, int param) override;
// optional information overrides
virtual const tiny_rom_entry *device_rom_region() const override;
@@ -60,15 +59,16 @@ private:
required_ioport_array<3> m_mouse;
output_finder<3> m_leds;
- emu_timer * m_mouse_timer;
- uint8_t m_mouse_phase;
- uint8_t m_mouse_xdir;
- uint8_t m_mouse_xref;
- uint8_t m_mouse_ydir;
- uint8_t m_mouse_yref;
- int16_t m_mouse_x;
- int16_t m_mouse_y;
- uint8_t m_mux;
+ emu_timer *m_mouse_timer;
+ uint8_t m_mouse_xphase;
+ uint8_t m_mouse_xdir;
+ uint8_t m_mouse_xref;
+ uint8_t m_mouse_yphase;
+ uint8_t m_mouse_ydir;
+ uint8_t m_mouse_yref;
+ int16_t m_mouse_x;
+ int16_t m_mouse_y;
+ uint8_t m_mux;
};
diff --git a/src/mame/machine/asic65.cpp b/src/mame/machine/asic65.cpp
index 6f9a021edd6..52c080ed0a9 100644
--- a/src/mame/machine/asic65.cpp
+++ b/src/mame/machine/asic65.cpp
@@ -169,7 +169,7 @@ void asic65_device::reset_line(int state)
*
*************************************/
-void asic65_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
+void asic65_device::device_timer(emu_timer &timer, device_timer_id id, int param)
{
switch (id)
{
diff --git a/src/mame/machine/asic65.h b/src/mame/machine/asic65.h
index 61fdac9d26f..3c333e8497b 100644
--- a/src/mame/machine/asic65.h
+++ b/src/mame/machine/asic65.h
@@ -55,7 +55,7 @@ protected:
virtual void device_start() override;
virtual void device_reset() override;
virtual void device_add_mconfig(machine_config &config) override;
- virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override;
+ virtual void device_timer(emu_timer &timer, device_timer_id id, int param) override;
private:
u8 m_asic65_type;
diff --git a/src/mame/machine/atarigen.cpp b/src/mame/machine/atarigen.cpp
index 057af93511c..604c7c240c6 100644
--- a/src/mame/machine/atarigen.cpp
+++ b/src/mame/machine/atarigen.cpp
@@ -35,13 +35,13 @@ void atarigen_state::machine_reset()
}
-void atarigen_state::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
+void atarigen_state::device_timer(emu_timer &timer, device_timer_id id, int param)
{
switch (id)
{
- // unhalt the CPU that was passed as a pointer
+ // unhalt the CPU
case TID_UNHALT_CPU:
- reinterpret_cast<device_t *>(ptr)->execute().set_input_line(INPUT_LINE_HALT, CLEAR_LINE);
+ m_maincpu->set_input_line(INPUT_LINE_HALT, CLEAR_LINE);
break;
}
}
@@ -69,8 +69,8 @@ void atarigen_state::halt_until_hblank_0(device_t &device, screen_device &screen
hblank += width;
// halt and set a timer to wake up
- device.execute().set_input_line(INPUT_LINE_HALT, ASSERT_LINE);
- timer_set(screen.scan_period() * (hblank - hpos) / width, TID_UNHALT_CPU, 0, (void *)&device);
+ m_maincpu->set_input_line(INPUT_LINE_HALT, ASSERT_LINE);
+ timer_set(screen.scan_period() * (hblank - hpos) / width, TID_UNHALT_CPU);
}
diff --git a/src/mame/machine/atarigen.h b/src/mame/machine/atarigen.h
index 2110928411f..e03c3e43136 100644
--- a/src/mame/machine/atarigen.h
+++ b/src/mame/machine/atarigen.h
@@ -28,7 +28,7 @@ protected:
// users must call through to these
virtual void machine_start() override;
virtual void machine_reset() override;
- virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override;
+ virtual void device_timer(emu_timer &timer, device_timer_id id, int param) override;
// video helpers
void halt_until_hblank_0(device_t &device, screen_device &screen);
diff --git a/src/mame/machine/atariscom.cpp b/src/mame/machine/atariscom.cpp
index 7165482d2f6..4c55b43a1ee 100644
--- a/src/mame/machine/atariscom.cpp
+++ b/src/mame/machine/atariscom.cpp
@@ -81,7 +81,7 @@ void atari_sound_comm_device::device_reset()
// calbacks
//-------------------------------------------------
-void atari_sound_comm_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
+void atari_sound_comm_device::device_timer(emu_timer &timer, device_timer_id id, int param)
{
switch (id)
{
diff --git a/src/mame/machine/atariscom.h b/src/mame/machine/atariscom.h
index 6b1d96917d5..abc0f8931e8 100644
--- a/src/mame/machine/atariscom.h
+++ b/src/mame/machine/atariscom.h
@@ -69,7 +69,7 @@ protected:
// device-level overrides
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_timer(emu_timer &timer, device_timer_id id, int param) override;
private:
// timer IDs
diff --git a/src/mame/machine/badlands.cpp b/src/mame/machine/badlands.cpp
index 1c3cb2c070c..b4c8d4f327b 100644
--- a/src/mame/machine/badlands.cpp
+++ b/src/mame/machine/badlands.cpp
@@ -24,8 +24,7 @@
*************************************/
// TODO: doesn't link?
-#ifdef UNUSED_FUNCTION
-const gfx_layout badlands_molayout =
+[[maybe_unused]] static const gfx_layout badlands_molayout =
{
16,8,
RGN_FRAC(1,1),
@@ -35,7 +34,6 @@ const gfx_layout badlands_molayout =
{ 0*8, 8*8, 16*8, 24*8, 32*8, 40*8, 48*8, 56*8 },
64*8
};
-#endif
/*************************************
*
diff --git a/src/mame/machine/bbc.cpp b/src/mame/machine/bbc.cpp
index 4281e2b0f1c..3cd5f5f24c1 100644
--- a/src/mame/machine/bbc.cpp
+++ b/src/mame/machine/bbc.cpp
@@ -1,12 +1,8 @@
// license:BSD-3-Clause
// copyright-holders:Gordon Jefferyes, Nigel Barnes
/******************************************************************************
- BBC Model B
-
- MESS Driver By:
- Gordon Jefferyes
- mess_bbc@romvault.com
+ BBC Model B
******************************************************************************/
diff --git a/src/mame/machine/bebox.cpp b/src/mame/machine/bebox.cpp
index dbc7f198063..97998b73473 100644
--- a/src/mame/machine/bebox.cpp
+++ b/src/mame/machine/bebox.cpp
@@ -726,7 +726,7 @@ void bebox_state::scsi53c810_pci_write(int function, int offset, uint32_t data,
}
-void bebox_state::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
+void bebox_state::device_timer(emu_timer &timer, device_timer_id id, int param)
{
switch (id)
{
@@ -768,7 +768,7 @@ void bebox_state::init_bebox()
/* set up boot and flash ROM */
membank("bank2")->set_base(memregion("user2")->base());
- /* install MESS managed RAM */
+ /* install managed RAM */
space_0.install_ram(0, m_ram->size() - 1, 0x02000000, m_ram->pointer());
space_1.install_ram(0, m_ram->size() - 1, 0x02000000, m_ram->pointer());
@@ -777,7 +777,7 @@ void bebox_state::init_bebox()
* lets CPU #1 go. However, it seems that CPU #1 jumps into never-never
* land, crashes, and then goes into NetBSD's crash handler which catches
* it. The current PowerPC core cannot catch this trip into never-never
- * land properly, and MESS crashes. In the interim, this "mitten" catches
+ * land properly, and MAME crashes. In the interim, this "mitten" catches
* the crash
*/
{
diff --git a/src/mame/machine/bingoct.cpp b/src/mame/machine/bingoct.cpp
index 497c2632ebf..d7dd3fca499 100644
--- a/src/mame/machine/bingoct.cpp
+++ b/src/mame/machine/bingoct.cpp
@@ -9,7 +9,7 @@
Hardware:
- 2x Z0840008PSC
- 32 MHz XTAL
- - MB8464A-15LL-SK (next go EPR-12646)
+ - MB8464A-15LL-SK (next to EPR-12646)
- 2x ASSP 5C68A
- 4x HM65256BLSP (next to 5C68A)
- 315-5338
diff --git a/src/mame/machine/bublbobl.cpp b/src/mame/machine/bublbobl.cpp
index 4cab1e64a47..59784418ca3 100644
--- a/src/mame/machine/bublbobl.cpp
+++ b/src/mame/machine/bublbobl.cpp
@@ -127,7 +127,7 @@ uint8_t bublbobl_state::tokiob_mcu_r()
}
-void bublbobl_state::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
+void bublbobl_state::device_timer(emu_timer &timer, device_timer_id id, int param)
{
switch (id)
{
diff --git a/src/mame/machine/cdicdic.cpp b/src/mame/machine/cdicdic.cpp
index 4eb6cd44dac..f858bb73864 100644
--- a/src/mame/machine/cdicdic.cpp
+++ b/src/mame/machine/cdicdic.cpp
@@ -17,7 +17,7 @@ STATUS:
TODO:
-- Decapping and proper emulation.
+- Work out more low-level functionality.
*******************************************************************************/
@@ -39,196 +39,259 @@ TODO:
#define LOG_RAM (1 << 9)
#define LOG_ALL (LOG_DECODES | LOG_SAMPLES | LOG_COMMANDS | LOG_SECTORS | LOG_IRQS | LOG_READS | LOG_WRITES | LOG_UNKNOWNS | LOG_RAM)
-#define VERBOSE (LOG_ALL)
+#define VERBOSE (0)
#include "logmacro.h"
// device type definition
DEFINE_DEVICE_TYPE(CDI_CDIC, cdicdic_device, "cdicdic", "CD-i CDIC")
-
//**************************************************************************
-// GLOBAL VARIABLES
+// STATIC MEMBERS
//**************************************************************************
-const int32_t cdicdic_device::s_cdic_adpcm_filter_coef[5][2] =
+const int16_t cdicdic_device::s_xa_filter_coef[4][2] =
{
- { 0,0 },
- { 60,0 },
- { 115,-52 },
- { 98,-55 },
- { 122,-60 },
+ { 0x000, 0x000 },
+ { 0x0F0, 0x000 },
+ { 0x1CC, -0x0D0 },
+ { 0x188, -0x0DC }
};
-//**************************************************************************
-// INLINES
-//**************************************************************************
-
-int cdicdic_device::is_valid_sample_buf(uint16_t addr) const
-{
- const uint8_t *cdram8 = ((uint8_t*)m_ram.get()) + addr;
- if (cdram8[10] != 0xff)
- {
- return 1;
- }
- return 0;
-}
+const int32_t cdicdic_device::s_samples_per_sector = 18 * 28 * 2;
-double cdicdic_device::sample_buf_freq(uint16_t addr) const
+const uint16_t cdicdic_device::s_crc_ccitt_table[256] =
{
- const uint8_t *cdram8 = ((uint8_t*)m_ram.get()) + addr + 8;
- switch (cdram8[2] & 0x3f)
- {
- case 0:
- case 1:
- case 16:
- case 17:
- return clock2() / 512.0f;
-
- case 4:
- case 5:
- return clock2() / 1024.0f;
+ 0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50a5, 0x60c6, 0x70e7,
+ 0x8108, 0x9129, 0xa14a, 0xb16b, 0xc18c, 0xd1ad, 0xe1ce, 0xf1ef,
+ 0x1231, 0x0210, 0x3273, 0x2252, 0x52b5, 0x4294, 0x72f7, 0x62d6,
+ 0x9339, 0x8318, 0xb37b, 0xa35a, 0xd3bd, 0xc39c, 0xf3ff, 0xe3de,
+ 0x2462, 0x3443, 0x0420, 0x1401, 0x64e6, 0x74c7, 0x44a4, 0x5485,
+ 0xa56a, 0xb54b, 0x8528, 0x9509, 0xe5ee, 0xf5cf, 0xc5ac, 0xd58d,
+ 0x3653, 0x2672, 0x1611, 0x0630, 0x76d7, 0x66f6, 0x5695, 0x46b4,
+ 0xb75b, 0xa77a, 0x9719, 0x8738, 0xf7df, 0xe7fe, 0xd79d, 0xc7bc,
+ 0x48c4, 0x58e5, 0x6886, 0x78a7, 0x0840, 0x1861, 0x2802, 0x3823,
+ 0xc9cc, 0xd9ed, 0xe98e, 0xf9af, 0x8948, 0x9969, 0xa90a, 0xb92b,
+ 0x5af5, 0x4ad4, 0x7ab7, 0x6a96, 0x1a71, 0x0a50, 0x3a33, 0x2a12,
+ 0xdbfd, 0xcbdc, 0xfbbf, 0xeb9e, 0x9b79, 0x8b58, 0xbb3b, 0xab1a,
+ 0x6ca6, 0x7c87, 0x4ce4, 0x5cc5, 0x2c22, 0x3c03, 0x0c60, 0x1c41,
+ 0xedae, 0xfd8f, 0xcdec, 0xddcd, 0xad2a, 0xbd0b, 0x8d68, 0x9d49,
+ 0x7e97, 0x6eb6, 0x5ed5, 0x4ef4, 0x3e13, 0x2e32, 0x1e51, 0x0e70,
+ 0xff9f, 0xefbe, 0xdfdd, 0xcffc, 0xbf1b, 0xaf3a, 0x9f59, 0x8f78,
+ 0x9188, 0x81a9, 0xb1ca, 0xa1eb, 0xd10c, 0xc12d, 0xf14e, 0xe16f,
+ 0x1080, 0x00a1, 0x30c2, 0x20e3, 0x5004, 0x4025, 0x7046, 0x6067,
+ 0x83b9, 0x9398, 0xa3fb, 0xb3da, 0xc33d, 0xd31c, 0xe37f, 0xf35e,
+ 0x02b1, 0x1290, 0x22f3, 0x32d2, 0x4235, 0x5214, 0x6277, 0x7256,
+ 0xb5ea, 0xa5cb, 0x95a8, 0x8589, 0xf56e, 0xe54f, 0xd52c, 0xc50d,
+ 0x34e2, 0x24c3, 0x14a0, 0x0481, 0x7466, 0x6447, 0x5424, 0x4405,
+ 0xa7db, 0xb7fa, 0x8799, 0x97b8, 0xe75f, 0xf77e, 0xc71d, 0xd73c,
+ 0x26d3, 0x36f2, 0x0691, 0x16b0, 0x6657, 0x7676, 0x4615, 0x5634,
+ 0xd94c, 0xc96d, 0xf90e, 0xe92f, 0x99c8, 0x89e9, 0xb98a, 0xa9ab,
+ 0x5844, 0x4865, 0x7806, 0x6827, 0x18c0, 0x08e1, 0x3882, 0x28a3,
+ 0xcb7d, 0xdb5c, 0xeb3f, 0xfb1e, 0x8bf9, 0x9bd8, 0xabbb, 0xbb9a,
+ 0x4a75, 0x5a54, 0x6a37, 0x7a16, 0x0af1, 0x1ad0, 0x2ab3, 0x3a92,
+ 0xfd2e, 0xed0f, 0xdd6c, 0xcd4d, 0xbdaa, 0xad8b, 0x9de8, 0x8dc9,
+ 0x7c26, 0x6c07, 0x5c64, 0x4c45, 0x3ca2, 0x2c83, 0x1ce0, 0x0cc1,
+ 0xef1f, 0xff3e, 0xcf5d, 0xdf7c, 0xaf9b, 0xbfba, 0x8fd9, 0x9ff8,
+ 0x6e17, 0x7e36, 0x4e55, 0x5e74, 0x2e93, 0x3eb2, 0x0ed1, 0x1ef0
+};
- default:
- return clock2() / 1024.0f;
- }
-}
+#define CRC_CCITT_ROUND(accum, data) (((accum << 8) | data) ^ s_crc_ccitt_table[accum >> 8])
-int cdicdic_device::sample_buf_size(uint16_t addr) const
+const uint8_t cdicdic_device::s_sector_scramble[2448] =
{
- const uint8_t *cdram8 = ((uint8_t*)m_ram.get()) + addr + 8;
- switch (cdram8[2] & 0x3f)
- {
- case 0:
- case 4:
- return 4;
-
- case 1:
- case 5:
- case 16:
- return 2;
-
- case 17:
- return 1;
-
- default:
- return 2;
- }
-}
+ // Sector sync area is not scrambled
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+
+ // Remaining data is scrambled
+ 0x01, 0x80, 0x00, 0x60, 0x00, 0x28, 0x00, 0x1e, 0x80, 0x08, 0x60, 0x06, 0xa8, 0x02, 0xfe, 0x81,
+ 0x80, 0x60, 0x60, 0x28, 0x28, 0x1e, 0x9e, 0x88, 0x68, 0x66, 0xae, 0xaa, 0xfc, 0x7f, 0x01, 0xe0,
+ 0x00, 0x48, 0x00, 0x36, 0x80, 0x16, 0xe0, 0x0e, 0xc8, 0x04, 0x56, 0x83, 0x7e, 0xe1, 0xe0, 0x48,
+ 0x48, 0x36, 0xb6, 0x96, 0xf6, 0xee, 0xc6, 0xcc, 0x52, 0xd5, 0xfd, 0x9f, 0x01, 0xa8, 0x00, 0x7e,
+ 0x80, 0x20, 0x60, 0x18, 0x28, 0x0a, 0x9e, 0x87, 0x28, 0x62, 0x9e, 0xa9, 0xa8, 0x7e, 0xfe, 0xa0,
+ 0x40, 0x78, 0x30, 0x22, 0x94, 0x19, 0xaf, 0x4a, 0xfc, 0x37, 0x01, 0xd6, 0x80, 0x5e, 0xe0, 0x38,
+ 0x48, 0x12, 0xb6, 0x8d, 0xb6, 0xe5, 0xb6, 0xcb, 0x36, 0xd7, 0x56, 0xde, 0xbe, 0xd8, 0x70, 0x5a,
+ 0xa4, 0x3b, 0x3b, 0x53, 0x53, 0x7d, 0xfd, 0xe1, 0x81, 0x88, 0x60, 0x66, 0xa8, 0x2a, 0xfe, 0x9f,
+ 0x00, 0x68, 0x00, 0x2e, 0x80, 0x1c, 0x60, 0x09, 0xe8, 0x06, 0xce, 0x82, 0xd4, 0x61, 0x9f, 0x68,
+ 0x68, 0x2e, 0xae, 0x9c, 0x7c, 0x69, 0xe1, 0xee, 0xc8, 0x4c, 0x56, 0xb5, 0xfe, 0xf7, 0x00, 0x46,
+ 0x80, 0x32, 0xe0, 0x15, 0x88, 0x0f, 0x26, 0x84, 0x1a, 0xe3, 0x4b, 0x09, 0xf7, 0x46, 0xc6, 0xb2,
+ 0xd2, 0xf5, 0x9d, 0x87, 0x29, 0xa2, 0x9e, 0xf9, 0xa8, 0x42, 0xfe, 0xb1, 0x80, 0x74, 0x60, 0x27,
+ 0x68, 0x1a, 0xae, 0x8b, 0x3c, 0x67, 0x51, 0xea, 0xbc, 0x4f, 0x31, 0xf4, 0x14, 0x47, 0x4f, 0x72,
+ 0xb4, 0x25, 0xb7, 0x5b, 0x36, 0xbb, 0x56, 0xf3, 0x7e, 0xc5, 0xe0, 0x53, 0x08, 0x3d, 0xc6, 0x91,
+ 0x92, 0xec, 0x6d, 0x8d, 0xed, 0xa5, 0x8d, 0xbb, 0x25, 0xb3, 0x5b, 0x35, 0xfb, 0x57, 0x03, 0x7e,
+ 0x81, 0xe0, 0x60, 0x48, 0x28, 0x36, 0x9e, 0x96, 0xe8, 0x6e, 0xce, 0xac, 0x54, 0x7d, 0xff, 0x61,
+ 0x80, 0x28, 0x60, 0x1e, 0xa8, 0x08, 0x7e, 0x86, 0xa0, 0x62, 0xf8, 0x29, 0x82, 0x9e, 0xe1, 0xa8,
+ 0x48, 0x7e, 0xb6, 0xa0, 0x76, 0xf8, 0x26, 0xc2, 0x9a, 0xd1, 0xab, 0x1c, 0x7f, 0x49, 0xe0, 0x36,
+ 0xc8, 0x16, 0xd6, 0x8e, 0xde, 0xe4, 0x58, 0x4b, 0x7a, 0xb7, 0x63, 0x36, 0xa9, 0xd6, 0xfe, 0xde,
+ 0xc0, 0x58, 0x50, 0x3a, 0xbc, 0x13, 0x31, 0xcd, 0xd4, 0x55, 0x9f, 0x7f, 0x28, 0x20, 0x1e, 0x98,
+ 0x08, 0x6a, 0x86, 0xaf, 0x22, 0xfc, 0x19, 0x81, 0xca, 0xe0, 0x57, 0x08, 0x3e, 0x86, 0x90, 0x62,
+ 0xec, 0x29, 0x8d, 0xde, 0xe5, 0x98, 0x4b, 0x2a, 0xb7, 0x5f, 0x36, 0xb8, 0x16, 0xf2, 0x8e, 0xc5,
+ 0xa4, 0x53, 0x3b, 0x7d, 0xd3, 0x61, 0x9d, 0xe8, 0x69, 0x8e, 0xae, 0xe4, 0x7c, 0x4b, 0x61, 0xf7,
+ 0x68, 0x46, 0xae, 0xb2, 0xfc, 0x75, 0x81, 0xe7, 0x20, 0x4a, 0x98, 0x37, 0x2a, 0x96, 0x9f, 0x2e,
+ 0xe8, 0x1c, 0x4e, 0x89, 0xf4, 0x66, 0xc7, 0x6a, 0xd2, 0xaf, 0x1d, 0xbc, 0x09, 0xb1, 0xc6, 0xf4,
+ 0x52, 0xc7, 0x7d, 0x92, 0xa1, 0xad, 0xb8, 0x7d, 0xb2, 0xa1, 0xb5, 0xb8, 0x77, 0x32, 0xa6, 0x95,
+ 0xba, 0xef, 0x33, 0x0c, 0x15, 0xc5, 0xcf, 0x13, 0x14, 0x0d, 0xcf, 0x45, 0x94, 0x33, 0x2f, 0x55,
+ 0xdc, 0x3f, 0x19, 0xd0, 0x0a, 0xdc, 0x07, 0x19, 0xc2, 0x8a, 0xd1, 0xa7, 0x1c, 0x7a, 0x89, 0xe3,
+ 0x26, 0xc9, 0xda, 0xd6, 0xdb, 0x1e, 0xdb, 0x48, 0x5b, 0x76, 0xbb, 0x66, 0xf3, 0x6a, 0xc5, 0xef,
+ 0x13, 0x0c, 0x0d, 0xc5, 0xc5, 0x93, 0x13, 0x2d, 0xcd, 0xdd, 0x95, 0x99, 0xaf, 0x2a, 0xfc, 0x1f,
+ 0x01, 0xc8, 0x00, 0x56, 0x80, 0x3e, 0xe0, 0x10, 0x48, 0x0c, 0x36, 0x85, 0xd6, 0xe3, 0x1e, 0xc9,
+ 0xc8, 0x56, 0xd6, 0xbe, 0xde, 0xf0, 0x58, 0x44, 0x3a, 0xb3, 0x53, 0x35, 0xfd, 0xd7, 0x01, 0x9e,
+ 0x80, 0x68, 0x60, 0x2e, 0xa8, 0x1c, 0x7e, 0x89, 0xe0, 0x66, 0xc8, 0x2a, 0xd6, 0x9f, 0x1e, 0xe8,
+ 0x08, 0x4e, 0x86, 0xb4, 0x62, 0xf7, 0x69, 0x86, 0xae, 0xe2, 0xfc, 0x49, 0x81, 0xf6, 0xe0, 0x46,
+ 0xc8, 0x32, 0xd6, 0x95, 0x9e, 0xef, 0x28, 0x4c, 0x1e, 0xb5, 0xc8, 0x77, 0x16, 0xa6, 0x8e, 0xfa,
+ 0xe4, 0x43, 0x0b, 0x71, 0xc7, 0x64, 0x52, 0xab, 0x7d, 0xbf, 0x61, 0xb0, 0x28, 0x74, 0x1e, 0xa7,
+ 0x48, 0x7a, 0xb6, 0xa3, 0x36, 0xf9, 0xd6, 0xc2, 0xde, 0xd1, 0x98, 0x5c, 0x6a, 0xb9, 0xef, 0x32,
+ 0xcc, 0x15, 0x95, 0xcf, 0x2f, 0x14, 0x1c, 0x0f, 0x49, 0xc4, 0x36, 0xd3, 0x56, 0xdd, 0xfe, 0xd9,
+ 0x80, 0x5a, 0xe0, 0x3b, 0x08, 0x13, 0x46, 0x8d, 0xf2, 0xe5, 0x85, 0x8b, 0x23, 0x27, 0x59, 0xda,
+ 0xba, 0xdb, 0x33, 0x1b, 0x55, 0xcb, 0x7f, 0x17, 0x60, 0x0e, 0xa8, 0x04, 0x7e, 0x83, 0x60, 0x61,
+ 0xe8, 0x28, 0x4e, 0x9e, 0xb4, 0x68, 0x77, 0x6e, 0xa6, 0xac, 0x7a, 0xfd, 0xe3, 0x01, 0x89, 0xc0,
+ 0x66, 0xd0, 0x2a, 0xdc, 0x1f, 0x19, 0xc8, 0x0a, 0xd6, 0x87, 0x1e, 0xe2, 0x88, 0x49, 0xa6, 0xb6,
+ 0xfa, 0xf6, 0xc3, 0x06, 0xd1, 0xc2, 0xdc, 0x51, 0x99, 0xfc, 0x6a, 0xc1, 0xef, 0x10, 0x4c, 0x0c,
+ 0x35, 0xc5, 0xd7, 0x13, 0x1e, 0x8d, 0xc8, 0x65, 0x96, 0xab, 0x2e, 0xff, 0x5c, 0x40, 0x39, 0xf0,
+ 0x12, 0xc4, 0x0d, 0x93, 0x45, 0xad, 0xf3, 0x3d, 0x85, 0xd1, 0xa3, 0x1c, 0x79, 0xc9, 0xe2, 0xd6,
+ 0xc9, 0x9e, 0xd6, 0xe8, 0x5e, 0xce, 0xb8, 0x54, 0x72, 0xbf, 0x65, 0xb0, 0x2b, 0x34, 0x1f, 0x57,
+ 0x48, 0x3e, 0xb6, 0x90, 0x76, 0xec, 0x26, 0xcd, 0xda, 0xd5, 0x9b, 0x1f, 0x2b, 0x48, 0x1f, 0x76,
+ 0x88, 0x26, 0xe6, 0x9a, 0xca, 0xeb, 0x17, 0x0f, 0x4e, 0x84, 0x34, 0x63, 0x57, 0x69, 0xfe, 0xae,
+ 0xc0, 0x7c, 0x50, 0x21, 0xfc, 0x18, 0x41, 0xca, 0xb0, 0x57, 0x34, 0x3e, 0x97, 0x50, 0x6e, 0xbc,
+ 0x2c, 0x71, 0xdd, 0xe4, 0x59, 0x8b, 0x7a, 0xe7, 0x63, 0x0a, 0xa9, 0xc7, 0x3e, 0xd2, 0x90, 0x5d,
+ 0xac, 0x39, 0xbd, 0xd2, 0xf1, 0x9d, 0x84, 0x69, 0xa3, 0x6e, 0xf9, 0xec, 0x42, 0xcd, 0xf1, 0x95,
+ 0x84, 0x6f, 0x23, 0x6c, 0x19, 0xed, 0xca, 0xcd, 0x97, 0x15, 0xae, 0x8f, 0x3c, 0x64, 0x11, 0xeb,
+ 0x4c, 0x4f, 0x75, 0xf4, 0x27, 0x07, 0x5a, 0x82, 0xbb, 0x21, 0xb3, 0x58, 0x75, 0xfa, 0xa7, 0x03,
+ 0x3a, 0x81, 0xd3, 0x20, 0x5d, 0xd8, 0x39, 0x9a, 0x92, 0xeb, 0x2d, 0x8f, 0x5d, 0xa4, 0x39, 0xbb,
+ 0x52, 0xf3, 0x7d, 0x85, 0xe1, 0xa3, 0x08, 0x79, 0xc6, 0xa2, 0xd2, 0xf9, 0x9d, 0x82, 0xe9, 0xa1,
+ 0x8e, 0xf8, 0x64, 0x42, 0xab, 0x71, 0xbf, 0x64, 0x70, 0x2b, 0x64, 0x1f, 0x6b, 0x48, 0x2f, 0x76,
+ 0x9c, 0x26, 0xe9, 0xda, 0xce, 0xdb, 0x14, 0x5b, 0x4f, 0x7b, 0x74, 0x23, 0x67, 0x59, 0xea, 0xba,
+ 0xcf, 0x33, 0x14, 0x15, 0xcf, 0x4f, 0x14, 0x34, 0x0f, 0x57, 0x44, 0x3e, 0xb3, 0x50, 0x75, 0xfc,
+ 0x27, 0x01, 0xda, 0x80, 0x5b, 0x20, 0x3b, 0x58, 0x13, 0x7a, 0x8d, 0xe3, 0x25, 0x89, 0xdb, 0x26,
+ 0xdb, 0x5a, 0xdb, 0x7b, 0x1b, 0x63, 0x4b, 0x69, 0xf7, 0x6e, 0xc6, 0xac, 0x52, 0xfd, 0xfd, 0x81,
+ 0x81, 0xa0, 0x60, 0x78, 0x28, 0x22, 0x9e, 0x99, 0xa8, 0x6a, 0xfe, 0xaf, 0x00, 0x7c, 0x00, 0x21,
+ 0xc0, 0x18, 0x50, 0x0a, 0xbc, 0x07, 0x31, 0xc2, 0x94, 0x51, 0xaf, 0x7c, 0x7c, 0x21, 0xe1, 0xd8,
+ 0x48, 0x5a, 0xb6, 0xbb, 0x36, 0xf3, 0x56, 0xc5, 0xfe, 0xd3, 0x00, 0x5d, 0xc0, 0x39, 0x90, 0x12,
+ 0xec, 0x0d, 0x8d, 0xc5, 0xa5, 0x93, 0x3b, 0x2d, 0xd3, 0x5d, 0x9d, 0xf9, 0xa9, 0x82, 0xfe, 0xe1,
+ 0x80, 0x48, 0x60, 0x36, 0xa8, 0x16, 0xfe, 0x8e, 0xc0, 0x64, 0x50, 0x2b, 0x7c, 0x1f, 0x61, 0xc8,
+ 0x28, 0x56, 0x9e, 0xbe, 0xe8, 0x70, 0x4e, 0xa4, 0x34, 0x7b, 0x57, 0x63, 0x7e, 0xa9, 0xe0, 0x7e,
+ 0xc8, 0x20, 0x56, 0x98, 0x3e, 0xea, 0x90, 0x4f, 0x2c, 0x34, 0x1d, 0xd7, 0x49, 0x9e, 0xb6, 0xe8,
+ 0x76, 0xce, 0xa6, 0xd4, 0x7a, 0xdf, 0x63, 0x18, 0x29, 0xca, 0x9e, 0xd7, 0x28, 0x5e, 0x9e, 0xb8,
+ 0x68, 0x72, 0xae, 0xa5, 0xbc, 0x7b, 0x31, 0xe3, 0x54, 0x49, 0xff, 0x76, 0xc0, 0x26, 0xd0, 0x1a,
+ 0xdc, 0x0b, 0x19, 0xc7, 0x4a, 0xd2, 0xb7, 0x1d, 0xb6, 0x89, 0xb6, 0xe6, 0xf6, 0xca, 0xc6, 0xd7,
+ 0x12, 0xde, 0x8d, 0x98, 0x65, 0xaa, 0xab, 0x3f, 0x3f, 0x50, 0x10, 0x3c, 0x0c, 0x11, 0xc5, 0xcc,
+ 0x53, 0x15, 0xfd, 0xcf, 0x01, 0x94, 0x00, 0x6f, 0x40, 0x2c, 0x30, 0x1d, 0xd4, 0x09, 0x9f, 0x46,
+ 0xe8, 0x32, 0xce, 0x95, 0x94, 0x6f, 0x2f, 0x6c, 0x1c, 0x2d, 0xc9, 0xdd, 0x96, 0xd9, 0xae, 0xda,
+ 0xfc, 0x5b, 0x01, 0xfb, 0x40, 0x43, 0x70, 0x31, 0xe4, 0x14, 0x4b, 0x4f, 0x77, 0x74, 0x26, 0xa7,
+ 0x5a, 0xfa, 0xbb, 0x03, 0x33, 0x41, 0xd5, 0xf0, 0x5f, 0x04, 0x38, 0x03, 0x52, 0x81, 0xfd, 0xa0,
+ 0x41, 0xb8, 0x30, 0x72, 0x94, 0x25, 0xaf, 0x5b, 0x3c, 0x3b, 0x51, 0xd3, 0x7c, 0x5d, 0xe1, 0xf9,
+ 0x88, 0x42, 0xe6, 0xb1, 0x8a, 0xf4, 0x67, 0x07, 0x6a, 0x82, 0xaf, 0x21, 0xbc, 0x18, 0x71, 0xca,
+ 0xa4, 0x57, 0x3b, 0x7e, 0x93, 0x60, 0x6d, 0xe8, 0x2d, 0x8e, 0x9d, 0xa4, 0x69, 0xbb, 0x6e, 0xf3,
+ 0x6c, 0x45, 0xed, 0xf3, 0x0d, 0x85, 0xc5, 0xa3, 0x13, 0x39, 0xcd, 0xd2, 0xd5, 0x9d, 0x9f, 0x29,
+ 0xa8, 0x1e, 0xfe, 0x88, 0x40, 0x66, 0xb0, 0x2a, 0xf4, 0x1f, 0x07, 0x48, 0x02, 0xb6, 0x81, 0xb6,
+ 0xe0, 0x76, 0xc8, 0x26, 0xd6, 0x9a, 0xde, 0xeb, 0x18, 0x4f, 0x4a, 0xb4, 0x37, 0x37, 0x56, 0x96,
+ 0xbe, 0xee, 0xf0, 0x4c, 0x44, 0x35, 0xf3, 0x57, 0x05, 0xfe, 0x83, 0x00, 0x61, 0xc0, 0x28, 0x50,
+ 0x1e, 0xbc, 0x08, 0x71, 0xc6, 0xa4, 0x52, 0xfb, 0x7d, 0x83, 0x61, 0xa1, 0xe8, 0x78, 0x4e, 0xa2,
+ 0xb4, 0x79, 0xb7, 0x62, 0xf6, 0xa9, 0x86, 0xfe, 0xe2, 0xc0, 0x49, 0x90, 0x36, 0xec, 0x16, 0xcd,
+ 0xce, 0xd5, 0x94, 0x5f, 0x2f, 0x78, 0x1c, 0x22, 0x89, 0xd9, 0xa6, 0xda, 0xfa, 0xdb, 0x03, 0x1b,
+ 0x41, 0xcb, 0x70, 0x57, 0x64, 0x3e, 0xab, 0x50, 0x7f, 0x7c, 0x20, 0x21, 0xd8, 0x18, 0x5a, 0x8a,
+ 0xbb, 0x27, 0x33, 0x5a, 0x95, 0xfb, 0x2f, 0x03, 0x5c, 0x01, 0xf9, 0xc0, 0x42, 0xd0, 0x31, 0x9c,
+ 0x14, 0x69, 0xcf, 0x6e, 0xd4, 0x2c, 0x5f, 0x5d, 0xf8, 0x39, 0x82, 0x92, 0xe1, 0xad, 0x88, 0x7d,
+ 0xa6, 0xa1, 0xba, 0xf8, 0x73, 0x02, 0xa5, 0xc1, 0xbb, 0x10, 0x73, 0x4c, 0x25, 0xf5, 0xdb, 0x07,
+ 0x1b, 0x42, 0x8b, 0x71, 0xa7, 0x64, 0x7a, 0xab, 0x63, 0x3f, 0x69, 0xd0, 0x2e, 0xdc, 0x1c, 0x59,
+ 0xc9, 0xfa, 0xd6, 0xc3, 0x1e, 0xd1, 0xc8, 0x5c, 0x56, 0xb9, 0xfe, 0xf2, 0xc0, 0x45, 0x90, 0x33,
+ 0x2c, 0x15, 0xdd, 0xcf, 0x19, 0x94, 0x0a, 0xef, 0x47, 0x0c, 0x32, 0x85, 0xd5, 0xa3, 0x1f, 0x39,
+ 0xc8, 0x12, 0xd6, 0x8d, 0x9e, 0xe5, 0xa8, 0x4b, 0x3e, 0xb7, 0x50, 0x76, 0xbc, 0x26, 0xf1, 0xda,
+ 0xc4, 0x5b, 0x13, 0x7b, 0x4d, 0xe3, 0x75, 0x89, 0xe7, 0x26, 0xca, 0x9a, 0xd7, 0x2b, 0x1e, 0x9f,
+ 0x48, 0x68, 0x36, 0xae, 0x96, 0xfc, 0x6e, 0xc1, 0xec, 0x50, 0x4d, 0xfc, 0x35, 0x81, 0xd7, 0x20,
+ 0x5e, 0x98, 0x38, 0x6a, 0x92, 0xaf, 0x2d, 0xbc, 0x1d, 0xb1, 0xc9, 0xb4, 0x56, 0xf7, 0x7e, 0xc6,
+ 0xa0, 0x52, 0xf8, 0x3d, 0x82, 0x91, 0xa1, 0xac, 0x78, 0x7d, 0xe2, 0xa1, 0x89, 0xb8, 0x66, 0xf2,
+ 0xaa, 0xc5, 0xbf, 0x13, 0x30, 0x0d, 0xd4, 0x05, 0x9f, 0x43, 0x28, 0x31, 0xde, 0x94, 0x58, 0x6f,
+ 0x7a, 0xac, 0x23, 0x3d, 0xd9, 0xd1, 0x9a, 0xdc, 0x6b, 0x19, 0xef, 0x4a, 0xcc, 0x37, 0x15, 0xd6,
+ 0x8f, 0x1e, 0xe4, 0x08, 0x4b, 0x46, 0xb7, 0x72, 0xf6, 0xa5, 0x86, 0xfb, 0x22, 0xc3, 0x59, 0x91,
+ 0xfa, 0xec, 0x43, 0x0d, 0xf1, 0xc5, 0x84, 0x53, 0x23, 0x7d, 0xd9, 0xe1, 0x9a, 0xc8, 0x6b, 0x16,
+ 0xaf, 0x4e, 0xfc, 0x34, 0x41, 0xd7, 0x70, 0x5e, 0xa4, 0x38, 0x7b, 0x52, 0xa3, 0x7d, 0xb9, 0xe1,
+ 0xb2, 0xc8, 0x75, 0x96, 0xa7, 0x2e, 0xfa, 0x9c, 0x43, 0x29, 0xf1, 0xde, 0xc4, 0x58, 0x53, 0x7a,
+ 0xbd, 0xe3, 0x31, 0x89, 0xd4, 0x66, 0xdf, 0x6a, 0xd8, 0x2f, 0x1a, 0x9c, 0x0b, 0x29, 0xc7, 0x5e,
+ 0xd2, 0xb8, 0x5d, 0xb2, 0xb9, 0xb5, 0xb2, 0xf7, 0x35, 0x86, 0x97, 0x22, 0xee, 0x99, 0x8c, 0x6a,
+ 0xe5, 0xef, 0x0b, 0x0c, 0x07, 0x45, 0xc2, 0xb3, 0x11, 0xb5, 0xcc, 0x77, 0x15, 0xe6, 0x8f, 0x0a,
+ 0xe4, 0x07, 0x0b, 0x42, 0x87, 0x71, 0xa2, 0xa4, 0x79, 0xbb, 0x62, 0xf3, 0x69, 0x85, 0xee, 0xe3,
+ 0x0c, 0x49, 0xc5, 0xf6, 0xd3, 0x06, 0xdd, 0xc2, 0xd9, 0x91, 0x9a, 0xec, 0x6b, 0x0d, 0xef, 0x45,
+ 0x8c, 0x33, 0x25, 0xd5, 0xdb, 0x1f, 0x1b, 0x48, 0x0b, 0x76, 0x87, 0x66, 0xe2, 0xaa, 0xc9, 0xbf,
+ 0x16, 0xf0, 0x0e, 0xc4, 0x04, 0x53, 0x43, 0x7d, 0xf1, 0xe1, 0x84, 0x48, 0x63, 0x76, 0xa9, 0xe6,
+ 0xfe, 0xca, 0xc0, 0x57, 0x10, 0x3e, 0x8c, 0x10, 0x65, 0xcc, 0x2b, 0x15, 0xdf, 0x4f, 0x18, 0x34,
+ 0x0a, 0x97, 0x47, 0x2e, 0xb2, 0x9c, 0x75, 0xa9, 0xe7, 0x3e, 0xca, 0x90, 0x57, 0x2c, 0x3e, 0x9d,
+ 0xd0, 0x69, 0x9c, 0x2e, 0xe9, 0xdc, 0x4e, 0xd9, 0xf4, 0x5a, 0xc7, 0x7b, 0x12, 0xa3, 0x4d, 0xb9,
+ 0xf5, 0xb2, 0xc7, 0x35, 0x92, 0x97, 0x2d, 0xae, 0x9d, 0xbc, 0x69, 0xb1, 0xee, 0xf4, 0x4c, 0x47,
+ 0x75, 0xf2, 0xa7, 0x05, 0xba, 0x83, 0x33, 0x21, 0xd5, 0xd8, 0x5f, 0x1a, 0xb8, 0x0b, 0x32, 0x87,
+ 0x55, 0xa2, 0xbf, 0x39, 0xb0, 0x12, 0xf4, 0x0d, 0x87, 0x45, 0xa2, 0xb3, 0x39, 0xb5, 0xd2, 0xf7,
+ 0x1d, 0x86, 0x89, 0xa2, 0xe6, 0xf9, 0x8a, 0xc2, 0xe7, 0x11, 0x8a, 0x8c, 0x67, 0x25, 0xea, 0x9b,
+ 0x0f, 0x2b, 0x44, 0x1f, 0x73, 0x48, 0x25, 0xf6, 0x9b, 0x06, 0xeb, 0x42, 0xcf, 0x71, 0x94, 0x24,
+ 0x6f, 0x5b, 0x6c, 0x3b, 0x6d, 0xd3, 0x6d, 0x9d, 0xed, 0xa9, 0x8d, 0xbe, 0xe5, 0xb0, 0x4b, 0x34,
+ 0x37, 0x57, 0x56, 0xbe, 0xbe, 0xf0, 0x70, 0x44, 0x24, 0x33, 0x5b, 0x55, 0xfb, 0x7f, 0x03, 0x60,
+ 0x01, 0xe8, 0x00, 0x4e, 0x80, 0x34, 0x60, 0x17, 0x68, 0x0e, 0xae, 0x84, 0x7c, 0x63, 0x61, 0xe9,
+ 0xe8, 0x4e, 0xce, 0xb4, 0x54, 0x77, 0x7f, 0x66, 0xa0, 0x2a, 0xf8, 0x1f, 0x02, 0x88, 0x01, 0xa6,
+ 0x80, 0x7a, 0xe0, 0x23, 0x08, 0x19, 0xc6, 0x8a, 0xd2, 0xe7, 0x1d, 0x8a, 0x89, 0xa7, 0x26, 0xfa,
+ 0x9a, 0xc3, 0x2b, 0x11, 0xdf, 0x4c, 0x58, 0x35, 0xfa, 0x97, 0x03, 0x2e, 0x81, 0xdc, 0x60, 0x59,
+ 0xe8, 0x3a, 0xce, 0x93, 0x14, 0x6d, 0xcf, 0x6d, 0x94, 0x2d, 0xaf, 0x5d, 0xbc, 0x39, 0xb1, 0xd2,
+ 0xf4, 0x5d, 0x87, 0x79, 0xa2, 0xa2, 0xf9, 0xb9, 0x82, 0xf2, 0xe1, 0x85, 0x88, 0x63, 0x26, 0xa9,
+ 0xda, 0xfe, 0xdb, 0x00, 0x5b, 0x40, 0x3b, 0x70, 0x13, 0x64, 0x0d, 0xeb, 0x45, 0x8f, 0x73, 0x24,
+ 0x25, 0xdb, 0x5b, 0x1b, 0x7b, 0x4b, 0x63, 0x77, 0x69, 0xe6, 0xae, 0xca, 0xfc, 0x57, 0x01, 0xfe,
+ 0x80, 0x40, 0x60, 0x30, 0x28, 0x14, 0x1e, 0x8f, 0x48, 0x64, 0x36, 0xab, 0x56, 0xff, 0x7e, 0xc0,
+ 0x20, 0x50, 0x18, 0x3c, 0x0a, 0x91, 0xc7, 0x2c, 0x52, 0x9d, 0xfd, 0xa9, 0x81, 0xbe, 0xe0, 0x70,
+ 0x48, 0x24, 0x36, 0x9b, 0x56, 0xeb, 0x7e, 0xcf, 0x60, 0x54, 0x28, 0x3f, 0x5e, 0x90, 0x38, 0x6c,
+ 0x12, 0xad, 0xcd, 0xbd, 0x95, 0xb1, 0xaf, 0x34, 0x7c, 0x17, 0x61, 0xce, 0xa8, 0x54, 0x7e, 0xbf,
+ 0x60, 0x70, 0x28, 0x24, 0x1e, 0x9b, 0x48, 0x6b, 0x76, 0xaf, 0x66, 0xfc, 0x2a, 0xc1, 0xdf, 0x10,
+ 0x58, 0x0c, 0x3a, 0x85, 0xd3, 0x23, 0x1d, 0xd9, 0xc9, 0x9a, 0xd6, 0xeb, 0x1e, 0xcf, 0x48, 0x54,
+ 0x36, 0xbf, 0x56, 0xf0, 0x3e, 0xc4, 0x10, 0x53, 0x4c, 0x3d, 0xf5, 0xd1, 0x87, 0x1c, 0x62, 0x89,
+ 0xe9, 0xa6, 0xce, 0xfa, 0xd4, 0x43, 0x1f, 0x71, 0xc8, 0x24, 0x56, 0x9b, 0x7e, 0xeb, 0x60, 0x4f,
+ 0x68, 0x34, 0x2e, 0x97, 0x5c, 0x6e, 0xb9, 0xec, 0x72, 0xcd, 0xe5, 0x95, 0x8b, 0x2f, 0x27, 0x5c,
+ 0x1a, 0xb9, 0xcb, 0x32, 0xd7, 0x55, 0x9e, 0xbf, 0x28, 0x70, 0x1e, 0xa4, 0x08, 0x7b, 0x46, 0xa3,
+ 0x72, 0xf9, 0xe5, 0x82, 0xcb, 0x21, 0x97, 0x58, 0x6e, 0xba, 0xac, 0x73, 0x3d, 0xe5, 0xd1, 0x8b,
+ 0x1c, 0x67, 0x49, 0xea, 0xb6, 0xcf, 0x36, 0xd4, 0x16, 0xdf, 0x4e, 0xd8, 0x34, 0x5a, 0x97, 0x7b,
+ 0x2e, 0xa3, 0x5c, 0x79, 0xf9, 0xe2, 0xc2, 0xc9, 0x91, 0x96, 0xec, 0x6e, 0xcd, 0xec, 0x55, 0x8d,
+ 0xff, 0x25, 0x80, 0x1b, 0x20, 0x0b, 0x58, 0x07, 0x7a, 0x82, 0xa3, 0x21, 0xb9, 0xd8, 0x72, 0xda,
+ 0xa5, 0x9b, 0x3b, 0x2b, 0x53, 0x5f, 0x7d, 0xf8, 0x21, 0x82, 0x98, 0x61, 0xaa, 0xa8, 0x7f, 0x3e,
+ 0xa0, 0x10, 0x78, 0x0c, 0x22, 0x85, 0xd9, 0xa3, 0x1a, 0xf9, 0xcb, 0x02, 0xd7, 0x41, 0x9e, 0xb0,
+ 0x68, 0x74, 0x2e, 0xa7, 0x5c, 0x7a, 0xb9, 0xe3, 0x32, 0xc9, 0xd5, 0x96, 0xdf, 0x2e, 0xd8, 0x1c,
+ 0x5a, 0x89, 0xfb, 0x26, 0xc3, 0x5a, 0xd1, 0xfb, 0x1c, 0x43, 0x49, 0xf1, 0xf6, 0xc4, 0x46, 0xd3,
+ 0x72, 0xdd, 0xe5, 0x99
+};
-static inline int16_t clamp(int16_t in)
-{
- return in;
-}
//**************************************************************************
// MEMBER FUNCTIONS
//**************************************************************************
-uint32_t cdicdic_device::increment_cdda_frame_bcd(uint32_t bcd)
-{
- uint8_t nybbles[6] =
- {
- static_cast<uint8_t>(bcd & 0x0000000f),
- static_cast<uint8_t>((bcd & 0x000000f0) >> 4),
- static_cast<uint8_t>((bcd & 0x00000f00) >> 8),
- static_cast<uint8_t>((bcd & 0x0000f000) >> 12),
- static_cast<uint8_t>((bcd & 0x000f0000) >> 16),
- static_cast<uint8_t>((bcd & 0x00f00000) >> 20)
- };
- nybbles[0]++;
- if (nybbles[0] == 5 && nybbles[1] == 7)
- {
- nybbles[0] = 0;
- nybbles[1] = 0;
- nybbles[2]++;
- }
- else if (nybbles[0] == 10)
- {
- nybbles[1]++;
- }
- if (nybbles[2] == 10)
- {
- nybbles[3]++;
- nybbles[2] = 0;
- }
- if (nybbles[3] == 6)
- {
- nybbles[4]++;
- nybbles[3] = 0;
- }
- if (nybbles[4] == 10)
- {
- nybbles[5]++;
- nybbles[4] = 0;
- }
- return (nybbles[5] << 20) | (nybbles[4] << 16) | (nybbles[3] << 12) | (nybbles[2] << 8) | (nybbles[1] << 4) | nybbles[0];
-}
-
-uint32_t cdicdic_device::increment_cdda_sector_bcd(uint32_t bcd)
-{
- uint8_t nybbles[6] =
- {
- static_cast<uint8_t>(bcd & 0x0000000f),
- static_cast<uint8_t>((bcd & 0x000000f0) >> 4),
- static_cast<uint8_t>((bcd & 0x00000f00) >> 8),
- static_cast<uint8_t>((bcd & 0x0000f000) >> 12),
- static_cast<uint8_t>((bcd & 0x000f0000) >> 16),
- static_cast<uint8_t>((bcd & 0x00f00000) >> 20)
- };
- nybbles[2]++;
- if (nybbles[2] == 10)
- {
- nybbles[3]++;
- nybbles[2] = 0;
- }
- if (nybbles[3] == 6)
- {
- nybbles[4]++;
- nybbles[3] = 0;
- }
- if (nybbles[4] == 10)
- {
- nybbles[5]++;
- nybbles[4] = 0;
- }
- return (nybbles[5] << 20) | (nybbles[4] << 16) | (nybbles[3] << 12) | (nybbles[2] << 8) | (nybbles[1] << 4) | nybbles[0];
-}
-
-void cdicdic_device::decode_xa_mono(int32_t *cdic_xa_last, const uint8_t *xa, int16_t *dp)
+void cdicdic_device::decode_xa_mono(int16_t *cdic_xa_last, const uint8_t *xa, int16_t *dp)
{
- int32_t l0 = cdic_xa_last[0];
- int32_t l1 = cdic_xa_last[1];
+ int16_t l0 = cdic_xa_last[0];
+ int16_t l1 = cdic_xa_last[1];
for (int32_t b = 0; b < 18; b++)
{
for (int32_t s = 0; s < 4; s++)
{
- uint8_t flags = xa[(4 + (s << 1)) ^ 1];
+ uint8_t flags = xa[4 + (s << 1)];
uint8_t shift = flags & 0xf;
- uint8_t filter = flags >> 4;
- int32_t f0 = s_cdic_adpcm_filter_coef[filter][0];
- int32_t f1 = s_cdic_adpcm_filter_coef[filter][1];
+ uint8_t filter = (flags >> 4) & 3;
+ int16_t f0 = s_xa_filter_coef[filter][0];
+ int16_t f1 = s_xa_filter_coef[filter][1];
for (int32_t i = 0; i < 28; i++)
{
- int16_t d = (xa[(16 + (i << 2) + s) ^ 1] & 0xf) << 12;
- d = clamp((d >> shift) + (((l0 * f0) + (l1 * f1) + 32) >> 6));
+ int16_t d = (xa[16 + (i << 2) + s] & 0xf) << 12;
+ d = (d >> shift) + (((l0 * f0) + (l1 * f1) + 128) >> 8);
*dp = d;
dp++;
l1 = l0;
l0 = d;
}
- flags = xa[(5 + (s << 1)) ^ 1];
+ flags = xa[5 + (s << 1)];
shift = flags & 0xf;
filter = flags >> 4;
- f0 = s_cdic_adpcm_filter_coef[filter][0];
- f1 = s_cdic_adpcm_filter_coef[filter][1];
+ f0 = s_xa_filter_coef[filter][0];
+ f1 = s_xa_filter_coef[filter][1];
for (int32_t i = 0; i < 28; i++)
{
- int16_t d = (xa[(16 + (i << 2) + s) ^ 1] >> 4) << 12;
- d = clamp((d >> shift) + (((l0 * f0) + (l1 * f1) + 32) >> 6));
+ int16_t d = (xa[16 + (i << 2) + s] >> 4) << 12;
+ d = (d >> shift) + (((l0 * f0) + (l1 * f1) + 128) >> 8);
*dp = d;
dp++;
l1 = l0;
@@ -243,25 +306,25 @@ void cdicdic_device::decode_xa_mono(int32_t *cdic_xa_last, const uint8_t *xa, in
cdic_xa_last[1] = l1;
}
-void cdicdic_device::decode_xa_mono8(int *cdic_xa_last, const unsigned char *xa, signed short *dp)
+void cdicdic_device::decode_xa_mono8(int16_t *cdic_xa_last, const unsigned char *xa, signed short *dp)
{
- int32_t l0 = cdic_xa_last[0];
- int32_t l1 = cdic_xa_last[1];
+ int16_t l0 = cdic_xa_last[0];
+ int16_t l1 = cdic_xa_last[1];
for (int32_t b = 0; b < 18; b++)
{
for (int32_t s = 0; s < 4; s++)
{
- uint8_t flags = xa[(4 + s) ^ 1];
+ uint8_t flags = xa[4 + s];
uint8_t shift = flags & 0xf;
- uint8_t filter = flags >> 4;
- int32_t f0 = s_cdic_adpcm_filter_coef[filter][0];
- int32_t f1 = s_cdic_adpcm_filter_coef[filter][1];
+ uint8_t filter = (flags >> 4) & 3;
+ int16_t f0 = s_xa_filter_coef[filter][0];
+ int16_t f1 = s_xa_filter_coef[filter][1];
for (int32_t i = 0; i < 28; i++)
{
- int16_t d = (xa[(16 + (i << 2) + s) ^ 1] << 8);
- d = clamp((d >> shift) + (((l0 * f0) + (l1 * f1) + 32) >> 6));
+ int16_t d = (xa[16 + (i << 2) + s] << 8);
+ d = (d >> shift) + (((l0 * f0) + (l1 * f1) + 128) >> 8);
*dp = d;
dp++;
l1 = l0;
@@ -276,41 +339,41 @@ void cdicdic_device::decode_xa_mono8(int *cdic_xa_last, const unsigned char *xa,
cdic_xa_last[1] = l1;
}
-void cdicdic_device::decode_xa_stereo(int32_t *cdic_xa_last, const uint8_t *xa, int16_t *dp)
+void cdicdic_device::decode_xa_stereo(int16_t *cdic_xa_last, const uint8_t *xa, int16_t *dp)
{
- int32_t l0 = cdic_xa_last[0];
- int32_t l1 = cdic_xa_last[1];
- int32_t l2 = cdic_xa_last[2];
- int32_t l3 = cdic_xa_last[3];
+ int16_t l0 = cdic_xa_last[0];
+ int16_t l1 = cdic_xa_last[1];
+ int16_t l2 = cdic_xa_last[2];
+ int16_t l3 = cdic_xa_last[3];
for (int32_t b = 0; b < 18; b++)
{
for (int32_t s = 0; s < 4; s++)
{
- uint8_t flags0 = xa[(4 + (s << 1)) ^ 1];
+ uint8_t flags0 = xa[4 + (s << 1)];
uint8_t shift0 = flags0 & 0xf;
- uint8_t filter0 = flags0 >> 4;
- uint8_t flags1 = xa[(5 + (s << 1)) ^ 1];
+ uint8_t filter0 = (flags0 >> 4) & 3;
+ uint8_t flags1 = xa[5 + (s << 1)];
uint8_t shift1 = flags1 & 0xf;
- uint8_t filter1 = flags1 >> 4;
+ uint8_t filter1 = (flags1 >> 4) & 3;
- int32_t f0 = s_cdic_adpcm_filter_coef[filter0][0];
- int32_t f1 = s_cdic_adpcm_filter_coef[filter0][1];
- int32_t f2 = s_cdic_adpcm_filter_coef[filter1][0];
- int32_t f3 = s_cdic_adpcm_filter_coef[filter1][1];
+ int16_t f0 = s_xa_filter_coef[filter0][0];
+ int16_t f1 = s_xa_filter_coef[filter0][1];
+ int16_t f2 = s_xa_filter_coef[filter1][0];
+ int16_t f3 = s_xa_filter_coef[filter1][1];
for (int32_t i = 0; i < 28; i++)
{
- int16_t d = xa[(16 + (i << 2) + s) ^ 1];
+ int16_t d = xa[16 + (i << 2) + s];
int16_t d0 = (d & 0xf) << 12;
int16_t d1 = (d >> 4) << 12;
- d0 = clamp((d0 >> shift0) + (((l0 * f0) + (l1 * f1) + 32) >> 6));
+ d0 = (d0 >> shift0) + (((l0 * f0) + (l1 * f1) + 128) >> 8);
*dp = d0;
dp++;
l1 = l0;
l0 = d0;
- d1 = clamp((d1 >> shift1) + (((l2 * f2) + (l3 * f3) + 32) >> 6));
+ d1 = (d1 >> shift1) + (((l2 * f2) + (l3 * f3) + 128) >> 8);
*dp = d1;
dp++;
l3 = l2;
@@ -327,40 +390,40 @@ void cdicdic_device::decode_xa_stereo(int32_t *cdic_xa_last, const uint8_t *xa,
cdic_xa_last[3] = l3;
}
-void cdicdic_device::decode_xa_stereo8(int32_t *cdic_xa_last, const uint8_t *xa, int16_t *dp)
+void cdicdic_device::decode_xa_stereo8(int16_t *cdic_xa_last, const uint8_t *xa, int16_t *dp)
{
- int32_t l0 = cdic_xa_last[0];
- int32_t l1 = cdic_xa_last[1];
- int32_t l2 = cdic_xa_last[2];
- int32_t l3 = cdic_xa_last[3];
+ int16_t l0 = cdic_xa_last[0];
+ int16_t l1 = cdic_xa_last[1];
+ int16_t l2 = cdic_xa_last[2];
+ int16_t l3 = cdic_xa_last[3];
for (int32_t b = 0; b < 18; b++)
{
for (int32_t s = 0; s < 4; s += 2)
{
- uint8_t flags0 = xa[(4 + s) ^ 1];
+ uint8_t flags0 = xa[4 + s];
uint8_t shift0 = flags0 & 0xf;
- uint8_t filter0 = flags0 >> 4;
- uint8_t flags1 = xa[(5 + s) ^ 1];
+ uint8_t filter0 = (flags0 >> 4) & 3;
+ uint8_t flags1 = xa[5 + s];
uint8_t shift1 = flags1 & 0xf;
- uint8_t filter1 = flags1 >> 4;
- int32_t f0 = s_cdic_adpcm_filter_coef[filter0][0];
- int32_t f1 = s_cdic_adpcm_filter_coef[filter0][1];
- int32_t f2 = s_cdic_adpcm_filter_coef[filter1][0];
- int32_t f3 = s_cdic_adpcm_filter_coef[filter1][1];
+ uint8_t filter1 = (flags1 >> 4) & 3;
+ int16_t f0 = s_xa_filter_coef[filter0][0];
+ int16_t f1 = s_xa_filter_coef[filter0][1];
+ int16_t f2 = s_xa_filter_coef[filter1][0];
+ int16_t f3 = s_xa_filter_coef[filter1][1];
for (int32_t i = 0; i < 28; i++)
{
- int16_t d0 = (xa[(16 + (i << 2) + s + 0) ^ 1] << 8);
- int16_t d1 = (xa[(16 + (i << 2) + s + 1) ^ 1] << 8);
+ int16_t d0 = (xa[16 + (i << 2) + s + 0] << 8);
+ int16_t d1 = (xa[16 + (i << 2) + s + 1] << 8);
- d0 = clamp((d0 >> shift0) + (((l0 * f0) + (l1 * f1) + 32) >> 6));
+ d0 = (d0 >> shift0) + (((l0 * f0) + (l1 * f1) + 128) >> 8);
*dp = d0;
dp++;
l1 = l0;
l0 = d0;
- d1 = clamp((d1 >> shift1) + (((l2 * f2) + (l3 * f3) + 32) >> 6));
+ d1 = (d1 >> shift1) + (((l2 * f2) + (l3 * f3) + 128) >> 8);
*dp = d1;
dp++;
l3 = l2;
@@ -377,599 +440,746 @@ void cdicdic_device::decode_xa_stereo8(int32_t *cdic_xa_last, const uint8_t *xa,
cdic_xa_last[3] = l3;
}
-void cdicdic_device::play_audio_sector()
+void cdicdic_device::decode_8bit_xa_unit(int channel, uint8_t param, const uint8_t *data, int16_t *out_buffer)
{
-}
+ int gain_shift = 8 - (param & 0xf);
-void cdicdic_device::decode_audio_sector(const uint8_t *xa, int32_t triggered)
-{
- // Get XA format from sector header
- const uint8_t *hdr = xa + 4;
- int32_t channels;
- int32_t bits = 4;
+ const int16_t *filter = s_xa_filter_coef[(param >> 4) & 3];
+ int16_t *old_samples = &m_xa_last[channel << 1];
- if (hdr[2] == 0xff && triggered == 1)
+ for (int i = 0; i < 28; i++)
{
- return;
+ int32_t sample = *data;
+ if (sample >= 128)
+ sample -= 256;
+ data += 4;
+
+ sample <<= gain_shift;
+
+ sample += (filter[0] * old_samples[0] + filter[1] * old_samples[1] + 128) / 256;
+
+ int16_t sample16 = (int16_t)sample;
+ if (sample < -32768)
+ sample16 = -32768;
+ else if (sample > 32767)
+ sample16 = 32767;
+
+ old_samples[1] = old_samples[0];
+ old_samples[0] = sample16;
+
+ out_buffer[i] = sample16;
}
+}
- int16_t *samples = &m_samples[m_decode_addr == 0x2800 ? 0 : 1][0];
- LOGMASKED(LOG_DECODES, "%s: decode_audio_sector: got header type %02x\n", machine().describe_context(), hdr[2]);
+void cdicdic_device::decode_4bit_xa_unit(int channel, uint8_t param, const uint8_t *data, uint8_t shift, int16_t *out_buffer)
+{
+ int gain_shift = 12 - (param & 0xf);
+
+ const int16_t *filter = s_xa_filter_coef[(param >> 4) & 3];
+ int16_t *old_samples = &m_xa_last[channel << 1];
- switch (hdr[2] & 0x3f) // ignore emphasis and reserved bits
+ for (int i = 0; i < 28; i++)
{
- case 0:
- channels = 1;
- m_audio_sample_freq = clock2() / 512.0f; // / 1024.0f;
- bits = 4;
- m_audio_sample_size = 4;
- break;
+ int32_t sample = (*data >> shift) & 0xf;
+ if (BIT(sample, 3))
+ sample -= 16;
+ data += 4;
- case 1:
- channels = 2;
- m_audio_sample_freq = clock2() / 512.0f;
- bits = 4;
- m_audio_sample_size = 2;
- break;
+ sample <<= gain_shift;
- case 4:
- channels = 1;
- m_audio_sample_freq = clock2() / 1024.0f; ///2.0f;
- bits = 4;
- m_audio_sample_size = 4;
- break;
+ sample += (filter[0] * old_samples[0] + filter[1] * old_samples[1] + 128) / 256;
- case 5:
- channels = 2;
- m_audio_sample_freq = clock2() / 1024.0f; //37800.0f/2.0f;
- bits = 4;
- m_audio_sample_size = 2;
- break;
+ int16_t sample16 = (int16_t)(uint16_t)(sample & 0xffff);
+ if (sample < -32768)
+ sample16 = -32768;
+ else if (sample > 32767)
+ sample16 = 32767;
- case 16:
- channels = 1;
- m_audio_sample_freq = clock2() / 512.0f;
- bits = 8;
- m_audio_sample_size = 2;
- break;
+ old_samples[1] = old_samples[0];
+ old_samples[0] = sample16;
- case 17:
- channels = 2;
- m_audio_sample_freq = clock2() / 512.0f;
- bits = 8;
- m_audio_sample_size = 1;
- break;
+ out_buffer[i] = sample16;
+ }
+}
- default:
- fatalerror("play_xa: unhandled xa mode %08x\n", hdr[2]);
+void cdicdic_device::play_raw_group(const uint8_t *data)
+{
+ int16_t samples[28];
+ for (int i = 0; i < 28; i++)
+ {
+ samples[i] = (int16_t)((data[1] << 8) | data[0]);
+ data += 4;
}
- m_dmadac[0]->set_frequency(m_audio_sample_freq);
- m_dmadac[1]->set_frequency(m_audio_sample_freq);
+ m_dmadac[0]->transfer(0, 1, 1, 28, samples);
+ m_dmadac[1]->transfer(0, 1, 1, 28, samples);
+}
- switch (channels)
+void cdicdic_device::play_xa_group(const uint8_t coding, const uint8_t *data)
+{
+ static const uint16_t s_4bit_header_offsets[8] = { 0, 1, 2, 3, 8, 9, 10, 11 };
+ static const uint16_t s_8bit_header_offsets[4] = { 0, 1, 2, 3 };
+ static const uint16_t s_4bit_data_offsets[8] = { 16, 16, 17, 17, 18, 18, 19, 19 };
+ static const uint16_t s_8bit_data_offsets[4] = { 16, 17, 18, 19 };
+
+ int16_t samples[28];
+
+ switch (coding & (CODING_BPS_MASK | CODING_CHAN_MASK))
{
- case 1:
- switch (bits)
+ case CODING_4BPS | CODING_MONO:
+ for (uint8_t i = 0; i < 8; i++)
{
- case 4:
- decode_xa_mono(m_xa_last, hdr + 4, samples);
- for (int32_t index = 18*28*8 - 1; index >= 0; index--)
- {
- samples[index*2 + 1] = samples[index];
- samples[index*2 + 0] = samples[index];
- }
- samples[18*28*16 + 0] = samples[18*28*16 + 2] = samples[18*28*16 + 4] = samples[18*28*16 + 6] = samples[18*28*16 + 8] = samples[18*28*16 + 10] = samples[18*28*16 + 12] = samples[18*28*16 + 14] = samples[18*28*16 - 2];
- samples[18*28*16 + 1] = samples[18*28*16 + 3] = samples[18*28*16 + 5] = samples[18*28*16 + 7] = samples[18*28*16 + 9] = samples[18*28*16 + 11] = samples[18*28*16 + 13] = samples[18*28*16 + 15] = samples[18*28*16 - 1];
- break;
- case 8:
- decode_xa_mono8(m_xa_last, hdr + 4, samples);
- for (int32_t index = 18*28*8 - 1; index >= 0; index--)
- {
- samples[index*2 + 1] = samples[index];
- samples[index*2 + 0] = samples[index];
- }
- samples[18*28*8 + 0] = samples[18*28*8 + 2] = samples[18*28*8 + 4] = samples[18*28*8 + 6] = samples[18*28*8 + 8] = samples[18*28*8 + 10] = samples[18*28*8 + 12] = samples[18*28*8 + 14] = samples[18*28*8 - 2];
- samples[18*28*8 + 1] = samples[18*28*8 + 3] = samples[18*28*8 + 5] = samples[18*28*8 + 7] = samples[18*28*8 + 9] = samples[18*28*8 + 11] = samples[18*28*8 + 13] = samples[18*28*8 + 15] = samples[18*28*8 - 1];
- break;
+ decode_4bit_xa_unit(0, data[s_4bit_header_offsets[i]], data + s_4bit_data_offsets[i], (i & 1) ? 4 : 0, samples);
+ m_dmadac[0]->transfer(0, 1, 1, 28, samples);
+ m_dmadac[1]->transfer(0, 1, 1, 28, samples);
}
- break;
- case 2:
- switch (bits)
+ return;
+
+ case CODING_4BPS | CODING_STEREO:
+ for (uint8_t i = 0; i < 8; i++)
{
- case 4:
- decode_xa_stereo(m_xa_last, hdr + 4, samples);
- samples[18*28*8 + 0] = samples[18*28*8 + 2] = samples[18*28*8 + 4] = samples[18*28*8 + 6] = samples[18*28*8 + 8] = samples[18*28*8 + 10] = samples[18*28*8 + 12] = samples[18*28*8 + 14] = samples[18*28*8 - 2];
- samples[18*28*8 + 1] = samples[18*28*8 + 3] = samples[18*28*8 + 5] = samples[18*28*8 + 7] = samples[18*28*8 + 9] = samples[18*28*8 + 11] = samples[18*28*8 + 13] = samples[18*28*8 + 15] = samples[18*28*8 - 1];
- //fwrite(samples, 1, 18*28*4*m_audio_sample_size, temp_adpcm);
- break;
- case 8:
- decode_xa_stereo8(m_xa_last, hdr + 4, samples);
- samples[18*28*4 + 0] = samples[18*28*4 + 2] = samples[18*28*4 + 4] = samples[18*28*4 + 6] = samples[18*28*4 + 8] = samples[18*28*4 + 10] = samples[18*28*4 + 12] = samples[18*28*4 + 14] = samples[18*28*4 - 2];
- samples[18*28*4 + 1] = samples[18*28*4 + 3] = samples[18*28*4 + 5] = samples[18*28*4 + 7] = samples[18*28*4 + 9] = samples[18*28*4 + 11] = samples[18*28*4 + 13] = samples[18*28*4 + 15] = samples[18*28*4 - 1];
- break;
+ decode_4bit_xa_unit(i & 1, data[s_4bit_header_offsets[i]], data + s_4bit_data_offsets[i], (i & 1) ? 4 : 0, samples);
+ m_dmadac[i & 1]->transfer(0, 1, 1, 28, samples);
}
- break;
+ return;
+
+ case CODING_8BPS | CODING_MONO:
+ for (uint8_t i = 0; i < 4; i++)
+ {
+ decode_8bit_xa_unit(0, data[s_8bit_header_offsets[i]], data + s_8bit_data_offsets[i], samples);
+ m_dmadac[0]->transfer(0, 1, 1, 28, samples);
+ m_dmadac[1]->transfer(0, 1, 1, 28, samples);
+ }
+ return;
+
+ case CODING_8BPS | CODING_STEREO:
+ for (uint8_t i = 0; i < 4; i++)
+ {
+ decode_8bit_xa_unit(i & 1, data[s_8bit_header_offsets[i]], data + s_8bit_data_offsets[i], samples);
+ m_dmadac[i & 1]->transfer(0, 1, 1, 28, samples);
+ }
+ return;
}
+}
- for (int i = 0; i < 2; i++)
+void cdicdic_device::play_cdda_sector(const uint8_t *data)
+{
+ m_dmadac[0]->set_frequency(44100);
+ m_dmadac[1]->set_frequency(44100);
+ m_dmadac[0]->set_volume(0x100);
+ m_dmadac[1]->set_volume(0x100);
+
+ int16_t samples[2][2352/4];
+ for (uint16_t i = 0; i < 2352/4; i++)
{
- m_dmadac[i]->enable(1);
- m_dmadac[i]->transfer(i, 1, 2, 18*28*2*m_audio_sample_size, &m_samples[m_decode_addr == 0x2800 ? 0 : 1][0]);
- m_dmadac[i]->flush();
+ samples[0][i] = (int16_t)((data[(i * 4) + 1] << 8) | data[(i * 4) + 0]);
+ samples[1][i] = (int16_t)((data[(i * 4) + 3] << 8) | data[(i * 4) + 2]);
}
+
+ m_dmadac[0]->transfer(0, 1, 1, SECTOR_SIZE/4, samples[0]);
+ m_dmadac[1]->transfer(0, 1, 1, SECTOR_SIZE/4, samples[1]);
}
-TIMER_CALLBACK_MEMBER( cdicdic_device::periodic_sample_trigger )
+void cdicdic_device::play_audio_sector(const uint8_t coding, const uint8_t *data)
{
- // Indicate that data has been decoded
- LOGMASKED(LOG_SAMPLES, "Flagging that audio data has been decoded\n");
- m_audio_buffer |= 0x8000;
+ if ((coding & CODING_CHAN_MASK) > CODING_STEREO || (coding & CODING_BPS_MASK) == CODING_BPS_MPEG || (coding & CODING_RATE_MASK) == CODING_RATE_RESV)
+ {
+ LOGMASKED(LOG_SECTORS, "Invalid coding (%02x), ignoring\n", coding);
+ return;
+ }
- // Set the CDIC interrupt line
- //LOGMASKED(LOG_SAMPLES, "Setting CDIC interrupt line for soundmap decode\n");
- //m_intreq_callback(ASSERT_LINE);
+ int channels = 2;
+ //offs_t buffer_length = 1;
+ if (!(coding & CODING_STEREO))
+ {
+ channels = 1;
+ //buffer_length *= 2;
+ }
+
+ int bits = 4;
+ switch (coding & CODING_BPS_MASK)
+ {
+ case CODING_8BPS:
+ bits = 8;
+ break;
+ case CODING_16BPS:
+ bits = 16;
+ fatalerror("play_audio_sector: unhandled 16-bit coding mode\n");
+ break;
+ default:
+ bits = 4;
+ //buffer_length *= 2;
+ break;
+ }
+
+ int32_t sample_frequency = 0;
+ switch (coding & CODING_RATE_MASK)
+ {
+ case CODING_37KHZ:
+ sample_frequency = clock2() / 512.0f;
+ break;
+ case CODING_18KHZ:
+ sample_frequency = clock2() / 1024.0f;
+ break;
+ case CODING_44KHZ:
+ fatalerror("play_audio_sector: unhandled 44KHz coding mode\n");
+ break;
+ default:
+ // Can't happen due to above early-out
+ break;
+ }
+
+ LOGMASKED(LOG_SECTORS, "Coding %02x, %d channels, %d bits, %08x frequency\n", coding, channels, bits, sample_frequency);
+
+ m_dmadac[0]->set_frequency(sample_frequency);
+ m_dmadac[1]->set_frequency(sample_frequency);
+ m_dmadac[0]->set_volume(0x100);
+ m_dmadac[1]->set_volume(0x100);
+
+ if (bits == 16 && channels == 2)
+ {
+ for (uint16_t i = 0; i < SECTOR_AUDIO_SIZE; i += 112, data += 112)
+ {
+ play_raw_group(data);
+ }
+ }
+ else
+ {
+ for (uint16_t i = 0; i < SECTOR_AUDIO_SIZE; i += 128, data += 128)
+ {
+ play_xa_group(coding, data);
+ }
+ }
}
-TIMER_CALLBACK_MEMBER( cdicdic_device::initial_sample_trigger )
+TIMER_CALLBACK_MEMBER( cdicdic_device::audio_tick )
{
- // Indicate that data has been decoded
- LOGMASKED(LOG_SAMPLES, "Flagging that audio data has been decoded\n");
- m_audio_buffer |= 0x8000;
-
- // Set the CDIC interrupt line
- LOGMASKED(LOG_SAMPLES, "Setting CDIC interrupt line for soundmap decode\n");
- m_intreq_callback(ASSERT_LINE);
+ if (m_audio_sector_counter > 0)
+ {
+ m_audio_sector_counter--;
+ if (m_audio_sector_counter > 0)
+ {
+ LOGMASKED(LOG_SAMPLES, "Audio sector counter %d, deducting and skipping\n", m_audio_sector_counter);
+ return;
+ }
+ LOGMASKED(LOG_SAMPLES, "Audio sector counter now 0, deducting and playing\n");
+ }
- sample_trigger();
+ if (m_decoding_audio_map)
+ {
+ process_audio_map();
+ }
}
-TIMER_CALLBACK_MEMBER( cdicdic_device::audio_sample_trigger )
+void cdicdic_device::process_audio_map()
{
- if (is_valid_sample_buf(m_decode_addr))
+ if (m_decode_addr == 0xffff)
{
- // Indicate that data has been decoded
- LOGMASKED(LOG_SAMPLES, "Flagging that audio data has been decoded\n");
- m_audio_buffer |= 0x8000;
+ m_audio_sector_counter = 0;
+ m_audio_format_sectors = 0;
+ m_decoding_audio_map = false;
+ return;
+ }
+
+ LOGMASKED(LOG_SAMPLES, "Procesing audio map from %04x\n", m_decode_addr);
+
+ uint8_t *ram = &m_ram[m_decode_addr & 0x3ffe];
+ m_decode_addr ^= 0x1a00;
- // Set the CDIC interrupt line
- LOGMASKED(LOG_SAMPLES, "Setting CDIC interrupt line for soundmap decode\n");
- m_intreq_callback(ASSERT_LINE);
+ const bool was_decoding = (m_audio_format_sectors != 0);
- sample_trigger();
+ const uint8_t coding = ram[(SECTOR_CODING2 - SECTOR_HEADER) ^ 1];
+ LOGMASKED(LOG_SAMPLES, "Coding is %02x\n", coding);
+ if (coding != 0xff)
+ {
+ m_decoding_audio_map = true;
+ m_audio_format_sectors = get_sector_count_for_coding(coding);
+ m_audio_sector_counter = m_audio_format_sectors;
+
+ ram += SECTOR_DATA - SECTOR_HEADER;
+ uint8_t swapped_data[(SECTOR_SIZE - (SECTOR_DATA - SECTOR_HEADER))];
+ for (uint16_t i = 0; i < (SECTOR_SIZE - (SECTOR_DATA - SECTOR_HEADER)); i++)
+ {
+ swapped_data[i ^ 1] = ram[i];
+ }
+ play_audio_sector(coding, swapped_data);
}
else
{
- // Indicate that data has been decoded
- LOGMASKED(LOG_SAMPLES, "Flagging end of sample\n");
+ m_decode_addr = 0xffff;
+ m_audio_sector_counter = m_audio_format_sectors;
+ }
+
+ if (was_decoding)
+ {
m_audio_buffer |= 0x8000;
+ update_interrupt_state();
+ }
+}
- // Set the CDIC interrupt line
- //LOGMASKED(LOG_SAMPLES, "Setting CDIC interrupt line to flag that sample decoding is done\n");
- //m_intreq_callback(ASSERT_LINE);
- m_z_buffer |= 1;
+void cdicdic_device::update_interrupt_state()
+{
+ const bool interrupt_active = (bool)BIT(m_x_buffer | m_audio_buffer, 15);
+ if (!interrupt_active)
+ LOGMASKED(LOG_SECTORS, "%s: Clearing CDIC interrupt line\n", machine().describe_context());
+ m_intreq_callback(interrupt_active ? ASSERT_LINE : CLEAR_LINE);
+}
+
+void cdicdic_device::descramble_sector(uint8_t *buffer)
+{
+ for (uint32_t i = 12; i < SECTOR_SIZE; i++)
+ {
+ buffer[i] ^= s_sector_scramble[i];
}
}
-void cdicdic_device::sample_trigger()
+bool cdicdic_device::is_valid_sector(const uint8_t *buffer)
{
- LOGMASKED(LOG_SAMPLES, "sample_trigger with m_decode_addr == %04x\n", m_decode_addr);
+ const uint32_t real_lba = m_curr_lba + 150;
+ const uint8_t mins = real_lba / (60 * 75);
+ const uint8_t secs = (real_lba / 75) % 60;
+ const uint8_t frac = real_lba % 75;
+ const uint8_t mins_bcd = ((mins / 10) << 4) | (mins % 10);
+ const uint8_t secs_bcd = ((secs / 10) << 4) | (secs % 10);
+ const uint8_t frac_bcd = ((frac / 10) << 4) | (frac % 10);
+
+ // Verify MSF
+ if (mins_bcd != buffer[SECTOR_MINUTES] || secs_bcd != buffer[SECTOR_SECONDS] || frac_bcd != buffer[SECTOR_FRACS])
+ {
+ LOGMASKED(LOG_SECTORS, "Not valid sector, MSF (%02x:%02x:%02x vs. %02x:%02x:%02x\n", mins_bcd, secs_bcd, frac_bcd, buffer[SECTOR_MINUTES], buffer[SECTOR_SECONDS], buffer[SECTOR_FRACS]);
+ return false;
+ }
- bool decoding = true;
- bool had_valid_sample = false;
- m_decode_period = attotime::zero;
- //const uint16_t decode_start = m_decode_addr;
- do
+ // Verify mode
+ if (buffer[SECTOR_MODE] != 1 && buffer[SECTOR_MODE] != 2)
{
- const bool valid_sample = is_valid_sample_buf(m_decode_addr & 0x3ffe);
+ LOGMASKED(LOG_SECTORS, "Not valid sector, mode %02x\n", buffer[SECTOR_MODE]);
+ return false;
+ }
- if (valid_sample)
- {
- had_valid_sample = true;
+ // Verify duplicate info
+ if (buffer[SECTOR_FILE1] != buffer[SECTOR_FILE2])
+ {
+ LOGMASKED(LOG_SECTORS, "Not valid sector, file %02x vs. %02x\n", buffer[SECTOR_FILE1], buffer[SECTOR_FILE2]);
+ return false;
+ }
+ if (buffer[SECTOR_CHAN1] != buffer[SECTOR_CHAN2])
+ {
+ LOGMASKED(LOG_SECTORS, "Not valid sector, channel %02x vs. %02x\n", buffer[SECTOR_CHAN1], buffer[SECTOR_CHAN2]);
+ return false;
+ }
+ if (buffer[SECTOR_SUBMODE1] != buffer[SECTOR_SUBMODE2])
+ {
+ LOGMASKED(LOG_SECTORS, "Not valid sector, channel %02x vs. %02x\n", buffer[SECTOR_SUBMODE1], buffer[SECTOR_SUBMODE2]);
+ return false;
+ }
+ if (buffer[SECTOR_CODING1] != buffer[SECTOR_CODING2])
+ {
+ LOGMASKED(LOG_SECTORS, "Not valid sector, coding %02x vs. %02x\n", buffer[SECTOR_CODING1], buffer[SECTOR_CODING2]);
+ return false;
+ }
- LOGMASKED(LOG_SAMPLES, "Hit audio_sample_trigger, with m_decode_addr == %04x, calling decode_audio_sector\n", m_decode_addr);
+ return true;
+}
- // Decode the data at Z+4, the same offset as a normal CD sector.
- decode_audio_sector(((uint8_t*)m_ram.get()) + (m_decode_addr & 0x3ffe) + 4, 1);
- play_audio_sector();
+bool cdicdic_device::is_mode2_sector_selected(const uint8_t *buffer)
+{
+ if ((buffer[SECTOR_FILE2] << 8) != m_file)
+ {
+ LOGMASKED(LOG_SECTORS, "Mode 2 sector is not selected, current file: %04x, disc file: %04x\n", m_file, buffer[SECTOR_FILE2]);
+ return false;
+ }
- // Delay until sample completion before requesting more data
- LOGMASKED(LOG_SAMPLES, "Data is valid, setting up a new callback\n");
- m_decode_period += attotime::from_hz(sample_buf_freq(m_decode_addr & 0x3ffe)) * (18*28*2*sample_buf_size(m_decode_addr & 0x3ffe));
- //m_periodic_sample_timer[m_decode_addr == 0x2800 ? 0 : 1]->adjust(m_decode_period);
- m_audio_sample_timer->adjust(m_decode_period);
- //dmadac_enable(&dmadac[0], 2, 0);
+ if (buffer[SECTOR_SUBMODE2] & SUBMODE_EOF)
+ {
+ LOGMASKED(LOG_SECTORS, "Mode 2 sector is EOF, queueing end of read\n");
+ m_disc_command = 0;
+ }
- m_decode_addr ^= 0x1a00;
- m_z_buffer ^= 0x1a00;
- LOGMASKED(LOG_SAMPLES, "Updated m_decode_addr, new value is %04x\n", m_decode_addr);
+ // End-of-File, End-of-Record, or Trigger sectors skip selection beyond initial file selection.
+ if (buffer[SECTOR_SUBMODE2] & (SUBMODE_EOF | SUBMODE_TRIG | SUBMODE_EOR))
+ {
+ LOGMASKED(LOG_SECTORS, "Mode 2 sector is selected due to EOF, TRIG, or EOR (%02x)\n", buffer[SECTOR_SUBMODE2]);
+ return true;
+ }
- // Indicate that data has been decoded
- //LOGMASKED(LOG_SAMPLES, "Flagging that audio data has been decoded\n");
- //m_audio_buffer |= 0x8000;
+ // Sectors with no applicable data are skipped.
+ if (!(buffer[SECTOR_SUBMODE2] & (SUBMODE_DATA | SUBMODE_AUDIO | SUBMODE_VIDEO)))
+ {
+ LOGMASKED(LOG_SECTORS, "Mode 2 sector is not selected due to being a message sector (%02x)\n", buffer[SECTOR_SUBMODE2]);
+ return false;
+ }
- // Set the CDIC interrupt line
- //LOGMASKED(LOG_SAMPLES, "Setting CDIC interrupt line for soundmap decode\n");
- //m_intreq_callback(ASSERT_LINE);
+ // Select based on the specified channel mask.
+ const bool channel_selected = (bool)BIT(m_channel, buffer[SECTOR_CHAN2]);
- // Swap buffer positions to indicate our new buffer position at the next read
+ LOGMASKED(LOG_SECTORS, "Mode 2 sector is %sselected due to channel (register %04x, buffer channel %04x)\n", channel_selected ? "" : "not ", m_channel, buffer[SECTOR_CHAN2]);
- //if (m_decode_addr == decode_start)
- {
- decoding = false;
- }
- }
- else
- {
- LOGMASKED(LOG_SAMPLES, "Data is not valid, stopping playback\n");
- m_audio_sample_timer->adjust(attotime::never);
- decoding = false;
+ return channel_selected;
+}
- // Indicate that data has been decoded
- LOGMASKED(LOG_SAMPLES, "Flagging that audio data has been decoded\n");
- //m_audio_buffer |= 0x8000;
+bool cdicdic_device::is_mode2_audio_selected(const uint8_t *buffer)
+{
+ // Non-Mode-2, Non-Audio sectors are never selected for audio playback.
+ if (!(buffer[SECTOR_SUBMODE2] & SUBMODE_FORM) || !(buffer[SECTOR_SUBMODE2] & SUBMODE_AUDIO))
+ {
+ LOGMASKED(LOG_SECTORS, "Audio is not selected; submode %02x\n", buffer[SECTOR_SUBMODE2]);
+ return false;
+ }
- // Set the CDIC interrupt line
- LOGMASKED(LOG_SAMPLES, "Setting CDIC interrupt line for soundmap decode\n");
- m_intreq_callback(ASSERT_LINE);
+ // Select based on the specified audio channel mask.
+ const bool channel_selected = (bool)BIT(m_audio_channel, buffer[SECTOR_CHAN2]);
- m_z_buffer |= 1;
- }
- } while (decoding);
+ LOGMASKED(LOG_SECTORS, "Mode 2 audio is %sselected due to channel (register %04x, buffer channel %04x)\n", channel_selected ? "" : "not ", m_audio_channel, buffer[SECTOR_CHAN2]);
+
+ return channel_selected;
+}
+
+TIMER_CALLBACK_MEMBER( cdicdic_device::sector_tick )
+{
+ if (m_disc_command == 0)
+ {
+ return;
+ }
- if (had_valid_sample)
+ if (m_disc_spinup_counter != 0)
{
- //m_periodic_sample_timer->adjust(m_decode_period);
+ LOGMASKED(LOG_SECTORS, "Sector tick, waiting on spinup\n");
+ m_disc_spinup_counter--;
+ return;
}
+
+ LOGMASKED(LOG_SECTORS, "About to process a disc sector\n");
+
+ process_disc_sector();
+
+ if (m_disc_command == 0)
+ {
+ LOGMASKED(LOG_SECTORS, "Disc command has been reset after processing; stopping processing.\n");
+ cancel_disc_read();
+ return;
+ }
+
+ m_curr_lba++;
}
-TIMER_CALLBACK_MEMBER( cdicdic_device::trigger_readback_int )
+uint8_t cdicdic_device::get_sector_count_for_coding(uint8_t coding)
{
- process_delayed_command();
+ uint8_t base_count = 2;
+
+ switch (coding & CODING_BPS_MASK)
+ {
+ case CODING_4BPS:
+ // Twice as many 4bpp audio frames fit as usual
+ base_count *= 2;
+ break;
+ case CODING_8BPS:
+ case CODING_16BPS:
+ // No multiplier vs. base
+ break;
+ case CODING_BPS_MPEG:
+ // Unsupported; clear to zero for now
+ base_count = 0;
+ break;
+ }
+
+ switch (coding & CODING_RATE_MASK)
+ {
+ case CODING_18KHZ:
+ // Twice as many half-rate audio frames fit as usual
+ base_count *= 2;
+ break;
+ case CODING_37KHZ:
+ case CODING_44KHZ:
+ // No multiplier vs. base
+ break;
+ case CODING_RATE_RESV:
+ // Unsupported reserved mode; clear to zero for now
+ base_count = 0;
+ break;
+ }
+
+ switch (coding & CODING_CHAN_MASK)
+ {
+ case CODING_MONO:
+ // Twice as many mono audio frames fit vs. stereo
+ base_count *= 2;
+ break;
+ case CODING_STEREO:
+ // No multiplier vs. base
+ break;
+ case CODING_CHAN_RESV:
+ case CODING_CHAN_MPEG:
+ // MPEG mode and reserved modes are unsupported; clear to zero for now
+ base_count = 0;
+ break;
+ }
+
+ return base_count;
}
-void cdicdic_device::process_delayed_command()
+void cdicdic_device::process_disc_sector()
{
- switch (m_command)
+ const uint32_t real_lba = m_curr_lba + 150;
+ const uint8_t mins = real_lba / (60 * 75);
+ const uint8_t secs = (real_lba / 75) % 60;
+ const uint8_t frac = real_lba % 75;
+ const uint8_t mins_bcd = ((mins / 10) << 4) | (mins % 10);
+ const uint8_t secs_bcd = ((secs / 10) << 4) | (secs % 10);
+ const uint8_t frac_bcd = ((frac / 10) << 4) | (frac % 10);
+
+ LOGMASKED(LOG_SECTORS, "Disc sector, current LBA: %08x, MSF: %02x %02x %02x\n", real_lba, mins_bcd, secs_bcd, frac_bcd);
+
+ uint8_t buffer[2560] = { 0 };
+ cdrom_read_data(m_cd, m_curr_lba, buffer, CD_TRACK_RAW_DONTCARE);
+
+ // Detect (badly) if we're dealing with a byteswapped loose-bin image
+ if (buffer[0] == 0xff && buffer[1] == 0x00)
{
- case 0x23: // Reset Mode 1
- case 0x24: // Reset Mode 2
- case 0x29: // Read Mode 1
- case 0x2a: // Read Mode 2
+ LOGMASKED(LOG_SECTORS, "Byteswapping\n");
+ m_cd_byteswap = true;
+ }
+
+ if (m_cd_byteswap)
+ {
+ for (uint16_t i = 0; i < 2560; i += 2)
{
- static const char* const s_cmds[8] =
- {
- "Reset Mode 1",
- "Reset Mode 2", 0, 0, 0, 0,
- "Read Mode 1",
- "Read Mode 2"
- };
- uint8_t buffer[2560] = { 0 };
- uint32_t msf = m_time >> 8;
- LOGMASKED(LOG_COMMANDS, "%s: Processing Delayed Command with MSF %06x: %s\n", machine().describe_context(), msf, s_cmds[m_command - 0x23]);
- uint8_t nybbles[6] =
- {
- static_cast<uint8_t>(msf & 0x0000000f),
- static_cast<uint8_t>((msf & 0x000000f0) >> 4),
- static_cast<uint8_t>((msf & 0x00000f00) >> 8),
- static_cast<uint8_t>((msf & 0x0000f000) >> 12),
- static_cast<uint8_t>((msf & 0x000f0000) >> 16),
- static_cast<uint8_t>((msf & 0x00f00000) >> 20)
- };
- if ((msf & 0x0000ff) >= 0x75)
- {
- LOGMASKED(LOG_COMMANDS, "%s: Weird frame timestamp detected: %02x\n", machine().describe_context(), (uint8_t)msf);
- msf &= 0xffff00;
- nybbles[0] = 0;
- nybbles[1] = 0;
- }
- if (nybbles[2] >= 2)
- {
- nybbles[2] -= 2;
- }
- else
- {
- nybbles[2] = 8 + nybbles[2];
- if (nybbles[3] > 0)
- {
- nybbles[3]--;
- }
- else
- {
- nybbles[3] = 5;
- if (nybbles[4] > 0)
- {
- nybbles[4]--;
- }
- else
- {
- nybbles[4] = 9;
- nybbles[5]--;
- }
- }
- }
- uint32_t lba = nybbles[0] + nybbles[1]*10 + ((nybbles[2] + nybbles[3]*10)*75) + ((nybbles[4] + nybbles[5]*10)*75*60);
+ std::swap(buffer[i], buffer[i + 1]);
+ }
+ }
+
+ if (!is_valid_sector(buffer))
+ {
+ uint8_t descramble_buffer[2560];
+ memcpy(descramble_buffer, buffer, sizeof(descramble_buffer));
+ LOGMASKED(LOG_SECTORS, "Sector seems to be encoded, attempting to apply descrambling\n");
+ descramble_sector(descramble_buffer);
- LOGMASKED(LOG_COMMANDS, "%s: Reading Mode %d sector from MSF location %06x / %x%x%x%x%x%x, LBA %08x\n", machine().describe_context(), m_command - 0x28,
- (m_time >> 8) - 0x200, nybbles[5], nybbles[4], nybbles[3], nybbles[2], nybbles[1], nybbles[0], lba);
+ if (!is_valid_sector(descramble_buffer))
+ {
+ LOGMASKED(LOG_SECTORS, "Sector remains invalid after descrambling, giving up and proceeding as normal\n");
+ }
+ else
+ {
+ memcpy(buffer, descramble_buffer, sizeof(descramble_buffer));
+ }
+ }
- cdrom_read_data(m_cd, lba, buffer, CD_TRACK_RAW_DONTCARE);
+ LOGMASKED(LOG_SECTORS, "Sector header data: %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\n",
+ buffer[ 0], buffer[ 1], buffer[ 2], buffer[ 3], buffer[ 4], buffer[ 5], buffer[ 6], buffer[ 7], buffer[ 8], buffer[ 9],
+ buffer[10], buffer[11], buffer[12], buffer[13], buffer[14], buffer[15], buffer[16], buffer[17], buffer[18], buffer[19],
+ buffer[20], buffer[21], buffer[22], buffer[23]);
- m_time += 0x100;
- if ((m_time & 0x00000f00) == 0x00000a00)
- {
- m_time &= 0xfffff0ff;
- m_time += 0x00001000;
- }
- if ((m_time & 0x0000ff00) == 0x00007500)
- {
- m_time &= 0xffff00ff;
- m_time += 0x00010000;
- if ((m_time & 0x000f0000) == 0x000a0000)
- {
- m_time &= 0xfff0ffff;
- m_time += 0x00100000;
- }
- }
- if ((m_time & 0x00ff0000) == 0x00600000)
+ if (buffer[SECTOR_MODE] == 2 && m_disc_mode == DISC_MODE2)
+ {
+ // First, filter whether we want to process this sector at all.
+ if (!is_mode2_sector_selected(buffer))
+ {
+ return;
+ }
+
+ // Next, determine if we want to process this sector as an audio sector.
+ if (is_mode2_audio_selected(buffer))
+ {
+ LOGMASKED(LOG_SECTORS, "Audio is selected\n");
+ m_audio_sector_counter = get_sector_count_for_coding(buffer[SECTOR_CODING2]);
+ m_decoding_audio_map = false;
+
+ play_audio_sector(buffer[SECTOR_CODING2], buffer + SECTOR_DATA);
+ }
+ }
+ else if (m_disc_mode == DISC_CDDA)
+ {
+ m_audio_sector_counter = 2;
+ m_decoding_audio_map = false;
+
+ // Byteswap if not already detected as byteswapped
+ if (!m_cd_byteswap)
+ {
+ uint8_t swapped_buffer[2560];
+ for (uint16_t i = 0; i < 2560; i += 2)
{
- m_time &= 0xff00ffff;
- m_time += 0x01000000;
- if ((m_time & 0x0f000000) == 0x0a000000)
- {
- m_time &= 0xf0ffffff;
- m_time += 0x10000000;
- }
+ swapped_buffer[i + 1] = buffer[i + 0];
+ swapped_buffer[i + 0] = buffer[i + 1];
}
+ play_cdda_sector(swapped_buffer);
+ }
+ else
+ {
+ play_cdda_sector(buffer);
+ }
- m_data_buffer &= ~0x0004;
- m_data_buffer ^= 0x0001;
+ if (frac != 0)
+ {
+ return;
+ }
+ }
- const bool file_match = (buffer[CDIC_SECTOR_FILE2] << 8) == m_file;
- const bool channel_match = (m_channel & (1 << buffer[CDIC_SECTOR_CHAN2])) != 0;
- const bool audio_channel_match = (m_audio_channel & (1 << buffer[CDIC_SECTOR_CHAN2])) != 0;
- const bool is_audio = (buffer[CDIC_SECTOR_SUBMODE2] & (CDIC_SUBMODE_FORM | CDIC_SUBMODE_DATA | CDIC_SUBMODE_AUDIO | CDIC_SUBMODE_VIDEO)) == (CDIC_SUBMODE_FORM | CDIC_SUBMODE_AUDIO);
- if (file_match)
- {
- if (is_audio && channel_match && audio_channel_match)
- {
- m_x_buffer |= 0x8000;
- //m_data_buffer |= 0x4000;
- m_data_buffer |= 4;
-
- LOGMASKED(LOG_SECTORS, "%s: Audio sector into %04x\n", machine().describe_context(), (m_data_buffer & 5) * 0xa00);
-
- for (int index = 6; index < 2352/2; index++)
- {
- m_ram[(m_data_buffer & 5) * (0xa00/2) + (index - 6)] = (buffer[index*2] << 8) | buffer[index*2 + 1];
- }
-
- decode_audio_sector(((uint8_t*)m_ram.get()) + ((m_data_buffer & 5) * 0xa00 + 4), 0);
-
- LOGMASKED(LOG_IRQS, "%s: Setting CDIC interrupt line for audio sector\n", machine().describe_context());
- //}
- m_intreq_callback(ASSERT_LINE);
- //else
- //{
- // LOGMASKED(LOG_IRQS, "%s: Setting CDIC interrupt line for ignored audio sector (m_channel %04x, m_audio_channel %04x, sector channel %04x\n",
- // machine().describe_context(), m_channel, m_audio_channel, (1 << buffer[CDIC_SECTOR_CHAN2]));
- // m_intreq_callback(ASSERT_LINE);
- //}
- }
- else if ((buffer[CDIC_SECTOR_SUBMODE2] & (CDIC_SUBMODE_DATA | CDIC_SUBMODE_AUDIO | CDIC_SUBMODE_VIDEO)) == 0x00)
- {
- m_x_buffer |= 0x8000;
- //m_data_buffer |= 0x4000;
-
- for (int index = 6; index < 2352/2; index++)
- {
- m_ram[(m_data_buffer & 5) * (0xa00/2) + (index - 6)] = (buffer[index*2] << 8) | buffer[index*2 + 1];
- }
-
- if ((buffer[CDIC_SECTOR_SUBMODE2] & CDIC_SUBMODE_TRIG) == CDIC_SUBMODE_TRIG ||
- (buffer[CDIC_SECTOR_SUBMODE2] & CDIC_SUBMODE_EOR) == CDIC_SUBMODE_EOR ||
- (buffer[CDIC_SECTOR_SUBMODE2] & CDIC_SUBMODE_EOF) == CDIC_SUBMODE_EOF)
- {
- LOGMASKED(LOG_IRQS, "%s: Setting CDIC interrupt line for message sector\n", machine().describe_context());
- m_intreq_callback(ASSERT_LINE);
- }
- else
- {
- LOGMASKED(LOG_SECTORS, "%s: Setting CDIC interrupt line for ignored message sector\n", machine().describe_context());
- m_intreq_callback(ASSERT_LINE);
- }
- }
- else if (channel_match)
- {
- m_x_buffer |= 0x8000;
- //m_data_buffer |= 0x4000;
-
- if (is_audio)
- {
- //m_data_buffer |= 4;
- //m_z_buffer = (m_data_buffer & 5) * 0xa00;
- }
-
- for (int index = 6; index < 2352/2; index++)
- {
- m_ram[(m_data_buffer & 5) * (0xa00/2) + (index - 6)] = (buffer[index*2] << 8) | buffer[index*2 + 1];
- }
-
- LOGMASKED(LOG_IRQS, "%s: Setting CDIC interrupt line for data sector to %04x, submode 2 flags are:\n", machine().describe_context(), (m_data_buffer & 5) * 0xa00);
- LOGMASKED(LOG_IRQS, "%s: Channel reg is: %08x, versus submode channel: %08x\n", machine().describe_context(), m_channel, (1 << buffer[CDIC_SECTOR_CHAN2]));
- if (!BIT(m_channel, buffer[CDIC_SECTOR_CHAN2]))
- {
- LOGMASKED(LOG_IRQS, "%s: Channel mismatch\n", machine().describe_context());
- m_intreq_callback(ASSERT_LINE);
- }
- else
- {
- m_intreq_callback(ASSERT_LINE);
- }
- const uint16_t submode2 = buffer[CDIC_SECTOR_SUBMODE2];
- if (submode2 & CDIC_SUBMODE_EOF) LOGMASKED(LOG_IRQS, "%s: CDIC_SUBMODE_EOF\n", machine().describe_context());
- if (submode2 & CDIC_SUBMODE_RT) LOGMASKED(LOG_IRQS, "%s: CDIC_SUBMODE_RT\n", machine().describe_context());
- if (submode2 & CDIC_SUBMODE_FORM) LOGMASKED(LOG_IRQS, "%s: CDIC_SUBMODE_FORM\n", machine().describe_context());
- if (submode2 & CDIC_SUBMODE_TRIG) LOGMASKED(LOG_IRQS, "%s: CDIC_SUBMODE_TRIG\n", machine().describe_context());
- if (submode2 & CDIC_SUBMODE_DATA) LOGMASKED(LOG_IRQS, "%s: CDIC_SUBMODE_DATA\n", machine().describe_context());
- if (submode2 & CDIC_SUBMODE_AUDIO) LOGMASKED(LOG_IRQS, "%s: CDIC_SUBMODE_AUDIO\n", machine().describe_context());
- if (submode2 & CDIC_SUBMODE_VIDEO) LOGMASKED(LOG_IRQS, "%s: CDIC_SUBMODE_VIDEO\n", machine().describe_context());
- if (submode2 & CDIC_SUBMODE_EOR) LOGMASKED(LOG_IRQS, "%s: CDIC_SUBMODE_EOR\n", machine().describe_context());
- }
- else
- {
- //m_x_buffer |= 0x8000;
-
- LOGMASKED(LOG_IRQS, "%s: No match: m_channel %04x, m_audio_channel %04x, sector channel %04x\n",
- machine().describe_context(), m_channel, m_audio_channel, (1 << buffer[CDIC_SECTOR_CHAN2]));
- const uint16_t submode2 = buffer[CDIC_SECTOR_SUBMODE2];
- if (submode2 & CDIC_SUBMODE_EOF) LOGMASKED(LOG_IRQS, "%s: CDIC_SUBMODE_EOF\n", machine().describe_context());
- if (submode2 & CDIC_SUBMODE_RT) LOGMASKED(LOG_IRQS, "%s: CDIC_SUBMODE_RT\n", machine().describe_context());
- if (submode2 & CDIC_SUBMODE_FORM) LOGMASKED(LOG_IRQS, "%s: CDIC_SUBMODE_FORM\n", machine().describe_context());
- if (submode2 & CDIC_SUBMODE_TRIG) LOGMASKED(LOG_IRQS, "%s: CDIC_SUBMODE_TRIG\n", machine().describe_context());
- if (submode2 & CDIC_SUBMODE_DATA) LOGMASKED(LOG_IRQS, "%s: CDIC_SUBMODE_DATA\n", machine().describe_context());
- if (submode2 & CDIC_SUBMODE_AUDIO) LOGMASKED(LOG_IRQS, "%s: CDIC_SUBMODE_AUDIO\n", machine().describe_context());
- if (submode2 & CDIC_SUBMODE_VIDEO) LOGMASKED(LOG_IRQS, "%s: CDIC_SUBMODE_VIDEO\n", machine().describe_context());
- if (submode2 & CDIC_SUBMODE_EOR) LOGMASKED(LOG_IRQS, "%s: CDIC_SUBMODE_EOR\n", machine().describe_context());
- //m_intreq_callback(ASSERT_LINE);
- }
+ // Calculate subcode data
+ uint8_t subcode_buffer[96];
+ memset(subcode_buffer, 0, sizeof(subcode_buffer));
- if ((buffer[CDIC_SECTOR_SUBMODE2] & CDIC_SUBMODE_EOF) == 0 && m_command != 0x23)
- {
- LOGMASKED(LOG_IRQS, "Setting CDIC processing to trigger in 75Hz due to non-EOF.\n");
- m_interrupt_timer->adjust(attotime::from_hz(75)); // 75Hz = 1x CD-ROM speed
- }
- else
- {
- LOGMASKED(LOG_IRQS, "Not setting CDIC processing, EOF is %d\n", (buffer[CDIC_SECTOR_SUBMODE2] & CDIC_SUBMODE_EOF) ? 1 : 0);
- m_interrupt_timer->adjust(attotime::never);
- //m_data_buffer &= ~0x4000;
- //m_interrupt_timer->adjust(attotime::from_hz(75));
- }
+ if (m_disc_mode == DISC_TOC)
+ {
+ uint8_t *toc_buffer = buffer;
+ const cdrom_toc *toc = cdrom_get_toc(m_cd);
+ uint32_t entry_count = 0;
+
+ // Determine total frame count for data, and total audio track count
+ uint32_t frames = toc->tracks[0].pregap;
+ int audio_tracks = 0;
+ int other_tracks = 0;
+ uint32_t audio_starts[CD_MAX_TRACKS];
+ for (uint32_t i = 0; i < toc->numtrks; i++)
+ {
+ if (toc->tracks[i].trktype != CD_TRACK_AUDIO)
+ {
+ frames += toc->tracks[i].frames + toc->tracks[i].extraframes;
}
else
{
- LOGMASKED(LOG_IRQS, "File mismatch\n");
+ audio_starts[audio_tracks++] = toc->tracks[i].logframeofs;
}
- break;
}
- case 0x2e: // Abort
- LOGMASKED(LOG_COMMANDS, "%s: Processing Delayed Command: Abort\n", machine().describe_context());
- m_interrupt_timer->adjust(attotime::never);
- //m_data_buffer &= ~4;
- break;
+ // Determine last-frame MSF
+ const uint8_t total_mins = frames / (60 * 75);
+ const uint8_t total_secs = (frames / 75) % 60;
+ const uint8_t total_frac = frames % 75;
- case 0x28: // Play CDDA audio
+ // Specify any audio tracks first
+ for (int i = 0; i < audio_tracks; i++)
{
- LOGMASKED(LOG_COMMANDS, "%s: Processing Delayed Command: Play CDDA Audio\n", machine().describe_context());
- uint8_t buffer[2560] = { 0 };
- uint32_t msf = (m_time & 0xffff7f00) >> 8;
- uint32_t next_msf = increment_cdda_frame_bcd((m_time & 0xffff7f00) >> 8);
- uint32_t rounded_next_msf = increment_cdda_sector_bcd((m_time & 0xffff0000) >> 8);
- uint8_t nybbles[6] =
- {
- static_cast<uint8_t>(msf & 0x0000000f),
- static_cast<uint8_t>((msf & 0x000000f0) >> 4),
- static_cast<uint8_t>((msf & 0x00000f00) >> 8),
- static_cast<uint8_t>((msf & 0x0000f000) >> 12),
- static_cast<uint8_t>((msf & 0x000f0000) >> 16),
- static_cast<uint8_t>((msf & 0x00f00000) >> 20)
- };
+ const uint8_t audio_mins = audio_starts[i] / (60 * 75);
+ const uint8_t audio_secs = (audio_starts[i] / 75) % 60;
+ const uint8_t audio_frac = audio_starts[i] % 75;
+ const uint8_t audio_mins_bcd = ((audio_mins / 10) << 4) | (audio_mins % 10);
+ const uint8_t audio_secs_bcd = ((audio_secs / 10) << 4) | (audio_secs % 10);
+ const uint8_t audio_frac_bcd = ((audio_frac / 10) << 4) | (audio_frac % 10);
- uint32_t lba = nybbles[0] + nybbles[1]*10 + ((nybbles[2] + nybbles[3]*10)*75) + ((nybbles[4] + nybbles[5]*10)*75*60);
+ const uint8_t track_bcd = (((i + 1) / 10) << 4) | ((i + 1) % 10);
- if (!cdrom_read_data(m_cd, lba, buffer, CD_TRACK_RAW_DONTCARE))
+ for (int j = 0; j < 3; j++)
{
- osd_printf_verbose("Unable to read CD-ROM data.\n", machine().describe_context());
+ *toc_buffer++ = 0x01; // Track type (CD-DA)
+ *toc_buffer++ = track_bcd; // Track number
+ *toc_buffer++ = audio_mins_bcd;
+ *toc_buffer++ = audio_secs_bcd;
+ *toc_buffer++ = audio_frac_bcd;
+ entry_count++;
}
+ }
+
+ // Packet A0 (lead-in)
+ for (int i = 0; i < 3; i++)
+ {
+ *toc_buffer++ = (other_tracks > 0) ? 0x41 : 0x01;
+ *toc_buffer++ = 0xa0;
+ *toc_buffer++ = 0x01;
+ *toc_buffer++ = (other_tracks > 0) ? 0x10 : 0x00;
+ *toc_buffer++ = 0x00;
+ entry_count++;
+ }
- if (!(msf & 0x0000ff))
+ // Packet A1
+ for (int i = 0; i < 3; i++)
+ {
+ *toc_buffer++ = (audio_tracks > 0) ? 0x01 : 0x41;
+ *toc_buffer++ = 0xa1;
+ if (audio_tracks > 0)
{
- LOGMASKED(LOG_COMMANDS, "%s: Playing CDDA sector from MSF location %06x\n", machine().describe_context(), m_time | 2);
- m_cdda->start_audio(lba, rounded_next_msf);
+ uint8_t last_audio_track = (uint8_t)(audio_tracks - 1);
+ *toc_buffer++ = ((last_audio_track / 10) << 4) | (last_audio_track % 10);
}
+ else
+ {
+ *toc_buffer++ = 0x00;
+ }
+ *toc_buffer++ = 0x00;
+ *toc_buffer++ = 0x00;
+ entry_count++;
+ }
- m_ram[(m_data_buffer & 5) * (0xa00/2) + 0x924/2] = 0x0001; // CTRL
- m_ram[(m_data_buffer & 5) * (0xa00/2) + 0x926/2] = 0x0001; // TRACK
- m_ram[(m_data_buffer & 5) * (0xa00/2) + 0x928/2] = 0x0000; // INDEX
- m_ram[(m_data_buffer & 5) * (0xa00/2) + 0x92a/2] = (m_time >> 24) & 0x000000ff; // MIN
- m_ram[(m_data_buffer & 5) * (0xa00/2) + 0x92c/2] = (m_time >> 16) & 0x000000ff; // SEC
- m_ram[(m_data_buffer & 5) * (0xa00/2) + 0x92e/2] = (m_time >> 8) & 0x0000007f; // FRAC
- m_ram[(m_data_buffer & 5) * (0xa00/2) + 0x930/2] = 0x0000; // ZERO
- m_ram[(m_data_buffer & 5) * (0xa00/2) + 0x932/2] = (m_time >> 24) & 0x000000ff; // AMIN
- m_ram[(m_data_buffer & 5) * (0xa00/2) + 0x934/2] = (m_time >> 16) & 0x000000ff; // ASEC
- m_ram[(m_data_buffer & 5) * (0xa00/2) + 0x936/2] = (m_time >> 8) & 0x0000007f; // AFRAC
- m_ram[(m_data_buffer & 5) * (0xa00/2) + 0x938/2] = 0x0000; // CRC1
- m_ram[(m_data_buffer & 5) * (0xa00/2) + 0x93a/2] = 0x0000; // CRC2
+ // Packet A2 (lead-out)
+ for (int i = 0; i < 3; i++)
+ {
+ *toc_buffer++ = (audio_tracks > 0) ? 0x01 : 0x41;
+ *toc_buffer++ = 0xa2;
+ *toc_buffer++ = ((total_mins / 10) << 4) | (total_mins % 10);
+ *toc_buffer++ = ((total_secs / 10) << 4) | (total_secs % 10);
+ *toc_buffer++ = ((total_frac / 10) << 4) | (total_frac % 10);
+ entry_count++;
+ }
- m_time = next_msf << 8;
+ uint8_t *toc_data = &buffer[(m_curr_lba % entry_count) * 5];
+
+ subcode_buffer[SUBCODE_Q_CONTROL] = toc_data[0];
+ subcode_buffer[SUBCODE_Q_TRACK] = 0x00;
+ subcode_buffer[SUBCODE_Q_INDEX] = toc_data[1];
+ subcode_buffer[SUBCODE_Q_MODE1_MINS] = 0xa0;
+ subcode_buffer[SUBCODE_Q_MODE1_SECS] = secs_bcd;
+ subcode_buffer[SUBCODE_Q_MODE1_FRAC] = frac_bcd;
+ subcode_buffer[SUBCODE_Q_MODE1_ZERO] = 0x00;
+ subcode_buffer[SUBCODE_Q_MODE1_AMINS] = toc_data[2];
+ subcode_buffer[SUBCODE_Q_MODE1_ASECS] = toc_data[3];
+ subcode_buffer[SUBCODE_Q_MODE1_AFRAC] = toc_data[4];
+ subcode_buffer[SUBCODE_Q_CRC0] = 0xff;
+ subcode_buffer[SUBCODE_Q_CRC1] = 0xff;
+ }
+ else
+ {
+ subcode_buffer[SUBCODE_Q_CONTROL] = (m_disc_mode == DISC_CDDA ? 0x01 : 0x41);
+ subcode_buffer[SUBCODE_Q_TRACK] = 0x01;
+ subcode_buffer[SUBCODE_Q_INDEX] = 0x01;
+ subcode_buffer[SUBCODE_Q_MODE1_MINS] = mins_bcd;
+ subcode_buffer[SUBCODE_Q_MODE1_SECS] = secs_bcd;
+ subcode_buffer[SUBCODE_Q_MODE1_FRAC] = frac_bcd;
+ subcode_buffer[SUBCODE_Q_MODE1_ZERO] = 0x00;
+ subcode_buffer[SUBCODE_Q_MODE1_AMINS] = mins_bcd;
+ subcode_buffer[SUBCODE_Q_MODE1_ASECS] = secs_bcd;
+ subcode_buffer[SUBCODE_Q_MODE1_AFRAC] = frac_bcd;
+ subcode_buffer[SUBCODE_Q_CRC0] = 0xff;
+ subcode_buffer[SUBCODE_Q_CRC1] = 0xff;
+ }
- // the following line BREAKS 'The Apprentice', hangs when you attempt to start the game
- //m_interrupt_timer->adjust(attotime::from_hz(75));
+ uint16_t crc_accum = 0;
+ for (int i = 0; i < 12; i++)
+ crc_accum = CRC_CCITT_ROUND(crc_accum, subcode_buffer[SUBCODE_Q_CONTROL + i]);
- m_x_buffer |= 0x8000;
- //m_data_buffer |= 0x4000;
+ subcode_buffer[SUBCODE_Q_CRC0] = (uint8_t)(crc_accum >> 8);
+ subcode_buffer[SUBCODE_Q_CRC1] = (uint8_t)crc_accum;
- for (int index = 6; index < 2352/2; index++)
- {
- m_ram[(m_data_buffer & 5) * (0xa00/2) + (index - 6)] = (buffer[index*2] << 8) | buffer[index*2 + 1];
- }
+ process_sector_data(buffer, subcode_buffer);
+}
- LOGMASKED(LOG_IRQS, "%s: Setting CDIC interrupt line for CDDA sector\n", machine().describe_context());
- m_intreq_callback(ASSERT_LINE);
- break;
- }
- case 0x2c: // Seek
- {
- LOGMASKED(LOG_COMMANDS, "%s: Processing Delayed Command: Seek\n", machine().describe_context());
- uint8_t buffer[2560] = { 0 };
- uint32_t msf = (m_time & 0xffff7f00) >> 8;
- uint32_t next_msf = increment_cdda_frame_bcd((m_time & 0xffff7f00) >> 8);
- uint8_t nybbles[6] =
- {
- static_cast<uint8_t>(msf & 0x0000000f),
- static_cast<uint8_t>((msf & 0x000000f0) >> 4),
- static_cast<uint8_t>((msf & 0x00000f00) >> 8),
- static_cast<uint8_t>((msf & 0x0000f000) >> 12),
- static_cast<uint8_t>((msf & 0x000f0000) >> 16),
- static_cast<uint8_t>((msf & 0x00f00000) >> 20)
- };
- uint32_t lba = nybbles[0] + nybbles[1]*10 + ((nybbles[2] + nybbles[3]*10)*75) + ((nybbles[4] + nybbles[5]*10)*75*60);
+void cdicdic_device::process_sector_data(const uint8_t *buffer, const uint8_t *subcode_buffer)
+{
+ m_data_buffer ^= 0x0001;
+ m_data_buffer &= ~0x0004;
- m_interrupt_timer->adjust(attotime::from_hz(75));
+ uint16_t *dev_buffer = (uint16_t *)&m_ram[(m_data_buffer & 0x0005) * 0xa00];
- cdrom_read_data(m_cd, lba, buffer, CD_TRACK_RAW_DONTCARE);
+ for (int i = SECTOR_HEADER; i < SECTOR_FILE2; i += 2)
+ *dev_buffer++ = ((uint16_t)buffer[i] << 8) | buffer[i + 1];
- m_data_buffer ^= 0x0001;
- m_x_buffer |= 0x8000;
- m_data_buffer |= 0x4000;
+ if (m_command == 0x2a && is_mode2_audio_selected(buffer))
+ {
+ m_data_buffer |= 0x0004;
+ dev_buffer += 0x1400;
+ }
- for (int index = 6; index < 2352/2; index++)
- {
- m_ram[(m_data_buffer & 5) * (0xa00/2) + (index - 6)] = (buffer[index*2] << 8) | buffer[index*2 + 1];
- }
+ for (int i = SECTOR_FILE2; i < SECTOR_SIZE; i += 2)
+ *dev_buffer++ = ((uint16_t)buffer[i] << 8) | buffer[i + 1];
- m_ram[(m_data_buffer & 5) * (0xa00/2) + 0x924/2] = 0x0041; // CTRL
- m_ram[(m_data_buffer & 5) * (0xa00/2) + 0x926/2] = 0x0001; // TRACK
- m_ram[(m_data_buffer & 5) * (0xa00/2) + 0x928/2] = 0x0000; // INDEX
- m_ram[(m_data_buffer & 5) * (0xa00/2) + 0x92a/2] = (m_time >> 24) & 0x000000ff; // MIN
- m_ram[(m_data_buffer & 5) * (0xa00/2) + 0x92c/2] = (m_time >> 16) & 0x000000ff; // SEC
- m_ram[(m_data_buffer & 5) * (0xa00/2) + 0x92e/2] = (m_time >> 8) & 0x0000007f; // FRAC
- m_ram[(m_data_buffer & 5) * (0xa00/2) + 0x930/2] = 0x0000; // ZERO
- m_ram[(m_data_buffer & 5) * (0xa00/2) + 0x932/2] = (m_time >> 24) & 0x000000ff; // AMIN
- m_ram[(m_data_buffer & 5) * (0xa00/2) + 0x934/2] = (m_time >> 16) & 0x000000ff; // ASEC
- m_ram[(m_data_buffer & 5) * (0xa00/2) + 0x936/2] = (m_time >> 8) & 0x0000007f; // AFRAC
- m_ram[(m_data_buffer & 5) * (0xa00/2) + 0x938/2] = 0x0000; // CRC1
- m_ram[(m_data_buffer & 5) * (0xa00/2) + 0x93a/2] = 0x0000; // CRC2
-
- m_time = next_msf << 8;
-
- LOGMASKED(LOG_IRQS, "%s: Setting CDIC interrupt line for Seek sector\n", machine().describe_context());
- m_intreq_callback(ASSERT_LINE);
- break;
- }
- }
+ for (int i = SUBCODE_Q_CONTROL; i <= SUBCODE_Q_CRC1; i++)
+ *dev_buffer++ = subcode_buffer[i];
+
+ m_x_buffer |= 0x8000;
+ m_data_buffer |= 0x4000;
+ update_interrupt_state();
+
+ if (m_command == 0x23 || m_command == 0x24) // Reset? If so, stop.
+ cancel_disc_read();
}
uint16_t cdicdic_device::regs_r(offs_t offset, uint16_t mem_mask)
@@ -1004,10 +1214,6 @@ uint16_t cdicdic_device::regs_r(offs_t offset, uint16_t mem_mask)
case 0x3c0c/2: // Audio Channel register
LOGMASKED(LOG_READS, "%s: cdic_r: Audio Channel Register = %04x & %04x\n", machine().describe_context(), m_audio_channel, mem_mask);
- if (m_break_on_achan)
- {
- machine().debug_break();
- }
return m_audio_channel;
case 0x3ff4/2: // ABUF
@@ -1015,11 +1221,7 @@ uint16_t cdicdic_device::regs_r(offs_t offset, uint16_t mem_mask)
uint16_t temp = m_audio_buffer;
LOGMASKED(LOG_READS, "%s: cdic_r: Audio Buffer Register = %04x & %04x\n", machine().describe_context(), temp, mem_mask);
m_audio_buffer &= 0x7fff;
- if (!((m_audio_buffer | m_x_buffer) & 0x8000))
- {
- m_intreq_callback(CLEAR_LINE);
- LOGMASKED(LOG_IRQS, "%s: Clearing CDIC interrupt line\n", machine().describe_context());
- }
+ update_interrupt_state();
return temp;
}
@@ -1028,29 +1230,20 @@ uint16_t cdicdic_device::regs_r(offs_t offset, uint16_t mem_mask)
uint16_t temp = m_x_buffer;
LOGMASKED(LOG_READS, "%s: cdic_r: X-Buffer Register = %04x & %04x\n", machine().describe_context(), temp, mem_mask);
m_x_buffer &= 0x7fff;
- if (!((m_audio_buffer | m_x_buffer) & 0x8000))
- {
- m_intreq_callback(CLEAR_LINE);
- LOGMASKED(LOG_IRQS, "%s: Clearing CDIC interrupt line\n", machine().describe_context());
- }
+ update_interrupt_state();
return temp;
}
case 0x3ffa/2: // AUDCTL
- {
+ if (!m_decoding_audio_map)
+ m_z_buffer ^= 0x0001;
LOGMASKED(LOG_READS, "%s: cdic_r: Z-Buffer Register Read: %04x & %04x\n", machine().describe_context(), m_z_buffer, mem_mask);
- if (m_audio_playback_timer->remaining().is_never() && m_audio_sample_timer->remaining().is_never())
- {
- return m_z_buffer | 1;
- }
return m_z_buffer;
- }
case 0x3ffe/2:
- {
LOGMASKED(LOG_READS, "%s: cdic_r: Data buffer Register = %04x & %04x\n", machine().describe_context(), m_data_buffer, mem_mask);
return m_data_buffer;
- }
+
default:
LOGMASKED(LOG_READS | LOG_UNKNOWNS, "%s: cdic_r: Unknown address: %04x & %04x\n", machine().describe_context(), addr*2, mem_mask);
return 0;
@@ -1117,19 +1310,19 @@ void cdicdic_device::regs_w(offs_t offset, uint16_t data, uint16_t mem_mask)
uint32_t start = m_scc->dma().channel[0].memory_address_counter;
uint32_t count = m_scc->dma().channel[0].transfer_counter;
uint32_t device_index = (data & 0x3fff) >> 1;
+ uint16_t *ram = (uint16_t *)m_ram.get();
LOGMASKED(LOG_WRITES, "%s: cdic_w: DMA Control Register = %04x & %04x\n", machine().describe_context(), data, mem_mask);
LOGMASKED(LOG_WRITES, "%s: Memory address counter: %08x\n", machine().describe_context(), m_scc->dma().channel[0].memory_address_counter);
LOGMASKED(LOG_WRITES, "%s: Doing copy, transferring %04x bytes %s\n", machine().describe_context(), count * 2, (m_scc->dma().channel[0].operation_control & OCR_D) ? "to main RAM" : "to device RAM");
- printf("\n");
for (uint32_t index = start / 2; index < (start / 2 + count); index++)
{
if (m_scc->dma().channel[0].operation_control & OCR_D)
{
- m_memory_space->write_word(index * 2, m_ram[device_index++]);
+ m_memory_space->write_word(index * 2, ram[device_index++]);
}
else
{
- m_ram[device_index++] = m_memory_space->read_word(index * 2);
+ ram[device_index++] = m_memory_space->read_word(index * 2);
}
}
m_scc->dma().channel[0].memory_address_counter += m_scc->dma().channel[0].transfer_counter * 2;
@@ -1137,29 +1330,21 @@ void cdicdic_device::regs_w(offs_t offset, uint16_t data, uint16_t mem_mask)
}
case 0x3ffa/2:
- {
LOGMASKED(LOG_WRITES, "%s: cdic_w: Z-Buffer Register Write: %04x & %04x\n", machine().describe_context(), data, mem_mask);
COMBINE_DATA(&m_z_buffer);
- if (m_z_buffer & 0x2000)
+ if (!(m_z_buffer & 0x2000))
{
- //if (m_audio_sample_timer->remaining().is_never())
- {
- m_decode_addr = m_z_buffer & 0x3a00;
- LOGMASKED(LOG_WRITES, "%s: New decode address: %04x\n", machine().describe_context(), m_decode_addr);
- m_audio_playback_timer->adjust(attotime::from_hz(1000));
- //m_decode_delay = 1;
- //m_audio_sample_timer->adjust(attotime::from_hz(75));
- }
+ m_decode_addr = 0xffff;
}
- else
+ else if (!m_decoding_audio_map)
{
- m_decode_addr = 0xffff;
- m_audio_sample_timer->adjust(attotime::never);
- m_periodic_sample_timer[0]->adjust(attotime::never);
- m_periodic_sample_timer[1]->adjust(attotime::never);
+ m_decode_addr = m_z_buffer & 0x3a00;
+ m_audio_format_sectors = 0;
+ m_audio_sector_counter = 1;
+ m_decoding_audio_map = true;
+ std::fill_n(&m_xa_last[0], 4, 0);
}
break;
- }
case 0x3ffc/2:
LOGMASKED(LOG_WRITES, "%s: cdic_w: Interrupt Vector Register = %04x & %04x\n", machine().describe_context(), data, mem_mask);
@@ -1167,73 +1352,113 @@ void cdicdic_device::regs_w(offs_t offset, uint16_t data, uint16_t mem_mask)
break;
case 0x3ffe/2:
- {
LOGMASKED(LOG_WRITES, "%s: cdic_w: Data Buffer Register = %04x & %04x\n", machine().describe_context(), data, mem_mask);
COMBINE_DATA(&m_data_buffer);
if (m_data_buffer & 0x8000)
{
- m_audio_sample_timer->adjust(attotime::never);
- m_audio_playback_timer->adjust(attotime::never);
- m_periodic_sample_timer[0]->adjust(attotime::never);
- m_periodic_sample_timer[1]->adjust(attotime::never);
LOGMASKED(LOG_WRITES, "%s: cdic_w: Data Buffer high-bit set, beginning command processing\n", machine().describe_context());
- switch (m_command)
- {
- case 0x23: // Reset Mode 1
- case 0x24: // Reset Mode 2
- LOGMASKED(LOG_WRITES, "%s: cdic_w: Reset Mode %d command\n", machine().describe_context(), m_command - 0x22);
- m_interrupt_timer->adjust(attotime::never);
- m_dmadac[0]->enable(0);
- m_dmadac[1]->enable(0);
- m_data_buffer &= 0x7fff;
- break;
- case 0x2e: // Abort
- LOGMASKED(LOG_WRITES, "%s: cdic_w: Abort command\n", machine().describe_context());
- m_interrupt_timer->adjust(attotime::never);
- //m_audio_sample_timer->adjust(attotime::never);
- //m_periodic_sample_timer->adjust(attotime::never);
- m_dmadac[0]->enable(0);
- m_dmadac[1]->enable(0);
- m_data_buffer &= 0x3fff;
- break;
- case 0x2b: // Stop CDDA
- LOGMASKED(LOG_WRITES, "%s: cdic_w: Stop CDDA\n", machine().describe_context());
- m_cdda->stop_audio();
- m_interrupt_timer->adjust(attotime::never);
- m_data_buffer &= 0x7fff;
- break;
- case 0x29: // Read Mode 1
- case 0x2a: // Read Mode 2
- case 0x28: // Play CDDA
- case 0x2c: // Seek
- {
- attotime period = m_interrupt_timer->remaining();
- if (!period.is_never())
- {
- LOGMASKED(LOG_WRITES, "%s: cdic_w: Other command (%02x), interrupt in-flight, letting it ride\n", machine().describe_context(), m_command);
- m_interrupt_timer->adjust(period);
- }
- else
- {
- LOGMASKED(LOG_WRITES, "%s: cdic_w: Other command (%02x), interrupt not in-flight, interrupting in 75Hz\n", machine().describe_context(), m_command);
- m_interrupt_timer->adjust(attotime::from_hz(75));
- }
- m_data_buffer &= 0x7fff;
- break;
- }
- default:
- LOGMASKED(LOG_COMMANDS, "%s: Unknown CDIC command: %02x\n", machine().describe_context(), m_command);
- break;
- }
+ handle_cdic_command();
+ }
+ if (!(m_data_buffer & 0x4000))
+ {
+ m_disc_command = 0;
+ m_disc_mode = 0;
+ m_disc_spinup_counter = 0;
+ m_curr_lba = 0;
}
break;
- }
+
default:
LOGMASKED(LOG_WRITES | LOG_UNKNOWNS, "%s: cdic_w: Unknown address: %04x = %04x & %04x\n", machine().describe_context(), addr*2, data, mem_mask);
break;
}
}
+void cdicdic_device::init_disc_read(uint8_t disc_mode)
+{
+ m_disc_command = m_command;
+ m_disc_mode = disc_mode;
+ m_curr_lba = lba_from_time();
+ m_disc_spinup_counter = 1;
+}
+
+void cdicdic_device::cancel_disc_read()
+{
+ m_disc_command = 0;
+ m_disc_mode = 0;
+ m_curr_lba = 0;
+ m_disc_spinup_counter = 0;
+}
+
+void cdicdic_device::handle_cdic_command()
+{
+ switch (m_command)
+ {
+ case 0x23: // Reset Mode 1
+ LOGMASKED(LOG_WRITES, "%s: cdic_w: Reset Mode 1 command\n", machine().describe_context());
+ if (m_disc_command == 0)
+ init_disc_read(DISC_MODE1);
+ break;
+ case 0x24: // Reset Mode 2
+ LOGMASKED(LOG_WRITES, "%s: cdic_w: Reset Mode 2 command\n", machine().describe_context());
+ if (m_disc_command == 0)
+ init_disc_read(DISC_MODE1);
+ break;
+ case 0x2b: // Stop CDDA
+ LOGMASKED(LOG_WRITES, "%s: cdic_w: Stop CDDA command\n", machine().describe_context());
+ cancel_disc_read();
+ break;
+ case 0x2e: // Update
+ LOGMASKED(LOG_WRITES, "%s: cdic_w: Update command\n", machine().describe_context());
+ break;
+ case 0x27: // Fetch TOC
+ init_disc_read(DISC_TOC);
+ break;
+ case 0x28: // Play CDDA
+ init_disc_read(DISC_CDDA);
+ break;
+ case 0x29: // Read Mode 1
+ case 0x2c: // Seek
+ init_disc_read(DISC_MODE1);
+ break;
+ case 0x2a: // Read Mode 2
+ init_disc_read(DISC_MODE2);
+ break;
+ }
+
+ m_data_buffer &= ~0x8000;
+}
+
+uint32_t cdicdic_device::lba_from_time()
+{
+ const uint8_t bcd_mins = (m_time >> 24) & 0xff;
+ const uint8_t mins_upper_digit = bcd_mins >> 4;
+ const uint8_t mins_lower_digit = bcd_mins & 0xf;
+ const uint8_t raw_mins = (mins_upper_digit * 10) + mins_lower_digit;
+
+ const uint8_t bcd_secs = (m_time >> 16) & 0xff;
+ const uint8_t secs_upper_digit = bcd_secs >> 4;
+ const uint8_t secs_lower_digit = bcd_secs & 0xf;
+ const uint8_t raw_secs = (secs_upper_digit * 10) + secs_lower_digit;
+
+ uint32_t lba = ((raw_mins * 60) + raw_secs) * 75;
+
+ const uint8_t bcd_frac = (m_time >> 8) & 0xff;
+ const bool even_second = BIT(bcd_frac, 7);
+ if (!even_second)
+ {
+ const uint8_t frac_upper_digit = bcd_frac >> 4;
+ const uint8_t frac_lower_digit = bcd_frac & 0xf;
+ const uint8_t raw_frac = (frac_upper_digit * 10) + frac_lower_digit;
+ lba += raw_frac;
+ }
+
+ if (lba >= 150)
+ lba -= 150;
+
+ return lba;
+}
+
//**************************************************************************
// LIVE DEVICE
//**************************************************************************
@@ -1248,7 +1473,6 @@ cdicdic_device::cdicdic_device(const machine_config &mconfig, const char *tag, d
, m_memory_space(*this, ":maincpu", AS_PROGRAM)
, m_dmadac(*this, ":dac%u", 1U)
, m_scc(*this, ":maincpu")
- , m_cdda(*this, ":cdda")
, m_cdrom_dev(*this, ":cdrom")
, m_clock2(clock)
{
@@ -1271,6 +1495,14 @@ void cdicdic_device::device_resolve_objects()
void cdicdic_device::device_start()
{
+ m_ram = std::make_unique<uint8_t[]>(0x4000);
+ m_samples[0] = std::make_unique<int16_t[]>(s_samples_per_sector * 8 + 16);
+ m_samples[1] = std::make_unique<int16_t[]>(s_samples_per_sector * 8 + 16);
+
+ save_pointer(NAME(m_ram), 0x4000);
+ save_pointer(NAME(m_samples[0]), s_samples_per_sector * 8 + 16);
+ save_pointer(NAME(m_samples[1]), s_samples_per_sector * 8 + 16);
+
save_item(NAME(m_command));
save_item(NAME(m_time));
save_item(NAME(m_file));
@@ -1283,26 +1515,23 @@ void cdicdic_device::device_start()
save_item(NAME(m_interrupt_vector));
save_item(NAME(m_data_buffer));
- save_item(NAME(m_audio_sample_freq));
- save_item(NAME(m_audio_sample_size));
+ save_item(NAME(m_disc_command));
+ save_item(NAME(m_disc_mode));
+ save_item(NAME(m_disc_spinup_counter));
+ save_item(NAME(m_curr_lba));
- m_interrupt_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(cdicdic_device::trigger_readback_int), this));
- m_interrupt_timer->adjust(attotime::never);
+ save_item(NAME(m_audio_sector_counter));
+ save_item(NAME(m_audio_format_sectors));
+ save_item(NAME(m_decoding_audio_map));
+ save_item(NAME(m_decode_addr));
- m_audio_sample_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(cdicdic_device::audio_sample_trigger), this));
- m_audio_sample_timer->adjust(attotime::never);
+ save_item(NAME(m_xa_last));
- m_audio_playback_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(cdicdic_device::initial_sample_trigger), this));
- m_audio_playback_timer->adjust(attotime::never);
+ m_audio_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(cdicdic_device::audio_tick), this));
+ m_audio_timer->adjust(attotime::never);
- m_periodic_sample_timer[0] = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(cdicdic_device::periodic_sample_trigger), this));
- m_periodic_sample_timer[0]->adjust(attotime::never);
- m_periodic_sample_timer[1] = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(cdicdic_device::periodic_sample_trigger), this));
- m_periodic_sample_timer[1]->adjust(attotime::never);
-
- m_ram = std::make_unique<uint16_t[]>(0x3c00/2);
- m_samples[0] = std::make_unique<int16_t[]>(18*28*16+16);
- m_samples[1] = std::make_unique<int16_t[]>(18*28*16+16);
+ m_sector_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(cdicdic_device::sector_tick), this));
+ m_sector_timer->adjust(attotime::never);
}
//-------------------------------------------------
@@ -1323,47 +1552,51 @@ void cdicdic_device::device_reset()
m_interrupt_vector = 0x0f;
m_data_buffer = 0;
- m_audio_sample_freq = 0;
- m_audio_sample_size = 0;
+ m_cd_byteswap = false;
+
+ m_disc_command = 0;
+ m_disc_mode = 0;
+ m_disc_spinup_counter = 0;
+ m_curr_lba = 0;
+ m_audio_sector_counter = 0;
+ m_audio_format_sectors = 0;
+ m_decoding_audio_map = false;
m_decode_addr = 0;
- m_decode_delay = 0;
if (m_cdrom_dev)
{
- // MESS case (has CDROM device)
+ // Console case (has CDROM device)
m_cd = m_cdrom_dev->get_cdrom_file();
- m_cdda->set_cdrom(m_cd);
}
else
{
- // MAME case
+ // Arcade case
m_cd = cdrom_open(machine().rom_load().get_disk_handle(":cdrom"));
- m_cdda->set_cdrom(m_cd);
}
- m_interrupt_timer->adjust(attotime::never);
- m_audio_sample_timer->adjust(attotime::never);
- m_audio_playback_timer->adjust(attotime::never);
- m_periodic_sample_timer[0]->adjust(attotime::never);
- m_periodic_sample_timer[1]->adjust(attotime::never);
-
- m_break_on_achan = false;
- m_valid_audio_sample = false;
+ m_audio_timer->adjust(attotime::from_hz(75), 0, attotime::from_hz(75));
+ m_sector_timer->adjust(attotime::from_hz(75), 0, attotime::from_hz(75));
m_intreq_callback(CLEAR_LINE);
+
+ m_dmadac[0]->enable(1);
+ m_dmadac[1]->enable(1);
+
+ std::fill_n(&m_xa_last[0], 4, 0);
}
void cdicdic_device::ram_w(offs_t offset, uint16_t data, uint16_t mem_mask)
{
LOGMASKED(LOG_RAM, "%s: ram_w: %04x = %04x & %04x\n", machine().describe_context(), offset << 1, data, mem_mask);
- COMBINE_DATA(&m_ram[offset]);
+ COMBINE_DATA((uint16_t *)&m_ram[offset << 1]);
}
uint16_t cdicdic_device::ram_r(offs_t offset, uint16_t mem_mask)
{
- LOGMASKED(LOG_RAM, "%s: ram_r: %04x : %04x & %04x\n", machine().describe_context(), offset << 1, m_ram[offset], mem_mask);
- return m_ram[offset];
+ const uint16_t data = ((uint16_t)m_ram[(offset << 1) + 1] << 8) | m_ram[offset << 1];
+ LOGMASKED(LOG_RAM, "%s: ram_r: %04x : %04x & %04x\n", machine().describe_context(), offset << 1, data, mem_mask);
+ return data;
}
uint8_t cdicdic_device::intack_r()
diff --git a/src/mame/machine/cdicdic.h b/src/mame/machine/cdicdic.h
index 3eafa710345..9075b77cb0d 100644
--- a/src/mame/machine/cdicdic.h
+++ b/src/mame/machine/cdicdic.h
@@ -32,7 +32,6 @@ TODO:
#include "sound/dmadac.h"
#include "cdrom.h"
-
//**************************************************************************
// TYPE DEFINITIONS
//**************************************************************************
@@ -53,7 +52,6 @@ public:
// non-static internal members
void sample_trigger();
- void process_delayed_command();
uint16_t regs_r(offs_t offset, uint16_t mem_mask = ~0);
void regs_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0);
@@ -69,58 +67,95 @@ protected:
virtual void device_reset() override;
// internal callbacks
- TIMER_CALLBACK_MEMBER( periodic_sample_trigger );
- TIMER_CALLBACK_MEMBER( audio_sample_trigger );
- TIMER_CALLBACK_MEMBER( initial_sample_trigger );
- TIMER_CALLBACK_MEMBER( trigger_readback_int );
+ TIMER_CALLBACK_MEMBER(sector_tick);
+ TIMER_CALLBACK_MEMBER(audio_tick);
private:
- enum
+ enum : uint8_t
{
- CDIC_SECTOR_SYNC = 0,
-
- CDIC_SECTOR_HEADER = 12,
-
- CDIC_SECTOR_MODE = 15,
-
- CDIC_SECTOR_FILE1 = 16,
- CDIC_SECTOR_CHAN1 = 17,
- CDIC_SECTOR_SUBMODE1 = 18,
- CDIC_SECTOR_CODING1 = 19,
-
- CDIC_SECTOR_FILE2 = 20,
- CDIC_SECTOR_CHAN2 = 21,
- CDIC_SECTOR_SUBMODE2 = 22,
- CDIC_SECTOR_CODING2 = 23,
-
- CDIC_SECTOR_DATA = 24,
-
- CDIC_SECTOR_SIZE = 2352,
-
- CDIC_SECTOR_DATASIZE = 2048,
- CDIC_SECTOR_AUDIOSIZE = 2304,
- CDIC_SECTOR_VIDEOSIZE = 2324,
-
- CDIC_SUBMODE_EOF = 0x80,
- CDIC_SUBMODE_RT = 0x40,
- CDIC_SUBMODE_FORM = 0x20,
- CDIC_SUBMODE_TRIG = 0x10,
- CDIC_SUBMODE_DATA = 0x08,
- CDIC_SUBMODE_AUDIO = 0x04,
- CDIC_SUBMODE_VIDEO = 0x02,
- CDIC_SUBMODE_EOR = 0x01
+ DISC_NONE,
+ DISC_MODE1,
+ DISC_MODE2,
+ DISC_CDDA,
+ DISC_TOC
};
- int is_valid_sample_buf(uint16_t addr) const;
- double sample_buf_freq(uint16_t addr) const;
- int sample_buf_size(uint16_t addr) const;
+ enum
+ {
+ SECTOR_SYNC = 0,
+
+ SECTOR_HEADER = 12,
+
+ SECTOR_MINUTES = 12,
+ SECTOR_SECONDS = 13,
+ SECTOR_FRACS = 14,
+ SECTOR_MODE = 15,
+
+ SECTOR_FILE1 = 16,
+ SECTOR_CHAN1 = 17,
+ SECTOR_SUBMODE1 = 18,
+ SECTOR_CODING1 = 19,
+
+ SECTOR_FILE2 = 20,
+ SECTOR_CHAN2 = 21,
+ SECTOR_SUBMODE2 = 22,
+ SECTOR_CODING2 = 23,
+
+ SECTOR_DATA = 24,
+
+ SECTOR_SIZE = 2352,
+ SECTOR_AUDIO_SIZE = 2304,
+
+ SECTOR_DATASIZE = 2048,
+ SECTOR_AUDIOSIZE = 2304,
+ SECTOR_VIDEOSIZE = 2324,
+
+ SUBMODE_EOF = 0x80,
+ SUBMODE_RT = 0x40,
+ SUBMODE_FORM = 0x20,
+ SUBMODE_TRIG = 0x10,
+ SUBMODE_DATA = 0x08,
+ SUBMODE_AUDIO = 0x04,
+ SUBMODE_VIDEO = 0x02,
+ SUBMODE_EOR = 0x01,
+
+ CODING_BPS_MASK = 0x30,
+ CODING_4BPS = 0x00,
+ CODING_8BPS = 0x10,
+ CODING_16BPS = 0x20,
+ CODING_BPS_MPEG = 0x30,
+
+ CODING_RATE_MASK = 0x0c,
+ CODING_37KHZ = 0x00,
+ CODING_18KHZ = 0x04,
+ CODING_RATE_RESV = 0x08,
+ CODING_44KHZ = 0x0c,
+
+ CODING_CHAN_MASK = 0x03,
+ CODING_MONO = 0x00,
+ CODING_STEREO = 0x01,
+ CODING_CHAN_RESV = 0x02,
+ CODING_CHAN_MPEG = 0x03,
+
+ SUBCODE_Q_CONTROL = 12,
+ SUBCODE_Q_TRACK = 13,
+ SUBCODE_Q_INDEX = 14,
+ SUBCODE_Q_MODE1_MINS = 15,
+ SUBCODE_Q_MODE1_SECS = 16,
+ SUBCODE_Q_MODE1_FRAC = 17,
+ SUBCODE_Q_MODE1_ZERO = 18,
+ SUBCODE_Q_MODE1_AMINS = 19,
+ SUBCODE_Q_MODE1_ASECS = 20,
+ SUBCODE_Q_MODE1_AFRAC = 21,
+ SUBCODE_Q_CRC0 = 22,
+ SUBCODE_Q_CRC1 = 23
+ };
devcb_write_line m_intreq_callback;
required_address_space m_memory_space;
required_device_array<dmadac_sound_device, 2> m_dmadac;
required_device<scc68070_device> m_scc;
- required_device<cdda_device> m_cdda;
optional_device<cdrom_image_device> m_cdrom_dev;
uint32_t m_clock2;
@@ -139,36 +174,58 @@ private:
uint16_t m_interrupt_vector; // CDIC Interrupt Vector Register (0x303ffc)
uint16_t m_data_buffer; // CDIC Data Buffer Register (0x303ffe)
- emu_timer *m_interrupt_timer;
cdrom_file *m_cd;
-
- emu_timer *m_audio_sample_timer;
- emu_timer *m_audio_playback_timer;
- emu_timer *m_periodic_sample_timer[2];
- int32_t m_audio_sample_freq;
- int32_t m_audio_sample_size;
-
+ bool m_cd_byteswap;
+
+ emu_timer *m_sector_timer;
+ uint8_t m_disc_command;
+ uint8_t m_disc_mode;
+ uint8_t m_disc_spinup_counter;
+ uint32_t m_curr_lba;
+
+ emu_timer *m_audio_timer;
+ uint8_t m_audio_sector_counter;
+ uint8_t m_audio_format_sectors;
+ bool m_decoding_audio_map;
uint16_t m_decode_addr;
- uint8_t m_decode_delay;
- attotime m_decode_period;
- bool m_break_on_achan;
- bool m_valid_audio_sample;
- int m_xa_last[4];
- std::unique_ptr<uint16_t[]> m_ram;
+ int16_t m_xa_last[4];
+ std::unique_ptr<uint8_t[]> m_ram;
std::unique_ptr<int16_t[]> m_samples[2];
- static void decode_xa_mono(int32_t *cdic_xa_last, const uint8_t *xa, int16_t *dp);
- static void decode_xa_mono8(int32_t *cdic_xa_last, const uint8_t *xa, int16_t *dp);
- static void decode_xa_stereo(int32_t *cdic_xa_last, const uint8_t *xa, int16_t *dp);
- static void decode_xa_stereo8(int32_t *cdic_xa_last, const uint8_t *xa, int16_t *dp);
-
- static const int32_t s_cdic_adpcm_filter_coef[5][2];
-
- uint32_t increment_cdda_frame_bcd(uint32_t bcd);
- uint32_t increment_cdda_sector_bcd(uint32_t bcd);
- void decode_audio_sector(const uint8_t *xa, int32_t triggered);
- void play_audio_sector();
+ void decode_8bit_xa_unit(int channel, uint8_t param, const uint8_t *data, int16_t *out_buffer);
+ void decode_4bit_xa_unit(int channel, uint8_t param, const uint8_t *data, uint8_t shift, int16_t *out_buffer);
+ void play_raw_group(const uint8_t *data);
+ void play_xa_group(const uint8_t coding, const uint8_t *data);
+ void play_audio_sector(const uint8_t coding, const uint8_t *data);
+ void play_cdda_sector(const uint8_t *data);
+ void process_audio_map();
+
+ void descramble_sector(uint8_t *buffer);
+ bool is_valid_sector(const uint8_t *buffer);
+ bool is_mode2_sector_selected(const uint8_t *buffer);
+ bool is_mode2_audio_selected(const uint8_t *buffer);
+
+ void process_disc_sector();
+ void process_sector_data(const uint8_t *buffer, const uint8_t *subcode_buffer);
+ void init_disc_read(uint8_t disc_mode);
+ void cancel_disc_read();
+ void handle_cdic_command();
+
+ void update_interrupt_state();
+
+ uint32_t lba_from_time();
+
+ static uint8_t get_sector_count_for_coding(uint8_t coding);
+ static void decode_xa_mono(int16_t *cdic_xa_last, const uint8_t *xa, int16_t *dp);
+ static void decode_xa_mono8(int16_t *cdic_xa_last, const uint8_t *xa, int16_t *dp);
+ static void decode_xa_stereo(int16_t *cdic_xa_last, const uint8_t *xa, int16_t *dp);
+ static void decode_xa_stereo8(int16_t *cdic_xa_last, const uint8_t *xa, int16_t *dp);
+
+ static const int16_t s_xa_filter_coef[4][2];
+ static const int32_t s_samples_per_sector;
+ static const uint16_t s_crc_ccitt_table[256];
+ static const uint8_t s_sector_scramble[2448];
};
// device type definition
diff --git a/src/mame/machine/cdislavehle.cpp b/src/mame/machine/cdislavehle.cpp
index c8e01d67a10..4c103f24a37 100644
--- a/src/mame/machine/cdislavehle.cpp
+++ b/src/mame/machine/cdislavehle.cpp
@@ -18,6 +18,8 @@ TODO:
#include "emu.h"
#include "machine/cdislavehle.h"
+#include <algorithm>
+
#define LOG_IRQS (1 << 0)
#define LOG_COMMANDS (1 << 1)
#define LOG_READS (1 << 2)
@@ -56,62 +58,57 @@ void cdislave_hle_device::prepare_readback(const attotime &delay, uint8_t channe
m_interrupt_timer->adjust(delay);
}
-void cdislave_hle_device::perform_mouse_update()
+INPUT_CHANGED_MEMBER( cdislave_hle_device::mouse_update )
{
- uint16_t x = m_mousex->read();
- uint16_t y = m_mousey->read();
- uint8_t buttons = m_mousebtn->read();
-
- uint16_t old_mouse_x = m_real_mouse_x;
- uint16_t old_mouse_y = m_real_mouse_y;
-
- if (m_real_mouse_x == 0xffff)
+ const uint8_t button_state = m_mousebtn->read();
+ uint8_t button_bits = 0x01;
+ if (BIT(button_state, 0))
+ button_bits |= 0x02;
+ if (BIT(button_state, 1))
+ button_bits |= 0x04;
+ if (BIT(button_state, 2))
+ button_bits |= 0x06;
+
+ const uint16_t x = m_mousex->read();
+ const uint16_t y = m_mousey->read();
+
+ int16_t deltax = 0;
+ int16_t deltay = 0;
+
+ if (m_input_mouse_x != 0xffff && m_input_mouse_y != 0xffff)
{
- old_mouse_x = x & 0x3ff;
- old_mouse_y = y & 0x3ff;
+ deltax = -(m_input_mouse_x - x);
+ deltay = -(m_input_mouse_y - y);
}
- m_real_mouse_x = x & 0x3ff;
- m_real_mouse_y = y & 0x3ff;
+ m_input_mouse_x = x;
+ m_input_mouse_y = y;
- m_fake_mouse_x += (m_real_mouse_x - old_mouse_x);
- m_fake_mouse_y += (m_real_mouse_y - old_mouse_y);
-
- while (m_fake_mouse_x > 0x3ff)
- {
- m_fake_mouse_x += 0x400;
- }
-
- while (m_fake_mouse_y > 0x3ff)
- {
- m_fake_mouse_y += 0x400;
- }
-
- x = m_fake_mouse_x;
- y = m_fake_mouse_y;
+ m_device_mouse_x = std::clamp(m_device_mouse_x + deltax, 0, 767);
+ m_device_mouse_y = std::clamp(m_device_mouse_y + deltay, 0, 559);
if (m_polling_active)
{
- prepare_readback(attotime::zero, 0, 4, ((x & 0x380) >> 7) | (buttons << 4), x & 0x7f, (y & 0x380) >> 7, y & 0x7f, 0xf7);
+ const uint8_t byte3 = ((m_device_mouse_x & 0x380) >> 7) | (button_bits << 3);
+ const uint8_t byte2 = m_device_mouse_x & 0x7f;
+ const uint8_t byte1 = (m_device_mouse_y & 0x380) >> 7;
+ const uint8_t byte0 = m_device_mouse_y & 0x7f;
+ prepare_readback(attotime::zero, 0, 4, byte3, byte2, byte1, byte0, 0xf7);
}
}
-INPUT_CHANGED_MEMBER( cdislave_hle_device::mouse_update )
-{
- perform_mouse_update();
-}
-
static INPUT_PORTS_START(cdislave_mouse)
PORT_START("MOUSEX")
- PORT_BIT(0x3ff, 0x000, IPT_MOUSE_X) PORT_SENSITIVITY(100) PORT_MINMAX(0x000, 0x3ff) PORT_KEYDELTA(2) PORT_CHANGED_MEMBER(DEVICE_SELF, cdislave_hle_device, mouse_update, 0)
+ PORT_BIT(0xffff, 0x000, IPT_MOUSE_X) PORT_SENSITIVITY(100) PORT_KEYDELTA(2) PORT_CHANGED_MEMBER(DEVICE_SELF, cdislave_hle_device, mouse_update, 0)
PORT_START("MOUSEY")
- PORT_BIT(0x3ff, 0x000, IPT_MOUSE_Y) PORT_SENSITIVITY(100) PORT_MINMAX(0x000, 0x3ff) PORT_KEYDELTA(2) PORT_CHANGED_MEMBER(DEVICE_SELF, cdislave_hle_device, mouse_update, 0)
+ PORT_BIT(0xffff, 0x000, IPT_MOUSE_Y) PORT_SENSITIVITY(100) PORT_KEYDELTA(2) PORT_CHANGED_MEMBER(DEVICE_SELF, cdislave_hle_device, mouse_update, 0)
PORT_START("MOUSEBTN")
- PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_BUTTON1) PORT_CODE(MOUSECODE_BUTTON1) PORT_NAME("Mouse Button 1") PORT_CHANGED_MEMBER(DEVICE_SELF, cdislave_hle_device, mouse_update, 0)
- PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_BUTTON2) PORT_CODE(MOUSECODE_BUTTON2) PORT_NAME("Mouse Button 2") PORT_CHANGED_MEMBER(DEVICE_SELF, cdislave_hle_device, mouse_update, 0)
- PORT_BIT(0xfc, IP_ACTIVE_HIGH, IPT_UNUSED)
+ PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_BUTTON1) PORT_CODE(MOUSECODE_BUTTON1) PORT_NAME("Button 1") PORT_CHANGED_MEMBER(DEVICE_SELF, cdislave_hle_device, mouse_update, 0)
+ PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_BUTTON2) PORT_CODE(MOUSECODE_BUTTON2) PORT_NAME("Button 2") PORT_CHANGED_MEMBER(DEVICE_SELF, cdislave_hle_device, mouse_update, 0)
+ PORT_BIT(0x04, IP_ACTIVE_HIGH, IPT_BUTTON3) PORT_CODE(MOUSECODE_BUTTON3) PORT_NAME("Button 3") PORT_CHANGED_MEMBER(DEVICE_SELF, cdislave_hle_device, mouse_update, 0)
+ PORT_BIT(0xf8, IP_ACTIVE_HIGH, IPT_UNUSED)
INPUT_PORTS_END
ioport_constructor cdislave_hle_device::device_input_ports() const
@@ -156,20 +153,8 @@ uint16_t cdislave_hle_device::slave_r(offs_t offset)
void cdislave_hle_device::set_mouse_position()
{
-// uint16_t x, y;
-
- //printf( "Set mouse position: %02x %02x %02x\n", m_in_buf[0], m_in_buf[1], m_in_buf[2] );
-
- m_fake_mouse_y = ((m_in_buf[1] & 0x0f) << 6) | (m_in_buf[0] & 0x3f);
- m_fake_mouse_x = ((m_in_buf[1] & 0x70) << 3) | m_in_buf[2];
-
-// x = m_fake_mouse_x;
-// y = m_fake_mouse_y;
-
- if (m_polling_active)
- {
- //prepare_readback(attotime::zero, 0, 4, (x & 0x380) >> 7, x & 0x7f, (y & 0x380) >> 7, y & 0x7f, 0xf7);
- }
+ m_device_mouse_x = ((m_in_buf[1] & 0x70) << 3) | (m_in_buf[2] & 0x7f);
+ m_device_mouse_y = ((m_in_buf[1] & 0x0f) << 6) | (m_in_buf[0] & 0x3f);
}
void cdislave_hle_device::slave_w(offs_t offset, uint16_t data)
@@ -290,20 +275,24 @@ void cdislave_hle_device::slave_w(offs_t offset, uint16_t data)
switch (data & 0x00ff)
{
case 0x82: // Mute Audio
+ {
LOGMASKED(LOG_COMMANDS, "slave_w: Channel %d: Mute Audio (0x82)\n", offset);
- m_dmadac[0]->enable(0);
- m_dmadac[1]->enable(0);
+ m_dmadac[0]->set_volume(0);
+ m_dmadac[1]->set_volume(0);
m_in_index = 0;
m_in_count = 0;
//cdic->audio_sample_timer->adjust(attotime::never);
break;
+ }
case 0x83: // Unmute Audio
+ {
LOGMASKED(LOG_COMMANDS, "slave_w: Channel %d: Unmute Audio (0x83)\n", offset);
- m_dmadac[0]->enable(1);
- m_dmadac[1]->enable(1);
+ m_dmadac[0]->set_volume(0x100);
+ m_dmadac[1]->set_volume(0x100);
m_in_index = 0;
m_in_count = 0;
break;
+ }
case 0xf0: // Set Front Panel LCD
LOGMASKED(LOG_COMMANDS, "slave_w: Channel %d: Set Front Panel LCD (0xf0)\n", offset);
m_in_count = 17;
@@ -476,11 +465,11 @@ void cdislave_hle_device::device_start()
save_item(NAME(m_lcd_state));
- save_item(NAME(m_real_mouse_x));
- save_item(NAME(m_real_mouse_y));
+ save_item(NAME(m_input_mouse_x));
+ save_item(NAME(m_input_mouse_y));
- save_item(NAME(m_fake_mouse_x));
- save_item(NAME(m_fake_mouse_y));
+ save_item(NAME(m_device_mouse_x));
+ save_item(NAME(m_device_mouse_y));
m_interrupt_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(cdislave_hle_device::trigger_readback_int), this));
m_interrupt_timer->adjust(attotime::never);
@@ -513,11 +502,11 @@ void cdislave_hle_device::device_reset()
memset(m_lcd_state, 0, 16);
- m_real_mouse_x = 0xffff;
- m_real_mouse_y = 0xffff;
+ m_input_mouse_x = 0xffff;
+ m_input_mouse_y = 0xffff;
- m_fake_mouse_x = 0;
- m_fake_mouse_y = 0;
+ m_device_mouse_x = 0;
+ m_device_mouse_y = 0;
m_int_callback(CLEAR_LINE);
}
diff --git a/src/mame/machine/cdislavehle.h b/src/mame/machine/cdislavehle.h
index 167437722fe..f4e31d7d117 100644
--- a/src/mame/machine/cdislavehle.h
+++ b/src/mame/machine/cdislavehle.h
@@ -55,6 +55,9 @@ protected:
TIMER_CALLBACK_MEMBER( trigger_readback_int );
private:
+ void prepare_readback(const attotime &delay, uint8_t channel, uint8_t count, uint8_t data0, uint8_t data1, uint8_t data2, uint8_t data3, uint8_t cmd);
+ void set_mouse_position();
+
devcb_write_line m_int_callback;
required_device_array<dmadac_sound_device, 2> m_dmadac;
@@ -63,12 +66,8 @@ private:
required_ioport m_mousey;
required_ioport m_mousebtn;
- // internal state
- class channel_state
+ struct channel_state
{
- public:
- channel_state() { }
-
uint8_t m_out_buf[4];
uint8_t m_out_index;
uint8_t m_out_count;
@@ -88,18 +87,11 @@ private:
uint8_t m_lcd_state[16];
- uint16_t m_real_mouse_x;
- uint16_t m_real_mouse_y;
+ uint16_t m_input_mouse_x;
+ uint16_t m_input_mouse_y;
- uint16_t m_fake_mouse_x;
- uint16_t m_fake_mouse_y;
-
- // static internal members
-
- // non-static internal members
- void prepare_readback(const attotime &delay, uint8_t channel, uint8_t count, uint8_t data0, uint8_t data1, uint8_t data2, uint8_t data3, uint8_t cmd);
- void perform_mouse_update();
- void set_mouse_position();
+ int16_t m_device_mouse_x;
+ int16_t m_device_mouse_y;
};
diff --git a/src/mame/machine/cmi_mkbd.cpp b/src/mame/machine/cmi_mkbd.cpp
index 2128f88c5b1..126b8da9e93 100644
--- a/src/mame/machine/cmi_mkbd.cpp
+++ b/src/mame/machine/cmi_mkbd.cpp
@@ -79,7 +79,7 @@ void cmi_music_keyboard_device::device_start()
m_scnd = 0;
}
-void cmi_music_keyboard_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
+void cmi_music_keyboard_device::device_timer(emu_timer &timer, device_timer_id id, int param)
{
switch (id)
{
diff --git a/src/mame/machine/cmi_mkbd.h b/src/mame/machine/cmi_mkbd.h
index 653083ce939..e1ab74bd6ac 100644
--- a/src/mame/machine/cmi_mkbd.h
+++ b/src/mame/machine/cmi_mkbd.h
@@ -38,7 +38,7 @@ protected:
virtual ioport_constructor device_input_ports() const override;
virtual void device_resolve_objects() override;
virtual void device_start() override;
- virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override;
+ virtual void device_timer(emu_timer &timer, device_timer_id id, int param) override;
private:
void cmi10_u20_a_w(u8 data);
diff --git a/src/mame/machine/coco.cpp b/src/mame/machine/coco.cpp
index 8e08656f447..f7c49070ce8 100644
--- a/src/mame/machine/coco.cpp
+++ b/src/mame/machine/coco.cpp
@@ -155,6 +155,7 @@ void coco_state::device_start()
save_item(NAME(m_dclg_state));
save_item(NAME(m_dclg_timer));
save_item(NAME(m_vhd_select));
+ save_item(NAME(m_in_floating_bus_read));
// miscellaneous
m_in_floating_bus_read = false;
@@ -189,7 +190,7 @@ void coco_state::device_reset()
// device_timer
//-------------------------------------------------
-void coco_state::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
+void coco_state::device_timer(emu_timer &timer, device_timer_id id, int param)
{
switch(id)
{
diff --git a/src/mame/machine/coco_vhd.h b/src/mame/machine/coco_vhd.h
index e523be69c20..78c7ca20b56 100644
--- a/src/mame/machine/coco_vhd.h
+++ b/src/mame/machine/coco_vhd.h
@@ -36,14 +36,13 @@ public:
// image-level overrides
virtual image_init_result call_load() override;
- virtual iodevice_t image_type() const noexcept override { return IO_HARDDISK; }
-
virtual bool is_readable() const noexcept override { return true; }
virtual bool is_writeable() const noexcept override { return true; }
virtual bool is_creatable() const noexcept override { return true; }
- virtual bool must_be_loaded() const noexcept override { return false; }
virtual bool is_reset_on_load() const noexcept override { return false; }
virtual const char *file_extensions() const noexcept override { return "vhd"; }
+ virtual const char *image_type_name() const noexcept override { return "harddisk"; }
+ virtual const char *image_brief_type_name() const noexcept override { return "hard"; }
// specific implementation
uint8_t read(offs_t offset);
diff --git a/src/mame/machine/cuda.cpp b/src/mame/machine/cuda.cpp
index 52194dbee55..83f8f126494 100644
--- a/src/mame/machine/cuda.cpp
+++ b/src/mame/machine/cuda.cpp
@@ -395,8 +395,8 @@ void cuda_device::device_start()
write_via_clock.resolve_safe();
write_via_data.resolve_safe();
- m_timer = timer_alloc(0, nullptr);
- m_prog_timer = timer_alloc(1, nullptr);
+ m_timer = timer_alloc(0);
+ m_prog_timer = timer_alloc(1);
save_item(NAME(ddrs[0]));
save_item(NAME(ddrs[1]));
save_item(NAME(ddrs[2]));
@@ -457,7 +457,7 @@ void cuda_device::device_reset()
last_adb = 0;
}
-void cuda_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
+void cuda_device::device_timer(emu_timer &timer, device_timer_id id, int param)
{
if (id == 0)
{
diff --git a/src/mame/machine/cuda.h b/src/mame/machine/cuda.h
index 37c5a164729..c786622a21b 100644
--- a/src/mame/machine/cuda.h
+++ b/src/mame/machine/cuda.h
@@ -87,7 +87,7 @@ protected:
required_device<cpu_device> m_maincpu;
- virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override;
+ virtual void device_timer(emu_timer &timer, device_timer_id id, int param) override;
private:
uint8_t ddrs[3];
diff --git a/src/mame/machine/dc.cpp b/src/mame/machine/dc.cpp
index c681fe19bc2..0698f187d3b 100644
--- a/src/mame/machine/dc.cpp
+++ b/src/mame/machine/dc.cpp
@@ -1,13 +1,15 @@
// license:LGPL-2.1+
-// copyright-holders:Angelo Salese, Olivier Galibert, David Haywood, Samuele Zannoli, R. Belmont, ElSemi
+// copyright-holders: Samuele Zannoli, R. Belmont, ElSemi, David Haywood, Angelo Salese, Olivier Galibert, MetalliC
/*
- dc.c - Sega Dreamcast hardware
+ dc.cpp - Sega Dreamcast hardware
+
+ Misc interfacing to common DC buses over the various clients.
*/
#include "emu.h"
-#include "debugger.h"
+//#include "debugger.h"
#include "includes/dc.h"
#include "cpu/sh/sh4.h"
#include "cpu/arm7/arm7core.h"
@@ -87,17 +89,28 @@ void dc_state::generic_dma(uint32_t main_adr, void *dma_ptr, uint32_t length, ui
ddt.source = main_adr;
ddt.buffer = dma_ptr;
ddt.length = length;
- ddt.size =size;
+ ddt.size = size;
ddt.direction = to_mainram;
ddt.channel = 0;
ddt.mode = -1;
m_maincpu->sh4_dma_ddt(&ddt);
}
-TIMER_CALLBACK_MEMBER(dc_state::g2_dma_irq)
+void dc_state::g2_dma_end_w(offs_t channel, u8 state)
+{
+ dc_sysctrl_regs[SB_ISTNRM] |= IST_DMA_AICA << channel;
+ dc_update_interrupt_status();
+}
+
+void dc_state::g2_dma_error_ia_w(offs_t channel, u8 state)
{
- m_g2_dma[param].start = g2bus_regs[SB_ADST + (param * 8)] = 0;
- dc_sysctrl_regs[SB_ISTNRM] |= IST_DMA_AICA << param;
+ dc_sysctrl_regs[SB_ISTERR] |= 0x8000 << channel;
+ dc_update_interrupt_status();
+}
+
+void dc_state::g2_dma_error_ov_w(offs_t channel, u8 state)
+{
+ dc_sysctrl_regs[SB_ISTERR] |= 0x80000 << channel;
dc_update_interrupt_status();
}
@@ -189,51 +202,12 @@ void dc_state::maple_irq(uint8_t data)
TIMER_CALLBACK_MEMBER(dc_state::ch2_dma_irq)
{
- dc_sysctrl_regs[SB_C2DLEN]=0;
- dc_sysctrl_regs[SB_C2DST]=0;
+ dc_sysctrl_regs[SB_C2DLEN] = 0;
+ dc_sysctrl_regs[SB_C2DST] = 0;
dc_sysctrl_regs[SB_ISTNRM] |= IST_DMA_CH2;
dc_update_interrupt_status();
}
-void dc_state::g2_dma_execute(address_space &space, int channel)
-{
- uint32_t src,dst,size;
- dst = m_g2_dma[channel].g2_addr;
- src = m_g2_dma[channel].root_addr;
- size = 0;
-
- /* 0 rounding size = 32 Mbytes */
- if (m_g2_dma[channel].size == 0) { m_g2_dma[channel].size = 0x200000; }
-
- if (m_g2_dma[channel].dir == 0)
- {
- for (; size<m_g2_dma[channel].size; size += 4)
- {
- space.write_dword(dst,space.read_dword(src));
- src+=4;
- dst+=4;
- }
- }
- else
- {
- for (; size<m_g2_dma[channel].size; size += 4)
- {
- space.write_dword(src,space.read_dword(dst));
- src+=4;
- dst+=4;
- }
- }
-
- /* update the params*/
- m_g2_dma[channel].g2_addr = g2bus_regs[SB_ADSTAG + (channel * 8)] = dst;
- m_g2_dma[channel].root_addr = g2bus_regs[SB_ADSTAR + (channel * 8)] = src;
- m_g2_dma[channel].size = g2bus_regs[SB_ADLEN + (channel * 8)] = 0;
- m_g2_dma[channel].flag = (m_g2_dma[channel].indirect & 1) ? 1 : 0;
- /* Note: if you trigger an instant DMA IRQ trigger, sfz3upper doesn't play any bgm. */
- /* TODO: timing of this */
- machine().scheduler().timer_set(m_maincpu->cycles_to_attotime(m_g2_dma[channel].size / 4), timer_expired_delegate(FUNC(dc_state::g2_dma_irq), this), channel);
-}
-
// register decode helpers
// this accepts only 32-bit accesses
@@ -340,19 +314,10 @@ void dc_state::dc_update_interrupt_status()
m_maincpu->sh4_set_irln_input(15-level);
/* Wave DMA HW trigger */
- for (int i = 0; i < 4; i++)
- {
- if (m_g2_dma[i].flag && ((m_g2_dma[i].sel & 2) == 2))
- {
- if ((dc_sysctrl_regs[SB_G2DTNRM] & dc_sysctrl_regs[SB_ISTNRM]) || (dc_sysctrl_regs[SB_G2DTEXT] & dc_sysctrl_regs[SB_ISTEXT]))
- {
- address_space &space = m_maincpu->space(AS_PROGRAM);
-
- printf("Wave DMA HW trigger\n");
- g2_dma_execute(space, i);
- }
- }
- }
+ m_g2if->hw_irq_trigger_hs(
+ dc_sysctrl_regs[SB_G2DTNRM] & dc_sysctrl_regs[SB_ISTNRM],
+ dc_sysctrl_regs[SB_G2DTEXT] & dc_sysctrl_regs[SB_ISTEXT]
+ );
/* PVR-DMA HW trigger */
if(m_powervr2->m_pvr_dma.flag && ((m_powervr2->m_pvr_dma.sel & 1) == 1))
@@ -361,12 +326,13 @@ void dc_state::dc_update_interrupt_status()
{
address_space &space = m_maincpu->space(AS_PROGRAM);
- printf("PVR-DMA HW trigger\n");
+ logerror("PVR-DMA HW trigger\n");
m_powervr2->pvr_dma_execute(space);
}
}
}
+// TODO: convert SYSCTRL to device I/F (NAOMI2 needs two of these)
uint64_t dc_state::dc_sysctrl_r(offs_t offset, uint64_t mem_mask)
{
int reg;
@@ -519,74 +485,6 @@ void dc_state::dc_gdrom_w(offs_t offset, uint64_t data, uint64_t mem_mask)
osd_printf_verbose("GDROM: [%08x=%x]write %x to %x, mask %x\n", 0x5f7000+off*4, dat, data, offset, mem_mask);
}
-uint64_t dc_state::dc_g2_ctrl_r(offs_t offset, uint64_t mem_mask)
-{
- int reg;
- uint64_t shift;
-
- reg = decode_reg32_64(offset, mem_mask, &shift);
- osd_printf_verbose("G2CTRL: Unmapped read %08x\n", 0x5f7800+reg*4);
- return (uint64_t)g2bus_regs[reg] << shift;
-}
-
-void dc_state::dc_g2_ctrl_w(address_space &space, offs_t offset, uint64_t data, uint64_t mem_mask)
-{
- int reg;
- uint64_t shift;
- uint32_t dat;
- uint8_t old;
-
- reg = decode_reg32_64(offset, mem_mask, &shift);
- dat = (uint32_t)(data >> shift);
-
- g2bus_regs[reg] = dat; // 5f7800+reg*4=dat
-
- if (reg >= (0x80 / 4))
- return;
- int g2chan = reg >> 3;
- switch (reg & 7)
- {
- /*G2 Address register*/
- case SB_ADSTAG: m_g2_dma[g2chan].g2_addr = dat; break;
- /*Root address (work ram)*/
- case SB_ADSTAR: m_g2_dma[g2chan].root_addr = dat; break;
- /*DMA size (in dword units, bit 31 is "set dma initiation enable setting to 0"*/
- case SB_ADLEN:
- m_g2_dma[g2chan].size = dat & 0x7fffffff;
- m_g2_dma[g2chan].indirect = (dat & 0x80000000) >> 31;
- break;
- /*0 = root memory to aica / 1 = aica to root memory*/
- case SB_ADDIR: m_g2_dma[g2chan].dir = (dat & 1); break;
- /*dma flag (active HIGH, bug in docs)*/
- case SB_ADEN: m_g2_dma[g2chan].flag = (dat & 1); break;
- /*
- SB_ADTSEL
- bit 1: (0) Wave DMA through SB_ADST flag (1) Wave DMA through irq trigger, defined by SB_G2DTNRM / SB_G2DTEXT
- */
- case SB_ADTSEL: m_g2_dma[g2chan].sel = dat & 7; break;
- /*ready for dma'ing*/
- case SB_ADST:
- old = m_g2_dma[g2chan].start & 1;
- m_g2_dma[g2chan].start = dat & 1;
-
- #if DEBUG_AICA_DMA
- printf("AICA: G2-DMA start \n");
- printf("DST %08x SRC %08x SIZE %08x IND %02x\n",m_g2_dma[g2chan].g2_addr,m_g2_dma[g2chan].root_addr,m_g2_dma[g2chan].size,m_g2_dma[g2chan].indirect);
- printf("SEL %08x ST %08x FLAG %08x DIR %02x\n",m_g2_dma[g2chan].sel,m_g2_dma[g2chan].start,m_g2_dma[g2chan].flag,m_g2_dma[g2chan].dir);
- #endif
-
- //osd_printf_verbose("SB_ADST data %08x\n",dat);
- if (((old & 1) == 0) && m_g2_dma[g2chan].flag && m_g2_dma[g2chan].start && ((m_g2_dma[g2chan].sel & 2) == 0)) // 0 -> 1
- g2_dma_execute(space, g2chan);
- break;
-
- default:
- /* might access the unhandled DMAs, so tell us if this happens. */
- //printf("Unhandled G2 register [%08x] -> %08x\n",reg,dat);
- break;
- }
-}
-
int dc_state::decode_reg_64(uint32_t offset, uint64_t mem_mask, uint64_t *shift)
{
int reg = offset * 2;
@@ -638,16 +536,6 @@ void dc_state::dc_modem_w(offs_t offset, uint64_t data, uint64_t mem_mask)
osd_printf_verbose("MODEM: [%08x=%x] write %x to %x, mask %x\n", 0x600000+reg*4, dat, data, offset, mem_mask);
}
-#define SAVE_G2DMA(x) \
- save_item(NAME(m_g2_dma[x].g2_addr)); \
- save_item(NAME(m_g2_dma[x].root_addr)); \
- save_item(NAME(m_g2_dma[x].size)); \
- save_item(NAME(m_g2_dma[x].dir)); \
- save_item(NAME(m_g2_dma[x].flag)); \
- save_item(NAME(m_g2_dma[x].indirect)); \
- save_item(NAME(m_g2_dma[x].start)); \
- save_item(NAME(m_g2_dma[x].sel));
-
void dc_state::machine_start()
{
// dccons doesn't have a specific g1 device yet
@@ -655,15 +543,11 @@ void dc_state::machine_start()
m_naomig1->set_dma_cb(naomi_g1_device::dma_cb(&dc_state::generic_dma, this));
m_maincpu->sh2drc_set_options(SH2DRC_STRICT_VERIFY | SH2DRC_STRICT_PCREL);
+ // TODO: repeated in dccons.cpp init_dc (NAOMI also uses double RAM)
m_maincpu->sh2drc_add_fastram(0x0c000000, 0x0cffffff, false, dc_ram);
// save states
save_pointer(NAME(dc_sysctrl_regs), 0x200/4);
- save_pointer(NAME(g2bus_regs), 0x100/4);
- SAVE_G2DMA(0)
- SAVE_G2DMA(1)
- SAVE_G2DMA(2)
- SAVE_G2DMA(3)
}
void dc_state::machine_reset()
@@ -768,3 +652,12 @@ TIMER_DEVICE_CALLBACK_MEMBER(dc_state::dc_scanline)
{
m_powervr2->pvr_scanline_timer(param);
}
+
+void dc_state::system_bus_config(machine_config &config, const char *cpu_tag)
+{
+ DC_G2IF(config, m_g2if, XTAL(25'000'000));
+ m_g2if->set_host_space(cpu_tag, AS_PROGRAM);
+ m_g2if->int_cb().set(FUNC(dc_state::g2_dma_end_w));
+ m_g2if->error_ia_cb().set(FUNC(dc_state::g2_dma_error_ia_w));
+ m_g2if->error_ov_cb().set(FUNC(dc_state::g2_dma_error_ov_w));
+}
diff --git a/src/mame/machine/dc_g2if.cpp b/src/mame/machine/dc_g2if.cpp
new file mode 100644
index 00000000000..a75bf4b0f37
--- /dev/null
+++ b/src/mame/machine/dc_g2if.cpp
@@ -0,0 +1,538 @@
+// license:LGPL-2.1+
+// copyright-holders:Angelo Salese
+/**************************************************************************************************
+
+ Sega Dreamcast G2 System Bus I/F
+
+ TODO:
+ - Single-step instead of transfering in one go;
+ - Abort DMA if suspend mode is triggered;
+ - Time Out mechanism thru DS# & TR# signals;
+ - External pin enable in trigger select;
+ - Create a pure abstract interface shared with PVR-DMA I/F
+ (one channel, different max size, simpler tsel, no suspend,
+ different security code & area protection);
+ - DMA starts should send DDT requests and being notified back to use this i/f implementation
+ anyway. Exact purpose is unknown, maybe it's for granting use of the bus?
+
+**************************************************************************************************/
+
+#include "emu.h"
+#include "dc_g2if.h"
+
+#define LOG_WARN (1U << 1)
+#define LOG_DMA (1U << 2) // log DMA starts with CPU triggers (.tsel bit 1 == 0)
+#define LOG_HWTRIG (1U << 3) // log DMA starts with HW triggers (.tsel bit 1 == 1)
+#define LOG_DMAEND (1U << 4) // log DMA event ends
+#define LOG_ILLEGAL (1U << 5) // log illegal/malformed addresses
+
+#define VERBOSE (LOG_WARN | LOG_DMA | LOG_HWTRIG | LOG_DMAEND | LOG_ILLEGAL)
+//#define LOG_OUTPUT_STREAM std::cout
+#include "logmacro.h"
+
+#define LOGWARN(...) LOGMASKED(LOG_WARN, __VA_ARGS__)
+#define LOGDMA(...) LOGMASKED(LOG_DMA, __VA_ARGS__)
+#define LOGHWTRIG(...) LOGMASKED(LOG_HWTRIG, __VA_ARGS__)
+#define LOGDMAEND(...) LOGMASKED(LOG_DMAEND, __VA_ARGS__)
+#define LOGILLEGAL(...) LOGMASKED(LOG_ILLEGAL, __VA_ARGS__)
+
+//**************************************************************************
+// GLOBAL VARIABLES
+//**************************************************************************
+
+
+// device type definition
+DEFINE_DEVICE_TYPE(DC_G2IF, dc_g2if_device, "dc_g2if", "Sega Dreamcast G2 I/F System Bus")
+
+
+//**************************************************************************
+// LIVE DEVICE
+//**************************************************************************
+
+
+//-------------------------------------------------
+// dc_g2if_device - constructor
+//-------------------------------------------------
+
+
+dc_g2if_device::dc_g2if_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
+ : device_t(mconfig, DC_G2IF, tag, owner, clock)
+ , m_host_space(*this, finder_base::DUMMY_TAG, -1)
+ , m_int_w(*this)
+ , m_error_ia_w(*this)
+ , m_error_ov_w(*this)
+{
+}
+
+
+//-------------------------------------------------
+// device_start - device-specific startup
+//-------------------------------------------------
+
+
+void dc_g2if_device::device_start()
+{
+ for (int i = 0; i < 4; i++)
+ {
+ m_dma[i].end_timer = timer_alloc(i);
+ }
+
+ m_int_w.resolve();
+ m_error_ia_w.resolve();
+ m_error_ov_w.resolve();
+
+ save_item(STRUCT_MEMBER(m_dma, g2_addr));
+ save_item(STRUCT_MEMBER(m_dma, root_addr));
+ save_item(STRUCT_MEMBER(m_dma, len));
+ save_item(STRUCT_MEMBER(m_dma, size));
+ save_item(STRUCT_MEMBER(m_dma, mode));
+ save_item(STRUCT_MEMBER(m_dma, dir));
+ save_item(STRUCT_MEMBER(m_dma, enable));
+ save_item(STRUCT_MEMBER(m_dma, in_progress));
+ save_item(STRUCT_MEMBER(m_dma, start));
+ save_item(STRUCT_MEMBER(m_dma, tsel));
+ save_item(STRUCT_MEMBER(m_dma, hw_trigger));
+ save_item(NAME(m_g2apro.top_addr));
+ save_item(NAME(m_g2apro.bottom_addr));
+}
+
+
+//-------------------------------------------------
+// device_reset - device-specific reset
+//-------------------------------------------------
+
+
+void dc_g2if_device::device_reset()
+{
+ for (int ch = 0; ch < 4; ch ++)
+ {
+ m_dma[ch].g2_addr = 0;
+ m_dma[ch].root_addr = 0;
+ m_dma[ch].len = 0;
+ m_dma[ch].size = 0;
+ m_dma[ch].mode = false;
+ m_dma[ch].dir = false;
+ m_dma[ch].enable = false;
+ m_dma[ch].in_progress = false;
+ m_dma[ch].start = false;
+ m_dma[ch].tsel = 0;
+ m_dma[ch].hw_trigger = false;
+ m_dma[ch].end_timer->adjust(attotime::never);
+ }
+}
+
+void dc_g2if_device::device_timer(emu_timer &timer, device_timer_id id, int param)
+{
+ u8 channel = (u8)id;
+ bool dma_result = (param == 1);
+ m_dma[channel].in_progress = false;
+ m_dma[channel].start = false;
+ LOGDMAEND("DMA%d %s\n", id, dma_result ? "normal end" : "overflow error");
+
+ if (dma_result)
+ m_int_w(channel, 1);
+ else
+ m_error_ov_w(channel, 1);
+}
+
+
+//**************************************************************************
+// READ/WRITE HANDLERS
+//**************************************************************************
+
+template <u8 Channel> void dc_g2if_device::channel_map(address_map &map)
+{
+ map(0x00, 0x03).rw(FUNC(dc_g2if_device::stag_r<Channel>), FUNC(dc_g2if_device::stag_w<Channel>));
+ map(0x04, 0x07).rw(FUNC(dc_g2if_device::star_r<Channel>), FUNC(dc_g2if_device::star_w<Channel>));
+ map(0x08, 0x0b).rw(FUNC(dc_g2if_device::len_r<Channel>), FUNC(dc_g2if_device::len_w<Channel>));
+ map(0x0c, 0x0f).rw(FUNC(dc_g2if_device::dir_r<Channel>), FUNC(dc_g2if_device::dir_w<Channel>));
+ map(0x10, 0x13).rw(FUNC(dc_g2if_device::tsel_r<Channel>), FUNC(dc_g2if_device::tsel_w<Channel>));
+ map(0x14, 0x17).rw(FUNC(dc_g2if_device::en_r<Channel>), FUNC(dc_g2if_device::en_w<Channel>));
+ map(0x18, 0x1b).rw(FUNC(dc_g2if_device::st_r<Channel>), FUNC(dc_g2if_device::st_w<Channel>));
+ map(0x1c, 0x1f).rw(FUNC(dc_g2if_device::susp_r<Channel>), FUNC(dc_g2if_device::susp_w<Channel>));
+}
+
+// Instantiate channel maps
+template void dc_g2if_device::channel_map<0>(address_map &map);
+template void dc_g2if_device::channel_map<1>(address_map &map);
+template void dc_g2if_device::channel_map<2>(address_map &map);
+template void dc_g2if_device::channel_map<3>(address_map &map);
+
+void dc_g2if_device::amap(address_map &map)
+{
+ // 0x5f7800-ff
+ // SB_AD*
+ map(0x00, 0x1f).m(FUNC(dc_g2if_device::channel_map<0>));
+ // SB_E1*
+ map(0x20, 0x3f).m(FUNC(dc_g2if_device::channel_map<1>));
+ // SB_E2*
+ map(0x40, 0x5f).m(FUNC(dc_g2if_device::channel_map<2>));
+ // SB_DD*
+ map(0x60, 0x7f).m(FUNC(dc_g2if_device::channel_map<3>));
+
+ map(0x80, 0x83).r(FUNC(dc_g2if_device::g2id_r));
+
+// map(0x90, 0x93).rw SB_G2DSTO #DS timeout
+// map(0x94, 0x97).rw SB_G2TRTO #TR timeout
+// map(0x98, 0x9b).rw SB_G2MDMTO modem wait timeout
+// map(0x9c, 0x9f).rw SB_G2MDMW modem wait time
+
+ map(0xbc, 0xbf).w(FUNC(dc_g2if_device::g2apro_w));
+
+// map(0xc0, 0xcb).r SB_AD*D live register reads (STAG, STAR, LEN)
+// map(0xd0, 0xdb).r SB_E1*D live register reads
+// map(0xe0, 0xeb).r SB_E2*D live register reads
+// map(0xf0, 0xfb).r SB_DD*D live register reads
+}
+
+template <u8 Channel> u32 dc_g2if_device::stag_r()
+{
+ return m_dma[Channel].g2_addr;
+}
+
+// SB_**STAG
+// G2 bus start address
+template <u8 Channel> void dc_g2if_device::stag_w(offs_t offset, u32 data, u32 mem_mask)
+{
+ COMBINE_DATA(&m_dma[Channel].g2_addr);
+
+ if (!g2_address_check(m_dma[Channel].g2_addr))
+ {
+ LOGILLEGAL("%s: G2 illegal Address trap %08x (%08x)\n", machine().describe_context(), data, mem_mask);
+ m_error_ia_w(Channel, 1);
+ }
+}
+
+template <u8 Channel> u32 dc_g2if_device::star_r()
+{
+ return m_dma[Channel].root_addr;
+}
+
+// SB_**STAR
+// root bus (SH4) start address
+template <u8 Channel> void dc_g2if_device::star_w(offs_t offset, u32 data, u32 mem_mask)
+{
+ COMBINE_DATA(&m_dma[Channel].root_addr);
+
+ if (!root_address_check(m_dma[Channel].root_addr))
+ {
+ LOGILLEGAL("%s: root illegal Address trap %08x (%08x)\n", machine().describe_context(), data, mem_mask);
+ m_error_ia_w(Channel, 1);
+ }
+}
+
+template <u8 Channel> u32 dc_g2if_device::len_r()
+{
+ return m_dma[Channel].len;
+}
+
+/*
+ * SB_**LEN
+ * x--- ---- ---- ---- ---- ---- ---- ---- DMA transfer mode
+ * (0) Restart
+ * (1) End (enable register clears to '0')
+ * ---- ---x xxxx xxxx xxxx xxxx xxx- ---- DMA transfer length
+ * (all buses?)
+ */
+template <u8 Channel> void dc_g2if_device::len_w(offs_t offset, u32 data, u32 mem_mask)
+{
+ COMBINE_DATA(&m_dma[Channel].len);
+ // log an attempt if any of the reserved bits 30-25 and 4-0 are set
+ if (m_dma[Channel].len & 0x7fe0001f)
+ LOGWARN("%s: DMA%d LEN setup %08x (mask=%08x)!\n", machine().describe_context(), data, mem_mask);
+// m_dma[Channel].size = m_dma[Channel].len & 0x7fffffff;
+ m_dma[Channel].size = m_dma[Channel].len & 0x001fffe0;
+ m_dma[Channel].mode = bool(BIT(m_dma[Channel].len, 31));
+}
+
+// TODO: following regs are supposedly single byte, but HW still accesses them as dword, is it a liability?
+
+template <u8 Channel> u32 dc_g2if_device::dir_r()
+{
+ return m_dma[Channel].dir;
+}
+
+/*
+ * SB_**DIR (transfer direction)
+ * ---x (0) root -> G2 device RAM
+ * (1) root <- G2 device RAM
+ */
+template <u8 Channel> void dc_g2if_device::dir_w(offs_t offset, u32 data, u32 mem_mask)
+{
+ if (ACCESSING_BITS_0_7)
+ m_dma[Channel].dir = bool(BIT(data, 0));
+}
+
+template <u8 Channel> u32 dc_g2if_device::tsel_r()
+{
+ return m_dma[Channel].tsel;
+}
+
+/*
+ * SB_**TSEL (trigger select)
+ * -x-- SUSPend enable
+ * --x- (0) CPU trigger (along with st_w '1'),
+ * (1) HW trigger (with external pin/irq mechanism)
+ * ---x External pin enable
+ */
+template <u8 Channel> void dc_g2if_device::tsel_w(offs_t offset, u32 data, u32 mem_mask)
+{
+ if (ACCESSING_BITS_0_7)
+ {
+ m_dma[Channel].tsel = data & 7;
+ m_dma[Channel].hw_trigger = bool(BIT(m_dma[Channel].tsel, 1));
+ }
+}
+
+
+template <u8 Channel> u32 dc_g2if_device::en_r()
+{
+ return m_dma[Channel].enable;
+}
+
+/*
+ * SB_**EN
+ * ---x DMA enable
+ * (0) mask
+ * (1) enabled
+ * Note: DMA transfer is aborted if this is written with a 0.
+ */
+template <u8 Channel> void dc_g2if_device::en_w(offs_t offset, u32 data, u32 mem_mask)
+{
+ if (ACCESSING_BITS_0_7)
+ {
+ m_dma[Channel].enable = bool(BIT(data, 0));
+ // TODO: suppresses an in-progress DMA if this is disabled
+ }
+}
+
+template <u8 Channel> u32 dc_g2if_device::st_r()
+{
+ return m_dma[Channel].in_progress & 1;
+}
+
+/*
+ * SB_**ST
+ * ---x DMA start/status
+ * (r) (0) DMA isn't running (1) DMA is in-progress
+ * (w) (1) starts a DMA (if hw_trigger is '0')
+ */
+template <u8 Channel> void dc_g2if_device::st_w(offs_t offset, u32 data, u32 mem_mask)
+{
+ if (ACCESSING_BITS_0_7)
+ {
+ if (m_dma[Channel].start == true)
+ {
+ LOGWARN("%s: DMA%d attempt to start an in-flight\n", machine().describe_context(), Channel);
+ return;
+ }
+
+ m_dma[Channel].start = bool(BIT(data, 0));
+
+ if (m_dma[Channel].enable && m_dma[Channel].start && m_dma[Channel].hw_trigger == false)
+ {
+ LOGDMA("%s: DMA%d root=%08x g2=%08x dir=G2%sroot (%d)\n size=%08x (len=%08x) mode=DMA %s\n",
+ machine().describe_context(), Channel,
+ m_dma[Channel].root_addr, m_dma[Channel].g2_addr, m_dma[Channel].dir ? "->" : "<-",
+ m_dma[Channel].dir,
+ m_dma[Channel].size, m_dma[Channel].len, m_dma[Channel].mode ? "end" : "restart"
+ );
+ dma_execute(Channel);
+ }
+ }
+}
+
+// --x- ---- (r/o) DMA request input state (from external bus?)
+// ---x ---- (r/o) DMA suspend/stop status (active low)
+// ---- ---x (w) DMA suspend request
+template <u8 Channel> u32 dc_g2if_device::susp_r()
+{
+ return (m_dma[Channel].in_progress == false) << 4;
+}
+
+template <u8 Channel> void dc_g2if_device::susp_w(offs_t offset, u32 data, u32 mem_mask)
+{
+ if (ACCESSING_BITS_0_7)
+ {
+ // TODO: unemulated suspend mode
+ if (data & 1)
+ {
+ LOGWARN("%s: DMA%d suspend write %08x %08x\n",
+ machine().describe_context(),
+ Channel, data, mem_mask
+ );
+ // ...
+ }
+ }
+}
+
+//**************************************************************************
+// Misc. registers
+//**************************************************************************
+
+// SB_G2ID
+// 0001 ---- Holly v1.0
+// ---- 0011 G2 version
+u32 dc_g2if_device::g2id_r()
+{
+ LOGWARN("%s: read ID\n", machine().describe_context());
+ return 0x12;
+}
+
+// SB_G2APRO
+// xxxx xxxx xxxx xxxx ---- ---- ---- ---- Unlock register (must be == 0x4659)
+// ---- ---- ---- ---- -xxx xxxx ---- ---- Top range (start address)
+// ---- ---- ---- ---- ---- ---- -xxx xxxx Bottom range (end address)
+// all channels follows this ruleset
+void dc_g2if_device::g2apro_w(offs_t offset, u32 data, u32 mem_mask)
+{
+ if (mem_mask != 0xffffffff)
+ {
+ LOGWARN("%s: g2apro_w attempt to write %08x with a non-dword (mem_mask=%08x)\n", machine().describe_context(), data, mem_mask);
+ return;
+ }
+ const u16 security_code = data >> 16;
+
+ if (security_code != 0x4659)
+ {
+ LOGWARN("%s: g2apro_w attempt to write %08x without satisfying security code condition\n", machine().describe_context(), data);
+ return;
+ }
+
+ const u16 top_range = (data & 0x7f00) >> 8;
+ const u16 bottom_range = (data & 0x7f);
+
+ m_g2apro.top_addr = (top_range << 20) | 0x08000000;
+ m_g2apro.bottom_addr = (bottom_range << 20) | 0x080fffff;
+
+ LOGILLEGAL("%s: g2apro_w set top=%08x bottom=%08x (%08x)\n",
+ machine().describe_context(),
+ m_g2apro.top_addr, m_g2apro.bottom_addr, data
+ );
+}
+
+//**************************************************************************
+// DMA implementation
+//**************************************************************************
+
+inline bool dc_g2if_device::root_address_check(u32 offset)
+{
+ const u8 area = (offset >> 26) & 7;
+ // root iA is generated by accessing outside System RAM or texture/framebuffer RAM
+ return area == 1 || area == 3;
+}
+
+inline bool dc_g2if_device::g2_address_check(u32 offset)
+{
+ const u8 area = (offset >> 26) & 7;
+ // g2 iA is generated by accessing outside:
+ // - area == 0 for AD/E1/E2 buses
+ // - area == 5 for DD
+ return area == 0 || area == 5;
+}
+
+inline bool dc_g2if_device::root_overflow_check(u32 offset, u8 channel)
+{
+ bool result = offset >= m_g2apro.top_addr && offset <= m_g2apro.bottom_addr;
+ if (result == false)
+ LOGILLEGAL("DMA%d overflow abort root=%08x\n", channel, offset);
+
+ return result;
+}
+
+void dc_g2if_device::dma_execute(u8 channel)
+{
+ u32 src, dst, index, transfer_size;
+ dst = m_dma[channel].g2_addr;
+ src = m_dma[channel].root_addr;
+
+ // Punt if attempts to go beyond the allocated buses
+ // TODO: should require two extra cycles for fetching addresses first
+ if (!root_address_check(src) || !g2_address_check(dst))
+ {
+ LOGILLEGAL("%s: DMA%d illegal address attempt root=%08x g2=%08x\n",
+ machine().describe_context(),
+ channel, src, dst
+ );
+ m_dma[channel].in_progress = false;
+ m_dma[channel].start = false;
+ m_dma[channel].enable = false;
+ m_error_ia_w(channel, 1);
+ return;
+ }
+
+ index = 0;
+
+ transfer_size = m_dma[channel].size;
+ /* 0 rounding size = 32 Mbytes */
+ if (transfer_size == 0) { transfer_size = 0x200000; }
+
+ if (m_dma[channel].dir == 1)
+ std::swap(src, dst);
+
+ // notify that a DMA is in progress
+ // ofc this should rather transfer one word at a time,
+ // we currently don't do that for performance reasons ...
+ m_dma[channel].in_progress = true;
+
+ bool dma_result = true;
+
+ for (; index < transfer_size; index += 2)
+ {
+ // assert that root address is inside the g2apro range
+ if (!root_overflow_check(m_dma[channel].dir ? dst : src, channel))
+ {
+ dma_result = false;
+ break;
+ }
+ // TODO: raise debug signals if SB_G2DSTO / SB_G2TRTO aren't respected
+ // Shouldn't matter for AICA RAM,
+ // it does in loopchk g2 test 0304 when it tries to write to
+ // expansion bus (where nothing lies on stock DC)
+ m_host_space->write_word(dst, m_host_space->read_word(src));
+ src += 2;
+ dst += 2;
+ }
+
+ // update the params
+ // Note: if you trigger an instant DMA IRQ trigger, sfz3ugd doesn't play any BGM.
+ // G2 bus is 16 bits @ 25 MHz according to Fig. 2-1
+ // TODO: reported limit output for AICA DMA is set at 11.3MB/s while the others at 24.0/26.0
+ // bus contention ftw ...
+ const attotime dma_time = attotime::from_ticks(index / 2, clock());
+
+ m_dma[channel].g2_addr = dst;
+ m_dma[channel].root_addr = src;
+ // TODO: how len copes with updates?
+ m_dma[channel].len = 0;
+ // clear mask flag if the DMA transfer mode is in End mode
+ // (Restart mode leaves this set to true)
+ if (m_dma[channel].mode == true)
+ m_dma[channel].enable = false;
+
+ m_dma[channel].end_timer->adjust(dma_time, dma_result);
+}
+
+/*
+ * normal_ist: SB_G2DTNRM & SB_ISTNRM
+ * (triggers a DMA if selected irq in former gets triggered)
+ * ext_ist: SB_G2DTEXT & SB_ISTEXT
+ * (triggers a DMA if external pin is triggered)
+ */
+void dc_g2if_device::hw_irq_trigger_hs(u32 normal_ist, u32 ext_ist)
+{
+ // TODO: is latter requiring .tsel bit 0 == 1?
+ bool hw_ist_enable = normal_ist || ext_ist;
+
+ if (hw_ist_enable == false)
+ return;
+
+ for (int ch = 0; ch < 4; ch++)
+ {
+ if (m_dma[ch].hw_trigger & m_dma[ch].enable)
+ {
+ LOGHWTRIG("HW trigger channel %d (ISTNRM=%08x ISTEXT=%08x)\n", ch, normal_ist, ext_ist);
+ dma_execute(ch);
+ }
+ }
+}
diff --git a/src/mame/machine/dc_g2if.h b/src/mame/machine/dc_g2if.h
new file mode 100644
index 00000000000..5cf0888b563
--- /dev/null
+++ b/src/mame/machine/dc_g2if.h
@@ -0,0 +1,105 @@
+// license:LGPL-2.1+
+// copyright-holders:Angelo Salese
+/**************************************************************************************************
+
+ Sega Dreamcast G2 System Bus I/F
+
+**************************************************************************************************/
+
+#ifndef MAME_MACHINE_DC_G2IF_H
+#define MAME_MACHINE_DC_G2IF_H
+
+#pragma once
+
+//**************************************************************************
+// TYPE DEFINITIONS
+//**************************************************************************
+
+class dc_g2if_device : public device_t
+{
+public:
+ // construction/destruction
+ dc_g2if_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
+ template <typename T> void set_host_space(T &&tag, int index) { m_host_space.set_tag(std::forward<T>(tag), index); }
+ auto int_cb() { return m_int_w.bind(); }
+ auto error_ia_cb() { return m_error_ia_w.bind(); }
+ auto error_ov_cb() { return m_error_ov_w.bind(); }
+
+ void amap(address_map &map);
+
+ void hw_irq_trigger_hs(u32 normal_ist, u32 ext_ist);
+
+protected:
+ // device-level overrides
+ //virtual void device_validity_check(validity_checker &valid) const override;
+ //virtual void device_add_mconfig(machine_config &config) override;
+ virtual void device_start() override;
+ virtual void device_reset() override;
+ virtual void device_timer(emu_timer &timer, device_timer_id id, int param) override;
+
+private:
+ required_address_space m_host_space;
+ devcb_write8 m_int_w;
+ devcb_write8 m_error_ia_w;
+ devcb_write8 m_error_ov_w;
+
+ struct {
+ u32 g2_addr;
+ u32 root_addr;
+ u32 len;
+ u32 size;
+ bool mode;
+ bool dir;
+ bool enable;
+ bool in_progress;
+ bool start;
+ u8 tsel;
+ bool hw_trigger;
+ emu_timer *end_timer;
+ } m_dma[4];
+
+ struct {
+ u32 bottom_addr;
+ u32 top_addr;
+ } m_g2apro;
+
+ template <u8 Channel> void channel_map(address_map &map);
+
+ template <u8 Channel> u32 stag_r();
+ template <u8 Channel> void stag_w(offs_t offset, u32 data, u32 mem_mask = ~0);
+
+ template <u8 Channel> u32 star_r();
+ template <u8 Channel> void star_w(offs_t offset, u32 data, u32 mem_mask = ~0);
+
+ template <u8 Channel> u32 len_r();
+ template <u8 Channel> void len_w(offs_t offset, u32 data, u32 mem_mask = ~0);
+
+ template <u8 Channel> u32 dir_r();
+ template <u8 Channel> void dir_w(offs_t offset, u32 data, u32 mem_mask = ~0);
+
+ template <u8 Channel> u32 tsel_r();
+ template <u8 Channel> void tsel_w(offs_t offset, u32 data, u32 mem_mask = ~0);
+
+ template <u8 Channel> u32 en_r();
+ template <u8 Channel> void en_w(offs_t offset, u32 data, u32 mem_mask = ~0);
+
+ template <u8 Channel> u32 st_r();
+ template <u8 Channel> void st_w(offs_t offset, u32 data, u32 mem_mask = ~0);
+
+ template <u8 Channel> u32 susp_r();
+ template <u8 Channel> void susp_w(offs_t offset, u32 data, u32 mem_mask = ~0);
+
+ void dma_execute(u8 channel);
+ bool root_address_check(u32 offset);
+ bool g2_address_check(u32 offset);
+ bool root_overflow_check(u32 offset, u8 channel);
+
+ u32 g2id_r();
+ void g2apro_w(offs_t offset, u32 data, u32 mem_mask = ~0);
+};
+
+
+// device type definition
+DECLARE_DEVICE_TYPE(DC_G2IF, dc_g2if_device)
+
+#endif // MAME_MACHINE_DC_G2IF_H
diff --git a/src/mame/machine/dccons.cpp b/src/mame/machine/dccons.cpp
index 08634ce1bd2..ba8ed4ba1c2 100644
--- a/src/mame/machine/dccons.cpp
+++ b/src/mame/machine/dccons.cpp
@@ -4,8 +4,14 @@
dc.c - Sega Dreamcast hardware
- MESS (DC home console) hardware overrides (GD-ROM drive etc)
+ DC home console hardware overrides (GD-ROM drive etc)
+ TODO:
+ - Convert to actual G1 I/F;
+ - gdrom_alt_status is identical to normal status except that "but it does not clear DMA status information when it is accessed";
+ - Verify unimplemented behaviours via tests;
+
+ Old notes, consultation only:
c230048 - 5 is written, want 6
c0d9d9e - where bad happens, from routine @ c0da260
@@ -13,20 +19,28 @@
cfffee0 - stack location when bad happens
- TODO:
- - gdrom_alt_status is identical to normal status except that "but it does not clear DMA status information when it is accessed"
-
*/
#include "emu.h"
#include "cdrom.h"
-#include "debugger.h"
+//#include "debugger.h"
#include "includes/dc.h"
#include "cpu/sh/sh4.h"
#include "sound/aica.h"
#include "includes/dccons.h"
-#define ATAPI_CYCLES_PER_SECTOR (5000) // TBD for Dreamcast
+// TODO: fine grain this value
+#define ATAPI_CYCLES_PER_SECTOR (5000)
+
+#define LOG_WARN (1U << 1)
+#define LOG_XFER (1U << 2) // log ATAPI transfers
+
+#define VERBOSE (LOG_WARN)
+//#define LOG_OUTPUT_STREAM std::cout
+#include "logmacro.h"
+
+#define LOGWARN(...) LOGMASKED(LOG_WARN, __VA_ARGS__)
+#define LOGXFER(...) LOGMASKED(LOG_XFER, __VA_ARGS__)
WRITE_LINE_MEMBER(dc_cons_state::ata_interrupt)
{
@@ -44,18 +58,18 @@ TIMER_CALLBACK_MEMBER(dc_cons_state::atapi_xfer_end )
atapi_timer->adjust(attotime::never);
- printf("atapi_xfer_end atapi_xferlen = %d\n", atapi_xferlen );
-
- //osd_printf_debug("ATAPI: xfer_end. xferlen = %d\n", atapi_xferlen);
+ LOGXFER("atapi_xfer_end atapi_xferlen = %d\n", atapi_xferlen );
m_ata->write_dmack(1);
atapi_xfercomplete = 0;
+
+ // TODO: dispatch transfers one step at a time instead of the full block
while (atapi_xferlen > 0 )
{
struct sh4_ddt_dma ddtdata;
// get a sector from the SCSI device
- for (int i = 0; i < 2048/2; i++)
+ for (int i = 0; i < 2048 / 2; i++)
{
int d = m_ata->read_dma();
sector_buffer[ i*2 ] = d & 0xff;
@@ -67,13 +81,15 @@ TIMER_CALLBACK_MEMBER(dc_cons_state::atapi_xfer_end )
// perform the DMA
ddtdata.destination = atapi_xferbase; // destination address
- ddtdata.length = 2048/4;
+ ddtdata.length = 2048 / 4;
ddtdata.size = 4;
ddtdata.buffer = sector_buffer;
- ddtdata.direction=1; // 0 source to buffer, 1 buffer to destination
- ddtdata.channel= 0;
- ddtdata.mode= -1; // copy from/to buffer
- printf("ATAPI: DMA one sector to %x, %x remaining\n", atapi_xferbase, atapi_xferlen);
+ ddtdata.direction = 1; // 0 source to buffer, 1 buffer to destination
+ ddtdata.channel = 0;
+ ddtdata.mode = -1; // copy from/to buffer
+ LOGXFER("G1 I/F ATAPI: DMA one sector to %x, %x remaining\n",
+ atapi_xferbase, atapi_xferlen
+ );
m_maincpu->sh4_dma_ddt(&ddtdata);
atapi_xferbase += 2048;
@@ -81,14 +97,16 @@ TIMER_CALLBACK_MEMBER(dc_cons_state::atapi_xfer_end )
m_ata->write_dmack(0);
- g1bus_regs[SB_GDST]=0;
+ g1bus_regs[SB_GDST] = 0;
dc_sysctrl_regs[SB_ISTNRM] |= IST_DMA_GDROM;
dc_update_interrupt_status();
}
void dc_cons_state::dreamcast_atapi_init()
{
- atapi_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(dc_cons_state::atapi_xfer_end),this));
+ atapi_timer = machine().scheduler().timer_alloc(
+ timer_expired_delegate(FUNC(dc_cons_state::atapi_xfer_end), this)
+ );
atapi_timer->adjust(attotime::never);
save_item(NAME(atapi_xferlen));
save_item(NAME(atapi_xferbase));
@@ -119,8 +137,9 @@ uint32_t dc_cons_state::dc_mess_g1_ctrl_r(offs_t offset)
switch(offset)
{
case SB_GDSTARD:
- printf("G1CTRL: GDSTARD %08x\n", atapi_xferbase); // Hello Kitty reads here
- machine().debug_break();
+ // TODO: one of the Hello Kitty (identify which) reads there
+ logerror("G1CTRL: GDSTARD %08x\n", atapi_xferbase);
+ //machine().debug_break();
return atapi_xferbase;
case SB_GDST:
break;
@@ -135,8 +154,8 @@ uint32_t dc_cons_state::dc_mess_g1_ctrl_r(offs_t offset)
// 0 - check in progress, BIOS data summed, G1 ATA area blocked (read FFFFFFFFh)
return 3;
default:
- printf("G1CTRL: Unmapped read %08x\n", 0x5f7400+offset*4);
- machine().debug_break();
+ LOGWARN("G1CTRL: Unmapped read %08x\n", 0x5f7400 + offset * 4);
+ //machine().debug_break();
break;
}
return g1bus_regs[offset];
@@ -148,27 +167,29 @@ void dc_cons_state::dc_mess_g1_ctrl_w(offs_t offset, uint32_t data, uint32_t mem
// osd_printf_verbose("G1CTRL: [%08x=%x] write %x to %x, mask %x\n", 0x5f7400+reg*4, dat, data, offset, mem_mask);
switch (offset)
{
- case SB_GDST:
- if (data & 1 && g1bus_regs[SB_GDEN] == 1) // 0 -> 1
- {
- if (g1bus_regs[SB_GDDIR] == 0)
+ case SB_GDST:
+ if (data & 1 && g1bus_regs[SB_GDEN] == 1) // 0 -> 1
{
- printf("G1CTRL: unsupported transfer\n");
- return;
+ if (g1bus_regs[SB_GDDIR] == 0)
+ {
+ // TODO: write to GD-ROM, shouldn't happen unless "special" condition occurs
+ // (implies a debug/development device?)
+ LOGWARN("%s: G1 I/F illegal direction transfer\n", machine().describe_context());
+ return;
+ }
+
+ atapi_xferbase = g1bus_regs[SB_GDSTAR];
+ //atapi_timer->adjust(m_maincpu->cycles_to_attotime((ATAPI_CYCLES_PER_SECTOR * (atapi_xferlen/2048))));
+ /* 12x * 75 Hz = 0,00(1) secs per sector */
+ /* TODO: make DMA to be single step */
+ atapi_timer->adjust(attotime::from_usec(1111*atapi_xferlen/2048));
+// atapi_regs[ATAPI_REG_SAMTAG] = GDROM_PAUSE_STATE | 0x80;
}
+ break;
- atapi_xferbase = g1bus_regs[SB_GDSTAR];
- //atapi_timer->adjust(m_maincpu->cycles_to_attotime((ATAPI_CYCLES_PER_SECTOR * (atapi_xferlen/2048))));
- /* 12x * 75 Hz = 0,00(1) secs per sector */
- /* TODO: make DMA to be single step */
- atapi_timer->adjust(attotime::from_usec(1111*atapi_xferlen/2048));
-// atapi_regs[ATAPI_REG_SAMTAG] = GDROM_PAUSE_STATE | 0x80;
- }
- break;
-
- case SB_GDLEN:
- atapi_xferlen = data;
- break;
+ case SB_GDLEN:
+ atapi_xferlen = data;
+ break;
/*
The following register is involved in BIOS checksum protection system.
@@ -195,12 +216,12 @@ void dc_cons_state::dc_mess_g1_ctrl_w(offs_t offset, uint32_t data, uint32_t mem
all described above works the same way in all HOLLY/CLX2-based systems - Dreamcast, Naomi 1/2, Atomiswave, SystemSP
*/
- case SB_SECUR_EADR:
- if (data==0 || data==0x001fffff || data==0x42fe)
- {
-// atapi_regs[ATAPI_REG_SAMTAG] = GDROM_PAUSE_STATE | 0x80;
- printf("Unlocking GD-ROM! %x\n", data);
- }
- break;
+ case SB_SECUR_EADR:
+ if (data==0 || data==0x001fffff || data==0x42fe)
+ {
+ // atapi_regs[ATAPI_REG_SAMTAG] = GDROM_PAUSE_STATE | 0x80;
+ logerror("%s: Unlocking GD-ROM %x\n", machine().describe_context(), data);
+ }
+ break;
}
}
diff --git a/src/mame/machine/dec0.cpp b/src/mame/machine/dec0.cpp
index befcf91b42d..926c2c58967 100644
--- a/src/mame/machine/dec0.cpp
+++ b/src/mame/machine/dec0.cpp
@@ -256,25 +256,6 @@ void dec0_state::sprite_mirror_w(offs_t offset, uint16_t data, uint16_t mem_mask
/******************************************************************************/
-uint16_t dec0_state::robocop_68000_share_r(offs_t offset)
-{
-//logerror("%08x: Share read %04x\n",m_maincpu->pc(),offset);
-
- return m_robocop_shared_ram[offset];
-}
-
-void dec0_state::robocop_68000_share_w(offs_t offset, uint16_t data)
-{
-// logerror("%08x: Share write %04x %04x\n",m_maincpu->pc(),offset,data);
-
- m_robocop_shared_ram[offset] = data & 0xff;
-
- if (offset == 0x7ff) /* A control address - not standard ram */
- m_subcpu->set_input_line(0, HOLD_LINE);
-}
-
-/******************************************************************************/
-
void dec0_state::h6280_decrypt(const char *cputag)
{
int i;
diff --git a/src/mame/machine/dec_lk201.cpp b/src/mame/machine/dec_lk201.cpp
index 3230a3b1dda..4bf0ad985bc 100644
--- a/src/mame/machine/dec_lk201.cpp
+++ b/src/mame/machine/dec_lk201.cpp
@@ -572,7 +572,7 @@ void lk201_device::device_reset()
m_led_hold = 0; // led11
}
-void lk201_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
+void lk201_device::device_timer(emu_timer &timer, device_timer_id id, int param)
{
switch (id)
{
diff --git a/src/mame/machine/dec_lk201.h b/src/mame/machine/dec_lk201.h
index 87a7e45a65d..59881d309a4 100644
--- a/src/mame/machine/dec_lk201.h
+++ b/src/mame/machine/dec_lk201.h
@@ -67,7 +67,7 @@ protected:
virtual ioport_constructor device_input_ports() const override;
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_timer(emu_timer &timer, device_timer_id id, int param) override;
// device_serial overrides
virtual void rcv_complete() override; // Rx completed receiving byte
diff --git a/src/mame/machine/decopincpu.cpp b/src/mame/machine/decopincpu.cpp
index 38e9d5c2d06..518149d0395 100644
--- a/src/mame/machine/decopincpu.cpp
+++ b/src/mame/machine/decopincpu.cpp
@@ -58,7 +58,7 @@ static INPUT_PORTS_START( decocpu1 )
PORT_CONFSETTING( 0x10, "English" )
INPUT_PORTS_END
-void decocpu_type1_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
+void decocpu_type1_device::device_timer(emu_timer &timer, device_timer_id id, int param)
{
switch(id)
{
diff --git a/src/mame/machine/decopincpu.h b/src/mame/machine/decopincpu.h
index ba3ae40cc06..5455d2fb37a 100644
--- a/src/mame/machine/decopincpu.h
+++ b/src/mame/machine/decopincpu.h
@@ -62,7 +62,7 @@ protected:
virtual void device_add_mconfig(machine_config &config) override;
virtual void device_start() override;
virtual ioport_constructor device_input_ports() const override;
- virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override;
+ virtual void device_timer(emu_timer &timer, device_timer_id id, int param) override;
void decocpu1_map(address_map &map);
diff --git a/src/mame/machine/dgn_beta.cpp b/src/mame/machine/dgn_beta.cpp
index d8e1026f39b..05066fab936 100644
--- a/src/mame/machine/dgn_beta.cpp
+++ b/src/mame/machine/dgn_beta.cpp
@@ -748,20 +748,20 @@ void dgn_beta_state::dgn_beta_frame_interrupt (int data)
ScanInKeyboard();
}
-#ifdef UNUSED_FUNCTION
-void dgn_beta_state::dgn_beta_line_interrupt (int data)
-{
-// /* Set PIA line, so it recognises interrupt */
-// if (data)
-// {
-// m_pia_0->cb1_w(ASSERT_LINE);
-// }
-// else
-// {
-// m_pia_0->cb1_w(CLEAR_LINE);
-// }
-}
+void dgn_beta_state::dgn_beta_line_interrupt(int data)
+{
+#if 0
+ /* Set PIA line, so it recognises interrupt */
+ if (data)
+ {
+ m_pia_0->cb1_w(ASSERT_LINE);
+ }
+ else
+ {
+ m_pia_0->cb1_w(CLEAR_LINE);
+ }
#endif
+}
/********************************* Machine/Driver Initialization ****************************************/
diff --git a/src/mame/machine/digilog320_kbd.cpp b/src/mame/machine/digilog320_kbd.cpp
new file mode 100644
index 00000000000..bcf36f315d2
--- /dev/null
+++ b/src/mame/machine/digilog320_kbd.cpp
@@ -0,0 +1,309 @@
+// license: BSD-3-Clause
+// copyright-holders: Dirk Best
+/***************************************************************************
+
+ Digilog 320 Keyboard (HLE)
+
+ TODO:
+ - Map and verify missing keys
+
+***************************************************************************/
+
+#include "emu.h"
+#include "digilog320_kbd.h"
+#include "machine/keyboard.ipp"
+
+
+//**************************************************************************
+// DEVICE DEFINITIONS
+//**************************************************************************
+
+DEFINE_DEVICE_TYPE(DIGILOG320_KBD_HLE, digilog320_kbd_hle_device, "digilog320_kbd_hle", "Digilog 320 Keyboard (HLE)")
+
+namespace {
+
+uint8_t const TRANSLATION_TABLE[4][5][18] =
+{
+ // unshift
+ {
+ { 0x00, '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '-', '=', 0x00, 0x8f, 0x96, 0x95, 0x80 }, // 0
+ { 0x8a, 'q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p', '[', ']', 0x8d, 0x8e, 0x89, 0x97, 0x88 }, // 1
+ { 0x00, 'a', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l', ';', 0x00, 0x00, 0x84, 0x85, 0x81, 0x90, 0x00 }, // 2
+ { 0x00, '\\', 'z', 'x', 'c', 'v', 'b', 'n', 'm', ',', '.', '/', 0x00, 0x98, 0x99, 0x91, 0x92, 0x93 }, // 3
+ { 0x00, 0x00, ' ', 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, '`', '\'', 0x87, 0x8b, 0x8c, 0x83, 0x94, 0x82 }, // 4
+ },
+ // shift
+ {
+ { 0x00, '!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '_', '+', 0x00, 0x00, 0x00, 0x00, 0x00 }, // 0
+ { 0x00, 'Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I', 'O', 'P', '{', '}', 0x00, 0x00, 0x00, 0x00, 0x00 }, // 1
+ { 0x00, 'A', 'S', 'D', 'F', 'G', 'H', 'J', 'K', 'L', ':', 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, // 2
+ { 0x00, '|', 'Z', 'X', 'C', 'V', 'B', 'N', 'M', '<', '>', '?', 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, // 3
+ { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, '~', '"', 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, // 4
+ },
+ // unshift-control
+ {
+ { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, // 0
+ { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, // 1
+ { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, // 2
+ { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, // 3
+ { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, // 4
+ },
+ // shift-control
+ {
+ { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, // 0
+ { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, // 1
+ { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, // 2
+ { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, // 3
+ { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, // 4
+ }
+};
+
+} // anonymous namespace
+
+//-------------------------------------------------
+// input_ports - device-specific input ports
+//-------------------------------------------------
+
+// unknown codes: Nul, Return, Halt, Mask / Crc, Don't Care (0x83?), Not (0x82?)
+
+static INPUT_PORTS_START( keyboard )
+ PORT_START("mod")
+ PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Ctrl") PORT_CODE(KEYCODE_LCONTROL) PORT_CODE(KEYCODE_RCONTROL) PORT_CHAR(UCHAR_MAMEKEY(LCONTROL))
+ PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Shift") PORT_CODE(KEYCODE_LSHIFT) PORT_CODE(KEYCODE_RSHIFT) PORT_CHAR(UCHAR_SHIFT_1)
+ PORT_BIT(0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Caps Lock") PORT_CODE(KEYCODE_CAPSLOCK) PORT_CHAR(UCHAR_MAMEKEY(CAPSLOCK)) PORT_TOGGLE
+
+ PORT_START("row_0")
+ PORT_BIT(0x000001, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_F1) PORT_NAME("Nul")
+ PORT_BIT(0x000002, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_1) PORT_CHAR('1') PORT_CHAR('!')
+ PORT_BIT(0x000004, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_2) PORT_CHAR('2') PORT_CHAR('@')
+ PORT_BIT(0x000008, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_3) PORT_CHAR('3') PORT_CHAR('#')
+ PORT_BIT(0x000010, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_4) PORT_CHAR('4') PORT_CHAR('$')
+ PORT_BIT(0x000020, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_5) PORT_CHAR('5') PORT_CHAR('%')
+ PORT_BIT(0x000040, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_6) PORT_CHAR('6') PORT_CHAR('^')
+ PORT_BIT(0x000080, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_7) PORT_CHAR('7') PORT_CHAR('&')
+ PORT_BIT(0x000100, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_8) PORT_CHAR('8') PORT_CHAR('*')
+ PORT_BIT(0x000200, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_9) PORT_CHAR('9') PORT_CHAR('(')
+ PORT_BIT(0x000400, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_0) PORT_CHAR('0') PORT_CHAR(')')
+ PORT_BIT(0x000800, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_MINUS) PORT_CHAR('-') PORT_CHAR('_')
+ PORT_BIT(0x001000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_EQUALS) PORT_CHAR('=') PORT_CHAR('+')
+ PORT_BIT(0x002000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_F2) PORT_NAME("Halt")
+ PORT_BIT(0x004000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_F3) PORT_NAME("Run Mon")
+ PORT_BIT(0x008000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_F4) PORT_NAME("Run Trap")
+ PORT_BIT(0x010000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_F5) PORT_NAME("Run Prog")
+ PORT_BIT(0x020000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_F6) PORT_NAME("Auto Set-up")
+
+ PORT_START("row_1")
+ PORT_BIT(0x000001, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_DEL) PORT_CHAR(UCHAR_MAMEKEY(DEL))
+ PORT_BIT(0x000002, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_Q) PORT_CHAR('q') PORT_CHAR('Q')
+ PORT_BIT(0x000004, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_W) PORT_CHAR('w') PORT_CHAR('W')
+ PORT_BIT(0x000008, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_E) PORT_CHAR('e') PORT_CHAR('E')
+ PORT_BIT(0x000010, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_R) PORT_CHAR('r') PORT_CHAR('R')
+ PORT_BIT(0x000020, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_T) PORT_CHAR('t') PORT_CHAR('T')
+ PORT_BIT(0x000040, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_Y) PORT_CHAR('y') PORT_CHAR('Y')
+ PORT_BIT(0x000080, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_U) PORT_CHAR('u') PORT_CHAR('U')
+ PORT_BIT(0x000100, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_I) PORT_CHAR('i') PORT_CHAR('I')
+ PORT_BIT(0x000200, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_O) PORT_CHAR('o') PORT_CHAR('O')
+ PORT_BIT(0x000400, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_P) PORT_CHAR('p') PORT_CHAR('P')
+ PORT_BIT(0x000800, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_OPENBRACE) PORT_CHAR('[') PORT_CHAR('{')
+ PORT_BIT(0x001000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_CLOSEBRACE) PORT_CHAR(']') PORT_CHAR('}')
+ PORT_BIT(0x002000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_PGDN) PORT_NAME("Page Fwd")
+ PORT_BIT(0x004000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_PGUP) PORT_NAME("Page Rev")
+ PORT_BIT(0x008000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_ESC) PORT_NAME("Main Menu")
+ PORT_BIT(0x010000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_F7) PORT_NAME("Exec Menu Cmd")
+ PORT_BIT(0x020000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_F8) PORT_NAME("Hex")
+
+ PORT_START("row_2")
+ PORT_BIT(0x000001, IP_ACTIVE_HIGH, IPT_UNUSED) // "Ctrl" handled elsewhere
+ PORT_BIT(0x000002, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_A) PORT_CHAR('a') PORT_CHAR('A')
+ PORT_BIT(0x000004, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_S) PORT_CHAR('s') PORT_CHAR('S')
+ PORT_BIT(0x000008, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_D) PORT_CHAR('d') PORT_CHAR('D')
+ PORT_BIT(0x000010, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_F) PORT_CHAR('f') PORT_CHAR('F')
+ PORT_BIT(0x000020, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_G) PORT_CHAR('g') PORT_CHAR('G')
+ PORT_BIT(0x000040, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_H) PORT_CHAR('h') PORT_CHAR('H')
+ PORT_BIT(0x000080, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_J) PORT_CHAR('j') PORT_CHAR('J')
+ PORT_BIT(0x000100, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_K) PORT_CHAR('k') PORT_CHAR('K')
+ PORT_BIT(0x000200, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_L) PORT_CHAR('l') PORT_CHAR('L')
+ PORT_BIT(0x000400, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_COLON) PORT_CHAR(';') PORT_CHAR(':')
+ PORT_BIT(0x000800, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_ENTER) PORT_CHAR(13)
+ PORT_BIT(0x001000, IP_ACTIVE_HIGH, IPT_UNUSED)
+ PORT_BIT(0x002000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_F9) PORT_NAME("Field Sel Fwd")
+ PORT_BIT(0x004000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_F10) PORT_NAME("Field Sel Rev")
+ PORT_BIT(0x008000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_BACKSPACE) PORT_NAME("Clear")
+ PORT_BIT(0x010000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_UP) PORT_CHAR(UCHAR_MAMEKEY(UP))
+ PORT_BIT(0x020000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_F11) PORT_NAME("Mask Crc")
+
+ PORT_START("row_3")
+ PORT_BIT(0x000001, IP_ACTIVE_HIGH, IPT_UNUSED) // "Left Shift" handled elsewhere
+ PORT_BIT(0x000002, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_BACKSLASH2) PORT_CHAR('\\') PORT_CHAR('|')
+ PORT_BIT(0x000004, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_Z) PORT_CHAR('z') PORT_CHAR('Z')
+ PORT_BIT(0x000008, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_X) PORT_CHAR('x') PORT_CHAR('X')
+ PORT_BIT(0x000010, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_C) PORT_CHAR('c') PORT_CHAR('C')
+ PORT_BIT(0x000020, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_V) PORT_CHAR('v') PORT_CHAR('V')
+ PORT_BIT(0x000040, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_B) PORT_CHAR('b') PORT_CHAR('B')
+ PORT_BIT(0x000080, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_N) PORT_CHAR('n') PORT_CHAR('N')
+ PORT_BIT(0x000100, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_M) PORT_CHAR('m') PORT_CHAR('M')
+ PORT_BIT(0x000200, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_COMMA) PORT_CHAR(',') PORT_CHAR('<')
+ PORT_BIT(0x000400, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_STOP) PORT_CHAR('.') PORT_CHAR('>')
+ PORT_BIT(0x000800, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_SLASH) PORT_CHAR('/') PORT_CHAR('?')
+ PORT_BIT(0x001000, IP_ACTIVE_HIGH, IPT_UNUSED) // "Right Shift" handled elsewhere
+ PORT_BIT(0x002000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_TAB) PORT_NAME("Tab Fwd")
+ PORT_BIT(0x004000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_F12) PORT_NAME("Tab Rev")
+ PORT_BIT(0x008000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_LEFT) PORT_CHAR(UCHAR_MAMEKEY(LEFT))
+ PORT_BIT(0x010000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_HOME) PORT_NAME("Freeze Home")
+ PORT_BIT(0x020000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_RIGHT) PORT_CHAR(UCHAR_MAMEKEY(RIGHT))
+
+ PORT_START("row_4")
+ PORT_BIT(0x000001, IP_ACTIVE_HIGH, IPT_UNUSED) // "Shift Lock"
+ PORT_BIT(0x000002, IP_ACTIVE_HIGH, IPT_UNUSED) // "Caps Lock" handled elsewhere
+ PORT_BIT(0x000004, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_SPACE) PORT_CHAR(' ')
+ PORT_BIT(0x000008, IP_ACTIVE_HIGH, IPT_UNUSED)
+ PORT_BIT(0x000010, IP_ACTIVE_HIGH, IPT_UNUSED)
+ PORT_BIT(0x000020, IP_ACTIVE_HIGH, IPT_UNUSED)
+ PORT_BIT(0x000040, IP_ACTIVE_HIGH, IPT_UNUSED)
+ PORT_BIT(0x000080, IP_ACTIVE_HIGH, IPT_UNUSED)
+ PORT_BIT(0x000100, IP_ACTIVE_HIGH, IPT_UNUSED)
+ PORT_BIT(0x000200, IP_ACTIVE_HIGH, IPT_UNUSED)
+ PORT_BIT(0x000400, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_TILDE) PORT_CHAR('`') PORT_CHAR('~')
+ PORT_BIT(0x000800, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_QUOTE) PORT_CHAR('\'') PORT_CHAR('"')
+ PORT_BIT(0x001000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_END) PORT_NAME("Help")
+ PORT_BIT(0x002000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_INSERT) PORT_NAME("Insert Line Del")
+ PORT_BIT(0x004000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_0_PAD) PORT_NAME("Insert Char Del")
+ PORT_BIT(0x008000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_1_PAD) PORT_NAME("Don\'t Care")
+ PORT_BIT(0x010000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_DOWN) PORT_CHAR(UCHAR_MAMEKEY(DOWN))
+ PORT_BIT(0x020000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_2_PAD) PORT_NAME("Not")
+INPUT_PORTS_END
+
+ioport_constructor digilog320_kbd_hle_device::device_input_ports() const
+{
+ return INPUT_PORTS_NAME( keyboard );
+}
+
+
+//**************************************************************************
+// LIVE DEVICE
+//**************************************************************************
+
+//-------------------------------------------------
+// digilog320_kbd_hle_device - constructor
+//-------------------------------------------------
+
+digilog320_kbd_hle_device::digilog320_kbd_hle_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
+ device_t(mconfig, DIGILOG320_KBD_HLE, tag, owner, clock),
+ device_buffered_serial_interface(mconfig, *this),
+ device_matrix_keyboard_interface(mconfig, *this, "row_0", "row_1", "row_2", "row_3", "row_4"),
+ m_modifiers(*this, "mod"),
+ m_tx_handler(*this)
+{
+}
+
+//-------------------------------------------------
+// device_start - device-specific startup
+//-------------------------------------------------
+
+void digilog320_kbd_hle_device::device_start()
+{
+ // resolve callbacks
+ m_tx_handler.resolve_safe();
+}
+
+//-------------------------------------------------
+// device_reset - device-specific reset
+//-------------------------------------------------
+
+void digilog320_kbd_hle_device::device_reset()
+{
+ clear_fifo();
+
+ receive_register_reset();
+ transmit_register_reset();
+
+ set_data_frame(1, 8, PARITY_EVEN, STOP_BITS_1);
+ set_rcv_rate(1200);
+ set_tra_rate(1200);
+
+ reset_key_state();
+ start_processing(attotime::from_hz(1200));
+ typematic_stop();
+}
+
+//-------------------------------------------------
+// tra_callback - send bit to host
+//-------------------------------------------------
+
+void digilog320_kbd_hle_device::tra_callback()
+{
+ m_tx_handler(transmit_register_get_data_bit());
+}
+
+//-------------------------------------------------
+// received_byte - handle received byte
+//-------------------------------------------------
+
+void digilog320_kbd_hle_device::received_byte(uint8_t byte)
+{
+ // might be send only
+ logerror("Received from host: %02x\n", byte);
+}
+
+//-------------------------------------------------
+// key_make - handle a key being pressed
+//-------------------------------------------------
+
+void digilog320_kbd_hle_device::key_make(uint8_t row, uint8_t column)
+{
+ uint8_t code = translate(row, column);
+
+ if (code != 0x00)
+ {
+ transmit_byte(code);
+ typematic_start(row, column, attotime::from_msec(750), attotime::from_msec(50));
+ }
+}
+
+//-------------------------------------------------
+// key_break - handle a key being released
+//-------------------------------------------------
+
+void digilog320_kbd_hle_device::key_break(uint8_t row, uint8_t column)
+{
+ if (typematic_is(row, column))
+ typematic_stop();
+}
+
+//-------------------------------------------------
+// key_repeat - handle a key being repeated
+//-------------------------------------------------
+
+void digilog320_kbd_hle_device::key_repeat(u8 row, u8 column)
+{
+ uint8_t code = translate(row, column);
+
+ if (code != 0x00)
+ transmit_byte(code);
+}
+
+//-------------------------------------------------
+// rx_w - receive bit from host
+//-------------------------------------------------
+
+void digilog320_kbd_hle_device::rx_w(int state)
+{
+ device_buffered_serial_interface::rx_w(state);
+}
+
+//-------------------------------------------------
+// translate - row and column to key code
+//-------------------------------------------------
+
+uint8_t digilog320_kbd_hle_device::translate(uint8_t row, uint8_t column)
+{
+ uint8_t const modifiers(m_modifiers->read());
+
+ bool const ctrl(modifiers & 0x01);
+ bool const shift(bool(modifiers & 0x02) || (bool(modifiers & 0x04)));
+ bool const ctrl_shift(ctrl && shift);
+
+ unsigned const map(ctrl_shift? 3 : ctrl ? 2 : shift ? 1 : 0);
+
+ return TRANSLATION_TABLE[map][row][column];
+}
diff --git a/src/mame/machine/digilog320_kbd.h b/src/mame/machine/digilog320_kbd.h
new file mode 100644
index 00000000000..d65ddf15df5
--- /dev/null
+++ b/src/mame/machine/digilog320_kbd.h
@@ -0,0 +1,64 @@
+// license: BSD-3-Clause
+// copyright-holders: Dirk Best
+/***************************************************************************
+
+ Digilog 320 Keyboard (HLE)
+
+***************************************************************************/
+
+#ifndef MAME_MACHINE_DIGILOG320_KBD_H
+#define MAME_MACHINE_DIGILOG320_KBD_H
+
+#pragma once
+
+#include "machine/keyboard.h"
+#include "diserial.h"
+
+
+//**************************************************************************
+// TYPE DEFINITIONS
+//**************************************************************************
+
+// ======================> digilog320_kbd_hle_device
+
+class digilog320_kbd_hle_device : public device_t,
+ public device_buffered_serial_interface<16>,
+ protected device_matrix_keyboard_interface<5>
+{
+public:
+ // construction/destruction
+ digilog320_kbd_hle_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock = 0);
+
+ // callbacks
+ auto tx_handler() { return m_tx_handler.bind(); }
+
+ // from host
+ void rx_w(int state);
+
+protected:
+ // device_t overrides
+ virtual ioport_constructor device_input_ports() const override;
+ virtual void device_start() override;
+ virtual void device_reset() override;
+
+ // device_buffered_serial_interface overrides
+ virtual void tra_callback() override;
+ virtual void received_byte(uint8_t byte) override;
+
+ // device_matrix_keyboard_interface overrides
+ virtual void key_make(uint8_t row, uint8_t column) override;
+ virtual void key_break(uint8_t row, uint8_t column) override;
+ virtual void key_repeat(uint8_t row, uint8_t column) override;
+
+private:
+ required_ioport m_modifiers;
+
+ uint8_t translate(uint8_t row, uint8_t column);
+
+ devcb_write_line m_tx_handler;
+};
+
+// device type definition
+DECLARE_DEVICE_TYPE(DIGILOG320_KBD_HLE, digilog320_kbd_hle_device)
+
+#endif // MAME_MACHINE_DIGILOG320_KBD_H
diff --git a/src/mame/machine/dmac_0266.cpp b/src/mame/machine/dmac_0266.cpp
index e3343baa8e0..8b873924cfa 100644
--- a/src/mame/machine/dmac_0266.cpp
+++ b/src/mame/machine/dmac_0266.cpp
@@ -124,7 +124,7 @@ void dmac_0266_device::control_w(u32 data)
soft_reset();
}
-void dmac_0266_device::dma_check(void *ptr, s32 param)
+void dmac_0266_device::dma_check(s32 param)
{
// check req active
if (!m_req_state)
diff --git a/src/mame/machine/dmac_0266.h b/src/mame/machine/dmac_0266.h
index 83150106d5d..fec9ddbccef 100644
--- a/src/mame/machine/dmac_0266.h
+++ b/src/mame/machine/dmac_0266.h
@@ -40,7 +40,7 @@ protected:
// dma logic
void soft_reset();
- void dma_check(void *ptr, s32 param);
+ void dma_check(s32 param);
private:
required_address_space m_bus;
diff --git a/src/mame/machine/dmac_0448.cpp b/src/mame/machine/dmac_0448.cpp
index 578c09fafd8..95c64e9f530 100644
--- a/src/mame/machine/dmac_0448.cpp
+++ b/src/mame/machine/dmac_0448.cpp
@@ -79,7 +79,7 @@ void dmac_0448_device::set_irq_line(int number, int state)
m_irq_check->adjust(attotime::zero);
}
-void dmac_0448_device::irq_check(void *ptr, s32 param)
+void dmac_0448_device::irq_check(s32 param)
{
bool const out_int_stat = bool(m_gstat & 0x55);
@@ -115,7 +115,7 @@ void dmac_0448_device::cctl_w(u8 data)
m_dma_check->adjust(attotime::zero);
}
-void dmac_0448_device::dma_check(void *ptr, s32 param)
+void dmac_0448_device::dma_check(s32 param)
{
bool active = false;
diff --git a/src/mame/machine/dmac_0448.h b/src/mame/machine/dmac_0448.h
index e85e8b1ecff..de755b03dbe 100644
--- a/src/mame/machine/dmac_0448.h
+++ b/src/mame/machine/dmac_0448.h
@@ -53,8 +53,8 @@ protected:
void cmap_w(offs_t offset, u16 data, u16 mem_mask) { COMBINE_DATA(&m_channel[m_gsel].cmap[m_channel[m_gsel].ctag]); }
void gsel_w(u8 data) { m_gsel = data; }
- void irq_check(void *ptr = nullptr, s32 param = 0);
- void dma_check(void *ptr = nullptr, s32 param = 0);
+ void irq_check(s32 param = 0);
+ void dma_check(s32 param = 0);
required_address_space m_bus;
diff --git a/src/mame/machine/e22_kbd.cpp b/src/mame/machine/e22_kbd.cpp
index 61cfafd9b94..52525fe5227 100644
--- a/src/mame/machine/e22_kbd.cpp
+++ b/src/mame/machine/e22_kbd.cpp
@@ -248,10 +248,15 @@ void e22_kbd_hle_device::received_byte(uint8_t byte)
switch (byte)
{
case 0x02: break; // keyclick on
- case 0x06: transmit_byte(0x01); break; // can't be 0x00
- case 0x07: transmit_byte(0x02); break; // can't be 0x00
+ case 0x06: transmit_byte(0x01); break; // keyboard model, can't be 0
+ case 0x07: transmit_byte(0x02); break; // read 3 times, can't be 0 in total
case 0x09: break; // bell?
case 0x12: break; // keyclick off
+ case 0xf8: logerror("Key repeat disabled\n"); break;
+ case 0xf9: logerror("Key repeat 6 cps\n"); break;
+ case 0xfa: logerror("Key repeat 12 cps\n"); break;
+ case 0xfb: logerror("Key repeat 24 cps\n"); break;
+ case 0xfc: logerror("Key repeat 30 cps\n"); break;
}
}
diff --git a/src/mame/machine/egret.cpp b/src/mame/machine/egret.cpp
index e9276c05352..f62c8484821 100644
--- a/src/mame/machine/egret.cpp
+++ b/src/mame/machine/egret.cpp
@@ -399,7 +399,7 @@ void egret_device::device_start()
}
#endif
- m_timer = timer_alloc(0, nullptr);
+ m_timer = timer_alloc(0);
save_item(NAME(ddrs[0]));
save_item(NAME(ddrs[1]));
save_item(NAME(ddrs[2]));
@@ -468,7 +468,7 @@ void egret_device::device_reset()
last_adb = 0;
}
-void egret_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
+void egret_device::device_timer(emu_timer &timer, device_timer_id id, int param)
{
onesec |= 0x40;
diff --git a/src/mame/machine/egret.h b/src/mame/machine/egret.h
index b4ea5882b0d..d58d2e5d00f 100644
--- a/src/mame/machine/egret.h
+++ b/src/mame/machine/egret.h
@@ -98,7 +98,7 @@ protected:
required_device<cpu_device> m_maincpu;
- virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override;
+ virtual void device_timer(emu_timer &timer, device_timer_id id, int param) override;
private:
uint8_t ddrs[3];
diff --git a/src/mame/machine/elan_eu3a05commonsys.cpp b/src/mame/machine/elan_eu3a05commonsys.cpp
index 38713b8789c..638bbe6e459 100644
--- a/src/mame/machine/elan_eu3a05commonsys.cpp
+++ b/src/mame/machine/elan_eu3a05commonsys.cpp
@@ -228,7 +228,7 @@ void elan_eu3a05commonsys_device::map(address_map &map)
}
-void elan_eu3a05commonsys_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
+void elan_eu3a05commonsys_device::device_timer(emu_timer &timer, device_timer_id id, int param)
{
switch (id)
{
diff --git a/src/mame/machine/elan_eu3a05commonsys.h b/src/mame/machine/elan_eu3a05commonsys.h
index 07016ad1207..647e250bfcd 100644
--- a/src/mame/machine/elan_eu3a05commonsys.h
+++ b/src/mame/machine/elan_eu3a05commonsys.h
@@ -31,7 +31,7 @@ protected:
// device-level overrides
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_timer(emu_timer &timer, device_timer_id id, int param) override;
required_device<m6502_device> m_cpu;
required_device<address_map_bank_device> m_bank;
diff --git a/src/mame/machine/electron.cpp b/src/mame/machine/electron.cpp
index 464f4f7a0da..6b4aa221100 100644
--- a/src/mame/machine/electron.cpp
+++ b/src/mame/machine/electron.cpp
@@ -1,11 +1,8 @@
// license:BSD-3-Clause
// copyright-holders:Wilbert Pol, Nigel Barnes
/******************************************************************************
- Acorn Electron driver
-
- MESS Driver By:
- Wilbert Pol
+ Acorn Electron driver
******************************************************************************/
@@ -28,18 +25,18 @@ void electron_state::waitforramsync()
}
-void electron_state::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
+void electron_state::device_timer(emu_timer &timer, device_timer_id id, int param)
{
switch (id)
{
case TIMER_TAPE_HANDLER:
- electron_tape_timer_handler(ptr, param);
+ electron_tape_timer_handler(param);
break;
case TIMER_SETUP_BEEP:
- setup_beep(ptr, param);
+ setup_beep(param);
break;
case TIMER_SCANLINE_INTERRUPT:
- electron_scanline_interrupt(ptr, param);
+ electron_scanline_interrupt(param);
break;
default:
throw emu_fatalerror("Unknown id in electron_state::device_timer");
diff --git a/src/mame/machine/esqpanel.cpp b/src/mame/machine/esqpanel.cpp
index c860d4a4d0d..338c7be5712 100644
--- a/src/mame/machine/esqpanel.cpp
+++ b/src/mame/machine/esqpanel.cpp
@@ -4,6 +4,7 @@
Ensoniq panel/display device
*/
#include "emu.h"
+#include "http.h"
#include "esqpanel.h"
#define ESQPANEL_EXTERNAL_TIMER_ID 47000
@@ -483,7 +484,7 @@ void esqpanel_device::device_stop()
m_external_panel_server = nullptr;
}
-void esqpanel_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
+void esqpanel_device::device_timer(emu_timer &timer, device_timer_id id, int param)
{
if (ESQPANEL_EXTERNAL_TIMER_ID == id)
{
diff --git a/src/mame/machine/esqpanel.h b/src/mame/machine/esqpanel.h
index 77ffc6f9daf..f902266afee 100644
--- a/src/mame/machine/esqpanel.h
+++ b/src/mame/machine/esqpanel.h
@@ -40,7 +40,7 @@ protected:
virtual void device_start() override;
virtual void device_reset() override;
virtual void device_stop() override;
- virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override;
+ virtual void device_timer(emu_timer &timer, device_timer_id id, int param) override;
// serial overrides
virtual void rcv_complete() override; // Rx completed receiving byte
diff --git a/src/mame/machine/esqvfd.cpp b/src/mame/machine/esqvfd.cpp
index b8c2ad44f31..5e2797cbd6e 100644
--- a/src/mame/machine/esqvfd.cpp
+++ b/src/mame/machine/esqvfd.cpp
@@ -140,7 +140,7 @@ void esqvfd_device::device_reset()
memset(m_dirty, 1, sizeof(m_attrs));
}
-void esqvfd_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
+void esqvfd_device::device_timer(emu_timer &timer, device_timer_id id, int param)
{
}
diff --git a/src/mame/machine/esqvfd.h b/src/mame/machine/esqvfd.h
index 3b0e008ed5e..fdaf87f6665 100644
--- a/src/mame/machine/esqvfd.h
+++ b/src/mame/machine/esqvfd.h
@@ -48,7 +48,7 @@ protected:
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_timer(emu_timer &timer, device_timer_id id, int param) override;
output_helper::ptr m_vfds;
int m_cursx, m_cursy;
diff --git a/src/mame/machine/f5220_kbd.cpp b/src/mame/machine/f5220_kbd.cpp
new file mode 100644
index 00000000000..91c590e402d
--- /dev/null
+++ b/src/mame/machine/f5220_kbd.cpp
@@ -0,0 +1,300 @@
+// license: BSD-3-Clause
+// copyright-holders: Dirk Best
+/***************************************************************************
+
+ Falco F5220 Keyboard
+
+***************************************************************************/
+
+#include "emu.h"
+#include "f5220_kbd.h"
+#include "machine/keyboard.ipp"
+
+
+DEFINE_DEVICE_TYPE(F5220_KBD, f5220_kbd_device, "f5220_kbd", "F5220 Keyboard")
+
+
+//**************************************************************************
+// DEVICE DEFINITIONS
+//**************************************************************************
+
+//-------------------------------------------------
+// input_ports - device-specific input ports
+//-------------------------------------------------
+
+// Missing: Local Print, Break, Function
+
+static INPUT_PORTS_START( keyboard )
+ PORT_START("row_0")
+ PORT_BIT(0x0001, IP_ACTIVE_HIGH, IPT_KEYBOARD) /* 00 */ PORT_NAME("00")
+ PORT_BIT(0x0002, IP_ACTIVE_HIGH, IPT_KEYBOARD) /* 01 */ PORT_CODE(KEYCODE_SCRLOCK) PORT_NAME("Hold Session")
+ PORT_BIT(0x0004, IP_ACTIVE_HIGH, IPT_KEYBOARD) /* 02 */ PORT_NAME("02") // print?
+ PORT_BIT(0x0008, IP_ACTIVE_HIGH, IPT_KEYBOARD) /* 03 */ PORT_NAME("03") // print?
+ PORT_BIT(0x0010, IP_ACTIVE_HIGH, IPT_KEYBOARD) /* 04 */ PORT_CODE(KEYCODE_ASTERISK) PORT_NAME("SetUp")
+ PORT_BIT(0x0020, IP_ACTIVE_HIGH, IPT_KEYBOARD) /* 05 */ PORT_NAME("05")
+ PORT_BIT(0x0040, IP_ACTIVE_HIGH, IPT_KEYBOARD) /* 06 */ PORT_NAME("06")
+ PORT_BIT(0x0080, IP_ACTIVE_HIGH, IPT_KEYBOARD) /* 07 */ PORT_NAME("Switch Session")
+ PORT_BIT(0x0100, IP_ACTIVE_HIGH, IPT_KEYBOARD) /* 08 */ PORT_CODE(KEYCODE_F6) PORT_CHAR(UCHAR_MAMEKEY(F6))
+ PORT_BIT(0x0200, IP_ACTIVE_HIGH, IPT_KEYBOARD) /* 09 */ PORT_CODE(KEYCODE_F7) PORT_CHAR(UCHAR_MAMEKEY(F7))
+ PORT_BIT(0x0400, IP_ACTIVE_HIGH, IPT_KEYBOARD) /* 0a */ PORT_CODE(KEYCODE_F8) PORT_CHAR(UCHAR_MAMEKEY(F8))
+ PORT_BIT(0x0800, IP_ACTIVE_HIGH, IPT_KEYBOARD) /* 0b */ PORT_CODE(KEYCODE_F9) PORT_CHAR(UCHAR_MAMEKEY(F9))
+ PORT_BIT(0x1000, IP_ACTIVE_HIGH, IPT_KEYBOARD) /* 0c */ PORT_CODE(KEYCODE_F10) PORT_CHAR(UCHAR_MAMEKEY(F10))
+ PORT_BIT(0x2000, IP_ACTIVE_HIGH, IPT_KEYBOARD) /* 0d */ PORT_CODE(KEYCODE_F11) PORT_CHAR(UCHAR_MAMEKEY(F11))
+ PORT_BIT(0x4000, IP_ACTIVE_HIGH, IPT_KEYBOARD) /* 0e */ PORT_CODE(KEYCODE_F12) PORT_CHAR(UCHAR_MAMEKEY(F12))
+ PORT_BIT(0x8000, IP_ACTIVE_HIGH, IPT_KEYBOARD) /* 0f */ PORT_CODE(KEYCODE_F13) PORT_CHAR(UCHAR_MAMEKEY(F13))
+
+ PORT_START("row_1")
+ PORT_BIT(0x0001, IP_ACTIVE_HIGH, IPT_KEYBOARD) /* 10 */ PORT_CODE(KEYCODE_F14) PORT_CHAR(UCHAR_MAMEKEY(F14))
+ PORT_BIT(0x0002, IP_ACTIVE_HIGH, IPT_KEYBOARD) /* 11 */ PORT_CODE(KEYCODE_F15) PORT_NAME("Help")
+ PORT_BIT(0x0004, IP_ACTIVE_HIGH, IPT_KEYBOARD) /* 12 */ PORT_CODE(KEYCODE_END) PORT_NAME("Prev Scrn")
+ PORT_BIT(0x0008, IP_ACTIVE_HIGH, IPT_KEYBOARD) /* 13 */ PORT_CODE(KEYCODE_F16) PORT_NAME("Do")
+ PORT_BIT(0x0010, IP_ACTIVE_HIGH, IPT_KEYBOARD) /* 14 */ PORT_NAME("14")
+ PORT_BIT(0x0020, IP_ACTIVE_HIGH, IPT_KEYBOARD) /* 15 */ PORT_CODE(KEYCODE_F17) PORT_CHAR(UCHAR_MAMEKEY(F17))
+ PORT_BIT(0x0040, IP_ACTIVE_HIGH, IPT_KEYBOARD) /* 16 */ PORT_CODE(KEYCODE_F18) PORT_CHAR(UCHAR_MAMEKEY(F18))
+ PORT_BIT(0x0080, IP_ACTIVE_HIGH, IPT_KEYBOARD) /* 17 */ PORT_CODE(KEYCODE_F19) PORT_CHAR(UCHAR_MAMEKEY(F19))
+ PORT_BIT(0x0100, IP_ACTIVE_HIGH, IPT_KEYBOARD) /* 18 */ PORT_CODE(KEYCODE_F20) PORT_CHAR(UCHAR_MAMEKEY(F20))
+ PORT_BIT(0x0200, IP_ACTIVE_HIGH, IPT_KEYBOARD) /* 19 */ PORT_CODE(KEYCODE_PGDN) PORT_NAME("Next Scrn")
+ PORT_BIT(0x0400, IP_ACTIVE_HIGH, IPT_KEYBOARD) /* 1a */ PORT_CODE(KEYCODE_TILDE) PORT_CHAR('`') PORT_CHAR('~')
+ PORT_BIT(0x0800, IP_ACTIVE_HIGH, IPT_KEYBOARD) /* 1b */ PORT_CODE(KEYCODE_1) PORT_CHAR('1') PORT_CHAR('!')
+ PORT_BIT(0x1000, IP_ACTIVE_HIGH, IPT_KEYBOARD) /* 1c */ PORT_CODE(KEYCODE_2) PORT_CHAR('2') PORT_CHAR('@')
+ PORT_BIT(0x2000, IP_ACTIVE_HIGH, IPT_KEYBOARD) /* 1d */ PORT_CODE(KEYCODE_3) PORT_CHAR('3') PORT_CHAR('#')
+ PORT_BIT(0x4000, IP_ACTIVE_HIGH, IPT_KEYBOARD) /* 1e */ PORT_CODE(KEYCODE_4) PORT_CHAR('4') PORT_CHAR('$')
+ PORT_BIT(0x8000, IP_ACTIVE_HIGH, IPT_KEYBOARD) /* 1f */ PORT_CODE(KEYCODE_5) PORT_CHAR('5') PORT_CHAR('%')
+
+ PORT_START("row_2")
+ PORT_BIT(0x0001, IP_ACTIVE_HIGH, IPT_KEYBOARD) /* 20 */ PORT_CODE(KEYCODE_6) PORT_CHAR('6') PORT_CHAR('^')
+ PORT_BIT(0x0002, IP_ACTIVE_HIGH, IPT_KEYBOARD) /* 21 */ PORT_CODE(KEYCODE_7) PORT_CHAR('7') PORT_CHAR('&')
+ PORT_BIT(0x0004, IP_ACTIVE_HIGH, IPT_KEYBOARD) /* 22 */ PORT_CODE(KEYCODE_8) PORT_CHAR('8') PORT_CHAR('*')
+ PORT_BIT(0x0008, IP_ACTIVE_HIGH, IPT_KEYBOARD) /* 23 */ PORT_CODE(KEYCODE_9) PORT_CHAR('9') PORT_CHAR('(')
+ PORT_BIT(0x0010, IP_ACTIVE_HIGH, IPT_KEYBOARD) /* 24 */ PORT_CODE(KEYCODE_0) PORT_CHAR('0') PORT_CHAR(')')
+ PORT_BIT(0x0020, IP_ACTIVE_HIGH, IPT_KEYBOARD) /* 25 */ PORT_CODE(KEYCODE_MINUS) PORT_CHAR('-') PORT_CHAR('_')
+ PORT_BIT(0x0040, IP_ACTIVE_HIGH, IPT_KEYBOARD) /* 26 */ PORT_CODE(KEYCODE_EQUALS) PORT_CHAR('=') PORT_CHAR('+')
+ PORT_BIT(0x0080, IP_ACTIVE_HIGH, IPT_KEYBOARD) /* 27 */ PORT_CODE(KEYCODE_RCONTROL) PORT_CHAR(UCHAR_MAMEKEY(DEL))
+ PORT_BIT(0x0100, IP_ACTIVE_HIGH, IPT_KEYBOARD) /* 28 */ PORT_CODE(KEYCODE_INSERT) PORT_NAME("Find")
+ PORT_BIT(0x0200, IP_ACTIVE_HIGH, IPT_KEYBOARD) /* 29 */ PORT_CODE(KEYCODE_HOME) PORT_NAME("Insert Here")
+ PORT_BIT(0x0400, IP_ACTIVE_HIGH, IPT_KEYBOARD) /* 2a */ PORT_CODE(KEYCODE_PGUP) PORT_NAME("Remove")
+ PORT_BIT(0x0800, IP_ACTIVE_HIGH, IPT_KEYBOARD) /* 2b */ PORT_CODE(KEYCODE_F2) PORT_CHAR(UCHAR_MAMEKEY(F2)) PORT_NAME("PF2")
+ PORT_BIT(0x1000, IP_ACTIVE_HIGH, IPT_KEYBOARD) /* 2c */ PORT_CODE(KEYCODE_F3) PORT_CHAR(UCHAR_MAMEKEY(F3)) PORT_NAME("PF3")
+ PORT_BIT(0x2000, IP_ACTIVE_HIGH, IPT_KEYBOARD) /* 2d */ PORT_CODE(KEYCODE_F4) PORT_CHAR(UCHAR_MAMEKEY(F4)) PORT_NAME("PF4")
+ PORT_BIT(0x4000, IP_ACTIVE_HIGH, IPT_KEYBOARD) /* 2e */ PORT_CODE(KEYCODE_ESC) PORT_CHAR(27)
+ PORT_BIT(0x8000, IP_ACTIVE_HIGH, IPT_KEYBOARD) /* 2f */ PORT_CODE(KEYCODE_TAB) PORT_CHAR(9)
+
+ PORT_START("row_3")
+ PORT_BIT(0x0001, IP_ACTIVE_HIGH, IPT_KEYBOARD) /* 30 */ PORT_CODE(KEYCODE_Q) PORT_CHAR('q') PORT_CHAR('Q')
+ PORT_BIT(0x0002, IP_ACTIVE_HIGH, IPT_KEYBOARD) /* 31 */ PORT_CODE(KEYCODE_W) PORT_CHAR('w') PORT_CHAR('W')
+ PORT_BIT(0x0004, IP_ACTIVE_HIGH, IPT_KEYBOARD) /* 32 */ PORT_CODE(KEYCODE_E) PORT_CHAR('e') PORT_CHAR('E')
+ PORT_BIT(0x0008, IP_ACTIVE_HIGH, IPT_KEYBOARD) /* 33 */ PORT_CODE(KEYCODE_R) PORT_CHAR('r') PORT_CHAR('R')
+ PORT_BIT(0x0010, IP_ACTIVE_HIGH, IPT_KEYBOARD) /* 34 */ PORT_CODE(KEYCODE_T) PORT_CHAR('t') PORT_CHAR('T')
+ PORT_BIT(0x0020, IP_ACTIVE_HIGH, IPT_KEYBOARD) /* 35 */ PORT_CODE(KEYCODE_Y) PORT_CHAR('y') PORT_CHAR('Y')
+ PORT_BIT(0x0040, IP_ACTIVE_HIGH, IPT_KEYBOARD) /* 36 */ PORT_CODE(KEYCODE_U) PORT_CHAR('u') PORT_CHAR('U')
+ PORT_BIT(0x0080, IP_ACTIVE_HIGH, IPT_KEYBOARD) /* 37 */ PORT_CODE(KEYCODE_I) PORT_CHAR('i') PORT_CHAR('I')
+ PORT_BIT(0x0100, IP_ACTIVE_HIGH, IPT_KEYBOARD) /* 38 */ PORT_CODE(KEYCODE_O) PORT_CHAR('o') PORT_CHAR('O')
+ PORT_BIT(0x0200, IP_ACTIVE_HIGH, IPT_KEYBOARD) /* 39 */ PORT_CODE(KEYCODE_P) PORT_CHAR('p') PORT_CHAR('P')
+ PORT_BIT(0x0400, IP_ACTIVE_HIGH, IPT_KEYBOARD) /* 3a */ PORT_CODE(KEYCODE_OPENBRACE) PORT_CHAR('[') PORT_CHAR('{')
+ PORT_BIT(0x0800, IP_ACTIVE_HIGH, IPT_KEYBOARD) /* 3b */ PORT_CODE(KEYCODE_CLOSEBRACE) PORT_CHAR(']') PORT_CHAR('}')
+ PORT_BIT(0x1000, IP_ACTIVE_HIGH, IPT_KEYBOARD) /* 3c */ PORT_CODE(KEYCODE_ENTER) PORT_CHAR(13)
+ PORT_BIT(0x2000, IP_ACTIVE_HIGH, IPT_KEYBOARD) /* 3d */ PORT_NAME("3d")
+ PORT_BIT(0x4000, IP_ACTIVE_HIGH, IPT_KEYBOARD) /* 3e */ PORT_CODE(KEYCODE_DEL) PORT_NAME("Select")
+ PORT_BIT(0x8000, IP_ACTIVE_HIGH, IPT_KEYBOARD) /* 3f */ PORT_NAME("3f")
+
+ PORT_START("row_4")
+ PORT_BIT(0x0001, IP_ACTIVE_HIGH, IPT_KEYBOARD) /* 40 */ PORT_CODE(KEYCODE_8_PAD) PORT_CHAR(UCHAR_MAMEKEY(8_PAD))
+ PORT_BIT(0x0002, IP_ACTIVE_HIGH, IPT_KEYBOARD) /* 41 */ PORT_CODE(KEYCODE_9_PAD) PORT_CHAR(UCHAR_MAMEKEY(9_PAD))
+ PORT_BIT(0x0004, IP_ACTIVE_HIGH, IPT_KEYBOARD) /* 42 */ PORT_CODE(KEYCODE_MINUS_PAD) PORT_CHAR(UCHAR_MAMEKEY(MINUS_PAD))
+ PORT_BIT(0x0008, IP_ACTIVE_HIGH, IPT_KEYBOARD) /* 43 */ PORT_CODE(KEYCODE_LCONTROL) PORT_CHAR(UCHAR_SHIFT_2)
+ PORT_BIT(0x0010, IP_ACTIVE_HIGH, IPT_KEYBOARD) /* 44 */ PORT_CODE(KEYCODE_CAPSLOCK) PORT_CHAR(UCHAR_MAMEKEY(CAPSLOCK))
+ PORT_BIT(0x0020, IP_ACTIVE_HIGH, IPT_KEYBOARD) /* 45 */ PORT_CODE(KEYCODE_A) PORT_CHAR('a') PORT_CHAR('A')
+ PORT_BIT(0x0040, IP_ACTIVE_HIGH, IPT_KEYBOARD) /* 46 */ PORT_CODE(KEYCODE_S) PORT_CHAR('s') PORT_CHAR('S')
+ PORT_BIT(0x0080, IP_ACTIVE_HIGH, IPT_KEYBOARD) /* 47 */ PORT_CODE(KEYCODE_D) PORT_CHAR('d') PORT_CHAR('D')
+ PORT_BIT(0x0100, IP_ACTIVE_HIGH, IPT_KEYBOARD) /* 48 */ PORT_CODE(KEYCODE_F) PORT_CHAR('f') PORT_CHAR('F')
+ PORT_BIT(0x0200, IP_ACTIVE_HIGH, IPT_KEYBOARD) /* 49 */ PORT_CODE(KEYCODE_G) PORT_CHAR('g') PORT_CHAR('G')
+ PORT_BIT(0x0400, IP_ACTIVE_HIGH, IPT_KEYBOARD) /* 4a */ PORT_CODE(KEYCODE_H) PORT_CHAR('h') PORT_CHAR('H')
+ PORT_BIT(0x0800, IP_ACTIVE_HIGH, IPT_KEYBOARD) /* 4b */ PORT_CODE(KEYCODE_J) PORT_CHAR('j') PORT_CHAR('J')
+ PORT_BIT(0x1000, IP_ACTIVE_HIGH, IPT_KEYBOARD) /* 4c */ PORT_CODE(KEYCODE_K) PORT_CHAR('k') PORT_CHAR('K')
+ PORT_BIT(0x2000, IP_ACTIVE_HIGH, IPT_KEYBOARD) /* 4d */ PORT_CODE(KEYCODE_L) PORT_CHAR('l') PORT_CHAR('L')
+ PORT_BIT(0x4000, IP_ACTIVE_HIGH, IPT_KEYBOARD) /* 4e */ PORT_CODE(KEYCODE_COLON) PORT_CHAR(';') PORT_CHAR(':')
+ PORT_BIT(0x8000, IP_ACTIVE_HIGH, IPT_KEYBOARD) /* 4f */ PORT_CODE(KEYCODE_QUOTE) PORT_CHAR('\'') PORT_CHAR('"')
+
+ PORT_START("row_5")
+ PORT_BIT(0x0001, IP_ACTIVE_HIGH, IPT_KEYBOARD) /* 50 */ PORT_CODE(KEYCODE_BACKSLASH) PORT_CHAR('\\') PORT_CHAR('|')
+ PORT_BIT(0x0002, IP_ACTIVE_HIGH, IPT_KEYBOARD) /* 51 */ PORT_NAME("51")
+ PORT_BIT(0x0004, IP_ACTIVE_HIGH, IPT_KEYBOARD) /* 52 */ PORT_NAME("52")
+ PORT_BIT(0x0008, IP_ACTIVE_HIGH, IPT_KEYBOARD) /* 53 */ PORT_CODE(KEYCODE_UP) PORT_CHAR(UCHAR_MAMEKEY(UP)) PORT_NAME("\xe2\x86\x91")
+ PORT_BIT(0x0010, IP_ACTIVE_HIGH, IPT_KEYBOARD) /* 54 */ PORT_NAME("54")
+ PORT_BIT(0x0020, IP_ACTIVE_HIGH, IPT_KEYBOARD) /* 55 */ PORT_CODE(KEYCODE_5_PAD) PORT_CHAR(UCHAR_MAMEKEY(5_PAD))
+ PORT_BIT(0x0040, IP_ACTIVE_HIGH, IPT_KEYBOARD) /* 56 */ PORT_CODE(KEYCODE_6_PAD) PORT_CHAR(UCHAR_MAMEKEY(6_PAD))
+ PORT_BIT(0x0080, IP_ACTIVE_HIGH, IPT_KEYBOARD) /* 57 */ PORT_CODE(KEYCODE_COMMA_PAD) PORT_CHAR(UCHAR_MAMEKEY(COMMA_PAD))
+ PORT_BIT(0x0100, IP_ACTIVE_HIGH, IPT_KEYBOARD) /* 58 */ PORT_NAME("58")
+ PORT_BIT(0x0200, IP_ACTIVE_HIGH, IPT_KEYBOARD) /* 59 */ PORT_CODE(KEYCODE_LSHIFT) PORT_CHAR(UCHAR_SHIFT_1) PORT_NAME("Left Shift")
+ PORT_BIT(0x0400, IP_ACTIVE_HIGH, IPT_KEYBOARD) /* 5a */ PORT_CODE(KEYCODE_BACKSLASH2) PORT_CHAR('<') PORT_CHAR('>')
+ PORT_BIT(0x0800, IP_ACTIVE_HIGH, IPT_KEYBOARD) /* 5b */ PORT_CODE(KEYCODE_Z) PORT_CHAR('z') PORT_CHAR('Z')
+ PORT_BIT(0x1000, IP_ACTIVE_HIGH, IPT_KEYBOARD) /* 5c */ PORT_CODE(KEYCODE_X) PORT_CHAR('x') PORT_CHAR('X')
+ PORT_BIT(0x2000, IP_ACTIVE_HIGH, IPT_KEYBOARD) /* 5d */ PORT_CODE(KEYCODE_C) PORT_CHAR('c') PORT_CHAR('C')
+ PORT_BIT(0x4000, IP_ACTIVE_HIGH, IPT_KEYBOARD) /* 5e */ PORT_CODE(KEYCODE_V) PORT_CHAR('v') PORT_CHAR('V')
+ PORT_BIT(0x8000, IP_ACTIVE_HIGH, IPT_KEYBOARD) /* 5f */ PORT_CODE(KEYCODE_B) PORT_CHAR('b') PORT_CHAR('B')
+
+ PORT_START("row_6")
+ PORT_BIT(0x0001, IP_ACTIVE_HIGH, IPT_KEYBOARD) /* 60 */ PORT_CODE(KEYCODE_N) PORT_CHAR('n') PORT_CHAR('N')
+ PORT_BIT(0x0002, IP_ACTIVE_HIGH, IPT_KEYBOARD) /* 61 */ PORT_CODE(KEYCODE_M) PORT_CHAR('m') PORT_CHAR('M')
+ PORT_BIT(0x0004, IP_ACTIVE_HIGH, IPT_KEYBOARD) /* 62 */ PORT_CODE(KEYCODE_COMMA) PORT_CHAR(',')
+ PORT_BIT(0x0008, IP_ACTIVE_HIGH, IPT_KEYBOARD) /* 63 */ PORT_CODE(KEYCODE_STOP) PORT_CHAR('.')
+ PORT_BIT(0x0010, IP_ACTIVE_HIGH, IPT_KEYBOARD) /* 64 */ PORT_CODE(KEYCODE_SLASH) PORT_CHAR('/') PORT_CHAR('?')
+ PORT_BIT(0x0020, IP_ACTIVE_HIGH, IPT_KEYBOARD) /* 65 */ PORT_CODE(KEYCODE_RSHIFT) PORT_CHAR(UCHAR_SHIFT_1) PORT_NAME("Right Shift")
+ PORT_BIT(0x0040, IP_ACTIVE_HIGH, IPT_KEYBOARD) /* 66 */ PORT_NAME("66")
+ PORT_BIT(0x0080, IP_ACTIVE_HIGH, IPT_KEYBOARD) /* 67 */ PORT_CODE(KEYCODE_DOWN) PORT_CHAR(UCHAR_MAMEKEY(DOWN)) PORT_NAME("\xe2\x86\x93")
+ PORT_BIT(0x0100, IP_ACTIVE_HIGH, IPT_KEYBOARD) /* 68 */ PORT_CODE(KEYCODE_RIGHT) PORT_CHAR(UCHAR_MAMEKEY(RIGHT)) PORT_NAME("\xe2\x86\x92")
+ PORT_BIT(0x0200, IP_ACTIVE_HIGH, IPT_KEYBOARD) /* 69 */ PORT_CODE(KEYCODE_2_PAD) PORT_CHAR(UCHAR_MAMEKEY(2_PAD))
+ PORT_BIT(0x0400, IP_ACTIVE_HIGH, IPT_KEYBOARD) /* 6a */ PORT_CODE(KEYCODE_3_PAD) PORT_CHAR(UCHAR_MAMEKEY(3_PAD))
+ PORT_BIT(0x0800, IP_ACTIVE_HIGH, IPT_KEYBOARD) /* 6b */ PORT_CODE(KEYCODE_ENTER_PAD) PORT_CHAR(UCHAR_MAMEKEY(ENTER_PAD))
+ PORT_BIT(0x1000, IP_ACTIVE_HIGH, IPT_KEYBOARD) /* 6c */ PORT_NAME("6c")
+ PORT_BIT(0x2000, IP_ACTIVE_HIGH, IPT_KEYBOARD) /* 6d */ PORT_NAME("6d")
+ PORT_BIT(0x4000, IP_ACTIVE_HIGH, IPT_KEYBOARD) /* 6e */ PORT_NAME("6e Function?")
+ PORT_BIT(0x8000, IP_ACTIVE_HIGH, IPT_KEYBOARD) /* 6f */ PORT_CODE(KEYCODE_SPACE) PORT_CHAR(' ')
+
+ PORT_START("row_7")
+ PORT_BIT(0x0001, IP_ACTIVE_HIGH, IPT_KEYBOARD) /* 70 */ PORT_CODE(KEYCODE_BACKSPACE) PORT_CHAR(8)
+ PORT_BIT(0x0002, IP_ACTIVE_HIGH, IPT_KEYBOARD) /* 71 */ PORT_CODE(KEYCODE_RCONTROL) PORT_NAME("Line Feed Home")
+ PORT_BIT(0x0004, IP_ACTIVE_HIGH, IPT_KEYBOARD) /* 72 */ PORT_CODE(KEYCODE_0_PAD) PORT_CHAR(UCHAR_MAMEKEY(0_PAD))
+ PORT_BIT(0x0008, IP_ACTIVE_HIGH, IPT_KEYBOARD) /* 73 */ PORT_NAME("73")
+ PORT_BIT(0x0010, IP_ACTIVE_HIGH, IPT_KEYBOARD) /* 74 */ PORT_CODE(KEYCODE_LEFT) PORT_CHAR(UCHAR_MAMEKEY(LEFT)) PORT_NAME("\xe2\x86\x90")
+ PORT_BIT(0x0020, IP_ACTIVE_HIGH, IPT_KEYBOARD) /* 75 */ PORT_CODE(KEYCODE_1_PAD) PORT_CHAR(UCHAR_MAMEKEY(1_PAD))
+ PORT_BIT(0x0040, IP_ACTIVE_HIGH, IPT_KEYBOARD) /* 76 */ PORT_CODE(KEYCODE_4_PAD) PORT_CHAR(UCHAR_MAMEKEY(4_PAD))
+ PORT_BIT(0x0080, IP_ACTIVE_HIGH, IPT_KEYBOARD) /* 77 */ PORT_CODE(KEYCODE_7_PAD) PORT_CHAR(UCHAR_MAMEKEY(7_PAD))
+ PORT_BIT(0x0100, IP_ACTIVE_HIGH, IPT_KEYBOARD) /* 78 */ PORT_CODE(KEYCODE_F1) PORT_CHAR(UCHAR_MAMEKEY(F1)) PORT_NAME("PF1")
+ PORT_BIT(0x0200, IP_ACTIVE_HIGH, IPT_KEYBOARD) /* 79 */ PORT_NAME("79")
+ PORT_BIT(0x0400, IP_ACTIVE_HIGH, IPT_KEYBOARD) /* 7a */ PORT_NAME("7a")
+ PORT_BIT(0x0800, IP_ACTIVE_HIGH, IPT_KEYBOARD) /* 7b */ PORT_NAME("7b")
+ PORT_BIT(0x1000, IP_ACTIVE_HIGH, IPT_KEYBOARD) /* 7c */ PORT_NAME("7c")
+ PORT_BIT(0x2000, IP_ACTIVE_HIGH, IPT_KEYBOARD) /* 7d */ PORT_NAME("7d")
+ PORT_BIT(0x4000, IP_ACTIVE_HIGH, IPT_KEYBOARD) /* 7e */ PORT_NAME("7e")
+ PORT_BIT(0x8000, IP_ACTIVE_HIGH, IPT_KEYBOARD) /* 7f */ PORT_NAME("7f")
+INPUT_PORTS_END
+
+ioport_constructor f5220_kbd_device::device_input_ports() const
+{
+ return INPUT_PORTS_NAME( keyboard );
+}
+
+
+//**************************************************************************
+// LIVE DEVICE
+//**************************************************************************
+
+//-------------------------------------------------
+// f5220_kbd_device - constructor
+//-------------------------------------------------
+
+f5220_kbd_device::f5220_kbd_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
+ : device_t(mconfig, F5220_KBD, tag, owner, clock),
+ device_matrix_keyboard_interface(mconfig, *this, "row_0", "row_1", "row_2", "row_3", "row_4", "row_5", "row_6", "row_7"),
+ m_int_handler(*this),
+ m_data(0x00)
+{
+}
+
+
+//-------------------------------------------------
+// device_start - device-specific startup
+//-------------------------------------------------
+
+void f5220_kbd_device::device_start()
+{
+ // resolve callbacks
+ m_int_handler.resolve_safe();
+
+ // timer for initial keyboard data
+ m_reset_timer = timer_alloc(0);
+ m_reset_timer->adjust(attotime::from_msec(1000));
+
+ // register for state saving
+ save_item(NAME(m_data));
+}
+
+//-------------------------------------------------
+// device_start - device-specific reset
+//-------------------------------------------------
+
+void f5220_kbd_device::device_reset()
+{
+ reset_key_state();
+ start_processing(attotime::from_hz(9600));
+ typematic_stop();
+
+ m_data = 0x00;
+}
+
+//-------------------------------------------------
+// device_timer - device-specific timer
+//-------------------------------------------------
+
+void f5220_kbd_device::device_timer(emu_timer &timer, device_timer_id id, int param)
+{
+ logerror("Reset\n");
+
+ m_int_handler(1);
+ m_int_handler(0);
+}
+
+//-------------------------------------------------
+// read - external read from keyboard
+//-------------------------------------------------
+
+uint8_t f5220_kbd_device::read()
+{
+ return m_data;
+}
+
+//-------------------------------------------------
+// key_make - handle a key being pressed
+//-------------------------------------------------
+
+void f5220_kbd_device::key_make(uint8_t row, uint8_t column)
+{
+ uint8_t code = translate(row, column);
+ send_key(code);
+ typematic_start(row, column, attotime::from_msec(750), attotime::from_msec(50));
+}
+
+//-------------------------------------------------
+// key_break - handle a key being released
+//-------------------------------------------------
+
+void f5220_kbd_device::key_break(uint8_t row, uint8_t column)
+{
+ if (typematic_is(row, column))
+ typematic_stop();
+
+ uint8_t code = translate(row, column);
+
+ send_key(0x80 | code);
+}
+
+//-------------------------------------------------
+// key_repeat - handle a key being repeated
+//-------------------------------------------------
+
+void f5220_kbd_device::key_repeat(u8 row, u8 column)
+{
+ uint8_t code = translate(row, column);
+ send_key(code);
+}
+
+//-------------------------------------------------
+// translate - row and column to key code
+//-------------------------------------------------
+
+uint8_t f5220_kbd_device::translate(uint8_t row, uint8_t column)
+{
+ return row * 16 + column;
+}
+
+//-------------------------------------------------
+// send_key - send key code to host
+//-------------------------------------------------
+
+void f5220_kbd_device::send_key(uint8_t code)
+{
+ m_data = code;
+ m_int_handler(1);
+ m_int_handler(0);
+}
diff --git a/src/mame/machine/f5220_kbd.h b/src/mame/machine/f5220_kbd.h
new file mode 100644
index 00000000000..2d3d22d1ef2
--- /dev/null
+++ b/src/mame/machine/f5220_kbd.h
@@ -0,0 +1,60 @@
+// license: BSD-3-Clause
+// copyright-holders: Dirk Best
+/***************************************************************************
+
+ Falco F5220 Keyboard
+
+***************************************************************************/
+
+#ifndef MAME_MACHINE_F5220_KBD_H
+#define MAME_MACHINE_F5220_KBD_H
+
+#pragma once
+
+#include "machine/keyboard.h"
+
+
+//**************************************************************************
+// TYPE DEFINITIONS
+//**************************************************************************
+
+// ======================> f5220_kbd_device
+
+class f5220_kbd_device : public device_t, protected device_matrix_keyboard_interface<8>
+{
+public:
+ // construction/destruction
+ f5220_kbd_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock = 0);
+
+ // callbacks
+ auto int_handler() { return m_int_handler.bind(); }
+
+ uint8_t read();
+
+protected:
+ // device-level overrides
+ virtual ioport_constructor device_input_ports() const override;
+ virtual void device_start() override;
+ virtual void device_reset() override;
+ virtual void device_timer(emu_timer &timer, device_timer_id id, int param) override;
+
+ // device_matrix_keyboard_interface overrides
+ virtual void key_make(uint8_t row, uint8_t column) override;
+ virtual void key_break(uint8_t row, uint8_t column) override;
+ virtual void key_repeat(uint8_t row, uint8_t column) override;
+
+private:
+ devcb_write_line m_int_handler;
+
+ uint8_t translate(uint8_t row, uint8_t column);
+ void send_key(uint8_t code);
+
+ emu_timer *m_reset_timer;
+
+ uint8_t m_data;
+};
+
+// device type definition
+DECLARE_DEVICE_TYPE(F5220_KBD, f5220_kbd_device)
+
+#endif // MAME_MACHINE_F5220_KBD_H
diff --git a/src/mame/machine/fidel_clockdiv.cpp b/src/mame/machine/fidel_clockdiv.cpp
index 13ec96c2ee1..0f0d9ebc85f 100644
--- a/src/mame/machine/fidel_clockdiv.cpp
+++ b/src/mame/machine/fidel_clockdiv.cpp
@@ -23,7 +23,7 @@ TODO:
void fidel_clockdiv_state::machine_start()
{
// dummy timer for cpu divider
- m_div_timer = machine().scheduler().timer_alloc(timer_expired_delegate(), this);
+ m_div_timer = machine().scheduler().timer_alloc(timer_expired_delegate());
}
diff --git a/src/mame/machine/fm_scsi.cpp b/src/mame/machine/fm_scsi.cpp
index f84738e3ec0..c370c232964 100644
--- a/src/mame/machine/fm_scsi.cpp
+++ b/src/mame/machine/fm_scsi.cpp
@@ -117,7 +117,7 @@ int fmscsi_device::get_scsi_cmd_len(uint8_t cbyte)
//return 6;
}
-void fmscsi_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
+void fmscsi_device::device_timer(emu_timer &timer, device_timer_id id, int param)
{
switch(id)
{
diff --git a/src/mame/machine/fm_scsi.h b/src/mame/machine/fm_scsi.h
index c9b9e55d831..5b3b06866f0 100644
--- a/src/mame/machine/fm_scsi.h
+++ b/src/mame/machine/fm_scsi.h
@@ -42,7 +42,7 @@ protected:
// device-level overrides (none are required, but these are common)
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_timer(emu_timer &timer, device_timer_id id, int param) override;
private:
// internal device state goes here
diff --git a/src/mame/machine/fmt_icmem.cpp b/src/mame/machine/fmt_icmem.cpp
index fc005570b9f..b38c3057eb7 100644
--- a/src/mame/machine/fmt_icmem.cpp
+++ b/src/mame/machine/fmt_icmem.cpp
@@ -22,7 +22,7 @@ DEFINE_DEVICE_TYPE(FMT_ICMEM, fmt_icmem_device, "fmt_icmem", "FM Towns IC Memory
fmt_icmem_device::fmt_icmem_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
: device_t(mconfig, FMT_ICMEM, tag, owner, clock),
- device_image_interface(mconfig, *this),
+ device_memcard_image_interface(mconfig, *this),
m_writeprotect(*this,"icmem"),
m_change(false),
m_attr_select(false),
diff --git a/src/mame/machine/fmt_icmem.h b/src/mame/machine/fmt_icmem.h
index 50e9abc8ed6..9f45ebcfe18 100644
--- a/src/mame/machine/fmt_icmem.h
+++ b/src/mame/machine/fmt_icmem.h
@@ -13,23 +13,19 @@
#pragma once
+#include "imagedev/memcard.h"
+
/***************************************************************************
FUNCTION PROTOTYPES
***************************************************************************/
-class fmt_icmem_device : public device_t, public device_image_interface
+class fmt_icmem_device : public device_t, public device_memcard_image_interface
{
public:
// construction/destruction
fmt_icmem_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
- virtual iodevice_t image_type() const noexcept override { return IO_MEMCARD; }
-
- virtual bool is_readable() const noexcept override { return true; }
- virtual bool is_writeable() const noexcept override { return true; }
- virtual bool is_creatable() const noexcept override { return true; }
- virtual bool must_be_loaded() const noexcept override { return false; }
virtual bool is_reset_on_load() const noexcept override { return false; }
virtual const char *file_extensions() const noexcept override { return "icm"; }
diff --git a/src/mame/machine/gaelco3d.h b/src/mame/machine/gaelco3d.h
index e4b1432b27c..05a09a8ee0a 100644
--- a/src/mame/machine/gaelco3d.h
+++ b/src/mame/machine/gaelco3d.h
@@ -10,6 +10,7 @@
#pragma once
+#include <mutex>
/***************************************************************************
DEVICE INTERFACE TYPE
diff --git a/src/mame/machine/gaelcrpt.cpp b/src/mame/machine/gaelcrpt.cpp
index ba7abfa66e6..786baf00c6f 100644
--- a/src/mame/machine/gaelcrpt.cpp
+++ b/src/mame/machine/gaelcrpt.cpp
@@ -6,12 +6,27 @@ Gaelco video RAM encryption
Thanks to GAELCO SA for information on the algorithm.
+TODO: the device must be able to know a 32-bit write was from the same
+ opcode WITHOUT looking at the host program counter.
+
*/
#include "emu.h"
-#include "includes/gaelcrpt.h"
+#include "gaelcrpt.h"
+
+DEFINE_DEVICE_TYPE(GAELCO_VRAM_ENCRYPTION, gaelco_vram_encryption_device, "gaelco_vram_crypt", "Gaelco VRAM Encryption")
+
+
+gaelco_vram_encryption_device::gaelco_vram_encryption_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
+ : device_t(mconfig, GAELCO_VRAM_ENCRYPTION, tag, owner, clock),
+ m_param1(0),
+ m_param2(0)
+{
+}
+
+
-static int decrypt(int const param1, int const param2, int const enc_prev_word, int const dec_prev_word, int const enc_word)
+int gaelco_vram_encryption_device::decrypt(int const enc_prev_word, int const dec_prev_word, int const enc_word)
{
int const swap = (BIT(dec_prev_word, 8) << 1) | BIT(dec_prev_word, 7);
int const type = (BIT(dec_prev_word,12) << 1) | BIT(dec_prev_word, 2);
@@ -26,7 +41,7 @@ static int decrypt(int const param1, int const param2, int const enc_prev_word,
case 3: res = bitswap<16>(enc_word, 3, 8, 1,13,14, 4,15, 0,10, 2, 7,12, 6,11, 9, 5); break;
}
- res ^= param2;
+ res ^= m_param2;
switch (type)
{
@@ -67,11 +82,11 @@ static int decrypt(int const param1, int const param2, int const enc_prev_word,
break;
}
- k ^= param1;
+ k ^= m_param1;
res = (res & 0xffc0) | ((res + k) & 0x003f);
- res ^= param1;
+ res ^= m_param1;
switch (type)
{
@@ -109,46 +124,57 @@ static int decrypt(int const param1, int const param2, int const enc_prev_word,
break;
}
- k ^= param1;
+ k ^= m_param1;
res = (res & 0x003f) |
((res + (k << 6)) & 0x07c0) |
((res + (k << 11)) & 0xf800);
- res ^= (param1 << 6) | (param1 << 11);
+ res ^= (m_param1 << 6) | (m_param1 << 11);
return bitswap<16>(res, 2,6,0,11,14,12,7,10,5,4,8,3,9,1,13,15);
}
-uint16_t gaelco_decrypt(cpu_device &cpu, int offset, int data, int param1, int param2)
+uint16_t gaelco_vram_encryption_device::gaelco_decrypt(cpu_device &cpu, int offset, int data)
{
- static int lastpc, lastoffset, lastencword, lastdecword;
-
int thispc = cpu.pc();
// int savedata = data;
/* check if 2nd half of 32 bit */
- if(lastpc == thispc && offset == lastoffset + 1)
+ if(m_lastpc == thispc && offset == m_lastoffset + 1)
{
- lastpc = 0;
- data = decrypt(param1, param2, lastencword, lastdecword, data);
+ m_lastpc = 0;
+ data = decrypt(m_lastencword, m_lastdecword, data);
}
else
{
/* code as 1st word */
- lastpc = thispc;
- lastoffset = offset;
- lastencword = data;
+ m_lastpc = thispc;
+ m_lastoffset = offset;
+ m_lastencword = data;
/* high word returned */
- data = decrypt(param1, param2, 0, 0, data);
+ data = decrypt(0, 0, data);
- lastdecword = data;
+ m_lastdecword = data;
-// logerror("%s : data1 = %4x > %4x @ %8x\n",machine().describe_context(),savedata,data,lastoffset);
+// logerror("%s : data1 = %4x > %4x @ %8x\n",machine().describe_context(),savedata,data,m_lastoffset);
}
return data;
}
+
+void gaelco_vram_encryption_device::device_start()
+{
+ save_item(NAME(m_lastpc));
+ save_item(NAME(m_lastoffset));
+ save_item(NAME(m_lastencword));
+ save_item(NAME(m_lastdecword));
+}
+
+void gaelco_vram_encryption_device::device_reset()
+{
+ m_lastpc = m_lastoffset = m_lastencword = m_lastdecword = -1;
+}
diff --git a/src/mame/machine/gaelcrpt.h b/src/mame/machine/gaelcrpt.h
new file mode 100644
index 00000000000..2ce4367132a
--- /dev/null
+++ b/src/mame/machine/gaelcrpt.h
@@ -0,0 +1,36 @@
+// license:BSD-3-Clause
+// copyright-holders:Manuel Abadia
+
+#ifndef MAME_MACHINE_GAELCRPT_H
+#define MAME_MACHINE_GAELCRPT_H
+
+#pragma once
+
+DECLARE_DEVICE_TYPE(GAELCO_VRAM_ENCRYPTION, gaelco_vram_encryption_device)
+
+
+class gaelco_vram_encryption_device : public device_t
+{
+public:
+ // construction/destruction
+ gaelco_vram_encryption_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock = 0);
+
+ void set_params(uint8_t param1, uint16_t param2) { m_param1 = param1; m_param2 = param2; }
+
+ uint16_t gaelco_decrypt(cpu_device &cpu, int offset, int data);
+
+protected:
+ virtual void device_start() override;
+ virtual void device_reset() override;
+
+private:
+ int decrypt(int const enc_prev_word, int const dec_prev_word, int const enc_word);
+
+ int32_t m_lastpc, m_lastoffset, m_lastencword, m_lastdecword;
+
+ // config
+ uint8_t m_param1;
+ uint16_t m_param2;
+};
+
+#endif // MAME_MACHINE_GAELCRPT_H
diff --git a/src/mame/machine/gb.cpp b/src/mame/machine/gb.cpp
index 4c742715d0c..c40618ff43d 100644
--- a/src/mame/machine/gb.cpp
+++ b/src/mame/machine/gb.cpp
@@ -114,7 +114,6 @@ void gb_state::save_gb_base()
save_item(NAME(m_triggering_irq));
save_item(NAME(m_reloading));
save_item(NAME(m_sio_count));
- save_item(NAME(m_bios_disable));
if (m_cartslot)
m_cartslot->save_ram();
}
@@ -195,31 +194,25 @@ void gb_state::machine_reset()
{
gb_init();
- // Enable BIOS ROM
- m_bios_disable = false;
+ m_cart_low.select(BIOS_ENABLED | (m_cartslot ? CART_PRESENT : NO_CART));
+ m_cart_high.select(m_cartslot ? CART_PRESENT : NO_CART);
}
MACHINE_RESET_MEMBER(gb_state,gbc)
{
- gb_init();
+ gb_state::machine_reset();
gb_init_regs();
- /* Enable BIOS rom */
- m_bios_disable = false;
-
for (auto & elem : m_gbc_rammap)
memset(elem, 0, 0x1000);
}
MACHINE_RESET_MEMBER(gb_state,sgb)
{
- gb_init();
+ gb_state::machine_reset();
gb_init_regs();
-
- /* Enable BIOS rom */
- m_bios_disable = false;
}
@@ -310,7 +303,7 @@ void gb_state::gb_io2_w(offs_t offset, uint8_t data)
if (offset == 0x10)
{
/* disable BIOS ROM */
- m_bios_disable = true;
+ m_cart_low.select(BIOS_DISABLED | (m_cartslot ? CART_PRESENT : NO_CART));
}
else
m_ppu->video_w(offset, data);
@@ -625,7 +618,7 @@ void gb_state::gbc_io2_w(offs_t offset, uint8_t data)
m_maincpu->set_speed(data);
return;
case 0x10: /* BFF - Bios disable */
- m_bios_disable = true;
+ m_cart_low.select(BIOS_DISABLED | (m_cartslot ? CART_PRESENT : NO_CART));
return;
case 0x16: /* RP - Infrared port */
break;
@@ -670,10 +663,10 @@ void megaduck_state::machine_start()
void megaduck_state::machine_reset()
{
- // We may have to add some more stuff here, if not then it can be merged back into gb
- gb_state::machine_reset();
+ gb_init();
- m_bios_disable = true;
+ m_cart_low.select((m_cartslot ? CART_PRESENT : NO_CART));
+ m_cart_high.select(m_cartslot ? CART_PRESENT : NO_CART);
}
/*
diff --git a/src/mame/machine/gdrom.cpp b/src/mame/machine/gdrom.cpp
index 1958692a442..257bf116d00 100644
--- a/src/mame/machine/gdrom.cpp
+++ b/src/mame/machine/gdrom.cpp
@@ -9,6 +9,18 @@
#include "emu.h"
#include "gdrom.h"
+#define LOG_WARN (1U << 1)
+#define LOG_CMD (1U << 2)
+#define LOG_XFER (1U << 3)
+
+#define VERBOSE (LOG_WARN | LOG_CMD)
+//#define LOG_OUTPUT_STREAM std::cout
+#include "logmacro.h"
+
+#define LOGWARN(...) LOGMASKED(LOG_WARN, __VA_ARGS__)
+#define LOGCMD(...) LOGMASKED(LOG_CMD, __VA_ARGS__)
+#define LOGXFER(...) LOGMASKED(LOG_XFER, __VA_ARGS__)
+
#define GDROM_BUSY_STATE 0x00
#define GDROM_PAUSE_STATE 0x01
#define GDROM_STANDBY_STATE 0x02
@@ -162,29 +174,29 @@ void gdrom_device::ExecCommand()
case 0x11: // REQ_MODE
m_phase = SCSI_PHASE_DATAIN;
m_status_code = SCSI_STATUS_CODE_GOOD;
- printf("REQ_MODE %02x %02x %02x %02x %02x %02x\n",
+ LOGCMD("REQ_MODE %02x %02x %02x %02x %02x %02x\n",
command[0], command[1],
command[2], command[3],
- command[4], command[5]);
+ command[4], command[5]
+ );
// if (SCSILengthFromUINT8( &command[ 4 ] ) < 32) return -1;
transferOffset = command[2];
m_transfer_length = SCSILengthFromUINT8( &command[ 4 ] );
break;
case 0x12: // SET_MODE
- logerror("GDROM: SET_MODE\n");
m_phase = SCSI_PHASE_DATAOUT;
m_status_code = SCSI_STATUS_CODE_GOOD;
//transferOffset = command[2];
m_transfer_length = SCSILengthFromUINT8( &command[ 4 ] );
- printf("SET_MODE %02x %02x\n",command[2],command[4]);
+ LOGCMD("SET_MODE %02x %02x\n", command[2], command[4]);
break;
case 0x30: // CD_READ
if (command[1] & 1)
{
- fatalerror("GDROM: MSF mode used for CD_READ, unsupported\n");
m_transfer_length = 0;
+ throw emu_fatalerror("GDROM: MSF mode used for CD_READ, unsupported");
}
else
{
@@ -196,15 +208,19 @@ void gdrom_device::ExecCommand()
if (read_type != 2) // mode 1
{
- fatalerror("GDROM: Unhandled read_type %d\n", read_type);
+ throw emu_fatalerror("GDROM: Unhandled read_type %d", read_type);
}
if (data_select != 2) // just sector data
{
- fatalerror("GDROM: Unhandled data_select %d\n", data_select);
+ throw emu_fatalerror("GDROM: Unhandled data_select %d", data_select);
}
- printf("GDROM: CD_READ at LBA %x for %d blocks (%d bytes, read type %d, data select %d)\n", m_lba, m_blocks, m_blocks * m_sector_bytes, read_type, data_select);
+ LOGCMD("CD_READ %02x %02x\n", command[2], command[4]);
+ LOGCMD(" LBA %x for %d blocks (%d bytes, read type %d, data select %d)\n",
+ m_lba, m_blocks,
+ m_blocks * m_sector_bytes, read_type, data_select
+ );
if (m_num_subblocks > 1)
{
@@ -230,7 +246,8 @@ void gdrom_device::ExecCommand()
// READ TOC (GD-ROM ver.)
case 0x14:
{
- int start_trk = command[2];// ok?
+ // TODO: is this correct?
+ int start_trk = command[2];
int end_trk = cdrom_get_last_track(m_cdrom);
int length;
int allocation_length = SCSILengthFromUINT16( &command[ 3 ] );
@@ -286,7 +303,7 @@ void gdrom_device::ExecCommand()
}
else
{
- printf("command 0x40: unhandled subchannel request\n");
+ LOGWARN("command 0x40: unhandled subchannel request\n");
}
break;
@@ -308,22 +325,22 @@ void gdrom_device::ReadData( uint8_t *data, int dataLength )
switch ( command[0] )
{
case 0x11: // REQ_MODE
- printf("REQ_MODE: dataLength %d\n", dataLength);
+ LOGCMD("REQ_MODE dataLength %d\n", dataLength);
memcpy(data, &GDROM_Cmd11_Reply[transferOffset], (dataLength >= 32-transferOffset) ? 32-transferOffset : dataLength);
break;
case 0x30: // CD_READ
- logerror("GDROM: read %x dataLength, \n", dataLength);
+ LOGCMD("CD_READ read %x dataLength,\n", dataLength);
if ((m_cdrom) && (m_blocks))
{
while (dataLength > 0)
{
if (!cdrom_read_data(m_cdrom, m_lba, tmp_buffer, CD_TRACK_MODE1))
{
- logerror("GDROM: CD read error!\n");
+ LOGWARN("CD read error!\n");
}
- logerror("True LBA: %d, buffer half: %d\n", m_lba, m_cur_subblock * m_sector_bytes);
+ LOGXFER("True LBA: %d, buffer half: %d\n", m_lba, m_cur_subblock * m_sector_bytes);
memcpy(data, &tmp_buffer[m_cur_subblock * m_sector_bytes], m_sector_bytes);
@@ -350,77 +367,81 @@ void gdrom_device::ReadData( uint8_t *data, int dataLength )
our internal routines for tracks use "0" as track 1. That probably
should be fixed...
*/
- printf("GDROM: READ TOC, format = %d time=%d\n", command[2]&0xf,(command[1]>>1)&1);
+ LOGCMD("READ TOC format = %d time=%d\n",
+ command[2] & 0xf, (command[1] >> 1) & 1
+ );
switch (command[2] & 0x0f)
{
case 0: // normal
+ {
+ int start_trk;
+ int end_trk;
+ int len;
+ int in_len;
+ int dptr;
+ uint32_t tstart;
+
+ start_trk = command[2];
+ if( start_trk == 0 )
{
- int start_trk;
- int end_trk;
- int len;
- int in_len;
- int dptr;
- uint32_t tstart;
-
- start_trk = command[2];
- if( start_trk == 0 )
- {
- start_trk = 1;
- }
+ start_trk = 1;
+ }
+
+ end_trk = cdrom_get_last_track(m_cdrom);
+ len = (end_trk * 8) + 2;
- end_trk = cdrom_get_last_track(m_cdrom);
- len = (end_trk * 8) + 2;
+ // the returned TOC DATA LENGTH must be the full amount,
+ // regardless of how much we're able to pass back due to in_len
+ dptr = 0;
+ data[dptr++] = (len>>8) & 0xff;
+ data[dptr++] = (len & 0xff);
+ data[dptr++] = 1;
+ data[dptr++] = end_trk;
- // the returned TOC DATA LENGTH must be the full amount,
- // regardless of how much we're able to pass back due to in_len
- dptr = 0;
- data[dptr++] = (len>>8) & 0xff;
- data[dptr++] = (len & 0xff);
- data[dptr++] = 1;
- data[dptr++] = end_trk;
+ if( start_trk == 0xaa )
+ {
+ end_trk = 0xaa;
+ }
- if( start_trk == 0xaa )
+ in_len = command[3]<<8 | command[4];
+
+ for (i = start_trk; i <= end_trk; i++)
+ {
+ int cdrom_track = i;
+ if( cdrom_track != 0xaa )
{
- end_trk = 0xaa;
+ cdrom_track--;
}
- in_len = command[3]<<8 | command[4];
-
- for (i = start_trk; i <= end_trk; i++)
+ if( dptr >= in_len )
{
- int cdrom_track = i;
- if( cdrom_track != 0xaa )
- {
- cdrom_track--;
- }
-
- if( dptr >= in_len )
- {
- break;
- }
-
- data[dptr++] = 0;
- data[dptr++] = cdrom_get_adr_control(m_cdrom, cdrom_track);
- data[dptr++] = i;
- data[dptr++] = 0;
-
- tstart = cdrom_get_track_start(m_cdrom, cdrom_track);
- if ((command[1]&2)>>1)
- tstart = lba_to_msf(tstart);
- data[dptr++] = (tstart>>24) & 0xff;
- data[dptr++] = (tstart>>16) & 0xff;
- data[dptr++] = (tstart>>8) & 0xff;
- data[dptr++] = (tstart & 0xff);
+ break;
}
+
+ data[dptr++] = 0;
+ data[dptr++] = cdrom_get_adr_control(m_cdrom, cdrom_track);
+ data[dptr++] = i;
+ data[dptr++] = 0;
+
+ tstart = cdrom_get_track_start(m_cdrom, cdrom_track);
+ if ((command[1]&2)>>1)
+ tstart = lba_to_msf(tstart);
+ data[dptr++] = (tstart>>24) & 0xff;
+ data[dptr++] = (tstart>>16) & 0xff;
+ data[dptr++] = (tstart>>8) & 0xff;
+ data[dptr++] = (tstart & 0xff);
}
+
break;
+ }
default:
- logerror("GDROM: Unhandled READ TOC format %d\n", command[2]&0xf);
+ LOGWARN("Unhandled READ TOC format %d\n", command[2]&0xf);
break;
}
break;
case 0x71:
+ LOGCMD("SYS_REQ_SECU\n");
memcpy(data, &GDROM_Cmd71_Reply[0], sizeof(GDROM_Cmd71_Reply));
if (is_real_gdrom_disc)
data[10] = 0x1f; // needed by dimm board firmware
@@ -534,7 +555,8 @@ void gdrom_device::device_start()
void gdrom_device::process_buffer()
{
atapi_hle_device::process_buffer();
- m_sector_number = 0x80 | GDROM_PAUSE_STATE; /// HACK: find out when this should be updated
+ // HACK: find out when this should be updated
+ m_sector_number = 0x80 | GDROM_PAUSE_STATE;
}
void gdrom_device::signature()
diff --git a/src/mame/machine/hds200_kbd.cpp b/src/mame/machine/hds200_kbd.cpp
new file mode 100644
index 00000000000..2e9116d472a
--- /dev/null
+++ b/src/mame/machine/hds200_kbd.cpp
@@ -0,0 +1,407 @@
+// license: BSD-3-Clause
+// copyright-holders: Dirk Best
+/***************************************************************************
+
+ HDS200 Keyboard (HLE)
+
+ TODO:
+ - Add missing keycodes, verify existing
+ - LEDs
+ - Keyclick
+
+ Notes:
+ - No clear picture of the keyboard available, everything guessed
+
+***************************************************************************/
+
+#include "emu.h"
+#include "hds200_kbd.h"
+#include "machine/keyboard.ipp"
+#include "speaker.h"
+
+
+//**************************************************************************
+// DEVICE DEFINITIONS
+//**************************************************************************
+
+DEFINE_DEVICE_TYPE(HDS200_KBD_HLE, hds200_kbd_hle_device, "hds200_kbd_hle", "HDS200 Keyboard (HLE)")
+
+namespace {
+
+uint8_t const TRANSLATION_TABLE[4][7][22] =
+{
+ // unshift
+ { // main control number pad
+ { 0xaf, 0xb0, 0x00, 0xb1, 0xb2, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x8b, 0x00, 0x8c, 0x8d, 0x8e, 0x93, 0x94, 0x95, 0x96 }, // 0
+ { 0xb3, '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '-', '=', '`', 0xb5, 0x97, 0x98, 0x99, 0x8f, 0x90, 0x91, 0x92 }, // 1
+ { 0xb4, 'q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p', '[', ']', 0x0d, 0xb6, 0xac, 0xad, 0xae, 0xa5, 0xa6, 0xa7, 0x9c }, // 2
+ { 0x00, 'a', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l', ';', '\'', 0x00, 0x00, '\\', 0x00, 0xa8, 0x00, 0xa2, 0xa3, 0xa4, 0x9b }, // 3
+ { 0x00, 0x00, 'z', 'x', 'c', 'v', 'b', 'n', 'm', ',', '.', '/', 0x00, 0x00, 0xb7, 0xab, 0xa9, 0xaa, 0x9f, 0xa0, 0xa1, 0x9a }, // 4
+ { 0x00, ' ', 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xb9, 0x00, 0x00, 0x00, 0x9e, 0x00, 0x9d, 0x00 } // 5
+ },
+ // shift
+ { // main control number pad
+ { 0xef, 0xf0, 0x00, 0xf1, 0xf2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xcb, 0x00, 0xcc, 0xcd, 0xce, 0xd3, 0xd4, 0xd5, 0xd6 }, // 0
+ { 0xf3, '!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '_', '+', '~', 0xf5, 0xd7, 0xd8, 0xd9, 0xcf, 0xd0, 0xd1, 0xd2 }, // 1
+ { 0xf4, 'Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I', 'O', 'P', '{', '}', 0x0d, 0xf6, 0xec, 0xed, 0xee, 0xe5, 0xe6, 0xe7, 0xdc }, // 2
+ { 0x00, 'A', 'S', 'D', 'F', 'G', 'H', 'J', 'K', 'L', ':', '"', 0x00, 0x00, '|', 0x00, 0xe8, 0x00, 0xe2, 0xe3, 0xe4, 0xdb }, // 3
+ { 0x00, 0x00, 'Z', 'X', 'C', 'V', 'B', 'N', 'M', '<', '>', '?', 0x00, 0x00, 0xf7, 0xeb, 0xe9, 0xea, 0xdf, 0xe0, 0xe1, 0xda }, // 4
+ { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xde, 0x00, 0xdd, 0x00 } // 5
+ },
+ // unshift-control
+ { // main control number pad
+ { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, // 0
+ { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, // 1
+ { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, // 2
+ { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, // 3
+ { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, // 4
+ { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } // 5
+ },
+ // shift-control
+ { // main control number pad
+ { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, // 0
+ { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, // 1
+ { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, // 2
+ { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, // 3
+ { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, // 4
+ { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } // 5
+ }
+};
+
+} // anonymous namespace
+
+//-------------------------------------------------
+// input_ports - device-specific input ports
+//-------------------------------------------------
+
+static INPUT_PORTS_START( keyboard )
+ PORT_START("mod")
+ PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Ctrl") PORT_CODE(KEYCODE_LCONTROL)
+ PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Left Shift") PORT_CODE(KEYCODE_LSHIFT)
+ PORT_BIT(0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Right Shift") PORT_CODE(KEYCODE_RSHIFT)
+
+ PORT_START("row_0")
+ PORT_BIT(0x000001, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_SCRLOCK) PORT_NAME("No Scroll")
+ PORT_BIT(0x000002, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_INSERT) PORT_NAME("Setup Status")
+ PORT_BIT(0x000004, IP_ACTIVE_HIGH, IPT_UNUSED) // double width key
+ PORT_BIT(0x000008, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_END) PORT_NAME("Halt Reset")
+ PORT_BIT(0x000010, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_PAUSE) PORT_NAME("Break Long Break")
+ PORT_BIT(0x000020, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_F1) PORT_CHAR(UCHAR_MAMEKEY(F1))
+ PORT_BIT(0x000040, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_F2) PORT_CHAR(UCHAR_MAMEKEY(F2))
+ PORT_BIT(0x000080, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_F3) PORT_CHAR(UCHAR_MAMEKEY(F3))
+ PORT_BIT(0x000100, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_F4) PORT_CHAR(UCHAR_MAMEKEY(F4))
+ PORT_BIT(0x000200, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_F5) PORT_CHAR(UCHAR_MAMEKEY(F5))
+ PORT_BIT(0x000400, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_F6) PORT_CHAR(UCHAR_MAMEKEY(F6))
+ PORT_BIT(0x000800, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_F7) PORT_CHAR(UCHAR_MAMEKEY(F7))
+ PORT_BIT(0x001000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_F8) PORT_CHAR(UCHAR_MAMEKEY(F8))
+ PORT_BIT(0x002000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_F9) PORT_CHAR(UCHAR_MAMEKEY(F9))
+ PORT_BIT(0x004000, IP_ACTIVE_HIGH, IPT_UNUSED) // one key less in this row
+ PORT_BIT(0x008000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_F10) PORT_CHAR(UCHAR_MAMEKEY(F10))
+ PORT_BIT(0x010000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_F11) PORT_CHAR(UCHAR_MAMEKEY(F11))
+ PORT_BIT(0x020000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_F12) PORT_CHAR(UCHAR_MAMEKEY(F12))
+ PORT_BIT(0x040000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_F17) PORT_CHAR(UCHAR_MAMEKEY(F17))
+ PORT_BIT(0x080000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_F18) PORT_CHAR(UCHAR_MAMEKEY(F18))
+ PORT_BIT(0x100000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_F19) PORT_CHAR(UCHAR_MAMEKEY(F19))
+ PORT_BIT(0x200000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_F20) PORT_CHAR(UCHAR_MAMEKEY(F20))
+ PORT_BIT(0x400000, IP_ACTIVE_HIGH, IPT_UNUSED)
+ PORT_BIT(0x800000, IP_ACTIVE_HIGH, IPT_UNUSED)
+
+ PORT_START("row_1")
+ PORT_BIT(0x000001, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_ESC) PORT_CHAR(27) PORT_NAME("Esc CMD")
+ PORT_BIT(0x000002, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_1) PORT_CHAR('1') PORT_CHAR('!')
+ PORT_BIT(0x000004, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_2) PORT_CHAR('2') PORT_CHAR('@')
+ PORT_BIT(0x000008, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_3) PORT_CHAR('3') PORT_CHAR('#')
+ PORT_BIT(0x000010, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_4) PORT_CHAR('4') PORT_CHAR('$')
+ PORT_BIT(0x000020, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_5) PORT_CHAR('5') PORT_CHAR('%')
+ PORT_BIT(0x000040, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_6) PORT_CHAR('6') PORT_CHAR('^')
+ PORT_BIT(0x000080, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_7) PORT_CHAR('7') PORT_CHAR('&')
+ PORT_BIT(0x000100, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_8) PORT_CHAR('8') PORT_CHAR('*')
+ PORT_BIT(0x000200, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_9) PORT_CHAR('9') PORT_CHAR('(')
+ PORT_BIT(0x000400, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_0) PORT_CHAR('0') PORT_CHAR(')')
+ PORT_BIT(0x000800, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_MINUS) PORT_CHAR('-') PORT_CHAR('_')
+ PORT_BIT(0x001000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_EQUALS) PORT_CHAR('=') PORT_CHAR('+')
+ PORT_BIT(0x002000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_TILDE) PORT_CHAR('`') PORT_CHAR('~')
+ PORT_BIT(0x004000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_BACKSPACE) PORT_CHAR(8)
+ PORT_BIT(0x008000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("F21") // PORT_CODE(KEYCODE_F21) (not supported by core)
+ PORT_BIT(0x010000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("F22") // PORT_CODE(KEYCODE_F22) (not supported by core)
+ PORT_BIT(0x020000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("F23") // PORT_CODE(KEYCODE_F23) (not supported by core)
+ PORT_BIT(0x040000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_F13) PORT_CHAR(UCHAR_MAMEKEY(F13)) PORT_NAME("F13 (PF1)")
+ PORT_BIT(0x080000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_F14) PORT_CHAR(UCHAR_MAMEKEY(F14)) PORT_NAME("F14 (PF2)")
+ PORT_BIT(0x100000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_F15) PORT_CHAR(UCHAR_MAMEKEY(F15)) PORT_NAME("F15 (PF3)")
+ PORT_BIT(0x200000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_F16) PORT_CHAR(UCHAR_MAMEKEY(F16)) PORT_NAME("F16 (PF4)")
+ PORT_BIT(0x400000, IP_ACTIVE_HIGH, IPT_UNUSED)
+ PORT_BIT(0x800000, IP_ACTIVE_HIGH, IPT_UNUSED)
+
+ PORT_START("row_2")
+ PORT_BIT(0x000001, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_TAB) PORT_CHAR(9)
+ PORT_BIT(0x000002, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_Q) PORT_CHAR('q') PORT_CHAR('Q')
+ PORT_BIT(0x000004, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_W) PORT_CHAR('w') PORT_CHAR('W')
+ PORT_BIT(0x000008, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_E) PORT_CHAR('e') PORT_CHAR('E')
+ PORT_BIT(0x000010, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_R) PORT_CHAR('r') PORT_CHAR('R')
+ PORT_BIT(0x000020, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_T) PORT_CHAR('t') PORT_CHAR('T')
+ PORT_BIT(0x000040, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_Y) PORT_CHAR('y') PORT_CHAR('Y')
+ PORT_BIT(0x000080, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_U) PORT_CHAR('u') PORT_CHAR('U')
+ PORT_BIT(0x000100, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_I) PORT_CHAR('i') PORT_CHAR('I')
+ PORT_BIT(0x000200, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_O) PORT_CHAR('o') PORT_CHAR('O')
+ PORT_BIT(0x000400, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_P) PORT_CHAR('p') PORT_CHAR('P')
+ PORT_BIT(0x000800, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_OPENBRACE) PORT_CHAR('[') PORT_CHAR('{')
+ PORT_BIT(0x001000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_CLOSEBRACE) PORT_CHAR(']') PORT_CHAR('}')
+ PORT_BIT(0x002000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_ENTER) PORT_CHAR(13)
+ PORT_BIT(0x004000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_DEL) PORT_CHAR(UCHAR_MAMEKEY(DEL))
+ PORT_BIT(0x008000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_HOME) PORT_CHAR(UCHAR_MAMEKEY(HOME))
+ PORT_BIT(0x010000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_PGUP) PORT_NAME("Scroll Down Scroll Up")
+ PORT_BIT(0x020000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_PGDN) PORT_NAME("Page Down Page Up")
+ PORT_BIT(0x040000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_7_PAD) PORT_CHAR(UCHAR_MAMEKEY(7_PAD))
+ PORT_BIT(0x080000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_8_PAD) PORT_CHAR(UCHAR_MAMEKEY(8_PAD))
+ PORT_BIT(0x100000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_9_PAD) PORT_CHAR(UCHAR_MAMEKEY(9_PAD))
+ PORT_BIT(0x200000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_MINUS_PAD) PORT_CHAR(UCHAR_MAMEKEY(MINUS_PAD))
+ PORT_BIT(0x400000, IP_ACTIVE_HIGH, IPT_UNUSED)
+ PORT_BIT(0x800000, IP_ACTIVE_HIGH, IPT_UNUSED)
+
+ PORT_START("row_3")
+ PORT_BIT(0x000001, IP_ACTIVE_HIGH, IPT_UNUSED) // Ctrl (handled elsewhere)
+ PORT_BIT(0x000002, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_A) PORT_CHAR('a') PORT_CHAR('A')
+ PORT_BIT(0x000004, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_S) PORT_CHAR('s') PORT_CHAR('S')
+ PORT_BIT(0x000008, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_D) PORT_CHAR('d') PORT_CHAR('D')
+ PORT_BIT(0x000010, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_F) PORT_CHAR('f') PORT_CHAR('F')
+ PORT_BIT(0x000020, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_G) PORT_CHAR('g') PORT_CHAR('G')
+ PORT_BIT(0x000040, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_H) PORT_CHAR('h') PORT_CHAR('H')
+ PORT_BIT(0x000080, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_J) PORT_CHAR('j') PORT_CHAR('J')
+ PORT_BIT(0x000100, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_K) PORT_CHAR('k') PORT_CHAR('K')
+ PORT_BIT(0x000200, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_L) PORT_CHAR('l') PORT_CHAR('L')
+ PORT_BIT(0x000400, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_COLON) PORT_CHAR(';') PORT_CHAR(':')
+ PORT_BIT(0x000800, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_QUOTE) PORT_CHAR('\'') PORT_CHAR('"')
+ PORT_BIT(0x001000, IP_ACTIVE_HIGH, IPT_UNUSED)
+ PORT_BIT(0x002000, IP_ACTIVE_HIGH, IPT_UNUSED)
+ PORT_BIT(0x004000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_BACKSLASH) PORT_CHAR('\\') PORT_CHAR('|')
+ PORT_BIT(0x008000, IP_ACTIVE_HIGH, IPT_UNUSED)
+ PORT_BIT(0x010000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_UP) PORT_CHAR(UCHAR_MAMEKEY(UP))
+ PORT_BIT(0x020000, IP_ACTIVE_HIGH, IPT_UNUSED)
+ PORT_BIT(0x040000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_4_PAD) PORT_CHAR(UCHAR_MAMEKEY(4_PAD))
+ PORT_BIT(0x080000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_5_PAD) PORT_CHAR(UCHAR_MAMEKEY(5_PAD))
+ PORT_BIT(0x100000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_6_PAD) PORT_CHAR(UCHAR_MAMEKEY(6_PAD))
+ PORT_BIT(0x200000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_PLUS_PAD) PORT_CHAR(UCHAR_MAMEKEY(PLUS_PAD)) PORT_NAME("Keypad ,")
+ PORT_BIT(0x400000, IP_ACTIVE_HIGH, IPT_UNUSED)
+ PORT_BIT(0x800000, IP_ACTIVE_HIGH, IPT_UNUSED)
+
+ PORT_START("row_4")
+ PORT_BIT(0x000001, IP_ACTIVE_HIGH, IPT_UNUSED) // Left Shift (handled elsewhere)
+ PORT_BIT(0x000002, IP_ACTIVE_HIGH, IPT_UNUSED)
+ PORT_BIT(0x000004, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_Z) PORT_CHAR('z') PORT_CHAR('Z')
+ PORT_BIT(0x000008, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_X) PORT_CHAR('x') PORT_CHAR('X')
+ PORT_BIT(0x000010, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_C) PORT_CHAR('c') PORT_CHAR('C')
+ PORT_BIT(0x000020, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_V) PORT_CHAR('v') PORT_CHAR('V')
+ PORT_BIT(0x000040, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_B) PORT_CHAR('b') PORT_CHAR('B')
+ PORT_BIT(0x000080, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_N) PORT_CHAR('n') PORT_CHAR('N')
+ PORT_BIT(0x000100, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_M) PORT_CHAR('m') PORT_CHAR('M')
+ PORT_BIT(0x000200, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_COMMA) PORT_CHAR(',') PORT_CHAR('<')
+ PORT_BIT(0x000400, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_STOP) PORT_CHAR('.') PORT_CHAR('>')
+ PORT_BIT(0x000800, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_SLASH) PORT_CHAR('/') PORT_CHAR('?')
+ PORT_BIT(0x001000, IP_ACTIVE_HIGH, IPT_UNUSED) // Right Shift (handled elsewhere)
+ PORT_BIT(0x002000, IP_ACTIVE_HIGH, IPT_UNUSED)
+ PORT_BIT(0x004000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Line Feed")
+ PORT_BIT(0x008000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_LEFT) PORT_CHAR(UCHAR_MAMEKEY(LEFT))
+ PORT_BIT(0x010000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_DOWN) PORT_CHAR(UCHAR_MAMEKEY(DOWN))
+ PORT_BIT(0x020000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_RIGHT) PORT_CHAR(UCHAR_MAMEKEY(RIGHT))
+ PORT_BIT(0x040000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_1_PAD) PORT_CHAR(UCHAR_MAMEKEY(1_PAD))
+ PORT_BIT(0x080000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_2_PAD) PORT_CHAR(UCHAR_MAMEKEY(2_PAD))
+ PORT_BIT(0x100000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_3_PAD) PORT_CHAR(UCHAR_MAMEKEY(3_PAD))
+ PORT_BIT(0x200000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_ENTER_PAD) PORT_CHAR(UCHAR_MAMEKEY(ENTER_PAD))
+ PORT_BIT(0x400000, IP_ACTIVE_HIGH, IPT_UNUSED)
+ PORT_BIT(0x800000, IP_ACTIVE_HIGH, IPT_UNUSED)
+
+ PORT_START("row_5")
+ PORT_BIT(0x000001, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Comp Char")
+ PORT_BIT(0x000002, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_SPACE) PORT_CHAR(' ')
+ PORT_BIT(0x000004, IP_ACTIVE_HIGH, IPT_UNUSED)
+ PORT_BIT(0x000008, IP_ACTIVE_HIGH, IPT_UNUSED)
+ PORT_BIT(0x000010, IP_ACTIVE_HIGH, IPT_UNUSED)
+ PORT_BIT(0x000020, IP_ACTIVE_HIGH, IPT_UNUSED)
+ PORT_BIT(0x000040, IP_ACTIVE_HIGH, IPT_UNUSED)
+ PORT_BIT(0x000080, IP_ACTIVE_HIGH, IPT_UNUSED)
+ PORT_BIT(0x000100, IP_ACTIVE_HIGH, IPT_UNUSED)
+ PORT_BIT(0x000200, IP_ACTIVE_HIGH, IPT_UNUSED)
+ PORT_BIT(0x000400, IP_ACTIVE_HIGH, IPT_UNUSED)
+ PORT_BIT(0x000800, IP_ACTIVE_HIGH, IPT_UNUSED)
+ PORT_BIT(0x001000, IP_ACTIVE_HIGH, IPT_UNUSED)
+ PORT_BIT(0x002000, IP_ACTIVE_HIGH, IPT_UNUSED)
+ PORT_BIT(0x004000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_CAPSLOCK) PORT_NAME("Caps Lock")
+ PORT_BIT(0x008000, IP_ACTIVE_HIGH, IPT_UNUSED)
+ PORT_BIT(0x010000, IP_ACTIVE_HIGH, IPT_UNUSED)
+ PORT_BIT(0x020000, IP_ACTIVE_HIGH, IPT_UNUSED)
+ PORT_BIT(0x040000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_0_PAD) PORT_CHAR(UCHAR_MAMEKEY(0_PAD))
+ PORT_BIT(0x080000, IP_ACTIVE_HIGH, IPT_UNUSED)
+ PORT_BIT(0x100000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_DEL_PAD) PORT_CHAR(UCHAR_MAMEKEY(DEL_PAD))
+ PORT_BIT(0x200000, IP_ACTIVE_HIGH, IPT_UNUSED)
+ PORT_BIT(0x400000, IP_ACTIVE_HIGH, IPT_UNUSED)
+ PORT_BIT(0x800000, IP_ACTIVE_HIGH, IPT_UNUSED)
+INPUT_PORTS_END
+
+ioport_constructor hds200_kbd_hle_device::device_input_ports() const
+{
+ return INPUT_PORTS_NAME( keyboard );
+}
+
+void hds200_kbd_hle_device::device_add_mconfig(machine_config &config)
+{
+ SPEAKER(config, "mono").front_center();
+ BEEP(config, m_bell, 786).add_route(ALL_OUTPUTS, "mono", 0.5); // unknown frequency
+}
+
+
+//**************************************************************************
+// LIVE DEVICE
+//**************************************************************************
+
+//-------------------------------------------------
+// hds200_kbd_hle_device - constructor
+//-------------------------------------------------
+
+hds200_kbd_hle_device::hds200_kbd_hle_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
+ device_t(mconfig, HDS200_KBD_HLE, tag, owner, clock),
+ device_buffered_serial_interface(mconfig, *this),
+ device_matrix_keyboard_interface(mconfig, *this, "row_0", "row_1", "row_2", "row_3", "row_4", "row_5"),
+ m_bell(*this, "bell"),
+ m_modifiers(*this, "mod"),
+ m_tx_handler(*this)
+{
+}
+
+//-------------------------------------------------
+// device_start - device-specific startup
+//-------------------------------------------------
+
+void hds200_kbd_hle_device::device_start()
+{
+ // resolve callbacks
+ m_tx_handler.resolve_safe();
+}
+
+//-------------------------------------------------
+// device_reset - device-specific reset
+//-------------------------------------------------
+
+void hds200_kbd_hle_device::device_reset()
+{
+ clear_fifo();
+
+ receive_register_reset();
+ transmit_register_reset();
+
+ set_data_frame(1, 8, PARITY_EVEN, STOP_BITS_2);
+ set_rcv_rate(2400);
+ set_tra_rate(2400);
+
+ reset_key_state();
+ start_processing(attotime::from_hz(2400));
+ typematic_stop();
+}
+
+//-------------------------------------------------
+// tra_callback - send bit to host
+//-------------------------------------------------
+
+void hds200_kbd_hle_device::tra_callback()
+{
+ m_tx_handler(transmit_register_get_data_bit());
+}
+
+//-------------------------------------------------
+// received_byte - handle received byte
+//-------------------------------------------------
+
+void hds200_kbd_hle_device::received_byte(uint8_t byte)
+{
+ logerror("Received from host: %02x\n", byte);
+
+ switch (byte & 0xc0)
+ {
+ // state
+ case 0x00:
+
+ // 76------ 00
+ // --5----- caps lock led
+ // ---43--- unknown
+ // -----2-- insert mode
+ // ------1- led l1
+ // -------0 bell
+
+ m_bell->set_state(BIT(byte, 0));
+ break;
+
+ // volume
+ case 0xc0:
+
+ // 76------ 11
+ // --543--- bell volume
+ // -----210 keyclick volume
+
+ int bell_vol = (byte >> 3) & 0x07;
+ m_bell->set_output_gain(0, bell_vol / 7.0);
+ break;
+ }
+}
+
+//-------------------------------------------------
+// key_make - handle a key being pressed
+//-------------------------------------------------
+
+void hds200_kbd_hle_device::key_make(uint8_t row, uint8_t column)
+{
+ uint8_t code = translate(row, column);
+
+ // send the code
+ if (code != 0x00)
+ {
+ transmit_byte(code);
+ typematic_start(row, column, attotime::from_msec(750), attotime::from_msec(50));
+ }
+}
+
+//-------------------------------------------------
+// key_break - handle a key being released
+//-------------------------------------------------
+
+void hds200_kbd_hle_device::key_break(uint8_t row, uint8_t column)
+{
+ if (typematic_is(row, column))
+ typematic_stop();
+}
+
+//-------------------------------------------------
+// key_repeat - handle a key being repeated
+//-------------------------------------------------
+
+void hds200_kbd_hle_device::key_repeat(u8 row, u8 column)
+{
+ uint8_t code = translate(row, column);
+
+ if (code != 0x00)
+ transmit_byte(code);
+}
+
+//-------------------------------------------------
+// rx_w - receive bit from host
+//-------------------------------------------------
+
+void hds200_kbd_hle_device::rx_w(int state)
+{
+ device_buffered_serial_interface::rx_w(state);
+}
+
+//-------------------------------------------------
+// translate - row and column to key code
+//-------------------------------------------------
+
+uint8_t hds200_kbd_hle_device::translate(uint8_t row, uint8_t column)
+{
+ uint8_t const modifiers(m_modifiers->read());
+
+ bool const ctrl(modifiers & 0x01);
+ bool const shift(bool(modifiers & 0x02) || bool(modifiers & 0x04));
+ bool const ctrl_shift(ctrl && shift);
+
+ unsigned const map(ctrl_shift? 3 : ctrl ? 2 : shift ? 1 : 0);
+
+ return TRANSLATION_TABLE[map][row][column];
+}
diff --git a/src/mame/machine/hds200_kbd.h b/src/mame/machine/hds200_kbd.h
new file mode 100644
index 00000000000..bce33e96241
--- /dev/null
+++ b/src/mame/machine/hds200_kbd.h
@@ -0,0 +1,66 @@
+// license: BSD-3-Clause
+// copyright-holders: Dirk Best
+/***************************************************************************
+
+ HDS200 Keyboard (HLE)
+
+***************************************************************************/
+
+#ifndef MAME_MACHINE_HDS200_KBD_H
+#define MAME_MACHINE_HDS200_KBD_H
+
+#pragma once
+
+#include "machine/keyboard.h"
+#include "sound/beep.h"
+#include "diserial.h"
+
+
+//**************************************************************************
+// TYPE DEFINITIONS
+//**************************************************************************
+
+// ======================> hds200_kbd_hle_device
+
+class hds200_kbd_hle_device : public device_t,
+ public device_buffered_serial_interface<16>,
+ protected device_matrix_keyboard_interface<6>
+{
+public:
+ // construction/destruction
+ hds200_kbd_hle_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock = 0);
+
+ // callbacks
+ auto tx_handler() { return m_tx_handler.bind(); }
+
+ // from host
+ void rx_w(int state);
+
+protected:
+ // device_t overrides
+ virtual ioport_constructor device_input_ports() const override;
+ virtual void device_add_mconfig(machine_config &config) override;
+ virtual void device_start() override;
+ virtual void device_reset() override;
+
+ // device_buffered_serial_interface overrides
+ virtual void tra_callback() override;
+ virtual void received_byte(uint8_t byte) override;
+
+ // device_matrix_keyboard_interface overrides
+ virtual void key_make(uint8_t row, uint8_t column) override;
+ virtual void key_break(uint8_t row, uint8_t column) override;
+ virtual void key_repeat(uint8_t row, uint8_t column) override;
+
+private:
+ required_device<beep_device> m_bell;
+ required_ioport m_modifiers;
+ devcb_write_line m_tx_handler;
+
+ uint8_t translate(uint8_t row, uint8_t column);
+};
+
+// device type definition
+DECLARE_DEVICE_TYPE(HDS200_KBD_HLE, hds200_kbd_hle_device)
+
+#endif // MAME_MACHINE_HDS200_KBD_H
diff --git a/src/mame/machine/hp2640_tape.cpp b/src/mame/machine/hp2640_tape.cpp
index ad22cc1c884..45fcc5caff7 100644
--- a/src/mame/machine/hp2640_tape.cpp
+++ b/src/mame/machine/hp2640_tape.cpp
@@ -311,7 +311,7 @@ void hp2640_tape_device::device_reset()
m_cell_timer->reset();
}
-void hp2640_tape_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
+void hp2640_tape_device::device_timer(emu_timer &timer, device_timer_id id, int param)
{
LOG("TMR %d @%s\n" , id , machine().time().to_string());
diff --git a/src/mame/machine/hp2640_tape.h b/src/mame/machine/hp2640_tape.h
index 38733094dd5..9c6ff7e382a 100644
--- a/src/mame/machine/hp2640_tape.h
+++ b/src/mame/machine/hp2640_tape.h
@@ -38,7 +38,7 @@ protected:
virtual void device_add_mconfig(machine_config &config) override;
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_timer(emu_timer &timer, device_timer_id id, int param) override;
private:
devcb_write_line m_irq_handler;
diff --git a/src/mame/machine/hp48_port.h b/src/mame/machine/hp48_port.h
index 887c702910a..4d2fcc4ba2a 100644
--- a/src/mame/machine/hp48_port.h
+++ b/src/mame/machine/hp48_port.h
@@ -35,16 +35,13 @@ public:
}
// image-level overrides
- virtual iodevice_t image_type() const noexcept override { return IO_MEMCARD; }
-
virtual bool is_readable() const noexcept override { return true; }
virtual bool is_writeable() const noexcept override { return true; }
virtual bool is_creatable() const noexcept override { return true; }
- virtual bool must_be_loaded() const noexcept override { return false; }
virtual bool is_reset_on_load() const noexcept override { return false; }
virtual const char *file_extensions() const noexcept override { return "crd"; }
- virtual const char *custom_instance_name() const noexcept override { return "port"; }
- virtual const char *custom_brief_instance_name() const noexcept override { return "p"; }
+ virtual const char *image_type_name() const noexcept override { return "port"; }
+ virtual const char *image_brief_type_name() const noexcept override { return "p"; }
virtual image_init_result call_load() override;
virtual void call_unload() override;
diff --git a/src/mame/machine/hp80_optrom.cpp b/src/mame/machine/hp80_optrom.cpp
index b8389dcf858..0dc0cec1022 100644
--- a/src/mame/machine/hp80_optrom.cpp
+++ b/src/mame/machine/hp80_optrom.cpp
@@ -23,7 +23,7 @@ DEFINE_DEVICE_TYPE(HP80_OPTROM, hp80_optrom_device, "hp80_optrom", "HP80 optiona
// +------------------+
hp80_optrom_device::hp80_optrom_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
device_t(mconfig, HP80_OPTROM, tag, owner, clock),
- device_image_interface(mconfig, *this),
+ device_rom_image_interface(mconfig, *this),
m_select_code(0)
{
}
diff --git a/src/mame/machine/hp80_optrom.h b/src/mame/machine/hp80_optrom.h
index 7ab35cd7967..2f4f6cd7250 100644
--- a/src/mame/machine/hp80_optrom.h
+++ b/src/mame/machine/hp80_optrom.h
@@ -13,13 +13,13 @@
#pragma once
-#include "softlist_dev.h"
+#include "imagedev/cartrom.h"
// Size of optional ROMs (8k)
static constexpr offs_t HP80_OPTROM_SIZE = 0x2000;
class hp80_optrom_device : public device_t,
- public device_image_interface
+ public device_rom_image_interface
{
public:
// construction/destruction
@@ -40,13 +40,7 @@ protected:
// image-level overrides
virtual image_init_result call_load() override;
virtual void call_unload() override;
- virtual const software_list_loader &get_software_list_loader() const override { return rom_software_list_loader::instance(); }
- virtual iodevice_t image_type() const noexcept override { return IO_ROM; }
- virtual bool is_readable() const noexcept override { return true; }
- virtual bool is_writeable() const noexcept override { return false; }
- virtual bool is_creatable() const noexcept override { return false; }
- virtual bool must_be_loaded() const noexcept override { return false; }
virtual bool is_reset_on_load() const noexcept override { return true; }
virtual const char *image_interface() const noexcept override { return "hp80_rom"; }
virtual const char *file_extensions() const noexcept override { return "bin"; }
diff --git a/src/mame/machine/hp9825_optrom.cpp b/src/mame/machine/hp9825_optrom.cpp
index b49ed6f4846..1466bf25b83 100644
--- a/src/mame/machine/hp9825_optrom.cpp
+++ b/src/mame/machine/hp9825_optrom.cpp
@@ -46,7 +46,7 @@ hp9825_optrom_device::hp9825_optrom_device(machine_config const &mconfig, char c
hp9825_optrom_device::hp9825_optrom_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
: device_t(mconfig, HP9825_OPTROM, tag, owner, clock)
- , device_image_interface(mconfig, *this)
+ , device_rom_image_interface(mconfig, *this)
, m_rom_limit(0xffffU)
, m_loaded_regions(0)
, m_space_r(nullptr)
diff --git a/src/mame/machine/hp9825_optrom.h b/src/mame/machine/hp9825_optrom.h
index d83cd9563a8..494f2ffda20 100644
--- a/src/mame/machine/hp9825_optrom.h
+++ b/src/mame/machine/hp9825_optrom.h
@@ -13,10 +13,10 @@
#pragma once
#include "machine/bankdev.h"
-#include "softlist_dev.h"
+#include "imagedev/cartrom.h"
class hp9825_optrom_device : public device_t,
- public device_image_interface
+ public device_rom_image_interface
{
public:
// construction/destruction
@@ -36,13 +36,7 @@ protected:
// image-level overrides
virtual image_init_result call_load() override;
virtual void call_unload() override;
- virtual const software_list_loader &get_software_list_loader() const override { return rom_software_list_loader::instance(); }
- virtual iodevice_t image_type() const noexcept override { return IO_ROM; }
- virtual bool is_readable() const noexcept override { return true; }
- virtual bool is_writeable() const noexcept override { return false; }
- virtual bool is_creatable() const noexcept override { return false; }
- virtual bool must_be_loaded() const noexcept override { return false; }
virtual bool is_reset_on_load() const noexcept override { return true; }
virtual const char *image_interface() const noexcept override { return "hp9825_rom"; }
virtual const char *file_extensions() const noexcept override { return "bin"; }
diff --git a/src/mame/machine/hp9845_optrom.cpp b/src/mame/machine/hp9845_optrom.cpp
index 7f01abee7c7..c33b8b8ab16 100644
--- a/src/mame/machine/hp9845_optrom.cpp
+++ b/src/mame/machine/hp9845_optrom.cpp
@@ -20,7 +20,7 @@ DEFINE_DEVICE_TYPE(HP9845_OPTROM, hp9845_optrom_device, "hp9845_optrom", "HP9845
// +--------------------+
hp9845_optrom_device::hp9845_optrom_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
device_t(mconfig, HP9845_OPTROM, tag, owner, clock),
- device_image_interface(mconfig, *this),
+ device_rom_image_interface(mconfig, *this),
m_base_addr(0),
m_end_addr(0)
{
diff --git a/src/mame/machine/hp9845_optrom.h b/src/mame/machine/hp9845_optrom.h
index 0345474c94d..0f972da3427 100644
--- a/src/mame/machine/hp9845_optrom.h
+++ b/src/mame/machine/hp9845_optrom.h
@@ -13,10 +13,10 @@
#pragma once
-#include "softlist_dev.h"
+#include "imagedev/cartrom.h"
class hp9845_optrom_device : public device_t,
- public device_image_interface
+ public device_rom_image_interface
{
public:
// construction/destruction
@@ -30,13 +30,7 @@ protected:
// image-level overrides
virtual image_init_result call_load() override;
virtual void call_unload() override;
- virtual const software_list_loader &get_software_list_loader() const override { return rom_software_list_loader::instance(); }
- virtual iodevice_t image_type() const noexcept override { return IO_ROM; }
- virtual bool is_readable() const noexcept override { return true; }
- virtual bool is_writeable() const noexcept override { return false; }
- virtual bool is_creatable() const noexcept override { return false; }
- virtual bool must_be_loaded() const noexcept override { return false; }
virtual bool is_reset_on_load() const noexcept override { return true; }
virtual const char *image_interface() const noexcept override { return "hp9845b_rom"; }
virtual const char *file_extensions() const noexcept override { return "bin"; }
diff --git a/src/mame/machine/hp9845_printer.cpp b/src/mame/machine/hp9845_printer.cpp
index accbc049141..c3b17acfaec 100644
--- a/src/mame/machine/hp9845_printer.cpp
+++ b/src/mame/machine/hp9845_printer.cpp
@@ -186,7 +186,7 @@ void hp9845_printer_device::device_reset()
m_sts_handler(true);
}
-void hp9845_printer_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
+void hp9845_printer_device::device_timer(emu_timer &timer, device_timer_id id, int param)
{
m_busy = false;
update_fsm();
diff --git a/src/mame/machine/hp9845_printer.h b/src/mame/machine/hp9845_printer.h
index d42c00c01cb..ce8fce69084 100644
--- a/src/mame/machine/hp9845_printer.h
+++ b/src/mame/machine/hp9845_printer.h
@@ -31,7 +31,7 @@ public:
virtual void device_add_mconfig(machine_config &config) override;
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_timer(emu_timer &timer, device_timer_id id, int param) override;
// PPU access
uint16_t printer_r(offs_t offset);
diff --git a/src/mame/machine/hp_ipc_optrom.cpp b/src/mame/machine/hp_ipc_optrom.cpp
index 75b66ec7a67..045b420b6ef 100644
--- a/src/mame/machine/hp_ipc_optrom.cpp
+++ b/src/mame/machine/hp_ipc_optrom.cpp
@@ -23,7 +23,7 @@ DEFINE_DEVICE_TYPE(HP_IPC_OPTROM, hp_ipc_optrom_device, "hp_ipc_optrom", "HP IPC
// +--------------------+
hp_ipc_optrom_device::hp_ipc_optrom_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
: device_t(mconfig, HP_IPC_OPTROM, tag, owner, clock)
- , device_image_interface(mconfig, *this)
+ , device_rom_image_interface(mconfig, *this)
, m_base(0)
{
}
diff --git a/src/mame/machine/hp_ipc_optrom.h b/src/mame/machine/hp_ipc_optrom.h
index 93872a0a5b8..bf7d62e6920 100644
--- a/src/mame/machine/hp_ipc_optrom.h
+++ b/src/mame/machine/hp_ipc_optrom.h
@@ -13,10 +13,10 @@
#pragma once
-#include "softlist_dev.h"
+#include "imagedev/cartrom.h"
class hp_ipc_optrom_device : public device_t,
- public device_image_interface
+ public device_rom_image_interface
{
public:
// construction/destruction
@@ -37,13 +37,7 @@ protected:
// image-level overrides
virtual image_init_result call_load() override;
virtual void call_unload() override;
- virtual const software_list_loader &get_software_list_loader() const override { return rom_software_list_loader::instance(); }
- virtual iodevice_t image_type() const noexcept override { return IO_ROM; }
- virtual bool is_readable() const noexcept override { return true; }
- virtual bool is_writeable() const noexcept override { return false; }
- virtual bool is_creatable() const noexcept override { return false; }
- virtual bool must_be_loaded() const noexcept override { return false; }
virtual bool is_reset_on_load() const noexcept override { return true; }
virtual const char *image_interface() const noexcept override { return "hp_ipc_rom"; }
virtual const char *file_extensions() const noexcept override { return "bin"; }
diff --git a/src/mame/machine/hpc3.cpp b/src/mame/machine/hpc3.cpp
index 4d2acb27b0c..dcab7432baa 100644
--- a/src/mame/machine/hpc3.cpp
+++ b/src/mame/machine/hpc3.cpp
@@ -218,7 +218,7 @@ void hpc3_device::map(address_map &map)
map(0x00060000, 0x0007ffff).rw(FUNC(hpc3_device::bbram_r), FUNC(hpc3_device::bbram_w));
}
-void hpc3_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
+void hpc3_device::device_timer(emu_timer &timer, device_timer_id id, int param)
{
switch (id)
{
@@ -1109,7 +1109,7 @@ void hpc3_device::eeprom_w(uint32_t data)
m_eeprom_clk_cb(BIT(data, 2));
}
-void hpc3_device::enet_transmit(void *ptr, int param)
+void hpc3_device::enet_transmit(int param)
{
// save the first transmit buffer descriptor pointer
// TODO: not sure how cpfbdp and ppfbdp work, perhaps round-robin?
diff --git a/src/mame/machine/hpc3.h b/src/mame/machine/hpc3.h
index b9599e043f6..508f707bc30 100644
--- a/src/mame/machine/hpc3.h
+++ b/src/mame/machine/hpc3.h
@@ -71,7 +71,7 @@ protected:
virtual void device_resolve_objects() override;
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_timer(emu_timer &timer, device_timer_id id, int param) override;
virtual space_config_vector memory_space_config() const override;
@@ -119,7 +119,7 @@ protected:
void scsi_drq(bool state, int channel);
//void scsi_dma(int channel);
- void enet_transmit(void *ptr = nullptr, int param = 0);
+ void enet_transmit(int param = 0);
void enet_misc_w(u32 data);
bool enet_rx_bc_dec(unsigned const count = 1);
diff --git a/src/mame/machine/hyperscan_card.cpp b/src/mame/machine/hyperscan_card.cpp
index 2e1f87f2a38..ad9642fec3a 100644
--- a/src/mame/machine/hyperscan_card.cpp
+++ b/src/mame/machine/hyperscan_card.cpp
@@ -9,6 +9,8 @@
#include "emu.h"
#include "hyperscan_card.h"
+#include "softlist_dev.h"
+
//#define LOG_OUTPUT_FUNC printf
//#define VERBOSE 1
#include "logmacro.h"
@@ -19,8 +21,13 @@ DEFINE_DEVICE_TYPE(HYPERSCAN_CARD, hyperscan_card_device, "hyperscan_card", "Hyp
hyperscan_card_device::hyperscan_card_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
: device_t(mconfig, HYPERSCAN_CARD, tag, owner, clock)
- , device_image_interface(mconfig, *this)
+ , device_memcard_image_interface(mconfig, *this)
+{
+}
+
+const software_list_loader &hyperscan_card_device::get_software_list_loader() const
{
+ return image_software_list_loader::instance();
}
//-------------------------------------------------
diff --git a/src/mame/machine/hyperscan_card.h b/src/mame/machine/hyperscan_card.h
index c1d2cff450e..5a48483149a 100644
--- a/src/mame/machine/hyperscan_card.h
+++ b/src/mame/machine/hyperscan_card.h
@@ -7,10 +7,10 @@
#pragma once
-#include "softlist_dev.h"
+#include "imagedev/memcard.h"
class hyperscan_card_device : public device_t,
- public device_image_interface
+ public device_memcard_image_interface
{
public:
hyperscan_card_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
@@ -25,17 +25,13 @@ protected:
// image-level overrides
virtual image_init_result call_load() override;
virtual void call_unload() override;
- virtual iodevice_t image_type() const noexcept override { return IO_MEMCARD; }
- virtual bool is_readable() const noexcept override { return true; }
- virtual bool is_writeable() const noexcept override { return true; }
virtual bool is_creatable() const noexcept override { return false; }
- virtual bool must_be_loaded() const noexcept override { return false; }
virtual bool is_reset_on_load() const noexcept override { return false; }
virtual const char *image_interface() const noexcept override { return "hyperscan_card"; }
virtual const char *file_extensions() const noexcept override { return "bin"; }
// device_image_interface implementation
- virtual const software_list_loader &get_software_list_loader() const override { return image_software_list_loader::instance(); }
+ virtual const software_list_loader &get_software_list_loader() const override;
private:
uint16_t calc_crc(std::vector<uint8_t> const &data);
diff --git a/src/mame/machine/ibm6580_fdc.cpp b/src/mame/machine/ibm6580_fdc.cpp
index 9feceae1a1f..5abc6573705 100644
--- a/src/mame/machine/ibm6580_fdc.cpp
+++ b/src/mame/machine/ibm6580_fdc.cpp
@@ -69,7 +69,7 @@ void dw_fdc_device::device_reset()
m_p1 = m_p2 = m_t0 = m_t1 = 0;
}
-void dw_fdc_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
+void dw_fdc_device::device_timer(emu_timer &timer, device_timer_id id, int param)
{
m_mcu->set_input_line(INPUT_LINE_RESET, ASSERT_LINE);
}
diff --git a/src/mame/machine/ibm6580_fdc.h b/src/mame/machine/ibm6580_fdc.h
index 33b860e146a..b5c9fa8b6fc 100644
--- a/src/mame/machine/ibm6580_fdc.h
+++ b/src/mame/machine/ibm6580_fdc.h
@@ -26,9 +26,9 @@ protected:
virtual const tiny_rom_entry *device_rom_region() const override;
virtual void device_add_mconfig(machine_config &config) override;
- void device_start() override;
- void device_reset() override;
- void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override;
+ virtual void device_start() override;
+ virtual void device_reset() override;
+ virtual void device_timer(emu_timer &timer, device_timer_id id, int param) override;
private:
uint8_t m_bus, m_t0, m_t1, m_p1, m_p2;
diff --git a/src/mame/machine/ibm6580_kbd.cpp b/src/mame/machine/ibm6580_kbd.cpp
index 1413747b5af..b08095e4a9a 100644
--- a/src/mame/machine/ibm6580_kbd.cpp
+++ b/src/mame/machine/ibm6580_kbd.cpp
@@ -6,14 +6,12 @@
//#define LOG_GENERAL (1U << 0) //defined in logmacro.h already
#define LOG_DEBUG (1U << 1)
-#define LOG_KEYBOARD (1U << 2)
//#define VERBOSE (LOG_GENERAL | LOG_DEBUG)
//#define LOG_OUTPUT_FUNC printf
#include "logmacro.h"
#define LOGDBG(...) LOGMASKED(LOG_DEBUG, __VA_ARGS__)
-#define LOGKBD(...) LOGMASKED(LOG_KEYBOARD, __VA_ARGS__)
DEFINE_DEVICE_TYPE(DW_KEYBOARD, dw_keyboard_device, "dw_kbd", "IBM Displaywriter Keyboard")
@@ -26,19 +24,19 @@ ROM_END
const tiny_rom_entry *dw_keyboard_device::device_rom_region() const
{
- return ROM_NAME( dw_keyboard );
+ return ROM_NAME(dw_keyboard);
}
void dw_keyboard_device::device_add_mconfig(machine_config &config)
{
- I8049(config, m_mcu, XTAL(6'000'000)); // XXX RC oscillator
- m_mcu->bus_in_cb().set(FUNC(dw_keyboard_device::bus_r));
+ I8049(config, m_mcu, XTAL(6'000'000)); // RC oscillator
+ m_mcu->bus_in_cb().set([this] () { return m_bus; });
m_mcu->bus_out_cb().set(FUNC(dw_keyboard_device::bus_w));
m_mcu->p1_out_cb().set(FUNC(dw_keyboard_device::p1_w));
- m_mcu->p2_in_cb().set(FUNC(dw_keyboard_device::p2_r));
+ m_mcu->p2_in_cb().set([this] () { return m_p2; });
m_mcu->p2_out_cb().set(FUNC(dw_keyboard_device::p2_w));
- m_mcu->t0_in_cb().set(FUNC(dw_keyboard_device::t0_r));
- m_mcu->t1_in_cb().set(FUNC(dw_keyboard_device::t1_r));
+ m_mcu->t0_in_cb().set([this] () { return m_ack; });
+ m_mcu->t1_in_cb().set([this] () { return m_keylatch; });
}
@@ -84,11 +82,11 @@ INPUT_PORTS_START( dw_keyboard )
PORT_START("COL.3")
PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("/ ?") PORT_CODE(KEYCODE_SLASH) PORT_CHAR('/') PORT_CHAR('?')
- PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("3 2") PORT_CODE(KEYCODE_BACKSLASH)
+ PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("3 2") PORT_CODE(KEYCODE_BACKSLASH) PORT_CHAR('\\') PORT_CHAR('|')
PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("[ ]") PORT_CODE(KEYCODE_CLOSEBRACE) PORT_CHAR('[') PORT_CHAR(']')
PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_EQUALS) PORT_CHAR('=') PORT_CHAR('+')
PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_MINUS) PORT_CHAR('-') PORT_CHAR('_')
- PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("1/4 1/2") PORT_CODE(KEYCODE_OPENBRACE)
+ PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("1/4 1/2") PORT_CODE(KEYCODE_OPENBRACE) PORT_CHAR('[') PORT_CHAR('{')
PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_QUOTE) PORT_CHAR('\'') PORT_CHAR('"')
PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Enter") PORT_CODE(KEYCODE_ENTER_PAD) PORT_CHAR(UCHAR_MAMEKEY(ENTER_PAD))
@@ -146,7 +144,7 @@ INPUT_PORTS_START( dw_keyboard )
PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("LShift") PORT_CODE(KEYCODE_LSHIFT) PORT_CHAR(UCHAR_SHIFT_1)
PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Lock") PORT_CODE(KEYCODE_CAPSLOCK) PORT_CHAR(UCHAR_MAMEKEY(CAPSLOCK))
PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_TAB) PORT_CHAR('\t')
- PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Plusminus") PORT_CODE(KEYCODE_TILDE)
+ PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Plusminus") PORT_CODE(KEYCODE_TILDE) PORT_CHAR('`') PORT_CHAR('~')
PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_UNUSED )
PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_UNUSED )
PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_UNUSED )
@@ -171,17 +169,21 @@ INPUT_PORTS_START( dw_keyboard )
PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_UNUSED )
PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Reqst")
PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_UNUSED )
+
+ PORT_START("MR")
+ PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Memory Record") PORT_CODE(KEYCODE_ESC) PORT_CHAR(UCHAR_MAMEKEY(ESC))
INPUT_PORTS_END
ioport_constructor dw_keyboard_device::device_input_ports() const
{
- return INPUT_PORTS_NAME( dw_keyboard );
+ return INPUT_PORTS_NAME(dw_keyboard);
}
dw_keyboard_device::dw_keyboard_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
: device_t(mconfig, DW_KEYBOARD, tag, owner, clock)
, m_kbd(*this, "COL.%u", 0)
+ , m_mr(*this, "MR")
, m_out_data(*this)
, m_out_clock(*this)
, m_out_strobe(*this)
@@ -194,16 +196,14 @@ void dw_keyboard_device::device_start()
m_out_data.resolve_safe();
m_out_clock.resolve_safe();
m_out_strobe.resolve_safe();
- m_reset_timer = timer_alloc();
}
void dw_keyboard_device::device_reset()
{
-}
-
-void dw_keyboard_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
-{
- m_mcu->set_input_line(INPUT_LINE_RESET, ASSERT_LINE);
+ LOG("device_reset()\n");
+ m_reset = 1;
+ m_keylatch = 0;
+ m_ack = 0;
}
void dw_keyboard_device::p1_w(uint8_t data)
@@ -215,7 +215,8 @@ void dw_keyboard_device::p1_w(uint8_t data)
void dw_keyboard_device::p2_w(uint8_t data)
{
- if (BIT(m_p2 ^ data, 3) && BIT(data, 3)) {
+ if (BIT(m_p2 ^ data, 3) && BIT(data, 3))
+ {
m_sense = data & 7;
}
@@ -225,33 +226,8 @@ void dw_keyboard_device::p2_w(uint8_t data)
LOGDBG("p2 <- %02x = drive %04x sense row %d\n", data, m_drive, data & 7);
}
-uint8_t dw_keyboard_device::p2_r()
-{
- uint8_t data = m_p2;
-
- LOGDBG("p2 == %02x\n", data);
-
- return data;
-}
-
-READ_LINE_MEMBER( dw_keyboard_device::t0_r )
-{
- LOGKBD("t0 == %d\n", m_ack);
-
- return m_ack;
-}
-
-READ_LINE_MEMBER( dw_keyboard_device::t1_r )
-{
- LOGDBG("t1 == %d\n", m_keylatch);
-
- return m_keylatch;
-}
-
void dw_keyboard_device::bus_w(uint8_t data)
{
- int i, sense = 0;
-
/*
bit description
@@ -275,9 +251,14 @@ void dw_keyboard_device::bus_w(uint8_t data)
m_out_strobe(BIT(data, 1));
m_out_clock(BIT(data, 4));
- if (BIT(data, 7)) {
- for (i = 0; i < 12; i++) {
- if (BIT(m_drive, i)) {
+ if (BIT(data, 7))
+ {
+ int i, sense = 0;
+
+ for (i = 0; i < 12; i++)
+ {
+ if (BIT(m_drive, i))
+ {
sense |= m_kbd[i]->read();
break;
}
@@ -287,35 +268,35 @@ void dw_keyboard_device::bus_w(uint8_t data)
LOG("bus key %02x pressed (drive %04x sense %x)\n", (i << 3) | m_sense, m_drive, m_sense);
}
- if (!BIT(data, 6)) {
+ if (!BIT(data, 6))
+ {
m_dip = ~ioport("DIP")->read();
LOG("bus loaded DIP switch setting 0x%02x\n", m_dip);
m_mcu->set_input_line(MCS48_INPUT_IRQ, m_dip & 1 ? ASSERT_LINE : CLEAR_LINE);
}
- if (!BIT(data, 5)) {
+ if (!BIT(data, 5))
+ {
m_dip >>= 1;
m_mcu->set_input_line(MCS48_INPUT_IRQ, m_dip & 1 ? ASSERT_LINE : CLEAR_LINE);
}
}
-uint8_t dw_keyboard_device::bus_r()
-{
- return m_bus;
-}
-
-WRITE_LINE_MEMBER( dw_keyboard_device::reset_w )
+WRITE_LINE_MEMBER(dw_keyboard_device::reset_w)
{
- if(!state)
- m_reset_timer->adjust(attotime::from_msec(50));
- else
+ if (m_reset ^ state)
{
- m_reset_timer->adjust(attotime::never);
- m_mcu->set_input_line(INPUT_LINE_RESET, CLEAR_LINE);
+ LOG("reset changed to %d\n", state);
+ m_reset = state;
+ if (!state)
+ {
+ m_mcu->set_input_line(INPUT_LINE_RESET, ASSERT_LINE);
+ m_mcu->set_input_line(INPUT_LINE_RESET, CLEAR_LINE);
+ }
}
}
-WRITE_LINE_MEMBER( dw_keyboard_device::ack_w )
+WRITE_LINE_MEMBER(dw_keyboard_device::ack_w)
{
m_ack = state;
}
diff --git a/src/mame/machine/ibm6580_kbd.h b/src/mame/machine/ibm6580_kbd.h
index a6c08c28ad6..8de7a2f358c 100644
--- a/src/mame/machine/ibm6580_kbd.h
+++ b/src/mame/machine/ibm6580_kbd.h
@@ -16,6 +16,8 @@ public:
auto out_clock_handler() { return m_out_clock.bind(); }
auto out_strobe_handler() { return m_out_strobe.bind(); }
+ int memory_record_r() { return m_mr->read(); }
+
DECLARE_WRITE_LINE_MEMBER(reset_w);
DECLARE_WRITE_LINE_MEMBER(ack_w);
@@ -26,27 +28,22 @@ protected:
void device_start() override;
void device_reset() override;
- void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override;
private:
uint8_t m_dip, m_bus, m_p2;
- int m_drive, m_sense;
- bool m_keylatch, m_ack;
- emu_timer *m_reset_timer;
+ int m_drive, m_sense, m_reset;
+ int m_keylatch, m_ack;
required_ioport_array<12> m_kbd;
+ required_ioport m_mr;
devcb_write_line m_out_data;
devcb_write_line m_out_clock;
devcb_write_line m_out_strobe;
required_device<i8049_device> m_mcu;
void bus_w(uint8_t data);
- uint8_t bus_r();
void p1_w(uint8_t data);
void p2_w(uint8_t data);
- uint8_t p2_r();
- DECLARE_READ_LINE_MEMBER(t0_r);
- DECLARE_READ_LINE_MEMBER(t1_r);
};
DECLARE_DEVICE_TYPE(DW_KEYBOARD, dw_keyboard_device)
diff --git a/src/mame/machine/imm6_76.h b/src/mame/machine/imm6_76.h
index e004f3b234a..cef6df9ba81 100644
--- a/src/mame/machine/imm6_76.h
+++ b/src/mame/machine/imm6_76.h
@@ -157,16 +157,14 @@ public:
virtual void call_unload() override;
// device_image_interface static info
- virtual iodevice_t image_type() const noexcept override { return IO_ROM; }
virtual bool is_readable() const noexcept override { return true; }
virtual bool is_writeable() const noexcept override { return true; }
virtual bool is_creatable() const noexcept override { return true; }
- virtual bool must_be_loaded() const noexcept override { return false; }
virtual bool is_reset_on_load() const noexcept override { return false; }
virtual bool support_command_line_image_creation() const noexcept override { return true; }
virtual char const *file_extensions() const noexcept override { return "rom,bin"; }
- virtual char const *custom_instance_name() const noexcept override { return "promimage"; }
- virtual char const *custom_brief_instance_name() const noexcept override { return "prom"; }
+ virtual char const *image_type_name() const noexcept override { return "promimage"; }
+ virtual char const *image_brief_type_name() const noexcept override { return "prom"; }
void di_w(u8 data);
void a_w(u8 data);
diff --git a/src/mame/machine/intv.cpp b/src/mame/machine/intv.cpp
index 7cddd86c724..c580b93dc37 100644
--- a/src/mame/machine/intv.cpp
+++ b/src/mame/machine/intv.cpp
@@ -317,7 +317,7 @@ void set_tape_bit(int position, int data)
}
#endif
-#if defined(LATER)
+#if 0
int intvkbd_tape_init(int id)
{
FILE *tapefile;
@@ -682,7 +682,7 @@ INTERRUPT_GEN_MEMBER(intv_state::intv_interrupt)
m_stic->screenrefresh();
}
-#if defined(LATER)
+#if 0
INTERRUPT_GEN( intvkbd_interrupt2 )
{
diff --git a/src/mame/machine/iteagle_fpga.cpp b/src/mame/machine/iteagle_fpga.cpp
index 52278b7bf90..fd54ccd8ec6 100644
--- a/src/mame/machine/iteagle_fpga.cpp
+++ b/src/mame/machine/iteagle_fpga.cpp
@@ -103,7 +103,7 @@ void iteagle_fpga_device::device_start()
// RAM defaults to base address 0x000e0000
bank_infos[2].adr = 0x000e0000 & (~(bank_infos[2].size - 1));
- m_timer = timer_alloc(0, nullptr);
+ m_timer = timer_alloc(0);
// Switch IO
m_in_cb.resolve_all_safe(0xffff);
@@ -207,7 +207,7 @@ void iteagle_fpga_device::update_sequence_eg1(uint32_t data)
//-------------------------------------------------
// device_timer - called when our device timer expires
//-------------------------------------------------
-void iteagle_fpga_device::device_timer(emu_timer &timer, device_timer_id tid, int param, void *ptr)
+void iteagle_fpga_device::device_timer(emu_timer &timer, device_timer_id tid, int param)
{
//int beamy = m_screen->vpos();
//const rectangle &visarea = m_screen->visible_area();
diff --git a/src/mame/machine/iteagle_fpga.h b/src/mame/machine/iteagle_fpga.h
index 9cfacc63484..692fd531324 100644
--- a/src/mame/machine/iteagle_fpga.h
+++ b/src/mame/machine/iteagle_fpga.h
@@ -64,7 +64,7 @@ public:
protected:
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_timer(emu_timer &timer, device_timer_id id, int param) override;
virtual void device_add_mconfig(machine_config &config) override;
private:
diff --git a/src/mame/machine/jaleco_ms32_sysctrl.cpp b/src/mame/machine/jaleco_ms32_sysctrl.cpp
index c9007080a66..17884d9efec 100644
--- a/src/mame/machine/jaleco_ms32_sysctrl.cpp
+++ b/src/mame/machine/jaleco_ms32_sysctrl.cpp
@@ -197,7 +197,7 @@ void jaleco_ms32_sysctrl_device::flush_scanline_timer(int current_scanline)
m_timer_scanline->adjust(m_screen->time_until_pos(next_scanline), next_scanline);
}
-void jaleco_ms32_sysctrl_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
+void jaleco_ms32_sysctrl_device::device_timer(emu_timer &timer, device_timer_id id, int param)
{
switch (id)
{
diff --git a/src/mame/machine/jaleco_ms32_sysctrl.h b/src/mame/machine/jaleco_ms32_sysctrl.h
index d765965d633..8f10db9a887 100644
--- a/src/mame/machine/jaleco_ms32_sysctrl.h
+++ b/src/mame/machine/jaleco_ms32_sysctrl.h
@@ -51,7 +51,7 @@ protected:
virtual void device_add_mconfig(machine_config &config) override;
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_timer(emu_timer &timer, device_timer_id id, int param) override;
private:
required_device<screen_device> m_screen;
diff --git a/src/mame/machine/k573dio.cpp b/src/mame/machine/k573dio.cpp
index 7e3c0ece28a..0838ac404b1 100644
--- a/src/mame/machine/k573dio.cpp
+++ b/src/mame/machine/k573dio.cpp
@@ -49,7 +49,7 @@
| AK4309B CN18 29.450MHz MAS3507D |
| |
| CN3 |
- | HYC24855 RCA-L/R |
+ | HYC2485S RCA-1/2 |
|-----------------------------------------------|
Notes:
@@ -73,8 +73,8 @@
CN18 - 6 pin connector
MAS3507D - IM MAS3507D D8 9173 51 HM U 072953.000 ES MPEG 1/2 Layer 2/3 Audio Decoder
CN3 - Connector joining this PCB to the MAIN PCB
- HYC24855 - ?
- RCA-L/R - RCA connectors for left/right audio output
+ HYC2485S - RS485 transceiver
+ RCA-1/2 - RCA connectors for network communication
*/
@@ -89,11 +89,12 @@ void k573dio_device::amap(address_map &map)
map(0x0a, 0x0b).r(FUNC(k573dio_device::a0a_r));
map(0x10, 0x11).w(FUNC(k573dio_device::a10_w));
map(0x80, 0x81).r(FUNC(k573dio_device::a80_r));
- map(0xc4, 0xc5).r(FUNC(k573dio_device::ac4_r));
- map(0xa0, 0xa1).w(FUNC(k573dio_device::mpeg_start_adr_high_w));
- map(0xa2, 0xa3).w(FUNC(k573dio_device::mpeg_start_adr_low_w));
- map(0xa4, 0xa5).w(FUNC(k573dio_device::mpeg_end_adr_high_w));
- map(0xa6, 0xa7).w(FUNC(k573dio_device::mpeg_end_adr_low_w));
+ map(0x90, 0x91).w(FUNC(k573dio_device::network_id_w));
+ //map(0x92, 0x93).w(FUNC(k573dio_device::network_unk_w));
+ map(0xa0, 0xa1).rw(FUNC(k573dio_device::mpeg_start_adr_high_r), FUNC(k573dio_device::mpeg_start_adr_high_w));
+ map(0xa2, 0xa3).rw(FUNC(k573dio_device::mpeg_start_adr_low_r), FUNC(k573dio_device::mpeg_start_adr_low_w));
+ map(0xa4, 0xa5).rw(FUNC(k573dio_device::mpeg_end_adr_high_r), FUNC(k573dio_device::mpeg_end_adr_high_w));
+ map(0xa6, 0xa7).rw(FUNC(k573dio_device::mpeg_end_adr_low_r), FUNC(k573dio_device::mpeg_end_adr_low_w));
map(0xa8, 0xa9).rw(FUNC(k573dio_device::mpeg_key_1_r), FUNC(k573dio_device::mpeg_key_1_w));
map(0xaa, 0xab).r(FUNC(k573dio_device::mpeg_ctrl_r));
map(0xac, 0xad).rw(FUNC(k573dio_device::mas_i2c_r), FUNC(k573dio_device::mas_i2c_w));
@@ -103,6 +104,10 @@ void k573dio_device::amap(address_map &map)
map(0xb4, 0xb5).rw(FUNC(k573dio_device::ram_r), FUNC(k573dio_device::ram_w));
map(0xb6, 0xb7).w(FUNC(k573dio_device::ram_read_adr_high_w));
map(0xb8, 0xb9).w(FUNC(k573dio_device::ram_read_adr_low_w));
+ map(0xc0, 0xc1).rw(FUNC(k573dio_device::network_r), FUNC(k573dio_device::network_w));
+ map(0xc2, 0xc3).r(FUNC(k573dio_device::network_output_buf_size_r));
+ map(0xc4, 0xc5).r(FUNC(k573dio_device::network_input_buf_size_r));
+ //map(0xc8, 0xc9).w(FUNC(k573dio_device::network_unk2_w));
map(0xca, 0xcb).r(FUNC(k573dio_device::mp3_counter_high_r));
map(0xcc, 0xcd).rw(FUNC(k573dio_device::mp3_counter_low_r), FUNC(k573dio_device::mp3_counter_low_w));
map(0xce, 0xcf).r(FUNC(k573dio_device::mp3_counter_diff_r));
@@ -139,6 +144,7 @@ void k573dio_device::device_start()
save_item(NAME(output_data));
save_item(NAME(is_ddrsbm_fpga));
save_item(NAME(crypto_key1));
+ save_item(NAME(network_id));
k573fpga->set_ddrsbm_fpga(is_ddrsbm_fpga);
}
@@ -148,6 +154,7 @@ void k573dio_device::device_reset()
ram_adr = 0;
ram_read_adr = 0;
crypto_key1 = 0;
+ network_id = 0;
std::fill(std::begin(output_data), std::end(output_data), 0);
}
@@ -172,7 +179,7 @@ void k573dio_device::device_add_mconfig(machine_config &config)
DS2401(config, digital_id);
}
-void k573dio_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
+void k573dio_device::device_timer(emu_timer &timer, device_timer_id id, int param)
{
}
@@ -211,24 +218,28 @@ void k573dio_device::a10_w(uint16_t data)
LOGUNKNOWNREG("%s: a10_w: %04x (%s)\n", tag(), data, machine().describe_context());
}
-uint16_t k573dio_device::ac4_r()
-{
- LOGUNKNOWNREG("%s: ac4_r (%s)\n", tag(), machine().describe_context());
- return 0;
-}
-
uint16_t k573dio_device::a80_r()
{
LOGUNKNOWNREG("%s: a80_r (%s)\n", tag(), machine().describe_context());
return 0x1234;
}
+uint16_t k573dio_device::mpeg_start_adr_high_r()
+{
+ return k573fpga->get_mp3_start_addr() >> 16;
+}
+
void k573dio_device::mpeg_start_adr_high_w(uint16_t data)
{
LOGMP3("FPGA MPEG start address high %04x\n", data);
k573fpga->set_mp3_start_addr((k573fpga->get_mp3_start_addr() & 0x0000ffff) | (data << 16)); // high
}
+uint16_t k573dio_device::mpeg_start_adr_low_r()
+{
+ return k573fpga->get_mp3_start_addr() & 0xffff;
+}
+
void k573dio_device::mpeg_start_adr_low_w(uint16_t data)
{
LOGMP3("FPGA MPEG start address low %04x\n", data);
@@ -238,12 +249,22 @@ void k573dio_device::mpeg_start_adr_low_w(uint16_t data)
k573fpga->set_crypto_key3(0);
}
+uint16_t k573dio_device::mpeg_end_adr_high_r()
+{
+ return k573fpga->get_mp3_end_addr() >> 16;
+}
+
void k573dio_device::mpeg_end_adr_high_w(uint16_t data)
{
LOGMP3("FPGA MPEG end address high %04x\n", data);
k573fpga->set_mp3_end_addr((k573fpga->get_mp3_end_addr() & 0x0000ffff) | (data << 16)); // high
}
+uint16_t k573dio_device::mpeg_end_adr_low_r()
+{
+ return k573fpga->get_mp3_end_addr() & 0xffff;
+}
+
void k573dio_device::mpeg_end_adr_low_w(uint16_t data)
{
LOGMP3("FPGA MPEG end address low %04x\n", data);
@@ -436,3 +457,32 @@ void k573dio_device::output(int offset, uint16_t data)
}
output_data[offset] = data;
}
+
+uint16_t k573dio_device::network_r()
+{
+ // Return a byte from the input buffer
+ return 0;
+}
+
+void k573dio_device::network_w(uint16_t data)
+{
+ // Write a byte to the output buffer
+}
+
+uint16_t k573dio_device::network_output_buf_size_r()
+{
+ // Number of bytes in the output buffer waiting to be sent
+ return 0;
+}
+
+uint16_t k573dio_device::network_input_buf_size_r()
+{
+ // Number of bytes in the input buffer waiting to be read
+ return 0;
+}
+
+void k573dio_device::network_id_w(uint16_t data)
+{
+ // The network ID configured in the operator menu
+ network_id = data;
+}
diff --git a/src/mame/machine/k573dio.h b/src/mame/machine/k573dio.h
index 2c22c82e453..682b8095523 100644
--- a/src/mame/machine/k573dio.h
+++ b/src/mame/machine/k573dio.h
@@ -25,11 +25,14 @@ public:
uint16_t a0a_r();
void a10_w(uint16_t data);
uint16_t a80_r();
- uint16_t ac4_r();
+ uint16_t mpeg_start_adr_high_r();
void mpeg_start_adr_high_w(uint16_t data);
+ uint16_t mpeg_start_adr_low_r();
void mpeg_start_adr_low_w(uint16_t data);
+ uint16_t mpeg_end_adr_high_r();
void mpeg_end_adr_high_w(uint16_t data);
+ uint16_t mpeg_end_adr_low_r();
void mpeg_end_adr_low_w(uint16_t data);
uint16_t mpeg_key_1_r();
void mpeg_key_1_w(uint16_t data);
@@ -61,13 +64,18 @@ public:
void output_4_w(uint16_t data);
void output_2_w(uint16_t data);
void output_5_w(uint16_t data);
+ uint16_t network_r();
+ void network_w(uint16_t data);
+ uint16_t network_output_buf_size_r();
+ uint16_t network_input_buf_size_r();
+ void network_id_w(uint16_t data);
protected:
virtual void device_start() override;
virtual void device_reset() override;
virtual const tiny_rom_entry *device_rom_region() const override;
virtual void device_add_mconfig(machine_config &config) override;
- virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override;
+ virtual void device_timer(emu_timer &timer, device_timer_id id, int param) override;
private:
memory_share_creator<uint16_t> ram;
@@ -82,6 +90,8 @@ private:
bool is_ddrsbm_fpga;
u16 crypto_key1;
+
+ uint16_t network_id;
};
DECLARE_DEVICE_TYPE(KONAMI_573_DIGITAL_IO_BOARD, k573dio_device)
diff --git a/src/mame/machine/k573kara.cpp b/src/mame/machine/k573kara.cpp
index b2663f196f3..3f38fa3ac66 100644
--- a/src/mame/machine/k573kara.cpp
+++ b/src/mame/machine/k573kara.cpp
@@ -112,7 +112,7 @@ void k573kara_device::device_add_mconfig(machine_config &config)
duart_chan0.out_rts_callback().set("rs232_chan0", FUNC(rs232_port_device::write_rts));
}
-void k573kara_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
+void k573kara_device::device_timer(emu_timer &timer, device_timer_id id, int param)
{
}
diff --git a/src/mame/machine/k573kara.h b/src/mame/machine/k573kara.h
index 57e53e16223..c551b5b088a 100644
--- a/src/mame/machine/k573kara.h
+++ b/src/mame/machine/k573kara.h
@@ -20,7 +20,7 @@ protected:
virtual void device_reset() override;
virtual const tiny_rom_entry *device_rom_region() const override;
virtual void device_add_mconfig(machine_config &config) override;
- virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override;
+ virtual void device_timer(emu_timer &timer, device_timer_id id, int param) override;
private:
uint16_t uart_r(offs_t offset);
diff --git a/src/mame/machine/k573mcr.cpp b/src/mame/machine/k573mcr.cpp
index a29a0f55cc5..8407c6fa8c3 100644
--- a/src/mame/machine/k573mcr.cpp
+++ b/src/mame/machine/k573mcr.cpp
@@ -150,10 +150,17 @@ bool k573mcr_device::pad_read(uint32_t port_no, uint8_t *output)
controller_port_send_byte(0x01);
uint8_t a = controller_port_send_byte('B');
uint8_t b = controller_port_send_byte(0);
- *output++ = controller_port_send_byte(0);
- *output++ = controller_port_send_byte(0);
+ auto connected = a == 0x41 && b == 0x5a;
+ if (connected) {
+ *output++ = controller_port_send_byte(0);
+ *output++ = controller_port_send_byte(0);
+ }
+ else {
+ *output++ = 0;
+ *output++ = 0;
+ }
- return a == 0x41 && b == 0x5a;
+ return connected;
}
bool k573mcr_device::memcard_read(uint32_t port_no, uint16_t block_addr, uint8_t *output)
diff --git a/src/mame/machine/k7659kb.cpp b/src/mame/machine/k7659kb.cpp
index c8ce5f6725e..f5aaadde9a9 100644
--- a/src/mame/machine/k7659kb.cpp
+++ b/src/mame/machine/k7659kb.cpp
@@ -224,7 +224,7 @@ void k7659_keyboard_device::device_reset()
m_timer->adjust(attotime::from_hz(200), 0, attotime::from_hz(200));
}
-void k7659_keyboard_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
+void k7659_keyboard_device::device_timer(emu_timer &timer, device_timer_id id, int param)
{
uint8_t retVal = 0;//m_lookup;
uint8_t a1 = ioport("A1")->read();
diff --git a/src/mame/machine/k7659kb.h b/src/mame/machine/k7659kb.h
index 14b9794dd80..f48ea303d62 100644
--- a/src/mame/machine/k7659kb.h
+++ b/src/mame/machine/k7659kb.h
@@ -39,7 +39,7 @@ protected:
// device-level overrides
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_timer(emu_timer &timer, device_timer_id id, int param) override;
// optional information overrides
virtual const tiny_rom_entry *device_rom_region() const override;
diff --git a/src/mame/machine/kaneko_calc3.cpp b/src/mame/machine/kaneko_calc3.cpp
index c3f79df2d11..5daf0485142 100644
--- a/src/mame/machine/kaneko_calc3.cpp
+++ b/src/mame/machine/kaneko_calc3.cpp
@@ -95,7 +95,7 @@ void kaneko_calc3_device::reset_run_timer()
m_runtimer->adjust(attotime::from_hz(59.1854));
}
-void kaneko_calc3_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
+void kaneko_calc3_device::device_timer(emu_timer &timer, device_timer_id id, int param)
{
switch(id)
{
diff --git a/src/mame/machine/kaneko_calc3.h b/src/mame/machine/kaneko_calc3.h
index 3ae8b0b78a7..ca9fc97f8ef 100644
--- a/src/mame/machine/kaneko_calc3.h
+++ b/src/mame/machine/kaneko_calc3.h
@@ -33,7 +33,7 @@ public:
protected:
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_timer(emu_timer &timer, device_timer_id id, int param) override;
private:
required_device<cpu_device> m_maincpu;
diff --git a/src/mame/machine/kc_keyb.cpp b/src/mame/machine/kc_keyb.cpp
index 5fceb7fc8f9..e2de504f367 100644
--- a/src/mame/machine/kc_keyb.cpp
+++ b/src/mame/machine/kc_keyb.cpp
@@ -491,7 +491,7 @@ ioport_constructor kc_keyboard_device::device_input_ports() const
// device_timer - handler timer events
//-------------------------------------------------
-void kc_keyboard_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
+void kc_keyboard_device::device_timer(emu_timer &timer, device_timer_id id, int param)
{
switch(id)
{
diff --git a/src/mame/machine/kc_keyb.h b/src/mame/machine/kc_keyb.h
index 3e4e53f1856..13ebee7f9e1 100644
--- a/src/mame/machine/kc_keyb.h
+++ b/src/mame/machine/kc_keyb.h
@@ -37,7 +37,7 @@ protected:
// device-level overrides
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_timer(emu_timer &timer, device_timer_id id, int param) override;
void add_pulse_to_transmit_buffer(int pulse_state, int pulse_number = 1);
void add_bit(int bit);
diff --git a/src/mame/machine/lynx.cpp b/src/mame/machine/lynx.cpp
index 161359d5d11..c00a1accdac 100644
--- a/src/mame/machine/lynx.cpp
+++ b/src/mame/machine/lynx.cpp
@@ -35,36 +35,6 @@ enum {
SHADOW
};
-uint8_t lynx_state::lynx_read_ram(uint16_t address)
-{
- uint8_t result = 0x00;
- if (address <= 0xfbff)
- result = m_mem_0000[address - 0x0000];
- else if (address <= 0xfcff)
- result = m_mem_fc00[address - 0xfc00];
- else if (address <= 0xfdff)
- result = m_mem_fd00[address - 0xfd00];
- else if (address <= 0xfff7)
- result = m_mem_fe00[address - 0xfe00];
- else if (address >= 0xfffa)
- result = m_mem_fffa[address - 0xfffa];
- return result;
-}
-
-void lynx_state::lynx_write_ram(uint16_t address, uint8_t data)
-{
- if (address <= 0xfbff)
- m_mem_0000[address - 0x0000] = data;
- else if (address <= 0xfcff)
- m_mem_fc00[address - 0xfc00] = data;
- else if (address <= 0xfdff)
- m_mem_fd00[address - 0xfd00] = data;
- else if (address <= 0xfff7)
- m_mem_fe00[address - 0xfe00] = data;
- else if (address >= 0xfffa)
- m_mem_fffa[address - 0xfffa] = data;
-}
-
/* The pen numbers range from '0' to 'F. Pen numbers '1' through 'D' are always collidable and opaque. The other
ones have different behavior depending on the sprite type: there are 8 types of sprites, each has different
characteristics relating to some or all of their pen numbers.
@@ -93,22 +63,20 @@ The sprite types relate to specific hardware functions according to the followin
0 0 0 0 0 0 0 1 exclusive-or the data
*/
-inline void lynx_state::lynx_plot_pixel(const int mode, const int16_t x, const int y, const int color)
+inline void lynx_state::plot_pixel(const s16 x, const s16 y, const u8 color)
{
- uint8_t back;
- uint16_t screen;
- uint16_t colbuf;
+ u8 back;
m_blitter.everon = true;
- screen = m_blitter.screen + y * 80 + x / 2;
- colbuf = m_blitter.colbuf + y * 80 + x / 2;
+ const u16 screen = m_blitter.screen + y * 80 + x / 2;
+ const u16 colbuf = m_blitter.colbuf + y * 80 + x / 2;
/* a note on timing: The hardware packs the pixel data and updates the screen and collision buffer a byte at a time.
Thus the buffer update for two pixels takes 3 memory accesses for a normal sprite (write to screen buffer, read/write to collision buffer).
+1 memory access for palette fetch?
*/
- switch (mode&0x7)
+ switch (m_blitter.mode & 0x7)
{
case NORMAL_SPRITE:
/* A sprite may be set to 'normal'. This means that pen number '0' will be transparent and
@@ -117,31 +85,29 @@ inline void lynx_state::lynx_plot_pixel(const int mode, const int16_t x, const i
break;
if (!(x & 0x01)) /* Upper nibble */
{
- back = lynx_read_ram(screen);
- lynx_write_ram(screen, (back & 0x0f) | (color << 4));
+ dram_byte_w(screen, color << 4, 0xf0);
m_blitter.memory_accesses++;
- if(m_blitter.sprite_collide && !(m_blitter.no_collide))
+ if (m_blitter.SPRITE_COLLIDE())
{
- back = lynx_read_ram(colbuf);
- lynx_write_ram(colbuf, (back & ~0xf0) | (m_blitter.spritenr << 4));
+ back = BIT(dram_byte_r(colbuf), 4, 4);
+ if (back > m_blitter.fred)
+ m_blitter.fred = back;
+ dram_byte_w(colbuf, m_blitter.spritenr << 4, 0xf0);
m_blitter.memory_accesses += 2;
- if ((back >> 4) > m_blitter.fred)
- m_blitter.fred = back >> 4;
}
m_blitter.memory_accesses++;
}
else /* Lower nibble */
{
- back = lynx_read_ram(screen);
- lynx_write_ram(screen, (back & 0xf0) | color);
+ dram_byte_w(screen, color, 0x0f);
- if(m_blitter.sprite_collide && !(m_blitter.no_collide))
+ if (m_blitter.SPRITE_COLLIDE())
{
- back = lynx_read_ram(colbuf);
- lynx_write_ram(colbuf, (back & ~0x0f) | (m_blitter.spritenr));
- if ((back & 0x0f) > m_blitter.fred)
- m_blitter.fred = back >> 4;
+ back = BIT(dram_byte_r(colbuf), 0, 4);
+ if (back > m_blitter.fred)
+ m_blitter.fred = back;
+ dram_byte_w(colbuf, m_blitter.spritenr, 0x0f);
}
}
break;
@@ -155,16 +121,15 @@ inline void lynx_state::lynx_plot_pixel(const int mode, const int16_t x, const i
{
if (color != 0x0f)
{
- back = lynx_read_ram(screen);
- lynx_write_ram(screen, (back & 0x0f) | (color << 4));
+ dram_byte_w(screen, color << 4, 0xf0);
m_blitter.memory_accesses++;
}
- if(m_blitter.sprite_collide && !(m_blitter.no_collide))
+ if (m_blitter.SPRITE_COLLIDE())
{
- back = lynx_read_ram(colbuf);
- lynx_write_ram(colbuf, (back & ~0xf0) | (m_blitter.spritenr << 4));
- if ((back >> 4) > m_blitter.fred)
- m_blitter.fred = back >> 4;
+ back = BIT(dram_byte_r(colbuf), 4, 4);
+ if (back > m_blitter.fred)
+ m_blitter.fred = back;
+ dram_byte_w(colbuf, m_blitter.spritenr << 4, 0xf0);
m_blitter.memory_accesses += 2;
}
m_blitter.memory_accesses++;
@@ -173,15 +138,14 @@ inline void lynx_state::lynx_plot_pixel(const int mode, const int16_t x, const i
{
if (color != 0x0f)
{
- back = lynx_read_ram(screen);
- lynx_write_ram(screen, (back & 0xf0) | color);
+ dram_byte_w(screen, color, 0x0f);
}
- if(m_blitter.sprite_collide && !(m_blitter.no_collide))
+ if (m_blitter.SPRITE_COLLIDE())
{
- back = lynx_read_ram(colbuf);
- lynx_write_ram(colbuf, (back & ~0x0f) | (m_blitter.spritenr));
- if ((back & 0x0f) > m_blitter.fred)
- m_blitter.fred = back >> 4;
+ back = BIT(dram_byte_r(colbuf), 0, 4);
+ if (back > m_blitter.fred)
+ m_blitter.fred = back;
+ dram_byte_w(colbuf, m_blitter.spritenr, 0x0f);
}
}
break;
@@ -193,31 +157,29 @@ inline void lynx_state::lynx_plot_pixel(const int mode, const int16_t x, const i
break;
if (!(x & 0x01)) /* Upper nibble */
{
- back = lynx_read_ram(screen);
- lynx_write_ram(screen, (back & 0x0f) | (color << 4));
+ dram_byte_w(screen, color << 4, 0xf0);
m_blitter.memory_accesses++;
- if (m_blitter.sprite_collide && (color != 0x0e) && !(m_blitter.no_collide))
+ if (m_blitter.SPRITE_COLLIDE() && (color != 0x0e))
{
- back = lynx_read_ram(colbuf);
- lynx_write_ram(colbuf, (back & ~0xf0) | (m_blitter.spritenr << 4));
- if ((back >> 4) > m_blitter.fred)
- m_blitter.fred = back >> 4;
+ back = BIT(dram_byte_r(colbuf), 4, 4);
+ if (back > m_blitter.fred)
+ m_blitter.fred = back;
+ dram_byte_w(colbuf, m_blitter.spritenr << 4, 0xf0);
m_blitter.memory_accesses += 2;
}
m_blitter.memory_accesses++;
}
else /* Lower nibble */
{
- back = lynx_read_ram(screen);
- lynx_write_ram(screen, (back & 0xf0) | color);
+ dram_byte_w(screen, color, 0x0f);
- if (m_blitter.sprite_collide && (color != 0x0e) && !(m_blitter.no_collide))
+ if (m_blitter.SPRITE_COLLIDE() && (color != 0x0e))
{
- back = lynx_read_ram(colbuf);
- lynx_write_ram(colbuf, (back & ~0x0f) | (m_blitter.spritenr));
- if ((back & 0x0f) > m_blitter.fred)
- m_blitter.fred = back >> 4;
+ back = BIT(dram_byte_r(colbuf), 0, 4);
+ if (back > m_blitter.fred)
+ m_blitter.fred = back;
+ dram_byte_w(colbuf, m_blitter.spritenr, 0x0f);
}
}
break;
@@ -232,16 +194,15 @@ inline void lynx_state::lynx_plot_pixel(const int mode, const int16_t x, const i
{
if (color != 0x0f)
{
- back = lynx_read_ram(screen);
- lynx_write_ram(screen, (back & 0x0f) | (color << 4));
+ dram_byte_w(screen, color << 4, 0xf0);
m_blitter.memory_accesses++;
}
- if (m_blitter.sprite_collide && (color != 0x0e) && !(m_blitter.no_collide))
+ if (m_blitter.SPRITE_COLLIDE() && (color != 0x0e))
{
- back = lynx_read_ram(colbuf);
- lynx_write_ram(colbuf, (back & ~0xf0) | (m_blitter.spritenr << 4));
- if ((back >> 4) > m_blitter.fred)
- m_blitter.fred = back >> 4;
+ back = BIT(dram_byte_r(colbuf), 4, 4);
+ if (back > m_blitter.fred)
+ m_blitter.fred = back;
+ dram_byte_w(colbuf, m_blitter.spritenr << 4, 0xf0);
m_blitter.memory_accesses += 2;
}
m_blitter.memory_accesses++;
@@ -250,15 +211,14 @@ inline void lynx_state::lynx_plot_pixel(const int mode, const int16_t x, const i
{
if (color != 0x0f)
{
- back = lynx_read_ram(screen);
- lynx_write_ram(screen, (back & 0xf0) | color);
+ dram_byte_w(screen, color, 0x0f);
}
- if (m_blitter.sprite_collide && (color != 0x0e) && !(m_blitter.no_collide))
+ if (m_blitter.SPRITE_COLLIDE() && (color != 0x0e))
{
- back = lynx_read_ram(colbuf);
- lynx_write_ram(colbuf, (back & ~0x0f) | (m_blitter.spritenr));
- if ((back & 0x0f) > m_blitter.fred)
- m_blitter.fred = back >> 4;
+ back = BIT(dram_byte_r(colbuf), 0, 4);
+ if (back > m_blitter.fred)
+ m_blitter.fred = back;
+ dram_byte_w(colbuf, m_blitter.spritenr, 0x0f);
}
}
break;
@@ -271,27 +231,23 @@ inline void lynx_state::lynx_plot_pixel(const int mode, const int16_t x, const i
and therefore not clear the collision buffer */
if (!(x & 0x01)) /* Upper nibble */
{
- back = lynx_read_ram(screen);
- lynx_write_ram(screen, (back & 0x0f) | (color << 4));
+ dram_byte_w(screen, color << 4, 0xf0);
m_blitter.memory_accesses++;
- if (m_blitter.sprite_collide && (color != 0x0e) && !(m_blitter.no_collide))
+ if (m_blitter.SPRITE_COLLIDE() && (color != 0x0e))
{
- back = lynx_read_ram(colbuf);
- lynx_write_ram(colbuf, (back & ~0xf0) | (m_blitter.spritenr << 4));
+ dram_byte_w(colbuf, m_blitter.spritenr << 4, 0xf0);
m_blitter.memory_accesses++;
}
m_blitter.memory_accesses++;
}
else /* Lower nibble */
{
- back = lynx_read_ram(screen);
- lynx_write_ram(screen, (back & 0xf0) | color);
+ dram_byte_w(screen, color, 0x0f);
- if (m_blitter.sprite_collide && (color != 0x0e) && !(m_blitter.no_collide))
+ if (m_blitter.SPRITE_COLLIDE() && (color != 0x0e))
{
- back = lynx_read_ram(colbuf);
- lynx_write_ram(colbuf, (back & ~0x0f) | (m_blitter.spritenr));
+ dram_byte_w(colbuf, m_blitter.spritenr, 0x0f);
}
}
break;
@@ -300,15 +256,13 @@ inline void lynx_state::lynx_plot_pixel(const int mode, const int16_t x, const i
/* This is a 'background' sprite with the exception that no activity occurs in the collision buffer */
if (!(x & 0x01)) /* Upper nibble */
{
- back = lynx_read_ram(screen);
- lynx_write_ram(screen, (back & 0x0f) | (color << 4));
+ dram_byte_w(screen, color << 4, 0xf0);
m_blitter.memory_accesses++;
m_blitter.memory_accesses++;
}
else /* Lower nibble */
{
- back = lynx_read_ram(screen);
- lynx_write_ram(screen, (back & 0xf0) | color);
+ dram_byte_w(screen, color, 0x0f);
}
break;
@@ -319,15 +273,13 @@ inline void lynx_state::lynx_plot_pixel(const int mode, const int16_t x, const i
break;
if (!(x & 0x01)) /* Upper nibble */
{
- back = lynx_read_ram(screen);
- lynx_write_ram(screen, (back & 0x0f) | (color << 4));
+ dram_byte_w(screen, color << 4, 0xf0);
m_blitter.memory_accesses++;
m_blitter.memory_accesses++;
}
else /* Lower nibble */
{
- back = lynx_read_ram(screen);
- lynx_write_ram(screen, (back & 0xf0) | color);
+ dram_byte_w(screen, color, 0x0f);
}
break;
@@ -340,60 +292,58 @@ inline void lynx_state::lynx_plot_pixel(const int mode, const int16_t x, const i
break;
if (!(x & 0x01)) /* Upper nibble */
{
- back = lynx_read_ram(screen);
- lynx_write_ram(screen, back^(color << 4));
+ dram_byte_w(screen, dram_byte_r(screen) ^ (color << 4), 0xf0);
m_blitter.memory_accesses += 2;
- if (m_blitter.sprite_collide && (color != 0x0e) && !(m_blitter.no_collide))
+ if (m_blitter.SPRITE_COLLIDE() && (color != 0x0e))
{
- back = lynx_read_ram(colbuf);
- lynx_write_ram(colbuf, (back & ~0xf0) | (m_blitter.spritenr << 4));
- if ((back >> 4) > m_blitter.fred)
- m_blitter.fred = back >> 4;
+ back = BIT(dram_byte_r(colbuf), 4, 4);
+ if (back > m_blitter.fred)
+ m_blitter.fred = back;
+ dram_byte_w(colbuf, m_blitter.spritenr << 4, 0xf0);
m_blitter.memory_accesses += 2;
}
m_blitter.memory_accesses++;
}
else /* Lower nibble */
{
- back = lynx_read_ram(screen);
- lynx_write_ram(screen, back^color);
- if (m_blitter.sprite_collide && (color != 0x0e) && !(m_blitter.no_collide))
+ dram_byte_w(screen, dram_byte_r(screen) ^ color, 0x0f);
+ if (m_blitter.SPRITE_COLLIDE() && (color != 0x0e))
{
- back = lynx_read_ram(colbuf);
- lynx_write_ram(colbuf, (back & ~0x0f) | (m_blitter.spritenr));
- if ((back & 0x0f) > m_blitter.fred)
- m_blitter.fred = back >> 4;
+ back = BIT(dram_byte_r(colbuf), 0, 4);
+ if (back > m_blitter.fred)
+ m_blitter.fred = back;
+ dram_byte_w(colbuf, m_blitter.spritenr, 0x0f);
}
}
break;
}
}
-void lynx_state::lynx_blit_do_work( const int y, const int xdir, const int bits_per_pixel, const int mask )
+void lynx_state::blit_do_work(const s16 y, const int xdir, const int bits_per_pixel, const u8 mask)
{
- int next_line_addr,i,j;
+ int i,j;
int xi, bits, color;
- uint16_t width_accum, buffer;
+ u16 buffer;
- next_line_addr = lynx_read_ram(m_blitter.bitmap); // offset to second sprite line
- width_accum = (xdir == 1) ? m_blitter.width_offset : 0;
+ const int next_line_addr = dram_byte_r(m_blitter.bitmap); // offset to second sprite line
+ u16 width_accum = (xdir == 1) ? m_blitter.width_offset : 0;
m_blitter.memory_accesses++;
- for (xi = m_blitter.x_pos - m_blitter.xoff, bits = 0, buffer = 0, j = 1; j < next_line_addr;j++)
+ for (xi = m_blitter.x_pos - m_blitter.xoff, bits = 0, buffer = 0, j = 1; j < next_line_addr; j++)
{
- buffer = (buffer << 8) | lynx_read_ram(m_blitter.bitmap + j);
+ buffer = (buffer << 8) | dram_byte_r(m_blitter.bitmap + j);
bits += 8; // current bits in buffer
m_blitter.memory_accesses++;
- for ( ; bits > bits_per_pixel; bits -= bits_per_pixel) // last data packet at end of scanline is not rendered (qix, blulght)
+ for (; bits > bits_per_pixel; bits -= bits_per_pixel) // last data packet at end of scanline is not rendered (qix, blulght)
{
color = m_blitter.color[(buffer >> (bits - bits_per_pixel)) & mask];
width_accum += m_blitter.width;
- for (i = 0; i < (width_accum>>8); i++, xi += xdir)
+ for (i = 0; i < (width_accum >> 8); i++, xi += xdir)
{
if ((xi >= 0) && (xi < 160))
{
- lynx_plot_pixel(m_blitter.mode, xi, y, color);
+ plot_pixel(xi, y, color);
}
}
width_accum &= 0xff;
@@ -401,25 +351,25 @@ void lynx_state::lynx_blit_do_work( const int y, const int xdir, const int bits_
}
}
-void lynx_state::lynx_blit_rle_do_work( const int16_t y, const int xdir, const int bits_per_pixel, const int mask )
+void lynx_state::blit_rle_do_work(const s16 y, const int xdir, const int bits_per_pixel, const u8 mask)
{
int i;
int xi;
int buffer, bits, j;
int literal_data, count, color;
- uint16_t width_accum;
- width_accum = (xdir == 1) ? m_blitter.width_offset : 0;
- for( bits = 0, j = 0, buffer = 0, xi = m_blitter.x_pos - m_blitter.xoff; ; ) /* through the rle entries */
+ const int next_line_addr = dram_byte_r(m_blitter.bitmap); // offset to second sprite line
+ u16 width_accum = (xdir == 1) ? m_blitter.width_offset : 0;
+ for (bits = 0, j = 0, buffer = 0, xi = m_blitter.x_pos - m_blitter.xoff; ;) /* through the rle entries */
{
if (bits < 5 + bits_per_pixel) /* under 7 bits no complete entry */
{
j++;
- if (j >= lynx_read_ram(m_blitter.bitmap))
+ if (j >= next_line_addr)
return;
bits += 8;
- buffer = (buffer << 8) | lynx_read_ram(m_blitter.bitmap + j);
+ buffer = (buffer << 8) | dram_byte_r(m_blitter.bitmap + j);
m_blitter.memory_accesses++;
}
@@ -430,25 +380,25 @@ void lynx_state::lynx_blit_rle_do_work( const int16_t y, const int xdir, const i
if (literal_data) /* count of different pixels */
{
- for ( ; count >= 0; count--)
+ for (; count >= 0; count--)
{
if (bits < bits_per_pixel)
{
j++;
- if (j >= lynx_read_ram(m_blitter.bitmap))
+ if (j >= next_line_addr)
return;
bits += 8;
- buffer = (buffer << 8) | lynx_read_ram(m_blitter.bitmap + j);
+ buffer = (buffer << 8) | dram_byte_r(m_blitter.bitmap + j);
m_blitter.memory_accesses++;
}
color = m_blitter.color[(buffer >> (bits - bits_per_pixel)) & mask];
bits -= bits_per_pixel;
width_accum += m_blitter.width;
- for (i = 0; i < (width_accum>>8); i++, xi += xdir)
+ for (i = 0; i < (width_accum >> 8); i++, xi += xdir)
{
if ((xi >= 0) && (xi < 160))
- lynx_plot_pixel(m_blitter.mode, xi, y, color);
+ plot_pixel(xi, y, color);
}
width_accum &= 0xff;
}
@@ -461,23 +411,23 @@ void lynx_state::lynx_blit_rle_do_work( const int16_t y, const int xdir, const i
if (bits < bits_per_pixel)
{
j++;
- if (j >= lynx_read_ram(m_blitter.bitmap))
+ if (j >= next_line_addr)
return;
bits += 8;
- buffer = (buffer << 8) | lynx_read_ram(m_blitter.bitmap + j);
+ buffer = (buffer << 8) | dram_byte_r(m_blitter.bitmap + j);
m_blitter.memory_accesses++;
}
color = m_blitter.color[(buffer >> (bits - bits_per_pixel)) & mask];
bits -= bits_per_pixel;
- for ( ; count>=0; count--)
+ for (; count >= 0; count--)
{
width_accum += m_blitter.width;
for (i = 0; i < (width_accum >> 8); i++, xi += xdir)
{
if ((xi >= 0) && (xi < 160))
- lynx_plot_pixel(m_blitter.mode, xi, y, color);
+ plot_pixel(xi, y, color);
}
width_accum &= 0xff;
}
@@ -485,17 +435,17 @@ void lynx_state::lynx_blit_rle_do_work( const int16_t y, const int xdir, const i
}
}
-void lynx_state::lynx_blit_lines()
+void lynx_state::blit_lines()
{
- static const int lynx_color_masks[4] = { 0x01, 0x03, 0x07, 0x0f };
- int16_t y;
+ static const u8 lynx_color_masks[4] = { 0x01, 0x03, 0x07, 0x0f };
+ s16 y;
int i;
int ydir = 0, xdir = 0;
int flip = 0;
m_blitter.everon = false;
- switch (m_blitter.spr_ctl1 & 0x03) /* Initial drawing direction */
+ switch (m_blitter.DRAW_ORIGIN()) /* Initial drawing direction */
{
case 0: // Down/Right (quadrant 0)
xdir = 1;
@@ -519,12 +469,12 @@ void lynx_state::lynx_blit_lines()
break;
}
- if (m_blitter.spr_ctl0 & 0x20) /* Horizontal Flip */
+ if (m_blitter.HFLIP()) /* Horizontal Flip */
{
xdir *= -1;
}
- if (m_blitter.spr_ctl0 & 0x10) /* Vertical Flip */
+ if (m_blitter.VFLIP()) /* Vertical Flip */
{
ydir *= -1;
}
@@ -533,7 +483,7 @@ void lynx_state::lynx_blit_lines()
m_blitter.height_accumulator = (ydir == 1) ? m_blitter.height_offset : 0x00;
// loop through lines, next line offset of zero indicates end of sprite
- for (y = m_blitter.y_pos - m_blitter.yoff; (i = lynx_read_ram(m_blitter.bitmap)); m_blitter.bitmap += i)
+ for (y = m_blitter.y_pos - m_blitter.yoff; (i = dram_byte_r(m_blitter.bitmap)); m_blitter.bitmap += i)
{
m_blitter.memory_accesses++;
@@ -565,48 +515,48 @@ void lynx_state::lynx_blit_lines()
if (y >= 0 && y < 102)
{
if (m_blitter.use_rle)
- lynx_blit_rle_do_work(y, xdir, m_blitter.line_color + 1, lynx_color_masks[m_blitter.line_color]);
+ blit_rle_do_work(y, xdir, m_blitter.line_color + 1, lynx_color_masks[m_blitter.line_color]);
else
- lynx_blit_do_work(y, xdir, m_blitter.line_color + 1, lynx_color_masks[m_blitter.line_color]);
+ blit_do_work(y, xdir, m_blitter.line_color + 1, lynx_color_masks[m_blitter.line_color]);
}
- m_blitter.width += (int16_t)m_blitter.stretch;
+ m_blitter.width += (s16)m_blitter.stretch;
if (m_blitter.vstretch) // doesn't seem to be used
{
- m_blitter.height += (int16_t)m_blitter.stretch;
+ m_blitter.height += (s16)m_blitter.stretch;
logerror("vertical stretch enabled");
}
m_blitter.tilt_accumulator += m_blitter.tilt;
- m_blitter.x_pos += (m_blitter.tilt_accumulator>>8);
+ m_blitter.x_pos += (m_blitter.tilt_accumulator >> 8);
m_blitter.tilt_accumulator &= 0xff;
}
m_blitter.height_accumulator &= 0xff;
}
}
-void lynx_state::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
+void lynx_state::device_timer(emu_timer &timer, device_timer_id id, int param)
{
switch (id)
{
case TIMER_BLITTER:
- lynx_blitter_timer(ptr, param);
+ blitter_timer(param);
break;
case TIMER_SHOT:
- lynx_timer_shot(ptr, param);
+ timer_shot(param);
break;
case TIMER_UART_LOOPBACK:
- lynx_uart_loopback_timer(ptr, param);
+ uart_loopback_timer(param);
break;
case TIMER_UART:
- lynx_uart_timer(ptr, param);
+ uart_timer(param);
break;
default:
throw emu_fatalerror("Unknown id in lynx_state::device_timer");
}
}
-TIMER_CALLBACK_MEMBER(lynx_state::lynx_blitter_timer)
+TIMER_CALLBACK_MEMBER(lynx_state::blitter_timer)
{
- m_blitter.busy=0; // blitter finished
+ m_blitter.busy = false; // blitter finished
m_maincpu->set_input_line(INPUT_LINE_HALT, CLEAR_LINE);
}
@@ -683,12 +633,10 @@ TIMER_CALLBACK_MEMBER(lynx_state::lynx_blitter_timer)
*/
-void lynx_state::lynx_blitter()
+void lynx_state::blitter()
{
- static const int lynx_colors[4] = { 2, 4, 8, 16 };
- uint8_t palette_offset;
- uint8_t coldep;
- int colors;
+ static const u8 lynx_colors[4] = { 2, 4, 8, 16 };
+ u8 palette_offset;
m_blitter.busy = 1; // blitter working
m_blitter.memory_accesses = 0;
@@ -701,69 +649,69 @@ void lynx_state::lynx_blitter()
m_blitter.tilt_accumulator = 0;
m_blitter.scb = m_blitter.scb_next; // current scb
- m_blitter.scb_next = lynx_read_ram(m_blitter.scb + SCB_SCBNEXT) | (lynx_read_ram(m_blitter.scb + SCB_SCBNEXT + 1) << 8); // next scb
- m_blitter.spr_ctl0 = lynx_read_ram(m_blitter.scb + SCB_SPRCTL0);
- m_blitter.spr_ctl1 = lynx_read_ram(m_blitter.scb + SCB_SPRCTL1);
- m_blitter.spr_coll = lynx_read_ram(m_blitter.scb + SCB_SPRCOLL);
+ m_blitter.scb_next = dram_word_r(m_blitter.scb + SCB_SCBNEXT); // next scb
+ m_blitter.spr_ctl0 = dram_byte_r(m_blitter.scb + SCB_SPRCTL0);
+ m_blitter.spr_ctl1 = dram_byte_r(m_blitter.scb + SCB_SPRCTL1);
+ m_blitter.spr_coll = dram_byte_r(m_blitter.scb + SCB_SPRCOLL);
m_blitter.memory_accesses += 5;
- if(!(m_blitter.spr_ctl1 & 0x04)) // sprite will be processed (if sprite is skipped first 5 bytes are still copied to suzy)
+ if (!(m_blitter.SKIP_SPRITE())) // sprite will be processed (if sprite is skipped first 5 bytes are still copied to suzy)
{
- m_blitter.bitmap = lynx_read_ram(m_blitter.scb + SCB_SPRDLINE) | (lynx_read_ram(m_blitter.scb + SCB_SPRDLINE + 1) << 8);
- m_blitter.x_pos = lynx_read_ram(m_blitter.scb + SCB_HPOSSTRT) | (lynx_read_ram(m_blitter.scb + SCB_HPOSSTRT + 1) << 8);
- m_blitter.y_pos = lynx_read_ram(m_blitter.scb + SCB_VPOSSTRT) | (lynx_read_ram(m_blitter.scb + SCB_VPOSSTRT + 1) << 8);
+ m_blitter.bitmap = dram_word_r(m_blitter.scb + SCB_SPRDLINE);
+ m_blitter.x_pos = dram_word_r(m_blitter.scb + SCB_HPOSSTRT);
+ m_blitter.y_pos = dram_word_r(m_blitter.scb + SCB_VPOSSTRT);
m_blitter.memory_accesses += 6;
- switch(m_blitter.spr_ctl1 & 0x30) // reload sprite scaling
+ switch (m_blitter.RELOAD_SCALE()) // reload sprite scaling
{
- case 0x30: // width, height, tilt, stretch
- m_blitter.tilt = lynx_read_ram(m_blitter.scb + SCB_TILT) | (lynx_read_ram(m_blitter.scb + SCB_TILT + 1) << 8);
- m_blitter.memory_accesses+=2;
+ case 0b11: // width, height, tilt, stretch
+ m_blitter.tilt = dram_word_r(m_blitter.scb + SCB_TILT);
+ m_blitter.memory_accesses += 2;
[[fallthrough]];
- case 0x20: // width, height, stretch
- m_blitter.stretch = lynx_read_ram(m_blitter.scb + SCB_STRETCH) | (lynx_read_ram(m_blitter.scb + SCB_STRETCH + 1) << 8);
- m_blitter.memory_accesses+=2;
+ case 0b10: // width, height, stretch
+ m_blitter.stretch = dram_word_r(m_blitter.scb + SCB_STRETCH);
+ m_blitter.memory_accesses += 2;
[[fallthrough]];
- case 0x10: // width, height
- m_blitter.width = lynx_read_ram(m_blitter.scb + SCB_SPRHSIZ) | (lynx_read_ram(m_blitter.scb + SCB_SPRHSIZ + 1) << 8);
- m_blitter.height = lynx_read_ram(m_blitter.scb + SCB_SPRVSIZ) | (lynx_read_ram(m_blitter.scb + SCB_SPRVSIZ + 1) << 8);
- m_blitter.memory_accesses+=4;
+ case 0b01: // width, height
+ m_blitter.width = dram_word_r(m_blitter.scb + SCB_SPRHSIZ);
+ m_blitter.height = dram_word_r(m_blitter.scb + SCB_SPRVSIZ);
+ m_blitter.memory_accesses += 4;
}
- if(!(m_blitter.spr_ctl1 & 0x08)) // reload palette
+ if (!(m_blitter.REUSE_PALETTE())) // reload palette
{
- if (m_blitter.spr_ctl1 & 0x30)
- palette_offset = 0x0b + 2*(((m_blitter.spr_ctl1 & 0x30)>>4) + 1); // palette data offset depends on width, height, etc. reloading
+ if (m_blitter.RELOAD_SCALE() != 0)
+ palette_offset = 0x0b + 2 * (m_blitter.RELOAD_SCALE() + 1); // palette data offset depends on width, height, etc. reloading
else
palette_offset = 0x0b;
- colors = lynx_colors[m_blitter.spr_ctl0 >> 6];
+ u8 colors = lynx_colors[m_blitter.BPP()];
for (int i = 0; i < colors / 2; i++)
{
- m_blitter.color[i * 2] = lynx_read_ram(m_blitter.scb + palette_offset + i) >> 4;
- m_blitter.color[i * 2 + 1 ] = lynx_read_ram(m_blitter.scb + palette_offset + i) & 0x0f;
+ m_blitter.color[i * 2] = dram_byte_r(m_blitter.scb + palette_offset + i) >> 4;
+ m_blitter.color[i * 2 + 1] = dram_byte_r(m_blitter.scb + palette_offset + i) & 0x0f;
m_blitter.memory_accesses++;
}
}
- }
+ }
- if (!(m_blitter.spr_ctl1 & 0x04)) // if 0, we skip this sprite
+ if (!(m_blitter.SKIP_SPRITE())) // if 0, we skip this sprite
{
- m_blitter.colpos = m_blitter.scb + (m_suzy.data[COLLOFFL] | (m_suzy.data[COLLOFFH]<<8));
- m_blitter.mode = m_blitter.spr_ctl0 & 0x07;
- m_blitter.use_rle = m_blitter.spr_ctl1 & 0x80 ? 0 : 1;
- m_blitter.line_color = (m_blitter.spr_ctl0 >> 6) & 0x03;
+ m_blitter.colpos = m_blitter.scb + (m_suzy.data[COLLOFFL] | (m_suzy.data[COLLOFFH] << 8));
+ m_blitter.mode = m_blitter.SPRITE_TYPE();
+ m_blitter.use_rle = !(m_blitter.RLE());
+ m_blitter.line_color = m_blitter.BPP();
- m_blitter.sprite_collide = !(m_blitter.spr_coll & 0x20);
- m_blitter.spritenr = m_blitter.spr_coll & 0x0f;
+ m_blitter.sprite_collide = !(m_blitter.SPRITE_COLLEN());
+ m_blitter.spritenr = m_blitter.SPRITE_COLNUM();
m_blitter.fred = 0;
/* Draw Sprite */
- lynx_blit_lines();
+ blit_lines();
- if (m_blitter.sprite_collide && !(m_blitter.no_collide))
+ if (m_blitter.SPRITE_COLLIDE())
{
switch (m_blitter.mode)
{
@@ -772,20 +720,13 @@ void lynx_state::lynx_blitter()
case NORMAL_SPRITE:
case XOR_SPRITE:
case SHADOW:
- lynx_write_ram(m_blitter.colpos, m_blitter.fred);
+ dram_byte_w(m_blitter.colpos, m_blitter.fred);
break;
}
}
- if (m_suzy.data[SPRGO] & 0x04) // Everon enabled
- {
- coldep = lynx_read_ram(m_blitter.colpos);
- if (!m_blitter.everon)
- coldep |= 0x80;
- else
- coldep &= 0x7f;
- lynx_write_ram(m_blitter.colpos, coldep);
- }
+ if (m_suzy.EVER_ON()) // Everon enabled
+ dram_byte_w(m_blitter.colpos, m_blitter.everon ? 0x00 : 0x80, 0x80);
}
}
@@ -810,11 +751,11 @@ if you just load the lower byte after a multiply by zero.
- in divide, the remainder will have 2 possible errors, depending on its actual value (no further
notes on these errors available) */
-void lynx_state::lynx_divide()
+void lynx_state::suzy_divide()
{
- uint32_t left;
- uint16_t right;
- uint32_t res, mod;
+ u32 left;
+ u16 right;
+ u32 res, mod;
/*
Hardware divide:
EFGH
@@ -851,10 +792,10 @@ void lynx_state::lynx_divide()
m_suzy.data[MATH_J] = 0;
}
-void lynx_state::lynx_multiply()
+void lynx_state::suzy_multiply()
{
- uint16_t left, right;
- uint32_t res, accu;
+ u16 left, right;
+ u32 res, accu;
/*
Hardware multiply:
AB
@@ -896,86 +837,87 @@ void lynx_state::lynx_multiply()
}
}
-uint8_t lynx_state::suzy_read(offs_t offset)
+u8 lynx_state::suzy_read(offs_t offset)
{
- uint8_t value = 0, input;
+ u8 value = 0, input;
switch (offset)
{
case TILTACUML:
return m_blitter.tilt_accumulator & 0xff;
case TILTACUMH:
- return m_blitter.tilt_accumulator>>8;
+ return m_blitter.tilt_accumulator >> 8;
case HOFFL:
return m_blitter.xoff & 0xff;
case HOFFH:
- return m_blitter.xoff>>8;
+ return m_blitter.xoff >> 8;
case VOFFL:
return m_blitter.yoff & 0xff;
case VOFFH:
- return m_blitter.yoff>>8;
+ return m_blitter.yoff >> 8;
case VIDBASL:
return m_blitter.screen & 0xff;
case VIDBASH:
- return m_blitter.screen>>8;
+ return m_blitter.screen >> 8;
case COLLBASL:
return m_blitter.colbuf & 0xff;
case COLLBASH:
- return m_blitter.colbuf>>8;
+ return m_blitter.colbuf >> 8;
case SCBNEXTL:
return m_blitter.scb_next & 0xff;
case SCBNEXTH:
- return m_blitter.scb_next>>8;
+ return m_blitter.scb_next >> 8;
case SPRDLINEL:
return m_blitter.bitmap & 0xff;
case SPRDLINEH:
- return m_blitter.bitmap>>8;
+ return m_blitter.bitmap >> 8;
case HPOSSTRTL:
return m_blitter.x_pos & 0xff;
case HPOSSTRTH:
- return m_blitter.x_pos>>8;
+ return m_blitter.x_pos >> 8;
case VPOSSTRTL:
return m_blitter.y_pos & 0xff;
case VPOSSTRTH:
- return m_blitter.y_pos>>8;
+ return m_blitter.y_pos >> 8;
case SPRHSIZL:
return m_blitter.width & 0xff;
case SPRHSIZH:
- return m_blitter.width>>8;
+ return m_blitter.width >> 8;
case SPRVSIZL:
return m_blitter.height & 0xff;
case SPRVSIZH:
- return m_blitter.height>>8;
+ return m_blitter.height >> 8;
case STRETCHL:
return m_blitter.stretch & 0xff;
case STRETCHH:
- return m_blitter.stretch>>8;
+ return m_blitter.stretch >> 8;
case TILTL:
return m_blitter.tilt & 0xff;
case TILTH:
- return m_blitter.tilt>>8;
+ return m_blitter.tilt >> 8;
// case SPRDOFFL:
// case SPRVPOSL:
// case COLLOFFL:
case VSIZACUML:
return m_blitter.height_accumulator & 0xff;
case VSIZACUMH:
- return m_blitter.height_accumulator>>8;
+ return m_blitter.height_accumulator >> 8;
case HSIZOFFL:
return m_blitter.width_offset & 0xff;
case HSIZOFFH:
- return m_blitter.width_offset>>8;
+ return m_blitter.width_offset >> 8;
case VSIZOFFL:
return m_blitter.height_offset & 0xff;
case VSIZOFFH:
- return m_blitter.height_offset>>8;
+ return m_blitter.height_offset >> 8;
case SCBADRL:
return m_blitter.scb & 0xff;
case SCBADRH:
- return m_blitter.scb>>8;
+ return m_blitter.scb >> 8;
//case PROCADRL:
- case SUZYHREV:
+ case SUZYHREV: // Suzy hardware revision
return 0x01; // must not be 0 for correct power up
+ //case 0x89: // SUZYSREV Suzy software revision
case SPRSYS:
// math busy, last carry, unsafe access, and stop on current sprite bits not implemented.
if (m_suzy.accumulate_overflow)
@@ -988,7 +930,7 @@ uint8_t lynx_state::suzy_read(offs_t offset)
value |= 0x01;
break;
case JOYSTICK:
- input = ioport("JOY")->read();
+ input = m_joy_io->read();
switch (m_rotate)
{
case 1:
@@ -1020,16 +962,17 @@ uint8_t lynx_state::suzy_read(offs_t offset)
value = input;
break;
case SWITCHES:
- value = ioport("PAUSE")->read();
+ value = m_pause_io->read();
break;
- case RCART:
+ case RCART: // connected to CE0 in cartridge slot
if (m_cart->exists())
- value = m_cart->read_rom((m_suzy.high * m_granularity) + m_suzy.low);
+ value = m_cart->read_rom(get_cart_addr());
else
value = 0;
- m_suzy.low = (m_suzy.low + 1) & (m_granularity - 1);
+ if (!machine().side_effects_disabled())
+ m_cart_addr_counter = (m_cart_addr_counter + 1) & (m_granularity - 1); // 4040 clock
break;
- //case RCART_BANK1: /* we need bank 1 emulation!!! */
+ //case RCART_BANK1: // connected to CE1 in cartridge slot /* we need bank 1 emulation!!! */
case SPRCTL0:
case SPRCTL1:
case SPRCOLL:
@@ -1046,7 +989,7 @@ uint8_t lynx_state::suzy_read(offs_t offset)
return value;
}
-void lynx_state::suzy_write(offs_t offset, uint8_t data)
+void lynx_state::suzy_write(offs_t offset, u8 data)
{
m_suzy.data[offset] = data;
//logerror("suzy write %.2x %.2x\n",offset,data);
@@ -1058,7 +1001,7 @@ void lynx_state::suzy_write(offs_t offset, uint8_t data)
if ((offset < 0x80) && !(offset & 0x01))
m_suzy.data[offset + 1] = 0;
- switch(offset)
+ switch (offset)
{
//case TMPADRL:
//case TMPADRH:
@@ -1067,91 +1010,91 @@ void lynx_state::suzy_write(offs_t offset, uint8_t data)
break;
case TILTACUMH:
m_blitter.tilt_accumulator &= 0xff;
- m_blitter.tilt_accumulator |= data<<8;
+ m_blitter.tilt_accumulator |= data << 8;
break;
case HOFFL:
m_blitter.xoff = data;
break;
case HOFFH:
m_blitter.xoff &= 0xff;
- m_blitter.xoff |= data<<8;
+ m_blitter.xoff |= data << 8;
break;
case VOFFL:
m_blitter.yoff = data;
break;
case VOFFH:
m_blitter.yoff &= 0xff;
- m_blitter.yoff |= data<<8;
+ m_blitter.yoff |= data << 8;
break;
case VIDBASL:
m_blitter.screen = data;
break;
case VIDBASH:
m_blitter.screen &= 0xff;
- m_blitter.screen |= data<<8;
+ m_blitter.screen |= data << 8;
break;
case COLLBASL:
m_blitter.colbuf = data;
break;
case COLLBASH:
m_blitter.colbuf &= 0xff;
- m_blitter.colbuf |= data<<8;
+ m_blitter.colbuf |= data << 8;
break;
case SCBNEXTL:
m_blitter.scb_next = data;
break;
case SCBNEXTH:
m_blitter.scb_next &= 0xff;
- m_blitter.scb_next |= data<<8;
+ m_blitter.scb_next |= data << 8;
break;
case SPRDLINEL:
m_blitter.bitmap = data;
break;
case SPRDLINEH:
m_blitter.bitmap &= 0xff;
- m_blitter.bitmap |= data<<8;
+ m_blitter.bitmap |= data << 8;
break;
case HPOSSTRTL:
m_blitter.x_pos = data;
[[fallthrough]]; // FIXME: really?
case HPOSSTRTH:
m_blitter.x_pos &= 0xff;
- m_blitter.x_pos |= data<<8;
+ m_blitter.x_pos |= data << 8;
[[fallthrough]]; // FIXME: really?
case VPOSSTRTL:
m_blitter.y_pos = data;
[[fallthrough]]; // FIXME: really?
case VPOSSTRTH:
m_blitter.y_pos &= 0xff;
- m_blitter.y_pos |= data<<8;
+ m_blitter.y_pos |= data << 8;
[[fallthrough]]; // FIXME: really?
case SPRHSIZL:
m_blitter.width = data;
break;
case SPRHSIZH:
m_blitter.width &= 0xff;
- m_blitter.width |= data<<8;
+ m_blitter.width |= data << 8;
break;
case SPRVSIZL:
m_blitter.height = data;
break;
case SPRVSIZH:
m_blitter.height &= 0xff;
- m_blitter.height |= data<<8;
+ m_blitter.height |= data << 8;
break;
case STRETCHL:
m_blitter.stretch = data;
break;
case STRETCHH:
m_blitter.stretch &= 0xff;
- m_blitter.stretch |= data<<8;
+ m_blitter.stretch |= data << 8;
break;
case TILTL:
m_blitter.tilt = data;
break;
case TILTH:
m_blitter.tilt &= 0xff;
- m_blitter.tilt |= data<<8;
+ m_blitter.tilt |= data << 8;
break;
// case SPRDOFFL:
// case SPRVPOSL:
@@ -1161,28 +1104,28 @@ void lynx_state::suzy_write(offs_t offset, uint8_t data)
break;
case VSIZACUMH:
m_blitter.height_accumulator &= 0xff;
- m_blitter.height_accumulator |= data<<8;
+ m_blitter.height_accumulator |= data << 8;
break;
case HSIZOFFL:
m_blitter.width_offset = data;
break;
case HSIZOFFH:
m_blitter.width_offset &= 0xff;
- m_blitter.width_offset |= data<<8;
+ m_blitter.width_offset |= data << 8;
break;
case VSIZOFFL:
m_blitter.height_offset = data;
break;
case VSIZOFFH:
m_blitter.height_offset &= 0xff;
- m_blitter.height_offset |= data<<8;
+ m_blitter.height_offset |= data << 8;
break;
case SCBADRL:
m_blitter.scb = data;
break;
case SCBADRH:
m_blitter.scb &= 0xff;
- m_blitter.scb |= data<<8;
+ m_blitter.scb |= data << 8;
break;
//case PROCADRL:
@@ -1195,12 +1138,12 @@ void lynx_state::suzy_write(offs_t offset, uint8_t data)
to an unsigned one */
if (m_suzy.signed_math)
{
- uint16_t factor, temp;
+ u16 factor, temp;
factor = m_suzy.data[MATH_D] | (m_suzy.data[MATH_C] << 8);
if ((factor - 1) & 0x8000) /* here we use -1 to cover the math bugs on the sign of 0 and 0x8000 */
{
temp = (factor ^ 0xffff) + 1;
- m_sign_CD = - 1;
+ m_sign_CD = -1;
m_suzy.data[MATH_D] = temp & 0xff;
m_suzy.data[MATH_C] = temp >> 8;
}
@@ -1222,23 +1165,23 @@ void lynx_state::suzy_write(offs_t offset, uint8_t data)
case MATH_A:
if (m_suzy.signed_math)
{
- uint16_t factor, temp;
+ u16 factor, temp;
factor = m_suzy.data[MATH_B] | (m_suzy.data[MATH_A] << 8);
if ((factor - 1) & 0x8000) /* here we use -1 to cover the math bugs on the sign of 0 and 0x8000 */
{
temp = (factor ^ 0xffff) + 1;
- m_sign_AB = - 1;
+ m_sign_AB = -1;
m_suzy.data[MATH_B] = temp & 0xff;
m_suzy.data[MATH_A] = temp >> 8;
}
else
m_sign_AB = 1;
}
- lynx_multiply();
+ suzy_multiply();
break;
/* Writing to E will start a 16 bit divide */
case MATH_E:
- lynx_divide();
+ suzy_divide();
break;
case SPRCTL0:
m_blitter.spr_ctl0 = data;
@@ -1253,19 +1196,19 @@ void lynx_state::suzy_write(offs_t offset, uint8_t data)
logerror("write to SUSYBUSEN %x \n", data);
break;
case SPRSYS:
- m_suzy.signed_math = (data & 0x80) ? 1:0;
- m_suzy.accumulate = (data & 0x40) ? 1:0;
- m_blitter.no_collide = (data & 0x20) ? 1:0;
- m_blitter.vstretch = (data & 0x10) ? 1:0;
- m_blitter.lefthanded = (data & 0x08) ? 1:0;
- // unsafe access clear and sprite engine stop request are not enabled
- if (data & 0x02) logerror("sprite engine stop request\n");
- break;
+ m_suzy.signed_math = BIT(data, 7);
+ m_suzy.accumulate = BIT(data, 6);
+ m_blitter.no_collide = BIT(data, 5);
+ m_blitter.vstretch = BIT(data, 4);
+ m_blitter.lefthanded = BIT(data, 3);
+ // unsafe access clear and sprite engine stop request are not enabled
+ if (BIT(data, 1)) logerror("sprite engine stop request\n");
+ break;
case SPRGO:
- if ((data & 0x01) && m_suzy.data[SUZYBUSEN])
+ if (m_suzy.SPRITE_GO() && m_suzy.data[SUZYBUSEN])
{
//m_blitter.time = machine().time();
- lynx_blitter();
+ blitter();
}
break;
case JOYSTICK:
@@ -1295,6 +1238,20 @@ void lynx_state::suzy_write(offs_t offset, uint8_t data)
*/
+void lynx_state::interrupt_set(u8 line)
+{
+ m_mikey.interrupt |= (1 << line);
+ m_maincpu->set_input_line(INPUT_LINE_HALT, CLEAR_LINE);
+ interrupt_update();
+}
+
+
+void lynx_state::interrupt_update()
+{
+ m_maincpu->set_input_line(M65SC02_IRQ_LINE, (m_mikey.interrupt == 0) ? CLEAR_LINE : ASSERT_LINE);
+}
+
+
/*
DISPCTL EQU $FD92 ; set to $D by INITMIKEY
@@ -1305,33 +1262,32 @@ DISPCTL EQU $FD92 ; set to $D by INITMIKEY
; B0 1 EQU video DMA enabled
*/
-void lynx_state::lynx_draw_line()
+void lynx_state::draw_line()
{
pen_t const *const pen = m_palette->pens();
- uint16_t j; // clipping needed!
// calculate y: first three lines are vblank,
- int const y = 101-m_timer[2].counter;
+ int const y = 101 - m_timer[2].counter;
// Documentation states lower two bits of buffer address are ignored (thus 0xfffc mask)
- j = (m_mikey.disp_addr & 0xfffc) + y * 160 / 2;
+ u16 j = (m_mikey.disp_addr & 0xfffc) + y * 160 / 2; // clipping needed!
if (m_mikey.data[0x92] & 0x02)
{
j -= 160 * 102 / 2 - 1;
- uint32_t *const line = &m_bitmap_temp.pix(102 - 1 - y);
+ u32 *const line = &m_bitmap_temp.pix(102 - 1 - y);
for (int x = 160 - 2; x >= 0; j++, x -= 2)
{
- uint8_t const byte = lynx_read_ram(j);
+ u8 const byte = dram_byte_r(j);
line[x + 1] = pen[(byte >> 4) & 0x0f];
line[x + 0] = pen[(byte >> 0) & 0x0f];
}
}
else
{
- uint32_t *const line = &m_bitmap_temp.pix(y);
+ u32 *const line = &m_bitmap_temp.pix(y);
for (int x = 0; x < 160; j++, x += 2)
{
- uint8_t const byte = lynx_read_ram(j);
+ u8 const byte = dram_byte_r(j);
line[x + 0] = pen[(byte >> 4) & 0x0f];
line[x + 1] = pen[(byte >> 0) & 0x0f];
}
@@ -1383,7 +1339,7 @@ TIM_BORROWOUT EQU %00000001
-void lynx_state::lynx_timer_init(int which)
+void lynx_state::timer_init(int which)
{
memset(&m_timer[which], 0, sizeof(LYNX_TIMER));
m_timer[which].timer = timer_alloc(TIMER_SHOT);
@@ -1395,13 +1351,11 @@ void lynx_state::lynx_timer_init(int which)
save_item(NAME(m_timer[which].timer_active), which);
}
-void lynx_state::lynx_timer_signal_irq(int which)
+void lynx_state::timer_signal_irq(int which)
{
- if ((m_timer[which].cntrl1 & 0x80) && (which != 4)) // if interrupts are enabled and timer != 4
+ if ((m_timer[which].int_en()) && (which != 4)) // if interrupts are enabled and timer != 4
{
- m_mikey.data[0x81] |= (1 << which); // set interrupt poll register
- m_maincpu->set_input_line(INPUT_LINE_HALT, CLEAR_LINE);
- m_maincpu->set_input_line(M65SC02_IRQ_LINE, ASSERT_LINE);
+ interrupt_set(which); // set interrupt poll register
}
switch (which) // count down linked timers
{
@@ -1411,32 +1365,34 @@ void lynx_state::lynx_timer_signal_irq(int which)
case 104:
break;
case 103:
- m_mikey.vb_rest = 1;
+ m_mikey.vb_rest = true;
break;
case 102:
m_mikey.disp_addr = m_mikey.data[0x94] | (m_mikey.data[0x95] << 8);
break;
case 101:
- m_mikey.vb_rest = 0;
- lynx_draw_line();
+ m_mikey.vb_rest = false;
+ draw_line();
break;
default:
- lynx_draw_line();
+ draw_line();
+ break;
}
- lynx_timer_count_down(2);
+ timer_count_down(2);
break;
case 2:
copybitmap(m_bitmap, m_bitmap_temp, 0, 0, 0, 0, m_screen->cliprect());
- lynx_timer_count_down(4);
+ update_screen_timing();
+ timer_count_down(4);
break;
case 1:
- lynx_timer_count_down(3);
+ timer_count_down(3);
break;
case 3:
- lynx_timer_count_down(5);
+ timer_count_down(5);
break;
case 5:
- lynx_timer_count_down(7);
+ timer_count_down(7);
break;
case 7:
m_sound->count_down(0);
@@ -1444,9 +1400,9 @@ void lynx_state::lynx_timer_signal_irq(int which)
}
}
-void lynx_state::lynx_timer_count_down(int which)
+void lynx_state::timer_count_down(int which)
{
- if ((m_timer[which].cntrl1 & 0x0f) == 0x0f) // count and linking enabled
+ if (m_timer[which].count_en() && m_timer[which].linked()) // count and linking enabled
{
if (m_timer[which].counter > 0)
{
@@ -1456,34 +1412,34 @@ void lynx_state::lynx_timer_count_down(int which)
}
if (m_timer[which].counter == 0)
{
- if (m_timer[which].cntrl2 & 0x01) // borrow out
+ if (m_timer[which].borrow_out()) // borrow out
{
- lynx_timer_signal_irq(which);
- if (m_timer[which].cntrl1 & 0x10) // if reload enabled
+ timer_signal_irq(which);
+ if (m_timer[which].reload_en()) // if reload enabled
{
m_timer[which].counter = m_timer[which].bakup;
}
else
{
- m_timer[which].cntrl2 |= 8; // set timer done
+ m_timer[which].set_timer_done(true); // set timer done
}
- m_timer[which].cntrl2 &= ~0x01; // clear borrow out
+ m_timer[which].set_borrow_out(false); // clear borrow out
}
else
- m_timer[which].cntrl2 |= 0x01; // set borrow out
+ m_timer[which].set_borrow_out(true); // set borrow out
return;
}
}
else
{
//m_timer[which].borrow_in = 0;
- m_timer[which].cntrl2 &= ~0x01;
+ m_timer[which].set_borrow_out(false);
}
}
-uint32_t lynx_state::lynx_time_factor(int val)
+u32 lynx_state::time_factor(int val)
{
- switch(val)
+ switch (val)
{
case 0: return 1000000;
case 1: return 500000;
@@ -1496,24 +1452,24 @@ uint32_t lynx_state::lynx_time_factor(int val)
}
}
-TIMER_CALLBACK_MEMBER(lynx_state::lynx_timer_shot)
+TIMER_CALLBACK_MEMBER(lynx_state::timer_shot)
{
- lynx_timer_signal_irq(param);
- if (!(m_timer[param].cntrl1 & 0x10)) // if reload not enabled
+ timer_signal_irq(param);
+ if (!(m_timer[param].reload_en())) // if reload not enabled
{
- m_timer[param].timer_active = 0;
- m_timer[param].cntrl2 |= 8; // set timer done
+ m_timer[param].timer_active = false;
+ m_timer[param].set_timer_done(true); // set timer done
}
else
{
- attotime t = (attotime::from_hz(lynx_time_factor(m_timer[param].cntrl1 & 0x07)) * (m_timer[param].bakup + 1));
+ attotime t = (attotime::from_hz(time_factor(m_timer[param].timer_clock())) * (m_timer[param].bakup + 1));
m_timer[param].timer->adjust(t, param);
}
}
-uint8_t lynx_state::lynx_timer_read(int which, int offset)
+u8 lynx_state::timer_read(int which, int offset)
{
- uint8_t value = 0;
+ u8 value = 0;
switch (offset)
{
@@ -1524,15 +1480,15 @@ uint8_t lynx_state::lynx_timer_read(int which, int offset)
value = m_timer[which].cntrl1;
break;
case 2:
- if ((m_timer[which].cntrl1 & 0x07) == 0x07) // linked timer
+ if (m_timer[which].linked()) // linked timer
{
value = m_timer[which].counter;
}
else
{
- if ( m_timer[which].timer_active )
+ if (m_timer[which].timer_active)
{
- value = (uint8_t) (m_timer[which].timer->remaining().as_ticks(1000000>>(m_timer[which].cntrl1 & 0x07)));
+ value = u8(m_timer[which].timer->remaining().as_ticks(1000000>>(m_timer[which].timer_clock())));
value -= value ? 1 : 0;
}
}
@@ -1546,14 +1502,14 @@ uint8_t lynx_state::lynx_timer_read(int which, int offset)
return value;
}
-void lynx_state::lynx_timer_write(int which, int offset, uint8_t data)
+void lynx_state::timer_write(int which, int offset, u8 data)
{
//logerror("timer %d write %x %.2x\n", which, offset, data);
attotime t;
- if ( m_timer[which].timer_active && ((m_timer[which].cntrl1 & 0x07) != 0x07))
+ if (m_timer[which].timer_active && (!(m_timer[which].linked())))
{
- m_timer[which].counter = (uint8_t) (m_timer[which].timer->remaining().as_ticks(1000000>>(m_timer[which].cntrl1 & 0x07)));
+ m_timer[which].counter = u8(m_timer[which].timer->remaining().as_ticks(1000000>>(m_timer[which].timer_clock())));
m_timer[which].counter -= (m_timer[which].counter) ? 1 : 0;
}
@@ -1565,7 +1521,7 @@ void lynx_state::lynx_timer_write(int which, int offset, uint8_t data)
case 1:
m_timer[which].cntrl1 = data;
if (data & 0x40) // reset timer done
- m_timer[which].cntrl2 &= ~0x08;
+ m_timer[which].set_timer_done(false);
break;
case 2:
m_timer[which].counter = data;
@@ -1576,22 +1532,42 @@ void lynx_state::lynx_timer_write(int which, int offset, uint8_t data)
}
/* Update timers */
- //if ( offset < 3 )
+ //if (offset < 3)
//{
m_timer[which].timer->reset();
- m_timer[which].timer_active = 0;
- if ((m_timer[which].cntrl1 & 0x08) && !(m_timer[which].cntrl2 & 0x08)) // if enable count
+ m_timer[which].timer_active = false;
+ if ((m_timer[which].count_en()) && !(m_timer[which].timer_done())) // if enable count
{
- if ((m_timer[which].cntrl1 & 0x07) != 0x07) // if not set to link mode
+ if (!(m_timer[which].linked())) // if not set to link mode
{
- t = (attotime::from_hz(lynx_time_factor(m_timer[which].cntrl1 & 0x07)) * (m_timer[which].counter + 1));
+ t = (attotime::from_hz(time_factor(m_timer[which].timer_clock())) * (m_timer[which].counter + 1));
m_timer[which].timer->adjust(t, which);
- m_timer[which].timer_active = 1;
+ m_timer[which].timer_active = true;
}
}
//}
}
+void lynx_state::update_screen_timing()
+{
+ // variable framerate handling, but needs to verification for screen size handling
+ if ((!(m_timer[0].linked()))
+ && ((m_timer[0].cntrl1 & 0x18) == 0x18)
+ && (m_timer[0].bakup != 0)
+ && ((m_timer[2].cntrl1 & 0x1f) == 0x1f)
+ && (m_timer[2].bakup != 0))
+ {
+ if ((m_pixclock != (m_timer[0].timer_clock())) || (m_hcount != m_timer[0].bakup) || (m_vcount != m_timer[2].bakup))
+ {
+ m_pixclock = time_factor(m_timer[0].timer_clock());
+ m_hcount = m_timer[0].bakup; // TODO: multiplied internally?
+ m_vcount = m_timer[2].bakup;
+ attotime framerate = attotime::from_hz(m_pixclock) * (m_hcount + 1) * (m_vcount + 1);
+ m_screen->configure(m_screen->width(), m_screen->height(), m_screen->visible_area(), framerate.attoseconds());
+ }
+ }
+}
+
/****************************************
@@ -1600,17 +1576,17 @@ void lynx_state::lynx_timer_write(int which, int offset, uint8_t data)
****************************************/
-void lynx_state::lynx_uart_reset()
+void lynx_state::uart_reset()
{
memset(&m_uart, 0, sizeof(m_uart));
}
-TIMER_CALLBACK_MEMBER(lynx_state::lynx_uart_loopback_timer)
+TIMER_CALLBACK_MEMBER(lynx_state::uart_loopback_timer)
{
m_uart.received = false;
}
-TIMER_CALLBACK_MEMBER(lynx_state::lynx_uart_timer)
+TIMER_CALLBACK_MEMBER(lynx_state::uart_timer)
{
if (m_uart.buffer_loaded)
{
@@ -1624,34 +1600,35 @@ TIMER_CALLBACK_MEMBER(lynx_state::lynx_uart_timer)
m_uart.received = true;
m_uart.data_received = m_uart.data_to_send;
timer_set(attotime::from_usec(11*16), TIMER_UART_LOOPBACK);
- if (m_uart.serctl & 0x40)
+ if (m_uart.RXINTEN())
{
- m_mikey.data[0x81] |= 0x10;
- m_maincpu->set_input_line(INPUT_LINE_HALT, CLEAR_LINE);
- m_maincpu->set_input_line(M65SC02_IRQ_LINE, ASSERT_LINE);
+ interrupt_set(4);
}
}
- if (m_uart.serctl & 0x80)
+ if (m_uart.TXINTEN())
{
- m_mikey.data[0x81] |= 0x10;
- m_maincpu->set_input_line(INPUT_LINE_HALT, CLEAR_LINE);
- m_maincpu->set_input_line(M65SC02_IRQ_LINE, ASSERT_LINE);
+ interrupt_set(4);
}
}
-uint8_t lynx_state::lynx_uart_r(offs_t offset)
+u8 lynx_state::uart_r(offs_t offset)
{
- uint8_t value = 0x00;
+ u8 value = 0x00;
switch (offset)
{
case 0x8c:
- if (!m_uart.buffer_loaded)
+ if (!m_uart.buffer_loaded) // TXRDY Transmit buffer ready
value |= 0x80;
- if (m_uart.received)
+ if (m_uart.received) // RXRDY Recevie character ready
value |= 0x40;
- if (!m_uart.sending)
+ if (!m_uart.sending) // TXEMPTY Transmit done
value |= 0x20;
+ // value |= 0x10; PARERR Recevied parity error (not implemented)
+ // value |= 0x08; OVERRUN Recevied overrun error (not implemented)
+ // value |= 0x04; FRAMERR Recevied framing error (not implemented)
+ // value |= 0x02; RXBRK Break recevied (not implemented)
+ // value |= 0x01; PARBIT 9th bit (not implemented)
break;
case 0x8d:
@@ -1662,7 +1639,7 @@ uint8_t lynx_state::lynx_uart_r(offs_t offset)
return value;
}
-void lynx_state::lynx_uart_w(offs_t offset, uint8_t data)
+void lynx_state::uart_w(offs_t offset, u8 data)
{
logerror("uart write %.2x %.2x\n", offset, data);
switch (offset)
@@ -1696,9 +1673,9 @@ void lynx_state::lynx_uart_w(offs_t offset, uint8_t data)
****************************************/
-uint8_t lynx_state::mikey_read(offs_t offset)
+u8 lynx_state::mikey_read(offs_t offset)
{
- uint8_t direction, value = 0x00;
+ u8 direction, value = 0x00;
switch (offset)
{
@@ -1710,7 +1687,7 @@ uint8_t lynx_state::mikey_read(offs_t offset)
case 0x14: case 0x15: case 0x16: case 0x17:
case 0x18: case 0x19: case 0x1a: case 0x1b:
case 0x1c: case 0x1d: case 0x1e: case 0x1f:
- value = lynx_timer_read(offset >> 2, offset & 0x03);
+ value = timer_read(offset >> 2, offset & 0x03);
break;
case 0x20: case 0x21: case 0x22: case 0x23: case 0x24: case 0x25: case 0x26: case 0x27:
@@ -1723,31 +1700,32 @@ uint8_t lynx_state::mikey_read(offs_t offset)
case 0x80:
case 0x81:
- value = m_mikey.data[0x81]; // both registers access the same interrupt status byte
- // logerror( "mikey read %.2x %.2x\n", offset, value );
+ value = m_mikey.interrupt; // both registers access the same interrupt status byte
+ // logerror("mikey read %.2x %.2x\n", offset, value);
break;
- case 0x84:
- case 0x85:
+ case 0x84: // MAGRDY0 Mag. tape channel 0 ready bit
+ case 0x85: // MAGRDY1 Mag. tape channel 1 ready bit
value = 0x00;
break;
- case 0x86:
+ case 0x86: // AUDIN Audio in
value = 0x80;
break;
- case 0x88:
+ case 0x88: // MIKEYHREV Mikey hardware revision
value = 0x01;
break;
+ //case 0x89: // MIKEYSREV Mikey software revision
case 0x8b:
- direction = m_mikey.data[0x8a];
- value |= (direction & 0x01) ? (m_mikey.data[offset] & 0x01) : 0x01; // External Power input
- value |= (direction & 0x02) ? (m_mikey.data[offset] & 0x02) : 0x00; // Cart Address Data output (0 turns cart power on)
- value |= (direction & 0x04) ? (m_mikey.data[offset] & 0x04) : 0x04; // noexp input
+ direction = m_mikey.IODIR();
+ value |= BIT(direction, 0) ? (m_mikey.data[offset] & 0x01) : 0x01; // External Power input
+ value |= BIT(direction, 1) ? (m_mikey.data[offset] & 0x02) : 0x00; // Cart Address Data output (0 turns cart power on)
+ value |= BIT(direction, 2) ? (m_mikey.data[offset] & 0x04) : 0x04; // noexp input
// REST read returns actual rest state anded with rest output bit
- value |= (direction & 0x08) ? (((m_mikey.data[offset] & 0x08) && (m_mikey.vb_rest)) ? 0x00 : 0x08) : 0x00; // rest output
- value |= (direction & 0x10) ? (m_mikey.data[offset] & 0x10) : 0x10; // audin input
+ value |= BIT(direction, 3) ? (((m_mikey.data[offset] & 0x08) && (m_mikey.vb_rest)) ? 0x00 : 0x08) : 0x00; // rest output
+ value |= BIT(direction, 4) ? (m_mikey.data[offset] & 0x10) : 0x10; // audin input
/* Hack: we disable COMLynx */
value |= 0x04;
/* B5, B6 & B7 are not used */
@@ -1755,17 +1733,17 @@ uint8_t lynx_state::mikey_read(offs_t offset)
case 0x8c:
case 0x8d:
- value = lynx_uart_r(offset);
+ value = uart_r(offset);
break;
default:
value = m_mikey.data[offset];
- //logerror( "mikey read %.2x %.2x\n", offset, value );
+ //logerror("mikey read %.2x %.2x\n", offset, value);
}
return value;
}
-void lynx_state::mikey_write(offs_t offset, uint8_t data)
+void lynx_state::mikey_write(offs_t offset, u8 data)
{
switch (offset)
{
@@ -1777,7 +1755,7 @@ void lynx_state::mikey_write(offs_t offset, uint8_t data)
case 0x14: case 0x15: case 0x16: case 0x17:
case 0x18: case 0x19: case 0x1a: case 0x1b:
case 0x1c: case 0x1d: case 0x1e: case 0x1f:
- lynx_timer_write(offset >> 2, offset & 3, data);
+ timer_write(offset >> 2, offset & 3, data);
return;
case 0x20: case 0x21: case 0x22: case 0x23: case 0x24: case 0x25: case 0x26: case 0x27:
@@ -1789,67 +1767,51 @@ void lynx_state::mikey_write(offs_t offset, uint8_t data)
return;
case 0x80:
- m_mikey.data[0x81] &= ~data; // clear interrupt source
+ m_mikey.interrupt &= ~data; // clear interrupt source
// logerror("mikey write %.2x %.2x\n", offset, data);
- if (!m_mikey.data[0x81])
- m_maincpu->set_input_line(M65SC02_IRQ_LINE, CLEAR_LINE);
+ if (!m_mikey.interrupt)
+ interrupt_update();
break;
/* Is this correct? */ // Notes say writing to register will result in interrupt being triggered.
case 0x81:
- m_mikey.data[0x81] |= data;
+ m_mikey.interrupt |= data;
if (data)
{
m_maincpu->set_input_line(INPUT_LINE_HALT, CLEAR_LINE);
- m_maincpu->set_input_line(M65SC02_IRQ_LINE, ASSERT_LINE);
+ interrupt_update();
logerror("direct write to interrupt register\n");
}
break;
case 0x87:
m_mikey.data[offset] = data;
- if (data & 0x02) // Power (1 = on)
+ if (BIT(data, 1)) // Power (1 = on)
{
- if (data & 0x01) // Cart Address Strobe
+ if (BIT(data, 0)) // Cart Address Strobe, positive edge
{
- m_suzy.high <<= 1;
- if (m_mikey.data[0x8b] & 0x02)
- m_suzy.high |= 1;
- m_suzy.high &= 0xff;
- m_suzy.low = 0;
+ m_cart_addr_block = ((m_cart_addr_block << 1) & 0xfe) | BIT(m_mikey.IODAT(), 1); // 74HC164 clock
+ m_cart_addr_counter = 0; // 4040 reset
}
}
else
{
- m_suzy.high = 0;
- m_suzy.low = 0;
+ m_cart_addr_block = 0;
+ m_cart_addr_counter = 0;
}
break;
- case 0x8c: case 0x8d:
- lynx_uart_w(offset, data);
- break;
-
- case 0xa0: case 0xa1: case 0xa2: case 0xa3: case 0xa4: case 0xa5: case 0xa6: case 0xa7:
- case 0xa8: case 0xa9: case 0xaa: case 0xab: case 0xac: case 0xad: case 0xae: case 0xaf:
- case 0xb0: case 0xb1: case 0xb2: case 0xb3: case 0xb4: case 0xb5: case 0xb6: case 0xb7:
- case 0xb8: case 0xb9: case 0xba: case 0xbb: case 0xbc: case 0xbd: case 0xbe: case 0xbf:
- m_mikey.data[offset] = data;
-
- /* RED = 0xb- & 0x0f, GREEN = 0xa- & 0x0f, BLUE = (0xb- & 0xf0) >> 4 */
- m_palette->set_pen_color(offset & 0x0f, rgb_t(
- pal4bit(m_mikey.data[0xb0 | (offset & 0x0f)] & 0x0f),
- pal4bit(m_mikey.data[0xa0 | (offset & 0x0f)] & 0x0f),
- pal4bit((m_mikey.data[0xb0 | (offset & 0x0f)] & 0xf0) >> 4)));
- break;
-
/* TODO: properly implement these writes */
case 0x8b:
m_mikey.data[offset] = data;
- if (m_mikey.data[0x8a] & 0x10)
+ if ((m_audin_offset == 0) && (m_mikey.IODIR() & 0x10))
logerror("Trying to enable bank 1 write. %d\n", m_mikey.data[offset] & 0x10);
break;
+ case 0x8c: case 0x8d:
+ uart_w(offset, data);
+ break;
+
//case 0x90: // SDONEACK - Suzy Done Acknowledge
case 0x91: // CPUSLEEP - CPU Bus Request Disable
m_mikey.data[offset] = data;
@@ -1859,16 +1821,34 @@ void lynx_state::mikey_write(offs_t offset, uint8_t data)
/* A write of '0' to this address will reset the CPU bus request flip flop */
}
break;
+ //case 0x93: // PBKUP - Magic 'P' count value
case 0x94: case 0x95:
- m_mikey.data[offset]=data;
+ m_mikey.data[offset] = data;
break;
case 0x9c: case 0x9d: case 0x9e:
- m_mikey.data[offset]=data;
- logerror("Mtest%d write: %x\n", offset&0x3, data);
+ m_mikey.data[offset] = data;
+ logerror("Mtest%d write: %x\n", offset & 0x3, data);
+ break;
+
+ case 0xa0: case 0xa1: case 0xa2: case 0xa3: case 0xa4: case 0xa5: case 0xa6: case 0xa7:
+ case 0xa8: case 0xa9: case 0xaa: case 0xab: case 0xac: case 0xad: case 0xae: case 0xaf:
+ m_mikey.data[offset] = data;
+
+ /* RED = 0xb- & 0x0f, GREEN = 0xa- & 0x0f, BLUE = (0xb- & 0xf0) >> 4 */
+ m_palette->set_pen_green_level(offset & 0x0f, pal4bit(data & 0x0f));
+ break;
+
+ case 0xb0: case 0xb1: case 0xb2: case 0xb3: case 0xb4: case 0xb5: case 0xb6: case 0xb7:
+ case 0xb8: case 0xb9: case 0xba: case 0xbb: case 0xbc: case 0xbd: case 0xbe: case 0xbf:
+ m_mikey.data[offset] = data;
+
+ /* RED = 0xb- & 0x0f, GREEN = 0xa- & 0x0f, BLUE = (0xb- & 0xf0) >> 4 */
+ m_palette->set_pen_red_level(offset & 0x0f, pal4bit(data & 0x0f));
+ m_palette->set_pen_blue_level(offset & 0x0f, pal4bit((data & 0xf0) >> 4));
break;
default:
- m_mikey.data[offset]=data;
+ m_mikey.data[offset] = data;
//logerror("mikey write %.2x %.2x\n",offset,data);
break;
}
@@ -1880,27 +1860,43 @@ void lynx_state::mikey_write(offs_t offset, uint8_t data)
****************************************/
-uint8_t lynx_state::lynx_memory_config_r()
+u8 lynx_state::memory_config_r()
{
return m_memory_config;
}
-void lynx_state::lynx_memory_config_w(uint8_t data)
+void lynx_state::memory_config_w(u8 data)
{
- /* bit 7: hispeed, uses page mode accesses (4 instead of 5 cycles )
+ /* bit 7: hispeed, uses page mode accesses (4 instead of 5 cycles)
* when these are safe in the cpu */
m_memory_config = data;
- m_bank_fc00->set_bank(BIT(data, 0));
- m_bank_fd00->set_bank(BIT(data, 1));
- m_bank_fe00->set_entry(BIT(data, 2));
- m_bank_fffa->set_entry(BIT(data, 3));
+ if (BIT(data, 0))
+ m_suzy_view.disable();
+ else
+ m_suzy_view.select(0);
+
+ if (BIT(data, 1))
+ m_mikey_view.disable();
+ else
+ m_mikey_view.select(0);
+
+ if (BIT(data, 2))
+ m_rom_view.disable();
+ else
+ m_rom_view.select(0);
+
+ if (BIT(data, 3))
+ m_vector_view.disable();
+ else
+ m_vector_view.select(0);
}
void lynx_state::machine_reset()
{
- lynx_memory_config_w(0);
+ memory_config_w(0);
+ m_mikey.interrupt = 0;
m_maincpu->set_input_line(INPUT_LINE_HALT, CLEAR_LINE);
m_maincpu->set_input_line(M65SC02_IRQ_LINE, CLEAR_LINE);
@@ -1918,34 +1914,39 @@ void lynx_state::machine_reset()
m_mikey.data[0x90] = 0x00;
m_mikey.data[0x92] = 0x00;
- lynx_uart_reset();
+ uart_reset();
// hack to allow current object loading to work
#if 0
- lynx_timer_write( this, 0, 0, 160 ); // set backup value (hpos) = 160
- lynx_timer_write( this, 0, 1, 0x10 | 0x8 | 0 ); // enable count, enable reload, 1us period
- lynx_timer_write( this, 2, 0, 105 ); // set backup value (vpos) = 102
- lynx_timer_write( this, 2, 1, 0x10 | 0x8 | 7 ); // enable count, enable reload, link
+ timer_write(0, 0, 158); // set backup value (hpos) = 159
+ timer_write(0, 1, 0x10 | 0x8 | 0); // enable count, enable reload, 1us period
+ timer_write(2, 0, 104); // set backup value (vpos) = 105
+ timer_write(2, 1, 0x10 | 0x8 | 7); // enable count, enable reload, link
#endif
render_target *target = machine().render().first_target();
target->set_view(m_rotate);
}
-void lynx_state::lynx_postload()
+void lynx_state::device_post_load()
{
- lynx_memory_config_w(m_memory_config);
+ memory_config_w(m_memory_config);
}
void lynx_state::machine_start()
{
- m_bitmap_temp.allocate(160,102,0,0);
+ m_bitmap_temp.allocate(160,105,0,0);
// save driver variables
+ save_item(NAME(m_cart_addr_block));
+ save_item(NAME(m_cart_addr_counter));
save_item(NAME(m_memory_config));
save_item(NAME(m_sign_AB));
save_item(NAME(m_sign_CD));
save_item(NAME(m_rotate));
+ save_item(NAME(m_pixclock));
+ save_item(NAME(m_hcount));
+ save_item(NAME(m_vcount));
// save blitter variables
save_item(NAME(m_blitter.screen));
save_item(NAME(m_blitter.colbuf));
@@ -1984,8 +1985,6 @@ void lynx_state::machine_start()
save_item(NAME(m_blitter.busy));
// save suzy variables
save_item(NAME(m_suzy.data));
- save_item(NAME(m_suzy.high));
- save_item(NAME(m_suzy.low));
save_item(NAME(m_suzy.signed_math));
save_item(NAME(m_suzy.accumulate));
save_item(NAME(m_suzy.accumulate_overflow));
@@ -1993,6 +1992,7 @@ void lynx_state::machine_start()
save_item(NAME(m_mikey.data));
save_item(NAME(m_mikey.disp_addr));
save_item(NAME(m_mikey.vb_rest));
+ save_item(NAME(m_mikey.interrupt));
// save uart variables
save_item(NAME(m_uart.serctl));
save_item(NAME(m_uart.data_received));
@@ -2002,15 +2002,13 @@ void lynx_state::machine_start()
save_item(NAME(m_uart.sending));
save_item(NAME(m_uart.buffer_loaded));
- machine().save().register_postload(save_prepost_delegate(FUNC(lynx_state::lynx_postload), this));
-
- m_bank_fe00->configure_entry(0, memregion("maincpu")->base() + 0x0000);
- m_bank_fe00->configure_entry(1, m_mem_fe00);
- m_bank_fffa->configure_entry(0, memregion("maincpu")->base() + 0x01fa);
- m_bank_fffa->configure_entry(1, m_mem_fffa);
+ m_suzy_view.select(0);
+ m_mikey_view.select(0);
+ m_rom_view.select(0);
+ m_vector_view.select(0);
for (int i = 0; i < NR_LYNX_TIMERS; i++)
- lynx_timer_init(i);
+ timer_init(i);
}
@@ -2020,7 +2018,7 @@ void lynx_state::machine_start()
****************************************/
-image_verify_result lynx_state::lynx_verify_cart(char *header, int kind)
+image_verify_result lynx_state::verify_cart(char *header, int kind)
{
if (kind)
{
@@ -2053,8 +2051,8 @@ DEVICE_IMAGE_LOAD_MEMBER(lynx_state::cart_load)
/* Lynx carts have 19 address lines, the upper 8 used for bank select. The lower
11 bits are used to address data within the selected bank. Valid bank sizes are 256,
512, 1024 or 2048 bytes. Commercial roms use all 256 banks.*/
- uint32_t size = m_cart->common_get_size("rom");
- uint16_t gran = 0;
+ u32 size = m_cart->common_get_size("rom");
+ u16 gran = 0;
if (!image.loaded_through_softlist())
{
@@ -2067,15 +2065,15 @@ DEVICE_IMAGE_LOAD_MEMBER(lynx_state::cart_load)
// 0 0 1 0
// 32 chars name
// 22 chars manufacturer
- uint8_t header[0x40];
+ u8 header[0x40];
image.fread(header, 0x40);
// Check the image
- if (lynx_verify_cart((char*)header, LYNX_CART) != image_verify_result::PASS)
+ if (verify_cart((char*)header, LYNX_CART) != image_verify_result::PASS)
return image_init_result::FAIL;
/* 2008-10 FP: According to Handy source these should be page_size_bank0. Are we using
- it correctly in MESS? Moreover, the next two values should be page_size_bank1. We should
+ it correctly in MAME? Moreover, the next two values should be page_size_bank1. We should
implement this as well */
gran = header[4] | (header[5] << 8);
@@ -2107,10 +2105,19 @@ DEVICE_IMAGE_LOAD_MEMBER(lynx_state::cart_load)
}
else
{
- if (size > 0xffff) // 64,128,256,512k cartridges
- m_granularity = size >> 8;
+ // Some cartridge uses AUDIN pin for bankswitch
+ if (image.get_feature("audin_offset") != nullptr)
+ m_audin_offset = atol(image.get_feature("audin_offset"));
+
+ if (image.get_feature("granularity") != nullptr)
+ m_granularity = atol(image.get_feature("granularity"));
else
- m_granularity = 0x400; // Homebrew roms not using all 256 banks (T-Tris) (none currently in softlist)
+ {
+ if (size > 0xffff) // 64,128,256,512k cartridges
+ m_granularity = size >> 8;
+ else
+ m_granularity = 0x400; // Homebrew roms not using all 256 banks (T-Tris) (none currently in softlist)
+ }
}
// set-up rotation from softlist
diff --git a/src/mame/machine/m1comm.h b/src/mame/machine/m1comm.h
index 96f5b13180b..451c6e9b436 100644
--- a/src/mame/machine/m1comm.h
+++ b/src/mame/machine/m1comm.h
@@ -7,7 +7,7 @@
#define M1COMM_SIMULATION
-#include "osdcore.h"
+#include "osdfile.h"
#include "cpu/z80/z80.h"
#include "machine/am9517a.h"
#include "machine/mb89374.h"
diff --git a/src/mame/machine/m24_kbd.cpp b/src/mame/machine/m24_kbd.cpp
index 13eb7cfc103..bc19f619453 100644
--- a/src/mame/machine/m24_kbd.cpp
+++ b/src/mame/machine/m24_kbd.cpp
@@ -225,7 +225,7 @@ void m24_keyboard_device::device_reset()
m_kbcdata = true;
}
-void m24_keyboard_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
+void m24_keyboard_device::device_timer(emu_timer &timer, device_timer_id id, int param)
{
m_mcu->set_input_line(INPUT_LINE_RESET, ASSERT_LINE);
m_out_data(1);
diff --git a/src/mame/machine/m24_kbd.h b/src/mame/machine/m24_kbd.h
index 5f882503cbb..69083734950 100644
--- a/src/mame/machine/m24_kbd.h
+++ b/src/mame/machine/m24_kbd.h
@@ -19,9 +19,9 @@ public:
DECLARE_WRITE_LINE_MEMBER(data_w);
protected:
- void device_start() override;
- void device_reset() override;
- void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override;
+ virtual void device_start() override;
+ virtual void device_reset() override;
+ virtual void device_timer(emu_timer &timer, device_timer_id id, int param) override;
virtual const tiny_rom_entry *device_rom_region() const override;
virtual void device_add_mconfig(machine_config &config) override;
virtual ioport_constructor device_input_ports() const override;
diff --git a/src/mame/machine/m2comm.h b/src/mame/machine/m2comm.h
index 8b8e719faee..06b58c20242 100644
--- a/src/mame/machine/m2comm.h
+++ b/src/mame/machine/m2comm.h
@@ -7,7 +7,7 @@
#define M2COMM_SIMULATION
-#include "osdcore.h"
+#include "osdfile.h"
//**************************************************************************
// TYPE DEFINITIONS
diff --git a/src/mame/machine/m3comm.cpp b/src/mame/machine/m3comm.cpp
index e1d74fc0ae3..ccd7a84ff74 100644
--- a/src/mame/machine/m3comm.cpp
+++ b/src/mame/machine/m3comm.cpp
@@ -194,7 +194,7 @@ uint16_t swapb16(uint16_t data)
}
-void m3comm_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
+void m3comm_device::device_timer(emu_timer &timer, device_timer_id id, int param)
{
if(id != TIMER_IRQ5)
return;
diff --git a/src/mame/machine/m3comm.h b/src/mame/machine/m3comm.h
index f4fd23c1578..529c0bec578 100644
--- a/src/mame/machine/m3comm.h
+++ b/src/mame/machine/m3comm.h
@@ -45,7 +45,7 @@ protected:
virtual void device_start() override;
virtual void device_reset() override;
virtual void device_reset_after_children() override;
- virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override;
+ virtual void device_timer(emu_timer &timer, device_timer_id id, int param) override;
virtual void device_add_mconfig(machine_config &config) override;
private:
diff --git a/src/mame/machine/macadb.cpp b/src/mame/machine/macadb.cpp
index 17620477bfd..28debf54c4b 100644
--- a/src/mame/machine/macadb.cpp
+++ b/src/mame/machine/macadb.cpp
@@ -231,7 +231,6 @@ void macadb_device::device_start()
m_adb_stream_ptr = 0;
m_adb_linein = 0;
std::fill(std::begin(m_adb_keybuf), std::end(m_adb_keybuf), 0);
- std::fill(std::begin(m_adb_pram), std::end(m_adb_pram), 0);
save_item(NAME(m_last_adb_time));
save_item(NAME(m_key_matrix));
@@ -262,7 +261,6 @@ void macadb_device::device_start()
save_item(NAME(m_adb_keybinitialized));
save_item(NAME(m_adb_currentkeys));
save_item(NAME(m_adb_modifiers));
- save_item(NAME(m_adb_pram));
save_item(NAME(m_adb_linein));
}
@@ -398,7 +396,10 @@ int macadb_device::adb_pollkbd(int update)
}
}
-// printf("ADB keyboard: update %d keys %02x %02x\n", update, codes[0], codes[1]);
+// if ((codes[0] != 0xff) || (codes[1] != 0xff))
+// {
+// printf("ADB keyboard: update %d keys %02x %02x\n", update, codes[0], codes[1]);
+// }
// figure out if there was a change
if ((m_adb_currentkeys[0] != codes[0]) || (m_adb_currentkeys[1] != codes[1]))
@@ -450,8 +451,10 @@ void macadb_device::adb_accummouse( uint8_t *MouseX, uint8_t *MouseY )
int MouseCountX = 0, MouseCountY = 0;
int NewX, NewY;
- NewX = ioport("MOUSE2")->read();
- NewY = ioport("MOUSE1")->read();
+ NewX = m_mouse2->read();
+ NewY = m_mouse1->read();
+
+// printf("pollmouse: X %d Y %d\n", NewX, NewY);
/* see if it moved in the x coord */
if (NewX != m_adb_lastmousex)
@@ -496,7 +499,7 @@ void macadb_device::adb_talk()
addr = (m_adb_command>>4);
reg = (m_adb_command & 3);
- //printf("Mac sent %x (cmd %d addr %d reg %d mr %d kr %d)\n", m_adb_command, (m_adb_command>>2)&3, addr, reg, m_adb_mouseaddr, m_adb_keybaddr);
+// printf("Mac sent %x (cmd %d addr %d reg %d mr %d kr %d)\n", m_adb_command, (m_adb_command>>2)&3, addr, reg, m_adb_mouseaddr, m_adb_keybaddr);
if (m_adb_waiting_cmd)
{
@@ -569,6 +572,7 @@ void macadb_device::adb_talk()
{
this->adb_accummouse(&mouseX, &mouseY);
}
+ //printf("X %x Y %x\n", mouseX, mouseY);
m_adb_buffer[0] = (m_adb_lastbutton & 0x01) ? 0x00 : 0x80;
m_adb_buffer[0] |= mouseX & 0x7f;
m_adb_buffer[1] = mouseY & 0x7f;
@@ -622,7 +626,7 @@ void macadb_device::adb_talk()
if(kbd_has_data)
{
- if(m_adb_keybuf_start == m_adb_keybuf_end)
+ if (m_adb_keybuf_start == m_adb_keybuf_end)
{
// printf("%s: buffer empty\n", __func__);
m_adb_buffer[0] = 0xff;
@@ -648,6 +652,7 @@ void macadb_device::adb_talk()
{
m_adb_buffer[0] = 0xff;
m_adb_buffer[1] = 0xff;
+ m_adb_datasize = 2;
}
break;
@@ -707,6 +712,7 @@ void macadb_device::adb_talk()
{
LOGMASKED(LOG_TALK_LISTEN, "MOUSE: moving to address %x\n", m_adb_command);
m_adb_mouseaddr = m_adb_command&0x0f;
+ m_adb_mouse_initialized = 1;
}
}
else if (m_adb_listenaddr == m_adb_keybaddr)
@@ -732,18 +738,21 @@ TIMER_CALLBACK_MEMBER(macadb_device::mac_adb_tick)
break;
case LST_TSTOPSTART:
+ LOGMASKED(LOG_LINESTATE, "Send: TStopStart begin\n");
set_adb_line(ASSERT_LINE);
m_adb_timer->adjust(attotime::from_ticks(adb_short, adb_timebase));
m_adb_linestate++;
break;
case LST_TSTOPSTARTa:
+ LOGMASKED(LOG_LINESTATE, "Send: TStopStart end\n");
set_adb_line(CLEAR_LINE);
m_adb_timer->adjust(attotime::from_ticks(adb_short, adb_timebase));
m_adb_linestate++;
break;
case LST_STARTBIT:
+ LOGMASKED(LOG_LINESTATE, "Send: Start bit\n");
set_adb_line(ASSERT_LINE);
m_adb_timer->adjust(attotime::from_ticks(adb_long, adb_timebase));
m_adb_linestate++;
@@ -760,12 +769,12 @@ TIMER_CALLBACK_MEMBER(macadb_device::mac_adb_tick)
set_adb_line(CLEAR_LINE);
if (m_adb_buffer[m_adb_stream_ptr] & 0x80)
{
- //printf("1 ");
+ LOGMASKED(LOG_LINESTATE, "Send: 1\n");
m_adb_timer->adjust(attotime::from_ticks(adb_short, adb_timebase));
}
else
{
- //printf("0 ");
+ LOGMASKED(LOG_LINESTATE, "Send: 0\n");
m_adb_timer->adjust(attotime::from_ticks(adb_long, adb_timebase));
}
m_adb_linestate++;
@@ -816,12 +825,14 @@ TIMER_CALLBACK_MEMBER(macadb_device::mac_adb_tick)
break;
case LST_SENDSTOP:
+ LOGMASKED(LOG_LINESTATE, "Send: Stop bit begin\n");
set_adb_line(CLEAR_LINE);
m_adb_timer->adjust(attotime::from_ticks((adb_short*2), adb_timebase));
m_adb_linestate++;
break;
case LST_SENDSTOPa:
+ LOGMASKED(LOG_LINESTATE, "Send: Stop bit end\n");
set_adb_line(ASSERT_LINE);
m_adb_timer->adjust(attotime::never);
m_adb_linestate = LST_IDLE;
@@ -1162,11 +1173,12 @@ WRITE_LINE_MEMBER(macadb_device::adb_linechange_w)
if (m_adb_datasize > 0)
{
- LOGMASKED(LOG_LINESTATE, "Device has %d bytes of data:\n", m_adb_datasize);
+ LOGMASKED(LOG_TALK_LISTEN, "Device has %d bytes of data:\n", m_adb_datasize);
for (int i = 0; i < m_adb_datasize; i++)
{
- LOGMASKED(LOG_LINESTATE, " %02x\n", m_adb_buffer[i]);
+ LOGMASKED(LOG_TALK_LISTEN, " %02x", m_adb_buffer[i]);
}
+ LOGMASKED(LOG_TALK_LISTEN, "\n");
m_adb_linestate = LST_TSTOPSTART; // T1t
m_adb_timer->adjust(attotime::from_ticks(324/4, adb_timebase));
m_adb_stream_ptr = 0;
diff --git a/src/mame/machine/macadb.h b/src/mame/machine/macadb.h
index 79f8ab63736..0d11758b1ca 100644
--- a/src/mame/machine/macadb.h
+++ b/src/mame/machine/macadb.h
@@ -75,9 +75,6 @@ private:
int m_adb_keybaddr;
int m_adb_keybinitialized, m_adb_currentkeys[2], m_adb_modifiers;
- // PRAM for ADB MCU HLEs (mostly unused now)
- uint8_t m_adb_pram[256];
-
int adb_pollkbd(int update);
int adb_pollmouse();
void adb_accummouse( uint8_t *MouseX, uint8_t *MouseY );
@@ -85,7 +82,7 @@ private:
inline void set_adb_line(int linestate) { write_adb_data(linestate); }
- TIMER_CALLBACK_MEMBER(mac_adb_tick); // macadb.c
+ TIMER_CALLBACK_MEMBER(mac_adb_tick);
};
// device type definition
diff --git a/src/mame/machine/mace.cpp b/src/mame/machine/mace.cpp
index 75f7fdef799..d2a1f8c12c3 100644
--- a/src/mame/machine/mace.cpp
+++ b/src/mame/machine/mace.cpp
@@ -440,7 +440,7 @@ void mace_device::rtc_w(offs_t offset, uint64_t data, uint64_t mem_mask)
// TIMERS
//**************************************************************************
-void mace_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
+void mace_device::device_timer(emu_timer &timer, device_timer_id id, int param)
{
if (id == TIMER_UST)
{
diff --git a/src/mame/machine/mace.h b/src/mame/machine/mace.h
index bac2e2cb8ca..74ed78030c8 100644
--- a/src/mame/machine/mace.h
+++ b/src/mame/machine/mace.h
@@ -35,7 +35,7 @@ protected:
virtual void device_start() override;
virtual void device_reset() override;
virtual void device_add_mconfig(machine_config &config) override;
- virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override;
+ virtual void device_timer(emu_timer &timer, device_timer_id id, int param) override;
static const device_timer_id TIMER_MSC = 0;
static const device_timer_id TIMER_UST = 1;
diff --git a/src/mame/machine/macrtc.cpp b/src/mame/machine/macrtc.cpp
index b375098daf1..19e0909c8d5 100644
--- a/src/mame/machine/macrtc.cpp
+++ b/src/mame/machine/macrtc.cpp
@@ -79,7 +79,7 @@ void rtc3430042_device::device_reset()
// device_timer - handler timer events
//-------------------------------------------------
-void rtc3430042_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
+void rtc3430042_device::device_timer(emu_timer &timer, device_timer_id id, int param)
{
advance_seconds();
}
diff --git a/src/mame/machine/macrtc.h b/src/mame/machine/macrtc.h
index df8dfce0ff1..bb19f49828f 100644
--- a/src/mame/machine/macrtc.h
+++ b/src/mame/machine/macrtc.h
@@ -38,7 +38,7 @@ protected:
// device-level overrides
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_timer(emu_timer &timer, device_timer_id id, int param) override;
// device_rtc_interface overrides
virtual void rtc_clock_updated(int year, int month, int day, int day_of_week, int hour, int minute, int second) override;
diff --git a/src/mame/machine/maple-dc.cpp b/src/mame/machine/maple-dc.cpp
index f2db34fd867..60f7008d243 100644
--- a/src/mame/machine/maple-dc.cpp
+++ b/src/mame/machine/maple-dc.cpp
@@ -68,7 +68,7 @@ void maple_dc_device::device_reset()
dma_endflag = false;
}
-void maple_dc_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
+void maple_dc_device::device_timer(emu_timer &timer, device_timer_id id, int param)
{
timer.adjust(attotime::never);
diff --git a/src/mame/machine/maple-dc.h b/src/mame/machine/maple-dc.h
index 19d0a3c7718..deb405b58d3 100644
--- a/src/mame/machine/maple-dc.h
+++ b/src/mame/machine/maple-dc.h
@@ -49,7 +49,7 @@ protected:
// device-level overrides
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_timer(emu_timer &timer, device_timer_id id, int param) override;
private:
enum {
diff --git a/src/mame/machine/mapledev.cpp b/src/mame/machine/mapledev.cpp
index 4279f21eb71..b2a6d11135d 100644
--- a/src/mame/machine/mapledev.cpp
+++ b/src/mame/machine/mapledev.cpp
@@ -26,7 +26,7 @@ void maple_device::maple_reset()
device_reset();
}
-void maple_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
+void maple_device::device_timer(emu_timer &timer, device_timer_id id, int param)
{
if(id != TIMER_ID)
return;
diff --git a/src/mame/machine/mapledev.h b/src/mame/machine/mapledev.h
index cbf020a8470..77f4d95a991 100644
--- a/src/mame/machine/mapledev.h
+++ b/src/mame/machine/mapledev.h
@@ -26,7 +26,7 @@ protected:
// device-level overrides
virtual void device_start() override;
- virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override;
+ virtual void device_timer(emu_timer &timer, device_timer_id id, int param) override;
void reply_ready();
void reply_ready_with_delay();
diff --git a/src/mame/machine/mct_adr.cpp b/src/mame/machine/mct_adr.cpp
index 9de43725ea9..81dc3db6907 100644
--- a/src/mame/machine/mct_adr.cpp
+++ b/src/mame/machine/mct_adr.cpp
@@ -185,7 +185,7 @@ void mct_adr_device::device_reset()
m_interval_timer->adjust(attotime::from_msec(1), 0, attotime::from_msec(1));
- irq_check(nullptr, 0);
+ irq_check(0);
}
void mct_adr_device::set_irq_line(int irq, int state)
diff --git a/src/mame/machine/megadriv.cpp b/src/mame/machine/megadriv.cpp
index 320fd0677fb..c0a76898b71 100644
--- a/src/mame/machine/megadriv.cpp
+++ b/src/mame/machine/megadriv.cpp
@@ -79,7 +79,7 @@ void md_base_state::megadriv_68k_YM2612_write(offs_t offset, uint8_t data, uint8
// this is used by 6 button pads and gets installed in machine_start for drivers requiring it
TIMER_CALLBACK_MEMBER(md_base_state::io_timeout_timer_callback)
{
- m_io_stage[(int)(uintptr_t)ptr] = -1;
+ m_io_stage[(int)param] = -1;
}
@@ -366,7 +366,7 @@ void md_base_state::megadrive_io_write_data_port_6button(offs_t offset, uint16_t
if (((m_megadrive_io_data_regs[portnum]&0x40)==0x00) && ((data&0x40) == 0x40))
{
m_io_stage[portnum]++;
- m_io_timeout[portnum]->adjust(m_maincpu->cycles_to_attotime(8192));
+ m_io_timeout[portnum]->adjust(m_maincpu->cycles_to_attotime(8192), portnum);
}
}
diff --git a/src/mame/machine/micro3d.cpp b/src/mame/machine/micro3d.cpp
index 8d8b60f1659..5b4758b8767 100644
--- a/src/mame/machine/micro3d.cpp
+++ b/src/mame/machine/micro3d.cpp
@@ -125,12 +125,12 @@ static inline int64_t normalised_multiply(int32_t a, int32_t b)
return result >> 14;
}
-void micro3d_state::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
+void micro3d_state::device_timer(emu_timer &timer, device_timer_id id, int param)
{
switch (id)
{
case TIMER_MAC_DONE:
- mac_done_callback(ptr, param);
+ mac_done_callback(param);
break;
default:
throw emu_fatalerror("Unknown id in micro3d_state::device_timer");
diff --git a/src/mame/machine/midikbd.cpp b/src/mame/machine/midikbd.cpp
index b1611d7703a..5fd3cbdb85c 100644
--- a/src/mame/machine/midikbd.cpp
+++ b/src/mame/machine/midikbd.cpp
@@ -13,7 +13,7 @@ midi_keyboard_device::midi_keyboard_device(const machine_config &mconfig, const
{
}
-void midi_keyboard_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
+void midi_keyboard_device::device_timer(emu_timer &timer, device_timer_id id, int param)
{
if(!id)
{
diff --git a/src/mame/machine/midikbd.h b/src/mame/machine/midikbd.h
index 494612bbe65..f9cdc05fed3 100644
--- a/src/mame/machine/midikbd.h
+++ b/src/mame/machine/midikbd.h
@@ -20,7 +20,7 @@ protected:
void device_start() override;
void tra_callback() override;
void tra_complete() override;
- void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override;
+ virtual void device_timer(emu_timer &timer, device_timer_id id, int param) override;
private:
void push_tx(uint8_t data) { ++m_head %= 16; m_buffer[m_head] = data; }
diff --git a/src/mame/machine/mie.cpp b/src/mame/machine/mie.cpp
index 1d39098ef36..9ea80066912 100644
--- a/src/mame/machine/mie.cpp
+++ b/src/mame/machine/mie.cpp
@@ -143,7 +143,7 @@ void mie_device::control_w(offs_t offset, uint8_t data)
}
}
-void mie_device::device_timer(emu_timer &_timer, device_timer_id id, int param, void *ptr)
+void mie_device::device_timer(emu_timer &_timer, device_timer_id id, int param)
{
timer->adjust(attotime::never);
if(control & CTRL_RXB) {
diff --git a/src/mame/machine/mie.h b/src/mame/machine/mie.h
index fbcd1e65836..ef8694a3197 100644
--- a/src/mame/machine/mie.h
+++ b/src/mame/machine/mie.h
@@ -83,7 +83,7 @@ protected:
// device-level overrides
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_timer(emu_timer &timer, device_timer_id id, int param) override;
// optional information overrides
virtual const tiny_rom_entry *device_rom_region() const override;
diff --git a/src/mame/machine/mm1kb.cpp b/src/mame/machine/mm1kb.cpp
index c411afc615b..800b73c5b30 100644
--- a/src/mame/machine/mm1kb.cpp
+++ b/src/mame/machine/mm1kb.cpp
@@ -247,7 +247,7 @@ void mm1_keyboard_device::shut_down_mm1()
// device_timer - handler timer events
//-------------------------------------------------
-void mm1_keyboard_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
+void mm1_keyboard_device::device_timer(emu_timer &timer, device_timer_id id, int param)
{
// handle scan timer
uint8_t data = 0xff;
diff --git a/src/mame/machine/mm1kb.h b/src/mame/machine/mm1kb.h
index 0924ac4836b..5d019c3daa4 100644
--- a/src/mame/machine/mm1kb.h
+++ b/src/mame/machine/mm1kb.h
@@ -48,7 +48,7 @@ public:
protected:
// device-level overrides
virtual void device_start() override;
- virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override;
+ virtual void device_timer(emu_timer &timer, device_timer_id id, int param) override;
// optional information overrides
virtual const tiny_rom_entry *device_rom_region() const override;
diff --git a/src/mame/machine/mpu4.cpp b/src/mame/machine/mpu4.cpp
index 8a7c57aecf9..00e59359ef8 100644
--- a/src/mame/machine/mpu4.cpp
+++ b/src/mame/machine/mpu4.cpp
@@ -693,7 +693,7 @@ void mpu4_state::ic24_setup()
}
-void mpu4_state::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
+void mpu4_state::device_timer(emu_timer &timer, device_timer_id id, int param)
{
switch(id)
{
@@ -796,9 +796,9 @@ uint8_t mpu4_state::pia_ic4_portb_r()
{
m_ic4_input_b |= 0x02; //Pulse the overcurrent line with every read to show the CPU each lamp has lit
}
- #ifdef UNUSED_FUNCTION
+#if 0
if ( lamp_undercurrent ) m_ic4_input_b |= 0x01;
- #endif
+#endif
LOG_IC3(("%s: IC4 PIA Read of Port B %x\n",machine().describe_context(),m_ic4_input_b));
return m_ic4_input_b;
diff --git a/src/mame/machine/n64.cpp b/src/mame/machine/n64.cpp
index 376a3b6162f..e29569aa1b0 100644
--- a/src/mame/machine/n64.cpp
+++ b/src/mame/machine/n64.cpp
@@ -1,6 +1,6 @@
// license:BSD-3-Clause
// copyright-holders:Ryan Holtz
-/* machine/n64.c - contains N64 hardware emulation shared between MAME and MESS */
+/* machine/n64.c - contains N64 hardware emulation shared between arcade and console */
#include "emu.h"
#include "debugger.h"
diff --git a/src/mame/machine/namco06.cpp b/src/mame/machine/namco06.cpp
index 37ec9688327..df37c79d1c6 100644
--- a/src/mame/machine/namco06.cpp
+++ b/src/mame/machine/namco06.cpp
@@ -106,23 +106,16 @@ TIMER_CALLBACK_MEMBER( namco_06xx_device::nmi_generate )
//
// During reads, the first NMI pulse is supressed to give the chip a
// cycle to write.
- //
- // If the control register is written while CS is asserted, RW won't be
- // changed until the next rising edge.
- if (m_rw_change && m_next_timer_state)
+ if (m_next_timer_state)
{
- if (!m_rw_stretch)
- {
- m_rw[0](0, BIT(m_control, 4));
- m_rw[1](0, BIT(m_control, 4));
- m_rw[2](0, BIT(m_control, 4));
- m_rw[3](0, BIT(m_control, 4));
- m_rw_change = false;
- }
+ m_rw[0](0, BIT(m_control, 4));
+ m_rw[1](0, BIT(m_control, 4));
+ m_rw[2](0, BIT(m_control, 4));
+ m_rw[3](0, BIT(m_control, 4));
}
- if (m_next_timer_state && !m_nmi_stretch )
+ if (m_next_timer_state && !m_read_stretch)
{
set_nmi(ASSERT_LINE);
}
@@ -130,6 +123,7 @@ TIMER_CALLBACK_MEMBER( namco_06xx_device::nmi_generate )
{
set_nmi(CLEAR_LINE);
}
+ m_read_stretch = false;
m_chipsel[0](0, BIT(m_control, 0) && m_next_timer_state);
m_chipsel[1](0, BIT(m_control, 1) && m_next_timer_state);
@@ -137,8 +131,6 @@ TIMER_CALLBACK_MEMBER( namco_06xx_device::nmi_generate )
m_chipsel[3](0, BIT(m_control, 3) && m_next_timer_state);
m_next_timer_state = !m_next_timer_state;
- m_nmi_stretch = false;
- m_rw_stretch = false;
}
uint8_t namco_06xx_device::data_r(offs_t offset)
@@ -162,15 +154,20 @@ uint8_t namco_06xx_device::data_r(offs_t offset)
void namco_06xx_device::data_w(offs_t offset, uint8_t data)
{
+ machine().scheduler().synchronize(timer_expired_delegate(FUNC(namco_06xx_device::write_sync),this), data);
+}
+
+TIMER_CALLBACK_MEMBER( namco_06xx_device::write_sync )
+{
if (BIT(m_control, 4))
{
logerror("%s: 06XX '%s' write in read mode %02x\n",machine().describe_context(),tag(),m_control);
return;
}
- if (BIT(m_control, 0)) m_write[0](0, data);
- if (BIT(m_control, 1)) m_write[1](0, data);
- if (BIT(m_control, 2)) m_write[2](0, data);
- if (BIT(m_control, 3)) m_write[3](0, data);
+ if (BIT(m_control, 0)) m_write[0](0, param);
+ if (BIT(m_control, 1)) m_write[1](0, param);
+ if (BIT(m_control, 2)) m_write[2](0, param);
+ if (BIT(m_control, 3)) m_write[3](0, param);
}
@@ -181,34 +178,56 @@ uint8_t namco_06xx_device::ctrl_r()
void namco_06xx_device::ctrl_w(uint8_t data)
{
- m_control = data;
+ machine().scheduler().synchronize(timer_expired_delegate(FUNC(namco_06xx_device::ctrl_w_sync),this), data);
+}
+
+TIMER_CALLBACK_MEMBER( namco_06xx_device::ctrl_w_sync )
+{
+ m_control = param;
// The upper 3 control bits are the clock divider.
if ((m_control & 0xe0) == 0)
{
m_nmi_timer->adjust(attotime::never);
+ m_next_timer_state = true;
set_nmi(CLEAR_LINE);
m_chipsel[0](0, CLEAR_LINE);
m_chipsel[1](0, CLEAR_LINE);
m_chipsel[2](0, CLEAR_LINE);
m_chipsel[3](0, CLEAR_LINE);
- // Setting this to true makes the next RW change not stretch.
- m_next_timer_state = true;
+ // RW is left as-is
}
else
{
- m_rw_stretch = !m_next_timer_state;
- m_rw_change = true;
- m_next_timer_state = true;
- m_nmi_stretch = BIT(m_control, 4);
- // NMI is cleared immediately if its to be stretched.
- if (m_nmi_stretch) set_nmi(CLEAR_LINE);
+ // NMI is cleared immediately if this is a read
+ // It will be supressed the next clock cycle.
+ if (BIT(m_control, 4))
+ {
+ set_nmi(CLEAR_LINE);
+ m_read_stretch = true;
+ } else {
+ m_read_stretch = false;
+ }
+
uint8_t num_shifts = (m_control & 0xe0) >> 5;
uint8_t divisor = 1 << num_shifts;
- // The next change should happen on the next clock falling edge.
- // Xevious' race causes this to bootloopsif it isn't 0.
- m_nmi_timer->adjust(attotime::zero, 0, attotime::from_hz(clock() / divisor) / 2);
+ attotime period = attotime::from_hz(clock() / divisor) / 2;
+ // This delay should be the next falling clock.
+ // That's complicated to get, as it's derived from the master
+ // clock. The CPU uses this same clock, so writes will come at
+ // a specific pace.
+ // Instead, just approximate a quarter cycle.
+ // Xevious is very sensitive to this. It will bootloop if it
+ // isn't correct.
+ attotime delay = attotime::from_hz(clock()) / 4; // average of one clock
+ if (!m_next_timer_state)
+ {
+ // NMI is asserted, wait one additional clock to start
+ m_nmi_timer->adjust(delay + attotime::from_hz(clock() / divisor), 0, period);
+ } else {
+ m_nmi_timer->adjust(delay, 0, period);
+ }
}
}
@@ -228,9 +247,7 @@ namco_06xx_device::namco_06xx_device(const machine_config &mconfig, const char *
: device_t(mconfig, NAMCO_06XX, tag, owner, clock)
, m_control(0)
, m_next_timer_state(false)
- , m_nmi_stretch(false)
- , m_rw_stretch(false)
- , m_rw_change(false)
+ , m_read_stretch(false)
, m_nmicpu(*this, finder_base::DUMMY_TAG)
, m_chipsel(*this)
, m_rw(*this)
@@ -255,9 +272,7 @@ void namco_06xx_device::device_start()
save_item(NAME(m_control));
save_item(NAME(m_next_timer_state));
- save_item(NAME(m_nmi_stretch));
- save_item(NAME(m_rw_stretch));
- save_item(NAME(m_rw_change));
+ save_item(NAME(m_read_stretch));
}
//-------------------------------------------------
diff --git a/src/mame/machine/namco06.h b/src/mame/machine/namco06.h
index fad249135a6..885305ef902 100644
--- a/src/mame/machine/namco06.h
+++ b/src/mame/machine/namco06.h
@@ -33,14 +33,14 @@ private:
void set_nmi(int state);
TIMER_CALLBACK_MEMBER( nmi_generate );
+ TIMER_CALLBACK_MEMBER( write_sync );
+ TIMER_CALLBACK_MEMBER( ctrl_w_sync );
// internal state
emu_timer *m_nmi_timer;
uint8_t m_control;
bool m_next_timer_state;
- bool m_nmi_stretch;
- bool m_rw_stretch;
- bool m_rw_change;
+ bool m_read_stretch;
required_device<cpu_device> m_nmicpu;
diff --git a/src/mame/machine/namco50.cpp b/src/mame/machine/namco50.cpp
index d9dad75941e..8baf8cb4bd5 100644
--- a/src/mame/machine/namco50.cpp
+++ b/src/mame/machine/namco50.cpp
@@ -159,8 +159,13 @@ uint8_t namco_50xx_device::R2_r()
void namco_50xx_device::O_w(uint8_t data)
{
- uint8_t out = (data & 0x0f);
- if (data & 0x10)
+ machine().scheduler().synchronize(timer_expired_delegate(FUNC(namco_50xx_device::O_w_sync),this), data);
+}
+
+TIMER_CALLBACK_MEMBER( namco_50xx_device::O_w_sync )
+{
+ uint8_t out = (param & 0x0f);
+ if (param & 0x10)
m_portO = (m_portO & 0x0f) | (out << 4);
else
m_portO = (m_portO & 0xf0) | (out);
diff --git a/src/mame/machine/namco50.h b/src/mame/machine/namco50.h
index 28d8b4eed04..d24a52b8f35 100644
--- a/src/mame/machine/namco50.h
+++ b/src/mame/machine/namco50.h
@@ -32,6 +32,7 @@ private:
uint8_t m_cmd;
uint8_t m_portO;
+ TIMER_CALLBACK_MEMBER( O_w_sync );
TIMER_CALLBACK_MEMBER( rw_sync );
TIMER_CALLBACK_MEMBER( write_sync );
diff --git a/src/mame/machine/namco51.cpp b/src/mame/machine/namco51.cpp
index fb4965cfd5f..1e574993a89 100644
--- a/src/mame/machine/namco51.cpp
+++ b/src/mame/machine/namco51.cpp
@@ -130,8 +130,13 @@ uint8_t namco_51xx_device::R3_r()
void namco_51xx_device::O_w(uint8_t data)
{
- uint8_t out = (data & 0x0f);
- if (data & 0x10)
+ machine().scheduler().synchronize(timer_expired_delegate(FUNC(namco_51xx_device::O_w_sync),this), data);
+}
+
+TIMER_CALLBACK_MEMBER( namco_51xx_device::O_w_sync )
+{
+ uint8_t out = (param & 0x0f);
+ if (param & 0x10)
m_portO = (m_portO & 0x0f) | (out << 4);
else
m_portO = (m_portO & 0xf0) | (out);
diff --git a/src/mame/machine/namco51.h b/src/mame/machine/namco51.h
index 392e94c735f..35cec6458f2 100644
--- a/src/mame/machine/namco51.h
+++ b/src/mame/machine/namco51.h
@@ -49,6 +49,7 @@ private:
TIMER_CALLBACK_MEMBER( rw_sync );
TIMER_CALLBACK_MEMBER( write_sync );
+ TIMER_CALLBACK_MEMBER( O_w_sync );
};
DECLARE_DEVICE_TYPE(NAMCO_51XX, namco_51xx_device)
diff --git a/src/mame/machine/naomi.cpp b/src/mame/machine/naomi.cpp
deleted file mode 100644
index 0521f62db4d..00000000000
--- a/src/mame/machine/naomi.cpp
+++ /dev/null
@@ -1,407 +0,0 @@
-// license:LGPL-2.1+
-// copyright-holders:Angelo Salese, Olivier Galibert, David Haywood, Samuele Zannoli, R. Belmont, ElSemi
-/***************************************************************************
-
-Per-game specific JVS settings / idle loop skips for the MAME Naomi driver.
-
-suchie3: check bp c0a6458 (might be protection related)
-
-tetkiwam: check bp c09613a
-
-vtennis: check wpset dee3ec8,8,w,wpdata==0xa8804000
-
-vtennis2: check bp c020130 / wpset c013ff0,f,w,wpdata==0x3f800000 -> 0xc020434 (test mode)
-
-smarinef: put cabinet in STD mode, bp c027968, wpset c0e66a6,4,w
-
-
-hotd2: bp 0xc0ba235, modify work RAM 0xc9c35e8 to be zero, bpclear
-
-hotd2o: bp 0xc0ba1f6, modify work RAM 0xc9c35a8 to be zero, bpclear
-***************************************************************************/
-
-#include "emu.h"
-#include "includes/dc.h"
-#include "includes/naomi.h"
-#include "sound/aica.h"
-
-uint64_t naomi_state::naomi_biose_idle_skip_r()
-{
-// if (m_maincpu->pc()==0xc04173c)
-// m_maincpu->spin_until_time(attotime::from_usec(500));
-//m_maincpu->spin_until_interrupt();
-// else
-// printf("%08x\n", m_maincpu->pc());
-
- return dc_ram[0x2ad238/8];
-}
-
-uint64_t naomi_state::naomi_biosh_idle_skip_r()
-{
-// if (m_maincpu->pc()==0xc045ffc)
-// m_maincpu->spin_until_time(attotime::from_usec(500));
-
-// printf("%08\n", m_maincpu->pc());
-
- return dc_ram[0x2b0600/8];
-}
-
-uint64_t naomi_state::naomi2_biose_idle_skip_r()
-{
-// if (m_maincpu->pc()==0xc04637c)
-// m_maincpu->spin_until_time(attotime::from_usec(500));
- //m_maincpu->spin_until_interrupt();
-// else
-// printf("%08x\n", m_maincpu->pc());
-
- return dc_ram[0x2b0600/8];
-}
-
-uint8_t naomi_state::asciihex_to_dec(uint8_t in)
-{
- if (in>=0x30 && in<=0x39)
- {
- return in - 0x30;
- }
- else
- if (in>=0x41 && in<=0x46)
- {
- return in - 0x37;
- }
- /*
- else
- if (in>=0x61 && in<=0x66)
- {
- return in - 0x57;
- }
- */
- else
- {
- fatalerror("unexpected value in asciihex_to_dec\n");
- }
-
-
-}
-
-// development helper function
-void naomi_state::create_pic_from_retdat()
-{
- {
- memory_region * rgn_hexregion = memregion("pichex");
- memory_region * rgn_retregion = memregion("picreturn");
- memory_region * rgn_newregion = memregion("pic");
- int outcount = 0;
-
- if (rgn_hexregion && rgn_newregion)
- {
- uint8_t* hexregion = rgn_hexregion->base();
- uint8_t* newregion = rgn_newregion->base();
-
-
- int hexoffs = 0;
- int line;
-
- hexoffs += 0x11; // skip first line // :020000040000FA
-
- for (line=0;line<0x200;line++)
- {
- int offs2;
-
- hexoffs+= 0x1; // skip :
- hexoffs+= 0x8; // skip line # (:20xxxxxx incrementing in 0x2000)
-
- for (offs2=0;offs2<0x20;offs2++)
- {
- uint8_t ascii1 = hexregion[hexoffs+0];
- uint8_t ascii2 = hexregion[hexoffs+1];
- uint8_t dec1 = asciihex_to_dec(ascii1);
- uint8_t dec2 = asciihex_to_dec(ascii2);
- uint8_t val = dec1 << 4 | dec2;
-
- //printf("%02x%02x", ascii1, ascii2);
-
- printf("%02x", val);
-
- newregion[outcount] = val;
-
- hexoffs+=2;
- outcount++;
- }
-
- hexoffs+=0x4; // skip running checksum + newline
-
- printf("\n");
-
-
- }
-
- if (rgn_retregion && rgn_newregion)
- {
- uint8_t* retregion = rgn_retregion->base();
- uint8_t* newregion = rgn_newregion->base();
-
-
- int i;
- printf("string 1 (key1)\n");
- for (i=0;i<7;i++)
- {
- printf("%02x %02x\n", newregion[0x780+i*2], retregion[0x31+i]);
-
- newregion[0x780+i*2] = retregion[0x31+i]; // patch with extracted data
- }
-
- printf("string 2 (key2)\n");
- for (i=0;i<7;i++)
- {
- printf("%02x %02x\n", newregion[0x7a0+i*2], retregion[0x29+i]);
-
- newregion[0x7a0+i*2] = retregion[0x29+i]; // patch with extracted data
- }
-
- printf("string 3 (filename)\n");
- for (i=0;i<7;i++)
- {
- printf("%02x %02x\n", newregion[0x7c0+i*2], retregion[0x21+i]);
-
- newregion[0x7c0+i*2] = retregion[0x21+i]; // patch with extracted data
- }
-
- printf("string 4 (filename?)\n");
- for (i=0;i<7;i++)
- {
- printf("%02x %02x\n", newregion[0x7e0+i*2], retregion[0x19+i]);
-
- newregion[0x7e0+i*2] = retregion[0x19+i]; // patch with extracted data
- }
- }
-
- if (rgn_newregion)
- {
- uint8_t* newregion = rgn_newregion->base();
-
- FILE *fp;
- char filename[256];
- sprintf(filename,"picbin_%s", machine().system().name);
- fp=fopen(filename, "w+b");
- if (fp)
- {
- fwrite(newregion, outcount, 1, fp);
- fclose(fp);
- }
-
- printf("wrote %04x bytes\n", outcount);
- }
-
- // hex dumps end with
- //:10400000000000000000000000000000000082002E
- //:00000001FF
-
-
- }
- }
-}
-
-void naomi_state::set_drc_options()
-{
- m_maincpu->sh2drc_set_options(SH2DRC_STRICT_VERIFY | SH2DRC_STRICT_PCREL);
- m_maincpu->sh2drc_add_fastram(0x00000000, 0x001fffff, true, m_rombase);
- m_maincpu->sh2drc_add_fastram(0x0c000000, 0x0dffffff, false, dc_ram);
-}
-
-void naomi_state::init_naomi()
-{
- //m_maincpu->space(AS_PROGRAM).install_read_handler(0xc2ad238, 0xc2ad23f, read64smo_delegate(*this, FUNC(naomi_state::naomi_biose_idle_skip_r)); // rev e bios
- m_maincpu->space(AS_PROGRAM).install_read_handler(0xc2b0600, 0xc2b0607, read64smo_delegate(*this, FUNC(naomi_state::naomi_biosh_idle_skip_r))); // rev h bios
-
- set_drc_options();
- create_pic_from_retdat();
-}
-
-void naomi2_state::init_naomi2()
-{
- m_maincpu->space(AS_PROGRAM).install_read_handler(0xc2b0600, 0xc2b0607, read64smo_delegate(*this, FUNC(naomi_state::naomi2_biose_idle_skip_r))); // rev e bios
-
- set_drc_options();
- create_pic_from_retdat();
-}
-
-INPUT_CHANGED_MEMBER(naomi_state::naomi_mp_w)
-{
- m_mp_mux = newval;
-}
-
-CUSTOM_INPUT_MEMBER(naomi_state::naomi_mp_r)
-{
- uint8_t retval = 0;
-
- int port = 0;
- for (int i = 0x80; i >= 0x08; i >>= 1, port++)
- {
- if (m_mp_mux & i)
- retval |= m_mp[port].read_safe(0);
- }
- return retval;
-}
-
-CUSTOM_INPUT_MEMBER(naomi_state::suchie3_mp_r)
-{
- uint8_t retval = 0;
-
- int port = 0;
- for (int i = 0x80; i >= 0x08; i >>= 1, port++)
- {
- if (m_mp_mux & i)
- {
- // KEY1 and KEY5 are swapped
- if (port == 0)
- retval |= m_mp[4].read_safe(0);
- else if (port == 4)
- retval |= m_mp[0].read_safe(0);
- else
- retval |= m_mp[port].read_safe(0);
- }
- }
- return retval;
-}
-
-CUSTOM_INPUT_MEMBER(naomi_state::naomi_kb_r)
-{
- // TODO: player 2 input reading
- uint8_t retval = 0;
- static const char *const keynames[] =
- {
- "P1.ROW0", "P1.ROW1", "P1.ROW2", "P1.ROW3", "P1.ROW4"
- };
-
- for(int i=0;i<5;i++)
- {
- uint32_t row;
-
- // read the current row
- row = ioport(keynames[i])->read();
-
- // if anything is pressed, convert the 32-bit raw value to keycode
- if(row != 0)
- {
- // base value x20
- retval = i * 0x20;
- for(int j=0;j<32;j++)
- {
- if(row & 1 << j)
- return retval + j;
- }
- }
- }
-
- return retval;
-}
-
-void naomi_state::init_naomi_mp()
-{
- //m_maincpu->space(AS_PROGRAM).install_read_handler(0xc2ad238, 0xc2ad23f, read64smo_delegate(*this, FUNC(naomi_state::naomi_biose_idle_skip_r)); // rev e bios
- m_maincpu->space(AS_PROGRAM).install_read_handler(0xc2b0600, 0xc2b0607, read64smo_delegate(*this, FUNC(naomi_state::naomi_biosh_idle_skip_r))); // rev h bios
- m_mp_mux = 0;
-
- set_drc_options();
- create_pic_from_retdat();
-}
-
-void naomi_state::init_naomigd()
-{
- m_maincpu->space(AS_PROGRAM).install_read_handler(0xc2ad238, 0xc2ad23f, read64smo_delegate(*this, FUNC(naomi_state::naomi_biose_idle_skip_r))); // rev e bios
- //m_maincpu->space(AS_PROGRAM).install_read_handler(0xc2b0600, 0xc2b0607, read64smo_delegate(*this, FUNC(naomi_state::naomi_biosh_idle_skip_r))); // rev h bios
-
- set_drc_options();
- create_pic_from_retdat();
-}
-
-void naomi_state::init_naomigd_mp()
-{
- m_maincpu->space(AS_PROGRAM).install_read_handler(0xc2ad238, 0xc2ad23f, read64smo_delegate(*this, FUNC(naomi_state::naomi_biose_idle_skip_r))); // rev e bios
- //m_maincpu->space(AS_PROGRAM).install_read_handler(0xc2b0600, 0xc2b0607, read64smo_delegate(*this, FUNC(naomi_state::naomi_biosh_idle_skip_r))); // rev h bios
- m_mp_mux = 0;
-
- set_drc_options();
- create_pic_from_retdat();
-}
-
-
-uint64_t naomi_state::naomigd_ggxxsla_idle_skip_r()
-{
-// if (m_maincpu->pc()==0x0c0c9adc)
-// m_maincpu->spin_until_time(attotime::from_usec(500));
-
- return dc_ram[0x1aae18/8];
-}
-
-void naomi_state::init_ggxxsla()
-{
- m_maincpu->space(AS_PROGRAM).install_read_handler(0xc1aae18, 0xc1aae1f, read64smo_delegate(*this, FUNC(naomi_state::naomigd_ggxxsla_idle_skip_r)));
- init_naomigd();
-}
-
-uint64_t naomi_state::naomigd_ggxx_idle_skip_r()
-{
-// if (m_maincpu->pc()==0xc0b5c3c) // or 0xc0bab0c
-// m_maincpu->spin_until_time(attotime::from_usec(500));
-
- return dc_ram[0x1837b8/8];
-}
-
-
-void naomi_state::init_ggxx()
-{
- m_maincpu->space(AS_PROGRAM).install_read_handler(0xc1837b8, 0xc1837bf, read64smo_delegate(*this, FUNC(naomi_state::naomigd_ggxx_idle_skip_r)));
- init_naomigd();
-}
-
-uint64_t naomi_state::naomigd_ggxxrl_idle_skip_r()
-{
-// if (m_maincpu->pc()==0xc0b84bc) // or 0xc0bab0c
-// m_maincpu->spin_until_time(attotime::from_usec(500));
-
- //printf("%08x\n", m_maincpu->pc());
-
- return dc_ram[0x18d6c8/8];
-}
-
-void naomi_state::init_ggxxrl()
-{
- m_maincpu->space(AS_PROGRAM).install_read_handler(0xc18d6c8, 0xc18d6cf, read64smo_delegate(*this, FUNC(naomi_state::naomigd_ggxxrl_idle_skip_r)));
- init_naomigd();
-}
-
-/* at least speeds up the annoying copyright screens ;-) */
-uint64_t naomi_state::naomigd_sfz3ugd_idle_skip_r()
-{
-// if (m_maincpu->pc()==0xc36a2dc)
-// m_maincpu->spin_until_time(attotime::from_usec(500));
-
- return dc_ram[0x5dc900/8];
-}
-
-void naomi_state::init_sfz3ugd()
-{
- m_maincpu->space(AS_PROGRAM).install_read_handler(0xc5dc900, 0xc5dc907, read64smo_delegate(*this, FUNC(naomi_state::naomigd_sfz3ugd_idle_skip_r)));
- init_naomigd();
-}
-
-
-uint64_t naomi_state::hotd2_idle_skip_r()
-{
-// if (m_maincpu->pc()==0xc0cfcbc)
-// m_maincpu->spin_until_time(attotime::from_usec(500));
- //m_maincpu->spin_until_interrupt();
-// else
-// printf("%08x\n", m_maincpu->pc());
-
- return dc_ram[0xa25fb8/8];
-}
-
-void naomi_state::init_hotd2()
-{
- m_maincpu->space(AS_PROGRAM).install_read_handler(0xca25fb8, 0xca25fbf, read64smo_delegate(*this, FUNC(naomi_state::hotd2_idle_skip_r)));
- set_drc_options();
-}
-
-// f355 PC=0xc065f7c RAM=0xc26dafc
diff --git a/src/mame/machine/naomig1.cpp b/src/mame/machine/naomig1.cpp
index f40958fa50b..716714e1da2 100644
--- a/src/mame/machine/naomig1.cpp
+++ b/src/mame/machine/naomig1.cpp
@@ -58,7 +58,7 @@ void naomi_g1_device::device_reset()
set_ext_irq(CLEAR_LINE);
}
-void naomi_g1_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
+void naomi_g1_device::device_timer(emu_timer &timer, device_timer_id id, int param)
{
timer.adjust(attotime::never);
if(!gdst)
diff --git a/src/mame/machine/naomig1.h b/src/mame/machine/naomig1.h
index 3c2e2dcfd91..32560d4eab9 100644
--- a/src/mame/machine/naomig1.h
+++ b/src/mame/machine/naomig1.h
@@ -57,7 +57,7 @@ protected:
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_timer(emu_timer &timer, device_timer_id id, int param) override;
virtual void dma_get_position(uint8_t *&base, uint32_t &limit, bool to_maincpu) = 0;
virtual void dma_advance(uint32_t size) = 0;
diff --git a/src/mame/machine/naomigd.cpp b/src/mame/machine/naomigd.cpp
index cc6fbf34f9f..3d7cdcbcd1f 100644
--- a/src/mame/machine/naomigd.cpp
+++ b/src/mame/machine/naomigd.cpp
@@ -448,7 +448,7 @@ void idegdrom_device::map_extra(uint64_t memory_window_start, uint64_t memory_wi
static void gdrom_devices(device_slot_interface &device)
{
- device.option_add(":gdrom", GDROM);
+ device.option_add("gdrom", GDROM);
}
@@ -459,7 +459,7 @@ WRITE_LINE_MEMBER(idegdrom_device::ide_irq)
void idegdrom_device::device_add_mconfig(machine_config &config)
{
- BUS_MASTER_IDE_CONTROLLER(config, m_ide).options(gdrom_devices, ":gdrom", nullptr, true);
+ BUS_MASTER_IDE_CONTROLLER(config, m_ide).options(gdrom_devices, "gdrom", nullptr, true);
m_ide->irq_handler().set(*this, FUNC(idegdrom_device::ide_irq));
m_ide->set_bus_master_space(space_owner_tag, space_owner_id);
}
diff --git a/src/mame/machine/nb1412m2.cpp b/src/mame/machine/nb1412m2.cpp
index 75d396e2c16..9e4ea2761d3 100644
--- a/src/mame/machine/nb1412m2.cpp
+++ b/src/mame/machine/nb1412m2.cpp
@@ -184,7 +184,7 @@ void nb1412m2_device::device_reset()
m_dac_timer->adjust(attotime::never);
}
-void nb1412m2_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
+void nb1412m2_device::device_timer(emu_timer &timer, device_timer_id id, int param)
{
switch (id)
{
diff --git a/src/mame/machine/nb1412m2.h b/src/mame/machine/nb1412m2.h
index afdbc30a8f4..ca6074c3ccb 100644
--- a/src/mame/machine/nb1412m2.h
+++ b/src/mame/machine/nb1412m2.h
@@ -39,7 +39,7 @@ protected:
// virtual void device_add_mconfig(machine_config &config) override;
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_timer(emu_timer &timer, device_timer_id id, int param) override;
virtual space_config_vector memory_space_config() const override;
private:
diff --git a/src/mame/machine/nb1413m3.cpp b/src/mame/machine/nb1413m3.cpp
index 00f99cd24ac..b4eaff9cff0 100644
--- a/src/mame/machine/nb1413m3.cpp
+++ b/src/mame/machine/nb1413m3.cpp
@@ -103,12 +103,12 @@ void nb1413m3_device::device_reset()
DEVICE HANDLERS
*****************************************************************************/
-void nb1413m3_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
+void nb1413m3_device::device_timer(emu_timer &timer, device_timer_id id, int param)
{
switch (id)
{
case TIMER_CB:
- timer_callback(ptr, param);
+ timer_callback(param);
break;
default:
throw emu_fatalerror("Unknown id in nb1413m3_device::device_timer");
diff --git a/src/mame/machine/nb1413m3.h b/src/mame/machine/nb1413m3.h
index b2b53160d5e..63586ac182e 100644
--- a/src/mame/machine/nb1413m3.h
+++ b/src/mame/machine/nb1413m3.h
@@ -180,7 +180,7 @@ protected:
// device-level overrides
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_timer(emu_timer &timer, device_timer_id id, int param) override;
private:
diff --git a/src/mame/machine/nes.cpp b/src/mame/machine/nes.cpp
index 993215b9b1c..ed62101c4af 100644
--- a/src/mame/machine/nes.cpp
+++ b/src/mame/machine/nes.cpp
@@ -43,6 +43,15 @@ void nes_state::machine_start()
{
address_space &space = m_maincpu->space(AS_PROGRAM);
+ // Fill main RAM with an arbitrary pattern (alternating 0x00/0xff) for software that depends on its contents at boot up (tsk tsk!)
+ // The fill value is a compromise since certain games malfunction with zero-filled memory, others with one-filled memory
+ // Examples: Minna no Taabou won't boot with all 0x00, Sachen's Dancing Block won't boot with all 0xff, Terminator 2 skips its copyright screen with all 0x00
+ for (int i = 0; i < 0x800; i += 2)
+ {
+ m_mainram[i] = 0x00;
+ m_mainram[i + 1] = 0xff;
+ }
+
// CIRAM (Character Internal RAM)
// NES has 2KB of internal RAM which can be used to fill the 4x1KB banks of PPU RAM at $2000-$2fff
// Line A10 is exposed to the carts, so that games can change CIRAM mapping in PPU (we emulate this with the set_nt_mirroring
@@ -81,6 +90,7 @@ void nes_state::machine_start()
BMC_8157,
BMC_970630C,
BMC_GOLD150,
+ BMC_KC885,
BMC_TELETUBBIES,
BMC_VT5201,
BTL_PALTHENA,
@@ -185,20 +195,13 @@ void nes_base_state::nes_in0_w(uint8_t data)
uint8_t nes_state::fc_in0_r()
{
uint8_t ret = 0x40;
- // bit 0 to controller port
+ // bit 0 from controller port
ret |= m_ctrl1->read_bit0();
- // expansion port bits (in the original FC, P2 controller was hooked to these lines
- // too, so in principle some homebrew hardware modification could use the same
- // connection with P1 controller too)
- ret |= m_ctrl1->read_exp(0);
- ret |= m_ctrl2->read_exp(0);
-
- // at the same time, we might have a standard joypad connected to the expansion port which
- // shall be read as P3 (this is needed here to avoid implementing the expansion port as a
- // different device compared to the standard control port... it might be changed later)
- ret |= (m_exp->read_bit0() << 1);
- // finally, read the expansion port as expected
+ // bit 2 from P2 controller microphone
+ ret |= m_ctrl2->read_bit2();
+
+ // and bit 1 comes from expansion port
ret |= m_exp->read_exp(0);
return ret;
}
@@ -206,17 +209,10 @@ uint8_t nes_state::fc_in0_r()
uint8_t nes_state::fc_in1_r()
{
uint8_t ret = 0x40;
- // bit 0 to controller port
+ // bit 0 from controller port
ret |= m_ctrl2->read_bit0();
- // expansion port bits (in the original FC, P2 controller was hooked to these lines
- // too, so in principle some homebrew hardware modification could use the same
- // connection with P1 controller too)
- ret |= m_ctrl1->read_exp(1);
- ret |= m_ctrl2->read_exp(1);
-
- // finally, read the expansion port as expected (standard pad cannot be hooked as P4, so
- // no read_bit0 here)
+ // bits 1-4 from expansion port (in theory bit 0 also can be read on AV Famicom when controller is unplugged)
ret |= m_exp->read_exp(1);
return ret;
}
diff --git a/src/mame/machine/nextkbd.cpp b/src/mame/machine/nextkbd.cpp
index f19aee60ce5..eadc0606563 100644
--- a/src/mame/machine/nextkbd.cpp
+++ b/src/mame/machine/nextkbd.cpp
@@ -124,7 +124,7 @@ void nextkbd_device::update_mouse(bool force_update)
send();
}
-void nextkbd_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
+void nextkbd_device::device_timer(emu_timer &timer, device_timer_id id, int param)
{
if(!fifo_empty())
send();
diff --git a/src/mame/machine/nextkbd.h b/src/mame/machine/nextkbd.h
index b5578f71e09..60e6d84735e 100644
--- a/src/mame/machine/nextkbd.h
+++ b/src/mame/machine/nextkbd.h
@@ -35,7 +35,7 @@ public:
protected:
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_timer(emu_timer &timer, device_timer_id id, int param) override;
virtual ioport_constructor device_input_ports() const override;
private:
diff --git a/src/mame/machine/ng_memcard.cpp b/src/mame/machine/ng_memcard.cpp
index e97cb1f771b..c82549cba7c 100644
--- a/src/mame/machine/ng_memcard.cpp
+++ b/src/mame/machine/ng_memcard.cpp
@@ -23,7 +23,7 @@ DEFINE_DEVICE_TYPE(NG_MEMCARD, ng_memcard_device, "ng_memcard", "NeoGeo Memory C
ng_memcard_device::ng_memcard_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
: device_t(mconfig, NG_MEMCARD, tag, owner, clock)
- , device_image_interface(mconfig, *this)
+ , device_memcard_image_interface(mconfig, *this)
{
}
diff --git a/src/mame/machine/ng_memcard.h b/src/mame/machine/ng_memcard.h
index 19870d4d166..186a998cc17 100644
--- a/src/mame/machine/ng_memcard.h
+++ b/src/mame/machine/ng_memcard.h
@@ -12,21 +12,18 @@
#pragma once
+#include "imagedev/memcard.h"
+
// ======================> ng_memcard_device
-class ng_memcard_device : public device_t, public device_image_interface
+class ng_memcard_device : public device_t, public device_memcard_image_interface
{
public:
// construction/destruction
ng_memcard_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
// device_image_interface implementation
- virtual iodevice_t image_type() const noexcept override { return IO_MEMCARD; }
- virtual bool is_readable() const noexcept override { return true; }
- virtual bool is_writeable() const noexcept override { return true; }
- virtual bool is_creatable() const noexcept override { return true; }
- virtual bool must_be_loaded() const noexcept override { return false; }
virtual bool is_reset_on_load() const noexcept override { return false; }
virtual const char *file_extensions() const noexcept override { return "neo"; }
diff --git a/src/mame/machine/p2000t_mdcr.cpp b/src/mame/machine/p2000t_mdcr.cpp
index 568364de3cf..8e6fa4d2a83 100644
--- a/src/mame/machine/p2000t_mdcr.cpp
+++ b/src/mame/machine/p2000t_mdcr.cpp
@@ -132,7 +132,7 @@ void mdcr_device::device_post_load()
m_cassette->seek(m_save_tape_time, SEEK_SET);
}
-void mdcr_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
+void mdcr_device::device_timer(emu_timer &timer, device_timer_id id, int param)
{
if (!m_recording && m_cassette->motor_on())
{
diff --git a/src/mame/machine/p2000t_mdcr.h b/src/mame/machine/p2000t_mdcr.h
index 9b312ed42d7..d114414e257 100644
--- a/src/mame/machine/p2000t_mdcr.h
+++ b/src/mame/machine/p2000t_mdcr.h
@@ -75,7 +75,7 @@ protected:
virtual void device_start() override;
virtual void device_pre_save() override;
virtual void device_post_load() override;
- virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override;
+ virtual void device_timer(emu_timer &timer, device_timer_id id, int param) override;
virtual void device_add_mconfig(machine_config &config) override;
diff --git a/src/mame/machine/pc1512kb.cpp b/src/mame/machine/pc1512kb.cpp
index f026f37cfd1..288bdb476ac 100644
--- a/src/mame/machine/pc1512kb.cpp
+++ b/src/mame/machine/pc1512kb.cpp
@@ -256,7 +256,7 @@ void pc1512_keyboard_device::device_reset()
// device_timer - handler timer events
//-------------------------------------------------
-void pc1512_keyboard_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
+void pc1512_keyboard_device::device_timer(emu_timer &timer, device_timer_id id, int param)
{
if (!m_clock_in)
{
diff --git a/src/mame/machine/pc1512kb.h b/src/mame/machine/pc1512kb.h
index bbd6fb441f9..538f8c51998 100644
--- a/src/mame/machine/pc1512kb.h
+++ b/src/mame/machine/pc1512kb.h
@@ -48,7 +48,7 @@ protected:
// device-level overrides
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_timer(emu_timer &timer, device_timer_id id, int param) override;
// optional information overrides
virtual const tiny_rom_entry *device_rom_region() const override;
diff --git a/src/mame/machine/pc80s31k.cpp b/src/mame/machine/pc80s31k.cpp
index eb05acb8cfd..7ecafea85a8 100644
--- a/src/mame/machine/pc80s31k.cpp
+++ b/src/mame/machine/pc80s31k.cpp
@@ -295,7 +295,7 @@ void pc80s31_device::device_add_mconfig(machine_config &config)
// device_timer - device-specific timers
//-------------------------------------------------
-void pc80s31_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
+void pc80s31_device::device_timer(emu_timer &timer, device_timer_id id, int param)
{
assert(id == 0);
diff --git a/src/mame/machine/pc80s31k.h b/src/mame/machine/pc80s31k.h
index b21d2845daf..e1050f60799 100644
--- a/src/mame/machine/pc80s31k.h
+++ b/src/mame/machine/pc80s31k.h
@@ -38,7 +38,7 @@ protected:
virtual void device_start() override;
virtual void device_reset() override;
virtual const tiny_rom_entry *device_rom_region() const override;
- virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override;
+ virtual void device_timer(emu_timer &timer, device_timer_id id, int param) override;
virtual void fdc_io(address_map &map);
diff --git a/src/mame/machine/pc9801_kbd.cpp b/src/mame/machine/pc9801_kbd.cpp
index a5e715cc5c2..12dc4eaa2e9 100644
--- a/src/mame/machine/pc9801_kbd.cpp
+++ b/src/mame/machine/pc9801_kbd.cpp
@@ -265,7 +265,7 @@ void pc9801_kbd_device::device_reset()
// device_timer - handler timer events
//-------------------------------------------------
-void pc9801_kbd_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
+void pc9801_kbd_device::device_timer(emu_timer &timer, device_timer_id id, int param)
{
if(id == RX_TIMER)
{
diff --git a/src/mame/machine/pc9801_kbd.h b/src/mame/machine/pc9801_kbd.h
index 3c5c811c9d1..80c8aaa81d2 100644
--- a/src/mame/machine/pc9801_kbd.h
+++ b/src/mame/machine/pc9801_kbd.h
@@ -37,7 +37,7 @@ protected:
virtual void device_validity_check(validity_checker &valid) const override;
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_timer(emu_timer &timer, device_timer_id id, int param) override;
devcb_write_line m_write_irq;
diff --git a/src/mame/machine/pce220_ser.cpp b/src/mame/machine/pce220_ser.cpp
index a6459ebac6c..7854fdc8c09 100644
--- a/src/mame/machine/pce220_ser.cpp
+++ b/src/mame/machine/pce220_ser.cpp
@@ -88,7 +88,7 @@ void pce220_serial_device::device_reset()
// device_timer - handler timer events
//-------------------------------------------------
-void pce220_serial_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
+void pce220_serial_device::device_timer(emu_timer &timer, device_timer_id id, int param)
{
if (id == TIMER_SEND && m_enabled)
{
diff --git a/src/mame/machine/pce220_ser.h b/src/mame/machine/pce220_ser.h
index c9249bf5853..4a5f13be782 100644
--- a/src/mame/machine/pce220_ser.h
+++ b/src/mame/machine/pce220_ser.h
@@ -33,14 +33,14 @@ public:
virtual void call_unload() override;
virtual image_init_result call_create(int format_type, util::option_resolution *format_options) override;
- virtual iodevice_t image_type() const noexcept override { return IO_SERIAL; }
-
virtual bool is_readable() const noexcept override { return true; }
virtual bool is_writeable() const noexcept override { return true; }
virtual bool is_creatable() const noexcept override { return true; }
- virtual bool must_be_loaded() const noexcept override { return false; }
virtual bool is_reset_on_load() const noexcept override { return false; }
+ virtual bool support_command_line_image_creation() const noexcept override { return true; }
virtual const char *file_extensions() const noexcept override { return "txt,ihx"; }
+ virtual const char *image_type_name() const noexcept override { return "serial"; }
+ virtual const char *image_brief_type_name() const noexcept override { return "serl"; }
// specific implementation
uint8_t in_xin(void) { return m_xin & 0x01; }
@@ -59,7 +59,7 @@ protected:
// device-level overrides
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_timer(emu_timer &timer, device_timer_id id, int param) override;
private:
// internal device state
diff --git a/src/mame/machine/pgm2_memcard.cpp b/src/mame/machine/pgm2_memcard.cpp
index 3e52d7a4eb7..f50c8b9e07b 100644
--- a/src/mame/machine/pgm2_memcard.cpp
+++ b/src/mame/machine/pgm2_memcard.cpp
@@ -24,7 +24,7 @@ DEFINE_DEVICE_TYPE(PGM2_MEMCARD, pgm2_memcard_device, "pgm2_memcard", "PGM2 Memo
pgm2_memcard_device::pgm2_memcard_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
: device_t(mconfig, PGM2_MEMCARD, tag, owner, clock)
- , device_image_interface(mconfig, *this)
+ , device_memcard_image_interface(mconfig, *this)
{
}
diff --git a/src/mame/machine/pgm2_memcard.h b/src/mame/machine/pgm2_memcard.h
index 41ec6ea2a59..b2239a1b8c6 100644
--- a/src/mame/machine/pgm2_memcard.h
+++ b/src/mame/machine/pgm2_memcard.h
@@ -13,6 +13,8 @@
#pragma once
+#include "imagedev/memcard.h"
+
/***************************************************************************
FUNCTION PROTOTYPES
@@ -21,18 +23,12 @@
// ======================> pgm2_memcard_device
class pgm2_memcard_device : public device_t,
- public device_image_interface
+ public device_memcard_image_interface
{
public:
// construction/destruction
pgm2_memcard_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
- virtual iodevice_t image_type() const noexcept override { return IO_MEMCARD; }
-
- virtual bool is_readable() const noexcept override { return true; }
- virtual bool is_writeable() const noexcept override { return true; }
- virtual bool is_creatable() const noexcept override { return true; }
- virtual bool must_be_loaded() const noexcept override { return false; }
virtual bool is_reset_on_load() const noexcept override { return false; }
virtual const char *file_extensions() const noexcept override { return "pg2,bin,mem"; }
diff --git a/src/mame/machine/pmd85.cpp b/src/mame/machine/pmd85.cpp
index 93a9edacc8b..c2895d0a7d3 100644
--- a/src/mame/machine/pmd85.cpp
+++ b/src/mame/machine/pmd85.cpp
@@ -620,12 +620,12 @@ void pmd85_state::mato_io_w(offs_t offset, uint8_t data)
}
}
-void pmd85_state::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
+void pmd85_state::device_timer(emu_timer &timer, device_timer_id id, int param)
{
switch (id)
{
case TIMER_CASSETTE:
- cassette_timer_callback(ptr, param);
+ cassette_timer_callback(param);
break;
default:
throw emu_fatalerror("Unknown id in pmd85_state::device_timer");
diff --git a/src/mame/machine/pocketc.cpp b/src/mame/machine/pocketc.cpp
index 48ac3aa3d08..3530366960d 100644
--- a/src/mame/machine/pocketc.cpp
+++ b/src/mame/machine/pocketc.cpp
@@ -14,7 +14,7 @@ READ_LINE_MEMBER(pocketc_state::brk_r)
return BIT(m_extra->read(), 0);
}
-void pocketc_state::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
+void pocketc_state::device_timer(emu_timer &timer, device_timer_id id, int param)
{
switch (id)
{
diff --git a/src/mame/machine/psion_pack.cpp b/src/mame/machine/psion_pack.cpp
index 09c523e09e5..104da5ceae9 100644
--- a/src/mame/machine/psion_pack.cpp
+++ b/src/mame/machine/psion_pack.cpp
@@ -23,6 +23,8 @@
#include "emu.h"
#include "psion_pack.h"
+#include "softlist_dev.h"
+
#include "opresolv.h"
// Datapack control lines
@@ -64,7 +66,7 @@ DEFINE_DEVICE_TYPE(PSION_DATAPACK, datapack_device, "datapack", "Psion Datapack"
datapack_device::datapack_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
: device_t(mconfig, PSION_DATAPACK, tag, owner, clock)
- , device_image_interface(mconfig, *this)
+ , device_memcard_image_interface(mconfig, *this)
{
}
@@ -101,6 +103,16 @@ void datapack_device::device_config_complete()
//-------------------------------------------------
+// get_software_list_loader -
+//-------------------------------------------------
+
+const software_list_loader &datapack_device::get_software_list_loader() const
+{
+ return image_software_list_loader::instance();
+}
+
+
+//-------------------------------------------------
// option_guide for create new image
//-------------------------------------------------
diff --git a/src/mame/machine/psion_pack.h b/src/mame/machine/psion_pack.h
index 35e69338d38..41b256f6df3 100644
--- a/src/mame/machine/psion_pack.h
+++ b/src/mame/machine/psion_pack.h
@@ -9,7 +9,7 @@
#ifndef MAME_MACHINE_PSION_PACK_H
#define MAME_MACHINE_PSION_PACK_H
-#include "softlist_dev.h"
+#include "imagedev/memcard.h"
/***************************************************************************
@@ -19,7 +19,7 @@
// ======================> datapack_device
class datapack_device : public device_t,
- public device_image_interface
+ public device_memcard_image_interface
{
public:
// construction/destruction
@@ -31,14 +31,11 @@ public:
virtual void call_unload() override;
virtual image_init_result call_create(int format_type, util::option_resolution *create_args) override;
- virtual iodevice_t image_type() const noexcept override { return IO_CARTSLOT; }
- virtual bool is_readable() const noexcept override { return true; }
- virtual bool is_writeable() const noexcept override { return true; }
- virtual bool is_creatable() const noexcept override { return true; }
- virtual bool must_be_loaded() const noexcept override { return false; }
virtual bool is_reset_on_load() const noexcept override { return false; }
virtual const char *image_interface() const noexcept override { return "psion_pack"; }
virtual const char *file_extensions() const noexcept override { return "opk"; }
+ virtual const char *image_type_name() const noexcept override { return "datapack"; }
+ virtual const char *image_brief_type_name() const noexcept override { return "dpak"; }
virtual const util::option_guide &create_option_guide() const override;
// specific implementation
@@ -56,7 +53,7 @@ protected:
virtual void device_config_complete() override;
// device_image_interface implementation
- virtual const software_list_loader &get_software_list_loader() const override { return image_software_list_loader::instance(); }
+ virtual const software_list_loader &get_software_list_loader() const override;
private:
// internal device state
diff --git a/src/mame/machine/psxcd.cpp b/src/mame/machine/psxcd.cpp
index 6c9580c3bd0..0d903ebc874 100644
--- a/src/mame/machine/psxcd.cpp
+++ b/src/mame/machine/psxcd.cpp
@@ -116,6 +116,7 @@ void psxcd_device::device_start()
{
m_timers[i] = timer_alloc(i);
m_timerinuse[i] = false;
+ m_results[i] = nullptr;
}
save_item(NAME(cmdbuf));
@@ -145,8 +146,8 @@ void psxcd_device::device_stop()
{
for (int i = 0; i < MAX_PSXCD_TIMERS; i++)
{
- if(m_timerinuse[i] && m_timers[i]->ptr())
- delete (command_result *)m_timers[i]->ptr();
+ if(m_timerinuse[i] && m_results[i])
+ delete m_results[i];
}
while(res_queue)
{
@@ -163,8 +164,8 @@ void psxcd_device::device_reset()
for (int i = 0; i < MAX_PSXCD_TIMERS; i++)
{
- if(m_timerinuse[i] && m_timers[i]->ptr())
- delete (command_result *)m_timers[i]->ptr();
+ if(m_timerinuse[i] && m_results[i])
+ delete m_results[i];
m_timers[i]->adjust(attotime::never, 0, attotime::never);
m_timerinuse[i] = false;
}
@@ -1182,7 +1183,7 @@ void psxcd_device::stop_read()
m_spu->flush_cdda(sector);
}
-void psxcd_device::device_timer(emu_timer &timer, device_timer_id tid, int param, void *ptr)
+void psxcd_device::device_timer(emu_timer &timer, device_timer_id tid, int param)
{
if (!m_timerinuse[tid])
{
@@ -1197,7 +1198,7 @@ void psxcd_device::device_timer(emu_timer &timer, device_timer_id tid, int param
{
verboselog(*this, 1, "psxcd: event cmd complete\n");
- cmd_complete((command_result *)ptr);
+ cmd_complete(m_results[tid]);
break;
}
@@ -1225,7 +1226,7 @@ int psxcd_device::add_system_event(int type, uint64_t t, command_result *ptr)
if(!m_timerinuse[i])
{
m_timers[i]->adjust(attotime::from_hz(hz), type, attotime::never);
- m_timers[i]->set_ptr(ptr);
+ m_results[i] = ptr;
m_timerinuse[i] = true;
return i;
}
diff --git a/src/mame/machine/psxcd.h b/src/mame/machine/psxcd.h
index b8146a3bc42..9e5dc1a12bc 100644
--- a/src/mame/machine/psxcd.h
+++ b/src/mame/machine/psxcd.h
@@ -35,7 +35,7 @@ protected:
virtual void device_start() override;
virtual void device_stop() 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_timer(emu_timer &timer, device_timer_id id, int param) override;
virtual const tiny_rom_entry *device_rom_region() const override;
private:
@@ -149,6 +149,7 @@ private:
uint32_t m_sysclock;
emu_timer *m_timers[MAX_PSXCD_TIMERS];
bool m_timerinuse[MAX_PSXCD_TIMERS];
+ command_result *m_results[MAX_PSXCD_TIMERS];
devcb_write_line m_irq_handler;
required_device<cpu_device> m_maincpu;
diff --git a/src/mame/machine/qx10kbd.cpp b/src/mame/machine/qx10kbd.cpp
index 9692f9b13a5..a3ffff7c637 100644
--- a/src/mame/machine/qx10kbd.cpp
+++ b/src/mame/machine/qx10kbd.cpp
@@ -37,7 +37,7 @@ WRITE_LINE_MEMBER(qx10_keyboard_device::input_txd)
m_rxd = state;
}
-void qx10_keyboard_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
+void qx10_keyboard_device::device_timer(emu_timer &timer, device_timer_id id, int param)
{
m_clk_state = !m_clk_state;
}
diff --git a/src/mame/machine/qx10kbd.h b/src/mame/machine/qx10kbd.h
index 84961e060d7..84cfd0be77c 100644
--- a/src/mame/machine/qx10kbd.h
+++ b/src/mame/machine/qx10kbd.h
@@ -22,7 +22,7 @@ public:
protected:
virtual const tiny_rom_entry *device_rom_region() const override;
virtual void device_add_mconfig(machine_config &config) override;
- virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override;
+ virtual void device_timer(emu_timer &timer, device_timer_id id, int param) override;
virtual void device_start() override;
private:
diff --git a/src/mame/machine/rmnimbus.cpp b/src/mame/machine/rmnimbus.cpp
index 040af0b382a..9805cb0a4ef 100644
--- a/src/mame/machine/rmnimbus.cpp
+++ b/src/mame/machine/rmnimbus.cpp
@@ -118,7 +118,7 @@ chdman createhd -o ST125N.chd -chs 41921,1,1 -ss 512
#define MOUSE_RBUTTON 0x20
// Frequency in Hz to poll for mouse movement.
-#define MOUSE_POLL_FREQUENCY 5000
+#define MOUSE_POLL_FREQUENCY 500
#define MOUSE_INT_ENABLED(state) (((state)->m_iou_reg092 & MOUSE_INT_ENABLE) ? 1 : 0)
@@ -137,8 +137,8 @@ chdman createhd -o ST125N.chd -chs 41921,1,1 -ss 512
/* Debugging */
-#define DEBUG_SET(flags) ((m_debug_machine & (flags))==(flags))
-#define DEBUG_SET_STATE(flags) ((state->m_debug_machine & (flags))==(flags))
+#define DEBUG_SET(flags) ((m_debug_machine & (flags))==(flags))
+#define DEBUG_SET_STATE(flags) ((state->m_debug_machine & (flags))==(flags))
#define DEBUG_NONE 0x0000000
#define DECODE_BIOS 0x0000002
@@ -228,7 +228,10 @@ void rmnimbus_state::machine_start()
}
m_debug_machine=DEBUG_NONE;
+ m_debug_trap=0;
+ m_voice_enabled=false;
m_fdc->dden_w(0);
+ //m_fdc->overide_delays(64,m_fdc->get_cmd_delay());
}
void rmnimbus_state::debug_command(const std::vector<std::string> &params)
@@ -254,38 +257,59 @@ static int instruction_hook(device_t &device, offs_t curpc)
{
rmnimbus_state *state = device.machine().driver_data<rmnimbus_state>();
address_space &space = device.memory().space(AS_PROGRAM);
- uint8_t *addr_ptr;
+ uint8_t *addr_ptr;
+ uint8_t first;
addr_ptr = (uint8_t*)space.get_read_ptr(curpc);
- if ((addr_ptr !=nullptr) && (addr_ptr[0]==0xCD))
+ first = (curpc & 0x01) ? 1 : 0;
+
+ if(DEBUG_SET_STATE(DECODE_BIOS) && (curpc == state->m_debug_trap) && (0 != state->m_debug_trap))
{
- if(DEBUG_SET_STATE(DECODE_BIOS) && (addr_ptr[1]==0xF0))
- {
- if(DEBUG_SET_STATE(DECODE_BIOS_RAW))
- state->decode_subbios(&device,curpc,1);
- else
- state->decode_subbios(&device,curpc,0);
- }
+ state->decode_subbios_return(&device,curpc);
+ }
+
+ if ((addr_ptr !=nullptr) && (addr_ptr[first]==0xCD))
+ {
+ if(DEBUG_SET_STATE(DECODE_BIOS) && (addr_ptr[first+1]==0xF0))
+ state->decode_subbios(&device,curpc);
- if(DEBUG_SET_STATE(DECODE_DOS21) && (addr_ptr[1]==0x21))
+ if(DEBUG_SET_STATE(DECODE_DOS21) && (addr_ptr[first+1]==0x21))
state->decode_dos21(&device,curpc);
}
return 0;
}
+void rmnimbus_state::decode_subbios_return(device_t *device, offs_t pc)
+{
+ uint16_t ax = m_maincpu->state_int(I8086_AX);
+ uint16_t ds = m_maincpu->state_int(I8086_DS);
+ uint16_t si = m_maincpu->state_int(I8086_SI);
+
+ if(!DEBUG_SET(DECODE_BIOS_RAW))
+ {
+ logerror("at %05X sub-bios return code : %04X\n",pc,ax);
+ decode_dssi_generic(ds,si);
+ logerror("=======================================================================\n");
+ }
+ else
+ logerror("%05X :: %04X\n",pc,ax);
+
+ m_debug_trap=0;
+}
+
#define set_type(type_name) sprintf(type_str,type_name)
#define set_drv(drv_name) sprintf(drv_str,drv_name)
#define set_func(func_name) sprintf(func_str,func_name)
-void rmnimbus_state::decode_subbios(device_t *device,offs_t pc, uint8_t raw_flag)
+void rmnimbus_state::decode_subbios(device_t *device,offs_t pc)
{
char type_str[80];
char drv_str[80];
char func_str[80];
- void (rmnimbus_state::*dump_dssi)(uint16_t, uint16_t, uint8_t) = &rmnimbus_state::decode_dssi_none;
+ void (rmnimbus_state::*dump_dssi)(uint16_t, uint16_t) = &rmnimbus_state::decode_dssi_none;
uint16_t ax = m_maincpu->state_int(I8086_AX);
uint16_t bx = m_maincpu->state_int(I8086_BX);
@@ -293,12 +317,15 @@ void rmnimbus_state::decode_subbios(device_t *device,offs_t pc, uint8_t raw_flag
uint16_t ds = m_maincpu->state_int(I8086_DS);
uint16_t si = m_maincpu->state_int(I8086_SI);
+ // Set the address to trap after the sub-bios call.
+ m_debug_trap=pc+2;
+
// *** TEMP Don't show f_enquire_display_line calls !
if((cx==6) && (ax==43))
return;
// *** END TEMP
- if(!raw_flag)
+ if(!DEBUG_SET(DECODE_BIOS_RAW))
{
logerror("=======================================================================\n");
logerror("Sub-bios call at %08X, AX=%04X, BX=%04X, CX=%04X, DS:SI=%04X:%04X\n",pc,ax,bx,cx,ds,si);
@@ -360,6 +387,8 @@ void rmnimbus_state::decode_subbios(device_t *device,offs_t pc, uint8_t raw_flag
case 4 : set_drv("d_eeprom"); break;
}
+ dump_dssi = &rmnimbus_state::decode_dssi_generic;
+
switch(ax)
{
case 0 : set_func("f_get_version_number"); break;
@@ -368,12 +397,11 @@ void rmnimbus_state::decode_subbios(device_t *device,offs_t pc, uint8_t raw_flag
case 3 : set_func("f_get_device_status"); break;
case 4 : set_func("f_read_n_sectors"); dump_dssi = &rmnimbus_state::decode_dssi_f_rw_sectors; break;
case 5 : set_func("f_write_n_sectors"); dump_dssi = &rmnimbus_state::decode_dssi_f_rw_sectors; break;
- case 6 : set_func("f_verify_n_sectors"); break;
+ case 6 : set_func("f_verify_n_sectors"); dump_dssi = &rmnimbus_state::decode_dssi_f_rw_sectors; break;
case 7 : set_func("f_media_check"); break;
case 8 : set_func("f_recalibrate"); break;
case 9 : set_func("f_motors_off"); break;
}
- dump_dssi = &rmnimbus_state::decode_dssi_f_rw_sectors;
}; break;
@@ -602,43 +630,42 @@ void rmnimbus_state::decode_subbios(device_t *device,offs_t pc, uint8_t raw_flag
}; break;
}
- if(raw_flag)
+ if(DEBUG_SET(DECODE_BIOS_RAW))
{
- (this->*dump_dssi)(ds, si, raw_flag);
+ (this->*dump_dssi)(ds, si);
}
else
{
logerror("Type=%s, Driver=%s, Function=%s\n",type_str,drv_str,func_str);
- (this->*dump_dssi)(ds, si, raw_flag);
+ (this->*dump_dssi)(ds, si);
logerror("=======================================================================\n");
}
}
-static inline void *get_dssi_ptr(address_space &space, uint16_t ds, uint16_t si)
+static inline void *get_regpair_ptr(address_space &space, uint16_t segment, uint16_t offset)
{
int addr;
- addr=((ds<<4)+si);
-// OUTPUT_SEGOFS("DS:SI",ds,si);
+ addr=((segment<<4)+offset);
return space.get_read_ptr(addr);
}
-void rmnimbus_state::decode_dssi_none(uint16_t ds, uint16_t si, uint8_t raw_flag)
+void rmnimbus_state::decode_dssi_none(uint16_t ds, uint16_t si)
{
}
-void rmnimbus_state::decode_dssi_generic(uint16_t ds, uint16_t si, uint8_t raw_flag)
+void rmnimbus_state::decode_dssi_generic(uint16_t ds, uint16_t si)
{
address_space &space = m_maincpu->space(AS_PROGRAM);
uint16_t *params;
int count;
- if(raw_flag)
+ if(DEBUG_SET(DECODE_BIOS_RAW))
return;
- params=(uint16_t *)get_dssi_ptr(space,ds,si);
+ params=(uint16_t *)get_regpair_ptr(space,ds,si);
for(count=0; count<10; count++)
logerror("%04X ",params[count]);
@@ -647,7 +674,7 @@ void rmnimbus_state::decode_dssi_generic(uint16_t ds, uint16_t si, uint8_t raw_f
}
-void rmnimbus_state::decode_dssi_f_fill_area(uint16_t ds, uint16_t si, uint8_t raw_flag)
+void rmnimbus_state::decode_dssi_f_fill_area(uint16_t ds, uint16_t si)
{
address_space &space = m_maincpu->space(AS_PROGRAM);
@@ -656,14 +683,14 @@ void rmnimbus_state::decode_dssi_f_fill_area(uint16_t ds, uint16_t si, uint8_t r
t_nimbus_brush *brush;
int cocount;
- area_params = (t_area_params *)get_dssi_ptr(space,ds,si);
+ area_params = (t_area_params *)get_regpair_ptr(space,ds,si);
- if (!raw_flag)
+ if (!DEBUG_SET(DECODE_BIOS_RAW))
OUTPUT_SEGOFS("SegBrush:OfsBrush",area_params->seg_brush,area_params->ofs_brush);
brush=(t_nimbus_brush *)space.get_read_ptr(LINEAR_ADDR(area_params->seg_brush,area_params->ofs_brush));
- if(raw_flag)
+ if(DEBUG_SET(DECODE_BIOS_RAW))
{
logerror("\tdw\t%04X, %04X, %04X, %04X, %04X, %04X, %04X, %04X, %04X, ",
brush->style,brush->style_index,brush->colour1,brush->colour2,
@@ -685,7 +712,7 @@ void rmnimbus_state::decode_dssi_f_fill_area(uint16_t ds, uint16_t si, uint8_t r
addr_ptr = (uint16_t *)space.get_read_ptr(LINEAR_ADDR(area_params->seg_data,area_params->ofs_data));
for(cocount=0; cocount < area_params->count; cocount++)
{
- if(raw_flag)
+ if(DEBUG_SET(DECODE_BIOS_RAW))
{
if(cocount!=(area_params->count-1))
logerror("%04X, %04X, ",addr_ptr[cocount*2],addr_ptr[(cocount*2)+1]);
@@ -696,11 +723,11 @@ void rmnimbus_state::decode_dssi_f_fill_area(uint16_t ds, uint16_t si, uint8_t r
logerror("x=%d y=%d\n",addr_ptr[cocount*2],addr_ptr[(cocount*2)+1]);
}
- if(raw_flag)
+ if(DEBUG_SET(DECODE_BIOS_RAW))
logerror("\n");
}
-void rmnimbus_state::decode_dssi_f_plot_character_string(uint16_t ds, uint16_t si, uint8_t raw_flag)
+void rmnimbus_state::decode_dssi_f_plot_character_string(uint16_t ds, uint16_t si)
{
address_space &space = m_maincpu->space(AS_PROGRAM);
@@ -708,10 +735,10 @@ void rmnimbus_state::decode_dssi_f_plot_character_string(uint16_t ds, uint16_t s
t_plot_string_params *plot_string_params;
int charno;
- if(raw_flag)
+ if(DEBUG_SET(DECODE_BIOS_RAW))
return;
- plot_string_params=(t_plot_string_params *)get_dssi_ptr(space,ds,si);
+ plot_string_params=(t_plot_string_params *)get_regpair_ptr(space,ds,si);
OUTPUT_SEGOFS("SegFont:OfsFont",plot_string_params->seg_font,plot_string_params->ofs_font);
OUTPUT_SEGOFS("SegData:OfsData",plot_string_params->seg_data,plot_string_params->ofs_data);
@@ -729,14 +756,14 @@ void rmnimbus_state::decode_dssi_f_plot_character_string(uint16_t ds, uint16_t s
logerror("\n");
}
-void rmnimbus_state::decode_dssi_f_set_new_clt(uint16_t ds, uint16_t si, uint8_t raw_flag)
+void rmnimbus_state::decode_dssi_f_set_new_clt(uint16_t ds, uint16_t si)
{
address_space &space = m_maincpu->space(AS_PROGRAM);
uint16_t *new_colours;
int colour;
- new_colours=(uint16_t *)get_dssi_ptr(space,ds,si);
+ new_colours=(uint16_t *)get_regpair_ptr(space,ds,si);
- if(raw_flag)
+ if(DEBUG_SET(DECODE_BIOS_RAW))
return;
OUTPUT_SEGOFS("SegColours:OfsColours",ds,si);
@@ -746,13 +773,13 @@ void rmnimbus_state::decode_dssi_f_set_new_clt(uint16_t ds, uint16_t si, uint8_t
}
-void rmnimbus_state::decode_dssi_f_plonk_char(uint16_t ds, uint16_t si, uint8_t raw_flag)
+void rmnimbus_state::decode_dssi_f_plonk_char(uint16_t ds, uint16_t si)
{
address_space &space = m_maincpu->space(AS_PROGRAM);
uint16_t *params;
- params=(uint16_t *)get_dssi_ptr(space,ds,si);
+ params=(uint16_t *)get_regpair_ptr(space,ds,si);
- if(raw_flag)
+ if(DEBUG_SET(DECODE_BIOS_RAW))
return;
OUTPUT_SEGOFS("SegParams:OfsParams",ds,si);
@@ -760,16 +787,24 @@ void rmnimbus_state::decode_dssi_f_plonk_char(uint16_t ds, uint16_t si, uint8_t
logerror("plonked_char=%c\n",params[0]);
}
-void rmnimbus_state::decode_dssi_f_rw_sectors(uint16_t ds, uint16_t si, uint8_t raw_flag)
+void rmnimbus_state::decode_dssi_f_rw_sectors(uint16_t ds, uint16_t si)
{
address_space &space = m_maincpu->space(AS_PROGRAM);
uint16_t *params;
int param_no;
- if(raw_flag)
+ if(DEBUG_SET(DECODE_BIOS_RAW))
return;
- params=(uint16_t *)get_dssi_ptr(space,ds,si);
+ params=(uint16_t *)get_regpair_ptr(space,ds,si);
+
+ logerror("unitno=%04X, count=%02X, first_sector=%08X buffer=%04X:%04X (%05X)\n",
+ params[0],
+ params[1],
+ ((params[3] * 65536)+params[2]),
+ params[5],params[4],
+ ((params[5]*16)+params[4])
+ );
for(param_no=0;param_no<16;param_no++)
logerror("%04X ",params[param_no]);
@@ -779,6 +814,10 @@ void rmnimbus_state::decode_dssi_f_rw_sectors(uint16_t ds, uint16_t si, uint8_t
void rmnimbus_state::decode_dos21(device_t *device,offs_t pc)
{
+ address_space &space = m_maincpu->space(AS_PROGRAM);
+ //uint16_t *params;
+ char *path;
+
uint16_t ax = m_maincpu->state_int(I8086_AX);
uint16_t bx = m_maincpu->state_int(I8086_BX);
uint16_t cx = m_maincpu->state_int(I8086_CX);
@@ -792,14 +831,79 @@ void rmnimbus_state::decode_dos21(device_t *device,offs_t pc)
uint16_t di = m_maincpu->state_int(I8086_DI);
uint16_t bp = m_maincpu->state_int(I8086_BP);
+ uint8_t dosfn = ax >> 8; // Dos function is AH, upper half of AX.
+
logerror("=======================================================================\n");
logerror("DOS Int 0x21 call at %05X\n",pc);
logerror("AX=%04X, BX=%04X, CX=%04X, DX=%04X\n",ax,bx,cx,dx);
logerror("CS=%04X, DS=%04X, ES=%04X, SS=%04X\n",cs,ds,es,ss);
logerror("SI=%04X, DI=%04X, BP=%04X\n",si,di,bp);
logerror("=======================================================================\n");
+
+ if (((dosfn >= 0x39) && (dosfn <= 0x3d))
+ || (0x43 == dosfn)
+ || (0x4e == dosfn)
+ || (0x56 == dosfn)
+ || ((dosfn >= 0x5a) && (dosfn <= 0x5b)) )
+ {
+ path=(char *)get_regpair_ptr(space,ds,dx);
+ logerror("Path at DS:DX=%s\n",path);
+
+ if (0x56 == dosfn)
+ {
+ path=(char *)get_regpair_ptr(space,es,di);
+ logerror("Path at ES:DI=%s\n",path);
+ }
+ logerror("=======================================================================\n");
+ }
}
+#define CBUFLEN 32
+
+offs_t rmnimbus_state::dasm_override(std::ostream &stream, offs_t pc, const util::disasm_interface::data_buffer &opcodes, const util::disasm_interface::data_buffer &params)
+{
+ unsigned call;
+ char callname[CBUFLEN];
+ offs_t result = 0;
+
+ // decode and document (some) INT XX calls
+ if (opcodes.r8(pc) == 0xCD)
+ {
+ call = opcodes.r8(pc+1);
+ switch (call)
+ {
+ case 0x20 :
+ strcpy(callname, "(dos terminate)");
+ break;
+
+ case 0x21 :
+ strcpy(callname, "(dos function)");
+ break;
+
+ case 0xf0 :
+ strcpy(callname, "(sub_bios)");
+ break;
+
+ case 0xf3 :
+ strcpy(callname, "(dispatch handler)");
+ break;
+
+ case 0xf5 :
+ strcpy(callname, "(event handler)");
+ break;
+
+ case 0xf6 :
+ strcpy(callname, "(resource message)");
+ break;
+
+ default :
+ strcpy(callname, "");
+ }
+ util::stream_format(stream, "int %02xh %s",call,callname);
+ result = 2;
+ }
+ return result;
+}
/*
The Nimbus has 3 banks of memory each of which can be either 16x4164 or 16x41256 giving
@@ -1021,6 +1125,11 @@ WRITE_LINE_MEMBER(rmnimbus_state::nimbus_fdc_drq_w)
m_maincpu->drq1_w(state && FDC_DRQ_ENABLED());
}
+READ_LINE_MEMBER(rmnimbus_state::nimbus_fdc_enmf_r)
+{
+ return false;
+}
+
uint8_t rmnimbus_state::fdc_driveno(uint8_t drivesel)
{
switch (drivesel)
@@ -1073,7 +1182,7 @@ uint8_t rmnimbus_state::scsi_r(offs_t offset)
{
result |= FDC_MOTOR() << 2;
result |= (!floppy->idx_r()) << 1;
- result |= floppy->ready_r() << 0;
+ result |= (floppy->dskchg_r()) << 0;
}
break;
case 0x08 :
@@ -1260,6 +1369,14 @@ WRITE_LINE_MEMBER( rmnimbus_state::write_scsi_req )
check_scsi_irq();
}
+void rmnimbus_state::nimbus_voice_w(offs_t offset, uint8_t data)
+{
+ if (offset == 0xB0)
+ m_voice_enabled = true;
+ else if (offset == 0xB2)
+ m_voice_enabled = false;
+}
+
/* 8031/8051 Peripheral controller 80186 side */
void rmnimbus_state::pc8031_reset()
@@ -1485,6 +1602,20 @@ void rmnimbus_state::iou_reset()
m_eeprom_state = 0;
}
+/* Rompacks, not completely implemented */
+
+uint8_t rmnimbus_state::nimbus_rompack_r(offs_t offset)
+{
+ logerror("Rompack read offset %02X, rompack address=%04X\n",offset,(m_ay8910_b*256)+m_ay8910_a);
+
+ return 0;
+}
+
+void rmnimbus_state::nimbus_rompack_w(offs_t offset, uint8_t data)
+{
+ logerror("Rompack write offset %02X, data=%02X, rompack address=%04X\n",offset,data,(m_ay8910_b*256)+m_ay8910_a);
+}
+
/*
Sound hardware : AY8910
@@ -1507,6 +1638,7 @@ void rmnimbus_state::rmni_sound_reset()
m_msm->playmode_w(m_last_playmode);
m_ay8910_a=0;
+ m_ay8910_b=0;
}
void rmnimbus_state::nimbus_sound_ay8910_porta_w(uint8_t data)
@@ -1514,16 +1646,21 @@ void rmnimbus_state::nimbus_sound_ay8910_porta_w(uint8_t data)
m_msm->data_w(data);
// Mouse code needs a copy of this.
+ // ROMpack lower address lines
m_ay8910_a=data;
}
void rmnimbus_state::nimbus_sound_ay8910_portb_w(uint8_t data)
{
- if ((data & 0x07) != m_last_playmode)
+ // Only update msm5205 if voice is enabled.....
+ if (m_voice_enabled && ((data & 0x07) != m_last_playmode))
{
m_last_playmode = (data & 0x07);
m_msm->playmode_w(m_last_playmode);
}
+
+ // ROMpack upper address lines
+ m_ay8910_b=data;
}
WRITE_LINE_MEMBER(rmnimbus_state::nimbus_msm5205_vck)
@@ -1532,29 +1669,23 @@ WRITE_LINE_MEMBER(rmnimbus_state::nimbus_msm5205_vck)
external_int(EXTERNAL_INT_MSM5205,state);
}
-static const int MOUSE_XYA[4] = { 1, 1, 0, 0 };
-static const int MOUSE_XYB[4] = { 0, 1, 1, 0 };
-
-void rmnimbus_state::mouse_js_reset()
+void rmnimbus_state::device_timer(emu_timer &timer, device_timer_id id, int param)
{
- m_nimbus_mouse.m_mouse_x=128;
- m_nimbus_mouse.m_mouse_y=128;
- m_nimbus_mouse.m_mouse_pcx=0;
- m_nimbus_mouse.m_mouse_pcy=0;
- m_nimbus_mouse.m_intstate_x=0;
- m_nimbus_mouse.m_intstate_y=0;
- m_nimbus_mouse.m_reg0a4=0xC0;
-
- // Setup timer to poll the mouse
- m_nimbus_mouse.m_mouse_timer->adjust(attotime::zero, 0, attotime::from_hz(MOUSE_POLL_FREQUENCY));
+ switch(id)
+ {
+ case TIMER_MOUSE : do_mouse(); break;
+ }
}
-void rmnimbus_state::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
+static const int MOUSE_XYA[4] = { 1, 1, 0, 0 };
+static const int MOUSE_XYB[4] = { 0, 1, 1, 0 };
+
+void rmnimbus_state::do_mouse()
{
- int mouse_x = 0; // Current mouse X and Y
- int mouse_y = 0;
- int xdiff = 0; // Difference from previous X and Y
- int ydiff = 0;
+ uint8_t mouse_x; // Current mouse X and Y
+ uint8_t mouse_y;
+ int8_t xdiff; // Difference from previous X and Y
+ int8_t ydiff;
uint8_t intstate_x; // Used to calculate if we should trigger interrupt
uint8_t intstate_y;
@@ -1576,17 +1707,6 @@ void rmnimbus_state::device_timer(emu_timer &timer, device_timer_id id, int para
xdiff = m_nimbus_mouse.m_mouse_x - mouse_x;
ydiff = m_nimbus_mouse.m_mouse_y - mouse_y;
- // check and compensate for wrap.....
- if (xdiff > 0x80)
- xdiff -= 0x100;
- else if (xdiff < -0x80)
- xdiff += 0x100;
-
- if (ydiff > 0x80)
- ydiff -= 0x100;
- else if (ydiff < -0x80)
- ydiff += 0x100;
-
// convert movement into emulated movement of quadrature encoder in mouse.
if (xdiff < 0)
m_nimbus_mouse.m_mouse_pcx++;
@@ -1648,6 +1768,20 @@ void rmnimbus_state::device_timer(emu_timer &timer, device_timer_id id, int para
m_nimbus_mouse.m_intstate_y=intstate_y;
}
+void rmnimbus_state::mouse_js_reset()
+{
+ m_nimbus_mouse.m_mouse_x=128;
+ m_nimbus_mouse.m_mouse_y=128;
+ m_nimbus_mouse.m_mouse_pcx=0;
+ m_nimbus_mouse.m_mouse_pcy=0;
+ m_nimbus_mouse.m_intstate_x=0;
+ m_nimbus_mouse.m_intstate_y=0;
+ m_nimbus_mouse.m_reg0a4=0xC0;
+
+ // Setup timer to poll the mouse
+ m_nimbus_mouse.m_mouse_timer->adjust(attotime::zero, 0, attotime::from_hz(MOUSE_POLL_FREQUENCY));
+}
+
uint8_t rmnimbus_state::nimbus_mouse_js_r()
{
/*
diff --git a/src/mame/machine/rtpc_iocc.cpp b/src/mame/machine/rtpc_iocc.cpp
index b06cb3f5147..aa98670da98 100644
--- a/src/mame/machine/rtpc_iocc.cpp
+++ b/src/mame/machine/rtpc_iocc.cpp
@@ -98,6 +98,7 @@ u8 rtpc_iocc_device::dma_b_r(offs_t offset)
m_csr &= ~CSR_PER;
m_csr |= (CSR_DE0 >> m_adc) | CSR_DEXK;
m_out_rst(1);
+ m_out_rst(0);
set_int(true);
}
}
diff --git a/src/mame/machine/rtpc_iocc.h b/src/mame/machine/rtpc_iocc.h
index cf7a2052ec7..bf4d925a61e 100644
--- a/src/mame/machine/rtpc_iocc.h
+++ b/src/mame/machine/rtpc_iocc.h
@@ -99,6 +99,9 @@ public:
template <unsigned Channel> void dack_w(int state) { if (!state) m_adc = Channel; }
+ // HACK: temporary workaround for eop handling
+ unsigned adc_r() { return m_adc; }
+
protected:
// device_t overrides
virtual void device_start() override;
@@ -133,6 +136,9 @@ protected:
// FIXME: get size from isa bus
return 1;
}
+ else if (address == 0xf000'80e0U)
+ // exception for i/o delay register
+ return 4;
else if (address == 0xf000'8400U)
// exception for kls
return 2;
diff --git a/src/mame/machine/s32comm.cpp b/src/mame/machine/s32comm.cpp
index 420b7d54471..f448d8fcfc2 100644
--- a/src/mame/machine/s32comm.cpp
+++ b/src/mame/machine/s32comm.cpp
@@ -99,6 +99,8 @@ void s32comm_device::device_add_mconfig(machine_config &config)
s32comm_device::s32comm_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
device_t(mconfig, S32COMM, tag, owner, clock)
{
+ std::fill(std::begin(m_shared), std::end(m_shared), 0);
+
// prepare localhost "filename"
m_localhost[0] = 0;
strcat(m_localhost, "socket.");
@@ -133,8 +135,6 @@ void s32comm_device::device_reset()
m_zfg = 0;
m_cn = 0;
m_fg = 0;
-
- std::fill(std::begin(m_shared), std::end(m_shared), 0);
}
uint8_t s32comm_device::zfg_r(offs_t offset)
diff --git a/src/mame/machine/s32comm.h b/src/mame/machine/s32comm.h
index 933a3686c57..43ac35bd9c7 100644
--- a/src/mame/machine/s32comm.h
+++ b/src/mame/machine/s32comm.h
@@ -7,7 +7,7 @@
#define S32COMM_SIMULATION
-#include "osdcore.h"
+#include "osdfile.h"
//**************************************************************************
diff --git a/src/mame/machine/saa7191.cpp b/src/mame/machine/saa7191.cpp
index 7298cc8b1d1..96a2e72315b 100644
--- a/src/mame/machine/saa7191.cpp
+++ b/src/mame/machine/saa7191.cpp
@@ -71,7 +71,7 @@ void saa7191_device::device_reset()
m_input_clock->adjust(attotime::never);
}
-void saa7191_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
+void saa7191_device::device_timer(emu_timer &timer, device_timer_id id, int param)
{
}
diff --git a/src/mame/machine/saa7191.h b/src/mame/machine/saa7191.h
index 34e9bec42fb..51a16b43a3b 100644
--- a/src/mame/machine/saa7191.h
+++ b/src/mame/machine/saa7191.h
@@ -39,7 +39,7 @@ protected:
// device-level overrides
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_timer(emu_timer &timer, device_timer_id id, int param) override;
private:
void reg_w(uint8_t data);
diff --git a/src/mame/machine/seicopbl.cpp b/src/mame/machine/seicopbl.cpp
index 58ee8a54d25..b4e898bc505 100644
--- a/src/mame/machine/seicopbl.cpp
+++ b/src/mame/machine/seicopbl.cpp
@@ -269,7 +269,7 @@ void seibu_cop_bootleg_device::cmd_trigger_w(offs_t offset, uint16_t data)
*/
case 0x8100:
{
- uint16_t sin_offs; //= m_host_space->read_dword(m_reg[0]+(0x34));
+ [[maybe_unused]] uint16_t sin_offs; //= m_host_space->read_dword(m_reg[0]+(0x34));
sin_offs = m_host_space->read_byte(m_reg[0]+(0x35));
sin_offs |= m_host_space->read_byte(m_reg[0]+(0x37)) << 8;
int raw_angle = (m_host_space->read_word(m_reg[0]+(0x34^2)) & 0xff);
diff --git a/src/mame/machine/sgi.cpp b/src/mame/machine/sgi.cpp
index 2abbec6849d..21eb109832d 100644
--- a/src/mame/machine/sgi.cpp
+++ b/src/mame/machine/sgi.cpp
@@ -721,7 +721,7 @@ void sgi_mc_device::write(offs_t offset, uint32_t data, uint32_t mem_mask)
}
}
-void sgi_mc_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
+void sgi_mc_device::device_timer(emu_timer &timer, device_timer_id id, int param)
{
if (id == TIMER_RPSS)
{
diff --git a/src/mame/machine/sgi.h b/src/mame/machine/sgi.h
index 3e4ae444707..0f5fd99e670 100644
--- a/src/mame/machine/sgi.h
+++ b/src/mame/machine/sgi.h
@@ -41,7 +41,7 @@ protected:
virtual void device_resolve_objects() override;
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_timer(emu_timer &timer, device_timer_id id, int param) override;
static const device_timer_id TIMER_RPSS = 0;
static const device_timer_id TIMER_DMA = 1;
diff --git a/src/mame/machine/snes.cpp b/src/mame/machine/snes.cpp
index 5afd2019388..c5aa0ad203c 100644
--- a/src/mame/machine/snes.cpp
+++ b/src/mame/machine/snes.cpp
@@ -43,30 +43,39 @@ uint32_t snes_state::screen_update(screen_device &screen, bitmap_rgb32 &bitmap,
Timers
*************************************/
-void snes_state::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
+void snes_state::scpu_irq_refresh()
+{
+ if (m_scpu_irq != nullptr) // multiplexed interrupt?
+ m_scpu_irq->in_w<0>(SNES_CPU_REG(TIMEUP) & 0x80);
+ else
+ m_maincpu->set_input_line(G65816_LINE_IRQ, (SNES_CPU_REG(TIMEUP) & 0x80) ? ASSERT_LINE : CLEAR_LINE);
+}
+
+
+void snes_state::device_timer(emu_timer &timer, device_timer_id id, int param)
{
switch (id)
{
case TIMER_NMI_TICK:
- snes_nmi_tick(ptr, param);
+ snes_nmi_tick(param);
break;
case TIMER_HIRQ_TICK:
- snes_hirq_tick_callback(ptr, param);
+ snes_hirq_tick_callback(param);
break;
case TIMER_RESET_OAM_ADDRESS:
- snes_reset_oam_address(ptr, param);
+ snes_reset_oam_address(param);
break;
case TIMER_RESET_HDMA:
- snes_reset_hdma(ptr, param);
+ snes_reset_hdma(param);
break;
case TIMER_UPDATE_IO:
- snes_update_io(ptr, param);
+ snes_update_io(param);
break;
case TIMER_SCANLINE_TICK:
- snes_scanline_tick(ptr, param);
+ snes_scanline_tick(param);
break;
case TIMER_HBLANK_TICK:
- snes_hblank_tick(ptr, param);
+ snes_hblank_tick(param);
break;
default:
throw emu_fatalerror("Unknown id in snes_state::device_timer");
@@ -89,7 +98,7 @@ void snes_state::hirq_tick()
// (don't need to switch to the 65816 context, we don't do anything dependant on it)
m_ppu->set_latch_hv(m_ppu->current_x(), m_ppu->current_y());
SNES_CPU_REG(TIMEUP) = 0x80; /* Indicate that irq occurred */
- m_maincpu->set_input_line(G65816_LINE_IRQ, ASSERT_LINE);
+ scpu_irq_refresh();
// don't happen again
m_hirq_timer->adjust(attotime::never);
@@ -136,7 +145,7 @@ TIMER_CALLBACK_MEMBER(snes_state::snes_scanline_tick)
SNES_CPU_REG(TIMEUP) = 0x80; /* Indicate that irq occurred */
// IRQ latches the counters, do it now
m_ppu->set_latch_hv(m_ppu->current_x(), m_ppu->current_y());
- m_maincpu->set_input_line(G65816_LINE_IRQ, ASSERT_LINE );
+ scpu_irq_refresh();
}
}
/* Horizontal IRQ timer */
@@ -404,8 +413,9 @@ uint8_t snes_state::snes_r_io(offs_t offset)
switch (offset) // offset is from 0x000000
{
case WMDATA: /* Data to read from WRAM */
- value = m_wram[m_wram_address++];
- m_wram_address &= 0x1ffff;
+ value = m_wram[m_wram_address];
+ if (!machine().side_effects_disabled())
+ m_wram_address = (m_wram_address + 1) & 0x1ffff;
return value;
case OLDJOY1: /* Data for old NES controllers (JOYSER1) */
@@ -416,12 +426,16 @@ uint8_t snes_state::snes_r_io(offs_t offset)
case RDNMI: /* NMI flag by v-blank and version number */
value = (SNES_CPU_REG(RDNMI) & 0x80) | (snes_open_bus_r() & 0x70);
- SNES_CPU_REG(RDNMI) &= 0x70; /* NMI flag is reset on read */
+ if (!machine().side_effects_disabled())
+ SNES_CPU_REG(RDNMI) &= 0x70; /* NMI flag is reset on read */
return value | 2; //CPU version number
case TIMEUP: /* IRQ flag by H/V count timer */
value = (snes_open_bus_r() & 0x7f) | (SNES_CPU_REG(TIMEUP) & 0x80);
- m_maincpu->set_input_line(G65816_LINE_IRQ, CLEAR_LINE );
- SNES_CPU_REG(TIMEUP) = 0; // flag is cleared on both read and write
+ if (!machine().side_effects_disabled())
+ {
+ SNES_CPU_REG(TIMEUP) = 0; // flag is cleared on both read and write
+ scpu_irq_refresh();
+ }
return value;
case HVBJOY: /* H/V blank and joypad controller enable */
// electronics test says hcounter 272 is start of hblank, which is beampos 363
@@ -500,16 +514,13 @@ void snes_state::snes_w_io(address_space &space, offs_t offset, uint8_t data)
m_wram_address &= 0x1ffff;
return;
case WMADDL: /* Address to read/write to wram (low) */
- m_wram_address = (m_wram_address & 0xffff00) | (data << 0);
- m_wram_address &= 0x1ffff;
+ m_wram_address = (m_wram_address & 0x1ff00) | (data << 0);
return;
case WMADDM: /* Address to read/write to wram (mid) */
- m_wram_address = (m_wram_address & 0xff00ff) | (data << 8);
- m_wram_address &= 0x1ffff;
+ m_wram_address = (m_wram_address & 0x100ff) | (data << 8);
return;
case WMADDH: /* Address to read/write to wram (high) */
- m_wram_address = (m_wram_address & 0x00ffff) | (data << 16);
- m_wram_address &= 0x1ffff;
+ m_wram_address = (m_wram_address & 0x0ffff) | ((data & 1) << 16);
return;
case OLDJOY1: /* Old NES joystick support */
write_joy_latch(data);
@@ -521,8 +532,8 @@ void snes_state::snes_w_io(address_space &space, offs_t offset, uint8_t data)
case NMITIMEN: /* Flag for v-blank, timer int. and joy read */
if ((data & 0x30) == 0x00)
{
- m_maincpu->set_input_line(G65816_LINE_IRQ, CLEAR_LINE );
SNES_CPU_REG(TIMEUP) = 0; // clear pending IRQ if irq is disabled here, 3x3 Eyes - Seima Korin Den behaves on this
+ scpu_irq_refresh();
}
SNES_CPU_REG(NMITIMEN) = data;
return;
@@ -531,20 +542,16 @@ void snes_state::snes_w_io(address_space &space, offs_t offset, uint8_t data)
SNES_CPU_REG(WRIO) = data;
return;
case HTIMEL: /* H-Count timer settings (low) */
- m_htime = (m_htime & 0xff00) | (data << 0);
- m_htime &= 0x1ff;
+ m_htime = (m_htime & 0x100) | (data << 0);
return;
case HTIMEH: /* H-Count timer settings (high) */
- m_htime = (m_htime & 0x00ff) | (data << 8);
- m_htime &= 0x1ff;
+ m_htime = (m_htime & 0x0ff) | ((data & 1) << 8);
return;
case VTIMEL: /* V-Count timer settings (low) */
- m_vtime = (m_vtime & 0xff00) | (data << 0);
- m_vtime &= 0x1ff;
+ m_vtime = (m_vtime & 0x100) | (data << 0);
return;
case VTIMEH: /* V-Count timer settings (high) */
- m_vtime = (m_vtime & 0x00ff) | (data << 8);
- m_vtime &= 0x1ff;
+ m_vtime = (m_vtime & 0x0ff) | ((data & 1) << 8);
return;
case MDMAEN: /* DMA channel designation and trigger */
dma(space, data);
@@ -556,8 +563,8 @@ void snes_state::snes_w_io(address_space &space, offs_t offset, uint8_t data)
SNES_CPU_REG(HDMAEN) = data;
return;
case TIMEUP: // IRQ Flag is cleared on both read and write
- m_maincpu->set_input_line(G65816_LINE_IRQ, CLEAR_LINE );
SNES_CPU_REG(TIMEUP) = 0;
+ scpu_irq_refresh();
return;
/* Following are read-only */
case HVBJOY: /* H/V blank and joypad enable */
@@ -1215,6 +1222,7 @@ inline int snes_state::dma_abus_valid( uint32_t address )
inline uint8_t snes_state::abus_read( address_space &space, uint32_t abus )
{
+ m_maincpu->adjust_icount(-8); // 8 master cycle per memory access
if (!dma_abus_valid(abus))
return 0;
@@ -1225,6 +1233,7 @@ inline void snes_state::dma_transfer( address_space &space, uint8_t dma, uint32_
{
if (m_dma_channel[dma].dmap & 0x80) /* PPU->CPU */
{
+ m_maincpu->adjust_icount(-8); // 8 master cycle per memory access
if (bbus == 0x2180 && ((abus & 0xfe0000) == 0x7e0000 || (abus & 0x40e000) == 0x0000))
{
//illegal WRAM->WRAM transfer (bus conflict)
diff --git a/src/mame/machine/snescx4.cpp b/src/mame/machine/snescx4.cpp
index 9741d143af0..9ffb0abcd02 100644
--- a/src/mame/machine/snescx4.cpp
+++ b/src/mame/machine/snescx4.cpp
@@ -21,7 +21,7 @@ static uint16_t CX4_readw(uint16_t addr);
static uint32_t CX4_readl(uint16_t addr);
static void CX4_writew(address_space &space, uint16_t addr, uint16_t data);
-//static void CX4_writel(address_space &space, uint16_t addr, uint32_t data);
+[[maybe_unused]] static void CX4_writel(address_space &space, uint16_t addr, uint32_t data);
static void CX4_C4DrawLine(int32_t X1, int32_t Y1, int16_t Z1, int32_t X2, int32_t Y2, int16_t Z2, uint8_t Color);
@@ -191,12 +191,10 @@ void CX4_write(address_space &space, uint32_t addr, uint8_t data)
}
}
-#ifdef UNUSED_FUNCTION
-void CX4_writeb(address_space &space, uint16_t addr, uint8_t data)
+[[maybe_unused]] static void CX4_writeb(address_space &space, uint16_t addr, uint8_t data)
{
CX4_write(space, addr, data);
}
-#endif
static void CX4_writew(address_space &space, uint16_t addr, uint16_t data)
{
@@ -204,14 +202,12 @@ static void CX4_writew(address_space &space, uint16_t addr, uint16_t data)
CX4_write(space, addr + 1, data >> 8);
}
-#ifdef UNUSED_FUNCTION
-void CX4_writel(address_space &space, uint16_t addr, uint32_t data)
+static void CX4_writel(address_space &space, uint16_t addr, uint32_t data)
{
CX4_write(space, addr + 0, data >> 0);
CX4_write(space, addr + 1, data >> 8);
CX4_write(space, addr + 2, data >> 16);
}
-#endif
uint8_t CX4_read(uint32_t addr)
{
@@ -230,12 +226,10 @@ uint8_t CX4_read(uint32_t addr)
return 0xff;
}
-#ifdef UNUSED_FUNCTION
-uint8_t CX4_readb(uint16_t addr)
+[[maybe_unused]] static uint8_t CX4_readb(uint16_t addr)
{
return CX4_read(addr);
}
-#endif
static uint16_t CX4_readw(uint16_t addr)
{
@@ -247,10 +241,8 @@ static uint32_t CX4_readl(uint16_t addr)
return CX4_read(addr) | (CX4_read(addr + 1) << 8) | (CX4_read(addr + 2) << 16);
}
-#ifdef UNUSED_FUNCTION
-void CX4_reset()
+[[maybe_unused]] void CX4_reset()
{
memset(cx4.ram, 0, 0x0c00);
memset(cx4.reg, 0, 0x0100);
}
-#endif
diff --git a/src/mame/machine/sorcerer.cpp b/src/mame/machine/sorcerer.cpp
index 84a696c1040..e134321e63a 100644
--- a/src/mame/machine/sorcerer.cpp
+++ b/src/mame/machine/sorcerer.cpp
@@ -28,15 +28,15 @@ TIMER_CALLBACK_MEMBER(sorcerer_state::serial_tc)
}
-void sorcerer_state::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
+void sorcerer_state::device_timer(emu_timer &timer, device_timer_id id, int param)
{
switch (id)
{
case TIMER_SERIAL:
- serial_tc(ptr, param);
+ serial_tc(param);
break;
case TIMER_CASSETTE:
- cassette_tc(ptr, param);
+ cassette_tc(param);
break;
default:
throw emu_fatalerror("Unknown id in sorcerer_state::device_timer");
diff --git a/src/mame/machine/stfight.cpp b/src/mame/machine/stfight.cpp
index e3f3d01a193..c20c656e0d5 100644
--- a/src/mame/machine/stfight.cpp
+++ b/src/mame/machine/stfight.cpp
@@ -109,7 +109,7 @@ void stfight_state::stfight_bank_w(uint8_t data)
* CPU 1 timed interrupt - 60Hz???
*/
-void stfight_state::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
+void stfight_state::device_timer(emu_timer &timer, device_timer_id id, int param)
{
switch (id)
{
diff --git a/src/mame/machine/tatsumi.cpp b/src/mame/machine/tatsumi.cpp
index 93922f9a614..a9837222f5f 100644
--- a/src/mame/machine/tatsumi.cpp
+++ b/src/mame/machine/tatsumi.cpp
@@ -266,7 +266,7 @@ uint16_t tatsumi_state::tatsumi_v30_68000_r(offs_t offset)
/* Read from 68k RAM */
if ((m_control_word&0x1f)==0x18)
{
- #ifdef UNUSED_FUNCTION
+#if 0
// hack to make roundup 5 boot
// doesn't seem necessary anymore, left for reference
if (m_maincpu->pc()==0xec575)
@@ -282,7 +282,7 @@ uint16_t tatsumi_state::tatsumi_v30_68000_r(offs_t offset)
dst[BYTE_XOR_LE(0xfc524)]=0x46;
dst[BYTE_XOR_LE(0xfc525)]=0x46;
}
- #endif
+#endif
return m_sharedram[offset & 0x1fff];
}
@@ -313,7 +313,7 @@ uint8_t cyclwarr_state::oki_status_xor_r()
// fwiw returning normal oki status doesn't work at all, both games don't make any sound.
// TODO: verify with HW
return (r ^ 0xff);
- #ifdef UNUSED_FUNCTION
+#if 0
// old hack left for reference
if (m_audiocpu->pc()==0x2b70 || m_audiocpu->pc()==0x2bb5
@@ -326,5 +326,5 @@ uint8_t cyclwarr_state::oki_status_xor_r()
|| m_audiocpu->pc()==0x1cac) // BigFight
return 0;
return r;
- #endif
+#endif
}
diff --git a/src/mame/machine/thomson.cpp b/src/mame/machine/thomson.cpp
index f8201ded8da..378bf038f1a 100644
--- a/src/mame/machine/thomson.cpp
+++ b/src/mame/machine/thomson.cpp
@@ -891,7 +891,7 @@ void thomson_state::to7_game_reset()
/* IMPORTANT NOTE:
The following is experimental and not compiled in by default.
It relies on the existence of an hypothetical "character device" API able
- to transmit bytes between the MESS driver and the outside world
+ to transmit bytes between the MAME driver and the outside world
(using, e.g., character device special files on some UNIX).
*/
diff --git a/src/mame/machine/ti85.cpp b/src/mame/machine/ti85.cpp
index d3c3bb93636..a9c473ba3c5 100644
--- a/src/mame/machine/ti85.cpp
+++ b/src/mame/machine/ti85.cpp
@@ -71,7 +71,7 @@ TIMER_CALLBACK_MEMBER(ti85_state::ti83_timer2_callback)
}
}
-void ti85_state::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
+void ti85_state::device_timer(emu_timer &timer, device_timer_id id, int param)
{
switch (id)
{
diff --git a/src/mame/machine/tsconf.cpp b/src/mame/machine/tsconf.cpp
new file mode 100644
index 00000000000..1b35f167878
--- /dev/null
+++ b/src/mame/machine/tsconf.cpp
@@ -0,0 +1,653 @@
+// license:BSD-3-Clause
+// copyright-holders:Andrei I. Holub
+
+#include "emu.h"
+#include "includes/tsconf.h"
+
+#define PAGE4K(_r) ((_r) << 14)
+
+#define W0_RAM (BIT(m_regs[MEM_CONFIG], 3))
+#define NW0_MAP (BIT(m_regs[MEM_CONFIG], 2))
+#define W0_WE (BIT(m_regs[MEM_CONFIG], 1))
+#define ROM128 (BIT(m_regs[MEM_CONFIG], 0))
+
+#define VM static_cast<v_mode>(BIT(m_regs[V_CONFIG], 0, 2))
+
+static constexpr rectangle resolution_info[4] = {
+ rectangle(52, 256 + 51, 48, 192 + 47), // 52|256|52 x 48-192-48
+ rectangle(20, 320 + 19, 44, 200 + 43), // 20|320|20 x 44-200-44
+ rectangle(20, 320 + 19, 24, 240 + 23), // 20|320|20 x 24-240-24
+ rectangle(0, 360 - 1, 0, 288 - 1) // 0|360|0 x 0-288-0
+};
+
+enum v_mode : u8
+{
+ VM_ZX = 0,
+ VM_16C,
+ VM_256C,
+ VM_TXT
+};
+
+// https://github.com/tslabs/zx-evo/blob/master/pentevo/vdac/vdac1/cpld/top.v
+static constexpr u8 pwm_to_rgb[32] = {
+ 0, 10, 21, 31, 42, 53, 63, 74,
+ 85, 95, 106, 117, 127, 138, 149, 159,
+ 170, 181, 191, 202, 213, 223, 234, 245,
+ 255, 255, 255, 255, 255, 255, 255, 255};
+
+static constexpr rgb_t from_pwm(u16 pwm15)
+{
+ return rgb_t(pwm_to_rgb[BIT(pwm15, 10, 5)], pwm_to_rgb[BIT(pwm15, 5, 5)], pwm_to_rgb[BIT(pwm15, 0, 5)]);
+}
+
+rectangle tsconf_state::get_resolution_info()
+{
+ rectangle info = resolution_info[BIT(m_regs[V_CONFIG], 6, 2)];
+ if (VM == VM_TXT)
+ {
+ info.set_origin(0, 0);
+ info.set_width(info.width() << 1);
+ }
+ return info;
+}
+
+void tsconf_state::tsconf_palette(palette_device &palette) const
+{
+ rgb_t colors[256] = {0};
+ palette.set_pen_colors(0, colors);
+}
+
+void tsconf_state::tsconf_update_bank1()
+{
+
+ //W0_WE
+ if (NW0_MAP)
+ {
+ m_ROMSelection = m_regs[PAGE0];
+ }
+ else
+ {
+ /* ROM: 0-SYS, 1-DOS, 2-128, 3-48 */
+ m_ROMSelection = m_beta->started() && m_beta->is_active() ? ROM128 : (0x02 | ROM128);
+ m_ROMSelection |= (m_regs[PAGE0] & 0xfc);
+ }
+
+ uint8_t *rom0;
+ if (W0_RAM)
+ {
+ rom0 = m_ram->pointer() + PAGE4K(m_ROMSelection);
+ m_bank1->set_base(rom0);
+ }
+ else
+ {
+ rom0 = &m_p_rom[0x10000 + PAGE4K(m_ROMSelection & 0x1f)];
+ m_bank1->set_base(rom0);
+ }
+ m_ram_0000 = W0_WE ? rom0 : nullptr;
+}
+
+void tsconf_state::tsconf_update_video_mode()
+{
+ rectangle resolution = resolution_info[3];
+ u8 *messram = m_ram->pointer();
+ switch (VM)
+ {
+ case VM_TXT: // Text Mode
+ resolution = get_resolution_info();
+ m_gfxdecode->gfx(1)->set_source(messram + PAGE4K(m_regs[V_PAGE] ^ 0x01));
+ break;
+ case VM_ZX: // Zx
+ {
+ m_screen_location = messram + ((m_port_7ffd_data & 8) ? PAGE4K(7) : PAGE4K(5));
+ break;
+ }
+ default:
+ break;
+ }
+
+ m_screen->configure(resolution.width(), resolution.height(), resolution, HZ_TO_ATTOSECONDS(50));
+}
+
+uint32_t tsconf_state::screen_update_spectrum(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
+{
+ if (m_screen_bitmap.valid())
+ {
+ // Border
+ if (m_border_bitmap.valid())
+ {
+ if (BIT(m_regs[V_CONFIG], 5) || VM != VM_ZX)
+ {
+ copyscrollbitmap(bitmap, m_border_bitmap, 0, nullptr, 0, nullptr, cliprect);
+ }
+ }
+
+ // Main Graphics
+ rectangle resolution = get_resolution_info();
+ if (!BIT(m_regs[V_CONFIG], 5))
+ {
+ if (VM == VM_ZX)
+ {
+ // Zx palette is stored at 0xf0. Adjust bitmaps colors.
+ for (auto y = cliprect.top(); y <= cliprect.bottom(); y++)
+ {
+ u16 *bm = &m_screen_bitmap.pix(y, 0);
+ for (auto x = cliprect.left(); x <= cliprect.right(); x++)
+ {
+ *bm++ |= 0xf0;
+ }
+ }
+ spectrum_state::screen_update_spectrum(screen, bitmap, cliprect);
+ }
+ else
+ {
+ copyscrollbitmap(bitmap, m_screen_bitmap, 0, nullptr, 0, nullptr, resolution);
+ }
+ }
+ // Tiles & Sprites
+ // TODO layers
+ if (!BIT(m_regs[V_CONFIG], 4))
+ {
+ if (BIT(m_regs[TS_CONFIG], 5))
+ {
+ m_ts_tilemap[1]->draw(screen, bitmap, resolution, 0);
+ }
+ if (BIT(m_regs[TS_CONFIG], 6))
+ {
+ m_ts_tilemap[2]->draw(screen, bitmap, resolution, 0);
+ }
+ if (BIT(m_regs[TS_CONFIG], 7))
+ {
+ draw_sprites(screen, bitmap, resolution);
+ }
+ }
+ }
+ return 0;
+}
+
+void tsconf_state::spectrum_UpdateScreenBitmap(bool eof)
+{
+ if (!BIT(m_regs[V_CONFIG], 5))
+ {
+ if (VM == VM_ZX)
+ {
+ spectrum_state::spectrum_UpdateScreenBitmap(eof);
+ }
+ else if (!eof)
+ {
+ u8 pal_offset = m_regs[PAL_SEL] << 4;
+ rectangle resolution = get_resolution_info();
+ if (VM == VM_TXT)
+ {
+ u8 *messram = m_ram->pointer();
+ u16 y = m_screen->vpos();
+ u8 *font_location = messram + PAGE4K(m_regs[V_PAGE] ^ 0x01);
+ u8 *text_location = messram + PAGE4K(m_regs[V_PAGE]) + (y / 8 * 256); // OFFSETs
+ u16 *bm = &m_screen_bitmap.pix(y, 0);
+ for (auto x = 0; x < resolution.width() / 8; x++)
+ {
+ u8 char_x = *(font_location + (*text_location * 8) + (y % 8));
+ u8 font_color = *(text_location + 128) & 0x0f;
+ u8 bg_color = (*(text_location + 128) & 0xf0) >> 4;
+ for (auto i = 7; i >= 0; i--)
+ {
+ *bm++ = (BIT(char_x, i) ? font_color : bg_color) + pal_offset;
+ }
+ text_location++;
+ }
+ }
+ else
+ {
+ if (m_screen->vpos() >= resolution.top())
+ {
+ u16 y = m_screen->vpos() - resolution.top();
+ u32 offset = ((y + ((m_regs[G_Y_OFFS_H] & 1) << 8) + m_regs[G_Y_OFFS_L]) * 512) +
+ ((m_regs[G_X_OFFS_H] & 1) << 8) + m_regs[G_X_OFFS_L];
+ if (VM == VM_16C)
+ {
+ // FIXME wouldn't work for odd offsets
+ offset >>= 1;
+ }
+ u8 *video_location = &m_ram->pointer()[PAGE4K(m_regs[V_PAGE]) + offset];
+ u16 *bm = &m_screen_bitmap.pix(m_screen->vpos(), resolution.left());
+ for (auto x = resolution.left(); x <= resolution.right(); x++)
+ {
+ u8 pix = *video_location;
+ if (VM == VM_16C)
+ {
+ *bm++ = (pix >> 4) + pal_offset;
+ *bm++ = (pix & 0x0f) + pal_offset;
+ x++;
+ }
+ else
+ {
+ *bm++ = pix;
+ }
+ video_location++;
+ }
+ }
+ }
+ }
+ }
+}
+
+u16 tsconf_state::get_border_color()
+{
+ return m_regs[BORDER];
+}
+
+void tsconf_state::draw_sprites(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
+{
+ //u8 *messram = m_ram->pointer();
+ //u8 *sprites_location = messram + PAGE4K(m_regs[SG_PAGE]);
+ for (u8 i = 0; i < 85; i++)
+ {
+ logerror("Draw Sprites ... TODO\n");
+ }
+}
+
+void tsconf_state::ram_bank_write(u8 bank, offs_t offset, u8 data)
+{
+ offs_t machine_addr = PAGE4K(bank) + offset;
+ offs_t fmap_addr = BIT(m_regs[FMAPS], 0, 4) << 12;
+ if (BIT(m_regs[FMAPS], 4) && (machine_addr >= fmap_addr) && (machine_addr < (fmap_addr + 512)))
+ {
+ cram_write(machine_addr - fmap_addr, data);
+ }
+ else if (bank > 0 || (W0_WE && W0_RAM))
+ {
+ ram_page_write(m_regs[PAGE0 + bank], offset, data);
+ }
+}
+
+void tsconf_state::ram_page_write(u8 page, offs_t offset, u8 data)
+{
+ u32 ram_addr = PAGE4K(page) + offset;
+ if (ram_addr >= PAGE4K(m_regs[T_MAP_PAGE]) && ram_addr < (PAGE4K(m_regs[T_MAP_PAGE] + 1)))
+ {
+ //TODO invalidate sprites, not entire map
+ m_ts_tilemap[1]->mark_all_dirty();
+ m_ts_tilemap[2]->mark_all_dirty();
+ }
+ else
+ {
+ if (ram_addr >= PAGE4K(m_regs[T0_G_PAGE]) && ram_addr < PAGE4K(m_regs[T0_G_PAGE] + 8))
+ {
+ m_ts_tilemap[1]->mark_all_dirty();
+ }
+ if (ram_addr >= PAGE4K(m_regs[T1_G_PAGE]) && ram_addr < PAGE4K(m_regs[T1_G_PAGE] + 8))
+ {
+ m_ts_tilemap[2]->mark_all_dirty();
+ }
+ if (ram_addr >= PAGE4K(m_regs[SG_PAGE]) && ram_addr < PAGE4K(m_regs[SG_PAGE] + 8))
+ {
+ m_ts_tilemap[3]->mark_all_dirty();
+ }
+ }
+
+ m_ram->write(ram_addr, data);
+}
+
+u16 tsconf_state::ram_read16(offs_t offset)
+{
+ return ((m_ram->read(offset & 0xfffffffe)) << 8) | m_ram->read(offset | 1);
+}
+
+void tsconf_state::ram_write16(offs_t offset, u16 data)
+{
+ m_ram->write(offset & 0xfffffffe, data >> 8);
+ m_ram->write(offset | 1, data & 0xff);
+}
+
+u16 tsconf_state::spi_read16()
+{
+ return (tsconf_port_57_zctr_r(0) << 8) | tsconf_port_57_zctr_r(0);
+}
+
+void tsconf_state::cram_write(u16 offset, u8 data)
+{
+ m_cram->write(offset, data);
+ u8 pen = offset >> 1;
+ rgb_t rgb = from_pwm((m_cram->read(offset | 1) << 8 | m_cram->read(offset & 0xfffe)));
+ m_palette->set_pen_color(pen, rgb);
+};
+
+void tsconf_state::cram_write16(offs_t offset, u16 data)
+{
+ cram_write(offset & 0xfffe, data >> 8);
+ cram_write(offset | 1, data & 0xff);
+};
+
+void tsconf_state::tsconf_port_7ffd_w(u8 data)
+{
+ /* disable paging */
+ if (m_port_7ffd_data & 0x20)
+ return;
+
+ /* store new state */
+ m_port_7ffd_data = data;
+ m_regs[MEM_CONFIG] = (m_regs[MEM_CONFIG] & 0xfe) | BIT(data, 4); // ROM128
+ m_regs[V_PAGE] = BIT(data, 3) ? 7 : 5;
+
+ /* update memory */
+ tsconf_update_bank1();
+ tsconf_update_video_mode();
+}
+
+void tsconf_state::tsconf_port_fe_w(offs_t offset, u8 data)
+{
+ m_regs[BORDER] = (data & 0x07) | 0xf0;
+ spectrum_ula_w(offset, data);
+}
+
+u8 tsconf_state::tsconf_port_xxaf_r(offs_t port)
+{
+ u8 nreg = port >> 8;
+ u8 data = 0xff;
+
+ switch (nreg)
+ {
+ case V_CONFIG:
+ data = 0b01000011; // PWR_UP, !FDRVER, 5bit VDAC
+ break;
+ case PAGE2:
+ case PAGE3:
+ data = m_regs[nreg];
+ break;
+
+ case DMA_CTRL: // DMAStatus
+ data = m_dma->is_ready() ? 0x00 : 0x80;
+ break;
+
+ case 0x30: // FRCnt0
+ case 0x31: // FRCnt1
+ case 0x32: // FRCnt2
+ default:
+ logerror("'tsconf': unmapped reg read %02X\n", nreg);
+ break;
+ }
+
+ //LOGWARN("'tsconf': reg read %02X = %02x\n", nreg, data);
+ return data;
+}
+
+void tsconf_state::tsconf_port_xxaf_w(offs_t port, u8 data)
+{
+ u8 nreg = port >> 8;
+ m_regs[nreg] = data;
+
+ switch (nreg)
+ {
+ case V_CONFIG:
+ case V_PAGE:
+ case PAL_SEL:
+ tsconf_update_video_mode();
+ break;
+
+ case T_MAP_PAGE:
+ m_ts_tilemap[1]->mark_all_dirty();
+ m_ts_tilemap[2]->mark_all_dirty();
+ break;
+
+ case T0_G_PAGE:
+ m_gfxdecode->gfx(2)->set_source(m_ram->pointer() + PAGE4K(data));
+ m_ts_tilemap[1]->mark_all_dirty();
+ break;
+
+ case T0_X_OFFSER_L:
+ case T0_X_OFFSER_H:
+ case T0_Y_OFFSER_L:
+ case T0_Y_OFFSER_H:
+ m_ts_tilemap[1]->set_scrollx((m_regs[T0_X_OFFSER_H] << 8) | m_regs[T0_X_OFFSER_L]);
+ m_ts_tilemap[1]->set_scrolly((m_regs[T0_Y_OFFSER_H] << 8) | m_regs[T0_Y_OFFSER_L]);
+ break;
+
+ case T1_G_PAGE:
+ m_gfxdecode->gfx(3)->set_source(m_ram->pointer() + PAGE4K(data));
+ m_ts_tilemap[2]->mark_all_dirty();
+ break;
+
+ case T1_X_OFFSER_L:
+ case T1_X_OFFSER_H:
+ case T1_Y_OFFSER_L:
+ case T1_Y_OFFSER_H:
+ m_ts_tilemap[2]->set_scrollx((m_regs[T1_X_OFFSER_H] << 8) | m_regs[T1_X_OFFSER_L]);
+ m_ts_tilemap[2]->set_scrolly((m_regs[T1_Y_OFFSER_H] << 8) | m_regs[T1_Y_OFFSER_L]);
+ break;
+
+ case SG_PAGE:
+ m_gfxdecode->gfx(4)->set_source(m_ram->pointer() + PAGE4K(data));
+ m_ts_tilemap[3]->mark_all_dirty();
+ break;
+
+ case MEM_CONFIG:
+ m_port_7ffd_data = (m_port_7ffd_data & 0xef) | (ROM128 << 4);
+ tsconf_update_bank1();
+ break;
+
+ case PAGE0:
+ tsconf_update_bank1();
+ break;
+
+ case PAGE1:
+ m_bank2->set_base(m_ram->pointer() + PAGE4K(data));
+ break;
+
+ case PAGE2:
+ m_bank3->set_base(m_ram->pointer() + PAGE4K(data));
+ break;
+
+ case PAGE3:
+ m_bank4->set_base(m_ram->pointer() + PAGE4K(data));
+ break;
+
+ case BORDER:
+ spectrum_UpdateBorderBitmap();
+ break;
+
+ case DMAS_ADDRESS_L:
+ m_dma->set_saddr_l(data);
+ break;
+
+ case DMAS_ADDRESS_H:
+ m_dma->set_saddr_h(data);
+ break;
+
+ case DMAS_ADDRESS_X:
+ m_dma->set_saddr_x(data);
+ break;
+
+ case DMAD_ADDRESS_L:
+ m_dma->set_daddr_l(data);
+ break;
+
+ case DMAD_ADDRESS_H:
+ m_dma->set_daddr_h(data);
+ break;
+
+ case DMAD_ADDRESS_X:
+ m_dma->set_daddr_x(data);
+ break;
+
+ case DMA_LEN:
+ m_dma->set_block_len(data);
+ break;
+
+ case DMA_NUM_L:
+ m_dma->set_block_num_l(data);
+ break;
+
+ case DMA_NUM_H:
+ m_dma->set_block_num_h(data);
+ break;
+
+ case DMA_CTRL:
+ m_dma->start_tx(((BIT(data, 7) << 3) | (data & 0x07)), BIT(data, 5), BIT(data, 4), BIT(data, 3));
+ break;
+
+ case SYS_CONFIG:
+ // 0 - 3.5MHz, 1 - 7MHz, 2 - 14MHz, 3 - reserved
+ switch (data & 0x03)
+ {
+ case 2:
+ m_maincpu->set_clock(X1);
+ break;
+ case 1:
+ m_maincpu->set_clock(X1 / 2);
+ break;
+ case 0:
+ default:
+ m_maincpu->set_clock(X1 / 4);
+ break;
+ }
+ break;
+
+ case FMAPS:
+ case TS_CONFIG:
+ case G_X_OFFS_L:
+ case G_X_OFFS_H:
+ case G_Y_OFFS_L:
+ case G_Y_OFFS_H:
+ case HS_INT:
+ case VS_INT_L:
+ case VS_INT_H:
+ case INT_MASK:
+ break;
+
+ default:
+ logerror("Unsupported reg write: %02X = %02x\n", nreg, data);
+ break;
+ }
+}
+
+u8 tsconf_state::tsconf_port_f7_r(offs_t offset)
+{
+ // BFF7
+ u8 data = 0xff;
+ if (m_port_f7_ext == PS2KEYBOARDS_LOG && m_port_f7_gluk_reg == 0xf0)
+ {
+ data = m_keyboard->read();
+ }
+ else if (m_port_f7_ext != DISABLED)
+ {
+ data = m_glukrs->read(m_port_f7_gluk_reg);
+ }
+
+ return data;
+}
+
+void tsconf_state::tsconf_port_f7_w(offs_t offset, u8 data)
+{
+ auto m_l = offset >> 12;
+ if (m_l == 6) // EF
+ {
+ m_port_f7_ext = (data & 0x80) ? CONF_VERSION : DISABLED;
+ }
+ else if (m_port_f7_ext != DISABLED)
+ {
+ if (m_l == 5) // DF
+ {
+ // 0x0E..0xEF
+ m_port_f7_gluk_reg = data;
+ }
+ else if (m_l == 3) // BF
+ {
+ if (m_port_f7_gluk_reg == 0xf0)
+ {
+ u8 m_fx[0xf] = {0xff};
+ m_port_f7_ext = static_cast<gluk_ext>(data);
+ switch (m_port_f7_ext)
+ {
+ case CONF_VERSION:
+ {
+ strcpy((char *)m_fx, "M.A.M.E.");
+ PAIR16 m_ver;
+ m_ver.w = ((21 << 9) | (12 << 5) | 15);
+ m_fx[0x0c] = m_ver.b.l;
+ m_fx[0x0d] = m_ver.b.h;
+ break;
+ }
+ case BOOTLOADER_VERSION:
+ case PS2KEYBOARDS_LOG:
+ break;
+ default:
+ logerror("Gluk extention not supported %x\n", m_port_f7_gluk_reg);
+ break;
+ }
+ for (u8 i = 0; i < 0xf; i++)
+ {
+ m_glukrs->write(0xf0 + i, m_fx[i]);
+ }
+ }
+ else
+ {
+ m_glukrs->write(m_port_f7_gluk_reg, data);
+ }
+ }
+ }
+}
+
+void tsconf_state::tsconf_port_77_zctr_w(offs_t port, u8 data)
+{
+ m_sdcard->spi_ss_w(BIT(data, 0));
+ m_zctl_cs = BIT(data, 1);
+}
+
+u8 tsconf_state::tsconf_port_77_zctr_r(offs_t port)
+{
+ return 0x02 | !m_sdcard->get_card_present();
+}
+
+void tsconf_state::tsconf_port_57_zctr_w(offs_t port, u8 data)
+{
+ if (!m_zctl_cs)
+ {
+ for (u8 m = 0x80; m; m >>= 1)
+ {
+ m_sdcard->spi_clock_w(CLEAR_LINE); //0-S R
+ m_sdcard->spi_mosi_w(data & m ? 1 : 0);
+ m_sdcard->spi_clock_w(ASSERT_LINE); //1-L W
+ }
+ }
+}
+
+u8 tsconf_state::tsconf_port_57_zctr_r(offs_t port)
+{
+ tsconf_port_57_zctr_w(0, 0xff);
+ return m_zctl_cs ? 0xff : m_zctl_di;
+}
+
+void tsconf_state::tsconf_spi_miso_w(u8 data)
+{
+ m_zctl_di <<= 1;
+ m_zctl_di |= data;
+}
+
+u8 tsconf_state::beta_neutral_r(offs_t offset)
+{
+ return m_program->read_byte(offset);
+}
+
+u8 tsconf_state::beta_enable_r(offs_t offset)
+{
+ if (m_ROMSelection == 3)
+ {
+ if (m_beta->started() /*&& !m_beta->is_active()*/)
+ {
+ m_beta->enable();
+ tsconf_update_bank1();
+ }
+ }
+
+ return m_program->read_byte(offset + 0x3d00);
+}
+
+u8 tsconf_state::beta_disable_r(offs_t offset)
+{
+ if (m_beta->started() && m_beta->is_active())
+ {
+ m_beta->disable();
+ tsconf_update_bank1();
+ }
+
+ return m_program->read_byte(offset + 0x4000);
+}
diff --git a/src/mame/machine/upd65031.cpp b/src/mame/machine/upd65031.cpp
index e9dffbfb359..f8dcbbf4797 100644
--- a/src/mame/machine/upd65031.cpp
+++ b/src/mame/machine/upd65031.cpp
@@ -283,7 +283,7 @@ void upd65031_device::device_reset()
// device_timer - handler timer events
//-------------------------------------------------
-void upd65031_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
+void upd65031_device::device_timer(emu_timer &timer, device_timer_id id, int param)
{
switch (id)
{
diff --git a/src/mame/machine/upd65031.h b/src/mame/machine/upd65031.h
index 153f6a1faf8..730da988e09 100644
--- a/src/mame/machine/upd65031.h
+++ b/src/mame/machine/upd65031.h
@@ -49,7 +49,7 @@ protected:
// device-level overrides
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_timer(emu_timer &timer, device_timer_id id, int param) override;
private:
inline void interrupt_refresh();
diff --git a/src/mame/machine/vectrex.cpp b/src/mame/machine/vectrex.cpp
index e314e488ed8..bb945b53203 100644
--- a/src/mame/machine/vectrex.cpp
+++ b/src/mame/machine/vectrex.cpp
@@ -48,30 +48,30 @@ static const double unknown_game_angles[3] = {0,0.16666666, 0.33333333};
-void vectrex_base_state::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
+void vectrex_base_state::device_timer(emu_timer &timer, device_timer_id id, int param)
{
switch (id)
{
case TIMER_VECTREX_IMAGER_CHANGE_COLOR:
- vectrex_imager_change_color(ptr, param);
+ vectrex_imager_change_color(param);
break;
case TIMER_UPDATE_LEVEL:
- update_level(ptr, param);
+ update_level(param);
break;
case TIMER_VECTREX_IMAGER_EYE:
- vectrex_imager_eye(ptr, param);
+ vectrex_imager_eye(param);
break;
case TIMER_LIGHTPEN_TRIGGER:
- lightpen_trigger(ptr, param);
+ lightpen_trigger(param);
break;
case TIMER_VECTREX_REFRESH:
- vectrex_refresh(ptr, param);
+ vectrex_refresh(param);
break;
case TIMER_VECTREX_ZERO_INTEGRATORS:
- vectrex_zero_integrators(ptr, param);
+ vectrex_zero_integrators(param);
break;
case TIMER_UPDATE_SIGNAL:
- update_signal(ptr, param);
+ update_signal(param);
break;
default:
fatalerror("Unknown id in vectrex_base_state::device_timer");
@@ -232,8 +232,7 @@ TIMER_CALLBACK_MEMBER(vectrex_base_state::vectrex_imager_change_color)
TIMER_CALLBACK_MEMBER(vectrex_base_state::update_level)
{
- if (ptr)
- * (uint8_t *) ptr = param;
+ m_imager_pinlevel = param;
}
@@ -258,7 +257,7 @@ TIMER_CALLBACK_MEMBER(vectrex_base_state::vectrex_imager_eye)
m_via6522_0->write_ca1(1);
m_via6522_0->write_ca1(0);
m_imager_pinlevel |= 0x80;
- timer_set(attotime::from_double(rtime / 360.0), TIMER_UPDATE_LEVEL, 0, &m_imager_pinlevel);
+ timer_set(attotime::from_double(rtime / 360.0), TIMER_UPDATE_LEVEL, 0);
}
}
}
diff --git a/src/mame/machine/victor9k_fdc.cpp b/src/mame/machine/victor9k_fdc.cpp
index c4b7adc66bb..413fe8373a0 100644
--- a/src/mame/machine/victor9k_fdc.cpp
+++ b/src/mame/machine/victor9k_fdc.cpp
@@ -341,7 +341,7 @@ void victor_9000_fdc_device::device_reset()
// device_timer - handler timer events
//-------------------------------------------------
-void victor_9000_fdc_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
+void victor_9000_fdc_device::device_timer(emu_timer &timer, device_timer_id id, int param)
{
switch (id)
{
diff --git a/src/mame/machine/victor9k_fdc.h b/src/mame/machine/victor9k_fdc.h
index 13077427979..67105ba4318 100644
--- a/src/mame/machine/victor9k_fdc.h
+++ b/src/mame/machine/victor9k_fdc.h
@@ -46,7 +46,7 @@ protected:
// device-level overrides
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_timer(emu_timer &timer, device_timer_id id, int param) override;
// optional information overrides
virtual const tiny_rom_entry *device_rom_region() const override;
diff --git a/src/mame/machine/vino.cpp b/src/mame/machine/vino.cpp
index 4d4085ebd8e..ef9d72acc68 100644
--- a/src/mame/machine/vino.cpp
+++ b/src/mame/machine/vino.cpp
@@ -146,7 +146,7 @@ void vino_device::device_add_mconfig(machine_config &config)
IMAGE_AVIVIDEO(config, m_avivideo);
}
-void vino_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
+void vino_device::device_timer(emu_timer &timer, device_timer_id id, int param)
{
if (id == TIMER_FETCH_CHA || id == TIMER_FETCH_CHB)
fetch_pixel((int)id);
diff --git a/src/mame/machine/vino.h b/src/mame/machine/vino.h
index b1f0d2e0cd7..f88e406bc38 100644
--- a/src/mame/machine/vino.h
+++ b/src/mame/machine/vino.h
@@ -37,7 +37,7 @@ protected:
virtual void device_start() override;
virtual void device_reset() override;
virtual void device_add_mconfig(machine_config &config) override;
- virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override;
+ virtual void device_timer(emu_timer &timer, device_timer_id id, int param) override;
private:
static constexpr device_timer_id TIMER_FETCH_CHA = 0;
diff --git a/src/mame/machine/vsnes.cpp b/src/mame/machine/vsnes.cpp
index cc45f2517f2..e888ab973a4 100644
--- a/src/mame/machine/vsnes.cpp
+++ b/src/mame/machine/vsnes.cpp
@@ -676,151 +676,58 @@ void vsnes_state::init_vsvram()
/**********************************************************************************/
-void vsnes_state::mapper4_set_prg( )
+void vsnes_state::vs108_rom_banking(offs_t offset, uint8_t data)
{
- uint8_t *prg = memregion("maincpu")->base();
- uint8_t prg_flip = (m_MMC3_cmd & 0x40) ? 2 : 0;
-
- memcpy(&prg[0x8000], &prg[0x2000 * (m_MMC3_prg_bank[0 ^ prg_flip] & m_MMC3_prg_mask) + 0x10000], 0x2000);
- memcpy(&prg[0xa000], &prg[0x2000 * (m_MMC3_prg_bank[1] & m_MMC3_prg_mask) + 0x10000], 0x2000);
- memcpy(&prg[0xc000], &prg[0x2000 * (m_MMC3_prg_bank[2 ^ prg_flip] & m_MMC3_prg_mask) + 0x10000], 0x2000);
- memcpy(&prg[0xe000], &prg[0x2000 * (m_MMC3_prg_bank[3] & m_MMC3_prg_mask) + 0x10000], 0x2000);
-}
-
-void vsnes_state::mapper4_set_chr( )
-{
- uint8_t chr_page = (m_MMC3_cmd & 0x80) >> 5;
-
- v_set_videorom_bank(chr_page ^ 0, 1, m_MMC3_chr_bank[0] & ~0x01);
- v_set_videorom_bank(chr_page ^ 1, 1, m_MMC3_chr_bank[0] | 0x01);
- v_set_videorom_bank(chr_page ^ 2, 1, m_MMC3_chr_bank[1] & ~0x01);
- v_set_videorom_bank(chr_page ^ 3, 1, m_MMC3_chr_bank[1] | 0x01);
- v_set_videorom_bank(chr_page ^ 4, 1, m_MMC3_chr_bank[2]);
- v_set_videorom_bank(chr_page ^ 5, 1, m_MMC3_chr_bank[3]);
- v_set_videorom_bank(chr_page ^ 6, 1, m_MMC3_chr_bank[4]);
- v_set_videorom_bank(chr_page ^ 7, 1, m_MMC3_chr_bank[5]);
-}
-
-
-void vsnes_state::mapper4_irq( int scanline, int vblank, int blanked )
-{
- if (scanline < ppu2c0x_device::BOTTOM_VISIBLE_SCANLINE)
- {
- int priorCount = m_IRQ_count;
- if (m_IRQ_count == 0)
- {
- m_IRQ_count = m_IRQ_count_latch;
- }
- else
- m_IRQ_count--;
-
- if (m_IRQ_enable && !blanked && (m_IRQ_count == 0) && priorCount)
- {
- m_maincpu->set_input_line(0, HOLD_LINE);
- }
- }
-}
-
-void vsnes_state::mapper4_w(offs_t offset, uint8_t data)
-{
- uint8_t MMC3_helper, cmd;
-
switch (offset & 0x6001)
{
- case 0x0000: /* $8000 */
- MMC3_helper = m_MMC3_cmd ^ data;
- m_MMC3_cmd = data;
-
- /* Has PRG Mode changed? */
- if (MMC3_helper & 0x40)
- mapper4_set_prg();
-
- /* Has CHR Mode changed? */
- if (MMC3_helper & 0x80)
- mapper4_set_chr();
+ case 0x0000: // $8000
+ m_108_reg = data & 0x07;
break;
- case 0x0001: /* $8001 */
- cmd = m_MMC3_cmd & 0x07;
- switch (cmd)
+ case 0x0001: // $8001
+ switch (m_108_reg)
{
- case 0: case 1: // these do not need to be separated: we take care of them in set_chr!
+ case 0: case 1:
+ v_set_videorom_bank(m_108_reg * 2, 2, data);
+ break;
case 2: case 3: case 4: case 5:
- m_MMC3_chr_bank[cmd] = data;
- mapper4_set_chr();
+ v_set_videorom_bank(m_108_reg + 2, 1, data);
break;
- case 6:
- case 7:
- m_MMC3_prg_bank[cmd - 6] = data;
- mapper4_set_prg();
+ case 6: case 7:
+ {
+ uint8_t *prg = memregion("maincpu")->base();
+ int addr = m_108_reg == 6 ? 0x8000 : 0xa000;
+ memcpy(&prg[addr], &prg[0x2000 * (data & m_108_prg_mask) + 0x10000], 0x2000);
+ }
break;
}
break;
- case 0x2000: /* $a000 */
- if (data & 0x40)
- v_set_mirroring(1, PPU_MIRROR_HIGH);
- else
- {
- if (data & 0x01)
- v_set_mirroring(1, PPU_MIRROR_HORZ);
- else
- v_set_mirroring(1, PPU_MIRROR_VERT);
- }
- break;
-
- case 0x2001: /* $a001 - extra RAM enable/disable */
- /* ignored - we always enable it */
- break;
-
- case 0x4000: /* $c000 - IRQ scanline counter */
- m_IRQ_count = data;
- break;
-
- case 0x4001: /* $c001 - IRQ scanline latch */
- m_IRQ_count_latch = data;
- break;
-
- case 0x6000: /* $e000 - Disable IRQs */
- m_IRQ_enable = 0;
- m_IRQ_count = m_IRQ_count_latch;
- m_ppu1->set_scanline_callback(nullptr);
- break;
-
- case 0x6001: /* $e001 - Enable IRQs */
- m_IRQ_enable = 1;
- m_ppu1->set_scanline_callback(*this, FUNC(vsnes_state::mapper4_irq));
- break;
-
default:
- logerror("mapper4_w uncaught: %04x value: %02x\n", offset + 0x8000, data);
+ logerror("vs108_rom_banking uncaught: %04x value: %02x\n", offset + 0x8000, data);
break;
}
}
-/* Common init for MMC3 games */
+// Common init for (Namco) 108 games
-void vsnes_state::init_MMC3()
+void vsnes_state::init_vs108()
{
uint8_t *prg = memregion("maincpu")->base();
- m_IRQ_enable = m_IRQ_count = m_IRQ_count_latch = 0;
- int MMC3_prg_chunks = (memregion("maincpu")->bytes() - 0x10000) / 0x4000;
-
- m_MMC3_prg_bank[0] = m_MMC3_prg_bank[2] = 0xfe;
- m_MMC3_prg_bank[1] = m_MMC3_prg_bank[3] = 0xff;
- m_MMC3_cmd = 0;
+ int prg_chunks = (memregion("maincpu")->bytes() - 0x10000) / 0x4000;
- m_MMC3_prg_mask = ((MMC3_prg_chunks << 1) - 1);
+ m_108_reg = 0;
+ m_108_prg_mask = (prg_chunks << 1) - 1;
- memcpy(&prg[0x8000], &prg[(MMC3_prg_chunks - 1) * 0x4000 + 0x10000], 0x2000);
- memcpy(&prg[0xa000], &prg[(MMC3_prg_chunks - 1) * 0x4000 + 0x12000], 0x2000);
- memcpy(&prg[0xc000], &prg[(MMC3_prg_chunks - 1) * 0x4000 + 0x10000], 0x2000);
- memcpy(&prg[0xe000], &prg[(MMC3_prg_chunks - 1) * 0x4000 + 0x12000], 0x2000);
+ memcpy(&prg[0x8000], &prg[(prg_chunks - 1) * 0x4000 + 0x10000], 0x2000);
+ memcpy(&prg[0xa000], &prg[(prg_chunks - 1) * 0x4000 + 0x12000], 0x2000);
+ memcpy(&prg[0xc000], &prg[(prg_chunks - 1) * 0x4000 + 0x10000], 0x2000);
+ memcpy(&prg[0xe000], &prg[(prg_chunks - 1) * 0x4000 + 0x12000], 0x2000);
- /* MMC3 mapper at writes to $8000-$ffff */
- m_maincpu->space(AS_PROGRAM).install_write_handler(0x8000, 0xffff, write8sm_delegate(*this, FUNC(vsnes_state::mapper4_w)));
+ // 108 chip at $8000-$9fff
+ m_maincpu->space(AS_PROGRAM).install_write_handler(0x8000, 0xffff, write8sm_delegate(*this, FUNC(vsnes_state::vs108_rom_banking)));
- /* extra ram at $6000-$7fff */
+ // extra ram at $6000-$7fff
m_extraram = std::make_unique<uint8_t[]>(0x2000);
save_pointer(NAME(m_extraram.get()), 0x2000);
m_maincpu->space(AS_PROGRAM).install_ram(0x6000, 0x7fff, m_extraram.get());
@@ -857,7 +764,7 @@ uint8_t vsnes_state::rbi_hack_r(offs_t offset)
void vsnes_state::init_rbibb()
{
- init_MMC3();
+ init_vs108();
/* RBI Base ball hack */
m_maincpu->space(AS_PROGRAM).install_read_handler(0x5e00, 0x5e01, read8sm_delegate(*this, FUNC(vsnes_state::rbi_hack_r)));
@@ -904,7 +811,7 @@ uint8_t vsnes_state::supxevs_read_prot_4_r()
void vsnes_state::init_supxevs()
{
- init_MMC3();
+ init_vs108();
/* Vs. Super Xevious Protection */
m_maincpu->space(AS_PROGRAM).install_read_handler(0x54ff, 0x54ff, read8smo_delegate(*this, FUNC(vsnes_state::supxevs_read_prot_1_r)));
@@ -938,7 +845,7 @@ uint8_t vsnes_state::tko_security_r(offs_t offset)
void vsnes_state::init_tkoboxng()
{
- init_MMC3();
+ init_vs108();
/* security device at $5e00-$5e01 */
m_maincpu->space(AS_PROGRAM).install_read_handler(0x5e00, 0x5e01, read8sm_delegate(*this, FUNC(vsnes_state::tko_security_r)));
@@ -948,7 +855,7 @@ void vsnes_state::init_tkoboxng()
void vsnes_state::init_vsfdf()
{
- init_MMC3();
+ init_vs108();
m_maincpu->space(AS_PROGRAM).install_readwrite_handler(0x4016, 0x4016, read8smo_delegate(*this, FUNC(vsnes_state::gun_in0_r)), write8smo_delegate(*this, FUNC(vsnes_state::gun_in0_w)));
diff --git a/src/mame/machine/wpc.cpp b/src/mame/machine/wpc.cpp
index ce4a29d981d..1d996aafdfc 100644
--- a/src/mame/machine/wpc.cpp
+++ b/src/mame/machine/wpc.cpp
@@ -54,7 +54,7 @@ void wpc_device::device_reset()
m_alpha_pos = 0;
}
-void wpc_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
+void wpc_device::device_timer(emu_timer &timer, device_timer_id id, int param)
{
switch(id)
{
diff --git a/src/mame/machine/wpc.h b/src/mame/machine/wpc.h
index 6bdb718aea7..a7419aa9100 100644
--- a/src/mame/machine/wpc.h
+++ b/src/mame/machine/wpc.h
@@ -111,7 +111,7 @@ protected:
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_timer(emu_timer &timer, device_timer_id id, int param) override;
private:
uint8_t m_shift_addr_high;
diff --git a/src/mame/machine/wpc_lamp.cpp b/src/mame/machine/wpc_lamp.cpp
index feee50cc926..8aaa2455285 100644
--- a/src/mame/machine/wpc_lamp.cpp
+++ b/src/mame/machine/wpc_lamp.cpp
@@ -57,7 +57,7 @@ void wpc_lamp_device::device_reset()
timer->adjust(attotime::from_hz(60), 0, attotime::from_hz(60));
}
-void wpc_lamp_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
+void wpc_lamp_device::device_timer(emu_timer &timer, device_timer_id id, int param)
{
for(int i=0; i<64; i++) {
uint8_t s = state[i];
diff --git a/src/mame/machine/wpc_lamp.h b/src/mame/machine/wpc_lamp.h
index e41ff339b0a..85ff587c0da 100644
--- a/src/mame/machine/wpc_lamp.h
+++ b/src/mame/machine/wpc_lamp.h
@@ -27,7 +27,7 @@ protected:
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_timer(emu_timer &timer, device_timer_id id, int param) override;
void update();
};
diff --git a/src/mame/machine/wpc_out.cpp b/src/mame/machine/wpc_out.cpp
index d23bbb83269..9de9b6988ac 100644
--- a/src/mame/machine/wpc_out.cpp
+++ b/src/mame/machine/wpc_out.cpp
@@ -132,7 +132,7 @@ void wpc_out_device::device_reset()
timer->adjust(attotime::from_hz(10), 0, attotime::from_hz(10));
}
-void wpc_out_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
+void wpc_out_device::device_timer(emu_timer &timer, device_timer_id id, int param)
{
gi_update();
for(int i=0; i<gi_count; i++) {
diff --git a/src/mame/machine/wpc_out.h b/src/mame/machine/wpc_out.h
index cbbb3b7ce72..91602f0ba54 100644
--- a/src/mame/machine/wpc_out.h
+++ b/src/mame/machine/wpc_out.h
@@ -45,7 +45,7 @@ protected:
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_timer(emu_timer &timer, device_timer_id id, int param) override;
void gi_update();
};
diff --git a/src/mame/machine/x68k_hdc.cpp b/src/mame/machine/x68k_hdc.cpp
index d3051b8bcb9..d3f108cb40b 100644
--- a/src/mame/machine/x68k_hdc.cpp
+++ b/src/mame/machine/x68k_hdc.cpp
@@ -27,8 +27,7 @@ ALLOW_SAVE_TYPE(x68k_hdc_image_device::sasi_phase);
DEFINE_DEVICE_TYPE(X68KHDC, x68k_hdc_image_device, "x68k_hdc_image", "SASI Hard Disk")
x68k_hdc_image_device::x68k_hdc_image_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock)
- : device_t(mconfig, X68KHDC, tag, owner, clock)
- , device_image_interface(mconfig, *this)
+ : harddisk_image_base_device(mconfig, X68KHDC, tag, owner, clock)
{
}
diff --git a/src/mame/machine/x68k_hdc.h b/src/mame/machine/x68k_hdc.h
index 05d2f86af5c..0927f29401d 100644
--- a/src/mame/machine/x68k_hdc.h
+++ b/src/mame/machine/x68k_hdc.h
@@ -10,9 +10,10 @@
#pragma once
+#include "imagedev/harddriv.h"
-class x68k_hdc_image_device : public device_t,
- public device_image_interface
+
+class x68k_hdc_image_device : public harddisk_image_base_device
{
enum class sasi_phase : u8
{
@@ -97,16 +98,9 @@ public:
x68k_hdc_image_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock = 0);
// image-level overrides
- virtual iodevice_t image_type() const noexcept override { return IO_HARDDISK; }
-
- virtual bool is_readable() const noexcept override { return true; }
- virtual bool is_writeable() const noexcept override { return true; }
- virtual bool is_creatable() const noexcept override { return true; }
- virtual bool must_be_loaded() const noexcept override { return false; }
- virtual bool is_reset_on_load() const noexcept override { return false; }
virtual const char *file_extensions() const noexcept override { return "hdf"; }
- virtual const char *custom_instance_name() const noexcept override { return "sasihd"; }
- virtual const char *custom_brief_instance_name() const noexcept override { return "sasi"; }
+ virtual const char *image_type_name() const noexcept override { return "sasihd"; }
+ virtual const char *image_brief_type_name() const noexcept override { return "sasi"; }
virtual image_init_result call_create(int format_type, util::option_resolution *format_options) override;
void hdc_w(offs_t offset, u16 data);
diff --git a/src/mame/machine/xbox.cpp b/src/mame/machine/xbox.cpp
index bc02ea60b26..3ce1c78b4dd 100644
--- a/src/mame/machine/xbox.cpp
+++ b/src/mame/machine/xbox.cpp
@@ -938,7 +938,7 @@ void xbox_base_state::xbox_base_map(address_map &map)
void xbox_base_state::xbox_base_map_io(address_map &map)
{
- map(0x01f0, 0x01f7).rw(":pci:09.0:ide1", FUNC(bus_master_ide_controller_device::cs0_r), FUNC(bus_master_ide_controller_device::cs0_w));
+ map(0x01f0, 0x01f7).rw("pci:09.0:ide1", FUNC(bus_master_ide_controller_device::cs0_r), FUNC(bus_master_ide_controller_device::cs0_w));
map(0x002e, 0x002f).rw(FUNC(xbox_base_state::superio_read), FUNC(xbox_base_state::superio_write));
map(0x03f8, 0x03ff).rw(FUNC(xbox_base_state::superiors232_read), FUNC(xbox_base_state::superiors232_write));
map(0x0cf8, 0x0cff).rw("pcibus", FUNC(pci_bus_legacy_device::read), FUNC(pci_bus_legacy_device::write));
@@ -960,25 +960,25 @@ void xbox_base_state::xbox_base(machine_config &config)
config.set_maximum_quantum(attotime::from_hz(6000));
- PCI_ROOT(config, ":pci", 0);
- NV2A_HOST(config, ":pci:00.0", 0, m_maincpu);
- NV2A_RAM(config, ":pci:00.3", 0, 128); // 128 megabytes
- MCPX_ISALPC(config, ":pci:01.0", 0, 0).interrupt_output().set(FUNC(xbox_base_state::maincpu_interrupt));
- XBOX_SUPERIO(config, ":pci:01.0:0", 0);
- MCPX_SMBUS(config, ":pci:01.1", 0, 0).interrupt_handler().set(":pci:01.0", FUNC(mcpx_isalpc_device::irq11)); //.set(FUNC(xbox_base_state::smbus_interrupt_changed));
- XBOX_PIC16LC(config, ":pci:01.1:110", 0); // these 3 are on smbus number 1
- XBOX_CX25871(config, ":pci:01.1:145", 0);
- XBOX_EEPROM(config, ":pci:01.1:154", 0);
- MCPX_OHCI(config, ":pci:02.0", 0, 0).interrupt_handler().set(":pci:01.0", FUNC(mcpx_isalpc_device::irq1)); //.set(FUNC(xbox_base_state::ohci_usb_interrupt_changed));
- MCPX_OHCI(config, ":pci:03.0", 0, 0);
- MCPX_ETH(config, ":pci:04.0", 0);
- MCPX_APU(config, ":pci:05.0", 0, 0, m_maincpu);
- MCPX_AC97_AUDIO(config, ":pci:06.0", 0, 0);
- MCPX_AC97_MODEM(config, ":pci:06.1", 0);
- PCI_BRIDGE(config, ":pci:08.0", 0, 0x10de01b8, 0);
- MCPX_IDE(config, ":pci:09.0", 0, 0).pri_interrupt_handler().set(":pci:01.0", FUNC(mcpx_isalpc_device::irq14)); //.set(FUNC(xbox_base_state::ide_interrupt_changed));
- NV2A_AGP(config, ":pci:1e.0", 0, 0x10de01b7, 0);
- NV2A_GPU(config, ":pci:1e.0:00.0", 0, m_maincpu).interrupt_handler().set(":pci:01.0", FUNC(mcpx_isalpc_device::irq3)); //.set(FUNC(xbox_base_state::nv2a_interrupt_changed));
+ PCI_ROOT(config, "pci", 0);
+ NV2A_HOST(config, "pci:00.0", 0, m_maincpu);
+ NV2A_RAM(config, "pci:00.3", 0, 128); // 128 megabytes
+ MCPX_ISALPC(config, "pci:01.0", 0, 0).interrupt_output().set(FUNC(xbox_base_state::maincpu_interrupt));
+ XBOX_SUPERIO(config, "pci:01.0:0", 0);
+ MCPX_SMBUS(config, "pci:01.1", 0, 0).interrupt_handler().set("pci:01.0", FUNC(mcpx_isalpc_device::irq11)); //.set(FUNC(xbox_base_state::smbus_interrupt_changed));
+ XBOX_PIC16LC(config, "pci:01.1:110", 0); // these 3 are on smbus number 1
+ XBOX_CX25871(config, "pci:01.1:145", 0);
+ XBOX_EEPROM(config, "pci:01.1:154", 0);
+ MCPX_OHCI(config, "pci:02.0", 0, 0).interrupt_handler().set("pci:01.0", FUNC(mcpx_isalpc_device::irq1)); //.set(FUNC(xbox_base_state::ohci_usb_interrupt_changed));
+ MCPX_OHCI(config, "pci:03.0", 0, 0);
+ MCPX_ETH(config, "pci:04.0", 0);
+ MCPX_APU(config, "pci:05.0", 0, 0, m_maincpu);
+ MCPX_AC97_AUDIO(config, "pci:06.0", 0, 0);
+ MCPX_AC97_MODEM(config, "pci:06.1", 0);
+ PCI_BRIDGE(config, "pci:08.0", 0, 0x10de01b8, 0);
+ MCPX_IDE(config, "pci:09.0", 0, 0).pri_interrupt_handler().set("pci:01.0", FUNC(mcpx_isalpc_device::irq14)); //.set(FUNC(xbox_base_state::ide_interrupt_changed));
+ NV2A_AGP(config, "pci:1e.0", 0, 0x10de01b7, 0);
+ NV2A_GPU(config, "pci:1e.0:00.0", 0, m_maincpu).interrupt_handler().set("pci:01.0", FUNC(mcpx_isalpc_device::irq3)); //.set(FUNC(xbox_base_state::nv2a_interrupt_changed));
/* video hardware */
screen_device &screen(SCREEN(config, "screen", SCREEN_TYPE_RASTER));
diff --git a/src/mame/machine/xbox_pci.cpp b/src/mame/machine/xbox_pci.cpp
index cebd51f9dd7..6027ab02591 100644
--- a/src/mame/machine/xbox_pci.cpp
+++ b/src/mame/machine/xbox_pci.cpp
@@ -757,10 +757,10 @@ void mcpx_ohci_device::device_config_complete()
}
}
-void mcpx_ohci_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
+void mcpx_ohci_device::device_timer(emu_timer &timer, device_timer_id id, int param)
{
if (ohci_usb)
- ohci_usb->timer(timer, id, param, ptr);
+ ohci_usb->timer(timer, id, param);
}
uint32_t mcpx_ohci_device::ohci_r(offs_t offset)
@@ -883,7 +883,7 @@ void mcpx_apu_device::device_reset()
pci_device::device_reset();
}
-void mcpx_apu_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
+void mcpx_apu_device::device_timer(emu_timer &timer, device_timer_id id, int param)
{
int cmd;
int bb, b, v;
diff --git a/src/mame/machine/xbox_usb.cpp b/src/mame/machine/xbox_usb.cpp
index 59883d2ca0b..5b2dca2be6e 100644
--- a/src/mame/machine/xbox_usb.cpp
+++ b/src/mame/machine/xbox_usb.cpp
@@ -220,7 +220,7 @@ void ohci_usb_controller::write(offs_t offset, uint32_t data)
ohcist.hc_regs[offset] = data;
}
-void ohci_usb_controller::timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
+void ohci_usb_controller::timer(emu_timer &timer, device_timer_id id, int param)
{
uint32_t hcca;
uint32_t plh;
diff --git a/src/mame/machine/z80ne.cpp b/src/mame/machine/z80ne.cpp
index af61fde4a04..8c9519d300f 100644
--- a/src/mame/machine/z80ne.cpp
+++ b/src/mame/machine/z80ne.cpp
@@ -144,7 +144,7 @@ TIMER_CALLBACK_MEMBER(z80ne_state::z80ne_kbd_scan)
}
}
-void z80ne_state::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
+void z80ne_state::device_timer(emu_timer &timer, device_timer_id id, int param)
{
switch (id)
{
diff --git a/src/mame/machine/znmcu.cpp b/src/mame/machine/znmcu.cpp
index 1b21d956e1b..a008ae0f954 100644
--- a/src/mame/machine/znmcu.cpp
+++ b/src/mame/machine/znmcu.cpp
@@ -96,7 +96,7 @@ WRITE_LINE_MEMBER(znmcu_device::write_clock)
}
}
-void znmcu_device::device_timer(emu_timer &timer, device_timer_id tid, int param, void *ptr)
+void znmcu_device::device_timer(emu_timer &timer, device_timer_id tid, int param)
{
m_dsr_handler(param);
diff --git a/src/mame/machine/znmcu.h b/src/mame/machine/znmcu.h
index 4207cae2038..f956ae87115 100644
--- a/src/mame/machine/znmcu.h
+++ b/src/mame/machine/znmcu.h
@@ -26,7 +26,7 @@ public:
protected:
// device-level overrides
virtual void device_start() override;
- virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override;
+ virtual void device_timer(emu_timer &timer, device_timer_id id, int param) override;
private:
devcb_read8 m_dsw_handler;
diff --git a/src/mame/machine/zx.cpp b/src/mame/machine/zx.cpp
index 3f95ecbf971..cd00c2673b8 100644
--- a/src/mame/machine/zx.cpp
+++ b/src/mame/machine/zx.cpp
@@ -119,22 +119,9 @@ uint8_t zx_state::zx80_io_r(offs_t offset)
if (!(offset & 0x01))
{
- if ((offset & 0x0100) == 0)
- data &= m_io_row0->read();
- if ((offset & 0x0200) == 0)
- data &= m_io_row1->read();
- if ((offset & 0x0400) == 0)
- data &= m_io_row2->read();
- if ((offset & 0x0800) == 0)
- data &= m_io_row3->read();
- if ((offset & 0x1000) == 0)
- data &= m_io_row4->read();
- if ((offset & 0x2000) == 0)
- data &= m_io_row5->read();
- if ((offset & 0x4000) == 0)
- data &= m_io_row6->read();
- if ((offset & 0x8000) == 0)
- data &= m_io_row7->read();
+ for (int i = 0; i < 8; i++)
+ if (!BIT(offset, i + 8))
+ data &= m_io_row[i]->read();
if (!m_io_config->read())
data &= ~0x40;
@@ -163,22 +150,9 @@ uint8_t zx_state::zx81_io_r(offs_t offset)
if (!(offset & 0x01))
{
- if ((offset & 0x0100) == 0)
- data &= m_io_row0->read();
- if ((offset & 0x0200) == 0)
- data &= m_io_row1->read();
- if ((offset & 0x0400) == 0)
- data &= m_io_row2->read();
- if ((offset & 0x0800) == 0)
- data &= m_io_row3->read();
- if ((offset & 0x1000) == 0)
- data &= m_io_row4->read();
- if ((offset & 0x2000) == 0)
- data &= m_io_row5->read();
- if ((offset & 0x4000) == 0)
- data &= m_io_row6->read();
- if ((offset & 0x8000) == 0)
- data &= m_io_row7->read();
+ for (int i = 0; i < 8; i++)
+ if (!BIT(offset, i + 8))
+ data &= m_io_row[i]->read();
if (!m_io_config->read())
data &= ~0x40;
@@ -217,22 +191,9 @@ uint8_t zx_state::pc8300_io_r(offs_t offset)
else
if (offs == 0xfe)
{
- if ((offset & 0x0100) == 0)
- data &= m_io_row0->read();
- if ((offset & 0x0200) == 0)
- data &= m_io_row1->read();
- if ((offset & 0x0400) == 0)
- data &= m_io_row2->read();
- if ((offset & 0x0800) == 0)
- data &= m_io_row3->read();
- if ((offset & 0x1000) == 0)
- data &= m_io_row4->read();
- if ((offset & 0x2000) == 0)
- data &= m_io_row5->read();
- if ((offset & 0x4000) == 0)
- data &= m_io_row6->read();
- if ((offset & 0x8000) == 0)
- data &= m_io_row7->read();
+ for (int i = 0; i < 8; i++)
+ if (!BIT(offset, i + 8))
+ data &= m_io_row[i]->read();
m_cassette->output(+1.0);
if(m_cassette_cur_level <= 0)
@@ -267,22 +228,9 @@ uint8_t zx_state::pow3000_io_r(offs_t offset)
else
if (offs == 0xfe)
{
- if ((offset & 0x0100) == 0)
- data &= m_io_row0->read();
- if ((offset & 0x0200) == 0)
- data &= m_io_row1->read();
- if ((offset & 0x0400) == 0)
- data &= m_io_row2->read();
- if ((offset & 0x0800) == 0)
- data &= m_io_row3->read();
- if ((offset & 0x1000) == 0)
- data &= m_io_row4->read();
- if ((offset & 0x2000) == 0)
- data &= m_io_row5->read();
- if ((offset & 0x4000) == 0)
- data &= m_io_row6->read();
- if ((offset & 0x8000) == 0)
- data &= m_io_row7->read();
+ for (int i = 0; i < 8; i++)
+ if (!BIT(offset, i + 8))
+ data &= m_io_row[i]->read();
m_cassette->output(+1.0);
if(m_cassette_cur_level <= 0)
diff --git a/src/mame/machine/zx8302.cpp b/src/mame/machine/zx8302.cpp
index 4ecab2f89a7..b2fd9acbfe2 100644
--- a/src/mame/machine/zx8302.cpp
+++ b/src/mame/machine/zx8302.cpp
@@ -220,7 +220,7 @@ void zx8302_device::device_start()
// device_timer - handler timer events
//-------------------------------------------------
-void zx8302_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
+void zx8302_device::device_timer(emu_timer &timer, device_timer_id id, int param)
{
switch (id)
{
diff --git a/src/mame/machine/zx8302.h b/src/mame/machine/zx8302.h
index 22ce85ba4b1..7aa922a4b3a 100644
--- a/src/mame/machine/zx8302.h
+++ b/src/mame/machine/zx8302.h
@@ -89,7 +89,7 @@ public:
protected:
// device-level overrides
virtual void device_start() override;
- virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override;
+ virtual void device_timer(emu_timer &timer, device_timer_id id, int param) override;
// device_serial_interface overrides
virtual void tra_callback() override;