Would it be possible to mod a NES to have that "Allow more than 8 sprites per scanline" feature from emulators?

Are you new to 6502, NES, or even programming in general? Post any of your questions here. Remember - the only dumb question is the question that remains unasked.

Moderator: Moderators

User avatar
Controllerhead
Posts: 148
Joined: Tue Nov 13, 2018 4:58 am
Location: $4016
Contact:

Re: Would it be possible to mod a NES to have that "Allow more than 8 sprites per scanline" feature from emulators?

Post by Controllerhead » Thu Sep 03, 2020 3:55 pm

tokumaru wrote:
Mon Aug 31, 2020 3:50 pm
You can probably write a Lua script in emulators that support that (FCEUX, Mesen) to get that information from $2002 and present it visually somehow.
Indeed you can! Here is some dodgy Lua code testing the notoriously unreliable sprite overflow flag.

I got you bro =)

Image
Attachments
testSpriteOverflow.zip
(615 Bytes) Downloaded 9 times
Image

User avatar
Quietust
Posts: 1597
Joined: Sun Sep 19, 2004 10:59 pm
Contact:

Re: Would it be possible to mod a NES to have that "Allow more than 8 sprites per scanline" feature from emulators?

Post by Quietust » Thu Sep 03, 2020 6:51 pm

Controllerhead wrote:
Thu Sep 03, 2020 3:55 pm
Here is some dodgy Lua code testing the notoriously unreliable sprite overflow flag.

Image
Wouldn't that script also cause the VBLANK flag to get immediately cleared, or does emu.read(<addr>, 256) prevent side effects?
Quietust, QMT Productions
P.S. If you don't get this note, let me know and I'll write you another.

User avatar
Controllerhead
Posts: 148
Joined: Tue Nov 13, 2018 4:58 am
Location: $4016
Contact:

Re: Would it be possible to mod a NES to have that "Allow more than 8 sprites per scanline" feature from emulators?

Post by Controllerhead » Thu Sep 03, 2020 8:05 pm

Quietust wrote:
Thu Sep 03, 2020 6:51 pm
does emu.read(<addr>, 256) prevent side effects?
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.
https://www.mesen.ca/docs/apireference/ ... ml#memtype

I think the way that i am polling it after every instruction is dodgy AF. I can't think of a better way though. There is no event listener for internal register updates in the Lua API. CPU/PPU write event listeners for $2002 don't trigger it. There is also no eventType for spriteOverflow like there is for spriteZeroHit. Nothing else i fiddled with worked reliably... There could be a better way though.

At least i'm 100% sure that an instruction will happen before HBLANK is over every scanline ...it's a terrible solution :?
Image

Fiskbit
Posts: 153
Joined: Sat Nov 18, 2017 9:15 pm

Re: Would it be possible to mod a NES to have that "Allow more than 8 sprites per scanline" feature from emulators?

Post by Fiskbit » Thu Sep 03, 2020 9:00 pm

You could probably execute 1 PPU cycle at a time and check sprite overflow after each step using emu.execute(count, type) with type ppuCycles and count 1.

User avatar
Controllerhead
Posts: 148
Joined: Tue Nov 13, 2018 4:58 am
Location: $4016
Contact:

Re: Would it be possible to mod a NES to have that "Allow more than 8 sprites per scanline" feature from emulators?

Post by Controllerhead » Thu Sep 03, 2020 9:18 pm

Fiskbit wrote:
Thu Sep 03, 2020 9:00 pm
You could probably execute 1 PPU cycle at a time and check sprite overflow after each step using emu.execute(count, type) with type ppuCycles and count 1.
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.

Optimally it would be nice if i could just listen for a $2002 change in the API, or at the very least, sync it up to HBLANK so i could listen for spriteOverflow 240 times a frame instead of the slightly over 9000 or so instructions that probably fire. I'm sure that could be done... but it runs fine the way it is. Meh.

Anyway, i'm sure this enough of a demo to get OP moving in the right direction in his quest to discover that rendering more than 8 sprites per scanline on hardware is physically impossible. I'm happy to lend a helping hand =)
Image

Nix
Posts: 6
Joined: Wed Aug 26, 2020 12:22 pm

Re: Would it be possible to mod a NES to have that "Allow more than 8 sprites per scanline" feature from emulators?

Post by Nix » Sat Sep 12, 2020 9:00 am

@Controllerhead: I finally got around to testing the lua script you provided and it works nicely! Thanks for that.

It works fine in Mesen, but if I try to load it in BizHawk, I get this error:
"NLua.Exceptions.LuaScriptException: [string "main"]:14: unexpected symbol near '&'"

Could you possibly provide a version that works there?

Post Reply