12
12
***************************************************************************/
14
14
#include "driver.h"
15
#include "vidhrdw/generic.h"
18
unsigned char *yard_scroll_x_low;
19
unsigned char *yard_scroll_x_high;
20
unsigned char *yard_scroll_y_low;
21
unsigned char *yard_score_panel_disabled;
22
static struct mame_bitmap *scroll_panel_bitmap;
16
UINT8 *yard_scroll_x_low;
17
UINT8 *yard_scroll_x_high;
18
UINT8 *yard_scroll_y_low;
19
UINT8 *yard_score_panel_disabled;
20
static mame_bitmap *scroll_panel_bitmap;
22
static tilemap *bg_tilemap;
24
24
#define SCROLL_PANEL_WIDTH (14*4)
26
25
#define RADAR_PALETTE_BASE (256+16)
26
#define TOTAL_COLORS(gfxn) (Machine->gfx[gfxn]->total_colors * Machine->gfx[gfxn]->color_granularity)
27
#define COLOR(gfxn,offs) (colortable[Machine->drv->gfxdecodeinfo[gfxn].color_codes_start + offs])
28
static struct rectangle panelvisiblearea =
29
static rectangle clippanel =
34
static struct rectangle panelvisibleareaflip =
35
static rectangle clippanelflip =
41
41
/***************************************************************************
43
43
Convert the color PROMs into a more useable format.
169
/***************************************************************************
171
Start the video hardware emulation.
173
***************************************************************************/
176
if ((dirtybuffer = auto_malloc(videoram_size)) == 0)
178
memset(dirtybuffer,1,videoram_size);
180
if ((tmpbitmap = auto_bitmap_alloc(Machine->drv->screen_width*2,Machine->drv->screen_height)) == 0)
183
if ((scroll_panel_bitmap = auto_bitmap_alloc(SCROLL_PANEL_WIDTH,Machine->drv->screen_height)) == 0)
192
WRITE8_HANDLER( yard_flipscreen_w )
194
/* screen flip is handled both by software and hardware */
195
data ^= ~readinputport(4) & 1;
197
flip_screen_set(data & 1);
199
coin_counter_w(0,data & 0x02);
200
coin_counter_w(1,data & 0x20);
158
WRITE8_HANDLER( yard_videoram_w )
160
if (videoram[offset] != data)
162
videoram[offset] = data;
163
tilemap_mark_tile_dirty(bg_tilemap, offset / 2);
204
167
WRITE8_HANDLER( yard_scroll_panel_w )
219
182
col = (data >> i) & 0x11;
220
183
col = ((col >> 3) | col) & 3;
222
plot_pixel(scroll_panel_bitmap, sx + i, sy, Machine->pens[RADAR_PALETTE_BASE + (sy & 0xfc) + col]);
185
plot_pixel(scroll_panel_bitmap, sx + i, sy,
186
Machine->pens[RADAR_PALETTE_BASE + (sy & 0xfc) + col]);
227
/***************************************************************************
229
Draw the game screen in the given mame_bitmap.
230
Do NOT call osd_update_display() from this function, it will be called by
231
the main emulation engine.
233
***************************************************************************/
190
static void yard_get_bg_tile_info(int tile_index)
192
int offs = tile_index * 2;
193
int attr = videoram[offs + 1];
194
int code = videoram[offs] + ((attr & 0xc0) << 2);
195
int color = attr & 0x1f;
196
int flags = (attr & 0x20) ? TILE_FLIPX : 0;
198
SET_TILE_INFO(0, code, color, flags)
201
static UINT32 yard_tilemap_scan_rows( UINT32 col, UINT32 row, UINT32 num_cols, UINT32 num_rows )
203
/* logical (col,row) -> memory offset */
205
return (row+32)*32 + col-32;
212
bg_tilemap = tilemap_create(yard_get_bg_tile_info, yard_tilemap_scan_rows,
213
TILEMAP_OPAQUE, 8, 8, 64, 32);
218
if ((scroll_panel_bitmap = auto_bitmap_alloc(SCROLL_PANEL_WIDTH, Machine->drv->screen_height)) == 0)
224
#define DRAW_SPRITE(code, sy) drawgfx(bitmap, Machine->gfx[1], code, color, flipx, flipy, sx, sy, cliprect, TRANSPARENCY_COLOR, 256);
226
static void yard_draw_sprites( mame_bitmap *bitmap, const rectangle *cliprect )
239
if (get_vh_global_attribute_changed())
241
memset(dirtybuffer,1,videoram_size);
245
/* for every character in the Video RAM, check if it has been modified */
246
/* since last time and update it accordingly. */
247
for (offs = videoram_size-2;offs >= 0;offs -= 2)
249
if (dirtybuffer[offs] || dirtybuffer[offs+1])
254
dirtybuffer[offs] = 0;
255
dirtybuffer[offs+1] = 0;
259
flipx = videoram[offs+1] & 0x20;
274
drawgfx(tmpbitmap,Machine->gfx[0],
275
videoram[offs] + ((videoram[offs+1] & 0xc0) << 2),
276
videoram[offs+1] & 0x1f,
279
0,TRANSPARENCY_NONE,0);
283
/* copy the temporary bitmap to the screen */
285
int scroll_x,scroll_y;
287
scroll_x = (*yard_scroll_x_high * 0x100) + *yard_scroll_x_low;
292
scroll_y = *yard_scroll_y_low ;
296
scroll_x = -scroll_x;
297
scroll_y = -*yard_scroll_y_low ;
300
copyscrollbitmap(bitmap,tmpbitmap,1,&scroll_x,1,&scroll_y,&Machine->visible_area,TRANSPARENCY_NONE,0);
304
for (offs = spriteram_size - 4;offs >= 0;offs -= 4)
306
int code1,code2,bank,sx,sy1,sy2,flipx,flipy;
309
bank = (spriteram[offs + 1] & 0x20) >> 5;
310
code1 = spriteram[offs + 2] & 0xbf;
311
sx = spriteram[offs + 3];
312
sy1 = 241 - spriteram[offs];
313
flipx = spriteram[offs + 1] & 0x40;
314
flipy = spriteram[offs + 1] & 0x80;
230
for (offs = spriteram_size - 4; offs >= 0; offs -= 4)
232
int attr = spriteram[offs + 1];
233
int bank = (attr & 0x20) >> 5;
234
int code1 = spriteram[offs + 2] & 0xbf;
236
int color = attr & 0x1f;
237
int flipx = attr & 0x40;
238
int flipy = attr & 0x80;
239
int sx = spriteram[offs + 3];
240
int sy1 = 241 - spriteram[offs];
336
263
sy2 = sy1 + 0x10;
339
drawgfx(bitmap,Machine->gfx[1],
341
spriteram[offs + 1] & 0x1f,
344
&Machine->visible_area,TRANSPARENCY_COLOR,256);
346
drawgfx(bitmap,Machine->gfx[1],
348
spriteram[offs + 1] & 0x1f,
351
&Machine->visible_area,TRANSPARENCY_COLOR,256);
266
DRAW_SPRITE(code1 + 256 * bank, sy1)
267
DRAW_SPRITE(code2 + 256 * bank, sy2)
355
/* draw the static bitmapped area to screen */
271
static void yard_draw_panel( mame_bitmap *bitmap, const rectangle *cliprect )
356
273
if (! *yard_score_panel_disabled)
360
xpos = flip_screen ? Machine->visible_area.min_x - 8 :
361
Machine->visible_area.max_x + 1 - SCROLL_PANEL_WIDTH;
363
copybitmap(bitmap,scroll_panel_bitmap,flip_screen,flip_screen,
365
flip_screen ? &panelvisibleareaflip : &panelvisiblearea,TRANSPARENCY_NONE,0);
275
int sx = flip_screen ? cliprect->min_x - 8 : cliprect->max_x + 1 - SCROLL_PANEL_WIDTH;
277
copybitmap(bitmap, scroll_panel_bitmap, flip_screen, flip_screen, sx, 0,
278
flip_screen ? &clippanelflip : &clippanel, TRANSPARENCY_NONE, 0);
284
tilemap_set_scrollx(bg_tilemap, 0, (*yard_scroll_x_high * 0x100) + *yard_scroll_x_low);
285
tilemap_set_scrolly(bg_tilemap, 0, *yard_scroll_y_low);
287
tilemap_draw(bitmap, cliprect, bg_tilemap, 0, 0);
288
yard_draw_sprites(bitmap, cliprect);
289
yard_draw_panel(bitmap, cliprect);