N64 DEVELOPMENT - Console Joystick Port Interfacing "JOYBUS-to-FPGA"

Discussion in 'Nintendo Game Development' started by Gerry_MAN, Aug 13, 2018.

  1. Gerry_MAN

    Gerry_MAN N64 Hardware Fanatic

    Joined:
    Dec 26, 2010
    Messages:
    157
    Likes Received:
    203
    Hi Folks,

    Just posting some info and a Video Demo on a Fun and Cool N64 Interfacing project I've been working on.

    I would mess around and Tinker on this whenever I could find the time.... over the past 6 months or so. I have about four other N64 related projects on the go.... Free time seems to be almost non-existent these days.....But I do what I can. :confused:

    Anyhow,
    for this particular project which is purely just for the Fun of Tinkering with the N64.... you could probably use a 64Drive flashcart to implement communication over its USB interface.....but I just thought this would be a fun interfacing project to mess around with on the N64. Fun Stuff!! :D:cool:


    So, essentially what I've managed to do.... is implement some FPGA code that receives the serial signals from one of the N64 Joystick ports....(Port#4 for my Project)...and translates this N64 Serial protocol into ASCII Hex Data. The data could possibly be sent to an LCD display, or potentially to an RS-232 Computer Serial Port, and displayed on an MS-DOS Hyper-terminal session using a program like PUTTY.


    In order to do this, I had to write 2 separate pieces of code.
    The 1st was to write some N64 "C" Code that I compile into a ROM, and then run on an N64 Flashcart.

    EDIT:
    I initially thought that I was writing Microcode for this...
    however "MICROCODE" is the code that is Run within the "IMEM" memory space of the N64...(Instruction Memory). This is located within the RCP...which houses both the RSP and RDP. I originally thought that "Microcode" was the term used for code that you write when you are writing data to any of the N64 Registers directly, with Raw HEX data.
    However this is not the case.

    N64 Microcode = Code that is run within "imem" (Instruction Memory).


    [​IMG]

    [​IMG]

    Anyhow,
    So the ROM game code I wrote for testing this.... it essentially takes control of the N64's Joystick Ports, and sends out some custom HEX DATA, out in a packet size that I declare for the FPGA to receive.


    So obviously the 2nd block of code I had to write, was the VHDL code that runs on an Altera FPGA / CPLD, to receive the N64 Serial signal.

    [​IMG]
    This code handles the N64's Serial "JOYBUS" protocol, and converts the Data into ASCII codes. This data can then be displayed on an HD44780 LCD display. The FPGA also handles all of the Logic signals to drive the LCD. This I implemented all in VHDL, I didn't use any 3rd party libraries for this. All pure Digital Logic in VHDL.

    So within my N64 microcode, I have the option of sending out a 36-Byte packet from the N64 Joystick port#4. (AKA N64 JOYBUS) However, I started a bit smaller and went with an 8-Byte packet size and kept it down to 32Bits. At least until I got things working....and then I could look at transferring larger packets if I wanted. So Far so good. :D

    [​IMG]

    There have been many FPGA and micro-controller projects that Read the N64 Controllers themselves....so that people could use them on their computers. However, I wanted to actually tap into the signals coming out of the N64 Joystick ports. So not exactly the same thing...just the other way around.

    There is actually alot of data on the net already that explains the N64 Joystick "JOYBUS" protocol.... so I used alot of what was already out there to learn how things worked.

    Like the basic N64 Protocol that the Joysticks use:
    [​IMG] [​IMG]
    (Images sourced from http://www.fpgalover.com )


    So as I moved forward with the project..... just this weekend I managed to make some great progress with my code, and started to get some Data being displayed on an LCD Display. You can just ignore the "BlueTooth Link" message shown on the LCD....LOL. That was from an older Project...and I just didn't bother to erase it while I was testing....lol.

    [​IMG]

    This is all pretty cool and a Ton of Fun to tinker with. So I thought I would post some info here on it...and I also have a Video on my YouTube Channel that explains the project...and also I Demo some of the data being sent out from the N64 JoyBus....over to an LCD Display. I'll be continuing to play around with this and improve on it when I can.

    Here is the Video DEMO on my YouTube Channel:


    Loads of Fun!
    Cheers! Folks,
    -Gerry
     
    Last edited: Sep 5, 2018
    sa1, Traace, ma777 and 8 others like this.
  2. zzattack

    zzattack Spirited Member

    Joined:
    Nov 19, 2014
    Messages:
    140
    Likes Received:
    53
    Pretty cool and nice workspace also :)
    Is this a project that is mostly about learning or do you have an actual use for the end result?
     
  3. Gerry_MAN

    Gerry_MAN N64 Hardware Fanatic

    Joined:
    Dec 26, 2010
    Messages:
    157
    Likes Received:
    203
    Hi @zzattack,
    Yeah Thanks! :cool:

    I've been in the electronics and Embedded systems scene for years... also a longtime Hobbyist, The Lab workspace I have is the Huge Nerds Man cave. :D I take great pride in keeping it clean and Tidy.....but only after I finish a project lol. As the video shows........it can become quite the disaster!! ;)

    The Project started out initially as a cheep Debug messaging tool that I wanted to develop, for the N64 Homebrew scene. I wanted something that would be supper cheap to build, and provide the means of receiving some debug messages or N64 status Register data.....to be sent out of the N64, to an external system during Runtime of a ROM game. Specifically for debugging purposes. This is similar to how the "IS-VIEWER64" Development Flashcart debugging feature operates.

    So by developing something like this very cheaply.....it would allow N64 Homebrew coders to get the same type of Messaging functionality with a minimal investment. As many know...most of the official N64 Dev platforms are very Rare.....and also quite expensive.

    However, after I had already started on this project...I was hooked. It became more of a Vendetta at that point, and I wanted to see it through. I later learned that if you have a 64Drive Flashcart.... you can apparently take advantage of its USB interface, and perform a similar type of debug messaging function. However, I have not seen a shared program online to do this....but that would be cool coding project too.....if someone provided some batch files... or other source code to get that working. That would be pretty useful.

    Anyhow,
    I'm continuing to messa around with it...and I want to implement the interface to the RS-232 port next. That will be cool also. You would essentially just have a Debug Cable that connects to the N64....and then straight into a PC's Serial port.

    This project could even lead to some other Fun interfacing projects.....
    something like these below perhaps?
    [​IMG]

    [​IMG]

    That would be kinda cool! :cool::cool:

    Cheers!
    -Gerry
     
    DS2, element18592 and Cat man like this.
  4. Gerry_MAN

    Gerry_MAN N64 Hardware Fanatic

    Joined:
    Dec 26, 2010
    Messages:
    157
    Likes Received:
    203
    Tonight I sat down and got some actual ROM Variable Data to be displayed on the LCD display.
    :D:D Again.....this is all being sent out of the N64 Console Joystick Port#4 to the FPGA.

    I also want to see if I can get one of the Joystick controllers to change some of the variable data while the ROM is running.......and then visually see the changes on the LCD in real time.

    [​IMG]

    [​IMG]

    After I have that working....I'll be testing the serial feed on a Hyper-Terminal session.... probably use PUTTY.
    Fun Stuff! :cool::cool:

    Cheers!
    -Gerry
     
    DS2, sa1 and nold like this.
  5. ma777

    ma777 Peppy Member

    Joined:
    Jan 15, 2008
    Messages:
    329
    Likes Received:
    20
    Pretty cool! I think I have that same scope or a very similar one.
    scope (2).PNG
     
  6. Gerry_MAN

    Gerry_MAN N64 Hardware Fanatic

    Joined:
    Dec 26, 2010
    Messages:
    157
    Likes Received:
    203
    Nice!
    Yeah, mine is an Agilent 54610B 500Mhz Oscilloscope... with an RS-232 interface module. Most of them have the GPIB interface module....but I didn't have an interface for it on my PC, and the GPIB-USB adapters at the time were like $500+.... so I got the RS-232 module for it instead for $125.

    They are older units....but work just fine for my purposes. :cool:
    -Gerry
     
  7. TriMesh

    TriMesh Site Supporter 2013-2017

    Joined:
    Jul 3, 2008
    Messages:
    2,095
    Likes Received:
    600
    I had one of those - I found it incredibly annoying to use for single-shot measurements because of the low sample rate. I really wonder what HP were thinking making a 500MHz scope with a 20Msps sample rate. Works great for repetitive signals, though. They also made a similar looking model called the HP54616 - which is also 500MHz BW, but a 2Gsps sampling rate.
     
  8. Gerry_MAN

    Gerry_MAN N64 Hardware Fanatic

    Joined:
    Dec 26, 2010
    Messages:
    157
    Likes Received:
    203
    Nice!
    Yeah, I remember they had those 2Gsps units in the electronics Labs back when I was in College.
    That was a little while ago. ;)
     
  9. ma777

    ma777 Peppy Member

    Joined:
    Jan 15, 2008
    Messages:
    329
    Likes Received:
    20

    Yep, I have the exact same one with GPIB. Newer scopes can do so much I just don't know where to begin. I like how simple these are. Did you know you can play Tetris on them?
     
    sa1 likes this.
  10. Gerry_MAN

    Gerry_MAN N64 Hardware Fanatic

    Joined:
    Dec 26, 2010
    Messages:
    157
    Likes Received:
    203
    Tetris..? Really?

    I always remembered it as being an old school ATARI style "Asteroids" game.
    The last time I remember trying to load the game....was back in College.

    I'll have to try and find the menu to turn that on.
    Fun Stuff!
    -Gerry
     
    sa1 likes this.
  11. Gerry_MAN

    Gerry_MAN N64 Hardware Fanatic

    Joined:
    Dec 26, 2010
    Messages:
    157
    Likes Received:
    203
    Hi All,

    I've been getting a lot of PM messages from some of you regarding the Interface to my Altera FPGA board that I have wired up. So I just wanted to post this to clarify those questions.


    The N64 JOYBUS protocol is a serial signal that talks to the Joysticks, Keyboard and other peripheral devices that are connected to any of the 4 Joystick ports. This protocol is specifically designed to communicate with the various JOYBUS controller chips that reside inside the N64 Joysticks, or other Nintendo hardware.
    As shown in the image below:

    [​IMG]


    When I started this project, I had no idea how the JOYBUS protocol worked. So I figured, to get things working, I needed complete control over the Joybus signals coming out of the N64.

    The Altera FPGA that I'm programming is essentially a custom Joystick controller chip.... just like the one above...but of my own design. Again, I'm still learning how it all works....so just tinkering and tweaking things as I go along.

    To have full control of the Signals coming out of the N64, I wrote a game ROM, that doesn't really do any graphics at all. Its sole purpose is to customize the Joybus signals coming out of the N64 Joystick port#4. This allows me to create my own protocol, by controlling all the data bits within the DMA packets that are sent to the PIF Chip. This Packet I send, contains both the PIF chip commands and Data. The header of the packet stores the PIF chip commands, to instruct the N64 what to do with the Data. Like send the data out to one of the Joystick ports. If you had an official Nintendo Joybus controller chip connected, then the Data you send out...must be ordered in a specific way to follow the JOYBUS Protocol.

    However, the fact that I don't have an official Nintendo controller chip connected in my circuit...this means I don't need to use the specific Joybus protocol if I don't want to. The only part of the packet that must not change, is the section of the header of the DMA Packet that holds the commands to talk to the PIF chip inside the N64. (The PIF Chip Command set.)

    When I started...I did not know how the full protocol worked. So I wanted to have full control in order to figure things out.

    My interface connects the N64 Joystick port, directly into the Altera FPGA I/O pin.
    Some of you assumed I was just monitoring the activity while the Protocol was communicating with a connected N64 Joystick. This is not the case. I may go down that road once I have a full grasp on the official Nintendo JOYBUS protocol.

    Right now....the Protocol I am using is my own.
    Tinkering is ongoing. :cool:

    Hope that clarifies things a bit more.;)
    Cheers! Folks,
    -Gerry
     

Share This Page