summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author mooglyguy <therealmogminer@gmail.com>2018-12-06 15:18:29 +0100
committer mooglyguy <therealmogminer@gmail.com>2018-12-06 15:18:43 +0100
commitbe47eccbb30ad90d1f0cbdfa4e1c1e45bb1539b2 (patch)
tree092214717882fe9824722d0c0e7fc54a37f834f7
parent8f534764f968b989488dec085dd607c51f125e6d (diff)
midtunit.cpp: Added an optional DMA-blitter viewer behind a #define. [Ryan Holtz]
-rw-r--r--src/mame/drivers/midtunit.cpp1
-rw-r--r--src/mame/drivers/midwunit.cpp1
-rw-r--r--src/mame/drivers/midxunit.cpp1
-rw-r--r--src/mame/video/midtunit.cpp17
-rw-r--r--src/mame/video/midtunit.h25
-rw-r--r--src/mame/video/midtunit.ipp (renamed from src/mame/video/midtunit.hxx)0
-rw-r--r--src/mame/video/midtview.ipp280
7 files changed, 321 insertions, 4 deletions
diff --git a/src/mame/drivers/midtunit.cpp b/src/mame/drivers/midtunit.cpp
index 882c72a4794..2b2db8280b7 100644
--- a/src/mame/drivers/midtunit.cpp
+++ b/src/mame/drivers/midtunit.cpp
@@ -604,6 +604,7 @@ void midtunit_state::tunit_core(machine_config &config)
m_maincpu->set_scanline_ind16_callback("video", FUNC(midtunit_video_device::scanline_update)); /* scanline updater (indexed16) */
m_maincpu->set_shiftreg_in_callback("video", FUNC(midtunit_video_device::to_shiftreg)); /* write to shiftreg function */
m_maincpu->set_shiftreg_out_callback("video", FUNC(midtunit_video_device::from_shiftreg)); /* read from shiftreg function */
+ m_maincpu->set_screen("screen");
NVRAM(config, "nvram", nvram_device::DEFAULT_ALL_0);
diff --git a/src/mame/drivers/midwunit.cpp b/src/mame/drivers/midwunit.cpp
index b98b260bc34..60a34efc8fd 100644
--- a/src/mame/drivers/midwunit.cpp
+++ b/src/mame/drivers/midwunit.cpp
@@ -636,6 +636,7 @@ void midwunit_state::wunit(machine_config &config)
m_maincpu->set_scanline_ind16_callback("video", FUNC(midtunit_video_device::scanline_update)); /* scanline updater (indexed16) */
m_maincpu->set_shiftreg_in_callback("video", FUNC(midtunit_video_device::to_shiftreg)); /* write to shiftreg function */
m_maincpu->set_shiftreg_out_callback("video", FUNC(midtunit_video_device::from_shiftreg)); /* read from shiftreg function */
+ m_maincpu->set_screen("screen");
NVRAM(config, "nvram", nvram_device::DEFAULT_ALL_0);
diff --git a/src/mame/drivers/midxunit.cpp b/src/mame/drivers/midxunit.cpp
index 3420dd2c730..c6d7ab3fa24 100644
--- a/src/mame/drivers/midxunit.cpp
+++ b/src/mame/drivers/midxunit.cpp
@@ -254,6 +254,7 @@ void midxunit_state::midxunit(machine_config &config)
m_maincpu->set_scanline_ind16_callback("video", FUNC(midxunit_video_device::scanline_update)); /* scanline updater (indexed16) */
m_maincpu->set_shiftreg_in_callback("video", FUNC(midxunit_video_device::to_shiftreg)); /* write to shiftreg function */
m_maincpu->set_shiftreg_out_callback("video", FUNC(midtunit_video_device::from_shiftreg)); /* read from shiftreg function */
+ m_maincpu->set_screen("screen");
NVRAM(config, "nvram", nvram_device::DEFAULT_ALL_0);
diff --git a/src/mame/video/midtunit.cpp b/src/mame/video/midtunit.cpp
index cb2df663e4b..6da22567b83 100644
--- a/src/mame/video/midtunit.cpp
+++ b/src/mame/video/midtunit.cpp
@@ -9,7 +9,9 @@
#include "emu.h"
#include "midtunit.h"
-#include "midtunit.hxx"
+#include "midtunit.ipp"
+#include "midtview.ipp"
+#include "screen.h"
DEFINE_DEVICE_TYPE(MIDTUNIT_VIDEO, midtunit_video_device, "tunitvid", "Midway T-Unit Video")
DEFINE_DEVICE_TYPE(MIDWUNIT_VIDEO, midwunit_video_device, "wunitvid", "Midway W-Unit Video")
@@ -23,6 +25,9 @@ midtunit_video_device::midtunit_video_device(const machine_config &mconfig, devi
, m_maincpu(*this, finder_base::DUMMY_TAG)
, m_palette(*this, finder_base::DUMMY_TAG)
, m_gfxrom(*this, finder_base::DUMMY_TAG)
+#if DEBUG_MIDTUNIT_BLITTER
+ , m_debug_palette(*this, "debugpalette")
+#endif
{
}
@@ -57,6 +62,10 @@ void midtunit_video_device::device_start()
/* allocate memory */
m_local_videoram = std::make_unique<uint16_t[]>(0x100000/2);
+#if DEBUG_MIDTUNIT_BLITTER
+ m_debug_videoram = std::make_unique<uint16_t[]>(0x100000/2);
+#endif
+
m_dma_timer = timer_alloc(TIMER_DMA);
/* reset all the globals */
@@ -88,7 +97,6 @@ void midwunit_video_device::device_start()
m_gfx_rom_large = true;
}
-
void midxunit_video_device::device_start()
{
midtunit_video_device::device_start();
@@ -364,7 +372,11 @@ void midtunit_video_device::dma_draw()
width = (m_dma_state.width - m_dma_state.endskip) << 8;
/* determine destination pointer */
+#if DEBUG_MIDTUNIT_BLITTER
+ d = m_doing_debug_dma ? &m_debug_videoram[sy * 512] : &m_local_videoram[sy * 512];
+#else
d = &m_local_videoram[sy * 512];
+#endif
/* loop until we draw the entire width */
while (ix < width)
@@ -606,7 +618,6 @@ WRITE16_MEMBER(midtunit_video_device::midtunit_dma_w)
/* fill in the rev 2 data */
m_dma_state.yflip = (command & 0x20) >> 5;
- m_dma_state.bpp = bpp;
m_dma_state.preskip = (command >> 8) & 3;
m_dma_state.postskip = (command >> 10) & 3;
m_dma_state.xstep = m_dma_register[DMA_SCALE_X] ? m_dma_register[DMA_SCALE_X] : 0x100;
diff --git a/src/mame/video/midtunit.h b/src/mame/video/midtunit.h
index 489a2e5906b..69cdec0cd3f 100644
--- a/src/mame/video/midtunit.h
+++ b/src/mame/video/midtunit.h
@@ -16,6 +16,8 @@
#include "cpu/tms34010/tms34010.h"
#include "emupal.h"
+#define DEBUG_MIDTUNIT_BLITTER (0)
+
class midtunit_video_device : public device_t
{
public:
@@ -132,7 +134,6 @@ protected:
uint16_t color; /* current foreground color with palette */
uint8_t yflip; /* yflip? */
- uint8_t bpp; /* bits per pixel */
uint8_t preskip; /* preskip scale */
uint8_t postskip; /* postskip scale */
int32_t topclip; /* top clipping scanline */
@@ -145,6 +146,25 @@ protected:
uint16_t ystep; /* 8.8 fixed number scale y factor */
};
dma_state m_dma_state;
+
+#if DEBUG_MIDTUNIT_BLITTER
+ virtual void device_reset() override;
+ virtual void device_add_mconfig(machine_config &config) override;
+
+ uint32_t debug_screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
+
+ void do_debug_blit();
+ void do_dma_debug_inputs();
+
+ required_device<palette_device> m_debug_palette;
+ std::unique_ptr<uint16_t[]> m_debug_videoram;
+ bool m_dma_debug;
+ bool m_doing_debug_dma;
+ dma_state m_debug_dma_state;
+ int32_t m_debug_dma_bpp;
+ int32_t m_debug_dma_mode;
+ int32_t m_debug_dma_command;
+#endif
};
class midwunit_video_device : public midtunit_video_device
@@ -170,6 +190,9 @@ protected:
midwunit_video_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock = 0);
virtual void device_start() override;
+#if DEBUG_MIDTUNIT_BLITTER
+ virtual void device_add_mconfig(machine_config &config) override;
+#endif
};
class midxunit_video_device : public midwunit_video_device
diff --git a/src/mame/video/midtunit.hxx b/src/mame/video/midtunit.ipp
index 690afa6646b..690afa6646b 100644
--- a/src/mame/video/midtunit.hxx
+++ b/src/mame/video/midtunit.ipp
diff --git a/src/mame/video/midtview.ipp b/src/mame/video/midtview.ipp
new file mode 100644
index 00000000000..02da31bf928
--- /dev/null
+++ b/src/mame/video/midtview.ipp
@@ -0,0 +1,280 @@
+// license:BSD-3-Clause
+// copyright-holders:Ryan Holtz
+/*************************************************************************
+
+ DMA-Blitter Viewer for Midway T-unit, W-unit, and X-unit games.
+
+**************************************************************************/
+
+#if DEBUG_MIDTUNIT_BLITTER
+void midtunit_video_device::device_reset()
+{
+ m_dma_debug = false;
+ m_doing_debug_dma = false;
+ memset(&m_debug_dma_state, 0, sizeof(dma_state));
+ m_debug_dma_state.gfxrom = m_gfxrom->base();
+ m_debug_dma_state.offset = 0;
+ m_debug_dma_state.rowbits = 0;
+ m_debug_dma_state.width = 256;
+ m_debug_dma_state.height = 256;
+ m_debug_dma_state.palette = 0x0100;
+ m_debug_dma_state.color = 0x0001;
+ m_debug_dma_state.yflip = 0;
+
+ m_debug_dma_state.xpos = 0;
+ m_debug_dma_state.ypos = 0;
+ m_debug_dma_state.preskip = 0;
+ m_debug_dma_state.postskip = 0;
+ m_debug_dma_state.topclip = 0;
+ m_debug_dma_state.botclip = 0xffff;
+ m_debug_dma_state.leftclip = 0;
+ m_debug_dma_state.rightclip = 0xffff;
+ m_debug_dma_state.startskip = 0;
+ m_debug_dma_state.endskip = 0;
+ m_debug_dma_state.xstep = 0x100;
+ m_debug_dma_state.ystep = 0x100;
+
+ m_debug_dma_bpp = 0;
+ m_debug_dma_mode = 1;
+ m_debug_dma_command = 0;
+}
+
+void midtunit_video_device::device_add_mconfig(machine_config &config)
+{
+ screen_device &debugscreen(SCREEN(config, "debugscreen", SCREEN_TYPE_RASTER));
+ debugscreen.set_raw(8000000 * 2, 506, 100, 500, 289, 20, 274);
+ debugscreen.set_screen_update(FUNC(midtunit_video_device::debug_screen_update));
+
+ PALETTE(config, m_debug_palette, 32768).set_format(PALETTE_FORMAT_xRRRRRGGGGGBBBBB);
+}
+
+void midwunit_video_device::device_add_mconfig(machine_config &config)
+{
+ screen_device &debugscreen(SCREEN(config, "debugscreen", SCREEN_TYPE_RASTER));
+ debugscreen.set_raw(8000000, 506, 101, 501, 289, 20, 274);
+ debugscreen.set_screen_update(FUNC(midwunit_video_device::debug_screen_update));
+
+ PALETTE(config, m_debug_palette, 32768).set_format(PALETTE_FORMAT_xRRRRRGGGGGBBBBB);
+}
+
+void midtunit_video_device::do_debug_blit()
+{
+ m_dma_state = m_debug_dma_state;
+ m_debug_dma_command = m_debug_dma_mode * 8 + m_debug_dma_bpp;
+ m_doing_debug_dma = true;
+ memset(&m_debug_videoram[0], 0, 0x100000);
+ ((this)->*(m_dma_draw_noskip_noscale[m_debug_dma_command]))();
+ m_doing_debug_dma = false;
+}
+
+void midtunit_video_device::do_dma_debug_inputs()
+{
+ static const char* const mode_strs[0x20] = {
+ "None", "P0", "P1", "P0P1", "C0", "C0", "C0P1", "C0P1", "C1", "P0C1", "C1", "P0C1", "C0C1", "C0C1", "C0C1", "C0C1",
+ "None", "P0F", "P1F", "P0P1F", "C0F", "C0F", "C0P1F", "C0P1F", "C1F", "P0C1F", "C1F", "P0C1F", "C0C1F", "C0C1F", "C0C1F", "C0C1F"
+ };
+
+ bool do_blit = false;
+ if (machine().input().code_pressed_once(KEYCODE_M))
+ {
+ m_dma_debug = !m_dma_debug;
+ if (m_dma_debug)
+ {
+ for (pen_t i = 0; i < 32768; i++)
+ {
+ m_debug_palette->set_pen_color(i, m_palette->pen_color(i));
+ }
+ do_blit = true;
+ }
+ }
+ else if (machine().input().code_pressed_once(KEYCODE_O))
+ {
+ m_debug_dma_state.rowbits++;
+ do_blit = true;
+ popmessage("DMA RowBits: %d", m_debug_dma_state.rowbits);
+ }
+ else if (machine().input().code_pressed_once(KEYCODE_U))
+ {
+ m_debug_dma_state.rowbits--;
+ if (m_debug_dma_state.rowbits < 0)
+ m_debug_dma_state.rowbits = 0;
+ else
+ do_blit = true;
+ popmessage("DMA RowBits: %d", m_debug_dma_state.rowbits);
+ }
+ else if (machine().input().code_pressed_once(KEYCODE_PGDN))
+ {
+ m_debug_dma_state.offset += 0x10000;
+ do_blit = true;
+ popmessage("DMA Offset: %08x", m_debug_dma_state.offset);
+ }
+ else if (machine().input().code_pressed_once(KEYCODE_PGUP))
+ {
+ uint32_t old_offset = m_debug_dma_state.offset;
+ m_debug_dma_state.offset -= 0x10000;
+ if (old_offset < m_debug_dma_state.offset)
+ m_debug_dma_state.offset = 0;
+ else
+ do_blit = true;
+ popmessage("DMA Offset: %08x", m_debug_dma_state.offset);
+ }
+ else if (machine().input().code_pressed_once(KEYCODE_END))
+ {
+ m_debug_dma_state.offset += 0x100;
+ do_blit = true;
+ popmessage("DMA Offset: %08x", m_debug_dma_state.offset);
+ }
+ else if (machine().input().code_pressed_once(KEYCODE_HOME))
+ {
+ uint32_t old_offset = m_debug_dma_state.offset;
+ m_debug_dma_state.offset -= 0x100;
+ if (old_offset < m_debug_dma_state.offset)
+ m_debug_dma_state.offset = 0;
+ else
+ do_blit = true;
+ popmessage("DMA Offset: %08x", m_debug_dma_state.offset);
+ }
+ else if (machine().input().code_pressed_once(KEYCODE_DEL))
+ {
+ m_debug_dma_state.offset++;
+ do_blit = true;
+ popmessage("DMA Offset: %08x", m_debug_dma_state.offset);
+ }
+ else if (machine().input().code_pressed_once(KEYCODE_INSERT))
+ {
+ uint32_t old_offset = m_debug_dma_state.offset;
+ m_debug_dma_state.offset--;
+ if (old_offset < m_debug_dma_state.offset)
+ m_debug_dma_state.offset = 0;
+ else
+ do_blit = true;
+ popmessage("DMA Offset: %08x", m_debug_dma_state.offset);
+ }
+ else if (machine().input().code_pressed_once(KEYCODE_RIGHT))
+ {
+ m_debug_dma_state.width += machine().input().code_pressed(KEYCODE_LCONTROL) ? 16 : 1;
+ if (m_debug_dma_state.width > 512)
+ m_debug_dma_state.width = 512;
+ else
+ do_blit = true;
+ popmessage("DMA Width: %d", m_debug_dma_state.width);
+ }
+ else if (machine().input().code_pressed_once(KEYCODE_LEFT))
+ {
+ m_debug_dma_state.width -= machine().input().code_pressed(KEYCODE_LCONTROL) ? 16 : 1;
+ if (m_debug_dma_state.width < 0)
+ m_debug_dma_state.width = 0;
+ else
+ do_blit = true;
+ popmessage("DMA Width: %d", m_debug_dma_state.width);
+ }
+ else if (machine().input().code_pressed_once(KEYCODE_UP))
+ {
+ m_debug_dma_state.height += machine().input().code_pressed(KEYCODE_LCONTROL) ? 16 : 1;
+ if (m_debug_dma_state.height > 512)
+ m_debug_dma_state.height = 512;
+ else
+ do_blit = true;
+ popmessage("DMA Height: %d", m_debug_dma_state.height);
+ }
+ else if (machine().input().code_pressed_once(KEYCODE_DOWN))
+ {
+ m_debug_dma_state.height -= machine().input().code_pressed(KEYCODE_LCONTROL) ? 16 : 1;
+ if (m_debug_dma_state.height < 0)
+ m_debug_dma_state.height = 0;
+ else
+ do_blit = true;
+ popmessage("DMA Height: %d", m_debug_dma_state.height);
+ }
+ else if (machine().input().code_pressed_once(KEYCODE_I))
+ {
+ m_debug_dma_state.palette += 0x0100;
+ do_blit = true;
+ popmessage("DMA Palette: %04x", m_debug_dma_state.palette);
+ }
+ else if (machine().input().code_pressed_once(KEYCODE_K))
+ {
+ m_debug_dma_state.palette -= 0x0100;
+ do_blit = true;
+ popmessage("DMA Palette: %04x", m_debug_dma_state.palette);
+ }
+ else if (machine().input().code_pressed_once(KEYCODE_L))
+ {
+ m_debug_dma_state.color++;
+ if (m_debug_dma_state.color == 0x0100)
+ m_debug_dma_state.color = 0;
+ do_blit = true;
+ popmessage("DMA Color: %02x", m_debug_dma_state.color);
+ }
+ else if (machine().input().code_pressed_once(KEYCODE_J))
+ {
+ m_debug_dma_state.color--;
+ if (m_debug_dma_state.color == 0xffff)
+ m_debug_dma_state.color = 0x00ff;
+ do_blit = true;
+ popmessage("DMA Color: %02x", m_debug_dma_state.color);
+ }
+ else if (machine().input().code_pressed_once(KEYCODE_H))
+ {
+ m_debug_dma_bpp++;
+ if (m_debug_dma_bpp > 7)
+ m_debug_dma_bpp = 7;
+ else
+ do_blit = true;
+ popmessage("DMA BitsPerPixel: %d", m_debug_dma_bpp ? m_debug_dma_bpp : 8);
+ }
+ else if (machine().input().code_pressed_once(KEYCODE_G))
+ {
+ m_debug_dma_bpp--;
+ if (m_debug_dma_bpp < 0)
+ m_debug_dma_bpp = 0;
+ else
+ do_blit = true;
+ popmessage("DMA BitsPerPixel: %d", m_debug_dma_bpp ? m_debug_dma_bpp : 8);
+ }
+ else if (machine().input().code_pressed_once(KEYCODE_Y))
+ {
+ m_debug_dma_mode++;
+ if (m_debug_dma_mode > 0x1f)
+ m_debug_dma_mode = 0x1f;
+ else
+ do_blit = true;
+ popmessage("DMA Mode: %s (%02x)", mode_strs[m_debug_dma_mode], m_debug_dma_mode);
+ }
+ else if (machine().input().code_pressed_once(KEYCODE_T))
+ {
+ m_debug_dma_mode--;
+ if (m_debug_dma_mode < 0)
+ m_debug_dma_mode = 0;
+ else
+ do_blit = true;
+ popmessage("DMA Mode: %s (%02x)", mode_strs[m_debug_dma_mode], m_debug_dma_mode);
+ }
+ else if (machine().input().code_pressed_once(KEYCODE_F))
+ {
+ m_debug_dma_state.yflip = 1 - m_debug_dma_state.yflip;
+ do_blit = true;
+ }
+
+ if (do_blit)
+ do_debug_blit();
+}
+
+uint32_t midtunit_video_device::debug_screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect)
+{
+ do_dma_debug_inputs();
+ const pen_t *pens = m_debug_palette->pens();
+ for (int y = 0; y <= cliprect.max_y; y++)
+ {
+ uint32_t *dest = &bitmap.pix32(y);
+ uint16_t *src = &m_debug_videoram[y * 512];
+ for (int x = 0; x < cliprect.max_x; x++)
+ {
+ *dest = pens[*src & 0x7fff];
+ src++;
+ dest++;
+ }
+ }
+ return 0;
+}
+#endif