📄 tp84.c
字号:
/***************************************************************************
to do:
-Better sound emulation
-Speed!!!
-The Z80 spends most of its time reading the timer, we should trap that.
Time Pilot 84 Memory Map (preliminary)
The schematics are available on the net.
There is 3 CPU for this game.
Two 68A09E for the game.
A Z80A for the sound
As I understand it, the second 6809 is for displaying
the sprites. If we do not emulate him, all work well, except
that the player cannot die.
Address 57ff must read 0 to pass the RAM test if the second CPU
is not emulated.
---- Master 6809 ------
Write
2000-27ff MAFR Watch dog ?
2800 COL0 a register that index the colors Proms
3000 reset IRQ
3001 OUT2 Coin Counter 2
3002 OUT1 Coin Counter 1
3003 MUT
3004 HREV
3005 VREV
3006 -
3007 GMED
3800 SON Sound on
3A00 SDA Sound data
3C00 SHF0 SHF1 J2 J3 J4 J5 J6 J7 background Y position
3E00 L0 - L7 background X position
Read:
2800 in0 Buttons 1
2820 in1 Buttons 2
2840 in2 Buttons 3
2860 in3 Dip switches 1
3000 in4 Dip switches 2
3800 in5 Dip switches 3 (not used)
Read/Write
4000-47ff Char ram, 2 pages
4800-4fff Background character ram, 2 pages
5000-57ff Ram (Common for the Master and Slave 6809) 0x5000-0x517f sprites data
6000-ffff Rom (only from $8000 to $ffff is used in this game)
------ Slave 6809 --------
0000-1fff SAFR Watch dog ?
2000 seem to be the beam position (if always 0, no player collision is detected)
4000 enable or reset IRQ
6000-7fff DRA ?
8000-87ff Ram (Common for the Master and Slave 6809)
E000-ffff Rom
------ Sound CPU (Z80) -----
There are 3 or 4 76489AN chips driven by the Z80
0000-1fff Rom program (A6)
2000-3fff Rom Program (A4) (not used or missing?)
4000-43ff Ram
6000-7fff Sound data in
8000-9fff Timer
A000-Bfff
C000 Store Data that will go to one of the 76489AN
C001 76489 #1 trigger
C002 76489 #2 (optional) trigger
C003 76489 #3 trigger
C004 76489 #4 trigger
***************************************************************************/
#include "driver.h"
#include "vidhrdw/generic.h"
/* In Machine */
extern int tp84_beam_r(int offset);
extern int tp84_interrupt(void);
void tp84_catchloop_w(int offset,int data); /* JB 970829 */
int tp84_catchloop_r(int offset); /* JB 970829 */
void tp84_init_machine(void); /* JB 970829 */
/* In Vidhrdw */
extern unsigned char *tp84_sharedram;
int tp84_sharedram_r(int offset);
void tp84_sharedram_w(int offset,int data);
extern unsigned char *tp84_videoram2;
extern unsigned char *tp84_colorram2;
extern unsigned char *tp84_scrollx;
extern unsigned char *tp84_scrolly;
void tp84_videoram2_w(int offset,int data);
void tp84_colorram2_w(int offset,int data);
void tp84_col0_w(int offset,int data);
void tp84_vh_convert_color_prom(unsigned char *palette, unsigned short *colortable,const unsigned char *color_prom);
int tp84_vh_start(void);
void tp84_vh_stop(void);
void tp84_vh_screenrefresh(struct osd_bitmap *bitmap,int full_refresh);
int tp84_sh_timer_r(int offset)
{
int clock;
#define TIMER_RATE 256
clock = cpu_gettotalcycles() / TIMER_RATE;
return clock;
}
void tp84_sh_irqtrigger_w(int offset,int data)
{
cpu_cause_interrupt(2,0xff);
}
/* CPU 1 read addresses */
static struct MemoryReadAddress readmem[] =
{
{ 0x2800, 0x2800, input_port_0_r },
{ 0x2820, 0x2820, input_port_1_r },
{ 0x2840, 0x2840, input_port_2_r },
{ 0x2860, 0x2860, input_port_3_r },
{ 0x3000, 0x3000, input_port_4_r },
{ 0x4000, 0x4fff, MRA_RAM },
{ 0x523a, 0x523a, tp84_catchloop_r }, /* JB 970829 */
{ 0x5000, 0x57ff, tp84_sharedram_r },
{ 0x8000, 0xffff, MRA_ROM },
{ -1 } /* end of table */
};
/* CPU 1 write addresses */
static struct MemoryWriteAddress writemem[] =
{
{ 0x2000, 0x2000, MWA_RAM }, /*Watch dog?*/
{ 0x2800, 0x2800, tp84_col0_w },
{ 0x3000, 0x3000, MWA_RAM },
{ 0x3800, 0x3800, tp84_sh_irqtrigger_w },
{ 0x3a00, 0x3a00, soundlatch_w },
{ 0x3c00, 0x3c00, MWA_RAM, &tp84_scrollx }, /* Y scroll */
{ 0x3e00, 0x3e00, MWA_RAM, &tp84_scrolly }, /* X scroll */
{ 0x4000, 0x43ff, videoram_w, &videoram , &videoram_size},
{ 0x4400, 0x47ff, tp84_videoram2_w, &tp84_videoram2 },
{ 0x4800, 0x4bff, colorram_w, &colorram },
{ 0x4c00, 0x4fff, tp84_colorram2_w, &tp84_colorram2 },
{ 0x5000, 0x57ff, tp84_sharedram_w, &tp84_sharedram }, /* 0x5000-0x517f sprites definitions*/
{ 0x8000, 0xffff, MWA_ROM },
{ -1 } /* end of table */
};
/* CPU 2 read addresses */
static struct MemoryReadAddress readmem_cpu2[] =
{
{ 0x0000, 0x0000, MRA_RAM },
{ 0x2000, 0x2000, tp84_beam_r }, /* beam position */
{ 0x6000, 0x7fff, MRA_RAM },
{ 0x8000, 0x87ff, tp84_sharedram_r }, /* shared RAM with the main CPU */
{ 0xe000, 0xffff, MRA_ROM },
{ -1 } /* end of table */
};
/* CPU 2 write addresses */
static struct MemoryWriteAddress writemem_cpu2[] =
{
{ 0x0000, 0x0000, MWA_RAM }, /* Watch dog ?*/
{ 0x4000, 0x4000, tp84_catchloop_w }, /* IRQ enable */ /* JB 970829 */
{ 0x6000, 0x7fff, MWA_RAM },
{ 0x8000, 0x87ff, tp84_sharedram_w }, /* shared RAM with the main CPU */
{ 0xe000, 0xffff, MWA_ROM }, /* ROM code */
{ -1 } /* end of table */
};
static struct MemoryReadAddress sound_readmem[] =
{
{ 0x0000, 0x1fff, MRA_ROM },
{ 0x4000, 0x43ff, MRA_RAM },
{ 0x6000, 0x6000, soundlatch_r },
{ 0x8000, 0x8000, tp84_sh_timer_r },
{ -1 } /* end of table */
};
static struct MemoryWriteAddress sound_writemem[] =
{
{ 0x0000, 0x1fff, MWA_ROM },
{ 0x4000, 0x43ff, MWA_RAM },
{ 0xc000, 0xc000, MWA_NOP },
{ 0xc001, 0xc001, SN76496_0_w },
{ 0xc003, 0xc003, SN76496_1_w },
{ 0xc004, 0xc004, SN76496_2_w },
{ -1 } /* end of table */
};
INPUT_PORTS_START( input_ports )
PORT_START /* IN0 */
PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN1 )
PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_COIN2 )
PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_COIN3 )
PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_START1 )
PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_START2 )
PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNKNOWN )
PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
PORT_START /* IN1 */
PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT | IPF_8WAY )
PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_8WAY )
PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_UP | IPF_8WAY )
PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN | 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_UNKNOWN )
PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
PORT_START /* IN2 */
PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT | IPF_8WAY | IPF_COCKTAIL )
PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_8WAY | IPF_COCKTAIL )
PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_UP | IPF_8WAY | IPF_COCKTAIL )
PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN | IPF_8WAY | IPF_COCKTAIL )
PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_COCKTAIL )
PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 | IPF_COCKTAIL )
PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
PORT_START /* DSW0 */
PORT_DIPNAME( 0x0f, 0x0f, "Coin A", IP_KEY_NONE )
PORT_DIPSETTING( 0x02, "4 Coins/1 Credit" )
PORT_DIPSETTING( 0x05, "3 Coins/1 Credit" )
PORT_DIPSETTING( 0x08, "2 Coins/1 Credit" )
PORT_DIPSETTING( 0x04, "3 Coins/2 Credits" )
PORT_DIPSETTING( 0x01, "4 Coins/3 Credits" )
PORT_DIPSETTING( 0x0f, "1 Coin/1 Credit" )
PORT_DIPSETTING( 0x03, "3 Coins/4 Credits" )
PORT_DIPSETTING( 0x07, "2 Coins/3 Credits" )
PORT_DIPSETTING( 0x0e, "1 Coin/2 Credits" )
PORT_DIPSETTING( 0x06, "2 Coins/5 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( 0x09, "1 Coin/7 Credits" )
PORT_DIPSETTING( 0x00, "Free Play" )
PORT_DIPNAME( 0xf0, 0xf0, "Coin B", IP_KEY_NONE )
PORT_DIPSETTING( 0x20, "4 Coins/1 Credit" )
PORT_DIPSETTING( 0x50, "3 Coins/1 Credit" )
PORT_DIPSETTING( 0x80, "2 Coins/1 Credit" )
PORT_DIPSETTING( 0x40, "3 Coins/2 Credits" )
PORT_DIPSETTING( 0x10, "4 Coins/3 Credits" )
PORT_DIPSETTING( 0xf0, "1 Coin/1 Credit" )
PORT_DIPSETTING( 0x30, "3 Coins/4 Credits" )
PORT_DIPSETTING( 0x70, "2 Coins/3 Credits" )
PORT_DIPSETTING( 0xe0, "1 Coin/2 Credits" )
PORT_DIPSETTING( 0x60, "2 Coins/5 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( 0x90, "1 Coin/7 Credits" )
PORT_DIPSETTING( 0x00, "Invalid" )
PORT_START /* DSW1 */
PORT_DIPNAME( 0x03, 0x02, "Lives", IP_KEY_NONE )
PORT_DIPSETTING( 0x03, "2" )
PORT_DIPSETTING( 0x02, "3" )
PORT_DIPSETTING( 0x01, "5" )
PORT_DIPSETTING( 0x00, "7" )
PORT_DIPNAME( 0x04, 0x00, "Cabinet", IP_KEY_NONE )
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -