trunk/src/emu/video/m50458.c
| r17521 | r17522 | |
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | |
| 3 | | Mitsubishi M50458 OSD chip |
| 3 | Mitsubishi M50458 OSD chip |
| 4 | 4 | |
| 5 | | preliminary device by Angelo Salese |
| 5 | preliminary device by Angelo Salese |
| 6 | 6 | |
| 7 | TODO: |
| 8 | - vertical scrolling needs references (might work differently and/or in |
| 9 | "worse" ways, the one currently implemented guesses that the screen is |
| 10 | masked at the top and the end when in scrolling mode). |
| 11 | - Understand what the "vertical start position" really does (vblank?) |
| 12 | |
| 7 | 13 | ***************************************************************************/ |
| 8 | 14 | |
| 9 | 15 | #include "emu.h" |
| r17521 | r17522 | |
| 54 | 60 | /* char part of vertical scrolling */ |
| 55 | 61 | m_scrr = (data & 0x0f00) >> 8; |
| 56 | 62 | |
| 57 | | printf("%02x %02x %02x\n",m_scrr,m_scrf,m_space); |
| 63 | // printf("%02x %02x %02x\n",m_scrr,m_scrf,m_space); |
| 58 | 64 | } |
| 59 | 65 | |
| 60 | 66 | WRITE16_MEMBER( m50458_device::vreg_126_w) |
| r17521 | r17522 | |
| 211 | 217 | break; |
| 212 | 218 | case OSD_SET_DATA: |
| 213 | 219 | //if(m_osd_addr >= 0x120) |
| 214 | | printf("%04x %04x\n",m_osd_addr,m_current_cmd); |
| 220 | //printf("%04x %04x\n",m_osd_addr,m_current_cmd); |
| 215 | 221 | write_word(m_osd_addr,m_current_cmd); |
| 216 | 222 | m_osd_addr++; |
| 217 | 223 | /* Presumably wraps at 0x127? */ |
| r17521 | r17522 | |
| 242 | 248 | bg_b = m_phase & 4 ? 0xdf : 0; |
| 243 | 249 | bitmap.fill(MAKE_ARGB(0xff,bg_r,bg_g,bg_b),cliprect); |
| 244 | 250 | |
| 245 | | |
| 246 | 251 | for(y=0;y<12;y++) |
| 247 | 252 | { |
| 248 | 253 | for(x=0;x<24;x++) |
| r17521 | r17522 | |
| 251 | 256 | UINT16 tile; |
| 252 | 257 | int y_base = y; |
| 253 | 258 | |
| 254 | | /* TODO: needs improvements */ |
| 255 | | if(y != 0 && m_scrr) |
| 256 | | y_base+=(m_scrr - 1); |
| 259 | if(y != 0 && m_scrr > 1) { y_base+=(m_scrr - 1); } |
| 260 | if(y_base > 11) { y_base -= 11; } |
| 261 | if(m_scrr && y == 11) { y_base = 0; } /* Guess: repeat line 0 if scrolling is active */ |
| 257 | 262 | |
| 258 | | if(y != 0 && y_base == 0) |
| 259 | | y_base ++; |
| 260 | | |
| 261 | | if(y_base >= 12) |
| 262 | | y_base -= 11; |
| 263 | | |
| 264 | | |
| 265 | 263 | tile = read_word(x+y_base*24); |
| 266 | 264 | |
| 267 | 265 | for(yi=0;yi<18;yi++) |
| r17521 | r17522 | |
| 271 | 269 | UINT8 pix; |
| 272 | 270 | UINT8 r,g,b; |
| 273 | 271 | UINT16 offset = ((tile & 0x7f)*36+yi*2); |
| 272 | int res_y; |
| 274 | 273 | |
| 275 | 274 | /* TODO: blinking, bit 7 (RTC test in NSS) */ |
| 276 | 275 | |
| r17521 | r17522 | |
| 286 | 285 | g = (tile & 0x200 && pix) ? 0xff : 0x00; |
| 287 | 286 | b = (tile & 0x400 && pix) ? 0xff : 0x00; |
| 288 | 287 | |
| 288 | res_y = y*18+yi; |
| 289 | |
| 290 | if(y != 0 && y != 11) |
| 291 | { |
| 292 | res_y -= m_scrf; |
| 293 | if(res_y < 18) /* wrap-around */ |
| 294 | res_y += 216; |
| 295 | } |
| 296 | |
| 289 | 297 | if(r || g || b) |
| 290 | | bitmap.pix32(y*18+yi,x*12+(xi-4)) = r << 16 | g << 8 | b; |
| 298 | bitmap.pix32(res_y,x*12+(xi-4)) = r << 16 | g << 8 | b; |
| 291 | 299 | } |
| 292 | 300 | } |
| 293 | 301 | } |