ML routine for polling 542 keyboard

Post Reply
lowrybt1
Posts: 212
Joined: Sun Mar 08, 2015 3:42 pm
Location: New York State

ML routine for polling 542 keyboard

Post by lowrybt1 »

Does anyone know a source for a published USR ML routine for polling the 542 keyboard that works under 65Dv3.3? I'm updating a BASIC lunar lander game I coded back in the day.

Thanks, Tom
C8PDF w. 48K, 2x 520 24K RAM boards and Glitchworks 64K board
OSI 567 Telephony board
Spare 8" drives
Klyball D-13
dave
Site Admin
Posts: 710
Joined: Tue Sep 09, 2008 5:24 am

Re: ML routine for polling 542 keyboard

Post by dave »

I'm not sure about a machine ready listing, but the June 1984 issue of Peek(65) has a commented disassembly of the ROM polled 542 keyboard routine:

http://osiweb.org/Peek65/Peek65_V5N6-06_1984.pdf

There is a ROM entry point you can call that runs the poll loop only once rather than wait for a key press.

The Software Consultants OS65D v3.2 disassembly manual has this to say about the way OS65D uses the ROM keyboard routine:
THIS ROUTINE USES THE SAME ROUTINE AS THE ROM BASED MACHINES. UNFORTUNATELY, THE DISK BASIC USES SOME OF THE SAME MEMORY LOCATIONS AS THE ROUTINE AT $FD00. INSTEAD OF DOING THE CORRECT THING. WRITING A NEW ROUTINE FOR THE DOS, OSI MADE ANOTHER PATCH. EVERY TIME YOU INPUT FROM THE 540 KEYBOARD YOU MUST FIRST SWAP OUT 4 BYTES, CALL THE ROUTINE IN ROM @ $FD00, AND THEN RESTORE THE 4 BYTES. HIGHLY INEFFICIENT!
So perhaps you'd be better off starting with the ROM routine, relocating to RAM, and fix the scratch memory conflicts.

However, if you're only using a few keys, it might be easier to hard-code the poll:

1) write the latch to enable one row,
2) read the columns from the keyboard
3) just test the bits corresponding to the keys you care about in that row, and set a bit in a scratch register (1 bit per key)
4) repeat for all the rows containing keys you need for the game
5) load up the scratch register into the Accumulator (if less than 8 keys), or A and X registers (if less than 16 keys), and return.

For a game with left, right, thrust, quit and maybe a couple of other keys, you could use 1 byte to encode the results of a poll.

Dave
Post Reply