i've been thinking about doing a secondary emulator for DOS as kind of a side project to my main one. i am wondering just how fast one could get. do you think it's possible to get much faster than NESticle? i was going to do it in 100% assembly, i'm working on the 6502 code right now.
any tips? i'm not aiming for accuracy, just pure speed. as long as it could play a fair amount of games properly, i'd be happy. i've got an old 25 MHz 486 laptop, think it's feasible to aim for full speed on that?
the PPU, of course, is going to be the tricky part. one thought i had was keep the whole 512x480 background rendered in memory (just the lower two bits of the pixel, since lots of games change attributes for background animation), only making small incremental changes when nametable blocks are changed. then i can just copy ready-to-go memory blocks for each scanline from the proper parts of the background, OR in the attribute bits, and write it to the PC's video RAM.
do you think the goal of full speed on 25 MHz is impossible?
Don't get too optimistic. PocketNES squeaks by on a 16.8 MHz ARM, but then it high-level emulates the NES PPU using the GBA PPU.
If you're caching the 512x480 pixel plane, the mid-screen bankswitching of Hatris in-game, Qix in-game, and Smash TV's title screen is going to be painful, and the bankswitching every few scanlines in Cosmic Epsilon even more so.
If you really want to sacrifice accuracy, you could port individual games to PC, as someone ported the disassembly of the original Super Mario Bros. to Sega Genesis instruction by instruction, and then call them game-specific emulators. Id Software's attempt at doing this to Super Mario Bros. led directly to the Commander Keen series.
Isn't Loopynes comparable in performance to Nesticle, and a whole lot better?
Right now, I think Famtasia might be the fastest Windows-compatible emulator.
Anyway... back to the topic.
In order to make a really fast NES emulator for an old DOS machine, some random thoughts:
* Use Mode X. Mode X lets you use bit planes.
* Possibly use VGA hardware scrolling and dirty rectangles? That would be tricky to pull off, would it work?
* Use speedhacks to skip emulating some of the CPU.
Maybe tricks like these would work on a J2ME or Javascript NES emulator. Not the Mode X one, but blit scrolling, dirty rectangles, and speedhacks.
I don't think id ever disassembled Super Mario Bros, it was just their experiments on playing with the EGA scrolling registers.
tepples wrote:
Don't get too optimistic. PocketNES squeaks by on a 16.8 MHz ARM, but then it high-level emulates the NES PPU using the GBA PPU.
If you're caching the 512x480 pixel plane, the mid-screen bankswitching of Hatris in-game, Qix in-game, and Smash TV's title screen is going to be painful, and the bankswitching every few scanlines in Cosmic Epsilon even more so.
If you really want to sacrifice accuracy, you could port individual games to PC, as someone ported the disassembly of the original Super Mario Bros. to Sega Genesis instruction by instruction, and then call them game-specific emulators. Id Software's attempt at doing this to Super Mario Bros. led directly to the Commander Keen series.
i have discussed porting that SMB code to the PC with a friend of mine several times, one of these days we were going to give it a shot actually. i bet that could run full speed on a 286 or even an 8088 if done carefully.
you've got a good point about games that bankswitch, that probably wouldn't work out to well then.
Dwedit wrote:
Isn't Loopynes comparable in performance to Nesticle, and a whole lot better?
Right now, I think Famtasia might be the fastest Windows-compatible emulator.
Anyway... back to the topic.
In order to make a really fast NES emulator for an old DOS machine, some random thoughts:
* Use Mode X. Mode X lets you use bit planes.
* Possibly use VGA hardware scrolling and dirty rectangles? That would be tricky to pull off, would it work?
* Use speedhacks to skip emulating some of the CPU.
Maybe tricks like these would work on a J2ME or Javascript NES emulator. Not the Mode X one, but blit scrolling, dirty rectangles, and speedhacks.
I don't think id ever disassembled Super Mario Bros, it was just their experiments on playing with the EGA scrolling registers.
mode x is a great idea. i've never heard of dirty rectangles, but i don't think VGA hardware scrolling would handle all of the work. vertical scrolling could be done, but not horizontal -- that would still have to be done by software. there is a VGA register that can be used to specify the starting address of (0,0) in video RAM.
This page says that VGA can do smooth horizontal scrolling.
Also, Pinball Fantasies did split screen hardware scrolling on VGA. (it also had a mod player that spat out 4-channel music through the PC speaker, amazing stuff)
I once tried NO$GMB on a 286 with CGA. It was pretty slow, it ran at about 8 FPS when running Sqrxz.
Dwedit wrote:
This page says that VGA can do smooth horizontal scrolling.
Also, Pinball Fantasies did split screen hardware scrolling on VGA. (it also had a mod player that spat out 4-channel music through the PC speaker, amazing stuff)
I once tried NO$GMB on a 286 with CGA. It was pretty slow, it ran at about 8 FPS when running Sqrxz.
huh, i wasn't aware it supported horizontal too. that might be useful. the complicating factor is that sprites have to be drawn too, without being affected by the scroll. too bad it doesn't have hardware support for multiple layers and transparency.
well, on a side note, i guess i need to add horizontal scrolling support to my VGA emu code in my PC emulator. i haven't seemed to run into any programs that tried to use that capability yet.
i recall using NO$GMB a long time ago on a 286 also, just to see how it ran. yeah it was pretty bad. maybe i'll give it a try on my XT just for fun. 4.77 furious megahertz.
I programmed a second NES emulator to try to achieve reasonable performance on my Pentium 233mhz laptop. I wasn't doing any assembly programming though. It was still all C++ but I optimized graphics rendering and emulation enough to get 60fps performance out of it even with Blargg's APU emulation for sound.
I'm not sure if you could out perform Nesticle. I have a feeling it's heavily optimized for speed given its age and reputation. I never used LoopyNES much but it also was quite fast and I recall didn't have problems with various games like Ninja Gaiden 3 which Nesticle has issues with scrolling.
As GBA was mentioned, I wonder if the Sharp X68000 could emulate NES fairly well since I believe it has console graphics capability but can have a 68000 cpu clocked reasonably high with plenty of memory. Not having to do software graphics emulation certainly helps reduce resources needed.
A SNES w/ SA-1 could probably emulate the NES pretty well, but I doubt at full speed.
JIT techniques could help a great deal with the CPU speed, but the PPU is a difficult problem to tackle, especially if you are aiming any kind of honorable level of accuracy.
VGA can do smooth 4-way scrolling, but the addresses only wrap at segment boundary if I recall correctly, meaning that if you scroll the screen 20 pixels to the left, what you get in the right edge of the screen is the 20 pixels of 1 scanline below. I may be mistaken at this, though.