⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 kingobox.c

📁 这个是延伸mame的在wince平台下的游戏模拟器的代码
💻 C
📖 第 1 页 / 共 3 页
字号:
/***************************************************************************

King of Boxer - (c) 1985 Woodplace Inc.
Ring King - (c) 1985 Data East USA Inc.

Preliminary driver by:
Ernesto Corvi
ernesto@imagina.com

Notes:
-----
Main CPU:
- Theres a memory area from 0xf000 to 0xf7ff, wich is clearly
  initialized at startup and never used anymore.


Ring King specific:
- Colors for some boxers are wrong.


***************************************************************************/

#include "driver.h"
#include "vidhrdw/generic.h"
#include "Z80/Z80.h"

/* from vidhrdw */
extern unsigned char *kingobox_videoram1;
extern unsigned char *kingobox_colorram1;
extern int kingobox_videoram1_size;
extern unsigned char *kingobox_scroll_y;
void kingofb_f800_w(int offset,int data);
void kingobox_vh_convert_color_prom(unsigned char *palette,unsigned short *colortable,const unsigned char *color_prom);
void ringking_vh_convert_color_prom(unsigned char *palette,unsigned short *colortable,const unsigned char *color_prom);
void kingobox_vh_screenrefresh(struct osd_bitmap *bitmap,int full_refresh);
void ringking_vh_screenrefresh(struct osd_bitmap *bitmap,int full_refresh);

static unsigned char *video_shared;
static unsigned char *sprite_shared;
int kingofb_nmi_enable = 0;

static int video_shared_r( int offs ) {
	return video_shared[offs];
}

static void video_shared_w( int offs, int data ) {
	video_shared[offs] = data;
}

static int sprite_shared_r( int offs ) {
	return sprite_shared[offs];
}

static void sprite_shared_w( int offs, int data ) {
	sprite_shared[offs] = data;
}

static void video_interrupt_w( int offs, int data ) {
	cpu_cause_interrupt( 1, 0xff );
}

static void sprite_interrupt_w( int offs, int data ) {
	cpu_cause_interrupt( 2, 0xff );
}

static void scroll_interrupt_w( int offs, int data ) {
	sprite_interrupt_w( offs, data );
	*kingobox_scroll_y = data;
}

static void sound_command_w( int offs, int data ) {
	soundlatch_w( 0, data );
	cpu_cause_interrupt( 3, 0xff );
}

static struct MemoryReadAddress main_readmem[] =
{
    { 0x0000, 0x7fff, MRA_ROM },
    { 0xc000, 0xc3ff, MRA_RAM }, /* work ram */
    { 0xe000, 0xe7ff, sprite_shared_r },
    { 0xe800, 0xefff, video_shared_r },
    { 0xf000, 0xf7ff, MRA_RAM }, /* ???? */
    { 0xfc00, 0xfc00, input_port_0_r }, /* DSW 0 */
    { 0xfc01, 0xfc01, input_port_1_r }, /* DSW 1 */
    { 0xfc02, 0xfc02, input_port_2_r }, /* Player 1 controls */
    { 0xfc03, 0xfc03, input_port_3_r }, /* Player 2 controls */
    { 0xfc04, 0xfc04, input_port_4_r }, /* Coin & Start */
    { 0xfc05, 0xfc05, input_port_5_r }, /* Player 1 & 2 button 3 */
    { -1 }  /* end of table */
};

static struct MemoryWriteAddress main_writemem[] =
{
    { 0x0000, 0x7fff, MWA_ROM },
    { 0xc000, 0xc3ff, MWA_RAM }, /* work ram */
    { 0xe000, 0xe7ff, sprite_shared_w }, /* shared with sprite cpu */
    { 0xe800, 0xefff, video_shared_w }, /* shared with video cpu */
    { 0xf000, 0xf7ff, MWA_RAM }, /* ???? */
    { 0xf800, 0xf800, kingofb_f800_w },	/* NMI enable, palette bank */
    { 0xf801, 0xf801, MWA_NOP }, /* ???? */
    { 0xf802, 0xf802, MWA_RAM, &kingobox_scroll_y },
    { 0xf803, 0xf803, scroll_interrupt_w  },
    { 0xf804, 0xf804, video_interrupt_w },
    { 0xf807, 0xf807, sound_command_w }, /* sound latch */
    { -1 }  /* end of table */
};

