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

Konami (GX) blending - additive sprite blending, improved tile blending #13473

Open
wants to merge 22 commits into
base: master
Choose a base branch
from

Conversation

FredYeye
Copy link
Contributor

@FredYeye FredYeye commented Mar 13, 2025

I feel like I'm starting to amass a lot of changes so I'm opening a PR now. That, and the current changes are starting to reach a stable state! ...I hope!

The TL;DR version, games I know to be affected in parentheses:
Additive sprite blending (mmaulers)
Improved tile blending (mystwarr, viostorm, metamrph, sexyparo)


10 months ago, master Galibert sent down His holy scriptures to a certain inquisitive peasant. Since then I've spent some time on and off trying to interpret His writings, and well, I can confidently say that some of it has definitely sunk in!


File by file commentary:

k053246_k053247_k055673.cpp, k053246_k053247_k055673.h:
I went back to update zdrawgfxzoom32GP(), now down to a third of its original size before I started changing it. As a thinly veiled excuse for reworking the whole function, I went ahead and added additive sprite blending (to the now singular alpha call site).

Remarks: the mix priority setting is not yet handled. It seems simple enough (flip dst and src), but I would like to find an example of this before I implement it.

k054156_k054157_k056832.cpp:
The attr variable holds what appear to be the elusive tile (external) mix codes. Attach it to the flags variable so these bits can be accessed in the tile callback functions. Tiles with mix codes gets their own tilemap category.

Remarks: this is kind of a hacky way to get attr into the callbacks. This should at minimum be documented, or be changed. I've now changed the callback to include an attr param.

k054338.cpp:
Update set_alpha_level. This function now returns a level, an additive blend bool and a mixpri bool. Minor style changes to the overall file.

Remarks: set_alpha_level doesn't actually set anything. Maybe rename to get_alpha_level?

moo.cpp, xexex.cpp:
Mask out the new additive & mixpri bits from set_alpha_level calls for now, until it's known if / how they should be used over there.

mystwarr_v.cpp, mystwarr.h:
Remove mystwarr water hack.
Update mystwarr_tile_callback (and add viostorm_tile_callback) to read tile mix codes, store last read mix code in a new m_last_alpha_tile_mix_code variable.
Attach m_last_alpha_tile_mix_code to mixerflags, which happens to have two unused bits.

Remarks: I should document that the two last bits of mixerflags is carrying a tile mix code now. I updated the mixerflags documentation to mention the usage of the last two bits.

konamigx_v.cpp, konamigx.cpp, konamigx.h:
Shrink GX_MAX_SPRITES, which to the best of my ability seems to be oversized. There does seem to be several oversized arrays / defs in these files, so I think this is one of them.
The usual FredYeye updates to konamigx_mixer - move declarations closer to use, more suited types, rename temp vars, etc.
Change objpool to a vector, simplifying usage (push_back, size).
Replace sorting loop with reverse + stable_sort.
Improve gx_draw_basic_tilemaps - read internal / external alpha mix codes based on vinmix_on. Tiles with mixcodes get drawn in a separate pass for per-tile blending.
Update alpha_tile_callback and add salmndr2_tile_callback, same as the mystwarr_v callbacks.

Remarks: There are still some things that should be done here - alpha_tile_callback needs to be cleaned up, for example. Mostly done here now.


What started out as trying to sort out konamigx_mixer() to look at shadow/priority issues instead ended up with me finally getting a foot into the figurative tile blending door. The mystwarr water hack is gone, and sexyparo gets transparent windows. This might affect many GX and related games. Alpha blending might be broken in some games now, and needs to get their mix codes attached in their respective callbacks. salmndr2 got tagged in my automatic video comparison for differing from earlier versions, that's why I managed to fix it already.

Known problems:
metamrph: stained glass windows are near-transparent at the moment. I think additive tile blending will fix it...
viostorm: character names fade in in reverse. This also uses additive blending, so this might also get fixed once that's in.
fantjour: the top & bottom flames at the captain kebab ship go missing. Uses additive blending.


I'll mark this as a draft and go ahead and try to improve on some of the current things that are left. Thanks for coming to my ted talk.

FredYeye added 14 commits March 6, 2025 18:41
-use rectangle for dst size
-turn do-while loops into for loops
-combine zoom and no-zoom loops
-don't use negative offset and stride for source indexing
-return blending mode and priority along with the alpha level
-minor style changes to overall file
mask out mix mode and priority bits until they are handled properly
k054338.cpp: fix mixlv type
konamigx_v.cpp: pass on alpha mode and prio bits for sprite blending
-move variable declaration closer to use
-use more appropriate types, shrink GX_MAX_SPRITES
-rename some "temp" variables
rename / retype more temp vars
…its() function, scanning tiles for mixing mode bits

k053246_k053247_k055673.cpp: update comment regarding mix_pri
konamigx_v.cpp, konamigx.h: update gx_draw_basic_tilemaps(), use get_mix_bits()
mystwarr_v.cpp: remove mystwarr water hack
@galibert
Copy link
Member

Please ping me at [email protected] with an email I can reach you at.

@FredYeye
Copy link
Contributor Author

@cuavas i hope you don't mind the ping. I'd like to attempt adding additive blending for tiles. I guess what I would like to know is where I should be doing this?
Tiles are currently being drawn in k054156_k054157_k056832.cpp, function m_tilemap_draw(), by using tmap->draw(screen, bitmap, drawrect, flags, priority);. So drawing is currently being done inside tilemap.cpp. I don't know if I'm supposed to add additive blending functionality to this file, or somewhere else (k054156_k054157_k056832.cpp?). I figured it's maybe best to ask about these kinds of things...

@TheCoolPup
Copy link

did some testing and most of the graphical bugs are gone now in mystic warriors, only bugs left is this bug and a brightness issue when going to the skull tank
Mystic Warriors (ver JAA)  mystwarrj  - MAME 0 275 (LLP64) 3_17_2025 10_01_19 PM
gif-output-Tue18Mar2025021036GMT
the screen is supposed to be getting darker the closer you get

@FredYeye
Copy link
Contributor Author

Oh, yeah, you're right! It does get darker, but it doesn't seem to get dark enough? I'll have to look at it

gx_draw_basic_tilemaps:
remove GXMIX_BLEND_NONE hack (wasn't being used)
update names
simplify category 1 tile alpha check
@FredYeye
Copy link
Contributor Author

I think I'm done adding new stuff to this PR now. I've opted to add a hack for additive alpha (invert alpha value) so it looks fine until it's properly handled.

While the sexyparo castle windows are transparent now, the transparency seemingly turns off for a frame or two when picking up power ups. I need to check PCB footage to see if that's actually a thing or not, but most videos are high score videos so they don't go this route.

@FredYeye FredYeye marked this pull request as ready for review March 18, 2025 08:52
@JimCarlTay
Copy link

JimCarlTay commented Mar 18, 2025

I've just checked the latest build of this pull request and I noticed that the title screen background color change issue in Mystic Warriors (mystwarr) is now fixed.

Meanwhile, it appears certain that some mystwarr-based games still have certain graphical issues like graphical garbage up top during the character roll call in Metamorphic Force (metamrph)'s opening, as well as the Konami copyright text not appearing on the title screen of that game (compared to FinalBurn Neo), aside from an earlier bug I previously mentioned of how the blending was rendered during the Athena and animals shot still being there. There's also a severe graphical regression in Martial Champion (mtlchamp).

I'm not sure if the need to fix those is within the scope of this pull request, but are there any considerations regarding that?

And as for the stage transition effects in Violent Storm (viostorm), which were slightly broken in 0.275, do those now render correctly so MT9131 can be marked fixed once this pull request is merged?

@FredYeye
Copy link
Contributor Author

FredYeye commented Mar 18, 2025

There's also a severe graphical regression in Martial Champion (mtlchamp).

Thanks for pointing that out! I completely overlooked that one. This should preferably be fixed before a potential merge. I will turn this PR back into draft status and see if I can fix it.

I'm not sure if the need to fix those is within the scope of this pull request, but are there any considerations regarding that?

Yes, I'm at least planning to keep addressing various issues with GX (and related) games.

And as for the stage transition effects in Violent Storm (viostorm), which were slightly broken in 0.275, do those now render correctly so MT9131 can be marked fixed once this pull request is merged?

I think this is still broken. I was planning on tackling this, but managed to get tile blending working instead, heh. I will definitely revisit this issue (shadow priority problem?).

@FredYeye FredYeye marked this pull request as draft March 18, 2025 20:01
@TheCoolPup
Copy link

Bro is about to become the golden savior of konami games on mame haha
Uploading GIpr4AvW8AAUIrU.jpg…

@TheCoolPup
Copy link

tested the new build and still doesnt get as dark as it should, but still i cant be too upset considering almost everything else has been fixed

@FredYeye
Copy link
Contributor Author

Luckily, the mtlchamp regression was just due to my additive blending hack. I've updated it so the intro doesn't go black.

tested the new build and still doesnt get as dark as it should
Yeah, I haven't had time to look into this yet. I'll keep it in mind though!

@FredYeye FredYeye marked this pull request as ready for review March 18, 2025 23:26
@TheCoolPup
Copy link

yet another regression
Mystic Warriors (ver JAA)  mystwarrj  - MAME 0 275 (LLP64) 3_18_2025 9_54_03 PM

@TheCoolPup
Copy link

noticed this too
Monster Maulers (ver EAA)  mmaulers  - MAME 0 275 (LLP64) 3_18_2025 9_58_15 PM

@JimCarlTay
Copy link

JimCarlTay commented Mar 19, 2025

So, were those screenshots referring to certain stages in Mystic Warriors (mystwarr) and Monster Maulers (mmaulers) being too dark?

I was more concerned about the graphics regression in Martial Champion (mtlchamp), which was eventually fixed as of the latest PR build.

@FredYeye
Copy link
Contributor Author

yet another regression Mystic Warriors (ver JAA) mystwarrj - MAME 0 275 (LLP64) 3_18_2025 9_54_03 PM

Hmm, I can't repro this one. This part looks fine with the latest changes for me?

@TheCoolPup
Copy link

I have a feeling the background glitch might have something to do with the starting level cheat, I'll do a regular playthrough to be sure

@TheCoolPup
Copy link

And with monster maulers you can notice those lines in his power up graphic thing

@FredYeye
Copy link
Contributor Author

And with monster maulers you can notice those lines in his power up graphic thing

Yeah, this is a problem with overlapping sprites I think. The same thing happens in the metamrph intro, I'll have to think of a solution another time.

@TheCoolPup
Copy link

ok so the background image was due to the cheat
Mystic Warriors (ver JAA)  mystwarrj  - MAME 0 275 (LLP64) 3_19_2025 2_13_56 PM

@TheCoolPup
Copy link

getting here normally does not cause this issue

@TheCoolPup
Copy link

https://youtu.be/hBtjrd3qYdw also got some hd footage of the pcb for you

@TheCoolPup
Copy link

Just posted a week ago oddly enough

@TheCoolPup
Copy link

Also i noticed for a split second in the intro you can see for a split second the nametags on the screen before it transitions to the next screen so def seems to be a blending issue

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

Successfully merging this pull request may close these issues.

4 participants