Thursday, May 10, 2007

Goldeneye

While I'm at it with the blog updates, I also invesitgated why Goldeneye no longer works in Daedalus (it did run with some of the very early releases, but stopped working some time ago.)

Goldeneye is quite an unusual game in that it's one of the few titles that executes code from virtual memory. I'm not sure exactly why it does this, but I suspect that it's to allow it to free up as much RAM as possible. It sets up a virtual memory range for the code, and pages in chunks of data to physical RAM as required (i.e. on TLB miss exceptions). I guess this means that it can just keep a few dozen KiB of code in RAM at a time, rather than the entire code segment.

Anway, emulating this accurately is incredibly slow - for every instruction that is executed, the emulator needs to check whether the instruction fetch would cause a TLB miss exception, and if so invoke the N64's exception handler. This is quite a time consuming process, so I tend to cheat and assume that the instruction pointer is in physical memory.

To get around this problem with Goldenye, I set up a couple of bogus entries in Daedalus' memory map that point directly to the correct region in the ROM image. In a way it's as if the N64 has a much larger TLB, and all the pages are permenantly mapped.

Normally (i.e. on the PC version of Daedalus) this all works fine. The problem as far as the PSP version is concerned is that the rom (all 12 MiB for Goldeneye) must be permenantly loaded into memory, and there just isn't enough memory left to do this anymore. As most N64 roms are simply far too large to fit in the PSP's RAM, I have to page chunks in from the memory stick on demand (pretty similar to what Goldeneye was doing on the N64 really :D)

So, there are a few possibilities for getting Goldeneye to work:


  • Permenantly disable dynarec for Goldeneye, and reuse the dynarec buffers (6MiB) the expansion pak (unneeded anyway, 4MiB) and anything else I can scavenge, to fit the rom in a contiguous block in memory.
  • Investigate a way of getting the memory-mapping hack to work with rom caching.
  • Re-examine how I handle TLB miss exceptions for instruction fetches, and implement them correctly.


Of all of these, the first solution is probably the easiest, but it's a bit hacky (I'd have to allocate a 12 MiB for Goldeneye at startup, and carve this up for different subsystems if other roms were run).

The second solution is a bit less horrible, but I'm still not sure it's possible without checking the instruction pointer for every instruction that's executed (and paging in chunks of ROM as required).

That leaves the third solution which is probably the most work, but I think will be the most stable solution in the long run. It may also help a few other roms that are using similar techniques to Goldeneye to run correctly. If I can get it to work in conjunction with the current dynarec implementation, it shouldn't even be any slower than the current hack that's in place.

Anyway, given the work involved Goldeneye isn't an immediate priority, but I am thinking about it.

-StrmnNrmn

13 comments:

andrew said...

Hey StrmnNrmn, great to hear from you as always.

Has the new PSP emulator been of any help to you yet? Have you tested it? I thought that some devs, especially you, could make use of it.

Morgan said...

Wow the hype for R12 just went through the roof! I love how SSB is looking and I love your trying to get Goldeneye working. A tip for you, I think some of the graphical issues that SSB is having are similar to the StarFox graphical issues so you might want to look into that. Lastly I would really want to request that you try to get Diddy Kong Racing working, I know this is sounding selficous right now but please look into it, judging by the FPS reader it runs pretty fast, just can't see anything. I love reading your updates and R12 looks so amazing now that your looking into fixing these other games, it's going to be amazing, thanks!

ps. Please consider looking into DKR's graphical issues it would mean an INCREDIBLE AMOUNT, more than you'de ever know, thanks!

Anonymous said...

Goldeneye should be very, VERY, low on your list. Why you ask? Simple, the psp setup is NOT any good for a FPS game, especially not when the n64 uses more buttons than the psp has. You will need to sacrifice some buttons for gameplay.

I vote for Zelda:OOT/MM, Mario 64, Paper Mario as some of the top games to get working, and if you can Donkey Kong 64, too.

Unknown said...

all i can say is your the man and you keep us updated keep up the good work i like seeing what great progress your making

MiLO22 said...

yay!!
Please don't forget about the Media Engine. ^_^

Falcon_maximus said...

Command & Conquer also doesn't work anymore since R10...... there where heavy graphical glitches in R10 (or was it even R9?), but using R11 it doesn't even start -> Black Screen, no sound...... why?

Please have a look a this and fix it.
Greetings
Florian

UXSupra said...

Could you fix the bug that keeps Paper mario from crashing? I want to play that game bad. Thanks Strmn :)

Rikki-Tikki-Tavi said...

Updates!

Huzzar to StrmnNrmn!

Huzzaar!!

Unknown said...

Hi there,
I just wanted to say that you're doing a great job! Here in Brazil, your emulator is being considered one of the greatest homebrews ever made for the psp.
We are all very excited to hear about the new versions of Daedalus, every technical or non-technical post is more than welcome!!
Success!!!

Rodrigo Cardoso said...

could you, maybe, cache the rom removing the maps, sounds, textures and 3d models that isnt being currently used? keeping all the code data.

is this kind of separation possible?

bye

Unknown said...

Nicely done, I can't wait for R12, I love Goldeneye and I never dreamed in a million years that I would be able to play it on a PORTABLE console :O Your a great guy for spending your extra time working on a N64 Emulator for PSP, I applaud you for your great work so far :) I hope someday that I can become a respected programmer like yourself. Peace and one love bro.

Jody said...

So Goldeneye isn't going to work nicely for you to fix?

Unknown said...

Hi StrmnNrmn,

Daedalus R12 is the first version I have downloaded and I love it.

I managed to get a Starfox ROM and it runs better than any of the the other ROMS I have. Super Mario 64 works a treat aswell but Goldeneye is far too slow to play. Zelda Ocarina of time doesnt load the actual game but the menu at the start loads fine.

Just thought you would like some feedback. Keep up the good work :)