diff options
-rw-r--r-- | .gitattributes | 2 | ||||
-rw-r--r-- | src/mame/drivers/fuukifg2.c | 4 | ||||
-rw-r--r-- | src/mame/drivers/fuukifg3.c | 14 | ||||
-rw-r--r-- | src/mame/includes/fuukifg2.h | 9 | ||||
-rw-r--r-- | src/mame/includes/fuukifg3.h | 10 | ||||
-rw-r--r-- | src/mame/mame.mak | 1 | ||||
-rw-r--r-- | src/mame/video/fuukifg.c | 183 | ||||
-rw-r--r-- | src/mame/video/fuukifg.h | 43 | ||||
-rw-r--r-- | src/mame/video/fuukifg2.c | 123 | ||||
-rw-r--r-- | src/mame/video/fuukifg3.c | 150 |
10 files changed, 256 insertions, 283 deletions
diff --git a/.gitattributes b/.gitattributes index 74266d9661b..622030c016d 100644 --- a/.gitattributes +++ b/.gitattributes @@ -7392,6 +7392,8 @@ src/mame/video/funkybee.c svneol=native#text/plain src/mame/video/funkyjet.c svneol=native#text/plain src/mame/video/funworld.c svneol=native#text/plain src/mame/video/funybubl.c svneol=native#text/plain +src/mame/video/fuukifg.c svneol=native#text/plain +src/mame/video/fuukifg.h svneol=native#text/plain src/mame/video/fuukifg2.c svneol=native#text/plain src/mame/video/fuukifg3.c svneol=native#text/plain src/mame/video/gaelco.c svneol=native#text/plain diff --git a/src/mame/drivers/fuukifg2.c b/src/mame/drivers/fuukifg2.c index e990053f692..be6b3a03c20 100644 --- a/src/mame/drivers/fuukifg2.c +++ b/src/mame/drivers/fuukifg2.c @@ -90,7 +90,7 @@ static ADDRESS_MAP_START( fuuki16_map, AS_PROGRAM, 16, fuuki16_state ) AM_RANGE(0x502000, 0x503fff) AM_RAM_WRITE(fuuki16_vram_1_w) AM_SHARE("vram.1") // AM_RANGE(0x504000, 0x505fff) AM_RAM_WRITE(fuuki16_vram_2_w) AM_SHARE("vram.2") // AM_RANGE(0x506000, 0x507fff) AM_RAM_WRITE(fuuki16_vram_3_w) AM_SHARE("vram.3") // - AM_RANGE(0x600000, 0x601fff) AM_MIRROR(0x008000) AM_RAM AM_SHARE("spriteram") // Sprites, mirrored? + AM_RANGE(0x600000, 0x601fff) AM_MIRROR(0x008000) AM_DEVREADWRITE("fuukivid", fuukivid_device, fuuki_sprram_r, fuuki_sprram_w) AM_SHARE("spriteram") // Sprites, mirrored? AM_RANGE(0x700000, 0x703fff) AM_RAM_DEVWRITE("palette", palette_device, write) AM_SHARE("palette") // Palette AM_RANGE(0x800000, 0x800001) AM_READ_PORT("SYSTEM") AM_RANGE(0x810000, 0x810001) AM_READ_PORT("P1_P2") @@ -464,6 +464,8 @@ static MACHINE_CONFIG_START( fuuki16, fuuki16_state ) MCFG_PALETTE_ADD("palette", 0x800*4) MCFG_PALETTE_FORMAT(xRRRRRGGGGGBBBBB) + MCFG_DEVICE_ADD("fuukivid", FUUKI_VIDEO, 0) + MCFG_FUUKI_VIDEO_GFXDECODE("gfxdecode") /* sound hardware */ MCFG_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker") diff --git a/src/mame/drivers/fuukifg3.c b/src/mame/drivers/fuukifg3.c index 5c316518c35..9caf4fada14 100644 --- a/src/mame/drivers/fuukifg3.c +++ b/src/mame/drivers/fuukifg3.c @@ -215,7 +215,7 @@ static ADDRESS_MAP_START( fuuki32_map, AS_PROGRAM, 32, fuuki32_state ) AM_RANGE(0x504000, 0x505fff) AM_RAM_WRITE(fuuki32_vram_2_w) AM_SHARE("vram.2") // Tilemap bg AM_RANGE(0x506000, 0x507fff) AM_RAM_WRITE(fuuki32_vram_3_w) AM_SHARE("vram.3") // Tilemap bg2 AM_RANGE(0x508000, 0x517fff) AM_RAM // More tilemap, or linescroll? Seems to be empty all of the time - AM_RANGE(0x600000, 0x601fff) AM_RAM AM_SHARE("spriteram") // Sprites + AM_RANGE(0x600000, 0x601fff) AM_RAM AM_DEVREADWRITE16("fuukivid", fuukivid_device, fuuki_sprram_r, fuuki_sprram_w, 0xffffffff) // Sprites AM_RANGE(0x700000, 0x703fff) AM_RAM_DEVWRITE("palette", palette_device, write) AM_SHARE("palette") // Palette AM_RANGE(0x800000, 0x800003) AM_READ_PORT("800000") AM_WRITENOP // Coin @@ -545,7 +545,7 @@ WRITE_LINE_MEMBER(fuuki32_state::irqhandler) m_soundcpu->set_input_line(0, state ? ASSERT_LINE : CLEAR_LINE); } -static MACHINE_CONFIG_START( fuuki32, fuuki32_state ) +static MACHINE_CONFIG_START(fuuki32, fuuki32_state) /* basic machine hardware */ MCFG_CPU_ADD("maincpu", M68EC020, CPU_CLOCK) /* 20MHz verified */ @@ -555,20 +555,22 @@ static MACHINE_CONFIG_START( fuuki32, fuuki32_state ) MCFG_CPU_PROGRAM_MAP(fuuki32_sound_map) MCFG_CPU_IO_MAP(fuuki32_sound_io_map) - /* video hardware */ MCFG_SCREEN_ADD("screen", RASTER) MCFG_SCREEN_REFRESH_RATE(60) - MCFG_SCREEN_SIZE(64*8, 32*8) - MCFG_SCREEN_VISIBLE_AREA(0, 40*8-1, 0, 30*8-1) + MCFG_SCREEN_SIZE(64 * 8, 32 * 8) + MCFG_SCREEN_VISIBLE_AREA(0, 40 * 8 - 1, 0, 30 * 8 - 1) MCFG_SCREEN_UPDATE_DRIVER(fuuki32_state, screen_update_fuuki32) MCFG_SCREEN_VBLANK_DRIVER(fuuki32_state, screen_eof_fuuki32) MCFG_SCREEN_PALETTE("palette") MCFG_GFXDECODE_ADD("gfxdecode", "palette", fuuki32) - MCFG_PALETTE_ADD("palette", 0x4000/2) + MCFG_PALETTE_ADD("palette", 0x4000 / 2) MCFG_PALETTE_FORMAT(xRRRRRGGGGGBBBBB) + MCFG_DEVICE_ADD("fuukivid", FUUKI_VIDEO, 0) + MCFG_FUUKI_VIDEO_GFXDECODE("gfxdecode") + /* sound hardware */ MCFG_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker") diff --git a/src/mame/includes/fuukifg2.h b/src/mame/includes/fuukifg2.h index 210bbb95313..c80dd4d5258 100644 --- a/src/mame/includes/fuukifg2.h +++ b/src/mame/includes/fuukifg2.h @@ -1,4 +1,5 @@ #include "sound/okim6295.h" +#include "video/fuukifg.h" class fuuki16_state : public driver_device { @@ -13,7 +14,6 @@ public: fuuki16_state(const machine_config &mconfig, device_type type, const char *tag) : driver_device(mconfig, type, tag), m_vram(*this, "vram"), - m_spriteram(*this, "spriteram"), m_vregs(*this, "vregs"), m_unknown(*this, "unknown"), m_priority(*this, "priority"), @@ -22,11 +22,12 @@ public: m_oki(*this, "oki"), m_gfxdecode(*this, "gfxdecode"), m_screen(*this, "screen"), - m_palette(*this, "palette") { } + m_palette(*this, "palette"), + m_fuukivid(*this, "fuukivid") + { } /* memory pointers */ required_shared_ptr_array<UINT16,4> m_vram; - required_shared_ptr<UINT16> m_spriteram; required_shared_ptr<UINT16> m_vregs; required_shared_ptr<UINT16> m_unknown; required_shared_ptr<UINT16> m_priority; @@ -59,13 +60,13 @@ public: UINT32 screen_update_fuuki16(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); inline void get_tile_info(tile_data &tileinfo, tilemap_memory_index tile_index, int _N_); inline void fuuki16_vram_w(offs_t offset, UINT16 data, UINT16 mem_mask, int _N_); - void draw_sprites( screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect ); void fuuki16_draw_layer( screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, int i, int flag, int pri ); DECLARE_WRITE_LINE_MEMBER(soundirq); required_device<okim6295_device> m_oki; required_device<gfxdecode_device> m_gfxdecode; required_device<screen_device> m_screen; required_device<palette_device> m_palette; + required_device<fuukivid_device> m_fuukivid; protected: virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr); }; diff --git a/src/mame/includes/fuukifg3.h b/src/mame/includes/fuukifg3.h index 5a7631c94bf..591ce2286a5 100644 --- a/src/mame/includes/fuukifg3.h +++ b/src/mame/includes/fuukifg3.h @@ -1,4 +1,4 @@ - +#include "video/fuukifg.h" /* Define clocks based on actual OSC on the PCB */ @@ -22,7 +22,6 @@ public: fuuki32_state(const machine_config &mconfig, device_type type, const char *tag) : driver_device(mconfig, type, tag), m_vram(*this, "vram"), - m_spriteram(*this, "spriteram"), m_vregs(*this, "vregs"), m_priority(*this, "priority"), m_tilebank(*this, "tilebank"), @@ -30,11 +29,12 @@ public: m_soundcpu(*this, "soundcpu"), m_gfxdecode(*this, "gfxdecode"), m_screen(*this, "screen"), - m_palette(*this, "palette") { } + m_palette(*this, "palette"), + m_fuukivid(*this, "fuukivid") + { } /* memory pointers */ required_shared_ptr_array<UINT32,4> m_vram; - required_shared_ptr<UINT32> m_spriteram; required_shared_ptr<UINT32> m_vregs; required_shared_ptr<UINT32> m_priority; required_shared_ptr<UINT32> m_tilebank; @@ -55,7 +55,7 @@ public: required_device<gfxdecode_device> m_gfxdecode; required_device<screen_device> m_screen; required_device<palette_device> m_palette; - + required_device<fuukivid_device> m_fuukivid; DECLARE_READ32_MEMBER(snd_020_r); DECLARE_WRITE32_MEMBER(snd_020_w); diff --git a/src/mame/mame.mak b/src/mame/mame.mak index a5f4222d5b5..329de7496aa 100644 --- a/src/mame/mame.mak +++ b/src/mame/mame.mak @@ -1148,6 +1148,7 @@ $(MAMEOBJ)/funworld.a: \ $(MAMEOBJ)/fuuki.a: \ $(DRIVERS)/fuukifg2.o $(VIDEO)/fuukifg2.o \ $(DRIVERS)/fuukifg3.o $(VIDEO)/fuukifg3.o \ + $(VIDEO)/fuukifg.o \ $(MAMEOBJ)/gaelco.a: \ $(DRIVERS)/atvtrack.o \ diff --git a/src/mame/video/fuukifg.c b/src/mame/video/fuukifg.c new file mode 100644 index 00000000000..017dc061065 --- /dev/null +++ b/src/mame/video/fuukifg.c @@ -0,0 +1,183 @@ +/* +*/ + +#include "emu.h" +#include "fuukifg.h" + +const device_type FUUKI_VIDEO = &device_creator<fuukivid_device>; + +fuukivid_device::fuukivid_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) + : device_t(mconfig, FUUKI_VIDEO, "Fuuki Video", tag, owner, clock, "fuukivid", __FILE__), + device_video_interface(mconfig, *this), + m_gfxdecode(*this) +{ +} + +void fuukivid_device::static_set_gfxdecode_tag(device_t &device, const char *tag) +{ + downcast<fuukivid_device &>(device).m_gfxdecode.set_tag(tag); +} + + +void fuukivid_device::device_start() +{ + m_sprram = auto_alloc_array_clear(machine(), UINT16, 0x2000 / 2); + + // fuukifg3 clearly has buffered ram, it is unclear if fuukifg2 has + // it is likely these render to a framebuffer as the tile bank (which is probably external hw) also needs to be banked + // suggesting that the sprites are rendered earlier, then displayed from a buffer + + m_sprram_old = auto_alloc_array_clear(machine(), UINT16, 0x2000 / 2); + m_sprram_old2 = auto_alloc_array_clear(machine(), UINT16, 0x2000 / 2); + + save_pointer(NAME(m_sprram), 0x2000 / 2); + save_pointer(NAME(m_sprram_old), 0x2000 / 2); + save_pointer(NAME(m_sprram_old2), 0x2000 / 2); + +} + +void fuukivid_device::device_reset() +{ +} + + +/*************************************************************************** + + + Sprites Drawing + + Offset: Bits: Value: + + 0.w fedc ---- ---- ---- Number Of Tiles Along X - 1 + ---- b--- ---- ---- Flip X + ---- -a-- ---- ---- 1 = Don't Draw This Sprite + ---- --98 7654 3210 X (Signed) + + 2.w fedc ---- ---- ---- Number Of Tiles Along Y - 1 + ---- b--- ---- ---- Flip Y + ---- -a-- ---- ---- + ---- --98 7654 3210 Y (Signed) + + 4.w fedc ---- ---- ---- Zoom X ($0 = Full Size, $F = Half Size) + ---- ba98 ---- ---- Zoom Y "" + ---- ---- 76-- ---- Priority + ---- ---- --54 3210 Color + + 6.w Tile Code + + for FG3 hardware + + 6.w fe-- ---- ---- ---- Tile Bank + --dc ba98 7654 3210 Tile Code + +***************************************************************************/ + +void fuukivid_device::draw_sprites( screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, int flip_screen , UINT32* tilebank) +{ + // as we're likely framebuffered (sprites are delayed by 2-3 frames, at least on FG3, and doing rasters on sprites causes glitches) we + // only draw the sprites when MAME wants to draw the final screen line. Ideally we should framebuffer them instead. + if (cliprect.max_y != m_screen->visible_area().max_y) + return; + + rectangle spriteclip = m_screen->visible_area(); + + int offs; + gfx_element *gfx = m_gfxdecode->gfx(0); + bitmap_ind8 &priority_bitmap = screen.priority(); + const rectangle &visarea = screen.visible_area(); + + UINT16 *spriteram16 = m_sprram; + + if (tilebank) spriteram16 = m_sprram_old2; // so that FG3 uses the buffered RAM + + int max_x = visarea.max_x + 1; + int max_y = visarea.max_y + 1; + + /* Draw them backwards, for pdrawgfx */ + for ( offs = (0x2000 - 8) / 2; offs >=0; offs -= 8 / 2 ) + { + int x, y, xstart, ystart, xend, yend, xinc, yinc; + int xnum, ynum, xzoom, yzoom, flipx, flipy; + int pri_mask; + + int sx = spriteram16[offs + 0]; + int sy = spriteram16[offs + 1]; + int attr = spriteram16[offs + 2]; + int code = spriteram16[offs + 3]; + + if (tilebank) + { + int bank = (code & 0xc000) >> 14; + int bank_lookedup; + + bank_lookedup = ((tilebank[1] & 0xffff0000) >> (16 + bank * 4)) & 0xf; + code &= 0x3fff; + code += bank_lookedup * 0x4000; + } + + if (sx & 0x400) + continue; + + flipx = sx & 0x0800; + flipy = sy & 0x0800; + + xnum = ((sx >> 12) & 0xf) + 1; + ynum = ((sy >> 12) & 0xf) + 1; + + xzoom = 16 * 8 - (8 * ((attr >> 12) & 0xf)) / 2; + yzoom = 16 * 8 - (8 * ((attr >> 8) & 0xf)) / 2; + + switch ((attr >> 6) & 3) + { + case 3: pri_mask = 0xf0 | 0xcc | 0xaa; break; // behind all layers + case 2: pri_mask = 0xf0 | 0xcc; break; // behind fg + middle layer + case 1: pri_mask = 0xf0; break; // behind fg layer + case 0: + default: pri_mask = 0; // above all + } + + sx = (sx & 0x1ff) - (sx & 0x200); + sy = (sy & 0x1ff) - (sy & 0x200); + + if (flip_screen) + { + flipx = !flipx; sx = max_x - sx - xnum * 16; + flipy = !flipy; sy = max_y - sy - ynum * 16; + } + + if (flipx) { xstart = xnum-1; xend = -1; xinc = -1; } + else { xstart = 0; xend = xnum; xinc = +1; } + + if (flipy) { ystart = ynum-1; yend = -1; yinc = -1; } + else { ystart = 0; yend = ynum; yinc = +1; } + + for (y = ystart; y != yend; y += yinc) + { + for (x = xstart; x != xend; x += xinc) + { + if (xzoom == (16*8) && yzoom == (16*8)) + gfx->prio_transpen(bitmap,spriteclip, + code++, + attr & 0x3f, + flipx, flipy, + sx + x * 16, sy + y * 16, + priority_bitmap, + pri_mask,15 ); + else + gfx->prio_zoom_transpen(bitmap,spriteclip, + code++, + attr & 0x3f, + flipx, flipy, + sx + (x * xzoom) / 8, sy + (y * yzoom) / 8, + (0x10000/0x10/8) * (xzoom + 8),(0x10000/0x10/8) * (yzoom + 8), priority_bitmap,// nearest greater integer value to avoid holes + pri_mask,15 ); + } + } + } +} + +void fuukivid_device::buffer_sprites(void) +{ + memcpy(m_sprram_old2, m_sprram_old, 0x2000); + memcpy(m_sprram_old, m_sprram, 0x2000); +}
\ No newline at end of file diff --git a/src/mame/video/fuukifg.h b/src/mame/video/fuukifg.h new file mode 100644 index 00000000000..fd7a86714df --- /dev/null +++ b/src/mame/video/fuukifg.h @@ -0,0 +1,43 @@ + + + +class fuukivid_device : public device_t, + public device_video_interface +{ +public: + fuukivid_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); + + // static configuration + static void static_set_gfxdecode_tag(device_t &device, const char *tag); + + void draw_sprites(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, int flip_screen, UINT32* tilebank); + UINT16* m_sprram; + UINT16* m_sprram_old; + UINT16* m_sprram_old2; + + + DECLARE_WRITE16_MEMBER(fuuki_sprram_w) + { + COMBINE_DATA(&m_sprram[offset]); + }; + + DECLARE_READ16_MEMBER(fuuki_sprram_r) + { + return m_sprram[offset]; + } + + void buffer_sprites(void); + +protected: + virtual void device_start(); + virtual void device_reset(); + +private: + required_device<gfxdecode_device> m_gfxdecode; +}; + +extern const device_type FUUKI_VIDEO; + +#define MCFG_FUUKI_VIDEO_GFXDECODE(_gfxtag) \ + fuukivid_device::static_set_gfxdecode_tag(*device, "^" _gfxtag); + diff --git a/src/mame/video/fuukifg2.c b/src/mame/video/fuukifg2.c index 6279d0f8b5d..5d7a4e1381f 100644 --- a/src/mame/video/fuukifg2.c +++ b/src/mame/video/fuukifg2.c @@ -106,127 +106,6 @@ void fuuki16_state::video_start() } -/*************************************************************************** - - - Sprites Drawing - - Offset: Bits: Value: - - 0.w fedc ---- ---- ---- Number Of Tiles Along X - 1 - ---- b--- ---- ---- Flip X - ---- -a-- ---- ---- 1 = Don't Draw This Sprite - ---- --98 7654 3210 X (Signed) - - 2.w fedc ---- ---- ---- Number Of Tiles Along Y - 1 - ---- b--- ---- ---- Flip Y - ---- -a-- ---- ---- - ---- --98 7654 3210 Y (Signed) - - 4.w fedc ---- ---- ---- Zoom X ($0 = Full Size, $F = Half Size) - ---- ba98 ---- ---- Zoom Y "" - ---- ---- 76-- ---- Priority - ---- ---- --54 3210 Color - - 6.w Code - - -***************************************************************************/ - -void fuuki16_state::draw_sprites( screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect ) -{ - int offs; - gfx_element *gfx = m_gfxdecode->gfx(0); - bitmap_ind8 &priority_bitmap = screen.priority(); - const rectangle &visarea = screen.visible_area(); - UINT16 *spriteram16 = m_spriteram; - int max_x = visarea.max_x + 1; - int max_y = visarea.max_y + 1; - - /* Draw them backwards, for pdrawgfx */ - for ( offs = (m_spriteram.bytes() - 8) / 2; offs >=0; offs -= 8 / 2 ) - { - int x, y, xstart, ystart, xend, yend, xinc, yinc; - int xnum, ynum, xzoom, yzoom, flipx, flipy; - int pri_mask; - - int sx = spriteram16[offs + 0]; - int sy = spriteram16[offs + 1]; - int attr = spriteram16[offs + 2]; - int code = spriteram16[offs + 3]; - - if (sx & 0x400) - continue; - - flipx = sx & 0x0800; - flipy = sy & 0x0800; - - xnum = ((sx >> 12) & 0xf) + 1; - ynum = ((sy >> 12) & 0xf) + 1; - - xzoom = 16 * 8 - (8 * ((attr >> 12) & 0xf)) / 2; - yzoom = 16 * 8 - (8 * ((attr >> 8) & 0xf)) / 2; - - switch ((attr >> 6) & 3) - { - case 3: pri_mask = 0xf0 | 0xcc | 0xaa; break; // behind all layers - case 2: pri_mask = 0xf0 | 0xcc; break; // behind fg + middle layer - case 1: pri_mask = 0xf0; break; // behind fg layer - case 0: - default: pri_mask = 0; // above all - } - - sx = (sx & 0x1ff) - (sx & 0x200); - sy = (sy & 0x1ff) - (sy & 0x200); - - if (flip_screen()) - { - flipx = !flipx; sx = max_x - sx - xnum * 16; - flipy = !flipy; sy = max_y - sy - ynum * 16; - } - - if (flipx) { xstart = xnum-1; xend = -1; xinc = -1; } - else { xstart = 0; xend = xnum; xinc = +1; } - - if (flipy) { ystart = ynum-1; yend = -1; yinc = -1; } - else { ystart = 0; yend = ynum; yinc = +1; } - - for (y = ystart; y != yend; y += yinc) - { - for (x = xstart; x != xend; x += xinc) - { - if (xzoom == (16*8) && yzoom == (16*8)) - gfx->prio_transpen(bitmap,cliprect, - code++, - attr & 0x3f, - flipx, flipy, - sx + x * 16, sy + y * 16, - priority_bitmap, - pri_mask,15 ); - else - gfx->prio_zoom_transpen(bitmap,cliprect, - code++, - attr & 0x3f, - flipx, flipy, - sx + (x * xzoom) / 8, sy + (y * yzoom) / 8, - (0x10000/0x10/8) * (xzoom + 8),(0x10000/0x10/8) * (yzoom + 8), priority_bitmap,// nearest greater integer value to avoid holes - pri_mask,15 ); - } - } - -#ifdef MAME_DEBUG -#if 0 -if (machine().input().code_pressed(KEYCODE_X)) -{ /* Display some info on each sprite */ - char buf[40]; - sprintf(buf, "%Xx%X %X",xnum,ynum,(attr>>6)&3); - ui_draw_text(buf, sx, sy); -} -#endif -#endif - } -} - /*************************************************************************** @@ -339,7 +218,7 @@ UINT32 fuuki16_state::screen_update_fuuki16(screen_device &screen, bitmap_ind16 fuuki16_draw_layer(screen, bitmap, cliprect, tm_middle, 0, 2); fuuki16_draw_layer(screen, bitmap, cliprect, tm_front, 0, 4); - draw_sprites(screen, bitmap, cliprect); + m_fuukivid->draw_sprites(screen, bitmap, cliprect, flip_screen(), 0); return 0; } diff --git a/src/mame/video/fuukifg3.c b/src/mame/video/fuukifg3.c index d6f1c7e1947..1337c149d2a 100644 --- a/src/mame/video/fuukifg3.c +++ b/src/mame/video/fuukifg3.c @@ -90,11 +90,10 @@ WRITE32_MEMBER(fuuki32_state::fuuki32_vram_3_w){ fuuki32_vram_w(offset, data, me void fuuki32_state::video_start() { - m_buf_spriteram = auto_alloc_array(machine(), UINT32, m_spriteram.bytes() / 4); - m_buf_spriteram2 = auto_alloc_array(machine(), UINT32, m_spriteram.bytes() / 4); +// m_buf_spriteram = auto_alloc_array(machine(), UINT32, m_spriteram.bytes() / 4); +// m_buf_spriteram2 = auto_alloc_array(machine(), UINT32, m_spriteram.bytes() / 4); + - save_pointer(NAME(m_buf_spriteram), m_spriteram.bytes() / 4); - save_pointer(NAME(m_buf_spriteram2), m_spriteram.bytes() / 4); m_tilemap[0] = &machine().tilemap().create(m_gfxdecode, tilemap_get_info_delegate(FUNC(fuuki32_state::get_tile_info_0),this), TILEMAP_SCAN_ROWS, 16, 16, 64, 32); m_tilemap[1] = &machine().tilemap().create(m_gfxdecode, tilemap_get_info_delegate(FUNC(fuuki32_state::get_tile_info_1),this), TILEMAP_SCAN_ROWS, 16, 16, 64, 32); @@ -111,144 +110,6 @@ void fuuki32_state::video_start() } -/*************************************************************************** - - - Sprites Drawing - - Offset: Bits: Value: - - 0.w fedc ---- ---- ---- Number Of Tiles Along X - 1 - ---- b--- ---- ---- Flip X - ---- -a-- ---- ---- 1 = Don't Draw This Sprite - ---- --98 7654 3210 X (Signed) - - 2.w fedc ---- ---- ---- Number Of Tiles Along Y - 1 - ---- b--- ---- ---- Flip Y - ---- -a-- ---- ---- - ---- --98 7654 3210 Y (Signed) - - 4.w fedc ---- ---- ---- Zoom X ($0 = Full Size, $F = Half Size) - ---- ba98 ---- ---- Zoom Y "" - ---- ---- 76-- ---- Priority - ---- ---- --54 3210 Color - - 6.w fe-- ---- ---- ---- Tile Bank - --dc ba98 7654 3210 Tile Code - - -***************************************************************************/ - -void fuuki32_state::draw_sprites( screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect ) -{ - int offs; - gfx_element *gfx = m_gfxdecode->gfx(0); - bitmap_ind8 &priority_bitmap = screen.priority(); - const rectangle &visarea = screen.visible_area(); - int max_x = visarea.max_x + 1; - int max_y = visarea.max_y + 1; - - UINT32 *src = m_buf_spriteram2; /* Use spriteram buffered by 2 frames, need palette buffered by one frame? */ - - /* Draw them backwards, for pdrawgfx */ - for (offs = (m_spriteram.bytes() - 8) / 4; offs >= 0; offs -= 8/4) - { - int x, y, xstart, ystart, xend, yend, xinc, yinc; - int xnum, ynum, xzoom, yzoom, flipx, flipy; - int pri_mask; - - int sx = (src[offs + 0]& 0xffff0000) >> 16; - int sy = (src[offs + 0]& 0x0000ffff); - int attr = (src[offs + 1]& 0xffff0000) >> 16; - int code = (src[offs + 1]& 0x0000ffff); - - int bank = (code & 0xc000) >> 14; - int bank_lookedup; - - bank_lookedup = ((m_spr_buffered_tilebank[1] & 0xffff0000) >> (16 + bank * 4)) & 0xf; - code &= 0x3fff; - code += bank_lookedup * 0x4000; - - if (sx & 0x400) - continue; - - flipx = sx & 0x0800; - flipy = sy & 0x0800; - - xnum = ((sx >> 12) & 0xf) + 1; - ynum = ((sy >> 12) & 0xf) + 1; - - xzoom = 16 * 8 - (8 * ((attr >> 12) & 0xf)) / 2; - yzoom = 16 * 8 - (8 * ((attr >> 8) & 0xf)) / 2; - - switch( (attr >> 6) & 3 ) - { - case 3: pri_mask = 0xf0 | 0xcc | 0xaa; break; // behind all layers - case 2: pri_mask = 0xf0 | 0xcc; break; // behind fg + middle layer - case 1: pri_mask = 0xf0; break; // behind fg layer - case 0: - default: pri_mask = 0; // above all - } - - sx = (sx & 0x1ff) - (sx & 0x200); - sy = (sy & 0x1ff) - (sy & 0x200); - - if (flip_screen()) - { - flipx = !flipx; sx = max_x - sx - xnum * 16; - flipy = !flipy; sy = max_y - sy - ynum * 16; - } - - if (flipx) { xstart = xnum-1; xend = -1; xinc = -1; } - else { xstart = 0; xend = xnum; xinc = +1; } - - if (flipy) { ystart = ynum-1; yend = -1; yinc = -1; } - else { ystart = 0; yend = ynum; yinc = +1; } - -#if 0 - if(!( (screen.machine().input().code_pressed(KEYCODE_V) && (((attr >> 6)&3) == 0)) - || (screen.machine().input().code_pressed(KEYCODE_B) && (((attr >> 6)&3) == 1)) - || (screen.machine().input().code_pressed(KEYCODE_N) && (((attr >> 6)&3) == 2)) - || (screen.machine().input().code_pressed(KEYCODE_M) && (((attr >> 6)&3) == 3)) - )) -#endif - - for (y = ystart; y != yend; y += yinc) - { - for (x = xstart; x != xend; x += xinc) - { - if (xzoom == (16*8) && yzoom == (16*8)) - gfx->prio_transpen(bitmap,cliprect, - code++, - attr & 0x3f, - flipx, flipy, - sx + x * 16, sy + y * 16, - priority_bitmap, - pri_mask,15 ); - else - gfx->prio_zoom_transpen(bitmap,cliprect, - code++, - attr & 0x3f, - flipx, flipy, - sx + (x * xzoom) / 8, sy + (y * yzoom) / 8, - (0x10000/0x10/8) * (xzoom + 8),(0x10000/0x10/8) * (yzoom + 8), priority_bitmap,// nearest greater integer value to avoid holes - pri_mask,15 ); - } - } - -#ifdef MAME_DEBUG -#if 0 -if (screen.machine().input().code_pressed(KEYCODE_X)) -{ /* Display some info on each sprite */ - char buf[40]; - sprintf(buf, "%Xx%X %X",xnum,ynum,(attr>>6)&3); - ui_draw_text(buf, sx, sy); -} -#endif -#endif - } -} - /*************************************************************************** @@ -356,7 +217,7 @@ UINT32 fuuki32_state::screen_update_fuuki32(screen_device &screen, bitmap_ind16 fuuki32_draw_layer(screen, bitmap, cliprect, tm_middle, 0, 2); fuuki32_draw_layer(screen, bitmap, cliprect, tm_front, 0, 4); - draw_sprites(screen, bitmap, cliprect); + m_fuukivid->draw_sprites(screen, bitmap, cliprect, flip_screen(), m_spr_buffered_tilebank); return 0; } @@ -368,7 +229,6 @@ void fuuki32_state::screen_eof_fuuki32(screen_device &screen, bool state) /* Buffer sprites and tilebank by 2 frames */ m_spr_buffered_tilebank[1] = m_spr_buffered_tilebank[0]; m_spr_buffered_tilebank[0] = m_tilebank[0]; - memcpy(m_buf_spriteram2, m_buf_spriteram, m_spriteram.bytes()); - memcpy(m_buf_spriteram, m_spriteram, m_spriteram.bytes()); + m_fuukivid->buffer_sprites(); } } |