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

Data in gsflib could get slightly erased wrongly sometimes #1

Closed
loveemu opened this issue May 31, 2018 · 0 comments
Closed

Data in gsflib could get slightly erased wrongly sometimes #1

loveemu opened this issue May 31, 2018 · 0 comments
Assignees
Labels

Comments

@loveemu
Copy link
Owner

loveemu commented May 31, 2018

Summary

Gsfopt is possible to write wrong value to ROM coverage in gsflib optimization (mode -l for instance). The condition to cause the glitch might not be very common, but it might wipe the ROM data (especially a sample) quite slightly without being noticed.

How to fix : If you worry about gsflibs that you have optimized by old gsfopt, redo the gsflib optimization with unoptimized ROM, then replace your gsflib to new one.

Here I can provide a special build of gsfopt 1.2.8, which can indicate the possible ROM offset which gets erased wrongly. gsfopt-1.2.8-win32-overflow-indicator.zip

Occurrence condition

The mechanism of the glitch is simple. It's too stupid.

u8 * rom_coverage;
u8 * another_rom_coverage;

for (u32 offset = 0; offset < size; offset++) {
    if (rom_coverage[offset] + another_rom_coverage[offset] <= 0xff) {
        rom_coverage[offset] += another_rom_coverage[offset];
    } else {
        rom_coverage[offset] += 0xff; // wait, why += is placed here
    }
}

In words: the glitch occurs when the song A refers to a certain address once, and another song B refers to the same address at least 255 times.

Screenshot

I have found the glitch since gsfopt destroyed a certain instrument of Juka and the Monophonic Menace BGM 7.

Actual diff of GSF content which is destroyed by gsfopt

@loveemu loveemu added the bug label May 31, 2018
@loveemu loveemu self-assigned this May 31, 2018
loveemu added a commit that referenced this issue May 31, 2018
@loveemu loveemu changed the title Placeholder for wipe bug Data in gsflib could get slightly erased wrongly sometimes May 31, 2018
@loveemu loveemu closed this as completed May 31, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant