1 // license:BSD-3-Clause
2 // copyright-holders:Allard van der Bas
3 /***************************************************************************
4
5 wiping.c
6
7 Functions to emulate the video hardware of the machine.
8
9 ***************************************************************************/
10
11 #include "emu.h"
12 #include "video/resnet.h"
13 #include "includes/wiping.h"
14
15
16 /***************************************************************************
17
18 Convert the color PROMs into a more useable format.
19
20 ***************************************************************************/
21
wiping_palette(palette_device & palette) const22 void wiping_state::wiping_palette(palette_device &palette) const
23 {
24 const uint8_t *color_prom = memregion("proms")->base();
25 static constexpr int resistances_rg[3] = { 1000, 470, 220 };
26 static constexpr int resistances_b [2] = { 470, 220 };
27
28 // compute the color output resistor weights
29 double rweights[3], gweights[3], bweights[2];
30 compute_resistor_weights(0, 255, -1.0,
31 3, &resistances_rg[0], rweights, 470, 0,
32 3, &resistances_rg[0], gweights, 470, 0,
33 2, &resistances_b[0], bweights, 470, 0);
34
35 // create a lookup table for the palette
36 for (int i = 0; i < 0x20; i++)
37 {
38 int bit0, bit1, bit2;
39
40 // red component
41 bit0 = BIT(color_prom[i], 0);
42 bit1 = BIT(color_prom[i], 1);
43 bit2 = BIT(color_prom[i], 2);
44 int const r = combine_weights(rweights, bit0, bit1, bit2);
45
46 // green component
47 bit0 = BIT(color_prom[i], 3);
48 bit1 = BIT(color_prom[i], 4);
49 bit2 = BIT(color_prom[i], 5);
50 int const g = combine_weights(gweights, bit0, bit1, bit2);
51
52 // blue component
53 bit0 = BIT(color_prom[i], 6);
54 bit1 = BIT(color_prom[i], 7);
55 int const b = combine_weights(bweights, bit0, bit1);
56
57 palette.set_indirect_color(i, rgb_t(r, g, b));
58 }
59
60 // color_prom now points to the beginning of the lookup table
61 color_prom += 0x20;
62
63 // chars use colors 0-15
64 for (int i = 0; i < 0x100; i++)
65 {
66 uint8_t const ctabentry = color_prom[i ^ 0x03] & 0x0f;
67 palette.set_pen_indirect(i, ctabentry);
68 }
69
70 // sprites use colors 16-31
71 for (int i = 0x100; i < 0x200; i++)
72 {
73 uint8_t const ctabentry = (color_prom[i ^ 0x03] & 0x0f) | 0x10;
74 palette.set_pen_indirect(i, ctabentry);
75 }
76 }
77
78
79
WRITE_LINE_MEMBER(wiping_state::flipscreen_w)80 WRITE_LINE_MEMBER(wiping_state::flipscreen_w)
81 {
82 m_flipscreen = state;
83 }
84
85
screen_update(screen_device & screen,bitmap_ind16 & bitmap,const rectangle & cliprect)86 uint32_t wiping_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
87 {
88 uint8_t *spriteram = m_spriteram;
89 int offs;
90
91 for (offs = 0x3ff; offs > 0; offs--)
92 {
93 int mx,my,sx,sy;
94
95 mx = offs % 32;
96 my = offs / 32;
97
98 if (my < 2)
99 {
100 sx = my + 34;
101 sy = mx - 2;
102 }
103 else if (my >= 30)
104 {
105 sx = my - 30;
106 sy = mx - 2;
107 }
108 else
109 {
110 sx = mx + 2;
111 sy = my - 2;
112 }
113
114 if (m_flipscreen)
115 {
116 sx = 35 - sx;
117 sy = 27 - sy;
118 }
119
120 m_gfxdecode->gfx(0)->opaque(bitmap,cliprect,
121 m_videoram[offs],
122 m_colorram[offs] & 0x3f,
123 m_flipscreen,m_flipscreen,
124 sx*8,sy*8);
125 }
126
127 /* Note, we're counting up on purpose ! */
128 /* This way the vacuum cleaner is always on top */
129 for (offs = 0x0; offs < 128; offs += 2) {
130 int sx,sy,color,flipx,flipy,otherbank;
131
132 sx = spriteram[offs+0x100+1] + ((spriteram[offs+0x81] & 0x01) << 8) - 40;
133 sy = 224 - spriteram[offs+0x100];
134 color = spriteram[offs+1] & 0x3f;
135
136 otherbank = spriteram[offs+0x80] & 0x01;
137
138 flipy = spriteram[offs] & 0x40;
139 flipx = spriteram[offs] & 0x80;
140
141 if (m_flipscreen)
142 {
143 sy = 208 - sy;
144 flipx = !flipx;
145 flipy = !flipy;
146 }
147
148 m_gfxdecode->gfx(1)->transmask(bitmap,cliprect,
149 (spriteram[offs] & 0x3f) + 64 * otherbank,
150 color,
151 flipx,flipy,
152 sx,sy,
153 m_palette->transpen_mask(*m_gfxdecode->gfx(1), color, 0x1f));
154 }
155
156 /* redraw high priority chars */
157 for (offs = 0x3ff; offs > 0; offs--)
158 {
159 if (m_colorram[offs] & 0x80)
160 {
161 int mx,my,sx,sy;
162
163 mx = offs % 32;
164 my = offs / 32;
165
166 if (my < 2)
167 {
168 sx = my + 34;
169 sy = mx - 2;
170 }
171 else if (my >= 30)
172 {
173 sx = my - 30;
174 sy = mx - 2;
175 }
176 else
177 {
178 sx = mx + 2;
179 sy = my - 2;
180 }
181
182 if (m_flipscreen)
183 {
184 sx = 35 - sx;
185 sy = 27 - sy;
186 }
187
188 m_gfxdecode->gfx(0)->opaque(bitmap,cliprect,
189 m_videoram[offs],
190 m_colorram[offs] & 0x3f,
191 m_flipscreen,m_flipscreen,
192 sx*8,sy*8);
193 }
194 }
195
196
197 #if 0
198 {
199 int i,j;
200
201 for (i = 0;i < 8;i++)
202 {
203 for (j = 0;j < 8;j++)
204 {
205 char buf[40];
206 sprintf(buf,"%01x",m_soundregs[i*8+j]&0xf);
207 ui_draw_text(buf,j*10,i*8);
208 }
209 }
210
211 for (i = 0;i < 8;i++)
212 {
213 for (j = 0;j < 8;j++)
214 {
215 char buf[40];
216 sprintf(buf,"%01x",m_soundregs[0x2000+i*8+j]>>4);
217 ui_draw_text(buf,j*10,80+i*8);
218 }
219 }
220 }
221 #endif
222 return 0;
223 }
224