Jump to content
IGNORED

Trackball detection: which titles really do that?


Danjovic

Recommended Posts

From 5200 schematic:

Votage that appears on pin 9 is controlled by pin S2 from GTIA.

image.thumb.png.b5bfdd48b96145ffd7e95060718b633f.png

 

From GTIA datasheet

S2 pin is open drain and inverted. Writing 1 to this bit will sink the voltage on the pin. Writing a zero will let the voltage be driven by an external pullup resistor.

 

image.thumb.png.71418d7fb17afc2378dd53ca1e802265.png

 

Simulating the circuit (in ewb), we see that when 0 is written to the pin the voltage at pin 9 drop down to zero volts.

image.thumb.png.3b4535fced0022db9cdc0092dbfe392a.png

 

And writing 1 to this bit activates the voltage on pin 9 ( in range ~ 4.0 to ~7.0 Volts) depending upon the value of the potentiometer

image.thumb.png.93be7a93a794ea3ef6d7033f5e4e4c6f.png

 

image.thumb.png.5f4b9746287bbc223c30069b792865bf.png

 

As the GTIA sits at $C000 I have disassembled 3 ROMS to investigate trackball detection:

 

- Pete's test cartridge : No writing to $C01F

- Centipede: No writing to $C01F

- Missile Command: 3 writes to $c01f

1006:                 lda     #$04
1008:                 sta     $c01f


119e:                 lda     #$00
11a0:                 sta     $c01f


11c5: L11C5           lda     $a5
11c7: L11C7           ora     #$04
11c9:                 sta     $c01f

 

I was expecting that all three titles dropped the voltage to try to differentiate a trackball from a joystick. 

 

Which other games behave or should behave differently with a trackball or a joystick ?

 

 

 

 

Link to comment
Share on other sites

Based on my experience with Magical Fairy Force, writing 0 to CONSOL ($c01f) and then reading the controller pots will give you a magic value ($e4) if the controller is a joystick (or disconnected), and some other value if the controller is a trakball.  This other value is the neutral value for the ball on that axis and is needed to properly interpret the pot values later.

 

Here's the code that I used for this in my game:

; Detect the types of controllers connected.
detect_controllers subroutine
    mva     #0,CONSOL               ; Disable pot scanning.
    ldy     #2
    jsr     wait_for_y_frames       ; Wait for the shadows to update.
    lda     sPOT0                   ; Check the first port.
    cmp     #$e4                    ; Joystick reads $e4 when disabled.
    bne     .p0_ball
    lda     #controller_stick       ; Joystick, or nothing perhaps.
    beq     .store_p0               ; Always true.
.p0_ball
    sta     p0_ball_rest_h          ; This is the horizontal rest value.
    lda     sPOT1                   ; Get the vertical rest value.
    sta     p0_ball_rest_v
    lda     #controller_ball
.store_p0
    sta     p0_controller_type
    lda     sPOT2                   ; Repeat for port 2.
    cmp     #$e4
    bne     .p1_ball
    lda     #controller_stick
    beq     .store_p1               ; Always true.
.p1_ball
    sta     p1_ball_rest_h
    lda     sPOT3
    sta     p1_ball_rest_v
    lda     #controller_ball
.store_p1
    sta     p1_controller_type
    mva     #4,CONSOL               ; Re-enable pot scanning.
    sta     active_controller
    ldy     #2
    jmp     wait_for_y_frames       ; Allow the shadows to update.

 

It surprises me that two of those carts never write to CONSOL, you need to at least write $04 to activate pot scanning.  Maybe it's being done indirectly somewhere, like a sta $c000,y or something.

 

Note that Pete's cart probably has no reason to differentiate between a joystick and a trakball since it just displays pot values (I think).  You only need to know the difference when you intend to actually act on those values.

  • Thanks 1
Link to comment
Share on other sites

1 hour ago, Ryan Witmer said:

Note that Pete's cart probably has no reason to differentiate between a joystick and a trakball since it just displays pot values (I think).

Pete's has a dedicated Trak-Ball mode that you have to enable while the cart is running. From the numerical-values POKEY resistor display, one of the button presses displays the word "CALIBRATE" below the table of values; that's for checking Trak-Ball input. The other button press takes you to the bordered black screen where you can visually see the controller input as it moves a colored dot around inside the box.

Edited by DrVenkman
typo
  • Thanks 1
Link to comment
Share on other sites

Dan Kramer, the Trak-Ball guy, told me that the 5200 Trak-Ball could be used as a digital input! Been thinking about it for awhile, and I'm thinking what if you disconnected the line going to pin 9 on the 5200 and let the signal go low on power up? Would this let you use the 4 up-down-left-right outputs as digital inputs?

 

CX53-Trakball Mod.png

Edited by SoundGammon
Add diagram
Link to comment
Share on other sites

1 hour ago, DrVenkman said:

