src/mess/video/crt9007.c
| r7518 | r7519 | |
| 26 | 26 | - operation modes 0,4,7
|
| 27 | 27 | - address modes 1,2,3
|
| 28 | 28 | - light pen
|
| 29 | | - variable clock frequency
|
| 30 | | - variable hpixels_per_column
|
| 31 | 29 | - state saving
|
| 32 | 30 | |
| 33 | 31 | */
|
| r7518 | r7519 | |
| 78 | 76 | ((crt9007->reg[0x08] & 0x1f) + 1)
|
| 79 | 77 | |
| 80 | 78 | #define SCAN_LINES_PER_FRAME \
|
| 81 | | (((crt9007->reg[0x08] << 3) & 0xff00) | crt9007->reg[0x09])
|
| 79 | (((crt9007->reg[0x08] << 3) & 0x0700) | crt9007->reg[0x09])
|
| 82 | 80 | |
| 83 | 81 | #define DMA_BURST_COUNT \
|
| 84 | 82 | (crt9007->reg[0x0a] & 0x0f)
|
| r7518 | r7519 | |
| 89 | 87 | #define DMA_DISABLE \
|
| 90 | 88 | BIT(crt9007->reg[0x0a], 7)
|
| 91 | 89 | |
| 90 | #define SINGLE_HEIGHT_CURSOR \
|
| 91 | BIT(crt9007->reg[0x0b], 0)
|
| 92 | |
| 92 | 93 | #define OPERATION_MODE \
|
| 93 | 94 | ((crt9007->reg[0x0b] >> 1) & 0x07)
|
| 94 | 95 | |
| 95 | 96 | #define INTERLACE_MODE \
|
| 96 | 97 | ((crt9007->reg[0x0b] >> 4) & 0x03)
|
| 97 | 98 | |
| 99 | #define PAGE_BLANK \
|
| 100 | BIT(crt9007->reg[0x0b], 6)
|
| 101 | |
| 98 | 102 | #define TABLE_START \
|
| 99 | 103 | (((crt9007->reg[0x0d] << 8) & 0x3f00) | crt9007->reg[0x0c])
|
| 100 | 104 | |
| r7518 | r7519 | |
| 104 | 108 | #define AUXILIARY_ADDRESS_1 \
|
| 105 | 109 | (((crt9007->reg[0x0f] << 8) & 0x3f00) | crt9007->reg[0x0e])
|
| 106 | 110 | |
| 111 | #define ROW_ATTRIBUTES_1 \
|
| 112 | ((crt9007->reg[0x0f] >> 6) & 0x03)
|
| 113 | |
| 107 | 114 | #define SEQUENTIAL_BREAK_1 \
|
| 108 | 115 | crt9007->reg[0x10]
|
| 109 | 116 | |
| r7518 | r7519 | |
| 119 | 126 | #define AUXILIARY_ADDRESS_2 \
|
| 120 | 127 | (((crt9007->reg[0x14] << 8) & 0x3f00) | crt9007->reg[0x13])
|
| 121 | 128 | |
| 129 | #define ROW_ATTRIBUTES_2 \
|
| 130 | ((crt9007->reg[0x14] >> 6) & 0x03)
|
| 131 | |
| 122 | 132 | #define SMOOTH_SCROLL_OFFSET \
|
| 123 | 133 | ((crt9007->reg[0x17] >> 1) & 0x3f)
|
| 124 | 134 | |
| r7518 | r7519 | |
| 202 | 212 | /* runtime variables, do not state save */
|
| 203 | 213 | int vsync_start;
|
| 204 | 214 | int vsync_end;
|
| 215 | int vfp;
|
| 205 | 216 | int hsync_start;
|
| 206 | 217 | int hsync_end;
|
| 218 | int hfp;
|
| 207 | 219 | |
| 208 | 220 | /* timers */
|
| 209 | 221 | emu_timer *vsync_timer; /* vertical sync timer */
|
| r7518 | r7519 | |
| 305 | 317 | |
| 306 | 318 | attoseconds_t refresh = HZ_TO_ATTOSECONDS(device->clock) * horiz_pix_total * vert_pix_total;
|
| 307 | 319 | |
| 320 | crt9007->hsync_start = (CHARACTERS_PER_HORIZONTAL_PERIOD - HORIZONTAL_SYNC_WIDTH) * crt9007->hpixels_per_column;
|
| 321 | crt9007->hsync_end = 0;
|
| 322 | crt9007->hfp = (HORIZONTAL_DELAY - HORIZONTAL_SYNC_WIDTH) * crt9007->hpixels_per_column;
|
| 323 | |
| 324 | crt9007->vsync_start = SCAN_LINES_PER_FRAME - VERTICAL_SYNC_WIDTH;
|
| 325 | crt9007->vsync_end = 0;
|
| 326 | crt9007->vfp = VERTICAL_DELAY - VERTICAL_SYNC_WIDTH;
|
| 327 | |
| 308 | 328 | rectangle visarea;
|
| 309 | 329 | |
| 310 | | visarea.min_x = 0;
|
| 311 | | visarea.min_y = 0;
|
| 312 | | visarea.max_x = (CHARACTERS_PER_DATA_ROW * crt9007->hpixels_per_column) - 1;
|
| 313 | | visarea.max_y = (VISIBLE_DATA_ROWS_PER_FRAME * SCAN_LINES_PER_DATA_ROW) - 1;
|
| 330 | visarea.min_x = crt9007->hsync_end;
|
| 331 | visarea.max_x = crt9007->hsync_start - 1;
|
| 314 | 332 | |
| 333 | visarea.min_y = crt9007->vsync_end;
|
| 334 | visarea.max_y = crt9007->vsync_start - 1;
|
| 335 | |
| 315 | 336 | if (LOG)
|
| 316 | 337 | {
|
| 317 | 338 | logerror("CRT9007 '%s' Screen: %u x %u @ %f Hz\n", device->tag.cstr(), horiz_pix_total, vert_pix_total, 1 / ATTOSECONDS_TO_DOUBLE(refresh));
|
| r7518 | r7519 | |
| 320 | 341 | |
| 321 | 342 | video_screen_configure(crt9007->screen, horiz_pix_total, vert_pix_total, &visarea, refresh);
|
| 322 | 343 | |
| 323 | | crt9007->vsync_start = VISIBLE_DATA_ROWS_PER_FRAME - VERTICAL_DELAY;
|
| 324 | | crt9007->vsync_end = (crt9007->vsync_start + VERTICAL_SYNC_WIDTH) % VISIBLE_DATA_ROWS_PER_FRAME;
|
| 325 | | crt9007->hsync_start = (CHARACTERS_PER_HORIZONTAL_PERIOD - HORIZONTAL_DELAY) * crt9007->hpixels_per_column;
|
| 326 | | crt9007->hsync_end = ((crt9007->hsync_start + HORIZONTAL_SYNC_WIDTH) % CHARACTERS_PER_HORIZONTAL_PERIOD) * crt9007->hpixels_per_column;
|
| 327 | | |
| 328 | 344 | update_hsync_timer(crt9007, 1);
|
| 329 | 345 | update_vsync_timer(crt9007, 1);
|
| 330 | 346 | }
|
| r7518 | r7519 | |
| 457 | 473 | case 0x0b:
|
| 458 | 474 | if (LOG)
|
| 459 | 475 | {
|
| 460 | | logerror("CRT9007 '%s' %s Height Cursor\n", device->tag.cstr(), BIT(data, 0) ? "Single" : "Double");
|
| 476 | logerror("CRT9007 '%s' %s Height Cursor\n", device->tag.cstr(), SINGLE_HEIGHT_CURSOR ? "Single" : "Double");
|
| 461 | 477 | logerror("CRT9007 '%s' Operation Mode: %u\n", device->tag.cstr(), OPERATION_MODE);
|
| 462 | 478 | logerror("CRT9007 '%s' Interlace Mode: %u\n", device->tag.cstr(), INTERLACE_MODE);
|
| 463 | | logerror("CRT9007 '%s' %s Mechanism\n", device->tag.cstr(), BIT(data, 6) ? "Page Blank" : "Smooth Scroll");
|
| 479 | logerror("CRT9007 '%s' %s Mechanism\n", device->tag.cstr(), PAGE_BLANK ? "Page Blank" : "Smooth Scroll");
|
| 464 | 480 | }
|
| 465 | 481 | break;
|
| 466 | 482 | |
| r7518 | r7519 | |
| 482 | 498 | if (LOG)
|
| 483 | 499 | {
|
| 484 | 500 | logerror("CRT9007 '%s' Auxialiary Address Register 1: %04x\n", device->tag.cstr(), AUXILIARY_ADDRESS_1);
|
| 485 | | logerror("CRT9007 '%s' Row Attributes: %u\n", device->tag.cstr(), (data >> 6) & 0x03);
|
| 501 | logerror("CRT9007 '%s' Row Attributes: %u\n", device->tag.cstr(), ROW_ATTRIBUTES_1);
|
| 486 | 502 | }
|
| 487 | 503 | break;
|
| 488 | 504 | |
| r7518 | r7519 | |
| 505 | 521 | if (LOG)
|
| 506 | 522 | {
|
| 507 | 523 | logerror("CRT9007 '%s' Auxiliary Address Register 2: %04x\n", device->tag.cstr(), AUXILIARY_ADDRESS_2);
|
| 508 | | logerror("CRT9007 '%s' Row Attributes: %u\n", device->tag.cstr(), (data >> 6) & 0x03);
|
| 524 | logerror("CRT9007 '%s' Row Attributes: %u\n", device->tag.cstr(), ROW_ATTRIBUTES_2);
|
| 509 | 525 | }
|
| 510 | 526 | break;
|
| 511 | 527 | |
| r7518 | r7519 | |
| 538 | 554 | case 0x1a:
|
| 539 | 555 | if (LOG)
|
| 540 | 556 | {
|
| 541 | | logerror("CRT9007 '%s' Frame Timer: %u\n", device->tag.cstr(), BIT(data, 0));
|
| 542 | | logerror("CRT9007 '%s' Light Pen Interrupt: %u\n", device->tag.cstr(), BIT(data, 5));
|
| 543 | | logerror("CRT9007 '%s' Vertical Retrace Interrupt: %u\n", device->tag.cstr(), BIT(data, 6));
|
| 557 | logerror("CRT9007 '%s' Frame Timer: %u\n", device->tag.cstr(), FRAME_TIMER);
|
| 558 | logerror("CRT9007 '%s' Light Pen Interrupt: %u\n", device->tag.cstr(), LIGHT_PEN_INTERRUPT);
|
| 559 | logerror("CRT9007 '%s' Vertical Retrace Interrupt: %u\n", device->tag.cstr(), VERTICAL_RETRACE_INTERRUPT);
|
| 544 | 560 | }
|
| 545 | 561 | break;
|
| 546 | 562 | |
| r7518 | r7519 | |
| 566 | 582 | }
|
| 567 | 583 | |
| 568 | 584 | /*-------------------------------------------------
|
| 585 | crt9007_set_clock - set device clock
|
| 586 | -------------------------------------------------*/
|
| 587 | |
| 588 | void crt9007_set_clock(running_device *device, UINT32 clock)
|
| 589 | {
|
| 590 | device->set_clock(clock);
|
| 591 | recompute_parameters(device);
|
| 592 | }
|
| 593 | |
| 594 | /*-------------------------------------------------
|
| 595 | crt9007_set_hpixels_per_column
|
| 596 | -------------------------------------------------*/
|
| 597 | |
| 598 | void crt9007_set_hpixels_per_column(running_device *device, int hpixels_per_column)
|
| 599 | {
|
| 600 | crt9007_t *crt9007 = get_safe_token(device);
|
| 601 | |
| 602 | crt9007->hpixels_per_column = hpixels_per_column;
|
| 603 | recompute_parameters(device);
|
| 604 | }
|
| 605 | |
| 606 | /*-------------------------------------------------
|
| 569 | 607 | crt9007_update - update screen
|
| 570 | 608 | -------------------------------------------------*/
|
| 571 | 609 | |
| r7518 | r7519 | |
| 575 | 613 | |
| 576 | 614 | if (crt9007->disp && HAS_VALID_PARAMETERS)
|
| 577 | 615 | {
|
| 578 | | for (int y = 0; y < (VISIBLE_DATA_ROWS_PER_FRAME * SCAN_LINES_PER_DATA_ROW); y++)
|
| 616 | int min_y = crt9007->vfp;
|
| 617 | int max_y = min_y + (VISIBLE_DATA_ROWS_PER_FRAME * SCAN_LINES_PER_DATA_ROW);
|
| 618 | |
| 619 | for (int y = min_y; y < max_y; y++)
|
| 579 | 620 | {
|
| 580 | | int sl = y % SCAN_LINES_PER_DATA_ROW;
|
| 581 | | int sy = y / SCAN_LINES_PER_DATA_ROW;
|
| 621 | int sl = (y - min_y) % SCAN_LINES_PER_DATA_ROW;
|
| 622 | int sy = (y - min_y) / SCAN_LINES_PER_DATA_ROW;
|
| 582 | 623 | int cursor_x = (sy == VERTICAL_CURSOR) ? HORIZONTAL_CURSOR : -1;
|
| 583 | 624 | UINT16 addr = TABLE_START + (sy * CHARACTERS_PER_DATA_ROW);
|
| 584 | | UINT8 data = devcb_call_read8(&crt9007->in_vd_func, addr);
|
| 625 | // UINT8 data = devcb_call_read8(&crt9007->in_vd_func, addr);
|
| 585 | 626 |
|
| 586 | | crt9007->draw_scanline_func(device, bitmap, cliprect, addr, sl, data, y, 0, CHARACTERS_PER_DATA_ROW, cursor_x);
|
| 627 | crt9007->draw_scanline_func(device, bitmap, cliprect, addr, sl, 0, y, crt9007->hfp, CHARACTERS_PER_DATA_ROW, cursor_x);
|
| 587 | 628 | |
| 588 | 629 | addr++;
|
| 589 | 630 | }
|
src/mess/drivers/tandy2k.c
| r7518 | r7519 | |
| 10 | 10 | |
| 11 | 11 | TODO:
|
| 12 | 12 | |
| 13 | | - port FFFE?
|
| 14 | | |
| 15 | | 'u76' (FFF07): unmapped I/O memory word write to FFFE = 00FF & FFFF
|
| 16 | | 'u76' (FFF0F): unmapped I/O memory word read from FFFE & FFFF
|
| 17 | | |
| 13 | - 80186
|
| 18 | 14 | - CRT9007
|
| 19 | | - video
|
| 20 | | - 80186
|
| 21 | 15 | - keyboard ROM
|
| 22 | 16 | - hires graphics board
|
| 23 | 17 | - floppy 720K DSQD
|
| r7518 | r7519 | |
| 165 | 159 | 15 VIDOUTS selects the video source for display on monochrome monitor
|
| 166 | 160 | |
| 167 | 161 | */
|
| 162 | |
| 163 | tandy2k_state *state = (tandy2k_state *)space->machine->driver_data;
|
| 164 | |
| 165 | /* video access */
|
| 166 | state->vram_base = data << 15;
|
| 167 | |
| 168 | /* video clock speed */
|
| 169 | crt9007_set_clock(state->vpac, BIT(data, 5) ? XTAL_16MHz*28/16 : XTAL_16MHz*28/20);
|
| 170 | |
| 171 | /* dots per char */
|
| 172 | crt9007_set_hpixels_per_column(state->vpac, BIT(data, 6) ? 8 : 10);
|
| 173 | |
| 174 | /* video source select */
|
| 175 | state->vidouts = BIT(data, 7);
|
| 176 | |
| 177 | logerror("Address Control %02x\n", data);
|
| 168 | 178 | }
|
| 169 | 179 | |
| 170 | 180 | static READ8_HANDLER( keyboard_x0_r )
|
| r7518 | r7519 | |
| 188 | 198 | |
| 189 | 199 | UINT8 data = 0xff;
|
| 190 | 200 | |
| 191 | | if (!BIT(state->keylatch, 0)) data &= input_port_read(space->machine, "Y0");
|
| 192 | | if (!BIT(state->keylatch, 1)) data &= input_port_read(space->machine, "Y1");
|
| 193 | | if (!BIT(state->keylatch, 2)) data &= input_port_read(space->machine, "Y2");
|
| 194 | | if (!BIT(state->keylatch, 3)) data &= input_port_read(space->machine, "Y3");
|
| 195 | | if (!BIT(state->keylatch, 4)) data &= input_port_read(space->machine, "Y4");
|
| 196 | | if (!BIT(state->keylatch, 5)) data &= input_port_read(space->machine, "Y5");
|
| 197 | | if (!BIT(state->keylatch, 6)) data &= input_port_read(space->machine, "Y6");
|
| 198 | | if (!BIT(state->keylatch, 7)) data &= input_port_read(space->machine, "Y7");
|
| 199 | | if (!BIT(state->keylatch, 8)) data &= input_port_read(space->machine, "Y8");
|
| 200 | | if (!BIT(state->keylatch, 9)) data &= input_port_read(space->machine, "Y9");
|
| 201 | if (!BIT(state->keylatch, 0)) data &= input_port_read(space->machine, "Y0");
|
| 202 | if (!BIT(state->keylatch, 1)) data &= input_port_read(space->machine, "Y1");
|
| 203 | if (!BIT(state->keylatch, 2)) data &= input_port_read(space->machine, "Y2");
|
| 204 | if (!BIT(state->keylatch, 3)) data &= input_port_read(space->machine, "Y3");
|
| 205 | if (!BIT(state->keylatch, 4)) data &= input_port_read(space->machine, "Y4");
|
| 206 | if (!BIT(state->keylatch, 5)) data &= input_port_read(space->machine, "Y5");
|
| 207 | if (!BIT(state->keylatch, 6)) data &= input_port_read(space->machine, "Y6");
|
| 208 | if (!BIT(state->keylatch, 7)) data &= input_port_read(space->machine, "Y7");
|
| 209 | if (!BIT(state->keylatch, 8)) data &= input_port_read(space->machine, "Y8");
|
| 210 | if (!BIT(state->keylatch, 9)) data &= input_port_read(space->machine, "Y9");
|
| 201 | 211 | if (!BIT(state->keylatch, 10)) data &= input_port_read(space->machine, "Y10");
|
| 202 | 212 | if (!BIT(state->keylatch, 11)) data &= input_port_read(space->machine, "Y11");
|
| 203 | 213 | |
| r7518 | r7519 | |
| 278 | 288 | // AM_RANGE(0x00180, 0x00180) AM_READ8(hires_status_r, 0x00ff)
|
| 279 | 289 | // AM_RANGE(0x00180, 0x001bf) AM_WRITE(hires_palette_w)
|
| 280 | 290 | // AM_RANGE(0x001a0, 0x001a0) AM_READ8(hires_plane_w, 0x00ff)
|
| 291 | // AM_RANGE(0x0ff00, 0x0ffff) AM_READWRITE(i186_internal_port_r, i186_internal_port_w)
|
| 281 | 292 | ADDRESS_MAP_END
|
| 282 | 293 | |
| 283 | 294 | static ADDRESS_MAP_START( tandy2k_hd_io, ADDRESS_SPACE_IO, 16 )
|
| r7518 | r7519 | |
| 424 | 435 | tandy2k_state *state = (tandy2k_state *)machine->driver_data;
|
| 425 | 436 | |
| 426 | 437 | /* find devices */
|
| 427 | | state->crt = devtag_get_device(machine, CRT9007_TAG);
|
| 438 | state->vpac = devtag_get_device(machine, CRT9007_TAG);
|
| 428 | 439 | }
|
| 429 | 440 | |
| 430 | 441 | static VIDEO_UPDATE( tandy2k )
|
| 431 | 442 | {
|
| 432 | 443 | tandy2k_state *state = (tandy2k_state *)screen->machine->driver_data;
|
| 433 | 444 | |
| 434 | | crt9007_update(state->crt, bitmap, cliprect);
|
| 445 | //if (state->vidouts)
|
| 446 | {
|
| 447 | crt9007_update(state->vpac, bitmap, cliprect);
|
| 448 | }
|
| 435 | 449 | |
| 436 | 450 | return 0;
|
| 437 | 451 | }
|
| 438 | 452 | |
| 439 | 453 | static CRT9007_DRAW_SCANLINE( tandy2k_crt9007_display_pixels )
|
| 440 | 454 | {
|
| 455 | tandy2k_state *state = (tandy2k_state *)device->machine->driver_data;
|
| 456 | const address_space *program = cputag_get_address_space(device->machine, I80186_TAG, ADDRESS_SPACE_PROGRAM);
|
| 457 | |
| 458 | for (int sx = 0; sx < x_count; sx++)
|
| 459 | {
|
| 460 | UINT32 videoram_addr = (state->vram_base | (va << 1)) + sx;
|
| 461 | UINT8 videoram_data = memory_read_word(program, videoram_addr);
|
| 462 | UINT16 charram_addr = (videoram_data << 4) | sl;
|
| 463 | UINT8 data = state->char_ram[charram_addr] & 0xff;
|
| 464 | |
| 465 | for (int bit = 0; bit < 10; bit++)
|
| 466 | {
|
| 467 | if (BIT(data, 7))
|
| 468 | {
|
| 469 | *BITMAP_ADDR16(bitmap, y, x + (sx * 10) + bit) = 1;
|
| 470 | }
|
| 471 | |
| 472 | data <<= 1;
|
| 473 | }
|
| 474 | }
|
| 441 | 475 | }
|
| 442 | 476 | |
| 443 | 477 | static CRT9007_INTERFACE( crt9007_intf )
|
| r7518 | r7519 | |
| 449 | 483 | DEVCB_NULL,
|
| 450 | 484 | DEVCB_NULL,
|
| 451 | 485 | DEVCB_NULL,
|
| 452 | | DEVCB_MEMORY_HANDLER(I80186_TAG, PROGRAM, memory_read_byte_16le),
|
| 486 | DEVCB_NULL,
|
| 453 | 487 | DEVCB_NULL
|
| 454 | 488 | };
|
| 455 | 489 | |
| r7518 | r7519 | |
| 723 | 757 | |
| 724 | 758 | memory_install_ram(program, 0x00000, ram_size - 1, 0, 0, ram);
|
| 725 | 759 | |
| 726 | | /* patch ROM */
|
| 760 | /* patch out i186 relocation register check */
|
| 727 | 761 | UINT8 *rom = memory_region(machine, I80186_TAG);
|
| 728 | 762 | rom[0x1f16] = 0x90;
|
| 729 | 763 | rom[0x1f17] = 0x90;
|