Jump to content



2

reading the paddles


12 replies to this topic

#1 Chainclaw OFFLINE  

Chainclaw

    Space Invader

  • 43 posts

Posted Sun May 25, 2008 1:10 AM

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.c...4/msg00044.html
http://nocash.emubas...trollerspaddles

from searching the forums:
http://www.atariage....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....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.

#2 BigO OFFLINE  

BigO

    River Patroller

  • 2,939 posts
  • Location:Phoenix, AZ

Posted Sun May 25, 2008 6:59 AM

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, Sun May 25, 2008 7:01 AM.


#3 SpiceWare OFFLINE  

SpiceWare

    Quadrunner

  • 5,987 posts
  • Medieval Mayhem
  • Location:Planet Houston

Posted Sun May 25, 2008 9:41 AM

here's a demo with source you may find useful:

http://spiceware.org...ri_paddles.html

Edited by SpiceWare, Sun May 25, 2008 9:42 AM.


#4 Thomas Jentzsch OFFLINE  

Thomas Jentzsch

    Thrust, Jammed, SWOOPS!

  • 16,745 posts
  • Always left from right here!
  • Location:Düsseldorf, Germany

Posted Sun May 25, 2008 11:29 AM

And check this website: http://www.qotile.ne...dig/tricks.html

#5 Wickeycolumbus OFFLINE  

Wickeycolumbus

    River Patroller

  • 4,063 posts
  • Location:Michigan

Posted Sun May 25, 2008 12:07 PM

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


#6 Chainclaw OFFLINE  

Chainclaw

    Space Invader

  • 43 posts

Posted Sun May 25, 2008 2:29 PM

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, Sun May 25, 2008 2:47 PM.


#7 BigO OFFLINE  

BigO

    River Patroller

  • 2,939 posts
  • Location:Phoenix, AZ

Posted Sun May 25, 2008 9:05 PM

View PostChainclaw, on Sun May 25, 2008 1:29 PM, said:

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.

#8 ibogost OFFLINE  

ibogost

    Chopper Commander

  • 136 posts
  • Location:Atlanta

Posted Fri Jul 15, 2011 10:03 AM

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?

#9 SpiceWare OFFLINE  

SpiceWare

    Quadrunner

  • 5,987 posts
  • Medieval Mayhem
  • Location:Planet Houston

Posted Fri Jul 15, 2011 10:14 AM

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

After loading your ROM:
  • hit TAB to bring up in-game menu
  • Select GAME PROPERTIES
  • select CONTROLLER tab
  • change controllers
  • 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, Fri Jul 15, 2011 10:16 AM.


#10 ibogost OFFLINE  

ibogost

    Chopper Commander

  • 136 posts
  • Location:Atlanta

Posted Fri Jul 15, 2011 10:16 AM

View PostSpiceWare, on Fri Jul 15, 2011 10:14 AM, said:

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

After loading your ROM:
  • hit TAB to bring up in-game menu
  • Select GAME PROPERTIES
  • select CONTROLLER tab
  • change controllers
  • 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.

#11 SpiceWare OFFLINE  

SpiceWare

    Quadrunner

  • 5,987 posts
  • Medieval Mayhem
  • Location:Planet Houston

Posted Fri Jul 15, 2011 10:19 AM

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".


stellaslideshow.gif

#12 Tjoppen OFFLINE  

Tjoppen

    Chopper Commander

  • 129 posts

Posted Fri Jul 15, 2011 2:39 PM

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

#13 ibogost OFFLINE  

ibogost

    Chopper Commander

  • 136 posts
  • Location:Atlanta

Posted Sat Jul 16, 2011 8:10 PM

View PostTjoppen, on Fri Jul 15, 2011 2:39 PM, said:

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.




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users