Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 11:32 26 Nov 2024 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : PACMAN for Maximite

     Page 3 of 8    
Author Message
Nick

Guru

Joined: 09/06/2011
Location: Australia
Posts: 512
Posted: 09:32pm 05 Mar 2012
Copy link to clipboard 
Print this post

Thanks crackerjack. Any chance of an explanation how IC2 works with regards to the joystick.

Nick
 
crackerjack

Senior Member

Joined: 11/07/2011
Location: Australia
Posts: 164
Posted: 01:26am 06 Mar 2012
Copy link to clipboard 
Print this post

Nick,

The Nunchuck Joystick (while an analog, "two-pot" stick) returns digital values via I2C as explained below...

The following assumes the use of a "clone" WII Nunchuck and not the original, which I understand works differently:

I2C is enabled at 400 kHz ("I2C fast mode") and the WII Nunchuck is addressed via it's 7-bit address which is h&52 (1010010x).

An initialisation sequence is then sent to the Nunchuck (the so-called "new way" which means no decryption of results is required).

This sequence is two bytes values of &hF0, &h55 followed by another two bytes of values &hFB, &h0

After this, the Nunchuck data can be accessed by writing a single byte value of &h00 and then reading 6 bytes into a read buffer to obtain the various elements of data for:

* C Button
* Z Button
* 8 or 10-bit X, Y and Z axes values of the accelerometer, and the
* X & Y co-ordinates of the analog joystick

The joystick values for both X and Y range from 0 to 255 and are held in bytes 0 and 1 of the read buffer. If you don't care for the buttons and accelerometer data at this stage, the other 4 bytes of returned data can be ignored. You could probably use a read buffer of two bytes.

The neutral position of the joystick will be somewhere around mid-way (255/2), but will vary depending on each specific device.

You can then use the resulting values read from the Nunchuck to determine the Joystick position, or do some basic maths to determine if the joystick is left/right and-or up/down of centre.

I would imagine you could deal with the Nunchuck initialisation, read and decoding of the joystick values in less than 10 lines of MMBasic code.
 
Nick

Guru

Joined: 09/06/2011
Location: Australia
Posts: 512
Posted: 02:21am 06 Mar 2012
Copy link to clipboard 
Print this post

Cool info. I must get one to hook up to the Maximite. Hopefully, reading of the nunchuck is fast enough not to slow the game down.

INKEY$ is working fine, although I could never get use to game controls using the keyboard cursor pad. My kids seem to have no problems though. :)

I may wire up a digital stick as Darth has since I have several of those from my Amiga.

I should be able to provide support for all devices, adding a prompt at the start of the game to choose the input device.
 
cosmic frog
Senior Member

Joined: 09/02/2012
Location: United Kingdom
Posts: 284
Posted: 10:26pm 07 Mar 2012
Copy link to clipboard 
Print this post

  Nick said   ...I may wire up a digital stick as Darth has since I have several of those from my Amiga....
.

I think I will be connecting an Amiga/Atari style joystick socket to my UBW32, I'm not too keen on the Wii numchuck thing, I like the old school way of doing things plus it can be used for other things not just a joystick. Both would be nice though.
 
Nick

Guru

Joined: 09/06/2011
Location: Australia
Posts: 512
Posted: 10:17pm 12 Mar 2012
Copy link to clipboard 
Print this post

Almost ready. Just a few minor "cosmetic bugs" and play testing.

There are still a few things I'd like to add but I may leave these for a Version 2 if I have the incentive.

Last job to do is to add the nunchuck support.
 
Nick

Guru

Joined: 09/06/2011
Location: Australia
Posts: 512
Posted: 10:15am 14 Mar 2012
Copy link to clipboard 
Print this post

Having trouble getting my Nunchuck to work. Decided to go the Atari stick way.

To those that have this stick interfaced to their MM (Darth?), which pins did you assign as the up.down,left,right and fire?

Is there a Maximite "standard" for the wiring of this type of stick?

NickEdited by Nick 2012-03-15
 
cosmic frog
Senior Member

Joined: 09/02/2012
Location: United Kingdom
Posts: 284
Posted: 09:46pm 14 Mar 2012
Copy link to clipboard 
Print this post

I found this on a previous post.

"Darthmite has used the following to interface "atari" style joysticks"
pin 11 - Up
Pin 12 - Down
Pin 13 - Left
Pin 14 - Right
pin 15 - Fire
 
