[Coco] PIA keyboard input?
Roger Taylor
rtaylor at bayou.com
Mon Dec 8 23:10:00 EST 2003
At 10:02 PM 12/7/2003 -0500, you wrote:
>James Dessart wrote:
>>On 7-Dec-03, at 5:09 PM, Robert Gault wrote:
>>
>>>Whether you ROL/ROR or ST depends on whether you want to detect one
>>>specific key or any possible key press combination. Clearly if you want
>>>any key you must test all possible column/row combinations.
>>
>>Well, what I wanted to do was to store a value into the PIA register,
>>through a loop. I'm doing this in C, and to do a ROL you need to write
>>inline assembly. So I was trying to store a constantly changing value
>>into the register through a C assignment. That didn't work for me, for
>>some reason... I never got key presses... I'll retry it, though, maybe I
>>was doing it wrong the first time and didn't realize it.
>>James
>That's easy to do if you use the correct algorithm. What is equivalent to
>rolling a bit? A power of 2 change is the same thing. So, if you want a
>zero bit, the loop would be (in Basic)
> for i =1 to 8
> poke pia, 255-2^(i-1)
> next i
>The above is going to give you 255-1=254=%11111110, 255-2=253=%11111101,
>255-4=251=%11111011, 255-8=247=%11110111, etc.
James,
A simulated roll or strobe is achieved using Robert's method above, since
you're forcing all but 1 bit to be high. Technically, a roll is the actual
rolling of all data bits in either direction. 9- or 17-bit data can be
handled sometimes by counting the carry as one of the data bits.
More information about the Coco
mailing list