summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author David Haywood <mamehaze@gmail.com>2019-05-14 15:02:40 +0100
committer ajrhacker <ajrhacker@users.noreply.github.com>2019-05-14 10:02:40 -0400
commite24a0a19308457e5a23cd84a35fffea53701eea5 (patch)
tree225b2908ad5409f1411dcbb46f3cf2fa65833616
parent12347f9d6445f05a00a0ddf388a2d2495b66d303 (diff)
smartfp - render something that isn't garbage (once sprites appear) (nw) (#5052)
* better logging (nw) * (nw) * (nw) * sprite drawing improvements (nw) * (nw) * debug stuff (nw) * this changes flow (nw) * prepare for possible palette banking (nw) * log a register value, might be important, might not (nw) * smartfp - push forward (nw) * 'bank' palette writes (nw)
-rw-r--r--src/devices/cpu/unsp/unsp_exxx.cpp2
-rw-r--r--src/devices/machine/sunplus_gcm394.cpp51
-rw-r--r--src/devices/machine/sunplus_gcm394.h20
-rw-r--r--src/devices/machine/sunplus_gcm394_video.cpp229
-rw-r--r--src/devices/machine/sunplus_gcm394_video.h22
-rw-r--r--src/mame/drivers/sunplus_gcm394.cpp62
6 files changed, 317 insertions, 69 deletions
diff --git a/src/devices/cpu/unsp/unsp_exxx.cpp b/src/devices/cpu/unsp/unsp_exxx.cpp
index 2572910cf43..57242b85488 100644
--- a/src/devices/cpu/unsp/unsp_exxx.cpp
+++ b/src/devices/cpu/unsp/unsp_exxx.cpp
@@ -165,7 +165,7 @@ void unsp_12_device::execute_exxx_group(uint16_t op)
case 0x02:
logerror("%s = %s lsl %s\n", regs[rd], regs[rd], regs[rs]);
- unimplemented_opcode(op);
+ m_core->m_r[rd] = m_core->m_r[rd] << m_core->m_r[rs];
return;
case 0x03:
diff --git a/src/devices/machine/sunplus_gcm394.cpp b/src/devices/machine/sunplus_gcm394.cpp
index 5e6061582b5..f63d69e9bcf 100644
--- a/src/devices/machine/sunplus_gcm394.cpp
+++ b/src/devices/machine/sunplus_gcm394.cpp
@@ -136,7 +136,7 @@ WRITE16_MEMBER(sunplus_gcm394_base_device::unkarea_7824_w) { LOGMASKED(LOG_GCM39
WRITE16_MEMBER(sunplus_gcm394_base_device::unkarea_7835_w) { LOGMASKED(LOG_GCM394, "%s:sunplus_gcm394_base_device::unkarea_7835_w %04x\n", machine().describe_context(), data); m_7835 = data; }
-READ16_MEMBER(sunplus_gcm394_base_device::unkarea_7860_r) { LOGMASKED(LOG_GCM394, "%s:sunplus_gcm394_base_device::unkarea_7860_r\n", machine().describe_context()); return m_7860; }
+READ16_MEMBER(sunplus_gcm394_base_device::unkarea_7860_r) { LOGMASKED(LOG_GCM394, "%s:sunplus_gcm394_base_device::unkarea_7860_r\n", machine().describe_context()); return m_porta_in(); }
WRITE16_MEMBER(sunplus_gcm394_base_device::unkarea_7860_w) { LOGMASKED(LOG_GCM394, "%s:sunplus_gcm394_base_device::unkarea_7860_w %04x\n", machine().describe_context(), data); m_7860 = 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; }
@@ -181,10 +181,19 @@ WRITE16_MEMBER(sunplus_gcm394_base_device::unkarea_78f0_w) { LOGMASKED(LOG_GCM39
// **************************************** 79xx region stubs *************************************************
-READ16_MEMBER(sunplus_gcm394_base_device::unkarea_7934_r) { LOGMASKED(LOG_GCM394, "%s:sunplus_gcm394_base_device::unkarea_7934_r\n", machine().describe_context()); return m_7934; }
+READ16_MEMBER(sunplus_gcm394_base_device::unkarea_7934_r) { LOGMASKED(LOG_GCM394, "%s:sunplus_gcm394_base_device::unkarea_7934_r\n", machine().describe_context()); return 0x0000; }
WRITE16_MEMBER(sunplus_gcm394_base_device::unkarea_7934_w) { LOGMASKED(LOG_GCM394, "%s:sunplus_gcm394_base_device::unkarea_7934_w %04x\n", machine().describe_context(), data); m_7934 = data; }
-READ16_MEMBER(sunplus_gcm394_base_device::unkarea_7936_r) { LOGMASKED(LOG_GCM394, "%s:sunplus_gcm394_base_device::unkarea_7936_r\n", machine().describe_context()); return m_7936; }
+// value of 7935 is read then written in irq6, nothing happens unless bit 0x0100 was set, which could be some kind of irq source being acked?
+READ16_MEMBER(sunplus_gcm394_base_device::unkarea_7935_r) { LOGMASKED(LOG_GCM394, "%s:sunplus_gcm394_base_device::unkarea_7935_r\n", machine().describe_context()); return m_7935; }
+WRITE16_MEMBER(sunplus_gcm394_base_device::unkarea_7935_w)
+{
+ LOGMASKED(LOG_GCM394, "%s:sunplus_gcm394_base_device::unkarea_7935_w %04x\n", machine().describe_context(), data);
+ m_7935 &= ~data;
+ checkirq6();
+}
+
+READ16_MEMBER(sunplus_gcm394_base_device::unkarea_7936_r) { LOGMASKED(LOG_GCM394, "%s:sunplus_gcm394_base_device::unkarea_7936_r\n", machine().describe_context()); return 0x0000; }
WRITE16_MEMBER(sunplus_gcm394_base_device::unkarea_7936_w) { LOGMASKED(LOG_GCM394, "%s:sunplus_gcm394_base_device::unkarea_7936_w %04x\n", machine().describe_context(), data); m_7936 = data; }
// **************************************** fallthrough logger etc. *************************************************
@@ -276,7 +285,8 @@ void sunplus_gcm394_base_device::map(address_map &map)
// 73xx-77xx = ram areas?
// ######################################################################################################################################################################################
- map(0x007300, 0x0073ff).ram().w("palette", FUNC(palette_device::write16)).share("palette");
+ map(0x007300, 0x0073ff).rw(m_spg_video, FUNC(gcm394_base_video_device::palette_r), FUNC(gcm394_base_video_device::palette_w));
+
map(0x007400, 0x0077ff).ram().share("spriteram");
// ######################################################################################################################################################################################
@@ -347,12 +357,14 @@ void sunplus_gcm394_base_device::map(address_map &map)
// ######################################################################################################################################################################################
map(0x007934, 0x007934).rw(FUNC(sunplus_gcm394_base_device::unkarea_7934_r), FUNC(sunplus_gcm394_base_device::unkarea_7934_w));
+ map(0x007935, 0x007935).rw(FUNC(sunplus_gcm394_base_device::unkarea_7935_r), FUNC(sunplus_gcm394_base_device::unkarea_7935_w));
map(0x007936, 0x007936).rw(FUNC(sunplus_gcm394_base_device::unkarea_7936_r), FUNC(sunplus_gcm394_base_device::unkarea_7936_w));
// ######################################################################################################################################################################################
// 7axx region = system (including dma)
// ######################################################################################################################################################################################
+
map(0x007a80, 0x007a86).w(FUNC(sunplus_gcm394_base_device::system_dma_params_w));
map(0x007abf, 0x007abf).rw(FUNC(sunplus_gcm394_base_device::system_dma_status_r), FUNC(sunplus_gcm394_base_device::system_dma_trigger_w));
@@ -368,6 +380,10 @@ void sunplus_gcm394_base_device::map(address_map &map)
void sunplus_gcm394_base_device::device_start()
{
+ m_porta_in.resolve_safe(0);
+
+ m_unk_timer = timer_alloc(0);
+ m_unk_timer->adjust(attotime::never);
}
void sunplus_gcm394_base_device::device_reset()
@@ -434,10 +450,34 @@ void sunplus_gcm394_base_device::device_reset()
// 79xx unknown
m_7934 = 0x0000;
+ m_7935 = 0x0000;
m_7936 = 0x0000;
+ m_unk_timer->adjust(attotime::from_hz(60), 0, attotime::from_hz(60));
+}
+
+void sunplus_gcm394_base_device::checkirq6()
+{
+ if (m_7935 & 0x0100)
+ m_cpu->set_state_unsynced(UNSP_IRQ6_LINE, ASSERT_LINE);
+ else
+ m_cpu->set_state_unsynced(UNSP_IRQ6_LINE, CLEAR_LINE);
+}
+
+void sunplus_gcm394_base_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
+{
+ switch (id)
+ {
+ case 0:
+ {
+ m_7935 |= 0x0100;
+ checkirq6();
+ break;
+ }
+ }
}
+
WRITE_LINE_MEMBER(sunplus_gcm394_base_device::videoirq_w)
{
m_cpu->set_state_unsynced(UNSP_IRQ5_LINE, state);
@@ -451,9 +491,6 @@ void sunplus_gcm394_base_device::device_add_mconfig(machine_config &config)
GCM394_VIDEO(config, m_spg_video, DERIVED_CLOCK(1, 1), m_cpu, m_screen);
m_spg_video->write_video_irq_callback().set(FUNC(sunplus_gcm394_base_device::videoirq_w));
- m_spg_video->set_palette(m_palette);
-
- PALETTE(config, m_palette).set_format(palette_device::xRGB_555, 256);
}
diff --git a/src/devices/machine/sunplus_gcm394.h b/src/devices/machine/sunplus_gcm394.h
index 70480f4d9ed..c822893b543 100644
--- a/src/devices/machine/sunplus_gcm394.h
+++ b/src/devices/machine/sunplus_gcm394.h
@@ -24,8 +24,8 @@ public:
, device_mixer_interface(mconfig, *this, 2)
, m_cpu(*this, finder_base::DUMMY_TAG)
, m_screen(*this, finder_base::DUMMY_TAG)
- , m_palette(*this, "palette")
, m_spg_video(*this, "spgvideo")
+ , m_porta_in(*this)
{
}
@@ -33,6 +33,8 @@ public:
uint32_t screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect) { return m_spg_video->screen_update(screen, bitmap, cliprect); }
+ auto porta_in() { return m_porta_in.bind(); }
+
DECLARE_WRITE_LINE_MEMBER(vblank) { m_spg_video->vblank(state); }
virtual void device_add_mconfig(machine_config& config) override;
@@ -44,9 +46,10 @@ protected:
required_device<unsp_device> m_cpu;
required_device<screen_device> m_screen;
- required_device<palette_device> m_palette;
required_device<gcm394_video_device> m_spg_video;
+ devcb_read16 m_porta_in;
+
uint16_t m_dma_params[7];
// unk 78xx
@@ -109,6 +112,7 @@ protected:
// unk 79xx
uint16_t m_7934;
+ uint16_t m_7935;
uint16_t m_7936;
@@ -194,12 +198,24 @@ private:
DECLARE_READ16_MEMBER(unkarea_7934_r);
DECLARE_WRITE16_MEMBER(unkarea_7934_w);
+
+ DECLARE_READ16_MEMBER(unkarea_7935_r);
+ DECLARE_WRITE16_MEMBER(unkarea_7935_w);
+
DECLARE_READ16_MEMBER(unkarea_7936_r);
DECLARE_WRITE16_MEMBER(unkarea_7936_w);
DECLARE_WRITE_LINE_MEMBER(videoirq_w);
+
+ void checkirq6();
+
+ emu_timer *m_unk_timer;
+ virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override;
+
};
+
+
class sunplus_gcm394_device : public sunplus_gcm394_base_device
{
public:
diff --git a/src/devices/machine/sunplus_gcm394_video.cpp b/src/devices/machine/sunplus_gcm394_video.cpp
index a07ea7c44f8..9b8c442d229 100644
--- a/src/devices/machine/sunplus_gcm394_video.cpp
+++ b/src/devices/machine/sunplus_gcm394_video.cpp
@@ -13,23 +13,24 @@ DEFINE_DEVICE_TYPE(GCM394_VIDEO, gcm394_video_device, "gcm394_video", "SunPlus G
#define LOG_GCM394_VIDEO_DMA (1U << 3)
#define LOG_GCM394_TMAP (1U << 2)
-#define LOG_GCM394 (1U << 1)
+#define LOG_GCM394_VIDEO (1U << 1)
-#define VERBOSE (LOG_GCM394_VIDEO_DMA)
+#define VERBOSE (LOG_GCM394_VIDEO_DMA | LOG_GCM394_VIDEO)
#include "logmacro.h"
gcm394_base_video_device::gcm394_base_video_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock)
: device_t(mconfig, type, tag, owner, clock)
- , device_gfx_interface(mconfig, *this, nullptr)
+ //, device_gfx_interface(mconfig, *this, nullptr)
, device_video_interface(mconfig, *this)
, m_cpu(*this, finder_base::DUMMY_TAG)
, m_screen(*this, finder_base::DUMMY_TAG)
// , m_scrollram(*this, "scrollram")
- , m_paletteram(*this, "^palette")
, m_spriteram(*this, "^spriteram")
, m_video_irq_cb(*this)
+ , m_palette(*this, "palette")
+ , m_gfxdecode(*this, "gfxdecode")
{
}
@@ -53,8 +54,9 @@ void gcm394_base_video_device::device_start()
m_video_irq_cb.resolve();
- uint8_t* gfxregion = memregion(":maincpu")->base();
- int gfxregion_size = memregion(":maincpu")->bytes();
+
+ m_gfxregion = memregion(":maincpu")->base();
+ m_gfxregionsize = memregion(":maincpu")->bytes();
int gfxelement = 0;
@@ -70,8 +72,8 @@ void gcm394_base_video_device::device_start()
{ STEP16(0,4 * 16) },
16 * 16 * 4
};
- obj_layout.total = gfxregion_size / (16 * 16 * 4 / 8);
- set_gfx(gfxelement, std::make_unique<gfx_element>(&palette(), obj_layout, gfxregion, 0, 0x10, 0));
+ 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, 0));
gfxelement++;
}
@@ -87,8 +89,8 @@ void gcm394_base_video_device::device_start()
{ STEP16(0,4 * 32) },
16 * 32 * 4
};
- obj_layout.total = gfxregion_size / (16 * 32 * 4 / 8);
- set_gfx(gfxelement, std::make_unique<gfx_element>(&palette(), obj_layout, gfxregion, 0, 0x10, 0));
+ 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, 0));
gfxelement++;
}
@@ -104,11 +106,66 @@ void gcm394_base_video_device::device_start()
{ STEP32(0,4 * 16) },
32 * 16 * 4
};
- obj_layout.total = gfxregion_size / (32 * 16 * 4 / 8);
- set_gfx(gfxelement, std::make_unique<gfx_element>(&palette(), obj_layout, gfxregion, 0, 0x10, 0));
+ 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, 0));
gfxelement++;
}
+ if (1)
+ {
+ gfx_layout obj_layout =
+ {
+ 32,32,
+ 0,
+ 4,
+ { STEP4(0,1) },
+ { STEP32(0,4) },
+ { 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, 0));
+ gfxelement++;
+ }
+
+ if (1)
+ {
+ gfx_layout obj_layout =
+ {
+ 8,16,
+ 0,
+ 2,
+ { 0,1 },
+ { STEP8(0,2) },
+ { 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, 0));
+ gfxelement++;
+ }
+
+ if (1)
+ {
+ const uint32_t texlayout_xoffset[64] = { STEP64(0,2) };
+ const uint32_t texlayout_yoffset[32] = { STEP32(0,2*64) };
+
+ gfx_layout obj_layout =
+ {
+ 64,32,
+ 0,
+ 2,
+ { 0,1 },
+ EXTENDED_XOFFS,
+ EXTENDED_YOFFS,
+ 32 * 64 * 2,
+ 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, 0));
+ gfxelement++;
+ }
save_item(NAME(m_spriteextra));
}
@@ -123,6 +180,10 @@ void gcm394_base_video_device::device_reset()
for (int i=0;i<0x100;i++)
m_spriteextra[i] = 0x0000;
+ for (int i=0;i<0x100;i++)
+ m_paletteram[i] = machine().rand()&0x7fff;
+
+
m_707f = 0x0000;
m_703a = 0x0000;
m_7062 = 0x0000;
@@ -158,14 +219,13 @@ void gcm394_base_video_device::device_reset()
inline uint16_t gcm394_base_video_device::read_data(uint32_t offset)
{
- address_space &space = m_cpu->space(AS_PROGRAM);
- uint16_t b = space.read_word(offset);
+ uint16_t b = m_gfxregion[(offset * 2) & (m_gfxregionsize - 1)] | (m_gfxregion[(offset * 2 + 1) & (m_gfxregionsize - 1)] << 8);
return b;
}
template<gcm394_base_video_device::blend_enable_t Blend, gcm394_base_video_device::rowscroll_enable_t RowScroll, gcm394_base_video_device::flipx_t FlipX>
-void gcm394_base_video_device::draw(const rectangle &cliprect, uint32_t line, uint32_t xoff, uint32_t yoff, uint32_t bitmap_addr, uint16_t tile, int32_t h, int32_t w, uint8_t bpp, uint32_t yflipmask, uint32_t palette_offset)
+void gcm394_base_video_device::draw(const rectangle &cliprect, uint32_t line, uint32_t xoff, uint32_t yoff, uint32_t bitmap_addr, uint32_t tile, int32_t h, int32_t w, uint8_t bpp, uint32_t yflipmask, uint32_t palette_offset)
{
uint32_t nc_bpp = ((bpp) + 1) << 1;
@@ -173,8 +233,14 @@ void gcm394_base_video_device::draw(const rectangle &cliprect, uint32_t line, ui
palette_offset <<= nc_bpp;
uint32_t bits_per_row = nc_bpp * w / 16;
- uint32_t words_per_tile = bits_per_row * h;
+ //uint32_t words_per_tile = bits_per_row * h;
+
+ 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);
+
+ m += (0x300000 / 2);
+
uint32_t bits = 0;
uint32_t nbits = 0;
uint32_t y = line;
@@ -301,7 +367,9 @@ void gcm394_base_video_device::draw_page(const rectangle &cliprect, uint32_t sca
const bool row_scroll = (tilectrl & 0x0010);
const bool flip_x = (tileattr & TILE_X_FLIP);
const uint32_t yflipmask = tileattr & TILE_Y_FLIP ? tile_h - 1 : 0;
- const uint32_t palette_offset = (tileattr & 0x0f00) >> 4;
+ uint32_t palette_offset = (tileattr & 0x0f00) >> 4;
+
+ palette_offset |= 0x0900;
const uint8_t bpp = tileattr & 0x0003;
@@ -346,11 +414,13 @@ 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];
- uint16_t tile = m_spriteram[base_addr + 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];
uint16_t attr = m_spriteram[base_addr + 3];
+ tile |= m_spriteextra[base_addr / 4] << 16;
+
if (!tile)
{
return;
@@ -389,7 +459,9 @@ void gcm394_base_video_device::draw_sprite(const rectangle &cliprect, uint32_t s
bool flip_x = (attr & TILE_X_FLIP);
const uint8_t bpp = attr & 0x0003;
const uint32_t yflipmask = attr & TILE_Y_FLIP ? h - 1 : 0;
- const uint32_t palette_offset = (attr & 0x0f00) >> 4;
+ uint32_t palette_offset = (attr & 0x0f00) >> 4;
+
+ palette_offset |= 0x0d00;
if (blend)
{
@@ -428,8 +500,11 @@ uint32_t gcm394_base_video_device::screen_update(screen_device &screen, bitmap_r
{
for (int i = 0; i < 4; i++)
{
- draw_page(cliprect, scanline, i, page1_addr, page1_regs);
- draw_page(cliprect, scanline, i, page2_addr, page2_regs);
+ if (1)
+ {
+ draw_page(cliprect, scanline, i, page1_addr, page1_regs);
+ draw_page(cliprect, scanline, i, page2_addr, page2_regs);
+ }
draw_sprites(cliprect, scanline, i);
}
}
@@ -532,17 +607,17 @@ 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
- LOGMASKED(LOG_GCM394, "%s:gcm394_base_video_device::unknown_video_device0_regs_w %01x %04x\n", machine().describe_context(), offset, data);
+ LOGMASKED(LOG_GCM394_VIDEO, "%s:gcm394_base_video_device::unknown_video_device0_regs_w %01x %04x\n", machine().describe_context(), offset, data);
}
WRITE16_MEMBER(gcm394_base_video_device::unknown_video_device0_unk0_w)
{
- LOGMASKED(LOG_GCM394, "%s:gcm394_base_video_device::unknown_video_device0_unk0_w %04x\n", machine().describe_context(), data);
+ LOGMASKED(LOG_GCM394_VIDEO, "%s:gcm394_base_video_device::unknown_video_device0_unk0_w %04x\n", machine().describe_context(), data);
}
WRITE16_MEMBER(gcm394_base_video_device::unknown_video_device0_unk1_w)
{
- LOGMASKED(LOG_GCM394, "%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::unknown_video_device0_unk1_w %04x\n", machine().describe_context(), data);
}
// **************************************** unknown video device 1 (another tilemap? sprite layer?) *************************************************
@@ -552,34 +627,34 @@ WRITE16_MEMBER(gcm394_base_video_device::unknown_video_device1_regs_w)
// offsets 0,1,4,5,6,7 used in main IRQ code
// offsets 2,3 only cleared on startup
- LOGMASKED(LOG_GCM394, "%s:gcm394_base_video_device::unknown_video_device1_regs_w %01x %04x\n", machine().describe_context(), offset, data);
+ 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::unknown_video_device1_unk0_w)
{
- LOGMASKED(LOG_GCM394, "%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::unknown_video_device1_unk0_w %04x\n", machine().describe_context(), data);
}
WRITE16_MEMBER(gcm394_base_video_device::unknown_video_device1_unk1_w)
{
- LOGMASKED(LOG_GCM394, "%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::unknown_video_device1_unk1_w %04x\n", machine().describe_context(), data);
}
// **************************************** unknown video device 2 (sprite control?) *************************************************
WRITE16_MEMBER(gcm394_base_video_device::unknown_video_device2_unk0_w)
{
- LOGMASKED(LOG_GCM394, "%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::unknown_video_device2_unk0_w %04x\n", machine().describe_context(), data);
}
WRITE16_MEMBER(gcm394_base_video_device::unknown_video_device2_unk1_w)
{
- LOGMASKED(LOG_GCM394, "%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::unknown_video_device2_unk1_w %04x\n", machine().describe_context(), data);
}
WRITE16_MEMBER(gcm394_base_video_device::unknown_video_device2_unk2_w)
{
- LOGMASKED(LOG_GCM394, "%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::unknown_video_device2_unk2_w %04x\n", machine().describe_context(), data);
}
// **************************************** video DMA device *************************************************
@@ -657,35 +732,72 @@ WRITE16_MEMBER(gcm394_base_video_device::video_dma_unk_w)
-READ16_MEMBER(gcm394_base_video_device::video_707f_r) { LOGMASKED(LOG_GCM394, "%s:gcm394_base_video_device::video_707f_r\n", machine().describe_context()); return m_707f; }
-WRITE16_MEMBER(gcm394_base_video_device::video_707f_w) { LOGMASKED(LOG_GCM394, "%s:gcm394_base_video_device::video_707f_w %04x\n", machine().describe_context(), data); m_707f = data; }
+READ16_MEMBER(gcm394_base_video_device::video_707f_r) { LOGMASKED(LOG_GCM394_VIDEO, "%s:gcm394_base_video_device::video_707f_r\n", machine().describe_context()); return m_707f; }
+WRITE16_MEMBER(gcm394_base_video_device::video_707f_w) { LOGMASKED(LOG_GCM394_VIDEO, "%s:gcm394_base_video_device::video_707f_w %04x\n", machine().describe_context(), data); m_707f = data; }
-READ16_MEMBER(gcm394_base_video_device::video_703a_r) { LOGMASKED(LOG_GCM394, "%s:gcm394_base_video_device::video_703a_r\n", machine().describe_context()); return m_703a; }
-WRITE16_MEMBER(gcm394_base_video_device::video_703a_w) { LOGMASKED(LOG_GCM394, "%s:gcm394_base_video_device::video_703a_w %04x\n", machine().describe_context(), data); m_703a = data; }
+READ16_MEMBER(gcm394_base_video_device::video_703a_r) { LOGMASKED(LOG_GCM394_VIDEO, "%s:gcm394_base_video_device::video_703a_r\n", machine().describe_context()); return m_703a; } // something to do with palette access, maybe bank?
+WRITE16_MEMBER(gcm394_base_video_device::video_703a_w) { LOGMASKED(LOG_GCM394_VIDEO, "%s:gcm394_base_video_device::video_703a_w %04x\n", machine().describe_context(), data); m_703a = data; }
-READ16_MEMBER(gcm394_base_video_device::video_7062_r) { LOGMASKED(LOG_GCM394, "%s:gcm394_base_video_device::video_7062_r\n", machine().describe_context()); return m_7062; }
-WRITE16_MEMBER(gcm394_base_video_device::video_7062_w) { LOGMASKED(LOG_GCM394, "%s:gcm394_base_video_device::video_7062_w %04x\n", machine().describe_context(), data); m_7062 = data; }
+READ16_MEMBER(gcm394_base_video_device::video_7062_r) { LOGMASKED(LOG_GCM394_VIDEO, "%s:gcm394_base_video_device::video_7062_r\n", machine().describe_context()); return m_7062; }
+WRITE16_MEMBER(gcm394_base_video_device::video_7062_w) { LOGMASKED(LOG_GCM394_VIDEO, "%s:gcm394_base_video_device::video_7062_w %04x\n", machine().describe_context(), data); m_7062 = data; }
-WRITE16_MEMBER(gcm394_base_video_device::video_7063_w) { LOGMASKED(LOG_GCM394, "%s:gcm394_base_video_device::video_7063_w %04x\n", machine().describe_context(), data); m_7063 = data; }
+WRITE16_MEMBER(gcm394_base_video_device::video_7063_w) { LOGMASKED(LOG_GCM394_VIDEO, "%s:gcm394_base_video_device::video_7063_w %04x\n", machine().describe_context(), data); m_7063 = data; }
-WRITE16_MEMBER(gcm394_base_video_device::video_702a_w) { LOGMASKED(LOG_GCM394, "%s:gcm394_base_video_device::video_702a_w %04x\n", machine().describe_context(), data); m_702a = data; }
+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) { LOGMASKED(LOG_GCM394, "%s:gcm394_base_video_device::video_7030_r\n", machine().describe_context()); return m_7030; }
-WRITE16_MEMBER(gcm394_base_video_device::video_7030_w) { LOGMASKED(LOG_GCM394, "%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, "%s:gcm394_base_video_device::video_703c_w %04x\n", machine().describe_context(), data); m_703c = data; }
-
-WRITE16_MEMBER(gcm394_base_video_device::video_7080_w) { LOGMASKED(LOG_GCM394, "%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, "%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, "%s:gcm394_base_video_device::video_7082_w %04x\n", machine().describe_context(), data); m_7082 = data; }
-WRITE16_MEMBER(gcm394_base_video_device::video_7083_w) { LOGMASKED(LOG_GCM394, "%s:gcm394_base_video_device::video_7083_w %04x\n", machine().describe_context(), data); m_7083 = data; }
-WRITE16_MEMBER(gcm394_base_video_device::video_7084_w) { LOGMASKED(LOG_GCM394, "%s:gcm394_base_video_device::video_7084_w %04x\n", machine().describe_context(), data); m_7084 = data; }
-WRITE16_MEMBER(gcm394_base_video_device::video_7085_w) { LOGMASKED(LOG_GCM394, "%s:gcm394_base_video_device::video_7085_w %04x\n", machine().describe_context(), data); m_7085 = data; }
-WRITE16_MEMBER(gcm394_base_video_device::video_7086_w) { LOGMASKED(LOG_GCM394, "%s:gcm394_base_video_device::video_7086_w %04x\n", machine().describe_context(), data); m_7086 = data; }
-WRITE16_MEMBER(gcm394_base_video_device::video_7087_w) { LOGMASKED(LOG_GCM394, "%s:gcm394_base_video_device::video_7087_w %04x\n", machine().describe_context(), data); m_7087 = data; }
-WRITE16_MEMBER(gcm394_base_video_device::video_7088_w) { LOGMASKED(LOG_GCM394, "%s:gcm394_base_video_device::video_7088_w %04x\n", machine().describe_context(), data); m_7088 = data; }
-
-READ16_MEMBER(gcm394_base_video_device::video_7083_r) { LOGMASKED(LOG_GCM394, "%s:gcm394_base_video_device::video_7083_r\n", machine().describe_context()); return m_7083; }
+READ16_MEMBER(gcm394_base_video_device::video_7030_r) { LOGMASKED(LOG_GCM394_VIDEO, "%s:gcm394_base_video_device::video_7030_r\n", machine().describe_context()); return m_7030; }
+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; }
+
+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; }
+WRITE16_MEMBER(gcm394_base_video_device::video_7083_w) { LOGMASKED(LOG_GCM394_VIDEO, "%s:gcm394_base_video_device::video_7083_w %04x\n", machine().describe_context(), data); m_7083 = data; }
+WRITE16_MEMBER(gcm394_base_video_device::video_7084_w) { LOGMASKED(LOG_GCM394_VIDEO, "%s:gcm394_base_video_device::video_7084_w %04x\n", machine().describe_context(), data); m_7084 = data; }
+WRITE16_MEMBER(gcm394_base_video_device::video_7085_w) { LOGMASKED(LOG_GCM394_VIDEO, "%s:gcm394_base_video_device::video_7085_w %04x\n", machine().describe_context(), data); m_7085 = data; }
+WRITE16_MEMBER(gcm394_base_video_device::video_7086_w) { LOGMASKED(LOG_GCM394_VIDEO, "%s:gcm394_base_video_device::video_7086_w %04x\n", machine().describe_context(), data); m_7086 = data; }
+WRITE16_MEMBER(gcm394_base_video_device::video_7087_w) { LOGMASKED(LOG_GCM394_VIDEO, "%s:gcm394_base_video_device::video_7087_w %04x\n", machine().describe_context(), data); m_7087 = data; }
+WRITE16_MEMBER(gcm394_base_video_device::video_7088_w) { LOGMASKED(LOG_GCM394_VIDEO, "%s:gcm394_base_video_device::video_7088_w %04x\n", machine().describe_context(), data); m_7088 = data; }
+
+READ16_MEMBER(gcm394_base_video_device::video_7083_r) { LOGMASKED(LOG_GCM394_VIDEO, "%s:gcm394_base_video_device::video_7083_r\n", machine().describe_context()); return m_7083; }
+
+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);
+
+ if (m_703a & 0xfff0)
+ {
+ fatalerror("palette writes with m_703a %04x\n", m_703a);
+ }
+ else
+ {
+ offset |= (m_703a & 0x000f) << 8;
+
+ m_paletteram[offset] = data;
+
+ uint32_t pal = m_rgb555_to_rgb888[data & 0x7fff];
+ int r = (pal >> 16) & 0xff;
+ int g = (pal >> 8) & 0xff;
+ int b = (pal >> 0) & 0xff;
+
+ m_palette->set_pen_color(offset, rgb_t(r, g, b));
+ }
+}
+
+READ16_MEMBER(gcm394_base_video_device::palette_r)
+{
+ if (m_703a & 0xfff0)
+ {
+ fatalerror("palette read with m_703a %04x\n", m_703a);
+ }
+ else
+ {
+ offset |= (m_703a & 0x000f) << 8;
+ return m_paletteram[offset];
+ }
+}
+
void gcm394_base_video_device::check_video_irq()
{
@@ -710,3 +822,14 @@ WRITE_LINE_MEMBER(gcm394_base_video_device::vblank)
}
}
+static GFXDECODE_START( gfx )
+GFXDECODE_END
+
+void gcm394_base_video_device::device_add_mconfig(machine_config &config)
+{
+ PALETTE(config, m_palette).set_format(palette_device::xRGB_555, 256*0x10);
+ GFXDECODE(config, m_gfxdecode, m_palette, gfx);
+
+}
+
+
diff --git a/src/devices/machine/sunplus_gcm394_video.h b/src/devices/machine/sunplus_gcm394_video.h
index 28ca2d0f1ff..4dfe3106e77 100644
--- a/src/devices/machine/sunplus_gcm394_video.h
+++ b/src/devices/machine/sunplus_gcm394_video.h
@@ -13,8 +13,9 @@
#include "cpu/unsp/unsp.h"
#include "screen.h"
+#include "emupal.h"
-class gcm394_base_video_device : public device_t, public device_gfx_interface, public device_video_interface
+class gcm394_base_video_device : public device_t, public device_video_interface
{
public:
gcm394_base_video_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock);
@@ -22,9 +23,6 @@ public:
uint32_t screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
DECLARE_WRITE_LINE_MEMBER(vblank);
-// DECLARE_READ16_MEMBER(video_r);
-// DECLARE_WRITE16_MEMBER(video_w);
-
void write_tmap_regs(int tmap, uint16_t* regs, int offset, uint16_t data);
DECLARE_READ16_MEMBER(tmap0_regs_r);
@@ -84,8 +82,16 @@ public:
DECLARE_READ16_MEMBER(video_7083_r);
+ DECLARE_READ16_MEMBER(palette_r);
+ DECLARE_WRITE16_MEMBER(palette_w);
+
auto write_video_irq_callback() { return m_video_irq_cb.bind(); };
+ uint8_t* m_gfxregion;
+ uint32_t m_gfxregionsize;
+
+ virtual void device_add_mconfig(machine_config& config) override;
+
protected:
enum
@@ -132,7 +138,7 @@ protected:
};
template<blend_enable_t Blend, rowscroll_enable_t RowScroll, flipx_t FlipX>
- void draw(const rectangle &cliprect, uint32_t line, uint32_t xoff, uint32_t yoff, uint32_t bitmap_addr, uint16_t tile, int32_t h, int32_t w, uint8_t bpp, uint32_t yflipmask, uint32_t palette_offset);
+ void draw(const rectangle &cliprect, uint32_t line, uint32_t xoff, uint32_t yoff, uint32_t bitmap_addr, uint32_t tile, int32_t h, int32_t w, uint8_t bpp, uint32_t yflipmask, uint32_t palette_offset);
void draw_page(const rectangle &cliprect, uint32_t scanline, int priority, uint32_t bitmap_addr, uint16_t *regs);
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);
@@ -144,7 +150,6 @@ protected:
required_device<unsp_device> m_cpu;
required_device<screen_device> m_screen;
// required_shared_ptr<uint16_t> m_scrollram;
- required_shared_ptr<uint16_t> m_paletteram;
required_shared_ptr<uint16_t> m_spriteram;
uint16_t m_page1_addr;
@@ -185,8 +190,13 @@ protected:
uint16_t m_video_irq_status;
uint16_t m_spriteextra[0x100];
+ uint16_t m_paletteram[0x100*0x10];
uint16_t read_data(uint32_t offset);
+
+ required_device<palette_device> m_palette;
+ required_device<gfxdecode_device> m_gfxdecode;
+
};
class gcm394_video_device : public gcm394_base_video_device
diff --git a/src/mame/drivers/sunplus_gcm394.cpp b/src/mame/drivers/sunplus_gcm394.cpp
index 0ce5af32a64..80515be47d0 100644
--- a/src/mame/drivers/sunplus_gcm394.cpp
+++ b/src/mame/drivers/sunplus_gcm394.cpp
@@ -31,6 +31,7 @@ public:
, m_screen(*this, "screen")
, m_spg(*this, "spg")
, m_bank(*this, "cartbank")
+ , m_io_p1(*this, "P1")
{ }
void base(machine_config &config);
@@ -46,16 +47,28 @@ protected:
required_device<sunplus_gcm394_device> m_spg;
optional_memory_bank m_bank;
+
+ required_ioport m_io_p1;
virtual void mem_map_4m(address_map &map);
private:
uint32_t m_current_bank;
+
+ DECLARE_READ16_MEMBER(porta_r);
};
+READ16_MEMBER(gcm394_game_state::porta_r)
+{
+ uint16_t data = m_io_p1->read();
+ logerror("Port A Read: %04x\n", data);
+ return data;
+}
+
void gcm394_game_state::base(machine_config &config)
{
GCM394(config, m_spg, XTAL(27'000'000), m_maincpu, m_screen);
+ m_spg->porta_in().set(FUNC(gcm394_game_state::porta_r));
UNSP_20(config, m_maincpu, XTAL(27'000'000)); // code at 8019 uses extended opcode, so must be 2.0+?
m_maincpu->set_addrmap(AS_PROGRAM, &gcm394_game_state::mem_map_4m);
@@ -107,6 +120,55 @@ void gcm394_game_state::mem_map_4m(address_map &map)
}
static INPUT_PORTS_START( gcm394 )
+ PORT_START("P1")
+ PORT_DIPNAME( 0x0001, 0x0001, "P1" )
+ PORT_DIPSETTING( 0x0001, DEF_STR( Off ) )
+ PORT_DIPSETTING( 0x0000, DEF_STR( On ) )
+ PORT_DIPNAME( 0x0002, 0x0002, DEF_STR( Unknown ) )
+ PORT_DIPSETTING( 0x0002, DEF_STR( Off ) )
+ PORT_DIPSETTING( 0x0000, DEF_STR( On ) )
+ PORT_DIPNAME( 0x0004, 0x0004, DEF_STR( Unknown ) )
+ PORT_DIPSETTING( 0x0004, DEF_STR( Off ) )
+ PORT_DIPSETTING( 0x0000, DEF_STR( On ) )
+ PORT_DIPNAME( 0x0008, 0x0008, DEF_STR( Unknown ) )
+ PORT_DIPSETTING( 0x0008, DEF_STR( Off ) )
+ PORT_DIPSETTING( 0x0000, DEF_STR( On ) )
+ PORT_DIPNAME( 0x0010, 0x0010, DEF_STR( Unknown ) )
+ PORT_DIPSETTING( 0x0010, DEF_STR( Off ) )
+ PORT_DIPSETTING( 0x0000, DEF_STR( On ) )
+ PORT_DIPNAME( 0x0020, 0x0020, DEF_STR( Unknown ) )
+ PORT_DIPSETTING( 0x0020, DEF_STR( Off ) )
+ PORT_DIPSETTING( 0x0000, DEF_STR( On ) )
+ PORT_DIPNAME( 0x0040, 0x0040, DEF_STR( Unknown ) )
+ PORT_DIPSETTING( 0x0040, DEF_STR( Off ) )
+ PORT_DIPSETTING( 0x0000, DEF_STR( On ) )
+ PORT_DIPNAME( 0x0080, 0x0080, DEF_STR( Unknown ) )
+ PORT_DIPSETTING( 0x0080, DEF_STR( Off ) )
+ PORT_DIPSETTING( 0x0000, DEF_STR( On ) )
+ PORT_DIPNAME( 0x0100, 0x0100, DEF_STR( Unknown ) )
+ PORT_DIPSETTING( 0x0100, DEF_STR( Off ) )
+ PORT_DIPSETTING( 0x0000, DEF_STR( On ) )
+ PORT_DIPNAME( 0x0200, 0x0200, DEF_STR( Unknown ) )
+ PORT_DIPSETTING( 0x0200, DEF_STR( Off ) )
+ PORT_DIPSETTING( 0x0000, DEF_STR( On ) )
+ PORT_DIPNAME( 0x0400, 0x0400, DEF_STR( Unknown ) )
+ PORT_DIPSETTING( 0x0400, DEF_STR( Off ) )
+ PORT_DIPSETTING( 0x0000, DEF_STR( On ) )
+ PORT_DIPNAME( 0x0800, 0x0800, DEF_STR( Unknown ) )
+ PORT_DIPSETTING( 0x0800, DEF_STR( Off ) )
+ PORT_DIPSETTING( 0x0000, DEF_STR( On ) )
+ PORT_DIPNAME( 0x1000, 0x1000, "Test 1/2" )
+ PORT_DIPSETTING( 0x1000, DEF_STR( Off ) )
+ PORT_DIPSETTING( 0x0000, DEF_STR( On ) )
+ PORT_DIPNAME( 0x2000, 0x2000, DEF_STR( Unknown ) )
+ PORT_DIPSETTING( 0x2000, DEF_STR( Off ) )
+ PORT_DIPSETTING( 0x0000, DEF_STR( On ) )
+ PORT_DIPNAME( 0x4000, 0x4000, DEF_STR( Unknown ) )
+ PORT_DIPSETTING( 0x4000, DEF_STR( Off ) )
+ PORT_DIPSETTING( 0x0000, DEF_STR( On ) )
+ PORT_DIPNAME( 0x8000, 0x8000, "Test 2/2" )
+ PORT_DIPSETTING( 0x8000, DEF_STR( Off ) )
+ PORT_DIPSETTING( 0x0000, DEF_STR( On ) )
INPUT_PORTS_END