reading the joystick

Basic and Machine Language

Moderator: Moderators

Post Reply
llcameron
Vic 20 Dabbler
Posts: 82
Joined: Tue Oct 06, 2009 2:02 pm

reading the joystick

Post by llcameron »

I've been resurrecting some of my old games I wrote when I was a kid in order to be able to upload them and share with my people :) I had a bug 30 years ago with reading the joystick, and the bug is still there amazingly ha!

I think there must be a register I need to reset or something. After reset and loading my game, the joystick will only read in the right direction. Up/down/left don't work, until I do a reset and run the game again. Since I was using HESMON, the monitor would come up and I could run my machine code again with the G command and the joystick would work properly.

How do you PROPERLY initialize the joystick port to be able to read it correctly???
User avatar
Mike
Herr VC
Posts: 4901
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Post by Mike »

Your program most probably compares whole register values. In that case, these postings might be interesting to you:

http://www.sleepingelephant.com/ipw-web ... 1&start=15

Greetings,

Michael
User avatar
nbla000
Salmon Run
Posts: 2582
Joined: Thu Oct 13, 2005 8:58 am
Location: Italy

Post by nbla000 »

Hi Mike,

In your sample you used the address 37151 to read the joy up/down/left/fire so the 37151 address replicate the address 37137...

From the Vic-20 Memory Map:

Code: Select all

9111 37137 Port A output register 
-(PA0) Bit 0=Serial CLK IN 
-(PA1) Bit 1=Serial DATA IN 
-(PA2) Bit 2=Joy 0 
-(PA3) Bit 3=Joy 1 
-(PA4) Bit 4=Joy 2 
-(PA5) Bit 5 = Lightpen/Fire button 
-(PA6) Bit 6=Cassette switch sense 
-(PA7) Bit 7=Serial ATN out 

911F 37151 Port A (Sense cassette switch) 
Mega-Cart: the cartridge you plug in once and for all.
User avatar
Mike
Herr VC
Posts: 4901
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Post by Mike »

nbla000 wrote:so the 37151 address replicate the address 37137...
Not quite. 37137 also controls the Handshake of Port A, 37151 has no effect on Handshake. For the aforementioned use, it surely makes no difference. But in my variant, all necessary registers are placed nearby - thus were more easily to remember for me.
llcameron
Vic 20 Dabbler
Posts: 82
Joined: Tue Oct 06, 2009 2:02 pm

Post by llcameron »

thanks for the tips. I was just reading the register values directly, so a simple AND should fix me up. Thanks!
User avatar
nbla000
Salmon Run
Posts: 2582
Joined: Thu Oct 13, 2005 8:58 am
Location: Italy

Post by nbla000 »

Mike wrote:thus were more easily to remember for me.
Thanks for your explanation.
Mega-Cart: the cartridge you plug in once and for all.
Post Reply