[Coco] PIA keyboard input?

Robert Gault robert.gault at worldnet.att.net
Sun Dec 7 22:02:00 EST 2003


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.




More information about the Coco mailing list