Nick

Guru

Joined: 09/06/2011
Location: Australia
Posts: 512
Posted: 01:56am 15 Mar 2012
Copy link to clipboard 
Print this post

  cosmic frog said  
"Darthmite has used the following to interface "atari" style joysticks"
pin 11 - Up
Pin 12 - Down
Pin 13 - Left
Pin 14 - Right
pin 15 - Fire


Fantastic. I'll wire it up tonight and add support for it in the code.

Couldn't get the nunchuck to work. Is there any pullup resistors needed to be installed?

NickEdited by Nick 2012-03-16
 
crackerjack

Senior Member

Joined: 11/07/2011
Location: Australia
Posts: 164
Posted: 05:09am 15 Mar 2012
Copy link to clipboard 
Print this post

No pullups required for the Nunchucks - they have these internally.
 
robarino
Newbie

Joined: 15/03/2012
Location: Sweden
Posts: 24
Posted: 01:35pm 15 Mar 2012
Copy link to clipboard 
Print this post

Hej!

I am an old COCO II user and I love these minimites and duinomites! My question is this...how do you get the objects to move without using cls? When I try to do any animation I use cls and it flickers. Maybe this is a dumb question but I am a noob....
 
Nick

Guru

Joined: 09/06/2011
Location: Australia
Posts: 512
Posted: 07:24pm 15 Mar 2012
Copy link to clipboard 
Print this post

  robarino said   Hej!

I am an old COCO II user and I love these minimites and duinomites! My question is this...how do you get the objects to move without using cls? When I try to do any animation I use cls and it flickers. Maybe this is a dumb question but I am a noob....


The quickest and cleanest way in MMBASIC is to simply define your characters with some blank space around them so you don't have to erase anything. As a character moves, as long as it moves by the amount of the blank space, it will automatically erase.

If an object does move more than this blank boundary, then it is best to actually print a blank space over it. The Maximite is fast enough to achieve a fluid enough movement.

I'm afraid the MM doesn't have any hardware based "sprites" to make this easier. :)
 
Nick

Guru

Joined: 09/06/2011
Location: Australia
Posts: 512
Posted: 09:50pm 15 Mar 2012
Copy link to clipboard 
Print this post

I'm having "Joystick Nightmares"!

First, I couldn't get the Wii Nunchuck to work at all.

So I gave up and decided to go to an Atari style stick and while it works, it's response is terrible.

