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 "common.h"
11 #include "usrintrf.h"
12 #include "vidhrdw/generic.h"
13
14
15 static int flipscreen[2];
16
17
WRITE_HANDLER(pkunwar_flipscreen_w)18 WRITE_HANDLER( pkunwar_flipscreen_w )
19 {
20 if (flipscreen[0] != (data & 1))
21 {
22 flipscreen[0] = data & 1;
23 memset(dirtybuffer,1,videoram_size);
24 }
25 if (flipscreen[1] != (data & 2))
26 {
27 flipscreen[1] = data & 2;
28 memset(dirtybuffer,1,videoram_size);
29 }
30 }
31
32
33
VIDEO_UPDATE(pkunwar)34 VIDEO_UPDATE( pkunwar )
35 {
36 int offs;
37
38
39 /* for every character in the Video RAM, check if it has been modified */
40 /* since last time and update it accordingly. */
41 for (offs = videoram_size - 1;offs >= 0;offs--)
42 {
43 if (dirtybuffer[offs])
44 {
45 int sx,sy;
46
47
48 dirtybuffer[offs] = 0;
49
50 sx = offs % 32;
51 sy = offs / 32;
52 if (flipscreen[0]) sx = 31 - sx;
53 if (flipscreen[1]) sy = 31 - sy;
54
55 drawgfx(tmpbitmap,Machine->gfx[0],
56 videoram[offs] + ((colorram[offs] & 0x07) << 8),
57 (colorram[offs] & 0xf0) >> 4,
58 flipscreen[0],flipscreen[1],
59 8*sx,8*sy,
60 &Machine->visible_area,TRANSPARENCY_NONE,0);
61 }
62 }
63
64 /* copy the character mapped graphics */
65 copybitmap(bitmap,tmpbitmap,0,0,0,0,&Machine->visible_area,TRANSPARENCY_NONE,0);
66
67
68 /* Draw the sprites. */
69 for (offs = 0;offs < spriteram_size;offs += 32)
70 {
71 int sx,sy,flipx,flipy;
72
73
74 sx = ((spriteram[offs + 1] + 8) & 0xff) - 8;
75 sy = spriteram[offs + 2];
76 flipx = spriteram[offs] & 0x01;
77 flipy = spriteram[offs] & 0x02;
78 if (flipscreen[0])
79 {
80 sx = 240 - sx;
81 flipx = !flipx;
82 }
83 if (flipscreen[1])
84 {
85 sy = 240 - sy;
86 flipy = !flipy;
87 }
88
89 drawgfx(bitmap,Machine->gfx[1],
90 ((spriteram[offs] & 0xfc) >> 2) + ((spriteram[offs + 3] & 0x07) << 6),
91 (spriteram[offs + 3] & 0xf0) >> 4,
92 flipx,flipy,
93 sx,sy,
94 &Machine->visible_area,TRANSPARENCY_PEN,0);
95 }
96
97
98 /* redraw characters which have priority over sprites */
99 for (offs = videoram_size - 1;offs >= 0;offs--)
100 {
101 if (colorram[offs] & 0x08)
102 {
103 int sx,sy;
104
105
106 sx = offs % 32;
107 sy = offs / 32;
108 if (flipscreen[0]) sx = 31 - sx;
109 if (flipscreen[1]) sy = 31 - sy;
110
111 drawgfx(bitmap,Machine->gfx[0],
112 videoram[offs] + ((colorram[offs] & 0x07) << 8),
113 (colorram[offs] & 0xf0) >> 4,
114 flipscreen[0],flipscreen[1],
115 8*sx,8*sy,
116 &Machine->visible_area,TRANSPARENCY_PEN,0);
117 }
118 }
119 }
120