PDA

View Full Version : NES/other console emulators on an 8086..?



Raven
June 7th, 2009, 01:16 PM
I'd like to emulate a NES on my 8086 desktop. It is a 9.somethingMhz 8086, and the nes is a 1.somethingMhz.. Z80 is it? Anywho, I think that a factor of 10 is enough so that an emulator could exist, does it? I couldn't locate one.

Fallo
June 7th, 2009, 05:56 PM
I'd like to emulate a NES on my 8086 desktop. It is a 9.somethingMhz 8086, and the nes is a 1.somethingMhz.. Z80 is it? Anywho, I think that a factor of 10 is enough so that an emulator could exist, does it? I couldn't locate one.

The NES uses a customized 6502 clone that runs at 1.79 Mhz.

The reason you couldn't find an emulator is because there is no way that an 8086 is powerful enough to emulate an NES. You'd need a 386 minimum.

General rule of thumb is that a given system must be at least 10 times more powerful than the system it's emulating. As I said, you'd need a 386 to emulate most 8-bit systems, and 16-bit systems like the Amiga would require at least a Pentium.

carlsson
June 8th, 2009, 02:45 AM
Even a 80386 isn't enough if you want to emulate another system, at least not anywhere near full speed. Perhaps if you're satisfied with advanced higher-level simulation. Possibly you can get the core of a 6502 CPU emulator running cycle exact on a 33 MHz 80386DX.

Consider most of the precise NES emulators stutter on a 200 MHz PC, possibly even 500 MHz unless you reduce the frame rate and turn off some of the features.

barythrin
June 8th, 2009, 07:56 AM
Ditto on the previous answers. Not 100% sure why but emulating another system (maybe because it has to emulate cpu, video and sound, etc not just cpu?) seems to take an exponential amount of computing power that I've never seen practical. Even the Playstation emulators (I only used them in their early years and both teams seemed to drop production and/or get sued by Sony (bleem)) but they were slow too even on new (at the time) hardware.

So the actual problem you'll probably find is I'm not sure anyone was trying emulating those systems during that era, so the programs written now are all compiled for newer processors and opcodes. If one was written in compatible assembly it might be tryable though. So despite it being slow, check a few programs out. Nesticle was written in pure asm I believe by Bloodlust Software, not sure who else was out there as I haven't been prevalent in the scene for a while. Perhaps someone made theirs open source or maybe some plugin for MAME, etc might have their code out there you could compile and try.

I'd be interested to see what happens :-) *on a side note didn't someone here overclock the ever loving crap out of a z80? I remember folks asking how the test was done/rated but don't remember who or what the conclusion was.

linuxlove
June 8th, 2009, 08:01 AM
quick google search for "overclocking a z80" brought this up:

The best overclock I ever had was a Zilog 2.5Mhz Z80, I overclocked it to 10Mhz that is a 400% overclock.

per
June 8th, 2009, 08:22 AM
Even a 80386 isn't enough if you want to emulate another system, at least not anywhere near full speed. Perhaps if you're satisfied with advanced higher-level simulation. Possibly you can get the core of a 6502 CPU emulator running cycle exact on a 33 MHz 80386DX.

Consider most of the precise NES emulators stutter on a 200 MHz PC, possibly even 500 MHz unless you reduce the frame rate and turn off some of the features.

I wrote an emulator for the Kenbak-1 once, however, it runs too slow on anything below 25MHz, and too fast on anything above 33MHz.

It's pretty slow compared to the original when run on an 8088.

carlsson
June 8th, 2009, 12:03 PM
In the case of Kenbak, I have a feeling there is no custom hardware apart from the CPU to emulate? Well, perhaps a few switches and lights. :-D

per
June 8th, 2009, 12:20 PM
In the case of Kenbak, I have a feeling there is no custom hardware apart from the CPU to emulate? Well, perhaps a few switches and lights. :-D

Yea. What it emulates is the memory, full instruction set (including the two-byte NOOP code), and front-panel (except the on/off switch) with the keyboard as input. I didn't try to emulate the spesiffic hardware or the serial data-steam architecture.

