diff --git a/.gitattributes b/.gitattributes index 10aab5d9736..905269ea7ad 100644 --- a/.gitattributes +++ b/.gitattributes @@ -3550,6 +3550,8 @@ src/mame/video/gomoku.c svneol=native#text/plain src/mame/video/gotcha.c svneol=native#text/plain src/mame/video/gottlieb.c svneol=native#text/plain src/mame/video/gotya.c svneol=native#text/plain +src/mame/video/gp9001.c svneol=native#text/plain +src/mame/video/gp9001.h svneol=native#text/plain src/mame/video/gradius3.c svneol=native#text/plain src/mame/video/grchamp.c svneol=native#text/plain src/mame/video/gridlee.c svneol=native#text/plain diff --git a/src/mame/drivers/toaplan2.c b/src/mame/drivers/toaplan2.c index 55b8ed9f0f6..fd7e8a30d0e 100644 --- a/src/mame/drivers/toaplan2.c +++ b/src/mame/drivers/toaplan2.c @@ -259,7 +259,7 @@ To Do / Unknowns: #include "sound/okim6295.h" #include "sound/ymz280b.h" #include "includes/toaplan2.h" - +#include "rendlay.h" /**************** Machine stuff ******************/ //#define USE_HD64x180 /* Define if CPU support is available */ @@ -301,101 +301,20 @@ static WRITE16_HANDLER( batsugun_share2_w ); -/* not used */ -static ADDRESS_MAP_START( toaplan2vdp_map, 0, 16 ) -ADDRESS_MAP_END - -class toaplan2vdp_device_config : public device_config, - public device_config_memory_interface -{ - friend class toaplan2vdp_device; - toaplan2vdp_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock); -public: - static device_config *static_alloc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock); - virtual device_t *alloc_device(running_machine &machine) const; -protected: - virtual void device_config_complete(); - virtual bool device_validity_check(const game_driver &driver) const; - virtual const address_space_config *memory_space_config(int spacenum = 0) const; - address_space_config m_space_config; -}; - -class toaplan2vdp_device : public device_t, - public device_memory_interface -{ - friend class toaplan2vdp_device_config; - toaplan2vdp_device(running_machine &_machine, const toaplan2vdp_device_config &config); -public: -protected: - virtual void device_start(); - virtual void device_reset(); - const toaplan2vdp_device_config &m_config; -}; - -const device_type toaplan2vdp_ = toaplan2vdp_device_config::static_alloc_device_config; - -toaplan2vdp_device_config::toaplan2vdp_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock) - : device_config(mconfig, static_alloc_device_config, "toaplan2vdp_", tag, owner, clock), - device_config_memory_interface(mconfig, *this), - m_space_config("toaplan2vdp", ENDIANNESS_BIG, 16,14, 0, NULL, *ADDRESS_MAP_NAME(toaplan2vdp_map)) -{ -} - -device_config *toaplan2vdp_device_config::static_alloc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock) -{ - return global_alloc(toaplan2vdp_device_config(mconfig, tag, owner, clock)); -} - -device_t *toaplan2vdp_device_config::alloc_device(running_machine &machine) const -{ - return auto_alloc(&machine, toaplan2vdp_device(machine, *this)); -} - -void toaplan2vdp_device_config::device_config_complete() -{ -// int address_bits = 14; -// m_space_config = address_space_config("toaplan2vdp", ENDIANNESS_BIG, 16, address_bits, 0, *ADDRESS_MAP_NAME(toaplan2vdp_map)); -} - -bool toaplan2vdp_device_config::device_validity_check(const game_driver &driver) const -{ - bool error = false; - return error; -} - -const address_space_config *toaplan2vdp_device_config::memory_space_config(int spacenum) const -{ - return (spacenum == 0) ? &m_space_config : NULL; -} - - -toaplan2vdp_device::toaplan2vdp_device(running_machine &_machine, const toaplan2vdp_device_config &config) - : device_t(_machine, config), - device_memory_interface(_machine, config, *this), - m_config(config) -{ -} - -void toaplan2vdp_device::device_start() -{ -} - -void toaplan2vdp_device::device_reset() -{ -} - -static running_device *sub_cpu = NULL; /*************************************************************************** Initialisation handlers ***************************************************************************/ +static running_device *sub_cpu = NULL; + static void toaplan2_reset(running_device *device) { if (sub_cpu != NULL) cpu_set_input_line(sub_cpu, INPUT_LINE_RESET, PULSE_LINE); } + static MACHINE_RESET( toaplan2 ) { mcu_data = 0x00; @@ -615,10 +534,7 @@ static DRIVER_INIT( bbakradu ) Toaplan games ***************************************************************************/ -static READ16_HANDLER( toaplan2_inputport_0_word_r ) -{ - return ((space->machine->primary_screen->vpos() + 15) % 262) >= 245; -} + static TIMER_CALLBACK( toaplan2_raise_irq ) @@ -1400,10 +1316,7 @@ static ADDRESS_MAP_START( tekipaki_68k_mem, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0x020000, 0x03ffff) AM_ROM /* extra for Whoopee */ AM_RANGE(0x080000, 0x082fff) AM_RAM AM_RANGE(0x0c0000, 0x0c0fff) AM_RAM_WRITE(paletteram16_xBBBBBGGGGGRRRRR_word_w) AM_BASE_GENERIC(paletteram) - AM_RANGE(0x140000, 0x140001) AM_WRITE(toaplan2_0_voffs_w) - AM_RANGE(0x140004, 0x140007) AM_READWRITE(toaplan2_0_videoram16_r, toaplan2_0_videoram16_w) /* Tile/Sprite VideoRAM */ - AM_RANGE(0x140008, 0x140009) AM_WRITE(toaplan2_0_scroll_reg_select_w) - AM_RANGE(0x14000c, 0x14000d) AM_READWRITE(toaplan2_inputport_0_word_r, toaplan2_0_scroll_reg_data_w) + AM_RANGE(0x140000, 0x14000d) AM_DEVREADWRITE("gp9001vdp0", gp9001_vdp_r, gp9001_vdp_w) AM_RANGE(0x180000, 0x180001) AM_READ_PORT("DSWA") AM_RANGE(0x180010, 0x180011) AM_READ_PORT("DSWB") AM_RANGE(0x180020, 0x180021) AM_READ_PORT("SYS") @@ -1421,10 +1334,7 @@ static ADDRESS_MAP_START( ghox_68k_mem, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0x080000, 0x083fff) AM_RAM AM_RANGE(0x0c0000, 0x0c0fff) AM_RAM_WRITE(paletteram16_xBBBBBGGGGGRRRRR_word_w) AM_BASE_GENERIC(paletteram) AM_RANGE(0x100000, 0x100001) AM_READ(ghox_p1_h_analog_r) /* Paddle 1 */ - AM_RANGE(0x140000, 0x140001) AM_WRITE(toaplan2_0_voffs_w) - AM_RANGE(0x140004, 0x140007) AM_READWRITE(toaplan2_0_videoram16_r, toaplan2_0_videoram16_w) /* Tile/Sprite VideoRAM */ - AM_RANGE(0x140008, 0x140009) AM_WRITE(toaplan2_0_scroll_reg_select_w) - AM_RANGE(0x14000c, 0x14000d) AM_READWRITE(toaplan2_inputport_0_word_r, toaplan2_0_scroll_reg_data_w) + AM_RANGE(0x140000, 0x14000d) AM_DEVREADWRITE("gp9001vdp0", gp9001_vdp_r, gp9001_vdp_w) AM_RANGE(0x180000, 0x180001) AM_READWRITE(ghox_mcu_r, ghox_mcu_w) /* really part of shared RAM */ AM_RANGE(0x180006, 0x180007) AM_READ_PORT("DSWA") AM_RANGE(0x180008, 0x180009) AM_READ_PORT("DSWB") @@ -1458,16 +1368,10 @@ static ADDRESS_MAP_START( dogyuun_68k_mem, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0x21fc00, 0x21ffff) AM_READWRITE(V25_sharedram_r, V25_sharedram_w) AM_BASE(&V25_shared_ram) /* 16-bit on 68000 side, 8-bit on V25+ side */ #endif /***** The following locations in 0x30000x are for video controller 1 ******/ - AM_RANGE(0x300000, 0x300001) AM_WRITE(toaplan2_0_voffs_w) /* VideoRAM selector/offset */ - AM_RANGE(0x300004, 0x300007) AM_READWRITE(toaplan2_0_videoram16_r, toaplan2_0_videoram16_w) /* Tile/Sprite VideoRAM */ - AM_RANGE(0x300008, 0x300009) AM_WRITE(toaplan2_0_scroll_reg_select_w) - AM_RANGE(0x30000c, 0x30000d) AM_READWRITE(toaplan2_inputport_0_word_r, toaplan2_0_scroll_reg_data_w) + AM_RANGE(0x300000, 0x30000d) AM_DEVREADWRITE("gp9001vdp0", gp9001_vdp_r, gp9001_vdp_w) AM_RANGE(0x400000, 0x400fff) AM_RAM_WRITE(paletteram16_xBBBBBGGGGGRRRRR_word_w) AM_BASE_GENERIC(paletteram) /***** The following loctions in 0x50000x are for video controller 2 ******/ - AM_RANGE(0x500000, 0x500001) AM_WRITE(toaplan2_1_voffs_w) /* VideoRAM selector/offset */ - AM_RANGE(0x500004, 0x500007) AM_READWRITE(toaplan2_1_videoram16_r, toaplan2_1_videoram16_w) /* Tile/Sprite VideoRAM */ - AM_RANGE(0x500008, 0x500009) AM_WRITE(toaplan2_1_scroll_reg_select_w) - AM_RANGE(0x50000c, 0x50000d) AM_WRITE(toaplan2_1_scroll_reg_data_w) + AM_RANGE(0x500000, 0x50000d) AM_DEVREADWRITE("gp9001vdp1", gp9001_vdp_r, gp9001_vdp_w) AM_RANGE(0x700000, 0x700001) AM_READ(video_count_r) /* test bit 8 */ ADDRESS_MAP_END @@ -1484,10 +1388,7 @@ static ADDRESS_MAP_START( kbash_68k_mem, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0x208014, 0x208015) AM_READ_PORT("IN2") AM_RANGE(0x208018, 0x208019) AM_READ_PORT("SYS") AM_RANGE(0x20801c, 0x20801d) AM_WRITE(toaplan2_coin_word_w) - AM_RANGE(0x300000, 0x300001) AM_WRITE(toaplan2_0_voffs_w) - AM_RANGE(0x300004, 0x300007) AM_READWRITE(toaplan2_0_videoram16_r, toaplan2_0_videoram16_w) /* Tile/Sprite VideoRAM */ - AM_RANGE(0x300008, 0x300009) AM_WRITE(toaplan2_0_scroll_reg_select_w) - AM_RANGE(0x30000c, 0x30000d) AM_READWRITE(toaplan2_inputport_0_word_r, toaplan2_0_scroll_reg_data_w) /* VBlank */ + AM_RANGE(0x300000, 0x30000d) AM_DEVREADWRITE("gp9001vdp0", gp9001_vdp_r, gp9001_vdp_w) AM_RANGE(0x400000, 0x400fff) AM_RAM_WRITE(paletteram16_xBBBBBGGGGGRRRRR_word_w) AM_BASE_GENERIC(paletteram) AM_RANGE(0x700000, 0x700001) AM_READ(video_count_r) /* test bit 8 */ ADDRESS_MAP_END @@ -1509,10 +1410,7 @@ static ADDRESS_MAP_START( kbash2_68k_mem, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0x200024, 0x200025) AM_DEVREADWRITE8("oki1", okim6295_r, okim6295_w, 0x00ff) AM_RANGE(0x200028, 0x200029) AM_DEVWRITE("oki1", oki_bankswitch_w) AM_RANGE(0x20002c, 0x20002d) AM_READ(video_count_r) - AM_RANGE(0x300000, 0x300001) AM_WRITE(toaplan2_0_voffs_w) /* VideoRAM selector/offset */ - AM_RANGE(0x300004, 0x300007) AM_READWRITE(toaplan2_0_videoram16_r, toaplan2_0_videoram16_w) /* Tile/Sprite VideoRAM */ - AM_RANGE(0x300008, 0x300009) AM_WRITE(toaplan2_0_scroll_reg_select_w) - AM_RANGE(0x30000c, 0x30000d) AM_READWRITE(toaplan2_inputport_0_word_r, toaplan2_0_scroll_reg_data_w) + AM_RANGE(0x300000, 0x30000d) AM_DEVREADWRITE("gp9001vdp0", gp9001_vdp_r, gp9001_vdp_w) AM_RANGE(0x400000, 0x400fff) AM_RAM_WRITE(paletteram16_xBBBBBGGGGGRRRRR_word_w) AM_BASE_GENERIC(paletteram) ADDRESS_MAP_END @@ -1520,10 +1418,7 @@ ADDRESS_MAP_END static ADDRESS_MAP_START( truxton2_68k_mem, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0x000000, 0x07ffff) AM_ROM AM_RANGE(0x100000, 0x10ffff) AM_RAM - AM_RANGE(0x200000, 0x200001) AM_WRITE(toaplan2_0_voffs_w) - AM_RANGE(0x200004, 0x200007) AM_READWRITE(toaplan2_0_videoram16_r, toaplan2_0_videoram16_w) - AM_RANGE(0x200008, 0x200009) AM_WRITE(toaplan2_0_scroll_reg_select_w) - AM_RANGE(0x20000c, 0x20000d) AM_READWRITE(toaplan2_inputport_0_word_r, toaplan2_0_scroll_reg_data_w) + AM_RANGE(0x200000, 0x20000d) AM_DEVREADWRITE("gp9001vdp0", gp9001_vdp_r, gp9001_vdp_w) AM_RANGE(0x300000, 0x300fff) AM_RAM_WRITE(paletteram16_xBBBBBGGGGGRRRRR_word_w) AM_BASE_GENERIC(paletteram) AM_RANGE(0x400000, 0x401fff) AM_READWRITE(toaplan2_txvideoram16_r, toaplan2_txvideoram16_w) AM_BASE(&toaplan2_txvideoram16) AM_SIZE(&toaplan2_tx_vram_size) AM_RANGE(0x402000, 0x4021ff) AM_READWRITE(toaplan2_txvideoram16_offs_r, toaplan2_txvideoram16_offs_w) AM_BASE(&toaplan2_txvideoram16_offs) AM_SIZE(&toaplan2_tx_offs_vram_size) @@ -1548,10 +1443,8 @@ static ADDRESS_MAP_START( pipibibs_68k_mem, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0x000000, 0x03ffff) AM_ROM AM_RANGE(0x080000, 0x082fff) AM_RAM AM_RANGE(0x0c0000, 0x0c0fff) AM_RAM_WRITE(paletteram16_xBBBBBGGGGGRRRRR_word_w) AM_BASE_GENERIC(paletteram) - AM_RANGE(0x140000, 0x140001) AM_WRITE(toaplan2_0_voffs_w) - AM_RANGE(0x140004, 0x140007) AM_READWRITE(toaplan2_0_videoram16_r, toaplan2_0_videoram16_w) - AM_RANGE(0x140008, 0x140009) AM_WRITE(toaplan2_0_scroll_reg_select_w) - AM_RANGE(0x14000c, 0x14000d) AM_READWRITE(toaplan2_inputport_0_word_r, toaplan2_0_scroll_reg_data_w) + AM_RANGE(0x140000, 0x14000d) AM_DEVREADWRITE("gp9001vdp0", gp9001_vdp_r, gp9001_vdp_w) + AM_RANGE(0x190000, 0x190fff) AM_READWRITE(toaplan2_shared_r, toaplan2_shared_w) AM_RANGE(0x19c01c, 0x19c01d) AM_WRITE(toaplan2_coin_word_w) /* Coin count/lock */ AM_RANGE(0x19c020, 0x19c021) AM_READ_PORT("DSWA") @@ -1562,17 +1455,17 @@ static ADDRESS_MAP_START( pipibibs_68k_mem, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0x19c034, 0x19c035) AM_READ_PORT("IN2") ADDRESS_MAP_END - -static ADDRESS_MAP_START( pipibibi_68k_mem, ADDRESS_SPACE_PROGRAM, 16 ) +// odd scroll registers +static ADDRESS_MAP_START( pipibibi_bootleg_68k_mem, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0x000000, 0x03ffff) AM_ROM AM_RANGE(0x080000, 0x082fff) AM_RAM - AM_RANGE(0x083000, 0x0837ff) AM_READWRITE(pipibibi_spriteram16_r, pipibibi_spriteram16_w) /* SpriteRAM */ + AM_RANGE(0x083000, 0x0837ff) AM_DEVREADWRITE("gp9001vdp0", pipibibi_bootleg_spriteram16_r, pipibibi_bootleg_spriteram16_w) /* SpriteRAM */ AM_RANGE(0x083800, 0x087fff) AM_RAM /* SpriteRAM (unused) */ AM_RANGE(0x0c0000, 0x0c0fff) AM_RAM_WRITE(paletteram16_xBBBBBGGGGGRRRRR_word_w) AM_BASE_GENERIC(paletteram) AM_RANGE(0x120000, 0x120fff) AM_RAM /* Copy of SpriteRAM ? */ // AM_RANGE(0x13f000, 0x13f001) AM_WRITENOP /* ??? */ - AM_RANGE(0x180000, 0x182fff) AM_READWRITE(pipibibi_videoram16_r, pipibibi_videoram16_w) /* TileRAM */ - AM_RANGE(0x188000, 0x18800f) AM_WRITE(pipibibi_scroll_w) + AM_RANGE(0x180000, 0x182fff) AM_DEVREADWRITE("gp9001vdp0", pipibibi_bootleg_videoram16_r, pipibibi_bootleg_videoram16_w ) /* TileRAM */ + AM_RANGE(0x188000, 0x18800f) AM_DEVWRITE("gp9001vdp0", pipibibi_bootleg_scroll_w) AM_RANGE(0x190002, 0x190003) AM_READ(pipibibi_z80_status_r) /* Z80 ready ? */ AM_RANGE(0x190010, 0x190011) AM_WRITE(pipibibi_z80_task_w) /* Z80 task to perform */ AM_RANGE(0x19c01c, 0x19c01d) AM_WRITE(toaplan2_coin_word_w) /* Coin count/lock */ @@ -1619,10 +1512,7 @@ static ADDRESS_MAP_START( fixeight_68k_mem, ADDRESS_SPACE_PROGRAM, 16 ) // AM_RANGE(0x28f00a, 0x28fbff) AM_READONLY /* part of shared ram */ AM_RANGE(0x28fc00, 0x28ffff) AM_READWRITE(V25_sharedram_r, V25_sharedram_w) AM_BASE(&V25_shared_ram) /* 16-bit on 68000 side, 8-bit on V25+ side */ #endif - AM_RANGE(0x300000, 0x300001) AM_WRITE(toaplan2_0_voffs_w) /* VideoRAM selector/offset */ - AM_RANGE(0x300004, 0x300007) AM_READWRITE(toaplan2_0_videoram16_r, toaplan2_0_videoram16_w) /* Tile/Sprite VideoRAM */ - AM_RANGE(0x300008, 0x300009) AM_WRITE(toaplan2_0_scroll_reg_select_w) - AM_RANGE(0x30000c, 0x30000d) AM_READWRITE(toaplan2_inputport_0_word_r, toaplan2_0_scroll_reg_data_w) + AM_RANGE(0x300000, 0x30000d) AM_DEVREADWRITE("gp9001vdp0", gp9001_vdp_r, gp9001_vdp_w) AM_RANGE(0x400000, 0x400fff) AM_RAM_WRITE(paletteram16_xBBBBBGGGGGRRRRR_word_w) AM_BASE_GENERIC(paletteram) AM_RANGE(0x500000, 0x501fff) AM_READWRITE(toaplan2_txvideoram16_r, toaplan2_txvideoram16_w) AM_BASE(&toaplan2_txvideoram16) AM_SIZE(&toaplan2_tx_vram_size) AM_RANGE(0x502000, 0x5021ff) AM_READWRITE(toaplan2_txvideoram16_offs_r, toaplan2_txvideoram16_offs_w) AM_BASE(&toaplan2_txvideoram16_offs) AM_SIZE(&toaplan2_tx_offs_vram_size) @@ -1643,10 +1533,7 @@ static ADDRESS_MAP_START( fixeighb_68k_mem, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0x200014, 0x200015) AM_DEVWRITE("oki", fixeighb_oki_bankswitch_w) /* Sound banking. Code at $4084c, $5070 */ AM_RANGE(0x200018, 0x200019) AM_DEVREADWRITE8("oki", okim6295_r, okim6295_w, 0x00ff) AM_RANGE(0x20001c, 0x20001d) AM_READ_PORT("DSWA") - AM_RANGE(0x300000, 0x300001) AM_WRITE(toaplan2_0_voffs_w) /* VideoRAM selector/offset */ - AM_RANGE(0x300004, 0x300007) AM_READWRITE(toaplan2_0_videoram16_r, toaplan2_0_videoram16_w) /* Tile/Sprite VideoRAM */ - AM_RANGE(0x300008, 0x300009) AM_WRITE(toaplan2_0_scroll_reg_select_w) - AM_RANGE(0x30000c, 0x30000d) AM_READWRITE(toaplan2_inputport_0_word_r, toaplan2_0_scroll_reg_data_w) + AM_RANGE(0x300000, 0x30000d) AM_DEVREADWRITE("gp9001vdp0", gp9001_vdp_r, gp9001_vdp_w) AM_RANGE(0x400000, 0x400fff) AM_RAM_WRITE(paletteram16_xBBBBBGGGGGRRRRR_word_w) AM_BASE_GENERIC(paletteram) AM_RANGE(0x500000, 0x501fff) AM_READWRITE(toaplan2_txvideoram16_r, toaplan2_txvideoram16_w) AM_BASE(&toaplan2_txvideoram16) AM_SIZE(&toaplan2_tx_vram_size) AM_RANGE(0x502000, 0x5021ff) AM_READWRITE(toaplan2_txvideoram16_offs_r, toaplan2_txvideoram16_offs_w) AM_BASE(&toaplan2_txvideoram16_offs) AM_SIZE(&toaplan2_tx_offs_vram_size) @@ -1677,10 +1564,7 @@ static ADDRESS_MAP_START( vfive_68k_mem, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0x21f008, 0x21f009) AM_READ_PORT("JMPR") AM_RANGE(0x21fc00, 0x21ffff) AM_READWRITE(V25_sharedram_r, V25_sharedram_w) AM_BASE(&V25_shared_ram) /* 16-bit on 68000 side, 8-bit on V25+ side */ #endif - AM_RANGE(0x300000, 0x300001) AM_WRITE(toaplan2_0_voffs_w) /* VideoRAM selector/offset */ - AM_RANGE(0x300004, 0x300007) AM_READWRITE(toaplan2_0_videoram16_r, toaplan2_0_videoram16_w) /* Tile/Sprite VideoRAM */ - AM_RANGE(0x300008, 0x300009) AM_WRITE(toaplan2_0_scroll_reg_select_w) - AM_RANGE(0x30000c, 0x30000d) AM_READWRITE(toaplan2_inputport_0_word_r, toaplan2_0_scroll_reg_data_w) + AM_RANGE(0x300000, 0x30000d) AM_DEVREADWRITE("gp9001vdp0", gp9001_vdp_r, gp9001_vdp_w) AM_RANGE(0x400000, 0x400fff) AM_RAM_WRITE(paletteram16_xBBBBBGGGGGRRRRR_word_w) AM_BASE_GENERIC(paletteram) AM_RANGE(0x700000, 0x700001) AM_READ(video_count_r) ADDRESS_MAP_END @@ -1753,16 +1637,10 @@ static ADDRESS_MAP_START( batsugun_68k_mem, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0x210000, 0x21ffff) AM_READWRITE( batsugun_share_r, batsugun_share_w ) /***** The following in 0x30000x are for video controller 1 ******/ - AM_RANGE(0x300000, 0x300001) AM_WRITE(toaplan2_0_voffs_w) /* VideoRAM selector/offset */ - AM_RANGE(0x300004, 0x300007) AM_READWRITE(toaplan2_0_videoram16_r, toaplan2_0_videoram16_w) /* Tile/Sprite VideoRAM */ - AM_RANGE(0x300008, 0x300009) AM_WRITE(toaplan2_0_scroll_reg_select_w) - AM_RANGE(0x30000c, 0x30000d) AM_READWRITE(toaplan2_inputport_0_word_r, toaplan2_0_scroll_reg_data_w) /* VBlank */ + AM_RANGE(0x300000, 0x30000d) AM_DEVREADWRITE("gp9001vdp0", gp9001_vdp_r, gp9001_vdp_w) AM_RANGE(0x400000, 0x400fff) AM_RAM_WRITE(paletteram16_xBBBBBGGGGGRRRRR_word_w) AM_BASE_GENERIC(paletteram) /***** The following in 0x50000x are for video controller 2 ******/ - AM_RANGE(0x500000, 0x500001) AM_WRITE(toaplan2_1_voffs_w) /* VideoRAM selector/offset */ - AM_RANGE(0x500004, 0x500007) AM_READWRITE(toaplan2_1_videoram16_r, toaplan2_1_videoram16_w) /* Tile/Sprite VideoRAM */ - AM_RANGE(0x500008, 0x500009) AM_WRITE(toaplan2_1_scroll_reg_select_w) - AM_RANGE(0x50000c, 0x50000d) AM_WRITE(toaplan2_1_scroll_reg_data_w) + AM_RANGE(0x500000, 0x50000d) AM_DEVREADWRITE("gp9001vdp1", gp9001_vdp_r, gp9001_vdp_w) AM_RANGE(0x700000, 0x700001) AM_READ(video_count_r) ADDRESS_MAP_END @@ -1770,10 +1648,7 @@ ADDRESS_MAP_END static ADDRESS_MAP_START( snowbro2_68k_mem, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0x000000, 0x07ffff) AM_ROM AM_RANGE(0x100000, 0x10ffff) AM_RAM - AM_RANGE(0x300000, 0x300001) AM_WRITE(toaplan2_0_voffs_w) /* VideoRAM selector/offset */ - AM_RANGE(0x300004, 0x300007) AM_READWRITE(toaplan2_0_videoram16_r, toaplan2_0_videoram16_w) /* Tile/Sprite VideoRAM */ - AM_RANGE(0x300008, 0x300009) AM_WRITE(toaplan2_0_scroll_reg_select_w) - AM_RANGE(0x30000c, 0x30000d) AM_READWRITE(toaplan2_inputport_0_word_r, toaplan2_0_scroll_reg_data_w) /* VBlank */ + AM_RANGE(0x300000, 0x30000d) AM_DEVREADWRITE("gp9001vdp0", gp9001_vdp_r, gp9001_vdp_w) AM_RANGE(0x400000, 0x400fff) AM_RAM_WRITE(paletteram16_xBBBBBGGGGGRRRRR_word_w) AM_BASE_GENERIC(paletteram) AM_RANGE(0x500000, 0x500003) AM_DEVREADWRITE8("ymsnd", ym2151_r, ym2151_w, 0x00ff) AM_RANGE(0x600000, 0x600001) AM_DEVREADWRITE8("oki", okim6295_r, okim6295_w, 0x00ff) @@ -1802,10 +1677,7 @@ static ADDRESS_MAP_START( mahoudai_68k_mem, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0x21c030, 0x21c031) AM_READ_PORT("DSWB") AM_RANGE(0x21c034, 0x21c035) AM_READ_PORT("JMPR") AM_RANGE(0x21c03c, 0x21c03d) AM_READ(video_count_r) - AM_RANGE(0x300000, 0x300001) AM_WRITE(toaplan2_0_voffs_w) - AM_RANGE(0x300004, 0x300007) AM_READWRITE(toaplan2_0_videoram16_r, toaplan2_0_videoram16_w) /* Tile/Sprite VideoRAM */ - AM_RANGE(0x300008, 0x300009) AM_WRITE(toaplan2_0_scroll_reg_select_w) - AM_RANGE(0x30000c, 0x30000d) AM_READWRITE(toaplan2_inputport_0_word_r, toaplan2_0_scroll_reg_data_w) /* VBlank */ + AM_RANGE(0x300000, 0x30000d) AM_DEVREADWRITE("gp9001vdp0", gp9001_vdp_r, gp9001_vdp_w) AM_RANGE(0x400000, 0x400fff) AM_RAM_WRITE(paletteram16_xBBBBBGGGGGRRRRR_word_w) AM_BASE_GENERIC(paletteram) AM_RANGE(0x401000, 0x4017ff) AM_RAM /* Unused PaletteRAM */ AM_RANGE(0x500000, 0x501fff) AM_READWRITE(toaplan2_txvideoram16_r, toaplan2_txvideoram16_w) AM_BASE(&toaplan2_txvideoram16) AM_SIZE(&toaplan2_tx_vram_size) @@ -1829,10 +1701,7 @@ static ADDRESS_MAP_START( shippumd_68k_mem, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0x21c030, 0x21c031) AM_READ_PORT("DSWB") AM_RANGE(0x21c034, 0x21c035) AM_READ_PORT("JMPR") AM_RANGE(0x21c03c, 0x21c03d) AM_READ(video_count_r) - AM_RANGE(0x300000, 0x300001) AM_WRITE(toaplan2_0_voffs_w) - AM_RANGE(0x300004, 0x300007) AM_READWRITE(toaplan2_0_videoram16_r, toaplan2_0_videoram16_w) /* Tile/Sprite VideoRAM */ - AM_RANGE(0x300008, 0x300009) AM_WRITE(toaplan2_0_scroll_reg_select_w) - AM_RANGE(0x30000c, 0x30000d) AM_READWRITE(toaplan2_inputport_0_word_r, toaplan2_0_scroll_reg_data_w) /* VBlank */ + AM_RANGE(0x300000, 0x30000d) AM_DEVREADWRITE("gp9001vdp0", gp9001_vdp_r, gp9001_vdp_w) AM_RANGE(0x400000, 0x400fff) AM_RAM_WRITE(paletteram16_xBBBBBGGGGGRRRRR_word_w) AM_BASE_GENERIC(paletteram) AM_RANGE(0x401000, 0x4017ff) AM_RAM /* Unused PaletteRAM */ AM_RANGE(0x500000, 0x501fff) AM_READWRITE(toaplan2_txvideoram16_r, toaplan2_txvideoram16_w) AM_BASE(&toaplan2_txvideoram16) AM_SIZE(&toaplan2_tx_vram_size) @@ -1855,10 +1724,7 @@ static ADDRESS_MAP_START( bgaregga_68k_mem, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0x21c030, 0x21c031) AM_READ_PORT("DSWB") AM_RANGE(0x21c034, 0x21c035) AM_READ_PORT("JMPR") AM_RANGE(0x21c03c, 0x21c03d) AM_READ(video_count_r) - AM_RANGE(0x300000, 0x300001) AM_WRITE(toaplan2_0_voffs_w) - AM_RANGE(0x300004, 0x300007) AM_READWRITE(toaplan2_0_videoram16_r, toaplan2_0_videoram16_w) /* Tile/Sprite VideoRAM */ - AM_RANGE(0x300008, 0x300009) AM_WRITE(toaplan2_0_scroll_reg_select_w) - AM_RANGE(0x30000c, 0x30000d) AM_READWRITE(toaplan2_inputport_0_word_r, toaplan2_0_scroll_reg_data_w) /* VBlank */ + AM_RANGE(0x300000, 0x30000d) AM_DEVREADWRITE("gp9001vdp0", gp9001_vdp_r, gp9001_vdp_w) AM_RANGE(0x400000, 0x400fff) AM_RAM_WRITE(paletteram16_xBBBBBGGGGGRRRRR_word_w) AM_BASE_GENERIC(paletteram) AM_RANGE(0x500000, 0x501fff) AM_READWRITE(toaplan2_txvideoram16_r, toaplan2_txvideoram16_w) AM_BASE(&toaplan2_txvideoram16) AM_SIZE(&toaplan2_tx_vram_size) AM_RANGE(0x502000, 0x5021ff) AM_READWRITE(toaplan2_txvideoram16_offs_r, toaplan2_txvideoram16_offs_w) AM_BASE(&toaplan2_txvideoram16_offs) AM_SIZE(&toaplan2_tx_offs_vram_size) @@ -1878,10 +1744,7 @@ static ADDRESS_MAP_START( batrider_68k_mem, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0x203400, 0x207fff) AM_READWRITE(raizing_tx_gfxram16_r, raizing_tx_gfxram16_w) /* Main RAM actually */ AM_RANGE(0x208000, 0x20ffff) AM_RAM AM_RANGE(0x300000, 0x37ffff) AM_READ(raizing_z80rom_r) - AM_RANGE(0x400000, 0x400001) AM_READWRITE(toaplan2_inputport_0_word_r, toaplan2_0_scroll_reg_data_w) /* VBlank */ - AM_RANGE(0x400004, 0x400005) AM_WRITE(toaplan2_0_scroll_reg_select_w) - AM_RANGE(0x400008, 0x40000b) AM_READWRITE(toaplan2_0_videoram16_r, toaplan2_0_videoram16_w) /* Tile/Sprite VideoRAM */ - AM_RANGE(0x40000c, 0x40000d) AM_WRITE(toaplan2_0_voffs_w) + AM_RANGE(0x400000, 0x40000d) AM_DEVREADWRITE("gp9001vdp0", gp9001_vdp_alt_r, gp9001_vdp_alt_w) AM_RANGE(0x500000, 0x500001) AM_READ_PORT("IN") AM_RANGE(0x500002, 0x500003) AM_READ_PORT("SYS-DSW") AM_RANGE(0x500004, 0x500005) AM_READ_PORT("DSW") @@ -1909,10 +1772,7 @@ static ADDRESS_MAP_START( bbakraid_68k_mem, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0x203400, 0x207fff) AM_READWRITE(raizing_tx_gfxram16_r, raizing_tx_gfxram16_w) /* Main RAM actually */ AM_RANGE(0x208000, 0x20ffff) AM_RAM AM_RANGE(0x300000, 0x33ffff) AM_READ(raizing_z80rom_r) - AM_RANGE(0x400000, 0x400001) AM_READWRITE(toaplan2_inputport_0_word_r, toaplan2_0_scroll_reg_data_w) /* VBlank */ - AM_RANGE(0x400004, 0x400005) AM_WRITE(toaplan2_0_scroll_reg_select_w) - AM_RANGE(0x400008, 0x40000b) AM_READWRITE(toaplan2_0_videoram16_r, toaplan2_0_videoram16_w) /* Tile/Sprite VideoRAM */ - AM_RANGE(0x40000c, 0x40000d) AM_WRITE(toaplan2_0_voffs_w) + AM_RANGE(0x400000, 0x40000d) AM_DEVREADWRITE("gp9001vdp0", gp9001_vdp_alt_r, gp9001_vdp_alt_w) AM_RANGE(0x500000, 0x500001) AM_READ_PORT("IN") AM_RANGE(0x500002, 0x500003) AM_READ_PORT("SYS-DSW") AM_RANGE(0x500004, 0x500005) AM_READ_PORT("DSW") @@ -3866,56 +3726,11 @@ static const ymz280b_interface ymz280b_config = }; - - - -static ADDRESS_MAP_START( toaplan2vdp0_map, 0, 16 ) - AM_RANGE(0x0000, 0x0fff) AM_READWRITE(toaplan2_bg_tilemap_r, toaplan2_bg_tilemap_w) - AM_RANGE(0x1000, 0x1fff) AM_READWRITE(toaplan2_fg_tilemap_r, toaplan2_fg_tilemap_w) - AM_RANGE(0x2000, 0x2fff) AM_READWRITE(toaplan2_top_tilemap_r, toaplan2_top_tilemap_w) - AM_RANGE(0x3000, 0x37ff) AM_READWRITE(toaplan2_spram_r, toaplan2_spram_w) - AM_RANGE(0x3800, 0x3fff) AM_RAM // sprite mirror? -ADDRESS_MAP_END - -static ADDRESS_MAP_START( toaplan2vdp1_map, 0, 16 ) - AM_RANGE(0x0000, 0x0fff) AM_READWRITE(toaplan2_bg_tilemap1_r, toaplan2_bg_tilemap1_w) - AM_RANGE(0x1000, 0x1fff) AM_READWRITE(toaplan2_fg_tilemap1_r, toaplan2_fg_tilemap1_w) - AM_RANGE(0x2000, 0x2fff) AM_READWRITE(toaplan2_top_tilemap1_r, toaplan2_top_tilemap1_w) - AM_RANGE(0x3000, 0x37ff) AM_READWRITE(toaplan2_spram1_r, toaplan2_spram1_w) - AM_RANGE(0x3800, 0x3fff) AM_RAM // sprite mirror? -ADDRESS_MAP_END - - -int toaplan2_videoram16_r(running_machine* machine, offs_t offset, int controller) -{ - int offs = (toaplan2_voffs[controller] &0x1fff); - toaplan2_voffs[controller]++; - - const address_space *vdp_space; - - if (controller==0) vdp_space = machine->device("toaplan2vdp0")->space(); - else vdp_space = machine->device("toaplan2vdp1")->space(); - - return memory_read_word_16be(vdp_space, offs*2); -} - - -void toaplan2_videoram16_w(running_machine* machine, offs_t offset, UINT16 data, UINT16 mem_mask, int controller) -{ - int offs = (toaplan2_voffs[controller] &0x1fff); - toaplan2_voffs[controller]++; - - const address_space *vdp_space; - - if (controller==0) vdp_space = machine->device("toaplan2vdp0")->space(); - else vdp_space = machine->device("toaplan2vdp1")->space(); - - memory_write_word_masked_16be(vdp_space, offs*2, data, mem_mask); -} - - static MACHINE_DRIVER_START( tekipaki ) + /* driver data */ + MDRV_DRIVER_DATA(toaplan2_state) + /* basic machine hardware */ MDRV_CPU_ADD("maincpu", M68000, XTAL_10MHz) /* 10MHz Oscillator */ MDRV_CPU_PROGRAM_MAP(tekipaki_68k_mem) @@ -3941,13 +3756,12 @@ static MACHINE_DRIVER_START( tekipaki ) MDRV_PALETTE_LENGTH(0x10000) // we encode priority with colour in the tilemaps, so need a larger palette - MDRV_DEVICE_ADD("toaplan2vdp0", toaplan2vdp_, 0) - MDRV_DEVICE_ADDRESS_MAP(0, toaplan2vdp0_map) + MDRV_DEVICE_ADD_VDP0 - MDRV_VIDEO_START(toaplan2_0) - MDRV_VIDEO_EOF(toaplan2_0) - MDRV_VIDEO_UPDATE(toaplan2_0) + MDRV_VIDEO_START(toaplan2) + MDRV_VIDEO_EOF(toaplan2) + MDRV_VIDEO_UPDATE(toaplan2) /* sound hardware */ MDRV_SPEAKER_STANDARD_MONO("mono") @@ -3960,6 +3774,9 @@ MACHINE_DRIVER_END static MACHINE_DRIVER_START( ghox ) + /* driver data */ + MDRV_DRIVER_DATA(toaplan2_state) + /* basic machine hardware */ MDRV_CPU_ADD("maincpu", M68000, XTAL_10MHz) /* verified on pcb */ MDRV_CPU_PROGRAM_MAP(ghox_68k_mem) @@ -3984,12 +3801,11 @@ static MACHINE_DRIVER_START( ghox ) MDRV_GFXDECODE(toaplan2) MDRV_PALETTE_LENGTH(0x10000) // we encode priority with colour in the tilemaps, so need a larger palette - MDRV_DEVICE_ADD("toaplan2vdp0", toaplan2vdp_, 0) - MDRV_DEVICE_ADDRESS_MAP(0, toaplan2vdp0_map) + MDRV_DEVICE_ADD_VDP0 - MDRV_VIDEO_START(toaplan2_0) - MDRV_VIDEO_EOF(toaplan2_0) - MDRV_VIDEO_UPDATE(toaplan2_0) + MDRV_VIDEO_START(toaplan2) + MDRV_VIDEO_EOF(toaplan2) + MDRV_VIDEO_UPDATE(toaplan2) /* sound hardware */ MDRV_SPEAKER_STANDARD_MONO("mono") @@ -4026,6 +3842,9 @@ static const nec_config ts002mach_config ={ ts002mach_decryption_table, }; static MACHINE_DRIVER_START( dogyuun ) + /* driver data */ + MDRV_DRIVER_DATA(toaplan2_state) + /* basic machine hardware */ MDRV_CPU_ADD("maincpu", M68000, XTAL_25MHz/2) /* verified on pcb */ MDRV_CPU_PROGRAM_MAP(dogyuun_68k_mem) @@ -4046,19 +3865,25 @@ static MACHINE_DRIVER_START( dogyuun ) MDRV_SCREEN_SIZE(432, 262) MDRV_SCREEN_VISIBLE_AREA(0, 319, 0, 239) +#ifdef DUAL_SCREEN_VDPS + MDRV_SCREEN_ADD("screen2", RASTER) + MDRV_SCREEN_REFRESH_RATE(60) + MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16) + MDRV_SCREEN_SIZE(432, 262) + MDRV_SCREEN_VISIBLE_AREA(0, 319, 0, 239) + + MDRV_DEFAULT_LAYOUT(layout_dualhsxs) +#endif + MDRV_GFXDECODE(2) MDRV_PALETTE_LENGTH(0x10000) // we encode priority with colour in the tilemaps, so need a larger palette - MDRV_DEVICE_ADD("toaplan2vdp0", toaplan2vdp_, 0) - MDRV_DEVICE_ADDRESS_MAP(0, toaplan2vdp0_map) - MDRV_DEVICE_ADD("toaplan2vdp1", toaplan2vdp_, 0) - MDRV_DEVICE_ADDRESS_MAP(0, toaplan2vdp1_map) + MDRV_DEVICE_ADD_VDP0 + MDRV_DEVICE_ADD_VDP1 - - - MDRV_VIDEO_START(toaplan2_1) - MDRV_VIDEO_EOF(toaplan2_1) - MDRV_VIDEO_UPDATE(dogyuun_1) + MDRV_VIDEO_START(toaplan2) + MDRV_VIDEO_EOF(toaplan2) + MDRV_VIDEO_UPDATE(dogyuun) /* sound hardware */ MDRV_SPEAKER_STANDARD_MONO("mono") @@ -4119,6 +3944,9 @@ static MACHINE_RESET(kbash) static MACHINE_DRIVER_START( kbash ) + /* driver data */ + MDRV_DRIVER_DATA(toaplan2_state) + /* basic machine hardware */ MDRV_CPU_ADD("maincpu", M68000, XTAL_16MHz) /* 16MHz Oscillator */ MDRV_CPU_PROGRAM_MAP(kbash_68k_mem) @@ -4145,12 +3973,11 @@ static MACHINE_DRIVER_START( kbash ) MDRV_GFXDECODE(toaplan2) MDRV_PALETTE_LENGTH(0x10000) // we encode priority with colour in the tilemaps, so need a larger palette - MDRV_DEVICE_ADD("toaplan2vdp0", toaplan2vdp_, 0) - MDRV_DEVICE_ADDRESS_MAP(0, toaplan2vdp0_map) + MDRV_DEVICE_ADD_VDP0 - MDRV_VIDEO_START(toaplan2_0) - MDRV_VIDEO_EOF(toaplan2_0) - MDRV_VIDEO_UPDATE(toaplan2_0) + MDRV_VIDEO_START(toaplan2) + MDRV_VIDEO_EOF(toaplan2) + MDRV_VIDEO_UPDATE(toaplan2) /* sound hardware */ MDRV_SPEAKER_STANDARD_MONO("mono") @@ -4164,6 +3991,10 @@ MACHINE_DRIVER_END static MACHINE_DRIVER_START( kbash2 ) + + /* driver data */ + MDRV_DRIVER_DATA(toaplan2_state) + /* basic machine hardware */ MDRV_CPU_ADD("maincpu", M68000, XTAL_16MHz) /* 16MHz Oscillator */ MDRV_CPU_PROGRAM_MAP(kbash2_68k_mem) @@ -4183,12 +4014,11 @@ static MACHINE_DRIVER_START( kbash2 ) MDRV_GFXDECODE(toaplan2) MDRV_PALETTE_LENGTH(0x10000) // we encode priority with colour in the tilemaps, so need a larger palette - MDRV_DEVICE_ADD("toaplan2vdp0", toaplan2vdp_, 0) - MDRV_DEVICE_ADDRESS_MAP(0, toaplan2vdp0_map) + MDRV_DEVICE_ADD_VDP0 - MDRV_VIDEO_START(toaplan2_0) - MDRV_VIDEO_EOF(toaplan2_0) - MDRV_VIDEO_UPDATE(toaplan2_0) + MDRV_VIDEO_START(toaplan2) + MDRV_VIDEO_EOF(toaplan2) + MDRV_VIDEO_UPDATE(toaplan2) /* sound hardware */ MDRV_SPEAKER_STANDARD_MONO("mono") @@ -4203,6 +4033,9 @@ MACHINE_DRIVER_END static MACHINE_DRIVER_START( truxton2 ) + /* driver data */ + MDRV_DRIVER_DATA(toaplan2_state) + /* basic machine hardware */ MDRV_CPU_ADD("maincpu", M68000, XTAL_16MHz) /* verified on pcb */ MDRV_CPU_PROGRAM_MAP(truxton2_68k_mem) @@ -4222,12 +4055,11 @@ static MACHINE_DRIVER_START( truxton2 ) MDRV_GFXDECODE(truxton2) MDRV_PALETTE_LENGTH(0x10000) // we encode priority with colour in the tilemaps, so need a larger palette - MDRV_DEVICE_ADD("toaplan2vdp0", toaplan2vdp_, 0) - MDRV_DEVICE_ADDRESS_MAP(0, toaplan2vdp0_map) + MDRV_DEVICE_ADD_VDP0 - MDRV_VIDEO_START(truxton2_0) - MDRV_VIDEO_EOF(toaplan2_0) - MDRV_VIDEO_UPDATE(truxton2_0) + MDRV_VIDEO_START(truxton2) + MDRV_VIDEO_EOF(toaplan2) + MDRV_VIDEO_UPDATE(truxton2) /* sound hardware */ MDRV_SPEAKER_STANDARD_MONO("mono") @@ -4242,6 +4074,9 @@ MACHINE_DRIVER_END static MACHINE_DRIVER_START( pipibibs ) + /* driver data */ + MDRV_DRIVER_DATA(toaplan2_state) + /* basic machine hardware */ MDRV_CPU_ADD("maincpu", M68000, XTAL_10MHz) /* verified on pcb */ MDRV_CPU_PROGRAM_MAP(pipibibs_68k_mem) @@ -4266,12 +4101,11 @@ static MACHINE_DRIVER_START( pipibibs ) MDRV_GFXDECODE(toaplan2) MDRV_PALETTE_LENGTH(0x10000) // we encode priority with colour in the tilemaps, so need a larger palette - MDRV_DEVICE_ADD("toaplan2vdp0", toaplan2vdp_, 0) - MDRV_DEVICE_ADDRESS_MAP(0, toaplan2vdp0_map) + MDRV_DEVICE_ADD_VDP0 - MDRV_VIDEO_START(toaplan2_0) - MDRV_VIDEO_EOF(toaplan2_0) - MDRV_VIDEO_UPDATE(toaplan2_0) + MDRV_VIDEO_START(toaplan2) + MDRV_VIDEO_EOF(toaplan2) + MDRV_VIDEO_UPDATE(toaplan2) /* sound hardware */ MDRV_SPEAKER_STANDARD_MONO("mono") @@ -4284,6 +4118,9 @@ MACHINE_DRIVER_END static MACHINE_DRIVER_START( whoopee ) + /* driver data */ + MDRV_DRIVER_DATA(toaplan2_state) + /* basic machine hardware */ MDRV_CPU_ADD("maincpu", M68000, XTAL_10MHz) /* 10MHz Oscillator */ MDRV_CPU_PROGRAM_MAP(tekipaki_68k_mem) @@ -4308,12 +4145,11 @@ static MACHINE_DRIVER_START( whoopee ) MDRV_GFXDECODE(toaplan2) MDRV_PALETTE_LENGTH(0x10000) // we encode priority with colour in the tilemaps, so need a larger palette - MDRV_DEVICE_ADD("toaplan2vdp0", toaplan2vdp_, 0) - MDRV_DEVICE_ADDRESS_MAP(0, toaplan2vdp0_map) + MDRV_DEVICE_ADD_VDP0 - MDRV_VIDEO_START(toaplan2_0) - MDRV_VIDEO_EOF(toaplan2_0) - MDRV_VIDEO_UPDATE(toaplan2_0) + MDRV_VIDEO_START(toaplan2) + MDRV_VIDEO_EOF(toaplan2) + MDRV_VIDEO_UPDATE(toaplan2) /* sound hardware */ MDRV_SPEAKER_STANDARD_MONO("mono") @@ -4324,11 +4160,14 @@ static MACHINE_DRIVER_START( whoopee ) MACHINE_DRIVER_END -static MACHINE_DRIVER_START( pipibibi ) +static MACHINE_DRIVER_START( pipibibi_bootleg ) + + /* driver data */ + MDRV_DRIVER_DATA(toaplan2_state) /* basic machine hardware */ MDRV_CPU_ADD("maincpu", M68000, XTAL_10MHz) /* 10MHz Oscillator */ - MDRV_CPU_PROGRAM_MAP(pipibibi_68k_mem) + MDRV_CPU_PROGRAM_MAP(pipibibi_bootleg_68k_mem) MDRV_CPU_VBLANK_INT("screen", toaplan2_vblank_irq4) MDRV_CPU_ADD("audiocpu", Z80, XTAL_27MHz/8) /* ??? 3.37MHz */ @@ -4350,12 +4189,11 @@ static MACHINE_DRIVER_START( pipibibi ) MDRV_GFXDECODE(toaplan2) MDRV_PALETTE_LENGTH(0x10000) // we encode priority with colour in the tilemaps, so need a larger palette - MDRV_DEVICE_ADD("toaplan2vdp0", toaplan2vdp_, 0) - MDRV_DEVICE_ADDRESS_MAP(0, toaplan2vdp0_map) + MDRV_DEVICE_ADD_VDP0 - MDRV_VIDEO_START(toaplan2_0) - MDRV_VIDEO_EOF(toaplan2_0) - MDRV_VIDEO_UPDATE(toaplan2_0) + MDRV_VIDEO_START(toaplan2) + MDRV_VIDEO_EOF(toaplan2) + MDRV_VIDEO_UPDATE(toaplan2) /* sound hardware */ MDRV_SPEAKER_STANDARD_MONO("mono") @@ -4394,6 +4232,9 @@ static const nec_config ts001turbo_config ={ ts001turbo_decryption_table, }; static MACHINE_DRIVER_START( fixeight ) + /* driver data */ + MDRV_DRIVER_DATA(toaplan2_state) + /* basic machine hardware */ MDRV_CPU_ADD("maincpu", M68000, XTAL_16MHz) /* verified on pcb */ MDRV_CPU_PROGRAM_MAP(fixeight_68k_mem) @@ -4421,12 +4262,11 @@ static MACHINE_DRIVER_START( fixeight ) MDRV_GFXDECODE(truxton2) MDRV_PALETTE_LENGTH(0x10000) // we encode priority with colour in the tilemaps, so need a larger palette - MDRV_DEVICE_ADD("toaplan2vdp0", toaplan2vdp_, 0) - MDRV_DEVICE_ADDRESS_MAP(0, toaplan2vdp0_map) + MDRV_DEVICE_ADD_VDP0 - MDRV_VIDEO_START(truxton2_0) - MDRV_VIDEO_EOF(toaplan2_0) - MDRV_VIDEO_UPDATE(truxton2_0) + MDRV_VIDEO_START(truxton2) + MDRV_VIDEO_EOF(toaplan2) + MDRV_VIDEO_UPDATE(truxton2) /* sound hardware */ MDRV_SPEAKER_STANDARD_MONO("mono") @@ -4440,6 +4280,10 @@ MACHINE_DRIVER_END static MACHINE_DRIVER_START( fixeighb ) + + /* driver data */ + MDRV_DRIVER_DATA(toaplan2_state) + /* basic machine hardware */ MDRV_CPU_ADD("maincpu", M68000, XTAL_10MHz) /* 10MHz Oscillator */ MDRV_CPU_PROGRAM_MAP(fixeighb_68k_mem) @@ -4459,12 +4303,11 @@ static MACHINE_DRIVER_START( fixeighb ) MDRV_GFXDECODE(fixeighb) MDRV_PALETTE_LENGTH(0x10000) // we encode priority with colour in the tilemaps, so need a larger palette - MDRV_DEVICE_ADD("toaplan2vdp0", toaplan2vdp_, 0) - MDRV_DEVICE_ADDRESS_MAP(0, toaplan2vdp0_map) + MDRV_DEVICE_ADD_VDP0 - MDRV_VIDEO_START(truxton2_0) - MDRV_VIDEO_EOF(toaplan2_0) - MDRV_VIDEO_UPDATE(truxton2_0) + MDRV_VIDEO_START(truxton2) + MDRV_VIDEO_EOF(toaplan2) + MDRV_VIDEO_UPDATE(truxton2) /* sound hardware */ MDRV_SPEAKER_STANDARD_MONO("mono") @@ -4507,6 +4350,9 @@ static const nec_config ts007spy_vfive_config ={ ts007spy_vfive_decryption_table static MACHINE_DRIVER_START( vfive ) + /* driver data */ + MDRV_DRIVER_DATA(toaplan2_state) + /* basic machine hardware */ MDRV_CPU_ADD("maincpu", M68000, XTAL_20MHz/2) /* verified on pcb */ MDRV_CPU_PROGRAM_MAP(vfive_68k_mem) @@ -4527,15 +4373,14 @@ static MACHINE_DRIVER_START( vfive ) MDRV_SCREEN_SIZE(432, 262) MDRV_SCREEN_VISIBLE_AREA(0, 319, 0, 239) - MDRV_DEVICE_ADD("toaplan2vdp0", toaplan2vdp_, 0) - MDRV_DEVICE_ADDRESS_MAP(0, toaplan2vdp0_map) + MDRV_DEVICE_ADD_VDP0 MDRV_GFXDECODE(toaplan2) MDRV_PALETTE_LENGTH(0x10000) // we encode priority with colour in the tilemaps, so need a larger palette - MDRV_VIDEO_START(toaplan2_0) - MDRV_VIDEO_EOF(toaplan2_0) - MDRV_VIDEO_UPDATE(toaplan2_0) + MDRV_VIDEO_START(toaplan2) + MDRV_VIDEO_EOF(toaplan2) + MDRV_VIDEO_UPDATE(toaplan2) /* sound hardware */ MDRV_SPEAKER_STANDARD_MONO("mono") @@ -4598,6 +4443,9 @@ static const nmk112_interface batrider_nmk112_intf = static MACHINE_DRIVER_START( batsugun ) + /* driver data */ + MDRV_DRIVER_DATA(toaplan2_state) + /* basic machine hardware */ MDRV_CPU_ADD("maincpu", M68000, XTAL_32MHz/2) /* 16MHz , 32MHz Oscillator */ MDRV_CPU_PROGRAM_MAP(batsugun_68k_mem) @@ -4620,17 +4468,25 @@ static MACHINE_DRIVER_START( batsugun ) MDRV_SCREEN_SIZE(432, 262) MDRV_SCREEN_VISIBLE_AREA(0, 319, 0, 239) +#ifdef DUAL_SCREEN_VDPS + MDRV_SCREEN_ADD("screen2", RASTER) + MDRV_SCREEN_REFRESH_RATE(60) + MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16) + MDRV_SCREEN_SIZE(432, 262) + MDRV_SCREEN_VISIBLE_AREA(0, 319, 0, 239) + + MDRV_DEFAULT_LAYOUT(layout_dualhsxs) +#endif + MDRV_GFXDECODE(2) MDRV_PALETTE_LENGTH(0x10000) // we encode priority with colour in the tilemaps, so need a larger palette - MDRV_DEVICE_ADD("toaplan2vdp0", toaplan2vdp_, 0) - MDRV_DEVICE_ADDRESS_MAP(0, toaplan2vdp0_map) - MDRV_DEVICE_ADD("toaplan2vdp1", toaplan2vdp_, 0) - MDRV_DEVICE_ADDRESS_MAP(0, toaplan2vdp1_map) + MDRV_DEVICE_ADD_VDP0 + MDRV_DEVICE_ADD_VDP1 - MDRV_VIDEO_START(toaplan2_1) - MDRV_VIDEO_EOF(toaplan2_1) - MDRV_VIDEO_UPDATE(batsugun_1) + MDRV_VIDEO_START(toaplan2) + MDRV_VIDEO_EOF(toaplan2) + MDRV_VIDEO_UPDATE(batsugun) /* sound hardware */ MDRV_SPEAKER_STANDARD_MONO("mono") @@ -4646,6 +4502,9 @@ MACHINE_DRIVER_END static MACHINE_DRIVER_START( snowbro2 ) + /* driver data */ + MDRV_DRIVER_DATA(toaplan2_state) + /* basic machine hardware */ MDRV_CPU_ADD("maincpu", M68000, XTAL_16MHz) MDRV_CPU_PROGRAM_MAP(snowbro2_68k_mem) @@ -4665,12 +4524,11 @@ static MACHINE_DRIVER_START( snowbro2 ) MDRV_GFXDECODE(toaplan2) MDRV_PALETTE_LENGTH(0x10000) // we encode priority with colour in the tilemaps, so need a larger palette - MDRV_DEVICE_ADD("toaplan2vdp0", toaplan2vdp_, 0) - MDRV_DEVICE_ADDRESS_MAP(0, toaplan2vdp0_map) + MDRV_DEVICE_ADD_VDP0 - MDRV_VIDEO_START(toaplan2_0) - MDRV_VIDEO_EOF(toaplan2_0) - MDRV_VIDEO_UPDATE(toaplan2_0) + MDRV_VIDEO_START(toaplan2) + MDRV_VIDEO_EOF(toaplan2) + MDRV_VIDEO_UPDATE(toaplan2) /* sound hardware */ MDRV_SPEAKER_STANDARD_MONO("mono") @@ -4685,6 +4543,9 @@ MACHINE_DRIVER_END static MACHINE_DRIVER_START( mahoudai ) + /* driver data */ + MDRV_DRIVER_DATA(toaplan2_state) + /* basic machine hardware */ MDRV_CPU_ADD("maincpu", M68000, XTAL_32MHz/2) /* 16MHz , 32MHz Oscillator */ MDRV_CPU_PROGRAM_MAP(mahoudai_68k_mem) @@ -4709,12 +4570,11 @@ static MACHINE_DRIVER_START( mahoudai ) MDRV_GFXDECODE(raizing) MDRV_PALETTE_LENGTH(0x10000) // we encode priority with colour in the tilemaps, so need a larger palette - MDRV_DEVICE_ADD("toaplan2vdp0", toaplan2vdp_, 0) - MDRV_DEVICE_ADDRESS_MAP(0, toaplan2vdp0_map) + MDRV_DEVICE_ADD_VDP0 - MDRV_VIDEO_START(bgaregga_0) - MDRV_VIDEO_EOF(toaplan2_0) - MDRV_VIDEO_UPDATE(mahoudai_0) + MDRV_VIDEO_START(bgaregga) + MDRV_VIDEO_EOF(toaplan2) + MDRV_VIDEO_UPDATE(truxton2) /* sound hardware */ MDRV_SPEAKER_STANDARD_MONO("mono") @@ -4729,6 +4589,9 @@ MACHINE_DRIVER_END static MACHINE_DRIVER_START( shippumd ) + /* driver data */ + MDRV_DRIVER_DATA(toaplan2_state) + /* basic machine hardware */ MDRV_CPU_ADD("maincpu", M68000, XTAL_32MHz/2) /* 16MHz , 32MHz Oscillator */ MDRV_CPU_PROGRAM_MAP(shippumd_68k_mem) @@ -4750,15 +4613,14 @@ static MACHINE_DRIVER_START( shippumd ) MDRV_SCREEN_SIZE(432, 262) MDRV_SCREEN_VISIBLE_AREA(0, 319, 0, 239) - MDRV_DEVICE_ADD("toaplan2vdp0", toaplan2vdp_, 0) - MDRV_DEVICE_ADDRESS_MAP(0, toaplan2vdp0_map) + MDRV_DEVICE_ADD_VDP0 MDRV_GFXDECODE(raizing) MDRV_PALETTE_LENGTH(0x10000) // we encode priority with colour in the tilemaps, so need a larger palette - MDRV_VIDEO_START(bgaregga_0) - MDRV_VIDEO_EOF(toaplan2_0) - MDRV_VIDEO_UPDATE(truxton2_0) + MDRV_VIDEO_START(bgaregga) + MDRV_VIDEO_EOF(toaplan2) + MDRV_VIDEO_UPDATE(truxton2) /* sound hardware */ MDRV_SPEAKER_STANDARD_MONO("mono") @@ -4773,6 +4635,9 @@ MACHINE_DRIVER_END static MACHINE_DRIVER_START( bgaregga ) + /* driver data */ + MDRV_DRIVER_DATA(toaplan2_state) + /* basic machine hardware */ MDRV_CPU_ADD("maincpu", M68000, XTAL_32MHz/2) /* 16MHz , 32MHz Oscillator */ MDRV_CPU_PROGRAM_MAP(bgaregga_68k_mem) @@ -4797,12 +4662,11 @@ static MACHINE_DRIVER_START( bgaregga ) MDRV_GFXDECODE(raizing) MDRV_PALETTE_LENGTH(0x10000) // we encode priority with colour in the tilemaps, so need a larger palette - MDRV_DEVICE_ADD("toaplan2vdp0", toaplan2vdp_, 0) - MDRV_DEVICE_ADDRESS_MAP(0, toaplan2vdp0_map) + MDRV_DEVICE_ADD_VDP0 - MDRV_VIDEO_START(bgaregga_0) - MDRV_VIDEO_EOF(toaplan2_0) - MDRV_VIDEO_UPDATE(truxton2_0) + MDRV_VIDEO_START(bgaregga) + MDRV_VIDEO_EOF(toaplan2) + MDRV_VIDEO_UPDATE(truxton2) /* sound hardware */ MDRV_SPEAKER_STANDARD_MONO("mono") @@ -4819,6 +4683,9 @@ MACHINE_DRIVER_END static MACHINE_DRIVER_START( batrider ) + /* driver data */ + MDRV_DRIVER_DATA(toaplan2_state) + /* basic machine hardware */ MDRV_CPU_ADD("maincpu", M68000, XTAL_32MHz/2) /* 16MHz , 32MHz Oscillator */ MDRV_CPU_PROGRAM_MAP(batrider_68k_mem) @@ -4844,11 +4711,10 @@ static MACHINE_DRIVER_START( batrider ) MDRV_GFXDECODE(batrider) MDRV_PALETTE_LENGTH(0x10000) // we encode priority with colour in the tilemaps, so need a larger palette - MDRV_DEVICE_ADD("toaplan2vdp0", toaplan2vdp_, 0) - MDRV_DEVICE_ADDRESS_MAP(0, toaplan2vdp0_map) - - MDRV_VIDEO_START(batrider_0) - MDRV_VIDEO_UPDATE(batrider_0) + MDRV_DEVICE_ADD_VDP0 + + MDRV_VIDEO_START(batrider) + MDRV_VIDEO_UPDATE(batrider) /* sound hardware */ MDRV_SPEAKER_STANDARD_MONO("mono") @@ -4867,6 +4733,9 @@ MACHINE_DRIVER_END static MACHINE_DRIVER_START( bbakraid ) + /* driver data */ + MDRV_DRIVER_DATA(toaplan2_state) + /* basic machine hardware */ MDRV_CPU_ADD("maincpu", M68000, XTAL_32MHz/2) /* 16MHz , 32MHz Oscillator */ MDRV_CPU_PROGRAM_MAP(bbakraid_68k_mem) @@ -4894,11 +4763,10 @@ static MACHINE_DRIVER_START( bbakraid ) MDRV_GFXDECODE(batrider) MDRV_PALETTE_LENGTH(0x10000) // we encode priority with colour in the tilemaps, so need a larger palette - MDRV_DEVICE_ADD("toaplan2vdp0", toaplan2vdp_, 0) - MDRV_DEVICE_ADDRESS_MAP(0, toaplan2vdp0_map) + MDRV_DEVICE_ADD_VDP0 - MDRV_VIDEO_START(batrider_0) - MDRV_VIDEO_UPDATE(batrider_0) + MDRV_VIDEO_START(batrider) + MDRV_VIDEO_UPDATE(batrider) /* sound hardware */ MDRV_SPEAKER_STANDARD_MONO("mono") @@ -6004,7 +5872,7 @@ GAME( 1992, truxton2, 0, truxton2, truxton2, T2_noZ80, ROT270, "Toaplan", GAME( 1991, pipibibs, 0, pipibibs, pipibibs, T2_Z80, ROT0, "Toaplan", "Pipi & Bibis / Whoopee!! (Z80 sound cpu, set 1)", GAME_SUPPORTS_SAVE ) GAME( 1991, pipibibsa,pipibibs, pipibibs, pipibibs, T2_Z80, ROT0, "Toaplan", "Pipi & Bibis / Whoopee!! (Z80 sound cpu, set 2)", GAME_SUPPORTS_SAVE ) GAME( 1991, whoopee, pipibibs, whoopee, whoopee, T2_Z180, ROT0, "Toaplan", "Pipi & Bibis / Whoopee!! (Whoopee!! board)", GAME_NO_SOUND | GAME_SUPPORTS_SAVE ) // original Whoopee!! boards have a HD647180 instead of Z80 -GAME( 1991, pipibibi, pipibibs, pipibibi, pipibibi, pipibibi, ROT0, "bootleg? (Ryouta Kikaku)", "Pipi & Bibis / Whoopee!! (bootleg?)", GAME_SUPPORTS_SAVE ) +GAME( 1991, pipibibi, pipibibs, pipibibi_bootleg, pipibibi, pipibibi, ROT0, "bootleg? (Ryouta Kikaku)", "Pipi & Bibis / Whoopee!! (bootleg?)", GAME_SUPPORTS_SAVE ) GAME( 1992, fixeight, 0, fixeight, fixeight, fixeight, ROT270, "Toaplan", "FixEight", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS | GAME_NOT_WORKING | GAME_SUPPORTS_SAVE ) GAME( 1992, fixeightb,fixeight, fixeighb, fixeighb, fixeighb, ROT270, "bootleg", "FixEight (bootleg)", GAME_SUPPORTS_SAVE ) diff --git a/src/mame/includes/toaplan2.h b/src/mame/includes/toaplan2.h index 02fa93b876b..89f651548b7 100644 --- a/src/mame/includes/toaplan2.h +++ b/src/mame/includes/toaplan2.h @@ -1,3 +1,28 @@ +/* vdp related */ + +// mixing debug, render each VDP to it's own screen - be sure to recompile both driver and video after changing +#define DUAL_SCREEN_VDPS + +#include "video/gp9001.h" + +// cache the vdps for faster access +class toaplan2_state : public driver_data_t +{ +public: + static driver_data_t *alloc(running_machine &machine) { return auto_alloc_clear(&machine, toaplan2_state(machine)); } + + toaplan2_state(running_machine &machine) + : driver_data_t(machine) + { + vdp0 = NULL; + vdp1 = NULL; + } + + gp9001vdp_device* vdp0; + gp9001vdp_device* vdp1; +}; + + /*----------- defined in audio/toaplan2.c -----------*/ void dogyuun_okisnd_w(running_device *device, int data); @@ -5,12 +30,10 @@ void kbash_okisnd_w(running_device *device, int data); void fixeight_okisnd_w(running_device *device, int data); void batsugun_okisnd_w(running_device *device, int data); - /*----------- defined in drivers/toaplan2.c -----------*/ extern int toaplan2_sub_cpu; - /*----------- defined in video/toaplan2.c -----------*/ extern UINT16 *toaplan2_txvideoram16; @@ -23,28 +46,20 @@ extern size_t toaplan2_tx_offs_vram_size; extern size_t toaplan2_tx_scroll_vram_size; extern size_t batrider_paletteram16_size; -VIDEO_EOF( toaplan2_0 ); -VIDEO_EOF( toaplan2_1 ); -VIDEO_START( toaplan2_0 ); -VIDEO_START( toaplan2_1 ); -VIDEO_START( truxton2_0 ); -VIDEO_START( bgaregga_0 ); -VIDEO_START( batrider_0 ); -VIDEO_UPDATE( toaplan2_0 ); -VIDEO_UPDATE( truxton2_0 ); -VIDEO_UPDATE( dogyuun_1 ); -VIDEO_UPDATE( batsugun_1 ); -VIDEO_UPDATE( batrider_0 ); -VIDEO_UPDATE( mahoudai_0 ); +VIDEO_EOF( toaplan2 ); +VIDEO_START( toaplan2 ); +VIDEO_START( truxton2 ); +VIDEO_START( fixeighb ); +VIDEO_START( bgaregga ); +VIDEO_START( batrider ); -WRITE16_HANDLER( toaplan2_0_voffs_w ); -WRITE16_HANDLER( toaplan2_1_voffs_w ); - -READ16_HANDLER ( toaplan2_0_videoram16_r ); -READ16_HANDLER ( toaplan2_1_videoram16_r ); -WRITE16_HANDLER( toaplan2_0_videoram16_w ); -WRITE16_HANDLER( toaplan2_1_videoram16_w ); +VIDEO_UPDATE( toaplan2 ); +VIDEO_UPDATE( truxton2 ); +VIDEO_UPDATE( batrider ); +VIDEO_UPDATE( dogyuun ); +VIDEO_UPDATE( batsugun ); +/* non-vdp text layer */ READ16_HANDLER ( toaplan2_txvideoram16_r ); WRITE16_HANDLER( toaplan2_txvideoram16_w ); READ16_HANDLER ( toaplan2_txvideoram16_offs_r ); @@ -56,39 +71,10 @@ WRITE16_HANDLER( toaplan2_tx_gfxram16_w ); READ16_HANDLER ( raizing_tx_gfxram16_r ); WRITE16_HANDLER( raizing_tx_gfxram16_w ); -WRITE16_HANDLER( toaplan2_0_scroll_reg_select_w ); -WRITE16_HANDLER( toaplan2_1_scroll_reg_select_w ); -WRITE16_HANDLER( toaplan2_0_scroll_reg_data_w ); -WRITE16_HANDLER( toaplan2_1_scroll_reg_data_w ); - WRITE16_HANDLER( batrider_objectbank_w ); WRITE16_HANDLER( batrider_textdata_decode ); -READ16_HANDLER ( pipibibi_videoram16_r ); -WRITE16_HANDLER( pipibibi_videoram16_w ); -READ16_HANDLER ( pipibibi_spriteram16_r ); -WRITE16_HANDLER( pipibibi_spriteram16_w ); -WRITE16_HANDLER( pipibibi_scroll_w ); -void toaplan2_videoram16_w(running_machine* machine, offs_t offset, UINT16 data, UINT16 mem_mask, int controller); -int toaplan2_videoram16_r(running_machine* machine, offs_t offset, int controller); -extern UINT16 toaplan2_voffs[2]; -WRITE16_HANDLER( toaplan2_bg_tilemap_w); -WRITE16_HANDLER( toaplan2_fg_tilemap_w ); -WRITE16_HANDLER( toaplan2_top_tilemap_w ); -WRITE16_HANDLER( toaplan2_spram_w ); -READ16_HANDLER( toaplan2_bg_tilemap_r ); -READ16_HANDLER( toaplan2_fg_tilemap_r ); -READ16_HANDLER( toaplan2_top_tilemap_r ); -READ16_HANDLER( toaplan2_spram_r ); -WRITE16_HANDLER( toaplan2_bg_tilemap1_w); -WRITE16_HANDLER( toaplan2_fg_tilemap1_w ); -WRITE16_HANDLER( toaplan2_top_tilemap1_w ); -WRITE16_HANDLER( toaplan2_spram1_w ); -READ16_HANDLER( toaplan2_bg_tilemap1_r ); -READ16_HANDLER( toaplan2_fg_tilemap1_r ); -READ16_HANDLER( toaplan2_top_tilemap1_r ); -READ16_HANDLER( toaplan2_spram1_r ); diff --git a/src/mame/video/gp9001.c b/src/mame/video/gp9001.c new file mode 100644 index 00000000000..c8e2c042559 --- /dev/null +++ b/src/mame/video/gp9001.c @@ -0,0 +1,1325 @@ +/* GP9001 Video Controller */ + +/*************************************************************************** + + Functions to emulate the video hardware of some Toaplan games, + which use one or more Toaplan L7A0498 GP9001 graphic controllers. + + The simpler hardware of these games use one GP9001 controller. + Next we have games that use two GP9001 controllers, whose priority + schemes between the two controllers is unknown at this time, and + may be game dependant. + Finally we have games using one GP9001 controller and an additional + text tile layer, which has highest priority. This text tile layer + appears to have line-scroll support. Some of these games copy the + text tile gfx data to RAM from the main CPU ROM, which easily allows + for effects to be added to the tiles, by manipulating the text tile + gfx data. The tiles are then dynamically decoded from RAM before + displaying them. + + + To Do / Unknowns + - Hack is needed to reset sound CPU and sound chip when machine + is 'tilted' in Pipi & Bibis. Otherwise sound CPU interferes + with the main CPU test of shared RAM. You get a 'Sub CPU RAM Error' + - What do Scroll registers 0Eh and 0Fh really do ???? + - Snow Bros 2 sets bit 6 of the sprite X info word during weather + world map, and bits 4, 5 and 6 of the sprite X info word during + the Rabbit boss screen - reasons are unknown. + - Fourth set of scroll registers have been used for Sprite scroll + though it may not be correct. For most parts this looks right + except for Snow Bros 2 when in the rabbit boss screen (all sprites + jump when big green nasty (which is the foreground layer) comes + in from the left) + - Teki Paki tests video RAM from address 0 past SpriteRAM to $37ff. + This seems to be a bug in Teki Paki's vram test routine ! + - Batsugun, relationship between the two video controllers (priority + wise) is wrong and unknown. + + + + + + GP9001 Tile RAM format (each tile takes up 32 bits) + + 0 1 2 3 + ---- ---- ---- ---- xxxx xxxx xxxx xxxx = Tile number (0 - FFFFh) + ---- ---- -xxx xxxx ---- ---- ---- ---- = Color (0 - 7Fh) + ---- ---- ?--- ---- ---- ---- ---- ---- = unknown / unused + ---- xxxx ---- ---- ---- ---- ---- ---- = Priority (0 - Fh) + ???? ---- ---- ---- ---- ---- ---- ---- = unknown / unused / possible flips + +Sprites are of varying sizes between 8x8 and 128x128 with any variation +in between, in multiples of 8 either way. + +Here we draw the first 8x8 part of the sprite, then by using the sprite +dimensions, we draw the rest of the 8x8 parts to produce the complete +sprite. + +There seems to be sprite buffering - double buffering actually. + + GP9001 Sprite RAM format (data for each sprite takes up 4 words) + + 0 + ---- ---- ---- --xx = top 2 bits of Sprite number + ---- ---- xxxx xx-- = Color (0 - 3Fh) + ---- xxxx ---- ---- = Priority (0 - Fh) + ---x ---- ---- ---- = Flip X + --x- ---- ---- ---- = Flip Y + -x-- ---- ---- ---- = Multi-sprite + x--- ---- ---- ---- = Show sprite ? + + 1 + xxxx xxxx xxxx xxxx = Sprite number (top two bits in word 0) + + 2 + ---- ---- ---- xxxx = Sprite X size (add 1, then multiply by 8) + ---- ---- -??? ---- = unknown - used in Snow Bros. 2 + xxxx xxxx x--- ---- = X position + + 3 + ---- ---- ---- xxxx = Sprite Y size (add 1, then multiply by 8) + ---- ---- -??? ---- = unknown / unused + xxxx xxxx x--- ---- = Y position + + + + + + GP9001 Scroll Registers (hex) : + + 00 Background scroll X (X flip off) + 01 Background scroll Y (Y flip off) + 02 Foreground scroll X (X flip off) + 03 Foreground scroll Y (Y flip off) + 04 Top (text) scroll X (X flip off) + 05 Top (text) scroll Y (Y flip off) + 06 Sprites scroll X (X flip off) ??? + 07 Sprites scroll Y (Y flip off) ??? + 0E ??? Initialise Video controller at startup ??? + 0F Scroll update complete ??? (Not used in Ghox and V-Five) + + 80 Background scroll X (X flip on) + 81 Background scroll Y (Y flip on) + 82 Foreground scroll X (X flip on) + 83 Foreground scroll Y (Y flip on) + 84 Top (text) scroll X (X flip on) + 85 Top (text) scroll Y (Y flip on) + 86 Sprites scroll X (X flip on) ??? + 87 Sprites scroll Y (Y flip on) ??? + 8F Same as 0Fh except flip bit is active + + +Scroll Register 0E writes (Video controller inits ?) from different games: + +Teki-Paki | Ghox | Knuckle Bash | Truxton 2 | +0003, 0002, 4000 | ????, ????, ???? | 0202, 0203, 4200 | 0003, 0002, 4000 | + +Dogyuun | Batsugun | +0202, 0203, 4200 | 0202, 0203, 4200 | +1202, 1203, 5200 | 1202, 1203, 5200 | <--- Second video controller + +Pipi & Bibis | Fix Eight | V-Five | Snow Bros. 2 | +0003, 0002, 4000 | 0202, 0203, 4200 | 0202, 0203, 4200 | 0202, 0203, 4200 | + +***************************************************************************/ + + +#include "emu.h" +#include "gp9001.h" + +bitmap_t* gp9001_custom_priority_bitmap; +int gp9001_displog = 0; + +static WRITE16_DEVICE_HANDLER( gp9001_bg_tilemap_w ) +{ + gp9001vdp_device *vdp = (gp9001vdp_device*)device; + COMBINE_DATA(&vdp->bgvideoram16[offset]); + tilemap_mark_tile_dirty(vdp->bg_tilemap,offset/2); +} + +static WRITE16_DEVICE_HANDLER( gp9001_fg_tilemap_w ) +{ + gp9001vdp_device *vdp = (gp9001vdp_device*)device; + COMBINE_DATA(&vdp->fgvideoram16[offset]); + tilemap_mark_tile_dirty(vdp->fg_tilemap,offset/2); +} + +static WRITE16_DEVICE_HANDLER( gp9001_top_tilemap_w ) +{ + gp9001vdp_device *vdp = (gp9001vdp_device*)device; + COMBINE_DATA(&vdp->topvideoram16[offset]); + tilemap_mark_tile_dirty(vdp->top_tilemap,offset/2); +} + +static READ16_DEVICE_HANDLER( gp9001_bg_tilemap_r ) +{ + gp9001vdp_device *vdp = (gp9001vdp_device*)device; + return vdp->bgvideoram16[offset]; +} + +static READ16_DEVICE_HANDLER( gp9001_fg_tilemap_r ) +{ + gp9001vdp_device *vdp = (gp9001vdp_device*)device; + return vdp->fgvideoram16[offset]; +} + +static READ16_DEVICE_HANDLER( gp9001_top_tilemap_r ) +{ + gp9001vdp_device *vdp = (gp9001vdp_device*)device; + return vdp->topvideoram16[offset]; +} + +static READ16_DEVICE_HANDLER( gp9001_spram_r ) +{ + gp9001vdp_device *vdp = (gp9001vdp_device*)device; + return vdp->spriteram16_new[offset]; +} + +static WRITE16_DEVICE_HANDLER( gp9001_spram_w ) +{ + gp9001vdp_device *vdp = (gp9001vdp_device*)device; + COMBINE_DATA(&vdp->spriteram16_new[offset]); +} + +/* how to create a generic map which uses the CURRENT device? we have to create specific ones below at the moment */ +static ADDRESS_MAP_START( gp9001vdp_map, 0, 16 ) +// AM_RANGE(0x0000, 0x0fff) AM_DEVREADWRITE( this, gp9001_bg_tilemap_r, gp9001_bg_tilemap_w) +// AM_RANGE(0x1000, 0x1fff) AM_DEVREADWRITE( this, gp9001_fg_tilemap_r, gp9001_fg_tilemap_w) +// AM_RANGE(0x2000, 0x2fff) AM_DEVREADWRITE( this, gp9001_top_tilemap_r, gp9001_top_tilemap_w) +// AM_RANGE(0x3000, 0x37ff) AM_DEVREADWRITE( this, gp9001_spram_r, gp9001_spram_w) +// AM_RANGE(0x3800, 0x3fff) AM_RAM // sprite mirror? +ADDRESS_MAP_END + +ADDRESS_MAP_START( gp9001vdp0_map, 0, 16 ) + AM_RANGE(0x0000, 0x0fff) AM_DEVREADWRITE("gp9001vdp0", gp9001_bg_tilemap_r, gp9001_bg_tilemap_w) + AM_RANGE(0x1000, 0x1fff) AM_DEVREADWRITE("gp9001vdp0", gp9001_fg_tilemap_r, gp9001_fg_tilemap_w) + AM_RANGE(0x2000, 0x2fff) AM_DEVREADWRITE("gp9001vdp0", gp9001_top_tilemap_r, gp9001_top_tilemap_w) + AM_RANGE(0x3000, 0x37ff) AM_DEVREADWRITE("gp9001vdp0", gp9001_spram_r, gp9001_spram_w) + AM_RANGE(0x3800, 0x3fff) AM_RAM // sprite mirror? +ADDRESS_MAP_END + +ADDRESS_MAP_START( gp9001vdp1_map, 0, 16 ) + AM_RANGE(0x0000, 0x0fff) AM_DEVREADWRITE("gp9001vdp1", gp9001_bg_tilemap_r, gp9001_bg_tilemap_w) + AM_RANGE(0x1000, 0x1fff) AM_DEVREADWRITE("gp9001vdp1", gp9001_fg_tilemap_r, gp9001_fg_tilemap_w) + AM_RANGE(0x2000, 0x2fff) AM_DEVREADWRITE("gp9001vdp1", gp9001_top_tilemap_r, gp9001_top_tilemap_w) + AM_RANGE(0x3000, 0x37ff) AM_DEVREADWRITE("gp9001vdp1", gp9001_spram_r, gp9001_spram_w) + AM_RANGE(0x3800, 0x3fff) AM_RAM // sprite mirror? +ADDRESS_MAP_END + + +gp9001vdp_device_config::gp9001vdp_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock) + : device_config(mconfig, static_alloc_device_config, "gp9001vdp_", tag, owner, clock), + device_config_memory_interface(mconfig, *this), + m_space_config("gp9001vdp", ENDIANNESS_BIG, 16,14, 0, NULL, *ADDRESS_MAP_NAME(gp9001vdp_map)) +{ +} + +device_config *gp9001vdp_device_config::static_alloc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock) +{ + return global_alloc(gp9001vdp_device_config(mconfig, tag, owner, clock)); +} + +device_t *gp9001vdp_device_config::alloc_device(running_machine &machine) const +{ + return auto_alloc(&machine, gp9001vdp_device(machine, *this)); +} + +void gp9001vdp_device_config::device_config_complete() +{ + m_gfxregion = m_inline_data[0]; +} + +bool gp9001vdp_device_config::device_validity_check(const game_driver &driver) const +{ + bool error = false; + return error; +} + +const address_space_config *gp9001vdp_device_config::memory_space_config(int spacenum) const +{ + return (spacenum == 0) ? &m_space_config : NULL; +} + + +gp9001vdp_device::gp9001vdp_device(running_machine &_machine, const gp9001vdp_device_config &config) + : device_t(_machine, config), + device_memory_interface(_machine, config, *this), + m_config(config), + m_gfxregion(m_config.m_gfxregion) +{ +} + + + +static TILE_GET_INFO_DEVICE( get_top0_tile_info ) +{ + int color, tile_number, attrib; + + gp9001vdp_device *vdp = (gp9001vdp_device*)device; + + attrib = vdp->topvideoram16[2*tile_index]; + + tile_number = vdp->topvideoram16[2*tile_index+1]; + + if (vdp->gp9001_gfxrom_is_banked) + { + tile_number = ( vdp->gp9001_gfxrom_bank[(tile_number >> 13) & 7] << 13 ) | ( tile_number & 0x1fff ); + } + else + { + if (tile_number>vdp->tile_limit) + { + tile_number = 0; + } + } + + color = attrib & 0x0fff; // 0x0f00 priority, 0x007f colour + SET_TILE_INFO_DEVICE( + vdp->tile_region, + tile_number, + color, + 0); + //tileinfo->category = (attrib & 0x0f00) >> 8; +} + + + +static TILE_GET_INFO_DEVICE( get_fg0_tile_info ) +{ + int color, tile_number, attrib; + + gp9001vdp_device *vdp = (gp9001vdp_device*)device; + + attrib = vdp->fgvideoram16[2*tile_index]; + + tile_number = vdp->fgvideoram16[2*tile_index+1]; + + + if (vdp->gp9001_gfxrom_is_banked) + { + tile_number = ( vdp->gp9001_gfxrom_bank[(tile_number >> 13) & 7] << 13 ) | ( tile_number & 0x1fff ); + } + else + { + if (tile_number>vdp->tile_limit) tile_number = 0; + } + + + color = attrib & 0x0fff; // 0x0f00 priority, 0x007f colour + SET_TILE_INFO_DEVICE( + vdp->tile_region, + tile_number, + color, + 0); + //tileinfo->category = (attrib & 0x0f00) >> 8; +} + +static TILE_GET_INFO_DEVICE( get_bg0_tile_info ) +{ + int color, tile_number, attrib; + gp9001vdp_device *vdp = (gp9001vdp_device*)device; + + attrib = vdp->bgvideoram16[2*tile_index]; + + tile_number = vdp->bgvideoram16[2*tile_index+1]; + + if (vdp->gp9001_gfxrom_is_banked) + { + tile_number = ( vdp->gp9001_gfxrom_bank[(tile_number >> 13) & 7] << 13 ) | ( tile_number & 0x1fff ); + } + else + { + if (tile_number>vdp->tile_limit) tile_number = 0; + } + + color = attrib & 0x0fff; // 0x0f00 priority, 0x007f colour + SET_TILE_INFO_DEVICE( + vdp->tile_region, + tile_number, + color, + 0); + //tileinfo->category = (attrib & 0x0f00) >> 8; +} + +static void create_tilemaps(gp9001vdp_device* vdp, int region) +{ + vdp->tile_region = region; + + vdp->top_tilemap = tilemap_create_device(vdp, get_top0_tile_info,tilemap_scan_rows,16,16,32,32); + vdp->fg_tilemap = tilemap_create_device(vdp, get_fg0_tile_info,tilemap_scan_rows,16,16,32,32); + vdp->bg_tilemap = tilemap_create_device(vdp, get_bg0_tile_info,tilemap_scan_rows,16,16,32,32); + + tilemap_set_transparent_pen(vdp->top_tilemap,0); + tilemap_set_transparent_pen(vdp->fg_tilemap,0); + tilemap_set_transparent_pen(vdp->bg_tilemap,0); +} + + +void gp9001vdp_device::device_start() +{ + topvideoram16 = auto_alloc_array_clear(machine, UINT16, GP9001_TOP_VRAM_SIZE/2); + fgvideoram16 = auto_alloc_array_clear(machine, UINT16, GP9001_FG_VRAM_SIZE/2); + bgvideoram16 = auto_alloc_array_clear(machine, UINT16, GP9001_BG_VRAM_SIZE/2); + + spriteram16_new = auto_alloc_array_clear(machine, UINT16, GP9001_SPRITERAM_SIZE/2); + spriteram16_now = auto_alloc_array_clear(machine, UINT16, GP9001_SPRITERAM_SIZE/2); + + spriteram16_n = spriteram16_now; + + create_tilemaps(this, m_gfxregion); + + state_save_register_device_item_pointer(this, 0, spriteram16_new, GP9001_SPRITERAM_SIZE/2); + state_save_register_device_item_pointer(this, 0, spriteram16_now, GP9001_SPRITERAM_SIZE/2); + state_save_register_device_item_pointer(this, 0, topvideoram16, GP9001_TOP_VRAM_SIZE/2); + state_save_register_device_item_pointer(this, 0, fgvideoram16, GP9001_FG_VRAM_SIZE/2); + state_save_register_device_item_pointer(this, 0, bgvideoram16, GP9001_BG_VRAM_SIZE/2); + + state_save_register_device_item(this,0, gp9001_scroll_reg); + state_save_register_device_item(this,0, gp9001_voffs); + state_save_register_device_item(this,0, bg_scrollx); + state_save_register_device_item(this,0, bg_scrolly); + state_save_register_device_item(this,0, fg_scrollx); + state_save_register_device_item(this,0, fg_scrolly); + state_save_register_device_item(this,0, top_scrollx); + state_save_register_device_item(this,0, top_scrolly); + state_save_register_device_item(this,0, sprite_scrollx); + state_save_register_device_item(this,0, sprite_scrolly); + state_save_register_device_item(this,0, bg_flip); + state_save_register_device_item(this,0, fg_flip); + state_save_register_device_item(this,0, top_flip); + state_save_register_device_item(this,0, sprite_flip); + + gp9001_gfxrom_is_banked = 0; + gp9001_gfxrom_bank_dirty = 0; + state_save_register_device_item_array(this,0,gp9001_gfxrom_bank); + + extra_xoffset[0]=0; + extra_xoffset[1]=0; + extra_xoffset[2]=0; + extra_xoffset[3]=0; + + extra_yoffset[0]=0; + extra_yoffset[1]=0; + extra_yoffset[2]=0; + extra_yoffset[3]=0; +} + +void gp9001vdp_device::device_reset() +{ + gp9001_voffs = 0; + gp9001_scroll_reg = 0; + bg_scrollx = bg_scrolly = 0; + fg_scrollx = fg_scrolly = 0; + top_scrollx = top_scrolly = 0; + sprite_scrollx = sprite_scrolly = 0; + + bg_flip = 0; + fg_flip = 0; + top_flip = 0; + sprite_flip = 0; + + tile_limit = 0xffff; + + /* debug */ + display_bg = 1; + display_fg = 1; + display_top = 1; + display_sp = 1; +} + + +void gp9001_voffs_w(gp9001vdp_device *vdp, offs_t offset, UINT16 data, UINT16 mem_mask) +{ + COMBINE_DATA(&vdp->gp9001_voffs); +} + +int gp9001_videoram16_r(gp9001vdp_device *vdp, offs_t offset) +{ + int offs = vdp->gp9001_voffs; + vdp->gp9001_voffs++; + return memory_read_word_16be(vdp->space(), offs*2); +} + + +void gp9001_videoram16_w(gp9001vdp_device *vdp, offs_t offset, UINT16 data, UINT16 mem_mask) +{ + int offs = vdp->gp9001_voffs; + vdp->gp9001_voffs++; + memory_write_word_masked_16be(vdp->space(), offs*2, data, mem_mask); +} + +WRITE16_DEVICE_HANDLER( gp9001_devvoffs_w ) +{ + gp9001vdp_device *vdp = (gp9001vdp_device *)device; + + gp9001_voffs_w(vdp, offset, data, mem_mask); +} + + +READ16_DEVICE_HANDLER( gp9001_devvideoram16_r ) +{ + gp9001vdp_device *vdp = (gp9001vdp_device *)device; + return gp9001_videoram16_r(vdp, offset); +} + +WRITE16_DEVICE_HANDLER( gp9001_devvideoram16_w ) +{ + gp9001vdp_device *vdp = (gp9001vdp_device *)device; + gp9001_videoram16_w(vdp, offset, data, mem_mask); +} + + +READ16_DEVICE_HANDLER( gp9001_vdpstatus_r ) +{ + return ((device->machine->primary_screen->vpos() + 15) % 262) >= 245; +} + +static void t2_scroll_reg_select_w(gp9001vdp_device *vdp, offs_t offset, UINT16 data, UINT16 mem_mask) +{ + if (ACCESSING_BITS_0_7) + { + vdp->gp9001_scroll_reg = data & 0x8f; + if (data & 0x70) + logerror("Hmmm, selecting unknown LSB video control register (%04x) Video controller %01x \n",vdp->gp9001_scroll_reg,vdp->tile_region>>1); + } + else + { + logerror("Hmmm, selecting unknown MSB video control register (%04x) Video controller %01x \n",vdp->gp9001_scroll_reg,vdp->tile_region>>1); + } +} + +WRITE16_DEVICE_HANDLER( gp9001_scroll_reg_select_w ) +{ + gp9001vdp_device *vdp = (gp9001vdp_device *)device; + t2_scroll_reg_select_w(vdp, offset, data, mem_mask); +} + +static void gp9001_scroll_reg_data_w(gp9001vdp_device *vdp, offs_t offset, UINT16 data, UINT16 mem_mask) +{ + + /************************************************************************/ + /***** layer X and Y flips can be set independently, so emulate it ******/ + /************************************************************************/ + + //printf("gp9001_scroll_reg_data_w %04x %04x\n", offset, data); + + + switch(vdp->gp9001_scroll_reg) + { + case 0x00: data -= 0x1d6; /* 1D6h */ + COMBINE_DATA(&vdp->bg_scrollx); + vdp->bg_flip &= (~TILEMAP_FLIPX); + tilemap_set_flip(vdp->bg_tilemap,vdp->bg_flip); + tilemap_set_scrollx(vdp->bg_tilemap,0,vdp->bg_scrollx+vdp->extra_xoffset[0]); + break; + case 0x01: data -= 0x1ef; /* 1EFh */ + COMBINE_DATA(&vdp->bg_scrolly); + vdp->bg_flip &= (~TILEMAP_FLIPY); + tilemap_set_flip(vdp->bg_tilemap,vdp->bg_flip); + tilemap_set_scrolly(vdp->bg_tilemap,0,vdp->bg_scrolly+vdp->extra_yoffset[0]); + break; + case 0x02: data -= 0x1d8; /* 1D0h */ + COMBINE_DATA(&vdp->fg_scrollx); + vdp->fg_flip &= (~TILEMAP_FLIPX); + tilemap_set_flip(vdp->fg_tilemap,vdp->fg_flip); + tilemap_set_scrollx(vdp->fg_tilemap,0,vdp->fg_scrollx+vdp->extra_xoffset[1]); + break; + case 0x03: data -= 0x1ef; /* 1EFh */ + COMBINE_DATA(&vdp->fg_scrolly); + vdp->fg_flip &= (~TILEMAP_FLIPY); + tilemap_set_flip(vdp->fg_tilemap,vdp->fg_flip); + tilemap_set_scrolly(vdp->fg_tilemap,0,vdp->fg_scrolly+vdp->extra_yoffset[1]); + break; + case 0x04: data -= 0x1da; /* 1DAh */ + COMBINE_DATA(&vdp->top_scrollx); + vdp->top_flip &= (~TILEMAP_FLIPX); + tilemap_set_flip(vdp->top_tilemap,vdp->top_flip); + tilemap_set_scrollx(vdp->top_tilemap,0,vdp->top_scrollx+vdp->extra_xoffset[2]); + break; + case 0x05: data -= 0x1ef; /* 1EFh */ + COMBINE_DATA(&vdp->top_scrolly); + vdp->top_flip &= (~TILEMAP_FLIPY); + tilemap_set_flip(vdp->top_tilemap,vdp->top_flip); + tilemap_set_scrolly(vdp->top_tilemap,0,vdp->top_scrolly+vdp->extra_yoffset[2]); + break; + case 0x06: data -= 0x1cc; /* 1D4h */ + COMBINE_DATA(&vdp->sprite_scrollx); + if (vdp->sprite_scrollx & 0x8000) vdp->sprite_scrollx |= 0xfffffe00; + else vdp->sprite_scrollx &= 0x1ff; + vdp->sprite_flip &= (~GP9001_SPRITE_FLIPX); + break; + case 0x07: data -= 0x1ef; /* 1F7h */ + COMBINE_DATA(&vdp->sprite_scrolly); + if (vdp->sprite_scrolly & 0x8000) vdp->sprite_scrolly |= 0xfffffe00; + else vdp->sprite_scrolly &= 0x1ff; + vdp->sprite_flip &= (~GP9001_SPRITE_FLIPY); + break; + case 0x0f: break; + case 0x80: data -= 0x229; /* 169h */ + COMBINE_DATA(&vdp->bg_scrollx); + vdp->bg_flip |= TILEMAP_FLIPX; + tilemap_set_flip(vdp->bg_tilemap,vdp->bg_flip); + tilemap_set_scrollx(vdp->bg_tilemap,0,vdp->bg_scrollx+vdp->extra_xoffset[0]); + break; + case 0x81: data -= 0x210; /* 100h */ + COMBINE_DATA(&vdp->bg_scrolly); + vdp->bg_flip |= TILEMAP_FLIPY; + tilemap_set_flip(vdp->bg_tilemap,vdp->bg_flip); + tilemap_set_scrolly(vdp->bg_tilemap,0,vdp->bg_scrolly+vdp->extra_yoffset[0]); + break; + case 0x82: data -= 0x227; /* 15Fh */ + COMBINE_DATA(&vdp->fg_scrollx); + vdp->fg_flip |= TILEMAP_FLIPX; + tilemap_set_flip(vdp->fg_tilemap,vdp->fg_flip); + tilemap_set_scrollx(vdp->fg_tilemap,0,vdp->fg_scrollx+vdp->extra_xoffset[1]); + break; + case 0x83: data -= 0x210; /* 100h */ + COMBINE_DATA(&vdp->fg_scrolly); + vdp->fg_flip |= TILEMAP_FLIPY; + tilemap_set_flip(vdp->fg_tilemap,vdp->fg_flip); + tilemap_set_scrolly(vdp->fg_tilemap,0,vdp->fg_scrolly+vdp->extra_yoffset[1]); + break; + case 0x84: data -= 0x225; /* 165h */ + COMBINE_DATA(&vdp->top_scrollx); + vdp->top_flip |= TILEMAP_FLIPX; + tilemap_set_flip(vdp->top_tilemap,vdp->top_flip); + tilemap_set_scrollx(vdp->top_tilemap,0,vdp->top_scrollx+vdp->extra_xoffset[2]); + break; + case 0x85: data -= 0x210; /* 100h */ + COMBINE_DATA(&vdp->top_scrolly); + vdp->top_flip |= TILEMAP_FLIPY; + tilemap_set_flip(vdp->top_tilemap,vdp->top_flip); + tilemap_set_scrolly(vdp->top_tilemap,0,vdp->top_scrolly+vdp->extra_yoffset[2]); + break; + case 0x86: data -= 0x17b; /* 17Bh */ + COMBINE_DATA(&vdp->sprite_scrollx); + if (vdp->sprite_scrollx & 0x8000) vdp->sprite_scrollx |= 0xfffffe00; + else vdp->sprite_scrollx &= 0x1ff; + vdp->sprite_flip |= GP9001_SPRITE_FLIPX; + break; + case 0x87: data -= 0x108; /* 108h */ + COMBINE_DATA(&vdp->sprite_scrolly); + if (vdp->sprite_scrolly & 0x8000) vdp->sprite_scrolly |= 0xfffffe00; + else vdp->sprite_scrolly &= 0x1ff; + vdp->sprite_flip |= GP9001_SPRITE_FLIPY; + break; + case 0x8f: break; + + case 0x0e: /******* Initialise video controller register ? *******/ + #if 0 // do we know this works on real hw? + if ((gp9001_sub_cpu == CPU_2_Z80) && (data == 3)) + { + /* HACK! When tilted, sound CPU needs to be reset. */ + running_device *ym = vdp->machine->device("ymsnd"); + + if (ym && ym->type() == SOUND_YM3812) + { + cputag_set_input_line(vdp->machine, "audiocpu", INPUT_LINE_RESET, PULSE_LINE); + devtag_reset(vdp->machine, "ymsnd"); + } + } + #endif + + default: logerror("Hmmm, writing %08x to unknown video control register (%08x) Video controller %01x !!!\n",data ,vdp->gp9001_scroll_reg,vdp->tile_region>>1); + break; + } + +// enable / disable layer debug keys (broken at the moment) +#ifdef MAME_DEBUG + // 1st vdp + if (vdp->tile_region == 0) + { + /* this is non-vdp + if ( input_code_pressed_once(vdp->machine, KEYCODE_W) ) + { + display_tx += 1; + display_tx &= 1; + if (gp9001_txvideoram16 != 0) + tilemap_set_enable(tx_tilemap, display_tx); + } + */ + + if ( input_code_pressed_once(vdp->machine, KEYCODE_L) ) + { + vdp->display_sp += 1; + vdp->display_sp &= 1; + } + if ( input_code_pressed_once(vdp->machine, KEYCODE_K) ) + { + vdp->display_top += 1; + vdp->display_top &= 1; + tilemap_set_enable(vdp->top_tilemap, vdp->display_top); + } + if ( input_code_pressed_once(vdp->machine, KEYCODE_J) ) + { + vdp->display_fg += 1; + vdp->display_fg &= 1; + tilemap_set_enable(vdp->fg_tilemap, vdp->display_fg); + } + if ( input_code_pressed_once(vdp->machine, KEYCODE_H) ) + { + vdp->display_bg += 1; + vdp->display_bg &= 1; + tilemap_set_enable(vdp->bg_tilemap, vdp->display_bg); + } + } + + // 2nd vdp + if (vdp->tile_region == 2) + { + if ( input_code_pressed_once(vdp->machine, KEYCODE_O) ) + { + vdp->display_sp += 1; + vdp->display_sp &= 1; + } + if ( input_code_pressed_once(vdp->machine, KEYCODE_I) ) + { + vdp->display_top += 1; + vdp->display_top &= 1; + tilemap_set_enable(vdp->top_tilemap, vdp->display_top); + } + if ( input_code_pressed_once(vdp->machine, KEYCODE_U) ) + { + vdp->display_fg += 1; + vdp->display_fg &= 1; + tilemap_set_enable(vdp->fg_tilemap, vdp->display_fg); + } + if ( input_code_pressed_once(vdp->machine, KEYCODE_Y) ) + { + vdp->display_bg += 1; + vdp->display_bg &= 1; + tilemap_set_enable(vdp->bg_tilemap, vdp->display_bg); + } + } +#endif +} + +WRITE16_DEVICE_HANDLER( gp9001_scroll_reg_devvdata_w ) +{ + gp9001vdp_device *vdp = (gp9001vdp_device*)device; + gp9001_scroll_reg_data_w(vdp, offset, data, mem_mask); +} + + + +READ16_DEVICE_HANDLER( gp9001_vdp_r ) +{ + switch (offset) + { + case 0x04/2: + case 0x06/2: + return gp9001_devvideoram16_r(device, offset-0x04/2, mem_mask); + + case 0x0c/2: + return gp9001_vdpstatus_r(device, offset-0x0c/2, mem_mask); + + default: + logerror("gp9001_vdp_r: read from unhandled offset %04x\n",offset*2); + } + + return 0xffff; +} + +WRITE16_DEVICE_HANDLER( gp9001_vdp_w ) +{ + switch (offset) + { + case 0x00/2: + gp9001_devvoffs_w(device, offset-0x00/2, data, mem_mask); + break; + + case 0x04/2: + case 0x06/2: + gp9001_devvideoram16_w(device, offset-0x04/2, data, mem_mask); + break; + + case 0x08/2: + gp9001_scroll_reg_select_w(device, offset-0x08/2, data, mem_mask); + break; + + case 0x0c/2: + gp9001_scroll_reg_devvdata_w(device, offset-0x0c/2, data, mem_mask); + break; + + default: + logerror("gp9001_vdp_w: write to unhandled offset %04x %04x\n",offset, data); + break; + } +} + +/* some raizing games have a different layout */ +READ16_DEVICE_HANDLER( gp9001_vdp_alt_r ) +{ + switch (offset) + { + case 0x00/2: + return gp9001_vdpstatus_r(device, offset-0x0c/2, mem_mask); + + case 0x08/2: + case 0x0a/2: + return gp9001_devvideoram16_r(device, offset-0x04/2, mem_mask); + + + default: + logerror("gp9001_vdp_alt_r: read from unhandled offset %04x\n",offset*2); + } + + return 0xffff; +} + +WRITE16_DEVICE_HANDLER( gp9001_vdp_alt_w ) +{ + switch (offset) + { + case 0x00/2: + gp9001_scroll_reg_devvdata_w(device, offset-0x0c/2, data, mem_mask); + break; + + case 0x04/2: + gp9001_scroll_reg_select_w(device, offset-0x08/2, data, mem_mask); + break; + + case 0x08/2: + case 0x0a/2: + gp9001_devvideoram16_w(device, offset-0x04/2, data, mem_mask); + break; + + case 0x0c/2: + gp9001_devvoffs_w(device, offset-0x00/2, data, mem_mask); + break; + + default: + logerror("gp9001_vdp_alt_w: write to unhandled offset %04x %04x\n",offset, data); + break; + } +} + + + +/***************************************************************************/ +/**************** PIPIBIBI bootleg interface into this video driver ********/ + +WRITE16_DEVICE_HANDLER( pipibibi_bootleg_scroll_w ) +{ + gp9001vdp_device *vdp = (gp9001vdp_device *)device; + + if (ACCESSING_BITS_8_15 && ACCESSING_BITS_0_7) + { + switch(offset) + { + case 0x00: data -= 0x01f; break; + case 0x01: data += 0x1ef; break; + case 0x02: data -= 0x01d; break; + case 0x03: data += 0x1ef; break; + case 0x04: data -= 0x01b; break; + case 0x05: data += 0x1ef; break; + case 0x06: data += 0x1d4; break; + case 0x07: data += 0x1f7; break; + default: logerror("PIPIBIBI writing %04x to unknown scroll register %04x",data, offset); + } + + vdp->gp9001_scroll_reg = offset; + gp9001_scroll_reg_data_w(vdp, offset, data, mem_mask); + } +} + +READ16_DEVICE_HANDLER( pipibibi_bootleg_videoram16_r ) +{ + gp9001vdp_device *vdp = (gp9001vdp_device*)device; + + gp9001_voffs_w(vdp, 0, offset, 0xffff); + return gp9001_videoram16_r(vdp, 0); +} + +WRITE16_DEVICE_HANDLER( pipibibi_bootleg_videoram16_w ) +{ + gp9001vdp_device *vdp = (gp9001vdp_device*)device; + + gp9001_voffs_w(vdp, 0, offset, 0xffff); + gp9001_videoram16_w(vdp, 0, data, mem_mask); +} + +READ16_DEVICE_HANDLER( pipibibi_bootleg_spriteram16_r ) +{ + gp9001vdp_device *vdp = (gp9001vdp_device*)device; + + gp9001_voffs_w(vdp, 0, (0x1800 + offset), 0); + return gp9001_videoram16_r(vdp, 0); +} + +WRITE16_DEVICE_HANDLER( pipibibi_bootleg_spriteram16_w ) +{ + gp9001vdp_device *vdp = (gp9001vdp_device*)device; + + gp9001_voffs_w(vdp, 0, (0x1800 + offset), mem_mask); + gp9001_videoram16_w(vdp, 0, data, mem_mask); +} + + + +void gp9001_log_vram(gp9001vdp_device* vdp, running_machine *machine) +{ + +#ifdef MAME_DEBUG + offs_t sprite_voffs, tile_voffs; + + if ( input_code_pressed(machine, KEYCODE_M) ) + { + UINT16 *source_now0 = 0; + UINT16 *source_new0 = 0; + UINT16 *source_now1 = 0; + UINT16 *source_new1 = 0; + + int schar[2],sattr[2],sxpos[2],sypos[2]; + + logerror("Scrolls BG-X BG-Y FG-X FG-Y TOP-X TOP-Y Sprite-X Sprite-Y\n"); + + if (vdp->tile_region == 0) + { + source_now0 = (UINT16 *)(vdp->spriteram16_now); + source_new0 = (UINT16 *)(vdp->spriteram16_new); + logerror("---0--> %04x %04x %04x %04x %04x %04x %04x %04x\n", vdp->bg_scrollx,vdp->bg_scrolly,vdp->fg_scrollx,vdp->fg_scrolly,vdp->top_scrollx,vdp->top_scrolly,vdp->sprite_scrollx, vdp->sprite_scrolly); + } + + if (vdp->tile_region == 2) + { + source_now1 = (UINT16 *)(vdp->spriteram16_now); + source_new1 = (UINT16 *)(vdp->spriteram16_new); + + logerror("Scrolls BG-X BG-Y FG-X FG-Y TOP-X TOP-Y Sprite-X Sprite-Y\n"); + logerror("---1--> %04x %04x %04x %04x %04x %04x %04x %04x\n", vdp->bg_scrollx,vdp->bg_scrolly,vdp->fg_scrollx,vdp->fg_scrolly,vdp->top_scrollx,vdp->top_scrolly,vdp->sprite_scrollx, vdp->sprite_scrolly); + } + + + for ( sprite_voffs = 0; sprite_voffs < (GP9001_SPRITERAM_SIZE/2); sprite_voffs += 4 ) + { + if (vdp->tile_region == 0) + { + sattr[0] = source_now0[sprite_voffs]; + schar[0] = source_now0[sprite_voffs + 1]; + sxpos[0] = source_now0[sprite_voffs + 2]; + sypos[0] = source_now0[sprite_voffs + 3]; + sattr[1] = source_new0[sprite_voffs]; + schar[1] = source_new0[sprite_voffs + 1]; + sxpos[1] = source_new0[sprite_voffs + 2]; + sypos[1] = source_new0[sprite_voffs + 3]; + logerror("SPoffs Sprt Attr Xpos Ypos Sprt Attr Xpos Ypos\n"); + logerror("0:%03x now:%04x %04x %04x %04x new:%04x %04x %04x %04x\n",sprite_voffs, + schar[0], sattr[0],sxpos[0], sypos[0], + schar[1], sattr[1],sxpos[1], sypos[1]); + } + + if (vdp->tile_region == 2) + { + sattr[0] = source_now1[sprite_voffs]; + schar[0] = source_now1[sprite_voffs + 1]; + sxpos[0] = source_now1[sprite_voffs + 2]; + sypos[0] = source_now1[sprite_voffs + 3]; + sattr[1] = source_new1[sprite_voffs]; + schar[1] = source_new1[sprite_voffs + 1]; + sxpos[1] = source_new1[sprite_voffs + 2]; + sypos[1] = source_new1[sprite_voffs + 3]; + logerror("1:%03x now:%04x %04x %04x %04x new:%04x %04x %04x %04x\n",sprite_voffs, + schar[0], sattr[0],sxpos[0], sypos[0], + schar[1], sattr[1],sxpos[1], sypos[1]); + } + } + } + + if ( input_code_pressed(machine, KEYCODE_N) ) + { + int tchar[2], tattr[2]; + logerror("Scrolls BG-X BG-Y FG-X FG-Y TOP-X TOP-Y Sprite-X Sprite-Y\n"); + + if (vdp->tile_region == 0) + { + logerror("---0--> %04x %04x %04x %04x %04x %04x %04x %04x\n", vdp->bg_scrollx,vdp->bg_scrolly,vdp->fg_scrollx,vdp->fg_scrolly,vdp->top_scrollx,vdp->top_scrolly,vdp->sprite_scrollx, vdp->sprite_scrolly); + } + if (vdp->tile_region == 2) + { + logerror("---1--> %04x %04x %04x %04x %04x %04x %04x %04x\n", vdp->bg_scrollx,vdp->bg_scrolly,vdp->fg_scrollx,vdp->fg_scrolly,vdp->top_scrollx,vdp->top_scrolly,vdp->sprite_scrollx, vdp->sprite_scrolly); + } + + + for ( tile_voffs = 0; tile_voffs < (GP9001_TOP_VRAM_SIZE/2); tile_voffs += 2 ) + { + if (vdp->tile_region == 0) + { + tchar[0] = vdp->topvideoram16[tile_voffs + 1]; + tattr[0] = vdp->topvideoram16[tile_voffs]; + logerror("TOPoffs:%04x Tile0:%04x Attr0:%04x\n", tile_voffs, tchar[0], tattr[0]); + } + + if (vdp->tile_region == 2) + { + tchar[1] = vdp->topvideoram16[tile_voffs + 1]; + tattr[1] = vdp->topvideoram16[tile_voffs]; + logerror("TOPoffs:%04x Tile0:%04x Attr0:%04x\n", tile_voffs, tchar[1], tattr[1]); + } + + } + } + if ( input_code_pressed(machine, KEYCODE_B) ) + { + int tchar[2], tattr[2]; + logerror("Scrolls BG-X BG-Y FG-X FG-Y TOP-X TOP-Y Sprite-X Sprite-Y\n"); + + if (vdp->tile_region == 0) + { + logerror("---0--> %04x %04x %04x %04x %04x %04x %04x %04x\n", vdp->bg_scrollx,vdp->bg_scrolly,vdp->fg_scrollx,vdp->fg_scrolly,vdp->top_scrollx,vdp->top_scrolly,vdp->sprite_scrollx, vdp->sprite_scrolly); + } + + if (vdp->tile_region == 2) + { + logerror("---1--> %04x %04x %04x %04x %04x %04x %04x %04x\n", vdp->bg_scrollx,vdp->bg_scrolly,vdp->fg_scrollx,vdp->fg_scrolly,vdp->top_scrollx,vdp->top_scrolly,vdp->sprite_scrollx, vdp->sprite_scrolly); + } + + + for ( tile_voffs = 0; tile_voffs < (GP9001_FG_VRAM_SIZE/2); tile_voffs += 2 ) + { + if (vdp->tile_region == 0) + { + tchar[0] = vdp->fgvideoram16[tile_voffs + 1]; + tattr[0] = vdp->fgvideoram16[tile_voffs]; + logerror("FGoffs:%04x Tile0:%04x Attr0:%04x\n", tile_voffs, tchar[0], tattr[0]); + } + + + if (vdp->tile_region == 2) + { + tchar[1] = vdp->fgvideoram16[tile_voffs + 1]; + tattr[1] = vdp->fgvideoram16[tile_voffs]; + logerror("FGoffs:%04x Tile0:%04x Attr0:%04x \n", tile_voffs, tchar[1], tattr[1]); + } + } + } + if ( input_code_pressed(machine, KEYCODE_V) ) + { + int tchar[2], tattr[2]; + logerror("Scrolls BG-X BG-Y FG-X FG-Y TOP-X TOP-Y Sprite-X Sprite-Y\n"); + + if (vdp->tile_region == 0) + { + logerror("---0--> %04x %04x %04x %04x %04x %04x %04x %04x\n", vdp->bg_scrollx,vdp->bg_scrolly,vdp->fg_scrollx,vdp->fg_scrolly,vdp->top_scrollx,vdp->top_scrolly,vdp->sprite_scrollx, vdp->sprite_scrolly); + } + + if (vdp->tile_region == 2) + { + logerror("---1--> %04x %04x %04x %04x %04x %04x %04x %04x\n", vdp->bg_scrollx,vdp->bg_scrolly,vdp->fg_scrollx,vdp->fg_scrolly,vdp->top_scrollx,vdp->top_scrolly,vdp->sprite_scrollx, vdp->sprite_scrolly); + } + + for ( tile_voffs = 0; tile_voffs < (GP9001_BG_VRAM_SIZE/2); tile_voffs += 2 ) + { + if (vdp->tile_region == 0) + { + tchar[0] = vdp->bgvideoram16[tile_voffs + 1]; + tattr[0] = vdp->bgvideoram16[tile_voffs]; + logerror("BGoffs:%04x Tile0:%04x Attr0:%04x\n", tile_voffs, tchar[0], tattr[0]); + } + + if (vdp->tile_region == 2) + { + tchar[1] = vdp->bgvideoram16[tile_voffs + 1]; + tattr[1] = vdp->bgvideoram16[tile_voffs]; + logerror("BGoffs:%04x Tile0:%04x Attr0:%04x\n", tile_voffs, tchar[1], tattr[1]); + } + } + } + + if ( input_code_pressed_once(machine, KEYCODE_C) ) + logerror("Mark here\n"); + + if ( input_code_pressed_once(machine, KEYCODE_E) ) + { + gp9001_displog += 1; + gp9001_displog &= 1; + } + if (gp9001_displog) + { + logerror("Scrolls BG-X BG-Y FG-X FG-Y TOP-X TOP-Y Sprite-X Sprite-Y\n"); + + if (vdp->tile_region == 0) + { + logerror("---0--> %04x %04x %04x %04x %04x %04x %04x %04x\n", vdp->bg_scrollx,vdp->bg_scrolly,vdp->fg_scrollx,vdp->fg_scrolly,vdp->top_scrollx,vdp->top_scrolly,vdp->sprite_scrollx, vdp->sprite_scrolly); + } + + if (vdp->tile_region == 2) + { + logerror("---1--> %04x %04x %04x %04x %04x %04x %04x %04x\n", vdp->bg_scrollx,vdp->bg_scrolly,vdp->fg_scrollx,vdp->fg_scrolly,vdp->top_scrollx,vdp->top_scrolly,vdp->sprite_scrollx, vdp->sprite_scrolly); + } + } +#endif +} + + + +/*************************************************************************** + Sprite Handlers +***************************************************************************/ + +void gp9001vdp_device::draw_sprites( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, const UINT8* primap ) +{ + const gfx_element *gfx = machine->gfx[tile_region+1]; + + int offs, old_x, old_y; + + + UINT16 *source = (UINT16 *)(spriteram16_n); + + old_x = (-(sprite_scrollx+extra_xoffset[3])) & 0x1ff; + old_y = (-(sprite_scrolly+extra_yoffset[3])) & 0x1ff; + + for (offs = 0; offs < (GP9001_SPRITERAM_SIZE/2); offs += 4) + { + int attrib, sprite, color, priority, flipx, flipy, sx, sy; + int sprite_sizex, sprite_sizey, dim_x, dim_y, sx_base, sy_base; + int bank, sprite_num; + + attrib = source[offs]; + priority = primap[((attrib & 0x0f00)>>8)]+1; + + if ((attrib & 0x8000)) + { + if (!gp9001_gfxrom_is_banked) /* No Sprite select bank switching needed */ + { + sprite = ((attrib & 3) << 16) | source[offs + 1]; /* 18 bit */ + } + else /* Batrider Sprite select bank switching required */ + { + sprite_num = source[offs + 1] & 0x7fff; + bank = ((attrib & 3) << 1) | (source[offs + 1] >> 15); + sprite = (gp9001_gfxrom_bank[bank] << 15 ) | sprite_num; + } + color = (attrib >> 2) & 0x3f; + + /***** find out sprite size *****/ + sprite_sizex = ((source[offs + 2] & 0x0f) + 1) * 8; + sprite_sizey = ((source[offs + 3] & 0x0f) + 1) * 8; + + /***** find position to display sprite *****/ + if (!(attrib & 0x4000)) + { + sx_base = ((source[offs + 2] >> 7) - (sprite_scrollx+extra_xoffset[3])) & 0x1ff; + sy_base = ((source[offs + 3] >> 7) - (sprite_scrolly+extra_yoffset[3])) & 0x1ff; + } else { + sx_base = (old_x + (source[offs + 2] >> 7)) & 0x1ff; + sy_base = (old_y + (source[offs + 3] >> 7)) & 0x1ff; + } + + old_x = sx_base; + old_y = sy_base; + + flipx = attrib & GP9001_SPRITE_FLIPX; + flipy = attrib & GP9001_SPRITE_FLIPY; + + if (flipx) + { + /***** Wrap sprite position around *****/ + sx_base -= 7; + if (sx_base >= 0x1c0) sx_base -= 0x200; + } + else + { + if (sx_base >= 0x180) sx_base -= 0x200; + } + + if (flipy) + { + sy_base -= 7; + if (sy_base >= 0x1c0) sy_base -= 0x200; + } + else + { + if (sy_base >= 0x180) sy_base -= 0x200; + } + + /***** Flip the sprite layer in any active X or Y flip *****/ + if (sprite_flip) + { + if (sprite_flip & GP9001_SPRITE_FLIPX) + sx_base = 320 - sx_base; + if (sprite_flip & GP9001_SPRITE_FLIPY) + sy_base = 240 - sy_base; + } + + /***** Cancel flip, if it, and sprite layer flip are active *****/ + flipx = (flipx ^ (sprite_flip & GP9001_SPRITE_FLIPX)); + flipy = (flipy ^ (sprite_flip & GP9001_SPRITE_FLIPY)); + + /***** Draw the complete sprites using the dimension info *****/ + for (dim_y = 0; dim_y < sprite_sizey; dim_y += 8) + { + if (flipy) sy = sy_base - dim_y; + else sy = sy_base + dim_y; + for (dim_x = 0; dim_x < sprite_sizex; dim_x += 8) + { + if (flipx) sx = sx_base - dim_x; + else sx = sx_base + dim_x; + + /* + drawgfx_transpen(bitmap,cliprect,gfx,sprite, + color, + flipx,flipy, + sx,sy,0); + */ + sprite %= gfx->total_elements; + color %= gfx->total_colors; + + { + int yy, xx; + const pen_t *paldata = &gfx->machine->pens[gfx->color_base + gfx->color_granularity * color]; + const UINT8* srcdata = gfx_element_get_data(gfx, sprite); + int count = 0; + int ystart, yend, yinc; + int xstart, xend, xinc; + + if (flipy) + { + ystart = 7; + yend = -1; + yinc = -1; + } + else + { + ystart = 0; + yend = 8; + yinc = 1; + } + + if (flipx) + { + xstart = 7; + xend = -1; + xinc = -1; + } + else + { + xstart = 0; + xend = 8; + xinc = 1; + } + + for (yy=ystart;yy!=yend;yy+=yinc) + { + int drawyy = yy+sy; + + + for (xx=xstart;xx!=xend;xx+=xinc) + { + int drawxx = xx+sx; + + if (drawxx>=cliprect->min_x && drawxx<=cliprect->max_x && drawyy>=cliprect->min_y && drawyy<=cliprect->max_y) + { + UINT8 pix = srcdata[count]; + UINT16* dstptr = BITMAP_ADDR16(bitmap,drawyy,drawxx); + UINT8* dstpri = BITMAP_ADDR8(gp9001_custom_priority_bitmap, drawyy, drawxx); + + if (priority >= dstpri[0]) + { + if (pix&0xf) + { + dstptr[0] = paldata[pix]; + dstpri[0] = priority; + + } + } + } + + + count++; + } + } + + + } + + sprite++ ; + } + } + } + } +} + + +/*************************************************************************** + Draw the game screen in the given bitmap_t. +***************************************************************************/ + +void gp9001vdp_device::gp9001_draw_custom_tilemap(running_machine* machine, bitmap_t* bitmap, tilemap_t* tilemap, const UINT8* priremap, const UINT8* pri_enable ) +{ + int width = machine->primary_screen->width(); + int height = machine->primary_screen->height(); + int y,x; + bitmap_t *tmb = tilemap_get_pixmap(tilemap); + UINT16* srcptr; + UINT16* dstptr; + UINT8* dstpriptr; + + int scrollx = tilemap_get_scrollx(tilemap, 0); + int scrolly = tilemap_get_scrolly(tilemap, 0); + + for (y=0;y>12); + + if (pri_enable[pixpri]) + { + pixpri = priremap[pixpri]+1; // priority of 0 isn't desireable + pixdat &=0x07ff; + + if (pixdat&0xf) + { + if (pixpri >= dstpriptr[x]) + { + dstptr[x] = pixdat; + dstpriptr[x] = pixpri; + } + } + } + } + } +} + + +static const UINT8 gp9001_primap1[16] = { 0x00, 0x04, 0x08, 0x0c, 0x10, 0x14, 0x18, 0x1c, 0x20, 0x24, 0x28, 0x2c, 0x30, 0x34, 0x38, 0x3c }; +//UINT8 gp9001_sprprimap1[16] = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f }; +static const UINT8 gp9001_sprprimap1[16] = { 0x00, 0x04, 0x08, 0x0c, 0x10, 0x14, 0x18, 0x1c, 0x20, 0x24, 0x28, 0x2c, 0x30, 0x34, 0x38, 0x3c }; + +static const UINT8 batsugun_prienable0[16]={ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }; + +void gp9001vdp_device::gp9001_render_vdp(running_machine* machine, bitmap_t* bitmap, const rectangle* cliprect) +{ + if (gp9001_gfxrom_is_banked && gp9001_gfxrom_bank_dirty) + { + tilemap_mark_all_tiles_dirty(bg_tilemap); + tilemap_mark_all_tiles_dirty(fg_tilemap); + gp9001_gfxrom_bank_dirty = 0; + } + + gp9001_draw_custom_tilemap( machine, bitmap, bg_tilemap, gp9001_primap1, batsugun_prienable0); + gp9001_draw_custom_tilemap( machine, bitmap, fg_tilemap, gp9001_primap1, batsugun_prienable0); + gp9001_draw_custom_tilemap( machine, bitmap, top_tilemap, gp9001_primap1, batsugun_prienable0); + draw_sprites( machine,bitmap,cliprect, gp9001_sprprimap1); +} + + +void gp9001vdp_device::gp9001_video_eof(void) +{ + /** Shift sprite RAM buffers *** Used to fix sprite lag **/ + memcpy(spriteram16_now,spriteram16_new,GP9001_SPRITERAM_SIZE); +} + + + diff --git a/src/mame/video/gp9001.h b/src/mame/video/gp9001.h new file mode 100644 index 00000000000..bae559a6e85 --- /dev/null +++ b/src/mame/video/gp9001.h @@ -0,0 +1,126 @@ +/* GP9001 Video Controller */ + +extern bitmap_t* gp9001_custom_priority_bitmap; + +class gp9001vdp_device_config : public device_config, + public device_config_memory_interface +{ + friend class gp9001vdp_device; + gp9001vdp_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock); +public: + static device_config *static_alloc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock); + virtual device_t *alloc_device(running_machine &machine) const; +protected: + virtual void device_config_complete(); + virtual bool device_validity_check(const game_driver &driver) const; + virtual const address_space_config *memory_space_config(int spacenum = 0) const; + address_space_config m_space_config; + UINT8 m_gfxregion; + +}; + +class gp9001vdp_device : public device_t, + public device_memory_interface +{ + friend class gp9001vdp_device_config; + gp9001vdp_device(running_machine &_machine, const gp9001vdp_device_config &config); +public: + UINT16 gp9001_voffs; + UINT16 *bgvideoram16; + UINT16 *fgvideoram16; + UINT16 *topvideoram16; + + UINT16 *spriteram16_now; /* Sprites to draw this frame */ + UINT16 *spriteram16_new; /* Sprites to add to next frame */ + UINT16 *spriteram16_n; + + UINT16 gp9001_scroll_reg; + UINT16 bg_scrollx; + UINT16 bg_scrolly; + UINT16 fg_scrollx; + UINT16 fg_scrolly; + UINT16 top_scrollx; + UINT16 top_scrolly; + UINT16 sprite_scrollx; + UINT16 sprite_scrolly; + + UINT8 bg_flip; + UINT8 fg_flip; + UINT8 top_flip; + UINT8 sprite_flip; + + UINT16 tile_limit; // prevent bad tile in Batsugun, might be something like the CPS1 tile addressing limits? + int tile_region; // we also use this to figure out which vdp we're using in some debug logging features + tilemap_t *top_tilemap, *fg_tilemap, *bg_tilemap; + + // debug + int display_bg; + int display_fg; + int display_top; + int display_sp; + + // technically this is just rom banking, allowing the chip to see more graphic ROM, however it's easier to handle it + // in the chip implementation than externally for now (which would require dynamic decoding of the entire charsets every + // time the bank was changed) + int gp9001_gfxrom_is_banked; + int gp9001_gfxrom_bank_dirty; /* dirty flag of object bank (for Batrider) */ + UINT16 gp9001_gfxrom_bank[8]; /* Batrider object bank */ + + + void draw_sprites( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, const UINT8* primap ); + void gp9001_draw_custom_tilemap(running_machine* machine, bitmap_t* bitmap, tilemap_t* tilemap, const UINT8* priremap, const UINT8* pri_enable ); + void gp9001_render_vdp(running_machine* machine, bitmap_t* bitmap, const rectangle* cliprect); + void gp9001_video_eof(void); + + // offset kludges, needed by fixeight bootleg + int extra_xoffset[4]; + int extra_yoffset[4]; + +protected: + virtual void device_start(); + virtual void device_reset(); + const gp9001vdp_device_config &m_config; + UINT8 m_gfxregion; + +}; + +const device_type gp9001vdp_ = gp9001vdp_device_config::static_alloc_device_config; + +#define GP9001_BG_VRAM_SIZE 0x1000 /* Background RAM size */ +#define GP9001_FG_VRAM_SIZE 0x1000 /* Foreground RAM size */ +#define GP9001_TOP_VRAM_SIZE 0x1000 /* Top Layer RAM size */ +#define GP9001_SPRITERAM_SIZE 0x800 /* Sprite RAM size */ +#define GP9001_SPRITE_FLIPX 0x1000 /* Sprite flip flags */ +#define GP9001_SPRITE_FLIPY 0x2000 + + +ADDRESS_MAP_EXTERN( gp9001vdp0_map, 16 ); +ADDRESS_MAP_EXTERN( gp9001vdp1_map, 16 ); +extern int gp9001_displog; + + +/* vdp map 0, gfx region 0 */ +#define MDRV_DEVICE_ADD_VDP0 \ + MDRV_DEVICE_ADD("gp9001vdp0", gp9001vdp_, 0) \ + MDRV_DEVICE_ADDRESS_MAP(0, gp9001vdp0_map) MDRV_DEVICE_INLINE_DATA16(0, 0) \ + +/* vdp map 1, gfx region 2 */ +#define MDRV_DEVICE_ADD_VDP1 \ + MDRV_DEVICE_ADD("gp9001vdp1", gp9001vdp_, 0) \ + MDRV_DEVICE_ADDRESS_MAP(0, gp9001vdp1_map) MDRV_DEVICE_INLINE_DATA16(0, 2) \ + + +// access to VDP +READ16_DEVICE_HANDLER( gp9001_vdp_r ); +WRITE16_DEVICE_HANDLER( gp9001_vdp_w ); +READ16_DEVICE_HANDLER( gp9001_vdp_alt_r ); +WRITE16_DEVICE_HANDLER( gp9001_vdp_alt_w ); +// this bootleg has strange access +READ16_DEVICE_HANDLER ( pipibibi_bootleg_videoram16_r ); +WRITE16_DEVICE_HANDLER( pipibibi_bootleg_videoram16_w ); +READ16_DEVICE_HANDLER ( pipibibi_bootleg_spriteram16_r ); +WRITE16_DEVICE_HANDLER( pipibibi_bootleg_spriteram16_w ); +WRITE16_DEVICE_HANDLER( pipibibi_bootleg_scroll_w ); + +void gp9001_log_vram(gp9001vdp_device* vdp, running_machine *machine); + diff --git a/src/mame/video/toaplan2.c b/src/mame/video/toaplan2.c index 8d4e876e6c3..d3054b7f8ca 100644 --- a/src/mame/video/toaplan2.c +++ b/src/mame/video/toaplan2.c @@ -1,93 +1,7 @@ /*************************************************************************** - Functions to emulate the video hardware of some Toaplan games, - which use one or more Toaplan L7A0498 GP9001 graphic controllers. - - The simpler hardware of these games use one GP9001 controller. - Next we have games that use two GP9001 controllers, whose priority - schemes between the two controllers is unknown at this time, and - may be game dependant. - Finally we have games using one GP9001 controller and an additional - text tile layer, which has highest priority. This text tile layer - appears to have line-scroll support. Some of these games copy the - text tile gfx data to RAM from the main CPU ROM, which easily allows - for effects to be added to the tiles, by manipulating the text tile - gfx data. The tiles are then dynamically decoded from RAM before - displaying them. - - - To Do / Unknowns - - Hack is needed to reset sound CPU and sound chip when machine - is 'tilted' in Pipi & Bibis. Otherwise sound CPU interferes - with the main CPU test of shared RAM. You get a 'Sub CPU RAM Error' - - What do Scroll registers 0Eh and 0Fh really do ???? - - Snow Bros 2 sets bit 6 of the sprite X info word during weather - world map, and bits 4, 5 and 6 of the sprite X info word during - the Rabbit boss screen - reasons are unknown. - - Fourth set of scroll registers have been used for Sprite scroll - though it may not be correct. For most parts this looks right - except for Snow Bros 2 when in the rabbit boss screen (all sprites - jump when big green nasty (which is the foreground layer) comes - in from the left) - - Teki Paki tests video RAM from address 0 past SpriteRAM to $37ff. - This seems to be a bug in Teki Paki's vram test routine ! - - Batsugun, relationship between the two video controllers (priority - wise) is wrong and unknown. - - - GP9001 Video RAM address layout: - - Bank data size of video layer - ----------------------------------------- - $0000-07FF 800h words for background layer - $0800-0FFF 800h words for foreground layer - $1000-17FF 800h words for top (text) layer - $1800-1BFF 400h words for sprites (100 possible sprites) - - - - GP9001 Tile RAM format (each tile takes up 32 bits) - - 0 1 2 3 - ---- ---- ---- ---- xxxx xxxx xxxx xxxx = Tile number (0 - FFFFh) - ---- ---- -xxx xxxx ---- ---- ---- ---- = Color (0 - 7Fh) - ---- ---- ?--- ---- ---- ---- ---- ---- = unknown / unused - ---- xxxx ---- ---- ---- ---- ---- ---- = Priority (0 - Fh) - ???? ---- ---- ---- ---- ---- ---- ---- = unknown / unused / possible flips - -Sprites are of varying sizes between 8x8 and 128x128 with any variation -in between, in multiples of 8 either way. - -Here we draw the first 8x8 part of the sprite, then by using the sprite -dimensions, we draw the rest of the 8x8 parts to produce the complete -sprite. - -There seems to be sprite buffering - double buffering actually. - - GP9001 Sprite RAM format (data for each sprite takes up 4 words) - - 0 - ---- ---- ---- --xx = top 2 bits of Sprite number - ---- ---- xxxx xx-- = Color (0 - 3Fh) - ---- xxxx ---- ---- = Priority (0 - Fh) - ---x ---- ---- ---- = Flip X - --x- ---- ---- ---- = Flip Y - -x-- ---- ---- ---- = Multi-sprite - x--- ---- ---- ---- = Show sprite ? - - 1 - xxxx xxxx xxxx xxxx = Sprite number (top two bits in word 0) - - 2 - ---- ---- ---- xxxx = Sprite X size (add 1, then multiply by 8) - ---- ---- -??? ---- = unknown - used in Snow Bros. 2 - xxxx xxxx x--- ---- = X position - - 3 - ---- ---- ---- xxxx = Sprite Y size (add 1, then multiply by 8) - ---- ---- -??? ---- = unknown / unused - xxxx xxxx x--- ---- = Y position - + Functions to emulate additional video hardware on several Toaplan2 games. + The main video is handled by the GP9001 (see video gp9001.c) Extra-text RAM format @@ -105,43 +19,6 @@ There seems to be sprite buffering - double buffering actually. ---- ---x xxxx xxxx = X-Scroll for each line - - GP9001 Scroll Registers (hex) : - - 00 Background scroll X (X flip off) - 01 Background scroll Y (Y flip off) - 02 Foreground scroll X (X flip off) - 03 Foreground scroll Y (Y flip off) - 04 Top (text) scroll X (X flip off) - 05 Top (text) scroll Y (Y flip off) - 06 Sprites scroll X (X flip off) ??? - 07 Sprites scroll Y (Y flip off) ??? - 0E ??? Initialise Video controller at startup ??? - 0F Scroll update complete ??? (Not used in Ghox and V-Five) - - 80 Background scroll X (X flip on) - 81 Background scroll Y (Y flip on) - 82 Foreground scroll X (X flip on) - 83 Foreground scroll Y (Y flip on) - 84 Top (text) scroll X (X flip on) - 85 Top (text) scroll Y (Y flip on) - 86 Sprites scroll X (X flip on) ??? - 87 Sprites scroll Y (Y flip on) ??? - 8F Same as 0Fh except flip bit is active - - -Scroll Register 0E writes (Video controller inits ?) from different games: - -Teki-Paki | Ghox | Knuckle Bash | Truxton 2 | -0003, 0002, 4000 | ????, ????, ???? | 0202, 0203, 4200 | 0003, 0002, 4000 | - -Dogyuun | Batsugun | -0202, 0203, 4200 | 0202, 0203, 4200 | -1202, 1203, 5200 | 1202, 1203, 5200 | <--- Second video controller - -Pipi & Bibis | Fix Eight | V-Five | Snow Bros. 2 | -0003, 0002, 4000 | 0202, 0203, 4200 | 0202, 0203, 4200 | 0202, 0203, 4200 | - ***************************************************************************/ #include "emu.h" @@ -149,23 +26,7 @@ Pipi & Bibis | Fix Eight | V-Five | Snow Bros. 2 | #include "sound/3812intf.h" #include "includes/toaplan2.h" - - -#define TOAPLAN2_BG_VRAM_SIZE 0x1000 /* Background RAM size */ -#define TOAPLAN2_FG_VRAM_SIZE 0x1000 /* Foreground RAM size */ -#define TOAPLAN2_TOP_VRAM_SIZE 0x1000 /* Top Layer RAM size */ -#define TOAPLAN2_SPRITERAM_SIZE 0x800 /* Sprite RAM size */ -#define TOAPLAN2_UNUSEDRAM_SIZE 0x800 /* Unused RAM size */ #define RAIZING_TX_GFXRAM_SIZE 0x8000 /* GFX data decode RAM size */ -size_t toaplan2_tx_vram_size; /* 0x2000 Text layer RAM size */ -size_t toaplan2_tx_offs_vram_size; /* 0x200 Text layer tile flip and positon ? */ -size_t toaplan2_tx_scroll_vram_size; /* 0x200 Text layer scroll ? */ -size_t batrider_paletteram16_size; - - - -#define TOAPLAN2_SPRITE_FLIPX 0x1000 /* Sprite flip flags */ -#define TOAPLAN2_SPRITE_FLIPY 0x2000 #define CPU_2_NONE 0x00 #define CPU_2_Z80 0x5a @@ -173,329 +34,31 @@ size_t batrider_paletteram16_size; #define CPU_2_V25 0xff -static UINT16 *bgvideoram16[2]; -static UINT16 *fgvideoram16[2]; -static UINT16 *topvideoram16[2]; -static UINT16 *spriteram16_now[2]; /* Sprites to draw this frame */ -static UINT16 *spriteram16_new[2]; /* Sprites to add to next frame */ -static UINT16 *spriteram16_n[2]; + UINT16 *toaplan2_txvideoram16; /* Video ram for extra text layer */ UINT16 *toaplan2_txvideoram16_offs; /* Text layer tile flip and positon ? */ UINT16 *toaplan2_txscrollram16; /* Text layer scroll ? */ UINT16 *toaplan2_tx_gfxram16; /* Text Layer RAM based tiles */ UINT16 *raizing_tx_gfxram16; /* Text Layer RAM based tiles (Batrider) */ -static UINT16 toaplan2_scroll_reg[2]; -UINT16 toaplan2_voffs[2]; -static UINT16 bg_scrollx[2]; -static UINT16 bg_scrolly[2]; -static UINT16 fg_scrollx[2]; -static UINT16 fg_scrolly[2]; -static UINT16 top_scrollx[2]; -static UINT16 top_scrolly[2]; -static UINT16 sprite_scrollx[2]; -static UINT16 sprite_scrolly[2]; -static int objectbank_dirty = 0; /* dirty flag of object bank (for Batrider) */ -static UINT16 batrider_object_bank[8]; /* Batrider object bank */ +size_t toaplan2_tx_vram_size; /* 0x2000 Text layer RAM size */ +size_t toaplan2_tx_offs_vram_size; /* 0x200 Text layer tile flip and positon ? */ +size_t toaplan2_tx_scroll_vram_size; /* 0x200 Text layer scroll ? */ +size_t batrider_paletteram16_size; -static bitmap_t* toaplan2_custom_priority_bitmap; -static UINT16 tile_limit[2]; // prevent bad tile in Batsugun, might be something like the CPS1 tile addressing limits? -static int toaplan2_banked_gfx; - -#ifdef MAME_DEBUG -static int display_bg[2]; -static int display_fg[2]; -static int display_top[2]; -static int displog = 0; static int display_tx; -#endif -static int display_sp[2]; - -static UINT8 bg_flip[2] = { 0, 0 }; -static UINT8 fg_flip[2] = { 0, 0 }; -static UINT8 top_flip[2] = { 0, 0 }; -static UINT8 sprite_flip[2] = { 0, 0 }; static UINT8 tx_flip = 0; -static UINT8 sprite_priority[2][16]; -static UINT8 top_tile_priority[2][16]; -static UINT8 fg_tile_priority[2][16]; -static UINT8 bg_tile_priority[2][16]; - - -static tilemap_t *top_tilemap[2], *fg_tilemap[2], *bg_tilemap[2]; static tilemap_t *tx_tilemap; /* Tilemap for extra-text-layer */ -static int xoffset[4]; -static int yoffset[4]; - -static void defaultOffsets(void) -{ - xoffset[0]=0; - xoffset[1]=0; - xoffset[2]=0; - xoffset[3]=0; - - yoffset[0]=0; - yoffset[1]=0; - yoffset[2]=0; - yoffset[3]=0; -} - - - -WRITE16_HANDLER( toaplan2_bg_tilemap_w) -{ - int controller = 0; - COMBINE_DATA(&bgvideoram16[controller][offset]); - tilemap_mark_tile_dirty(bg_tilemap[controller],offset/2); -} - -WRITE16_HANDLER( toaplan2_fg_tilemap_w ) -{ - int controller = 0; - COMBINE_DATA(&fgvideoram16[controller][offset]); - tilemap_mark_tile_dirty(fg_tilemap[controller],offset/2); -} - -WRITE16_HANDLER( toaplan2_top_tilemap_w ) -{ - int controller = 0; - COMBINE_DATA(&topvideoram16[controller][offset]); - tilemap_mark_tile_dirty(top_tilemap[controller],offset/2); -} - - -WRITE16_HANDLER( toaplan2_spram_w ) -{ - int controller = 0; - COMBINE_DATA(&spriteram16_new[controller][offset]); -} - -READ16_HANDLER( toaplan2_bg_tilemap_r ) -{ - int controller = 0; - return bgvideoram16[controller][offset]; -} - -READ16_HANDLER( toaplan2_fg_tilemap_r ) -{ - int controller = 0; - return fgvideoram16[controller][offset]; -} - -READ16_HANDLER( toaplan2_top_tilemap_r ) -{ - int controller = 0; - return topvideoram16[controller][offset]; -} - -READ16_HANDLER( toaplan2_spram_r ) -{ - int controller = 0; - return spriteram16_new[controller][offset]; -} - - - -WRITE16_HANDLER( toaplan2_bg_tilemap1_w) -{ - int controller = 1; - COMBINE_DATA(&bgvideoram16[controller][offset]); - tilemap_mark_tile_dirty(bg_tilemap[controller],offset/2); -} - -WRITE16_HANDLER( toaplan2_fg_tilemap1_w ) -{ - int controller = 1; - COMBINE_DATA(&fgvideoram16[controller][offset]); - tilemap_mark_tile_dirty(fg_tilemap[controller],offset/2); -} - -WRITE16_HANDLER( toaplan2_top_tilemap1_w ) -{ - int controller = 1; - COMBINE_DATA(&topvideoram16[controller][offset]); - tilemap_mark_tile_dirty(top_tilemap[controller],offset/2); -} - - -WRITE16_HANDLER( toaplan2_spram1_w ) -{ - int controller = 1; - COMBINE_DATA(&spriteram16_new[controller][offset]); -} - -READ16_HANDLER( toaplan2_bg_tilemap1_r ) -{ - int controller = 1; - return bgvideoram16[controller][offset]; -} - -READ16_HANDLER( toaplan2_fg_tilemap1_r ) -{ - int controller = 1; - return fgvideoram16[controller][offset]; -} - -READ16_HANDLER( toaplan2_top_tilemap1_r ) -{ - int controller = 1; - return topvideoram16[controller][offset]; -} - -READ16_HANDLER( toaplan2_spram1_r ) -{ - int controller = 1; - return spriteram16_new[controller][offset]; -} - /*************************************************************************** Callbacks for the TileMap code ***************************************************************************/ -static TILE_GET_INFO( get_top0_tile_info ) -{ - int color, tile_number, attrib; - - attrib = topvideoram16[0][2*tile_index]; - - tile_number = topvideoram16[0][2*tile_index+1]; - - if (toaplan2_banked_gfx) - { - tile_number = ( batrider_object_bank[(tile_number >> 13) & 7] << 13 ) | ( tile_number & 0x1fff ); - } - else - { - if (tile_number>tile_limit[0]) - { - tile_number = 0; - } - } - - color = attrib & 0x0fff; // 0x0f00 priority, 0x007f colour - SET_TILE_INFO( - 0, - tile_number, - color, - 0); - //tileinfo->category = (attrib & 0x0f00) >> 8; -} - -static TILE_GET_INFO( get_fg0_tile_info ) -{ - int color, tile_number, attrib; - - attrib = fgvideoram16[0][2*tile_index]; - - tile_number = fgvideoram16[0][2*tile_index+1]; - - - if (toaplan2_banked_gfx) - { - tile_number = ( batrider_object_bank[(tile_number >> 13) & 7] << 13 ) | ( tile_number & 0x1fff ); - } - else - { - if (tile_number>tile_limit[0]) tile_number = 0; - } - - - color = attrib & 0x0fff; // 0x0f00 priority, 0x007f colour - SET_TILE_INFO( - 0, - tile_number, - color, - 0); - //tileinfo->category = (attrib & 0x0f00) >> 8; -} - -static TILE_GET_INFO( get_bg0_tile_info ) -{ - int color, tile_number, attrib; - - attrib = bgvideoram16[0][2*tile_index]; - - tile_number = bgvideoram16[0][2*tile_index+1]; - - if (toaplan2_banked_gfx) - { - tile_number = ( batrider_object_bank[(tile_number >> 13) & 7] << 13 ) | ( tile_number & 0x1fff ); - } - else - { - if (tile_number>tile_limit[0]) tile_number = 0; - } - - color = attrib & 0x0fff; // 0x0f00 priority, 0x007f colour - SET_TILE_INFO( - 0, - tile_number, - color, - 0); - //tileinfo->category = (attrib & 0x0f00) >> 8; -} - -static TILE_GET_INFO( get_top1_tile_info ) -{ - int color, tile_number, attrib; - - attrib = topvideoram16[1][2*tile_index]; - tile_number = topvideoram16[1][2*tile_index+1]; - - if (tile_number>tile_limit[1]) tile_number = 0; - - color = attrib & 0x0fff; // 0x0f00 priority, 0x007f colour - SET_TILE_INFO( - 2, - tile_number, - color, - 0); - //tileinfo->category = (attrib & 0x0f00) >> 8; -} - -static TILE_GET_INFO( get_fg1_tile_info ) -{ - int color, tile_number, attrib; - - attrib = fgvideoram16[1][2*tile_index]; - tile_number = fgvideoram16[1][2*tile_index+1]; - - if (tile_number>tile_limit[1]) tile_number = 0; - - color = attrib & 0x0fff; // 0x0f00 priority, 0x007f colour - SET_TILE_INFO( - 2, - tile_number, - color, - 0); - //tileinfo->category = (attrib & 0x0f00) >> 8; -} - -static TILE_GET_INFO( get_bg1_tile_info ) -{ - int color, tile_number, attrib; - - attrib = bgvideoram16[1][2*tile_index]; - tile_number = bgvideoram16[1][2*tile_index+1]; - - if (tile_number>tile_limit[1]) tile_number = 0; - - color = attrib & 0x0fff; // 0x0f00 priority, 0x007f colour - SET_TILE_INFO( - 2, - tile_number, - color, - 0); - //tileinfo->category = (attrib & 0x0f00) >> 8; -} - - static TILE_GET_INFO( get_text_tile_info ) { int color, tile_number, attrib; @@ -515,262 +78,98 @@ static TILE_GET_INFO( get_text_tile_info ) Start the video hardware emulation. ***************************************************************************/ -static void create_tilemaps_0(running_machine *machine) + + +static void truxton2_create_tx_tilemap(running_machine *machine) { - top_tilemap[0] = tilemap_create(machine, get_top0_tile_info,tilemap_scan_rows,16,16,32,32); - fg_tilemap[0] = tilemap_create(machine, get_fg0_tile_info,tilemap_scan_rows,16,16,32,32); - bg_tilemap[0] = tilemap_create(machine, get_bg0_tile_info,tilemap_scan_rows,16,16,32,32); - tile_limit[0] = 0xffff; - - tilemap_set_transparent_pen(top_tilemap[0],0); - tilemap_set_transparent_pen(fg_tilemap[0],0); - tilemap_set_transparent_pen(bg_tilemap[0],0); -} - -static void create_tilemaps_1(running_machine *machine) -{ - top_tilemap[1] = tilemap_create(machine, get_top1_tile_info,tilemap_scan_rows,16,16,32,32); - fg_tilemap[1] = tilemap_create(machine, get_fg1_tile_info,tilemap_scan_rows,16,16,32,32); - bg_tilemap[1] = tilemap_create(machine, get_bg1_tile_info,tilemap_scan_rows,16,16,32,32); - tile_limit[1] = 0xffff; - - tilemap_set_transparent_pen(top_tilemap[1],0); - tilemap_set_transparent_pen(fg_tilemap[1],0); - tilemap_set_transparent_pen(bg_tilemap[1],0); -} - -static void truxton2_create_tilemaps_0(running_machine *machine) -{ - create_tilemaps_0(machine); - tx_tilemap = tilemap_create(machine, get_text_tile_info,tilemap_scan_rows,8,8,64,32); tilemap_set_scroll_rows(tx_tilemap,8*32); /* line scrolling */ tilemap_set_scroll_cols(tx_tilemap,1); tilemap_set_transparent_pen(tx_tilemap,0); } -static void batrider_create_tilemaps_0(running_machine *machine) +static void register_state_save(running_machine *machine) { - create_tilemaps_0(machine); - - tx_tilemap = tilemap_create(machine, get_text_tile_info,tilemap_scan_rows,8,8,64,32); - - tilemap_set_scroll_rows(tx_tilemap,8*32); /* line scrolling */ - tilemap_set_scroll_cols(tx_tilemap,1); - tilemap_set_transparent_pen(tx_tilemap,0); -} - - -static void toaplan2_vram_alloc(running_machine *machine, int controller) -{ - spriteram16_new[controller] = auto_alloc_array_clear(machine, UINT16, TOAPLAN2_SPRITERAM_SIZE/2); - spriteram16_now[controller] = auto_alloc_array_clear(machine, UINT16, TOAPLAN2_SPRITERAM_SIZE/2); - topvideoram16[controller] = auto_alloc_array_clear(machine, UINT16, TOAPLAN2_TOP_VRAM_SIZE/2); - fgvideoram16[controller] = auto_alloc_array_clear(machine, UINT16, TOAPLAN2_FG_VRAM_SIZE/2); - bgvideoram16[controller] = auto_alloc_array_clear(machine, UINT16, TOAPLAN2_BG_VRAM_SIZE/2); - - spriteram16_n[controller] = spriteram16_now[controller]; -} - -static void toaplan2_vh_start(running_machine *machine, int controller) -{ - int width = machine->primary_screen->width(); - int height = machine->primary_screen->height(); - - toaplan2_vram_alloc(machine, controller); - - toaplan2_custom_priority_bitmap = auto_bitmap_alloc(machine, width, height, BITMAP_FORMAT_INDEXED8); - - if (controller == 0) - { - create_tilemaps_0(machine); - } - if (controller == 1) - { - create_tilemaps_1(machine); - } - -#ifdef MAME_DEBUG - display_bg[controller] = 1; - display_fg[controller] = 1; - display_top[controller] = 1; - displog = 0; - display_tx = 1; -#endif - - display_sp[controller] = 1; -} - -static void register_state_save(running_machine *machine, int vrams) -{ - state_save_register_global_array(machine, toaplan2_scroll_reg); - state_save_register_global_array(machine, toaplan2_voffs); - state_save_register_global_array(machine, bg_scrollx); - state_save_register_global_array(machine, bg_scrolly); - state_save_register_global_array(machine, fg_scrollx); - state_save_register_global_array(machine, fg_scrolly); - state_save_register_global_array(machine, top_scrollx); - state_save_register_global_array(machine, top_scrolly); - state_save_register_global_array(machine, sprite_scrollx); - state_save_register_global_array(machine, sprite_scrolly); - state_save_register_global_array(machine, batrider_object_bank); - - state_save_register_global_array(machine, bg_flip); - state_save_register_global_array(machine, fg_flip); - state_save_register_global_array(machine, top_flip); - state_save_register_global_array(machine, sprite_flip); state_save_register_global(machine, tx_flip); - - state_save_register_global_2d_array(machine, sprite_priority); - state_save_register_global_2d_array(machine, top_tile_priority); - state_save_register_global_2d_array(machine, fg_tile_priority); - state_save_register_global_2d_array(machine, bg_tile_priority); - - switch (vrams) - { - case 2: - state_save_register_global_pointer(machine, spriteram16_new[1], TOAPLAN2_SPRITERAM_SIZE/2); - state_save_register_global_pointer(machine, spriteram16_now[1], TOAPLAN2_SPRITERAM_SIZE/2); - state_save_register_global_pointer(machine, topvideoram16[1], TOAPLAN2_TOP_VRAM_SIZE/2); - state_save_register_global_pointer(machine, fgvideoram16[1], TOAPLAN2_FG_VRAM_SIZE/2); - state_save_register_global_pointer(machine, bgvideoram16[1], TOAPLAN2_BG_VRAM_SIZE/2); - /* fall through */ - case 1: - state_save_register_global_pointer(machine, spriteram16_new[0], TOAPLAN2_SPRITERAM_SIZE/2); - state_save_register_global_pointer(machine, spriteram16_now[0], TOAPLAN2_SPRITERAM_SIZE/2); - state_save_register_global_pointer(machine, topvideoram16[0], TOAPLAN2_TOP_VRAM_SIZE/2); - state_save_register_global_pointer(machine, fgvideoram16[0], TOAPLAN2_FG_VRAM_SIZE/2); - state_save_register_global_pointer(machine, bgvideoram16[0], TOAPLAN2_BG_VRAM_SIZE/2); - /* fall through */ - default: - break; - } - } -VIDEO_START( toaplan2_0 ) -{ - defaultOffsets(); - toaplan2_vh_start(machine, 0); - register_state_save(machine,1); - toaplan2_banked_gfx = 0; -} -VIDEO_START( toaplan2_1 ) -{ - toaplan2_vh_start(machine, 0); - toaplan2_vh_start(machine, 1); - defaultOffsets(); - register_state_save(machine,2); - toaplan2_banked_gfx = 0; -} - -VIDEO_START( truxton2_0 ) +VIDEO_START( toaplan2 ) { int width = machine->primary_screen->width(); int height = machine->primary_screen->height(); - toaplan2_vram_alloc(machine, 0); - truxton2_create_tilemaps_0(machine); + /* cache the VDP device */ + toaplan2_state *state = machine->driver_data(); + state->vdp0 = machine->device("gp9001vdp0"); + state->vdp1 = machine->device("gp9001vdp1"); - toaplan2_custom_priority_bitmap = auto_bitmap_alloc(machine, width, height, BITMAP_FORMAT_INDEXED8); + /* our current VDP implementation needs this bitmap to work with */ + gp9001_custom_priority_bitmap = auto_bitmap_alloc(machine, width, height, BITMAP_FORMAT_INDEXED8); + gp9001_displog = 0; // debug flag + + display_tx = 1; + + register_state_save(machine); +} + +VIDEO_START( truxton2 ) +{ + VIDEO_START_CALL( toaplan2 ); + + /* Create the Text tilemap for this game */ + truxton2_create_tx_tilemap(machine); if (machine->gfx[2]->srcdata == NULL) gfx_element_set_source(machine->gfx[2], (UINT8 *)toaplan2_tx_gfxram16); - - if(!strcmp(machine->gamedrv->name,"fixeightb")) - { - xoffset[0]=-26; - xoffset[1]=-22; - xoffset[2]=-18; - xoffset[3]=8; - - yoffset[0]=-15; - yoffset[1]=-15; - yoffset[2]=-15; - yoffset[3]=8; - tilemap_set_scrolldx(tx_tilemap, 0, 0); - } - else - { - defaultOffsets(); - tilemap_set_scrolldx(tx_tilemap, 0x1d4 +1, 0x2a); - } - - display_sp[0] = 1; - register_state_save(machine,1); - toaplan2_banked_gfx = 0; + tilemap_set_scrolldx(tx_tilemap, 0x1d4 +1, 0x2a); } -VIDEO_START( bgaregga_0 ) +VIDEO_START( fixeighb ) { - int width = machine->primary_screen->width(); - int height = machine->primary_screen->height(); + toaplan2_state *state = machine->driver_data(); - toaplan2_custom_priority_bitmap = auto_bitmap_alloc(machine, width, height, BITMAP_FORMAT_INDEXED8); + VIDEO_START_CALL( truxton2 ); + + /* This bootleg has additional layer offsets on the VDP */ + state->vdp0->extra_xoffset[0]=-26; + state->vdp0->extra_xoffset[1]=-22; + state->vdp0->extra_xoffset[2]=-18; + state->vdp0->extra_xoffset[3]=8; - toaplan2_vram_alloc(machine, 0); - truxton2_create_tilemaps_0(machine); + state->vdp0->extra_yoffset[0]=-15; + state->vdp0->extra_yoffset[1]=-15; + state->vdp0->extra_yoffset[2]=-15; + state->vdp0->extra_yoffset[3]=8; + + tilemap_set_scrolldx(tx_tilemap, 0, 0); +} + +VIDEO_START( bgaregga ) +{ + VIDEO_START_CALL( toaplan2 ); + + /* Create the Text tilemap for this game */ + truxton2_create_tx_tilemap(machine); tilemap_set_scrolldx(tx_tilemap, 0x1d4, 0x2a); - defaultOffsets(); - display_sp[0] = 1; - display_sp[1] = 1; - register_state_save(machine,1); - toaplan2_banked_gfx = 0; } -VIDEO_START( batrider_0 ) +VIDEO_START( batrider ) { - int width = machine->primary_screen->width(); - int height = machine->primary_screen->height(); - - toaplan2_custom_priority_bitmap = auto_bitmap_alloc(machine, width, height, BITMAP_FORMAT_INDEXED8); + toaplan2_state *state = machine->driver_data(); + VIDEO_START_CALL( toaplan2 ); + state->vdp0->spriteram16_n = state->vdp0->spriteram16_new; + /* Create the Text tilemap for this game */ raizing_tx_gfxram16 = auto_alloc_array_clear(machine, UINT16, RAIZING_TX_GFXRAM_SIZE/2); state_save_register_global_pointer(machine, raizing_tx_gfxram16, RAIZING_TX_GFXRAM_SIZE/2); - gfx_element_set_source(machine->gfx[2], (UINT8 *)raizing_tx_gfxram16); - - toaplan2_vram_alloc(machine, 0); - spriteram16_n[0] = spriteram16_new[0]; - - batrider_create_tilemaps_0(machine); - + truxton2_create_tx_tilemap(machine); tilemap_set_scrolldx(tx_tilemap, 0x1d4, 0x2a); - defaultOffsets(); - display_sp[0] = 1; - display_sp[1] = 1; - register_state_save(machine,1); - toaplan2_banked_gfx = 1; -} - - -/*************************************************************************** - - Video I/O port hardware. - -***************************************************************************/ - -static void toaplan2_voffs_w(offs_t offset, UINT16 data, UINT16 mem_mask, int controller) -{ - if (data >= 0x1c00) - logerror("Hmmm, unknown video controller %01x layer being selected (%08x)\n",controller,data); - COMBINE_DATA(&toaplan2_voffs[controller]); -} - -WRITE16_HANDLER( toaplan2_0_voffs_w ) -{ - //printf("toaplan2_0_voffs_w %04x %04x\n",offset,data); - - toaplan2_voffs_w(offset, data, mem_mask, 0); -} - -WRITE16_HANDLER( toaplan2_1_voffs_w ) -{ - //printf("toaplan2_1_voffs_w %04x %04x\n",offset,data); - - toaplan2_voffs_w(offset, data, mem_mask, 1); + + /* Has special banking */ + state->vdp0->gp9001_gfxrom_is_banked = 1; } READ16_HANDLER( toaplan2_txvideoram16_r ) @@ -896,825 +295,75 @@ WRITE16_HANDLER( batrider_textdata_decode ) WRITE16_HANDLER( batrider_objectbank_w ) { + toaplan2_state *state = space->machine->driver_data(); + if (ACCESSING_BITS_0_7) { data &= 0xf; - if (batrider_object_bank[offset] != data) + if (state->vdp0->gp9001_gfxrom_bank[offset] != data) { - batrider_object_bank[offset] = data; - objectbank_dirty = 1; + state->vdp0->gp9001_gfxrom_bank[offset] = data; + state->vdp0->gp9001_gfxrom_bank_dirty = 1; } } } - - -READ16_HANDLER( toaplan2_0_videoram16_r ) +VIDEO_UPDATE( toaplan2 ) { - return toaplan2_videoram16_r(space->machine, offset, 0); -} - -READ16_HANDLER( toaplan2_1_videoram16_r ) -{ - return toaplan2_videoram16_r(space->machine, offset, 1); -} + toaplan2_state *state = screen->machine->driver_data(); -WRITE16_HANDLER( toaplan2_0_videoram16_w ) -{ - toaplan2_videoram16_w(space->machine, offset, data, mem_mask, 0); -} - -WRITE16_HANDLER( toaplan2_1_videoram16_w ) -{ - toaplan2_videoram16_w(space->machine, offset, data, mem_mask, 1); -} - - -static void toaplan2_scroll_reg_select_w(offs_t offset, UINT16 data, UINT16 mem_mask, int controller) -{ - if (ACCESSING_BITS_0_7) + if (state->vdp0) { - toaplan2_scroll_reg[controller] = data & 0x8f; - if (data & 0x70) - logerror("Hmmm, selecting unknown LSB video control register (%04x) Video controller %01x \n",toaplan2_scroll_reg[controller],controller); - } - else - { - logerror("Hmmm, selecting unknown MSB video control register (%04x) Video controller %01x \n",toaplan2_scroll_reg[controller],controller); - } -} + running_device *screen1 = screen->machine->device("screen"); -WRITE16_HANDLER( toaplan2_0_scroll_reg_select_w ) -{ -// printf("toaplan2_scroll_reg_select_w %04x %04x\n",offset,data); + gp9001_log_vram(state->vdp0, screen->machine); - toaplan2_scroll_reg_select_w(offset, data, mem_mask, 0); -} - -WRITE16_HANDLER( toaplan2_1_scroll_reg_select_w ) -{ -// printf("toaplan2_scroll_1_reg_select_w %04x %04x\n",offset,data); - - toaplan2_scroll_reg_select_w(offset, data, mem_mask, 1); -} - - -static void toaplan2_scroll_reg_data_w(running_machine *machine, offs_t offset, UINT16 data, UINT16 mem_mask, int controller) -{ - /************************************************************************/ - /***** layer X and Y flips can be set independently, so emulate it ******/ - /************************************************************************/ - - //printf("toaplan2_scroll_reg_data_w %04x %04x\n", offset, data); -#ifdef MAME_DEBUG - int vid_controllers = 1; -#endif - - switch(toaplan2_scroll_reg[controller]) - { - case 0x00: data -= 0x1d6; /* 1D6h */ - COMBINE_DATA(&bg_scrollx[controller]); - bg_flip[controller] &= (~TILEMAP_FLIPX); - tilemap_set_flip(bg_tilemap[controller],bg_flip[controller]); - tilemap_set_scrollx(bg_tilemap[controller],0,bg_scrollx[controller]+xoffset[0]); - break; - case 0x01: data -= 0x1ef; /* 1EFh */ - COMBINE_DATA(&bg_scrolly[controller]); - bg_flip[controller] &= (~TILEMAP_FLIPY); - tilemap_set_flip(bg_tilemap[controller],bg_flip[controller]); - tilemap_set_scrolly(bg_tilemap[controller],0,bg_scrolly[controller]+yoffset[0]); - break; - case 0x02: data -= 0x1d8; /* 1D0h */ - COMBINE_DATA(&fg_scrollx[controller]); - fg_flip[controller] &= (~TILEMAP_FLIPX); - tilemap_set_flip(fg_tilemap[controller],fg_flip[controller]); - tilemap_set_scrollx(fg_tilemap[controller],0,fg_scrollx[controller]+xoffset[1]); - break; - case 0x03: data -= 0x1ef; /* 1EFh */ - COMBINE_DATA(&fg_scrolly[controller]); - fg_flip[controller] &= (~TILEMAP_FLIPY); - tilemap_set_flip(fg_tilemap[controller],fg_flip[controller]); - tilemap_set_scrolly(fg_tilemap[controller],0,fg_scrolly[controller]+yoffset[1]); - break; - case 0x04: data -= 0x1da; /* 1DAh */ - COMBINE_DATA(&top_scrollx[controller]); - top_flip[controller] &= (~TILEMAP_FLIPX); - tilemap_set_flip(top_tilemap[controller],top_flip[controller]); - tilemap_set_scrollx(top_tilemap[controller],0,top_scrollx[controller]+xoffset[2]); - break; - case 0x05: data -= 0x1ef; /* 1EFh */ - COMBINE_DATA(&top_scrolly[controller]); - top_flip[controller] &= (~TILEMAP_FLIPY); - tilemap_set_flip(top_tilemap[controller],top_flip[controller]); - tilemap_set_scrolly(top_tilemap[controller],0,top_scrolly[controller]+yoffset[2]); - break; - case 0x06: data -= 0x1cc; /* 1D4h */ - COMBINE_DATA(&sprite_scrollx[controller]); - if (sprite_scrollx[controller] & 0x8000) sprite_scrollx[controller] |= 0xfffffe00; - else sprite_scrollx[controller] &= 0x1ff; - sprite_flip[controller] &= (~TOAPLAN2_SPRITE_FLIPX); - break; - case 0x07: data -= 0x1ef; /* 1F7h */ - COMBINE_DATA(&sprite_scrolly[controller]); - if (sprite_scrolly[controller] & 0x8000) sprite_scrolly[controller] |= 0xfffffe00; - else sprite_scrolly[controller] &= 0x1ff; - sprite_flip[controller] &= (~TOAPLAN2_SPRITE_FLIPY); - break; - case 0x0f: break; - case 0x80: data -= 0x229; /* 169h */ - COMBINE_DATA(&bg_scrollx[controller]); - bg_flip[controller] |= TILEMAP_FLIPX; - tilemap_set_flip(bg_tilemap[controller],bg_flip[controller]); - tilemap_set_scrollx(bg_tilemap[controller],0,bg_scrollx[controller]+xoffset[0]); - break; - case 0x81: data -= 0x210; /* 100h */ - COMBINE_DATA(&bg_scrolly[controller]); - bg_flip[controller] |= TILEMAP_FLIPY; - tilemap_set_flip(bg_tilemap[controller],bg_flip[controller]); - tilemap_set_scrolly(bg_tilemap[controller],0,bg_scrolly[controller]+yoffset[0]); - break; - case 0x82: data -= 0x227; /* 15Fh */ - COMBINE_DATA(&fg_scrollx[controller]); - fg_flip[controller] |= TILEMAP_FLIPX; - tilemap_set_flip(fg_tilemap[controller],fg_flip[controller]); - tilemap_set_scrollx(fg_tilemap[controller],0,fg_scrollx[controller]+xoffset[1]); - break; - case 0x83: data -= 0x210; /* 100h */ - COMBINE_DATA(&fg_scrolly[controller]); - fg_flip[controller] |= TILEMAP_FLIPY; - tilemap_set_flip(fg_tilemap[controller],fg_flip[controller]); - tilemap_set_scrolly(fg_tilemap[controller],0,fg_scrolly[controller]+yoffset[1]); - break; - case 0x84: data -= 0x225; /* 165h */ - COMBINE_DATA(&top_scrollx[controller]); - top_flip[controller] |= TILEMAP_FLIPX; - tilemap_set_flip(top_tilemap[controller],top_flip[controller]); - tilemap_set_scrollx(top_tilemap[controller],0,top_scrollx[controller]+xoffset[2]); - break; - case 0x85: data -= 0x210; /* 100h */ - COMBINE_DATA(&top_scrolly[controller]); - top_flip[controller] |= TILEMAP_FLIPY; - tilemap_set_flip(top_tilemap[controller],top_flip[controller]); - tilemap_set_scrolly(top_tilemap[controller],0,top_scrolly[controller]+yoffset[2]); - break; - case 0x86: data -= 0x17b; /* 17Bh */ - COMBINE_DATA(&sprite_scrollx[controller]); - if (sprite_scrollx[controller] & 0x8000) sprite_scrollx[controller] |= 0xfffffe00; - else sprite_scrollx[controller] &= 0x1ff; - sprite_flip[controller] |= TOAPLAN2_SPRITE_FLIPX; - break; - case 0x87: data -= 0x108; /* 108h */ - COMBINE_DATA(&sprite_scrolly[controller]); - if (sprite_scrolly[controller] & 0x8000) sprite_scrolly[controller] |= 0xfffffe00; - else sprite_scrolly[controller] &= 0x1ff; - sprite_flip[controller] |= TOAPLAN2_SPRITE_FLIPY; - break; - case 0x8f: break; - - case 0x0e: /******* Initialise video controller register ? *******/ - if ((toaplan2_sub_cpu == CPU_2_Z80) && (data == 3)) - { - /* HACK! When tilted, sound CPU needs to be reset. */ - running_device *ym = machine->device("ymsnd"); - - if (ym && ym->type() == SOUND_YM3812) - { - cputag_set_input_line(machine, "audiocpu", INPUT_LINE_RESET, PULSE_LINE); - devtag_reset(machine, "ymsnd"); - } - } - - default: logerror("Hmmm, writing %08x to unknown video control register (%08x) Video controller %01x !!!\n",data ,toaplan2_scroll_reg[controller],controller); - break; - } - -#ifdef MAME_DEBUG - - if (spriteram16_now[1] && spriteram16_new[1] - && top_tilemap[1] && fg_tilemap[1] && bg_tilemap[1]) - { - vid_controllers = 2; - } - - if ( input_code_pressed_once(machine, KEYCODE_W) ) - { - display_tx += 1; - display_tx &= 1; - if (toaplan2_txvideoram16 != 0) - tilemap_set_enable(tx_tilemap, display_tx); - } - if ( input_code_pressed_once(machine, KEYCODE_L) ) - { - display_sp[0] += 1; - display_sp[0] &= 1; - } - if ( input_code_pressed_once(machine, KEYCODE_K) ) - { - display_top[0] += 1; - display_top[0] &= 1; - tilemap_set_enable(top_tilemap[0], display_top[0]); - } - if ( input_code_pressed_once(machine, KEYCODE_J) ) - { - display_fg[0] += 1; - display_fg[0] &= 1; - tilemap_set_enable(fg_tilemap[0], display_fg[0]); - } - if ( input_code_pressed_once(machine, KEYCODE_H) ) - { - display_bg[0] += 1; - display_bg[0] &= 1; - tilemap_set_enable(bg_tilemap[0], display_bg[0]); - } - if (vid_controllers == 2) - { - if ( input_code_pressed_once(machine, KEYCODE_O) ) + if (screen == screen1) { - display_sp[1] += 1; - display_sp[1] &= 1; + bitmap_fill(bitmap,cliprect,0); + bitmap_fill(gp9001_custom_priority_bitmap, cliprect, 0); + state->vdp0->gp9001_render_vdp(screen->machine, bitmap, cliprect); } - if ( input_code_pressed_once(machine, KEYCODE_I) ) + } + + /* debug code, render 2nd VDP to 2nd screen if they exist for test */ +#ifdef DUAL_SCREEN_VDPS + if (state->vdp1) + { + running_device *screen2 = screen->machine->device("screen2"); + + gp9001_log_vram(state->vdp1, screen->machine); + + if (screen == screen2) { - display_top[1] += 1; - display_top[1] &= 1; - tilemap_set_enable(top_tilemap[1], display_top[1]); - } - if ( input_code_pressed_once(machine, KEYCODE_U) ) - { - display_fg[1] += 1; - display_fg[1] &= 1; - tilemap_set_enable(fg_tilemap[1], display_fg[1]); - } - if ( input_code_pressed_once(machine, KEYCODE_Y) ) - { - display_bg[1] += 1; - display_bg[1] &= 1; - tilemap_set_enable(bg_tilemap[1], display_bg[1]); + bitmap_fill(bitmap,cliprect,0); + bitmap_fill(gp9001_custom_priority_bitmap, cliprect, 0); + state->vdp1->gp9001_render_vdp(screen->machine, bitmap, cliprect); } } #endif -} - -WRITE16_HANDLER( toaplan2_0_scroll_reg_data_w ) -{ - toaplan2_scroll_reg_data_w(space->machine, offset, data, mem_mask, 0); -} - -WRITE16_HANDLER( toaplan2_1_scroll_reg_data_w ) -{ - toaplan2_scroll_reg_data_w(space->machine, offset, data, mem_mask, 1); -} - - -/***************************************************************************/ -/**************** PIPIBIBI interface into this video driver ****************/ - -WRITE16_HANDLER( pipibibi_scroll_w ) -{ - if (ACCESSING_BITS_8_15 && ACCESSING_BITS_0_7) - { - switch(offset) - { - case 0x00: data -= 0x01f; break; - case 0x01: data += 0x1ef; break; - case 0x02: data -= 0x01d; break; - case 0x03: data += 0x1ef; break; - case 0x04: data -= 0x01b; break; - case 0x05: data += 0x1ef; break; - case 0x06: data += 0x1d4; break; - case 0x07: data += 0x1f7; break; - default: logerror("PIPIBIBI writing %04x to unknown scroll register %04x",data, offset); - } - - toaplan2_scroll_reg[0] = offset; - toaplan2_scroll_reg_data_w(space->machine, offset, data, mem_mask, 0); - } -} - -READ16_HANDLER( pipibibi_videoram16_r ) -{ - toaplan2_voffs_w(0, offset, 0xffff, 0); - return toaplan2_videoram16_r(space->machine, 0, 0); -} - -WRITE16_HANDLER( pipibibi_videoram16_w) -{ - toaplan2_voffs_w(0, offset, 0xffff, 0); - toaplan2_videoram16_w(space->machine, 0, data, mem_mask, 0); -} - -READ16_HANDLER( pipibibi_spriteram16_r ) -{ - toaplan2_voffs_w(0, (0x1800 + offset), 0, 0); - return toaplan2_videoram16_r(space->machine, 0, 0); -} - -WRITE16_HANDLER( pipibibi_spriteram16_w ) -{ - toaplan2_voffs_w(0, (0x1800 + offset), mem_mask, 0); - toaplan2_videoram16_w(space->machine, 0, data, mem_mask, 0); -} - - - -static void toaplan2_log_vram(running_machine *machine) -{ -#ifdef MAME_DEBUG - offs_t sprite_voffs, tile_voffs; - int vid_controllers = 1; - - if (spriteram16_now[1] && spriteram16_new[1] - && top_tilemap[1] && fg_tilemap[1] && bg_tilemap[1]) - { - vid_controllers = 2; - } - - if ( input_code_pressed_once(machine, KEYCODE_M) ) - { - UINT16 *source_now0 = (UINT16 *)(spriteram16_now[0]); - UINT16 *source_new0 = (UINT16 *)(spriteram16_new[0]); - UINT16 *source_now1 = (UINT16 *)(spriteram16_now[0]); - UINT16 *source_new1 = (UINT16 *)(spriteram16_new[0]); - - int schar[2],sattr[2],sxpos[2],sypos[2]; - - if (vid_controllers == 2) - { - source_now1 = (UINT16 *)(spriteram16_now[1]); - source_new1 = (UINT16 *)(spriteram16_new[1]); - } - - logerror("Scrolls BG-X BG-Y FG-X FG-Y TOP-X TOP-Y Sprite-X Sprite-Y\n"); - logerror("---0--> %04x %04x %04x %04x %04x %04x %04x %04x\n", bg_scrollx[0],bg_scrolly[0],fg_scrollx[0],fg_scrolly[0],top_scrollx[0],top_scrolly[0],sprite_scrollx[0], sprite_scrolly[0]); - if (vid_controllers == 2) - { - logerror("---1--> %04x %04x %04x %04x %04x %04x %04x %04x\n", bg_scrollx[1],bg_scrolly[1],fg_scrollx[1],fg_scrolly[1],top_scrollx[1],top_scrolly[1],sprite_scrollx[1], sprite_scrolly[1]); - } - for ( sprite_voffs = 0; sprite_voffs < (TOAPLAN2_SPRITERAM_SIZE/2); sprite_voffs += 4 ) - { - sattr[0] = source_now0[sprite_voffs]; - schar[0] = source_now0[sprite_voffs + 1]; - sxpos[0] = source_now0[sprite_voffs + 2]; - sypos[0] = source_now0[sprite_voffs + 3]; - sattr[1] = source_new0[sprite_voffs]; - schar[1] = source_new0[sprite_voffs + 1]; - sxpos[1] = source_new0[sprite_voffs + 2]; - sypos[1] = source_new0[sprite_voffs + 3]; - logerror("SPoffs Sprt Attr Xpos Ypos Sprt Attr Xpos Ypos\n"); - logerror("0:%03x now:%04x %04x %04x %04x new:%04x %04x %04x %04x\n",sprite_voffs, - schar[0], sattr[0],sxpos[0], sypos[0], - schar[1], sattr[1],sxpos[1], sypos[1]); - if (vid_controllers == 2) - { - sattr[0] = source_now1[sprite_voffs]; - schar[0] = source_now1[sprite_voffs + 1]; - sxpos[0] = source_now1[sprite_voffs + 2]; - sypos[0] = source_now1[sprite_voffs + 3]; - sattr[1] = source_new1[sprite_voffs]; - schar[1] = source_new1[sprite_voffs + 1]; - sxpos[1] = source_new1[sprite_voffs + 2]; - sypos[1] = source_new1[sprite_voffs + 3]; - logerror("1:%03x now:%04x %04x %04x %04x new:%04x %04x %04x %04x\n",sprite_voffs, - schar[0], sattr[0],sxpos[0], sypos[0], - schar[1], sattr[1],sxpos[1], sypos[1]); - } - } - } - if ( input_code_pressed_once(machine, KEYCODE_N) ) - { - int tchar[2], tattr[2]; - logerror("Scrolls BG-X BG-Y FG-X FG-Y TOP-X TOP-Y Sprite-X Sprite-Y\n"); - logerror("---0--> %04x %04x %04x %04x %04x %04x %04x %04x\n", bg_scrollx[0],bg_scrolly[0],fg_scrollx[0],fg_scrolly[0],top_scrollx[0],top_scrolly[0],sprite_scrollx[0], sprite_scrolly[0]); - if (vid_controllers == 2) - { - logerror("---1--> %04x %04x %04x %04x %04x %04x %04x %04x\n", bg_scrollx[1],bg_scrolly[1],fg_scrollx[1],fg_scrolly[1],top_scrollx[1],top_scrolly[1],sprite_scrollx[1], sprite_scrolly[1]); - } - for ( tile_voffs = 0; tile_voffs < (TOAPLAN2_TOP_VRAM_SIZE/2); tile_voffs += 2 ) - { - tchar[0] = topvideoram16[0][tile_voffs + 1]; - tattr[0] = topvideoram16[0][tile_voffs]; - if (vid_controllers == 2) - { - tchar[1] = topvideoram16[1][tile_voffs + 1]; - tattr[1] = topvideoram16[1][tile_voffs]; - logerror("TOPoffs:%04x Tile0:%04x Attr0:%04x Tile1:%04x Attr1:%04x\n", tile_voffs, tchar[0], tattr[0], tchar[1], tattr[1]); - } - else - { - logerror("TOPoffs:%04x Tile0:%04x Attr0:%04x\n", tile_voffs, tchar[0], tattr[0]); - } - } - } - if ( input_code_pressed_once(machine, KEYCODE_B) ) - { - int tchar[2], tattr[2]; - logerror("Scrolls BG-X BG-Y FG-X FG-Y TOP-X TOP-Y Sprite-X Sprite-Y\n"); - logerror("---0--> %04x %04x %04x %04x %04x %04x %04x %04x\n", bg_scrollx[0],bg_scrolly[0],fg_scrollx[0],fg_scrolly[0],top_scrollx[0],top_scrolly[0],sprite_scrollx[0], sprite_scrolly[0]); - if (vid_controllers == 2) - { - logerror("---1--> %04x %04x %04x %04x %04x %04x %04x %04x\n", bg_scrollx[1],bg_scrolly[1],fg_scrollx[1],fg_scrolly[1],top_scrollx[1],top_scrolly[1],sprite_scrollx[1], sprite_scrolly[1]); - } - for ( tile_voffs = 0; tile_voffs < (TOAPLAN2_FG_VRAM_SIZE/2); tile_voffs += 2 ) - { - tchar[0] = fgvideoram16[0][tile_voffs + 1]; - tattr[0] = fgvideoram16[0][tile_voffs]; - if (vid_controllers == 2) - { - tchar[1] = fgvideoram16[1][tile_voffs + 1]; - tattr[1] = fgvideoram16[1][tile_voffs]; - logerror("FGoffs:%04x Tile0:%04x Attr0:%04x Tile1:%04x Attr1:%04x\n", tile_voffs, tchar[0], tattr[0], tchar[1], tattr[1]); - } - else - { - logerror("FGoffs:%04x Tile0:%04x Attr0:%04x\n", tile_voffs, tchar[0], tattr[0]); - } - } - } - if ( input_code_pressed_once(machine, KEYCODE_V) ) - { - int tchar[2], tattr[2]; - logerror("Scrolls BG-X BG-Y FG-X FG-Y TOP-X TOP-Y Sprite-X Sprite-Y\n"); - logerror("---0--> %04x %04x %04x %04x %04x %04x %04x %04x\n", bg_scrollx[0],bg_scrolly[0],fg_scrollx[0],fg_scrolly[0],top_scrollx[0],top_scrolly[0],sprite_scrollx[0], sprite_scrolly[0]); - if (vid_controllers == 2) - { - logerror("---1--> %04x %04x %04x %04x %04x %04x %04x %04x\n", bg_scrollx[1],bg_scrolly[1],fg_scrollx[1],fg_scrolly[1],top_scrollx[1],top_scrolly[1],sprite_scrollx[1], sprite_scrolly[1]); - } - for ( tile_voffs = 0; tile_voffs < (TOAPLAN2_BG_VRAM_SIZE/2); tile_voffs += 2 ) - { - tchar[0] = bgvideoram16[0][tile_voffs + 1]; - tattr[0] = bgvideoram16[0][tile_voffs]; - if (vid_controllers == 2) - { - tchar[1] = bgvideoram16[1][tile_voffs + 1]; - tattr[1] = bgvideoram16[1][tile_voffs]; - logerror("BGoffs:%04x Tile0:%04x Attr0:%04x Tile1:%04x Attr1:%04x\n", tile_voffs, tchar[0], tattr[0], tchar[1], tattr[1]); - } - else - { - logerror("BGoffs:%04x Tile0:%04x Attr0:%04x\n", tile_voffs, tchar[0], tattr[0]); - } - } - } - - if ( input_code_pressed_once(machine, KEYCODE_C) ) - logerror("Mark here\n"); - - if ( input_code_pressed_once(machine, KEYCODE_E) ) - { - displog += 1; - displog &= 1; - } - if (displog) - { - logerror("Scrolls BG-X BG-Y FG-X FG-Y TOP-X TOP-Y Sprite-X Sprite-Y\n"); - logerror("---0--> %04x %04x %04x %04x %04x %04x %04x %04x\n", bg_scrollx[0],bg_scrolly[0],fg_scrollx[0],fg_scrolly[0],top_scrollx[0],top_scrolly[0],sprite_scrollx[0], sprite_scrolly[0]); - if (vid_controllers == 2) - { - logerror("---1--> %04x %04x %04x %04x %04x %04x %04x %04x\n", bg_scrollx[1],bg_scrolly[1],fg_scrollx[1],fg_scrolly[1],top_scrollx[1],top_scrolly[1],sprite_scrollx[1], sprite_scrolly[1]); - } - } -#endif -} - - - -/*************************************************************************** - Sprite Handlers -***************************************************************************/ - -static void draw_sprites( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, int controller, const UINT8* primap ) -{ - const gfx_element *gfx = machine->gfx[ ((controller*2)+1) ]; - - int offs, old_x, old_y; - - UINT16 *source = (UINT16 *)(spriteram16_n[controller]); - - old_x = (-(sprite_scrollx[controller]+xoffset[3])) & 0x1ff; - old_y = (-(sprite_scrolly[controller]+yoffset[3])) & 0x1ff; - - for (offs = 0; offs < (TOAPLAN2_SPRITERAM_SIZE/2); offs += 4) - { - int attrib, sprite, color, priority, flipx, flipy, sx, sy; - int sprite_sizex, sprite_sizey, dim_x, dim_y, sx_base, sy_base; - int bank, sprite_num; - - attrib = source[offs]; - priority = primap[((attrib & 0x0f00)>>8)]+1; - - if ((attrib & 0x8000)) - { - if (!toaplan2_banked_gfx) /* No Sprite select bank switching needed */ - { - sprite = ((attrib & 3) << 16) | source[offs + 1]; /* 18 bit */ - } - else /* Batrider Sprite select bank switching required */ - { - sprite_num = source[offs + 1] & 0x7fff; - bank = ((attrib & 3) << 1) | (source[offs + 1] >> 15); - sprite = (batrider_object_bank[bank] << 15 ) | sprite_num; - } - color = (attrib >> 2) & 0x3f; - - /***** find out sprite size *****/ - sprite_sizex = ((source[offs + 2] & 0x0f) + 1) * 8; - sprite_sizey = ((source[offs + 3] & 0x0f) + 1) * 8; - - /***** find position to display sprite *****/ - if (!(attrib & 0x4000)) - { - sx_base = ((source[offs + 2] >> 7) - (sprite_scrollx[controller]+xoffset[3])) & 0x1ff; - sy_base = ((source[offs + 3] >> 7) - (sprite_scrolly[controller]+yoffset[3])) & 0x1ff; - } else { - sx_base = (old_x + (source[offs + 2] >> 7)) & 0x1ff; - sy_base = (old_y + (source[offs + 3] >> 7)) & 0x1ff; - } - - old_x = sx_base; - old_y = sy_base; - - flipx = attrib & TOAPLAN2_SPRITE_FLIPX; - flipy = attrib & TOAPLAN2_SPRITE_FLIPY; - - if (flipx) - { - /***** Wrap sprite position around *****/ - sx_base -= 7; - if (sx_base >= 0x1c0) sx_base -= 0x200; - } - else - { - if (sx_base >= 0x180) sx_base -= 0x200; - } - - if (flipy) - { - sy_base -= 7; - if (sy_base >= 0x1c0) sy_base -= 0x200; - } - else - { - if (sy_base >= 0x180) sy_base -= 0x200; - } - - /***** Flip the sprite layer in any active X or Y flip *****/ - if (sprite_flip[controller]) - { - if (sprite_flip[controller] & TOAPLAN2_SPRITE_FLIPX) - sx_base = 320 - sx_base; - if (sprite_flip[controller] & TOAPLAN2_SPRITE_FLIPY) - sy_base = 240 - sy_base; - } - - /***** Cancel flip, if it, and sprite layer flip are active *****/ - flipx = (flipx ^ (sprite_flip[controller] & TOAPLAN2_SPRITE_FLIPX)); - flipy = (flipy ^ (sprite_flip[controller] & TOAPLAN2_SPRITE_FLIPY)); - - /***** Draw the complete sprites using the dimension info *****/ - for (dim_y = 0; dim_y < sprite_sizey; dim_y += 8) - { - if (flipy) sy = sy_base - dim_y; - else sy = sy_base + dim_y; - for (dim_x = 0; dim_x < sprite_sizex; dim_x += 8) - { - if (flipx) sx = sx_base - dim_x; - else sx = sx_base + dim_x; - - /* - drawgfx_transpen(bitmap,cliprect,gfx,sprite, - color, - flipx,flipy, - sx,sy,0); - */ - sprite %= gfx->total_elements; - color %= gfx->total_colors; - - { - int yy, xx; - const pen_t *paldata = &gfx->machine->pens[gfx->color_base + gfx->color_granularity * color]; - const UINT8* srcdata = gfx_element_get_data(gfx, sprite); - int count = 0; - int ystart, yend, yinc; - int xstart, xend, xinc; - - if (flipy) - { - ystart = 7; - yend = -1; - yinc = -1; - } - else - { - ystart = 0; - yend = 8; - yinc = 1; - } - - if (flipx) - { - xstart = 7; - xend = -1; - xinc = -1; - } - else - { - xstart = 0; - xend = 8; - xinc = 1; - } - - for (yy=ystart;yy!=yend;yy+=yinc) - { - int drawyy = yy+sy; - - - for (xx=xstart;xx!=xend;xx+=xinc) - { - int drawxx = xx+sx; - - if (drawxx>=cliprect->min_x && drawxxmax_x && drawyy>=cliprect->min_y && drawyymax_y) - { - UINT8 pix = srcdata[count]; - UINT16* dstptr = BITMAP_ADDR16(bitmap,drawyy,drawxx); - UINT8* dstpri = BITMAP_ADDR8(toaplan2_custom_priority_bitmap, drawyy, drawxx); - - if (priority >= dstpri[0]) - { - if (pix&0xf) - { - dstptr[0] = paldata[pix]; - dstpri[0] = priority; - - } - } - } - - - count++; - } - } - - - } - - - - sprite++ ; - } - } - } - } -} - - -/*************************************************************************** - Draw the game screen in the given bitmap_t. -***************************************************************************/ - -static void toaplan2_draw_custom_tilemap(running_machine* machine, bitmap_t* bitmap, tilemap_t* tilemap, const UINT8* priremap, const UINT8* pri_enable ) -{ - int width = machine->primary_screen->width(); - int height = machine->primary_screen->height(); - int y,x; - bitmap_t *tmb = tilemap_get_pixmap(tilemap); - UINT16* srcptr; - UINT16* dstptr; - UINT8* dstpriptr; - - int scrollx = tilemap_get_scrollx(tilemap, 0); - int scrolly = tilemap_get_scrolly(tilemap, 0); - - for (y=0;y>12); - - if (pri_enable[pixpri]) - { - pixpri = priremap[pixpri]+1; // priority of 0 isn't desireable - pixdat &=0x07ff; - - if (pixdat&0xf) - { - if (pixpri >= dstpriptr[x]) - { - dstptr[x] = pixdat; - dstpriptr[x] = pixpri; - } - } - } - } - } -} - - -static const UINT8 toaplan2_primap1[16] = { 0x00, 0x04, 0x08, 0x0c, 0x10, 0x14, 0x18, 0x1c, 0x20, 0x24, 0x28, 0x2c, 0x30, 0x34, 0x38, 0x3c }; -//UINT8 toaplan2_sprprimap1[16] = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f }; -static const UINT8 toaplan2_sprprimap1[16] = { 0x00, 0x04, 0x08, 0x0c, 0x10, 0x14, 0x18, 0x1c, 0x20, 0x24, 0x28, 0x2c, 0x30, 0x34, 0x38, 0x3c }; - -static const UINT8 batsugun_prienable0[16]={ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }; - - -VIDEO_UPDATE( toaplan2_0 ) -{ - bitmap_fill(bitmap,cliprect,0); - bitmap_fill(toaplan2_custom_priority_bitmap, cliprect, 0); - - toaplan2_draw_custom_tilemap( screen->machine, bitmap, bg_tilemap[0], toaplan2_primap1, batsugun_prienable0); - toaplan2_draw_custom_tilemap( screen->machine, bitmap, fg_tilemap[0], toaplan2_primap1, batsugun_prienable0); - toaplan2_draw_custom_tilemap( screen->machine, bitmap, top_tilemap[0], toaplan2_primap1, batsugun_prienable0); - draw_sprites(screen->machine,bitmap,cliprect,0, toaplan2_sprprimap1); return 0; } - -/* How do the dual VDP games mix? The internal mixing of each VDP chip is independent, if you view only a single - VDP then the priorities for that VDP are correct, however, it is completely unclear how the priorities of the - two VDPs should actually mix together, as a result these games are broken for now. */ -VIDEO_UPDATE( dogyuun_1 ) +VIDEO_UPDATE( truxton2 ) { - toaplan2_log_vram(screen->machine); - - bitmap_fill(bitmap,cliprect,0); - bitmap_fill(toaplan2_custom_priority_bitmap, cliprect, 0); - - toaplan2_draw_custom_tilemap( screen->machine, bitmap, bg_tilemap[1], toaplan2_primap1, batsugun_prienable0); - toaplan2_draw_custom_tilemap( screen->machine, bitmap, bg_tilemap[0], toaplan2_primap1, batsugun_prienable0); - toaplan2_draw_custom_tilemap( screen->machine, bitmap, fg_tilemap[1], toaplan2_primap1, batsugun_prienable0); - toaplan2_draw_custom_tilemap( screen->machine, bitmap, fg_tilemap[0], toaplan2_primap1, batsugun_prienable0); - toaplan2_draw_custom_tilemap( screen->machine, bitmap, top_tilemap[1], toaplan2_primap1, batsugun_prienable0); - toaplan2_draw_custom_tilemap( screen->machine, bitmap, top_tilemap[0], toaplan2_primap1, batsugun_prienable0); - - draw_sprites(screen->machine,bitmap,cliprect,1, toaplan2_sprprimap1); - draw_sprites(screen->machine,bitmap,cliprect,0, toaplan2_sprprimap1); - - - return 0; -} - - -VIDEO_UPDATE( batsugun_1 ) -{ - - toaplan2_log_vram(screen->machine); - - bitmap_fill(bitmap,cliprect,0); - bitmap_fill(toaplan2_custom_priority_bitmap, cliprect, 0); - - tile_limit[1] = 0x1fff; // 0x2000-0x3fff seem to be for sprites only? (corruption on level 1 otherwise) - - toaplan2_draw_custom_tilemap( screen->machine, bitmap, bg_tilemap[1], toaplan2_primap1, batsugun_prienable0); - toaplan2_draw_custom_tilemap( screen->machine, bitmap, bg_tilemap[0], toaplan2_primap1, batsugun_prienable0); - toaplan2_draw_custom_tilemap( screen->machine, bitmap, fg_tilemap[1], toaplan2_primap1, batsugun_prienable0); - toaplan2_draw_custom_tilemap( screen->machine, bitmap, fg_tilemap[0], toaplan2_primap1, batsugun_prienable0); - toaplan2_draw_custom_tilemap( screen->machine, bitmap, top_tilemap[1], toaplan2_primap1, batsugun_prienable0); - toaplan2_draw_custom_tilemap( screen->machine, bitmap, top_tilemap[0], toaplan2_primap1, batsugun_prienable0); - - draw_sprites(screen->machine,bitmap,cliprect,1, toaplan2_sprprimap1); - draw_sprites(screen->machine,bitmap,cliprect,0, toaplan2_sprprimap1); - - return 0; -} - -VIDEO_UPDATE( truxton2_0 ) -{ - VIDEO_UPDATE_CALL(toaplan2_0); + VIDEO_UPDATE_CALL(toaplan2); tilemap_draw(bitmap,cliprect,tx_tilemap,0,0); return 0; } -VIDEO_UPDATE( batrider_0 ) + +VIDEO_UPDATE( batrider ) { + VIDEO_UPDATE_CALL( toaplan2 ); + int line; rectangle clip; const rectangle &visarea = screen->visible_area(); - toaplan2_log_vram(screen->machine); - - /* If object bank is changed, all tile must be redrawn to blow off glitches. */ - /* This causes serious slow down. Is there better algorithm ? */ - if (objectbank_dirty) - { - tilemap_mark_all_tiles_dirty(bg_tilemap[0]); - tilemap_mark_all_tiles_dirty(fg_tilemap[0]); - objectbank_dirty = 0; - } - - VIDEO_UPDATE_CALL( toaplan2_0 ); - clip.min_x = visarea.min_x; clip.max_x = visarea.max_x; clip.min_y = visarea.min_y; @@ -1731,26 +380,64 @@ VIDEO_UPDATE( batrider_0 ) } -VIDEO_UPDATE( mahoudai_0 ) -{ - toaplan2_log_vram(screen->machine); - VIDEO_UPDATE_CALL( toaplan2_0 ); +/* How do the dual VDP games mix? The internal mixing of each VDP chip is independent, if you view only a single + VDP then the priorities for that VDP are correct, however, it is completely unclear how the priorities of the + two VDPs should actually mix together, as a result these games are broken for now. */ +VIDEO_UPDATE( dogyuun ) +{ +#ifdef DUAL_SCREEN_VDPS + VIDEO_UPDATE_CALL( toaplan2 ); +#else + toaplan2_state *state = screen->machine->driver_data(); + + bitmap_fill(bitmap,cliprect,0); + bitmap_fill(gp9001_custom_priority_bitmap, cliprect, 0); + + state->vdp1->toaplan2_draw_custom_tilemap( screen->machine, bitmap, state->vdp1->bg_tilemap, toaplan2_primap1, batsugun_prienable0); + state->vdp0->toaplan2_draw_custom_tilemap( screen->machine, bitmap, state->vdp0->bg_tilemap, toaplan2_primap1, batsugun_prienable0); + state->vdp1->toaplan2_draw_custom_tilemap( screen->machine, bitmap, state->vdp1->fg_tilemap, toaplan2_primap1, batsugun_prienable0); + state->vdp0->toaplan2_draw_custom_tilemap( screen->machine, bitmap, state->vdp0->fg_tilemap, toaplan2_primap1, batsugun_prienable0); + state->vdp1->toaplan2_draw_custom_tilemap( screen->machine, bitmap, state->vdp1->top_tilemap, toaplan2_primap1, batsugun_prienable0); + state->vdp0->toaplan2_draw_custom_tilemap( screen->machine, bitmap, state->vdp0->top_tilemap, toaplan2_primap1, batsugun_prienable0); + + state->vdp1->draw_sprites(screen->machine,bitmap,cliprect, toaplan2_sprprimap1); + state->vdp0->draw_sprites(screen->machine,bitmap,cliprect, toaplan2_sprprimap1); +#endif - tilemap_draw(bitmap,cliprect,tx_tilemap,0,0); return 0; } - -VIDEO_EOF( toaplan2_0 ) +VIDEO_UPDATE( batsugun ) { - /** Shift sprite RAM buffers *** Used to fix sprite lag **/ - memcpy(spriteram16_now[0],spriteram16_new[0],TOAPLAN2_SPRITERAM_SIZE); + toaplan2_state *state = screen->machine->driver_data(); + state->vdp1->tile_limit = 0x1fff; // 0x2000-0x3fff seem to be for sprites only? (corruption on level 1 otherwise) + + +#ifdef DUAL_SCREEN_VDPS + VIDEO_UPDATE_CALL( toaplan2 ); +#else + bitmap_fill(bitmap,cliprect,0); + bitmap_fill(gp9001_custom_priority_bitmap, cliprect, 0); + + + state->vdp1->toaplan2_draw_custom_tilemap( screen->machine, bitmap, state->vdp1->bg_tilemap, toaplan2_primap1, batsugun_prienable0); + state->vdp0->toaplan2_draw_custom_tilemap( screen->machine, bitmap, state->vdp0->bg_tilemap, toaplan2_primap1, batsugun_prienable0); + state->vdp1->toaplan2_draw_custom_tilemap( screen->machine, bitmap, state->vdp1->fg_tilemap, toaplan2_primap1, batsugun_prienable0); + state->vdp0->toaplan2_draw_custom_tilemap( screen->machine, bitmap, state->vdp0->fg_tilemap, toaplan2_primap1, batsugun_prienable0); + state->vdp1->toaplan2_draw_custom_tilemap( screen->machine, bitmap, state->vdp1->top_tilemap, toaplan2_primap1, batsugun_prienable0); + state->vdp0->toaplan2_draw_custom_tilemap( screen->machine, bitmap, state->vdp0->top_tilemap, toaplan2_primap1, batsugun_prienable0); + + state->vdp1->draw_sprites(screen->machine,bitmap,cliprect, toaplan2_sprprimap1); + state->vdp0->draw_sprites(screen->machine,bitmap,cliprect, toaplan2_sprprimap1); +#endif + + return 0; } -VIDEO_EOF( toaplan2_1 ) +VIDEO_EOF( toaplan2 ) { - /** Shift sprite RAM buffers *** Used to fix sprite lag **/ - memcpy(spriteram16_now[0],spriteram16_new[0],TOAPLAN2_SPRITERAM_SIZE); - memcpy(spriteram16_now[1],spriteram16_new[1],TOAPLAN2_SPRITERAM_SIZE); + toaplan2_state *state = machine->driver_data(); + if (state->vdp0) state->vdp0->gp9001_video_eof(); + if (state->vdp1) state->vdp1->gp9001_video_eof(); }