1 /***************************************************************************
2
3 Taito Super Speed Race video emulation
4
5 ***************************************************************************/
6
7 #include "driver.h"
8
9 static int toggle;
10
11 static unsigned driver_horz;
12 static unsigned driver_vert;
13 static unsigned driver_pic;
14
15 static unsigned drones_horz;
16 static unsigned drones_vert[3];
17 static unsigned drones_mask;
18
19 static unsigned track_horz;
20 static unsigned track_vert[2];
21 static unsigned track_ice;
22
23
WRITE_HANDLER(sspeedr_driver_horz_w)24 WRITE_HANDLER( sspeedr_driver_horz_w )
25 {
26 driver_horz = (driver_horz & 0x100) | data;
27 }
28
29
WRITE_HANDLER(sspeedr_driver_horz_2_w)30 WRITE_HANDLER( sspeedr_driver_horz_2_w )
31 {
32 driver_horz = (driver_horz & 0xff) | ((data & 1) << 8);
33 }
34
35
WRITE_HANDLER(sspeedr_driver_vert_w)36 WRITE_HANDLER( sspeedr_driver_vert_w )
37 {
38 driver_vert = data;
39 }
40
41
WRITE_HANDLER(sspeedr_driver_pic_w)42 WRITE_HANDLER( sspeedr_driver_pic_w )
43 {
44 driver_pic = data & 0x1f;
45 }
46
47
WRITE_HANDLER(sspeedr_drones_horz_w)48 WRITE_HANDLER( sspeedr_drones_horz_w )
49 {
50 drones_horz = (drones_horz & 0x100) | data;
51 }
52
53
WRITE_HANDLER(sspeedr_drones_horz_2_w)54 WRITE_HANDLER( sspeedr_drones_horz_2_w )
55 {
56 drones_horz = (drones_horz & 0xff) | ((data & 1) << 8);
57 }
58
59
WRITE_HANDLER(sspeedr_drones_mask_w)60 WRITE_HANDLER( sspeedr_drones_mask_w )
61 {
62 drones_mask = data & 0x3f;
63 }
64
65
WRITE_HANDLER(sspeedr_drones_vert_w)66 WRITE_HANDLER( sspeedr_drones_vert_w )
67 {
68 drones_vert[offset] = data;
69 }
70
71
WRITE_HANDLER(sspeedr_track_horz_w)72 WRITE_HANDLER( sspeedr_track_horz_w )
73 {
74 track_horz = (track_horz & 0x100) | data;
75 }
76
77
WRITE_HANDLER(sspeedr_track_horz_2_w)78 WRITE_HANDLER( sspeedr_track_horz_2_w )
79 {
80 track_horz = (track_horz & 0xff) | ((data & 1) << 8);
81 }
82
83
WRITE_HANDLER(sspeedr_track_vert_w)84 WRITE_HANDLER( sspeedr_track_vert_w )
85 {
86 track_vert[offset] = data & 0x7f;
87 }
88
89
WRITE_HANDLER(sspeedr_track_ice_w)90 WRITE_HANDLER( sspeedr_track_ice_w )
91 {
92 track_ice = data & 0x07;
93 }
94
95
draw_track(struct mame_bitmap * bitmap)96 static void draw_track(struct mame_bitmap* bitmap)
97 {
98 const UINT8* p = memory_region(REGION_GFX3);
99
100 int x;
101 int y;
102
103 for (x = 0; x < 376; x++)
104 {
105 unsigned counter_x = x + track_horz + 0x50;
106
107 int flag = 0;
108
109 if (track_ice & 2)
110 {
111 flag = 1;
112 }
113 else if (track_ice & 4)
114 {
115 if (track_ice & 1)
116 {
117 flag = (counter_x <= 0x1ff);
118 }
119 else
120 {
121 flag = (counter_x >= 0x200);
122 }
123 }
124
125 if (counter_x >= 0x200)
126 {
127 counter_x -= 0x1c8;
128 }
129
130 y = 0;
131
132 /* upper landscape */
133
134 for (; y < track_vert[0]; y++)
135 {
136 unsigned counter_y = y - track_vert[0];
137
138 int offset =
139 ((counter_y & 0x1f) << 3) |
140 ((counter_x & 0x1c) >> 2) |
141 ((counter_x & 0xe0) << 3);
142
143 if (counter_x & 2)
144 {
145 plot_pixel(bitmap, x, y, p[offset] / 16);
146 }
147 else
148 {
149 plot_pixel(bitmap, x, y, p[offset] % 16);
150 }
151 }
152
153 /* street */
154
155 for (; y < 128 + track_vert[1]; y++)
156 {
157 plot_pixel(bitmap, x, y, flag ? 15 : 0);
158 }
159
160 /* lower landscape */
161
162 for (; y < 248; y++)
163 {
164 unsigned counter_y = y - track_vert[1];
165
166 int offset =
167 ((counter_y & 0x1f) << 3) |
168 ((counter_x & 0x1c) >> 2) |
169 ((counter_x & 0xe0) << 3);
170
171 if (counter_x & 2)
172 {
173 plot_pixel(bitmap, x, y, p[offset] / 16);
174 }
175 else
176 {
177 plot_pixel(bitmap, x, y, p[offset] % 16);
178 }
179 }
180 }
181 }
182
183
draw_drones(struct mame_bitmap * bitmap,const struct rectangle * cliprect)184 static void draw_drones(struct mame_bitmap* bitmap, const struct rectangle* cliprect)
185 {
186 static const UINT8 code[6] =
187 {
188 0xf, 0x4, 0x3, 0x9, 0x7, 0xc
189 };
190
191 int i;
192
193 for (i = 0; i < 6; i++)
194 {
195 int x;
196 int y;
197
198 if ((drones_mask >> i) & 1)
199 {
200 continue;
201 }
202
203 x = (code[i] << 5) - drones_horz - 0x50;
204
205 if (x <= -32)
206 {
207 x += 0x1c8;
208 }
209
210 y = 0xf0 - drones_vert[i >> 1];
211
212 drawgfx(bitmap, Machine->gfx[1],
213 code[i] ^ toggle,
214 0,
215 0, 0,
216 x,
217 y,
218 cliprect,
219 TRANSPARENCY_PEN, 0);
220 }
221 }
222
223
draw_driver(struct mame_bitmap * bitmap,const struct rectangle * cliprect)224 static void draw_driver(struct mame_bitmap* bitmap, const struct rectangle* cliprect)
225 {
226 int x;
227 int y;
228
229 if (!(driver_pic & 0x10))
230 {
231 return;
232 }
233
234 x = 0x1e0 - driver_horz - 0x50;
235
236 if (x <= -32)
237 {
238 x += 0x1c8;
239 }
240
241 y = 0xf0 - driver_vert;
242
243 drawgfx(bitmap, Machine->gfx[0],
244 driver_pic,
245 0,
246 0, 0,
247 x,
248 y,
249 cliprect,
250 TRANSPARENCY_PEN, 0);
251 }
252
253
VIDEO_START(sspeedr)254 VIDEO_START( sspeedr )
255 {
256 toggle = 0;
257
258 return 0;
259 }
260
261
VIDEO_UPDATE(sspeedr)262 VIDEO_UPDATE( sspeedr )
263 {
264 draw_track(bitmap);
265
266 draw_drones(bitmap, cliprect);
267
268 draw_driver(bitmap, cliprect);
269 }
270
271
VIDEO_EOF(sspeedr)272 VIDEO_EOF( sspeedr )
273 {
274 toggle ^= 1;
275 }
276