xjsxjs197 / WiiSXRX_2022

GNU General Public License v3.0
159 stars 15 forks source link

Rayman 2 - The Great Escape (USA) (SLUS-01235) crashes after Rayman says "Globox" cutscene. + CHD crashes because of memory overflow #198

Closed saulfabregwiivc closed 7 months ago

saulfabregwiivc commented 8 months ago

Like the title says, not sure what happened or in what exact commit caused this issue but seems the game Rayman 2 - The Great Escape (USA) (SLUS-01235) it worked fine before, but now on latest WiiStation 3.0 and later commits, it crashes after the cutscene where Rayman says "Globoooox!", and it's almost after the start of the game.

ID: SLUS-01235, but i think it also happens on all other regions. Using BIN/CUE, cause i know CHD is still somewhat unstable.

On latest PCSX-ReARMed this issue doesn't happen.

xjsxjs197 commented 8 months ago

This issue should have been resolved. In the future, when adding new features, it is important to pay attention to the remaining MEM1

saulfabregwiivc commented 7 months ago

Thanks for your fix, it's working now.

If using CHD it still crashes before the Rayman saying "Globox" cutscene but i guess it's because we ran out of memory in this part of decompressing things from the CHD.

But i think we'll check this part when the latest CHD implementation gets merged, which i'm still working in it currently.

saulfabregwiivc commented 7 months ago

BTW, how i can check how much memory is remaining in MEM1 and MEM2 when using WiiStation?

xjsxjs197 commented 7 months ago

BTW, how i can check how much memory is remaining in MEM1 and MEM2 when using WiiStation?

Using [SYS_GetArena1Size() >> 10] can obtain the remaining KB capacity of MEM1. The usage of MEM2 is defined in MEM2.h. Currently, 128KB+128KB+256KB+20M+20M are used. If possible, the decompression of libchdr can be placed in MEM2, which will not cause the problem of insufficient content in MEM1.

saulfabregwiivc commented 7 months ago

@xjsxjs197

That'll be very, very nice of storing the temporal decompressed data of libCHDr and its dependencies in MEM2 instead of MEM1, i believe doing that could solve some games crashing when using CHD.

The only problem is... i don't know how to move those data to our MEM2 so they don't plague MEM1...

I kindly ask you: could you try to see how to move all the temporal CHD data to MEM2 so it don't overflow MEM1? Anyways, thanks for responding.

saulfabregwiivc commented 7 months ago

I think another option for store the temporal decompressed data from libCHDr instead of moving to MEM2, is by implementing a sort of virtual memory (VM) pagefile, which uses some of the NAND memory as virtual RAM.

I know WiiSX (http://github.com/emukidid/pcsxgc) and even other homebrew such Not64 (http://github.com/extremscorner/not64) has this for use this method of VM on NAND for run things without overloading too much MEM1/MEM2.

Is that possible to be implemented in WiiStation somehow?

xjsxjs197 commented 7 months ago

I kindly ask you: could you try to see how to move all the temporal CHD data to MEM2 so it don't overflow MEM1? Anyways, thanks for responding.

Let me first understand the relevant logic, I think it should be possible.

saulfabregwiivc commented 7 months ago

I kindly ask you: could you try to see how to move all the temporal CHD data to MEM2 so it don't overflow MEM1? Anyways, thanks for responding.

Let me first understand the relevant logic, I think it should be possible.

thanks, altrough i think it's better to have a VM (virtual memory) instead, because we only have a little free space on MEM2... Read this post i posted here:

I think another option for store the temporal decompressed data from libCHDr instead of moving to MEM2, is by implementing a sort of virtual memory (VM) pagefile, which uses some of the NAND memory as virtual RAM.

I know WiiSX (http://github.com/emukidid/pcsxgc) and even other homebrew such Not64 (http://github.com/extremscorner/not64) has this for use this method of VM on NAND for run things without overloading too much MEM1/MEM2.

Is that possible to be implemented in WiiStation somehow?

xjsxjs197 commented 7 months ago

I can give it a try, but I'm not sure how to create CHD files, or do you have CHD files for testing purposes?

saulfabregwiivc commented 7 months ago

I can give it a try, but I'm not sure how to create CHD files, or do you have CHD files for testing purposes?

You can download USA/NTSC-U PlayStation CHDs files ready for use here: https://archive.org/download/chd_psx/CHD-PSX-USA/ (not sure if in your region allows you to use Internet Archive)

There's CHDs for lots of games but i would recommend trying with Rayman 2: The Great Escape since it's the most notable in crashing at certain point because of memory overload.

xjsxjs197 commented 7 months ago

I have downloaded [Rayman 2 - The Great Escape (USA) (En,Fr,Es).chd], but when loading the game, an error occurred and unable to enter the game. Even if using versions before v3.0, I am using the Dolphin emulator. Is it because my running mode is incorrect, or is there an incorrect setting somewhere?

saulfabregwiivc commented 7 months ago

Btw, a few time ago i tested the same CHD you got and i havent got any issues besides the crash after escaping the pirate boat (start of the game) caused by memory overflow.

Try using SD/USB BIOS instead of HLE, enabling Boot Through Bios (set it to "Yes") and disabling the MemCard 2? Try using the Release build instead of the Debug one?

EDIT: Crap, when i made the PR for update libCHDr, i forgot to add to the debug Makefile this flag -DUSE_LIBCHDR in CFLAGS. You could try adding that flag in CFLAGS in your debug Makefile. Btw, i will check again the Debug makefile and update it for reflect the new changes made to Release makefile too.

saulfabregwiivc commented 7 months ago

I have downloaded [Rayman 2 - The Great Escape (USA) (En,Fr,Es).chd], but when loading the game, an error occurred and unable to enter the game. Even if using versions before v3.0, I am using the Dolphin emulator. Is it because my running mode is incorrect, or is there an incorrect setting somewhere?

I have fixed your issue of debug builds being unable to play games in CHD, it's because of the Makefile for DEBUG. https://github.com/xjsxjs197/WiiSXRX_2022/pull/203 Merge this first, then try again loading the CHD files in Debug builds.

xjsxjs197 commented 7 months ago

Move Lightrec's 4M Buffer to MEM2 memory. At present, MEM1 has 6MB of remaining memory, so even for other CHD games, there should be no errors

xjsxjs197 commented 7 months ago

Using NAND is too difficult, let's temporarily use this method

saulfabregwiivc commented 7 months ago

Thanks for your workaround, i'll compile this and try with other CHD games again.

Btw, saying that now MEM1 has free 6MB for that, with your MEM2 modifications, how much MEM2 memory is free at present?

saulfabregwiivc commented 7 months ago

Tested your new changes and now Rayman 2 doesn't crash anymore at certain point when using CHD, thanks!

As you said, this is a temporary solution of moving to MEM2 some things, but i think it's better to have a virtual memory logic. But for now, it's solved. Closing.

xjsxjs197 commented 7 months ago

Thanks for your workaround, i'll compile this and try with other CHD games again.

Btw, saying that now MEM1 has free 6MB for that, with your MEM2 modifications, how much MEM2 memory is free at present?

There is still 16M left in MEM2, with some reserved for use by the HID controller and the other reserved for texture caching in future GL rendering, which may take a long time. I am not sure if this can be achieved