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

Uninitialized use of local variable in bsmemory.cpp #277

Open
CasualPokePlayer opened this issue Mar 22, 2023 · 2 comments
Open

Uninitialized use of local variable in bsmemory.cpp #277

CasualPokePlayer opened this issue Mar 22, 2023 · 2 comments

Comments

@CasualPokePlayer
Copy link

for(uint6 id : range(block.count())) {
uint8 address;
address += (id >> 0 & 3) * 0x08; //verified for LH28F800SUT-ZI
address += (id >> 2 & 3) * 0x40; //verified for LH28F800SUT-ZI
address += (id >> 4 & 1) * 0x20; //guessed for LH28F016SU
address += (id >> 5 & 1) * 0x04; //guessed for LH28F032SU; will overwrite unknown constants
uint32 erased = 1 << 31 | block(id).erased; //unknown if d31 is set when erased == 0
for(uint2 byte : range(4)) {
page.write(address + byte, erased >> byte * 8); //little endian
}
}

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).

@CasualPokePlayer CasualPokePlayer changed the title Uninitialized use of local variable Uninitialized use of local variable in bsmemory.cpp Mar 22, 2023
@Screwtapello
Copy link
Contributor

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
Copy link

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?

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