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

ogc_card_writepage() incorrectly calculates offset after block 1024 #120

Closed
suloku opened this issue Oct 9, 2021 · 2 comments
Closed

ogc_card_writepage() incorrectly calculates offset after block 1024 #120

suloku opened this issue Oct 9, 2021 · 2 comments

Comments

@suloku
Copy link
Contributor

suloku commented Oct 9, 2021

ogc_card_writepage() will start over when the memory card has over 1024 blocks

card->cmd[1] = (card->cmd_sector_addr>>17)&0x3f;
card->cmd[2] = (card->cmd_sector_addr>>9)&0xff;
card->cmd[3] = (card->cmd_sector_addr>>7)&3;
card->cmd[4] = card->cmd_sector_addr&0x7f;

After address 0x800000 the results are the same as 0x0000, next block (0x802000) is equal to 0x2000 and so on.

This is correctly handled in ogc_card_readsegment() (haven't checked the values for more than 2048 0x2000 sector blocks though, not that there are bigger memory cards...)

card->cmd[1] = (card->cmd_sector_addr&0xFE0000)>>17;
card->cmd[2] = (card->cmd_sector_addr&0x01FE00)>>9;
card->cmd[3] = (card->cmd_sector_addr&0x000180)>>7;
card->cmd[4] = (card->cmd_sector_addr&0x00007F);

I haven't tested restoring single savegames to a memory card that is already filled further than 1023 blocks, but raw writing doesn't work unless ogc_card_writepage is updated to calculate offsets as ogc_card_readsegment()

This has been tested and seems to be working fine so far.

@WinterMute
Copy link
Member

Could you submit a PR with your fix please?

@DacoTaco
Copy link
Member

PR verified and merged

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