Friday, June 24, 2016

Famicom Homebrew : So Close, Yet So Far

NES homebrew has been around for a very, very long time.  Chris Covell's Solar Wars, which is the first complete NES game developed independently, came out in October, 1999.  This was a mere four years after the NES was officially discontinued in 1995.  In those days, the Nesticle was the emulator of choice for playing NES games, but was very inaccurate at emulating the hardware.  Nonetheless, Solar Wars established an important precedent by working on real Nintendo hardware.

Unfortunately, if you wanted to play Solar Wars back in 1999, you had to modify an existing NES cartridge. Fortunately it uses a common PCB, but not everyone had access to an EPROM programmer and soldering and desoldering tools.  The next step was the release of the first homebrew cartridge the Garage Cart, was released by Joey Parsell (Memblers) in 2005.  It cost $42.00 and included Solar Wars and two other small games.  While it still used a donor board, it was significant in that you could purchase one and play it on your real NES without any programming or soldering hassles.  

Sunday, June 19, 2016

Recovering 240p from Video Capture Devices and Putting it Online

Video capture devices are often used to backup NTSC video sources like VHS cassettes and DVDs.  Many consumer level devices on the market have this purpose in mind.  You can use these devices to backup old video recordings, unprotected commercial video tapes and DVDs.  Your retro consoles and some computers also output an NTSC signal, but there is a substantial difference between the two.

Your standard NTSC-M video source uses a 480i resolution.  The picture is constructed from two fields, each containing half the data of a frame.  These fields are interlaced so that the odd lines of the frame are displayed first, then the even lines of the frame.  The eye usually cannot notice the interlacing effect when viewing a CRT TV screen at a reasonable distance.   In NTSC, there are 59.94 fields displayed in each second, half odd, half even.  This gives an actual frame rate of 29.97 frames per second.

All consoles from the Atari 2600 to the Nintendo 64 typically output 240p video.  Many computers, including virtually all the 8-bit home computers from Apple, Commodore, Atari, Texas Instruments, Timex Sinclair, Mattel and Coleco output 240p.  Some more advanced home computers, like the IBM PC with CGA, the IBM PCjr and Tandy 1000, the Atari ST, Apple //gs and Commodore Amiga also can output a 240p signal.  All these hardware devices output 240p do this by tricking the screen.  Instead of sending the proper signal for an odd and an even field, they send the signal for two odd fields.  The resolution is reduced to no more than 240 lines, and often there are fewer visible lines drawn and the rest of the lines are filled with a background color, often black.  On the positive side, the images are drawn twice as frequently, 60 times per second.  Because the screen is not evenly covered, scanlines are more visible in 240p than 480i.  This was not part of the NSTC-M standard, but works on every NTSC CRT TV and monitor ever made and most LCD monitors and TVs that could accept a composite input until recently.

Friday, June 10, 2016

DRAM Addressing Capacity

Dynamic RAM is typically used in computers because it is cheaper than Static RAM.

Dynamic RAM must be periodically refreshed by an access to RAM or the data contained within the RAM cell decays.  Static RAM does not need refreshing, all it needs is a steady supply of power.  Computers typically had a method of refreshing the RAM, often tied to the video controller, which refreshes the screen fifty or sixty times per second.  Steve Wozniak for example used a unified memory architecture where the video controller circuitry would access the RAM 50-60 times per second, which was sufficiently reliable to keep the RAM contents from degrading.

Virtually all vintage home computers used discrete DRAM chips.  However, if you look at the printed circuit board of any old computer, you will see memory chips in columns of eight (or nine) chips.  Why is that?  This is because a DRAM chip typically holds one bit of data for each memory cell.  So you need eight chips to hold a byte.  By contrast, you only need one SRAM chip to hold a byte.  Despite the need for a refresh circuit and the extra space and complexity required to interface eight DRAM chips compared to one SRAM chip, DRAM was still so much cheaper that it was almost always used.

