Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Libretro port of Gearboy #52

Closed
anyputer opened this issue Nov 19, 2017 · 31 comments
Closed

Libretro port of Gearboy #52

anyputer opened this issue Nov 19, 2017 · 31 comments
Labels

Comments

@anyputer
Copy link
Contributor

No description provided.

@drhelius
Copy link
Owner

It's a nice idea.
Any help, info, indications or whatever are welcome 😀

@anyputer
Copy link
Contributor Author

anyputer commented Dec 9, 2017

I personally barely know anything about the actual Libretro API, but here are some important things:

Libretro API Header: https://github.com/libretro/RetroArch/blob/master/libretro-common/include/libretro.h

Libretro Website: https://www.libretro.com/

Oh and I mentioned the possibility of an Libretro port on the Libretro forums so maybe the Libretro devs can come help?
https://forums.libretro.com/t/not-yet-ported-open-source-emulators-you-want-to-see-in-retroarch/9281/70

@gouchi
Copy link

gouchi commented Dec 9, 2017

You can check some links in the develop part, libretro-samples repository for example and also on the doc.

If you have any question please come to the channel #libretro.

Thank you.

@andres-asm
Copy link
Contributor

The core seems ideal for a port except that it's quite tangled up with SDL as far as I can see.
Is it possible to remove the SDL dependency?

@andres-asm
Copy link
Contributor

retroarch_2017-12-10_12-11-44

retroarch_2017-12-10_12-09-42

After ~15 minutes

I see one problem in addition to SDL.
There is some internal throttle mechanism (which we don't need).
Is there any way to disable it?

@drhelius
Copy link
Owner

Impressive work, thanks!
Including SDL audio code inside the core was a very bad decision from the beginning due to my poor understanding of how it worked at that time.
The throttling is due to audio timing, so it should be taken out from the core.
I will be spending some time this week to refactor the audio properly.

@drhelius
Copy link
Owner

drhelius commented Dec 10, 2017

BTW, you can try disabling sound, this should disable frame synching.
void GearboyCore::EnableSound(bool enabled)

@anyputer
Copy link
Contributor Author

Already? That is very cool!

@anyputer
Copy link
Contributor Author

Since I feel like not being useless, here is the core info file:

https://1drv.ms/u/s!AvB-c2zUfIalpwhX-jGwGNgOQ7c4

The bios stuff might need to be changed. So there, I saved you ten seconds! :D

@andres-asm
Copy link
Contributor

andres-asm commented Dec 10, 2017

We got it working, with sound too.
Sound's a bit off pitch and a bit crackly but it works

@andres-asm
Copy link
Contributor

hey are these legal?
https://github.com/libretro/Gearboy/blob/master/src/boot_roms.h

Is it just the boot logo and sound?

@drhelius
Copy link
Owner

Not sure, they are from here:
http://gbdev.gg8.se/wiki/articles/Gameboy_Bootstrap_ROM
Can be removed if there is any problem though, doesn't add too much

@andres-asm
Copy link
Contributor

Seems they are ripped from the original hardware, you shouldn't include that.
I don't expect anything to happen from that but it's better to play safe.

@drhelius
Copy link
Owner

I just made a refactor to remove any reference to SDL inside the core.
I also removed the boot roms and fixed sound with libretro.
Now it runs pretty well, thanks for all the help.
I'm going to start working on RAM/RTC access and other features.

@anyputer
Copy link
Contributor Author

I just compiled it and it just shows a black screen... when you toggle menu, it shows something? At least the audio sounds nice!

prism-v0 94-b0223-171229-040556

Windows 64-bit .dll of the Gearboy Libretro core:
https://1drv.ms/u/s!AvB-c2zUfIalsQ6_LO-j7aGholHZ

@drhelius
Copy link
Owner

Sorry, silly mistake, it's working properly now.

@anyputer
Copy link
Contributor Author

Thank you so much! Oh, and when are we going to have core options? ( The different palettes as seen in the screenshots, for example )

@anyputer
Copy link
Contributor Author

anyputer commented Dec 30, 2017

Wait... are .gearboy files saves? Those should not be in the directory where the ROM is, but it should be in the frontend's saves folder ( For RetroArch that's RetroArch/saves, not sure about other frontends :P )
I think you should use:

