CPCWiki forum

General Category => Programming => Topic started by: CPCLER on 02:10, 17 July 09

Title: Joystick in keyboard matrix?
Post by: CPCLER on 02:10, 17 July 09
Having had a look in the non firmware keyboard scanning routine:

http://cpcwiki.eu/index.php/Programming:Keyboard_scanning (http://../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
Title: Re: Joystick in keyboard matrix?
Post by: fano on 02:24, 17 July 09
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 :

Code: [Select]

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
Title: Re: Joystick in keyboard matrix?
Post by: Longshot on 11:15, 17 July 09
See http://cpcrulez.free.fr/coding_logon43.htm scheme number 6. J1 & J2 for Joysticks
Title: Re: Joystick in keyboard matrix?
Post by: CPCLER on 15:44, 17 July 09
See http://cpcrulez.free.fr/coding_logon43.htm (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