src/mess/drivers/fmtowns.c
| r6369 | r6370 | |
| 607 | 607 | /* |
| 608 | 608 | * Port 0x600-0x607 - Keyboard controller (8042 MCU) |
| 609 | 609 | * |
| 610 | * Sends two-byte code on each key press and release. |
| 611 | * First byte has the MSB set, and contains shift/ctrl/alt/kana flags |
| 612 | * Known bits: |
| 613 | * bit 7 = always 1 |
| 614 | * bit 4 = key release |
| 615 | * bit 3 = ctrl (yet to be confirmed) |
| 616 | * bit 2 = shift (yet to be confirmed) |
| 617 | * |
| 618 | * Second byte has the MSB reset, and contains the scancode of the key |
| 619 | * pressed or released. |
| 620 | * bit 7 = always 0 |
| 621 | * bits 6-0 = key scancode |
| 610 | 622 | */ |
| 611 | 623 | static void towns_kb_sendcode(running_machine* machine, UINT8 scancode, int release) |
| 612 | 624 | { |
| r6369 | r6370 | |
| 1631 | 1643 | { |
| 1632 | 1644 | int x,y; |
| 1633 | 1645 | UINT8 colour; |
| 1646 | UINT32 colourcode; |
| 1634 | 1647 | UINT8 row; // JIS row number |
| 1635 | 1648 | UINT16 code; |
| 1636 | 1649 | int off = 0; |
| r6369 | r6370 | |
| 1657 | 1670 | } |
| 1658 | 1671 | |
| 1659 | 1672 | // draw text layer |
| 1673 | /* |
| 1674 | * Text layer format |
| 1675 | * 2 bytes per character at both 0xc8000 and 0xca000 |
| 1676 | * 0xc8xxx: Byte 1: ASCII character |
| 1677 | * Byte 2: Attributes |
| 1678 | * bits 2-0: GRB (or is it BRG?) |
| 1679 | * bit 3: Inverse |
| 1680 | * bit 4: Blink |
| 1681 | * bit 5: high brightness |
| 1682 | * bits 7-6: Kanji high/low |
| 1683 | * |
| 1684 | * If either bits 6 or 7 are high, then a fullwidth Kanji character is displayed |
| 1685 | * at this location. The character displayed is represented by a 2-byte |
| 1686 | * JIS code at the same offset at 0xca000. |
| 1687 | */ |
| 1660 | 1688 | if(towns_tvram_enable != 0) |
| 1661 | 1689 | { |
| 1662 | 1690 | for(y=0;y<40;y++) |
| r6369 | r6370 | |
| 1664 | 1692 | off = 160 * y; |
| 1665 | 1693 | for(x=0;x<80;x++) |
| 1666 | 1694 | { |
| 1667 | | colour = towns_txtvram[off+1] & 0x0f; |
| 1695 | colour = towns_txtvram[off+1] & 0x07; |
| 1696 | if(towns_txtvram[off+1] & 0x20) |
| 1697 | { // Bright |
| 1698 | colourcode = (((colour & 0x02) ? 0xfe : 0x00) << 16) |
| 1699 | | (((colour & 0x04) ? 0xfe : 0x00) << 8) |
| 1700 | | ((colour & 0x01) ? 0xfe : 0x00); |
| 1701 | } |
| 1702 | else |
| 1703 | { |
| 1704 | colourcode = (((colour & 0x02) ? 0x7f : 0x00) << 16) |
| 1705 | | (((colour & 0x04) ? 0x7f : 0x00) << 8) |
| 1706 | | ((colour & 0x01) ? 0x7f : 0x00); |
| 1707 | } |
| 1708 | |
| 1668 | 1709 | if((towns_txtvram[off+1] & 0xc0) != 0) |
| 1669 | 1710 | { // double width |
| 1670 | | // TODO: work out exactly how these map to the font ROM |
| 1671 | | // Numbers are tiles 0x70-0x79 |
| 1672 | | // lowercase characters are from tile 0x160 |
| 1673 | | // uppercase characters are from tile 0x260 |
| 1674 | 1711 | if(towns_txtvram[off+1] & 0x40) |
| 1675 | 1712 | { |
| 1676 | 1713 | row = (towns_txtvram[off+0x2000] - 32); |
| r6369 | r6370 | |
| 1691 | 1728 | + (((row-16) & 0x70) * 0x60); |
| 1692 | 1729 | } |
| 1693 | 1730 | drawgfx_transpen_raw(bitmap,cliprect,screen->machine->gfx[1],code, |
| 1694 | | (towns_palette_r[colour] << 16) |
| 1695 | | | (towns_palette_g[colour] << 8) |
| 1696 | | | (towns_palette_b[colour]), |
| 1697 | | 0,0,x*8,y*16,0); |
| 1731 | colourcode, 0,0,x*8,y*16,0); |
| 1698 | 1732 | } |
| 1699 | 1733 | } |
| 1700 | 1734 | else |
| 1701 | 1735 | { |
| 1702 | 1736 | drawgfx_transpen_raw(bitmap,cliprect,screen->machine->gfx[0],towns_txtvram[off], |
| 1703 | | (towns_palette_r[colour] << 16) |
| 1704 | | | (towns_palette_g[colour] << 8) |
| 1705 | | | (towns_palette_b[colour]), |
| 1706 | | 0,0,x*8,y*16,0); |
| 1737 | colourcode, 0,0,x*8,y*16,0); |
| 1707 | 1738 | } |
| 1708 | 1739 | off += 2; |
| 1709 | 1740 | } |