Pete's has a dedicated Trak-Ball mode

Ah, I didn't know that.  I've never actually used Pete's cart, just one of the diagnostic carts that just displays POT scan values.  I assumed Pete's was similar (ass out of you and me).

 

Maybe I should get my hands on one.

Link to comment
Share on other sites

Just now, Ryan Witmer said:

Ah, I didn't know that.  I've never actually used Pete's cart, just one of the diagnostic carts that just displays POT scan values.  I assumed Pete's was similar (ass out of you and me).

 

Maybe I should get my hands on one.

No worries; it's not particularly obvious or intuitive to use with a Trak-Ball. When @MakerMatrix and I were making and selling thumbstick controllers awhile back, I used Pete's several times a day to check each controller I built to verify both the build as well as the digital potentiometer chips used (*).  I got very familiar with that aspect of Pete's  for sure. Using it for a Trak-Ball should generally work the same way though I haven't really done much with that aspect of it myself. 

 

 

(*) The chips used have a disappointingly-high variance in their specs. About 4 - 5 out of every 100 would read out-of-spec low on an axis. One or two of them might be low on both, but low on one axis was much more common. Annoying as hell to have a bunch of digipot chips you really can't use for controllers sitting around in the junk parts drawer. :( 

Link to comment
Share on other sites

On 3/14/2021 at 3:37 PM, DrVenkman said:

 

(*) The chips used have a disappointingly-high variance in their specs. About 4 - 5 out of every 100 would read out-of-spec low on an axis

That's weird. You mean half of the chip work ok and the other half is out or specs, right? Does it still provide linear variation? If so you can trim the capacitor to match the digipot.

Does that happens with either half equally? Any diffetence ifyou tie the not used terminal with the wiper?

If you invert the side of the pot would that work as expected ( scale ok but inverse direction of atuation)?

Would be too bad to add a second socket for a second digipot? (and some cutting jumpers)

 

Link to comment
Share on other sites

5 minutes ago, Danjovic said:

That's weird. You mean half of the chip work ok and the other half is out or specs, right? Does it still provide linear variation? If so you can trim the capacitor to match the digipot.

Does that happens with either half equally? Any diffetence ifyou tie the not used terminal with the wiper?

If you invert the side of the pot would that work as expected ( scale ok but inverse direction of atuation)?

Would be too bad to add a second socket for a second digipot? (and some cutting jumpers)

 

Yes, one channel would be perfect, the other out-of-spec low by 10 - 20 points per the values in Pete's Test Cart. We were building boards designed by Scott Baker and had neither the license nor the time to do a lot of experimenting with the board design or fooling around with replacement capacitors to try to fix the problem. In a batch assembly process, we would have had to desolder the capacitor corresponding to whichever axis was reading incorrectly, then tried to monkey around with new cap values to get that axis correct. The board design has very small solder pads and very tightly spaced components. That kind of work would take more time and too high a risk of damage to the PCB than simply swapping the chip for another one. 

Link to comment
Share on other sites

On 3/14/2021 at 7:49 AM, Danjovic said:

From 5200 schematic:

Votage that appears on pin 9 is controlled by pin S2 from GTIA.

image.thumb.png.b5bfdd48b96145ffd7e95060718b633f.png

 

From GTIA datasheet

S2 pin is open drain and inverted. Writing 1 to this bit will sink the voltage on the pin. Writing a zero will let the voltage be driven by an external pullup resistor.

 

image.thumb.png.71418d7fb17afc2378dd53ca1e802265.png

 

Simulating the circuit (in ewb), we see that when 0 is written to the pin the voltage at pin 9 drop down to zero volts.

image.thumb.png.3b4535fced0022db9cdc0092dbfe392a.png

 

And writing 1 to this bit activates the voltage on pin 9 ( in range ~ 4.0 to ~7.0 Volts) depending upon the value of the potentiometer

image.thumb.png.93be7a93a794ea3ef6d7033f5e4e4c6f.png

 

image.thumb.png.5f4b9746287bbc223c30069b792865bf.png

 

As the GTIA sits at $C000 I have disassembled 3 ROMS to investigate trackball detection:

 

- Pete's test cartridge : No writing to $C01F

- Centipede: No writing to $C01F

- Missile Command: 3 writes to $c01f

1006:                 lda     #$04
1008:                 sta     $c01f


119e:                 lda     #$00
11a0:                 sta     $c01f


11c5: L11C5           lda     $a5
11c7: L11C7           ora     #$04
11c9:                 sta     $c01f

 

I was expecting that all three titles dropped the voltage to try to differentiate a trackball from a joystick. 

 

Which other games behave or should behave differently with a trackball or a joystick ?

 

 

 

 

I'm not sure how Centipede works with the Trak-ball, but with the analog stick it is kinda half way between analog and digital, as it has two speeds (slow or fast), and only two speeds, depending on how far you move the analog stick.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...