1 /***************************************************************************
2 
3   vidhrdw.c
4 
5   Functions to emulate the video hardware of the machine.
6 
7 ***************************************************************************/
8 
9 #include "driver.h"
10 #include "vidhrdw/generic.h"
11 
12 
13 #define TOP_MONITOR_ROWS 28
14 #define BOTTOM_MONITOR_ROWS 28
15 
16 #define BIGSPRITE_WIDTH 128
17 #define BIGSPRITE_HEIGHT 256
18 #define ARMWREST_BIGSPRITE_WIDTH 256
19 #define ARMWREST_BIGSPRITE_HEIGHT 128
20 
21 unsigned char *punchout_videoram2;
22 size_t punchout_videoram2_size;
23 unsigned char *punchout_bigsprite1ram;
24 size_t punchout_bigsprite1ram_size;
25 unsigned char *punchout_bigsprite2ram;
26 size_t punchout_bigsprite2ram_size;
27 unsigned char *punchout_scroll;
28 unsigned char *punchout_bigsprite1;
29 unsigned char *punchout_bigsprite2;
30 unsigned char *punchout_palettebank;
31 static unsigned char *dirtybuffer2,*bs1dirtybuffer,*bs2dirtybuffer;
32 static struct mame_bitmap *bs1tmpbitmap,*bs2tmpbitmap;
33 
34 static int top_palette_bank,bottom_palette_bank;
35 
36 static struct rectangle topvisiblearea =
37 {
38 	0*8, 32*8-1,
39 	0*8, TOP_MONITOR_ROWS*8-1
40 };
41 static struct rectangle bottomvisiblearea =
42 {
43 	0*8, 32*8-1,
44 	TOP_MONITOR_ROWS*8, (TOP_MONITOR_ROWS+BOTTOM_MONITOR_ROWS)*8-1
45 };
46 static struct rectangle backgroundvisiblearea =
47 {
48 	0*8, 64*8-1,
49 	TOP_MONITOR_ROWS*8, (TOP_MONITOR_ROWS+BOTTOM_MONITOR_ROWS)*8-1
50 };
51 
52 
53 
54 /***************************************************************************
55 
56   Convert the color PROMs into a more useable format.
57 
58   Punch Out has a six 512x4 palette PROMs (one per gun; three for the top
59   monitor chars, three for everything else).
60   The PROMs are connected to the RGB output this way:
61 
62   bit 3 -- 240 ohm resistor -- inverter  -- RED/GREEN/BLUE
63         -- 470 ohm resistor -- inverter  -- RED/GREEN/BLUE
64         -- 1  kohm resistor -- inverter  -- RED/GREEN/BLUE
65   bit 0 -- 2  kohm resistor -- inverter  -- RED/GREEN/BLUE
66 
67 ***************************************************************************/
convert_palette(const unsigned char * color_prom)68 static void convert_palette(const unsigned char *color_prom)
69 {
70 	int i;
71 
72 
73 	for (i = 0;i < 1024;i++)
74 	{
75 		int bit0,bit1,bit2,bit3,r,g,b;
76 
77 
78 		bit0 = (color_prom[0] >> 0) & 0x01;
79 		bit1 = (color_prom[0] >> 1) & 0x01;
80 		bit2 = (color_prom[0] >> 2) & 0x01;
81 		bit3 = (color_prom[0] >> 3) & 0x01;
82 		r = 255 - (0x10 * bit0 + 0x21 * bit1 + 0x46 * bit2 + 0x88 * bit3);
83 		bit0 = (color_prom[1024] >> 0) & 0x01;
84 		bit1 = (color_prom[1024] >> 1) & 0x01;
85 		bit2 = (color_prom[1024] >> 2) & 0x01;
86 		bit3 = (color_prom[1024] >> 3) & 0x01;
87 		g = 255 - (0x10 * bit0 + 0x21 * bit1 + 0x46 * bit2 + 0x88 * bit3);
88 		bit0 = (color_prom[2*1024] >> 0) & 0x01;
89 		bit1 = (color_prom[2*1024] >> 1) & 0x01;
90 		bit2 = (color_prom[2*1024] >> 2) & 0x01;
91 		bit3 = (color_prom[2*1024] >> 3) & 0x01;
92 		b = 255 - (0x10 * bit0 + 0x21 * bit1 + 0x46 * bit2 + 0x88 * bit3);
93 
94 		palette_set_color(i,r,g,b);
95 		color_prom++;
96 	}
97 
98 	/* reserve the last color for the transparent pen (none of the game colors has */
99 	/* these RGB components) */
100 	palette_set_color(1024,240,240,240);
101 }
102 
103 
104 /* these depend on jumpers on the board and change from game to game */
105 static int gfx0inv,gfx1inv,gfx2inv,gfx3inv;
106 
PALETTE_INIT(punchout)107 PALETTE_INIT( punchout )
108 {
109 	int i;
110 	#define TOTAL_COLORS(gfxn) (Machine->gfx[gfxn]->total_colors * Machine->gfx[gfxn]->color_granularity)
111 	#define COLOR(gfxn,offs) (colortable[Machine->drv->gfxdecodeinfo[gfxn].color_codes_start + (offs)])
112 
113 
114 	convert_palette(color_prom);
115 
116 
117 	/* top monitor chars */
118 	for (i = 0;i < TOTAL_COLORS(0);i++)
119 		COLOR(0,i ^ gfx0inv) = i;
120 
121 	/* bottom monitor chars */
122 	for (i = 0;i < TOTAL_COLORS(1);i++)
123 		COLOR(1,i ^ gfx1inv) = i + 512;
124 
125 	/* big sprite #1 */
126 	for (i = 0;i < TOTAL_COLORS(2);i++)
127 	{
128 		if (i % 8 == 0) COLOR(2,i ^ gfx2inv) = 1024;	/* transparent */
129 		else COLOR(2,i ^ gfx2inv) = i + 512;
130 	}
131 
132 	/* big sprite #2 */
133 	for (i = 0;i < TOTAL_COLORS(3);i++)
134 	{
135 		if (i % 4 == 0) COLOR(3,i ^ gfx3inv) = 1024;	/* transparent */
136 		else COLOR(3,i ^ gfx3inv) = i + 512;
137 	}
138 }
139 
PALETTE_INIT(armwrest)140 PALETTE_INIT( armwrest )
141 {
142 	int i;
143 	#define TOTAL_COLORS(gfxn) (Machine->gfx[gfxn]->total_colors * Machine->gfx[gfxn]->color_granularity)
144 	#define COLOR(gfxn,offs) (colortable[Machine->drv->gfxdecodeinfo[gfxn].color_codes_start + (offs)])
145 
146 
147 	convert_palette(color_prom);
148 
149 
150 	/* top monitor / bottom monitor backround chars */
151 	for (i = 0;i < TOTAL_COLORS(0);i++)
152 		COLOR(0,i) = i;
153 
154 	/* bottom monitor foreground chars */
155 	for (i = 0;i < TOTAL_COLORS(1);i++)
156 		COLOR(1,i) = i + 512;
157 
158 	/* big sprite #1 */
159 	for (i = 0;i < TOTAL_COLORS(2);i++)
160 	{
161 		if (i % 8 == 7) COLOR(2,i) = 1024;	/* transparent */
162 		else COLOR(2,i) = i + 512;
163 	}
164 
165 	/* big sprite #2 - pen order is inverted */
166 	for (i = 0;i < TOTAL_COLORS(3);i++)
167 	{
168 		if (i % 4 == 3) COLOR(3,i ^ 3) = 1024;	/* transparent */
169 		else COLOR(3,i ^ 3) = i + 512;
170 	}
171 }
172 
173 
174 
gfx_fix(void)175 static void gfx_fix(void)
176 {
177 	/* one graphics ROM (4v) doesn't */
178 	/* exist but must be seen as a 0xff fill for colors to come out properly */
179 	memset(memory_region(REGION_GFX3) + 0x2c000,0xff,0x4000);
180 }
181 
DRIVER_INIT(punchout)182 DRIVER_INIT( punchout )
183 {
184 	gfx_fix();
185 
186 	gfx0inv = 0x03;
187 	gfx1inv = 0xfc;
188 	gfx2inv = 0xff;
189 	gfx3inv = 0xfc;
190 }
191 
DRIVER_INIT(spnchout)192 DRIVER_INIT( spnchout )
193 {
194 	gfx_fix();
195 
196 	gfx0inv = 0x00;
197 	gfx1inv = 0xff;
198 	gfx2inv = 0xff;
199 	gfx3inv = 0xff;
200 }
201 
DRIVER_INIT(spnchotj)202 DRIVER_INIT( spnchotj )
203 {
204 	gfx_fix();
205 
206 	gfx0inv = 0xfc;
207 	gfx1inv = 0xff;
208 	gfx2inv = 0xff;
209 	gfx3inv = 0xff;
210 }
211 
DRIVER_INIT(armwrest)212 DRIVER_INIT( armwrest )
213 {
214 	gfx_fix();
215 
216 	/* also, ROM 2k is enabled only when its top half is accessed. The other half must */
217 	/* be seen as a 0xff fill for colors to come out properly */
218 	memset(memory_region(REGION_GFX2) + 0x08000,0xff,0x2000);
219 }
220 
221 
222 
223 
224 /***************************************************************************
225 
226   Start the video hardware emulation.
227 
228 ***************************************************************************/
VIDEO_START(punchout)229 VIDEO_START( punchout )
230 {
231 	if ((dirtybuffer = auto_malloc(videoram_size)) == 0)
232 		return 1;
233 	memset(dirtybuffer,1,videoram_size);
234 
235 	if ((dirtybuffer2 = auto_malloc(punchout_videoram2_size)) == 0)
236 		return 1;
237 	memset(dirtybuffer2,1,punchout_videoram2_size);
238 
239 	if ((tmpbitmap = auto_bitmap_alloc(512,480)) == 0)
240 		return 1;
241 
242 	if ((bs1dirtybuffer = auto_malloc(punchout_bigsprite1ram_size)) == 0)
243 		return 1;
244 	memset(bs1dirtybuffer,1,punchout_bigsprite1ram_size);
245 
246 	if ((bs1tmpbitmap = auto_bitmap_alloc(BIGSPRITE_WIDTH,BIGSPRITE_HEIGHT)) == 0)
247 		return 1;
248 
249 	if ((bs2dirtybuffer = auto_malloc(punchout_bigsprite2ram_size)) == 0)
250 		return 1;
251 	memset(bs2dirtybuffer,1,punchout_bigsprite2ram_size);
252 
253 	if ((bs2tmpbitmap = auto_bitmap_alloc(BIGSPRITE_WIDTH,BIGSPRITE_HEIGHT)) == 0)
254 		return 1;
255 
256 	return 0;
257 }
258 
VIDEO_START(armwrest)259 VIDEO_START( armwrest )
260 {
261 	if ((dirtybuffer = auto_malloc(videoram_size)) == 0)
262 		return 1;
263 	memset(dirtybuffer,1,videoram_size);
264 
265 	if ((dirtybuffer2 = auto_malloc(punchout_videoram2_size)) == 0)
266 		return 1;
267 	memset(dirtybuffer2,1,punchout_videoram2_size);
268 
269 	if ((tmpbitmap = auto_bitmap_alloc(512,480)) == 0)
270 		return 1;
271 
272 	if ((bs1dirtybuffer = auto_malloc(punchout_bigsprite1ram_size)) == 0)
273 		return 1;
274 	memset(bs1dirtybuffer,1,punchout_bigsprite1ram_size);
275 
276 	if ((bs1tmpbitmap = auto_bitmap_alloc(ARMWREST_BIGSPRITE_WIDTH,ARMWREST_BIGSPRITE_HEIGHT)) == 0)
277 		return 1;
278 
279 	if ((bs2dirtybuffer = auto_malloc(punchout_bigsprite2ram_size)) == 0)
280 		return 1;
281 	memset(bs2dirtybuffer,1,punchout_bigsprite2ram_size);
282 
283 	if ((bs2tmpbitmap = auto_bitmap_alloc(BIGSPRITE_WIDTH,BIGSPRITE_HEIGHT)) == 0)
284 		return 1;
285 
286 	return 0;
287 }
288 
289 
290 
WRITE_HANDLER(punchout_videoram2_w)291 WRITE_HANDLER( punchout_videoram2_w )
292 {
293 	if (punchout_videoram2[offset] != data)
294 	{
295 		dirtybuffer2[offset] = 1;
296 
297 		punchout_videoram2[offset] = data;
298 	}
299 }
300 
WRITE_HANDLER(punchout_bigsprite1ram_w)301 WRITE_HANDLER( punchout_bigsprite1ram_w )
302 {
303 	if (punchout_bigsprite1ram[offset] != data)
304 	{
305 		bs1dirtybuffer[offset] = 1;
306 
307 		punchout_bigsprite1ram[offset] = data;
308 	}
309 }
310 
WRITE_HANDLER(punchout_bigsprite2ram_w)311 WRITE_HANDLER( punchout_bigsprite2ram_w )
312 {
313 	if (punchout_bigsprite2ram[offset] != data)
314 	{
315 		bs2dirtybuffer[offset] = 1;
316 
317 		punchout_bigsprite2ram[offset] = data;
318 	}
319 }
320 
321 
322 
WRITE_HANDLER(punchout_palettebank_w)323 WRITE_HANDLER( punchout_palettebank_w )
324 {
325 	*punchout_palettebank = data;
326 
327 	if (top_palette_bank != ((data >> 1) & 0x01))
328 	{
329 		top_palette_bank = (data >> 1) & 0x01;
330 		memset(dirtybuffer,1,videoram_size);
331 	}
332 	if (bottom_palette_bank != ((data >> 0) & 0x01))
333 	{
334 		bottom_palette_bank = (data >> 0) & 0x01;
335 		memset(dirtybuffer2,1,punchout_videoram2_size);
336 		memset(bs1dirtybuffer,1,punchout_bigsprite1ram_size);
337 		memset(bs2dirtybuffer,1,punchout_bigsprite2ram_size);
338 	}
339 }
340 
341 
342 
343 /***************************************************************************
344 
345   Draw the game screen in the given mame_bitmap.
346   Do NOT call osd_update_display() from this function, it will be called by
347   the main emulation engine.
348 
349 ***************************************************************************/
VIDEO_UPDATE(punchout)350 VIDEO_UPDATE( punchout )
351 {
352 	int offs;
353 
354 
355 	/* for every character in the Video RAM, check if it has been modified */
356 	/* since last time and update it accordingly. */
357 	for (offs = videoram_size - 2;offs >= 0;offs -= 2)
358 	{
359 		if (dirtybuffer[offs] || dirtybuffer[offs + 1])
360 		{
361 			int sx,sy;
362 
363 
364 			dirtybuffer[offs] = 0;
365 			dirtybuffer[offs + 1] = 0;
366 
367 			sx = offs/2 % 32;
368 			sy = offs/2 / 32;
369 
370 			drawgfx(tmpbitmap,Machine->gfx[0],
371 					videoram[offs] + 256 * (videoram[offs + 1] & 0x03),
372 					((videoram[offs + 1] & 0x7c) >> 2) + 64 * top_palette_bank,
373 					videoram[offs + 1] & 0x80,0,
374 					8*sx,8*sy - 16,
375 					&topvisiblearea,TRANSPARENCY_NONE,0);
376 		}
377 	}
378 
379 	for (offs = punchout_videoram2_size - 2;offs >= 0;offs -= 2)
380 	{
381 		if (dirtybuffer2[offs] | dirtybuffer2[offs + 1])
382 		{
383 			int sx,sy;
384 
385 
386 			dirtybuffer2[offs] = 0;
387 			dirtybuffer2[offs + 1] = 0;
388 
389 			sx = offs/2 % 64;
390 			sy = offs/2 / 64;
391 
392 			drawgfx(tmpbitmap,Machine->gfx[1],
393 					punchout_videoram2[offs] + 256 * (punchout_videoram2[offs + 1] & 0x03),
394 					((punchout_videoram2[offs + 1] & 0x7c) >> 2) + 64 * bottom_palette_bank,
395 					punchout_videoram2[offs + 1] & 0x80,0,
396 					8*sx,8*sy + 8*TOP_MONITOR_ROWS - 16,
397 					&backgroundvisiblearea,TRANSPARENCY_NONE,0);
398 		}
399 	}
400 
401 	for (offs = punchout_bigsprite1ram_size - 4;offs >= 0;offs -= 4)
402 	{
403 		if (bs1dirtybuffer[offs] | bs1dirtybuffer[offs + 1] | bs1dirtybuffer[offs + 3])
404 		{
405 			int sx,sy;
406 
407 
408 			bs1dirtybuffer[offs] = 0;
409 			bs1dirtybuffer[offs + 1] = 0;
410 			bs1dirtybuffer[offs + 3] = 0;
411 
412 			sx = offs/4 % 16;
413 			sy = offs/4 / 16;
414 
415 			drawgfx(bs1tmpbitmap,Machine->gfx[2],
416 					punchout_bigsprite1ram[offs] + 256 * (punchout_bigsprite1ram[offs + 1] & 0x1f),
417 					(punchout_bigsprite1ram[offs + 3] & 0x1f) + 32 * bottom_palette_bank,
418 					punchout_bigsprite1ram[offs + 3] & 0x80,0,
419 					8*sx,8*sy,
420 					0,TRANSPARENCY_NONE,0);
421 		}
422 	}
423 
424 	for (offs = punchout_bigsprite2ram_size - 4;offs >= 0;offs -= 4)
425 	{
426 		if (bs2dirtybuffer[offs] | bs2dirtybuffer[offs + 1] | bs2dirtybuffer[offs + 3])
427 		{
428 			int sx,sy;
429 
430 
431 			bs2dirtybuffer[offs] = 0;
432 			bs2dirtybuffer[offs + 1] = 0;
433 			bs2dirtybuffer[offs + 3] = 0;
434 
435 			sx = offs/4 % 16;
436 			sy = offs/4 / 16;
437 
438 			drawgfx(bs2tmpbitmap,Machine->gfx[3],
439 					punchout_bigsprite2ram[offs] + 256 * (punchout_bigsprite2ram[offs + 1] & 0x0f),
440 					(punchout_bigsprite2ram[offs + 3] & 0x3f) + 64 * bottom_palette_bank,
441 					punchout_bigsprite2ram[offs + 3] & 0x80,0,
442 					8*sx,8*sy,
443 					0,TRANSPARENCY_NONE,0);
444 		}
445 	}
446 
447 
448 	/* copy the character mapped graphics */
449 	{
450 		int scroll[64];
451 
452 
453 		for (offs = 0;offs < TOP_MONITOR_ROWS;offs++)
454 			scroll[offs] = 0;
455 		for (offs = 0;offs < BOTTOM_MONITOR_ROWS;offs++)
456 			scroll[TOP_MONITOR_ROWS + offs] = -(58 + punchout_scroll[2*(offs+2)] + 256 * (punchout_scroll[2*(offs+2) + 1] & 0x01));
457 
458 		copyscrollbitmap(bitmap,tmpbitmap,TOP_MONITOR_ROWS + BOTTOM_MONITOR_ROWS,scroll,0,0,&Machine->visible_area,TRANSPARENCY_NONE,0);
459 	}
460 
461 	/* copy the two big sprites */
462 	{
463 		int zoom;
464 
465 		zoom = punchout_bigsprite1[0] + 256 * (punchout_bigsprite1[1] & 0x0f);
466 		if (zoom)
467 		{
468 			int sx,sy;
469 			UINT32 startx,starty;
470 			int incxx,incyy;
471 
472 			sx = 4096 - (punchout_bigsprite1[2] + 256 * (punchout_bigsprite1[3] & 0x0f));
473 			if (sx > 4096-4*127) sx -= 4096;
474 
475 			sy = -(punchout_bigsprite1[4] + 256 * (punchout_bigsprite1[5] & 1));
476 			if (sy <= -256 + zoom/0x40) sy += 512;
477 
478 			incxx = zoom << 6;
479 			incyy = zoom << 6;
480 
481 			startx = -sx * 0x4000;
482 			starty = -sy * 0x10000;
483 			startx += 3740 * zoom;	/* adjustment to match the screen shots */
484 			starty -= 178 * zoom;	/* and make the hall of fame picture nice */
485 
486 			if (punchout_bigsprite1[6] & 1)	/* flip x */
487 			{
488 				startx = (bs1tmpbitmap->width << 16) - startx - 1;
489 				incxx = -incxx;
490 			}
491 
492 			if (punchout_bigsprite1[7] & 1)	/* display in top monitor */
493 			{
494 				copyrozbitmap(bitmap,bs1tmpbitmap,
495 					startx,starty + 0x200*(2) * zoom,
496 					incxx,0,0,incyy,	/* zoom, no rotation */
497 					0,	/* no wraparound */
498 					&topvisiblearea,TRANSPARENCY_COLOR,1024,0);
499 			}
500 			if (punchout_bigsprite1[7] & 2)	/* display in bottom monitor */
501 			{
502 				copyrozbitmap(bitmap,bs1tmpbitmap,
503 					startx,starty - 0x200*TOP_MONITOR_ROWS * zoom,
504 					incxx,0,0,incyy,	/* zoom, no rotation */
505 					0,	/* no wraparound */
506 					&bottomvisiblearea,TRANSPARENCY_COLOR,1024,0);
507 			}
508 		}
509 	}
510 	{
511 		int sx,sy;
512 
513 
514 		sx = 512 - (punchout_bigsprite2[0] + 256 * (punchout_bigsprite2[1] & 1));
515 		if (sx > 512-127) sx -= 512;
516 		sx -= 55;	/* adjustment to match the screen shots */
517 
518 		sy = -punchout_bigsprite2[2] + 256 * (punchout_bigsprite2[3] & 1);
519 		sy += 3;	/* adjustment to match the screen shots */
520 
521 		copybitmap(bitmap,bs2tmpbitmap,
522 				punchout_bigsprite2[4] & 1,0,
523 				sx,sy + 8*TOP_MONITOR_ROWS - 16,
524 				&bottomvisiblearea,TRANSPARENCY_COLOR,1024);
525 	}
526 }
527 
528 
VIDEO_UPDATE(armwrest)529 VIDEO_UPDATE( armwrest )
530 {
531 	int offs;
532 
533 
534 	/* for every character in the Video RAM, check if it has been modified */
535 	/* since last time and update it accordingly. */
536 	for (offs = punchout_videoram2_size - 2;offs >= 0;offs -= 2)
537 	{
538 		if (dirtybuffer2[offs] | dirtybuffer2[offs + 1])
539 		{
540 			int sx,sy;
541 
542 
543 			dirtybuffer2[offs] = 0;
544 			dirtybuffer2[offs + 1] = 0;
545 
546 			sx = offs/2 % 32;
547 			sy = offs/2 / 32;
548 
549 			if (sy >= 32)
550 			{
551 				/* top screen */
552 				sy -= 32;
553 				drawgfx(tmpbitmap,Machine->gfx[0],
554 						punchout_videoram2[offs] + 256 * (punchout_videoram2[offs + 1] & 0x03) +
555 								8 * (punchout_videoram2[offs + 1] & 0x80),
556 						((punchout_videoram2[offs + 1] & 0x7c) >> 2) + 64 * top_palette_bank,
557 						0,0,
558 						8*sx,8*sy - 16,
559 						&topvisiblearea,TRANSPARENCY_NONE,0);
560 			}
561 			else
562 				/* bottom screen background */
563 				drawgfx(tmpbitmap,Machine->gfx[0],
564 						punchout_videoram2[offs] + 256 * (punchout_videoram2[offs + 1] & 0x03),
565 						128 + ((punchout_videoram2[offs + 1] & 0x7c) >> 2) + 64 * bottom_palette_bank,
566 						punchout_videoram2[offs + 1] & 0x80,0,
567 						8*sx,8*sy + 8*TOP_MONITOR_ROWS - 16,
568 						&backgroundvisiblearea,TRANSPARENCY_NONE,0);
569 		}
570 	}
571 
572 	for (offs = punchout_bigsprite1ram_size - 4;offs >= 0;offs -= 4)
573 	{
574 		if (bs1dirtybuffer[offs] | bs1dirtybuffer[offs + 1] | bs1dirtybuffer[offs + 3])
575 		{
576 			int sx,sy;
577 
578 
579 			bs1dirtybuffer[offs] = 0;
580 			bs1dirtybuffer[offs + 1] = 0;
581 			bs1dirtybuffer[offs + 3] = 0;
582 
583 			sx = offs/4 % 16;
584 			sy = offs/4 / 16;
585 			if (sy >= 16)
586 			{
587 				sy -= 16;
588 				sx += 16;
589 			}
590 
591 			drawgfx(bs1tmpbitmap,Machine->gfx[2],
592 					punchout_bigsprite1ram[offs] + 256 * (punchout_bigsprite1ram[offs + 1] & 0x1f),
593 					(punchout_bigsprite1ram[offs + 3] & 0x1f) + 32 * bottom_palette_bank,
594 					punchout_bigsprite1ram[offs + 3] & 0x80,0,
595 					8*sx,8*sy,
596 					0,TRANSPARENCY_NONE,0);
597 		}
598 	}
599 
600 	for (offs = punchout_bigsprite2ram_size - 4;offs >= 0;offs -= 4)
601 	{
602 		if (bs2dirtybuffer[offs] | bs2dirtybuffer[offs + 1] | bs2dirtybuffer[offs + 3])
603 		{
604 			int sx,sy;
605 
606 
607 			bs2dirtybuffer[offs] = 0;
608 			bs2dirtybuffer[offs + 1] = 0;
609 			bs2dirtybuffer[offs + 3] = 0;
610 
611 			sx = offs/4 % 16;
612 			sy = offs/4 / 16;
613 
614 			drawgfx(bs2tmpbitmap,Machine->gfx[3],
615 					punchout_bigsprite2ram[offs] + 256 * (punchout_bigsprite2ram[offs + 1] & 0x0f),
616 					(punchout_bigsprite2ram[offs + 3] & 0x3f) + 64 * bottom_palette_bank,
617 					punchout_bigsprite2ram[offs + 3] & 0x80,0,
618 					8*sx,8*sy,
619 					0,TRANSPARENCY_NONE,0);
620 		}
621 	}
622 
623 
624 	/* copy the character mapped graphics */
625 	copybitmap(bitmap,tmpbitmap,0,0,0,0,&Machine->visible_area,TRANSPARENCY_NONE,0);
626 
627 
628 	/* copy the two big sprites */
629 	{
630 		int zoom;
631 
632 		zoom = punchout_bigsprite1[0] + 256 * (punchout_bigsprite1[1] & 0x0f);
633 		if (zoom)
634 		{
635 			int sx,sy;
636 			UINT32 startx,starty;
637 			int incxx,incyy;
638 
639 			sx = 4096 - (punchout_bigsprite1[2] + 256 * (punchout_bigsprite1[3] & 0x0f));
640 			if (sx > 4096-4*127) sx -= 4096;
641 
642 			sy = -(punchout_bigsprite1[4] + 256 * (punchout_bigsprite1[5] & 1));
643 			if (sy <= -256 + zoom/0x40) sy += 512;
644 
645 			incxx = zoom << 6;
646 			incyy = zoom << 6;
647 
648 			startx = -sx * 0x4000;
649 			starty = -sy * 0x10000;
650 			startx += 3740 * zoom;	/* adjustment to match the screen shots */
651 			starty -= 178 * zoom;	/* and make the hall of fame picture nice */
652 
653 			if (punchout_bigsprite1[6] & 1)	/* flip x */
654 			{
655 				startx = (bs1tmpbitmap->width << 16) - startx - 1;
656 				incxx = -incxx;
657 			}
658 
659 			if (punchout_bigsprite1[7] & 1)	/* display in top monitor */
660 			{
661 				copyrozbitmap(bitmap,bs1tmpbitmap,
662 					startx,starty + 0x200*(2) * zoom,
663 					incxx,0,0,incyy,	/* zoom, no rotation */
664 					0,	/* no wraparound */
665 					&topvisiblearea,TRANSPARENCY_COLOR,1024,0);
666 			}
667 			if (punchout_bigsprite1[7] & 2)	/* display in bottom monitor */
668 			{
669 				copyrozbitmap(bitmap,bs1tmpbitmap,
670 					startx,starty - 0x200*(TOP_MONITOR_ROWS-2) * zoom,
671 					incxx,0,0,incyy,	/* zoom, no rotation */
672 					0,	/* no wraparound */
673 					&bottomvisiblearea,TRANSPARENCY_COLOR,1024,0);
674 			}
675 		}
676 	}
677 	{
678 		int sx,sy;
679 
680 
681 		sx = 512 - (punchout_bigsprite2[0] + 256 * (punchout_bigsprite2[1] & 1));
682 		if (sx > 512-127) sx -= 512;
683 		sx -= 55;	/* adjustment to match the screen shots */
684 
685 		sy = -punchout_bigsprite2[2] + 256 * (punchout_bigsprite2[3] & 1);
686 		sy += 3;	/* adjustment to match the screen shots */
687 
688 		copybitmap(bitmap,bs2tmpbitmap,
689 				punchout_bigsprite2[4] & 1,0,
690 				sx,sy + 8*TOP_MONITOR_ROWS - 16,
691 				&bottomvisiblearea,TRANSPARENCY_COLOR,1024);
692 	}
693 
694 
695 	/* draw the foregound chars */
696 	for (offs = videoram_size - 2;offs >= 0;offs -= 2)
697 	{
698 		int sx,sy;
699 
700 
701 		dirtybuffer[offs] = 0;
702 		dirtybuffer[offs + 1] = 0;
703 
704 		sx = offs/2 % 32;
705 		sy = offs/2 / 32;
706 
707 		drawgfx(bitmap,Machine->gfx[1],
708 				videoram[offs] + 256 * (videoram[offs + 1] & 0x07),
709 				((videoram[offs + 1] & 0xf8) >> 3) + 32 * bottom_palette_bank,
710 				videoram[offs + 1] & 0x80,0,
711 				8*sx,8*sy + 8*TOP_MONITOR_ROWS - 16,
712 				&backgroundvisiblearea,TRANSPARENCY_PEN,7);
713 	}
714 }
715