📄 atarisy1.c
字号:
redraw_playfield_chunk (tempbitmap, xpos, ypos, 1, vsize, TRANSPARENCY_PEN, 0, -1);
/* finally, copy this chunk to the real bitmap */
tclip.min_x = xpos;
tclip.max_x = xpos + 7;
tclip.min_y = ypos;
tclip.max_y = ypos + vsize * 8 - 1;
if (tclip.min_y < clip->min_y) tclip.min_y = clip->min_y;
if (tclip.max_y > clip->max_y) tclip.max_y = clip->max_y;
copybitmap (bitmap, tempbitmap, 0, 0, 0, 0, &tclip, TRANSPARENCY_THROUGH, palette_transparent_pen);
}
}
/***************************************************************************
Draw the game screen in the given osd_bitmap.
Do NOT call osd_update_display() from this function, it will be called by
the main emulation engine.
***************************************************************************/
/*
* playfield redraw function
*/
static void redraw_playfield_chunk (struct osd_bitmap *bitmap, int xpos, int ypos, int w, int h, int transparency, int transparency_color, int type)
{
struct rectangle clip;
int y, x;
/* make a clip */
clip.min_x = xpos;
clip.max_x = xpos + w * 8 - 1;
clip.min_y = ypos;
clip.max_y = ypos + h * 8 - 1;
/* round the positions */
xpos = (xpos - xscroll) / 8;
ypos = (ypos - yscroll) / 8;
/* loop over the rows */
for (y = ypos + h; y >= ypos; y--)
{
/* compute the scroll-adjusted y position */
int sy = (y * 8 + yscroll) & 0x1ff;
if (sy > 0x1f8) sy -= 0x200;
/* loop over the columns */
for (x = xpos + w; x >= xpos; x--)
{
/* compute the scroll-adjusted x position */
int sx = (x * 8 + xscroll) & 0x1ff;
if (sx > 0x1f8) sx -= 0x200;
{
/* process the data */
int data = pfmapped[(y & 0x3f) * 64 + (x & 0x3f)];
int color = LCOLOR (data);
/* draw */
if (type == -1)
drawgfx (bitmap, Machine->gfx[LBANK (data)], LPICT (data), color, LFLIP (data), 0,
sx, sy, &clip, transparency, transparency_color);
else if (type == -2)
{
if (color == (16 >> pf_map_shift))
drawgfx (bitmap, Machine->gfx[LBANK (data)], LPICT (data), color, LFLIP (data), 0,
sx, sy, &clip, transparency, transparency_color);
}
else
drawgfx (bitmap, Machine->gfx[LBANK (data)], LPICT (data), type, LFLIP (data), 0,
sx, sy, &clip, transparency, transparency_color);
}
}
}
}
/*************************************
*
* Generic System 1 refresh
*
*************************************/
void atarisys1_vh_screenrefresh(struct osd_bitmap *bitmap,int full_refresh)
{
unsigned char mo_map[32], al_map[8], pf_map[32];
int x, y, sx, sy, xoffs, yoffs, offs, i, *r;
struct atarisys1_mo_data modata;
int redraw_list[1024];
/* reset color tracking */
memset (mo_map, 0, sizeof (mo_map));
memset (pf_map, 0, sizeof (pf_map));
memset (al_map, 0, sizeof (al_map));
memset (palette_used_colors, PALETTE_COLOR_UNUSED, Machine->drv->total_colors * sizeof(unsigned char));
/* assign our special pen here */
memset (&palette_used_colors[1024], PALETTE_COLOR_TRANSPARENT, 16);
/* update color usage for the playfield */
for (offs = 0; offs < 64*64; offs++)
{
int data = pfmapped[offs];
int color = LCOLOR (data);
pf_map[color] = 1;
}
/* update color usage for the mo's */
atarigen_render_display_list (bitmap, atarisys1_calc_mo_colors, mo_map);
/* update color usage for the alphanumerics */
for (sy = 0; sy < YCHARS; sy++)
{
for (sx = 0, offs = sy * 64; sx < XCHARS; sx++, offs++)
{
int data = READ_WORD (&atarigen_alpharam[offs * 2]);
int color = (data >> 10) & 7;
al_map[color] = 1;
}
}
/* rebuild the palette */
for (i = 0; i < 32; i++)
{
if (pf_map[i])
memset (&palette_used_colors[256 + i * (16 << pf_map_shift)], PALETTE_COLOR_USED, 16 << pf_map_shift);
if (mo_map[i])
{
palette_used_colors[256 + i * (16 >> mo_map_shift)] = PALETTE_COLOR_TRANSPARENT;
memset (&palette_used_colors[256 + i * (16 >> mo_map_shift) + 1], PALETTE_COLOR_USED, (16 >> mo_map_shift) - 1);
}
}
for (i = 0; i < 8; i++)
if (al_map[i])
memset (&palette_used_colors[0 + i * 4], PALETTE_COLOR_USED, 4);
/* always remap the transluscent colors */
memset (&palette_used_colors[768], PALETTE_COLOR_USED, 16 >> mo_map_shift);
if (palette_recalc ())
{
for (i = atarigen_playfieldram_size / 2 - 1; i >= 0; i--)
pfmapped[i] |= LDIRTYFLAG;
}
/* load the scroll values from the start of the previous frame */
if (scrolllist_end)
{
xscroll = scrolllist[0] >> 12;
yscroll = scrolllist[0];
}
else
{
xscroll = READ_WORD (&atarigen_hscroll[0]);
yscroll = READ_WORD (&atarigen_vscroll[0]);
}
xscroll = -(xscroll & 0x1ff);
yscroll = -(yscroll & 0x1ff);
/*
*---------------------------------------------------------------------------------
*
* Playfield encoding
*
* 1 16-bit word is used
*
* Bits 0-14 = index of the image; a 16th bit is pulled from the playfield
* bank selection bit. The upper 8 bits of this 16-bit index
* are passed through a pair of lookup PROMs to select which
* graphics bank and color to use
* Bit 15 = horizontal flip
*
*---------------------------------------------------------------------------------
*/
/* update only the portion of the playfield that's visible. */
xoffs = (-xscroll / 8);
yoffs = (-yscroll / 8);
/* loop over the visible Y region */
for (y = yoffs + YCHARS + 1; y >= yoffs; y--)
{
sy = y & 63;
/* loop over the visible X region */
for (x = xoffs + XCHARS + 1; x >= xoffs; x--)
{
int data;
/* read the data word */
sx = x & 63;
offs = sy * 64 + sx;
data = pfmapped[offs];
/* rerender if dirty */
if (LDIRTY (data))
{
int bank = LBANK (data);
if (bank)
drawgfx (playfieldbitmap, Machine->gfx[bank], LPICT (data), LCOLOR (data), LFLIP (data), 0,
8*sx, 8*sy, 0, TRANSPARENCY_NONE, 0);
pfmapped[offs] = data & ~LDIRTYFLAG;
}
}
}
/* copy the playfield to the destination */
copyscrollbitmap (bitmap, playfieldbitmap, 1, &xscroll, 1, &yscroll, &Machine->drv->visible_area,
TRANSPARENCY_NONE, 0);
/* prepare the motion object data structure */
modata.pcolor = READ_WORD (&atarisys1_prioritycolor[0]) & 0xff;
modata.redraw_list = modata.redraw = redraw_list;
/* render the motion objects */
atarigen_render_display_list (bitmap, atarisys1_render_mo, &modata);
/* redraw playfield tiles with higher priority */
for (r = modata.redraw_list; r < modata.redraw; r++)
{
int val = *r;
int xpos = (val >> 23) & 0x1ff;
int ypos = (val >> 14) & 0x1ff;
int h = val & 0x1f;
redraw_playfield_chunk (bitmap, xpos, ypos, 1, h, TRANSPARENCY_PENS, ~modata.pcolor, -2);
}
/*
*---------------------------------------------------------------------------------
*
* Alpha layer encoding
*
* 1 16-bit word is used
*
* Bits 0-9 = index of the character
* Bits 10-12 = color
* Bit 13 = transparency
*
*---------------------------------------------------------------------------------
*/
/* redraw the alpha layer completely */
for (sy = 0; sy < YCHARS; sy++)
{
for (sx = 0, offs = sy*64; sx < XCHARS; sx++, offs++)
{
int data = READ_WORD (&atarigen_alpharam[offs*2]);
int pict = (data & 0x3ff);
if (pict || (data & 0x2000))
{
int color = ((data >> 10) & 7);
drawgfx (bitmap, Machine->gfx[0],
pict, color,
0, 0,
8*sx, 8*sy,
0,
(data & 0x2000) ? TRANSPARENCY_NONE : TRANSPARENCY_PEN, 0);
}
}
}
}
/*************************************
*
* Road Blasters refresh
*
*************************************/
void roadblst_vh_screenrefresh(struct osd_bitmap *bitmap,int full_refresh)
{
unsigned char mo_map[32], al_map[8];
unsigned short pf_map[32];
int i, y, sx, sy, offs, shift, lasty, *scroll;
struct atarisys1_mo_data modata;
/* reset color tracking */
memset (mo_map, 0, sizeof (mo_map));
memset (pf_map, 0, sizeof (pf_map));
memset (al_map, 0, sizeof (al_map));
memset (palette_used_colors, PALETTE_COLOR_UNUSED, Machine->drv->total_colors * sizeof(unsigned char));
/* assign our special pen here */
memset (&palette_used_colors[1024], PALETTE_COLOR_TRANSPARENT, 16);
/* update color usage for the playfield */
for (offs = 0; offs < 64*64; offs++)
{
int data = pfmapped[offs];
int color = LCOLOR (data);
int bank = LBANK (data);
int pict = LPICT (data);
if (bank == 1)
{
pf_map[color * 4 + 0] |= roadblst_pen_usage[pict * 4 + 0];
pf_map[color * 4 + 1] |= roadblst_pen_usage[pict * 4 + 1];
pf_map[color * 4 + 2] |= roadblst_pen_usage[pict * 4 + 2];
pf_map[color * 4 + 3] |= roadblst_pen_usage[pict * 4 + 3];
}
else
pf_map[color] |= Machine->gfx[bank]->pen_usage[pict];
}
/* update color usage for the mo's */
atarigen_render_display_list (bitmap, atarisys1_calc_mo_colors, mo_map);
/* update color usage for the alphanumerics */
for (sy = 0; sy < YCHARS; sy++)
{
for (sx = 0, offs = sy * 64; sx < XCHARS; sx++, offs++)
{
int data = READ_WORD (&atarigen_alpharam[offs * 2]);
int color = (data >> 10) & 7;
al_map[color] = 1;
}
}
/* rebuild the palette */
for (i = 0; i < 32; i++)
{
if (pf_map[i])
{
int j;
for (j = 0; j < 16; j++)
if (pf_map[i] & (1 << j))
palette_used_colors[256 + i * 16 + j] = PALETTE_COLOR_USED;
}
if (mo_map[i])
{
palette_used_colors[256 + i * (16 >> mo_map_shift)] = PALETTE_COLOR_TRANSPARENT;
memset (&palette_used_colors[256 + i * 16 + 1], PALETTE_COLOR_USED, 15);
}
}
for (i = 0; i < 8; i++)
if (al_map[i])
memset (&palette_used_colors[0 + i * 4], PALETTE_COLOR_USED, 4);
if (palette_recalc ())
{
for (i = atarigen_playfieldram_size / 2 - 1; i >= 0; i--)
pfmapped[i] |= LDIRTYFLAG;
}
/*
*---------------------------------------------------------------------------------
*
* Playfield encoding
*
* 1 16-bit word is used
*
* Bits 0-14 = index of the image; a 16th bit is pulled from the playfield
* bank selection bit. The upper 8 bits of this 16-bit index
* are passed through a pair of lookup PROMs to select which
* graphics bank and color to use
* Bit 15 = horizontal flip
*
*---------------------------------------------------------------------------------
*/
/* loop over the entire Y region */
for (sy = offs = 0; sy < 64; sy++)
{
/* loop over the entire X region */
for (sx = 0; sx < 64; sx++, offs++)
{
int data = pfmapped[offs];
/* things only get tricky if we're not already dirty */
if (LDIRTY (data))
{
int color = LCOLOR (data);
int gfxbank = LBANK (data);
/* draw this character */
drawgfx (playfieldbitmap, Machine->gfx[gfxbank], LPICT (data), color, LFLIP (data), 0,
8 * sx, 8 * sy, 0, TRANSPARENCY_NONE, 0);
pfmapped[offs] = data & ~LDIRTYFLAG;
}
}
}
/* WARNING: this code won't work rotated! */
shift = bitmap->depth / 8 - 1;
lasty = -1;
scroll = (int *)scrolllist;
/* finish the scrolling list from the previous frame */
xscroll = READ_WORD (&atarigen_hscroll[0]) & 0x1ff;
yscroll = READ_WORD (&atarigen_vscroll[0]) & 0x1ff;
offs = (xscroll << 12) + yscroll;
for (y = scrolllist_end; y < YDIM; y++)
scrolllist[y] = offs;
/* loop over and copy the data row by row */
for (y = 0; y < YDIM; y++)
{
int scrollx = (*scroll >> 12) & 0x1ff;
int scrolly = *scroll++ & 0x1ff;
int dy;
/* when a write to the scroll register occurs, the counter is reset */
if (scrolly != lasty)
{
offs = y;
lasty = scrolly;
}
dy = (scrolly + y - offs) & 0x1ff;
/* handle the wrap around case */
if (scrollx + XDIM > 0x200)
{
int chunk = 0x200 - scrollx;
memcpy (&bitmap->line[y][0], &playfieldbitmap->line[dy][scrollx << shift], chunk << shift);
memcpy (&bitmap->line[y][chunk << shift], &playfieldbitmap->line[dy][0], (XDIM - chunk) << shift);
}
else
memcpy (&bitmap->line[y][0], &playfieldbitmap->line[dy][scrollx << shift], XDIM << shift);
}
/* prepare the motion object data structure */
modata.pcolor = 0;
modata.redraw_list = modata.redraw = 0;
/* render the motion objects */
atarigen_render_display_list (bitmap, atarisys1_render_mo, &modata);
/*
*---------------------------------------------------------------------------------
*
* Alpha layer encoding
*
* 1 16-bit word is used
*
* Bits 0-9 = index of the character
* Bits 10-12 = color
* Bit 13 = transparency
*
*---------------------------------------------------------------------------------
*/
for (sy = 0; sy < YCHARS; sy++)
{
for (sx = 0, offs = sy*64; sx < XCHARS; sx++, offs++)
{
int data = READ_WORD (&atarigen_alpharam[offs*2]);
int pict = (data & 0x3ff);
if (pict || (data & 0x2000))
{
int color = ((data >> 10) & 7);
drawgfx (bitmap, Machine->gfx[0],
pict, color,
0, 0,
8*sx, 8*sy,
0,
(data & 0x2000) ? TRANSPARENCY_NONE : TRANSPARENCY_PEN, 0);
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -