Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 15:35 29 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 : PicoMite: PicoGAME VGA development

     Page 26 of 31    
Author Message
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 4047
Posted: 01:39pm 17 Jul 2022
Copy link to clipboard 
Print this post

Thanks for renaming the thread @Gizmo.

Best wishes,

Tom
Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 4047
Posted: 08:53am 18 Jul 2022
Copy link to clipboard 
Print this post

  Volhout said  In line with the capabilities of the picomite VGA, I tried to improve the SSTV program ...


Thanks @Volhout, if you're going to keep posting about this then it should probably be in its own thread because your SSTV work is not specific to the PicoGAME VGA.

I'm afraid that whilst I was fascinated to learn about this and see if demonstrated on the PicoMite - and my RiscOS cronies were interested too, I simply don't have the time to follow through in any fashion ... I suppose each of us has our own projects and passions.

Best wishes,

Tom
Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
thwill

Guru

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

Hi folks,

In order to help out @Martin H. I was having a play with reading the NES controller in MMBasic (not PIO) yesterday evening and made an interesting discovery.

In theory this is what it takes to read an NES gamepad connected to port A:

Const DATA_PIN%  = MM.Info(PinNo GP1)
Const LATCH_PIN% = MM.Info(PinNo GP2)
Const CLOCK_PIN% = MM.Info(PinNo GP3)
Const PULSE_DURATION! = 0.012 ' 12 micro-seconds

nes_init_a()
Do
 Print nes_read_a%()
 Pause 100
Loop

Sub nes_init_a()
 SetPin LATCH_PIN%, Dout
 SetPin CLOCK_PIN%, Dout
 SetPin DATA_PIN%, Din
 Pin(LATCH_PIN%) = 0
 Pin(CLOCK_PIN%) = 0
End Sub

Function nes_read_a%()
 Local i%
 Pulse LATCH_PIN%, PULSE_DURATION!
 For i% = 0 To 7
   If i% > 0 Then Pulse CLOCK_PIN%, PULSE_DURATION!
   Inc nes_read_a%, Not Pin(DATA_PIN%) * 2^i%
 Next
End Function


And, if for example you press the RIGHT direction button this will print 128.

Note how:
   a) you don't pulse the clock immediately after the latch and before reading the 1st bit.
   b) you don't need to pulse the clock after reading the 8th bit, but it is harmless to do so.

- This works fine with my breadboard controller (with discrete pull-up resistors and 4021 shift-register IC.)
- This works fine with my "new old stock" clone Famicom controller (with an epoxy blob.)
- This works fine with my new Ali Express "SNES" controllers (unopened, but presumably with an epoxy blob.)

However with my new Ali Express "NES" controllers (with epoxy blobs) when you press the RIGHT direction button it prints 129 ... it's fine for all the other buttons. What's more if you press and release the RIGHT direction button then the output is:

...
0
0
0
128 <== what it should read
129
129
... repeats whilst the button is held
129
129
1   <== interesting
0
0
...


Now here's the kicker, if you change the code to perform the "unnecessary" pulse of the clock after reading the 8th bit then it works correctly and always prints 128 for the right direction button !!!

It appears that these particular controllers are off spec and whatever is inside the epoxy blob is not a 4021 shift-register or compatible.

Note this is different to the issue reported previously of "some" of these controllers not consistently sending the correct signal for the UP direction button. That only happens for SOME controllers, whereas this is consistently happening for ALL of them.

Best wishes,

Tom
Edited 2022-07-21 19:22 by thwill
Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
Sasquatch

Guru

Joined: 08/05/2020
Location: United States
Posts: 362
Posted: 05:13pm 21 Jul 2022
Copy link to clipboard 
Print this post

@thwill

Nice Work!

I have two "el-cheapo,AliExpress,epoxy-blob" NES gamepad controllers.  I ordered them at the same time from a single vendor and received them in a single package.  Yet they are slightly different cosmetically. One works perfectly, the second one is a bit wonky on the D-Pad and you must be very intentional so as not to press two directions simultaneously.  I guess that's what you get when you buy $2.65 USD controllers on AliExpress.

Both of my NES GamePad controllers exhibit the "Right = 129" issue without the extra clock pulse.  This makes little sense as you would expect the subsequent "latch" pulse to clear everything and start fresh.  This is clearly not the case.  Both work well and report "Right = 128" with the extra clock.

