pengo.c


WRITE_HANDLER( menugam_gfxbank_w )
{     
        int bankaddress;
        unsigned char *RAM = memory_region(REGION_CPU1);

        //logerror("Input Port 1 %n\n", &data);

        if (gfx_bank != (data % 0x10))
	{
                gfx_bank = data % 0x10;
		memset(dirtybuffer,1,videoram_size);
	}

       memset(dirtybuffer,1,videoram_size);
       bankaddress = 0x10000 + ((data % 0x10) * 0x8000);
       cpu_setbank(1,&RAM[bankaddress]);
       cpu_setbank(2,&RAM[bankaddress+0x4000]);
}

pacman.c


// David Widel's 500-in-1 Pacman Game //
// Preliminary Driver by Peter Storey (XzeriX)
// TO DO: CPU and Graphics Banking, without which this is unplayable :-(

/*
        Memory map (preliminary)

        0000-3fff ROM (Banked)
	4000-43ff Video RAM
	4400-47ff Color RAM
	4c00-4fff RAM
        8000-b7ff ROM (Banked)
        b800-bfff NV-RAM
*/

INPUT_PORTS_START( menugam )
	PORT_START	/* IN0 */
	PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP    | IPF_4WAY )
	PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT  | IPF_4WAY )
	PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_4WAY )
	PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN  | IPF_4WAY )
	//PORT_BITX(    0x10, 0x10, IPT_DIPSWITCH_NAME | IPF_CHEAT, "Rack Test", KEYCODE_F1, IP_JOY_NONE )
	PORT_DIPNAME( 0x10, 0x10, "DIP 7:  Rack Test" )
	PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
	PORT_DIPSETTING(    0x00, DEF_STR( On ) )
	PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_COIN1 )
	PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_COIN2 )
	PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_SERVICE1 )

	PORT_START	/* IN1 */
	PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP    | IPF_4WAY | IPF_COCKTAIL )
	PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT  | IPF_4WAY | IPF_COCKTAIL )
	PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_4WAY | IPF_COCKTAIL )
	PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN  | IPF_4WAY | IPF_COCKTAIL )
	PORT_SERVICE( 0x10, IP_ACTIVE_LOW )
        PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_START1 )
        PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_START2 )
        PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON1 )
        PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON2 )

	PORT_DIPNAME(0x80, 0x80, DEF_STR( Cabinet ) )
	PORT_DIPSETTING(   0x80, DEF_STR( Upright ) )
	PORT_DIPSETTING(   0x00, DEF_STR( Cocktail ) )

	PORT_START	/* DSW 1 */
	PORT_DIPNAME( 0x01, 0x01, "DIP 1" )
	PORT_DIPSETTING(    0x01, DEF_STR( Off ) )
	PORT_DIPSETTING(    0x00, DEF_STR( On ) )
	PORT_DIPNAME( 0x02, 0x02, "DIP 2:  Initials only" )
	PORT_DIPSETTING(    0x02, DEF_STR( Off ) )
	PORT_DIPSETTING(    0x00, DEF_STR( On ) )
	PORT_DIPNAME( 0x04, 0x04, "DIP 3:  Fast OK for TM" )
	PORT_DIPSETTING(    0x04, DEF_STR( Off ) )
	PORT_DIPSETTING(    0x00, DEF_STR( On ) )
	PORT_DIPNAME( 0x08, 0x08, "DIP 4:  Tournament Mode" )
	PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
	PORT_DIPSETTING(    0x00, DEF_STR( On ) )
	PORT_DIPNAME( 0x10, 0x10, "DIP 5:  Guest Mode" )
	PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
	PORT_DIPSETTING(    0x00, DEF_STR( On ) )
	PORT_DIPNAME( 0x20, 0x20, "DIP 6:  Dip Menu" )
	PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
	PORT_DIPSETTING(    0x00, DEF_STR( On ) )
	PORT_DIPNAME( 0x40, 0x40, DEF_STR( Difficulty ) )
	PORT_DIPSETTING(    0x40, "Normal" )
	PORT_DIPSETTING(    0x00, "Hard" )
	PORT_DIPNAME( 0x80, 0x80, "Ghost Names" )
	PORT_DIPSETTING(    0x80, "Normal" )
	PORT_DIPSETTING(    0x00, "Alternate" )
	PORT_START	/* DSW 2 */
	PORT_BIT( 0xff, IP_ACTIVE_HIGH, IPT_UNUSED )

	PORT_START	/* FAKE */
	/* This fake input port is used to get the status of the fire button */
	/* and activate the speedup cheat if it is. */
	PORT_BITX(    0x02, 0x00, IPT_DIPSWITCH_NAME , "Reset Button", KEYCODE_RCONTROL, JOYCODE_1_BUTTON1 )
	PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
	PORT_DIPSETTING(    0x02, DEF_STR( On ) )