It was mostly a project I did to practice my skills in x86 assembler-programming. I actually added some additional features too. A "quicksave" feautre with 10 different save-slots, and a function to display the entire memory (pluss the address register) in octal data on the screen at any time durning runtime.

When running it on a 8088, the speed difference between displaying the memory and not displaying the memory is enormous!

In addition, I actually made contact with Mr. Blankenbaker himself to make sure the emulation of the front panel was as accurate as possible.

Mike Chambers
June 9th, 2009, 09:16 AM
if there is a DOS emulator compiled to run totally in 16-bit real mode, sure you can emulate the NES on an 8086. that's assuming that you don't mind 1 frame per minute.

swaaye
June 9th, 2009, 11:17 AM
I just got done trying to get SNES emulators running well on a Pentium II 233 notebook. Close but no cigar. It works but you are in for some chops and stutters.

NES emulation is obviously less demanding, but it'll never ever happen on something that old. I would imagine that a Pentium is probably needed to do it well.

You have to realize that emulation of a console is more than just about its CPU. You are trying to duplicate the functions of everything. RAM, instruction sets, quirks, hacks, audio, video, inputs, etc. There's nothing trivial about it.

Mike Chambers
June 9th, 2009, 12:32 PM
I just got done trying to get SNES emulators running well on a Pentium II 233 notebook. Close but no cigar. It works but you are in for some chops and stutters.

NES emulation is obviously less demanding, but it'll never ever happen on something that old. I would imagine that a Pentium is probably needed to do it well.

You have to realize that emulation of a console is more than just about its CPU. You are trying to duplicate the functions of everything. RAM, instruction sets, quirks, hacks, audio, video, inputs, etc. There's nothing trivial about it.

nesticle is able to emulate the NES in DOS with a high-end 486, but that's the limit.

Vlad
June 9th, 2009, 01:01 PM
The last time I used a NES emulator was on my old Thinkpad which was I THINK (no pun intended) a 133 MHz P1. It ran fine but I don't recall what software was used.

carlsson
June 9th, 2009, 02:06 PM
It may also depend on which application (game) you run inside the emulator. Some are more basic than others, not really depending on perfect timing.

Raven
June 11th, 2009, 11:49 AM
Yeah that's a good point, I was only thinking about the CPU.

What's a DOS-compatible NES emulator then for my Pentium box? I tried a few I found and none worked for me.

barythrin
June 11th, 2009, 12:00 PM
I haven't played with them in years but my friends and I settled on nesticle for nes. I don't recall any issues with it and it's fairly advanced feature wise including tcp/ip multiplayer abilities and some debugging tools to speed things up or edit whatever (turn frames on/off, turn off layers, etc).

http://www.emulator-zone.com/doc.php/nes/ has another one mentioned "fwnes".

I remember zsnes for super nintendo was our favorite although later on the windows compiled Win9xsnes or something was cool for TCP play.

Fallo
June 11th, 2009, 12:23 PM
I haven't played with them in years but my friends and I settled on nesticle for nes.

On most of the NES emulator screenshots I've seen, the colors are wrong. In particular, Nesticle is way off. The NES palette is difficult to get right because it's based on NTSC values rather than RGB.


I remember zsnes for super nintendo was our favorite although later on the windows compiled Win9xsnes or something was cool for TCP play.

I've never really used a console emulator, but I have used C64 emulators before. In particular, my 133 Mhz Pentium wasn't fast enough to handle anything above VICE 1.7.

Mad-Mike
June 11th, 2009, 04:22 PM
Ah, Emulation, here's my experiences....

ANYTHING lower than a 486 DX2-66 with all but the most sparse and featureless of emulators tends to be choppy, slow, and lacking in performance. System Memory is ALSO important.

The lowest I've gone is NESticle on a 486 DX/2 66 running MS-DOS 6.22, with sound. That was years ago using NESticle x.xx. I had full frame rate, and full sound on an IBM PS/Valuepoint with a DX/2, on 8MB of RAM.

