trunk/src/emu/video/m50458.c
r17530 | r17531 | |
9 | 9 | "worse" ways, the one currently implemented guesses that the screen is |
10 | 10 | masked at the top and the end when in scrolling mode). |
11 | 11 | - Understand what the "vertical start position" really does (vblank?) |
| 12 | - Check if the ROM source is actually 2bpp once that a redump is made |
| 13 | (the shadow ROM copy doesn't convince me 100%); |
12 | 14 | |
13 | 15 | ***************************************************************************/ |
14 | 16 | |
r17530 | r17531 | |
79 | 81 | int i; |
80 | 82 | |
81 | 83 | for(i=0;i<0x120;i++) |
82 | | { |
83 | | write_word(i,0); |
84 | | } |
| 84 | write_word(i,0x007f); |
85 | 85 | } |
86 | 86 | } |
87 | 87 | |
r17530 | r17531 | |
160 | 160 | |
161 | 161 | void m50458_device::device_start() |
162 | 162 | { |
| 163 | UINT16 tmp; |
| 164 | UINT8 *pcg = memregion("m50458")->base(); |
| 165 | int tile; |
| 166 | int yi; |
| 167 | UINT16 src,dst; |
163 | 168 | |
| 169 | /* Create an array for shadow gfx */ |
| 170 | /* this will spread the source ROM into four directions (up-left, up-right, down-left, down-right) thus creating a working shadow copy */ |
| 171 | m_shadow_gfx = auto_alloc_array_clear(machine(), UINT8, 0x1200); |
| 172 | |
| 173 | for(tile=0;tile<0x80;tile++) |
| 174 | { |
| 175 | for(yi=1;yi<17;yi++) |
| 176 | { |
| 177 | src = (tile & 0x7f)*36+yi*2; /* source offset */ |
| 178 | |
| 179 | dst = (tile & 0x7f)*36+(yi-1)*2; /* destination offset */ |
| 180 | |
| 181 | tmp = (((pcg[src]<<8)|(pcg[src+1]&0xff)) & 0xfffe) >> 1; |
| 182 | |
| 183 | m_shadow_gfx[dst+1] |= tmp & 0xff; |
| 184 | m_shadow_gfx[dst] |= (tmp >> 8); |
| 185 | |
| 186 | tmp = (((pcg[src]<<8)|(pcg[src+1]&0xff)) & 0x7fff) << 1; |
| 187 | |
| 188 | m_shadow_gfx[dst+1] |= tmp & 0xff; |
| 189 | m_shadow_gfx[dst] |= (tmp >> 8); |
| 190 | |
| 191 | dst = (tile & 0x7f)*36+(yi+1)*2; /* destination offset */ |
| 192 | |
| 193 | tmp = (((pcg[src]<<8)|(pcg[src+1]&0xff)) & 0xfffe) >> 1; |
| 194 | |
| 195 | m_shadow_gfx[dst+1] |= tmp & 0xff; |
| 196 | m_shadow_gfx[dst] |= (tmp >> 8); |
| 197 | |
| 198 | tmp = (((pcg[src]<<8)|(pcg[src+1]&0xff)) & 0x7fff) << 1; |
| 199 | |
| 200 | m_shadow_gfx[dst+1] |= tmp & 0xff; |
| 201 | m_shadow_gfx[dst] |= (tmp >> 8); |
| 202 | } |
| 203 | } |
164 | 204 | } |
165 | 205 | |
166 | 206 | |
r17530 | r17531 | |
170 | 210 | |
171 | 211 | void m50458_device::device_reset() |
172 | 212 | { |
| 213 | int i; |
| 214 | |
| 215 | /* clear VRAM at boot */ |
| 216 | for(i=0;i<0x120;i++) |
| 217 | write_word(i,0x007f); |
173 | 218 | } |
174 | 219 | |
175 | 220 | |
r17530 | r17531 | |
267 | 312 | for(xi=4;xi<16;xi++) /* TODO: remove 4 / 16 / -4 offset once that the ROM is fixed */ |
268 | 313 | { |
269 | 314 | UINT8 pix; |
270 | | UINT8 r,g,b; |
| 315 | UINT8 color = (tile & 0x700) >> 8; |
271 | 316 | UINT16 offset = ((tile & 0x7f)*36+yi*2); |
272 | 317 | int res_y; |
273 | 318 | |
274 | 319 | /* TODO: blinking, bit 7 (RTC test in NSS) */ |
275 | 320 | |
276 | 321 | if(xi>=8) |
277 | | pix = (pcg[offset+1] >> (7-(xi & 0x7))) & 1; |
| 322 | pix = ((pcg[offset+1] >> (7-(xi & 0x7))) & 1) << 1; |
278 | 323 | else |
279 | | pix = (pcg[offset+0] >> (7-(xi & 0x7))) & 1; |
| 324 | pix = ((pcg[offset+0] >> (7-(xi & 0x7))) & 1) << 1; |
280 | 325 | |
| 326 | if(xi>=8) |
| 327 | pix |= ((m_shadow_gfx[offset+1] >> (7-(xi & 0x7))) & 1); |
| 328 | else |
| 329 | pix |= ((m_shadow_gfx[offset+0] >> (7-(xi & 0x7))) & 1); |
| 330 | |
281 | 331 | if(yi == 17 && tile & 0x1000) /* underline? */ |
282 | 332 | pix |= 1; |
283 | 333 | |
284 | | r = (tile & 0x100 && pix) ? 0xff : 0x00; |
285 | | g = (tile & 0x200 && pix) ? 0xff : 0x00; |
286 | | b = (tile & 0x400 && pix) ? 0xff : 0x00; |
287 | | |
288 | 334 | res_y = y*18+yi; |
289 | 335 | |
290 | 336 | if(y != 0 && y != 11) |
r17530 | r17531 | |
294 | 340 | res_y += 216; |
295 | 341 | } |
296 | 342 | |
297 | | if(r || g || b) |
| 343 | if(pix != 0) |
| 344 | { |
| 345 | UINT8 r,g,b; |
| 346 | |
| 347 | if(pix & 2) |
| 348 | { |
| 349 | r = (color & 0x1) ? 0xff : 0x00; |
| 350 | g = (color & 0x2) ? 0xff : 0x00; |
| 351 | b = (color & 0x4) ? 0xff : 0x00; |
| 352 | } |
| 353 | else //if(pix & 1) |
| 354 | { |
| 355 | /* TODO: shadow parameter */ |
| 356 | r = 0x00; |
| 357 | g = 0x00; |
| 358 | b = 0x00; |
| 359 | } |
| 360 | |
298 | 361 | bitmap.pix32(res_y,x*12+(xi-4)) = r << 16 | g << 8 | b; |
| 362 | } |
299 | 363 | } |
300 | 364 | } |
301 | 365 | } |