1 /***************************************************************************
2 
3   vidhrdw.c
4 
5   Functions to emulate the video hardware of the machine.
6 
7 ***************************************************************************/
8 #include "driver.h"
9 
10 
11 UINT8 *beg_spriteram1;
12 UINT8 *beg_spriteram2;
13 
14 
15 static UINT32 vidram_bank = 0;
16 static UINT32 plane_selected = 0;
17 static UINT32 plane_visible = 0;
18 static UINT8 *vidram;
19 
20 
21 static struct mame_bitmap *tmp_bitmap[4];
22 
WRITE_HANDLER(beg_palette_w)23 WRITE_HANDLER(beg_palette_w)
24 {
25 	int color;
26 
27 	paletteram[offset] = data;
28 	color = paletteram[offset&0x3ff] | (paletteram[0x400+(offset&0x3ff)] << 8);
29 	palette_set_color(offset&0x3ff, color&0xf0, (color&0xf)<<4, (color&0xf00)>>4);
30 }
31 
WRITE_HANDLER(beg_gfxcontrol_w)32 WRITE_HANDLER( beg_gfxcontrol_w )
33 {
34 /* bits used: 0,1,2,3
35  0 and 2 select plane,
36  1 and 3 select visible plane,
37 */
38 	plane_selected=((data & 4)>>1) | (data&1);
39 	plane_visible =((data & 8)>>2) | ((data&2)>>1);
40 }
41 
WRITE_HANDLER(bigevglf_vidram_addr_w)42 WRITE_HANDLER( bigevglf_vidram_addr_w )
43 {
44 	vidram_bank = (data & 0xff) * 0x100;
45 }
46 
WRITE_HANDLER(bigevglf_vidram_w)47 WRITE_HANDLER( bigevglf_vidram_w )
48 {
49 	UINT32 x,y,o;
50 	o = vidram_bank + offset;
51 	vidram[ o+0x10000*plane_selected ] = data;
52 	y = o >>8;
53 	x = (o & 255);
54 	plot_pixel(tmp_bitmap[plane_selected],x,y,data );
55 }
56 
READ_HANDLER(bigevglf_vidram_r)57 READ_HANDLER( bigevglf_vidram_r )
58 {
59 	return vidram[ 0x10000 * plane_selected + vidram_bank + offset];
60 }
61 
VIDEO_START(bigevglf)62 VIDEO_START( bigevglf )
63 {
64 	tmp_bitmap[0] = auto_bitmap_alloc(Machine->drv->screen_width,Machine->drv->screen_height);
65 	tmp_bitmap[1] = auto_bitmap_alloc(Machine->drv->screen_width,Machine->drv->screen_height);
66 	tmp_bitmap[2] = auto_bitmap_alloc(Machine->drv->screen_width,Machine->drv->screen_height);
67 	tmp_bitmap[3] = auto_bitmap_alloc(Machine->drv->screen_width,Machine->drv->screen_height);
68 	vidram = auto_malloc(0x100*0x100 * 4);
69 	return 0;
70 }
71 
beg_draw_sprites(struct mame_bitmap * bitmap,const struct rectangle * cliprect)72 void beg_draw_sprites(struct mame_bitmap *bitmap, const struct rectangle *cliprect)
73 {
74 	int i,j;
75 	for (i = 0xc0-4; i >= 0; i-=4)
76 	{
77 		int code,sx,sy;
78 		code = beg_spriteram2[i+1];
79 		sx = beg_spriteram2[i+3];
80 		sy = 200-beg_spriteram2[i];
81 		for(j=0;j<16;j++)
82 			drawgfx(bitmap,Machine->gfx[0],
83 				beg_spriteram1[(code<<4)+j]+((beg_spriteram1[0x400+(code<<4)+j]&0xf)<<8),
84 				beg_spriteram2[i+2] & 0xf,
85 				0,0,
86 				sx+((j&1)<<3),sy+((j>>1)<<3),
87 				cliprect,TRANSPARENCY_PEN,0);
88 	}
89 }
90 
VIDEO_UPDATE(bigevglf)91 VIDEO_UPDATE( bigevglf )
92 {
93 	copybitmap(bitmap,tmp_bitmap[ plane_visible ],0,0,0,0,cliprect,TRANSPARENCY_NONE, 0);
94 	beg_draw_sprites(bitmap,cliprect);
95 }
96