static struct MemoryReadAddress video_readmem[] =
{
    { 0x0000, 0x3fff, MRA_ROM },
    { 0x8000, 0x87ff, MRA_RAM }, /* work ram */
    { 0xa000, 0xa7ff, video_shared_r }, /* shared with main */
    { 0xc000, 0xc0ff, videoram_r }, /* background vram */
    { 0xc400, 0xc4ff, colorram_r }, /* background colorram */
    { 0xc800, 0xcbff, MRA_RAM }, /* foreground vram */
    { 0xcc00, 0xcfff, MRA_RAM }, /* foreground colorram */
    { -1 }  /* end of table */
};

static struct MemoryWriteAddress video_writemem[] =
{
    { 0x0000, 0x3fff, MWA_ROM },
    { 0x8000, 0x87ff, MWA_RAM }, /* work ram */
    { 0xa000, 0xa7ff, video_shared_w, &video_shared }, /* shared with main */
    { 0xc000, 0xc0ff, videoram_w, &videoram, &videoram_size }, /* background vram */
    { 0xc400, 0xc4ff, colorram_w, &colorram }, /* background colorram */
    { 0xc800, 0xcbff, MWA_RAM, &kingobox_videoram1, &kingobox_videoram1_size }, /* foreground vram */
    { 0xcc00, 0xcfff, MWA_RAM, &kingobox_colorram1 }, /* foreground colorram */
    { -1 }  /* end of table */
};

static struct MemoryReadAddress sprite_readmem[] =
{
    { 0x0000, 0x1fff, MRA_ROM },
    { 0x8000, 0x87ff, MRA_RAM }, /* work ram */
    { 0xa000, 0xa7ff, sprite_shared_r }, /* shared with main */
    { 0xc000, 0xc3ff, spriteram_r }, /* sprite ram */
    { 0xc400, 0xc43f, MRA_RAM }, /* something related to scroll? */
    { -1 }  /* end of table */
};

static struct MemoryWriteAddress sprite_writemem[] =
{
    { 0x0000, 0x1fff, MWA_ROM },
    { 0x8000, 0x87ff, MWA_RAM }, /* work ram */
    { 0xa000, 0xa7ff, sprite_shared_w, &sprite_shared }, /* shared with main */
    { 0xc000, 0xc3ff, spriteram_w, &spriteram, &spriteram_size }, /* sprite ram */
    { 0xc400, 0xc43f, MWA_RAM },  /* something related to scroll? */
    { -1 }  /* end of table */
};

static struct MemoryReadAddress sound_readmem[] =
{
    { 0x0000, 0xbfff, MRA_ROM },
    { 0xc000, 0xc3ff, MRA_RAM }, /* work ram */
    { -1 }  /* end of table */
};

static struct MemoryWriteAddress sound_writemem[] =
{
    { 0x8000, 0x8000, MWA_NOP }, /* ??? */
    { 0x0000, 0xbfff, MWA_ROM },
    { 0xc000, 0xc3ff, MWA_RAM }, /* work ram */
    { -1 }  /* end of table */
};

static struct IOReadPort sound_readport[] =
{
	{ 0x08, 0x08, AY8910_read_port_0_r },
	{ -1 }  /* end of table */
};

static struct IOWritePort sound_writeport[] =
{
	{ 0x00, 0x00, DAC_data_w },
	{ 0x08, 0x08, AY8910_write_port_0_w },
	{ 0x0c, 0x0c, AY8910_control_port_0_w },
	{ -1 }  /* end of table */
};

/* Ring King */
static struct MemoryReadAddress rk_main_readmem[] =
{
    { 0x0000, 0xbfff, MRA_ROM },
    { 0xc000, 0xc3ff, MRA_RAM }, /* work ram */
    { 0xc800, 0xcfff, sprite_shared_r },
    { 0xd000, 0xd7ff, video_shared_r },
    { 0xe000, 0xe000, input_port_0_r }, /* DSW 0 */
    { 0xe001, 0xe001, input_port_1_r }, /* DSW 1 */
    { 0xe002, 0xe002, input_port_2_r }, /* Player 1 controls */
    { 0xe003, 0xe003, input_port_3_r }, /* Player 2 controls */
    { 0xe004, 0xe004, input_port_4_r }, /* Coin & Start */
    { 0xe005, 0xe005, input_port_5_r }, /* Player 1 & 2 button 3 */
    { 0xf000, 0xf7ff, MRA_RAM }, /* ???? */
    { -1 }  /* end of table */
};

