diff --git a/.gitattributes b/.gitattributes index 34eeb9f85a0..6bf0a064e83 100644 --- a/.gitattributes +++ b/.gitattributes @@ -7029,6 +7029,8 @@ src/mame/video/equites.c svneol=native#text/plain src/mame/video/esd16.c svneol=native#text/plain src/mame/video/espial.c svneol=native#text/plain src/mame/video/esripsys.c svneol=native#text/plain +src/mame/video/excellent_spr.c svneol=native#text/plain +src/mame/video/excellent_spr.h svneol=native#text/plain src/mame/video/exedexes.c svneol=native#text/plain src/mame/video/exerion.c svneol=native#text/plain src/mame/video/exidy.c svneol=native#text/plain diff --git a/src/mame/drivers/aquarium.c b/src/mame/drivers/aquarium.c index 7eb28fbed69..30bc254dda5 100644 --- a/src/mame/drivers/aquarium.c +++ b/src/mame/drivers/aquarium.c @@ -105,7 +105,7 @@ static ADDRESS_MAP_START( main_map, AS_PROGRAM, 16, aquarium_state ) AM_RANGE(0xc00000, 0xc00fff) AM_RAM_WRITE(aquarium_mid_videoram_w) AM_SHARE("mid_videoram") AM_RANGE(0xc01000, 0xc01fff) AM_RAM_WRITE(aquarium_bak_videoram_w) AM_SHARE("bak_videoram") AM_RANGE(0xc02000, 0xc03fff) AM_RAM_WRITE(aquarium_txt_videoram_w) AM_SHARE("txt_videoram") - AM_RANGE(0xc80000, 0xc81fff) AM_RAM AM_SHARE("spriteram") + AM_RANGE(0xc80000, 0xc81fff) AM_DEVREADWRITE8("spritegen", excellent_spr_device, read, write, 0x00ff) AM_RANGE(0xd00000, 0xd00fff) AM_RAM_DEVWRITE("palette", palette_device, write) AM_SHARE("palette") AM_RANGE(0xd80014, 0xd8001f) AM_WRITEONLY AM_SHARE("scroll") AM_RANGE(0xd80068, 0xd80069) AM_WRITENOP /* probably not used */ @@ -320,6 +320,8 @@ static MACHINE_CONFIG_START( aquarium, aquarium_state ) MCFG_PALETTE_ADD("palette", 0x1000/2) MCFG_PALETTE_FORMAT(RRRRGGGGBBBBRGBx) + MCFG_DEVICE_ADD("spritegen", EXCELLENT_SPRITE, 0) + /* sound hardware */ MCFG_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker") diff --git a/src/mame/drivers/gcpinbal.c b/src/mame/drivers/gcpinbal.c index 22c4e96a64c..16f2b39daec 100644 --- a/src/mame/drivers/gcpinbal.c +++ b/src/mame/drivers/gcpinbal.c @@ -32,7 +32,7 @@ Stephh's notes (based on the game M68000 code and some tests) : - Reset the game while pressing START1 to enter the "test mode" - + ***************************************************************************/ #include "emu.h" @@ -235,7 +235,7 @@ WRITE_LINE_MEMBER(gcpinbal_state::gcp_adpcm_int) static ADDRESS_MAP_START( gcpinbal_map, AS_PROGRAM, 16, gcpinbal_state ) AM_RANGE(0x000000, 0x1fffff) AM_ROM AM_RANGE(0xc00000, 0xc03fff) AM_READWRITE(gcpinbal_tilemaps_word_r, gcpinbal_tilemaps_word_w) AM_SHARE("tilemapram") - AM_RANGE(0xc80000, 0xc80fff) AM_RAM AM_SHARE("spriteram") /* sprite ram */ + AM_RANGE(0xc80000, 0xc81fff) AM_DEVREADWRITE8("spritegen", excellent_spr_device, read, write, 0x00ff) AM_RANGE(0xd00000, 0xd00fff) AM_RAM_DEVWRITE("palette", palette_device, write) AM_SHARE("palette") AM_RANGE(0xd80000, 0xd800ff) AM_READWRITE(ioc_r, ioc_w) AM_SHARE("ioc_ram") AM_RANGE(0xff0000, 0xffffff) AM_RAM /* RAM */ @@ -442,6 +442,8 @@ static MACHINE_CONFIG_START( gcpinbal, gcpinbal_state ) MCFG_PALETTE_ADD("palette", 4096) MCFG_PALETTE_FORMAT(RRRRGGGGBBBBRGBx) + MCFG_DEVICE_ADD("spritegen", EXCELLENT_SPRITE, 0) + /* sound hardware */ MCFG_SPEAKER_STANDARD_MONO("mono") diff --git a/src/mame/includes/aquarium.h b/src/mame/includes/aquarium.h index 3ae9c293bdf..033635a1c71 100644 --- a/src/mame/includes/aquarium.h +++ b/src/mame/includes/aquarium.h @@ -1,5 +1,5 @@ #include "sound/okim6295.h" - +#include "video/excellent_spr.h" class aquarium_state : public driver_device { @@ -9,19 +9,18 @@ public: m_mid_videoram(*this, "mid_videoram"), m_bak_videoram(*this, "bak_videoram"), m_txt_videoram(*this, "txt_videoram"), - m_spriteram(*this, "spriteram"), m_scroll(*this, "scroll"), m_audiocpu(*this, "audiocpu"), m_maincpu(*this, "maincpu"), m_oki(*this, "oki"), m_gfxdecode(*this, "gfxdecode"), - m_palette(*this, "palette") { } + m_palette(*this, "palette"), + m_sprgen(*this, "spritegen"){ } /* memory pointers */ required_shared_ptr m_mid_videoram; required_shared_ptr m_bak_videoram; required_shared_ptr m_txt_videoram; - required_shared_ptr m_spriteram; required_shared_ptr m_scroll; // UINT16 * m_paletteram; // currently this uses generic palette handling @@ -58,4 +57,6 @@ public: required_device m_oki; required_device m_gfxdecode; required_device m_palette; + required_device m_sprgen; + }; diff --git a/src/mame/includes/gcpinbal.h b/src/mame/includes/gcpinbal.h index 86904b1dfec..bd7569c36ae 100644 --- a/src/mame/includes/gcpinbal.h +++ b/src/mame/includes/gcpinbal.h @@ -1,6 +1,7 @@ #include "sound/okim6295.h" #include "sound/msm5205.h" +#include "video/excellent_spr.h" class gcpinbal_state : public driver_device { @@ -17,10 +18,10 @@ public: m_oki(*this, "oki"), m_msm(*this, "msm"), m_tilemapram(*this, "tilemapram"), - m_spriteram(*this, "spriteram"), m_ioc_ram(*this, "ioc_ram"), m_gfxdecode(*this, "gfxdecode"), - m_palette(*this, "palette") + m_palette(*this, "palette"), + m_sprgen(*this, "spritegen") { } /* devices */ @@ -30,7 +31,6 @@ public: /* memory pointers */ required_shared_ptr m_tilemapram; - required_shared_ptr m_spriteram; required_shared_ptr m_ioc_ram; required_device m_gfxdecode; @@ -74,6 +74,7 @@ public: void gcpinbal_core_vh_start( ); void draw_sprites( screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, int y_offs ); DECLARE_WRITE_LINE_MEMBER(gcp_adpcm_int); + required_device m_sprgen; protected: virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr); diff --git a/src/mame/mame.mak b/src/mame/mame.mak index fd064fa09c9..fecf6c7da53 100644 --- a/src/mame/mame.mak +++ b/src/mame/mame.mak @@ -1103,6 +1103,7 @@ $(MAMEOBJ)/excelent.a: \ $(DRIVERS)/d9final.o \ $(DRIVERS)/dblcrown.o \ $(DRIVERS)/gcpinbal.o $(VIDEO)/gcpinbal.o \ + $(VIDEO)/excellent_spr.o \ $(DRIVERS)/lastbank.o \ $(MAMEOBJ)/exidy.a: \ diff --git a/src/mame/video/aquarium.c b/src/mame/video/aquarium.c index a206ac3c1bc..0a5c5b896dc 100644 --- a/src/mame/video/aquarium.c +++ b/src/mame/video/aquarium.c @@ -3,86 +3,6 @@ #include "emu.h" #include "includes/aquarium.h" -/* gcpinbal.c modified */ -void aquarium_state::draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect, int y_offs ) -{ - int offs, chain_pos; - int x, y, curx, cury; - UINT8 col, flipx, flipy, chain; - UINT16 code; - - for (offs = 0; offs < m_spriteram.bytes() / 2; offs += 8) - { - code = ((m_spriteram[offs + 5]) & 0xff) + (((m_spriteram[offs + 6]) & 0xff) << 8); - code &= 0x3fff; - - if (!(m_spriteram[offs + 4] &0x80)) /* active sprite ? */ - { - x = ((m_spriteram[offs + 0]) &0xff) + (((m_spriteram[offs + 1]) & 0xff) << 8); - y = ((m_spriteram[offs + 2]) &0xff) + (((m_spriteram[offs + 3]) & 0xff) << 8); - - /* Treat coords as signed */ - if (x & 0x8000) x -= 0x10000; - if (y & 0x8000) y -= 0x10000; - - col = ((m_spriteram[offs + 7]) & 0x0f); - chain = (m_spriteram[offs + 4]) & 0x07; - flipy = (m_spriteram[offs + 4]) & 0x10; - flipx = (m_spriteram[offs + 4]) & 0x20; - - curx = x; - cury = y; - - if (((m_spriteram[offs + 4]) & 0x08) && flipy) - cury += (chain * 16); - - if (!(((m_spriteram[offs + 4]) & 0x08)) && flipx) - curx += (chain * 16); - - - for (chain_pos = chain; chain_pos >= 0; chain_pos--) - { - m_gfxdecode->gfx(0)->transpen(bitmap,cliprect, - code, - col, - flipx, flipy, - curx,cury,0); - - /* wrap around y */ - m_gfxdecode->gfx(0)->transpen(bitmap,cliprect, - code, - col, - flipx, flipy, - curx,cury + 256,0); - - code++; - - if ((m_spriteram[offs + 4]) &0x08) /* Y chain */ - { - if (flipy) - cury -= 16; - else - cury += 16; - } - else /* X chain */ - { - if (flipx) - curx -= 16; - else - curx += 16; - } - } - } - } -#if 0 - if (rotate) - { - char buf[80]; - sprintf(buf, "sprite rotate offs %04x ?", rotate); - popmessage(buf); - } -#endif -} /* TXT Layer */ TILE_GET_INFO_MEMBER(aquarium_state::get_aquarium_txt_tile_info) @@ -162,7 +82,7 @@ UINT32 aquarium_state::screen_update_aquarium(screen_device &screen, bitmap_ind1 m_bak_tilemap->draw(screen, bitmap, cliprect, 0, 0); m_mid_tilemap->draw(screen, bitmap, cliprect, 0, 0); - draw_sprites(bitmap, cliprect, 16); + m_sprgen->aquarium_draw_sprites(bitmap, cliprect, m_gfxdecode, 16); m_bak_tilemap->draw(screen, bitmap, cliprect, 1, 0); m_mid_tilemap->draw(screen, bitmap, cliprect, 1, 0); diff --git a/src/mame/video/excellent_spr.c b/src/mame/video/excellent_spr.c new file mode 100644 index 00000000000..1757d78efe4 --- /dev/null +++ b/src/mame/video/excellent_spr.c @@ -0,0 +1,221 @@ +/* + Excellent Systems Sprite chip + + is this original hw or a clone of something? + + possible chips: + ES 9207 & ES 9303 are near the sprite ROM (aquarium) + ES 9208 is near the tilemap ROM so probably not the sprite chip + + + todo: collapse to single draw function instead of one for each game + +*/ + + +#include "emu.h" +#include "excellent_spr.h" + + +const device_type EXCELLENT_SPRITE = &device_creator; + +excellent_spr_device::excellent_spr_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) + : device_t(mconfig, EXCELLENT_SPRITE, "Excllent 8-bit Sprite", tag, owner, clock, "excellent_spr", __FILE__), + device_video_interface(mconfig, *this) +{ +} + + +void excellent_spr_device::device_start() +{ + m_ram = auto_alloc_array_clear(this->machine(), UINT8, 0x1000); +} + + +READ8_MEMBER(excellent_spr_device::read) +{ + return m_ram[offset]; +} + +WRITE8_MEMBER(excellent_spr_device::write) +{ + m_ram[offset] = data; +} + +void excellent_spr_device::device_reset() +{ +} + + +/**************************************************************** + SPRITE DRAW ROUTINE + (8-bit) + + Word | Bit(s) | Use + -----+-----------------+----------------- + 0 | xxxxxxxx| X lo + 1 | xxxxxxxx| X hi + 2 | xxxxxxxx| Y lo + 3 | xxxxxxxx| Y hi + 4 | x.......| Disable + 4 | ...x....| Flip Y + 4 | ....x...| 1 = Y chain, 0 = X chain + 4 | .....xxx| Chain size + 5 | ??xxxxxx| Tile (low) + 6 | xxxxxxxx| Tile (high) + 7 | ....xxxx| Color Bank + +****************************************************************/ + + +void excellent_spr_device::aquarium_draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect, gfxdecode_device *gfxdecode, int y_offs ) +{ + + int offs, chain_pos; + int x, y, curx, cury; + UINT8 col, flipx, flipy, chain; + UINT16 code; + + for (offs = 0; offs < 0x1000; offs += 8) + { + code = ((m_ram[offs + 5]) & 0xff) + (((m_ram[offs + 6]) & 0xff) << 8); + code &= 0x3fff; + + if (!(m_ram[offs + 4] &0x80)) /* active sprite ? */ + { + x = ((m_ram[offs + 0]) &0xff) + (((m_ram[offs + 1]) & 0xff) << 8); + y = ((m_ram[offs + 2]) &0xff) + (((m_ram[offs + 3]) & 0xff) << 8); + + /* Treat coords as signed */ + if (x & 0x8000) x -= 0x10000; + if (y & 0x8000) y -= 0x10000; + + col = ((m_ram[offs + 7]) & 0x0f); + chain = (m_ram[offs + 4]) & 0x07; + flipy = (m_ram[offs + 4]) & 0x10; + flipx = (m_ram[offs + 4]) & 0x20; + + curx = x; + cury = y; + + if (((m_ram[offs + 4]) & 0x08) && flipy) + cury += (chain * 16); + + if (!(((m_ram[offs + 4]) & 0x08)) && flipx) + curx += (chain * 16); + + + for (chain_pos = chain; chain_pos >= 0; chain_pos--) + { + gfxdecode->gfx(0)->transpen(bitmap,cliprect, + code, + col, + flipx, flipy, + curx,cury,0); + + /* wrap around y */ + gfxdecode->gfx(0)->transpen(bitmap,cliprect, + code, + col, + flipx, flipy, + curx,cury + 256,0); + + code++; + + if ((m_ram[offs + 4]) &0x08) /* Y chain */ + { + if (flipy) + cury -= 16; + else + cury += 16; + } + else /* X chain */ + { + if (flipx) + curx -= 16; + else + curx += 16; + } + } + } + } + +#if 0 + if (rotate) + { + char buf[80]; + sprintf(buf, "sprite rotate offs %04x ?", rotate); + popmessage(buf); + } +#endif +} + +void excellent_spr_device::gcpinbal_draw_sprites( screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, gfxdecode_device *gfxdecode, int y_offs, int priority ) +{ + UINT8 *spriteram = m_ram; + int offs, chain_pos; + int x, y, curx, cury; +// int priority = 0; + UINT8 col, flipx, flipy, chain; + UINT16 code; + + + for (offs = 0x1000 - 8; offs >= 0; offs -= 8) + { + code = ((spriteram[offs + 5]) & 0xff) + (((spriteram[offs + 6]) & 0xff) << 8); + code &= 0x3fff; + + if (!(spriteram[offs + 4] &0x80)) /* active sprite ? */ + { + x = ((spriteram[offs + 0]) & 0xff) + (((spriteram[offs + 1]) & 0xff) << 8); + y = ((spriteram[offs + 2]) & 0xff) + (((spriteram[offs + 3]) & 0xff) << 8); + + /* Treat coords as signed */ + if (x & 0x8000) x -= 0x10000; + if (y & 0x8000) y -= 0x10000; + + col = ((spriteram[offs + 7]) & 0x0f) | 0x60; + chain = (spriteram[offs + 4]) & 0x07; + flipy = (spriteram[offs + 4]) & 0x10; + flipx = 0; + + curx = x; + cury = y; + + if (((spriteram[offs + 4]) & 0x08) && flipy) + cury += (chain * 16); + + for (chain_pos = chain; chain_pos >= 0; chain_pos--) + { + gfxdecode->gfx(0)->prio_transpen(bitmap,cliprect, + code, + col, + flipx, flipy, + curx,cury, + screen.priority(), + priority ? 0xfc : 0xf0,0); + + code++; + + if ((spriteram[offs + 4]) & 0x08) /* Y chain */ + { + if (flipy) cury -= 16; + else cury += 16; + } + else /* X chain */ + { + curx += 16; + } + } + } + } +#if 0 + if (rotate) + { + char buf[80]; + sprintf(buf, "sprite rotate offs %04x ?", rotate); + popmessage(buf); + } +#endif +} + diff --git a/src/mame/video/excellent_spr.h b/src/mame/video/excellent_spr.h new file mode 100644 index 00000000000..f28a5f0d98c --- /dev/null +++ b/src/mame/video/excellent_spr.h @@ -0,0 +1,26 @@ + +class excellent_spr_device : public device_t, + public device_video_interface +{ +public: + excellent_spr_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); + + void draw_sprites(screen_device &screen, gfxdecode_device *gfxdecode, const rectangle &cliprect); + + DECLARE_READ8_MEMBER(read); + DECLARE_WRITE8_MEMBER(write); + + void aquarium_draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, gfxdecode_device *gfxdecode, int y_offs); + void gcpinbal_draw_sprites(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, gfxdecode_device *gfxdecode, int y_offs, int priority); + +protected: + UINT8* m_ram; + + virtual void device_start(); + virtual void device_reset(); +private: +}; + +extern const device_type EXCELLENT_SPRITE; + + diff --git a/src/mame/video/gcpinbal.c b/src/mame/video/gcpinbal.c index a8578c63a3e..3f8cdbf10ba 100644 --- a/src/mame/video/gcpinbal.c +++ b/src/mame/video/gcpinbal.c @@ -87,152 +87,6 @@ WRITE16_MEMBER(gcpinbal_state::gcpinbal_tilemaps_word_w) } -#ifdef UNUSED_FUNCTION - -READ16_MEMBER(gcpinbal_state::gcpinbal_ctrl_word_r) -{ - // ***** NOT HOOKED UP ***** - - return gcpinbal_piv_ctrlram[offset]; -} - - -WRITE16_MEMBER(gcpinbal_state::gcpinbal_ctrl_word_w) -{ - // ***** NOT HOOKED UP ***** - - COMBINE_DATA(&gcpinbal_piv_ctrlram[offset]); - data = gcpinbal_piv_ctrlram[offset]; - - switch (offset) - { - case 0x00: - gcpinbal_scrollx[0] = -data; - break; - - case 0x01: - gcpinbal_scrollx[1] = -data; - break; - - case 0x02: - gcpinbal_scrollx[2] = -data; - break; - - case 0x03: - gcpinbal_scrolly[0] = data; - break; - - case 0x04: - gcpinbal_scrolly[1] = data; - break; - - case 0x05: - gcpinbal_scrolly[2] = data; - break; - - case 0x06: - gcpinbal_ctrl_reg = data; - break; - } -} - -#endif - - -/**************************************************************** - SPRITE DRAW ROUTINE - - Word | Bit(s) | Use - -----+-----------------+----------------- - 0 |........ xxxxxxxx| X lo - 1 |........ xxxxxxxx| X hi - 2 |........ xxxxxxxx| Y lo - 3 |........ xxxxxxxx| Y hi - 4 |........ x.......| Disable - 4 |........ ...x....| Flip Y - 4 |........ ....x...| 1 = Y chain, 0 = X chain - 4 |........ .....xxx| Chain size - 5 |........ ??xxxxxx| Tile (low) - 6 |........ xxxxxxxx| Tile (high) - 7 |........ ....xxxx| Color Bank - - Modified table from Raine - -****************************************************************/ - -void gcpinbal_state::draw_sprites( screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, int y_offs ) -{ - UINT16 *spriteram = m_spriteram; - int offs, chain_pos; - int x, y, curx, cury; - int priority = 0; - UINT8 col, flipx, flipy, chain; - UINT16 code; - - /* According to Raine, word in ioc_ram determines sprite/tile priority... */ - priority = (m_ioc_ram[0x68 / 2] & 0x8800) ? 0 : 1; - - for (offs = m_spriteram.bytes() / 2 - 8; offs >= 0; offs -= 8) - { - code = ((spriteram[offs + 5]) & 0xff) + (((spriteram[offs + 6]) & 0xff) << 8); - code &= 0x3fff; - - if (!(spriteram[offs + 4] &0x80)) /* active sprite ? */ - { - x = ((spriteram[offs + 0]) & 0xff) + (((spriteram[offs + 1]) & 0xff) << 8); - y = ((spriteram[offs + 2]) & 0xff) + (((spriteram[offs + 3]) & 0xff) << 8); - - /* Treat coords as signed */ - if (x & 0x8000) x -= 0x10000; - if (y & 0x8000) y -= 0x10000; - - col = ((spriteram[offs + 7]) & 0x0f) | 0x60; - chain = (spriteram[offs + 4]) & 0x07; - flipy = (spriteram[offs + 4]) & 0x10; - flipx = 0; - - curx = x; - cury = y; - - if (((spriteram[offs + 4]) & 0x08) && flipy) - cury += (chain * 16); - - for (chain_pos = chain; chain_pos >= 0; chain_pos--) - { - m_gfxdecode->gfx(0)->prio_transpen(bitmap,cliprect, - code, - col, - flipx, flipy, - curx,cury, - screen.priority(), - priority ? 0xfc : 0xf0,0); - - code++; - - if ((spriteram[offs + 4]) & 0x08) /* Y chain */ - { - if (flipy) cury -= 16; - else cury += 16; - } - else /* X chain */ - { - curx += 16; - } - } - } - } -#if 0 - if (rotate) - { - char buf[80]; - sprintf(buf, "sprite rotate offs %04x ?", rotate); - popmessage(buf); - } -#endif -} - - - /************************************************************** SCREEN REFRESH @@ -304,8 +158,8 @@ UINT32 gcpinbal_state::screen_update_gcpinbal(screen_device &screen, bitmap_ind1 #endif m_tilemap[layer[2]]->draw(screen, bitmap, cliprect, 0, 4); - - draw_sprites(screen, bitmap, cliprect, 16); + int sprpri = (m_ioc_ram[0x68 / 2] & 0x8800) ? 0 : 1; + m_sprgen->gcpinbal_draw_sprites(screen, bitmap, cliprect, m_gfxdecode, 16, sprpri); #if 0 {