[Coco] Technical: PIA Help

Brad Grier bradgrier at cox.net
Thu Dec 1 00:18:32 EST 2005


Hello all,

I'm trying to get Tetris to work in Mocha but I'm having trouble getting 
the emulator to recognize key presses in the game. This is the only 
program I've found that exhibits this behavior.

My understanding of the CoCo PIA keyboard routine is as follows: Write a 
zero to the bit that corresponds to the keyboard column you're 
interested in (with the rest of the bits set to 1) and poke it into 
0xff02. Next read 0xff00 and if a key is pressed you'll get a zero in 
the bit corresponding to the keyboard row.

Tetris seems to do all of it's keyboard polling from a field sync 
interrupt routine. It's constantly poking 0xff into 0xff02 - normally 
Mocha would ignore the subsequent read at 0xff00 because no bits are 
zero. I've found that if I treat 0xff as a request to see if *any* key 
is down regardless of column, I can at least get some keys to kind of 
work. Maybe it all boils down to what does a 0xff into 0xff02 really do? 
I'm sure I'm overlooking something obvious...

Anyway, I've been making a lot of changes to Mocha recently and this one 
is last on the list for the time being. That, and I like Tetris.

Thanks,

Brad
http://members.cox.net/javacoco/




More information about the Coco mailing list