project64 / project64

N64 Emulator
http://www.pj64-emu.com/
GNU General Public License v2.0
2.57k stars 493 forks source link

Pokemon Stadium 2 GB tower bad recompiler performance #964

Open purplemarshmallow opened 8 years ago

purplemarshmallow commented 8 years ago

In the GB tower the CPU recompiler is really slow the interpreter is many times faster. The GB tower is a gameboy emulator on the N64.

project64 commented 8 years ago

most likely either the game is triggering the recompiler to to keep resetting function and keep compiling, or it is generating a lot of exceptions (detecting writing to registers)

LegendOfDragoon commented 8 years ago

Can you try seeing if the performance improves after disabling advanced block linking? I just realized that ABL is what caused the bad performance in Abs Crap.

purplemarshmallow commented 8 years ago

it's disabled by default for this game

LegendOfDragoon commented 8 years ago

Yup, definitely something wrong with the cpu recompiler. Any idea why the audio is awful? I tried 1964 1.1 and it also had really bad audio.

Interesting how it seems to require cpu <-> rsp sync for GB Tower.

purplemarshmallow commented 8 years ago

The counter factor seems to play a role POKEMON STADIUM 2.zip Here's my save. It unlocks the speedup feature. Press c right to play at 2x or 3x speed. This does not seem to work at all with CF2. With CF1 you can speed up but timings still do not seem to be right.

LegendOfDragoon commented 8 years ago

Thanks for the save. One interesting thing I learned is that it uses 48khz for frequency. I could not figure out why the audio is bad. VI refresh rate also makes a difference, but doesn't seem like tweaking the number really fixes anything.

LegendOfDragoon commented 8 years ago

I think this game really benefits from ABL.

@project64 could you take a look at https://github.com/project64/project64/blob/master/Source/Project64-core/N64System/Recompiler/LoopAnalysis.cpp#L328 ? From my brief testing, ABL seems to work fine with Protect Memory, but I get that breakpoint error when trying to run GB Tower in Pokemon Stadium 2.

LegendOfDragoon commented 8 years ago

Turns out that the audio issue is just an AI emulation issue. Seems fixable.

@project64 I think fixing ABL is the best solution. I'd be willing to try and fix a few bugs, if i can get some help. I'm going to start working on cpu recompiler.

@purplemarshmallow are you able to get GB Tower working in Pokemon Stadium 1? I can't :disappointed: .

purplemarshmallow commented 8 years ago

@purplemarshmallow are you able to get GB Tower working in Pokemon Stadium 1? I can't :disappointed: .

No, and I also can't get the GB tower in Pokemon Stadium 2 working with Red/Blue/Yellow. Only Gold/Silver/Crystal seem to work

LegendOfDragoon commented 8 years ago

Ok well I got it working, by using a hack. The problem is that with ABL off, it generates too many exceptions because the recompiler analysis isn't thorough enough. Patching the recompiler for this instruction fixes the slowdown 0x80154D20 LW $9, 16(T0)

So the solution is to either write game specific code, or fix ABL. I did this sort of patch work for other games like Super Smash Bros and improved the cpu performance :smile: .

LegendOfDragoon commented 7 years ago

Seems like ABL would fix the problem. I just need to check and make sure there's no sync errors.

I also can't get the GB tower in Pokemon Stadium 2 working with Red/Blue/Yellow.

That's odd, red version works for me in Stadium 2.

project64 commented 4 years ago

closing old issue, if this is still an issue it can be reopened

oddMLan commented 4 years ago

It is an ongoing issue, please reopen

EDIT: Someone mentioned OC = 3 fixes the performance using the recompiler

AlexN64gamer commented 2 years ago

Not to mention that on Pokemon Stadium 1 the GB tower does not work at all (tested many times) it only works on 2, and doesnt even really "works" cause its so choppy and laggy that it cannot be played, it is a ongoing issue @project64

AlexN64gamer commented 2 years ago

https://www.youtube.com/watch?v=P80oQ7q-l2A

oddMLan commented 2 years ago

Use interpreter mode or set CF=3 in recompiler mode

AlexN64gamer commented 2 years ago

@oddMLan I have already told many times that doesn't work, I have set both modes, and increased the counter factor, the GB Tower is still to slow to be played, it needs to be in the list of future improvements, it is an important feature inside Pokémon Stadium (doduo tower, dodrio tower, new borders, etc) so please, keep up the research, and thanks for the great work

GB-CG commented 2 years ago

@AlexN64gamer Why not use mGBA with SGB border and fast-forward support in the meantime, or BGB? The Game Boy Tower emulator itself isn't as accurate as BGB or Gambatte-speedrun.

AlexN64gamer commented 2 years ago

@GB-CG that's out of the question mate, it is a good suggestion and I already use BGB to emulate the experience, but for example, you can just use one speed at a time when fast forwarding, while in the real GB Tower you just press the C button and it increases or decreases the speed, so, it still needs to be researched and featured in P64 next release

project64 commented 2 years ago

I know I am starting to do refactoring and trying to get things more accurate .. now some of these refracting might make a difference here .. still might not make any difference, but something I can look at some time after the refactoring.

LegendOfDragoon commented 2 years ago

I have set both modes, and increased the counter factor, the GB Tower is still to slow to be played

You are doing something wrong if you can't get full speed with interpreter. My 11 year old laptop is getting full speed. image

All you have to do is disable debugger, enable interpreter, and use counter factor 2.

AlexN64gamer commented 2 years ago

Im so sure about what I say that Im going to send a video footage of my pc, btw.... specs: Intel I7 9700k (8-cores) 3,6ghz Nvidia RTX 2060 ti 6gb ram, 32gb ram Corsair Vengeance ddr5, SSD Corsair MP600 1TB, I guess is powerfull enough to get full speed, and I tried EXACTLY the same you say; debugger disabled, cpu core style: interpreter, counter factor: 2 , the speed is about 10%, unplayable, Im talking about Pokemon Stadium 1 with my red save file, I haven tested Pokemon Stadium 2 yet, but the point is that both should be playable, so, still needs research @project64

Squall-Leonhart commented 1 year ago

the pokemon emulator in the stadium games doesn't perform properly with the VI rate that the rest of the game requires for operation.

You can use a recent 4.x build along with the romhack here https://www.romhacking.net/hacks/4506/ and play the games at full speed with the included profile for the hack.

Changing the counterfactor will indeed just make the emulation slower.

[27BC81C2-49AFB311-C:45] Good Name=SGB Emulator v1.2 Status=Compatible Core Note=Requires Parallel-RSP. Counter Factor=1 Linking=Off ViRefresh=3000