EASy68K  
It is currently Sat Oct 21, 2017 7:34 pm

All times are UTC




Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Wed Jun 26, 2013 11:40 pm 
Offline
User avatar

Joined: Tue Jun 18, 2013 10:41 am
Posts: 5
Location: UK
Hi,

So I'm using the following code to see which key was pressed

Code:
* -- grab input --
    *Check to see if a key has been pressed
       clr.l   d1
       move.b   #7,d0
       trap   #15
       tst.l   d1
       beq       nokey       Key wasn't pressed, clear movement

    *Read the key that was pressed and find out which key it was
       move.b   #5,d0
       trap   #15


then comparing the d1 register e.g.:

Code:
       cmp.b   #'4',d1       Key pressed: 4 (left)
       beq       move_left


OK that's all fine, however if I press a key down and hold, it detects the key press, but then it's almost like it clears the d1 for a second or so and then registers it again.

Next issue is that if I press and hold a key, then press another key, the first key is no longer registering, even though it's still being pressed.

Is this correct? Am I using the correct method for detecting key presses? Or should I be using a better way of detecting multiple key presses?

Any help on the matter would be much appreciated, thank you, Rich

_________________
Retro Rich - Retro gaming and coding - http://www.retrorich.co.uk/ Tweet me @rich_lloyd


Top
 Profile  
 
PostPosted: Thu Jun 27, 2013 12:09 pm 
Offline
User avatar

Joined: Thu Dec 16, 2004 6:42 pm
Posts: 1048
Trap task 7 does character input. The auto key repeat feature in Windows will make it look like the key is being pressed and released if a key is held down. To read the current state of a key use trap task 19. Up to 4 key states may be read at the same time. From EASy68K help:
    Returns current state of up to 4 specified keys or returns key scan code.
    Pre: D1.L = four 1-byte key codes
    Post: D1.L contains four 1-byte Booleans.
    $FF = corresponding key is pressed, $00 = corresponding key not pressed.
    Pre: D1.L = $00000000
    Post: D1.L upper word contains key code of last key up.
    D1.L lower word contains key code of last key down.

    Example:
    Code:
         MOVE.B #19,D0     
         MOVE.L #'A'<<24+'S'<<16+'D'<<8+'F',D1 ; check for keypress (a,s,d,f)
         TRAP   #15
         BTST.L #24,D1     ; test for 'a'
         IF <NE> THEN      ; if 'a'
             {a code}
         ENDI
         BTST.L #16,D1     ; test for 's'
         IF <NE> THEN      ; if 's'
            ... etc

_________________
Prof. Kelly


Top
 Profile  
 
PostPosted: Thu Jun 27, 2013 1:11 pm 
Offline
User avatar

Joined: Tue Jun 18, 2013 10:41 am
Posts: 5
Location: UK
Thank you so much, that is now perfect! I thought it was task 19 I needed, but I couldn't work out how to use it, but it's working great now.

_________________
Retro Rich - Retro gaming and coding - http://www.retrorich.co.uk/ Tweet me @rich_lloyd


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

All times are UTC


Who is online

Users browsing this forum: Baidu [Spider], Yahoo [Bot] 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
Powered by phpBB® Forum Software © phpBB Group