I have ordered two SNES game controllers with the 9 pin "D" connectors from AliExpress.  Can't wait to see what I get!  I'll report the test results here when they arrive.

I also found that by reversing the order of the Pulse and Read in the loop you can eliminate the IF statement and also provide the "phantom" clock pulse.

Here is the modified code I am using now:

'NES GamePad Test

Const DATA_PIN%  = MM.Info(PinNo GP1)
Const LATCH_PIN% = MM.Info(PinNo GP2)
Const CLOCK_PIN% = MM.Info(PinNo GP3)
Const PULSE_DURATION! = 0.012 ' 12 micro-seconds

nes_init_a()
Do
Print nes_read_a%()
Pause 100
Loop

Sub nes_init_a()
SetPin LATCH_PIN%, Dout
SetPin CLOCK_PIN%, Dout
SetPin DATA_PIN%, Din
Pin(LATCH_PIN%) = 0
Pin(CLOCK_PIN%) = 0
End Sub

Function nes_read_a%()
Local i%
Pulse LATCH_PIN%, PULSE_DURATION!
For i% = 0 To 7
  Inc nes_read_a%, Not Pin(DATA_PIN%) * 2^i%
  Pulse CLOCK_PIN%, PULSE_DURATION!
Next
End Function


P.S.  I also have some SNES controllers with the original flat connector.  When I get some time I'll rig them up and run some tests.

Regards,
Edited 2022-07-22 03:20 by Sasquatch
-Carl
 
Volhout
Guru

Joined: 05/03/2018
Location: Netherlands
Posts: 4256
Posted: 12:54pm 22 Jul 2022
Copy link to clipboard 
Print this post

Maybe these controllers contain 5v chips that do not operate well at 3.3v. Or, they do have 1k pullup resistors in them. You could squeeze the max out of them by putting GP14 output high. The voltage drop accross the 150ohm resistor would be minimized.

Happy gaming,

Volhout
PicomiteVGA PETSCII ROBOTS
 
Turbo46

Guru

Joined: 24/12/2017
Location: Australia
Posts: 1611
Posted: 09:12pm 22 Jul 2022
Copy link to clipboard 
Print this post

  Quote  Maybe these controllers contain 5v chips that do not operate well at 3.3v. Or, they do have 1k pullup resistors in them. You could squeeze the max out of them by putting GP14 output high. The voltage drop across the 150ohm resistor would be minimized.


+1

Having no appreciable decoupling capacitor would make the situation worse.

Bill
Keep safe. Live long and prosper.
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 4047
Posted: 01:52pm 23 Jul 2022
Copy link to clipboard 
Print this post

Hi folks,

In the interests of science I attached one of the accused up to run at 5V on a CMM2, pulling data, latch and clock up to 5V with 10K resistors.

Same "duff" result.

Also I know that the use of decoupling capacitors on every IC is practically a religion around here but those smart Japanese chaps at Nintendo seem to have decided it was unnecessary in the original NES controllers. I've never seen a schematic online showing a decoupling capacitor within and the photos of the internals of various generations of NES controllers don't show one either ... unless it's hiding in the epoxy blob on the later controllers, is that possible ?

Obviously you need to allow for my incompetence when it comes to hardware .

Best wishes,

Tom
Edited 2022-07-24 00:13 by thwill
Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
thwill

Guru

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

  Sasquatch said  Here is the modified code I am using now: ...


Yes, that matches how I was doing it "originally" until I noticed that according to the spec. the final clock pulse should have been unnecessary, and that's where the fun began ...

Best wishes,

Tom
Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 4047
Posted: 02:30pm 23 Jul 2022
Copy link to clipboard 
Print this post

@Volhout,

The output of the PIONES code appears to be "backwards", the Nintendo standard suggests that the 8 bits map to:
   0 - A
   1 - B
   2 - Select
   3 - Start
   4 - Up
   5 - Down
   6 - Left
   7 - Right

Whereas the output of PIONES seems to be:
   7 - A
   6 - B
   5 - Select
   4 - Start
   3 - Up
   2 - Down
   1 - Left
   0 - Right

Can this be fixed in the PIO code ? if it has to be fixed in the MMBasic then probably any speed advantage of using the PIO in the first place will be lost - alternatively games will have to be written in knowledge of this non-standard mapping.

Best wishes,

Tom
Edited 2022-07-24 00:40 by thwill
Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
JohnS
Guru

Joined: 18/11/2011
Location: United Kingdom
Posts: 3816
Posted: 03:02pm 23 Jul 2022
Copy link to clipboard 
Print this post

The numbers look to be inverted.

John
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 4047
Posted: 03:10pm 23 Jul 2022
Copy link to clipboard 
Print this post

  JohnS said  The numbers look to be inverted.

John


That would be simple to fix, but alas the result of inverting 0x80 is not 0x01. Instead the order of bits in the output byte is reversed, which unless I'm having a senior moment is rather more expensive to correct for - I know how to do it in MMBasic, I'd just rather not.

Best wishes,

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

Joined: 05/03/2018
Location: Netherlands
Posts: 4256
Posted: 05:09pm 23 Jul 2022
Copy link to clipboard 
Print this post

  thwill said  @Volhout,

The output of the PIONES code appears to be "backwards", the Nintendo standard suggests that the 8 bits map to:
   0 - A
   1 - B
   2 - Select
   3 - Start
   4 - Up
   5 - Down
   6 - Left
   7 - Right

Whereas the output of PIONES seems to be:
   7 - A
   6 - B
   5 - Select
   4 - Start
   3 - Up
   2 - Down
   1 - Left
   0 - Right

Can this be fixed in the PIO code ? if it has to be fixed in the MMBasic then probably any speed advantage of using the PIO in the first place will be lost - alternatively games will have to be written in knowledge of this non-standard mapping.

Best wishes,

Tom


I am sure that can be done. On holiday now, Ill look into it mid august.

Volhout
PicomiteVGA PETSCII ROBOTS
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 4047
Posted: 05:29pm 23 Jul 2022
Copy link to clipboard 
Print this post

  Volhout said  I am sure that can be done. On holiday now, I'll look into it mid august.


That would be most appreciated.

I think this reversal of bit order may also explain this:

  Volhout said  I can confirm that PIONES16 works with 8 bit NES controllers.
The response is a 16 bit number, where the 8 MSB are the NES buttons.
The 8 LSB should be ignored, as they should represent SNES keys.


I suspected at the time that the LSB should be the NES buttons and thus code designed to read the NES protocol (and ignorant of the SNES protocol) would still correctly read a subset of the SNES buttons.

FYI, and you may already have found this, this is the SNES gamepad protocol:
Clock Cycle/Bit     Button Reported
===============     ===============
1                   B  (this is NES button A)
2                   Y  (this is NES button B)
3                   Select
4                   Start
5                   Up on joypad
6                   Down on joypad
7                   Left on joypad
8                   Right on joypad
9                   A
10                  X
11                  L
12                  R
13                  none (always high)
14                  none (always high)
15                  none (always high)
16                  none (always high)


Enjoy your holiday,

Tom
Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 4047
Posted: 01:56pm 24 Jul 2022
Copy link to clipboard 
Print this post

Hi folks,

So having finally gotten around to testing them properly it turns out these 9-pin Ali Express "SNES" controllers are NOT SNES compatible controllers at all !!!

They are regular NES compatible controllers and the additional X, Y and Left & Right shoulder buttons oscillate either the A or B buttons just like the "Turbo Buttons" that are present on some NES controllers. I've taken one apart and this is quite clearly the case from the PCB layout. I wonder how difficult it would be to replace the PCB with a custom one that is correct, something to look at in the future perhaps.

Definitely a case of let the buyer beware - I don't believe I ever "recommended" buying them, but if someone does feel that they bought them on such a recommendation then I apologise.

EDIT: I have to say I don't see the "point" of this deception, they could have made it correct for basically the same price ?

EDIT 2: Interestingly they don't show the "Right returning 129" problem reported above, so they are in some ways a better NES compatible controller.

I've ordered a different "brand" of SNES controller to investigate.

Best wishes,

Tom
Edited 2022-07-25 00:29 by thwill
Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 6814
Posted: 02:40pm 24 Jul 2022
Copy link to clipboard 
Print this post

They must be good though, as they have "4 red buttons to make you experience more wonderful and excitement." :)
Quality stuff....  :)

Is there enough space to isolate the "blob" and replace it with a small board? I suspect their pcb has the lower half of the buttons on it.
Edited 2022-07-25 00:47 by Mixtel90
Mick

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

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 4047
Posted: 02:54pm 24 Jul 2022
Copy link to clipboard 
Print this post

  Mixtel90 said  Is there enough space to isolate the "blob" and replace it with a small board? I suspect their pcb has the lower half of the buttons on it.


It's not just the blob that is wrong, the tracks from the buttons are too. Some of the buttons share (difficult to cut) tracks that they shouldn't.

And there isn't a lot of space to stick two 4021 shift registers and 11 x 10K resistors in there.

Best wishes,

Tom
Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
Sasquatch

Guru

Joined: 08/05/2020
Location: United States
Posts: 362
Posted: 07:37pm 24 Jul 2022
Copy link to clipboard 
Print this post

  thwill said  
  Mixtel90 said  Is there enough space to isolate the "blob" and replace it with a small board? I suspect their pcb has the lower half of the buttons on it.


It's not just the blob that is wrong, the tracks from the buttons are too. Some of the buttons share (difficult to cut) tracks that they shouldn't.

And there isn't a lot of space to stick two 4021 shift registers and 11 x 10K resistors in there.

Best wishes,

Tom


Perhaps a more practical solution would be to modify the cable and/or plug on a controller made for the SNES, or build an adapter cable from the SNES 7pin flat plug to the D9 port on the PicoGame board.

I also ordered some of the 9pin SNES controllers from AliExpress, I'll let you know when they arrive but they are almost certainly NES controllers in a SNES form factor.  It turns out these were designed for a Chinese Famicon clone "500 in one TV game" aka the "FamiClone."  It's a modern incarnation of the original but comes with hundreds of games in flash memory.

I seem to have all the parts here to build some adapter cables, I'll post here when I know more.

Ahhh....  So many projects, so little time!
-Carl
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 6814
Posted: 07:45pm 24 Jul 2022
Copy link to clipboard 
Print this post

Even more practical is to stick with the NES "clone" controllers. ;)
It would be nice to figure out the problem Tom has had though.
Mick

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

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

  Mixtel90 said  Even more practical is to stick with the NES "clone" controllers. ;)
It would be nice to figure out the problem Tom has had though.


If you want, I will look into it. Send me the controller. Tom, you have my address. I am curious too how this can happen.
But it is totally possible that if this is a controller for a specific game machine, that the machine has a work around for this artefact. Or these controllers where dumped cheap on the market becase this bug.

Volhout
Edited 2022-07-25 06:30 by Volhout
PicomiteVGA PETSCII ROBOTS
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 4047
Posted: 01:36pm 25 Jul 2022
Copy link to clipboard 
Print this post

Hello folks,

  Sasquatch said  Perhaps a more practical solution would be to modify the cable and/or plug on a controller made for the SNES, or build an adapter cable from the SNES 7pin flat plug to the D9 port on the PicoGame board.

I have ordered a pair of 7-pin clones from AliExpress (so no guarantee they aren't the same crap internally) and have more than enough controllers to provide some donor 9-pin plugs for some cable surgery - I've now bought 12 controllers and 2 joysticks for our little project - I do this so hopefully other people don't have to .

  Mixtel90 said  Even more practical is to stick with the NES "clone" controllers. ;)

Probably, but wouldn't it be nice to determine if there is a practical option with the 4 additional independent buttons ?

  Mixtel90 said  It would be nice to figure out the problem Tom has had though.

I assume you mean the Right = 129 issue with the grey NES style controllers with the 4 red buttons ?

  Volhout said  If you want, I will look into it. Send me the controller. Tom, you have my address I am curious too how this can happen. But it is totally possible that if this is a controller for a specific game machine, that the machine has a work around for this artefact. Or these controllers were dumped cheap on the market becase this bug.

I suspect it's the former, it is actually simpler to pulse the clock after every read even if the "official" 4021 based controllers don't require it. Anyway, I have surplus so I'll look at throwing a couple in the post for Dutch customs to play with.

@Mixtel90 I may have misread/misinterpreted but does the 2.0 PCB have support for an Atari style joystick on Port B as well as Port A ? If so then is there a simple patch I can do to a 1.4 PCB to replicate this ?

Best wishes,

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