Building an NES Emulator
An anonymous reader writes: Programmer Michael Fogleman recently built his own emulator for the original Nintendo Entertainment System. He's now put up a post sharing many technical insights he learned along the way. For example: "The NES used the MOS 6502 (at 1.79 MHz) as its CPU. The 6502 is an 8-bit microprocessor that was designed in 1975. ... The 6502 had no multiply or divide instructions. And, of course, no floating point. There was a BCD (Binary Coded Decimal) mode but this was disabled in the NES version of the chip—possibly due to patent concerns. The 6502 had a 256-byte stack with no overflow detection. The 6502 had 151 opcodes (of a possible 256). The remaining 105 values are illegal / undocumented opcodes. Many of them crash the processor. But some of them perform possibly useful results by coincidence. As such, many of these have been given names based on what they do." It's an interesting look at how software and hardware interacted back then, and what it takes to emulate that in modern times. Fogleman released the source code on GitHub.
In a previous lifetime I repaired coin-op arcade games, and the Nintendo VS system was certainly one of them. At some point after Nintendo utterly abandoned the coin-op industry (leaving countless operators flapping in the wind with no new games for their VS system cabinets) I discovered, in the schematics of the VS system motherboard, proof that Nintendo was using the coin-op industry as a test-bed for a home system: the control panel inputs, which in an arcade game are all discrete inputs per switch (4 for a joystick, for instance) didn't go to a parallel buffer or parallel-input register IC, they went to a parallel-input shift register, the serial output of which was routed to a serial-to-parallel shift register, which was then connected to the data bus! If you have or can get a schematic for this PCB, look for it for all the player inputs. There is no reason to have this over-complicated arrangement in an arcade game -- but it just so happens that this is the exact arrangement that the NES used to connect player controls, via a skinny cable with as few connections as possible. So don't go getting so misty-eyed about Nintendo, they're utter bastards who care only about profits, and not who they screw over in the process.
Are YOU using the TOOL, or is the TOOL using YOU? Think about it!