The best experience at the lowest for me is a 486 DX4-100 with a decent sound card, and NESticle x.xx and LoopyNES beta to choose from running on a good SVGA graphics card with a good amount of VRAM (at least 1MB). NESticle is better, but LoopyNES will run things NESticle won't for some reason in certain memory hungry situations, like Dragon Warrior III, or Dragon Warrior IV on a system with a lot of resources being hogged.

NES Emulation got good for me on the Pentium level, with NESter. I had NESter and NNESterJ, and NESter was the best though it lacked Game Genie support :/

For the past few years, I've been running FCEU and FCEUx on my 500+ MHz boxes, and that Emulator has been the best thus far, with the most accurate emulation, a proper Game Genie emulation, smooth scrolling (thanks to having NVIDIA GeForce cards in all my 500+ MHz boxes). Now I run FCEUx on my Pentium D with 4GB of RAM, I can literally RECORD my games at full frame rate using screen capture software.

Atari 2600 emulation is even worse. On a 486 DX4, expect at least a 10% slowdown, if not more, and for games like Pitfall II, forgettaboutit', it'll run like molasses in January.

SNES Emulation, I had it running in a "playable" state on a 486 using a very old command-line driven SNES emulator, but things did not get good till I finally started using a 500+ MHz Machine with a decent amount of RAM, and SNES9x.

However, I'd LOVE to see someone try and emulate an NES on a CGA 8088 computer, the graphics sprites are could very well be possible being as the NES uses only 4 "colors" for each sprite out of the total pallet. The problem lies more in graphics speed and the ability to process multiple streams of data at once that create the "virtual machine" so to speak. A NES Emulator does more than just run code, it converts the I/O to work with standard PC Peripherals, changes the video to look as accurate as possible, controls all NES-type memory operations, plays back sound, and all the other things. That's why an 8088 based emulator is at least next to impossible in practice.

Fallo
June 12th, 2009, 08:42 AM
However, I'd LOVE to see someone try and emulate an NES on a CGA 8088 computer, the graphics sprites are could very well be possible being as the NES uses only 4 "colors" for each sprite out of the total pallet.

I think it would be easier to port NES games to the PC rather than trying to emulate them. Imagine SMB or Zelda in CGA...

Of course, a lot of NES games (mainly arcade titles) were available on the PC, although the quality of them was often not very good (eg. Bad Dudes).

Trixter
June 12th, 2009, 11:14 AM
The only usable emulator I ever ran on an 8086 was the Apple II emulator "Applemu". It took almost a minute to boot, so you might think it is frozen, but if you wait long enough it loads and is surprisingly usable. I remember putting in 10-line basic programs that were half POKES (ie. little demo graphical things) and they ran just fine, about 2-3x slower than the real thing.

The first Williams Arcade Classics package was one of Jeff Vavasour's early works and half of the games (including Sinistar) run pretty well on a 386-25. One of the ways Jeff cut down on the emulation requirements was to write emulation for the sound hardware, use it to generate all of the sounds the game produced and storing the output as 8-bit samples, then only playing back the samples when a particular sound event was triggered. The end-user experience was the same, but was one less IC to emulate while the game was running.

There was another very early arcade emulator (I want to say 1996 or so) that ran pac man, galaxian, and a few others comfortably on a 386-25 as well. I don't recall the name, sorry.

