diff options
-rw-r--r-- | src/mame/drivers/galpani2.c | 44 | ||||
-rw-r--r-- | src/mame/includes/galpani2.h | 25 | ||||
-rw-r--r-- | src/mame/video/galpani2.c | 122 |
3 files changed, 83 insertions, 108 deletions
diff --git a/src/mame/drivers/galpani2.c b/src/mame/drivers/galpani2.c index cfc02cd65c8..7222ae6833a 100644 --- a/src/mame/drivers/galpani2.c +++ b/src/mame/drivers/galpani2.c @@ -337,21 +337,23 @@ static ADDRESS_MAP_START( galpani2_mem1, AS_PROGRAM, 16, galpani2_state ) AM_RANGE(0x300000, 0x301fff) AM_RAM // ? AM_RANGE(0x302000, 0x303fff) AM_RAM AM_SHARE("spriteram") // Sprites AM_RANGE(0x304000, 0x30401f) AM_DEVREADWRITE("kan_spr", kaneko16_sprite_device, kaneko16_sprites_regs_r, kaneko16_sprites_regs_w) - AM_RANGE(0x308000, 0x308001) AM_WRITENOP // ? 0 at startup - AM_RANGE(0x30c000, 0x30c001) AM_WRITENOP // ? hblank effect ? - AM_RANGE(0x310000, 0x3101ff) AM_RAM_WRITE(galpani2_palette_0_w) AM_SHARE("palette.0") // ? +// AM_RANGE(0x308000, 0x308001) AM_WRITENOP // ? 0 at startup +// AM_RANGE(0x30c000, 0x30c001) AM_WRITENOP // ? hblank effect ? + AM_RANGE(0x310000, 0x3101ff) AM_RAM_DEVWRITE("bg8palette", palette_device, write) AM_SHARE("bg8palette") // ? AM_RANGE(0x314000, 0x314001) AM_WRITENOP // ? flip backgrounds ? AM_RANGE(0x318000, 0x318001) AM_READWRITE(galpani2_eeprom_r, galpani2_eeprom_w) // EEPROM AM_RANGE(0x380000, 0x387fff) AM_RAM // Palette? AM_RANGE(0x388000, 0x38ffff) AM_RAM_DEVWRITE("palette", palette_device, write) AM_SHARE("palette") // Palette - AM_RANGE(0x390000, 0x3901ff) AM_WRITENOP // ? at startup of service mode +// AM_RANGE(0x390000, 0x3901ff) AM_WRITENOP // ? at startup of service mode - AM_RANGE(0x400000, 0x43ffff) AM_RAM_WRITE(galpani2_bg8_0_w) AM_SHARE("bg8.0") // Background 0 + AM_RANGE(0x400000, 0x43ffff) AM_RAM AM_SHARE("bg8.0") // Background 0 AM_RANGE(0x440000, 0x440001) AM_RAM AM_SHARE("bg8_scrollx.0") // Background 0 Scroll X AM_RANGE(0x480000, 0x480001) AM_RAM AM_SHARE("bg8_scrolly.0") // Background 0 Scroll Y - AM_RANGE(0x4c0000, 0x4c0001) AM_WRITENOP // ? 0 at startup only - AM_RANGE(0x500000, 0x53ffff) AM_RAM_WRITE(galpani2_bg8_1_w) AM_SHARE("bg8.1") // Background 1 +// AM_RANGE(0x4c0000, 0x4c0001) AM_WRITENOP // ? 0 at startup only + AM_RANGE(0x500000, 0x53ffff) AM_RAM AM_SHARE("bg8.1") // Background 1 AM_RANGE(0x540000, 0x540001) AM_RAM AM_SHARE("bg8_scrollx.1") // Background 1 Scroll X + AM_RANGE(0x580000, 0x580001) AM_RAM AM_SHARE("bg8_scrolly.1") // Background 1 Scroll Y +// AM_RANGE(0x5c0000, 0x5c0001) AM_WRITENOP // ? 0 at startup only AM_RANGE(0x540572, 0x540573) AM_READNOP // ? galpani2 at F0A4 AM_RANGE(0x54057a, 0x54057b) AM_READNOP // ? galpani2 at F148 @@ -363,9 +365,7 @@ static ADDRESS_MAP_START( galpani2_mem1, AS_PROGRAM, 16, galpani2_state ) AM_RANGE(0x5405c2, 0x5405c3) AM_READNOP // ? galpani2 at F0A4 and F148 AM_RANGE(0x5405ca, 0x5405cb) AM_READNOP // ? galpani2 at F148 - AM_RANGE(0x580000, 0x580001) AM_RAM AM_SHARE("bg8_scrolly.1") // Background 1 Scroll Y - AM_RANGE(0x5c0000, 0x5c0001) AM_WRITENOP // ? 0 at startup only - AM_RANGE(0x600000, 0x600001) AM_WRITENOP // Watchdog + AM_RANGE(0x600000, 0x600001) AM_NOP // Watchdog AM_RANGE(0x640000, 0x640001) AM_WRITE8(galpani2_mcu_init_w, 0x00ff ) // ? 0 before resetting and at startup, Reset mcu ? AM_RANGE(0x680000, 0x680001) AM_WRITE8(galpani2_mcu_nmi1_w, 0x00ff) // ? 0 -> 1 -> 0 (lev 5) / 0 -> $10 -> 0 AM_RANGE(0x6c0000, 0x6c0001) AM_WRITE8(galpani2_coin_lockout_w, 0xff00 ) // Coin + Card Lockout @@ -403,13 +403,12 @@ READ16_MEMBER(galpani2_state::galpani2_bankedrom_r) static ADDRESS_MAP_START( galpani2_mem2, AS_PROGRAM, 16, galpani2_state ) AM_RANGE(0x000000, 0x03ffff) AM_ROM // ROM AM_RANGE(0x100000, 0x13ffff) AM_RAM AM_SHARE("ram2") // Work RAM - AM_RANGE(0x400000, 0x4fffff) AM_RAM_WRITE(galpani2_bg15_w) AM_SHARE("bg15") // bg15 - AM_RANGE(0x500000, 0x5fffff) AM_RAM // bg15 - AM_RANGE(0x600000, 0x600001) AM_NOP // ? 0 at startup only - AM_RANGE(0x640000, 0x640001) AM_WRITENOP // ? 0 at startup only - AM_RANGE(0x680000, 0x680001) AM_WRITENOP // ? 0 at startup only - AM_RANGE(0x6c0000, 0x6c0001) AM_WRITENOP // ? 0 at startup only - AM_RANGE(0x700000, 0x700001) AM_WRITENOP // Watchdog + AM_RANGE(0x400000, 0x5fffff) AM_RAM AM_SHARE("bg15") // bg15 +// AM_RANGE(0x600000, 0x600001) AM_NOP // ? 0 at startup only +// AM_RANGE(0x640000, 0x640001) AM_WRITENOP // ? 0 at startup only +// AM_RANGE(0x680000, 0x680001) AM_WRITENOP // ? 0 at startup only +// AM_RANGE(0x6c0000, 0x6c0001) AM_WRITENOP // ? 0 at startup only + AM_RANGE(0x700000, 0x700001) AM_NOP // Watchdog // AM_RANGE(0x740000, 0x740001) AM_WRITENOP // ? Reset mcu AM_RANGE(0x780000, 0x780001) AM_WRITE8(galpani2_mcu_nmi2_w, 0x00ff) // ? 0 -> 1 -> 0 (lev 5) AM_RANGE(0x7c0000, 0x7c0001) AM_WRITEONLY AM_SHARE("rombank") // Rom Bank @@ -626,12 +625,17 @@ static MACHINE_CONFIG_START( galpani2, galpani2_state ) MCFG_SCREEN_SIZE(320, 256) MCFG_SCREEN_VISIBLE_AREA(0, 320-1, 0, 256-1-16) MCFG_SCREEN_UPDATE_DRIVER(galpani2_state, screen_update_galpani2) - MCFG_SCREEN_PALETTE("palette") MCFG_GFXDECODE_ADD("gfxdecode", "palette", galpani2) - MCFG_PALETTE_ADD("palette", 0x4000 + 0x200 + 0x8000) // sprites, bg8, bg15 + MCFG_PALETTE_ADD("palette", 0x4000) // sprites + MCFG_PALETTE_FORMAT(xGGGGGRRRRRBBBBB) + + MCFG_PALETTE_ADD("bg8palette", 0x200/2) // bg8 + MCFG_PALETTE_FORMAT(xGGGGGRRRRRBBBBB) + + MCFG_PALETTE_ADD("bgpalette", 32768) /* 32768 static colors for the bg */ MCFG_PALETTE_FORMAT(xGGGGGRRRRRBBBBB) - MCFG_PALETTE_INIT_OWNER(galpani2_state, galpani2) + MCFG_PALETTE_INIT_OWNER(galpani2_state,galpani2) MCFG_DEVICE_ADD_KC002_SPRITES kaneko16_sprite_device::set_offsets(*device, 0x10000 - 0x16c0 + 0xc00, 0); diff --git a/src/mame/includes/galpani2.h b/src/mame/includes/galpani2.h index be92174407f..7dcb80b1a28 100644 --- a/src/mame/includes/galpani2.h +++ b/src/mame/includes/galpani2.h @@ -21,8 +21,10 @@ public: m_spriteram(*this, "spriteram"), m_oki2(*this, "oki2"), m_eeprom(*this, "eeprom"), - m_palette(*this, "palette") - { } + m_palette(*this, "palette"), + m_bg15palette(*this, "bgpalette"), + m_bg8palette(*this, "bg8palette") + { } required_shared_ptr_array<UINT16, 2> m_bg8; optional_shared_ptr_array<UINT16, 2> m_palette_val; @@ -35,8 +37,6 @@ public: UINT16 m_old_mcu_nmi1; UINT16 m_old_mcu_nmi2; required_shared_ptr<UINT16> m_rombank; - bitmap_ind16 *m_bg8_bitmap[2]; - bitmap_ind16 *m_bg15_bitmap; required_device<cpu_device> m_maincpu; required_device<cpu_device> m_subcpu; @@ -55,23 +55,20 @@ public: virtual void machine_reset(); virtual void video_start(); DECLARE_PALETTE_INIT(galpani2); - UINT32 screen_update_galpani2(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); + UINT32 screen_update_galpani2(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect); + void copybg8(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect, int layer); + void copybg15(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect); + TIMER_DEVICE_CALLBACK_MEMBER(galpani2_interrupt1); TIMER_DEVICE_CALLBACK_MEMBER(galpani2_interrupt2); void galpani2_mcu_nmi1(); void galpani2_mcu_nmi2(); /*----------- defined in video/galpani2.c -----------*/ - inline void galpani2_bg8_w(offs_t offset, UINT16 data, UINT16 mem_mask, int _n_); - inline void galpani2_palette_w(offs_t offset, UINT16 data, UINT16 mem_mask, int _n_); - - DECLARE_WRITE16_MEMBER( galpani2_palette_0_w ); - DECLARE_WRITE16_MEMBER( galpani2_palette_1_w ); - DECLARE_WRITE16_MEMBER( galpani2_bg8_0_w ); - DECLARE_WRITE16_MEMBER( galpani2_bg8_1_w ); - - DECLARE_WRITE16_MEMBER( galpani2_bg15_w ); required_device<okim6295_device> m_oki2; required_device<eeprom_serial_93cxx_device> m_eeprom; required_device<palette_device> m_palette; + required_device<palette_device> m_bg15palette; + required_device<palette_device> m_bg8palette; + }; diff --git a/src/mame/video/galpani2.c b/src/mame/video/galpani2.c index a71c2e2c758..9e565cb3209 100644 --- a/src/mame/video/galpani2.c +++ b/src/mame/video/galpani2.c @@ -55,47 +55,6 @@ WRITE16_MEMBER( galpani2_bg8_regs_0_w ) { galpani2_bg8_regs_w(space, offset, dat WRITE16_MEMBER( galpani2_bg8_regs_1_w ) { galpani2_bg8_regs_w(space, offset, data, mem_mask, 1); } #endif -inline void galpani2_state::galpani2_bg8_w(offs_t offset, UINT16 data, UINT16 mem_mask, int _n_) -{ - int x,y,pen; - UINT16 newword = COMBINE_DATA(&m_bg8[_n_][offset]); - pen = newword & 0xff; - x = (offset % 512); /* 512 x 256 */ - y = (offset / 512); - m_bg8_bitmap[_n_]->pix16(y, x) = 0x4000 + pen; -} - -WRITE16_MEMBER( galpani2_state::galpani2_bg8_0_w ) { galpani2_bg8_w(offset, data, mem_mask, 0); } -WRITE16_MEMBER( galpani2_state::galpani2_bg8_1_w ) { galpani2_bg8_w(offset, data, mem_mask, 1); } - -inline void galpani2_state::galpani2_palette_w(offs_t offset, UINT16 data, UINT16 mem_mask, int _n_) -{ - UINT16 newword = COMBINE_DATA(&m_palette_val[_n_][offset]); - m_palette->set_pen_color( offset + 0x4000 + _n_ * 0x100, pal5bit(newword >> 5), pal5bit(newword >> 10), pal5bit(newword >> 0) ); -} - -WRITE16_MEMBER( galpani2_state::galpani2_palette_0_w ) { galpani2_palette_w(offset, data, mem_mask, 0); } -WRITE16_MEMBER( galpani2_state::galpani2_palette_1_w ) { galpani2_palette_w(offset, data, mem_mask, 1); } - - -/*************************************************************************** - - - xRGB Background Layer - - -***************************************************************************/ - -/* 8 horizontal pages of 256x256 pixels? */ -WRITE16_MEMBER( galpani2_state::galpani2_bg15_w ) -{ - UINT16 newword = COMBINE_DATA(&m_bg15[offset]); - - int x = (offset % 256) + (offset / (256*256)) * 256 ; - int y = (offset / 256) % 256; - - m_bg15_bitmap->pix16(y, x) = 0x4200 + (newword & 0x7fff); -} /*************************************************************************** @@ -113,14 +72,11 @@ PALETTE_INIT_MEMBER(galpani2_state, galpani2) /* initialize 555 RGB lookup */ for (i = 0; i < 0x8000; i++) - palette.set_pen_color(0x4200+i,pal5bit(i >> 5),pal5bit(i >> 10),pal5bit(i >> 0)); + palette.set_pen_color(i,pal5bit(i >> 5),pal5bit(i >> 10),pal5bit(i >> 0)); } void galpani2_state::video_start() { - m_bg15_bitmap = auto_bitmap_ind16_alloc(machine(), 256*8, 256); - m_bg8_bitmap[0] = auto_bitmap_ind16_alloc(machine(), 512, 256); - m_bg8_bitmap[1] = auto_bitmap_ind16_alloc(machine(), 512, 256); } @@ -132,11 +88,53 @@ void galpani2_state::video_start() ***************************************************************************/ -UINT32 galpani2_state::screen_update_galpani2(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) +// based on videos these 8-bit layers actually get *blended* against the RGB555 layer +// it should be noted that in the layer at 0x500000 the upper 8 bits are set too, this could be related +void galpani2_state::copybg8(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect, int layer) +{ + int x = - ( *m_bg8_scrollx[layer] + 0x200 - 0x0f5 ); + int y = - ( *m_bg8_scrolly[layer] + 0x200 - 0x1be ); + UINT16* ram = m_bg8[layer]; + + const pen_t *clut = &m_bg8palette->pen(0); + for (int xx = 0; xx < 320; xx++) + { + for (int yy = 0; yy < 240; yy++) + { + UINT16 pen = ram[(((y + yy) & 0xff) * 512) + ((x + xx) & 0x1ff)]; + if (pen) bitmap.pix32(yy, xx) = clut[pen & 0xff]; + } + } +} + +// this seems to be 256x256 pages (arranged as 1024*256), but the game resolution is 320x240 +// https://www.youtube.com/watch?v=2b2SLFtC0uA is a video of the galpanic2j set, and shows the RGB pattern at +// startup covering all screen lines - is the hardware mixing bitmaps of different resolutions or is there a +// line select somewhere? I should find the gal images and find what resolution they're stored at too. +// (or is this just wrong format / layout due to protection?) +void galpani2_state::copybg15(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect) +{ + UINT16* ram = m_bg15 + 0x40000/2; + + //int x = 0; + //int y = 0; + + const pen_t *clut = &m_bg15palette->pen(0); + for (int xx = 0; xx < 320; xx++) + { + for (int yy = 0; yy < 240; yy++) + { + UINT16 pen = ram[(xx * 0x800) + yy]; + bitmap.pix32(yy, xx) = clut[pen & 0x7fff]; + } + } +} + +UINT32 galpani2_state::screen_update_galpani2(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect) { int layers_ctrl = -1; -#ifdef MAME_DEBUG +#if 1 // MAME_DEBUG if (machine().input().code_pressed(KEYCODE_Z)) { int msk = 0; @@ -151,39 +149,15 @@ if (machine().input().code_pressed(KEYCODE_Z)) bitmap.fill(0, cliprect); screen.priority().fill(0, cliprect); - if (layers_ctrl & 0x1) - { - int x = 0; - int y = 0; - copyscrollbitmap_trans(bitmap, *m_bg15_bitmap, - 1, &x, 1, &y, - cliprect,0x4200 + 0); - } - /* test mode: 304000:0040 0000 0100 0000-0000 0000 0000 0000 (Sprite regs) 304010:16C0 0200 16C0 0200-16C0 0200 16C0 0200 16c0/40 = 5b 200/40 = 8 scrollx = f5, on screen x should be 0 (f5+5b = 150) */ - if (layers_ctrl & 0x2) - { - int x = - ( *m_bg8_scrollx[0] + 0x200 - 0x0f5 ); - int y = - ( *m_bg8_scrolly[0] + 0x200 - 0x1be ); - copyscrollbitmap_trans(bitmap, *m_bg8_bitmap[0], - 1, &x, 1, &y, - cliprect,0x4000 + 0); - } - - if (layers_ctrl & 0x4) - { - int x = - ( *m_bg8_scrollx[1] + 0x200 - 0x0f5 ); - int y = - ( *m_bg8_scrolly[1] + 0x200 - 0x1be ); - copyscrollbitmap_trans(bitmap, *m_bg8_bitmap[1], - 1, &x, 1, &y, - cliprect,0x4000 + 0); - } - + if (layers_ctrl & 0x1) copybg15(screen, bitmap, cliprect); + if (layers_ctrl & 0x2) copybg8(screen, bitmap, cliprect, 0); + if (layers_ctrl & 0x4) copybg8(screen, bitmap, cliprect, 1); if (layers_ctrl & 0x8) m_kaneko_spr->kaneko16_render_sprites(bitmap, cliprect, screen.priority(), m_spriteram, m_spriteram.bytes()); return 0; } |