irixxxx / picodrive

Fast MegaDrive/MegaCD/32X emulator
Other
52 stars 24 forks source link

rg99 support #83

Closed SnDream closed 1 year ago

SnDream commented 1 year ago

Simple support for RG99, works, except for poor 32X emulation speed.

irixxxx commented 1 year ago

which toolchain and/or sdk did you use?

SnDream commented 1 year ago

toolchain-rs90 from https://github.com/OpenDingux/buildroot/actions

CROSS_COMPILE=/opt/rs90-toolchain/bin/mipsel-rs90-linux-musl- ./configure --platform=rg99
irixxxx commented 1 year ago

Just out of curiosity, what happens without the plat_video_set_size in plat_init?

SnDream commented 1 year ago

RG99 has a screen resolution of 320x480, but with non-square pixels. Opendingux needs to explicitly set the resolution to 320x240 to make the screen output similar to a normal screen.

If the code removes plat_video_set_size in plat_init, the program will handle the 320x480 resolution correctly, but expect square pixels. The result is that the output is displayed in the center, with the height squashed to half the normal (8:3).

By the way, in this case, opening the menu and then closing it restores the correct display. It seems that the initialization gets the resolution automatically based on the hardware, but once you enter the menu, it calls plat_video_set_size to force it to 320x240, and closing the menu doesn't change it back.

irixxxx commented 1 year ago

RG99 has a screen resolution of 320x480, but with non-square pixels. Opendingux needs to explicitly set the resolution to 320x240 to make the screen output similar to a normal screen.

If the code removes plat_video_set_size in plat_init, the program will handle the 320x480 resolution correctly, but expect square pixels. The result is that the output is displayed in the center, with the height squashed to half the normal (8:3).

Huh? I'd have thought Opendingux (or rather gmenu2x?) would set it up in a "normal" way with at least nearly square pixels. Is there a possibility to get the pixel aspect ratio?

By the way, in this case, opening the menu and then closing it restores the correct display. It seems that the initialization gets the resolution automatically based on the hardware, but once you enter the menu, it calls plat_video_set_size to force it to 320x240, and closing the menu doesn't change it back.

That sounds like a bug. I have modified the screen handling code to improve on window resizing within the limits of the design. That might have damaged something in your scenario. Well, the testing with the devices available to me before the next release will show if there's other fallout.

SnDream commented 1 year ago

Is there a possibility to get the pixel aspect ratio?

I don't know very much about RG99 running on OpenDingux either. Since most emulators require a lot of modifications to run on RG99, I generally hardcode the resolution. PicoDrive is one of the few emulators that runs with almost no code modifications.

That might have damaged something in your scenario.

Since RG99 is not officially supported yet, I can continue to add RG99 modifications after the fix. It would be nice to provide a function similar to game_set_size_plat to set the resolution according to the platform when entering the game screen.

irixxxx commented 1 year ago

I don't know very much about RG99 running on OpenDingux either. Since most emulators require a lot of modifications to run on RG99, I generally hardcode the resolution. PicoDrive is one of the few emulators that runs with almost no code modifications.

Historically, Picodrive has a quite good support for SDL, and I put some additional work into improving it. That makes it a lot easier to port it to more platforms having SDL support. For the same historical reasons it's however only SDL 1.2.

Since RG99 is not officially supported yet, I can continue to add RG99 modifications after the fix. It would be nice to provide a function similar to game_set_size_plat to set the resolution according to the platform when entering the game screen.

I can't probably deliver official support, since I don't have a device for pre-release testing. I'd however be willing to host builds for additional platforms by others.

irixxxx commented 1 year ago

Do you know if this would work with an rs90 as well? I can't check since I don't have neither an rs99 nor an rs90. In that case it would probably make sense to rename the target appropriately.

SnDream commented 1 year ago

The resolution of rs90 is only 240x160, which does not seem to meet the minimum resolution required to run a generic picodrive. Scaling code for rs90 is needed, which is generally maintained in a separate custom project. By the way, I personally am not interested in emulator output with less than 1x scaling, maybe I will personally customize a GameGear-only picodrive for rs90.

irixxxx commented 1 year ago

I know the screen s inferior, but doesn't the JZ IPU provide hardware scaling?

SnDream commented 1 year ago

4725B is the low-end version in the JZ series. The IPU configuration of other JZ CPUs does not seem to apply to the 4725B, although the 4725B has its own IPU mode, which I have not looked into. Most of the RS90 emulators I've seen scale through the CPU.

irixxxx commented 1 year ago

I had the idea of it being compatible because it says in the jz4725b programming manual's IPU chapter:

Image resizing − Up scaling ratios up to 1:2 in fractional steps with 1/32 accuracy − Down scaling ratios up to 32:1 in fractional steps with 1/32 accuracy

And my understanding was that opendingux is using the IPU for frame buffer scaling, so I assumed it may work right out of the box when setting the resolution to 320x240. It seems to do so on the rs99 anyway. At least it would be worth a try on the device, I guess...

SnDream commented 1 year ago

I have both RS90 and RG99 for testing. However, I am currently back in my hometown on vacation and do not have it with me, I will try it after the vacation to see if it works.

irixxxx commented 1 year ago

That sounds good, thx!

irixxxx commented 1 year ago

I changed something in the window size handling which might lead to setting the video resolution with plat_video_set_size not giving the expected results any longer. Could you please check if it still works on rg99, and, if not, change line 392 of platform/common/plat_sdl.c to "plat_sdl_change_video_mode(320, 240, 1)"?

BTW, have you found the time to check on rs90?

SnDream commented 1 year ago
  1. RG99 is working
  2. RS90 is not working. The logs are as follows:
    
    plat_sdl: using 240x160 as fullscreen resolution
    warning: video overlay is not hardware accelerated, not going to use it.
    SDL_SetVideoMode failed: Unable to set video mode.

SDL_SetVideoMode failed: Unable to set video mode.

irixxxx commented 1 year ago

OK, thx for testing, so no scaling hardware (or at least unsupported by OD) on jz4725b. Was this with the latest master? I'd have suspected it wouldn't work since set_size doesn't set the menu screen size anymore.