bsnes-emu / bsnes

bsnes is a Super Nintendo (SNES) emulator focused on performance, features, and ease of use.
Other
1.63k stars 154 forks source link

Uninitialized use of local variable in bsmemory.cpp #277

Open CasualPokePlayer opened 1 year ago

CasualPokePlayer commented 1 year ago

https://github.com/bsnes-emu/bsnes/blob/5cefce5c08f74cfc80eee3f82a32d846144e5277/bsnes/sfc/slot/bsmemory/bsmemory.cpp#L319-L329

Not sure what was the actual intent behind this. Was it so address may be "reused" each iteration? (so hoping that it starts at 0 and keeps the value of the previous iteration cycle, i.e. like if address was defined above the loop and set to 0, this appears to be what compilers output anyways?). Or was it actually meant to always start at 0 for each iteration cycle? (so a simple = 0 would give the intended behavior).

Screwtapello commented 1 year ago

That's a good question.

Searching the web for "LH28F800SUT" I found a datasheet that confirmed that 0x99 0xd0 was the sequence to request the "Upload Device Information" operation. However, the datasheet doesn't describe what it does, nor does fullsnes or this SNESdev thread where nocash and Near are talking about BS-X datapacks.

I assume Near figured it out based on actually tinkering with a data pack and figuring out what it was doing.

jeffythedragonslayer commented 1 year ago

Well, there are quite a few guesses and unknowns mentioned in the comments, so I think it's safe to conclude that it's not a mature or fully debugged piece of code.

Does any games break if you move the uint8 declaration outside the loop?