src/mess/video/upd3301.c
| r6363 | r6364 | |
| 11 | 11 | |
| 12 | 12 | TODO:
|
| 13 | 13 | |
| 14 | | - FIFO
|
| 15 | | - screen display
|
| 16 | | - set_drq
|
| 17 | | - dack_w
|
| 18 | | - interrupts
|
| 14 | - attributes
|
| 15 | - N interrupt
|
| 19 | 16 | - light pen
|
| 20 | 17 | - reset counters
|
| 18 | - proper DMA timing (now the whole screen is transferred at the end of the frame, |
| 19 | accurate timing requires CCLK timer which kills performance)
|
| 21 | 20 | |
| 22 | 21 | */
|
| 23 | 22 | |
| r6363 | r6364 | |
| 34 | 33 | #define UPD3301_COMMAND_RESET 0x00
|
| 35 | 34 | #define UPD3301_COMMAND_START_DISPLAY 0x20
|
| 36 | 35 | #define UPD3301_COMMAND_SET_INTERRUPT_MASK 0x40
|
| 37 | | #define UPD3301_COMMAND_READ_LIGHT_PEN 0x60
|
| 36 | #define UPD3301_COMMAND_READ_LIGHT_PEN 0x60 /* not supported */
|
| 38 | 37 | #define UPD3301_COMMAND_LOAD_CURSOR_POSITION 0x80
|
| 39 | 38 | #define UPD3301_COMMAND_RESET_INTERRUPT 0xa0
|
| 40 | | #define UPD3301_COMMAND_RESET_COUNTERS 0xc0
|
| 39 | #define UPD3301_COMMAND_RESET_COUNTERS 0xc0 /* not supported */
|
| 41 | 40 | |
| 42 | 41 | #define UPD3301_STATUS_VE 0x10
|
| 43 | 42 | #define UPD3301_STATUS_U 0x08 /* not supported */
|
| r6363 | r6364 | |
| 61 | 60 | typedef struct _upd3301_t upd3301_t;
|
| 62 | 61 | struct _upd3301_t
|
| 63 | 62 | {
|
| 64 | | devcb_resolved_write_line out_int_func;
|
| 65 | | devcb_resolved_write_line out_drq_func;
|
| 66 | | devcb_resolved_write_line out_hrtc_func;
|
| 67 | | devcb_resolved_write_line out_vrtc_func;
|
| 63 | /* callbacks */
|
| 64 | devcb_resolved_write_line out_int_func;
|
| 65 | devcb_resolved_write_line out_drq_func;
|
| 66 | devcb_resolved_write_line out_hrtc_func;
|
| 67 | devcb_resolved_write_line out_vrtc_func;
|
| 68 | upd3301_display_pixels_func display_func;
|
| 68 | 69 | |
| 70 | /* screen drawing */
|
| 69 | 71 | const device_config *screen; /* screen */
|
| 70 | | int width; /* character width */
|
| 72 | bitmap_t *bitmap; /* bitmap */
|
| 73 | int y; /* current scanline */
|
| 71 | 74 | |
| 72 | | int mode;
|
| 73 | | UINT8 status;
|
| 74 | | int param_count;
|
| 75 | /* live state */
|
| 76 | int mode; /* command mode */
|
| 77 | UINT8 status; /* status register */
|
| 78 | int param_count; /* parameter count */
|
| 75 | 79 | |
| 76 | | UINT8 row_buffer[80][2]; /* row buffer */
|
| 77 | | UINT8 fifo[20][2]; /* FIFO */
|
| 80 | /* FIFOs */
|
| 81 | UINT8 data_fifo[80][2]; /* row data FIFO */
|
| 82 | UINT8 attr_fifo[40][2]; /* attribute FIFO */
|
| 83 | int data_fifo_pos; /* row data FIFO position */
|
| 84 | int attr_fifo_pos; /* attribute FIFO position */
|
| 85 | int input_fifo; /* which FIFO is in input mode */
|
| 78 | 86 | |
| 87 | /* interrupts */
|
| 88 | int mn; /* disable special character interrupt */
|
| 89 | int me; /* disable end of screen interrupt */
|
| 79 | 90 | int dma_mode; /* DMA mode */
|
| 91 | |
| 92 | /* screen geometry */
|
| 93 | int width; /* character width */
|
| 80 | 94 | int h; /* characters per line */
|
| 81 | 95 | int b; /* cursor blink time */
|
| 82 | 96 | int l; /* lines per screen */
|
| r6363 | r6364 | |
| 85 | 99 | int r; /* lines per character */
|
| 86 | 100 | int v; /* vertical blanking height */
|
| 87 | 101 | int z; /* horizontal blanking width */
|
| 102 | |
| 103 | /* attributes */
|
| 88 | 104 | int at1; /* */
|
| 89 | 105 | int at0; /* */
|
| 90 | 106 | int sc; /* */
|
| 91 | 107 | int a; /* attributes per row */
|
| 92 | | int mn; /* disable special character interrupt */
|
| 93 | | int me; /* disable end of screen interrupt */
|
| 108 | int attr_blink; /* attribute blink */
|
| 109 | int attr_frame; /* attribute blink frame counter */
|
| 110 | |
| 111 | /* cursor */
|
| 94 | 112 | int cm; /* cursor visible */
|
| 95 | 113 | int cx; /* cursor column */
|
| 96 | 114 | int cy; /* cursor row */
|
| 115 | int cursor_blink; /* cursor blink */
|
| 116 | int cursor_frame; /* cursor blink frame counter */
|
| 97 | 117 | |
| 98 | 118 | /* timers */
|
| 99 | 119 | emu_timer *vrtc_timer; /* vertical sync timer */
|
| r6363 | r6364 | |
| 142 | 162 | }
|
| 143 | 163 | |
| 144 | 164 | /*-------------------------------------------------
|
| 165 | set_drq - set data request line state
|
| 166 | -------------------------------------------------*/
|
| 167 | |
| 168 | static void set_drq(const device_config *device, int state)
|
| 169 | {
|
| 170 | upd3301_t *upd3301 = get_safe_token(device);
|
| 171 | |
| 172 | if (LOG) logerror("UPD3301 '%s' DRQ: %u\n", device->tag, state);
|
| 173 | |
| 174 | devcb_call_write_line(&upd3301->out_drq_func, state);
|
| 175 | }
|
| 176 | |
| 177 | /*-------------------------------------------------
|
| 145 | 178 | set_display - set display state
|
| 146 | 179 | -------------------------------------------------*/
|
| 147 | 180 | |
| r6363 | r6364 | |
| 166 | 199 | static void reset_counters(const device_config *device)
|
| 167 | 200 | {
|
| 168 | 201 | set_interrupt(device, 0);
|
| 202 | set_drq(device, 0);
|
| 169 | 203 | }
|
| 170 | 204 | |
| 171 | 205 | /*-------------------------------------------------
|
| 172 | | update_hrtc_timer -
|
| 206 | update_hrtc_timer - update horizontal retrace
|
| 207 | timer
|
| 173 | 208 | -------------------------------------------------*/
|
| 174 | 209 | |
| 175 | 210 | static void update_hrtc_timer(upd3301_t *upd3301, int state)
|
| r6363 | r6364 | |
| 185 | 220 | }
|
| 186 | 221 | |
| 187 | 222 | /*-------------------------------------------------
|
| 188 | | update_vrtc_timer -
|
| 223 | update_vrtc_timer - update vertical retrace
|
| 224 | timer
|
| 189 | 225 | -------------------------------------------------*/
|
| 190 | 226 | |
| 191 | 227 | static void update_vrtc_timer(upd3301_t *upd3301, int state)
|
| r6363 | r6364 | |
| 198 | 234 | }
|
| 199 | 235 | |
| 200 | 236 | /*-------------------------------------------------
|
| 201 | | recompute_parameters -
|
| 237 | recompute_parameters - recompute screen
|
| 238 | geometry parameters
|
| 202 | 239 | -------------------------------------------------*/
|
| 203 | 240 | |
| 204 | 241 | static void recompute_parameters(const device_config *device)
|
| r6363 | r6364 | |
| 283 | 320 | |
| 284 | 321 | case 1: /* status */
|
| 285 | 322 | data = upd3301->status;
|
| 323 | upd3301->status &= ~(UPD3301_STATUS_LP | UPD3301_STATUS_E |UPD3301_STATUS_N | UPD3301_STATUS_U);
|
| 286 | 324 | break;
|
| 287 | 325 | }
|
| 288 | 326 | |
| r6363 | r6364 | |
| 423 | 461 | |
| 424 | 462 | case UPD3301_COMMAND_RESET_COUNTERS:
|
| 425 | 463 | if (LOG) logerror("UPD3301 '%s' Reset Counters\n", device->tag);
|
| 464 | upd3301->mode = MODE_RESET_COUNTERS;
|
| 426 | 465 | reset_counters(device);
|
| 427 | 466 | break;
|
| 428 | 467 | }
|
| r6363 | r6364 | |
| 439 | 478 | }
|
| 440 | 479 | |
| 441 | 480 | /*-------------------------------------------------
|
| 481 | draw_row - draw character row
|
| 482 | -------------------------------------------------*/
|
| 483 | |
| 484 | static void draw_row(const device_config *device, bitmap_t *bitmap)
|
| 485 | {
|
| 486 | upd3301_t *upd3301 = get_safe_token(device);
|
| 487 | int sx, lc;
|
| 488 | |
| 489 | for (lc = 0; lc < upd3301->r; lc++)
|
| 490 | {
|
| 491 | for (sx = 0; sx < upd3301->h; sx++)
|
| 492 | {
|
| 493 | int y = upd3301->y + lc;
|
| 494 | UINT8 cc = upd3301->data_fifo[sx][!upd3301->input_fifo];
|
| 495 | int hlgt = 0;
|
| 496 | int rvv = 0;
|
| 497 | int vsp = 0;
|
| 498 | int sl0 = 0;
|
| 499 | int sl12 = 0;
|
| 500 | int csr = upd3301->cm && upd3301->cursor_blink && ((y / upd3301->r) == upd3301->cy) && (sx == upd3301->cx);
|
| 501 | int gpa = 0;
|
| 502 | |
| 503 | upd3301->display_func(device, bitmap, y, sx, cc, lc, hlgt, rvv, vsp, sl0, sl12, csr, gpa);
|
| 504 | }
|
| 505 | }
|
| 506 | |
| 507 | upd3301->y += upd3301->r;
|
| 508 | }
|
| 509 | |
| 510 | /*-------------------------------------------------
|
| 442 | 511 | upd3301_dack_w - DMA acknowledge write
|
| 443 | 512 | -------------------------------------------------*/
|
| 444 | 513 | |
| 445 | 514 | WRITE8_DEVICE_HANDLER( upd3301_dack_w )
|
| 446 | 515 | {
|
| 447 | | logerror("DMA WRITE %02x\n", data);
|
| 516 | upd3301_t *upd3301 = get_safe_token(device);
|
| 517 | |
| 518 | if (upd3301->data_fifo_pos < upd3301->h)
|
| 519 | {
|
| 520 | upd3301->data_fifo[upd3301->data_fifo_pos][upd3301->input_fifo] = data;
|
| 521 | upd3301->data_fifo_pos++;
|
| 522 | }
|
| 523 | else
|
| 524 | {
|
| 525 | upd3301->attr_fifo[upd3301->attr_fifo_pos][upd3301->input_fifo] = data;
|
| 526 | upd3301->attr_fifo_pos++;
|
| 527 | }
|
| 528 | |
| 529 | if ((upd3301->data_fifo_pos == upd3301->h) && (upd3301->attr_fifo_pos == (upd3301->a << 1)))
|
| 530 | {
|
| 531 | upd3301->input_fifo = !upd3301->input_fifo;
|
| 532 | upd3301->data_fifo_pos = 0;
|
| 533 | upd3301->attr_fifo_pos = 0;
|
| 534 | draw_row(device, upd3301->bitmap);
|
| 535 | }
|
| 536 | |
| 537 | if (upd3301->y == (upd3301->l * upd3301->r))
|
| 538 | {
|
| 539 | /* end DMA transfer */
|
| 540 | set_drq(device, 0);
|
| 541 | }
|
| 448 | 542 | }
|
| 449 | 543 | |
| 450 | 544 | /*-------------------------------------------------
|
| r6363 | r6364 | |
| 457 | 551 | |
| 458 | 552 | if (upd3301->status & UPD3301_STATUS_VE)
|
| 459 | 553 | {
|
| 554 | upd3301->y = 0;
|
| 555 | upd3301->bitmap = bitmap;
|
| 556 | upd3301->data_fifo_pos = 0;
|
| 557 | upd3301->attr_fifo_pos = 0;
|
| 558 | |
| 559 | upd3301->cursor_frame++;
|
| 560 | |
| 561 | if (upd3301->cursor_frame == upd3301->b)
|
| 562 | {
|
| 563 | upd3301->cursor_frame = 0;
|
| 564 | upd3301->cursor_blink = !upd3301->cursor_blink;
|
| 565 | }
|
| 566 | |
| 567 | upd3301->attr_frame++;
|
| 568 | |
| 569 | if (upd3301->attr_frame == (upd3301->b << 1))
|
| 570 | {
|
| 571 | upd3301->attr_frame = 0;
|
| 572 | upd3301->attr_blink = !upd3301->attr_blink;
|
| 573 | }
|
| 574 | |
| 460 | 575 | /* start DMA transfer */
|
| 461 | | //devcb_call_write_line(&upd3301->out_drq_func, 1);
|
| 576 | set_drq(device, 1);
|
| 462 | 577 | }
|
| 463 | 578 | else
|
| 464 | 579 | {
|
| r6363 | r6364 | |
| 486 | 601 | assert(upd3301->screen != NULL);
|
| 487 | 602 | |
| 488 | 603 | /* get character width */
|
| 604 | upd3301->display_func = intf->display_func;
|
| 489 | 605 | upd3301->width = intf->width;
|
| 490 | 606 | |
| 491 | 607 | /* create the timers */
|
| r6363 | r6364 | |
| 510 | 626 | upd3301->r = 10;
|
| 511 | 627 | upd3301->v = 6;
|
| 512 | 628 | upd3301->z = 32;
|
| 629 | upd3301->status = 0;
|
| 513 | 630 | |
| 631 | set_interrupt(device, 0);
|
| 632 | set_drq(device, 0);
|
| 633 | |
| 514 | 634 | recompute_parameters(device);
|
| 515 | 635 | }
|
| 516 | 636 | |
src/mess/video/upd3301.h
| r6363 | r6364 | |
| 52 | 52 | TYPE DEFINITIONS
|
| 53 | 53 | ***************************************************************************/
|
| 54 | 54 | |
| 55 | | typedef void (*upd3301_display_pixels_func)(const device_config *device, bitmap_t *bitmap, int y, int x, UINT8 cc, UINT8 lc, int hlgt, int rvv, int vsp, int sl0, int sl12, int csr, int gpa);
|
| 56 | | #define UPD3301_DISPLAY_PIXELS(name) void name(const device_config *device, bitmap_t *bitmap, int y, int x, UINT8 cc, UINT8 lc, int hlgt, int rvv, int vsp, int sl0, int sl12, int csr, int gpa)
|
| 55 | typedef void (*upd3301_display_pixels_func)(const device_config *device, bitmap_t *bitmap, int y, int sx, UINT8 cc, UINT8 lc, int hlgt, int rvv, int vsp, int sl0, int sl12, int csr, int gpa);
|
| 56 | #define UPD3301_DISPLAY_PIXELS(name) void name(const device_config *device, bitmap_t *bitmap, int y, int sx, UINT8 cc, UINT8 lc, int hlgt, int rvv, int vsp, int sl0, int sl12, int csr, int gpa)
|
| 57 | 57 | |
| 58 | 58 | typedef struct _upd3301_interface upd3301_interface;
|
| 59 | 59 | struct _upd3301_interface
|
src/mess/drivers/pc8001.c
| r6363 | r6364 | |
| 2 | 2 | |
| 3 | 3 | http://www2.odn.ne.jp/~haf09260/Pc80/EnrPc.htm |
| 4 | 4 | http://home1.catvmics.ne.jp/~kanemoto/n80/inside.html |
| 5 | http://www.geocities.jp/retro_zzz/machines/nec/8001/index.html |
| 5 | 6 | |
| 6 | 7 | */ |
| 7 | 8 | |
| r6363 | r6364 | |
| 9 | 10 | |
| 10 | 11 | TODO: |
| 11 | 12 | |
| 13 | - 8257dma has write modes flipped (should be 1=r, 2=w) |
| 12 | 14 | - uPD3301 |
| 13 | 15 | - PCG1000 |
| 14 | 16 | - Intel 8251 |
| r6363 | r6364 | |
| 84 | 86 | |
| 85 | 87 | pc8001_state *state = space->machine->driver_data; |
| 86 | 88 | |
| 89 | /* characters per line */ |
| 90 | state->width80 = BIT(data, 0); |
| 91 | |
| 92 | /* color mode */ |
| 93 | state->color = BIT(data, 1); |
| 94 | |
| 87 | 95 | /* cassette motor */ |
| 88 | 96 | cassette_change_state(state->cassette, BIT(data, 3) ? CASSETTE_MOTOR_ENABLED : CASSETTE_MOTOR_DISABLED, CASSETTE_MASK_MOTOR); |
| 89 | 97 | } |
| r6363 | r6364 | |
| 382 | 390 | { |
| 383 | 391 | pc8001_state *state = device->machine->driver_data; |
| 384 | 392 | |
| 385 | | UINT8 data = state->char_rom[(cc << 4) | lc]; |
| 393 | UINT8 data = state->char_rom[(cc << 3) | lc]; |
| 386 | 394 | int i; |
| 387 | 395 | |
| 388 | | for (i = 0; i < 8; i++) |
| 396 | if (lc >= 8) return; |
| 397 | if (csr) data = 0xff; |
| 398 | |
| 399 | if (state->width80) |
| 389 | 400 | { |
| 390 | | int color = BIT(data, i); |
| 401 | for (i = 0; i < 8; i++) |
| 402 | { |
| 403 | int color = BIT(data, 7) ^ rvv; |
| 391 | 404 | |
| 392 | | *BITMAP_ADDR16(tmpbitmap, y, x + i) = color; |
| 405 | *BITMAP_ADDR16(bitmap, y, (sx * 8) + i) = color; |
| 406 | |
| 407 | data <<= 1; |
| 408 | } |
| 393 | 409 | } |
| 410 | else |
| 411 | { |
| 412 | if (sx % 2) return; |
| 413 | |
| 414 | for (i = 0; i < 8; i++) |
| 415 | { |
| 416 | int color = BIT(data, 7) ^ rvv; |
| 417 | |
| 418 | *BITMAP_ADDR16(bitmap, y, (sx/2 * 16) + (i * 2)) = color; |
| 419 | *BITMAP_ADDR16(bitmap, y, (sx/2 * 16) + (i * 2) + 1) = color; |
| 420 | |
| 421 | data <<= 1; |
| 422 | } |
| 423 | } |
| 394 | 424 | } |
| 395 | 425 | |
| 396 | 426 | static WRITE_LINE_DEVICE_HANDLER( pc8001_vrtc_w ) |
| r6363 | r6364 | |
| 612 | 642 | |
| 613 | 643 | ROM_START( pc8001 ) |
| 614 | 644 | ROM_REGION( 0x6000, "n80", 0 ) |
| 615 | | ROM_SYSTEM_BIOS( 0, "v101", "N80-BASIC v1.01" ) |
| 645 | ROM_SYSTEM_BIOS( 0, "v101", "N-BASIC v1.01" ) |
| 616 | 646 | ROMX_LOAD( "n80v101.rom", 0x00000, 0x6000, CRC(a2cc9f22) SHA1(6d2d838de7fea20ddf6601660d0525d5b17bf8a3), ROM_BIOS(1) ) |
| 617 | | ROM_SYSTEM_BIOS( 1, "v102", "N80-BASIC v1.02" ) |
| 647 | ROM_SYSTEM_BIOS( 1, "v102", "N-BASIC v1.02" ) |
| 618 | 648 | ROMX_LOAD( "n80v102.rom", 0x00000, 0x6000, CRC(ed01ca3f) SHA1(b34a98941499d5baf79e7c0e5578b81dbede4a58), ROM_BIOS(2) ) |
| 619 | | ROM_SYSTEM_BIOS( 2, "v110", "N80-BASIC v1.10" ) |
| 649 | ROM_SYSTEM_BIOS( 2, "v110", "N-BASIC v1.10" ) |
| 620 | 650 | ROMX_LOAD( "n80v110.rom", 0x00000, 0x6000, CRC(1e02d93f) SHA1(4603cdb7a3833e7feb257b29d8052c872369e713), ROM_BIOS(3) ) |
| 621 | 651 | |
| 622 | 652 | ROM_REGION( 0x800, "chargen", 0) |