INPUT_PORTS_END

static WRITE_HANDLER( menugam_banking_w)
{
        // Banking code to go here
}

static PORT_WRITE_START( menugam_writeport )
	{ 0x00, 0x00, interrupt_vector_w },	/* Pac-Man only */
        { 0x01, 0x01, menugam_gfxbank_w },      /* Banking! */
PORT_END


MACHINE_INIT( menugam )
{
	unsigned char *RAM = memory_region(REGION_CPU1);

	/* check if the loaded set of ROMs allows the Pac Man speed hack */
	if ((RAM[0x180b] == 0xbe && RAM[0x1ffd] == 0x00) ||
			(RAM[0x180b] == 0x01 && RAM[0x1ffd] == 0xbd))
		speedcheat = 1;
	else
		speedcheat = 0;
}

static MEMORY_READ_START( menugam_readmem )
        { 0x0000, 0x3fff, MRA_BANK1 },
	{ 0x4000, 0x47ff, MRA_RAM },	/* video and color RAM */
	{ 0x4c00, 0x4fff, MRA_RAM },	/* including sprite codes at 4ff0-4fff */
	{ 0x5000, 0x503f, input_port_0_r },	/* IN0 */
	{ 0x5040, 0x507f, input_port_1_r },	/* IN1 */
	{ 0x5080, 0x50bf, input_port_2_r },	/* DSW1 */
	{ 0x50c0, 0x50ff, input_port_3_r },	/* DSW2 */
        { 0x8000, 0xb7ff, MRA_BANK2 },
        { 0xb800, 0xbfff, MRA_RAM },
MEMORY_END


static MEMORY_WRITE_START( menugam_writemem )
	{ 0x0000, 0x3fff, MWA_ROM },
	{ 0x4000, 0x43ff, videoram_w, &videoram, &videoram_size },
	{ 0x4400, 0x47ff, colorram_w, &colorram },
	{ 0x4c00, 0x4fef, MWA_RAM },
	{ 0x4ff0, 0x4fff, MWA_RAM, &spriteram, &spriteram_size },
	{ 0x5000, 0x5000, interrupt_enable_w },
	{ 0x5001, 0x5001, pengo_sound_enable_w },
	{ 0x5002, 0x5002, MWA_NOP },
	{ 0x5003, 0x5003, pengo_flipscreen_w },
 	{ 0x5004, 0x5005, pacman_leds_w },
// 	{ 0x5006, 0x5006, pacman_coin_lockout_global_w },	this breaks many games
 	{ 0x5007, 0x5007, pacman_coin_counter_w },
	{ 0x5040, 0x505f, pengo_sound_w, &pengo_soundregs },
	{ 0x5060, 0x506f, MWA_RAM, &spriteram_2 },
      { 0x50c0, 0x50c0, watchdog_reset_w },
        { 0x8000, 0xb7ff, MWA_ROM },
        { 0xb800, 0xbfff, MWA_RAM, &generic_nvram, &generic_nvram_size}, // Actually, this is NV-RAM
        { 0xc000, 0xc3ff, videoram_w }, /* mirror address for video ram, */
	{ 0xc400, 0xc7ef, colorram_w }, /* used to display HIGH SCORE and CREDITS */
	{ 0xffff, 0xffff, MWA_NOP },	/* Eyes writes to this location to simplify code */
MEMORY_END


static struct GfxDecodeInfo menugam_gfxdecodeinfo[] =
{
        { REGION_GFX1, 0x00000, &tilelayout,   0, 32 },
        { REGION_GFX1, 0x01000, &spritelayout, 0, 32 },
        { REGION_GFX1, 0x02000, &tilelayout,   0, 32 },
        { REGION_GFX1, 0x03000, &spritelayout, 0, 32 },
        { REGION_GFX1, 0x04000, &tilelayout,   0, 32 },
        { REGION_GFX1, 0x05000, &spritelayout, 0, 32 },
        { REGION_GFX1, 0x06000, &tilelayout,   0, 32 },
        { REGION_GFX1, 0x07000, &spritelayout, 0, 32 },
        { REGION_GFX1, 0x08000, &tilelayout,   0, 32 },
        { REGION_GFX1, 0x09000, &spritelayout, 0, 32 },
        { REGION_GFX1, 0x0a000, &tilelayout,   0, 32 },
        { REGION_GFX1, 0x0b000, &spritelayout, 0, 32 },
        { REGION_GFX1, 0x0c000, &tilelayout,   0, 32 },
        { REGION_GFX1, 0x0d000, &spritelayout, 0, 32 },
        { REGION_GFX1, 0x0e000, &tilelayout,   0, 32 },
        { REGION_GFX1, 0x0f000, &spritelayout, 0, 32 },
        { REGION_GFX1, 0x10000, &tilelayout,   0, 32 },
        { REGION_GFX1, 0x11000, &spritelayout, 0, 32 },
        { REGION_GFX1, 0x12000, &tilelayout,   0, 32 },
        { REGION_GFX1, 0x13000, &spritelayout, 0, 32 },
        { REGION_GFX1, 0x14000, &tilelayout,   0, 32 },
        { REGION_GFX1, 0x15000, &spritelayout, 0, 32 },
        { REGION_GFX1, 0x16000, &tilelayout,   0, 32 },
        { REGION_GFX1, 0x17000, &spritelayout, 0, 32 },
        { REGION_GFX1, 0x18000, &tilelayout,   0, 32 },
        { REGION_GFX1, 0x19000, &spritelayout, 0, 32 },
        { REGION_GFX1, 0x1a000, &tilelayout,   0, 32 },
        { REGION_GFX1, 0x1b000, &spritelayout, 0, 32 },
        { REGION_GFX1, 0x1c000, &tilelayout,   0, 32 },
        { REGION_GFX1, 0x1d000, &spritelayout, 0, 32 },
        { REGION_GFX1, 0x1e000, &tilelayout,   0, 32 },
        { REGION_GFX1, 0x1f000, &spritelayout, 0, 32 },
	{ -1 } /* end of array */
};

static MACHINE_DRIVER_START( menugam )

	/* basic machine hardware */
	MDRV_CPU_ADD_TAG("main", Z80, 18432000/6)
        MDRV_CPU_MEMORY(menugam_readmem,menugam_writemem)
        MDRV_CPU_PORTS(0,menugam_writeport)
	MDRV_CPU_VBLANK_INT(pacman_interrupt,1)

	MDRV_FRAMES_PER_SECOND(60.606060)
	MDRV_VBLANK_DURATION(DEFAULT_REAL_60HZ_VBLANK_DURATION)
        MDRV_MACHINE_INIT(menugam)

	/* video hardware */
	MDRV_VIDEO_ATTRIBUTES(VIDEO_TYPE_RASTER)
	MDRV_SCREEN_SIZE(36*8, 28*8)
	MDRV_VISIBLE_AREA(0*8, 36*8-1, 0*8, 28*8-1)
        MDRV_GFXDECODE(menugam_gfxdecodeinfo)
	MDRV_PALETTE_LENGTH(16)
	MDRV_COLORTABLE_LENGTH(4*32)

	MDRV_PALETTE_INIT(pacman)
        MDRV_VIDEO_START(pacman)
	MDRV_VIDEO_UPDATE(pengo)
	MDRV_NVRAM_HANDLER(generic_0fill)

	/* sound hardware */
	MDRV_SOUND_ADD_TAG("namco", NAMCO, namco_interface)
MACHINE_DRIVER_END



ROM_START( 96in1 )
        ROM_REGION( 0x90000, REGION_CPU1, 0 )
        ROM_LOAD( "menugame.bin",  0x10000, 0x80000, CRC(78d927dd) )   /* banked */
        ROM_COPY( REGION_CPU1, 0x10000, 0x00000, 0x4000)
        ROM_COPY( REGION_CPU1, 0x14000, 0x08000, 0x3800)
     
        ROM_REGION( 0x20000, REGION_GFX1, ROMREGION_DISPOSE )
        ROM_LOAD( "menuggr.bin",   0x0000, 0x20000, CRC(ba4c283d) )

	ROM_REGION( 0x0120, REGION_PROMS, 0 )
	ROM_LOAD( "82s123.7f",    0x0000, 0x0020, CRC(2fc650bd) SHA1(8d0268dee78e47c712202b0ec4f1f51109b1f2a5) )
	ROM_LOAD( "82s126.4a",    0x0020, 0x0100, CRC(3eb3a8e4) SHA1(19097b5f60d1030f8b82d9f1d3a241f93e5c75d6) )

	ROM_REGION( 0x0200, REGION_SOUND1, 0 )
	ROM_LOAD( "82s126.1m",    0x0000, 0x0100, CRC(a9cc86bf) SHA1(bbcec0570aeceb582ff8238a4bc8546a23430081) )
	ROM_LOAD( "82s126.3m",    0x0100, 0x0100, CRC(77245b66) SHA1(0c4d0bee858b97632411c440bea6948a74759746) )
ROM_END

/*          rom       parent    machine   inp       init */
GAME( 2003, 96in1,  0,        menugam,  menugam,  0,        ROT90,  "[Hack] David Widel", "Pacman 500+ Multigame aka 96 in 1" )