I'm sure I've wire up all the correct joystick lines to the appropriate digital pins (as Darth's) but I often seem to get multiple reads of the positions.

I've written the following test routine...

FOR x=11 TO 15
SETPIN x,2
NEXT

SCAN:

LOCATE 0,100
FOR x=11 TO 15
PRINT PIN(x)
PAUSE 10
NEXT

GOTO SCAN

(The PAUSE 10 was put in to give the read some settle time, shouldn't be needed)

Often when I move the joystick UP, I get an UP and RIGHT reading. Two readings! Which causes my game to do the wrong thing. Other times it doesn't read at all and other times it reads correctly.

I thought it was the joystick so have tried a few, same problem.

I removed the joystick and shorted the direction pins manually with a probe/wire, again the same.

I'm using a prototyping board for the MM connected via a ribbon cable to the MM. Could it be interference? I'll buy an edge connector today and wire the stick directly, keeping wires short.

I just can't seem to get accurate digital reading from the joystick.

Any clues anyone?Edited by Nick 2012-03-17
 
Vikingboy
Regular Member

Joined: 23/09/2011
Location: Australia
Posts: 82
Posted: 11:15pm 15 Mar 2012
Copy link to clipboard 
Print this post

Hi Nick,

Just an idea, you will need pull op or down resistors for the atari style as they are just straight switches, I found without them I got unreliable results, also as they are switches you may find a debounce routine may help.

rgds,

Andrew
 
Nick

Guru

Joined: 09/06/2011
Location: Australia
Posts: 512
Posted: 11:33pm 15 Mar 2012
Copy link to clipboard 
Print this post

I think you could be right on this. What value pullup resistors should I use? 1K?

And do I tie the individual direction pin to 5v?
 
Vikingboy
Regular Member

Joined: 23/09/2011
Location: Australia
Posts: 82
Posted: 12:03am 16 Mar 2012
Copy link to clipboard 
Print this post

I am by no means an expert and some one else can probably tell you the correct value, but I just used some 500 ohm resistors and pulled each input line high and then closing the switch for each direction pulls it back to 0v.
and set the pin appropriately, or use an interupt to be active low, dont know which would be more suitable.

rgds,

Andrew
 
darthmite

Senior Member

Joined: 20/11/2011
Location: France
Posts: 240
Posted: 03:36am 16 Mar 2012
Copy link to clipboard 
Print this post

Hi Nick ,

I forget to tell you that all button are pulled up with a 10K resistor.
The normal state is 1 and when you press a button you get the 0.
Here is my joystick test program :

'Amiga Compatible Joystick test for Maximite
'
CLEAR
CLS
'PIN 11 = UP
SETPIN 11,2
'PIN 12 = DOWN
SETPIN 12,2
'PIN 13 = LEFT
SETPIN 13,2
'PIN 14 = RIGHT
SETPIN 14,2
'PIN 15 = Button 1
SETPIN 15,2
'PIN 16 = Button 2
SETPIN 16,2
'PIN 1 = Potentiometer
SETPIN 1,1
'Main Loop
DO While 1
locate 0,0 : print "UP = ";PIN(11);" "
locate 0,20 : print "DOWN = ";PIN(12);" "
locate 0,40 : print "LEFT = ";PIN(13);" "
locate 0,60 : print "RIGHT = ";PIN(14);" "
locate 0,80 : print "BUTTON 1 = ";PIN(15);" "
locate 0,100 : print "BUTTON 2 = ";PIN(16);" "
locate 0,120 : print "POTENTIOMETER = ";PIN(1);" "
loop



here the Schematic :



Edited by darthmite 2012-03-17
Theory is when we know everything but nothing work ...
Practice is when everything work but no one know why ;)
 
Nick

Guru

Joined: 09/06/2011
Location: Australia
Posts: 512
Posted: 08:14pm 26 Mar 2012
Copy link to clipboard 
Print this post

MaxMan is here!

Written completely in MMBasic for the Maximite Computer developed by Geoff Graham.

Firstly, I must stress to the programming purists out there that MaxMan is NOT an example of structured coding. It contains many GOTO statements and has heavy use of multiple statement lines. For many, the code will be very hard to understand … but I have no problem following the code myself.

This game is to be ENJOYED, not STUDIED.

Copy the files to your SD card and RUN”MAXMAN” to get it going on your Maximite.

The game supports keyboard and joystick (using Darthmite’s Atari stick specification). Unfortunately, no Wii Nunchuck (couldn’t get my nunchuck to work). More control instructions are included within the code opening REM lines.

It features arcade-like sound effects so hook up that amp!

It is designed for a VGA display, LCD or CRT (looks best on a CRT).

It requires MMbasic 3.1.

I would be curious to know if it also works on the other Maximite compatible machines.

Enjoy the first commercial grade arcade game for the Maximite!

DOWNLOAD: 2012-03-27_061443_MAXMAN.zip




Edited by Nick 2012-03-28
 
Bill.b

Senior Member

Joined: 25/06/2011
Location: Australia
Posts: 226
Posted: 10:50pm 26 Mar 2012
Copy link to clipboard 
Print this post

Hi Nick

loader maxman but seem to have problems with keyboard control.
pressing any key at the start does not seem to give me keyboard
control any suggenstions.

Bill

In the interests of the environment, this post has been constructed entirely from recycled electrons.
 
Nick

Guru

Joined: 09/06/2011
Location: Australia
Posts: 512
Posted: 10:54pm 26 Mar 2012
Copy link to clipboard 
Print this post

  Bill.b said   Hi Nick

loader maxman but seem to have problems with keyboard control.
pressing any key at the start does not seem to give me keyboard
control any suggenstions.

Bill


Strange?? It's only using the inkey$ command for that. Nothing special.

Anyone else having trouble starting it? Darthmite's is working fine.

Anything odd or non-standard about your Maximite?

Hold the key down for a second.

NickEdited by Nick 2012-03-28
 
Bill.b

Senior Member

Joined: 25/06/2011
Location: Australia
Posts: 226
Posted: 11:00pm 26 Mar 2012
Copy link to clipboard 
Print this post

got it working by coninually pressing a key while drawing screen.
great work Nick.

Bill
In the interests of the environment, this post has been constructed entirely from recycled electrons.
 
     Page 3 of 8    
Print this page
© JAQ Software 2024