summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices
diff options
context:
space:
mode:
authorGravatarGravatar David Haywood <28625134+DavidHaywood@users.noreply.github.com>2019-12-04 19:26:23 +0000
committerGravatarGravatar R. Belmont <rb6502@users.noreply.github.com>2019-12-04 14:26:23 -0500
commit3127f799a2f97298e2c071548e0a0d7a354dbb8f (patch)
tree1568be305e67a825d49d1e1c57af13527453c431 /src/devices
parentc4fcbb0ce7e1ef899b125e08e8ac7ad73e4c6a96 (diff)
Sunplus Plug & Play work (cleanup + fixes + notes based on wrlshunt code analysis) (#6010)
* misc sunplus work (nw) * unbreak a few things, remove some test code (nw) * mask shift values, maybe correct based on code study (nw) * refactor (nw) * notes based on code study (nw) * force a different codepath in wrlshunt, static screen, but differnet, no crash, need to see if it's valid (nw) * test (nw)
Diffstat (limited to 'src/devices')
-rw-r--r--src/devices/cpu/unsp/unsp_exxx.cpp27
-rw-r--r--src/devices/cpu/unsp/unsp_fxxx.cpp21
-rw-r--r--src/devices/machine/spg2xx.cpp12
-rw-r--r--src/devices/machine/spg2xx.h15
-rw-r--r--src/devices/machine/spg2xx_io.cpp12
-rw-r--r--src/devices/machine/spg2xx_io.h8
-rw-r--r--src/devices/machine/sunplus_gcm394.cpp87
-rw-r--r--src/devices/machine/sunplus_gcm394_video.cpp277
-rw-r--r--src/devices/machine/sunplus_gcm394_video.h48
9 files changed, 328 insertions, 179 deletions
diff --git a/src/devices/cpu/unsp/unsp_exxx.cpp b/src/devices/cpu/unsp/unsp_exxx.cpp
index e7db4ba5a0d..af9a01bfc89 100644
--- a/src/devices/cpu/unsp/unsp_exxx.cpp
+++ b/src/devices/cpu/unsp/unsp_exxx.cpp
@@ -116,10 +116,12 @@ void unsp_12_device::execute_exxx_group(uint16_t op)
if (op & 0x0100)
{
// MUL su ( unsigned * signed )
- logerror("MUL su\n");
const uint16_t opa = (op >> 9) & 7;
const uint16_t opb = op & 7;
m_core->m_icount -= 12;
+
+ logerror("%s: MUL su with %04x (signed) * %04x (unsigned) : ", machine().describe_context(), m_core->m_r[opa], m_core->m_r[opb]);
+
uint32_t lres = m_core->m_r[opa] * m_core->m_r[opb];
if (m_core->m_r[opa] & 0x8000)
{
@@ -127,6 +129,9 @@ void unsp_12_device::execute_exxx_group(uint16_t op)
}
m_core->m_r[REG_R4] = lres >> 16;
m_core->m_r[REG_R3] = (uint16_t)lres;
+
+ logerror("result was : %08x\n", lres);
+
return;
}
else
@@ -175,32 +180,36 @@ void unsp_12_device::execute_exxx_group(uint16_t op)
return;
case 0x02:
- logerror("pc:%06x: %s = %s lsl %s (%04x %04x)\n", UNSP_LPC, regs[rd], regs[rd], regs[rs], m_core->m_r[rd], m_core->m_r[rs]);
- m_core->m_r[rd] = m_core->m_r[rd] << m_core->m_r[rs];
+ logerror("pc:%06x: %s = %s lsl %s (%04x %04x) : ", UNSP_LPC, regs[rd], regs[rd], regs[rs], m_core->m_r[rd], m_core->m_r[rs]);
+ m_core->m_r[rd] = (uint16_t)(m_core->m_r[rd] << (m_core->m_r[rs] & 0x0f));
+ logerror("result %04x\n", m_core->m_r[rd]);
return;
case 0x03:
{
// wrlshunt uses this
- logerror("pc:%06x: %s = %s lslor %s (%04x %04x)\n", UNSP_LPC, regs[rd], regs[rd], regs[rs], m_core->m_r[rd], m_core->m_r[rs]);
+ logerror("pc:%06x: %s = %s lslor %s (%04x %04x) : ", UNSP_LPC, regs[rd], regs[rd], regs[rs], m_core->m_r[rd], m_core->m_r[rs]);
uint16_t tmp = m_core->m_r[rd];
- m_core->m_r[rd] = m_core->m_r[rd] << m_core->m_r[rs];
+ m_core->m_r[rd] = (uint16_t)(m_core->m_r[rd] << (m_core->m_r[rs] & 0x0f));
m_core->m_r[rd] |= tmp; // guess
+ logerror("result %04x\n", m_core->m_r[rd]);
return;
}
case 0x04:
// smartfp loops increasing shift by 4 up to values of 28? (but regs are 16-bit?)
- logerror("pc:%06x: %s = %s lsr %s (%04x %04x)\n", UNSP_LPC, regs[rd], regs[rd], regs[rs], m_core->m_r[rd], m_core->m_r[rs]);
- m_core->m_r[rd] = m_core->m_r[rd] >> m_core->m_r[rs];
+ logerror("pc:%06x: %s = %s lsr %s (%04x %04x) : ", UNSP_LPC, regs[rd], regs[rd], regs[rs], m_core->m_r[rd], m_core->m_r[rs]);
+ m_core->m_r[rd] = (uint16_t)(m_core->m_r[rd] >> (m_core->m_r[rs] & 0xf));
+ logerror("result %04x\n", m_core->m_r[rd]);
return;
case 0x05:
{
- logerror("pc:%06x: %s = %s lsror %s (%04x %04x)\n", UNSP_LPC, regs[rd], regs[rd], regs[rs], m_core->m_r[rd], m_core->m_r[rs]);
+ logerror("pc:%06x: %s = %s lsror %s (%04x %04x) : ", UNSP_LPC, regs[rd], regs[rd], regs[rs], m_core->m_r[rd], m_core->m_r[rs]);
uint16_t tmp = m_core->m_r[rd];
- m_core->m_r[rd] = m_core->m_r[rd] >> m_core->m_r[rs];
+ m_core->m_r[rd] = (uint16_t)(m_core->m_r[rd] >> (m_core->m_r[rs] & 0x0f));
m_core->m_r[rd] |= tmp; // guess
+ logerror("result %04x\n", m_core->m_r[rd]);
return;
}
diff --git a/src/devices/cpu/unsp/unsp_fxxx.cpp b/src/devices/cpu/unsp/unsp_fxxx.cpp
index 442b497a5eb..2dd1b42bcec 100644
--- a/src/devices/cpu/unsp/unsp_fxxx.cpp
+++ b/src/devices/cpu/unsp/unsp_fxxx.cpp
@@ -289,27 +289,14 @@ void unsp_12_device::execute_fxxx_101_group(uint16_t op)
{
uint16_t r4 = m_core->m_r[REG_R4];
- // this could be optimized, but logic is correct for use cases seen
if (r4 & 0x8000)
{
// r2 undefined (code will check for this and avoid calculations
}
- else if (r4 & 0x4000) { m_core->m_r[REG_R2] = 0x0000; }
- else if (r4 & 0x2000) { m_core->m_r[REG_R2] = 0x0001; }
- else if (r4 & 0x1000) { m_core->m_r[REG_R2] = 0x0002; }
- else if (r4 & 0x0800) { m_core->m_r[REG_R2] = 0x0003; }
- else if (r4 & 0x0400) { m_core->m_r[REG_R2] = 0x0004; }
- else if (r4 & 0x0200) { m_core->m_r[REG_R2] = 0x0005; }
- else if (r4 & 0x0100) { m_core->m_r[REG_R2] = 0x0006; }
- else if (r4 & 0x0080) { m_core->m_r[REG_R2] = 0x0007; }
- else if (r4 & 0x0040) { m_core->m_r[REG_R2] = 0x0008; }
- else if (r4 & 0x0020) { m_core->m_r[REG_R2] = 0x0009; }
- else if (r4 & 0x0010) { m_core->m_r[REG_R2] = 0x000a; }
- else if (r4 & 0x0008) { m_core->m_r[REG_R2] = 0x000b; }
- else if (r4 & 0x0004) { m_core->m_r[REG_R2] = 0x000c; }
- else if (r4 & 0x0002) { m_core->m_r[REG_R2] = 0x000d; }
- else if (r4 & 0x0001) { m_core->m_r[REG_R2] = 0x000e; }
- else { m_core->m_r[REG_R2] = 0x000f; }
+ else
+ {
+ m_core->m_r[REG_R2] = count_leading_zeros(r4) - 17; // -17 because count_leading_zeros works with 32-bit values
+ }
return;
}
diff --git a/src/devices/machine/spg2xx.cpp b/src/devices/machine/spg2xx.cpp
index 5acaa464456..804cafe4f76 100644
--- a/src/devices/machine/spg2xx.cpp
+++ b/src/devices/machine/spg2xx.cpp
@@ -34,8 +34,8 @@ spg2xx_device::spg2xx_device(const machine_config &mconfig, device_type type, co
, m_portb_in(*this)
, m_portc_in(*this)
, m_adc_in{{*this}, {*this}}
- , m_eeprom_w(*this)
- , m_eeprom_r(*this)
+ , m_i2c_w(*this)
+ , m_i2c_r(*this)
, m_uart_tx(*this)
, m_chip_sel(*this)
, m_screen(*this, finder_base::DUMMY_TAG)
@@ -79,8 +79,8 @@ void spg2xx_device::device_start()
m_portc_in.resolve_safe(0);
m_adc_in[0].resolve_safe(0x0fff);
m_adc_in[1].resolve_safe(0x0fff);
- m_eeprom_w.resolve_safe();
- m_eeprom_r.resolve_safe(0);
+ m_i2c_w.resolve_safe();
+ m_i2c_r.resolve_safe(0);
m_uart_tx.resolve_safe();
m_chip_sel.resolve_safe();
@@ -146,8 +146,8 @@ void spg2xx_device::configure_spg_io(spg2xx_io_device* io)
io->portc_out().set(FUNC(spg2xx_device::portc_w));
io->adc_in<0>().set(FUNC(spg2xx_device::adc_r<0>));
io->adc_in<1>().set(FUNC(spg2xx_device::adc_r<1>));
- io->eeprom_w().set(FUNC(spg2xx_device::eepromx_w));
- io->eeprom_r().set(FUNC(spg2xx_device::eepromx_r));
+ io->i2c_w().set(FUNC(spg2xx_device::eepromx_w));
+ io->i2c_r().set(FUNC(spg2xx_device::eepromx_r));
io->uart_tx().set(FUNC(spg2xx_device::tx_w));
io->chip_select().set(FUNC(spg2xx_device::cs_w));
io->pal_read_callback().set(FUNC(spg2xx_device::get_pal_ntsc));
diff --git a/src/devices/machine/spg2xx.h b/src/devices/machine/spg2xx.h
index 2d26d6ef135..ec99c6f0533 100644
--- a/src/devices/machine/spg2xx.h
+++ b/src/devices/machine/spg2xx.h
@@ -21,10 +21,9 @@
D - SPG243 - Wall-E
D - SPG243 - KenSingTon / Siatronics / Jungle Soft Vii
Partial D - SPG200 - VTech V.Smile
- ND - unknown - Zone 40
+ D - unknown - Zone 40
D - SPG243 - Zone 60
D - SPG243 - Wireless 60
- ND - unknown - Wireless Air 60
ND - Likely many more
**********************************************************************/
@@ -56,8 +55,8 @@ public:
template <size_t Line> auto adc_in() { return m_adc_in[Line].bind(); }
- auto eeprom_w() { return m_eeprom_w.bind(); }
- auto eeprom_r() { return m_eeprom_r.bind(); }
+ auto i2c_w() { return m_i2c_w.bind(); }
+ auto i2c_r() { return m_i2c_r.bind(); }
auto uart_tx() { return m_uart_tx.bind(); }
@@ -109,8 +108,8 @@ protected:
devcb_read16 m_adc_in[2];
- devcb_write8 m_eeprom_w;
- devcb_read8 m_eeprom_r;
+ devcb_write8 m_i2c_w;
+ devcb_read8 m_i2c_r;
devcb_write8 m_uart_tx;
@@ -130,8 +129,8 @@ protected:
DECLARE_WRITE16_MEMBER(portc_w) { m_portc_out(offset, data, mem_mask); }
template <size_t Line> DECLARE_READ16_MEMBER(adc_r) { return m_adc_in[Line](); }
- DECLARE_WRITE8_MEMBER(eepromx_w) { m_eeprom_w(offset, data, mem_mask); }
- DECLARE_READ8_MEMBER(eepromx_r) { return m_eeprom_r(); };
+ DECLARE_WRITE8_MEMBER(eepromx_w) { m_i2c_w(offset, data, mem_mask); }
+ DECLARE_READ8_MEMBER(eepromx_r) { return m_i2c_r(); };
DECLARE_WRITE8_MEMBER(tx_w) { m_uart_tx(offset, data, mem_mask); }
DECLARE_WRITE8_MEMBER(cs_w) { m_chip_sel(offset, data, mem_mask); }
diff --git a/src/devices/machine/spg2xx_io.cpp b/src/devices/machine/spg2xx_io.cpp
index fed6fa261c6..cbcb7f53213 100644
--- a/src/devices/machine/spg2xx_io.cpp
+++ b/src/devices/machine/spg2xx_io.cpp
@@ -45,8 +45,8 @@ spg2xx_io_device::spg2xx_io_device(const machine_config &mconfig, device_type ty
, m_portb_in(*this)
, m_portc_in(*this)
, m_adc_in{{*this}, {*this}}
- , m_eeprom_w(*this)
- , m_eeprom_r(*this)
+ , m_i2c_w(*this)
+ , m_i2c_r(*this)
, m_uart_tx(*this)
, m_chip_sel(*this)
, m_cpu(*this, finder_base::DUMMY_TAG)
@@ -81,8 +81,8 @@ void spg2xx_io_device::device_start()
m_portc_in.resolve_safe(0);
m_adc_in[0].resolve_safe(0x0fff);
m_adc_in[1].resolve_safe(0x0fff);
- m_eeprom_w.resolve_safe();
- m_eeprom_r.resolve_safe(0);
+ m_i2c_w.resolve_safe();
+ m_i2c_r.resolve_safe(0);
m_uart_tx.resolve_safe();
m_chip_sel.resolve_safe();
m_pal_read_cb.resolve_safe(0);
@@ -1325,9 +1325,9 @@ void spg2xx_io_device::do_i2c()
const uint16_t addr = ((m_io_regs[0x5b] & 0x06) << 7) | (uint8_t)m_io_regs[0x5c];
if (m_io_regs[0x58] & 0x40) // Serial EEPROM read
- m_io_regs[0x5e] = m_eeprom_r(addr);
+ m_io_regs[0x5e] = m_i2c_r(addr);
else
- m_eeprom_w(addr, m_io_regs[0x5d]);
+ m_i2c_w(addr, m_io_regs[0x5d]);
m_io_regs[0x59] |= 1;
}
diff --git a/src/devices/machine/spg2xx_io.h b/src/devices/machine/spg2xx_io.h
index d1ddd573283..37cd0d6141f 100644
--- a/src/devices/machine/spg2xx_io.h
+++ b/src/devices/machine/spg2xx_io.h
@@ -23,8 +23,8 @@ public:
template <size_t Line> auto adc_in() { return m_adc_in[Line].bind(); }
- auto eeprom_w() { return m_eeprom_w.bind(); }
- auto eeprom_r() { return m_eeprom_r.bind(); }
+ auto i2c_w() { return m_i2c_w.bind(); }
+ auto i2c_r() { return m_i2c_r.bind(); }
auto uart_tx() { return m_uart_tx.bind(); }
@@ -112,8 +112,8 @@ protected:
devcb_read16 m_adc_in[2];
- devcb_write8 m_eeprom_w;
- devcb_read8 m_eeprom_r;
+ devcb_write8 m_i2c_w;
+ devcb_read8 m_i2c_r;
devcb_write8 m_uart_tx;
diff --git a/src/devices/machine/sunplus_gcm394.cpp b/src/devices/machine/sunplus_gcm394.cpp
index 4998bbce242..44b17fdfc92 100644
--- a/src/devices/machine/sunplus_gcm394.cpp
+++ b/src/devices/machine/sunplus_gcm394.cpp
@@ -163,33 +163,70 @@ WRITE16_MEMBER(sunplus_gcm394_base_device::unkarea_7835_w) { LOGMASKED(LOG_GCM39
// IO here?
-READ16_MEMBER(sunplus_gcm394_base_device::ioport_a_r) { LOGMASKED(LOG_GCM394, "%s:sunplus_gcm394_base_device::ioport_a_r\n", machine().describe_context()); return m_porta_in(); }
-WRITE16_MEMBER(sunplus_gcm394_base_device::ioport_a_w) { LOGMASKED(LOG_GCM394, "%s:sunplus_gcm394_base_device::ioport_a_w %04x\n", machine().describe_context(), data); m_porta_out(data); }
+READ16_MEMBER(sunplus_gcm394_base_device::ioport_a_r)
+{
+ LOGMASKED(LOG_GCM394, "%s:sunplus_gcm394_base_device::ioport_a_r\n", machine().describe_context());
+ return m_porta_in();
+}
+
+WRITE16_MEMBER(sunplus_gcm394_base_device::ioport_a_w)
+{
+ LOGMASKED(LOG_GCM394, "%s:sunplus_gcm394_base_device::ioport_a_w %04x\n", machine().describe_context(), data);
+ m_porta_out(data);
+}
+
+READ16_MEMBER(sunplus_gcm394_base_device::unkarea_7861_r)
+{
+ LOGMASKED(LOG_GCM394, "%s:sunplus_gcm394_base_device::unkarea_7861_r\n", machine().describe_context());
+ return 0x0000;// 0xffff;// m_7861;
+}
+
+READ16_MEMBER(sunplus_gcm394_base_device::unkarea_7862_r)
+{
+ LOGMASKED(LOG_GCM394, "%s:sunplus_gcm394_base_device::unkarea_7862_r\n", machine().describe_context());
+ return 0x0000;// m_7862;
+}
+
+WRITE16_MEMBER(sunplus_gcm394_base_device::unkarea_7862_w)
+{
+ LOGMASKED(LOG_GCM394, "%s:sunplus_gcm394_base_device::unkarea_7862_w %04x\n", machine().describe_context(), data);
+ m_7862 = data;
+}
-READ16_MEMBER(sunplus_gcm394_base_device::unkarea_7861_r) { LOGMASKED(LOG_GCM394, "%s:sunplus_gcm394_base_device::unkarea_7861_r\n", machine().describe_context()); return m_7861; }
+READ16_MEMBER(sunplus_gcm394_base_device::unkarea_7863_r)
+{
+ LOGMASKED(LOG_GCM394, "%s:sunplus_gcm394_base_device::unkarea_7863_r\n", machine().describe_context());
+ return 0x0000; //0xffff;// m_7863;
+}
-READ16_MEMBER(sunplus_gcm394_base_device::unkarea_7862_r) { LOGMASKED(LOG_GCM394, "%s:sunplus_gcm394_base_device::unkarea_7862_r\n", machine().describe_context()); return m_7862; }
-WRITE16_MEMBER(sunplus_gcm394_base_device::unkarea_7862_w) { LOGMASKED(LOG_GCM394, "%s:sunplus_gcm394_base_device::unkarea_7862_w %04x\n", machine().describe_context(), data); m_7862 = data; }
-READ16_MEMBER(sunplus_gcm394_base_device::unkarea_7863_r) { LOGMASKED(LOG_GCM394, "%s:sunplus_gcm394_base_device::unkarea_7863_r\n", machine().describe_context()); return m_7863; }
-WRITE16_MEMBER(sunplus_gcm394_base_device::unkarea_7863_w) { LOGMASKED(LOG_GCM394, "%s:sunplus_gcm394_base_device::unkarea_7863_w %04x\n", machine().describe_context(), data); m_7863 = data; }
+WRITE16_MEMBER(sunplus_gcm394_base_device::unkarea_7863_w)
+{
+ LOGMASKED(LOG_GCM394, "%s:sunplus_gcm394_base_device::unkarea_7863_w %04x\n", machine().describe_context(), data);
+ m_7863 = data;
+}
// similar read/write pattern to above, 2nd group?
READ16_MEMBER(sunplus_gcm394_base_device::unkarea_7870_r) { LOGMASKED(LOG_GCM394, "%s:sunplus_gcm394_base_device::unkarea_7870_r\n", machine().describe_context()); return m_portb_in(); }
WRITE16_MEMBER(sunplus_gcm394_base_device::unkarea_7870_w) { LOGMASKED(LOG_GCM394, "%s:sunplus_gcm394_base_device::unkarea_7870_w %04x\n", machine().describe_context(), data); m_7870 = data; }
-READ16_MEMBER(sunplus_gcm394_base_device::unkarea_7871_r) { LOGMASKED(LOG_GCM394, "%s:sunplus_gcm394_base_device::unkarea_7871_r\n", machine().describe_context()); return m_7871; }
+READ16_MEMBER(sunplus_gcm394_base_device::unkarea_7871_r) { LOGMASKED(LOG_GCM394, "%s:sunplus_gcm394_base_device::unkarea_7871_r\n", machine().describe_context()); return 0xffff;// m_7871;
+}
-READ16_MEMBER(sunplus_gcm394_base_device::unkarea_7872_r) { LOGMASKED(LOG_GCM394, "%s:sunplus_gcm394_base_device::unkarea_7872_r\n", machine().describe_context()); return m_7872; }
+READ16_MEMBER(sunplus_gcm394_base_device::unkarea_7872_r) { LOGMASKED(LOG_GCM394, "%s:sunplus_gcm394_base_device::unkarea_7872_r\n", machine().describe_context()); return 0xffff;// m_7872;
+}
WRITE16_MEMBER(sunplus_gcm394_base_device::unkarea_7872_w) { LOGMASKED(LOG_GCM394, "%s:sunplus_gcm394_base_device::unkarea_7872_w %04x\n", machine().describe_context(), data); m_7872 = data; }
-READ16_MEMBER(sunplus_gcm394_base_device::unkarea_7873_r) { LOGMASKED(LOG_GCM394, "%s:sunplus_gcm394_base_device::unkarea_7873_r\n", machine().describe_context()); return m_7873; }
+READ16_MEMBER(sunplus_gcm394_base_device::unkarea_7873_r) { LOGMASKED(LOG_GCM394, "%s:sunplus_gcm394_base_device::unkarea_7873_r\n", machine().describe_context()); return 0xffff;// m_7873;
+}
WRITE16_MEMBER(sunplus_gcm394_base_device::unkarea_7873_w) { LOGMASKED(LOG_GCM394, "%s:sunplus_gcm394_base_device::unkarea_7873_w %04x\n", machine().describe_context(), data); m_7873 = data; }
-READ16_MEMBER(sunplus_gcm394_base_device::unkarea_7882_r) { LOGMASKED(LOG_GCM394, "%s:sunplus_gcm394_base_device::unkarea_7882_r\n", machine().describe_context()); return m_7882; }
+READ16_MEMBER(sunplus_gcm394_base_device::unkarea_7882_r) { LOGMASKED(LOG_GCM394, "%s:sunplus_gcm394_base_device::unkarea_7882_r\n", machine().describe_context()); return 0xffff;// m_7882;
+}
WRITE16_MEMBER(sunplus_gcm394_base_device::unkarea_7882_w) { LOGMASKED(LOG_GCM394, "%s:sunplus_gcm394_base_device::unkarea_7882_w %04x\n", machine().describe_context(), data); m_7882 = data; }
-READ16_MEMBER(sunplus_gcm394_base_device::unkarea_7883_r) { LOGMASKED(LOG_GCM394, "%s:sunplus_gcm394_base_device::unkarea_7883_r\n", machine().describe_context()); return m_7883; }
+READ16_MEMBER(sunplus_gcm394_base_device::unkarea_7883_r) { LOGMASKED(LOG_GCM394, "%s:sunplus_gcm394_base_device::unkarea_7883_r\n", machine().describe_context()); return 0xffff;// m_7883;
+}
WRITE16_MEMBER(sunplus_gcm394_base_device::unkarea_7883_w) { LOGMASKED(LOG_GCM394, "%s:sunplus_gcm394_base_device::unkarea_7883_w %04x\n", machine().describe_context(), data); m_7883 = data; }
WRITE16_MEMBER(sunplus_gcm394_base_device::unkarea_78a0_w) { LOGMASKED(LOG_GCM394, "%s:sunplus_gcm394_base_device::unkarea_78a0_w %04x\n", machine().describe_context(), data); m_78a0 = data; }
@@ -197,7 +234,7 @@ WRITE16_MEMBER(sunplus_gcm394_base_device::unkarea_78a0_w) { LOGMASKED(LOG_GCM39
READ16_MEMBER(sunplus_gcm394_base_device::unkarea_78a1_r)
{
LOGMASKED(LOG_GCM394, "%s:sunplus_gcm394_base_device::unkarea_78a1_r\n", machine().describe_context());
- return machine().rand();
+ return 0xffff;// machine().rand();
}
WRITE16_MEMBER(sunplus_gcm394_base_device::unkarea_78a4_w) { LOGMASKED(LOG_GCM394, "%s:sunplus_gcm394_base_device::unkarea_78a4_w %04x\n", machine().describe_context(), data); m_78a4 = data; }
@@ -213,7 +250,7 @@ WRITE16_MEMBER(sunplus_gcm394_base_device::unkarea_78b1_w) { LOGMASKED(LOG_GCM39
READ16_MEMBER(sunplus_gcm394_base_device::unkarea_78b2_r)
{
LOGMASKED(LOG_GCM394, "%s:sunplus_gcm394_base_device::unkarea_78b2_r\n", machine().describe_context());
- return m_78b2;
+ return 0xffff;// m_78b2;
}
WRITE16_MEMBER(sunplus_gcm394_base_device::unkarea_78b2_w) { LOGMASKED(LOG_GCM394, "%s:sunplus_gcm394_base_device::unkarea_78b2_w %04x\n", machine().describe_context(), data); m_78b2 = data; }
@@ -280,31 +317,33 @@ void sunplus_gcm394_base_device::internal_map(address_map &map)
// note, tilemaps are at the same address offsets in video device as spg2xx (but unknown devices are extra)
- map(0x007000, 0x007007).w(m_spg_video, FUNC(gcm394_base_video_device::unknown_video_device0_regs_w));
- map(0x007008, 0x00700f).w(m_spg_video, FUNC(gcm394_base_video_device::unknown_video_device1_regs_w));
+ map(0x007000, 0x007007).w(m_spg_video, FUNC(gcm394_base_video_device::unk_vid1_regs_w));
+ map(0x007008, 0x00700f).w(m_spg_video, FUNC(gcm394_base_video_device::unk_vid2_regs_w));
map(0x007010, 0x007015).rw(m_spg_video, FUNC(gcm394_base_video_device::tmap0_regs_r), FUNC(gcm394_base_video_device::tmap0_regs_w));
map(0x007016, 0x00701b).rw(m_spg_video, FUNC(gcm394_base_video_device::tmap1_regs_r), FUNC(gcm394_base_video_device::tmap1_regs_w));
map(0x007020, 0x007020).w(m_spg_video, FUNC(gcm394_base_video_device::tmap0_tilebase_lsb_w)); // probably tilebase, written with other tmap0 regs
map(0x007021, 0x007021).w(m_spg_video, FUNC(gcm394_base_video_device::tmap1_tilebase_lsb_w)); // probably tilebase, written with other tmap1 regs
- map(0x007022, 0x007022).w(m_spg_video, FUNC(gcm394_base_video_device::unknown_video_device2_unk0_w)); // another tilebase? maybe sprites? written as 7022, 702d and 7042 group
- map(0x007023, 0x007023).w(m_spg_video, FUNC(gcm394_base_video_device::unknown_video_device0_unk0_w)); // written with other unknown_video_device0 regs
- map(0x007024, 0x007024).w(m_spg_video, FUNC(gcm394_base_video_device::unknown_video_device1_unk0_w)); // written with other unknown_video_device1 regs
+ map(0x007022, 0x007022).w(m_spg_video, FUNC(gcm394_base_video_device::unk_vid0_gfxbase_lsb_w)); // another tilebase? maybe sprites? written as 7022, 702d and 7042 group
+ map(0x007023, 0x007023).w(m_spg_video, FUNC(gcm394_base_video_device::unk_vid1_gfxbase_lsb_w)); // written with other unknown_video_device0 regs
+ map(0x007024, 0x007024).w(m_spg_video, FUNC(gcm394_base_video_device::unk_vid2_gfxbase_lsb_w)); // written with other unknown_video_device1 regs
map(0x00702a, 0x00702a).w(m_spg_video, FUNC(gcm394_base_video_device::video_702a_w));
map(0x00702b, 0x00702b).w(m_spg_video, FUNC(gcm394_base_video_device::tmap0_tilebase_msb_w)); // written with other tmap0 regs
map(0x00702c, 0x00702c).w(m_spg_video, FUNC(gcm394_base_video_device::tmap1_tilebase_msb_w)); // written with other tmap1 regs
- map(0x00702d, 0x00702d).w(m_spg_video, FUNC(gcm394_base_video_device::unknown_video_device2_unk1_w)); // maybe sprites? written as 7022, 702d and 7042 group
- map(0x00702e, 0x00702e).w(m_spg_video, FUNC(gcm394_base_video_device::unknown_video_device0_unk1_w)); // written with other unknown_video_device0 regs
- map(0x00702f, 0x00702f).w(m_spg_video, FUNC(gcm394_base_video_device::unknown_video_device1_unk1_w)); // written with other unknown_video_device1 regs
+ map(0x00702d, 0x00702d).w(m_spg_video, FUNC(gcm394_base_video_device::unk_vid0_gfxbase_msb_w)); // maybe sprites? written as 7022, 702d and 7042 group
+ map(0x00702e, 0x00702e).w(m_spg_video, FUNC(gcm394_base_video_device::unk_vid1_gfxbase_msb_w)); // written with other unknown_video_device0 regs
+ map(0x00702f, 0x00702f).w(m_spg_video, FUNC(gcm394_base_video_device::unk_vid2_gfxbase_msb_w)); // written with other unknown_video_device1 regs
- map(0x007030, 0x007030).rw(m_spg_video, FUNC(gcm394_base_video_device::video_7030_r), FUNC(gcm394_base_video_device::video_7030_w));
+ map(0x007030, 0x007030).rw(m_spg_video, FUNC(gcm394_base_video_device::video_7030_brightness_r), FUNC(gcm394_base_video_device::video_7030_brightness_w));
map(0x00703a, 0x00703a).rw(m_spg_video, FUNC(gcm394_base_video_device::video_703a_r), FUNC(gcm394_base_video_device::video_703a_w));
map(0x00703c, 0x00703c).w(m_spg_video, FUNC(gcm394_base_video_device::video_703c_w));
- map(0x007042, 0x007042).w(m_spg_video, FUNC(gcm394_base_video_device::unknown_video_device2_unk2_w)); // maybe sprites? written as 7022, 702d and 7042 group
+ map(0x007042, 0x007042).w(m_spg_video, FUNC(gcm394_base_video_device::unk_vid0_extra_w)); // maybe sprites? written as 7022, 702d and 7042 group
+
+ map(0x007051, 0x007051).r(m_spg_video, FUNC(gcm394_base_video_device::video_7051_r)); // wrlshunt checks this
map(0x007062, 0x007062).rw(m_spg_video, FUNC(gcm394_base_video_device::video_7062_r), FUNC(gcm394_base_video_device::video_7062_w));
map(0x007063, 0x007063).rw(m_spg_video, FUNC(gcm394_base_video_device::video_7063_r), FUNC(gcm394_base_video_device::video_7063_w));
diff --git a/src/devices/machine/sunplus_gcm394_video.cpp b/src/devices/machine/sunplus_gcm394_video.cpp
index 44a574e99bf..2aac3b9cfec 100644
--- a/src/devices/machine/sunplus_gcm394_video.cpp
+++ b/src/devices/machine/sunplus_gcm394_video.cpp
@@ -40,26 +40,10 @@ gcm394_video_device::gcm394_video_device(const machine_config &mconfig, const ch
{
}
-void gcm394_base_video_device::device_start()
+void gcm394_base_video_device::decodegfx(const char* tag)
{
- for (uint8_t i = 0; i < 32; i++)
- {
- m_rgb5_to_rgb8[i] = (i << 3) | (i >> 2);
- }
- for (uint16_t i = 0; i < 0x8000; i++)
- {
- m_rgb555_to_rgb888[i] = (m_rgb5_to_rgb8[(i >> 10) & 0x1f] << 16) |
- (m_rgb5_to_rgb8[(i >> 5) & 0x1f] << 8) |
- (m_rgb5_to_rgb8[(i >> 0) & 0x1f] << 0);
- }
-
- m_video_irq_cb.resolve();
-
-
- m_gfxregion = memregion(":maincpu")->base();
- m_gfxregionsize = memregion(":maincpu")->bytes();
-
- int gfxelement = 0;
+ uint8_t* gfxregion = memregion(tag)->base();
+ int gfxregionsize = memregion(tag)->bytes();
if (1)
{
@@ -73,9 +57,9 @@ void gcm394_base_video_device::device_start()
{ STEP16(0,4 * 16) },
16 * 16 * 4
};
- obj_layout.total = m_gfxregionsize / (16 * 16 * 4 / 8);
- m_gfxdecode->set_gfx(gfxelement, std::make_unique<gfx_element>(m_palette, obj_layout, m_gfxregion, 0, 0x10 * 0x10, 0));
- gfxelement++;
+ obj_layout.total = gfxregionsize / (16 * 16 * 4 / 8);
+ m_gfxdecode->set_gfx(m_maxgfxelement, std::make_unique<gfx_element>(m_palette, obj_layout, gfxregion, 0, 0x10 * 0x10, 0));
+ m_maxgfxelement++;
}
if (1)
@@ -90,9 +74,9 @@ void gcm394_base_video_device::device_start()
{ STEP16(0,4 * 32) },
16 * 32 * 4
};
- obj_layout.total = m_gfxregionsize / (16 * 32 * 4 / 8);
- m_gfxdecode->set_gfx(gfxelement, std::make_unique<gfx_element>(m_palette, obj_layout, m_gfxregion, 0, 0x10 * 0x10, 0));
- gfxelement++;
+ obj_layout.total = gfxregionsize / (16 * 32 * 4 / 8);
+ m_gfxdecode->set_gfx(m_maxgfxelement, std::make_unique<gfx_element>(m_palette, obj_layout, gfxregion, 0, 0x10 * 0x10, 0));
+ m_maxgfxelement++;
}
if (1)
@@ -107,9 +91,9 @@ void gcm394_base_video_device::device_start()
{ STEP32(0,4 * 16) },
32 * 16 * 4
};
- obj_layout.total = m_gfxregionsize / (32 * 16 * 4 / 8);
- m_gfxdecode->set_gfx(gfxelement, std::make_unique<gfx_element>(m_palette, obj_layout, m_gfxregion, 0, 0x10 * 0x10, 0));
- gfxelement++;
+ obj_layout.total = gfxregionsize / (32 * 16 * 4 / 8);
+ m_gfxdecode->set_gfx(m_maxgfxelement, std::make_unique<gfx_element>(m_palette, obj_layout, gfxregion, 0, 0x10 * 0x10, 0));
+ m_maxgfxelement++;
}
if (1)
@@ -124,9 +108,9 @@ void gcm394_base_video_device::device_start()
{ STEP32(0,4 * 32) },
32 * 32 * 4
};
- obj_layout.total = m_gfxregionsize / (32 * 32 * 4 / 8);
- m_gfxdecode->set_gfx(gfxelement, std::make_unique<gfx_element>(m_palette, obj_layout, m_gfxregion, 0, 0x10 * 0x10, 0));
- gfxelement++;
+ obj_layout.total = gfxregionsize / (32 * 32 * 4 / 8);
+ m_gfxdecode->set_gfx(m_maxgfxelement, std::make_unique<gfx_element>(m_palette, obj_layout, gfxregion, 0, 0x10 * 0x10, 0));
+ m_maxgfxelement++;
}
if (1)
@@ -141,9 +125,9 @@ void gcm394_base_video_device::device_start()
{ STEP16(0,2 * 8) },
8 * 16 * 2
};
- obj_layout.total = m_gfxregionsize / (8 * 16 * 2 / 8);
- m_gfxdecode->set_gfx(gfxelement, std::make_unique<gfx_element>(m_palette, obj_layout, m_gfxregion, 0, 0x40 * 0x10, 0));
- gfxelement++;
+ obj_layout.total = gfxregionsize / (8 * 16 * 2 / 8);
+ m_gfxdecode->set_gfx(m_maxgfxelement, std::make_unique<gfx_element>(m_palette, obj_layout, gfxregion, 0, 0x40 * 0x10, 0));
+ m_maxgfxelement++;
}
if (1)
@@ -163,10 +147,65 @@ void gcm394_base_video_device::device_start()
texlayout_xoffset,
texlayout_yoffset
};
- obj_layout.total = m_gfxregionsize / (16 * 32 * 2 / 8);
- m_gfxdecode->set_gfx(gfxelement, std::make_unique<gfx_element>(m_palette, obj_layout, m_gfxregion, 0, 0x40 * 0x10, 0));
- gfxelement++;
+ obj_layout.total = gfxregionsize / (16 * 32 * 2 / 8);
+ m_gfxdecode->set_gfx(m_maxgfxelement, std::make_unique<gfx_element>(m_palette, obj_layout, gfxregion, 0, 0x40 * 0x10, 0));
+ m_maxgfxelement++;
+ }
+
+ if (1)
+ {
+ gfx_layout obj_layout =
+ {
+ 32,32,
+ 0,
+ 8,
+ { STEP8(0,1) },
+ { STEP32(0,8) },
+ { STEP32(0,8 * 32) },
+ 32 * 32 * 8
+ };
+ obj_layout.total = gfxregionsize / (32 * 32 * 8 / 8);
+ m_gfxdecode->set_gfx(m_maxgfxelement, std::make_unique<gfx_element>(m_palette, obj_layout, gfxregion, 0, 0x10, 0));
+ m_maxgfxelement++;
+ }
+
+ if (1)
+ {
+ gfx_layout obj_layout =
+ {
+ 32,32,
+ 0,
+ 6,
+ { 0,1,2,3,4,5 },
+ { STEP32(0,6) },
+ { STEP32(0,6 * 32) },
+ 32 * 32 * 6
+ };
+ obj_layout.total = gfxregionsize / (32 * 32 * 6 / 8);
+ m_gfxdecode->set_gfx(m_maxgfxelement, std::make_unique<gfx_element>(m_palette, obj_layout, gfxregion, 0, 0x40, 0));
+ m_maxgfxelement++;
+ }
+}
+
+void gcm394_base_video_device::device_start()
+{
+ for (uint8_t i = 0; i < 32; i++)
+ {
+ m_rgb5_to_rgb8[i] = (i << 3) | (i >> 2);
+ }
+ for (uint16_t i = 0; i < 0x8000; i++)
+ {
+ m_rgb555_to_rgb888[i] = (m_rgb5_to_rgb8[(i >> 10) & 0x1f] << 16) |
+ (m_rgb5_to_rgb8[(i >> 5) & 0x1f] << 8) |
+ (m_rgb5_to_rgb8[(i >> 0) & 0x1f] << 0);
}
+
+ m_video_irq_cb.resolve();
+
+ m_maxgfxelement = 0;
+
+ decodegfx(":maincpu");
+
save_item(NAME(m_spriteextra));
m_space_read_cb.resolve_safe(0);
}
@@ -192,7 +231,7 @@ void gcm394_base_video_device::device_reset()
m_7063 = 0x0000;
m_702a = 0x0000;
- m_7030 = 0x0000;
+ m_7030_brightness = 0x0000;
m_703c = 0x0000;
@@ -213,6 +252,13 @@ void gcm394_base_video_device::device_reset()
m_video_irq_status = 0x0000;
+ m_unk_vid0_gfxbase_lsb = 0;
+ m_unk_vid0_gfxbase_msb = 0;
+ m_unk_vid1_gfxbase_lsb = 0;
+ m_unk_vid1_gfxbase_msb = 0;
+ m_unk_vid2_gfxbase_lsb = 0;
+ m_unk_vid2_gfxbase_msb = 0;
+
}
/*************************
@@ -233,9 +279,8 @@ void gcm394_base_video_device::draw(const rectangle &cliprect, uint32_t line, ui
uint32_t words_per_tile = 8; // seems to be correct for sprites regardless of size / bpp
- uint32_t m = bitmap_addr + words_per_tile * tile + bits_per_row * (line ^ yflipmask);
+ uint32_t m = (bitmap_addr - 0x20000) + (words_per_tile * tile + bits_per_row * (line ^ yflipmask));
- m += (0x300000 / 2);
uint32_t bits = 0;
uint32_t nbits = 0;
@@ -245,10 +290,10 @@ void gcm394_base_video_device::draw(const rectangle &cliprect, uint32_t line, ui
if (yy >= 0x01c0)
yy -= 0x0200;
- if (yy > 240 || yy < 0)
+ if (yy > cliprect.max_y || yy < 0)
return;
- int y_index = yy * 320;
+ int y_index = yy * m_screen->width();
for (int32_t x = FlipX ? (w - 1) : 0; FlipX ? x >= 0 : x < w; FlipX ? x-- : x++)
{
@@ -299,7 +344,7 @@ void gcm394_base_video_device::draw(const rectangle &cliprect, uint32_t line, ui
if (xx >= 0x01c0)
xx -= 0x0200;
- if (xx >= 0 && xx < 320)
+ if (xx >= 0 && xx <= cliprect.max_x)
{
int pix_index = xx + y_index;
@@ -438,7 +483,7 @@ void gcm394_base_video_device::draw_page(const rectangle &cliprect, uint32_t sca
void gcm394_base_video_device::draw_sprite(const rectangle &cliprect, uint32_t scanline, int priority, uint32_t base_addr)
{
- uint32_t bitmap_addr = 0;// 0x40 * m_video_regs[0x22];
+ uint32_t bitmap_addr = (m_unk_vid1_gfxbase_msb << 16) | m_unk_vid1_gfxbase_lsb; // or unk_vid2 / 0
uint32_t tile = m_spriteram[base_addr + 0];
int16_t x = m_spriteram[base_addr + 1];
int16_t y = m_spriteram[base_addr + 2];
@@ -516,10 +561,10 @@ void gcm394_base_video_device::draw_sprites(const rectangle &cliprect, uint32_t
uint32_t gcm394_base_video_device::screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect)
{
- memset(&m_screenbuf[320 * cliprect.min_y], 0, 4 * 320 * ((cliprect.max_y - cliprect.min_y) + 1));
+ memset(&m_screenbuf[m_screen->width() * cliprect.min_y], 0, 4 * m_screen->width() * ((cliprect.max_y - cliprect.min_y) + 1));
- const uint32_t page0_addr = 0x40 * (m_page0_addr | (m_page0_addr_msb<<16));
- const uint32_t page1_addr = 0x40 * (m_page1_addr | (m_page1_addr_msb<<16));
+ const uint32_t page0_addr = (m_page0_addr_lsb | (m_page0_addr_msb<<16));
+ const uint32_t page1_addr = (m_page1_addr_lsb | (m_page1_addr_msb<<16));
uint16_t* page0_regs = m_tmap0_regs;
uint16_t* page1_regs = m_tmap1_regs;
@@ -539,7 +584,7 @@ uint32_t gcm394_base_video_device::screen_update(screen_device &screen, bitmap_r
for (int y = cliprect.min_y; y <= cliprect.max_y; y++)
{
uint32_t *dest = &bitmap.pix32(y, cliprect.min_x);
- uint32_t *src = &m_screenbuf[cliprect.min_x + 320 * y];
+ uint32_t *src = &m_screenbuf[cliprect.min_x + m_screen->width() * y];
memcpy(dest, src, sizeof(uint32_t) * ((cliprect.max_x - cliprect.min_x) + 1));
}
@@ -552,34 +597,34 @@ void gcm394_base_video_device::write_tmap_regs(int tmap, uint16_t* regs, int off
switch (offset)
{
case 0x0: // Page X scroll
- LOGMASKED(LOG_GCM394_TMAP, "write_tmap_regs: Page %d X Scroll = %04x\n", tmap, data & 0x01ff);
+ LOGMASKED(LOG_GCM394_TMAP, "%s: write_tmap_regs: Page %d X Scroll = %04x\n", machine().describe_context(), tmap, data & 0x01ff);
regs[offset] = data & 0x01ff;
break;
case 0x1: // Page Y scroll
- LOGMASKED(LOG_GCM394_TMAP, "write_tmap_regs: Page %d Y Scroll = %04x\n", tmap, data & 0x00ff);
+ LOGMASKED(LOG_GCM394_TMAP, "%s: write_tmap_regs: Page %d Y Scroll = %04x\n", machine().describe_context(), tmap, data & 0x00ff);
regs[offset] = data & 0x00ff;
break;
case 0x2: // Page Attributes
- LOGMASKED(LOG_GCM394_TMAP, "write_tmap_regs: Page %d Attributes = %04x (Depth:%d, Palette:%d, VSize:%d, HSize:%d, FlipY:%d, FlipX:%d, BPP:%d)\n", tmap, data
+ LOGMASKED(LOG_GCM394_TMAP, "%s: write_tmap_regs: Page %d Attributes = %04x (Depth:%d, Palette:%d, VSize:%d, HSize:%d, FlipY:%d, FlipX:%d, BPP:%d)\n", machine().describe_context(), tmap, data
, (data >> 12) & 3, (data >> 8) & 15, 8 << ((data >> 6) & 3), 8 << ((data >> 4) & 3), BIT(data, 3), BIT(data, 2), 2 * ((data & 3) + 1));
regs[offset] = data;
break;
case 0x3: // Page Control
- LOGMASKED(LOG_GCM394_TMAP, "write_tmap_regs: Page %d Control = %04x (Blend:%d, HiColor:%d, RowScroll:%d, Enable:%d, Wallpaper:%d, RegSet:%d, Bitmap:%d)\n", tmap, data
+ LOGMASKED(LOG_GCM394_TMAP, "%s: write_tmap_regs: Page %d Control = %04x (Blend:%d, HiColor:%d, RowScroll:%d, Enable:%d, Wallpaper:%d, RegSet:%d, Bitmap:%d)\n", machine().describe_context(), tmap, data
, BIT(data, 8), BIT(data, 7), BIT(data, 4), BIT(data, 3), BIT(data, 2), BIT(data, 1), BIT(data, 0));
regs[offset] = data;
break;
case 0x4: // Page Tile Address
- LOGMASKED(LOG_GCM394_TMAP, "write_tmap_regs: Page %d Tile Address = %04x\n", tmap, data & 0x1fff);
+ LOGMASKED(LOG_GCM394_TMAP, "%s: write_tmap_regs: Page %d Tile Address = %04x\n", machine().describe_context(), tmap, data & 0x1fff);
regs[offset] = data;
break;
case 0x5: // Page Attribute write_tmap_regs
- LOGMASKED(LOG_GCM394_TMAP, "write_tmap_regs: Page %d Attribute Address = %04x\n", tmap, data & 0x1fff);
+ LOGMASKED(LOG_GCM394_TMAP, "%s: write_tmap_regs: Page %d Attribute Address = %04x\n", machine().describe_context(), tmap, data & 0x1fff);
regs[offset] = data;
break;
}
@@ -598,13 +643,15 @@ WRITE16_MEMBER(gcm394_base_video_device::tmap0_regs_w)
WRITE16_MEMBER(gcm394_base_video_device::tmap0_tilebase_lsb_w)
{
LOGMASKED(LOG_GCM394_TMAP, "%s:gcm394_base_video_device::tmap0_tilebase_lsb_w %04x\n", machine().describe_context(), data);
- m_page0_addr = data;
+ m_page0_addr_lsb = data;
+ LOGMASKED(LOG_GCM394_TMAP, " (tmap0 tilegfxbase is now %04x%04x)\n", m_page0_addr_msb, m_page0_addr_lsb);
}
WRITE16_MEMBER(gcm394_base_video_device::tmap0_tilebase_msb_w)
{
LOGMASKED(LOG_GCM394_TMAP, "%s:gcm394_base_video_device::tmap0_tilebase_msb_w %04x\n", machine().describe_context(), data);
m_page0_addr_msb = data;
+ LOGMASKED(LOG_GCM394_TMAP, " (tmap0 tilegfxbase is now %04x%04x)\n", m_page0_addr_msb, m_page0_addr_lsb);
}
// **************************************** TILEMAP 1 *************************************************
@@ -620,72 +667,110 @@ WRITE16_MEMBER(gcm394_base_video_device::tmap1_regs_w)
WRITE16_MEMBER(gcm394_base_video_device::tmap1_tilebase_lsb_w)
{
LOGMASKED(LOG_GCM394_TMAP, "%s:gcm394_base_video_device::tmap1_tilebase_lsb_w %04x\n", machine().describe_context(), data);
- m_page1_addr = data;
+ m_page1_addr_lsb = data;
+ LOGMASKED(LOG_GCM394_TMAP, " (tmap1 tilegfxbase is now %04x%04x)\n", m_page1_addr_msb, m_page1_addr_lsb);
}
WRITE16_MEMBER(gcm394_base_video_device::tmap1_tilebase_msb_w)
{
LOGMASKED(LOG_GCM394_TMAP, "%s:gcm394_base_video_device::tmap1_tilebase_msb_w %04x\n", machine().describe_context(), data);
m_page1_addr_msb = data;
+ LOGMASKED(LOG_GCM394_TMAP, " (tmap1 tilegfxbase is now %04x%04x)\n", m_page1_addr_msb, m_page1_addr_lsb);
}
-// **************************************** unknown video device 0 (another tilemap? sprite layer?) *************************************************
+// **************************************** unknown video device handler for below *************************************************
-WRITE16_MEMBER(gcm394_base_video_device::unknown_video_device0_regs_w)
+// offsets 0,1,4,5,6,7 used in main IRQ code
+// offsets 2,3 only cleared on startup
+void gcm394_base_video_device::unk_vid_regs_w(int which, int offset, uint16_t data)
{
- // offsets 0,1,4,5,6,7 used in main IRQ code
- // offsets 2,3 only cleared on startup
+ switch (offset)
+ {
+ case 0x0:
+ LOGMASKED(LOG_GCM394_VIDEO, "unk_vid_regs_w (unk chip %d) %01x %04x (X scroll?)\n", machine().describe_context(), which, offset, data); // masked with 0x3ff in code like x-scroll for tilemaps
+ break;
+
+ case 0x1:
+ LOGMASKED(LOG_GCM394_VIDEO, "unk_vid_regs_w (unk chip %d) %01x %04x (y scroll?)\n", machine().describe_context(), which, offset, data); // masked with 0x3ff in code like x-scroll for tilemaps
+ break;
- LOGMASKED(LOG_GCM394_VIDEO, "%s:gcm394_base_video_device::unknown_video_device0_regs_w %01x %04x\n", machine().describe_context(), offset, data);
+ case 0x02: // startup?
+ case 0x03: // startup?
+
+ case 0x04:
+ case 0x05:
+ case 0x06:
+ case 0x07:
+ LOGMASKED(LOG_GCM394_VIDEO, "unk_vid_regs_w (unk chip %d) %01x %04x\n", machine().describe_context(), which, offset, data);
+ break;
+
+ }
}
-WRITE16_MEMBER(gcm394_base_video_device::unknown_video_device0_unk0_w)
+// **************************************** unknown video device 1 (another tilemap? sprite layer?) *************************************************
+
+WRITE16_MEMBER(gcm394_base_video_device::unk_vid1_regs_w)
{
- LOGMASKED(LOG_GCM394_VIDEO, "%s:gcm394_base_video_device::unknown_video_device0_unk0_w %04x\n", machine().describe_context(), data);
+ unk_vid_regs_w(0, offset, data);
}
-WRITE16_MEMBER(gcm394_base_video_device::unknown_video_device0_unk1_w)
+WRITE16_MEMBER(gcm394_base_video_device::unk_vid1_gfxbase_lsb_w)
{
- LOGMASKED(LOG_GCM394_VIDEO, "%s:gcm394_base_video_device::unknown_video_device0_unk1_w %04x\n", machine().describe_context(), data);
+ LOGMASKED(LOG_GCM394_VIDEO, "%s:gcm394_base_video_device::unk_vid1_gfxbase_lsb_w %04x\n", machine().describe_context(), data);
+ m_unk_vid1_gfxbase_lsb = data;
+ LOGMASKED(LOG_GCM394_TMAP, " (unk_vid1 tilegfxbase is now %04x%04x)\n", m_unk_vid1_gfxbase_msb, m_unk_vid1_gfxbase_lsb);
}
-// **************************************** unknown video device 1 (another tilemap? sprite layer?) *************************************************
-
-WRITE16_MEMBER(gcm394_base_video_device::unknown_video_device1_regs_w)
+WRITE16_MEMBER(gcm394_base_video_device::unk_vid1_gfxbase_msb_w)
{
- // offsets 0,1,4,5,6,7 used in main IRQ code
- // offsets 2,3 only cleared on startup
+ LOGMASKED(LOG_GCM394_VIDEO, "%s:gcm394_base_video_device::unk_vid1_gfxbase_msb_w %04x\n", machine().describe_context(), data);
+ m_unk_vid1_gfxbase_msb = data;
+ LOGMASKED(LOG_GCM394_TMAP, " (unk_vid1 tilegfxbase is now %04x%04x)\n", m_unk_vid1_gfxbase_msb, m_unk_vid1_gfxbase_lsb);
+}
+
+// **************************************** unknown video device 2 (another tilemap? sprite layer?) *************************************************
- LOGMASKED(LOG_GCM394_VIDEO, "%s:gcm394_base_video_device::unknown_video_device1_regs_w %01x %04x\n", machine().describe_context(), offset, data);
+WRITE16_MEMBER(gcm394_base_video_device::unk_vid2_regs_w)
+{
+ unk_vid_regs_w(1, offset, data);
}
-WRITE16_MEMBER(gcm394_base_video_device::unknown_video_device1_unk0_w)
+WRITE16_MEMBER(gcm394_base_video_device::unk_vid2_gfxbase_lsb_w)
{
- LOGMASKED(LOG_GCM394_VIDEO, "%s:gcm394_base_video_device::unknown_video_device1_unk0_w %04x\n", machine().describe_context(), data);
+ LOGMASKED(LOG_GCM394_VIDEO, "%s:gcm394_base_video_device::unk_vid2_gfxbase_lsb_w %04x\n", machine().describe_context(), data);
+ m_unk_vid2_gfxbase_lsb = data;
+ LOGMASKED(LOG_GCM394_TMAP, " (unk_vid2 tilegfxbase is now %04x%04x)\n", m_unk_vid2_gfxbase_msb, m_unk_vid2_gfxbase_lsb);
}
-WRITE16_MEMBER(gcm394_base_video_device::unknown_video_device1_unk1_w)
+WRITE16_MEMBER(gcm394_base_video_device::unk_vid2_gfxbase_msb_w)
{
- LOGMASKED(LOG_GCM394_VIDEO, "%s:gcm394_base_video_device::unknown_video_device1_unk1_w %04x\n", machine().describe_context(), data);
+ LOGMASKED(LOG_GCM394_VIDEO, "%s:gcm394_base_video_device::unk_vid2_gfxbase_msb_w %04x\n", machine().describe_context(), data);
+ m_unk_vid2_gfxbase_msb = data;
+ LOGMASKED(LOG_GCM394_TMAP, " (unk_vid2 tilegfxbase is now %04x%04x)\n", m_unk_vid2_gfxbase_msb, m_unk_vid2_gfxbase_lsb);
}
-// **************************************** unknown video device 2 (sprite control?) *************************************************
+// **************************************** unknown video device 0 (sprite control?) *************************************************
-WRITE16_MEMBER(gcm394_base_video_device::unknown_video_device2_unk0_w)
+WRITE16_MEMBER(gcm394_base_video_device::unk_vid0_gfxbase_lsb_w)
{
- LOGMASKED(LOG_GCM394_VIDEO, "%s:gcm394_base_video_device::unknown_video_device2_unk0_w %04x\n", machine().describe_context(), data);
+ LOGMASKED(LOG_GCM394_VIDEO, "%s:gcm394_base_video_device::unk_vid0_gfxbase_lsb_w %04x\n", machine().describe_context(), data);
+ m_unk_vid0_gfxbase_lsb = data;
+ LOGMASKED(LOG_GCM394_TMAP, " (unk_vid0 tilegfxbase is now %04x%04x)\n", m_unk_vid0_gfxbase_msb, m_unk_vid0_gfxbase_lsb);
}
-WRITE16_MEMBER(gcm394_base_video_device::unknown_video_device2_unk1_w)
+WRITE16_MEMBER(gcm394_base_video_device::unk_vid0_gfxbase_msb_w)
{
- LOGMASKED(LOG_GCM394_VIDEO, "%s:gcm394_base_video_device::unknown_video_device2_unk1_w %04x\n", machine().describe_context(), data);
+ LOGMASKED(LOG_GCM394_VIDEO, "%s:gcm394_base_video_device::unk_vid0_gfxbase_msb_w %04x\n", machine().describe_context(), data);
+ m_unk_vid0_gfxbase_msb = data;
+ LOGMASKED(LOG_GCM394_TMAP, " (unk_vid0 tilegfxbase is now %04x%04x)\n", m_unk_vid0_gfxbase_msb, m_unk_vid0_gfxbase_lsb);
}
-WRITE16_MEMBER(gcm394_base_video_device::unknown_video_device2_unk2_w)
+WRITE16_MEMBER(gcm394_base_video_device::unk_vid0_extra_w)
{
- LOGMASKED(LOG_GCM394_VIDEO, "%s:gcm394_base_video_device::unknown_video_device2_unk2_w %04x\n", machine().describe_context(), data);
+ LOGMASKED(LOG_GCM394_VIDEO, "%s:gcm394_base_video_device::unk_vid0_extra_w %04x\n", machine().describe_context(), data);
}
+
// **************************************** video DMA device *************************************************
WRITE16_MEMBER(gcm394_base_video_device::video_dma_source_w)
@@ -798,15 +883,33 @@ WRITE16_MEMBER(gcm394_base_video_device::video_7063_w)
WRITE16_MEMBER(gcm394_base_video_device::video_702a_w) { LOGMASKED(LOG_GCM394_VIDEO, "%s:gcm394_base_video_device::video_702a_w %04x\n", machine().describe_context(), data); m_702a = data; }
// read in IRQ
-READ16_MEMBER(gcm394_base_video_device::video_7030_r)
+READ16_MEMBER(gcm394_base_video_device::video_7030_brightness_r)
{
- LOGMASKED(LOG_GCM394_VIDEO, "%s:gcm394_base_video_device::video_7030_r\n", machine().describe_context());
- return 0x0000; /* wrlshunt ends up doing an explicit jump to 0000 shortly after boot if you just return the value written here, what is it? do we want to be returning non-zero to continue, with the problem being elsewhere, or is this the problem? */
+ /* wrlshunt ends up doing an explicit jump to 0000 shortly after boot if you just return the value written here, however I think that is correct code flow and something else is wrong
+ as this simply looks like some kind of brightness register - there is code to decrease it from 0xff to 0x00 by 0x5 increments (waiting for it to hit 0x05) and code to do the reverse
+ either way it really looks like the data written should be read back.
+ */
+ uint16_t retdat = m_7030_brightness;
+ LOGMASKED(LOG_GCM394_VIDEO, "%s:gcm394_base_video_device::video_7030_brightness_r (returning %04x)\n", machine().describe_context(), retdat);
+ return retdat;
+}
+
+WRITE16_MEMBER(gcm394_base_video_device::video_7030_brightness_w)
+{
+ LOGMASKED(LOG_GCM394_VIDEO, "%s:gcm394_base_video_device::video_7030_brightness_w %04x\n", machine().describe_context(), data);
+ m_7030_brightness = data;
}
-WRITE16_MEMBER(gcm394_base_video_device::video_7030_w) { LOGMASKED(LOG_GCM394_VIDEO, "%s:gcm394_base_video_device::video_7030_w %04x\n", machine().describe_context(), data); m_7030 = data; }
WRITE16_MEMBER(gcm394_base_video_device::video_703c_w) { LOGMASKED(LOG_GCM394_VIDEO, "%s:gcm394_base_video_device::video_703c_w %04x\n", machine().describe_context(), data); m_703c = data; }
+READ16_MEMBER(gcm394_base_video_device::video_7051_r)
+{
+ /* related to what ends up crashing wrlshunt? */
+ uint16_t retdat = 0x03ff;
+ LOGMASKED(LOG_GCM394_VIDEO, "%s:gcm394_base_video_device::video_7051_r (returning %04x)\n", machine().describe_context(), retdat);
+ return retdat;
+}
+
WRITE16_MEMBER(gcm394_base_video_device::video_7080_w) { LOGMASKED(LOG_GCM394_VIDEO, "%s:gcm394_base_video_device::video_7080_w %04x\n", machine().describe_context(), data); m_7080 = data; }
WRITE16_MEMBER(gcm394_base_video_device::video_7081_w) { LOGMASKED(LOG_GCM394_VIDEO, "%s:gcm394_base_video_device::video_7081_w %04x\n", machine().describe_context(), data); m_7081 = data; }
WRITE16_MEMBER(gcm394_base_video_device::video_7082_w) { LOGMASKED(LOG_GCM394_VIDEO, "%s:gcm394_base_video_device::video_7082_w %04x\n", machine().describe_context(), data); m_7082 = data; }
@@ -821,7 +924,7 @@ READ16_MEMBER(gcm394_base_video_device::video_7083_r) { LOGMASKED(LOG_GCM394_VID
WRITE16_MEMBER(gcm394_base_video_device::palette_w)
{
- LOGMASKED(LOG_GCM394_VIDEO, "%s:gcm394_base_video_device::palette_w %04x : %04x (value of 0x703a is %04x)\n", machine().describe_context().c_str(), offset, data, m_703a);
+ LOGMASKED(LOG_GCM394_VIDEO, "%s:gcm394_base_video_device::palette_w %04x : %04x (value of 0x703a is %04x)\n", machine().describe_context(), offset, data, m_703a);
if (m_703a & 0xfff0)
{
diff --git a/src/devices/machine/sunplus_gcm394_video.h b/src/devices/machine/sunplus_gcm394_video.h
index 0c4940bf53d..17131c3ca22 100644
--- a/src/devices/machine/sunplus_gcm394_video.h
+++ b/src/devices/machine/sunplus_gcm394_video.h
@@ -37,17 +37,17 @@ public:
DECLARE_WRITE16_MEMBER(tmap1_tilebase_lsb_w);
DECLARE_WRITE16_MEMBER(tmap1_tilebase_msb_w);
- DECLARE_WRITE16_MEMBER(unknown_video_device0_regs_w);
- DECLARE_WRITE16_MEMBER(unknown_video_device0_unk0_w);
- DECLARE_WRITE16_MEMBER(unknown_video_device0_unk1_w);
+ DECLARE_WRITE16_MEMBER(unk_vid1_regs_w);
+ DECLARE_WRITE16_MEMBER(unk_vid1_gfxbase_lsb_w);
+ DECLARE_WRITE16_MEMBER(unk_vid1_gfxbase_msb_w);
- DECLARE_WRITE16_MEMBER(unknown_video_device1_regs_w);
- DECLARE_WRITE16_MEMBER(unknown_video_device1_unk0_w);
- DECLARE_WRITE16_MEMBER(unknown_video_device1_unk1_w);
+ DECLARE_WRITE16_MEMBER(unk_vid2_regs_w);
+ DECLARE_WRITE16_MEMBER(unk_vid2_gfxbase_lsb_w);
+ DECLARE_WRITE16_MEMBER(unk_vid2_gfxbase_msb_w);
- DECLARE_WRITE16_MEMBER(unknown_video_device2_unk0_w);
- DECLARE_WRITE16_MEMBER(unknown_video_device2_unk1_w);
- DECLARE_WRITE16_MEMBER(unknown_video_device2_unk2_w);
+ DECLARE_WRITE16_MEMBER(unk_vid0_gfxbase_lsb_w);
+ DECLARE_WRITE16_MEMBER(unk_vid0_gfxbase_msb_w);
+ DECLARE_WRITE16_MEMBER(unk_vid0_extra_w);
DECLARE_WRITE16_MEMBER(video_dma_source_w);
DECLARE_WRITE16_MEMBER(video_dma_dest_w);
@@ -65,8 +65,8 @@ public:
DECLARE_WRITE16_MEMBER(video_7063_w);
DECLARE_WRITE16_MEMBER(video_702a_w);
- DECLARE_READ16_MEMBER(video_7030_r);
- DECLARE_WRITE16_MEMBER(video_7030_w);
+ DECLARE_READ16_MEMBER(video_7030_brightness_r);
+ DECLARE_WRITE16_MEMBER(video_7030_brightness_w);
DECLARE_WRITE16_MEMBER(video_703c_w);
DECLARE_READ16_MEMBER(video_707c_r);
@@ -89,10 +89,9 @@ public:
DECLARE_READ16_MEMBER(palette_r);
DECLARE_WRITE16_MEMBER(palette_w);
- auto write_video_irq_callback() { return m_video_irq_cb.bind(); };
+ DECLARE_READ16_MEMBER(video_7051_r);
- uint8_t* m_gfxregion;
- uint32_t m_gfxregionsize;
+ auto write_video_irq_callback() { return m_video_irq_cb.bind(); };
virtual void device_add_mconfig(machine_config& config) override;
@@ -147,7 +146,7 @@ protected:
void draw_sprites(const rectangle& cliprect, uint32_t scanline, int priority);
void draw_sprite(const rectangle& cliprect, uint32_t scanline, int priority, uint32_t base_addr);
- uint32_t m_screenbuf[320 * 240];
+ uint32_t m_screenbuf[640 * 480];
uint8_t m_rgb5_to_rgb8[32];
uint32_t m_rgb555_to_rgb888[0x8000];
@@ -156,10 +155,10 @@ protected:
// required_shared_ptr<uint16_t> m_scrollram;
required_shared_ptr<uint16_t> m_spriteram;
- uint16_t m_page0_addr;
+ uint16_t m_page0_addr_lsb;
uint16_t m_page0_addr_msb;
- uint16_t m_page1_addr;
+ uint16_t m_page1_addr_lsb;
uint16_t m_page1_addr_msb;
uint16_t m_videodma_bank;
@@ -180,7 +179,7 @@ protected:
uint16_t m_7063;
uint16_t m_702a;
- uint16_t m_7030;
+ uint16_t m_7030_brightness;
uint16_t m_703c;
@@ -194,6 +193,15 @@ protected:
uint16_t m_7087;
uint16_t m_7088;
+ uint16_t m_unk_vid0_gfxbase_lsb;
+ uint16_t m_unk_vid0_gfxbase_msb;
+ uint16_t m_unk_vid1_gfxbase_lsb;
+ uint16_t m_unk_vid1_gfxbase_msb;
+ uint16_t m_unk_vid2_gfxbase_lsb;
+ uint16_t m_unk_vid2_gfxbase_msb;
+
+ void unk_vid_regs_w(int which, int offset, uint16_t data);
+
uint16_t m_video_irq_status;
uint16_t m_spriteextra[0x100];
@@ -202,6 +210,10 @@ protected:
required_device<palette_device> m_palette;
required_device<gfxdecode_device> m_gfxdecode;
devcb_read16 m_space_read_cb;
+
+ int m_maxgfxelement;
+ void decodegfx(const char* tag);
+
};
class gcm394_video_device : public gcm394_base_video_device