Home
JAQForum Ver 20.06
Log In or Join  
Active Topics
Local Time 05:07 28 Apr 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 : PicoVaders

     Page 2 of 4    
Author Message
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 5727
Posted: 10:38am 05 Jul 2022
Copy link to clipboard 
Print this post

I can confirm that the standard Atari joysticks work fine at 3V3 on the PicoGAME. This I know 'cos I have one. :)

Not all D9F joysticks will work though as some use non-Atari wiring. Typically, anything intended for the Spectrum+ or Spectrum 128 built-in jowstick ports will definitely not work unless you either make an adapter or rewire them. The connections are completely different.

Of course, if I was modifying this for the PicoGAME I'd probably make it recognise the controllers rather than the joysticks.
Mick

Zilog Inside! nascom.info for Nascom & Gemini
Preliminary MMBasic docs & my PCB designs
 
cosmic frog
Senior Member

Joined: 09/02/2012
Location: United Kingdom
Posts: 278
Posted: 10:47am 05 Jul 2022
Copy link to clipboard 
Print this post

There was a similar discusion about standardizing joysticks for the original Colour MaxiMite way back in 2013. Link  

Dave.
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 5727
Posted: 10:55am 05 Jul 2022
Copy link to clipboard 
Print this post

As far as PicoGAME is concerned I simply used pins that would reach on the PCB. :)
As usual it was designed for my own fun so I'd no standards to follow. lol

