ekeeke / Genesis-Plus-GX

An enhanced port of Genesis Plus - accurate & portable Sega 8/16 bit emulator
Other
698 stars 199 forks source link

Add SRAM support for games larger than 8MB #381

Closed pjft closed 3 years ago

pjft commented 3 years ago

Per https://github.com/libretro/Genesis-Plus-GX/pull/255 and @ekeeke 's recommendation, I'm opening an issue here.

Demons of Asteborg is a 16MB game that was just released, and uses SRAM. Currently, the emulator works with the game, but doesn't support SRAM.

Tagging @Infitek if any special info about the actual game is needed. On my end, I am more than happy to test things or dig into the code in my limited capacity.

Thank you very much for accommodating, and for all the patience and detail you've provided in all your answers so far. And apologies for the issues caused with trying to contribute to the current emulator without fully understanding the specifics of the memory limits in place, as well as with having used a first ROM version that was faulty.

Let me know how I can help.

pjft commented 3 years ago

For what it's worth, changing

  if (cart.romsize > 0x800000) return;
  sram.sram = cart.rom + 0x800000;

to

  if (cart.romsize > 0xf00000) return;
  sram.sram = cart.rom + 0xf00000;

does work, but might breaks other things, I don't know. I tested a few other games and still seemed to work, but I don't know a lot more about this.

Of course, you might want to consider how to make it work for any other ROM size, rather than fixing it now at 16MB.

Let me know how I can help.

ekeeke commented 3 years ago

Yes, this works likely because the game does not use the last MB so you can map SRAM there. However, this is not a proper solution as this still limit SRAM to game of some arbitrary size (which is the design issue that should actually be fixed) and it will crash on platforms that do not redefine MAXROMSIZE to 16MB as it will map SRAM to some undefined memory area.

I will come with a solution, don't worry, I just need some time to think about it and find the cleanest solution that also does not break other parts of the emulator as some of them rely on this old design choice.

pjft commented 3 years ago

Thank you. Of course, makes sense. I was just sharing what my limited tests were able to get to, in hopes it'd work.

There is no urgency here, and honestly, I'll gladly follow and just learn from what design decision you come up to here.

Thank you and have a great day.

Flupper commented 3 years ago

@pjft I'm curious, which emulator did you use to run this game ? Retroarch 1.9.7 + e6ab756 core from this repo, freshly compiled, wont run the game.

Flupper commented 3 years ago

Never mind, looks a RetroArch issue, standalone SDL2 version runs the game.

ekeeke commented 3 years ago

Fixed in https://github.com/ekeeke/Genesis-Plus-GX/commit/e6ab7563e7cfb4e18c29e557d36e59cc51e83815

ekeeke commented 3 years ago

@Flupper : additional changes to libretro Makefile are required to increase maximal ROM size (the current limit is 10MB while that new released game is 15MB I think).

Note that I might finallly increase the limit in loadrom.h instead as it is only a 5MB increment and would probably still fit on platforms with limited RAM (still need to check Gamecube standalone port to be sure).

Flupper commented 3 years ago

Aah, I see. I made a small edit to loadrom.h, that makes the game run.

define MAXROMSIZE 16777216

ner00 commented 3 years ago

Note that I might finallly increase the limit in loadrom.h instead as it is only a 5MB increment and would probably still fit on platforms with limited RAM (still need to check Gamecube standalone port to be sure).

Can we reopen this issue and hold a little while longer to track the status of support for larger ROM size? I want to follow the development of Genesis Plus GX in this context. Is there a better way to do that? Github's 'watch' functionality doesn't seem to allow me to get notified on every commit. Besides, this way we could just reply when there is a conclusive answer to the subject of how large ROMs will be handled.

ekeeke commented 3 years ago

No need to reopen this issue as this is a different matter, I will post in the libretro repository initial PR when I am done with this.

I tested the Gamecube standalone port (in Dolphin) and can confirm there is not enough RAM available when MAXROMSIZE is increased to 15MB so it will need to be increased in Makefiles per platform as initially indicated. It seems to works fine in Wii standalone port with a few changes to memory allocation order as there is ~52MB more available for Wii homebrew but I still need to confirm on real hardware with loaded CD games before commiting a Makefile change.

As for libretro Makefile change, I think it would be safe to redefine MAXROMSIZE to max possible value for SSF mapper (32MB) in Windows and Linux ports then leave the rest up to libretro team as they would be more knowledgeable about each other supported platform specific RAM constraints.

L10N37 commented 2 years ago

is this game fixed yet? I can't play it on OG hardware , my FPGA mega SG or retroarch on a modded PS3...

ner00 commented 2 years ago

is this game fixed yet? I can't play it on OG hardware , my FPGA mega SG or retroarch on a modded PS3...

Yes, since late August, in RetroArch, but I think only these systems have been fixed: macOS, Windows, Linux (maybe Android?)

Apparently it's a lack of resources in other systems, read here: https://github.com/libretro/Genesis-Plus-GX/issues/258#issuecomment-943287956

Related code: https://github.com/ekeeke/Genesis-Plus-GX/commit/4e3ca297abccc9a2a51369f905fb8283c8419388

L10N37 commented 2 years ago

thanks. I had to try 3 or 4 versions on PS3 to find one that was stable and acceptable. it doesn't even exist on the official page so I guess I'm out of luck.

ner00 commented 2 years ago

Basically any system with the increased MAXROMSIZE at 16M or above: https://github.com/ekeeke/Genesis-Plus-GX/blob/master/Makefile.libretro

The PS3 is not included; mega Sg and OG system seem to support with an EverDrive Pro.

L10N37 commented 2 years ago

yeah these are like 500 bucks on Amazon ... It was a 30 buck game lol..

ner00 commented 2 years ago

$200, but I get your point.

L10N37 commented 2 years ago

283AUD atm. I'd love one but not just to play this. I was never into any Sega CD stuff.. I have regular everdrives.