Author Topic: Joystick in keyboard matrix?  (Read 2140 times)

0 Members and 1 Guest are viewing this topic.

Offline CPCLER

  • CPC664
  • ***
  • Posts: 104
  • Country: dk
  • Pecunia non olet
  • Liked: 3
  • Likes Given: 37
Joystick in keyboard matrix?
« 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

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

Offline fano

  • Supporter
  • 6128 Plus
  • *
  • Posts: 836
  • Country: fr
  • Easter Egg Programmer
    • Easter Egg
  • Liked: 290
  • Likes Given: 618
Re: Joystick in keyboard matrix?
« Reply #1 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
« Last Edit: 02:29, 17 July 09 by fano »
"NOP" is the perfect program : short , fast and (known) bug free

Follow Easter Egg products on Facebook !

Offline Longshot

  • Supporter
  • CPC664
  • *
  • Posts: 109
  • Country: fr
    • Logon System Web Site
  • Liked: 114
  • Likes Given: 25
Re: Joystick in keyboard matrix?
« Reply #2 on: 11:15, 17 July 09 »
See http://cpcrulez.free.fr/coding_logon43.htm scheme number 6. J1 & J2 for Joysticks
Rhaaaaaa

Offline CPCLER

  • CPC664
  • ***
  • Posts: 104
  • Country: dk
  • Pecunia non olet
  • Liked: 3
  • Likes Given: 37
Re: Joystick in keyboard matrix?
« Reply #3 on: 15:44, 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