(Doing final hardware tweaks today, I think. Then I need to have a serious look at the documentation as quite a bit has changed since V1.4. It's now, officially, going to be V2.0. I made my mind up this morning. The ports are identical to V1.4.)
Mick

Zilog Inside! nascom.info for Nascom & Gemini
Preliminary MMBasic docs & my PCB designs
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 3841
Posted: 10:59am 05 Jul 2022
Copy link to clipboard 
Print this post

  cosmic frog said  There was a similar discusion about standardizing joysticks for the original Colour MaxiMite way back in 2013.


Hence
  thwill said  ... the residents of The Backshed have a pathological aversion to standardising which ports should be assigned to game controllers.


Personally whenever this is brought up I'm going to push what Mick has already comitted to fibreglass, and provided @matherp doesn't decide on something different that will then give us a defacto standard for the PicoMite VGA ... until someone decides what they really want is Nunchucks https://www.youtube.com/watch?v=-ctFBlSStFI

  Mixtel90 said  Of course, if I was modifying this for the PicoGAME I'd probably make it recognise the controllers rather than the joysticks.


I believe the OP is just wiring up 3 buttons and wanted some sort of compatibility, and it's easier to be compatible with the PicoGAME joystick interface than the PicoGAME gamepad interface.

Best wishes,

Tom
Edited 2022-07-05 21:17 by thwill
Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 5727
Posted: 11:10am 05 Jul 2022
Copy link to clipboard 
Print this post

Incidentally, the PicoGAME Mini uses the same GP connections on its controller port, so that's another layer of compatibility. :)
Mick

Zilog Inside! nascom.info for Nascom & Gemini
Preliminary MMBasic docs & my PCB designs
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 3841
Posted: 11:16am 05 Jul 2022
Copy link to clipboard 
Print this post

  Mixtel90 said  Incidentally, the PicoGAME Mini uses the same GP connections on its controller port, so that's another layer of compatibility. :)



Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
Martin H.

Guru

Joined: 04/06/2022
Location: Germany
Posts: 899
Posted: 04:18pm 05 Jul 2022
Copy link to clipboard 
Print this post

Because I followed the manual,
I already use GP0 and GP1 for audio.
  Quote  
This command should be entered at the command prompt and will be saved, so it only needs to be run once.
Both pins must be on the same PWM channel with PWM-A the left audio channel and PWM-B the right.
For example:
OPTION AUDIO GP0, GP1

so I use GP2 for Fire,
GP3 for Left and GP4 for Right

all 3 Switches are connected to 3.3V and the GPIO Pins

the Start of the Program looks like this:

'GPIO USED: GP2 Fire, GP3 Left,GP4 Right
Const JF=4 'GP2
Const JL=5 'GP3
Const JR=6 'GP4

SetPin JF, DIN, pulldown:'fire
SetPin JL, DIN, pulldown:'left
SetPin JR, DIN, pulldown:'right
Thanks Mick


so that everyone can use the Pins of his choise by changing the Const Values

Here the Version with (additional) Joystick or Button support

PicoVadersGPIO.zip
Edited 2022-07-06 02:25 by Martin H.
'no comment
 
Volhout
Guru

Joined: 05/03/2018
Location: Netherlands
Posts: 3528
Posted: 07:53pm 05 Jul 2022
Copy link to clipboard 
Print this post

Hi Martin, Mick, Tom,

This is a patch for the GAME pico VGA board revision 1.4. It uses the "PIONES" statemachine handling a single NES controller at port A (K8).

It is very playable !!!

Use < and > and B key to fire.

picovaders_NES.zip

Enjoy...
Edited 2022-07-06 06:06 by Volhout
PicomiteVGA PETSCII ROBOTS
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 3841
Posted: 08:27pm 05 Jul 2022
Copy link to clipboard 
Print this post

Neat, I've just given it a go on my PicoGAME VGA with the clone NES controller and it works quite nicely.

Only two significant issues, the title-screen is very unresponsive to the fire-button being pressed and occasionally movement of the gun halts and I have to release and repress the direction button. Not sure if this is a problem with the cheapo controller, with @Volhout's PIO code, or with the game logic itself.

Despite this I think the PicoGAME VGA really does meet its design goals and PicoVaders shows it off very nicely. Even if it is a little self-serving I think congratulations are due to all involved .

EDIT:
  Volhout said  Use < and > and B key to fire.

Actually it appears (correctly) to be the A key to fire, so is that a typo or is one of our controllers labeled wrong ?

Best wishes,

Tom
Edited 2022-07-06 06:33 by thwill
Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
Volhout
Guru

Joined: 05/03/2018
Location: Netherlands
Posts: 3528
Posted: 08:59pm 05 Jul 2022
Copy link to clipboard 
Print this post

Sorry, yes it is the A key.

I noticed the reluctance to start from startup screen. Will look into that tomorrow.

Volhout
PicomiteVGA PETSCII ROBOTS
 
Martin H.

Guru

Joined: 04/06/2022
Location: Germany
Posts: 899
Posted: 03:32am 06 Jul 2022
Copy link to clipboard 
Print this post

  Volhout said  Hi Martin, Mick, Tom,

This is a patch for the GAME pico VGA board revision 1.4. It uses the "PIONES" statemachine handling a single NES controller at port A (K8).

It is very playable !!!

Use < and > and B key to fire.

picovaders_NES.zip

Enjoy...


to get the start screen more responsive, change the end of the Into Sub to
Do While Inkey$<>" "
Print @(74,210) "  PRESS FIRE TO START   "
for btn=1 to 60
 If Pin(jf) Then Exit sub
 Pause 10
next btn
Print @(82,210) "                    "
for btn=1 to 60
 If Pin(jf) Then Exit sub
 Pause 10
next btn
Loop

this should make things better. The difference between The Button and a Keypress is. The Pin request gives the current state of the fire button while the last Keypress is buffered.  
If you press space at any stage in the loop it is noticed and the Loop end.
The State of the fire Button is requestet "just in Time"
---
AT the Next Game I will ask you first the do the routines for the NES Controller  
How about a little Library which can be merged to the own source code to make things easier
Have Fun, Chears
Martin
Edited 2022-07-06 13:45 by Martin H.
'no comment
 
Martin H.

Guru

Joined: 04/06/2022
Location: Germany
Posts: 899
Posted: 05:41am 06 Jul 2022
Copy link to clipboard 
Print this post

PicoVaders1.0.zip
so here is the fixed Version with a more responsive Intro Screen :-)
If you might change the GPIO Ports, it is done by the "Const" Settings at the Start of the Program.
'-----------------Init----------------
'
'GPIO USED: GP2 Fire, GP3 Left,GP4 Right
'Change this for your Input Ports
'
Const JF=4 'GP2
Const JL=5 'GP3
Const JR=6 'GP4
'
'-------------------------------------


have Fun ..
chars,
Martin  
'no comment
 
Volhout
Guru

Joined: 05/03/2018
Location: Netherlands
Posts: 3528
Posted: 11:20am 06 Jul 2022
Copy link to clipboard 
Print this post

Hi Martin, Tom,

I have changed the PIONES program by adding some more comments.
How this would translate into a library, I am not sure.

But this should allow you to adapt the PIONES to other IO pins, and (not tested) would also allow for support of up to 4 NES controllers as PIO1 has 4 state machines. Just add PIO INIT's and PIO start's

Regards,

Volhout
'PIONES - PIO SPI for NES controller

'PIONES is software that runs on the RP2040 PIO state machines to read from
'NES controllers (SPI). This is indenpendent of the 2 ARM cores.
'For VGA picomite PIO 0 is used to generate VGA. PIO 1 is used for PIONES

'-------------------------------- IO pin configuration -------------------------
'VGApicomiteGAME board revision 1.4

'pin asignment   Port A/K8/sm0       Port B/K7/sm1
'data (in)         gp1                  gp4
'latch (out)       gp2                  gp5
'clk (out)         gp3                  gp22


'--------------------------------- PIO configuration --------------------------
'note: the PIO program for both PIO statemachines is the same, the IO definition
'in the pinctrl register is different. The statemachines actually run same code