Vintage consoles more often used SRAM because it made their boards cheaper to manufacture, an important concern when you intend to sell millions of systems based on the same board design.  The Atari 2600 used 128 bytes of SRAM, but it was embedded within the RIOT chip.  The Atari 5200 used 16KB of DRAM chips, but it was based on the design of the Atari 8-bit computers.  The Colecovision uses 1KB of DRAM chips for CPU memory but also a 16KB SRAM chip for the video memory.  The NES uses 2KB SRAMs for CPU and PPU memory, but its sprite RAM uses embedded DRAM on the CPU.  The SNES uses DRAM throughout, which tends to cause the white stripe issue with its video due to the refresh signal.

In a system with a sixteen bit data bus, you need sixteen chips.  In this system, the CPU deals in two bytes (a word) at a time.  So the first eight chips hold one byte and the second eight chips hold the next byte.  An earlier IBM PC AT system has two banks of eighteen chips each (see parity below).  When fully populated, you will have a whopping 512KB of RAM.  Each socket uses a pair of 64Kb chips, one piggybacked on top of the other, for 128Kb.  So each row of chips provides 128KB.  The CPU sees a pair of rows in a 128Kx16bit configuration, but in real purposes you have 256x8bits.

IBM systems, except for the PCjr., use parity memory.  Parity memory uses a ninth DRAM chip for each eight DRAM chips.  The extra chip is not usable memory, it instead alerts the system to a memory error.

By the mid eighties, some companies were using four bit DRAMs.  Four bit DRAMs hold four times the bit capacity as a one bit DRAM.  So when you used to need eight chips to form a bank of eight bit DRAM, now you only need two chips.

One bit DRAMs typically have a marking on them like 4116 or 4164, denoting 16Kb and 64Kb parts, respectively.  (In this article, a "B" as in KB means byte and a "b" as in Kb means bit).  Four bit DRAMs have markings like 4416 and 4464 for the same respective parts.    They are also commonly shown as 16Kx1 and 16Kx4.

You can find 1Kb, 4Kb, 16Kb, 64Kb, 256Kb and even 1Mb DRAM chips.  You will not find 2Kb, 8Kb, 32Kb, 128Kb or 512Kb chips.  Why is that?  This is because of the way DRAM is addressed.  DRAM is addressed more in a matrix-fashion than a true linear fashion.  DRAM uses address lines just like SRAM and ROM chips, but fewer than you would expect.

SRAM can be had in virtually any power of two capacity.  1KB, 2KB, 4KB, 8KB, 16KB, 32KB, 64KB, 128KB, 512KB and 1MB SRAM chips exist.  Many chips of the lower capacities can be found in NES and SNES cartridges.

A 64KB SRAM chip has sixteen address lines, but a 64Kb DRAM chip only has eight.  We all know that 2^16 = 64KB, right?  In order to get to 64Kb in a DRAM chip, you need the Row Access Strobe (RAS) and the Column Access Strobe (CAS) signals.  So, first you send a read or write via the address lines and RAS signal, then you send the read or write via the address lines and the CAS signal.  Since you are using eight bits twice to get to the correct memory cell, you get your sixteen address bits.  If you add a ninth address line to your chip, you will get eighteen bit addressing, which gives you 256Kb.  This is why there is no such thing as a 128Kb DRAM chip.

Thursday, June 2, 2016

More HDMI-ifying your Consoles, the UperGrafx for the NEC Turbo/PC Engine Systems

Today I found out about an upcoming Japanese product called the UperGrafx. The UperGrafx, as its name suggests, is intended to be used with a NEC PC Engine. What it does is it upscales the native PC Engine graphics (typically 256, 320 or 512 horizontal pixels by 224 or 239 lines) to the 720p resolution (1280x720). It plugs into the back of the PC Engine, Core Grafx or Core Grafx II, where there is a 69-pin expansion connector. It has also been confirmed to work with the US TurboGrafx-16 expansion connector. It won't work with a PC Engine Shuttle or any of the handhelds, Duos or the SuperGrafx.

Although the Expansion Connector supplies the analog RGB signals, it also supplies a lot more video information. The UperGrafx takes this information and builds a digital picture, then upscales it for the 720p resolution. The UperGrafx works similarly to the NESRGB and HiDef NES Mod.  

