From 5871259308d7596a0d4f836b090e124b8e8d4975 Mon Sep 17 00:00:00 2001 From: Scott Stone Date: Wed, 25 Jul 2012 14:15:05 +0000 Subject: [PATCH] pokechmp.c: [David Haywood] - Finally figured out the 8bpp BG tile plane order, a bit odd, guess there are swapped lines - Hooked up OKI sound banking - Fixed sprite attributes - Simplified CPU banking - Use generic palette functions --- src/mame/drivers/pokechmp.c | 125 +++++++++++++++-------------------- src/mame/includes/pokechmp.h | 1 - src/mame/video/pokechmp.c | 5 +- 3 files changed, 59 insertions(+), 72 deletions(-) diff --git a/src/mame/drivers/pokechmp.c b/src/mame/drivers/pokechmp.c index 2f434ddd665..4cc500fd6ac 100644 --- a/src/mame/drivers/pokechmp.c +++ b/src/mame/drivers/pokechmp.c @@ -6,14 +6,12 @@ Samples are played by OKIM6295 Different Banking More Tiles, 8bpp - Sprites 4bpp? instead of 2bpp + Sprites 4bpp instead of 2bpp Many code changes Todo: - Fix colours - Fix sound banking - Verify frequencies etc. + Verify frequencies etc. */ @@ -32,7 +30,7 @@ ROM 10 = Sound samples? ROM 11 = Main CPU code? -There's a "copyright 1987 data east corp.all rights reserved" - string inside ROM 11 + string inside ROM 11 (because it's a hack of Pocket Gal) -Sound = Yamaha YM2203C + Y3014B @@ -53,37 +51,23 @@ ClawGrip, Jul 2006 WRITE8_MEMBER(pokechmp_state::pokechmp_bank_w) { - UINT8 *RAM = memregion("maincpu")->base(); + UINT8 *ROM = memregion("maincpu")->base(); - if (data == 0x00) - { - membank("bank1")->set_base(&RAM[0x10000]); - membank("bank2")->set_base(&RAM[0x12000]); - } - if (data == 0x01) - { - membank("bank1")->set_base(&RAM[0x14000]); - membank("bank2")->set_base(&RAM[0x16000]); - } - if (data == 0x02) - { - membank("bank1")->set_base(&RAM[0x20000]); - membank("bank2")->set_base(&RAM[0x22000]); - } + int bank; + + bank = (data & 0x1) ? 0x04000 : 0x00000; + bank |= (data & 0x2) ? 0x10000 : 0x00000; - if (data == 0x03) - { - membank("bank1")->set_base(&RAM[0x04000]); - membank("bank2")->set_base(&RAM[0x06000]); - } + membank("bank1")->set_base(&ROM[bank]); } -#ifdef UNUSED_FUNCTION + WRITE8_MEMBER(pokechmp_state::pokechmp_sound_bank_w) { - membank("bank3")->set_entry((data >> 2) & 1); + UINT8 *ROM = memregion("oki")->base(); + membank("okibank")->set_base(&ROM[data*0x8000]); } -#endif + WRITE8_MEMBER(pokechmp_state::pokechmp_sound_w) { @@ -92,17 +76,6 @@ WRITE8_MEMBER(pokechmp_state::pokechmp_sound_w) } -INLINE void pokechmp_set_color(running_machine &machine, pen_t color, int rshift, int gshift, int bshift, UINT16 data) -{ - palette_set_color_rgb(machine, color, pal5bit(data >> rshift), pal5bit(data >> gshift), pal5bit(data >> bshift)); -} - - -WRITE8_MEMBER(pokechmp_state::pokechmp_paletteram_w) -{ - m_generic_paletteram_8[offset] = data; - pokechmp_set_color(machine(), offset &0x3ff, 0, 5, 10, (m_generic_paletteram_8[offset&0x3ff]<<8) | ( m_generic_paletteram_8[ (offset&0x3ff)+0x400 ] ) ); -} static ADDRESS_MAP_START( pokechmp_map, AS_PROGRAM, 8, pokechmp_state ) @@ -119,11 +92,11 @@ static ADDRESS_MAP_START( pokechmp_map, AS_PROGRAM, 8, pokechmp_state ) AM_RANGE(0x1c00, 0x1c00) AM_READ_PORT("DSW") AM_WRITE(pokechmp_bank_w) /* Extra on Poke Champ (not on Pocket Gal) */ - AM_RANGE(0x2000, 0x27ff) AM_RAM_WRITE(pokechmp_paletteram_w) AM_SHARE("paletteram") + AM_RANGE(0x2000, 0x23ff) AM_RAM_WRITE(paletteram_xBBBBBGGGGGRRRRR_byte_split_hi_w) AM_SHARE("paletteram2") + AM_RANGE(0x2400, 0x27ff) AM_RAM_WRITE(paletteram_xBBBBBGGGGGRRRRR_byte_split_lo_w) AM_SHARE("paletteram") - AM_RANGE(0x4000, 0x5fff) AM_ROMBANK("bank1") - AM_RANGE(0x6000, 0x7fff) AM_ROMBANK("bank2") - AM_RANGE(0x8000, 0xffff) AM_ROM + AM_RANGE(0x4000, 0x7fff) AM_ROMBANK("bank1") + AM_RANGE(0x8000, 0xffff) AM_ROMBANK("fixed") ADDRESS_MAP_END @@ -134,15 +107,21 @@ static ADDRESS_MAP_START( pokechmp_sound_map, AS_PROGRAM, 8, pokechmp_state ) AM_RANGE(0x0800, 0x0801) AM_DEVWRITE_LEGACY("ym1", ym2203_w) AM_RANGE(0x1000, 0x1001) AM_DEVWRITE_LEGACY("ym2", ym3812_w) AM_RANGE(0x1800, 0x1800) AM_WRITENOP /* MSM5205 chip on Pocket Gal, not connected here? */ -// AM_RANGE(0x2000, 0x2000) AM_WRITE(pokechmp_sound_bank_w)/ * might still be sound bank */ + AM_RANGE(0x2000, 0x2000) AM_WRITE(pokechmp_sound_bank_w) /* sound rom bank seems to be replaced with OKI bank */ AM_RANGE(0x2800, 0x2800) AM_DEVREADWRITE("oki", okim6295_device, read, write) // extra AM_RANGE(0x3000, 0x3000) AM_READ(soundlatch_byte_r) -// AM_RANGE(0x3400, 0x3400) AM_READ_LEGACY(pokechmp_adpcm_reset_r) /* ? not sure */ +// AM_RANGE(0x3400, 0x3400) AM_READ_LEGACY(pokechmp_adpcm_reset_r) /* not on here */ AM_RANGE(0x4000, 0x7fff) AM_ROMBANK("bank3") AM_RANGE(0x8000, 0xffff) AM_ROM ADDRESS_MAP_END +static ADDRESS_MAP_START( pokechmp_oki_map, AS_0, 8, pokechmp_state ) + AM_RANGE(0x00000, 0x37fff) AM_ROM + AM_RANGE(0x38000, 0x3ffff) AM_ROMBANK("okibank") +ADDRESS_MAP_END + + static INPUT_PORTS_START( pokechmp ) PORT_START("P1") PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_8WAY @@ -190,35 +169,35 @@ static INPUT_PORTS_START( pokechmp ) PORT_DIPSETTING( 0x00, DEF_STR( On ) ) INPUT_PORTS_END -/* this makes no sense at all! it seems impossible to get the colours to align up in the korean flag ingame and everything else is slightly broken too */ static const gfx_layout pokechmp_charlayout = { - 8,8, /* 8*8 characters */ + 8,8, /* 8*8 characters */ RGN_FRAC(1,8), 8, - { RGN_FRAC(1,8), RGN_FRAC(0,8),RGN_FRAC(3,8),RGN_FRAC(2,8),RGN_FRAC(5,8),RGN_FRAC(4,8),RGN_FRAC(7,8),RGN_FRAC(6,8) }, + /* bizzare order, but it seems to be correct? */ + { RGN_FRAC(1,8), RGN_FRAC(3,8),RGN_FRAC(0,8),RGN_FRAC(5,8),RGN_FRAC(2,8),RGN_FRAC(7,8),RGN_FRAC(4,8),RGN_FRAC(6,8) }, { 0, 1, 2, 3, 4, 5, 6, 7 }, { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8 }, 8*8 /* every char takes 8 consecutive bytes */ }; -/* should be ok.. */ + static const gfx_layout pokechmp_spritelayout = { -16,16, /* 16*16 sprites */ -RGN_FRAC(1,8), /* 1024 sprites */ -4, -{RGN_FRAC(1,8),RGN_FRAC(3,8),RGN_FRAC(5,8),RGN_FRAC(7,8)}, -{ 128+7, 128+6, 128+5, 128+4, 128+3, 128+2, 128+1, 128+0, 7, 6, 5, 4, 3, 2, 1, 0 }, -{ 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8, 8*8, 9*8, 10*8, 11*8, 12*8, 13*8, 14*8, 15*8 }, -32*8 /* every char takes 8 consecutive bytes */ + 16,16, /* 16*16 sprites */ + RGN_FRAC(1,4), /* 1024 sprites */ + 4, + {RGN_FRAC(0,4),RGN_FRAC(1,4),RGN_FRAC(2,4),RGN_FRAC(3,4)}, + { 128+7, 128+6, 128+5, 128+4, 128+3, 128+2, 128+1, 128+0, 7, 6, 5, 4, 3, 2, 1, 0 }, + { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8, 8*8, 9*8, 10*8, 11*8, 12*8, 13*8, 14*8, 15*8 }, + 32*8 /* every char takes 8 consecutive bytes */ }; static GFXDECODE_START( pokechmp ) - GFXDECODE_ENTRY( "gfx1", 0x00000, pokechmp_charlayout, 0x100, 32 ) /* chars */ - GFXDECODE_ENTRY( "gfx2", 0x00000, pokechmp_spritelayout, 0, 32 ) /* sprites */ + GFXDECODE_ENTRY( "bgs", 0x00000, pokechmp_charlayout, 0x100, 4 ) /* chars */ + GFXDECODE_ENTRY( "sprites", 0x00000, pokechmp_spritelayout, 0, 32 ) /* sprites */ GFXDECODE_END @@ -258,39 +237,45 @@ static MACHINE_CONFIG_START( pokechmp, pokechmp_state ) MCFG_OKIM6295_ADD("oki", 4000000/4, OKIM6295_PIN7_HIGH) // ?? unknown frequency MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50) /* sound fx */ MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50) + MCFG_DEVICE_ADDRESS_MAP(AS_0, pokechmp_oki_map) MACHINE_CONFIG_END static DRIVER_INIT( pokechmp ) { + // default sound rom bank machine.root_device().membank("bank3")->configure_entries(0, 2, machine.root_device().memregion("audiocpu")->base() + 0x10000, 0x4000); + + // default fixed area for main CPU + machine.root_device().membank("fixed")->set_base( machine.root_device().memregion("maincpu")->base() + 0x18000 ); + + // default OKI sample bank + machine.root_device().membank("okibank")->set_base( machine.root_device().memregion("oki")->base() + 0x40000 ); } ROM_START( pokechmp ) - ROM_REGION( 0x24000, "maincpu", 0 ) /* 64k for code + 16k for banks */ - ROM_LOAD( "pokechamp_11_27010.bin", 0x10000, 0x14000, CRC(9afb6912) SHA1(e45da9524e3bb6f64a68200b70d0f83afe6e4379) ) - ROM_CONTINUE( 0x04000, 0xc000) + ROM_REGION( 0x20000, "maincpu", 0 ) + ROM_LOAD( "pokechamp_11_27010.bin", 0x00000, 0x20000, CRC(9afb6912) SHA1(e45da9524e3bb6f64a68200b70d0f83afe6e4379) ) ROM_REGION( 0x18000, "audiocpu", 0 ) /* 96k for code + 96k for decrypted opcodes */ ROM_LOAD( "pokechamp_09_27c512.bin", 0x10000, 0x8000, CRC(c78f6483) SHA1(a0d063effd8d1850f674edccb6e7a285b2311d21) ) ROM_CONTINUE( 0x08000, 0x8000 ) - ROM_REGION( 0x100000, "gfx1", 0) - /* Seems to be 8bpp */ + ROM_REGION( 0x100000, "bgs", 0 ) ROM_LOAD( "pokechamp_05_27c020.bin", 0x00000, 0x40000, CRC(554cfa42) SHA1(862d0dd83697da7bd52dc640c34926c62691afea) ) ROM_LOAD( "pokechamp_06_27c020.bin", 0x40000, 0x40000, CRC(00bb9536) SHA1(1a5584297ebb425d6ce331955e0c6a4f467cd1e6) ) ROM_LOAD( "pokechamp_07_27c020.bin", 0x80000, 0x40000, CRC(4b15ab5e) SHA1(5523134853b9ea1c81fd5aeb58061376d94e9298) ) ROM_LOAD( "pokechamp_08_27c020.bin", 0xc0000, 0x40000, CRC(e9db54d6) SHA1(ac3b7c06d0f61847bf9bc6147f2f88d712f2b4b3) ) - ROM_REGION( 0x40000, "gfx2", 0 ) + ROM_REGION( 0x20000, "sprites", 0 ) /* the first half of all these roms is identical. For rom 3 both halves match. Correct decode is to ignore the first half */ - ROM_LOAD( "pokechamp_02_27c512.bin", 0x00000, 0x10000, CRC(1ff44545) SHA1(2eee44484accce7b0ba21babf6e8344b234a4e87) ) - ROM_LOAD( "pokechamp_01_27c512.bin", 0x10000, 0x10000, CRC(338fc412) SHA1(bb8ae99ee6a399a8c67bedb88d0837fd0a4a426c) ) - ROM_LOAD( "pokechamp_04_27c512.bin", 0x20000, 0x10000, CRC(ee6991af) SHA1(8eca3cdfd2eb74257253957a87b245b7f85bd038) ) - ROM_LOAD( "pokechamp_03_27c512.bin", 0x30000, 0x10000, CRC(99f9884a) SHA1(096d6ce70dc51fb9142e80e1ec45d6d7225481f5) ) + ROM_LOAD( "pokechamp_02_27c512.bin", 0x00000, 0x08000, CRC(1ff44545) SHA1(2eee44484accce7b0ba21babf6e8344b234a4e87) ) ROM_CONTINUE( 0x00000, 0x8000 ) + ROM_LOAD( "pokechamp_01_27c512.bin", 0x08000, 0x08000, CRC(338fc412) SHA1(bb8ae99ee6a399a8c67bedb88d0837fd0a4a426c) ) ROM_CONTINUE( 0x08000, 0x8000 ) + ROM_LOAD( "pokechamp_04_27c512.bin", 0x10000, 0x08000, CRC(ee6991af) SHA1(8eca3cdfd2eb74257253957a87b245b7f85bd038) ) ROM_CONTINUE( 0x10000, 0x8000 ) + ROM_LOAD( "pokechamp_03_27c512.bin", 0x18000, 0x08000, CRC(99f9884a) SHA1(096d6ce70dc51fb9142e80e1ec45d6d7225481f5) ) ROM_CONTINUE( 0x18000, 0x8000 ) ROM_REGION( 0x80000, "oki", 0 ) ROM_LOAD( "pokechamp_10_27c040.bin", 0x00000, 0x80000, CRC(b54806ed) SHA1(c6e1485c263ebd9102ff1e8c09b4c4ca5f63c3da) ) ROM_END -GAME( 1995, pokechmp, 0, pokechmp, pokechmp, pokechmp, ROT0, "D.G.R.M.", "Poke Champ", GAME_WRONG_COLORS | GAME_IMPERFECT_SOUND ) +GAME( 1995, pokechmp, 0, pokechmp, pokechmp, pokechmp, ROT0, "D.G.R.M.", "Poke Champ", 0 ) diff --git a/src/mame/includes/pokechmp.h b/src/mame/includes/pokechmp.h index 2dfb468f592..3037a0f96e8 100644 --- a/src/mame/includes/pokechmp.h +++ b/src/mame/includes/pokechmp.h @@ -12,7 +12,6 @@ public: DECLARE_WRITE8_MEMBER(pokechmp_bank_w); DECLARE_WRITE8_MEMBER(pokechmp_sound_bank_w); DECLARE_WRITE8_MEMBER(pokechmp_sound_w); - DECLARE_WRITE8_MEMBER(pokechmp_paletteram_w); DECLARE_WRITE8_MEMBER(pokechmp_videoram_w); DECLARE_WRITE8_MEMBER(pokechmp_flipscreen_w); }; diff --git a/src/mame/video/pokechmp.c b/src/mame/video/pokechmp.c index 49eaa06aa08..da4b3df382b 100644 --- a/src/mame/video/pokechmp.c +++ b/src/mame/video/pokechmp.c @@ -61,9 +61,12 @@ static void draw_sprites(running_machine &machine, bitmap_ind16 &bitmap, const r if (flipx) flipx=0; else flipx=1; if (flipy) flipy=0; else flipy=1; } + int tileno = spriteram[offs+3]; + if (spriteram[offs+1] & 0x01) tileno += 0x100; + if (spriteram[offs+1] & 0x08) tileno += 0x200; drawgfx_transpen(bitmap,cliprect,machine.gfx[1], - spriteram[offs+3] + ((spriteram[offs+1] & 1) << 8), + tileno, (spriteram[offs+1] & 0xf0) >> 4, flipx,flipy, sx,sy,0);