'PIO1 execute frequency (identical for all state machines)
f=100000

'PIO1 shift register control (identical for all state machines)
s=2^19                            'set bit 19 = IN shift left, OUT shift right

'PIO1 sm0 config
'When your NES controller is connected to different pins, adapt below 4 lines.
SetPin gp1,pio1 'data
SetPin gp2,pio1 'latch
SetPin gp3,pio1 'clock
p0=Pio(pinctrl 1,1,1,gp1,gp3,gp2,gp3)   'GP1=IN base GP2=SET GP3=OUT/SIDESET
'                     ^   ^   ^   ^
'                     |   |   |   +---- clock pin
'                     |   |   +-------- latch pin
'                     |   +------------ clock pin (second definition of same pin)
'                     +---------------- data pin

'PIO1 sm1 config
'When your 2nd NES controller connects to different pins, adapt below 4 lines.
SetPin gp4,pio1 'data
SetPin gp5,pio1 'latch
SetPin gp22,pio1 'clock
p1=Pio(pinctrl 1,1,1,gp4,gp22,gp5,gp22) 'GP4=IN base, GP5=SET GP22=OUT/SIDESET
'                     ^   ^   ^   ^
'                     |   |   |   +---- clock pin
'                     |   |   +-------- latch pin
'                     |   +------------ clock pin (second definition of same pin)
'                     +---------------- data pin


'------------------------------ PIO program (comment) -------------------------
'pio1 sm0 program, identical code for sm0 and sm1, clock is side set pin
'adr/instr/comment
'0 E081 'set pindir latch, out     [side 0]
'1 E000 'set latch low             [side 0]
'2 A0EB 'MOV null inverted to OSR  [side 0] OSR = &hffffffff
'3 6081 'OUT 1 bit OSR to pindirs  [side 0] set clock to output (pindir = 1)

'4 E001 'latch high                [side 0] latch pulse
'5 E000 'latch low                 [side 0]
'6 E027 'load X with value 7       [side 0] counter for bits shifted in
'7 A0C3 'mov NULL to ISR           [side 0] clear shift register

'8 4001 'shift 1 bit data in ISR   [side 0] adress 8 and 9 are the shift in loop
'9 1048 'JMP X-- to &h8            [side 1] this is the clock pulse
'A 8000 'push ISR                  [side 0] 8 bits to fifo
'B 0004 'jmp to &h4                [side 0] next cycle

'&h0C....&h1F not used
'------------------------- END PIO program (comment) --------------------------


'-------------------------------- START PIO 1 ---------------------------------

'PIO1 program (hex data values are from above listing)
Dim a%(7)=(&h6081A0EBE000E081,&hA0C3E027E000E001,&h0004800010484001,0,0,0,0,0)

'program and start the PIO1 state machines
PIO program 1,a%()                    'program PIO1
PIO init machine 1,0,f,p0,,s,0        'init sm0 from address &h00
PIO init machine 1,1,f,p1,,s,0        'init sm1 from address &h00 (run same code)
PIO start 1,0                         'start PIO1 sm0
PIO start 1,1                         'start PIO1 sm1

Print "PIO 1 running"



'------------------------------ MAIN level test code -----------------------------
dim h%(4)   'read PIO fifo's to this array

'power the 2 ports K8 and K7 only if needed by hardware platform
SetPin gp14,dout:Pin(gp14)=1
SetPin gp15,dout:Pin(gp15)=1


'read the FIFO's that contain the NES controller keys
'  the FIFO's are 4 levels deep, are autonomously filled from the statemachines
'  when full, new data is refused. To get the latest NES controller status, read 4
'  old fifo values, the 5'th values is just entered in the fifo, and is actual.

Do
 PIO read 1,0,5,h%()    'read 5 values (h%(0...4)) from FIFO sm0
 Print Hex$(255-h%(4)), 'print actual (h%(4)) value inverted (switches pull down)
 PIO read 1,1,5,h%()    'read 5 values (h%(0...4)) from FIFO sm1
 Print Hex$(255-h%(4))  'print actual (h%(4)) value inverted (switches pull down)
 Pause 100
Loop While Inkey$=""

End

Edited 2022-07-06 21:35 by Volhout
PicomiteVGA PETSCII ROBOTS
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 3841
Posted: 11:46am 06 Jul 2022
Copy link to clipboard 
Print this post

  Volhout said  Hi Martin, Tom,

I have changed the PIONES program by adding some more comments.
How this would translate into a library, I am not sure.

But this should allow you to adapt the PIONES to other IO pins, and (not tested) would also allow for support of up to 4 NES controllers (no reason why it would not).
Just add PIO INIT's and PIO start's


Thanks Volhout.

The PicoMite doesn't really have provision for libraries per se (i.e. no #INCLUDE), you are basically limited to copying and pasting code snippets.