I also recall running a full-frame Atari 2600 emulator ("PCAE") on a 486 without too much difficulty. (PCAE, btw, was the first emulator to add code that emulated some additional hardware found in carts, like Pitfall II. I don't know if other emulators have added that code yet, but it was a really big deal in the 1990s that only one emulator could run Pitfall II...)

Nesticle runs just fine on a 486-66, and runs acceptably on a 386-40 if you skip frames. The guy who wrote nesticle also wrote a sega genesis emulator that, while not perfect, also runs on that class of hardware.

For most people, 100% emulation is usually a requirement, and for that, the rule of 10X original system speed still holds. However, most emulators today are written for portability, so you need 20X for decent results.

Trixter
June 12th, 2009, 11:17 AM
Atari 2600 emulation is even worse. On a 486 DX4, expect at least a 10% slowdown, if not more, and for games like Pitfall II, forgettaboutit', it'll run like molasses in January.

Must not have been using PCAE. Try that sometime.



However, I'd LOVE to see someone try and emulate an NES on a CGA 8088 computer, the graphics sprites are could very well be possible being as the NES uses only 4 "colors" for each sprite out of the total pallet.

Well, the colors would look universally terrible, but aside from that, the 8088 needs 4 cycles per memory access and CGA video memory requires a wait state -- the end result would be unusably slow.

Raven
June 12th, 2009, 01:08 PM
I'm using a VGA card in the 8086 I was talking about, btw. :P

It's a Tandy 1000 RL/HD which I popped a VGA card into to make usable, as the wonky PCjr-style CGA I had no monitor for.:confused:

carlsson
June 13th, 2009, 11:52 AM
the 8088 needs 4 cycles per memory access and CGA video memory requires a wait state -- the end result would be unusably slow.
Hopefully the 8088 machine code will be slightly more efficient per cycle than 6502 (well, 2A03) code is. That means even if the CPU takes a lot of clock cycles, perhaps it gets more done without shuffling registers and accumulators back and forth. An IBM PC also runs at 4.77 MHz compared to a NES at 1.78 MHz, so what takes 4 clock cycles on a 8088 may not take more than 1.5 cycles on a 6502.

Trixter
June 13th, 2009, 01:12 PM
Hopefully the 8088 machine code will be slightly more efficient per cycle than 6502 (well, 2A03) code is. That means even if the CPU takes a lot of clock cycles, perhaps it gets more done without shuffling registers and accumulators back and forth. An IBM PC also runs at 4.77 MHz compared to a NES at 1.78 MHz, so what takes 4 clock cycles on a 8088 may not take more than 1.5 cycles on a 6502.

Unfortunately, it's a bit worse than that. A C64 and a 4.77MHz 8088 are roughly the same overall speed because most instructions on 8088 take an average of 8 cycles to execute (4 for the opcode fetch, 2-4 to execute). Memory taking 4 cycles per byte really blows. Compare that to the c64 in which most instructions and memory accesses are, what, 1 or 2 cycles?

The only advantage an 8088 has over a C64 (in terms of processing speed) are a real MUL, DIV, and 16-bit registers.

8086s have more "awesome" because they can fetch two bytes in 4 cycles as opposed to one byte. I remember with one benchmark, my 7.16MHz 8086 clone was 1.9x faster than my 4.77MHz 8088.

I really need to find some time to write that benchmark :-/

Fallo
June 13th, 2009, 02:21 PM
Unfortunately, it's a bit worse than that. A C64 and a 4.77MHz 8088 are roughly the same overall speed because most instructions on 8088 take an average of 8 cycles to execute (4 for the opcode fetch, 2-4 to execute). Memory taking 4 cycles per byte really blows. Compare that to the c64 in which most instructions and memory accesses are, what, 1 or 2 cycles?

The 8088 _is_ faster than a 6502, but only by a little bit.


The only advantage an 8088 has over a C64 (in terms of processing speed) are a real MUL, DIV, and 16-bit registers.

And a much bigger address space (64k against 1MB) and a bigger and easier to use instruction set. The MUL and DIV instructions are very slow and useless since the 8088 has no hardware multiply or divide, and relies on microcode for them. You'll get better performance using bit shift instructions (which is how multiplication and division are done on the 6502, anyway), although it takes a bit more memory.

barythrin
June 13th, 2009, 05:45 PM
Kind of interesting when you think about it. I've never done emulation coding (I'm not any cpu/ML expert, just an infrequent code junkie that used to write quick PoC stuff for kicks). So my initial assumption was that an emulator would read the bytes of the binary file and then emulate things live. Obviously taking a few extra cycles to convert commands, etc.

