drhelius / Gearboy

Game Boy / Gameboy Color emulator and debugger for macOS, Windows, Linux, BSD and RetroArch.
https://x.com/drhelius
GNU General Public License v3.0
850 stars 132 forks source link

Libretro port of Gearboy #52

Closed anyputer closed 6 years ago

drhelius commented 6 years ago

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

anyputer commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

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

anyputer commented 6 years ago

Already? That is very cool!

anyputer commented 6 years ago

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 commented 6 years ago

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

andres-asm commented 6 years ago

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

Is it just the boot logo and sound?

drhelius commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

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

anyputer commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

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

CuttleFishJones865 commented 6 years ago

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 commented 6 years ago

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

andres-asm commented 6 years ago

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

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

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 commented 6 years ago

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 commented 6 years ago

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

andres-asm commented 6 years ago

you're right, it's completely fine now

andres-asm commented 6 years ago

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

drhelius commented 6 years ago

Nope :(

andres-asm commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

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

drhelius commented 6 years ago

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.