[Hardware] Analog joypad

hu, cd, scd, acd, supergrafx discussions.
Post Reply
User avatar
MooZ
Site Admin
Posts: 389
Joined: Sun Jun 22, 2008 3:19 pm
Location: Lvl 3
Contact:

[Hardware] Analog joypad

Post by MooZ » Sat Mar 19, 2016 7:03 pm

I think I found the routines that detects and read an analog joypad.
According to Gamesx wiki, only 4 games (all by NEC Avenue) are supporting analogue controllers:
  • Afterburner II
  • Forgotten Worlds
  • Operation Wolf
  • Outrun
This is what you'll see with Operation Wolf:
Image

I attached 2 etripator configuration files for Operation Wolf and Afterburner II.
The code in both games are nearly identical.

Code: Select all

X = 0

joyport = 0
delay

for (count=0; count<5; count++)
{   joyport = 2
    delay
    for(Y=0; Y<256; Y++)
    {   A = joyport
        if( (A & 3) == 0 )
            break;
    }
    if( Y == 256 )
        NOT FOUND

    joyport = 3
    delay
    A = joyport
    Y = A & 0x0F
    out[X++] = tab[Y]

    joyport = 2 
    delay

    for(Y=0; Y<256; Y++)
    {   A = joyport
        if( (A & 3) == 1)
            break;
    }
    if( Y == 256)
        NOT FOUND

    joyport = 3
    delay
    A = joyport
    Y = A & 0x0F
    out[X++] = tab[Y]
}
tab contains the following values:

Code: Select all

tab:
    .db $00, $01, $08, $09, $02, $03, $0a, $0b
    .db $04, $05, $0c, $0d, $06, $07, $0e, $0f 
The out array contains only 4 bit values. They are therefore reassembled. Note that Operation Wolf and Afterburner II seems to do it differently.
Here's the code for Operation Wolf.

Code: Select all

v30 = (out[0] << 4) | out[1]
Y = (out[2] << 4) | out[6]
v31 = unknown_array[Y]
Y = (out[3] << 4) | out[7]
v32 = another_unknown_array[Y]
v33 = (out[4] << 4) | out[8]
v34 = (out[5] << 4) | out[9]
Edit:
  • v31 contains the vertical axis value.
  • v32 contains the horizontal axis value.
According to the manuals (see below), there are 10 buttons (START, SELECT, A, B, C, D, A', B', E1, E2) and one slider. v30 may contains some button values (at least START and SELECT). Indeed, the value is used to test the RESET combo in Operation Wolf.

Code: Select all

l_f6cd:
          JSR     joy_analogue
          LDA     $2540
          STA     $2545
          LDA     $2a30
          AND     #$03
          ASL     A
          ASL     A
          STA     <$1d
          LDA     $2a30
          AND     #$c0
          CLC     
          ROL     A
          ROL     A
          STA     <$1e
          ROL     A
          ROL     A
          AND     #$02
          ORA     <$1e
          ORA     <$1d
          EOR     #$ff
          AND     #$0f
          STA     $2540
          EOR     $2545
          AND     $2540
          STA     $254a
          LDA     <$47
          AND     $f77c
          BEQ     lf77b_01
          LDA     $254a
          CMP     #$04
          BNE     lf77b_01
          LDA     $2540
          CMP     #$0c
          BNE     lf77b_01
          JMP     le000_01 ; RESET vector
; the "standard" joypad routine comes next...
lf77b_01:
          RTS
Attachments
Operation Wolf (Japan)-0000.png
(1.74 KiB) Not downloaded yet
operation_wolf.cfg
(69 Bytes) Downloaded 40 times
afterburner.cfg
(137 Bytes) Downloaded 40 times

User avatar
MooZ
Site Admin
Posts: 389
Joined: Sun Jun 22, 2008 3:19 pm
Location: Lvl 3
Contact:

Re: [Hardware] Analog joypad

Post by MooZ » Mon Mar 21, 2016 1:33 pm

It seems that the code after l_f6cd is about moving hgfedcba into 0000bagh. Bits a and b being Select and Start.
Anyway the 19 lines of codes that computes this can be reduced to :

Code: Select all

    lda $2a30
    asl A      ; A=gfedcba0 carry=h
    rol A      ; A=fedcba0h carry=g
    bcc l0     ; if(carry != 0) A |= 0x$02
        ora #$02
l0:            ; A=fedcbagh
    eor #$ff
    and #$0f
    sta $2540

User avatar
MooZ
Site Admin
Posts: 389
Joined: Sun Jun 22, 2008 3:19 pm
Location: Lvl 3
Contact:

Re: [Hardware] Analog joypad

Post by MooZ » Sat Apr 16, 2016 8:51 am

Here are the scans of the manual:

User avatar
MooZ
Site Admin
Posts: 389
Joined: Sun Jun 22, 2008 3:19 pm
Location: Lvl 3
Contact:

Re: [Hardware] Analog joypad

Post by MooZ » Mon Oct 30, 2017 2:07 pm

Apparently according to this blog post, the analog joypad is also supported by Thunder Force.
I'll have to check this.

Any way in order to use the analog sticks, you'll also need a XHE-3.

Post Reply