📄 zerowing.c
字号:
/***************************************************************************
Zero Wing (ToaPlan)
***************************************************************************/
#include "driver.h"
#include "vidhrdw/generic.h"
#include "M68000/m68000.h"
#include "Z80/z80.h"
/* change this to malloc */
int vblank_r(int offset);
int framedone_r(int offset);
void framedone_w(int offset, int data);
void video_ofs_w(int offset, int data);
void video_ofs3_w(int offset, int data);
int video_ofs_r(int offset);
int video_ofs3_r(int offset);
int scrollregs_r(int offset);
void scrollregs_w(int offset, int data);
void zerowing_videoram1_w(int offset, int data);
void zerowing_videoram2_w(int offset, int data);
void zerowing_videoram3_w(int offset, int data);
int zerowing_videoram1_r(int offset);
int zerowing_videoram2_r(int offset);
int zerowing_videoram3_r(int offset);
void zerowing_colorram1_w(int offset, int data);
int zerowing_colorram1_r(int offset);
void zerowing_colorram2_w(int offset, int data);
int zerowing_colorram2_r(int offset);
void zerowing_vh_screenrefresh(struct osd_bitmap *bitmap,int full_refresh);
void vimana_vh_screenrefresh(struct osd_bitmap *bitmap,int full_refresh);
void zerowing_vh_stop(void);
int zerowing_vh_start(void);
static unsigned char *ram;
int unk;
int int_enable;
int credits;
int latch;
extern int vblank ;
extern int framedone ;
extern int video_ofs ;
extern int video_ofs3 ;
unsigned char *shared_ram;
extern unsigned char *zerowing_colorram1;
extern unsigned char *zerowing_colorram2;
extern int colorram1_size;
extern int colorram2_size;
static int zerowing_interrupt(void)
{
if ( int_enable )
return MC68000_IRQ_4;
return MC68000_INT_NONE;
}
static int unk_r(int offset)
{
return unk ^= 1;
}
static int vm_input_port_4_r(int offset)
{
int data, p ;
p = input_port_4_r(0) ;
latch ^= p ;
data = (latch & p ) ;
/* simulate the mcu keeping track of credits */
/* latch is so is doesn't add more than one */
/* credit per keypress */
if ( data & 0x18 )
{
credits++ ;
}
latch = p ;
return p ;
}
static int vm_mcu_r(int offset)
{
int data = 0 ;
switch ( offset >> 1 )
{
case 0:
data = 0xff ;
break ;
case 1:
data = 0 ;
break ;
case 2:
data = credits ;
break ;
}
return data ;
}
static void vm_mcu_w(int offset, int data)
{
switch ( offset >> 1 )
{
case 0:
break ;
case 1:
break ;
case 2:
credits = data ;
break ;
}
}
static int shared_r(int offset)
{
return shared_ram[offset>>1] ;
}
static void shared_w(int offset, int data)
{
shared_ram[offset>>1] = data ;
}
static void int_enable_w(int offset, int data )
{
int_enable = data ;
}
static void toaplan_init_machine (void)
{
unk = 0;
int_enable = 0;
credits = 0;
latch = 0;
}
/* Sound Routines */
static void zw_opl_w(int offset, int data)
{
if ( (offset & 0xfe) == 0xa8 )
{
if ( offset == 0xa8 )
{
YM3812_control_port_0_w( 0, data ) ;
}
else
{
YM3812_write_port_0_w(0, data);
}
}
}
static void hf_opl_w(int offset, int data)
{
if ( (offset & 0xfe) == 0x70 )
{
if ( offset == 0x70 )
{
YM3812_control_port_0_w( 0, data ) ;
}
else
{
YM3812_write_port_0_w(0, data);
}
}
}
static struct MemoryReadAddress vm_readmem[] =
{
{ 0x000000, 0x03ffff, MRA_ROM },
{ 0x0c0000, 0x0c0001, vblank_r },
{ 0x0c0002, 0x0c0003, video_ofs_r },
{ 0x0c0004, 0x0c0005, zerowing_videoram1_r }, /* sprites info */
{ 0x0c0006, 0x0c0007, zerowing_videoram2_r }, /* sprite size ? */
{ 0x400000, 0x400001, vblank_r },
{ 0x404000, 0x4047ff, zerowing_colorram1_r },
{ 0x406000, 0x4067ff, zerowing_colorram2_r },
{ 0x440000, 0x440005, vm_mcu_r },
{ 0x440006, 0x440007, input_port_2_r },
{ 0x440008, 0x440009, vm_input_port_4_r },
{ 0x44000a, 0x44000b, input_port_0_r },
{ 0x44000c, 0x44000d, input_port_1_r },
{ 0x44000e, 0x44000f, input_port_3_r },
{ 0x440010, 0x440011, input_port_5_r },
{ 0x480000, 0x480147, MRA_BANK1 },
{ 0x480148, 0x487fff, MRA_BANK2 },
{ 0x4c0000, 0x4c0001, unk_r },
{ 0x4c0002, 0x4c0003, video_ofs3_r },
{ 0x4c0004, 0x4c0007, zerowing_videoram3_r }, /* tile layers */
{ 0x4c0010, 0x4c001f, scrollregs_r },
{ -1 } /* end of table */
};
static struct MemoryWriteAddress vm_writemem[] =
{
{ 0x000000, 0x03ffff, MWA_ROM },
{ 0x0c0002, 0x0c0003, video_ofs_w },
{ 0x0c0004, 0x0c0005, zerowing_videoram1_w }, /* sprites info */
{ 0x0c0006, 0x0c0007, zerowing_videoram2_w }, /* sprite size ? */
{ 0x400000, 0x400001, int_enable_w },
{ 0x400002, 0x400003, MWA_NOP }, /* IRQACK? */
{ 0x404000, 0x4047ff, zerowing_colorram1_w, &zerowing_colorram1, &colorram1_size },
{ 0x406000, 0x4067ff, zerowing_colorram2_w, &zerowing_colorram2, &colorram2_size },
{ 0x440000, 0x440005, vm_mcu_w },
{ 0x480000, 0x480147, MWA_BANK1 },
{ 0x480148, 0x487fff, MWA_BANK2 },
{ 0x4c0002, 0x4c0003, video_ofs3_w },
{ 0x4c0004, 0x4c0007, zerowing_videoram3_w }, /* tile layers */
{ 0x4c0010, 0x4c001f, scrollregs_w },
{ -1 } /* end of table */
};
static struct MemoryReadAddress zw_readmem[] =
{
{ 0x000000, 0x07ffff, MRA_ROM },
{ 0x080000, 0x08176d, MRA_BANK1 },
{ 0x08176e, 0x08176f, framedone_r },
{ 0x081770, 0x087fff, MRA_BANK2 },
{ 0x400000, 0x400005, unk_r },
{ 0x404000, 0x4047ff, zerowing_colorram1_r },
{ 0x406000, 0x4067ff, zerowing_colorram2_r },
{ 0x440000, 0x440fff, shared_r },
{ 0x480002, 0x480003, video_ofs3_r },
{ 0x480004, 0x480007, zerowing_videoram3_r }, /* tile layers */
{ 0x480010, 0x48001f, scrollregs_r },
{ 0x4c0000, 0x4c0001, vblank_r },
{ 0x4c0002, 0x4c0003, video_ofs_r },
{ 0x4c0004, 0x4c0005, zerowing_videoram1_r }, /* sprites info */
{ 0x4c0006, 0x4c0007, zerowing_videoram2_r }, /* sprite size ? */
{ -1 } /* end of table */
};
static struct MemoryWriteAddress zw_writemem[] =
{
{ 0x000000, 0x07ffff, MWA_ROM },
{ 0x080000, 0x08176d, MWA_BANK1 },
{ 0x08176e, 0x08176f, framedone_w },
{ 0x081770, 0x087fff, MWA_BANK2 },
{ 0x400002, 0x400003, int_enable_w },
{ 0x404000, 0x4047ff, zerowing_colorram1_w, &zerowing_colorram1, &colorram1_size },
{ 0x406000, 0x4067ff, zerowing_colorram2_w, &zerowing_colorram2, &colorram2_size },
{ 0x440000, 0x440fff, shared_w, &shared_ram },
{ 0x480002, 0x480003, video_ofs3_w },
{ 0x480004, 0x480007, zerowing_videoram3_w }, /* tile layers */
{ 0x480010, 0x48001f, scrollregs_w },
{ 0x4c0002, 0x4c0003, video_ofs_w },
{ 0x4c0004, 0x4c0005, zerowing_videoram1_w }, /* sprites info */
{ 0x4c0006, 0x4c0007, zerowing_videoram2_w }, /* sprite size ? */
{ -1 } /* end of table */
};
static struct MemoryReadAddress hf_readmem[] =
{
{ 0x000000, 0x03ffff, MRA_ROM },
{ 0x040000, 0x0422f1, MRA_BANK1 },
{ 0x0422f2, 0x0422f3, framedone_r },
{ 0x0422f4, 0x047fff, MRA_BANK2 },
{ 0x084000, 0x0847ff, zerowing_colorram1_r },
{ 0x086000, 0x0867ff, zerowing_colorram2_r },
{ 0x0c0000, 0x0c0fff, shared_r },
{ 0x100002, 0x100003, video_ofs3_r },
{ 0x100004, 0x100007, zerowing_videoram3_r }, /* tile layers */
{ 0x100010, 0x10001f, scrollregs_r },
{ 0x140000, 0x140001, vblank_r },
{ 0x140002, 0x140003, video_ofs_r },
{ 0x140004, 0x140005, zerowing_videoram1_r }, /* sprites info */
{ 0x140006, 0x140007, zerowing_videoram2_r }, /* sprite size ? */
{ -1 } /* end of table */
};
static struct MemoryWriteAddress hf_writemem[] =
{
{ 0x000000, 0x03ffff, MWA_ROM },
{ 0x040000, 0x0422f1, MWA_BANK1 },
{ 0x0422f2, 0x0422f3, framedone_w },
{ 0x0422f4, 0x047fff, MWA_BANK2 },
{ 0x080002, 0x080003, int_enable_w },
{ 0x084000, 0x0847ff, zerowing_colorram1_w, &zerowing_colorram1, &colorram1_size },
{ 0x086000, 0x0867ff, zerowing_colorram2_w, &zerowing_colorram2, &colorram2_size },
{ 0x0c0000, 0x0c0fff, shared_w, &shared_ram },
{ 0x100002, 0x100003, video_ofs3_w },
{ 0x100004, 0x100007, zerowing_videoram3_w }, /* tile layers */
{ 0x100010, 0x10001f, scrollregs_w },
{ 0x140002, 0x140003, video_ofs_w },
{ 0x140004, 0x140005, zerowing_videoram1_w }, /* sprites info */
{ 0x140006, 0x140007, zerowing_videoram2_w }, /* sprite size ? */
{ -1 } /* end of table */
};
static struct MemoryReadAddress sound_readmem[] =
{
{ 0x0000, 0x7fff, MRA_ROM },
{ 0x8000, 0xffff, MRA_RAM },
{ -1 } /* end of table */
};
static struct MemoryWriteAddress sound_writemem[] =
{
{ 0x0000, 0x7fff, MWA_ROM },
{ 0x8000, 0xffff, MWA_RAM, &shared_ram },
{ -1 } /* end of table */
};
static struct IOReadPort zw_sound_readport[] =
{
{ 0x00, 0x00, input_port_0_r }, /* player 1 */
{ 0x08, 0x08, input_port_1_r }, /* player 2 */
{ 0x20, 0x20, input_port_2_r }, /* DSW1 */
{ 0x28, 0x28, input_port_3_r }, /* DSW2 */
{ 0x80, 0x80, input_port_4_r }, /* DSWX */
{ 0x88, 0x88, input_port_5_r }, /* DSW3 */
{ 0xa8, 0xa8, YM3812_status_port_0_r },
{ -1 } /* end of table */
};
static struct IOWritePort zw_sound_writeport[] =
{
{ 0x00, 0xff, zw_opl_w },
{ -1 } /* end of table */
};
static struct IOReadPort hf_sound_readport[] =
{
{ 0x00, 0x00, input_port_2_r }, /* DSW1 */
{ 0x10, 0x10, input_port_3_r }, /* DSW2 */
{ 0x40, 0x40, input_port_0_r }, /* player 1 */
{ 0x50, 0x50, input_port_1_r }, /* player 2 */
{ 0x60, 0x60, input_port_4_r }, /* DSWX */
{ 0x20, 0x20, input_port_5_r }, /* DSW3 */
{ 0x70, 0x70, YM3812_status_port_0_r },
{ -1 } /* end of table */
};
static struct IOWritePort hf_sound_writeport[] =
{
{ 0x00, 0xff, hf_opl_w },
{ -1 } /* end of table */
};
INPUT_PORTS_START( zerowing_input_ports )
PORT_START /* PLAYER 1 */
PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP | IPF_PLAYER1 | IPF_8WAY )
PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN | IPF_PLAYER1 | IPF_8WAY )
PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT | IPF_PLAYER1 | IPF_8WAY )
PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT | IPF_PLAYER1 | IPF_8WAY )
PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_BUTTON1 | IPF_PLAYER1 )
PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_BUTTON2 | IPF_PLAYER1 )
PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_UNKNOWN )
PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_UNKNOWN )
PORT_START /* PLAYER 2 */
PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP | IPF_PLAYER2 | IPF_8WAY )
PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN | IPF_PLAYER2 | IPF_8WAY )
PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT | IPF_PLAYER2 | IPF_8WAY )
PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT | IPF_PLAYER2 | IPF_8WAY )
PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_BUTTON1 | IPF_PLAYER2 )
PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_BUTTON2 | IPF_PLAYER2 )
PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_UNKNOWN )
PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_UNKNOWN )
PORT_START /* DSWA */
PORT_DIPNAME( 0x01, 0x01, "Cabinet", IP_KEY_NONE )
PORT_DIPSETTING( 0x01, "Upright" )
PORT_DIPSETTING( 0x00, "Cocktail" )
PORT_DIPNAME( 0x02, 0x00, "Flip Screen", IP_KEY_NONE )
PORT_DIPSETTING( 0x00, "Off" )
PORT_DIPSETTING( 0x02, "On" )
PORT_BITX( 0x04, 0x00, IPT_DIPSWITCH_NAME | IPF_TOGGLE, "Service Mode", OSD_KEY_F2, IP_JOY_NONE, 0 )
PORT_DIPSETTING( 0x00, "Off" )
PORT_DIPSETTING( 0x04, "On" )
PORT_DIPNAME( 0x08, 0x00, "Demo Sounds", IP_KEY_NONE )
PORT_DIPSETTING( 0x08, "Off" )
PORT_DIPSETTING( 0x00, "On" )
PORT_DIPNAME( 0x30, 0x00, "Coin A", IP_KEY_NONE )
PORT_DIPSETTING( 0x20, "2 Coins/1 Credit" )
PORT_DIPSETTING( 0x00, "1 Coin/1 Credit" )
PORT_DIPSETTING( 0x30, "2 Coins/3 Credit" )
PORT_DIPSETTING( 0x10, "1 Coins/2 Credit" )
PORT_DIPNAME( 0xc0, 0x00, "Coin B", IP_KEY_NONE )
PORT_DIPSETTING( 0x80, "2 Coins/1 Credit" )
PORT_DIPSETTING( 0x00, "1 Coins/1 Credit" )
PORT_DIPSETTING( 0xc0, "2 Coins/3 Credit" )
PORT_DIPSETTING( 0x40, "1 Coins/2 Credit" )
PORT_START /* DSWB */
PORT_DIPNAME( 0x03, 0x00, "Difficulty", IP_KEY_NONE )
PORT_DIPSETTING( 0x01, "Easy" )
PORT_DIPSETTING( 0x00, "Medium" )
PORT_DIPSETTING( 0x02, "Hard" )
PORT_DIPSETTING( 0x03, "Hardest" )
PORT_DIPNAME( 0x0c, 0x00, "Bonus Life", IP_KEY_NONE )
PORT_DIPSETTING( 0x00, "200K and 500K" )
PORT_DIPSETTING( 0x04, "500K and 1M" )
PORT_DIPSETTING( 0x08, "500K" )
PORT_DIPSETTING( 0x0c, "None" )
PORT_DIPNAME( 0x30, 0x00, "Lives", IP_KEY_NONE )
PORT_DIPSETTING( 0x30, "2" )
PORT_DIPSETTING( 0x00, "3" )
PORT_DIPSETTING( 0x20, "4" )
PORT_DIPSETTING( 0x10, "5" )
PORT_BITX( 0x40, 0x00, IPT_DIPSWITCH_NAME | IPF_CHEAT, "Invulnerability", IP_KEY_NONE, IP_JOY_NONE, 0 )
PORT_DIPSETTING( 0x00, "Off" )
PORT_DIPSETTING( 0x40, "On" )
PORT_DIPNAME( 0x80, 0x00, "Allow Continue", IP_KEY_NONE )
PORT_DIPSETTING( 0x80, "No" )
PORT_DIPSETTING( 0x00, "Yes" )
PORT_START /* DSWX */
PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_COIN3 ) /* Service switch */
PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_TILT )
PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_UNKNOWN )
PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_COIN1 )
PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_COIN2 )
PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_START1 )
PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_START2 )
PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_UNKNOWN )
PORT_START /* DSW3 */
PORT_DIPNAME( 0x03, 0x03, "Territory", IP_KEY_NONE )
PORT_DIPSETTING( 0x00, "Japan" )
PORT_DIPSETTING( 0x01, "US" )
PORT_DIPSETTING( 0x03, "Europe" )
PORT_DIPNAME( 0x04, 0x00, "Unknown", IP_KEY_NONE )
PORT_DIPSETTING( 0x00, "Off" )
PORT_DIPSETTING( 0x04, "On" )
PORT_DIPNAME( 0x08, 0x00, "Unknown", IP_KEY_NONE )
PORT_DIPSETTING( 0x00, "Off" )
PORT_DIPSETTING( 0x08, "On" )
PORT_BIT( 0xf0, IP_ACTIVE_HIGH, IPT_UNKNOWN )
INPUT_PORTS_END
INPUT_PORTS_START( hellfire_input_ports )
PORT_START /* PLAYER 1 */
PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP | IPF_PLAYER1 | IPF_8WAY )
PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN | IPF_PLAYER1 | IPF_8WAY )
PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT | IPF_PLAYER1 | IPF_8WAY )
PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT | IPF_PLAYER1 | IPF_8WAY )
PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_BUTTON1 | IPF_PLAYER1 )
PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_BUTTON2 | IPF_PLAYER1 )
PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_UNKNOWN )
PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_UNKNOWN )
PORT_START /* PLAYER 2 */
PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP | IPF_PLAYER2 | IPF_8WAY )
PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN | IPF_PLAYER2 | IPF_8WAY )
PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT | IPF_PLAYER2 | IPF_8WAY )
PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT | IPF_PLAYER2 | IPF_8WAY )
PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_BUTTON1 | IPF_PLAYER2 )
PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_BUTTON2 | IPF_PLAYER2 )
PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_UNKNOWN )
PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_UNKNOWN )
PORT_START /* DSWA */
PORT_DIPNAME( 0x01, 0x00, "Unknown", IP_KEY_NONE )
PORT_DIPSETTING( 0x00, "Off" )
PORT_DIPSETTING( 0x01, "On" )
PORT_DIPNAME( 0x02, 0x00, "Flip Screen", IP_KEY_NONE )
PORT_DIPSETTING( 0x00, "Off" )
PORT_DIPSETTING( 0x02, "On" )
PORT_BITX( 0x04, 0x00, IPT_DIPSWITCH_NAME | IPF_TOGGLE, "Service Mode", OSD_KEY_F2, IP_JOY_NONE, 0 )
PORT_DIPSETTING( 0x00, "Off" )
PORT_DIPSETTING( 0x04, "On" )
PORT_DIPNAME( 0x08, 0x00, "Demo Sounds", IP_KEY_NONE )
PORT_DIPSETTING( 0x08, "Off" )
PORT_DIPSETTING( 0x00, "On" )
PORT_DIPNAME( 0x30, 0x00, "Coin A", IP_KEY_NONE )
PORT_DIPSETTING( 0x20, "2 Coins/1 Credit" )
PORT_DIPSETTING( 0x00, "1 Coin/1 Credit" )
PORT_DIPSETTING( 0x30, "2 Coins/3 Credit" )
PORT_DIPSETTING( 0x10, "1 Coins/2 Credit" )
PORT_DIPNAME( 0xc0, 0x00, "Coin B", IP_KEY_NONE )
PORT_DIPSETTING( 0x80, "2 Coins/1 Credit" )
PORT_DIPSETTING( 0x00, "1 Coins/1 Credit" )
PORT_DIPSETTING( 0xc0, "2 Coins/3 Credit" )
PORT_DIPSETTING( 0x40, "1 Coins/2 Credit" )
PORT_START /* DSWB */
PORT_DIPNAME( 0x03, 0x00, "Difficulty", IP_KEY_NONE )
PORT_DIPSETTING( 0x01, "Easy" )
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -