📄 neogeo.c
字号:
{ 0x320000, 0x320001, neo_z80_w }, /* Sound CPU */
{ 0x380000, 0x380001, MWA_NOP }, /* Used by bios, unknown */
{ 0x380030, 0x380031, MWA_NOP }, /* Used by bios, unknown */
{ 0x380040, 0x380041, MWA_NOP }, /* Output leds */
{ 0x380050, 0x380051, neo_pd4990a_control_w },
{ 0x380060, 0x380063, MWA_NOP }, /* Used by bios, unknown */
{ 0x3800e0, 0x3800e3, MWA_NOP }, /* Used by bios, unknown */
{ 0x3a0000, 0x3a0001, MWA_NOP },
{ 0x3a0010, 0x3a0011, MWA_NOP },
{ 0x3a0002, 0x3a0003, MWA_NOP },
{ 0x3a0012, 0x3a0013, MWA_NOP },
{ 0x3a000a, 0x3a000b, neo_board_fix }, /* Select board FIX char rom */
{ 0x3a001a, 0x3a001b, neo_game_fix }, /* Select game FIX char rom */
{ 0x3a000c, 0x3a000d, neogeo_sram_lock_w },
{ 0x3a001c, 0x3a001d, neogeo_sram_unlock_w },
{ 0x3a000e, 0x3a000f, neogeo_setpalbank1 },
{ 0x3a001e, 0x3a001f, neogeo_setpalbank0 }, /* Palette banking */
{ 0x3c0000, 0x3c0001, vidram_offset_w },
{ 0x3c0002, 0x3c0003, vidram_data_w },
{ 0x3c0004, 0x3c0005, vidram_modulo_w },
{ 0x3c0006, 0x3c0007, neo_control_w }, /* See level 2 of spinmasters, rowscroll data? */
{ 0x3c0008, 0x3c000b, neo_irq2pos_w }, /* IRQ2 x/y position? */
{ 0x3c000c, 0x3c000d, MWA_NOP }, /* IRQ acknowledge */
/* 4 = IRQ 1 */
/* 2 = IRQ 2 */
/* 1 = IRQ 3 (does any game use this?) */
{ 0x400000, 0x401fff, neogeo_paletteram_w },
{ 0x600000, 0x61ffff, mish_vid_w }, /* Debug only, not part of real NeoGeo */
{ 0xd00000, 0xd0ffff, neogeo_sram_w, &neogeo_sram }, /* 64k battery backed SRAM */
{ -1 } /* end of table */
};
/******************************************************************************/
static struct MemoryReadAddress sound_readmem[] =
{
{ 0x0000, 0x7fff, MRA_ROM },
{ 0x8000, 0xbfff, MRA_BANK5 },
{ 0xc000, 0xdfff, MRA_BANK6 },
{ 0xe000, 0xefff, MRA_BANK7 },
{ 0xf000, 0xf7ff, MRA_BANK8 },
{ 0xf800, 0xffff, MRA_RAM },
{ -1 } /* end of table */
};
static struct MemoryWriteAddress sound_writemem[] =
{
{ 0x0000, 0xf7ff, MWA_ROM },
{ 0xf800, 0xffff, MWA_RAM },
{ -1 } /* end of table */
};
static int z80_port_r(int offset)
{
static int bank[4];
#if 0
{
char buf[80];
sprintf(buf,"%05x %05x %05x %05x",bank[0],bank[1],bank[2],bank[3]);
usrintf_showmessage(buf);
}
#endif
switch (offset & 0xff)
{
case 0x00:
pending_command = 0;
return soundlatch_r(0);
break;
case 0x04:
return YM2610_status_port_0_A_r(0);
break;
case 0x05:
return YM2610_read_port_0_r(0);
break;
case 0x06:
return YM2610_status_port_0_B_r(0);
break;
case 0x08:
{
unsigned char *RAM = Machine->memory_region[Machine->drv->cpu[1].memory_region];
bank[3] = 0x0800 * ((offset >> 8) & 0x3f);
cpu_setbank(8,&RAM[bank[3]]);
return 0;
break;
}
case 0x09:
{
unsigned char *RAM = Machine->memory_region[Machine->drv->cpu[1].memory_region];
bank[2] = 0x1000 * ((offset >> 8) & 0x1f);
cpu_setbank(7,&RAM[bank[2]]);
return 0;
break;
}
case 0x0a:
{
unsigned char *RAM = Machine->memory_region[Machine->drv->cpu[1].memory_region];
bank[1] = 0x2000 * ((offset >> 8) & 0x0f);
cpu_setbank(6,&RAM[bank[1]]);
return 0;
break;
}
case 0x0b:
{
unsigned char *RAM = Machine->memory_region[Machine->drv->cpu[1].memory_region];
bank[0] = 0x4000 * ((offset >> 8) & 0x07);
cpu_setbank(5,&RAM[bank[0]]);
return 0;
break;
}
default:
return 0;
break;
}
}
static void z80_port_w(int offset,int data)
{
switch (offset & 0xff)
{
case 0x04:
YM2610_control_port_0_A_w(0,data);
break;
case 0x05:
YM2610_data_port_0_A_w(0,data);
break;
case 0x06:
YM2610_control_port_0_B_w(0,data);
break;
case 0x07:
YM2610_data_port_0_B_w(0,data);
break;
case 0x08:
/* NMI enable / acknowledge? (the data written doesn't matter) */
break;
case 0x0c:
result_code = data;
break;
case 0x18:
/* NMI disable? (the data written doesn't matter) */
break;
default:
break;
}
}
static struct IOReadPort neo_readio[] =
{
{ 0x0000, 0xffff, z80_port_r },
{ -1 }
};
static struct IOWritePort neo_writeio[] =
{
{ 0x0000, 0xffff, z80_port_w },
{ -1 }
};
/******************************************************************************/
INPUT_PORTS_START( neogeo_ports )
PORT_START /* IN0 */
PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP )
PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN )
PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT )
PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT )
PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 )
PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 )
PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON3 )
PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_BUTTON4 )
PORT_START /* IN1 */
PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP | IPF_PLAYER2 )
PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN | IPF_PLAYER2 )
PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT | IPF_PLAYER2 )
PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_PLAYER2 )
PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_PLAYER2 )
PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 | IPF_PLAYER2 )
PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON3 | IPF_PLAYER2 )
PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_BUTTON4 | IPF_PLAYER2 )
PORT_START /* IN2 */
PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_START1 ) /* Player 1 Start */
PORT_BITX( 0x02, IP_ACTIVE_LOW, 0, "SELECT 1",OSD_KEY_6, IP_JOY_NONE, 0) /* Player 1 Select */
PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_START2 ) /* Player 2 Start */
PORT_BITX( 0x08, IP_ACTIVE_LOW, 0, "SELECT 2",OSD_KEY_7, IP_JOY_NONE, 0) /* Player 2 Select */
PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNKNOWN ) /* Bits 10 & 20 have significance.. don't know what yet */
PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNKNOWN )
PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
PORT_START /* IN3 */
PORT_DIPNAME( 0x01, 0x01, "Test Switch", IP_KEY_NONE )
PORT_DIPSETTING( 0x01, "Off" )
PORT_DIPSETTING( 0x00, "On" )
PORT_DIPNAME( 0x02, 0x02, "Unknown", IP_KEY_NONE )
PORT_DIPSETTING( 0x02, "Off" )
PORT_DIPSETTING( 0x00, "On" )
PORT_DIPNAME( 0x04, 0x04, "Unknown", IP_KEY_NONE )
PORT_DIPSETTING( 0x04, "Off" )
PORT_DIPSETTING( 0x00, "On" )
PORT_DIPNAME( 0x38, 0x38, "COMM Setting", IP_KEY_NONE )
PORT_DIPSETTING( 0x38, "Off" )
PORT_DIPSETTING( 0x30, "1" )
PORT_DIPSETTING( 0x20, "2" )
PORT_DIPSETTING( 0x10, "3" )
PORT_DIPSETTING( 0x00, "4" )
PORT_DIPNAME( 0x40, 0x40, "Free Play", IP_KEY_NONE )
PORT_DIPSETTING( 0x40, "Off" )
PORT_DIPSETTING( 0x00, "On" )
PORT_DIPNAME( 0x80, 0x80, "Freeze", IP_KEY_NONE )
PORT_DIPSETTING( 0x80, "Off" )
PORT_DIPSETTING( 0x00, "On" )
PORT_START /* IN4 */
PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN1 )
PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_COIN2 )
PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_COIN3 ) /* Service */
/* Fake IN 5 */
PORT_START
PORT_DIPNAME( 0x03, 0x02,"Territory", IP_KEY_NONE )
PORT_DIPSETTING( 0x00,"Japan" )
PORT_DIPSETTING( 0x01,"USA" )
PORT_DIPSETTING( 0x02,"Europe" )
PORT_DIPNAME( 0x04, 0x04,"Machine mode", IP_KEY_NONE )
PORT_DIPSETTING( 0x00,"Home" )
PORT_DIPSETTING( 0x04,"Arcade" )
PORT_START /* Test switch */
PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_UNKNOWN )
PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_UNKNOWN )
PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_UNKNOWN )
PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_UNKNOWN )
PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_UNKNOWN )
PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_UNKNOWN )
PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_UNKNOWN ) /* This bit is used.. */
PORT_BITX( 0x80, IP_ACTIVE_LOW, 0, "Test Switch", OSD_KEY_F2, IP_JOY_NONE, 0)
INPUT_PORTS_END
/******************************************************************************/
/* character layout (same for all games) */
static struct GfxLayout charlayout = /* All games */
{
8,8, /* 8 x 8 chars */
4096, /* 4096 in total */
4, /* 4 bits per pixel */
{ 0, 1, 2, 3 }, /* planes are packed in a nibble */
{ 33*4, 32*4, 49*4, 48*4, 1*4, 0*4, 17*4, 16*4 },
{ 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8 },
32*8 /* 32 bytes per char */
};
/* Placeholder and also reminder of how this graphic format is put together */
static struct GfxLayout dummy_mgd2_tilelayout =
{
16,16, /* 16*16 sprites */
20, /* sprites */
4, /* 4 bits per pixel */
{ /*0x10000*32*8*3*/3, /*0x10000*32*8*2*/2, /*0x10000*32*8*/1, 0 },
{ 16*8+7, 16*8+6, 16*8+5, 16*8+4, 16*8+3, 16*8+2, 16*8+1, 16*8+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 sprite takes 32 consecutive bytes */
};
/* Placeholder and also reminder of how this graphic format is put together */
static struct GfxLayout dummy_mvs_tilelayout =
{
16,16, /* 16*16 sprites */
20,
4,
{ /*0x400000*8 +*/ 8, /*0x400000*8 + */0, 8, 0 }, /* plane offset */
{ 32*8+7, 32*8+6, 32*8+5, 32*8+4, 32*8+3, 32*8+2, 32*8+1, 32*8+0,
7, 6, 5, 4, 3, 2, 1, 0 },
{ 0*16, 1*16, 2*16, 3*16, 4*16, 5*16, 6*16, 7*16,
8*16, 9*16, 10*16, 11*16, 12*16, 13*16, 14*16, 15*16 },
64*8 /* every sprite takes 64 consecutive bytes */
};
static struct GfxDecodeInfo neogeo_mvs_gfxdecodeinfo[] =
{
{ 1, 0x000000, &charlayout, 0, 16 },
{ 1, 0x020000, &charlayout, 0, 16 },
{ 1, 0x000000, &dummy_mvs_tilelayout, 0, 256 }, /* Placeholder */
{ -1 } /* end of array */
};
static struct GfxDecodeInfo neogeo_mgd2_gfxdecodeinfo[] =
{
{ 1, 0x000000, &charlayout, 0, 16 },
{ 1, 0x020000, &charlayout, 0, 16 },
{ 1, 0x000000, &dummy_mvs_tilelayout, 0, 256 }, /* Placeholder */
{ -1 } /* end of array */
};
/******************************************************************************/
static void neogeo_sound_irq( void )
{
cpu_cause_interrupt(1,0xff);
}
struct YM2610interface neogeo_ym2610_interface =
{
1,
8000000,
{ YM2203_VOL(60,0x301e) },
{ 0 },
{ 0 },
{ 0 },
{ 0 },
{ neogeo_sound_irq },
{ 7 },
{ 6 }
};
/******************************************************************************/
static struct MachineDriver neogeo_mgd2_machine_driver =
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -