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

Green swap support #235

Open
GValiente opened this issue Dec 30, 2023 · 15 comments
Open

Green swap support #235

GValiente opened this issue Dec 30, 2023 · 15 comments

Comments

@GValiente
Copy link

Thanks for your work on this core, compatibility is much better than I expected!
Most of Butano games and examples work without issues.

Would it be too hard to add support for the green swap effect?
I know that it's a niche thing and no commercial games used it, but it would be cool to see it on this core too.

Here's a test ROM and a couple of screenshots:
Test ROM

green_swap-0 green_swap-1

@andymcca
Copy link

Ah - is that the undocumented mode in DISPCNT? Not sure how hard that would be to implement - can't speak for David but I might have a look at some point out of curiosity - although ultimately it's probably a bit far down the priority list given there's still issues with commercial games to resolve! Will keep you updated here tho.

@davidgfnet
Copy link
Collaborator

Yeah I am aware of this bit, however since no commercial games used it I did not bother :D
Do homebrew games use this often? I'm curious what's the usecase. Is it to "mimic" some sort of mosaic effect?
We have been fixing many bugs related to new homebrew (for instance Good Boy has uncovered a bunch of bugs) so any bugs and/or fixes are welcome!

@GValiente
Copy link
Author

I use it quite a bit, usually to mimic a short full screen blur:

  • Butano Fighter shows it when the MC is hit.
  • Varooom 3D shows it when the car is hit or when a turbo boost is used.
  • GBA-NICCC uses it to show the black and white antialiased mode.

@GValiente
Copy link
Author

GValiente commented Jan 13, 2024

Some pics taken with mGBA:
bf_off bf_on
v3d_off v3d_on
gba-niccc_off gba-niccc_on

@davidgfnet
Copy link
Collaborator

Cool! Will give it a look! It might require some work since gpsp tries really hard to optimize stuff like palette writes and conversion (for speed) and there's palette calculations all over the place :D
It's also a case that should be really optimized for it being disabled, since literally 99% of games dont use it.
Thanks!!

@GValiente
Copy link
Author

Isn't it just a full screen effect after the final image has been composed?

According to gbatek, green swap "appears to be applied to the final picture (ie. after mixing the separate BG and OBJ layers)."

Anyway, thanks a lot for looking at it.

@davidgfnet
Copy link
Collaborator

Ah right! For some reason I recalled it being like mosaic (with BG/OBJ bits), but it's just a full effect at the end!
Yeah we can just add some routine at the end, won't be very fast tho, but it's OK since nobody uses it.
I have some plan to rewrite some of these parts in gpsp to make it faster. We currently have color correction (which is also a full-screen effect), and we could merge some of these effects so that they don't require a full screen update at the end (and save a lot of cycles, right now video rendering is 50% of the consumed cpu cycles for the emulator).
Thanks!

@andymcca
Copy link

andymcca commented Aug 25, 2024

Hey @GValiente, I just opened draft PRs that implement Green Swap - PR #260 and PR #261. I used the mgba implementation as a guide. Looks pretty straightforward but any chance you can build and test it for me? It looks correct to me when I try the test ROM you gave in the first message but my eyes aren't what they used to be!!!

@davidgfnet I added the code to video.cc rather than in post-processing in libretro.c - as this is a native effect rather an emulation feature this seemed more correct?

@andymcca
Copy link

Screen.Recording.2024-08-25.221816.mp4

Just me pressing A at random times on your demo to toggle between AA on/off. Think it seems to be working ok?

@GValiente
Copy link
Author

There's no fake antialiasing like with mGBA:

green_swap

@andymcca
Copy link

andymcca commented Aug 26, 2024

@GValiente I think I've fixed it - needed to use RGB565 values but also a dumb error on my part with overwriting the previous pixel value before getting the next green channel to swap. Please try testing again? Thanks!

Screen.Recording.2024-08-26.143425.mp4

@GValiente
Copy link
Author

GValiente commented Aug 26, 2024

The new video looks better, yeah.

Here's a test ROM, if you want to compare it against a real GBA and other emulators: green_swap.zip

EDIT: I already posted it in the first post xD

@andymcca
Copy link

Thanks - yes I used green_swap.gba primarily to compare gpsp to mgba and Nanoboy when troubleshooting intially. The results are now pretty much identical since my latest commit to the PR.

@andymcca
Copy link

mgba
Screenshot 2024-08-31 122356

@andymcca
Copy link

andymcca commented Aug 31, 2024

gpsp (with PR #260 / PR #261)
Screenshot 2024-08-31 122614

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

No branches or pull requests

3 participants