📄 mappy.c
字号:
/***************************************************************************
Mappy memory map (preliminary)
CPU #1:
0000-07ff video RAM
0800-0fff color RAM
1000-177f RAM
1780-17ff sprite data 1 (sprite number & color)
1800-1f7f RAM
1f80-1fff sprite data 2 (x, y position)
2000-277f RAM
2780-27ff sprite data 3 (high bit of y, flip flags, double-size flags)
3800-3fff scroll register map
4040-43ff RAM shared with CPU #2
4800-480f custom I/O chip #1
4810-481f custom I/O chip #2
5002-5003 IRQ enable
500a-500b CPU #2 enable
8000 watchdog timer
a000-ffff ROM
CPU #2:
0000-0040 sound registers
0040-03ff RAM shared with CPU #1
2000-2001 IRQ enable
2006-2007 sound enable
e000-ffff ROM
Interrupts:
CPU #1 IRQ generated by VBLANK
CPU #2 IRQ generated by VBLANK
***************************************************************************/
#include "driver.h"
#include "vidhrdw/generic.h"
/* machine driver data & functions */
extern unsigned char *mappy_sharedram;
extern unsigned char *mappy_customio_1,*mappy_customio_2;
void mappy_init_machine(void);
void motos_init_machine(void);
int mappy_sharedram_r(int offset);
void mappy_sharedram_w(int offset,int data);
void mappy_customio_w_1(int offset,int data);
void mappy_customio_w_2(int offset,int data);
int mappy_interrupt_1(void);
int mappy_interrupt_2(void);
void mappy_interrupt_enable_1_w(int offset,int data);
void mappy_interrupt_enable_2_w(int offset,int data);
void mappy_cpu_enable_w(int offset,int data);
int mappy_sharedram_r2(int offset);
int mappy_cpu1ram_r(int offset);
int mappy_customio_r_1(int offset);
int mappy_customio_r_2(int offset);
int digdug2_sharedram_r2(int offset);
int digdug2_cpu1ram_r(int offset);
int digdug2_customio_r_1(int offset);
int digdug2_customio_r_2(int offset);
int motos_sharedram_r2(int offset);
int motos_cpu1ram_r(int offset);
int motos_customio_r_1(int offset);
int motos_customio_r_2(int offset);
int todruaga_sharedram_r2(int offset);
int todruaga_cpu1ram_r(int offset);
int todruaga_customio_r_1(int offset);
int todruaga_customio_r_2(int offset);
/* video driver data & functions */
int mappy_vh_start(void);
int motos_vh_start(void);
void mappy_vh_stop(void);
void mappy_vh_screenrefresh(struct osd_bitmap *bitmap,int full_refresh);
void mappy_videoram_w(int offset,int data);
void mappy_colorram_w(int offset,int data);
void mappy_scroll_w(int offset,int data);
void mappy_vh_convert_color_prom(unsigned char *palette, unsigned short *colortable,const unsigned char *color_prom);
/* sound driver data & functions */
extern unsigned char *mappy_soundregs;
void mappy_sound_w(int offset,int data);
void mappy_sound_enable_w(int offset,int data);
/* CPU 1 read addresses */
static struct MemoryReadAddress mappy_readmem_cpu1[] =
{
{ 0xa000, 0xffff, MRA_ROM }, /* ROM code */
{ 0x4040, 0x43ff, MRA_RAM, &mappy_sharedram }, /* shared RAM with the sound CPU */
{ 0x4800, 0x480f, mappy_customio_r_1, &mappy_customio_1 }, /* custom I/O chip #1 interface */
{ 0x4810, 0x481f, mappy_customio_r_2, &mappy_customio_2 }, /* custom I/O chip #2 interface */
{ 0x0000, 0x9fff, mappy_cpu1ram_r }, /* RAM everywhere else */
{ -1 } /* end of table */
};
static struct MemoryReadAddress digdug2_readmem_cpu1[] =
{
{ 0x8000, 0xffff, MRA_ROM }, /* ROM code */
{ 0x4040, 0x43ff, MRA_RAM, &mappy_sharedram }, /* shared RAM with the sound CPU */
{ 0x4800, 0x480f, digdug2_customio_r_1, &mappy_customio_1 }, /* custom I/O chip #1 interface */
{ 0x4810, 0x481f, digdug2_customio_r_2, &mappy_customio_2 }, /* custom I/O chip #2 interface */
{ 0x4820, 0x4bff, MRA_RAM }, /* extra RAM for Dig Dug 2 */
{ 0x0000, 0x7fff, digdug2_cpu1ram_r }, /* RAM everywhere else */
{ -1 } /* end of table */
};
static struct MemoryReadAddress motos_readmem_cpu1[] =
{
{ 0x8000, 0xffff, MRA_ROM }, /* ROM code */
{ 0x4040, 0x43ff, MRA_RAM, &mappy_sharedram }, /* shared RAM with the sound CPU */
{ 0x4800, 0x480f, motos_customio_r_1, &mappy_customio_1 }, /* custom I/O chip #1 interface */
{ 0x4810, 0x481f, motos_customio_r_2, &mappy_customio_2 }, /* custom I/O chip #2 interface */
{ 0x0000, 0x7fff, motos_cpu1ram_r }, /* RAM everywhere else */
{ -1 } /* end of table */
};
static struct MemoryReadAddress todruaga_readmem_cpu1[] =
{
{ 0x8000, 0xffff, MRA_ROM }, /* ROM code */
{ 0x4040, 0x43ff, MRA_RAM, &mappy_sharedram }, /* shared RAM with the sound CPU */
{ 0x4800, 0x480f, todruaga_customio_r_1, &mappy_customio_1 }, /* custom I/O chip #1 interface */
{ 0x4810, 0x481f, todruaga_customio_r_2, &mappy_customio_2 }, /* custom I/O chip #2 interface */
{ 0x0000, 0x7fff, todruaga_cpu1ram_r }, /* RAM everywhere else */
{ -1 } /* end of table */
};
/* CPU 1 write addresses */
static struct MemoryWriteAddress writemem_cpu1[] =
{
{ 0x1000, 0x177f, MWA_RAM }, /* general RAM, area 1 */
{ 0x1800, 0x1f7f, MWA_RAM }, /* general RAM, area 2 */
{ 0x2000, 0x277f, MWA_RAM }, /* general RAM, area 3 */
{ 0x4040, 0x43ff, MWA_RAM }, /* shared RAM with the sound CPU */
{ 0x4820, 0x4bff, MWA_RAM }, /* extra RAM for Dig Dug 2 */
{ 0x0000, 0x07ff, mappy_videoram_w, &videoram, &videoram_size },/* video RAM */
{ 0x0800, 0x0fff, mappy_colorram_w, &colorram }, /* color RAM */
{ 0x1780, 0x17ff, MWA_RAM, &spriteram, &spriteram_size }, /* sprite RAM, area 1 */
{ 0x1f80, 0x1fff, MWA_RAM, &spriteram_2 }, /* sprite RAM, area 2 */
{ 0x2780, 0x27ff, MWA_RAM, &spriteram_3 }, /* sprite RAM, area 3 */
{ 0x3800, 0x3fff, mappy_scroll_w }, /* scroll registers */
{ 0x4800, 0x480f, mappy_customio_w_1 }, /* custom I/O chip #1 interface */
{ 0x4810, 0x481f, mappy_customio_w_2 }, /* custom I/O chip #2 interface */
{ 0x5002, 0x5003, mappy_interrupt_enable_1_w }, /* interrupt enable */
{ 0x500a, 0x500b, mappy_cpu_enable_w }, /* sound CPU enable */
{ 0x8000, 0x8000, MWA_NOP }, /* watchdog timer */
{ 0x8000, 0xffff, MWA_ROM }, /* ROM code */
{ -1 } /* end of table */
};
/* CPU 2 read addresses */
static struct MemoryReadAddress mappy_readmem_cpu2[] =
{
{ 0xe000, 0xffff, MRA_ROM }, /* ROM code */
{ 0x0040, 0x03ff, mappy_sharedram_r2 }, /* shared RAM with the main CPU */
{ -1 } /* end of table */
};
static struct MemoryReadAddress digdug2_readmem_cpu2[] =
{
{ 0xe000, 0xffff, MRA_ROM }, /* ROM code */
{ 0x0040, 0x03ff, digdug2_sharedram_r2 }, /* shared RAM with the main CPU */
{ -1 } /* end of table */
};
static struct MemoryReadAddress motos_readmem_cpu2[] =
{
{ 0xe000, 0xffff, MRA_ROM }, /* ROM code */
{ 0x0040, 0x03ff, motos_sharedram_r2 }, /* shared RAM with the main CPU */
{ -1 } /* end of table */
};
static struct MemoryReadAddress todruaga_readmem_cpu2[] =
{
{ 0xe000, 0xffff, MRA_ROM }, /* ROM code */
{ 0x0040, 0x03ff, motos_sharedram_r2 }, /* shared RAM with the main CPU */
{ -1 } /* end of table */
};
/* CPU 2 write addresses */
static struct MemoryWriteAddress writemem_cpu2[] =
{
{ 0x0040, 0x03ff, mappy_sharedram_w }, /* shared RAM with the main CPU */
{ 0x0000, 0x003f, mappy_sound_w, &mappy_soundregs }, /* sound control registers */
{ 0x2000, 0x2001, mappy_interrupt_enable_2_w }, /* interrupt enable */
{ 0x2006, 0x2007, mappy_sound_enable_w }, /* sound enable */
{ 0xe000, 0xffff, MWA_ROM }, /* ROM code */
{ -1 } /* end of table */
};
/* input from the outside world */
INPUT_PORTS_START( mappy_input_ports )
PORT_START /* DSW0 */
PORT_DIPNAME( 0x03, 0x00, "Difficulty", IP_KEY_NONE )
PORT_DIPSETTING( 0x00, "Easy" )
PORT_DIPSETTING( 0x01, "Medium" )
PORT_DIPSETTING( 0x02, "Hard" )
PORT_DIPSETTING( 0x03, "Hardest" )
PORT_BIT( 0x1c, IP_ACTIVE_HIGH, IPT_UNUSED )
PORT_DIPNAME( 0x20, 0x00, "Demo Sounds", IP_KEY_NONE )
PORT_DIPSETTING( 0x20, "Off" )
PORT_DIPSETTING( 0x00, "On" )
PORT_BITX( 0x40, 0x00, IPT_DIPSWITCH_NAME | IPF_CHEAT, "Rack Test", OSD_KEY_F1, IP_JOY_NONE, 0 )
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 /* DSW1 */
PORT_DIPNAME( 0x07, 0x00, "Coins", IP_KEY_NONE )
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/6 Credits" )
PORT_DIPSETTING( 0x04, "2 Coins/1 Credit" )
PORT_DIPSETTING( 0x05, "2 Coins/3 Credits" )
PORT_DIPSETTING( 0x06, "3 Coins/1 Credits" )
PORT_DIPSETTING( 0x07, "3 Coins/2 Credits" )
/* TODO: bonus scores are different for 5 lives */
PORT_DIPNAME( 0x38, 0x00, "Bonus Life", IP_KEY_NONE )
PORT_DIPSETTING( 0x38, "None" )
PORT_DIPSETTING( 0x20, "20k" )
PORT_DIPSETTING( 0x08, "20k 60k" )
PORT_DIPSETTING( 0x00, "20k 70k" )
PORT_DIPSETTING( 0x10, "20k 80k" )
PORT_DIPSETTING( 0x18, "30k 100k" )
PORT_DIPSETTING( 0x28, "20k 70k 70k" )
PORT_DIPSETTING( 0x30, "20k 80k 80k" )
PORT_DIPNAME( 0xc0, 0x00, "Lives", IP_KEY_NONE )
PORT_DIPSETTING( 0x80, "1" )
PORT_DIPSETTING( 0xc0, "2" )
PORT_DIPSETTING( 0x00, "3" )
PORT_DIPSETTING( 0x40, "5" )
PORT_START /* DSW2 */
PORT_BIT( 0x03, IP_ACTIVE_HIGH, IPT_UNUSED )
PORT_DIPNAME( 0x04, 0x00, "Orientation", IP_KEY_NONE )
PORT_DIPSETTING( 0x00, "Upright" )
PORT_DIPSETTING( 0x04, "Cocktail" )
PORT_BITX( 0x08, 0x00, IPT_DIPSWITCH_NAME | IPF_TOGGLE, "Service Mode", OSD_KEY_F2, IP_JOY_NONE, 0 )
PORT_DIPSETTING( 0x00, "Off" )
PORT_DIPSETTING( 0x08, "On" )
PORT_BIT( 0xf0, IP_ACTIVE_HIGH, IPT_UNUSED )
PORT_START /* FAKE */
/* The player inputs are not memory mapped, they are handled by an I/O chip. */
/* These fake input ports are read by mappy_customio_data_r() */
PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_UNUSED )
PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT | IPF_2WAY )
PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_UNUSED )
PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT | IPF_2WAY )
PORT_BITX(0x10, IP_ACTIVE_HIGH, IPT_BUTTON1 | IPF_IMPULSE,
IP_NAME_DEFAULT, IP_KEY_DEFAULT, IP_JOY_DEFAULT, 1 )
PORT_BITX(0x20, IP_ACTIVE_HIGH, IPT_BUTTON1, 0, IP_KEY_PREVIOUS, IP_JOY_PREVIOUS, 0 )
PORT_BIT( 0xc0, IP_ACTIVE_HIGH, IPT_UNUSED )
PORT_START /* FAKE */
PORT_BITX(0x01, IP_ACTIVE_HIGH, IPT_COIN1 | IPF_IMPULSE,
IP_NAME_DEFAULT, IP_KEY_DEFAULT, IP_JOY_DEFAULT, 1 )
PORT_BITX(0x02, IP_ACTIVE_HIGH, IPT_COIN2 | IPF_IMPULSE,
IP_NAME_DEFAULT, IP_KEY_DEFAULT, IP_JOY_DEFAULT, 1 )
PORT_BIT( 0x0c, IP_ACTIVE_HIGH, IPT_UNUSED )
PORT_BITX(0x10, IP_ACTIVE_HIGH, IPT_START1 | IPF_IMPULSE,
IP_NAME_DEFAULT, IP_KEY_DEFAULT, IP_JOY_DEFAULT, 1 )
PORT_BITX(0x20, IP_ACTIVE_HIGH, IPT_START2 | IPF_IMPULSE,
IP_NAME_DEFAULT, IP_KEY_DEFAULT, IP_JOY_DEFAULT, 1 )
PORT_BIT( 0xc0, IP_ACTIVE_HIGH, IPT_UNUSED )
INPUT_PORTS_END
INPUT_PORTS_START( digdug2_input_ports )
PORT_START /* DSW0 */
PORT_BIT( 0x1f, IP_ACTIVE_HIGH, IPT_UNUSED )
PORT_DIPNAME( 0x20, 0x00, "Lives", IP_KEY_NONE )
PORT_DIPSETTING( 0x00, "3" )
PORT_DIPSETTING( 0x20, "5" )
PORT_DIPNAME( 0xc0, 0x00, "Coins", IP_KEY_NONE )
PORT_DIPSETTING( 0x00, "1 Coin/1 Credit" )
PORT_DIPSETTING( 0x40, "2 Coins/1 Credits" )
PORT_DIPSETTING( 0x80, "1 Coin/2 Credits" )
PORT_DIPSETTING( 0xc0, "3 Coins/1 Credits" )
PORT_START /* DSW1 */
PORT_DIPNAME( 0x03, 0x00, "Extend", IP_KEY_NONE )
PORT_DIPSETTING( 0x00, "Type A" )
PORT_DIPSETTING( 0x02, "Type B" )
PORT_DIPSETTING( 0x01, "Type C" )
PORT_DIPSETTING( 0x03, "Type D" )
PORT_DIPNAME( 0x04, 0x00, "Level Select", IP_KEY_NONE )
PORT_DIPSETTING( 0x00, "Off" )
PORT_DIPSETTING( 0x04, "On" )
PORT_DIPNAME( 0x08, 0x00, "Freeze", IP_KEY_NONE )
PORT_DIPSETTING( 0x00, "Off" )
PORT_DIPSETTING( 0x08, "On" )
PORT_BITX(0x10, IP_ACTIVE_HIGH, IPT_BUTTON2 | IPF_IMPULSE,
IP_NAME_DEFAULT, IP_KEY_DEFAULT, IP_JOY_DEFAULT, 1 )
PORT_BITX(0x20, IP_ACTIVE_HIGH, IPT_BUTTON2, 0, IP_KEY_PREVIOUS, IP_JOY_PREVIOUS, 0 )
PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_UNUSED )
PORT_DIPNAME( 0x80, 0x00, "Orientation", IP_KEY_NONE )
PORT_DIPSETTING( 0x00, "Upright" )
PORT_DIPSETTING( 0x80, "Cocktail" )
PORT_START /* DSW2 */
PORT_BIT( 0x07, IP_ACTIVE_HIGH, IPT_UNUSED )
PORT_BITX( 0x08, 0x00, IPT_DIPSWITCH_NAME | IPF_TOGGLE, "Service Mode", OSD_KEY_F2, IP_JOY_NONE, 0 )
PORT_DIPSETTING( 0x00, "Off" )
PORT_DIPSETTING( 0x08, "On" )
PORT_BIT( 0xf0, IP_ACTIVE_HIGH, IPT_UNUSED )
PORT_START /* FAKE */
/* The player inputs are not memory mapped, they are handled by an I/O chip. */
/* These fake input ports are read by mappy_customio_data_r() */
PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP | IPF_4WAY )
PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT | IPF_4WAY )
PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN | IPF_4WAY )
PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT | IPF_4WAY )
PORT_BITX(0x10, IP_ACTIVE_HIGH, IPT_BUTTON1 | IPF_IMPULSE,
IP_NAME_DEFAULT, IP_KEY_DEFAULT, IP_JOY_DEFAULT, 1 )
PORT_BITX(0x20, IP_ACTIVE_HIGH, IPT_BUTTON1, 0, IP_KEY_PREVIOUS, IP_JOY_PREVIOUS, 0 )
PORT_BIT( 0xc0, IP_ACTIVE_HIGH, IPT_UNUSED )
PORT_START /* FAKE */
PORT_BITX(0x01, IP_ACTIVE_HIGH, IPT_COIN1 | IPF_IMPULSE,
IP_NAME_DEFAULT, IP_KEY_DEFAULT, IP_JOY_DEFAULT, 1 )
PORT_BITX(0x02, IP_ACTIVE_HIGH, IPT_COIN2 | IPF_IMPULSE,
IP_NAME_DEFAULT, IP_KEY_DEFAULT, IP_JOY_DEFAULT, 1 )
PORT_BIT( 0x0c, IP_ACTIVE_HIGH, IPT_UNUSED )
PORT_BITX(0x10, IP_ACTIVE_HIGH, IPT_START1 | IPF_IMPULSE,
IP_NAME_DEFAULT, IP_KEY_DEFAULT, IP_JOY_DEFAULT, 1 )
PORT_BITX(0x20, IP_ACTIVE_HIGH, IPT_START2 | IPF_IMPULSE,
IP_NAME_DEFAULT, IP_KEY_DEFAULT, IP_JOY_DEFAULT, 1 )
PORT_BIT( 0xc0, IP_ACTIVE_HIGH, IPT_UNUSED )
INPUT_PORTS_END
INPUT_PORTS_START( motos_input_ports )
PORT_START /* DSW0 */
PORT_DIPNAME( 0x01, 0x00, "Reset", IP_KEY_NONE )
PORT_DIPSETTING( 0x00, "Off" )
PORT_DIPSETTING( 0x01, "On" )
PORT_DIPNAME( 0x06, 0x00, "Coins", IP_KEY_NONE )
PORT_DIPSETTING( 0x00, "1 Coin/1 Credit" )
PORT_DIPSETTING( 0x02, "1 Coin/2 Credits" )
PORT_DIPSETTING( 0x04, "2 Coins/1 Credit" )
PORT_DIPSETTING( 0x06, "3 Coins/1 Credit" )
PORT_DIPNAME( 0x08, 0x00, "Motos", IP_KEY_NONE )
PORT_DIPSETTING( 0x00, "3" )
PORT_DIPSETTING( 0x08, "5" )
PORT_DIPNAME( 0x10, 0x00, "Rank", IP_KEY_NONE )
PORT_DIPSETTING( 0x00, "A" )
PORT_DIPSETTING( 0x10, "B" )
PORT_DIPNAME( 0x60, 0x00, "Bonus life", IP_KEY_NONE )
PORT_DIPSETTING( 0x00, "10k 30k 50k" )
PORT_DIPSETTING( 0x20, "20k -- 50k" )
PORT_DIPSETTING( 0x40, "30k -- 70k" )
PORT_DIPSETTING( 0x60, "20k 70k" )
PORT_DIPNAME( 0x80, 0x00, "Demo Sounds", IP_KEY_NONE )
PORT_DIPSETTING( 0x80, "Off" )
PORT_DIPSETTING( 0x00, "On" )
PORT_START /* DSW1 */
PORT_BIT( 0x3f, IP_ACTIVE_HIGH, IPT_UNUSED )
PORT_DIPNAME( 0x40, 0x00, "Orientation", IP_KEY_NONE )
PORT_DIPSETTING( 0x00, "Upright" )
PORT_DIPSETTING( 0x40, "Cocktail" )
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 /* FAKE */
/* The player inputs are not memory mapped, they are handled by an I/O chip. */
/* These fake input ports are read by mappy_customio_data_r() */
PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP | IPF_8WAY )
PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT | IPF_8WAY )
PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN | IPF_8WAY )
PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT | IPF_8WAY )
PORT_BITX(0x10, IP_ACTIVE_HIGH, IPT_BUTTON1 | IPF_IMPULSE,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -