Author Topic: N64 Cartridge Dump (for Gameshark Pro)  (Read 10592 times)

Offline Paul

  • Administrator
  • double
  • *****
  • Posts: 3473
  • Developer
    • View Profile
    • PaulsCode.Com
N64 Cartridge Dump (for Gameshark Pro)
« on: September 13, 2014, 09:27:28 AM »
-- This slot is reserved for the most recent working releases --
Device: Samsung Galaxy Nexus i515
CPU: TI OMAP4460, 1.2 GHz (dual core, ARM Cortex-A9)
GPU: PowerVR SGX540, 307 MHz
RAM: 1 GB
Resolution: 720 x 1280
Rom: omni-4.4.4-20141014-toro-FML KitKat 4.4.4, rooted

Device: Eee PC 1015PEM
CPU: Intel Atom N550, 1.5 GHz (dual core, x86)
GPU: Intel GMA 3150, 200 MHz (dual core)
RAM: 2GB
Resolution: 1024 x 600
Rom: android-x86-4.3-20130725 Jelly Bean 4.3, rooted

Offline Paul

  • Administrator
  • double
  • *****
  • Posts: 3473
  • Developer
    • View Profile
    • PaulsCode.Com
Re: N64 Cartridge Dump (for Gameshark Pro)
« Reply #1 on: September 13, 2014, 09:27:35 AM »
-- This slot is reserved for useful information and references --

"Enabling PCI LPT cards on Linux": show

Since hardly anyone uses LPT any more, modern Linux distributions may not have the necessary modules enabled by default.  So after installing a new PCI LPT card, you may also need to make a few updates.

The following was done on Ubuntu 14.04, but should apply to other distributions as well

To check if your LPT port is active, first run:
Code: [Select]
sudo cat /proc/ioports | grep parport


If this does not produce any output, then continue.

Run the following two commands:
Code: [Select]
sudo modprobe -r lp
sudo modprobe -r parport_pc

Then run the following command:
Code: [Select]
sudo lspci -v
Look through the output for a block that starts with "Parallel controller".  Will look something like this:
Code: [Select]
03:06.2 Parallel controller: NetMos Technology PCI 9865 Multi-I/O Controller (prog-if 03)
Subsystem: Device a000:2000
Flags: bus master, medium devsel, latency 64, IRQ 10
I/O ports at e000 [size=8]
I/O ports at d800 [size=8]
Memory at febfb000 (32-bit, non-prefetchable) [size=4K]
Memory at febfa000 (32-bit, non-prefetchable) [size=4K]
Capabilities: [48] Power Management version 2

Note the two addresses that are on lines that start with "I/O ports at ..."  The first one is the base address of your LPT port.  Write this down somewhere for reference (will be different than in the above example).  Also write down the IRQ number (10 in the above example)

Next, run the following commands (replace e000 with the address you wrote down in the previous step):
Code: [Select]
sudo modprobe parport_pc io=0xe000
sudo modprobe lp

