📄 megasys1.c
字号:
{ 0x060000, 0x060001, soundlatch_r },
{ 0x080002, 0x080003, YM2151_status_port_0_r },
{ 0x0a0000, 0x0a0001, OKIM6295_status_0_r },
{ 0x0c0000, 0x0c0001, OKIM6295_status_1_r },
{ 0x0e0000, 0x0effff, MRA_BANK1 },
{ -1 }
};
static struct MemoryWriteAddress sound_writemem_C[] =
{
{ 0x000000, 0x03ffff, MWA_ROM }, /* MS1-C has half that */
{ 0x040000, 0x040001, MWA_NOP }, /* ? */
{ 0x060000, 0x060001, MWA_NOP }, /* sound command received ? */
{ 0x080000, 0x080001, YM2151_register_port_0_w },
{ 0x080002, 0x080003, YM2151_data_port_0_w},
{ 0x0a0000, 0x0a0003, OKIM6295_data_0_w },
{ 0x0c0000, 0x0c0003, OKIM6295_data_1_w },
{ 0x0e0000, 0x0effff, MWA_BANK1 },
{ -1 }
};
#define sound_writemem_B sound_writemem_C
#define sound_readmem_B sound_readmem_C
#define sound_interrupt_B sound_interrupt_C
/******************** Z80 ***********************/
static struct MemoryReadAddress sound_readmem_z80[] =
{
{ 0x0000, 0x3fff, MRA_ROM },
{ 0xc000, 0xc7ff, MRA_RAM },
{ 0xe000, 0xe000, soundlatch_r },
{ -1 }
};
static struct MemoryWriteAddress sound_writemem_z80[] =
{
{ 0x0000, 0x3fff, MWA_ROM },
{ 0xc000, 0xc7ff, MWA_RAM },
{ -1 }
};
static struct IOReadPort sound_readport[] =
{
{ 0x00, 0x00, YM2203_status_port_0_r },
{ -1 }
};
static struct IOWritePort sound_writeport[] =
{
{ 0x00, 0x00, YM2203_control_port_0_w },
{ 0x01, 0x01, YM2203_write_port_0_w },
{ -1 }
};
/* IN0 - COINS */
#define SERVICE \
PORT_START\
PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_START1 )\
PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_START2 )\
PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN )\
PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNKNOWN )\
PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNKNOWN )\
PORT_BITX( 0x20, IP_ACTIVE_LOW, IPT_SERVICE, "Test", OSD_KEY_F2, IP_JOY_NONE )\
PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_COIN1 )\
PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_COIN2 )
/* IN1/3 - PLAYER 1/2 */
#define JOY(_flag_) \
PORT_START\
PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_8WAY | _flag_ )\
PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT | IPF_8WAY | _flag_ )\
PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN | IPF_8WAY | _flag_ )\
PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_UP | IPF_8WAY | _flag_ )\
PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 | _flag_ )\
PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 | _flag_ )\
PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON3 | _flag_ )\
PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_BUTTON4 | _flag_ )
/* IN2 - Reserve */
#define RESERVE \
PORT_START\
PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN ) /* Reserve 1P */\
PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN )\
PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN )\
PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNKNOWN )\
PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNKNOWN ) /* Reserve 2P */\
PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNKNOWN )\
PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )\
PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
/* IN4 - DSW1 MS1-A */
#define COINAGE_A \
PORT_START\
PORT_DIPNAME( 0x07, 0x07, DEF_STR( Coin_A ) )\
PORT_DIPSETTING( 0x01, "4 Coins / 1 Credit" )\
PORT_DIPSETTING( 0x02, "3 Coins / 1 Credit" )\
PORT_DIPSETTING( 0x03, "2 Coins / 1 Credit" )\
PORT_DIPSETTING( 0x07, "1 Coin / 1 Credit" )\
PORT_DIPSETTING( 0x06, "1 Coin / 2 Credits" )\
PORT_DIPSETTING( 0x05, "1 Coin / 3 Credits" )\
PORT_DIPSETTING( 0x04, "1 Coin / 4 Credits" )\
PORT_DIPSETTING( 0x00, DEF_STR( Free_Play ) )\
PORT_DIPNAME( 0x38, 0x38, DEF_STR( Coin_B ) )\
PORT_DIPSETTING( 0x08, "4 Coins / 1 Credit" )\
PORT_DIPSETTING( 0x10, "3 Coins / 1 Credit" )\
PORT_DIPSETTING( 0x18, "2 Coins / 1 Credit" )\
PORT_DIPSETTING( 0x38, "1 Coin / 1 Credit" )\
PORT_DIPSETTING( 0x30, "1 Coin / 2 Credits" )\
PORT_DIPSETTING( 0x28, "1 Coin / 3 Credits" )\
PORT_DIPSETTING( 0x20, "1 Coin / 4 Credits" )\
PORT_DIPSETTING( 0x00, DEF_STR( Free_Play ) )\
PORT_DIPNAME( 0x40, 0x40, DEF_STR( Demo_Sounds ) )\
PORT_DIPSETTING( 0x00, DEF_STR( Off ) )\
PORT_DIPSETTING( 0x40, DEF_STR( On ) )\
PORT_BITX( 0x80, 0x80, IPT_DIPSWITCH_NAME | IPF_CHEAT, "Invulnerability", IP_KEY_NONE, IP_JOY_NONE ) \
PORT_DIPSETTING( 0x80, DEF_STR( Off ) )\
PORT_DIPSETTING( 0x00, DEF_STR( On ) )\
#define COINAGE_A_2 \
PORT_START \
PORT_DIPNAME( 0x07, 0x07, DEF_STR( Coin_A ) )\
PORT_DIPSETTING( 0x04, "3 Coins / 1 Credit" )\
PORT_DIPSETTING( 0x02, "2 Coins / 1 Credit" )\
PORT_DIPSETTING( 0x07, "1 Coin / 1 Credit" )\
PORT_DIPSETTING( 0x03, "1 Coin / 2 Credits" )\
PORT_DIPSETTING( 0x05, "1 Coin / 3 Credits" )\
PORT_DIPSETTING( 0x01, "1 Coin / 4 Credits" )\
PORT_DIPSETTING( 0x06, "1 Coin / 5 Credits" )\
PORT_DIPSETTING( 0x00, DEF_STR( Free_Play ) )\
PORT_DIPNAME( 0x38, 0x38, DEF_STR( Coin_B ) )\
PORT_DIPSETTING( 0x00, "4 Coins / 1 Credit" )\
PORT_DIPSETTING( 0x20, "3 Coins / 1 Credit" )\
PORT_DIPSETTING( 0x10, "2 Coins / 1 Credit" )\
PORT_DIPSETTING( 0x38, "1 Coin / 1 Credit" )\
PORT_DIPSETTING( 0x18, "1 Coin / 2 Credits" )\
PORT_DIPSETTING( 0x28, "1 Coin / 3 Credits" )\
PORT_DIPSETTING( 0x08, "1 Coin / 4 Credits" )\
PORT_DIPSETTING( 0x30, "1 Coin / 5 Credits" )\
PORT_DIPNAME( 0x40, 0x40, DEF_STR( Demo_Sounds ) )\
PORT_DIPSETTING( 0x40, DEF_STR( Off ) )\
PORT_DIPSETTING( 0x00, DEF_STR( On ) )\
PORT_DIPNAME( 0x80, 0x80, DEF_STR( Service_Mode ) )\
PORT_DIPSETTING( 0x80, DEF_STR( Off ) )\
PORT_DIPSETTING( 0x00, DEF_STR( On ) )\
/* IN4 - DSW1 MS1-C */
#define COINAGE_C \
PORT_START\
PORT_DIPNAME( 0x0f, 0x0f, DEF_STR( Coin_A ) )\
PORT_DIPSETTING( 0x07, "4 Coins / 1 Credit" )\
PORT_DIPSETTING( 0x08, "3 Coins / 1 Credit" )\
PORT_DIPSETTING( 0x09, "2 Coins / 1 Credit" )\
PORT_DIPSETTING( 0x0f, "1 Coin / 1 Credit" )\
PORT_DIPSETTING( 0x05, "1 Coin / 1 Credit" )\
PORT_DIPSETTING( 0x04, "1 Coin / 1 Credit" )\
PORT_DIPSETTING( 0x03, "1 Coin / 1 Credit" )\
PORT_DIPSETTING( 0x02, "1 Coin / 1 Credit" )\
PORT_DIPSETTING( 0x01, "1 Coin / 1 Credit" )\
PORT_DIPSETTING( 0x06, "2 Coins / 3 Credits" )\
PORT_DIPSETTING( 0x0e, "1 Coin / 2 Credits" )\
PORT_DIPSETTING( 0x0d, "1 Coin / 3 Credits" )\
PORT_DIPSETTING( 0x0c, "1 Coin / 4 Credits" )\
PORT_DIPSETTING( 0x0b, "1 Coin / 5 Credits" )\
PORT_DIPSETTING( 0x0a, "1 Coin / 6 Credits" )\
PORT_DIPSETTING( 0x00, DEF_STR( Free_Play ) )\
PORT_DIPNAME( 0xf0, 0xf0, DEF_STR( Coin_B ) )\
PORT_DIPSETTING( 0x70, "4 Coins / 1 Credit" )\
PORT_DIPSETTING( 0x80, "3 Coins / 1 Credit" )\
PORT_DIPSETTING( 0x90, "2 Coins / 1 Credit" )\
PORT_DIPSETTING( 0xf0, "1 Coin / 1 Credit" )\
PORT_DIPSETTING( 0x50, "1 Coin / 1 Credit" )\
PORT_DIPSETTING( 0x40, "1 Coin / 1 Credit" )\
PORT_DIPSETTING( 0x30, "1 Coin / 1 Credit" )\
PORT_DIPSETTING( 0x20, "1 Coin / 1 Credit" )\
PORT_DIPSETTING( 0x10, "1 Coin / 1 Credit" )\
PORT_DIPSETTING( 0x60, "2 Coins / 3 Credits" )\
PORT_DIPSETTING( 0xe0, "1 Coin / 2 Credits" )\
PORT_DIPSETTING( 0xd0, "1 Coin / 3 Credits" )\
PORT_DIPSETTING( 0xc0, "1 Coin / 4 Credits" )\
PORT_DIPSETTING( 0xb0, "1 Coin / 5 Credits" )\
PORT_DIPSETTING( 0xa0, "1 Coin / 6 Credits" )\
PORT_DIPSETTING( 0x00, DEF_STR( Free_Play ) )\
/* IN5 - DSW2 */
#define UNKNOWN \
PORT_START\
PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN )\
PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN )\
PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN )\
PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNKNOWN )\
PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNKNOWN )\
PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNKNOWN )\
PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )\
PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
/*
**
** Gfx data
**
*/
#define layout8x8(_name_,_romsize_)\
static struct GfxLayout _name_ =\
{\
8,8,\
(_romsize_)*8/(8*8*4),\
4,\
{0, 1, 2, 3},\
{0*4,1*4,2*4,3*4,4*4,5*4,6*4,7*4},\
{0*32,1*32,2*32,3*32,4*32,5*32,6*32,7*32},\
8*8*4\
};\
#define layout16x16(_name_,_romsize_)\
static struct GfxLayout _name_ =\
{\
16,16,\
(_romsize_)*8/(16*16*4),\
4,\
{0, 1, 2, 3},\
{0*4,1*4,2*4,3*4,4*4,5*4,6*4,7*4,\
0*4+32*16,1*4+32*16,2*4+32*16,3*4+32*16,4*4+32*16,5*4+32*16,6*4+32*16,7*4+32*16},\
{0*32,1*32,2*32,3*32,4*32,5*32,6*32,7*32,\
8*32,9*32,10*32,11*32,12*32,13*32,14*32,15*32},\
16*16*4\
};\
layout8x8( tilelayout1, 0x10000*1)
layout8x8( charlayout, 0x20000*1) /* P-47 has half that chars */
layout8x8( tilelayout, 0x20000*4)
layout16x16(spritelayout_Z,0x20000*1)
layout16x16(spritelayout_A,0x20000*4)
layout16x16(spritelayout_C,0x20000*8)
static struct GfxDecodeInfo gfxdecodeinfo_Z[] =
{
{ 1, 0x000000, &tilelayout, 256*0, 16 },
{ 1, 0x020000, &tilelayout1, 256*2, 16 },
{ 1, 0x030000, &spritelayout_Z, 256*1, 16 },
{ -1 }
};
static struct GfxDecodeInfo gfxdecodeinfo_A[] =
{
{ 1, 0x000000, &tilelayout, 256*0, 16 },
{ 1, 0x080000, &tilelayout, 256*1, 16 },
{ 1, 0x100000, &charlayout, 256*2, 16 },
{ 1, 0x120000, &spritelayout_A, 256*3, 16 },
{ -1 }
};
#define gfxdecodeinfo_B gfxdecodeinfo_A
static struct GfxDecodeInfo gfxdecodeinfo_C[] =
{
{ 1, 0x000000, &tilelayout, 256*0, 16 },
{ 1, 0x080000, &tilelayout, 256*1, 16 },
{ 1, 0x100000, &charlayout, 256*2, 16 },
{ 1, 0x120000, &spritelayout_C, 256*3, 16 },
{ -1 }
};
static struct YM2151interface ym2151_interface =
{
1,
3000000, /* ?? */
{ YM3012_VOL(50,OSD_PAN_LEFT,50,OSD_PAN_RIGHT) },
{ 0 }
};
static struct OKIM6295interface okim6295_interface =
{
2,
22000, /* ?? */
{3,4},
{ 50, 50 }
};
#define MEGASYS1_MACHINE(_type_) \
static struct MachineDriver machine_driver_##_type_ = \
{\
{\
{\
CPU_M68000,\
7000000, /* ?? */ \
0,\
readmem_##_type_,writemem_##_type_,0,0,\
interrupt_##_type_,interrupt_num_##_type_ \
},\
{\
CPU_M68000 | CPU_AUDIO_CPU,\
7000000, /* ?? */ \
2,\
sound_readmem_##_type_,sound_writemem_##_type_,0,0,\
sound_interrupt_##_type_,1\
},\
},\
60,DEFAULT_60HZ_VBLANK_DURATION,\
10,\
megasys1_init_machine,\
/* video hardware */ \
256, 256,{ 0, 256-1, 0+16, 256-16-1 },\
gfxdecodeinfo_##_type_,\
1024, 1024,\
0,\
VIDEO_TYPE_RASTER | VIDEO_MODIFIES_PALETTE,\
0,\
vh_start,\
vh_stop,\
vh_screenrefresh,\
/* sound hardware */ \
0,0,0,0,\
{\
{\
SOUND_YM2151,\
&ym2151_interface\
},\
{\
SOUND_OKIM6295,\
&okim6295_interface\
}\
}\
};
MEGASYS1_MACHINE(A)
MEGASYS1_MACHINE(B)
MEGASYS1_MACHINE(C)
void irq_handler(int irq)
{
cpu_set_irq_line(1,0,irq ? ASSERT_LINE : CLEAR_LINE);
}
static struct YM2203interface ym2203_interface =
{
1,
1200000, /* ?? */
{ YM2203_VOL(0xff,0xff) }, /* gain,volume */
{ 0 },
{ 0 },
{ 0 },
{ 0 },
{ irq_handler }
};
static struct MachineDriver machine_driver_Z = \
{\
{\
{\
CPU_M68000,\
6000000, /* ?? */ \
0,\
readmem_A,writemem_A,0,0,\
interrupt_A,interrupt_num_A \
},\
{\
CPU_Z80 | CPU_AUDIO_CPU,\
3000000, /* ?? */ \
2,\
sound_readmem_z80,sound_writemem_z80,sound_readport,sound_writeport,\
ignore_interrupt,1 /* irq generated by YM2203 */ \
},\
},\
60,DEFAULT_60HZ_VBLANK_DURATION,\
10,\
0,\
/* video hardware */ \
256, 256,{ 0, 256-1, 0+16, 256-16-1 },\
gfxdecodeinfo_Z,\
256*3, 256*3,\
0,\
VIDEO_TYPE_RASTER | VIDEO_MODIFIES_PALETTE,\
0,\
vh_start,\
vh_stop,\
vh_screenrefresh,\
/* sound hardware */ \
0,0,0,0,\
{\
{\
SOUND_YM2203,\
&ym2203_interface\
},\
}\
};
void driver_init_Z(void) {hardware_type = 'Z' ; spriteram = &ram[0x8000];}
void driver_init_A(void) {hardware_type = 'A' ; spriteram = &ram[0x8000];}
void driver_init_B(void)
{
unsigned char *RAM;
int i,j;
hardware_type = 'B' ;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -