Previous 15994 Revisions Next

r9378 Thursday 14th October, 2010 at 08:12:36 UTC by Robbbert
[MBEE] mbee256 - fixed keyboard.
[src/mess/drivers]mbee.c
[src/mess/machine]mbee.c

src/mess/machine/mbee.c
r9377r9378
1515
1616static size_t mbee_size;
1717static UINT8 mbee_clock_pulse;
18static UINT8 mbee256_key_available;
1819static UINT8 fdc_status = 0;
1920static UINT8 mbee_0a;
2021static running_device *mbee_fdc;
r9377r9378
6364
6465static READ8_DEVICE_HANDLER( pio_port_b_r )
6566{
66   UINT8 data = z80pio_pb_r(mbee_z80pio,0) & 0x7e;
67   UINT8 data = 0;
6768
68   if (cassette_input(mbee_cassette) > 0.03)
69      data |= 0x01;
69   if (cassette_input(mbee_cassette) > 0.03) data |= 1;
7070
7171   data |= mbee_clock_pulse;
72   data |= mbee256_key_available;
7273
7374   mbee_clock_pulse = 0;
7475
r9377r9378
147148
148149static UINT8 mbee256_was_pressed[15] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 };
149150static UINT8 mbee256_q[20];
150static UINT8 mbee256_q_pos = 0;
151static UINT8 mbee256_q_pos;
151152
152153static TIMER_CALLBACK( mbee256_kbd )
153154{
154    /* Keyboard scanner is a '3870' chip. It is not clocked, but is triggered by each read of port 18.
155    When a key is detected, it sets bit 1 of port 2 (one of the pio input lines). The next read of
156    port 18 will clear this line. The 3870 can store up to 9 keys, and has separate scan codes for
157    keys being pressed and being released. With no data sheet available, the following is a guess. */
155    /* Keyboard scanner is a '3870' chip. Its speed of operation is determined by a 15k resistor on
156    pin 2 (XTL2) and is therefore unknown. If a key change is detected (up or down), the /strobe
157    line activates, sending a high to bit 1 of port 2 (one of the pio input lines). The next read of
158    port 18 will clear this line, and read the key scancode. It will also signal the 3870 that the key
159    data has been read, on pin 38 (/extint). The 3870 can cache up to 9 keys. With no data sheet
160    available, the following is a guess. */
158161
159   UINT8 i, j, scancode;
160   UINT8 pressed[15] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 };
162   UINT8 i, j;
163   UINT8 pressed[15];
161164   char kbdrow[6];
162165
163166
164    /* see what is pressed */
167   /* see what is pressed */
165168   for (i = 0; i < 15; i++)
166169   {
167170      sprintf(kbdrow,"LINE%d",i);
168171      pressed[i] = (input_port_read(machine, kbdrow));
169172   }
170173
171    /* find what has changed */
174   /* find what has changed */
172175   for (i = 0; i < 15; i++)
173176   {
174177      if (pressed[i] != mbee256_was_pressed[i])
r9377r9378
178181         {
179182            if (BIT(pressed[i]^mbee256_was_pressed[i], j))
180183            {
181               scancode = (i << 3) | j | (BIT(pressed[i], j) ? 0x80 : 0);
182184               /* put it in the queue */
183               mbee256_q[mbee256_q_pos] = scancode;
185               mbee256_q[mbee256_q_pos] = (i << 3) | j | (BIT(pressed[i], j) ? 0x80 : 0);
184186               if (mbee256_q_pos < 19) mbee256_q_pos++;
185187            }
186188         }
r9377r9378
188190      }
189191   }
190192
191    /* if anything queued, cause an interrupt */
193   /* if anything queued, cause an interrupt */
192194   if (mbee256_q_pos)
193   {
194      i = z80pio_pb_r(mbee_z80pio,0);
195      z80pio_pb_w(mbee_z80pio, 0, i | 2);
196   }
195      mbee256_key_available = 2; // set irq
197196}
198197
199198READ8_HANDLER( mbee256_18_r )
200199{
201   UINT8 i, ret = 5; // no idea what the 'nokey' value should be
200   UINT8 i;
201   UINT8 data = mbee256_q[0]; // get oldest key
202
202203   if (mbee256_q_pos)
203204   {
204205      mbee256_q_pos--;
205      ret = mbee256_q[0]; // get oldest key
206206      for (i = 0; i < mbee256_q_pos; i++) mbee256_q[i] = mbee256_q[i+1]; // ripple queue
207207   }
208208
209   z80pio_pb_w(mbee_z80pio, 0, z80pio_pb_r(mbee_z80pio,0) & 0xfd); // clear irq
210
211    /* time delay of 0.01uf cap and 1.5k resistor */
212   timer_set(space->machine, ATTOTIME_IN_USEC(15), NULL, 0, mbee256_kbd);
213
214    /* get next char and return it */
215   
216   return ret;
209   mbee256_key_available = 0; // clear irq
210   return data;
217211}
218212
219213
r9377r9378
472466    The bios will support 256 PAKs, although normally only
473467    8 are available in hardware. Each PAK is normally a 4K
474468    ROM. If 8K ROMs are used, the 2nd half becomes PAK+8,
475    thus 16 PAKs in total. This is what we support.
469    thus 16 PAKs in total. This is used in the PC85 models.
476470
477471************************************************************/
478472
r9377r9378
725719   memory_configure_bank(machine, "bank8h", 0, 1, &RAM[0x0800],  0x0000); // rom
726720
727721   timer_pulse(machine, ATTOTIME_IN_HZ(1),NULL,0,mbee_rtc_irq);   /* timer for rtc */
722   timer_pulse(machine, ATTOTIME_IN_HZ(25),NULL,0,mbee256_kbd);   /* timer for kbd */
728723}
729724
730725
src/mess/drivers/mbee.c
r9377r9378
7474
7575    - Printer needs to be understood and fixed.
7676
77    - Roms for mbeepc to be checked against ubee512
78
7977    - Fix Paste (it loses most of the characters)
8078
8179    - RTC for 256TC works, but it is supposed to be an option on other
r9377r9378
8482    - Most early models have a clock in Telcom, and in the menu. It doesn't
8583      work.
8684
87    - 256TC keyboard IRQ is active all the time, it needs to be rewritten
88
8985    - The Monitor program on 128k and 256TC crashes the system. This appears
9086      to be a MAME core bug involving the z80pio.
9187

Previous 15994 Revisions Next


© 1998-2018 The MESS Team