Danjovic Posted March 14, 2021 Share Posted March 14, 2021 From 5200 schematic: Votage that appears on pin 9 is controlled by pin S2 from GTIA. 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. 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. 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 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 ? Quote Link to comment Share on other sites More sharing options...
+Ryan Witmer Posted March 14, 2021 Share Posted March 14, 2021 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. 1 Quote Link to comment Share on other sites More sharing options...
+DrVenkman Posted March 14, 2021 Share Posted March 14, 2021 (edited) 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 March 14, 2021 by DrVenkman typo 1 Quote Link to comment Share on other sites More sharing options...
SoundGammon Posted March 14, 2021 Share Posted March 14, 2021 (edited) 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? Edited March 14, 2021 by SoundGammon Add diagram Quote Link to comment Share on other sites More sharing options...
+Ryan Witmer Posted March 14, 2021 Share Posted March 14, 2021 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. Quote Link to comment Share on other sites More sharing options...
+DrVenkman Posted March 14, 2021 Share Posted March 14, 2021 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. Quote Link to comment Share on other sites More sharing options...
Danjovic Posted March 15, 2021 Author Share Posted March 15, 2021 On 3/14/2021 at 12:43 PM, Ryan Witmer said: Here's the code that I used for this in my game: Thanks for the code. It provided me a good insight about the timing related to the detection of the trackball. Quote Link to comment Share on other sites More sharing options...
Danjovic Posted March 15, 2021 Author Share Posted March 15, 2021 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) Quote Link to comment Share on other sites More sharing options...
+DrVenkman Posted March 15, 2021 Share Posted March 15, 2021 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. Quote Link to comment Share on other sites More sharing options...
Swami Posted March 16, 2021 Share Posted March 16, 2021 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. 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. 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. 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 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. Quote Link to comment Share on other sites More sharing options...
Danjovic Posted March 16, 2021 Author Share Posted March 16, 2021 29 minutes ago, DrVenkman said: ...than simply swapping the chip for another one. Ok I get it now. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.