It is currently Mon Oct 20, 2014 4:04 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 6 posts ] 
Author Message
PostPosted: Tue Jul 02, 2013 4:05 pm 
Offline
 Profile

Joined: Tue Feb 09, 2010 2:25 am
Posts: 4
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.


Top
 
PostPosted: Wed Jul 03, 2013 10:47 am 
Offline
User avatar
 WWW  Profile

Joined: Thu Apr 03, 2008 2:49 pm
Posts: 277
Location: Antarctica
If the OS is still functional, then OS Byte 129 is your man


Top
 
PostPosted: Wed Jul 03, 2013 5:50 pm 
Offline
 Profile

Joined: Mon Jul 21, 2008 9:29 pm
Posts: 25
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


Top
 
PostPosted: Wed Jul 03, 2013 9:24 pm 
Offline
 Profile

Joined: Tue Feb 09, 2010 2:25 am
Posts: 4
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.


Top
 
PostPosted: Wed Jul 03, 2013 10:47 pm 
Offline
User avatar
 WWW  Profile

Joined: Wed Jan 26, 2011 2:35 am
Posts: 139
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. :)


Top
 
PostPosted: Wed Jul 03, 2013 11:09 pm 
Offline
 Profile

Joined: Tue Feb 09, 2010 2:25 am
Posts: 4
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.


Top
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron