Previous 15994 Revisions Next

r15815 Wednesday 8th August, 2012 at 14:47:47 UTC by Curt Coder
[PROF80] Replaced keyboard hack with ASCII keyboard. (nw)
[src/mess/machine]ecb_grip.c ecb_grip.h

src/mess/machine/ecb_grip.c
r15814r15815
495495};
496496
497497
498//-------------------------------------------------
499//  ASCII_KEYBOARD_INTERFACE( kb_intf )
500//-------------------------------------------------
498501
502WRITE8_MEMBER( grip_device::kb_w )
503{
504   if (!m_kbf)
505   {
506      m_keydata = data;
507
508      // trigger GRIP 8255 port C bit 2 (_STBB)
509      m_ppi->pc2_w(0);
510      m_ppi->pc2_w(1);
511   }
512}
513
514static ASCII_KEYBOARD_INTERFACE( kb_intf )
515{
516   DEVCB_DEVICE_MEMBER(DEVICE_SELF_OWNER, grip_device, kb_w)
517};
518
519
520
499521//**************************************************************************
500522//  MACHINE CONFIGURATION
501523//**************************************************************************
r15814r15815
523545   MCFG_I8255A_ADD(I8255A_TAG, ppi_intf)
524546   MCFG_Z80STI_ADD(Z80STI_TAG, XTAL_16MHz/4, sti_intf)
525547   MCFG_CENTRONICS_PRINTER_ADD(CENTRONICS_TAG, standard_centronics)
548   MCFG_ASCII_KEYBOARD_ADD("keyboard", kb_intf)
526549MACHINE_CONFIG_END
527550
528551
r15814r15815
547570//-------------------------------------------------
548571
549572static INPUT_PORTS_START( grip )
550   PORT_START("ROW0")
551   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("HELP") PORT_CODE(KEYCODE_TILDE)
552   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_1) PORT_CHAR('1') PORT_CHAR('!')
553   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_2) PORT_CHAR('2') PORT_CHAR('@')
554   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_3) PORT_CHAR('3') PORT_CHAR('#')
555   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_4) PORT_CHAR('4') PORT_CHAR('$')
556   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_5) PORT_CHAR('5') PORT_CHAR('%')
557   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_6) PORT_CHAR('6') PORT_CHAR('^')
558   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_7) PORT_CHAR('7') PORT_CHAR('&')
559
560   PORT_START("ROW1")
561   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_8) PORT_CHAR('8') PORT_CHAR('*')
562   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_9) PORT_CHAR('9') PORT_CHAR('(')
563   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_0) PORT_CHAR('0') PORT_CHAR(')')
564   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_MINUS) PORT_CHAR('-') PORT_CHAR('_')
565   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_EQUALS) PORT_CHAR('=') PORT_CHAR('+')
566   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("BACKSPACE") PORT_CODE(KEYCODE_BACKSPACE) PORT_CHAR(8)
567   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("DEL") PORT_CODE(KEYCODE_DEL)
568   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("Keypad -") PORT_CODE(KEYCODE_MINUS_PAD)
569
570   PORT_START("ROW2")
571   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("Keypad 7") PORT_CODE(KEYCODE_7_PAD)
572   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("Keypad 8") PORT_CODE(KEYCODE_8_PAD)
573   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("Keypad 9") PORT_CODE(KEYCODE_9_PAD)
574   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("TAB") PORT_CODE(KEYCODE_TAB) PORT_CHAR('\t')
575   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_Q) PORT_CHAR('q') PORT_CHAR('Q')
576   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_W) PORT_CHAR('w') PORT_CHAR('W')
577   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_E) PORT_CHAR('e') PORT_CHAR('E')
578   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_R) PORT_CHAR('r') PORT_CHAR('R')
579
580   PORT_START("ROW3")
581   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_T) PORT_CHAR('t') PORT_CHAR('T')
582   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_Y) PORT_CHAR('y') PORT_CHAR('Y')
583   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_U) PORT_CHAR('u') PORT_CHAR('U')
584   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_I) PORT_CHAR('i') PORT_CHAR('I')
585   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_O) PORT_CHAR('o') PORT_CHAR('O')
586   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_P) PORT_CHAR('p') PORT_CHAR('P')
587   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_OPENBRACE) PORT_CHAR('[') PORT_CHAR('{')
588   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_CLOSEBRACE) PORT_CHAR(']') PORT_CHAR('}')
589
590   PORT_START("ROW4")
591   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("ESC") PORT_CODE(KEYCODE_ESC) PORT_CHAR(UCHAR_MAMEKEY(ESC))
592   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("Keypad +") PORT_CODE(KEYCODE_PLUS_PAD)
593   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("Keypad 4") PORT_CODE(KEYCODE_4_PAD)
594   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("Keypad 5") PORT_CODE(KEYCODE_5_PAD)
595   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("Keypad 6") PORT_CODE(KEYCODE_6_PAD)
596   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_A) PORT_CHAR('a') PORT_CHAR('A')
597   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_S) PORT_CHAR('s') PORT_CHAR('S')
598   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_D) PORT_CHAR('d') PORT_CHAR('D')
599
600   PORT_START("ROW5")
601   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F) PORT_CHAR('f') PORT_CHAR('F')
602   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_G) PORT_CHAR('g') PORT_CHAR('G')
603   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_H) PORT_CHAR('h') PORT_CHAR('H')
604   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_J) PORT_CHAR('j') PORT_CHAR('J')
605   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_K) PORT_CHAR('k') PORT_CHAR('K')
606   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_L) PORT_CHAR('l') PORT_CHAR('L')
607   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_COLON) PORT_CHAR(';') PORT_CHAR(':')
608   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_QUOTE) PORT_CHAR('\'') PORT_CHAR('"')
609
610   PORT_START("ROW6")
611   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("RETURN") PORT_CODE(KEYCODE_ENTER) PORT_CHAR('\r')
612   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("LINE FEED") PORT_CODE(KEYCODE_ENTER_PAD)
613   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME(UTF8_UP) PORT_CODE(KEYCODE_UP) PORT_CHAR(UCHAR_MAMEKEY(UP))
614   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("Keypad 1") PORT_CODE(KEYCODE_1_PAD)
615   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("Keypad 2") PORT_CODE(KEYCODE_2_PAD)
616   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("Keypad 3") PORT_CODE(KEYCODE_3_PAD)
617   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_Z) PORT_CHAR('z') PORT_CHAR('Z')
618   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_X) PORT_CHAR('x') PORT_CHAR('X')
619
620   PORT_START("ROW7")
621   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_C) PORT_CHAR('c') PORT_CHAR('C')
622   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_V) PORT_CHAR('v') PORT_CHAR('V')
623   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_B) PORT_CHAR('b') PORT_CHAR('B')
624   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_N) PORT_CHAR('n') PORT_CHAR('N')
625   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_M) PORT_CHAR('m') PORT_CHAR('M')
626   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_COMMA) PORT_CHAR(',') PORT_CHAR('<')
627   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_STOP) PORT_CHAR('.') PORT_CHAR('>')
628   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_SLASH) PORT_CHAR('/') PORT_CHAR('?')
629
630   PORT_START("ROW8")
631   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME(UTF8_LEFT) PORT_CODE(KEYCODE_LEFT) PORT_CHAR(UCHAR_MAMEKEY(LEFT))
632   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME(UTF8_DOWN) PORT_CODE(KEYCODE_DOWN) PORT_CHAR(UCHAR_MAMEKEY(DOWN))
633   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME(UTF8_RIGHT) PORT_CODE(KEYCODE_RIGHT) PORT_CHAR(UCHAR_MAMEKEY(RIGHT))
634   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("Keypad 0") PORT_CODE(KEYCODE_0_PAD)
635   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("Keypad .") PORT_CODE(KEYCODE_ASTERISK)
636   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("SPACE") PORT_CODE(KEYCODE_SPACE) PORT_CHAR(' ')
637   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_KEYBOARD )
638   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_KEYBOARD )
639
640   PORT_START("ROW9")
641   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("LOCK") PORT_CODE(KEYCODE_CAPSLOCK) PORT_TOGGLE
642   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("LEFT SHIFT") PORT_CODE(KEYCODE_LSHIFT) PORT_CHAR(UCHAR_SHIFT_1)
643   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("RIGHT SHIFT") PORT_CODE(KEYCODE_RSHIFT)
644   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("LEFT CTRL") PORT_CODE(KEYCODE_LCONTROL) PORT_CHAR(UCHAR_MAMEKEY(LCONTROL))
645   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("RIGHT CTRL") PORT_CODE(KEYCODE_RCONTROL) PORT_CHAR(UCHAR_MAMEKEY(RCONTROL))
646
647573   PORT_START("J1")
648574   PORT_CONFNAME( 0x01, 0x00, "J1 EPROM Type")
649575   PORT_CONFSETTING( 0x00, "2732" )
r15814r15815
795721
796722
797723//-------------------------------------------------
798//  device_timer - handler timer events
799//-------------------------------------------------
800
801void grip_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
802{
803   if (!m_kbf)
804   {
805      scan_keyboard();
806   }
807}
808
809
810//-------------------------------------------------
811724//  vol0_w - volume 0
812725//-------------------------------------------------
813726
r15814r15815
1032945
1033946   return false;
1034947}
1035
1036
1037
1038//**************************************************************************
1039//  KEYBOARD HACK
1040//**************************************************************************
1041
1042static const UINT8 KEYCODES[3][9][8] =
1043{
1044   // unshifted
1045   {
1046   { 0x1e, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37 },
1047   { 0x38, 0x39, 0x30, 0x2d, 0x3d, 0x08, 0x7f, 0x2d },
1048   { 0x37, 0x38, 0x39, 0x09, 0x71, 0x77, 0x65, 0x72 },
1049   { 0x74, 0x79, 0x75, 0x69, 0x6f, 0x70, 0x5b, 0x5d },
1050   { 0x1b, 0x2b, 0x34, 0x35, 0x36, 0x61, 0x73, 0x64 },
1051   { 0x66, 0x67, 0x68, 0x6a, 0x6b, 0x6c, 0x3b, 0x27 },
1052   { 0x0d, 0x0a, 0x01, 0x31, 0x32, 0x33, 0x7a, 0x78 },
1053   { 0x63, 0x76, 0x62, 0x6e, 0x6d, 0x2c, 0x2e, 0x2f },
1054   { 0x04, 0x02, 0x03, 0x30, 0x2e, 0x20, 0x00, 0x00 }
1055   },
1056
1057   // shifted
1058   {
1059   { 0x1e, 0x21, 0x40, 0x23, 0x24, 0x25, 0x5e, 0x26 },
1060   { 0x2a, 0x28, 0x29, 0x5f, 0x2b, 0x08, 0x7f, 0x2d },
1061   { 0x37, 0x38, 0x39, 0x09, 0x51, 0x57, 0x45, 0x52 },
1062   { 0x54, 0x59, 0x55, 0x49, 0x4f, 0x50, 0x7b, 0x7d },
1063   { 0x1b, 0x2b, 0x34, 0x35, 0x36, 0x41, 0x53, 0x44 },
1064   { 0x46, 0x47, 0x48, 0x4a, 0x4b, 0x4c, 0x3a, 0x22 },
1065   { 0x0d, 0x0a, 0x01, 0x31, 0x32, 0x33, 0x5a, 0x58 },
1066   { 0x43, 0x56, 0x42, 0x4e, 0x4d, 0x3c, 0x3e, 0x3f },
1067   { 0x04, 0x02, 0x03, 0x30, 0x2e, 0x20, 0x00, 0x00 }
1068   },
1069
1070   // control
1071   {
1072   { 0x9e, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97 },
1073   { 0x98, 0x99, 0x90, 0x1f, 0x9a, 0x88, 0xff, 0xad },
1074   { 0xb7, 0xb8, 0xb9, 0x89, 0x11, 0x17, 0x05, 0x12 },
1075   { 0x14, 0x19, 0x15, 0x09, 0x0f, 0x10, 0x1b, 0x1d },
1076   { 0x9b, 0xab, 0xb4, 0xb5, 0xb6, 0x01, 0x13, 0x04 },
1077   { 0x06, 0x07, 0x08, 0x0a, 0x0b, 0x0c, 0x7e, 0x60 },
1078   { 0x8d, 0x8a, 0x81, 0xb1, 0xb2, 0xb3, 0x1a, 0x18 },
1079   { 0x03, 0x16, 0x02, 0x0e, 0x0d, 0x1c, 0x7c, 0x5c },
1080   { 0x84, 0x82, 0x83, 0xb0, 0xae, 0x00, 0x00, 0x00 }
1081   }
1082};
1083
1084void grip_device::scan_keyboard()
1085{
1086   static const char *const keynames[] = { "ROW0", "ROW1", "ROW2", "ROW3", "ROW4", "ROW5", "ROW6", "ROW7", "ROW8" };
1087   int table = 0, row, col;
1088   int keydata = -1;
1089
1090   if (ioport("ROW9")->read() & 0x07)
1091   {
1092      // shift, upper case
1093      table = 1;
1094   }
1095
1096   if (ioport("ROW9")->read() & 0x18)
1097   {
1098      // ctrl
1099      table = 2;
1100   }
1101
1102   // scan keyboard
1103   for (row = 0; row < 9; row++)
1104   {
1105      UINT8 data = ioport(keynames[row])->read();
1106
1107      for (col = 0; col < 8; col++)
1108      {
1109         if (!BIT(data, col))
1110         {
1111            // latch key data
1112            keydata = KEYCODES[table][row][col];
1113
1114            if (m_keydata != keydata)
1115            {
1116               m_keydata = keydata;
1117
1118               // trigger GRIP 8255 port C bit 2 (_STBB)
1119               m_ppi->pc2_w(0);
1120               m_ppi->pc2_w(1);
1121               return;
1122            }
1123         }
1124      }
1125   }
1126
1127   m_keydata = keydata;
1128}
src/mess/machine/ecb_grip.h
r15814r15815
1919#include "machine/ctronics.h"
2020#include "machine/ecbbus.h"
2121#include "machine/i8255.h"
22#include "machine/keyboard.h"
2223#include "machine/z80sti.h"
2324#include "sound/speaker.h"
2425#include "video/mc6845.h"
r15814r15815
5960   DECLARE_WRITE8_MEMBER( ppi_pc_w );
6061   DECLARE_READ8_MEMBER( sti_gpio_r );
6162   DECLARE_WRITE_LINE_MEMBER( speaker_w );
63   DECLARE_WRITE8_MEMBER( kb_w );
6264
6365   void crtc_update_row(mc6845_device *device, bitmap_rgb32 &bitmap, const rectangle &cliprect, UINT16 ma, UINT8 ra, UINT16 y, UINT8 x_count, INT8 cursor_x, void *param);
6466
r15814r15815
6769   virtual void device_start();
6870   virtual void device_reset();
6971    virtual void device_config_complete() { m_shortname = "grip"; }
70   virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
7172
7273   // device_ecbbus_card_interface overrides
7374   virtual UINT8 ecbbus_io_r(offs_t offset);
r15814r15815
8182   required_device<centronics_device> m_centronics;
8283   required_device<device_t> m_speaker;
8384
84   void scan_keyboard();
85
8685   // sound state
8786   int m_vol0;
8887   int m_vol1;

Previous 15994 Revisions Next


© 1998-2018 The MESS Team