At this point, if you run the first command I listed earlier, you should now be getting some output:
Code: [Select]
sudo cat /proc/ioports | grep parport
To make the changes apply the next time you reboot, you will need to edit a couple of files:
Code: [Select]
sudo nano /etc/modprobe.d/parport_pc.conf(This will typically be empty, since you are creating a new file).  Add the following lines to the file and save (don't forget to replace e000 with the address you wrote down earlier, and 10 with the IRQ number you wrote down):
Code: [Select]
alias parport_lowlevel parport_pc
options parport_pc io=0xe000 irq=10

Finally, edit the following file:
Code: [Select]
sudo nano /etc/modulesAdd the following lines and save (lp may already be in there, only add it if it is not):
Code: [Select]
parport_pc
lp

That's it.  Reboot your computer and make sure everything worked by checking if you still get output from the first command I listed above:
Code: [Select]
sudo cat /proc/ioports | grep parport



"WINE with LPT support for Win98 applications on Linux": show

WINE can be used to run several old applications, including those which communicate with the GameShark via the LPT port.  These include tools like WinROM64, N64Utils, Gameshark Code Creator, and others.  In my tests, the LPT port only worked if it was built into the motherboard.  PCI cards or USB to LPT adaptors did not work.  That said, old laptops with a built in LPT port, like the Dell Latitude D600, used in conjunction with Lubuntu, can be a relatively cheap option (~$50 for the necessary components on Ebay at the time of writing this).

First, create a DOS device for LPT1 (replace ~/.wine with the path to your wine prefix):
Code: [Select]
cd ~/.wine/dosdevices
ln -s /dev/lp0 lpt1

Then run "wine regedit" from terminal.  Navigate to "HKEY_CURRENT_USER\Software\Wine".  Right-click "Wine" and add a new Key named "VDM".  Right click on VDM and add a new Key named "ppdev".  Right click on ppdev, and add a new String Value named "378".  Right click on 378 and choose Modify.  Enter the value "/dev/parport0" and click OK.

Run winecfg, and set wine to Windows 98 mode (LPT access will crash WINE in XP mode)

Change permissions of /dev/lp0 and /dev/parport0:

Code: [Select]
sudo chmod a+rw /dev/parport0 && sudo chmod a+rw /dev/lp0
« Last Edit: February 09, 2017, 11:30:55 PM by Paul »
Device: Samsung Galaxy Nexus i515
CPU: TI OMAP4460, 1.2 GHz (dual core, ARM Cortex-A9)
GPU: PowerVR SGX540, 307 MHz
RAM: 1 GB
Resolution: 720 x 1280
Rom: omni-4.4.4-20141014-toro-FML KitKat 4.4.4, rooted

Device: Eee PC 1015PEM
CPU: Intel Atom N550, 1.5 GHz (dual core, x86)
GPU: Intel GMA 3150, 200 MHz (dual core)
RAM: 2GB
Resolution: 1024 x 600
Rom: android-x86-4.3-20130725 Jelly Bean 4.3, rooted

Offline Paul

  • Administrator
  • double
  • *****
  • Posts: 3473
  • Developer
    • View Profile
    • PaulsCode.Com
Re: N64 Cartridge Dump (for Gameshark Pro)
« Reply #2 on: November 20, 2014, 05:16:00 PM »
Project Overview:

The goal of this project is to create a software interface that runs on modern PC's to facilitate backing up N64 cartridges with the Gameshark Pro.  It should support LPT ports built into the motherboard, PCI expansions that add an LPT port, and USB - LPT adaptors.  It should also be OS-independent, free, and open-source to allow maintenance over time as technology progresses.


Background:

In the past, I have directed folks who ask about dumping their own N64 cartridges to use the Gameshark Pro.  It is considerably cheaper than the Doctor V64 for example, and is readily available on places like eBay.  The main drawback is that the software required to facilitate the cartridge dump is ancient, and only works reliably on Windows 98 (can be made to work on Windows XP and maybe later with some tweaking, but is unstable).

Additionally the outdated software only works reliably with a DB25 LPT port built into the motherboard (which few modern computers have).  LPT ports added through PCI expansion slot are hit-and-miss (a hack is required to get it working, which itself limits the OS), and I have not read any posts about successful use with a USB - DB25 adaptor.  The software is not compatible on WINE, so Mac and Linux users have an even more difficult time. (no longer accurate)  For the average user, what this means is that the only way to reliably and affordably dump their N64 cartridges is with a dedicated laptop or PC that has a built-in LPT port and is running Windows 98. (a simpler solution is to run the software on a lightweight Linux like Lubuntu, using WINE)

It is time for a solution that is OS-independent and open-source, so it can adapt to changing technologies and operating systems over time, rather than being proprietary, abandoned, and left in the dust.


Getting Started:

I plan to build most of the UI and backend in JAVA  There will be a small native component (since Java does not directly support LPT communication), linked via JNI.  Backend and UI will be modular, to allow easy porting to other systems.  To drive this goal, I intend to write an Android port of the software to use with USB OTG cable plus USB - LPT adaptor (this will force me to keep the UI and backend separate). 

For the native component, I will be drawing from the open-source projects GSUploader, gs_libusb, and n64rd.  These projects include the basics for communicating with the GameShark Pro through the LPT port, and should be an excellent starting point for the project.  GSUploader operates on both Windows and Linux, which supports my goal of OS-independence.  Gs_libusb is a fork of GSUploader demonstrating use of a USB to LPT adapter, which is another of my goals.  And n64rd specifically demonstrates dumping a ROM, which of course is my ultimate goal here.
« Last Edit: February 07, 2017, 08:03:41 AM by Paul »
Device: Samsung Galaxy Nexus i515
CPU: TI OMAP4460, 1.2 GHz (dual core, ARM Cortex-A9)
GPU: PowerVR SGX540, 307 MHz
RAM: 1 GB
Resolution: 720 x 1280
Rom: omni-4.4.4-20141014-toro-FML KitKat 4.4.4, rooted

Device: Eee PC 1015PEM
CPU: Intel Atom N550, 1.5 GHz (dual core, x86)
GPU: Intel GMA 3150, 200 MHz (dual core)
RAM: 2GB
Resolution: 1024 x 600
Rom: android-x86-4.3-20130725 Jelly Bean 4.3, rooted

Offline Paul

  • Administrator
  • double
  • *****
  • Posts: 3473
  • Developer
    • View Profile
    • PaulsCode.Com
Re: N64 Cartridge Dump (for Gameshark Pro)
« Reply #3 on: November 21, 2014, 12:00:21 PM »
I've been looking for a good way to not have to hard-code the LPT base address.  One way would be to have the user provide it, but would be nice if I could just look it up (and provide selectable options if they have multiple LPT ports).

On Linux (including Android), I can parse this from /proc/ioports.  May be the same on Mac since it also utilizes the /proc folder, but I haven't actually looked to see if it uses ioports the same way Linux does (I am starting with Linux and Windows, since that is what gsuploader is written for).

I'm not having much luck finding a way to do this without a 3rd-party DLL on Windows.  I'm hoping maybe I can get this from a registry key or something, if only I knew where to look..

Anyone here have thoughts?
Device: Samsung Galaxy Nexus i515
CPU: TI OMAP4460, 1.2 GHz (dual core, ARM Cortex-A9)
GPU: PowerVR SGX540, 307 MHz
RAM: 1 GB
Resolution: 720 x 1280
Rom: omni-4.4.4-20141014-toro-FML KitKat 4.4.4, rooted

Device: Eee PC 1015PEM
CPU: Intel Atom N550, 1.5 GHz (dual core, x86)
GPU: Intel GMA 3150, 200 MHz (dual core)
RAM: 2GB
Resolution: 1024 x 600
Rom: android-x86-4.3-20130725 Jelly Bean 4.3, rooted

Offline Paul

  • Administrator
  • double
  • *****
  • Posts: 3473
  • Developer
    • View Profile
    • PaulsCode.Com
Re: N64 Cartridge Dump (for Gameshark Pro)
« Reply #4 on: December 12, 2014, 11:35:23 PM »
Quick progress update.

I bricked my GameShark last week, but got a replacement in the mail yesterday.  No luck reviving the old one using the piggyback method unfortunately, but the new one is working well.  I'll probably just use the bricked one for parts (I have a working 3.3 crippled version that I could probably get the LPT port functioning by moving over the missing chips and resistors from the bricked one)

Anyway, I have been able to successfully dump Mario 64 a few times (borrowing heavily from n64rd source code for communicating with the GameShark).  It was originally dumping the ROM plus a whole lot of junk data.  I believe I have properly written logic to detect the end of the ROM and truncate it to the correct size (will need to test on a lot more games though to be sure and do MD5 comparisons).  I also want to build into this tool the ability to convert to any of the three ROM formats (to ensure compatibility with other devices, like the Doctor V64 or Z64 Mr Backup).

Main problem I am now facing is that I can only communicate with the GameShark on an ancient Dell Latitude D600 running Lubuntu.  I suspect it is because this computer has the parallel port built into the motherboard (your typical IEEE 1284 at 0x378).  I cannot get it to work with the PCI LPT card on my main PC (communication link just times out).  One difference is its non-standard address 0x0C10, but not sure if that is relevant.  I've even tried a Linux VM in VirtualBox (so the guest machine would see it as 0x378), but no luck with that.  Diagnostics on the parallel port itself indicate that it is working.  I'll probably start looking at gsuploader a little more closely since it communicates with the gameshark differently than n64rd.  I could also shift focus to gs_libusb for a while to look at communicating with the gameshark via a USB/ LPT adapter.
« Last Edit: December 12, 2014, 11:40:05 PM by Paul »
Device: Samsung Galaxy Nexus i515
CPU: TI OMAP4460, 1.2 GHz (dual core, ARM Cortex-A9)
GPU: PowerVR SGX540, 307 MHz
RAM: 1 GB
Resolution: 720 x 1280
Rom: omni-4.4.4-20141014-toro-FML KitKat 4.4.4, rooted

Device: Eee PC 1015PEM
CPU: Intel Atom N550, 1.5 GHz (dual core, x86)
GPU: Intel GMA 3150, 200 MHz (dual core)
RAM: 2GB
Resolution: 1024 x 600
Rom: android-x86-4.3-20130725 Jelly Bean 4.3, rooted