#define RETRO_ENVIRONMENT_GET_SAVE_DIRECTORY 31
                                           /* const char ** --
                                            * Returns the "save" directory of the frontend.
                                            * This directory can be used to store SRAM, memory cards,
                                            * high scores, etc, if the libretro core
                                            * cannot use the regular memory interface (retro_get_memory_data()).
                                            *
                                            * NOTE: libretro cores used to check GET_SYSTEM_DIRECTORY for
                                            * similar things before.
                                            * They should still check GET_SYSTEM_DIRECTORY if they want to
                                            * be backwards compatible.
                                            * The path here can be NULL. It should only be non-NULL if the
                                            * frontend user has set a specific save path.
                                            */

It's annoying seeing .gearboy files everywhere. Unless you want standalone Gearboy to work immediately, which really only requires renaming the file from .srm to .gearboy and putting it in the right directory. This would also allow other cores to use the saves! And if you are wondering if the saves actually work in other cores... of course!

@drhelius
Copy link
Owner

Yes you're completely right. The core is very basic right now, I will be adding all this features over the next days.

@CuttleFishJones865
Copy link

Hey, one of the maintainers of libretro/docs here.

https://docs.libretro.com/library/gearboy/

Do you want the report core issues link at the bottom of the page to link to your issue tracker?

You're free to let us know if you want something changed in the doc or you can go ahead and contribute directly at the libretro/docs repository. What gets put on the doc is 100% under your control and approval.

@drhelius
Copy link
Owner

drhelius commented Jan 7, 2018

Oh, many thanks! Yes, a link to this issue tracker would be great.

@andres-asm
Copy link
Contributor

andres-asm commented Jan 24, 2018

So, let's try to get further with this:
Questions:

  • Do you have an API to access save data? We use this to save SRAM. We have used file based fallbacks as workarounds before but we prefer to be able to read/write SRAM directly

Here is the sameboy implementation:
https://github.com/libretro/SameBoy/blob/master/libretro/libretro.c#L480

  • Do you have serialization/savestate support? If so, do you have an API to get/set the data to be serialized/unserialized into a buffer? we have no support for file fallbacks on this aspect

  • Do you have rumble support? It's optional

  • Do you have an API to read/write from RAM? we use this for RetroAchievements support, it's fully optional

Again the sameboy implementation: https://github.com/libretro/SameBoy/blob/master/libretro/libretro.c#L381

With those in place we would have a more or less complete core. (I should try to fix sound though)

@drhelius
Copy link
Owner

I'm working on save states and memory access, wouldn't take me too much.

No rumble support, I can look into it.

What's the problem with sound? I thought I fixed that myself.

@andres-asm
Copy link
Contributor

Ah I haven't checked the libretro core in a while, I'll check and report back :)

@andres-asm
Copy link
Contributor

you're right, it's completely fine now

@andres-asm
Copy link
Contributor

Hey, just wondering, do you have link cable support?
Recenly hooked it up for another core :P

@drhelius
Copy link
Owner

drhelius commented Feb 4, 2018

Nope :(

@andres-asm
Copy link
Contributor

Just FYI, I updated the fork so we're up-to-date with you.
I'll try standalone to try to expose any options you may have in your frontend.

@drhelius
Copy link
Owner

drhelius commented Mar 5, 2018

Memory access is mostly finished. Retroarch can save RAM including RTC data but I can't get achievements to work.

I will be working on save states now.

I'm working on "develop" so you don't get noise until finished.

@drhelius
Copy link
Owner

drhelius commented Mar 5, 2018

Ok, made some progress using RETRO_ENVIRONMENT_SET_MEMORY_MAPS correctly, now I have some achievements 😄

@drhelius
Copy link
Owner

drhelius commented Mar 7, 2018

I've finished adding achievements, ram and rtc saves, save states, soft patching, core options and reset so I consider it complete.

I'm closing the issue now, thanks for all the help.

I'll may add cheats in the future but that's a
story for another day.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants