src/mess/video/mbee.c
| r4421 | r4422 | |
| 83 | 83 | colorram[offset] = data; |
| 84 | 84 | } |
| 85 | 85 | |
| 86 | static const char *const keynames[] = { "LINE0", "LINE1", "LINE2", "LINE3", "LINE4", "LINE5", "LINE6", "LINE7" }; |
| 87 | |
| 88 | /* The "extra" keys are non-standard and will be removed eventually */ |
| 86 | 89 | static int keyboard_matrix_r(running_machine *machine, int offs) |
| 87 | 90 | { |
| 88 | 91 | int port = (offs >> 7) & 7; |
| 89 | 92 | int bit = (offs >> 4) & 7; |
| 90 | 93 | int extra = input_port_read(machine, "EXTRA"); |
| 91 | 94 | int data = 0; |
| 92 | | static const char *const keynames[] = { "LINE0", "LINE1", "LINE2", "LINE3", "LINE4", "LINE5", "LINE6", "LINE7" }; |
| 93 | 95 | |
| 94 | | |
| 95 | 96 | data = (input_port_read(machine, keynames[port]) >> bit) & 1; |
| 96 | 97 | |
| 97 | 98 | if( extra & 0x01 ) /* extra: cursor up */ |
| r4421 | r4422 | |
| 119 | 120 | if( port == 7 && bit == 1 ) data = 1; /* Control */ |
| 120 | 121 | if( port == 2 && bit == 6 ) data = 1; /* V */ |
| 121 | 122 | } |
| 123 | |
| 122 | 124 | if( data ) |
| 123 | 125 | { |
| 124 | 126 | crt.lpen_lo = offs & 0xff; |
| r4421 | r4422 | |
| 375 | 377 | } |
| 376 | 378 | } |
| 377 | 379 | |
| 378 | | /* The 6845 can produce a variety of cursor shapes - all are emulated here */ |
| 380 | /* The 6845 can produce a variety of cursor shapes - all are emulated here |
| 381 | Need to find out if the 6545 works the same way */ |
| 379 | 382 | static void mc6845_cursor_configure(void) |
| 380 | 383 | { |
| 381 | 384 | UINT8 i,curs_type=0,r9,r10,r11; |
| r4421 | r4422 | |
| 447 | 450 | |
| 448 | 451 | VIDEO_UPDATE( mbee ) |
| 449 | 452 | { |
| 450 | | UINT8 y,z,chr,gfx; |
| 451 | | UINT16 mem,sy=0,sx=0,x,i; |
| 453 | UINT8 y,ra,chr,gfx; |
| 454 | UINT16 mem,sy=0,ma=0,x; |
| 452 | 455 | UINT8 speed = crt.cursor_top&0x20, flash = crt.cursor_top&0x40; // cursor modes |
| 453 | 456 | UINT16 cursor = (crt.cursor_address_hi<<8) | crt.cursor_address_lo; // get cursor position |
| 454 | 457 | UINT16 screen_home = (crt.screen_address_hi<<8) | crt.screen_address_lo; // screen home offset (usually zero) |
| 455 | 458 | |
| 456 | | for( i = 0; i < 0x380; i += 0x10 ) keyboard_matrix_r(screen->machine, i); |
| 457 | | |
| 458 | 459 | framecnt++; |
| 459 | 460 | |
| 460 | 461 | for (y = 0; y < crt.vertical_displayed; y++) // for each row of chars |
| 461 | 462 | { |
| 462 | | for (z = 0; z < crt.scan_lines+1; z++) // for each scanline |
| 463 | for (ra = 0; ra < (crt.scan_lines&15)+1; ra++) // for each scanline - RA4 is used as an update strobe for the keyboard |
| 463 | 464 | { |
| 464 | 465 | UINT16 *p = BITMAP_ADDR16(bitmap, sy++, 0); |
| 465 | 466 | |
| 466 | | for (x = sx; x < sx + crt.horizontal_displayed; x++) // for each character |
| 467 | for (x = ma; x < ma + crt.horizontal_displayed; x++) // for each character |
| 467 | 468 | { |
| 468 | 469 | UINT8 inv=0; |
| 469 | 470 | mem = (x + screen_home) & 0x7ff; |
| 470 | 471 | chr = videoram[mem]; |
| 471 | | |
| 472 | if ((x & 15) == 0) keyboard_matrix_r(screen->machine, x); // actually happens for every scanline of every character, but imposes too much unnecessary overhead */ |
| 472 | 473 | /* process cursor */ |
| 473 | 474 | if ((((!flash) && (!speed)) || // (5,6)=(0,0) = cursor on always |
| 474 | 475 | ((flash) && (speed) && (framecnt & 0x10)) || // (5,6)=(1,1) = cycle per 32 frames |
| 475 | 476 | ((flash) && (!speed) && (framecnt & 8))) && // (5,6)=(0,1) = cycle per 16 frames |
| 476 | 477 | (mem == cursor)) // displaying at cursor position? |
| 477 | | inv ^= mc6845_cursor[z]; // cursor scan row |
| 478 | inv ^= mc6845_cursor[ra]; // cursor scan row |
| 478 | 479 | |
| 479 | 480 | /* get pattern of pixels for that character scanline */ |
| 480 | | gfx = mbee_pcgram[(chr<<4) | z] ^ inv; |
| 481 | gfx = mbee_pcgram[(chr<<4) | ra] ^ inv; |
| 481 | 482 | |
| 482 | 483 | /* Display a scanline of a character (8 pixels) */ |
| 483 | 484 | *p = ( gfx & 0x80 ) ? 1 : 0; p++; |
| r4421 | r4422 | |
| 490 | 491 | *p = ( gfx & 0x01 ) ? 1 : 0; p++; |
| 491 | 492 | } |
| 492 | 493 | } |
| 493 | | sx+=crt.horizontal_displayed; |
| 494 | ma+=crt.horizontal_displayed; |
| 494 | 495 | } |
| 495 | 496 | return 0; |
| 496 | 497 | } |
| 497 | 498 | |
| 498 | 499 | VIDEO_UPDATE( mbeeic ) |
| 499 | 500 | { |
| 500 | | UINT8 y,z,chr,gfx,fg,bg; |
| 501 | | UINT16 mem,sy=0,sx=0,x,i,col; |
| 501 | UINT8 y,ra,chr,gfx,fg,bg; |
| 502 | UINT16 mem,sy=0,ma=0,x,col; |
| 502 | 503 | UINT8 speed = crt.cursor_top&0x20, flash = crt.cursor_top&0x40; // cursor modes |
| 503 | 504 | UINT16 cursor = (crt.cursor_address_hi<<8) | crt.cursor_address_lo; // get cursor position |
| 504 | 505 | UINT16 screen_home = (crt.screen_address_hi<<8) | crt.screen_address_lo; // screen home offset (usually zero) |
| 505 | 506 | UINT16 colourm = (mbee_pcg_color_latch & 0x0e) << 7; |
| 506 | 507 | |
| 507 | | for( i = 0; i < 0x380; i += 0x10 ) keyboard_matrix_r(screen->machine, i); |
| 508 | | |
| 509 | 508 | framecnt++; |
| 510 | 509 | |
| 511 | 510 | for (y = 0; y < crt.vertical_displayed; y++) // for each row of chars |
| 512 | 511 | { |
| 513 | | for (z = 0; z < crt.scan_lines+1; z++) // for each scanline |
| 512 | for (ra = 0; ra < (crt.scan_lines&15)+1; ra++) // for each scanline - RA4 is used as an update strobe for the keyboard |
| 514 | 513 | { |
| 515 | 514 | UINT16 *p = BITMAP_ADDR16(bitmap, sy++, 0); |
| 516 | 515 | |
| 517 | | for (x = sx; x < sx + crt.horizontal_displayed; x++) // for each character |
| 516 | for (x = ma; x < ma + crt.horizontal_displayed; x++) // for each character |
| 518 | 517 | { |
| 519 | 518 | UINT8 inv=0; |
| 520 | 519 | mem = (x + screen_home) & 0x7ff; |
| 521 | 520 | chr = videoram[mem]; |
| 522 | 521 | col = colorram[mem] | colourm; // read a byte of colour |
| 522 | if ((x & 15) == 0) keyboard_matrix_r(screen->machine, x); // actually happens for every scanline of every character, but imposes too much unnecessary overhead */ |
| 523 | 523 | |
| 524 | 524 | /* process cursor */ |
| 525 | 525 | if ((((!flash) && (!speed)) || // (5,6)=(0,0) = cursor on always |
| 526 | 526 | ((flash) && (speed) && (framecnt & 0x10)) || // (5,6)=(1,1) = cycle per 32 frames |
| 527 | 527 | ((flash) && (!speed) && (framecnt & 8))) && // (5,6)=(0,1) = cycle per 16 frames |
| 528 | 528 | (mem == cursor)) // displaying at cursor position? |
| 529 | | inv ^= mc6845_cursor[z]; // cursor scan row |
| 529 | inv ^= mc6845_cursor[ra]; // cursor scan row |
| 530 | 530 | |
| 531 | 531 | /* get pattern of pixels for that character scanline */ |
| 532 | | gfx = mbee_pcgram[(chr<<4) | z] ^ inv; |
| 532 | gfx = mbee_pcgram[(chr<<4) | ra] ^ inv; |
| 533 | 533 | fg = (col & 0x001f) | 64; // map to foreground palette |
| 534 | 534 | bg = (col & 0x07e0) >> 5; // and background palette |
| 535 | 535 | |
| r4421 | r4422 | |
| 544 | 544 | *p = ( gfx & 0x01 ) ? fg : bg; p++; |
| 545 | 545 | } |
| 546 | 546 | } |
| 547 | | sx+=crt.horizontal_displayed; |
| 547 | ma+=crt.horizontal_displayed; |
| 548 | 548 | } |
| 549 | 549 | return 0; |
| 550 | 550 | } |