static struct MemoryWriteAddress rk_main_writemem[] =
{
    { 0x0000, 0xbfff, MWA_ROM },
    { 0xc000, 0xc3ff, MWA_RAM }, /* work ram */
    { 0xc800, 0xcfff, sprite_shared_w },
    { 0xd000, 0xd7ff, video_shared_w },
    { 0xd800, 0xd800, kingofb_f800_w },
    { 0xd801, 0xd801, sprite_interrupt_w },
    { 0xd802, 0xd802, video_interrupt_w },
    { 0xd803, 0xd803, sound_command_w },
    { 0xe800, 0xe800, MWA_RAM, &kingobox_scroll_y },
    { 0xf000, 0xf7ff, MWA_RAM }, /* ???? */
    { -1 }  /* end of table */
};

static struct MemoryReadAddress rk_video_readmem[] =
{
    { 0x0000, 0x3fff, MRA_ROM },
    { 0x8000, 0x87ff, MRA_RAM }, /* work ram */
    { 0xc000, 0xc7ff, video_shared_r }, /* shared with main */
    { 0xa800, 0xa8ff, videoram_r }, /* background vram */
    { 0xac00, 0xacff, colorram_r }, /* background colorram */
    { 0xa000, 0xa3ff, MRA_RAM }, /* foreground vram */
    { 0xa400, 0xa7ff, MRA_RAM }, /* foreground colorram */
    { -1 }  /* end of table */
};

static struct MemoryWriteAddress rk_video_writemem[] =
{
    { 0x0000, 0x3fff, MWA_ROM },
    { 0x8000, 0x87ff, MWA_RAM }, /* work ram */
    { 0xc000, 0xc7ff, video_shared_w, &video_shared }, /* shared with main */
    { 0xa800, 0xa8ff, videoram_w, &videoram, &videoram_size }, /* background vram */
    { 0xac00, 0xacff, colorram_w, &colorram }, /* background colorram */
    { 0xa000, 0xa3ff, MWA_RAM, &kingobox_videoram1, &kingobox_videoram1_size }, /* foreground vram */
    { 0xa400, 0xa7ff, MWA_RAM, &kingobox_colorram1 }, /* foreground colorram */
    { -1 }  /* end of table */
};

static struct MemoryReadAddress rk_sprite_readmem[] =
{
    { 0x0000, 0x1fff, MRA_ROM },
    { 0x8000, 0x87ff, MRA_RAM }, /* work ram */
    { 0xc800, 0xcfff, sprite_shared_r }, /* shared with main */
    { 0xa000, 0xa3ff, spriteram_r }, /* sprite ram */
    { 0xa400, 0xa43f, MRA_RAM }, /* something related to scroll? */
    { -1 }  /* end of table */
};

static struct MemoryWriteAddress rk_sprite_writemem[] =
{
    { 0x0000, 0x1fff, MWA_ROM },
    { 0x8000, 0x87ff, MWA_RAM }, /* work ram */
    { 0xc800, 0xcfff, sprite_shared_w, &sprite_shared }, /* shared with main */
    { 0xa000, 0xa3ff, spriteram_w, &spriteram, &spriteram_size }, /* sprite ram */
    { 0xa400, 0xa43f, MWA_RAM },  /* something related to scroll? */
    { -1 }  /* end of table */
};

static struct IOReadPort rk_sound_readport[] =
{
	{ 0x02, 0x02, AY8910_read_port_0_r },
	{ -1 }  /* end of table */
};

static struct IOWritePort rk_sound_writeport[] =
{
	{ 0x00, 0x00, DAC_data_w },
	{ 0x02, 0x02, AY8910_write_port_0_w },
	{ 0x03, 0x03, AY8910_control_port_0_w },
	{ -1 }  /* end of table */
};

