Date : Mon, 05 Sep 1994 18:37:14 +0100 (BST)
From : Mark Cooke <ee2015@...>
Subject: Re: Fixed my bug - and keyboard stuff
>
> Firstly, I fixed my bug! 2^2 now returns 4. No offence to the person who
> wrote to me about it but I can't remember their name. Anyway, THANKS! He
> said that he had the same problem and it was caused by PLA not setting C
> and Z. Well, I thought, it's a shot in the dark but... yep, that's what
> it was. That would have taken me *ages* to find; I thank you from the
> bottom of my heart, whoever you were! Had you been here yesterday I'd
> have hugged ya [bet you're glad you weren't!].
Glad to have been of help...It's an odd error, and I fixed it quite by
chance the first time it happened - I was implementing the extra opcodes
of the CMOS 6502 PLX and PLY. It seems odd though, that both you and Mike
(archimedes) and myself all had the same bug...
> Anyway, I thought I'd get to work on the keyboard, which appears to have
> been causing everyone countless problems. However, I've had a look at the
> AUG and with my usual technical abilities I haven't a clue what happens
> when you press a key. Any chance of someone who's actually done this
> posting a wee "complete thicko's guide to the keyboard"? ie. how to deal
> with keypresses? I'm afraid I got lost under a pile of AUG!
>
Well, someone else has already replied to this, but I have some working
code. I hook the keyboard interrupt and take over all of the PC keyboard
handling myself. It's somewhat quicker than letting the bios do it.
Quick synopsis :
Tables : 128 bytes for key down bits. Byte at [BBC Internal Key] = 1 if
the key is currently down.
10 bytes for column key press count. Used for setting CA2
128 Bytes for normal PC key to BBC internal key conversion
128 bytes for extended PC key to BBC internal key conversion
Method : on PC keyboard irq, read key pressed
convert key to BBC internal key number.
check key press table. If state of key is changing, modify
column key count aswell as key press state
Don't forget to acknowledge the irq from the PC.
In the BBC emulator, the keyboard columns are scanned at 1Mhz when the
keyboard latch bit is disabled. The keyboard diagram at the back of the AUG
shows the circuit. Thus, if you keep a count of the cycles, the currently
checked column is ((count & 0x0F) >> 1). A quick check of the column
table tells you if an irq needs to be generated.
There's a fair bit more to it than that - if the keyboard latch is
enabled, then the column scanning is frozen. Writing out to 6522 Port A will
set the column to look at.
Another consideration is that only edges cause IRQs, so if two keys in
adjacent columns are pressed, then the second one will not set CA2. Note
also that SHIFT and CTRL keys **NEVER EVER** cause CA2 to be set. (That
particular row is not connected to the NAND gate). Also, this means that
the bootup switched don't cause IRQ's either.
CTRL and SHIFT are polled by T1 irqs - along with a load of other stuff
the OS does, like flashing colour processing, sounds etc.
Best of luck with the keyboard handler
Mark