www.retrosoftware.co.uk
http://www.retrosoftware.co.uk/forum/

6502 keyboard recognition...
http://www.retrosoftware.co.uk/forum/viewtopic.php?f=73&t=831
Page 1 of 1

Author:  VinnyM [ Tue Jul 02, 2013 4:05 pm ]
Post subject:  6502 keyboard recognition...

I wonder if someone can help me, please?

I'm looking for a simple piece of 6502 code for the BBC that does the following:
- looks to see if I have pressed the keyboard...
- recognises that I've pressed "1" on the keyboard
- goes to a particular mem location if I have pressed "1"
- if nothing is pressed, RTS

Does that make sense?

I want to add a small piece of code somewhere in a game so that when I press "1" it gives me infinite lives.

Author:  DaveF [ Wed Jul 03, 2013 10:47 am ]
Post subject:  Re: 6502 keyboard recognition...

If the OS is still functional, then OS Byte 129 is your man

Author:  RobC [ Wed Jul 03, 2013 5:50 pm ]
Post subject:  Re: 6502 keyboard recognition...

If you can't use the OS routine then this describes how to read the hardware directly: http://www.retrosoftware.co.uk/wiki/index.php/Reading_the_keyboard_by_direct_hardware_access

Author:  VinnyM [ Wed Jul 03, 2013 9:24 pm ]
Post subject:  Re: 6502 keyboard recognition...

Cheers guys. I'm not really sure what I'm supposed to do, but I'll try and work it out from what you've given me.

Author:  DavidB [ Wed Jul 03, 2013 10:47 pm ]
Post subject:  Re: 6502 keyboard recognition...

OS Byte is a routine at $fff4 which takes an argument in the accumulator. It returns the key code in the X register:
Code:
lda #129
jsr $fff4
The key code for "1" is 49, so this is the value that you need to compare the X register against:
Code:
cpx #49
If the contents of the register matches then branch to your code elsewhere; otherwise return:
Code:
beq some_location
rts
I hope that 1) I'm not spoon-feeding someone who already knows their 6502, and 2) I've got the above code more-or-less correct. :)

Author:  VinnyM [ Wed Jul 03, 2013 11:09 pm ]
Post subject:  Re: 6502 keyboard recognition...

That's exactly what I needed. Thank you :-)

It's kind of similar to the Commodore 64. I just needed to know the correct locations.

Thank you.

Page 1 of 1 All times are UTC [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/