📄 pooyan.c
字号:
/***************************************************************************
Pooyan memory map (preliminary)
Thanks must go to Mike Cuddy for providing information on this one.
Sound processor memory map.
0x3000-0x33ff RAM.
AY-8910 #1 : reg 0x5000
wr 0x4000
rd 0x4000
AY-8910 #2 : reg 0x7000
wr 0x6000
rd 0x6000
Main processor memory map.
0000-7fff ROM
8000-83ff color RAM
8400-87ff video RAM
8800-8fff RAM
9000-97ff sprite RAM (only areas 0x9010 and 0x9410 are used).
memory mapped ports:
read:
0xA000 Dipswitch 2 adddbtll
a = attract mode
ddd = difficulty 0=easy, 7=hardest.
b = bonus setting (easy/hard)
t = table / upright
ll = lives: 11=3, 10=4, 01=5, 00=255.
0xA0E0 llllrrrr
l == left coin mech, r = right coinmech.
0xA080 IN0 Port
0xA0A0 IN1 Port
0xA0C0 IN2 Port
write:
0xA100 command for the audio CPU.
0xA180 NMI enable. (0xA180 == 1 = deliver NMI to CPU).
0xA181 interrupt trigger on audio CPU.
0xA183 maybe reset sound cpu?
0xA184 ????
0xA187 Flip screen
interrupts:
standard NMI at 0x66
***************************************************************************/
#include "driver.h"
#include "vidhrdw/generic.h"
void pooyan_flipscreen_w(int offset,int data);
void pooyan_vh_convert_color_prom(unsigned char *palette, unsigned short *colortable,const unsigned char *color_prom);
void pooyan_vh_screenrefresh(struct osd_bitmap *bitmap,int full_refresh);
/* I am not 100% sure that this timer is correct, but */
/* I'm using the Gyruss wired to the higher 4 bits */
/* instead of the lower ones, so there is a good */
/* chance it's the right one. */
/* The timer clock which feeds the lower 4 bits of */
/* AY-3-8910 port A is based on the same clock */
/* feeding the sound CPU Z80. It is a divide by */
/* 10240, formed by a standard divide by 1024, */
/* followed by a divide by 10 using a 4 bit */
/* bi-quinary count sequence. (See LS90 data sheet */
/* for an example). */
/* Bits 1-3 come directly from the upper three bits */
/* of the bi-quinary counter. Bit 0 comes from the */
/* output of the divide by 1024. */
static int pooyan_timer[20] = {
0x00, 0x01, 0x00, 0x01, 0x02, 0x03, 0x02, 0x03, 0x04, 0x05,
0x08, 0x09, 0x08, 0x09, 0x0a, 0x0b, 0x0a, 0x0b, 0x0c, 0x0d
};
static int pooyan_portB_r(int offset)
{
/* need to protect from totalcycles overflow */
static int last_totalcycles = 0;
/* number of Z80 clock cycles to count */
static int clock;
int current_totalcycles;
current_totalcycles = cpu_gettotalcycles();
clock = (clock + (current_totalcycles-last_totalcycles)) % 10240;
last_totalcycles = current_totalcycles;
return pooyan_timer[clock/512] << 4;
}
void pooyan_sh_irqtrigger_w(int offset,int data)
{
static int last;
if (last == 1 && data == 0)
{
/* setting bit 0 high then low triggers IRQ on the sound CPU */
cpu_cause_interrupt(1,0xff);
}
last = data;
}
static struct MemoryReadAddress readmem[] =
{
{ 0x0000, 0x7fff, MRA_ROM },
{ 0x8000, 0x8fff, MRA_RAM }, /* color and video RAM */
{ 0xa000, 0xa000, input_port_4_r }, /* DSW2 */
{ 0xa080, 0xa080, input_port_0_r }, /* IN0 */
{ 0xa0a0, 0xa0a0, input_port_1_r }, /* IN1 */
{ 0xa0c0, 0xa0c0, input_port_2_r }, /* IN2 */
{ 0xa0e0, 0xa0e0, input_port_3_r }, /* DSW1 */
{ -1 } /* end of table */
};
static struct MemoryWriteAddress writemem[] =
{
{ 0x0000, 0x7fff, MWA_ROM },
{ 0x8000, 0x83ff, colorram_w, &colorram },
{ 0x8400, 0x87ff, videoram_w, &videoram, &videoram_size },
{ 0x8800, 0x8fff, MWA_RAM },
{ 0x9010, 0x903f, MWA_RAM, &spriteram, &spriteram_size },
{ 0x9410, 0x943f, MWA_RAM, &spriteram_2 },
{ 0xa000, 0xa000, MWA_NOP }, /* watchdog reset? */
{ 0xa100, 0xa100, soundlatch_w },
{ 0xa180, 0xa180, interrupt_enable_w },
{ 0xa181, 0xa181, pooyan_sh_irqtrigger_w },
{ 0xa187, 0xa187, pooyan_flipscreen_w },
{ -1 } /* end of table */
};
static struct MemoryReadAddress sound_readmem[] =
{
{ 0x0000, 0x1fff, MRA_ROM },
{ 0x3000, 0x33ff, MRA_RAM },
{ 0x4000, 0x4000, AY8910_read_port_0_r },
{ 0x6000, 0x6000, AY8910_read_port_1_r },
{ -1 } /* end of table */
};
static struct MemoryWriteAddress sound_writemem[] =
{
{ 0x0000, 0x1fff, MWA_ROM },
{ 0x3000, 0x33ff, MWA_RAM },
{ 0x4000, 0x4000, AY8910_write_port_0_w },
{ 0x5000, 0x5000, AY8910_control_port_0_w },
{ 0x6000, 0x6000, AY8910_write_port_1_w },
{ 0x7000, 0x7000, AY8910_control_port_1_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_UNKNOWN )
PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN )
PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_UP | IPF_2WAY )
PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN | IPF_2WAY )
PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 )
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 /* IN2 */
PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN )
PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN )
PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_UP | IPF_2WAY | IPF_COCKTAIL )
PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN | IPF_2WAY | IPF_COCKTAIL )
PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_COCKTAIL )
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 /* 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( 0x00, "Attract Mode - No Play" )
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_START /* DSW1 */
PORT_DIPNAME( 0x03, 0x03, "Lives", IP_KEY_NONE )
PORT_DIPSETTING( 0x03, "3" )
PORT_DIPSETTING( 0x02, "4" )
PORT_DIPSETTING( 0x01, "5" )
PORT_BITX( 0, 0x00, IPT_DIPSWITCH_SETTING | IPF_CHEAT, "255", IP_KEY_NONE, IP_JOY_NONE, 0 )
PORT_DIPNAME( 0x04, 0x00, "Cabinet", IP_KEY_NONE )
PORT_DIPSETTING( 0x00, "Upright" )
PORT_DIPSETTING( 0x04, "Cocktail" )
PORT_DIPNAME( 0x08, 0x08, "Bonus Life", IP_KEY_NONE )
PORT_DIPSETTING( 0x08, "50000 80000" )
PORT_DIPSETTING( 0x00, "30000 70000" )
PORT_DIPNAME( 0x70, 0x70, "Difficulty", IP_KEY_NONE )
PORT_DIPSETTING( 0x70, "Easiest" )
PORT_DIPSETTING( 0x60, "Easier" )
PORT_DIPSETTING( 0x50, "Easy" )
PORT_DIPSETTING( 0x40, "Normal" )
PORT_DIPSETTING( 0x30, "Medium" )
PORT_DIPSETTING( 0x20, "Difficult" )
PORT_DIPSETTING( 0x10, "Hard" )
PORT_DIPSETTING( 0x00, "Hardest" )
PORT_DIPNAME( 0x80, 0x00, "Demo Sounds", IP_KEY_NONE )
PORT_DIPSETTING( 0x00, "On" )
PORT_DIPSETTING( 0x80, "Off" )
INPUT_PORTS_END
static struct GfxLayout charlayout =
{
8,8, /* 8*8 characters */
256, /* 256 characters */
4, /* 4 bits per pixel */
{ 0x1000*8+4, 0x1000*8+0, 4, 0 },
{ 0, 1, 2, 3, 8*8+0,8*8+1,8*8+2,8*8+3 },
{ 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8 },
16*8 /* every char takes 16 consecutive bytes */
};
static struct GfxLayout spritelayout =
{
16,16, /* 16*16 sprites */
64, /* 64 sprites */
4, /* 4 bits per pixel */
{ 0x1000*8+4, 0x1000*8+0, 4, 0 },
{ 0, 1, 2, 3, 8*8+0, 8*8+1, 8*8+2, 8*8+3,
16*8+0, 16*8+1, 16*8+2, 16*8+3, 24*8+0, 24*8+1, 24*8+2, 24*8+3 },
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -