Indeed you can! Here is some dodgy Lua code testing the notoriously unreliable sprite overflow flag.
I got you bro =)
Moderator: Moderators
Indeed you can! Here is some dodgy Lua code testing the notoriously unreliable sprite overflow flag.
Wouldn't that script also cause the VBLANK flag to get immediately cleared, or does emu.read(<addr>, 256) prevent side effects?Controllerhead wrote: ↑Thu Sep 03, 2020 3:55 pm Here is some dodgy Lua code testing the notoriously unreliable sprite overflow flag.
Yes 256 is code for a "cpuDebug" read. No side effects. I am just reading the emulated value as opposed to a hardware style read.
I could. That would be slower than what i'm doing currently... But, if you wanted exact pixel accuracy on when spriteOverflow fires instead of scanline accuracy, that would be the way to go.
Awesome!
No. Sorry =(
No worries. Well, I'm not sure how I'd go about that myself as I've never coded any LUA script before, but I can try.Controllerhead wrote: ↑Mon Oct 05, 2020 11:48 pm No. Sorry =(
I am using the Mesen specific Lua API to make that script work. I have never used bizhawk. The code is only 30 lines long though; it might be possible to port? You can check to see if there are similar API functions in Bizhawk. You're on your own for that.
Next time, instead of just writing "@" just quote/tag names in your post. I didn't see this until a month later.
Good luck!
It only detects what scanline the sprite overflow flag was set and draws it. The flag itself is prone to failure. In fact, it can trigger when there are exactly 8 sprites, and fail in other cases. The wiki describes this.
No, sorry =(Nix wrote: ↑Tue Oct 06, 2020 11:41 am Can you make another LUA (for Mesen) specifically for detecting masking effects? I mean like those used in games like Simon's Quest, Zelda 1, Gimmick and such. This would help me finding more games that make use of this particular quirk (for documentation purposes).
To give an idea on how to code this script, looking into the Mesen code below might help:
https://github.com/SourMesen/Mesen/comm ... 1ae818464c
Nesdev Wiki Sprite overflow games - Use of excess sprites for masking effectsKitty_Space_Program wrote: ↑Wed Oct 07, 2020 7:01 am What games use that? I’m kinda curious to see how it looks.
Nix wrote: ↑Tue Oct 06, 2020 11:41 am Can you make another LUA (for Mesen) specifically for detecting masking effects? [...]
To give an idea on how to code this script, looking into the Mesen code below might help:
https://github.com/SourMesen/Mesen/comm ... 1ae818464c
For clarity, here is the most recent version of that code: Mesen github PPU.cpp - LoadExtraSprites(). This code appears to implement Mesen's first two "Advanced Video" options:Controllerhead wrote: ↑Tue Oct 06, 2020 12:18 pm Thanks for the example, but, I have no idea what this code is doing. I have no idea how you would even do that.
Remove sprite limit: The NES can normally only draw up to 8 sprites per line – this limitation is indirectly responsible for some of the flickering seen in games at times. When this option is enabled, the limit is disabled, allowing up to 64 sprites to be drawn on the same line.
Automatically re-enable sprite limit as needed to prevent graphical glitches when possible: Some games rely on the sprite limit to hide objects from view. These games will have graphical glitches when the Remove sprite limit option is enabled. By enabling this option, Mesen will try to detect when games are attempting to hit the sprite limit on purpose and temporarely re-enable the limit in these specific cases. This option is not perfect and may not work in certain games, but it helps reduce the potential negative impacts of the Remove sprite limit option.
Games will place 8 consecutive sprites with the same Y coordinate and same tile number. If you see this, then that is a sign that the game is using a masking effect, and the 8-sprite limit should be enforced for that area.However, Mesen appears to not care about the tile number but does care about the X coordinate. That is, reading over the code above, Mesen appears to be detecting intentional masking as follows:
Out of the sprites that have tile boxes on this scanline, if there are 8 or more consecutive sprites with the same Y coordinate and the same X coordinate, then the masking is intentional.