I was trying to think what one could do to optimize this, and while it would take longer load time, what if it read the file and wrote a converted output to run. I guess it'd just be a cross-compiler instead of an emulator but THEN all the code is realtime, no conversion necessary. Then I wonder what it'd be like (besides color palettes being kinda wrong and I'm not sure what could be done for sound).

Mike Chambers
December 5th, 2013, 03:25 PM
However, I'd LOVE to see someone try and emulate an NES on a CGA 8088 computer, the graphics sprites are could very well be possible being as the NES uses only 4 "colors" for each sprite out of the total pallet. The problem lies more in graphics speed and the ability to process multiple streams of data at once that create the "virtual machine" so to speak. A NES Emulator does more than just run code, it converts the I/O to work with standard PC Peripherals, changes the video to look as accurate as possible, controls all NES-type memory operations, plays back sound, and all the other things. That's why an 8088 based emulator is at least next to impossible in practice.

I know this thread is ancient, but I'm necroposting because it's a funny idea and I've done it. :)

Not using CGA, that would be slower... but 256x256x8 VGA mode. I ported my Windows NES emulator to DOS and ran it on my IBM XT just to see exactly how slow it would be. The answer is "brutally". It takes almost a minute to render a full frame. It's a slow emulator compared to something like NESticle. It needs a Pentium 2 to be playable, but even with extreme optimization there's no way you'll get anything near playable on an 8086/8088. Even with rendering disabled totally, it takes about 3-5 seconds to emulate one frame's worth of game code. Here's proof it works though.

http://rubbermallet.org/nes8088.jpg

:twisted:

If you want to actually watch it in "action" if you can call it that, here is a video of it rendering the SMB1 title screen:


https://www.youtube.com/watch?v=kt46q538Rlc


So, now we have our (admittedly obvious) answer. The biggest problem is indeed the graphics rendering. It's quite CPU intensive. While drawing the background it has to do calculations for H/V scrolling, and calculate the background nametable to take the tile values from based on that, and then determine the actual pixel inside that tile to draw... for each of the 256x240 pixels on the screen. Each background and sprite pixel also has to pull data from multiple places in video memory, do some bit-shuffling, combine a few bits from each source into one value, then prioritize the background sprite, background field, and foreground sprite, check for transparencies, and draw the correct pixel, as well as increment scroll registers, address registers, etc. in the NES PPU. I'm utterly amazed that NESticle can even do what it does on a 486.

barythrin
December 5th, 2013, 04:26 PM
http://rubbermallet.org/nes8088.jpg

lol.. and the winner for the most confused technology picture goes to.. ;-) (IBM PC with 5.25" drive with 3.5" floppy and CDs sitting on it, running an NES game on an LCD screen!)

Mike Chambers
December 5th, 2013, 04:37 PM
lol.. and the winner for the most confused technology picture goes to.. ;-) (IBM PC with 5.25" drive with 3.5" floppy and CDs sitting on it, running an NES game on an LCD screen!)

hahaha. I didn't even think about that. It's even worse than that really. That's actually a DVD and there's also a 4 GB SDHC card sitting on that floppy sleeve. :)

Yeah, that bench is a warzone.

eeguru
December 5th, 2013, 08:11 PM
An HD set top box on the market from a company that shall remain nameless had a port of FCEU with a Legend of Zelda ROM ported by me. It was triggered by a debug menu and ran on a 300 MHz MIPS R4Ke. Was in software releases for nearly a full year before I finally removed it fearing legal issues. It ran at roughly 80% CPU and supported the NES/Famicom USB type game pads.

Mike Chambers
December 5th, 2013, 09:33 PM
An HD set top box on the market from a company that shall remain nameless had a port of FCEU with a Legend of Zelda ROM ported by me. It was triggered by a debug menu and ran on a 300 MHz MIPS R4Ke. Was in software releases for nearly a full year before I finally removed it fearing legal issues. It ran at roughly 80% CPU and supported the NES/Famicom USB type game pads.

That's one of the coolest things I've ever heard! :D