INPUT_PORTS_START( input_ports )
    PORT_START /* DSW0 - 0xfc01 */
    PORT_DIPNAME( 0x03, 0x01, "Rest Up Points", IP_KEY_NONE )
    PORT_DIPSETTING(    0x02, "70000" )
    PORT_DIPSETTING(    0x01, "100000" )
    PORT_DIPSETTING(    0x03, "150000" )
    PORT_DIPSETTING(    0x00, "No" )
    PORT_DIPNAME( 0x04, 0x00, "Demo Sounds", IP_KEY_NONE )
    PORT_DIPSETTING(    0x04, "Off" )
    PORT_DIPSETTING(    0x00, "On" )
    PORT_DIPNAME( 0x18, 0x00, "Difficulty", IP_KEY_NONE )
    PORT_DIPSETTING(    0x00, "Easy" )
    PORT_DIPSETTING(    0x08, "Medium" )
    PORT_DIPSETTING(    0x10, "Hard" )
    PORT_DIPSETTING(    0x18, "Hardest" )
	PORT_DIPNAME( 0x20, 0x20, "Cabinet", IP_KEY_NONE )
    PORT_DIPSETTING(    0x20, "Upright" )
    PORT_DIPSETTING(    0x00, "Cocktail" )
    PORT_DIPNAME( 0x40, 0x00, "Unknown", IP_KEY_NONE )
    PORT_DIPSETTING(    0x00, "Off" )
    PORT_DIPSETTING(    0x40, "On" )
	PORT_BITX(    0x80, 0x00, IPT_DIPSWITCH_NAME | IPF_TOGGLE, "Service Mode", OSD_KEY_F2, IP_JOY_NONE, 0 )
	PORT_DIPSETTING(    0x00, "Off" )
	PORT_DIPSETTING(    0x80, "On" )

    PORT_START /* DSW1 - 0xfc01 */
    PORT_DIPNAME( 0x07, 0x00, "Coinage", IP_KEY_NONE )
    PORT_DIPSETTING(    0x07, "4 Coins/1 Credit" )
    PORT_DIPSETTING(    0x06, "3 Coins/1 Credit" )
    PORT_DIPSETTING(    0x05, "2 Coins/1 Credit" )
    PORT_DIPSETTING(    0x00, "1 Coin/1 Credit" )
    PORT_DIPSETTING(    0x01, "1 Coin/2 Credits" )
    PORT_DIPSETTING(    0x02, "1 Coin/3 Credits" )
    PORT_DIPSETTING(    0x03, "1 Coin/4 Credits" )
    PORT_DIPSETTING(    0x04, "1 Coin/5 Credits" )
    PORT_DIPNAME( 0x08, 0x00, "Unknown", IP_KEY_NONE )
    PORT_DIPSETTING(    0x00, "Off" )
    PORT_DIPSETTING(    0x08, "On" )
    PORT_DIPNAME( 0x10, 0x00, "Unknown", IP_KEY_NONE )
    PORT_DIPSETTING(    0x00, "Off" )
    PORT_DIPSETTING(    0x10, "On" )
    PORT_DIPNAME( 0x20, 0x00, "Unknown", IP_KEY_NONE )
    PORT_DIPSETTING(    0x00, "Off" )
    PORT_DIPSETTING(    0x20, "On" )
    PORT_DIPNAME( 0x40, 0x00, "Unknown", IP_KEY_NONE )
    PORT_DIPSETTING(    0x00, "Off" )
    PORT_DIPSETTING(    0x40, "On" )
    PORT_DIPNAME( 0x80, 0x00, "Freeze", IP_KEY_NONE )
    PORT_DIPSETTING(    0x00, "Off" )
    PORT_DIPSETTING(    0x80, "On" )

    PORT_START /* IN 0 - 0xfc02 */
	PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP )
	PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN )
	PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT )
	PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT )
	PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_BUTTON1 )
	PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_BUTTON2 )
	PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_UNKNOWN )
	PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_UNKNOWN )

    PORT_START /* IN 1 - 0xfc03 */
	PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP | IPF_COCKTAIL )
	PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN | IPF_COCKTAIL )
	PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT | IPF_COCKTAIL )
	PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT | IPF_COCKTAIL )
	PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_BUTTON1 | IPF_COCKTAIL )
	PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_BUTTON2 | IPF_COCKTAIL )
	PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_UNKNOWN )
	PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_UNKNOWN )

	PORT_START /* IN 2 - 0xfc04 */
	PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_COIN1 )
	PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_UNKNOWN )
	PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_START1 )
	PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_START2 )
	PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_UNKNOWN )
	PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_UNKNOWN )
	PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_UNKNOWN )
	PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_UNKNOWN )

    PORT_START /* IN 3 - 0xfc05 */
	PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON3 )
	PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_BUTTON3 | IPF_COCKTAIL )
	PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_UNKNOWN )
	PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_UNKNOWN )
	PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_UNKNOWN )

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -