📄 segar.c
字号:
/***************************************************************************
This port controls the Space Odyssey background scrolling. Each write to
this port scrolls the background by one bit. Faster speeds are achieved
by the program writing more often to this port. Oddly enough, the value
sent to this port also seems to indicate the speed, but the value itself
is never checked.
***************************************************************************/
void spaceod_backshift_w(int offset,int data)
{
segar_backshift= (segar_backshift + 1) % 0x400;
segar_has_background=1;
segar_fill_background=0;
}
/***************************************************************************
This port resets the Space Odyssey background to the "top". This is only
really important for the Black Hole level, since the only way the program
can line up the background's Black Hole with knowing when to spin the ship
is to force the background to restart every time you die.
***************************************************************************/
void spaceod_backshift_clear_w(int offset,int data)
{
segar_backshift=0;
segar_has_background=1;
segar_fill_background=0;
}
/***************************************************************************
Space Odyssey also lets you fill the background with a specific color.
***************************************************************************/
void spaceod_backfill_w(int offset,int data)
{
segar_backfill=data + 0x40 + 1;
segar_fill_background=1;
}
/***************************************************************************
***************************************************************************/
void spaceod_nobackfill_w(int offset,int data)
{
segar_backfill=0;
segar_fill_background=0;
}
/***************************************************************************
Special refresh for Space Odyssey, this code refreshes the static background.
***************************************************************************/
void spaceod_vh_screenrefresh(struct osd_bitmap *bitmap,int full_refresh)
{
int offs;
int charcode;
int sprite_transparency;
int vert_scene;
if (full_refresh)
segar_refresh = 1;
vert_scene = ((segar_backscene & 0x2000) == 0x2000);
sprite_transparency=TRANSPARENCY_COLOR;
/* If the background picture changed, draw the new one in temp storage */
if (segar_brefresh)
{
segar_brefresh=0;
for (offs = 0x1000 - 1; offs >= 0; offs--)
{
int sx,sy;
/* Use Vertical Back Scene */
if (vert_scene)
{
sx = 8 * ((((offs % 0x400) / 32)-3)%32);
sy = 8 * (32*(3-(((offs+0xC00) / 0x400)%4)) + (31-(offs % 32)));
if (segar_bcocktail)
{
sx = 27*8 - sx; /* is this right? */
sy = 31*8 - sy;
}
}
/* Use Horizontal Back Scene */
else
{
sx = 8 * (offs / 32);
sy = 8 * (31 - offs % 32);
if (segar_bcocktail)
{
sx = 127*8 - sx; /* is this right? */
sy = 31*8 - sy;
}
}
charcode = segar_mem_blookup[offs + segar_backscene] + segar_backoffset;
if (vert_scene)
{
drawgfx(vertbackbitmap,Machine->gfx[1],
charcode,0,
segar_bcocktail,segar_bcocktail,sx,sy,
0,TRANSPARENCY_NONE,0);
}
else
{
drawgfx(horizbackbitmap,Machine->gfx[1],
charcode,0,
segar_bcocktail,segar_bcocktail,sx,sy,
0,TRANSPARENCY_NONE,0);
}
}
}
/* Copy the scrolling background */
{
int scroll;
if (vert_scene)
{
if (segar_bcocktail)
scroll = -segar_backshift;
else
scroll = segar_backshift;
copyscrollbitmap(bitmap,vertbackbitmap,0,0,1,&scroll,&Machine->drv->visible_area,TRANSPARENCY_NONE,0);
}
else
{
if (segar_bcocktail)
scroll = segar_backshift;
else
scroll = -segar_backshift;
copyscrollbitmap(bitmap,horizbackbitmap,1,&scroll,0,0,&Machine->drv->visible_area,TRANSPARENCY_NONE,0);
}
}
if (segar_fill_background==1)
{
fillbitmap(bitmap,Machine->pens[segar_backfill],&Machine->drv->visible_area);
}
/* Refresh the "standard" graphics */
segar_common_screenrefresh(bitmap, TRANSPARENCY_NONE, TRANSPARENCY_COLOR);
}
/***************************************************************************
---------------------------------------------------------------------------
Monster Bash Functions
---------------------------------------------------------------------------
***************************************************************************/
/***************************************************************************
This port controls which background to draw for Monster Bash. The tempscene
and tempoffset are analogous to control lines used to bank switch the
background ROMs. If the background changed, refresh the screen.
***************************************************************************/
void monsterb_back_port_w(int offset,int data)
{
unsigned int tempscene,tempoffset;
tempscene = 0x400 * ((data & 0x70) >> 4);
tempoffset = 0x100 * (data & 0x03);
if (segar_backscene != tempscene)
{
segar_backscene = tempscene;
segar_refresh=1;
}
if (segar_backoffset != tempoffset)
{
segar_backoffset = tempoffset;
segar_refresh=1;
}
/* This bit turns the background off and on. */
if ((data & 0x80) && (segar_has_background==0))
{
segar_has_background=1;
segar_refresh=1;
}
else if (((data & 0x80)==0) && (segar_has_background==1))
{
segar_has_background=0;
segar_refresh=1;
}
}
/***************************************************************************
Special refresh for Monster Bash, this code refreshes the static background.
***************************************************************************/
void monsterb_vh_screenrefresh(struct osd_bitmap *bitmap,int full_refresh)
{
int offs;
int charcode;
int sprite_transparency;
if (full_refresh)
segar_refresh = 1;
sprite_transparency=TRANSPARENCY_NONE;
/* If the background is turned on, refresh it first. */
if (segar_has_background)
{
/* for every character in the Video RAM, check if it has been modified */
/* since last time and update it accordingly. */
for (offs = videoram_size - 1;offs >= 0;offs--)
{
if ((segar_char_refresh) && (segar_dirtycharacter[videoram[offs]]))
dirtybuffer[offs]=1;
/* Redraw every background character if our palette or scene changed */
if ((dirtybuffer[offs]) || segar_refresh)
{
int sx,sy;
sx = 8 * (offs / 32);
sy = 8 * (31 - offs % 32);
if (segar_cocktail)
{
sx = 27*8 - sx;
sy = 31*8 - sy;
}
charcode = segar_mem_blookup[offs + segar_backscene] + segar_backoffset;
drawgfx(tmpbitmap,Machine->gfx[1],
charcode,((charcode & 0xF0)>>4),
segar_cocktail,segar_cocktail,sx,sy,
&Machine->drv->visible_area,TRANSPARENCY_NONE,0);
}
}
sprite_transparency=TRANSPARENCY_COLOR;
}
/* Refresh the "standard" graphics */
segar_common_screenrefresh(bitmap, sprite_transparency, TRANSPARENCY_NONE);
}
/***************************************************************************
---------------------------------------------------------------------------
Pig Newton Functions
---------------------------------------------------------------------------
***************************************************************************/
/***************************************************************************
These ports might control the background color for Pig Newton.
As you can see, my guessing obviously aren't quite right...
***************************************************************************/
void pignewt_back_color_w(int offset,int data)
{
static unsigned char red[] = {0x00, 0x24, 0x49, 0x6D, 0x92, 0xB6, 0xDB, 0xFF };
static unsigned char grn[] = {0x00, 0x24, 0x49, 0x6D, 0x92, 0xB6, 0xDB, 0xFF };
static unsigned char blu[] = {0x00, 0x55, 0xAA, 0xFF };
static unsigned int pignewt_bcolor_offset=0;
int r,g,b;
if (offset == 0)
{
pignewt_bcolor_offset = data;
}
else
{
b = blu[(data & 0xC0) >> 6];
g = grn[(data & 0x38) >> 3];
r = red[(data & 0x07)];
osd_modify_pen(Machine->pens[pignewt_bcolor_offset + 0x40 + 1],r,g,b);
}
}
/***************************************************************************
These ports control which background to draw for Pig Newton. They might
also control other video aspects, since without schematics the usage of
many of the data lines is indeterminate. Segar_backscene and segar_backoffset
are analogous to registers used to control bank-switching of the background
"videorom" ROMs and the background graphics ROMs, respectively.
If the background changed, refresh the screen.
***************************************************************************/
void pignewt_back_ports_w(int offset,int data)
{
unsigned int tempscene;
/* These are all guesses. There are some bits still being ignored! */
switch (offset)
{
case 1:
/* Bit D7 turns the background off and on? */
if ((data & 0x80) && (segar_has_background==0))
{
segar_has_background=1;
segar_refresh=1;
}
else if (((data & 0x80)==0) && (segar_has_background==1))
{
segar_has_background=0;
segar_refresh=1;
}
/* Bits D0-D1 help select the background? */
tempscene = (segar_backscene & 0x0C) | (data & 0x03);
if (segar_backscene != tempscene)
{
segar_backscene = tempscene;
segar_refresh=1;
}
break;
case 3:
/* Bits D0-D1 help select the background? */
tempscene = ((data << 2) & 0x0C) | (segar_backscene & 0x03);
if (segar_backscene != tempscene)
{
segar_backscene = tempscene;
segar_refresh=1;
}
break;
case 4:
if (segar_backoffset != (data & 0x03))
{
segar_backoffset = data & 0x03;
segar_refresh=1;
}
break;
}
}
/***************************************************************************
Special refresh for Pig Newton, this code refreshes the static background.
***************************************************************************/
void pignewt_vh_screenrefresh(struct osd_bitmap *bitmap,int full_refresh)
{
int offs;
int charcode;
int sprite_transparency;
unsigned long backoffs;
unsigned long backscene;
if (full_refresh)
segar_refresh = 1;
sprite_transparency=TRANSPARENCY_NONE;
/* If the background is turned on, refresh it first. */
if (segar_has_background)
{
/* for every character in the Video RAM, check if it has been modified */
/* since last time and update it accordingly. */
for (offs = videoram_size - 1;offs >= 0;offs--)
{
if ((segar_char_refresh) && (segar_dirtycharacter[videoram[offs]]))
dirtybuffer[offs]=1;
/* Redraw every background character if our palette or scene changed */
if ((dirtybuffer[offs]) || segar_refresh)
{
int sx,sy;
sx = 8 * (offs / 32);
sy = 8 * (31 - offs % 32);
if (segar_cocktail)
{
sx = 27*8 - sx;
sy = 31*8 - sy;
}
backscene = (segar_backscene & 0x0C) << 10;
backoffs = (offs & 0x01F) + ((offs & 0x3E0) << 2) + ((segar_backscene & 0x03) << 5);
charcode = segar_mem_blookup[backoffs + backscene] + (segar_backoffset * 0x100);
drawgfx(tmpbitmap,Machine->gfx[1],
charcode, 0,
segar_cocktail,segar_cocktail,sx,sy,
&Machine->drv->visible_area,TRANSPARENCY_NONE,0);
}
}
sprite_transparency=TRANSPARENCY_COLOR;
}
/* Refresh the "standard" graphics */
segar_common_screenrefresh(bitmap, sprite_transparency, TRANSPARENCY_NONE);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -