SNES Controller Interface - Part 2 - Connecting to the homebrew CPU

  Переглядів 6,280

James Sharman

James Sharman

День тому

The next big step for the SNES controller interface is to build the circuitry that allows connection to a CPU. I build the circuit on breadboard and connect it to my homebrew CPU. I briefly cover the code necessary to read from the controller and finish by adding support to my serial terminal game “Snek”.
0:00 Introduction
0:41 Circuit Recap
1:25 Discussion
4:19 Build
12:37 Integrate into CPU Build
13:26 Add Support
17:41 Testing
19:11 Snek!
21:28 Outro
Join the channels Discord: / discord
You can support the channel on Patreon: / jamessharman

КОМЕНТАРІ: 134
@weirdboyjim
@weirdboyjim Рік тому
Join the channels Discord: discord.gg/jmf6M3z7XS You can support the channel on Patreon: www.patreon.com/JamesSharman
@alschnittke
@alschnittke Рік тому
i love the schematic visuals on the side with you walking through your design decisions and logic so clearly. keep up the great work!
@weirdboyjim
@weirdboyjim Рік тому
Glad you are enjoying it thanks Jack!
@andrewwatts1997
@andrewwatts1997 Рік тому
From a CPU to a game console, great work !
@weirdboyjim
@weirdboyjim Рік тому
Thanks Andrew!
@McTroyd
@McTroyd Рік тому
Don't think I've said anything about it yet, but those schematics you're animating as the bread board goes together have been extremely helpful. As someone who easily loses track of his own breadboard projects, it makes the build much easier to follow. 👍
@weirdboyjim
@weirdboyjim Рік тому
They are a real pain to do so it's good to hear they are useful!
@reinoud6377
@reinoud6377 Рік тому
Nice! But why didn't you choose for say 2 times 6 bits ordered in a way that makes sense and then use the 8th bit as a marker like you are using it now?
@CeDoMain
@CeDoMain Рік тому
Agree with that. You read both bytes when you read the controller. So you have both bytes available in your registers. I cannot see any case when an 6-6 bit solution is slower or more calculation expensive than your current 8-4. Since your bit test behaves the same on both registers. 🤔 If your sign bit is not ambigous you are faster at runtime because there is no need to check the top bit. If you do this check on init it is enough i think.
@weirdboyjim
@weirdboyjim Рік тому
Would have been totally valid to do so and it was actually something I considered but decided against. The reason why is the combined result of 2 considerations, I wanted the bits in the registers to match the bits coming out of the shift registers (i.e. I didn’t want to reorder them). Additionally I wanted the 4 arrow direction bits to be in the same byte, inevitably these end up being processed together by the same but of code and splitting them up would be a programming annoyance. I try and touch on this stuff in the discussions but if I talk about everything that crossed my mind designing something it would be more of a rambling mess that it is already ;-)
@anthonyaraujo2826
@anthonyaraujo2826 Рік тому
@@weirdboyjim Personally, the more rambling mess the better ;)
@101blog
@101blog Рік тому
Agreed other than he decided that he wanted the 1st 8 bits of the controller to remain the same.... Think of all those stubborn decisions we make then all the faf we undergo to implement them
@Cowboy-Ben-Alman
@Cowboy-Ben-Alman Рік тому
Yeah, this is the first thing that came to my mind as you were building this. It seems like a super minor change that could reduce overall complexity. If so, why not do it? Also why use L and H in your constant names for the buttons? Does it really matter that the programmer knows an implementation detail like this when writing code that uses the buttons? It seems like just another thing to have to memorize. Either way, great stuff!
@kriswillems5661
@kriswillems5661 Рік тому
You could pull the 2 upper bits high, because it's physically impossible to press left and right at the same time.
@weirdboyjim
@weirdboyjim Рік тому
Nice idea, but that's actually not true. On the Nintendo controllers you can just about get left and right at the same time but there were 3rd party controllers that had four buttons (more like the ps1 controller) which make it easy.
@0LoneTech
@0LoneTech Рік тому
@@weirdboyjim The PS1 controller has a gap in its D-pad for horrible blistering, but it's still one hard piece teetering. Dance mats do use simultaneous opposite directions though.
@hicknopunk
@hicknopunk Рік тому
@@0LoneTech he is talking a 3rd party crap controller
@schrodingerscat1863
@schrodingerscat1863 Рік тому
This is a good solution to read 16 bits with only one control line. I think I would have changed the interface a bit to free up bit 8 free on both bytes to be used purely for identification so you would always be able to guarantee which byte has been read just by testing bit 8. I know exactly where you are coming from trying to keep the variety of components to a minimum, even if it used a couple of extra chips overall working with fewer different chips is less head space.
@weirdboyjim
@weirdboyjim Рік тому
I’ve mentioned it in a few comment replies already but I did consider splitting the bits more like that but picked this for a reason. I wanted all the direction bits to be in the same byte (that makes life easier working with the data in code), and I didn’t want to re-order the bits relative to the original data stream.
@schrodingerscat1863
@schrodingerscat1863 Рік тому
@@weirdboyjim Right, it seemed a little odd that you hadn't done this but thinking about it from a software development perspective it makes perfect sense.
@lefauve
@lefauve Рік тому
@@weirdboyjim what about a time based reset of the flip flop? You'll likely read both bytes right after one another, and probably not more than once every 60th of a second, so if you reset it every 10ms you'll know that on the next reading cycle you'll always get the first byte first. 6 buttons Megadrive joypads use this trick, so older games which expect a 3 buttons joypad and read only one byte per frame always get what they're expecting.
@Stingpie
@Stingpie Рік тому
@@weirdboyjim another alternative is to pull up bit 7 & 8 for the second byte, since it would be impossible to press both left & right on the controller at the same time.
@johnaldis9832
@johnaldis9832 Рік тому
I think I'd have made the "signal" that the top *two* bits were high: to fake that a user would have to hold left *and* right simultaneously, which I believe is mechanically impossible on the real controller?
@TheRealBobHickman
@TheRealBobHickman Рік тому
Nice one James, this is shaping up really well.
@weirdboyjim
@weirdboyjim Рік тому
Thanks Bob! Always good to hear from you!
@StefanRink
@StefanRink Рік тому
You are getting better at this video editting thingy too! I like how you added the circuit in real-time while patching the wires! Keep up the good work.
@weirdboyjim
@weirdboyjim Рік тому
Thanks Stefan. I do worry that "Getting better at this video editting thingy" is actually just me spending more and more time on it relative to actual building.
@KimSeiji
@KimSeiji Рік тому
Great work James! 👏
@weirdboyjim
@weirdboyjim Рік тому
Thanks Kim!
@rauljvila
@rauljvila Рік тому
At first the controller looked (to me) like a minor accesory, but now I see that it made the computer fully independant of any other device. Congratulations! And it's awesome how smooth the first steps in expanding the ssytem are going. Just before you said it I was (we all were?) rooting for a Controlled Supported SNEK! Thanks for all the great content :)
@weirdboyjim
@weirdboyjim Рік тому
Indeed! Not everyone is interested in all the peripherals but what I'm doing here is building all the components for a mini homebrew game system.
@m1geo
@m1geo Рік тому
Awesome progress! Nicely done! I may have used all 4 bits of the MSBs to hold a pattern to test, but the single MSB works well enough! 👌👏
@weirdboyjim
@weirdboyjim Рік тому
Thanks George. I could do, but I kind of wanted to deliver those 3 bits from the shift registers. It will let me know if someone plugs a non controller in.
@peter.stimpel
@peter.stimpel Рік тому
I really like the synced view on breadboarding vs easyeda. Good one, James!
@weirdboyjim
@weirdboyjim Рік тому
Thanks Peter, getting that all synced up is a pain but people do seem to like it.
@peter.stimpel
@peter.stimpel Рік тому
@@weirdboyjim makes it much easier to follow your wiring action!
@CeDoMain
@CeDoMain Рік тому
Great circuit james! I like it! Cant wait to see snek on vga. 😎
@weirdboyjim
@weirdboyjim Рік тому
Me too! But I'll probably not do a final port of snek until I have the tiledata circuit working so I can do it justice.
@luandkg
@luandkg Рік тому
Oh my God, this project is amazing 👏🏻👏🏻👏🏻
@weirdboyjim
@weirdboyjim Рік тому
Thanks Luan!
@colonelbarker
@colonelbarker Рік тому
I feel like having six on each bit would be a better idea, so you know that the MSB is always the high/low bit flag. I actually made a hex keypad using a very similar counter and demux selector and dlatches this week. Nice to see others have used the same route.
@efanchen2440
@efanchen2440 Рік тому
thought the same. just move the highbit from the first chip to the next free bit on the second chip. Then let the high bit from second chip high and bind the high bit from the first chip low. then you always can be sure about the readout. I hope the pcbs are not made yet :D
@weirdboyjim
@weirdboyjim Рік тому
It would be a pain for the direction buttons to be in a different byte of the resulting data.
@weirdboyjim
@weirdboyjim Рік тому
I did consider that before I made the circuit but I had reasons for going the way I did.
@13ohms
@13ohms Рік тому
Hi James, I followed your comments below and it seems that everyone feels a little unhappy with the ambiguous MSB as an indentifier -- maybe including yourself. However, I also understand that you need the D-pad not to be split, as you pointed out to Reinoud. I think, not "reordering the bits" is also a valid argument -- in software, at least, because it costs time. But what if you actually used the line buffes for the reordering of your shift register outputs? I see no reason, why the original bit sequence from the controller is in any way relevant in later software or the processor itself. You could even choose a more sensible layout for the data. For example: Stick the D-Pad into the low nibble of byte 0 and the four ABXY into the low nibble of byte 1 (so they're not split anymore); the sholder buttons and Start/Select each find their place in bits 4 and 5 and the MSB could then identify the multiplexing of the data unambiguously. And if, one day, you choose to add a second controller, you have another spare bit for the controller port ID (as I am not the first one to point out, either, and I think, you should absolutely add a second controller anyway). Please let the hardware do its magic. :-)
@weirdboyjim
@weirdboyjim Рік тому
I’m totally fine with it. Reordering the bits would add to pcb routing complexity but that’s unlikely to be a big deal. Every time there is a subjective choice there will be people who disagree but these videos are not me saying “This is the one true way to solve this problem” this is me saying “I did this and it works”. A second controller would work just as well under my system, you would need to switch to a de-multiplexer and put in an extra pair of shift registers and line drivers.
@anthonyaraujo2826
@anthonyaraujo2826 Рік тому
James, I love your videos! I would be very interested in seeing some of the "logistics" of building that you use in your projects. For example, your extensive use of EasyEDA; your soldering setup for SMD (i.e. temps and speeds that you use on your hot air gun/iron). I have used EasyEDA in the past, but I am nowhere nearly as proficient in its utilization as you are, a demonstration/narration of how you align, rename, wire, etc. would be invaluable, in my opinion. Also the manual routing that you do, how you decide where tracks should be; doing the turns; etc.
@weirdboyjim
@weirdboyjim Рік тому
Thanks Anthony! I did talk about temps etc.. in some of the earlier videos. Maybe I could put more detail in an extras channel video, you can always stop by the discord and ask questions though.
@anthonyaraujo2826
@anthonyaraujo2826 Рік тому
@@weirdboyjim I appreciate that! I just find your technique (especially in EasyEDA) pretty amazing and I remember in the early stages of this project you mentioning that it was your first foray into the PCB design world. So, color me impressed! Just wondering how you achieved such expertise.
@damouze
@damouze Рік тому
The circuit looks so simple, yet I am having a hard time wrapping my head around how the shift registers work in practice. I mean, I understand how they work in theory, but for some reason all the control lines keep confusing me! ;-) Thanks again for the past two video's. I am looking forward to part 3.
@weirdboyjim
@weirdboyjim Рік тому
Best thing you can do is get a chip and a breadboard and have a play. Drop by the discord and ask if you are still struggling though.
@StefanRink
@StefanRink Рік тому
Basically it's just a bunch of flip-flops after each other and depending on the type of shifter (parallel input or output) they pins on the chip are connected a bit differently to the flip-flops. My advice would be take Logisim or Digital (hneemann/Digital) and build one your own and test with it. Digital has most TTL chips you could just include in your experiment and you could open them up and somewhat look how they work internally.
@damouze
@damouze Рік тому
@@StefanRink ​ @James Sharman That's basically what I've been doing so far. I really like both programs. I will try and have some fun with it (after my new desk chair has arrived). Thank you both. By the way, what confuses me most is the inconsistent naming of the pins across various manufacturers and software.
@Quxxy
@Quxxy Рік тому
Nice. I'm glad to see I managed to guess how it would be integrated, *and* what the first demo would be. :P At this point, I think the only thing missing for a proper VGA port of snek is the tilemap so you can do text. I might start porting my version over to VGA, and see about integrating my music tracker... just need to find a reasonable track to use. I think Nyancat on loop would just drive people insane...
@weirdboyjim
@weirdboyjim Рік тому
Yeah, the Tilemap would make it easier. I think having Audio and Controller on pcb would help as well, I'm low on space without making everything really small in the video feed.
@MarkOfBitcoin
@MarkOfBitcoin 10 місяців тому
Do you publish the schematic for this circuit, anywhere. You make it look so easy! Great job!
@weirdboyjim
@weirdboyjim 8 місяців тому
I usually publish the schematic when I make the pcb. That will be the next (and final) video in this side series , hopefully not too far in the future.
@DamianReloaded
@DamianReloaded Рік тому
Very nice! Could you use only 1 of these to read the state of two controllers alternately?
@weirdboyjim
@weirdboyjim Рік тому
Well you would need to add some components, but you wouldn't need to duplicate it all.
@kaminutter
@kaminutter Рік тому
Cool :D. Just wondering why not use the write line to reset the flip flop so to read the controller you can just write then read read to get the data?
@weirdboyjim
@weirdboyjim Рік тому
That would be a similar system to one I discussed for the Audio system, a valid approach of course but the obvious write line here (Also the audio one) is itself stateful so you would have an extra layer of programming considerations to worry about. That I was considering making the controller stateful was actually a contributory reason why I didn’t use a similar technique in the Audio system.
@OscarSommerbo
@OscarSommerbo Рік тому
Did you just call me out at 7:40, James? :) Reducing the part count is completely valid, but I look to chips that do the job better/easier. However, I am just some guy on the Internet with opinions, I am nearly irrelevant. I just like to point out different ways to do what you did. For instance, I would have split the line to 6 and 6, that gives one bit to unerringly identify high/low part of the controller data, and the option to add a second controller. But again, I am not the one building this fabulous computer and making the neat videos, I am just the opinionated asshole living in the comments :D Thanks for another great one! The circuit is very clever!! Any plans for a second controller? There are unused bits in the high byte that could be used for ID. I wish I could support you on Patreon, but living on a fixed income sucks. I will continue to cheer you on from the sidelines, as it were.
@weirdboyjim
@weirdboyjim Рік тому
I wasn’t thinking of you specifically, but if the shoe fits…. But you are never irrelevant Oscar! I did have a reason why I didn’t split it 6:6 though. I wanted all the direction bits to be in the same byte, and I didn’t want to re-order the bits relative to the original data stream.
@OscarSommerbo
@OscarSommerbo Рік тому
@@weirdboyjim Not splitting off the direction bits makes sense, but not reordering the data stream less so. Regardless, your way works beautifully. And you probably could retrofit a second controller if you wanted one.
@Philip8888888
@Philip8888888 Рік тому
Nice. Small question: what did you use to draw your diagram at 3:00?
@weirdboyjim
@weirdboyjim Рік тому
I actually just draw those in photoshop. there are probably far better programs for doing that kind of work in.
@stellsy3496
@stellsy3496 Рік тому
you could shuffle the bits over a little to free the high bit on the other register to be permanently low
@weirdboyjim
@weirdboyjim Рік тому
That would work, but it wouldn't simplify the reading code and would loose one bit of input. This doesn't matter in the grand scheme of things but I like that the low byte is the exact inputs from the original nes controller.
@TheCunningFellow
@TheCunningFellow Рік тому
Another option rather than having the MSB pulled to VCC to work out hi/lo byte is to have some time function (maybe even a 555) do the work for you. The first byte being read is the low byte. If another byte is read before an n millisecond time-out period then it is the hi byte. It also might be an idea to not clock in the SNES data constantly if you ever want to use some old school wireless controllers. Some of those would freak out if they did not have a rest between clocking.
@weirdboyjim
@weirdboyjim Рік тому
Interesting idea. If you were to implement something like that it would be better to make the timeout a number of system clocks though to make it deterministic.
@jimmy21584
@jimmy21584 Рік тому
To avoid a miscreant holding the button down to fool the circuit: could you switch the wire going from the top bit of the lower byte shift register, into a spare bit in the upper byte output? So only 7 bits are ever set on the lower byte.
@weirdboyjim
@weirdboyjim Рік тому
At least I'm safe from the aforementioned miscreant beating my Snek score!
@cadatoiva
@cadatoiva Рік тому
I thought I saw somewhere that at least one of the old nintendo controllers (nes or snes, maybe both) have a nub under the directional pad that made pressing opposite directions impossible. If the snes controller has that feature, you could do left/right or up/down pair of lines to force forever high on the high byte and avoid any edge cases entirely.
@weirdboyjim
@weirdboyjim Рік тому
That's right, but you can still push both sides at the same time and there were third party controllers that just had 4 buttons.
@LeeSmith-cf1vo
@LeeSmith-cf1vo Рік тому
13:00 - is that why it was (for a while) common to have a "game port" (aka joystick connection) on PC sound cards?
@weirdboyjim
@weirdboyjim Рік тому
No, but I do like the similarity here. The real reason why game ports and sound cards were often found together was some early clones had limited slots. The joystick cards were very simple circuits so adding that functionality to a sound card was easy and made the first cards to do it stand out.
@TheEmbeddedHobbyist
@TheEmbeddedHobbyist Рік тому
as you will be reading both to get the controler data, can't you move the lower 8 bit signal to the upper port where you have 3 spare bits and then set bit 8 low. then you will have bit 8 defining the port being read.
@weirdboyjim
@weirdboyjim Рік тому
If I was smarter I would have realized everyone was going to suggest this. I considered it but went with the solution I implemented for a couple of reasons. I wanted all the direction bits to be in the same byte, and I didn’t want to re-order the bits relative to the original data stream.
@TheEmbeddedHobbyist
@TheEmbeddedHobbyist Рік тому
@@weirdboyjim Sounds like a reasonable requirement. But the business case would be to tell the customer that due to the 12bit i/o they need to upgrade to a 16bit board. ;-)
@azayles
@azayles Рік тому
Could you feasibly use the reset line to hold the shift register's enable pin in a disabled state until the processor finishes booting? That'll make sure the controller is ignored during powerup, and holding any of the buttons won't do anything
@weirdboyjim
@weirdboyjim Рік тому
You could indeed, but I avoid hardware state that can’t be reset in software. Imagine developing a piece of code, you upload a version that crashes and then you test a fix but can’t be sure if the broken version left things in an unexpected state.
@JonnyBergdahl
@JonnyBergdahl Рік тому
@@weirdboyjim Watching the video I had that same idea, letting the reset line initialize the hardware makes total sense to me. Not sure I even understand your answer, as software is only ever run after the processor is done with the powerup.
@weirdboyjim
@weirdboyjim Рік тому
@@JonnyBergdahl More than one program can be run between hard resets, I don't want one program to be able to interfere with another.
@angeldude101
@angeldude101 Рік тому
@@weirdboyjim Trying to stop Stop-N-Swap tricks? ;) (Regardless, the controller reset could also happen upon soft-reset rather than just hard-reset.)
@weirdboyjim
@weirdboyjim Рік тому
@@angeldude101 No. This is more about the case where no reset is happening, debugging code usually has me running code lots without a reset of any kind, it's important to trust the system state rather than have something persistent between test sessions.
@docteurwho1506
@docteurwho1506 Рік тому
I personally think at this time stamp 4:10 you could move the Right D-pad to the other 74xx541 and then you could pull it down to ground and with that you'll be able to deferient the high byte from the low byte enven if we presse any button
@weirdboyjim
@weirdboyjim Рік тому
You could. But then the 4 direction buttons would arrive in different bytes which makes it more of a pain for programming. There is really no problem with this circuit as it stands although it's fine if you would have made a different circuit.
@bonitahedden2813
@bonitahedden2813 Рік тому
Why not add the AB Buttons to the bottom of second byte and have the d-pad & start/select on the lower byte and the 6 game buttons on the upper byte. then use the top two bits of each byte for byte and controller identification? like using bit 7 for byte select and bit 6 for controller ID or reverse it so bits 6&7 would be a accending number from 1-4 (if you wanted to use two controllers). That would remove the need for discarding data. - Wes Hedden
@weirdboyjim
@weirdboyjim Рік тому
Remember that the byte discard should only ever happen once in the entire program execution.
@wChris_
@wChris_ Рік тому
you could have just started the state on power up to have the low byte asserted. This is also how the NES/SNES interface with the PPU for example. What actually happens for the controller is that the CPU manually has to shift in the bits. And to latch new data the CPU has to write to one of the controller port. You could have done something similar, let the CPU decide with the write line when to latch data and use assert to read it. This also avoids an issue when the CPU reads the data while it is being updated.
@weirdboyjim
@weirdboyjim Рік тому
Implementing the protocol in software would still mean I'd need to build a basic circuit to allow the interfacing. A legitimate choice but I wouldn't have been able to make the circuit stand alone initially which I think makes for a progression.
@yrath5034
@yrath5034 Рік тому
That bus tester is cool, is that your own design?
@TroySchrapel
@TroySchrapel Рік тому
ukposts.info/have/v-deo/maKmaG5pfZyJzZ8.html
@weirdboyjim
@weirdboyjim Рік тому
Yes it is! There should have been a card popup for the link but the video where I design it is here: ukposts.info/have/v-deo/maKmaG5pfZyJzZ8.html
@AJMansfield1
@AJMansfield1 Рік тому
Is there a way to do presence detection on a SNES controller?
@weirdboyjim
@weirdboyjim Рік тому
Interesting! If you were to change that pull-up to a pull-down it would look like all the buttons were depressed which would indicate no controller (Or a very annoying tester).
@AJMansfield1
@AJMansfield1 Рік тому
@@weirdboyjim if you were to attempt to shift an additional 13th bit out of the shift register, the value of that bit could distinguish that 'annoying tester' case.
@marcolokker911
@marcolokker911 Рік тому
personaly i would choose to make bit 7 follow the flipflop this limit the lower byte to to 7 input lines ( bit 7 is alway 0) and then use 5 inputs on the higher byte where (bit 7 is alwas 1) , this way we alway know if we reading the lower or upper part off the joystick input.
@maxpoulin64
@maxpoulin64 Рік тому
So for identifying the flip flop state, I think I found a solution only using the two upper bits of the high byte: make bit 8 of the high byte be the NAND of left and right, and bit 7 be the XOR of left and right. It results in a truth table that can tell which one is which because there's no conflict. So you can compute the two bits in software, and when you read the next byte you can tell which way it is based on whether it matched or not. Buttons - low high - high low None - 00 10 - 10 00 Right - 10 11 - 11 10 Left - 01 11 - 11 01 Both - 11 00 - 00 11 It's probably not worth the chip(s?) just for that though. Might as well tie them both high and if somehow the player manages to press both right and left at the same time, yell at the player to stop it so controller detection works. The only other solution that I can think of would be to add more flip flops to have a third state where it returns all 1s and could probably be done with just one existing chip, and would also be fairly cheap on the software side but kind of gross and wasteful compared to a one-time init at start of the program :/ Thanks for the videos! Really ties up how all those parts work together to make an actual computer! Also makes for pretty nice brain teasers trying to solve problems like this one.
@weirdboyjim
@weirdboyjim Рік тому
Half you are enjoying, your solution is interesting but it would cost several chips. It’s worth remembering that a single sample without a direction held to correctly detect the polarity.
@tmbarral664
@tmbarral664 Рік тому
yep, James, a lot of comments ;) Good thing as it means we're a bunch following your adventures ;) Bad thing as it means there's a flaw in what you did and we're all eager to help ;) guess what ? yep ;oD myself included. Oh boy, another one. Gimme a rope... :) So I understand you wish to do close to none mods if possible. But still we have 2 bytes to distinguish and a single bit to do it. The +5v is at the same pos as the Right, correct? So let's say instead of a single bit, you use 4. All up. I suppose we my have less chance to have the LRUB buttons all pushed at the same time. Narrowing down then the risk of error. If what I'm saying is completely silly, please, forgive me. I'll shut up forever and after ;) btw, thank you very much for you work. Amazinlgy entertaining
@weirdboyjim
@weirdboyjim Рік тому
If I was clever I'd occasionally invent controversial decisions like this to promote discussion for the benefit of the youtube algorithm. 😉
@brianwild4640
@brianwild4640 Рік тому
What if the controller is fault with a stuck button even if the computer is running software that does not use the faulty button is all of the controller not going to work?
@weirdboyjim
@weirdboyjim Рік тому
That very specific situation would indeed be a problem for my design. I think it's likely that all the games I write will need the direction pad though.
@brianwild4640
@brianwild4640 Рік тому
@@weirdboyjim not a problem or a criticism. I just remember as a kid playing games with my faulty joystick that would not go up
@sayethwe8683
@sayethwe8683 Рік тому
my first thought for compression was to take advantage of the fact that the d-pad is a single piece and thus can't have opposing directions pushed simultaneously to try and save bits by encoding, but then I realized that doesn't save enough bits to reduce to a single byte, and if you can press two adjacent directions or none at all, might not save *any* bits.
@weirdboyjim
@weirdboyjim Рік тому
I suppose you could encode the direction into 3 bits but that would cost you extra circuitry.
@sayethwe8683
@sayethwe8683 Рік тому
Not only would it cost extra circuitry, there are 9 directions (assuming it's only opposite buttons that can't be simultaneously pushed), which costs the same four bits anyway: no direction up up-left left down-left down down-right right up-right and is then more complex to read on the CPU side as well.
@mikafoxx2717
@mikafoxx2717 3 місяці тому
Be careful, Nintendo verification likes to use broken controllers to make sure your code is solid.
@Richard25000
@Richard25000 Рік тому
Why not do 6 bits per line driver then you could do a top bit to identify the state of flip flip. You'd even have a spare bit to identify a second controller port so 24 bits 6 bits per driver then 2 bits yo identify the byte. Then a single port on bus could drive 2 controllers with 4 reads.
@weirdboyjim
@weirdboyjim Рік тому
I’ve mentioned it in a few comment replies already but I did consider splitting the bits more like that but picked this for a reason. I wanted all the direction bits to be in the same byte (that makes life easier working with the data in code), and I didn’t want to re-order the bits relative to the original data stream. You would have to bring a demultiplexer in but iy would indeed be pretty easy to add a 2nd controller, I don't think you would need to output the byte index though, you just need to identify the zero byte.
@bzuidgeest
@bzuidgeest Рік тому
Why not just map both bytes to a different memory address? Memory mapped Io? Seems much simpler. Maybe the answer is obvious but with so many interesting projects to follow i cannot fully know every single one.
@weirdboyjim
@weirdboyjim Рік тому
That would work, but be much more complex. This circuit connects tot he cpu with 12 wires, you would need to add the address bus and the memory control lines to it. Then you would need to decode the address lines which would take a bunch of extra chips.
@bzuidgeest
@bzuidgeest Рік тому
@@weirdboyjim not necessarily. Address decoding often is a task of a single chip or unit in your case. All the boards would need is a select line and a single address line to check odd or even address in this case. The one address line would replace the flip flop and the software state detection
@charlierobson
@charlierobson Рік тому
You have left & right on bits 6&7, why not make the flipflop test be for both bits 6&7 high? this would be unambiguous as you would never have l&r pressed at the same time. At least not without a very broken controller..!
@CeDoMain
@CeDoMain Рік тому
That wouldnt work with the fast sign test he use.
@weirdboyjim
@weirdboyjim Рік тому
Interesting suggestion that didn't occur to me. But it does remind me of a bug I heard about on an actual snes game that took the developers a while to find and fix. The games tester who reported it had a 3rd party controller where it was much easier to trigger opposing direction’s at the same time.
@RaStrNL
@RaStrNL Рік тому
Hi James, have you considered to use timing to reset the flip flop? I have seen that trick sometime when two quick successive reads just reset the flip-flop sometime at the beginning of your code, while "normal" code will probably never just read the same port twice. You could use just simple timer (probably some clever construction with 555) if you will have fixed clocks, but in your case you would better count main CPU clock pulses or something like that. Hope you understand my idea, seems to be "cleaner" to me without dependency on input state of the top bit like you have here.
@weirdboyjim
@weirdboyjim Рік тому
Someone else suggested this as well, it didn't occur to me but I like it. CPU clocks is definitely the right way to do it though. My only objection is that it would add several chips to the build. I think I could do it with 2 if the timeout could be kept within 16 clocks.
@Vanders456
@Vanders456 Рік тому
Right, Left, Down, Up, Start, Select Me: That isn't the Konami Code...
@weirdboyjim
@weirdboyjim Рік тому
I'll have to put a Konami code Easter egg in somewhere sooner or later, it's the law or something...
@TheEmbeddedHobbyist
@TheEmbeddedHobbyist Рік тому
component re-use in design is always a good thing, why buy 1 of loads, when you can buy loads of 1.
@weirdboyjim
@weirdboyjim Рік тому
At least you understand Teh!
@TheEmbeddedHobbyist
@TheEmbeddedHobbyist Рік тому
@@weirdboyjim You learn a few things after 42 years in electronics production / test / R&D etc. :-)
@nightwing36s
@nightwing36s Рік тому
18:42 Couldn't you pull up all four of the lines on the upper byte? Then you'd have U/D/L/R all set at once, a physically impossible input on an SNES controller
@weirdboyjim
@weirdboyjim Рік тому
You could do, but I know a few games testers who would just take "a physically impossible input on an SNES controller" as a challenge. It can definitely be done on some 3rd party controllers.
@nolan412
@nolan412 Рік тому
Just saw Adafruit is sporting LED noodles.
@weirdboyjim
@weirdboyjim Рік тому
Not sure what you mean by that.
@nolan412
@nolan412 Рік тому
@@weirdboyjim tweeted at you.
@nolan412
@nolan412 Рік тому
Production wise: parallel breadboarding and schematic is nice.
@Sven1222225
@Sven1222225 Рік тому
Is it Doom? ;)
@weirdboyjim
@weirdboyjim Рік тому
What was Doom's minimum spec again? ;-)
SNES Controller Interface - Part 3 - Final PCB Module
45:00
James Sharman
Переглядів 5 тис.
Tile Data - VGA from Scratch - Part 13
1:00:34
James Sharman
Переглядів 15 тис.
Excited Dog Zooms In and Out of Sliding Door!
00:18
The Pet Collective
Переглядів 8 млн
Пескоструйный АППАРАТ! #shorts
01:00
Гараж 54
Переглядів 3,2 млн
КИРПИЧ ОБ ГОЛОВУ #shorts
00:24
Паша Осадчий
Переглядів 6 млн
I designed my own 8-bit computer just to play PONG
17:19
jdh
Переглядів 679 тис.
Hardware SPI Continued - IO from Scratch - Part 7
31:13
James Sharman
Переглядів 4,5 тис.
Tilemap (Framebuffer) PCB - VGA from Scratch - Part 9
47:13
James Sharman
Переглядів 10 тис.
why can’t computers have thousands of cores?
8:08
Low Level Learning
Переглядів 713 тис.
I Designed My Own 16-bit CPU
15:46
AstroSam
Переглядів 1,8 млн
Hardware SPI - IO from Scratch - Part 6
26:14
James Sharman
Переглядів 6 тис.
Introduction - VGA from Scratch - Part 1
22:53
James Sharman
Переглядів 61 тис.
С Какой Высоты Разобьётся NOKIA3310 ?!😳
0:43
The PA042 SAMSUNG S24 Ultra phone cage turns your phone into a pro camera!
0:24