"Inside the Dragon" described on Page 198-204 all the basics. I have read it carefully, but didn't understand it completely I missed a complete, detailed example.
I have study the XRoar sources, but didn't help at all.
I would like to start to implement only the Keyboard stuff in my Emulation. So, i think only the following parts must be implemented:
- $ff00 -> PIA 0 A side Data register
- $ff02 -> PIA 0 B side Data register
Code: Select all
| PB0 PB1 PB2 PB3 PB4 PB5 PB6 PB7
----|----------------------------------------------
PA0 | 0 1 2 3 4 5 6 7
PA1 | 8 9 * ; , - . /
PA2 | @ A B C D E F G
PA3 | H I J K L M N O
PA4 | P Q R S T U V W
PA5 | X Y Z Up Down Left Right Space
PA6 | ENT CLR BRK N/C N/C N/C N/C SHFT
- configured as outputs
- connected to: $ff02 -> PIA 0 B side Data register
- configured as inputs
- connected to: $ff00 -> PIA 0 A side Data register
I my current emulation i can see this:
bbff writes $ff (11111111) to $ff02
bbcd reads from $ff00
I send $ff (11111111) back.
Now i see the "next row" scan loop:
bc0e writes $fe (11111110) to $ff02
bbcd reads from $ff00
bc23 writes $fd (11111101) to $ff02
bbcd reads from $ff00
bc23 writes $fb (11111011) to $ff02
bbcd reads from $ff00
...snip...
bc23 writes $bf (10111111) to $ff02
bbcd reads from $ff00
bc23 writes $7f (01111111) to $ff02
bbcd reads from $ff00
So the complete loop writes $ff02 this sequence:
Code: Select all
11111110
11111101
11111011
11110111
11101111
11011111
10111111
01111111
So my first questions is, what should be send back, if key XY is pressed on $ff00 ?
e.g.:
"U" pressed: col = 5 - row = 4 => 0xfb => 11111011 or inverted: 00000100
or
"A" pressed: col = 1 - row = 2 => 0xbf => 10111111 or inverted: 01000000
or
Shift + K is pressed?
I think if "U" is pressed and on column PB5 is a 1 then row PA4 is 0 and if PB5 is 0, then PA4 is 0
In other words: If PB0-PB7 are all 1, then PA0-PA6 are: 11101011
Of is it the opposite? Result a key press a pull up or a pull down?
EDIT: I have try to fake a keypress by clear one bit it the output. e.g. i send in the "next row" loop this back on $ff00:
Code: Select all
11111010
11111001
11111011
11110011
11101011
11011011
10111011
01111011