<< Previous Message Main Index Next Message >>
<< Previous Message in Thread This Month Next Message in Thread >>
Date   : Mon, 12 Feb 1996 06:48:16 +0000 (GMT)
From   : Tom Seddon <T.W.Seddon@...>
Subject: THAT KEYBOARD...

I HATE THE BBC KEYBOARD

I have been hacking away at my BBC emulator since about 1:00 this morning.
I have fixed some dreadful VIA bugs which I hadn't noticed. I have even
dived in and implemented input latching, so ORx/IRx and the values on Px
are separate (I've been meaning to do that for a while). However... THAT
KEYBOARD STILL DOES NOT WORK!

I've been through the mailing list archives, and I've found nothing of 
much use. I am well and truly stuck. Here is what I do:

I have an array: byte BBCKeyFlags[16][16]. The first subscript is the 
row, the second the colum. These are updated on each PC keyboard 
interrupt, and 1 is placed in the appropriate array item if the key is 
pressed, and 0 if it is released. Furthermore if a key is pressed, and it 
isn't already pressed (the PC keeps generating keypress interrupts as you 
hold down a key, that's why), a CA2 interrupt is sent to the user VIA, 
which can be serviced when the interrupt routine stops. (I tried only 
sending interrupts when the keyboard enable line (latch bit 3) was high 
but it didn't work)

Writing to port A, or writing the addressable latch, causes a keyboard 
scan of the current position (according to PA) and if a key is pressedin 
the row (or is it column? I can't remember) being scanned then another 
CA2 interrupt is generated. (All that only happens when latch bit 3 is 
set to zero)

I also have a system VIA register list onscreen (updated after every
instruction), so after each keypress I can watch the IFR change to 81,
then PA/ORA count down from 9 to 0 (with bit 3 of the latch toggling now
and again) and neatly not notice the key I've just pressed :-)

I assume that once the OS finds a row (column?) with a key being pressed
on it it will count from 9 to 0 in the high nybble to see which key has
been pressed, but since my emulator has never done this I don't know for
sure ;-(

I thought that perhaps the keypress was being lost before the scan routine
had finished (keypresses in BBCKeyFlags[][] are recorded in real time,
although the emulator isn't real-time yet--since I have debugging output
after every instruction the emulation is very slow (the 100hz timer is
more like 0.1hz)--but even if I hold the key down until IER bit 1 comes
back on again nothing happens. I've tried waiting for the next T1
interrupt (there's about 10 seconds between each one...), synchronising my
keypresses so the keyboard interrupt routine leaves the moment the T1
interrupt occurs (an impressive feat of timing, I think I managed to get
it down to 1 instruction between the end of one interrupt and the
beginning of the other), and various other ploys... but to no avail. 

I am at my wits' end. I'm sure I've said that before about other problems 
but this time I am well and truly STUCK STUCK STUCK STUCK. I have been 
through the source code to Xbeeb 0.2, BeebEm (For Windows) and James 
Bonfield's emulator, and the resultant keyboard code is a bizarre cross 
between XBeeb's and James Bonfield's. However it still doesn't work, and 
I've no idea what's going on. Any pointers would be very, very gratefully 
received.

--Tom

PS When I say 'row (column?)', it doesn't mean I don't know which, just
that I can't remember offhand... I've been through my source code several
times to make sure the row and column are in the right order, and I'm now
pretty sure they are. 

     .                     ** Tom Seddon **                     .
    / \              E-mail: T.W.Seddon@...              / \
   /(o)\                                                      /(o)\
  /=====\            Call out GANDHU and be happy            /=====\
 /       \                                                  /       \
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

<< Previous Message Main Index Next Message >>
<< Previous Message in Thread This Month Next Message in Thread >>