Jump to content
Chainclaw

reading the paddles

Recommended Posts

I have been searching for information on reading the paddle controllers, and it's a lot trickier than I expected.

 

Here's what I've gathered so far:

 

from google searching:

http://www.biglist.com/lists/stella/archiv...4/msg00044.html

http://nocash.emubase.de/2k6specs.htm#controllerspaddles

 

from searching the forums:

http://www.atariage.com/forums/index.php?a...addle&st=25

 

 

I found this a few days ago when I was just learning other stuff, but I didn't follow it too well at the time. I'm going to re-read the source, and hopefully it will make more sense now.

http://www.atariage.com/forums/index.php?s...st&p=506647

 

I might have more links, as well.

 

Anyways, what I'm getting at, is there a straightforward tutorial that covers reading paddles? It would be way quicker than all the legwork I've been going through. If there isn't, I'm sure I'll figure it out in a few days on my own, but it would be nice to save some time on my project.

Share this post


Link to post
Share on other sites

You've got several decent examples there. They may be as straight forward as you'll find. Do you have a good grasp of how the paddle controllers work? If not, maybe that will help you make more sense of the code.

 

Just in case:

The paddles work by charging a capacitor (inside the console) through a variable resistance (the pot in the paddle controller).

 

Starting with the capacitor at 0 volts, it will take a certain amount of time for the capacitor to charge up to a specific voltage. That amount of time varies based on the position (resistance) of the pot in the controller. In other words, the position of the paddle controller determines how long it takes for the capacitor to charge.

 

If you know when the capacitor started charging and you know when it reaches the "charged" state, you basically know what the position of the paddle controller is because you know how long it took to charge.

 

How do you know when it started charging? You tell it when to start.

How do you tell it when to start? You write code that discharges or "dumps" the capacitor.

 

How do you know when it gets charged? You keep checking the voltage level of the cap.

How do you check the voltage level on the cap? The cap is attached to an input of the TIA. Reading that pin over and over, you'll see a "0" until the charge is high enough for the digital logic to read the charge voltage as a "1".

 

How do you know how long it took to charge? You count the number of processor cycles it takes for the input pin to reach a "1" after the charge was dumped. I think people generally count scan lines to accomplish this.

 

See the second example you provided for a reference to which registers and bits in the registers are used to dump the charge then read the input value.

 

Knowing those registers/bits/pins/actions should help you pick out the actual paddle reading parts in the sample code you're looking at.

 

Have you read the "Stella Programmers Guide"? (It's all over the 'net, Google it). Section 12.1 should help you pick out the parts of code that you're looking for.

 

There's a potentially misleading statement in 12.1: "The microprocessor discharges this capacitor by writing a "1" to D7

of VBLANK then measures the time it takes to detect a logic one at that port." That bit about "measures the time", that measuring is done by the programmer keeping track of processor cycles between the dumping and the time the input pin reaches a logic 1.

Edited by BigO
  • Like 1

Share this post


Link to post
Share on other sites

Here is some code that some people around the forums helped me write:

 

	processor 6502
include "vcs.h"
org $F000

MAC	PADDLE_0		  ;Macro For reading paddles
lda INPT0
bpl .save
.byte $2C
.save
sty paddle
ENDM


paddle		 = $80
shpaddle 	 = $81


START
lda #0
tax
tay
RAMCLR
sta 0,x
inx
bne RAMCLR

lda #$0F
sta COLUP0


STARTFRAME

lda #$82			 ;Dump paddles to ground and start vertical blank
sta VBLANK


sta VSYNC

sta WSYNC
sta WSYNC
sta WSYNC

lda #0
sta VSYNC

lda #$02
sta VBLANK

ldy #36
VERT


sta WSYNC
PADDLE_0	  ;read paddles
dey
bne VERT


sta WSYNC

lda #$FF
sta GRP0

lda #0			 ;end Vertical blank, turn on video output
sta VBLANK

ldy #192
pic

PADDLE_0

dey
sta WSYNC
bne pic




lda #0
sta GRP0


sta HMCLR

ldx paddle
cpx shpaddle	
beq nochange	
bpl plus	
bmi minus

plus
lda #%11100000
sta HMP0
jmp nochange

minus
lda #%00100000
sta HMP0

nochange
lda paddle
sta shpaddle

sta WSYNC

ldy #28
overscan
dey
sta WSYNC
bne overscan

sta WSYNC
sta HMOVE

jmp STARTFRAME








org $FFFA
.word START
.word START
.word START

Share this post


Link to post
Share on other sites

awesome, all very useful. One of the things I was stuck on, was I was misreading how the capacitor for the paddle worked. I thought it was being charged through the motion of spinning the paddle. The demos make a lot more sense now that I understand the position of the paddle determines how much the capacitor will charge, so it's more of an absolute position than relative.

 

edit:

OK, I got the paddles reading, and my sprite on screen moves with the paddles. Now I just have to start cleaning up my code, and I'll have a nice and simple template for starting on a paddle game.

Edited by Chainclaw

Share this post


Link to post
Share on other sites
OK, I got the paddles reading, and my sprite on screen moves with the paddles. Now I just have to start cleaning up my code, and I'll have a nice and simple template for starting on a paddle game.

 

Cool. Good luck with your game.

Share this post


Link to post
Share on other sites

All right, I've tried all the code linked in this thread, and all the assembled binaries therewith, and none of them work with the paddle in Stella. That is to say, none respond to the paddle at all.

 

Games like Video Olympics and Kaboom! are working fine with my paddles via Stelladaptor.

 

What am I doing wrong?

Share this post


Link to post
Share on other sites

Stella defaults to Joysticks unless it's a known Paddle game (detected via it's MD5 signature).

 

After loading your ROM:

  1. hit TAB to bring up in-game menu
  2. Select GAME PROPERTIES
  3. select CONTROLLER tab
  4. change controllers
  5. hit OK

 

The setting for that ROM will be saved, so if you load it again it will start out with paddles. You'll have to go thru the process again if you make a revision to your ROM.

Edited by SpiceWare

Share this post


Link to post
Share on other sites

Stella defaults to Joysticks unless it's a known paddle game (detected via it's MD5 signature).

 

After loading your ROM:

  1. hit TAB to bring up in-game menu
  2. Select GAME PROPERTIES
  3. select CONTROLLER tab
  4. change controllers
  5. hit OK

 

The setting for that ROM will be saved, so if you load it again it will start out with paddles. You'll have to go thru the process again if you make a revision to your ROM.

 

Oh good lord I feel stupid. Thank you.

Share this post


Link to post
Share on other sites

It's easy to overlook. When I was maintaining the OS/2 port of Stella I used the status line to show what was "plugged in".

 

 

post-3056-0-36727800-1310746722.gif

Share this post


Link to post
Share on other sites

Put "-lc Paddles" in your arguments to Stella - that'll keep it from defaulting to joystick whenever you change your code

Share this post


Link to post
Share on other sites

Put "-lc Paddles" in your arguments to Stella - that'll keep it from defaulting to joystick whenever you change your code

 

Yup, figured this out, and adjusted my build tool to add the argument for build-and-run. Off to the races.

Share this post


Link to post
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...