trunk/src/emu/video/i8275x.c
| r29185 | r29186 | |
| 25 | 25 | // MACROS / CONSTANTS |
| 26 | 26 | //************************************************************************** |
| 27 | 27 | |
| 28 | #define LOG 0 |
| 29 | |
| 30 | |
| 28 | 31 | const int DMA_BURST_SPACING[] = { 0, 7, 15, 23, 31, 39, 47, 55 }; |
| 29 | 32 | |
| 33 | |
| 30 | 34 | #define DOUBLE_SPACED_ROWS \ |
| 31 | 35 | BIT(m_param[REG_SCN1], 7) |
| 32 | 36 | |
| r29185 | r29186 | |
| 66 | 70 | |
| 67 | 71 | |
| 68 | 72 | //************************************************************************** |
| 69 | | // somethign |
| 73 | // DEVICE DEFINITIONS |
| 70 | 74 | //************************************************************************** |
| 71 | 75 | |
| 72 | 76 | // device type definition |
| 73 | 77 | const device_type I8275x = &device_creator<i8275x_device>; |
| 74 | 78 | |
| 75 | 79 | |
| 80 | |
| 76 | 81 | //************************************************************************** |
| 77 | 82 | // LIVE DEVICE |
| 78 | 83 | //************************************************************************** |
| r29185 | r29186 | |
| 81 | 86 | // i8275x_device - constructor |
| 82 | 87 | //------------------------------------------------- |
| 83 | 88 | |
| 84 | | i8275x_device::i8275x_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) |
| 85 | | : device_t(mconfig, I8275x, "I8275", tag, owner, clock, "i8275x", __FILE__), |
| 86 | | device_video_interface(mconfig, *this), |
| 87 | | m_write_irq(*this), |
| 88 | | m_write_drq(*this), |
| 89 | | m_write_hrtc(*this), |
| 90 | | m_write_vrtc(*this), |
| 91 | | m_display_cb(NULL), |
| 92 | | m_status(0), |
| 93 | | m_param_idx(0), |
| 94 | | m_param_end(0), |
| 95 | | m_buffer_idx(0), |
| 96 | | m_fifo_next(false), |
| 97 | | m_buffer_dma(0), |
| 98 | | m_lpen(0), |
| 99 | | m_hlgt(0), |
| 100 | | m_vsp(0), |
| 101 | | m_gpa(0), |
| 102 | | m_rvv(0), |
| 103 | | m_lten(0), |
| 104 | | m_scanline(0), |
| 105 | | m_du(false), |
| 106 | | m_cursor_blink(0), |
| 107 | | m_char_blink(0) |
| 89 | i8275x_device::i8275x_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : |
| 90 | device_t(mconfig, I8275x, "I8275", tag, owner, clock, "i8275x", __FILE__), |
| 91 | device_video_interface(mconfig, *this), |
| 92 | m_write_irq(*this), |
| 93 | m_write_drq(*this), |
| 94 | m_write_hrtc(*this), |
| 95 | m_write_vrtc(*this), |
| 96 | m_display_cb(NULL), |
| 97 | m_status(0), |
| 98 | m_param_idx(0), |
| 99 | m_param_end(0), |
| 100 | m_buffer_idx(0), |
| 101 | m_fifo_next(false), |
| 102 | m_buffer_dma(0), |
| 103 | m_lpen(0), |
| 104 | m_hlgt(0), |
| 105 | m_vsp(0), |
| 106 | m_gpa(0), |
| 107 | m_rvv(0), |
| 108 | m_lten(0), |
| 109 | m_scanline(0), |
| 110 | m_du(false), |
| 111 | m_cursor_blink(0), |
| 112 | m_char_blink(0) |
| 108 | 113 | { |
| 109 | 114 | } |
| 110 | 115 | |
| r29185 | r29186 | |
| 173 | 178 | switch (id) |
| 174 | 179 | { |
| 175 | 180 | case TIMER_HRTC_ON: |
| 176 | | //logerror("I8275 '%s' y %u x %u HRTC 1\n", tag(), y, x); |
| 181 | //if (LOG) logerror("I8275 '%s' y %u x %u HRTC 1\n", tag(), y, x); |
| 177 | 182 | m_write_hrtc(1); |
| 178 | 183 | break; |
| 179 | 184 | |
| 180 | 185 | case TIMER_DRQ_ON: |
| 181 | | //logerror("I8275 '%s' y %u x %u DRQ 1\n", tag(), y, x); |
| 186 | //if (LOG) logerror("I8275 '%s' y %u x %u DRQ 1\n", tag(), y, x); |
| 182 | 187 | m_write_drq(1); |
| 183 | 188 | m_drq_off_timer->adjust(clocks_to_attotime(DMA_BURST_COUNT)); |
| 184 | 189 | break; |
| r29185 | r29186 | |
| 188 | 193 | { |
| 189 | 194 | m_status |= ST_DU; |
| 190 | 195 | m_du = true; |
| 191 | | //logerror("I8275 '%s' y %u x %u DRQ 0\n", tag(), y, x); |
| 196 | //if (LOG) logerror("I8275 '%s' y %u x %u DRQ 0\n", tag(), y, x); |
| 192 | 197 | m_write_drq(0); |
| 193 | 198 | } |
| 194 | 199 | else if (m_buffer_idx == CHARACTERS_PER_ROW) |
| 195 | 200 | { |
| 196 | | //logerror("I8275 '%s' y %u x %u DRQ 0\n", tag(), y, x); |
| 201 | //if (LOG) logerror("I8275 '%s' y %u x %u DRQ 0\n", tag(), y, x); |
| 197 | 202 | m_write_drq(0); |
| 198 | 203 | } |
| 199 | 204 | else if (DMA_BURST_SPACE > 0) |
| 200 | 205 | { |
| 201 | | //logerror("I8275 '%s' y %u x %u DRQ 0\n", tag(), y, x); |
| 206 | //if (LOG) logerror("I8275 '%s' y %u x %u DRQ 0\n", tag(), y, x); |
| 202 | 207 | m_write_drq(0); |
| 203 | 208 | m_drq_on_timer->adjust(clocks_to_attotime(DMA_BURST_SPACE)); |
| 204 | 209 | } |
| r29185 | r29186 | |
| 207 | 212 | case TIMER_SCANLINE: |
| 208 | 213 | if (!(m_status & ST_VE)) break; |
| 209 | 214 | |
| 210 | | //logerror("I8275 '%s' y %u x %u HRTC 0\n", tag(), y, x); |
| 215 | //if (LOG) logerror("I8275 '%s' y %u x %u HRTC 0\n", tag(), y, x); |
| 211 | 216 | m_write_hrtc(0); |
| 212 | 217 | |
| 213 | 218 | if (m_scanline == 0) |
| 214 | 219 | { |
| 215 | | //logerror("I8275 '%s' y %u x %u VRTC 0\n", tag(), y, x); |
| 220 | //if (LOG) logerror("I8275 '%s' y %u x %u VRTC 0\n", tag(), y, x); |
| 216 | 221 | m_write_vrtc(0); |
| 217 | 222 | } |
| 218 | 223 | else if (m_scanline == m_irq_scanline) |
| 219 | 224 | { |
| 220 | 225 | if (m_status & ST_IE) |
| 221 | 226 | { |
| 222 | | //logerror("I8275 '%s' y %u x %u IRQ 1\n", tag(), y, x); |
| 227 | //if (LOG) logerror("I8275 '%s' y %u x %u IRQ 1\n", tag(), y, x); |
| 223 | 228 | m_status |= ST_IR; |
| 224 | 229 | m_write_irq(ASSERT_LINE); |
| 225 | 230 | } |
| 226 | 231 | } |
| 227 | 232 | else if (m_scanline == m_vrtc_scanline) |
| 228 | 233 | { |
| 229 | | //logerror("I8275 '%s' y %u x %u VRTC 1\n", tag(), y, x); |
| 234 | //if (LOG) logerror("I8275 '%s' y %u x %u VRTC 1\n", tag(), y, x); |
| 230 | 235 | m_write_vrtc(1); |
| 231 | 236 | |
| 232 | 237 | // reset field attributes |
| r29185 | r29186 | |
| 366 | 371 | |
| 367 | 372 | if (m_status & ST_IR) |
| 368 | 373 | { |
| 369 | | //logerror("I8275 '%s' IRQ 0\n", tag()); |
| 374 | //if (LOG) logerror("I8275 '%s' IRQ 0\n", tag()); |
| 370 | 375 | m_write_irq(CLEAR_LINE); |
| 371 | 376 | } |
| 372 | 377 | |
| r29185 | r29186 | |
| 395 | 400 | { |
| 396 | 401 | if (offset & 0x01) |
| 397 | 402 | { |
| 398 | | logerror("I8275 '%s' Command %02x\n", tag(), data); |
| 403 | if (LOG) logerror("I8275 '%s' Command %02x\n", tag(), data); |
| 399 | 404 | |
| 400 | 405 | switch (data >> 5) |
| 401 | 406 | { |
| 402 | 407 | case CMD_RESET: |
| 403 | | logerror("I8275 '%s' Reset\n", tag()); |
| 408 | if (LOG) logerror("I8275 '%s' Reset\n", tag()); |
| 404 | 409 | |
| 405 | 410 | m_status &= ~ST_IE; |
| 406 | | logerror("I8275 '%s' IRQ 0\n", tag()); |
| 411 | if (LOG) logerror("I8275 '%s' IRQ 0\n", tag()); |
| 407 | 412 | m_write_irq(CLEAR_LINE); |
| 408 | 413 | |
| 409 | 414 | m_param_idx = REG_SCN1; |
| r29185 | r29186 | |
| 413 | 418 | case CMD_START_DISPLAY: |
| 414 | 419 | { |
| 415 | 420 | m_param[REG_DMA] = data; |
| 416 | | logerror("I8275 '%s' Start Display %u %u\n", tag(), DMA_BURST_COUNT, DMA_BURST_SPACE); |
| 421 | if (LOG) logerror("I8275 '%s' Start Display %u %u\n", tag(), DMA_BURST_COUNT, DMA_BURST_SPACE); |
| 417 | 422 | m_status |= (ST_IE | ST_VE); |
| 418 | 423 | } |
| 419 | 424 | break; |
| 420 | 425 | |
| 421 | 426 | case CMD_STOP_DISPLAY: |
| 422 | | logerror("I8275 '%s' Stop Display\n", tag()); |
| 427 | if (LOG) logerror("I8275 '%s' Stop Display\n", tag()); |
| 423 | 428 | m_status &= ~ST_VE; |
| 424 | 429 | break; |
| 425 | 430 | |
| 426 | 431 | case CMD_READ_LIGHT_PEN: |
| 427 | | logerror("I8275 '%s' Read Light Pen\n", tag()); |
| 432 | if (LOG) logerror("I8275 '%s' Read Light Pen\n", tag()); |
| 428 | 433 | m_param_idx = REG_LPEN_COL; |
| 429 | 434 | m_param_end = REG_LPEN_ROW; |
| 430 | 435 | break; |
| 431 | 436 | |
| 432 | 437 | case CMD_LOAD_CURSOR: |
| 433 | | logerror("I8275 '%s' Load Cursor\n", tag()); |
| 438 | if (LOG) logerror("I8275 '%s' Load Cursor\n", tag()); |
| 434 | 439 | m_param_idx = REG_CUR_COL; |
| 435 | 440 | m_param_end = REG_CUR_ROW; |
| 436 | 441 | break; |
| 437 | 442 | |
| 438 | 443 | case CMD_ENABLE_INTERRUPT: |
| 439 | | logerror("I8275 '%s' Enable Interrupt\n", tag()); |
| 444 | if (LOG) logerror("I8275 '%s' Enable Interrupt\n", tag()); |
| 440 | 445 | m_status |= ST_IE; |
| 441 | 446 | break; |
| 442 | 447 | |
| 443 | 448 | case CMD_DISABLE_INTERRUPT: |
| 444 | | logerror("I8275 '%s' Disable Interrupt\n", tag()); |
| 449 | if (LOG) logerror("I8275 '%s' Disable Interrupt\n", tag()); |
| 445 | 450 | m_status &= ~ST_IE; |
| 446 | 451 | break; |
| 447 | 452 | |
| 448 | 453 | case CMD_PRESET_COUNTERS: |
| 449 | | logerror("I8275 '%s' Preset Counters\n", tag()); |
| 454 | if (LOG) logerror("I8275 '%s' Preset Counters\n", tag()); |
| 450 | 455 | m_scanline = 0; |
| 451 | 456 | break; |
| 452 | 457 | } |
| 453 | 458 | } |
| 454 | 459 | else |
| 455 | 460 | { |
| 456 | | logerror("I8275 '%s' Parameter %02x\n", tag(), data); |
| 461 | if (LOG) logerror("I8275 '%s' Parameter %02x\n", tag(), data); |
| 457 | 462 | |
| 458 | 463 | m_param[m_param_idx] = data; |
| 459 | 464 | |
| r29185 | r29186 | |
| 473 | 478 | |
| 474 | 479 | WRITE8_MEMBER( i8275x_device::dack_w ) |
| 475 | 480 | { |
| 476 | | //logerror("DACK write %02x %u\n", data, m_buffer_idx); |
| 481 | //if (LOG) logerror("DACK write %02x %u\n", data, m_buffer_idx); |
| 477 | 482 | |
| 478 | 483 | if (m_fifo_next) |
| 479 | 484 | { |
| r29185 | r29186 | |
| 553 | 558 | int max_visible_x = (CHARACTERS_PER_ROW * m_hpixels_per_column) - 1; |
| 554 | 559 | int max_visible_y = (CHARACTER_ROWS_PER_FRAME * SCANLINES_PER_ROW) - 1; |
| 555 | 560 | |
| 556 | | logerror("width %u height %u max_x %u max_y %u refresh %f\n", horiz_pix_total, vert_pix_total, max_visible_x, max_visible_y, 1 / ATTOSECONDS_TO_DOUBLE(refresh)); |
| 561 | if (LOG) logerror("width %u height %u max_x %u max_y %u refresh %f\n", horiz_pix_total, vert_pix_total, max_visible_x, max_visible_y, 1 / ATTOSECONDS_TO_DOUBLE(refresh)); |
| 557 | 562 | |
| 558 | 563 | rectangle visarea; |
| 559 | 564 | visarea.set(0, max_visible_x, 0, max_visible_y); |