📄 gng.c
字号:
/***************************************************************************
GHOST AND GOBLINS HARDWARE. ( Doc By Roberto Ventura )
The hardware is similar to 1942's and other Capcom games.
It seems that it's adapted by software to run on a standard (horizontal)
CRT display.
-ROM CONTENTS.
GG1.bin = Character display. (unlike 1942 this is bit complemented)
GG2.bin = Sound ROM.
GG3.bin = CPU main chunk,fixed in 8000h-ffffh.
GG4.bin = CPU paged in.Upmost 2000h fixed in 6000h-7fffh.
GG5.bin = CPU paged in 4000h-5fffh.
GG6.bin = background set 2-3 plane 3
GG7.bin = background set 0-1 plane 3
GG8.bin = background set 2-3 plane 2
GG9.bin = background set 0-1 plane 2
GG10.bin = background set 2-3 plane 1
GG11.bin = background set 0-1 plane 1
GG12.bin = sprites set 2 planes 3-4
GG13.bin = sprites set 1 planes 3-4
GG14.bin = sprites set 0 planes 3-4
GG15.bin = sprites set 2 planes 1-2
GG16.bin = sprites set 1 planes 1-2
GG17.bin = sprites set 0 planes 1-2
Note: the plane order is important because the game's palette is
not stored in hardware,therefore there is only a way to match a bit
with the corresponding colour.
In other ROM sets I've found a different in-rom arrangement of banks.
(16k ROMs instead of 32k)
-MEMORY MAP:
0000-1DFF = Work RAM
1e00-1f7f = Sprites
2000-23ff = Characters video ram.
2400-27ff = Characters attributes.
2800-2bff = Background video ram.
2c00-2fff = Background attributes.
3000-37ff = Input ports.
3800-3fff = Output ports.
4000-5fff = Bank switched.
6000-7fff = GG4 8k upmost. (fixed)
8000-ffff = GG3. (fixed)
-CHARACTER TILE FORMAT.
Attribute description:
76543210
^^^^ Palette selector.
^ Page selector.
^^ ^ Unknown/unused.
Two 256 tiles pages are available for characters.
Sixteen 4 colours palettes are available for characters.
-BACKGROUND TILE FORMAT:
Both scroll and attributes map consist of 4 pages which wrap up/down
and left/right.
Attribute description:
76543210
^^^ Palette selector
^ Tile priority
^ Flip X
^ Flip Y? (should be present.)
^^ Tile page selector.
When the priority bit is set the tile can overlap sprites.
Eight 8 colours palettes are available for background.
Four 256 tiles pages are available for background.
-SPRITE FORMAT:
There hardware is capable to display 96 sprites,they use 4 bytes each,in order:
1) Sprite number.
2) Sprite attribute.
3) Y pos.
4) X pos.
Sprite attribute description:
76543210
^ X "Sprite clipping"
^ Unknown/Unused
^ Flip X
^Flip Y
^^ Palette selector
^^ Sprite page selector
I've called bit 1 "Sprite clipping" bit because this does not act as a
MSB,it's set when the sprite reaches either left or right border,
according to the MSB bit of the X position (rough scroll) selects two
border display columns,where sprites horizontal movement is limited
by a 7 bit offset (rest of X position).
Four 16 colours palettes are available for sprites.
Three 256 sprites pages are available.
The sprite priority is inversed: the last sprite,increasing memory,
has the higher priority.
INPUT:
3000 = Coin and start buttons
3001 = Controls and joystick 1.
3002 = Controls and joystick 2.
3003 = DIP 0
3004 = DIP 1
OUTPUT:
3800-38ff = Palette HI: 2 nibbles:red and green.
3900-39ff = Palette LO: 1 nibble:blue (low nibble set to zero)
The palette depth is 12 bits (4096 colours).
Each object (scroll,characters,sprites) has it's own palette space.
00-3f: background palettes. (8x8 colours)
40-7f: sprites palettes. (4*16 colours)
80-bf: characters palettes (16*4 colours)
c0-ff: duplicate of character palettes ?? (16*4 colours)
note: character and sprite palettes are in reversed order,the
transparent colour is the last colour,not colour zero.
3a00 = sound output?
3b08 = scroll X
3b09 = scroll X MSB
3b0a = scroll Y
3b0b = scroll Y MSB
3c00 = watchdog???
3d00 = ???
3d01 = ???
3d02 = ???
3d03 = ???
3e00 = page selector (valid pages are 0,1,2,3 and 4)
***************************************************************************/
#include "driver.h"
#include "vidhrdw/generic.h"
#include "M6809/M6809.h"
void gng_bankswitch_w(int offset,int data);
int gng_bankedrom_r(int offset);
void gng_init_machine(void);
extern unsigned char *gng_bgvideoram,*gng_bgcolorram;
extern int gng_bgvideoram_size;
extern unsigned char *gng_scrollx,*gng_scrolly;
void gng_bgvideoram_w(int offset,int data);
void gng_bgcolorram_w(int offset,int data);
void gng_flipscreen_w(int offset,int data);
int gng_vh_start(void);
void gng_vh_stop(void);
void gng_vh_screenrefresh(struct osd_bitmap *bitmap,int full_refresh);
void gng_bankswitch_w(int offset,int data)
{
unsigned char *RAM = Machine->memory_region[Machine->drv->cpu[0].memory_region];
static int bank[] = { 0x10000, 0x12000, 0x14000, 0x16000, 0x04000, 0x18000 };
cpu_setbank (1, &RAM[bank[data]]);
}
void gng_init_machine(void)
{
/* Set optimization flags for M6809 */
m6809_Flags = M6809_FAST_NONE;
}
static struct MemoryReadAddress readmem[] =
{
{ 0x0000, 0x2fff, MRA_RAM },
{ 0x3000, 0x3000, input_port_0_r },
{ 0x3001, 0x3001, input_port_1_r },
{ 0x3002, 0x3002, input_port_2_r },
{ 0x3003, 0x3003, input_port_3_r },
{ 0x3004, 0x3004, input_port_4_r },
{ 0x3c00, 0x3c00, MRA_NOP }, /* watchdog? */
{ 0x4000, 0x5fff, MRA_BANK1 },
{ 0x6000, 0xffff, MRA_ROM },
{ -1 } /* end of table */
};
static struct MemoryWriteAddress writemem[] =
{
{ 0x0000, 0x1dff, MWA_RAM },
{ 0x1e00, 0x1fff, MWA_RAM, &spriteram, &spriteram_size },
{ 0x2000, 0x23ff, videoram_w, &videoram, &videoram_size },
{ 0x2400, 0x27ff, colorram_w, &colorram },
{ 0x2800, 0x2bff, gng_bgvideoram_w, &gng_bgvideoram, &gng_bgvideoram_size },
{ 0x2c00, 0x2fff, gng_bgcolorram_w, &gng_bgcolorram },
{ 0x3800, 0x38ff, paletteram_RRRRGGGGBBBBxxxx_split2_w, &paletteram_2 },
{ 0x3900, 0x39ff, paletteram_RRRRGGGGBBBBxxxx_split1_w, &paletteram },
{ 0x3a00, 0x3a00, soundlatch_w },
{ 0x3b08, 0x3b09, MWA_RAM, &gng_scrollx },
{ 0x3b0a, 0x3b0b, MWA_RAM, &gng_scrolly },
{ 0x3c00, 0x3c00, MWA_NOP }, /* watchdog? */
{ 0x3d00, 0x3d00, gng_flipscreen_w },
{ 0x3e00, 0x3e00, gng_bankswitch_w },
{ 0x4000, 0xffff, MWA_ROM },
{ -1 } /* end of table */
};
static struct MemoryReadAddress sound_readmem[] =
{
{ 0xc000, 0xc7ff, MRA_RAM },
{ 0xc800, 0xc800, soundlatch_r },
{ 0x0000, 0x7fff, MRA_ROM },
{ -1 } /* end of table */
};
static struct MemoryWriteAddress sound_writemem[] =
{
{ 0xc000, 0xc7ff, MWA_RAM },
{ 0xe000, 0xe000, YM2203_control_port_0_w },
{ 0xe001, 0xe001, YM2203_write_port_0_w },
{ 0xe002, 0xe002, YM2203_control_port_1_w },
{ 0xe003, 0xe003, YM2203_write_port_1_w },
{ 0x0000, 0x7fff, MWA_ROM },
{ -1 } /* end of table */
};
INPUT_PORTS_START( gng_input_ports )
PORT_START /* IN0 */
PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_START1 )
PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_START2 )
PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN )
PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNKNOWN )
PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNKNOWN )
PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_COIN3 )
PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_COIN1 )
PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_COIN2 )
PORT_START /* IN1 */
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_UNKNOWN )
PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
PORT_START /* IN2 */
PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_8WAY | IPF_COCKTAIL )
PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT | IPF_8WAY | IPF_COCKTAIL )
PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN | IPF_8WAY | IPF_COCKTAIL )
PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_UP | 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, "Coinage", 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( 0x10, 0x10, "Coinage affects", IP_KEY_NONE )
PORT_DIPSETTING( 0x10, "Coin A" )
PORT_DIPSETTING( 0x00, "Coin B" )
PORT_DIPNAME( 0x20, 0x00, "Demo Sounds", IP_KEY_NONE )
PORT_DIPSETTING( 0x20, "Off" )
PORT_DIPSETTING( 0x00, "On" )
PORT_BITX( 0x40, 0x40, IPT_DIPSWITCH_NAME | IPF_TOGGLE, "Service Mode", OSD_KEY_F2, IP_JOY_NONE, 0 )
PORT_DIPSETTING( 0x40, "Off" )
PORT_DIPSETTING( 0x00, "On" )
PORT_DIPNAME( 0x80, 0x80, "Flip Screen", IP_KEY_NONE )
PORT_DIPSETTING( 0x80, "Off" )
PORT_DIPSETTING( 0x00, "On" )
PORT_START /* DSW1 */
PORT_DIPNAME( 0x03, 0x03, "Lives", IP_KEY_NONE )
PORT_DIPSETTING( 0x03, "3" )
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -