From 6d3fa422b1dcca4f240f4c9842596c5b279b5c4e Mon Sep 17 00:00:00 2001 From: mooglyguy Date: Wed, 5 Dec 2018 10:53:47 +0100 Subject: Initial attempt at device-ifying midtunit video, only midtunit.cpp compiles right now --- src/devices/cpu/tms34010/tms34010.h | 87 ++++- src/mame/drivers/midtunit.cpp | 48 ++- src/mame/includes/midtunit.h | 45 +-- src/mame/includes/midxunit.h | 1 - src/mame/machine/midtunit.cpp | 8 +- src/mame/video/midtunit.cpp | 756 ++++++++++++++++-------------------- src/mame/video/midtunit.h | 201 ++++++++++ src/mame/video/midtunit.hxx | 143 +++++++ 8 files changed, 778 insertions(+), 511 deletions(-) create mode 100644 src/mame/video/midtunit.h create mode 100644 src/mame/video/midtunit.hxx diff --git a/src/devices/cpu/tms34010/tms34010.h b/src/devices/cpu/tms34010/tms34010.h index 6d835a18975..132fb6c4725 100644 --- a/src/devices/cpu/tms34010/tms34010.h +++ b/src/devices/cpu/tms34010/tms34010.h @@ -112,6 +112,7 @@ enum #define MCFG_TMS340X0_PIXELS_PER_CLOCK(_value) \ downcast(*device).set_pixels_per_clock(_value); + #define TMS340X0_SCANLINE_IND16_CB_MEMBER(_name) void _name(screen_device &screen, bitmap_ind16 &bitmap, int scanline, const tms340x0_device::display_params *params) #define MCFG_TMS340X0_SCANLINE_IND16_CB(_class, _method) \ @@ -124,8 +125,7 @@ enum downcast(*device).set_scanline_rgb32_callback(tms340x0_device::scanline_rgb32_cb_delegate(&_class::_method, #_class "::" #_method, this)); -#define MCFG_TMS340X0_OUTPUT_INT_CB(_devcb) \ - downcast(*device).set_output_int_callback(DEVCB_##_devcb); +#define MCFG_TMS340X0_OUTPUT_INT_CB(_devcb) #define TMS340X0_TO_SHIFTREG_CB_MEMBER(_name) void _name(address_space &space, offs_t address, uint16_t *shiftreg) @@ -157,18 +157,83 @@ public: typedef device_delegate scanline_ind16_cb_delegate; typedef device_delegate scanline_rgb32_cb_delegate; - typedef device_delegate to_shiftreg_cb_delegate; - typedef device_delegate from_shiftreg_cb_delegate; + typedef device_delegate shiftreg_in_cb_delegate; + typedef device_delegate shiftreg_out_cb_delegate; void set_halt_on_reset(bool halt_on_reset) { m_halt_on_reset = halt_on_reset; } void set_pixel_clock(uint32_t pixclock) { m_pixclock = pixclock; } void set_pixel_clock(const XTAL &xtal) { set_pixel_clock(xtal.value()); } void set_pixels_per_clock(int pixperclock) { m_pixperclock = pixperclock; } - template void set_scanline_ind16_callback(Object &&cb) { m_scanline_ind16_cb = std::forward(cb); } - template void set_scanline_rgb32_callback(Object &&cb) { m_scanline_rgb32_cb = std::forward(cb); } - template devcb_base &set_output_int_callback(Object &&cb) { return m_output_int_cb.set_callback(std::forward(cb)); } - template void set_to_shiftreg_callback(Object &&cb) { m_to_shiftreg_cb = std::forward(cb); } - template void set_from_shiftreg_callback(Object &&cb) { m_from_shiftreg_cb = std::forward(cb); } + + auto output_int() { return m_output_int_cb.bind(); } + + // Setters for ind16 scanline callback + template + void set_scanline_ind16_callback(void (FunctionClass::*callback)(screen_device &, bitmap_ind16 &, int, const display_params *), + const char *name) + { + set_scanline_ind16_callback(scanline_ind16_cb_delegate(callback, name, nullptr, static_cast(nullptr))); + } + template + void set_scanline_ind16_callback(const char *devname, void (FunctionClass::*callback)(screen_device &, bitmap_ind16 &, int, const display_params *), + const char *name) + { + set_scanline_ind16_callback(scanline_ind16_cb_delegate(callback, name, devname, static_cast(nullptr))); + } + void set_scanline_ind16_callback(scanline_ind16_cb_delegate callback) + { + m_scanline_ind16_cb = callback; + } + + // Setters for rgb32 scanline callback + template + void set_scanline_rgb32_callback(void (FunctionClass::*callback)(screen_device &, bitmap_rgb32 &, int, const display_params *), + const char *name) + { + set_scanline_rgb32_callback(scanline_rgb32_cb_delegate(callback, name, nullptr, static_cast(nullptr))); + } + template + void set_scanline_rgb32_callback(const char *devname, void (FunctionClass::*callback)(screen_device &, bitmap_rgb32 &, int, const display_params *), + const char *name) + { + set_scanline_rgb32_callback(scanline_rgb32_cb_delegate(callback, name, devname, static_cast(nullptr))); + } + void set_scanline_rgb32_callback(scanline_rgb32_cb_delegate callback) + { + m_scanline_rgb32_cb = callback; + } + + // Setters for shift register input callback + template + void set_shiftreg_in_callback(void (FunctionClass::*callback)(address_space &, offs_t, uint16_t *), const char *name) + { + set_shiftreg_in_callback(shiftreg_in_cb_delegate(callback, name, nullptr, static_cast(nullptr))); + } + template + void set_shiftreg_in_callback(const char *devname, void (FunctionClass::*callback)(address_space &, offs_t, uint16_t *), const char *name) + { + set_shiftreg_in_callback(shiftreg_in_cb_delegate(callback, name, devname, static_cast(nullptr))); + } + void set_shiftreg_in_callback(shiftreg_in_cb_delegate callback) + { + m_to_shiftreg_cb = callback; + } + + // Setters for shift register output callback + template + void set_shiftreg_out_callback(void (FunctionClass::*callback)(address_space &, offs_t, uint16_t *), const char *name) + { + set_shiftreg_out_callback(shiftreg_out_cb_delegate(callback, name, nullptr, static_cast(nullptr))); + } + template + void set_shiftreg_out_callback(const char *devname, void (FunctionClass::*callback)(address_space &, offs_t, uint16_t *), const char *name) + { + set_shiftreg_out_callback(shiftreg_out_cb_delegate(callback, name, devname, static_cast(nullptr))); + } + void set_shiftreg_out_callback(shiftreg_out_cb_delegate callback) + { + m_from_shiftreg_cb = callback; + } void get_display_params(display_params *params); void tms34010_state_postload(); @@ -333,8 +398,8 @@ protected: scanline_ind16_cb_delegate m_scanline_ind16_cb; scanline_rgb32_cb_delegate m_scanline_rgb32_cb; devcb_write_line m_output_int_cb; /* output interrupt callback */ - to_shiftreg_cb_delegate m_to_shiftreg_cb; /* shift register write */ - from_shiftreg_cb_delegate m_from_shiftreg_cb; /* shift register read */ + shiftreg_in_cb_delegate m_to_shiftreg_cb; /* shift register write */ + shiftreg_out_cb_delegate m_from_shiftreg_cb; /* shift register read */ struct XY { diff --git a/src/mame/drivers/midtunit.cpp b/src/mame/drivers/midtunit.cpp index aae36462505..e6163ff490a 100644 --- a/src/mame/drivers/midtunit.cpp +++ b/src/mame/drivers/midtunit.cpp @@ -47,7 +47,7 @@ void midtunit_state::main_map(address_map &map) { map.unmap_value_high(); - map(0x00000000, 0x003fffff).rw(FUNC(midtunit_state::midtunit_vram_r), FUNC(midtunit_state::midtunit_vram_w)); + map(0x00000000, 0x003fffff).rw(m_video, FUNC(midtunit_video_device::midtunit_vram_r), FUNC(midtunit_video_device::midtunit_vram_w)); map(0x01000000, 0x013fffff).ram(); map(0x01400000, 0x0141ffff).rw(FUNC(midtunit_state::midtunit_cmos_r), FUNC(midtunit_state::midtunit_cmos_w)).share("nvram"); map(0x01480000, 0x014fffff).w(FUNC(midtunit_state::midtunit_cmos_enable_w)); @@ -56,14 +56,14 @@ void midtunit_state::main_map(address_map &map) map(0x01600020, 0x0160002f).portr("IN2"); map(0x01600030, 0x0160003f).portr("DSW"); map(0x01800000, 0x0187ffff).ram().w(m_palette, FUNC(palette_device::write16)).share("palette"); - map(0x01a80000, 0x01a800ff).rw(FUNC(midtunit_state::midtunit_dma_r), FUNC(midtunit_state::midtunit_dma_w)); - map(0x01b00000, 0x01b0001f).w(FUNC(midtunit_state::midtunit_control_w)); + map(0x01a80000, 0x01a800ff).rw(m_video, FUNC(midtunit_video_device::midtunit_dma_r), FUNC(midtunit_video_device::midtunit_dma_w)); + map(0x01b00000, 0x01b0001f).w(m_video, FUNC(midtunit_video_device::midtunit_control_w)); /* AM_RANGE(0x01c00060, 0x01c0007f) AM_WRITE(midtunit_cmos_enable_w) */ map(0x01d00000, 0x01d0001f).r(FUNC(midtunit_state::midtunit_sound_state_r)); map(0x01d01020, 0x01d0103f).rw(FUNC(midtunit_state::midtunit_sound_r), FUNC(midtunit_state::midtunit_sound_w)); map(0x01d81060, 0x01d8107f).w("watchdog", FUNC(watchdog_timer_device::reset16_w)); - map(0x01f00000, 0x01f0001f).w(FUNC(midtunit_state::midtunit_control_w)); - map(0x02000000, 0x07ffffff).r(FUNC(midtunit_state::midtunit_gfxrom_r)).share("gfxrom"); + map(0x01f00000, 0x01f0001f).w(m_video, FUNC(midtunit_video_device::midtunit_control_w)); + map(0x02000000, 0x07ffffff).r(m_video, FUNC(midtunit_video_device::midtunit_gfxrom_r)).share("gfxrom"); map(0x1f800000, 0x1fffffff).rom().region("maincpu", 0); /* mirror used by MK */ map(0xc0000000, 0xc00001ff).rw("maincpu", FUNC(tms34010_device::io_register_r), FUNC(tms34010_device::io_register_w)); map(0xff800000, 0xffffffff).rom().region("maincpu", 0); @@ -591,35 +591,33 @@ INPUT_PORTS_END * *************************************/ -MACHINE_CONFIG_START(midtunit_state::tunit_core) +void midtunit_state::tunit_core(machine_config &config) +{ + MIDTUNIT_VIDEO(config, "video", "maincpu", "palette", "gfxrom"); /* basic machine hardware */ - MCFG_DEVICE_ADD("maincpu", TMS34010, CPU_CLOCK) - MCFG_DEVICE_PROGRAM_MAP(main_map) - MCFG_TMS340X0_HALT_ON_RESET(false) /* halt on reset */ - MCFG_TMS340X0_PIXEL_CLOCK(PIXEL_CLOCK) /* pixel clock */ - MCFG_TMS340X0_PIXELS_PER_CLOCK(2) /* pixels per clock */ - MCFG_TMS340X0_SCANLINE_IND16_CB(midtunit_state, scanline_update) /* scanline updater (indexed16) */ - MCFG_TMS340X0_TO_SHIFTREG_CB(midtunit_state, to_shiftreg) /* write to shiftreg function */ - MCFG_TMS340X0_FROM_SHIFTREG_CB(midtunit_state, from_shiftreg) /* read from shiftreg function */ - - MCFG_MACHINE_RESET_OVERRIDE(midtunit_state,midtunit) + tms340x0_device &maincpu(TMS34010(config, "maincpu", CPU_CLOCK)); + maincpu.set_addrmap(AS_PROGRAM, &midtunit_state::main_map); + maincpu.set_halt_on_reset(false); /* halt on reset */ + maincpu.set_pixel_clock(PIXEL_CLOCK); /* pixel clock */ + maincpu.set_pixels_per_clock(2); /* pixels per clock */ + maincpu.set_scanline_ind16_callback("video", FUNC(midtunit_video_device::scanline_update)); /* scanline updater (indexed16) */ + maincpu.set_shiftreg_in_callback("video", FUNC(midtunit_video_device::to_shiftreg)); /* write to shiftreg function */ + maincpu.set_shiftreg_out_callback("video", FUNC(midtunit_video_device::from_shiftreg)); /* read from shiftreg function */ + NVRAM(config, "nvram", nvram_device::DEFAULT_ALL_0); WATCHDOG_TIMER(config, "watchdog"); /* video hardware */ - MCFG_PALETTE_ADD("palette", 32768) - MCFG_PALETTE_FORMAT(xRRRRRGGGGGBBBBB) + PALETTE(config, "palette", 32768).set_format(PALETTE_FORMAT_xRRRRRGGGGGBBBBB); - MCFG_SCREEN_ADD("screen", RASTER) + screen_device &screen(SCREEN(config, "screen", SCREEN_TYPE_RASTER)); // from TMS340 registers - MCFG_SCREEN_RAW_PARAMS(PIXEL_CLOCK * 2, 506, 100, 500, 289, 20, 274) - MCFG_SCREEN_UPDATE_DEVICE("maincpu", tms34010_device, tms340x0_ind16) - MCFG_SCREEN_PALETTE("palette") - - MCFG_VIDEO_START_OVERRIDE(midtunit_state,midtunit) -MACHINE_CONFIG_END + screen.set_raw(PIXEL_CLOCK * 2, 506, 100, 500, 289, 20, 274); + screen.set_screen_update("maincpu", FUNC(tms34010_device::tms340x0_ind16)); + screen.set_palette("palette"); +} void midtunit_state::tunit_adpcm(machine_config &config) diff --git a/src/mame/includes/midtunit.h b/src/mame/includes/midtunit.h index e658d6ef542..0f1fc45485a 100644 --- a/src/mame/includes/midtunit.h +++ b/src/mame/includes/midtunit.h @@ -13,6 +13,7 @@ #include "audio/dcs.h" #include "audio/williams.h" +#include "video/midtunit.h" #include "cpu/tms34010/tms34010.h" #include "emupal.h" @@ -21,14 +22,10 @@ class midtunit_state : public driver_device { public: - enum - { - TIMER_DMA - }; - midtunit_state(const machine_config &mconfig, device_type type, const char *tag) : driver_device(mconfig, type, tag), m_maincpu(*this, "maincpu"), + m_video(*this, "video"), m_dcs(*this, "dcs"), m_palette(*this, "palette"), m_cvsd_sound(*this, "cvsd"), @@ -48,38 +45,14 @@ public: void init_jdreddp(); void init_mk2(); - TMS340X0_TO_SHIFTREG_CB_MEMBER(to_shiftreg); - TMS340X0_FROM_SHIFTREG_CB_MEMBER(from_shiftreg); - TMS340X0_SCANLINE_IND16_CB_MEMBER(scanline_update); - protected: - required_device m_maincpu; + void machine_reset() override; + + required_device m_maincpu; + required_device m_video; optional_device m_dcs; required_device m_palette; - DECLARE_READ16_MEMBER(midtunit_vram_r); - DECLARE_WRITE16_MEMBER(midtunit_vram_w); - DECLARE_READ16_MEMBER(midtunit_gfxrom_r); - DECLARE_WRITE16_MEMBER(midtunit_vram_data_w); - DECLARE_WRITE16_MEMBER(midtunit_vram_color_w); - DECLARE_READ16_MEMBER(midtunit_vram_data_r); - DECLARE_READ16_MEMBER(midtunit_vram_color_r); - - DECLARE_WRITE16_MEMBER(midxunit_paletteram_w); - DECLARE_READ16_MEMBER(midxunit_paletteram_r); - - DECLARE_READ16_MEMBER(midtunit_dma_r); - DECLARE_WRITE16_MEMBER(midtunit_dma_w); - - DECLARE_READ16_MEMBER(midwunit_gfxrom_r); - - DECLARE_WRITE16_MEMBER(midwunit_control_w); - DECLARE_READ16_MEMBER(midwunit_control_r); - - DECLARE_VIDEO_START(midtunit); - - uint8_t m_gfx_rom_large; - private: optional_device m_cvsd_sound; optional_device m_adpcm_sound; @@ -105,16 +78,11 @@ private: DECLARE_WRITE16_MEMBER(nbajam_prot_w); DECLARE_WRITE16_MEMBER(jdredd_prot_w); DECLARE_READ16_MEMBER(jdredd_prot_r); - DECLARE_WRITE16_MEMBER(midtunit_control_w); - - DECLARE_MACHINE_RESET(midtunit); void register_state_saving(); void init_tunit_generic(int sound); void init_nbajam_common(int te_protection); - emu_timer *m_dma_timer; - /* CMOS-related variables */ uint8_t m_cmos_write_enable; @@ -135,7 +103,6 @@ private: uint8_t m_jdredd_prot_max; void main_map(address_map &map); - virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override; }; #endif // MAME_INCLUDES_MIDTUNIT_H diff --git a/src/mame/includes/midxunit.h b/src/mame/includes/midxunit.h index dbb5afbdb61..1b2d162bf29 100644 --- a/src/mame/includes/midxunit.h +++ b/src/mame/includes/midxunit.h @@ -44,7 +44,6 @@ private: DECLARE_MACHINE_RESET(midxunit); DECLARE_VIDEO_START(midxunit); void register_state_saving(); - TMS340X0_SCANLINE_IND16_CB_MEMBER(scanline_update); void main_map(address_map &map); diff --git a/src/mame/machine/midtunit.cpp b/src/mame/machine/midtunit.cpp index f04a957c62f..fe284aed25d 100644 --- a/src/mame/machine/midtunit.cpp +++ b/src/mame/machine/midtunit.cpp @@ -361,10 +361,6 @@ void midtunit_state::init_tunit_generic(int sound) /* load sound ROMs and set up sound handlers */ m_chip_type = sound; - - - /* default graphics functionality */ - m_gfx_rom_large = 0; } @@ -463,7 +459,7 @@ void midtunit_state::init_mk2() { /* common init */ init_tunit_generic(SOUND_DCS); - m_gfx_rom_large = 1; + m_video->set_gfx_rom_large(true); /* protection */ m_maincpu->space(AS_PROGRAM).install_write_handler(0x00f20c60, 0x00f20c7f, write16_delegate(FUNC(midtunit_state::mk2_prot_w),this)); @@ -483,7 +479,7 @@ void midtunit_state::init_mk2() * *************************************/ -MACHINE_RESET_MEMBER(midtunit_state,midtunit) +void midtunit_state::machine_reset() { /* reset sound */ switch (m_chip_type) diff --git a/src/mame/video/midtunit.cpp b/src/mame/video/midtunit.cpp index 6e91baff868..71112f2e32b 100644 --- a/src/mame/video/midtunit.cpp +++ b/src/mame/video/midtunit.cpp @@ -3,84 +3,43 @@ // thanks-to:Kurt Mahan /************************************************************************* - Driver for Midway T-unit games. + Video Emulation for Midway T-unit, W-unit, and X-unit games. **************************************************************************/ #include "emu.h" -#include "cpu/tms34010/tms34010.h" -#include "includes/midtunit.h" -#include "includes/midwunit.h" -#include "includes/midxunit.h" +#include "midtunit.h" +#include "midtunit.hxx" +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") +DEFINE_DEVICE_TYPE(MIDXUNIT_VIDEO, midxunit_video_device, "xunitvid", "Midway X-Unit Video") /* compile-time options */ #define LOG_DMA 0 /* DMAs are logged if the 'L' key is pressed */ - -/* constants for the DMA chip */ -enum +midtunit_video_device::midtunit_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) + , m_maincpu(*this, finder_base::DUMMY_TAG) + , m_palette(*this, finder_base::DUMMY_TAG) + , m_gfxrom(*this, finder_base::DUMMY_TAG) { - DMA_LRSKIP = 0, - DMA_COMMAND, - DMA_OFFSETLO, - DMA_OFFSETHI, - DMA_XSTART, - DMA_YSTART, - DMA_WIDTH, - DMA_HEIGHT, - DMA_PALETTE, - DMA_COLOR, - DMA_SCALE_X, - DMA_SCALE_Y, - DMA_TOPCLIP, - DMA_BOTCLIP, - DMA_UNKNOWN_E, /* MK1/2 never write here; NBA only writes 0 */ - DMA_CONFIG, - DMA_LEFTCLIP, /* pseudo-register */ - DMA_RIGHTCLIP /* pseudo-register */ -}; - - - -/* graphics-related variables */ -static uint16_t midtunit_control; - -/* videoram-related variables */ -static uint32_t gfxbank_offset[2]; -static std::unique_ptr local_videoram; -static uint8_t videobank_select; - -/* DMA-related variables */ -static uint16_t dma_register[18]; -static struct +} + +midtunit_video_device::midtunit_video_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) + : midtunit_video_device(mconfig, MIDTUNIT_VIDEO, tag, owner, clock) { - uint8_t * gfxrom; - - uint32_t offset; /* source offset, in bits */ - int32_t rowbits; /* source bits to skip each row */ - int32_t xpos; /* x position, clipped */ - int32_t ypos; /* y position, clipped */ - int32_t width; /* horizontal pixel count */ - int32_t height; /* vertical pixel count */ - uint16_t palette; /* palette base */ - 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 */ - int32_t botclip; /* bottom clipping scanline */ - int32_t leftclip; /* left clipping column */ - int32_t rightclip; /* right clipping column */ - int32_t startskip; /* pixels to skip at start */ - int32_t endskip; /* pixels to skip at end */ - uint16_t xstep; /* 8.8 fixed number scale x factor */ - uint16_t ystep; /* 8.8 fixed number scale y factor */ -} dma_state; +} +midwunit_video_device::midwunit_video_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) + : midtunit_video_device(mconfig, MIDWUNIT_VIDEO, tag, owner, clock) +{ +} +midxunit_video_device::midxunit_video_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) + : midtunit_video_device(mconfig, MIDXUNIT_VIDEO, tag, owner, clock) +{ +} /************************************* * @@ -88,42 +47,48 @@ static struct * *************************************/ -VIDEO_START_MEMBER(midtunit_state,midtunit) +void midtunit_video_device::device_start() { /* allocate memory */ - local_videoram = std::make_unique(0x100000/2); + m_local_videoram = std::make_unique(0x100000/2); m_dma_timer = timer_alloc(TIMER_DMA); /* reset all the globals */ - gfxbank_offset[0] = 0x000000; - gfxbank_offset[1] = 0x400000; + m_gfxbank_offset[0] = 0x000000; + m_gfxbank_offset[1] = 0x400000; - memset(dma_register, 0, sizeof(dma_register)); - memset(&dma_state, 0, sizeof(dma_state)); - dma_state.gfxrom = m_gfxrom->base(); + memset(m_dma_register, 0, sizeof(m_dma_register)); + memset(&m_dma_state, 0, sizeof(dma_state)); + m_dma_state.gfxrom = m_gfxrom->base(); /* register for state saving */ - save_item(NAME(midtunit_control)); - save_item(NAME(gfxbank_offset)); - save_pointer(NAME(local_videoram), 0x100000/sizeof(local_videoram[0])); - save_item(NAME(videobank_select)); - save_item(NAME(dma_register)); + save_item(NAME(m_midtunit_control)); + save_item(NAME(m_gfxbank_offset)); + save_pointer(NAME(m_local_videoram), 0x100000/sizeof(m_local_videoram[0])); + save_item(NAME(m_videobank_select)); + save_item(NAME(m_dma_register)); + + INIT_TEMPLATED_DMA_DRAW_GROUP(m_dma_draw_skip_scale, true, true); + INIT_TEMPLATED_DMA_DRAW_GROUP(m_dma_draw_noskip_scale, false, true); + INIT_TEMPLATED_DMA_DRAW_GROUP(m_dma_draw_skip_noscale, true, false); + INIT_TEMPLATED_DMA_DRAW_GROUP(m_dma_draw_noskip_noscale, false, false); + + m_gfx_rom_large = false; } - -VIDEO_START_MEMBER(midwunit_state,midwunit) +void midwunit_video_device::device_start() { - VIDEO_START_CALL_MEMBER(midtunit); - m_gfx_rom_large = 1; + midtunit_video_device::device_start(); + m_gfx_rom_large = true; } -VIDEO_START_MEMBER(midxunit_state,midxunit) +void midxunit_video_device::device_start() { - VIDEO_START_CALL_MEMBER(midtunit); - m_gfx_rom_large = 1; - videobank_select = 1; + midtunit_video_device::device_start(); + m_gfx_rom_large = true; + m_videobank_select = 1; } @@ -134,17 +99,17 @@ VIDEO_START_MEMBER(midxunit_state,midxunit) * *************************************/ -READ16_MEMBER(midtunit_state::midtunit_gfxrom_r) +READ16_MEMBER(midtunit_video_device::midtunit_gfxrom_r) { - uint8_t *base = m_gfxrom->base() + gfxbank_offset[(offset >> 21) & 1]; + uint8_t *base = m_gfxrom->base() + m_gfxbank_offset[(offset >> 21) & 1]; offset = (offset & 0x01fffff) * 2; return base[offset] | (base[offset + 1] << 8); } -READ16_MEMBER(midtunit_state::midwunit_gfxrom_r) +READ16_MEMBER(midwunit_video_device::midwunit_gfxrom_r) { - uint8_t *base = m_gfxrom->base() + gfxbank_offset[0]; + uint8_t *base = m_gfxrom->base() + m_gfxbank_offset[0]; offset *= 2; return base[offset] | (base[offset + 1] << 8); } @@ -157,67 +122,67 @@ READ16_MEMBER(midtunit_state::midwunit_gfxrom_r) * *************************************/ -WRITE16_MEMBER(midtunit_state::midtunit_vram_w) +WRITE16_MEMBER(midtunit_video_device::midtunit_vram_w) { offset *= 2; - if (videobank_select) + if (m_videobank_select) { - if (ACCESSING_BITS_0_7) - local_videoram[offset] = (data & 0xff) | ((dma_register[DMA_PALETTE] & 0xff) << 8); + if (ACCESSING_BITS_0_7) + m_local_videoram[offset] = 0;// (data & 0xff) | ((m_dma_register[DMA_PALETTE] & 0xff) << 8); if (ACCESSING_BITS_8_15) - local_videoram[offset + 1] = ((data >> 8) & 0xff) | (dma_register[DMA_PALETTE] & 0xff00); + m_local_videoram[offset + 1] = ((data >> 8) & 0xff) | (m_dma_register[DMA_PALETTE] & 0xff00); } else { if (ACCESSING_BITS_0_7) - local_videoram[offset] = (local_videoram[offset] & 0xff) | ((data & 0xff) << 8); + m_local_videoram[offset] = (m_local_videoram[offset] & 0xff) | ((data & 0xff) << 8); if (ACCESSING_BITS_8_15) - local_videoram[offset + 1] = (local_videoram[offset + 1] & 0xff) | (data & 0xff00); + m_local_videoram[offset + 1] = (m_local_videoram[offset + 1] & 0xff) | (data & 0xff00); } } -WRITE16_MEMBER(midtunit_state::midtunit_vram_data_w) +WRITE16_MEMBER(midtunit_video_device::midtunit_vram_data_w) { offset *= 2; if (ACCESSING_BITS_0_7) - local_videoram[offset] = (data & 0xff) | ((dma_register[DMA_PALETTE] & 0xff) << 8); + m_local_videoram[offset] = (data & 0xff) | ((m_dma_register[DMA_PALETTE] & 0xff) << 8); if (ACCESSING_BITS_8_15) - local_videoram[offset + 1] = ((data >> 8) & 0xff) | (dma_register[DMA_PALETTE] & 0xff00); + m_local_videoram[offset + 1] = ((data >> 8) & 0xff) | (m_dma_register[DMA_PALETTE] & 0xff00); } -WRITE16_MEMBER(midtunit_state::midtunit_vram_color_w) +WRITE16_MEMBER(midtunit_video_device::midtunit_vram_color_w) { offset *= 2; if (ACCESSING_BITS_0_7) - local_videoram[offset] = (local_videoram[offset] & 0xff) | ((data & 0xff) << 8); + m_local_videoram[offset] = (m_local_videoram[offset] & 0xff) | ((data & 0xff) << 8); if (ACCESSING_BITS_8_15) - local_videoram[offset + 1] = (local_videoram[offset + 1] & 0xff) | (data & 0xff00); + m_local_videoram[offset + 1] = (m_local_videoram[offset + 1] & 0xff) | (data & 0xff00); } -READ16_MEMBER(midtunit_state::midtunit_vram_r) +READ16_MEMBER(midtunit_video_device::midtunit_vram_r) { offset *= 2; - if (videobank_select) - return (local_videoram[offset] & 0x00ff) | (local_videoram[offset + 1] << 8); + if (m_videobank_select) + return (m_local_videoram[offset] & 0x00ff) | (m_local_videoram[offset + 1] << 8); else - return (local_videoram[offset] >> 8) | (local_videoram[offset + 1] & 0xff00); + return (m_local_videoram[offset] >> 8) | (m_local_videoram[offset + 1] & 0xff00); } -READ16_MEMBER(midtunit_state::midtunit_vram_data_r) +READ16_MEMBER(midtunit_video_device::midtunit_vram_data_r) { offset *= 2; - return (local_videoram[offset] & 0x00ff) | (local_videoram[offset + 1] << 8); + return (m_local_videoram[offset] & 0x00ff) | (m_local_videoram[offset + 1] << 8); } -READ16_MEMBER(midtunit_state::midtunit_vram_color_r) +READ16_MEMBER(midtunit_video_device::midtunit_vram_color_r) { offset *= 2; - return (local_videoram[offset] >> 8) | (local_videoram[offset + 1] & 0xff00); + return (m_local_videoram[offset] >> 8) | (m_local_videoram[offset + 1] & 0xff00); } @@ -228,15 +193,15 @@ READ16_MEMBER(midtunit_state::midtunit_vram_color_r) * *************************************/ -TMS340X0_TO_SHIFTREG_CB_MEMBER(midtunit_state::to_shiftreg) +TMS340X0_TO_SHIFTREG_CB_MEMBER(midtunit_video_device::to_shiftreg) { - memcpy(shiftreg, &local_videoram[address >> 3], 2 * 512 * sizeof(uint16_t)); + memcpy(shiftreg, &m_local_videoram[address >> 3], 2 * 512 * sizeof(uint16_t)); } -TMS340X0_FROM_SHIFTREG_CB_MEMBER(midtunit_state::from_shiftreg) +TMS340X0_FROM_SHIFTREG_CB_MEMBER(midtunit_video_device::from_shiftreg) { - memcpy(&local_videoram[address >> 3], shiftreg, 2 * 512 * sizeof(uint16_t)); + memcpy(&m_local_videoram[address >> 3], shiftreg, 2 * 512 * sizeof(uint16_t)); } @@ -247,7 +212,7 @@ TMS340X0_FROM_SHIFTREG_CB_MEMBER(midtunit_state::from_shiftreg) * *************************************/ -WRITE16_MEMBER(midtunit_state::midtunit_control_w) +WRITE16_MEMBER(midtunit_video_device::midtunit_control_w) { /* other important bits: @@ -255,20 +220,20 @@ WRITE16_MEMBER(midtunit_state::midtunit_control_w) */ logerror("T-unit control = %04X\n", data); - COMBINE_DATA(&midtunit_control); + COMBINE_DATA(&m_midtunit_control); /* gfx bank select is bit 7 */ - if (!(midtunit_control & 0x0080) || !m_gfx_rom_large) - gfxbank_offset[0] = 0x000000; + if (!(m_midtunit_control & 0x0080) || !m_gfx_rom_large) + m_gfxbank_offset[0] = 0x000000; else - gfxbank_offset[0] = 0x800000; + m_gfxbank_offset[0] = 0x800000; /* video bank select is bit 5 */ - videobank_select = (midtunit_control >> 5) & 1; + m_videobank_select = (m_midtunit_control >> 5) & 1; } -WRITE16_MEMBER(midtunit_state::midwunit_control_w) +WRITE16_MEMBER(midwunit_video_device::midwunit_control_w) { /* other important bits: @@ -276,19 +241,19 @@ WRITE16_MEMBER(midtunit_state::midwunit_control_w) */ logerror("Wolf-unit control = %04X\n", data); - COMBINE_DATA(&midtunit_control); + COMBINE_DATA(&m_midtunit_control); /* gfx bank select is bits 8-9 */ - gfxbank_offset[0] = 0x800000 * ((midtunit_control >> 8) & 3); + m_gfxbank_offset[0] = 0x800000 * ((m_midtunit_control >> 8) & 3); /* video bank select is unknown */ - videobank_select = (midtunit_control >> 11) & 1; + m_videobank_select = (m_midtunit_control >> 11) & 1; } -READ16_MEMBER(midtunit_state::midwunit_control_r) +READ16_MEMBER(midwunit_video_device::midwunit_control_r) { - return midtunit_control; + return m_midtunit_control; } @@ -299,14 +264,14 @@ READ16_MEMBER(midtunit_state::midwunit_control_r) * *************************************/ -WRITE16_MEMBER(midtunit_state::midxunit_paletteram_w) +WRITE16_MEMBER(midxunit_video_device::midxunit_paletteram_w) { if (!(offset & 1)) m_palette->write16(space, offset / 2, data, mem_mask); } -READ16_MEMBER(midtunit_state::midxunit_paletteram_r) +READ16_MEMBER(midxunit_video_device::midxunit_paletteram_r) { return m_palette->read16(space, offset / 2, mem_mask); } @@ -319,27 +284,6 @@ READ16_MEMBER(midtunit_state::midxunit_paletteram_r) * *************************************/ -/*** constant definitions ***/ -#define PIXEL_SKIP 0 -#define PIXEL_COLOR 1 -#define PIXEL_COPY 2 - -#define XFLIP_NO 0 -#define XFLIP_YES 1 - -#define SKIP_NO 0 -#define SKIP_YES 1 - -#define SCALE_NO 0 -#define SCALE_YES 1 - -#define XPOSMASK 0x3ff -#define YPOSMASK 0x1ff - - -typedef void (*dma_draw_func)(void); - - /*** fast pixel extractors ***/ #if !defined(ALIGN_SHORTS) && defined(LSB_FIRST) #define EXTRACTGEN(m) ((*(uint16_t *)&base[o >> 3] >> (o & 7)) & (m)) @@ -350,230 +294,188 @@ typedef void (*dma_draw_func)(void); #endif /*** core blitter routine macro ***/ -#define DMA_DRAW_FUNC_BODY(name, bitsperpixel, extractor, xflip, skip, scale, zero, nonzero) \ -{ \ - int height = dma_state.height << 8; \ - uint8_t *base = dma_state.gfxrom; \ - uint32_t offset = dma_state.offset; \ - uint16_t pal = dma_state.palette; \ - uint16_t color = pal | dma_state.color; \ - int sy = dma_state.ypos, iy = 0, ty; \ - int bpp = bitsperpixel; \ - int mask = (1 << bpp) - 1; \ - int xstep = scale ? dma_state.xstep : 0x100; \ - \ - /* loop over the height */ \ - while (iy < height) \ - { \ - int startskip = dma_state.startskip << 8; \ - int endskip = dma_state.endskip << 8; \ - int width = dma_state.width << 8; \ - int sx = dma_state.xpos, ix = 0, tx; \ - uint32_t o = offset; \ - int pre, post; \ - uint16_t *d; \ - \ - /* handle skipping */ \ - if (skip) \ - { \ - uint8_t value = EXTRACTGEN(0xff); \ - o += 8; \ - \ - /* adjust for preskip */ \ - pre = (value & 0x0f) << (dma_state.preskip + 8); \ - tx = pre / xstep; \ - if (xflip) \ - sx = (sx - tx) & XPOSMASK; \ - else \ - sx = (sx + tx) & XPOSMASK; \ - ix += tx * xstep; \ - \ - /* adjust for postskip */ \ - post = ((value >> 4) & 0x0f) << (dma_state.postskip + 8); \ - width -= post; \ - endskip -= post; \ - } \ - \ - /* handle Y clipping */ \ - if (sy < dma_state.topclip || sy > dma_state.botclip) \ - goto clipy; \ - \ - /* handle start skip */ \ - if (ix < startskip) \ - { \ - tx = ((startskip - ix) / xstep) * xstep; \ - ix += tx; \ - o += (tx >> 8) * bpp; \ - } \ - \ - /* handle end skip */ \ - if ((width >> 8) > dma_state.width - dma_state.endskip) \ - width = (dma_state.width - dma_state.endskip) << 8; \ - \ - /* determine destination pointer */ \ - d = &local_videoram[sy * 512]; \ - \ - /* loop until we draw the entire width */ \ - while (ix < width) \ - { \ - /* only process if not clipped */ \ - if (sx >= dma_state.leftclip && sx <= dma_state.rightclip) \ - { \ - /* special case similar handling of zero/non-zero */ \ - if (zero == nonzero) \ - { \ - if (zero == PIXEL_COLOR) \ - d[sx] = color; \ - else if (zero == PIXEL_COPY) \ - d[sx] = (extractor(mask)) | pal; \ - } \ - \ - /* otherwise, read the pixel and look */ \ - else \ - { \ - int pixel = (extractor(mask)); \ - \ - /* non-zero pixel case */ \ - if (pixel) \ - { \ - if (nonzero == PIXEL_COLOR) \ - d[sx] = color; \ - else if (nonzero == PIXEL_COPY) \ - d[sx] = pixel | pal; \ - } \ - \ - /* zero pixel case */ \ - else \ - { \ - if (zero == PIXEL_COLOR) \ - d[sx] = color; \ - else if (zero == PIXEL_COPY) \ - d[sx] = pal; \ - } \ - } \ - } \ - \ - /* update pointers */ \ - if (xflip) \ - sx = (sx - 1) & XPOSMASK; \ - else \ - sx = (sx + 1) & XPOSMASK; \ - \ - /* advance to the next pixel */ \ - if (!scale) \ - { \ - ix += 0x100; \ - o += bpp; \ - } \ - else \ - { \ - tx = ix >> 8; \ - ix += xstep; \ - tx = (ix >> 8) - tx; \ - o += bpp * tx; \ - } \ - } \ - \ - clipy: \ - /* advance to the next row */ \ - if (dma_state.yflip) \ - sy = (sy - 1) & YPOSMASK; \ - else \ - sy = (sy + 1) & YPOSMASK; \ - if (!scale) \ - { \ - iy += 0x100; \ - width = dma_state.width; \ - if (skip) \ - { \ - offset += 8; \ - width -= (pre + post) >> 8; \ - if (width > 0) offset += width * bpp; \ - } \ - else \ - offset += width * bpp; \ - } \ - else \ - { \ - ty = iy >> 8; \ - iy += dma_state.ystep; \ - ty = (iy >> 8) - ty; \ - if (!skip) \ - offset += ty * dma_state.width * bpp; \ - else if (ty--) \ - { \ - o = offset + 8; \ - width = dma_state.width - ((pre + post) >> 8); \ - if (width > 0) o += width * bpp; \ - while (ty--) \ - { \ - uint8_t value = EXTRACTGEN(0xff); \ - o += 8; \ - pre = (value & 0x0f) << dma_state.preskip; \ - post = ((value >> 4) & 0x0f) << dma_state.postskip; \ - width = dma_state.width - pre - post; \ - if (width > 0) o += width * bpp; \ - } \ - offset = o; \ - } \ - } \ - } \ -} - - -/*** slightly simplified one for most blitters ***/ -#define DMA_DRAW_FUNC(name, bpp, extract, xflip, skip, scale, zero, nonzero) \ -static void name(void) \ -{ \ - DMA_DRAW_FUNC_BODY(name, bpp, extract, xflip, skip, scale, zero, nonzero) \ -} - -/*** empty blitter ***/ -static void dma_draw_none(void) +template +void midtunit_video_device::dma_draw() { + int height = m_dma_state.height << 8; + uint8_t *base = m_dma_state.gfxrom; + uint32_t offset = m_dma_state.offset; + uint16_t pal = m_dma_state.palette; + uint16_t color = pal | m_dma_state.color; + int sy = m_dma_state.ypos; + int iy = 0; + int ty; + int mask = (1 << BitsPerPixel) - 1; + int xstep = Scale ? m_dma_state.xstep : 0x100; + + /* loop over the height */ + while (iy < height) + { + int startskip = m_dma_state.startskip << 8; + int endskip = m_dma_state.endskip << 8; + int width = m_dma_state.width << 8; + int sx = m_dma_state.xpos; + int ix = 0; + int tx; + uint32_t o = offset; + int pre, post; + uint16_t *d; + + /* handle skipping */ + if (Skip) + { + uint8_t value = EXTRACTGEN(0xff); + o += 8; + + /* adjust for preskip */ + pre = (value & 0x0f) << (m_dma_state.preskip + 8); + tx = pre / xstep; + if (XFlip) + sx = (sx - tx) & XPOSMASK; + else + sx = (sx + tx) & XPOSMASK; + ix += tx * xstep; + + /* adjust for postskip */ + post = ((value >> 4) & 0x0f) << (m_dma_state.postskip + 8); + width -= post; + endskip -= post; + } + + /* handle Y clipping */ + if (sy < m_dma_state.topclip || sy > m_dma_state.botclip) + goto clipy; + + /* handle start skip */ + if (ix < startskip) + { + tx = ((startskip - ix) / xstep) * xstep; + ix += tx; + o += (tx >> 8) * BitsPerPixel; + } + + /* handle end skip */ + if ((width >> 8) > m_dma_state.width - m_dma_state.endskip) + width = (m_dma_state.width - m_dma_state.endskip) << 8; + + /* determine destination pointer */ + d = &m_local_videoram[sy * 512]; + + /* loop until we draw the entire width */ + while (ix < width) + { + /* only process if not clipped */ + if (sx >= m_dma_state.leftclip && sx <= m_dma_state.rightclip) + { + /* special case similar handling of zero/non-zero */ + if (Zero == NonZero) + { + if (Zero == PIXEL_COLOR) + d[sx] = color; + else if (Zero == PIXEL_COPY) + d[sx] = (EXTRACTGEN(mask)) | pal; + } + + /* otherwise, read the pixel and look */ + else + { + int pixel = (EXTRACTGEN(mask)); + + /* non-zero pixel case */ + if (pixel) + { + if (NonZero == PIXEL_COLOR) + d[sx] = color; + else if (NonZero == PIXEL_COPY) + d[sx] = pixel | pal; + } + + /* zero pixel case */ + else + { + if (Zero == PIXEL_COLOR) + d[sx] = color; + else if (Zero == PIXEL_COPY) + d[sx] = pal; + } + } + } + + /* update pointers */ + if (XFlip) + sx = (sx - 1) & XPOSMASK; + else + sx = (sx + 1) & XPOSMASK; + + /* advance to the next pixel */ + if (!Scale) + { + ix += 0x100; + o += BitsPerPixel; + } + else + { + tx = ix >> 8; + ix += xstep; + tx = (ix >> 8) - tx; + o += BitsPerPixel * tx; + } + } + + clipy: + /* advance to the next row */ + if (m_dma_state.yflip) + sy = (sy - 1) & YPOSMASK; + else + sy = (sy + 1) & YPOSMASK; + if (!Scale) + { + iy += 0x100; + width = m_dma_state.width; + if (Skip) + { + offset += 8; + width -= (pre + post) >> 8; + if (width > 0) offset += width * BitsPerPixel; + } + else + { + offset += width * BitsPerPixel; + } + } + else + { + ty = iy >> 8; + iy += m_dma_state.ystep; + ty = (iy >> 8) - ty; + if (!Skip) + { + offset += ty * m_dma_state.width * BitsPerPixel; + } + else if (ty--) + { + o = offset + 8; + width = m_dma_state.width - ((pre + post) >> 8); + if (width > 0) o += width * BitsPerPixel; + while (ty--) + { + uint8_t value = EXTRACTGEN(0xff); + o += 8; + pre = (value & 0x0f) << m_dma_state.preskip; + post = ((value >> 4) & 0x0f) << m_dma_state.postskip; + width = m_dma_state.width - pre - post; + if (width > 0) o += width * BitsPerPixel; + } + offset = o; + } + } + } } -/*** super macro for declaring an entire blitter family ***/ -#define DECLARE_BLITTER_SET(prefix, bpp, extract, skip, scale) \ -DMA_DRAW_FUNC(prefix##_p0, bpp, extract, XFLIP_NO, skip, scale, PIXEL_COPY, PIXEL_SKIP) \ -DMA_DRAW_FUNC(prefix##_p1, bpp, extract, XFLIP_NO, skip, scale, PIXEL_SKIP, PIXEL_COPY) \ -DMA_DRAW_FUNC(prefix##_c0, bpp, extract, XFLIP_NO, skip, scale, PIXEL_COLOR, PIXEL_SKIP) \ -DMA_DRAW_FUNC(prefix##_c1, bpp, extract, XFLIP_NO, skip, scale, PIXEL_SKIP, PIXEL_COLOR) \ -DMA_DRAW_FUNC(prefix##_p0p1, bpp, extract, XFLIP_NO, skip, scale, PIXEL_COPY, PIXEL_COPY) \ -DMA_DRAW_FUNC(prefix##_c0c1, bpp, extract, XFLIP_NO, skip, scale, PIXEL_COLOR, PIXEL_COLOR) \ -DMA_DRAW_FUNC(prefix##_c0p1, bpp, extract, XFLIP_NO, skip, scale, PIXEL_COLOR, PIXEL_COPY) \ -DMA_DRAW_FUNC(prefix##_p0c1, bpp, extract, XFLIP_NO, skip, scale, PIXEL_COPY, PIXEL_COLOR) \ - \ -DMA_DRAW_FUNC(prefix##_p0_xf, bpp, extract, XFLIP_YES, skip, scale, PIXEL_COPY, PIXEL_SKIP) \ -DMA_DRAW_FUNC(prefix##_p1_xf, bpp, extract, XFLIP_YES, skip, scale, PIXEL_SKIP, PIXEL_COPY) \ -DMA_DRAW_FUNC(prefix##_c0_xf, bpp, extract, XFLIP_YES, skip, scale, PIXEL_COLOR, PIXEL_SKIP) \ -DMA_DRAW_FUNC(prefix##_c1_xf, bpp, extract, XFLIP_YES, skip, scale, PIXEL_SKIP, PIXEL_COLOR) \ -DMA_DRAW_FUNC(prefix##_p0p1_xf, bpp, extract, XFLIP_YES, skip, scale, PIXEL_COPY, PIXEL_COPY) \ -DMA_DRAW_FUNC(prefix##_c0c1_xf, bpp, extract, XFLIP_YES, skip, scale, PIXEL_COLOR, PIXEL_COLOR) \ -DMA_DRAW_FUNC(prefix##_c0p1_xf, bpp, extract, XFLIP_YES, skip, scale, PIXEL_COLOR, PIXEL_COPY) \ -DMA_DRAW_FUNC(prefix##_p0c1_xf, bpp, extract, XFLIP_YES, skip, scale, PIXEL_COPY, PIXEL_COLOR) \ - \ -static const dma_draw_func prefix[32] = \ -{ \ -/* B0:N / B1:N B0:Y / B1:N B0:N / B1:Y B0:Y / B1:Y */ \ - dma_draw_none, prefix##_p0, prefix##_p1, prefix##_p0p1, /* no color */ \ - prefix##_c0, prefix##_c0, prefix##_c0p1, prefix##_c0p1, /* color 0 pixels */ \ - prefix##_c1, prefix##_p0c1, prefix##_c1, prefix##_p0c1, /* color non-0 pixels */\ - prefix##_c0c1, prefix##_c0c1, prefix##_c0c1, prefix##_c0c1, /* fill */ \ - \ - dma_draw_none, prefix##_p0_xf, prefix##_p1_xf, prefix##_p0p1_xf, /* no color */ \ - prefix##_c0_xf, prefix##_c0_xf, prefix##_c0p1_xf, prefix##_c0p1_xf, /* color 0 pixels */ \ - prefix##_c1_xf, prefix##_p0c1_xf, prefix##_c1_xf, prefix##_p0c1_xf, /* color non-0 pixels */\ - prefix##_c0c1_xf, prefix##_c0c1_xf, prefix##_c0c1_xf, prefix##_c0c1_xf /* fill */ \ -}; - - -/*** blitter family declarations ***/ -DECLARE_BLITTER_SET(dma_draw_skip_scale, dma_state.bpp, EXTRACTGEN, SKIP_YES, SCALE_YES) -DECLARE_BLITTER_SET(dma_draw_noskip_scale, dma_state.bpp, EXTRACTGEN, SKIP_NO, SCALE_YES) -DECLARE_BLITTER_SET(dma_draw_skip_noscale, dma_state.bpp, EXTRACTGEN, SKIP_YES, SCALE_NO) -DECLARE_BLITTER_SET(dma_draw_noskip_noscale, dma_state.bpp, EXTRACTGEN, SKIP_NO, SCALE_NO) - +DEFINE_TEMPLATED_DMA_DRAW_GROUP(true, true); +DEFINE_TEMPLATED_DMA_DRAW_GROUP(false, true); +DEFINE_TEMPLATED_DMA_DRAW_GROUP(true, false); +DEFINE_TEMPLATED_DMA_DRAW_GROUP(false, false); /************************************* @@ -582,16 +484,16 @@ DECLARE_BLITTER_SET(dma_draw_noskip_noscale, dma_state.bpp, EXTRACTGEN, SKIP * *************************************/ -void midtunit_state::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) +void midtunit_video_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) { switch (id) { case TIMER_DMA: - dma_register[DMA_COMMAND] &= ~0x8000; /* tell the cpu we're done */ + m_dma_register[DMA_COMMAND] &= ~0x8000; /* tell the cpu we're done */ m_maincpu->set_input_line(0, ASSERT_LINE); break; default: - assert_always(false, "Unknown id in midtunit_state::device_timer"); + assert_always(false, "Unknown id in midtunit_video_device::device_timer"); } } @@ -603,14 +505,14 @@ void midtunit_state::device_timer(emu_timer &timer, device_timer_id id, int para * *************************************/ -READ16_MEMBER(midtunit_state::midtunit_dma_r) +READ16_MEMBER(midtunit_video_device::midtunit_dma_r) { /* rmpgwt sometimes reads register 0, expecting it to return the */ /* current DMA status; thus we map register 0 to register 1 */ /* openice does it as well */ if (offset == 0) offset = 1; - return dma_register[offset]; + return m_dma_register[offset]; } @@ -660,28 +562,26 @@ READ16_MEMBER(midtunit_state::midtunit_dma_r) * | ----------2----- | select top/bottom or left/right for reg 12/13 */ -WRITE16_MEMBER(midtunit_state::midtunit_dma_w) +WRITE16_MEMBER(midtunit_video_device::midtunit_dma_w) { static const uint8_t register_map[2][16] = { { 0,1,2,3,4,5,6,7,8,9,10,11,16,17,14,15 }, { 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 } }; - int regbank = (dma_register[DMA_CONFIG] >> 5) & 1; - int command, bpp, regnum; - uint32_t gfxoffset; + int regbank = (m_dma_register[DMA_CONFIG] >> 5) & 1; int pixels = 0; /* blend with the current register contents */ - regnum = register_map[regbank][offset]; - COMBINE_DATA(&dma_register[regnum]); + int regnum = register_map[regbank][offset]; + COMBINE_DATA(&m_dma_register[regnum]); /* only writes to DMA_COMMAND actually cause actions */ if (regnum != DMA_COMMAND) return; /* high bit triggers action */ - command = dma_register[DMA_COMMAND]; + int command = m_dma_register[DMA_COMMAND]; m_maincpu->set_input_line(0, CLEAR_LINE); if (!(command & 0x8000)) return; @@ -689,32 +589,32 @@ WRITE16_MEMBER(midtunit_state::midtunit_dma_w) g_profiler.start(PROFILER_USER1); /* determine bpp */ - bpp = (command >> 12) & 7; + int bpp = (command >> 12) & 7; /* fill in the basic data */ - dma_state.xpos = dma_register[DMA_XSTART] & XPOSMASK; - dma_state.ypos = dma_register[DMA_YSTART] & YPOSMASK; - dma_state.width = dma_register[DMA_WIDTH] & 0x3ff; - dma_state.height = dma_register[DMA_HEIGHT] & 0x3ff; - dma_state.palette = dma_register[DMA_PALETTE] & 0x7f00; - dma_state.color = dma_register[DMA_COLOR] & 0xff; + m_dma_state.xpos = m_dma_register[DMA_XSTART] & XPOSMASK; + m_dma_state.ypos = m_dma_register[DMA_YSTART] & YPOSMASK; + m_dma_state.width = m_dma_register[DMA_WIDTH] & 0x3ff; + m_dma_state.height = m_dma_register[DMA_HEIGHT] & 0x3ff; + m_dma_state.palette = m_dma_register[DMA_PALETTE] & 0x7f00; + m_dma_state.color = m_dma_register[DMA_COLOR] & 0xff; /* fill in the rev 2 data */ - dma_state.yflip = (command & 0x20) >> 5; - dma_state.bpp = bpp ? bpp : 8; - dma_state.preskip = (command >> 8) & 3; - dma_state.postskip = (command >> 10) & 3; - dma_state.xstep = dma_register[DMA_SCALE_X] ? dma_register[DMA_SCALE_X] : 0x100; - dma_state.ystep = dma_register[DMA_SCALE_Y] ? dma_register[DMA_SCALE_Y] : 0x100; + 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; + m_dma_state.ystep = m_dma_register[DMA_SCALE_Y] ? m_dma_register[DMA_SCALE_Y] : 0x100; /* clip the clippers */ - dma_state.topclip = dma_register[DMA_TOPCLIP] & 0x1ff; - dma_state.botclip = dma_register[DMA_BOTCLIP] & 0x1ff; - dma_state.leftclip = dma_register[DMA_LEFTCLIP] & 0x3ff; - dma_state.rightclip = dma_register[DMA_RIGHTCLIP] & 0x3ff; + m_dma_state.topclip = m_dma_register[DMA_TOPCLIP] & 0x1ff; + m_dma_state.botclip = m_dma_register[DMA_BOTCLIP] & 0x1ff; + m_dma_state.leftclip = m_dma_register[DMA_LEFTCLIP] & 0x3ff; + m_dma_state.rightclip = m_dma_register[DMA_RIGHTCLIP] & 0x3ff; /* determine the offset */ - gfxoffset = dma_register[DMA_OFFSETLO] | (dma_register[DMA_OFFSETHI] << 16); + uint32_t gfxoffset = m_dma_register[DMA_OFFSETLO] | (m_dma_register[DMA_OFFSETHI] << 16); if (LOG_DMA) { @@ -722,15 +622,15 @@ if (LOG_DMA) { logerror("DMA command %04X: (bpp=%d skip=%d xflip=%d yflip=%d preskip=%d postskip=%d)\n", command, (command >> 12) & 7, (command >> 7) & 1, (command >> 4) & 1, (command >> 5) & 1, (command >> 8) & 3, (command >> 10) & 3); - logerror(" offset=%08X pos=(%d,%d) w=%d h=%d clip=(%d,%d)-(%d,%d)\n", gfxoffset, dma_register[DMA_XSTART], dma_register[DMA_YSTART], - dma_register[DMA_WIDTH], dma_register[DMA_HEIGHT], dma_register[DMA_LEFTCLIP], dma_register[DMA_TOPCLIP], dma_register[DMA_RIGHTCLIP], dma_register[DMA_BOTCLIP]); - logerror(" offset=%08X pos=(%d,%d) w=%d h=%d clip=(%d,%d)-(%d,%d)\n", gfxoffset, dma_state.xpos, dma_state.ypos, - dma_state.width, dma_state.height, dma_state.leftclip, dma_state.topclip, dma_state.rightclip, dma_state.botclip); + logerror(" offset=%08X pos=(%d,%d) w=%d h=%d clip=(%d,%d)-(%d,%d)\n", gfxoffset, m_dma_register[DMA_XSTART], m_dma_register[DMA_YSTART], + m_dma_register[DMA_WIDTH], m_dma_register[DMA_HEIGHT], m_dma_register[DMA_LEFTCLIP], m_dma_register[DMA_TOPCLIP], m_dma_register[DMA_RIGHTCLIP], m_dma_register[DMA_BOTCLIP]); + logerror(" offset=%08X pos=(%d,%d) w=%d h=%d clip=(%d,%d)-(%d,%d)\n", gfxoffset, m_dma_state.xpos, m_dma_state.ypos, + m_dma_state.width, m_dma_state.height, m_dma_state.leftclip, m_dma_state.topclip, m_dma_state.rightclip, m_dma_state.botclip); logerror(" palette=%04X color=%04X lskip=%02X rskip=%02X xstep=%04X ystep=%04X test=%04X config=%04X\n", - dma_register[DMA_PALETTE], dma_register[DMA_COLOR], - dma_register[DMA_LRSKIP] >> 8, dma_register[DMA_LRSKIP] & 0xff, - dma_register[DMA_SCALE_X], dma_register[DMA_SCALE_Y], dma_register[DMA_UNKNOWN_E], - dma_register[DMA_CONFIG]); + m_dma_register[DMA_PALETTE], m_dma_register[DMA_COLOR], + m_dma_register[DMA_LRSKIP] >> 8, m_dma_register[DMA_LRSKIP] & 0xff, + m_dma_register[DMA_SCALE_X], m_dma_register[DMA_SCALE_Y], m_dma_register[DMA_UNKNOWN_E], + m_dma_register[DMA_CONFIG]); logerror("----\n"); } } @@ -744,7 +644,7 @@ if (LOG_DMA) if (gfxoffset >= 0xf8000000) gfxoffset -= 0xf8000000; if (gfxoffset < 0x10000000) - dma_state.offset = gfxoffset; + m_dma_state.offset = gfxoffset; else { logerror("DMA source out of range: %08X\n", gfxoffset); @@ -758,34 +658,34 @@ if (LOG_DMA) /* full word seems to be the starting skip value. */ if (command & 0x40) { - dma_state.startskip = dma_register[DMA_LRSKIP] & 0xff; - dma_state.endskip = dma_register[DMA_LRSKIP] >> 8; + m_dma_state.startskip = m_dma_register[DMA_LRSKIP] & 0xff; + m_dma_state.endskip = m_dma_register[DMA_LRSKIP] >> 8; } else { - dma_state.startskip = 0; - dma_state.endskip = dma_register[DMA_LRSKIP]; + m_dma_state.startskip = 0; + m_dma_state.endskip = m_dma_register[DMA_LRSKIP]; } /* then draw */ - if (dma_state.xstep == 0x100 && dma_state.ystep == 0x100) + if (m_dma_state.xstep == 0x100 && m_dma_state.ystep == 0x100) { if (command & 0x80) - (*dma_draw_skip_noscale[command & 0x1f])(); + ((this)->*(m_dma_draw_skip_noscale[(command & 0x1f)*8 + bpp]))(); else - (*dma_draw_noskip_noscale[command & 0x1f])(); + ((this)->*(m_dma_draw_noskip_noscale[(command & 0x1f)*8 + bpp]))(); - pixels = dma_state.width * dma_state.height; + pixels = m_dma_state.width * m_dma_state.height; } else { if (command & 0x80) - (*dma_draw_skip_scale[command & 0x1f])(); + ((this)->*(m_dma_draw_skip_scale[(command & 0x1f)*8 + bpp]))(); else - (*dma_draw_noskip_scale[command & 0x1f])(); + ((this)->*(m_dma_draw_noskip_scale[(command & 0x1f)*8 + bpp]))(); - if (dma_state.xstep && dma_state.ystep) - pixels = ((dma_state.width << 8) / dma_state.xstep) * ((dma_state.height << 8) / dma_state.ystep); + if (m_dma_state.xstep && m_dma_state.ystep) + pixels = ((m_dma_state.width << 8) / m_dma_state.xstep) * ((m_dma_state.height << 8) / m_dma_state.ystep); else pixels = 0; } @@ -805,26 +705,24 @@ skipdma: * *************************************/ -TMS340X0_SCANLINE_IND16_CB_MEMBER(midtunit_state::scanline_update) +TMS340X0_SCANLINE_IND16_CB_MEMBER(midtunit_video_device::scanline_update) { - uint16_t *src = &local_videoram[(params->rowaddr << 9) & 0x3fe00]; + uint16_t *src = &m_local_videoram[(params->rowaddr << 9) & 0x3fe00]; uint16_t *dest = &bitmap.pix16(scanline); int coladdr = params->coladdr << 1; - int x; /* copy the non-blanked portions of this scanline */ - for (x = params->heblnk; x < params->hsblnk; x++) + for (int x = params->heblnk; x < params->hsblnk; x++) dest[x] = src[coladdr++ & 0x1ff] & 0x7fff; } -TMS340X0_SCANLINE_IND16_CB_MEMBER(midxunit_state::scanline_update) +TMS340X0_SCANLINE_IND16_CB_MEMBER(midxunit_video_device::scanline_update) { uint32_t fulladdr = ((params->rowaddr << 16) | params->coladdr) >> 3; - uint16_t *src = &local_videoram[fulladdr & 0x3fe00]; + uint16_t *src = &m_local_videoram[fulladdr & 0x3fe00]; uint16_t *dest = &bitmap.pix16(scanline); - int x; /* copy the non-blanked portions of this scanline */ - for (x = params->heblnk; x < params->hsblnk; x++) + for (int x = params->heblnk; x < params->hsblnk; x++) dest[x] = src[fulladdr++ & 0x1ff] & 0x7fff; } diff --git a/src/mame/video/midtunit.h b/src/mame/video/midtunit.h new file mode 100644 index 00000000000..ba47b53bd68 --- /dev/null +++ b/src/mame/video/midtunit.h @@ -0,0 +1,201 @@ +// license:BSD-3-Clause +// copyright-holders:Alex Pasadyn, Zsolt Vasvari, Ernesto Corvi, Aaron Giles +// thanks-to:Kurt Mahan +/************************************************************************* + + Video Emulation for Midway T-unit, W-unit, and X-unit games. + +**************************************************************************/ + +#ifndef MAME_VIDEO_MIDTUNIT_H +#define MAME_VIDEO_MIDTUNIT_H + +#pragma once + +#include "emu.h" +#include "cpu/tms34010/tms34010.h" +#include "emupal.h" + +class midtunit_video_device : public device_t +{ +public: + // construction/destruction + template + midtunit_video_device(const machine_config &mconfig, const char *tag, device_t *owner, T &&cpu_tag, U &&palette_tag, V &&gfxrom_tag) + : midtunit_video_device(mconfig, tag, owner, (uint32_t)0) + { + m_maincpu.set_tag(std::forward(cpu_tag)); + m_palette.set_tag(std::forward(palette_tag)); + m_gfxrom.set_tag(std::forward(gfxrom_tag)); + } + + midtunit_video_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock = 0); + + TMS340X0_TO_SHIFTREG_CB_MEMBER(to_shiftreg); + TMS340X0_FROM_SHIFTREG_CB_MEMBER(from_shiftreg); + TMS340X0_SCANLINE_IND16_CB_MEMBER(scanline_update); + + DECLARE_READ16_MEMBER(midtunit_vram_r); + DECLARE_WRITE16_MEMBER(midtunit_vram_w); + DECLARE_READ16_MEMBER(midtunit_gfxrom_r); + DECLARE_WRITE16_MEMBER(midtunit_vram_data_w); + DECLARE_WRITE16_MEMBER(midtunit_vram_color_w); + DECLARE_READ16_MEMBER(midtunit_vram_data_r); + DECLARE_READ16_MEMBER(midtunit_vram_color_r); + + DECLARE_READ16_MEMBER(midtunit_dma_r); + DECLARE_WRITE16_MEMBER(midtunit_dma_w); + + DECLARE_WRITE16_MEMBER(midtunit_control_w); + + void set_gfx_rom_large(bool gfx_rom_large) { m_gfx_rom_large = gfx_rom_large; } + + enum op_type_t + { + PIXEL_SKIP = 0, + PIXEL_COLOR = 1, + PIXEL_COPY = 2 + }; + +protected: + // construction/destruction + midtunit_video_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock = 0); + + virtual void device_start() override; + virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override; + + static const device_timer_id TIMER_DMA = 0; + + required_device m_maincpu; + required_device m_palette; + required_memory_region m_gfxrom; + + emu_timer *m_dma_timer; + + /* constants for the DMA chip */ + static constexpr uint32_t XPOSMASK = 0x3ff; + static constexpr uint32_t YPOSMASK = 0x1ff; + + template void dma_draw(); + void dma_draw_none() {}; + + typedef void (midtunit_video_device::*draw_func)(); + draw_func m_dma_draw_skip_scale[8*32]; + draw_func m_dma_draw_noskip_scale[8*32]; + draw_func m_dma_draw_skip_noscale[8*32]; + draw_func m_dma_draw_noskip_noscale[8*32]; + + enum + { + DMA_LRSKIP = 0, + DMA_COMMAND, + DMA_OFFSETLO, + DMA_OFFSETHI, + DMA_XSTART, + DMA_YSTART, + DMA_WIDTH, + DMA_HEIGHT, + DMA_PALETTE, + DMA_COLOR, + DMA_SCALE_X, + DMA_SCALE_Y, + DMA_TOPCLIP, + DMA_BOTCLIP, + DMA_UNKNOWN_E, /* MK1/2 never write here; NBA only writes 0 */ + DMA_CONFIG, + DMA_LEFTCLIP, /* pseudo-register */ + DMA_RIGHTCLIP /* pseudo-register */ + }; + + /* graphics-related variables */ + uint16_t m_midtunit_control; + bool m_gfx_rom_large; + + /* videoram-related variables */ + uint32_t m_gfxbank_offset[2]; + std::unique_ptr m_local_videoram; + uint8_t m_videobank_select; + + /* DMA-related variables */ + uint16_t m_dma_register[18]; + struct dma_state + { + uint8_t * gfxrom; + + uint32_t offset; /* source offset, in bits */ + int32_t rowbits; /* source bits to skip each row */ + int32_t xpos; /* x position, clipped */ + int32_t ypos; /* y position, clipped */ + int32_t width; /* horizontal pixel count */ + int32_t height; /* vertical pixel count */ + uint16_t palette; /* palette base */ + 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 */ + int32_t botclip; /* bottom clipping scanline */ + int32_t leftclip; /* left clipping column */ + int32_t rightclip; /* right clipping column */ + int32_t startskip; /* pixels to skip at start */ + int32_t endskip; /* pixels to skip at end */ + uint16_t xstep; /* 8.8 fixed number scale x factor */ + uint16_t ystep; /* 8.8 fixed number scale y factor */ + }; + dma_state m_dma_state; +}; + +class midwunit_video_device : public midtunit_video_device +{ +public: + // construction/destruction + template + midwunit_video_device(const machine_config &mconfig, const char *tag, device_t *owner, T &&cpu_tag, U &&palette_tag, V &&gfxrom_tag) + : midwunit_video_device(mconfig, tag, owner, (uint32_t)0) + { + m_maincpu.set_tag(std::forward(cpu_tag)); + m_palette.set_tag(std::forward(palette_tag)); + m_gfxrom.set_tag(std::forward(gfxrom_tag)); + } + midwunit_video_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock = 0); + + DECLARE_READ16_MEMBER(midwunit_gfxrom_r); + + DECLARE_WRITE16_MEMBER(midwunit_control_w); + DECLARE_READ16_MEMBER(midwunit_control_r); + +protected: + virtual void device_start() override; +}; + +class midxunit_video_device : public midtunit_video_device +{ +public: + // construction/destruction + template + midxunit_video_device(const machine_config &mconfig, const char *tag, device_t *owner, T &&cpu_tag, U &&palette_tag, V &&gfxrom_tag) + : midxunit_video_device(mconfig, tag, owner, (uint32_t)0) + { + m_maincpu.set_tag(std::forward(cpu_tag)); + m_palette.set_tag(std::forward(palette_tag)); + m_gfxrom.set_tag(std::forward(gfxrom_tag)); + } + + midxunit_video_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock = 0); + + DECLARE_WRITE16_MEMBER(midxunit_paletteram_w); + DECLARE_READ16_MEMBER(midxunit_paletteram_r); + + TMS340X0_SCANLINE_IND16_CB_MEMBER(scanline_update); + +protected: + virtual void device_start() override; +}; + +DECLARE_DEVICE_TYPE(MIDTUNIT_VIDEO, midtunit_video_device) +DECLARE_DEVICE_TYPE(MIDWUNIT_VIDEO, midwunit_video_device) +DECLARE_DEVICE_TYPE(MIDXUNIT_VIDEO, midxunit_video_device) + +#endif // MAME_VIDEO_MIDTUNIT_H \ No newline at end of file diff --git a/src/mame/video/midtunit.hxx b/src/mame/video/midtunit.hxx new file mode 100644 index 00000000000..0d5ca3f3750 --- /dev/null +++ b/src/mame/video/midtunit.hxx @@ -0,0 +1,143 @@ +// license:BSD-3-Clause +// copyright-holders:Alex Pasadyn, Zsolt Vasvari, Ernesto Corvi, Aaron Giles +// thanks-to:Kurt Mahan +/************************************************************************* + + #defines related to the video emulation of Midway T-unit, W-unit, + and X-unit games. + +**************************************************************************/ + +#define INIT_TEMPLATED_DMA_DRAW(dest, i, xflip, skip, scale, zero, nonzero) \ + dest[i+0] = &midtunit_video_device::dma_draw<8, xflip, skip, scale, zero, nonzero>; \ + dest[i+1] = &midtunit_video_device::dma_draw<1, xflip, skip, scale, zero, nonzero>; \ + dest[i+2] = &midtunit_video_device::dma_draw<2, xflip, skip, scale, zero, nonzero>; \ + dest[i+3] = &midtunit_video_device::dma_draw<3, xflip, skip, scale, zero, nonzero>; \ + dest[i+4] = &midtunit_video_device::dma_draw<4, xflip, skip, scale, zero, nonzero>; \ + dest[i+5] = &midtunit_video_device::dma_draw<5, xflip, skip, scale, zero, nonzero>; \ + dest[i+6] = &midtunit_video_device::dma_draw<6, xflip, skip, scale, zero, nonzero>; \ + dest[i+7] = &midtunit_video_device::dma_draw<7, xflip, skip, scale, zero, nonzero>; + +#define TEMPLATED_DMA_DRAW_NONE(dest, i) \ + dest[i*8+0] = &midtunit_video_device::dma_draw_none; \ + dest[i*8+1] = &midtunit_video_device::dma_draw_none; \ + dest[i*8+2] = &midtunit_video_device::dma_draw_none; \ + dest[i*8+3] = &midtunit_video_device::dma_draw_none; \ + dest[i*8+4] = &midtunit_video_device::dma_draw_none; \ + dest[i*8+5] = &midtunit_video_device::dma_draw_none; \ + dest[i*8+6] = &midtunit_video_device::dma_draw_none; \ + dest[i*8+7] = &midtunit_video_device::dma_draw_none; + +#define TEMPLATED_DMA_DRAW_P0(dest, i, skip, scale) INIT_TEMPLATED_DMA_DRAW(dest, i*8, false, skip, scale, PIXEL_COPY, PIXEL_SKIP) +#define TEMPLATED_DMA_DRAW_P1(dest, i, skip, scale) INIT_TEMPLATED_DMA_DRAW(dest, i*8, false, skip, scale, PIXEL_SKIP, PIXEL_COPY) +#define TEMPLATED_DMA_DRAW_C0(dest, i, skip, scale) INIT_TEMPLATED_DMA_DRAW(dest, i*8, false, skip, scale, PIXEL_COLOR, PIXEL_SKIP) +#define TEMPLATED_DMA_DRAW_C1(dest, i, skip, scale) INIT_TEMPLATED_DMA_DRAW(dest, i*8, false, skip, scale, PIXEL_SKIP, PIXEL_COLOR) +#define TEMPLATED_DMA_DRAW_P0P1(dest, i, skip, scale) INIT_TEMPLATED_DMA_DRAW(dest, i*8, false, skip, scale, PIXEL_COPY, PIXEL_COPY) +#define TEMPLATED_DMA_DRAW_C0C1(dest, i, skip, scale) INIT_TEMPLATED_DMA_DRAW(dest, i*8, false, skip, scale, PIXEL_COLOR, PIXEL_COLOR) +#define TEMPLATED_DMA_DRAW_C0P1(dest, i, skip, scale) INIT_TEMPLATED_DMA_DRAW(dest, i*8, false, skip, scale, PIXEL_COLOR, PIXEL_COPY) +#define TEMPLATED_DMA_DRAW_P0C1(dest, i, skip, scale) INIT_TEMPLATED_DMA_DRAW(dest, i*8, false, skip, scale, PIXEL_COPY, PIXEL_COLOR) + +#define TEMPLATED_DMA_DRAW_P0_XF(dest, i, skip, scale) INIT_TEMPLATED_DMA_DRAW(dest, i*8, true, skip, scale, PIXEL_COPY, PIXEL_SKIP) +#define TEMPLATED_DMA_DRAW_P1_XF(dest, i, skip, scale) INIT_TEMPLATED_DMA_DRAW(dest, i*8, true, skip, scale, PIXEL_SKIP, PIXEL_COPY) +#define TEMPLATED_DMA_DRAW_C0_XF(dest, i, skip, scale) INIT_TEMPLATED_DMA_DRAW(dest, i*8, true, skip, scale, PIXEL_COLOR, PIXEL_SKIP) +#define TEMPLATED_DMA_DRAW_C1_XF(dest, i, skip, scale) INIT_TEMPLATED_DMA_DRAW(dest, i*8, true, skip, scale, PIXEL_SKIP, PIXEL_COLOR) +#define TEMPLATED_DMA_DRAW_P0P1_XF(dest, i, skip, scale) INIT_TEMPLATED_DMA_DRAW(dest, i*8, true, skip, scale, PIXEL_COPY, PIXEL_COPY) +#define TEMPLATED_DMA_DRAW_C0C1_XF(dest, i, skip, scale) INIT_TEMPLATED_DMA_DRAW(dest, i*8, true, skip, scale, PIXEL_COLOR, PIXEL_COLOR) +#define TEMPLATED_DMA_DRAW_C0P1_XF(dest, i, skip, scale) INIT_TEMPLATED_DMA_DRAW(dest, i*8, true, skip, scale, PIXEL_COLOR, PIXEL_COPY) +#define TEMPLATED_DMA_DRAW_P0C1_XF(dest, i, skip, scale) INIT_TEMPLATED_DMA_DRAW(dest, i*8, true, skip, scale, PIXEL_COPY, PIXEL_COLOR) + +#define INIT_TEMPLATED_DMA_DRAW_GROUP(dest, skip, scale) \ + TEMPLATED_DMA_DRAW_NONE(dest, 0); \ + TEMPLATED_DMA_DRAW_P0(dest, 8, skip, scale); \ + TEMPLATED_DMA_DRAW_P1(dest, 16, skip, scale); \ + TEMPLATED_DMA_DRAW_P0P1(dest, 24, skip, scale); \ + TEMPLATED_DMA_DRAW_C0(dest, 32, skip, scale); \ + TEMPLATED_DMA_DRAW_C0(dest, 40, skip, scale); \ + TEMPLATED_DMA_DRAW_C0P1(dest, 48, skip, scale); \ + TEMPLATED_DMA_DRAW_C0P1(dest, 56, skip, scale); \ + TEMPLATED_DMA_DRAW_C1(dest, 64, skip, scale); \ + TEMPLATED_DMA_DRAW_P0C1(dest, 72, skip, scale); \ + TEMPLATED_DMA_DRAW_C1(dest, 80, skip, scale); \ + TEMPLATED_DMA_DRAW_P0C1(dest, 88, skip, scale); \ + TEMPLATED_DMA_DRAW_C0C1(dest, 96, skip, scale); \ + TEMPLATED_DMA_DRAW_C0C1(dest, 104, skip, scale); \ + TEMPLATED_DMA_DRAW_C0C1(dest, 112, skip, scale); \ + TEMPLATED_DMA_DRAW_C0C1(dest, 120, skip, scale); \ + TEMPLATED_DMA_DRAW_NONE(dest, 128); \ + TEMPLATED_DMA_DRAW_P0_XF(dest, 136, skip, scale); \ + TEMPLATED_DMA_DRAW_P1_XF(dest, 144, skip, scale); \ + TEMPLATED_DMA_DRAW_P0P1_XF(dest, 152, skip, scale); \ + TEMPLATED_DMA_DRAW_C0_XF(dest, 160, skip, scale); \ + TEMPLATED_DMA_DRAW_C0_XF(dest, 168, skip, scale); \ + TEMPLATED_DMA_DRAW_C0P1_XF(dest, 176, skip, scale); \ + TEMPLATED_DMA_DRAW_C0P1_XF(dest, 184, skip, scale); \ + TEMPLATED_DMA_DRAW_C1_XF(dest, 192, skip, scale); \ + TEMPLATED_DMA_DRAW_P0C1_XF(dest, 200, skip, scale); \ + TEMPLATED_DMA_DRAW_C1_XF(dest, 208, skip, scale); \ + TEMPLATED_DMA_DRAW_P0C1_XF(dest, 216, skip, scale); \ + TEMPLATED_DMA_DRAW_C0C1_XF(dest, 224, skip, scale); \ + TEMPLATED_DMA_DRAW_C0C1_XF(dest, 232, skip, scale); \ + TEMPLATED_DMA_DRAW_C0C1_XF(dest, 240, skip, scale); \ + TEMPLATED_DMA_DRAW_C0C1_XF(dest, 248, skip, scale); + +#define DEFINE_TEMPLATED_DMA_DRAW(xflip, skip, scale, zero, nonzero) \ + template void midtunit_video_device::dma_draw<8, xflip, skip, scale, zero, nonzero>(); \ + template void midtunit_video_device::dma_draw<1, xflip, skip, scale, zero, nonzero>(); \ + template void midtunit_video_device::dma_draw<2, xflip, skip, scale, zero, nonzero>(); \ + template void midtunit_video_device::dma_draw<3, xflip, skip, scale, zero, nonzero>(); \ + template void midtunit_video_device::dma_draw<4, xflip, skip, scale, zero, nonzero>(); \ + template void midtunit_video_device::dma_draw<5, xflip, skip, scale, zero, nonzero>(); \ + template void midtunit_video_device::dma_draw<6, xflip, skip, scale, zero, nonzero>(); \ + template void midtunit_video_device::dma_draw<7, xflip, skip, scale, zero, nonzero>(); + +#define DEFINE_TEMPLATED_DMA_DRAW_P0(skip, scale) \ + DEFINE_TEMPLATED_DMA_DRAW(false, skip, scale, midtunit_video_device::PIXEL_COPY, midtunit_video_device::PIXEL_SKIP) +#define DEFINE_TEMPLATED_DMA_DRAW_P1(skip, scale) \ + DEFINE_TEMPLATED_DMA_DRAW(false, skip, scale, midtunit_video_device::PIXEL_SKIP, midtunit_video_device::PIXEL_COPY) +#define DEFINE_TEMPLATED_DMA_DRAW_C0(skip, scale) \ + DEFINE_TEMPLATED_DMA_DRAW(false, skip, scale, midtunit_video_device::PIXEL_COLOR, midtunit_video_device::PIXEL_SKIP) +#define DEFINE_TEMPLATED_DMA_DRAW_C1(skip, scale) \ + DEFINE_TEMPLATED_DMA_DRAW(false, skip, scale, midtunit_video_device::PIXEL_SKIP, midtunit_video_device::PIXEL_COLOR) +#define DEFINE_TEMPLATED_DMA_DRAW_P0P1(skip, scale) \ + DEFINE_TEMPLATED_DMA_DRAW(false, skip, scale, midtunit_video_device::PIXEL_COPY, midtunit_video_device::PIXEL_COPY) +#define DEFINE_TEMPLATED_DMA_DRAW_C0C1(skip, scale) \ + DEFINE_TEMPLATED_DMA_DRAW(false, skip, scale, midtunit_video_device::PIXEL_COLOR, midtunit_video_device::PIXEL_COLOR) +#define DEFINE_TEMPLATED_DMA_DRAW_C0P1(skip, scale) \ + DEFINE_TEMPLATED_DMA_DRAW(false, skip, scale, midtunit_video_device::PIXEL_COLOR, midtunit_video_device::PIXEL_COPY) +#define DEFINE_TEMPLATED_DMA_DRAW_P0C1(skip, scale) \ + DEFINE_TEMPLATED_DMA_DRAW(false, skip, scale, midtunit_video_device::PIXEL_COPY, midtunit_video_device::PIXEL_COLOR) + +#define DEFINE_TEMPLATED_DMA_DRAW_P0_XF(skip, scale) \ + DEFINE_TEMPLATED_DMA_DRAW(true, skip, scale, midtunit_video_device::PIXEL_COPY, midtunit_video_device::PIXEL_SKIP) +#define DEFINE_TEMPLATED_DMA_DRAW_P1_XF(skip, scale) \ + DEFINE_TEMPLATED_DMA_DRAW(true, skip, scale, midtunit_video_device::PIXEL_SKIP, midtunit_video_device::PIXEL_COPY) +#define DEFINE_TEMPLATED_DMA_DRAW_C0_XF(skip, scale) \ + DEFINE_TEMPLATED_DMA_DRAW(true, skip, scale, midtunit_video_device::PIXEL_COLOR, midtunit_video_device::PIXEL_SKIP) +#define DEFINE_TEMPLATED_DMA_DRAW_C1_XF(skip, scale) \ + DEFINE_TEMPLATED_DMA_DRAW(true, skip, scale, midtunit_video_device::PIXEL_SKIP, midtunit_video_device::PIXEL_COLOR) +#define DEFINE_TEMPLATED_DMA_DRAW_P0P1_XF(skip, scale) \ + DEFINE_TEMPLATED_DMA_DRAW(true, skip, scale, midtunit_video_device::PIXEL_COPY, midtunit_video_device::PIXEL_COPY) +#define DEFINE_TEMPLATED_DMA_DRAW_C0C1_XF(skip, scale) \ + DEFINE_TEMPLATED_DMA_DRAW(true, skip, scale, midtunit_video_device::PIXEL_COLOR, midtunit_video_device::PIXEL_COLOR) +#define DEFINE_TEMPLATED_DMA_DRAW_C0P1_XF(skip, scale) \ + DEFINE_TEMPLATED_DMA_DRAW(true, skip, scale, midtunit_video_device::PIXEL_COLOR, midtunit_video_device::PIXEL_COPY) +#define DEFINE_TEMPLATED_DMA_DRAW_P0C1_XF(skip, scale) \ + DEFINE_TEMPLATED_DMA_DRAW(true, skip, scale, midtunit_video_device::PIXEL_COPY, midtunit_video_device::PIXEL_COLOR) + +#define DEFINE_TEMPLATED_DMA_DRAW_GROUP(skip, scale) \ + DEFINE_TEMPLATED_DMA_DRAW_P0(skip, scale) \ + DEFINE_TEMPLATED_DMA_DRAW_P1(skip, scale) \ + DEFINE_TEMPLATED_DMA_DRAW_C0(skip, scale) \ + DEFINE_TEMPLATED_DMA_DRAW_C1(skip, scale) \ + DEFINE_TEMPLATED_DMA_DRAW_P0P1(skip, scale) \ + DEFINE_TEMPLATED_DMA_DRAW_C0C1(skip, scale) \ + DEFINE_TEMPLATED_DMA_DRAW_C0P1(skip, scale) \ + DEFINE_TEMPLATED_DMA_DRAW_P0C1(skip, scale) \ + DEFINE_TEMPLATED_DMA_DRAW_P0_XF(skip, scale) \ + DEFINE_TEMPLATED_DMA_DRAW_P1_XF(skip, scale) \ + DEFINE_TEMPLATED_DMA_DRAW_C0_XF(skip, scale) \ + DEFINE_TEMPLATED_DMA_DRAW_C1_XF(skip, scale) \ + DEFINE_TEMPLATED_DMA_DRAW_P0P1_XF(skip, scale) \ + DEFINE_TEMPLATED_DMA_DRAW_C0C1_XF(skip, scale) \ + DEFINE_TEMPLATED_DMA_DRAW_C0P1_XF(skip, scale) \ + DEFINE_TEMPLATED_DMA_DRAW_P0C1_XF(skip, scale) -- cgit v1.2.3