The N64 is a lot more powerful than the NDS
How do you figure? DS has a lot of advantages over N64 and vice-versa. It's really difficult to compare them. Two games that are written with the strength of both in mind will look very different from each other.
but the NDS have a few hardware periphials that you need to sync with the CPU. For example, the hardware matrix co-processor. The CPU expects a result to be read from the registers within tens of cycles, so you'd need to splice that into the CPU emulation. I have never written a dynarec, but my gut feeling tells me that this will result in horribly slow code.
Nah.
The whole 3D pipeline on DS is actually pretty decoupled from anything the CPU sees, thanks to the majority of the results going to private memory which can't be read back, or at least not until much later when the capture unit gets to it. There are some exceptions, like getting the state of the matrices or reading back the results of the box tests, but games don't do a lot of this. For the most part an emulator can queue up an entire scene's worth of commands before actually doing anything with it.
However, game code does rely on pretty tight synchronization between the ARM9 and ARM7. As part of its initialization routine the ARM9 attempts to communicate with the ARM7 and waits for the result in a busy loop, and will pretty quickly time out and fail if it doesn't get a response. So you can only run several dozens of instructions on the ARM9 before you need to catch up with the ARM7. This isn't that bad though, nothing in the realm of dynarec killing, and since only a few ARM7 binaries are used for all games you could probably HLE/hack your way around it.
The GPU seems okay, and *should* be possible to translate to GLES calls, even though it seems to be desgiend to be emulated with OpenGL 1.0 glBegin...glEnd sillyness. Also, I'm not sure about everything else it can do apart from bare primitive rendering and what incompatibilities with OpenGL that might be waiting there.
Its interface may be sort of OpenGL-like but there are all sorts of low-level things that OpenGL 1.x (and for that matter, standard OpenGL ES 2.0) can't handle properly, or can't handle without a ton of shader power (more than is reasonable even for the DM3730 Pandora). For instance, just off the top of my head:
- Polygons are rendered with two-fold linear interpolation instead of standard affine parameters. For triangles this just means they look glitchier but quads can look totally different
- Edge marking which at the very least requires you to read back the framebuffer and depth buffer, former is very expensive, latter can't be done at all
- Paletted and compressed texture formats which require expensive texture caching or expensive shaders
- Need to be able to read back framebuffer to combine it with 2D, again, very expensive
- DS can pre-load the depth buffer,
- Polygon-ID rendering nuances which means more outputs in addition to color/depth/stencil, problematic to do without multiple render targets
- Edge anti-aliasing which doesn't look MSAA et al
I guess the good news is that the NDS GPU emulation doesn't have to handle that replaceable microcode bullshit the N64 required.
The "replaceable microcode bullshit" is why N64 has been successfully emulated on such weak hardware. N64 does not have hardware with programmable microcode, rather it has a vector coprocessor. Since there's not a lot of program/data memory on this coprocessor most games are instead using it to interpret a stream of commands in a standard Nintendo/SGI interpreter, commands they (badly) call microcode. These commands are also used to handle audio. Because of this most N64 emulators don't emulate this vector coprocessor, or the GPU for that matter, but instead emulate the microcode interpreters. That means that the only substantial piece of hardware that these emulators have to handle a low level is the CPU, which is in practice much slower than you'd expect it to be because the memory sucks so badly. Proper low level N64 emulation would never be fast enough on something like Pandora.
On DS emulating the geometry engine + GPU isn't that much more intricate than emulating microcode on the N64, per se. But on DS you have to emulate two ARM CPUs, the main one which is not as crippled as N64's, and you have to emulate two real 2D engines (both more powerful than GBA's) and a real audio engine. The memory layout of the CPUs is a lot more complex and accesses are a lot more varied, so I doubt you'd have as much success with the kind of optimization N64 emulators use for memory access, which is a huge chunk of CPU emulation.