wc90b.c
来自「这个是延伸mame的在wince平台下的游戏模拟器的代码」· C语言 代码 · 共 503 行 · 第 1/2 页
C
503 行
/*
World Cup 90 bootleg driver
---------------------------
Ernesto Corvi
(ernesto@imagina.com)
CPU #1 : Handles background & foreground tiles, controllers, dipswitches.
CPU #2 : Handles sprites and palette
CPU #3 : Audio. The audio chip is a YM2203. I need help with this!.
Memory Layout:
CPU #1
0000-8000 ROM
8000-9000 RAM
a000-a800 Color Ram for background #1 tiles
a800-b000 Video Ram for background #1 tiles
c000-c800 Color Ram for background #2 tiles
c800-c000 Video Ram for background #2 tiles
e000-e800 Color Ram for foreground tiles
e800-f000 Video Ram for foreground tiles
f800-fc00 Common Ram with CPU #2
fd00-fd00 Stick 1, Coin 1 & Start 1 input port
fd02-fd02 Stick 2, Coin 2 & Start 2 input port
fd06-fc06 Dip Switch A
fd08-fc08 Dip Switch B
CPU #2
0000-c000 ROM
c000-d000 RAM
d000-d800 RAM Sprite Ram
e000-e800 RAM Palette Ram
f800-fc00 Common Ram with CPU #1
CPU #3
0000-0xc000 ROM
???????????
Notes:
-----
The bootleg video hardware is quite different from the original machine.
I could not figure out the encoding of the scrolling for the new
video hardware. The memory positions, in case anyone wants to try, are
the following ( CPU #1 memory addresses ):
fd06: scroll bg #1 X coordinate
fd04: scroll bg #1 Y coordinate
fd08: scroll bg #2 X coordinate
fd0a: scroll bg #2 Y coordinate
fd0e: ????
What i used instead, was the local copy kept in RAM. These values
are the ones the original machine uses. This will differ when trying
to use some of this code to write a driver for a similar tecmo bootleg.
Sprites are also very different. Theres a code snippet in the ROM
that converts the original sprites to the new format, wich only allows
16x16 sprites. That snippet also does some ( nasty ) clipping.
Colors are accurate. The graphics ROMs have been modified severely
and encoded in a different way from the original machine. Even if
sometimes it seems colors are not entirely correct, this is only due
to the crappy artwork of the person that did the bootleg.
Dip switches are not complete and they dont seem to differ from
the original machine.
Last but not least, the set of ROMs i have for Euro League seem to have
the sprites corrupted. The game seems to be exactly the same as the
World Cup 90 bootleg.
*/
#include "driver.h"
#include "vidhrdw/generic.h"
#include "z80/z80.h"
#define TEST_DIPS false /* enable to test unmapped dip switches */
extern unsigned char *wc90b_shared;
extern unsigned char *wc90b_tile_colorram, *wc90b_tile_videoram;
extern unsigned char *wc90b_tile_colorram2, *wc90b_tile_videoram2;
extern unsigned char *wc90b_scroll1xlo, *wc90b_scroll1xhi;
extern unsigned char *wc90b_scroll2xlo, *wc90b_scroll2xhi;
extern unsigned char *wc90b_scroll1ylo, *wc90b_scroll1yhi;
extern unsigned char *wc90b_scroll2ylo, *wc90b_scroll2yhi;
extern int wc90b_tile_videoram_size;
extern int wc90b_tile_videoram_size2;
int wc90b_vh_start( void );
void wc90b_vh_stop ( void );
int wc90b_tile_videoram_r ( int offset );
void wc90b_tile_videoram_w( int offset, int v );
int wc90b_tile_colorram_r ( int offset );
void wc90b_tile_colorram_w( int offset, int v );
int wc90b_tile_videoram2_r ( int offset );
void wc90b_tile_videoram2_w( int offset, int v );
int wc90b_tile_colorram2_r ( int offset );
void wc90b_tile_colorram2_w( int offset, int v );
int wc90b_shared_r ( int offset );
void wc90b_shared_w( int offset, int v );
void wc90b_vh_screenrefresh(struct osd_bitmap *bitmap,int full_refresh);
static void wc90b_bankswitch_w(int offset,int data)
{
int bankaddress;
unsigned char *RAM = Machine->memory_region[Machine->drv->cpu[0].memory_region];
bankaddress = 0x10000 + ((data & 0xf8) << 8);
cpu_setbank(1,&RAM[bankaddress]);
}
static void wc90b_bankswitch1_w(int offset,int data)
{
int bankaddress;
unsigned char *RAM = Machine->memory_region[Machine->drv->cpu[1].memory_region];
bankaddress = 0x10000 + ((data & 0xf8) << 8);
cpu_setbank(2,&RAM[bankaddress]);
}
static void wc90b_sound_command_w(int offset,int data)
{
soundlatch_w(offset,data);
cpu_cause_interrupt(2,/*Z80_NMI_INT*/-1000);
}
static struct MemoryReadAddress wc90b_readmem1[] =
{
{ 0x0000, 0x7fff, MRA_ROM },
{ 0x8000, 0x9fff, MRA_RAM }, /* Main RAM */
{ 0xa000, 0xa7ff, wc90b_tile_colorram_r }, /* bg 1 color ram */
{ 0xa800, 0xafff, wc90b_tile_videoram_r }, /* bg 1 tile ram */
{ 0xc000, 0xc7ff, wc90b_tile_colorram2_r }, /* bg 2 color ram */
{ 0xc800, 0xcfff, wc90b_tile_videoram2_r }, /* bg 2 tile ram */
{ 0xe000, 0xe7ff, colorram_r }, /* fg color ram */
{ 0xe800, 0xefff, videoram_r }, /* fg tile ram */
{ 0xf000, 0xf7ff, MRA_BANK1 },
{ 0xf800, 0xfbff, wc90b_shared_r },
{ 0xfd00, 0xfd00, input_port_0_r }, /* Stick 1, Coin 1 & Start 1 */
{ 0xfd02, 0xfd02, input_port_1_r }, /* Stick 2, Coin 2 & Start 2 */
{ 0xfd06, 0xfd06, input_port_2_r }, /* DIP Switch A */
{ 0xfd08, 0xfd08, input_port_3_r }, /* DIP Switch B */
{ 0xfd00, 0xffff, MRA_RAM },
{ -1 } /* end of table */
};
static struct MemoryReadAddress wc90b_readmem2[] =
{
{ 0x0000, 0xbfff, MRA_ROM },
{ 0xc000, 0xc1ff, MRA_RAM },
{ 0xc200, 0xe1ff, MRA_RAM },
{ 0xe000, 0xe7ff, MRA_RAM },
{ 0xf000, 0xf7ff, MRA_BANK2 },
{ 0xf800, 0xfbff, wc90b_shared_r },
{ -1 } /* end of table */
};
static struct MemoryWriteAddress wc90b_writemem1[] =
{
{ 0x0000, 0x7fff, MWA_ROM },
{ 0x8000, 0x8075, MWA_RAM },
{ 0x8076, 0x8076, MWA_RAM, &wc90b_scroll1xlo },
{ 0x8077, 0x8077, MWA_RAM, &wc90b_scroll1xhi },
{ 0x8078, 0x8078, MWA_RAM, &wc90b_scroll1ylo },
{ 0x8079, 0x8079, MWA_RAM, &wc90b_scroll1yhi },
{ 0x807a, 0x807a, MWA_RAM, &wc90b_scroll2xlo },
{ 0x807b, 0x807b, MWA_RAM, &wc90b_scroll2xhi },
{ 0x807c, 0x807c, MWA_RAM, &wc90b_scroll2ylo },
{ 0x807d, 0x807d, MWA_RAM, &wc90b_scroll2yhi },
{ 0x807e, 0x9fff, MWA_RAM },
{ 0xa000, 0xa7ff, wc90b_tile_colorram_w, &wc90b_tile_colorram },
{ 0xa800, 0xafff, wc90b_tile_videoram_w, &wc90b_tile_videoram, &wc90b_tile_videoram_size },
{ 0xc000, 0xc7ff, wc90b_tile_colorram2_w, &wc90b_tile_colorram2 },
{ 0xc800, 0xcfff, wc90b_tile_videoram2_w, &wc90b_tile_videoram2, &wc90b_tile_videoram_size2 },
{ 0xe000, 0xe7ff, colorram_w, &colorram },
{ 0xe800, 0xefff, videoram_w, &videoram, &videoram_size },
{ 0xf000, 0xf7ff, MWA_ROM },
{ 0xf800, 0xfbff, wc90b_shared_w, &wc90b_shared },
{ 0xfc00, 0xfc00, wc90b_bankswitch_w },
{ 0xfd00, 0xfd00, wc90b_sound_command_w },
/* */
{ -1 } /* end of table */
};
static struct MemoryWriteAddress wc90b_writemem2[] =
{
{ 0x0000, 0xbfff, MWA_ROM },
{ 0xc000, 0xcfff, MWA_RAM },
{ 0xd000, 0xd7ff, MWA_RAM, &spriteram, &spriteram_size },
{ 0xe000, 0xe7ff, paletteram_xxxxBBBBGGGGRRRR_swap_w, &paletteram },
{ 0xf000, 0xf7ff, MWA_ROM },
{ 0xf800, 0xfbff, wc90b_shared_w },
{ 0xfc00, 0xfc00, wc90b_bankswitch1_w },
{ -1 } /* end of table */
};
static struct MemoryReadAddress sound_readmem[] =
{
{ 0x0000, 0xbfff, MRA_ROM },
{ 0xf000, 0xf7ff, MRA_RAM },
{ 0xe800, 0xe800, YM2203_status_port_0_r },
{ 0xe801, 0xe801, YM2203_read_port_0_r },
{ 0xec00, 0xec00, YM2203_status_port_1_r },
{ 0xec01, 0xec01, YM2203_read_port_1_r },
{ 0xf800, 0xf800, soundlatch_r },
{ -1 } /* end of table */
};
static struct MemoryWriteAddress sound_writemem[] =
{
{ 0x0000, 0xbfff, MWA_ROM },
{ 0xf000, 0xf7ff, MWA_RAM },
{ 0xe800, 0xe800, YM2203_control_port_0_w },
{ 0xe801, 0xe801, YM2203_write_port_0_w },
{ 0xec00, 0xec00, YM2203_control_port_1_w },
{ 0xec01, 0xec01, YM2203_write_port_1_w },
{ -1 } /* end of table */
};
INPUT_PORTS_START( wc90b_input_ports )
PORT_START /* IN0 bit 0-5 */
PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_8WAY )
PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT | IPF_8WAY )
PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN | IPF_8WAY )
PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_UP | IPF_8WAY )
PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 )
PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 )
PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_START1 )
PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_COIN1 )
PORT_START /* IN1 bit 0-5 */
PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_8WAY | IPF_PLAYER2 )
PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT | IPF_8WAY | IPF_PLAYER2 )
PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN | IPF_8WAY | IPF_PLAYER2 )
PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_UP | IPF_8WAY | 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_START2 )
PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_COIN2 )
PORT_START /* DSWA */
PORT_DIPNAME( 0x0f, 0x0f, "Coinage", IP_KEY_NONE )
PORT_DIPSETTING( 0x00, "10 Coins/1 Credit" )
PORT_DIPSETTING( 0x08, "9 Coins/1 Credit" )
PORT_DIPSETTING( 0x04, "8 Coins/1 Credit" )
PORT_DIPSETTING( 0x0c, "7 Coins/1 Credit" )
PORT_DIPSETTING( 0x02, "6 Coins/1 Credit" )
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?