Giving a NES an Internal OS?

This is an archive of a topic from NESdev BBS, taken in mid-October 2019 before a server upgrade.
View original topic
Giving a NES an Internal OS?
by on (#108040)
Hey all!

So I still have a NES my grandfather bought kicking around.
Its missing the top half of the case, but i have everything that matters; It still ticks (and is currently playing the SMB3 World 1 music as i speak)...

I want to transfer it over to a new case (of which i haven't decided yet), and i figured since it was going to be in a new case, that i'd make the power/reset/LED setup digital instead of analog.

So a couple nights ago, while thinking about what case to put it in and what i wanted the digital power-switch-board to do, i had kind of a thought...
'What if the NES had an "OS" to boot into, like a modern console, when no cartridge is plugged in?"

I've kinda been thinking on how to do it over the past couple of days, but I'm quite new to programming for NES. And for that matter i'm generally inexperienced in embedded programming. The original plan, the digital power/reset board, I can handle. Controlling a PIC from a NES Cart; I have no clue where to start on that.

If I do this, my main goal is to keep it faithful to the original 1987 hardware; This isn't going to be a Raspberry Pi or an x86 running an emulator. I want to it to be running legitimate Nintendo hardware.

I was thinking the 'OS' would basically be an internal cartridge that boots up when a game cartridge isn't inserted. However, i'm not certain on how (from an electronics perspective) two carts could be connected without interfering with each other.

Long story short, I would like to mod my NES to boot an internal cartridge (that can communicate with a PIC) if no external cart is detected, but I'm unsure how to go about it.

So is this just a pipe dream? Or could this actually be pulled off? I ask because I haven't seen anything like it before, and I'd like to not waste my time if you guys think I'm chasing a dragon...
Re: Giving a NES an Internal OS?
by on (#108043)
A boot logo when no cartridge inserted is surely doable. There are plently old Famiclones that had 'built-in' games that were actually a cartridge PCB inserted into a second slot at bottom side of the main PCB. It was connected 1-to-1 for the most part. Not sure what exactly should be done to replicate the same on the original NES. Guess detection of inserted cartridge was done through the pins that are short by inserted cartridge, and switch between them is by switching a line, maybe RD or something.
Re: Giving a NES an Internal OS?
by on (#108045)
It's possible. I'd say based on the nature of your questions it would be an excessively difficult 'first' project. May be achievable if you take small steps.

CIRAM /CE and CHR /A13 being shorted together would be a pretty decent way to sense a cart was plugged in. The only exception would be 4screen mirroring games but there are only a handful of those. Another way would be to sense the current draw from the cartridge (no current = no cart).

Out of curiosity what would you have the 'os' do? One simpler method would be to only use PRG-ROM for your OS, and use CIRAM for both name and pattern tables.
Re: Giving a NES an Internal OS?
by on (#108047)
Copynes uses an interesting method to get a "bios" running before the game.
Re: Giving a NES an Internal OS?
by on (#108049)
infiniteneslives wrote:
Out of curiosity what would you have the 'os' do? One simpler method would be to only use PRG-ROM for your OS, and use CIRAM for both name and pattern tables.


This. What's the point? Definitely figure out what the goal is going to be. You can certainly internalize software to the NES console but what functions are supposed to be done? OS is a very strange term to use. Do you mean you want something like Windows 3.1? Or just a snazzy Logo with Music?
Re: Giving a NES an Internal OS?
by on (#108051)
Netbooting from ENIO or controller 2 serial like the GBA does. Or maybe just Snail Maze like the SMS.
Re: Giving a NES an Internal OS?
by on (#108053)
infiniteneslives wrote:
Out of curiosity what would you have the 'os' do?


My original thoughts would be just shutdown and reset functions in a menu. That's pretty much the only practical use i can think of right now, but if you could get it to throw interrupts on a PIC you could pretty much do whatever. Even a simple splash screen as Shiru mentioned would be fine at first.

Initially, i'll need to be able to determine the presence of an external cart and be able to run both the 'OS' cart and a game cart, all the while keeping the 'OS' cart hard wired into the system. Once that works, i could move onto resetting/powering down the console from software.

I kind of imagine it like the PS2 OS for NES.

The whole project is really a 'why not' kind of thing, from a personal perspective. Running a rom from a boot menu isn't really practical, but it'd be fun just getting it to work. There may be no reason in reality other than an excuse to play around with the internals of my NES, and perhaps learn something along the way. :)

However, it could provide a means of having an 'OS' rom that you could expand upon for your NES. There are greater minds than mine out there. I don't plan to mass produce/sell it, and i have no problem documenting it.

MottZilla wrote:
This. What's the point? Definitely figure out what the goal is going to be. You can certainly internalize software to the NES console but what functions are supposed to be done? OS is a very strange term to use. Do you mean you want something like Windows 3.1? Or just a snazzy Logo with Music?


OS is probably a VERY invalid term for this, at least in my case, and i use it very loosely. BIOS is probably more accurate, to be honest.

This is why i posted here, honestly. Personally, i have free time on my hands, so i figure 'Why not?' and I figured you guys would be able to answer that question, among others.
Re: Giving a NES an Internal OS?
by on (#108054)
I've always thought the M82 Kiosk http://www.youtube.com/watch?v=Tf5DQuUnKoI would be a great NES BIOS screen. Just change some of the instruction text.
Re: Giving a NES an Internal OS?
by on (#108059)
IMO the best thing this can provide is a bootloader, so that you can put in a nice all-RAM cart (no ROM at all) and upload programs from a PC to it. It also lets you dump carts, backup/restore SRAM on them, etc. Having it on the NES mainboard is less tedious and more reliable than putting it on a Game Genie's boot ROM.
Re: Giving a NES an Internal OS?
by on (#108060)
blargg wrote:
IMO the best thing this can provide is a bootloader, so that you can put in a nice all-RAM cart (no ROM at all) and upload programs from a PC to it. It also lets you dump carts, backup/restore SRAM on them, etc. Having it on the NES mainboard is less tedious and more reliable than putting it on a Game Genie's boot ROM.



So copynes?...with a non pc interface. (technically possible, you'll just need to add circuitry to hijack the chr rom as well)
Re: Giving a NES an Internal OS?
by on (#108064)
Shiru wrote:
A boot logo when no cartridge inserted is surely doable. There are plently old Famiclones that had 'built-in' games that were actually a cartridge PCB inserted into a second slot at bottom side of the main PCB. It was connected 1-to-1 for the most part. Not sure what exactly should be done to replicate the same on the original NES. Guess detection of inserted cartridge was done through the pins that are short by inserted cartridge, and switch between them is by switching a line, maybe RD or something.

+1

Also you should read about Sharp Twin Famicom

P.S. blargg, could you please reply my PM, which i sent while ago
Re: Giving a NES an Internal OS?
by on (#108065)
I really don't see what you gain from software-based shutdown or reboot. The power button we had before brought up game software instantly; there is no subsystem of software or drivers to load or an HAL to initialise... A boot logo like the SMS had would be great though.
Re: Giving a NES an Internal OS?
by on (#108066)
I always hated the boot logos on the SMS and Genesis. They inevitably made games take longer to boot and homogenized to some extent the intros of games. I much prefer the NES and SNES allowing absolutely full control of everything from the moment the console powers on.
Re: Giving a NES an Internal OS?
by on (#108067)
rvIceBreaker wrote:
i'd make the power/reset/LED setup digital instead of analog.
??? The reset and LED lines are digital. The power switch is ... well, I wouldn't say "analog". Maybe "the same as any other hard power switch".

Quote:
So is this just a pipe dream? Or could this actually be pulled off? I ask because I haven't seen anything like it before, and I'd like to not waste my time if you guys think I'm chasing a dragon...
I think there are three ways to do this, of varying dubiousness.
1- solder in a ROM. Put large resistors in series with the data lines. If anything else is plugged in, it'll lose the argument and the external code gets run instead.
2- Modify the power or ground rails so that one pin becomes a hotplug detection. Use appropriate digital logic to only enable the internal ROM when the hotplug detect is false. This won't work with all games.
3- Do something like copynes such that it always boots from the internal ROM, which then bootstraps and the code in that ROM sees if a cartridge is connected, and if so jumps to it instead.
Re: Giving a NES an Internal OS?
by on (#108068)
blargg wrote:
IMO the best thing this can provide is a bootloader, so that you can put in a nice all-RAM cart (no ROM at all) and upload programs from a PC to it. It also lets you dump carts, backup/restore SRAM on them, etc. Having it on the NES mainboard is less tedious and more reliable than putting it on a Game Genie's boot ROM.


That's probably the most "OS" like suggestion so far. RAM cart program loading, Cartridge Dumping of ROM and Backup RAM and writing back Backup RAM. You could perhaps figure out a way to attach a storage device to the NES directly rather than a PC to backup and load data. You could make a simple RAM cart built into the NES itself, maybe something with 256K PRG / 8K CHR and support for NROM, UNROM, and AxROM.

The first and most pressing subject about all this is what various ways you can implement an internal cartridge. The method where the internal ROM always gets control first is probably the one that makes the most sense, and from there you could check if a cartridge is inserted and choose what to do either automatically or with an on screen menu. You could also get some kind of hardware sensor/switch to detect physically if a cartridge is inserted into the system.
Re: Giving a NES an Internal OS?
by on (#108069)
blargg wrote:
I always hated the boot logos on the SMS and Genesis. They inevitably made games take longer to boot and homogenized to some extent the intros of games. I much prefer the NES and SNES allowing absolutely full control of everything from the moment the console powers on.


The earliest revisions of the MD / Genesis didn't have any TMSS screen!