The PC Engine has sixteen sixteen color palette entries available for backgrounds and sixteen sixteen color palette entries for sprites. The first color entry of all background palettes is set to the universal background color and the first color entry of all sprite palettes is set to transparency. This gives a maximum of 482 colors on the screen at once. The Expansion Connector is constantly outputting these palette indexes on a separate video data bus that usually goes to the Color Encoder chip. Unlike the NES it also has a special signal to distinguish sprite palette indexes from background palette indexes, so you can still view the native video signal. The PC Engine displays 9-bit RGB for 512 colors maximum. The UperGrafx must be able to snoop on the color values stored for each palette index like the NES mods. The full CPU address and data bus is available on the Expansion Connector, so the color values for the palettes have been available. The result, when combined with the dot clock and sync signals, can give a truly digital representation of the screen image. Even better than the NES is the fact that there is no need to guestimate a composite to RGB palette.

There is a minijack next to the DVI port, which would suggest that audio is passed through from the Expansion Connector. The Expansion Connector supports stereo audio. The audio is output through the DVI connector, which is something of a pseudo-standard. Essentially the audio must be converted from analog to digital inside the UperGrafx.

Finally, the unit acts similarly to a Hudson Tennokoe 2 Backup Unit or a NEC Backup Booster. It allows you to save games to battery backed RAM instead of using passwords for those games that supported it. Unlike the original devices, there will be a USB port which you can use to transfer saves to and from the UperGrafx. The original devices came with 2KB of RAM, I do not know how much RAM will be available for the UperGrafx, but it is likely to have more RAM than the old devices.

The greatest benefit to the UperGrafx is that you are getting a pure digital video signal. There is no analog to digital conversion or degradation. There is nothing like jailbars induced by analog noise. When I had an RGB-modded PC Engine Duo last year, I could observe alternating bands of light and dark areas in the green background of Bonk's Adventure through RGB but not through composite. This cannot happen on the UperGrafx.

The second greatest benefit to the UperGrafx is that you do not need to mod your system to get perfect quality video out of it. The original PC Engine and TurboGrafx 16 only support RF output and the Core Grafx only handle composite video. No NEC console handles RGB without a mod, and there are more than one school of thought about what the perfect RGB mod should be. The unit I was using last year had a mod from doujindance, who has an excellent reputation for modding within the PC Engine/Turbo community. However, given the banding in his RGB mod, there is room for improvement.

There are some downsides. First, there is no passthrough for the expansion connector, so you cannot connect a CD-ROM unit. Second, you need a DVI to HDMI cable if your TV or monitor does not have a DVI input, but they are pretty cheap ($5-10). Third, it only upscales to 720p, not the more common 1080p of higher end displays. Fourth, it attaches to the back of the console like an "L", sticking straight up into the air, and there is nothing but friction keeping it attached to the console (not unlike attachments for the ZX Spectrum). Finally, it always displays "UperGrafx" in the borders of the frame, which some people may not appreciate.

So, for the suggested retail price of ¥40,000/$368, why should anyone buy this unit over a Framemeister? The Framemeister costs just as much and can work with almost any system. Also, if you buy this modern version of the Turbo Booster for $65, you can get the highest quality analog signals (RGB + CSync, S-Video and Composite) at a fraction of the cost.

You can see Jason of test the device and give his initial thoughts here :

A pure video of the DVI output for the device is available here :

Here is more information and pictures about the device, translated from Japanese :

The guy who supplied Jason with the device says that the lag on the device is between 0 and 1 frame. By comparison, kevtris' Hi-Def NES gives lag in the 2-4ms range. One frame is 16ms. The Framemeister gives lag in the 16-24ms range, depending on the settings used. But both the Hi-Def NES and the Framemeister support 1080p. The UperGrafx and the AVS only support 720p. What processing speed advantage given by the pure digital signal may be taken away by the upscaling done by non-true 720p displays (I am not even sure if there is a such thing as a true 1280x720p display). Lag comes from many sources and is quite insidious. Given the large number of shmups for the Turbo/PC Engine where timing is critical, maintaining a latency of well under one frame per second is essential if you want to buy this device over a Framemeister.