News:

Printed Amstrad Addict magazine announced, check it out here!

Main Menu
avatar_CPCLER

Joystick in keyboard matrix?

Started by CPCLER, 00:10, 17 July 09

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

CPCLER

Having had a look in the non firmware keyboard scanning routine:

http://cpcwiki.eu/index.php/Programming:Keyboard_scanning

I wonder how to read the input from a joystick (1 or 2)..

Is there a special way to get input from them or are the input also located in the keyboard matrix?

Any help appreciated  :)

/CPCLER

fano

#1
afaik joy 1 is on line &49.For joy 2 , i remember getting its state long time ago, it is in keyboard matrix but i can not rememeber where  :-\

This is the code i am using, taken from CPCwiki to get joy1 state :



joy_up    EQU 1
joy_dn    EQU 2
joy_lt    EQU 4
joy_rt    EQU 8
joy_b1    EQU 16
joy_b2    EQU 32

joy_update:
    ld A,#49
    call key_update
    xor #FF
    ld (joy_state),A
    ret


; update a key state
; A from 0 to 9 with bdir/bc1=01
; code found @cpcwiki


key_update:
    LD BC,#F782 ; PPI port A out /C out
    OUT (C),C
    LD BC,#F40E ; Select Ay reg 14 on ppi port A
    OUT (C),C
    LD BC,#F6C0 ; This value is an AY index (R14)
    OUT (C),C
    db #ED,#71 ;OUT (C),0
    LD BC,#F792 ; PPI port A in/C out
    OUT (C),C
    DEC B
    OUT (C),A ; Send KbdLine on reg 14 AY through ppi port A
    LD B,#F4 ; Read ppi port A
    IN A,(C) ; e.g. AY R14 (AY port A)
    LD BC,#F782 ; PPI port A out / C out
    OUT (C),C
    DEC B ; Reset PPI Write
    db #ED,#71 ;OUT (C),0
    ret
"NOP" is the perfect program : short , fast and (known) bug free

Follow Easter Egg products on Facebook !

Longshot

Rhaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa!!

CPCLER

Quote from: Longshot on 09:15, 17 July 09
See http://cpcrulez.free.fr/coding_logon43.htm scheme number 6. J1 & J2 for Joysticks

Thanks, this was exactly what i needed. I have also updated the Matrix scheme in the CPCWIKI so i now shows the places for joystick scanning. :)

/CPCLER

Powered by SMFPacks Menu Editor Mod