In theory my MMBasic transpiler 'sptrans' (https://github.com/thwill1000/cmm2-sptools) can be used as a pre-processing step to #INCLUDE code, however I've not ported that to PicoMite yet, and it would itself need transpiling. This isn't a priority for me at the moment as I don't develop on the PicoMite directly but on Linux and then use 'sptrans' running on MMB4L to transpile followed by 'gonzo' to transfer the .bas file to the PicoMite. I've also been using MMB4W and SD card swapping where that is more convenient.

I still haven't gotten around to playing with gamepad support in my own PicoMite game, but I wonder if there is a fundamental problem that we are only reading the controller at a single specific instant in each game frame. Possibly it needs reading multiple times during each frame and the results ORing together, you would clear this state at the beginning of each frame - I will need to experiment.

Martin note that when reading the pins directly for a digital joystick (or just discrete buttons) you can instead of reading all the pins at a single instant register I/O pin interrupts to capture "button" presses. In the interrupt handler store the presses as bits in a byte (the format the NES PIO code uses to return its results) which you then inspect at the appropriate place in the main loop.

And finally (at least for now) Volhout I'm not asking you to look at it in the short-term, but I wonder if rather than the above we could/should use PIO to read the Atari joysticks too and return the results in exactly the same format/order as the NES gamepads - though obviously only 5 bits (directions and button 'A') rather than 8 bits of data.

Best wishes,

Tom
Edited 2022-07-06 21:56 by thwill
Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
Martin H.

Guru

Joined: 04/06/2022
Location: Germany
Posts: 899
Posted: 11:59am 06 Jul 2022
Copy link to clipboard 
Print this post

Hi Tom
  Quote  The PicoMite doesn't really have provision for libraries per se (i.e. no #INCLUDE), you are basically limited to copying and pasting code snippets.

Well, I know, lib Function is just for Maximite  
I meant more a collection of sups and functions that one can integrate into the own program to standardize the joystic query and so, support the PicoGAME board per default.
Such a Function that I can call during the Program
for Example "Joystat(nr)" which returns the Status of one Joystick

Maybe returns a String such as "Up" Down" "Left" "Right" "Fire" "Start" "Select"
Or a combination
Edited 2022-07-06 22:12 by Martin H.
'no comment
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 3841
Posted: 12:02pm 06 Jul 2022
Copy link to clipboard 
Print this post

  Martin H. said  Hi Tom,
<snip>
I meant more a collection of sups and functions that one can integrate into the own program to standardize the joystic query and so, support the PicoGameBoard per default.


https://github.com/thwill1000/pico-game-vga/wiki/Reading-the-NES-gamepads

Very much WIP.
Edited 2022-07-06 22:03 by thwill
Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
Martin H.

Guru

Joined: 04/06/2022
Location: Germany
Posts: 899
Posted: 12:24pm 06 Jul 2022
Copy link to clipboard 
Print this post

well from my point of view, PicoVaders is finnished..

Thanks to Volhout for doing the adaptations To PicoGAME board.  
(I can't test it right now  because i dont own one)

I'm just experrimenating with the SetTick function and I'm thrilled.
This opens up further possibilities for the next project
Edited 2022-07-06 22:26 by Martin H.
'no comment
 
Volhout
Guru

Joined: 05/03/2018
Location: Netherlands
Posts: 3528
Posted: 02:28pm 06 Jul 2022
Copy link to clipboard 
Print this post

Hi Martin, Tom,

This is the changed code for the startup screen using the NES controller.

'adaptation for piones handler
do
 'Do While Inkey$<>" "
 Print @(74,210) "  PRESS FIRE TO START   "
 for i=1 to 60
   Pause 10
   pio read 1,0,5,NES%()
   if 255-NES%(4)=&h80 then exit do
 next i
 Print @(82,210) "                    "
 for i=1 to 60
   Pause 10
   pio read 1,0,5,NES%()
   if 255-NES%(4)=&h80 then exit do
 next i
loop
'end of adaptation for piones handler
End Sub

PicomiteVGA PETSCII ROBOTS
 
Martin H.

Guru

Joined: 04/06/2022
Location: Germany
Posts: 899
Posted: 05:37pm 06 Jul 2022
Copy link to clipboard 
Print this post

Fine
Thank you all for your support.
I think, I'll consider the PicoGAME board. when I start my next "Proof of Concept"  



(is there a shop were I can order the PCB within the EU?)
'no comment
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 3841
Posted: 05:42pm 06 Jul 2022
Copy link to clipboard 
Print this post

  Martin H. said  (is there a shop were I can order the PCB within the EU?)


Alas "no", but once Mick finishes work on the v2.0 PCB I don't mind putting one in the post to you at cost  - no promises on whether German customs will be so generous.

Best wishes,

Tom
Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
     Page 2 of 4    
Print this page
© JAQ Software 2024