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

Add PSX memory card support #2067

Merged
merged 1 commit into from Sep 17, 2017

Conversation

Projects
None yet
8 participants
@RedPanda4552
Contributor

RedPanda4552 commented Sep 9, 2017

The majority of code for PSX memory cards existed with a few exceptions:

  • PSX memory card creation was not possible through the emulator
  • Games could not see a PSX memory card was inserted

This PR addresses these two issues by doing the following:

  • Adds a checkbox to the memory card creation screen allowing PSX cards to be made, as well as the logic for writing the empty card. There is no regard for custom sizes or folder format cards, only the standard 128 KiB size, and file based cards.
  • Modifying the existing preprocessor based SIO interrupts to instead work based on the running game's type (PSX/PS2). This allows PS2 games to skip the delays as they were before, but for PSX games to use the delays, which are necessary for memory card interaction.

Edit: I should apologize in advance for the eyesore that is the commit history, learned about the evil that is merging from remote, and had issues that involved forking multiple times and finessing Git locally.

@lightningterror

This comment has been minimized.

Show comment
Hide comment
@lightningterror

lightningterror Sep 9, 2017

Member

My eyes ... xD
Anyway never use the Git gui for updating your fork , use Git shell.
Here is a guide how to do so.
https://gist.github.com/CristinaSolana/1885435
DON'T DO THIS ATM! Because you made changes to the master branch and not a separate branch created from master.

Next you should never make the changes on your master but branches created from master so that way you can always have pcsx2 master and your master the same without updates and be able to create separate branches that are up do date with no changes from start.

You need to squash the commits in to 1
You can do that when you have a branch selected open up git shell and type
git rebase -i master (this will open up all the commits on the branch ) but since you're working on the master branch you'd go with) git rebase -i HEAD~19
A doc will popup , all the instructions are there followed by a second doc popup.
After you're done you will see the commits merge in to 1.
Once all of that is done you type in git push -f to push the changes on github

I advice you to make a copy from the entire code changes before doing this just in case , you never know what might happen 😄

Member

lightningterror commented Sep 9, 2017

My eyes ... xD
Anyway never use the Git gui for updating your fork , use Git shell.
Here is a guide how to do so.
https://gist.github.com/CristinaSolana/1885435
DON'T DO THIS ATM! Because you made changes to the master branch and not a separate branch created from master.

Next you should never make the changes on your master but branches created from master so that way you can always have pcsx2 master and your master the same without updates and be able to create separate branches that are up do date with no changes from start.

You need to squash the commits in to 1
You can do that when you have a branch selected open up git shell and type
git rebase -i master (this will open up all the commits on the branch ) but since you're working on the master branch you'd go with) git rebase -i HEAD~19
A doc will popup , all the instructions are there followed by a second doc popup.
After you're done you will see the commits merge in to 1.
Once all of that is done you type in git push -f to push the changes on github

I advice you to make a copy from the entire code changes before doing this just in case , you never know what might happen 😄

@RedPanda4552

This comment has been minimized.

Show comment
Hide comment
@RedPanda4552

RedPanda4552 Sep 9, 2017

Contributor

The rebase is claiming merge conflicts... How critical is it I squash this?

Contributor

RedPanda4552 commented Sep 9, 2017

The rebase is claiming merge conflicts... How critical is it I squash this?

@lightningterror

This comment has been minimized.

Show comment
Hide comment
@lightningterror

lightningterror Sep 9, 2017

Member

It keeps git history clean . otherwise it will get quite messy. It will also show up on the buildbot website and pcsx2.net

Anyway I was able to rebase the last 5 so you can start with that but first you need to abort the previous rebase
git rebase --abort
git rebase -i HEAD~5

edit: forgot to mention but also discard the changes that show up as conflicts.

Member

lightningterror commented Sep 9, 2017

It keeps git history clean . otherwise it will get quite messy. It will also show up on the buildbot website and pcsx2.net

Anyway I was able to rebase the last 5 so you can start with that but first you need to abort the previous rebase
git rebase --abort
git rebase -i HEAD~5

edit: forgot to mention but also discard the changes that show up as conflicts.

@lightningterror

This comment has been minimized.

Show comment
Hide comment
@lightningterror

lightningterror Sep 9, 2017

Member

You can also drop 4b1402a/ 3088a48 , b2877d2 / 7622e58 since you reverted the changes.

Member

lightningterror commented Sep 9, 2017

You can also drop 4b1402a/ 3088a48 , b2877d2 / 7622e58 since you reverted the changes.

@lightningterror

This comment has been minimized.

Show comment
Hide comment
@lightningterror

lightningterror Sep 9, 2017

Member

My guess is the conflict was caused from the reverts. It's all good now. 👍

Double check the code just in case if all the changes are present.

Member

lightningterror commented Sep 9, 2017

My guess is the conflict was caused from the reverts. It's all good now. 👍

Double check the code just in case if all the changes are present.

@RedPanda4552

This comment has been minimized.

Show comment
Hide comment
@RedPanda4552

RedPanda4552 Sep 9, 2017

Contributor

Alright that was a final rebase there. Left out the memory card creation bit which is kind of important.

Contributor

RedPanda4552 commented Sep 9, 2017

Alright that was a final rebase there. Left out the memory card creation bit which is kind of important.

Show outdated Hide outdated pcsx2/R3000A.cpp Outdated
Show outdated Hide outdated pcsx2/R5900.cpp Outdated
Show outdated Hide outdated pcsx2/Sio.cpp Outdated

@ssakash ssakash added the PSX Mode label Sep 9, 2017

Show outdated Hide outdated pcsx2/R5900.cpp Outdated
@ramapcsx2

Might want to squash it once more when everything is done. Thanks! :)

@lightningterror

This comment has been minimized.

Show comment
Hide comment
@lightningterror

lightningterror Sep 11, 2017

Member

@AdmiralCurtiss can you also take a look at the PR?

Member

lightningterror commented Sep 11, 2017

@AdmiralCurtiss can you also take a look at the PR?

@RedPanda4552

This comment has been minimized.

Show comment
Hide comment
@RedPanda4552

RedPanda4552 Sep 15, 2017

Contributor

I found HW_ICFG = 0x1f801450 in IopHw.cpp. Searching for 0xBF801450 yields no results in the project. Dumping psxHu32(HW_ICFG) to console outputs 1 for PS2 games, and 8 for PSX games. Change that to binary and we get 0001 for PS2, 1000 for PSX. So when you said 3rd bit, if you were starting with the rightmost bit being 0th bit, then that's spot on. Though it is mildly interesting the 0th bit is changing as well from 1 to 0.

Contributor

RedPanda4552 commented Sep 15, 2017

I found HW_ICFG = 0x1f801450 in IopHw.cpp. Searching for 0xBF801450 yields no results in the project. Dumping psxHu32(HW_ICFG) to console outputs 1 for PS2 games, and 8 for PSX games. Change that to binary and we get 0001 for PS2, 1000 for PSX. So when you said 3rd bit, if you were starting with the rightmost bit being 0th bit, then that's spot on. Though it is mildly interesting the 0th bit is changing as well from 1 to 0.

@gregory38

This comment has been minimized.

Show comment
Hide comment
@gregory38

gregory38 Sep 15, 2017

Contributor

0xA00....0xBFF address space is a kernel segment of uncached memory. Bottom part of the segment is the RAM, upper part is the ROM and middle the register. The segment are 512MB.

Contributor

gregory38 commented Sep 15, 2017

0xA00....0xBFF address space is a kernel segment of uncached memory. Bottom part of the segment is the RAM, upper part is the ROM and middle the register. The segment are 512MB.

Show outdated Hide outdated pcsx2/Sio.cpp Outdated
@ramapcsx2

This comment has been minimized.

Show comment
Hide comment
@ramapcsx2

ramapcsx2 Sep 15, 2017

Member

I'm fine with merging. What's everyone else's opinion?

Member

ramapcsx2 commented Sep 15, 2017

I'm fine with merging. What's everyone else's opinion?

@MrCK1

This comment has been minimized.

Show comment
Hide comment
@MrCK1

MrCK1 Sep 15, 2017

Member

I haven't tried it, but the code looks fine to me.

Member

MrCK1 commented Sep 15, 2017

I haven't tried it, but the code looks fine to me.

@ramapcsx2

This comment has been minimized.

Show comment
Hide comment
@ramapcsx2

ramapcsx2 Sep 15, 2017

Member

I've tested it briefly:

  • It never triggers the PSX mode stuff in PS2 games.
  • It works for PSX titles. Compatibility is up, but a few games (mostly Squaresoft titles) don't work with it. They didn't work before either, so that's fine.
  • Card creation works fine. The BIOS can recognize and format a new PSX card and games accept it as well.
Member

ramapcsx2 commented Sep 15, 2017

I've tested it briefly:

  • It never triggers the PSX mode stuff in PS2 games.
  • It works for PSX titles. Compatibility is up, but a few games (mostly Squaresoft titles) don't work with it. They didn't work before either, so that's fine.
  • Card creation works fine. The BIOS can recognize and format a new PSX card and games accept it as well.
@lightningterror

This comment has been minimized.

Show comment
Hide comment
@lightningterror

lightningterror Sep 15, 2017

Member

It never triggers the PSX mode stuff in PS2 games.

Did you also test behavior with compressed and uncompressed memory cards ?

Member

lightningterror commented Sep 15, 2017

It never triggers the PSX mode stuff in PS2 games.

Did you also test behavior with compressed and uncompressed memory cards ?

@RedPanda4552

This comment has been minimized.

Show comment
Hide comment
@RedPanda4552

RedPanda4552 Sep 15, 2017

Contributor

Tested with and without NTFS compression, memory card creation, formatting, saving and loading all work without issue on Digimon World 2 and 3.

Some things that may be arbitrary but I still want to point out:

  • I'm not sure at what level NTFS compression operates, but I did not touch it in code, and cannot confirm or deny if the setting is having a tangible effect on the PSX cards because...
  • The PSX card sizes on my file system are both 128 KiB, and the save files within are identically sized for both games as well.
Contributor

RedPanda4552 commented Sep 15, 2017

Tested with and without NTFS compression, memory card creation, formatting, saving and loading all work without issue on Digimon World 2 and 3.

Some things that may be arbitrary but I still want to point out:

  • I'm not sure at what level NTFS compression operates, but I did not touch it in code, and cannot confirm or deny if the setting is having a tangible effect on the PSX cards because...
  • The PSX card sizes on my file system are both 128 KiB, and the save files within are identically sized for both games as well.
@mirh

This comment has been minimized.

Show comment
Hide comment
@mirh

mirh Sep 15, 2017

NTFS compression should be totally 100% transparent to applications.

And its size, and files inside one, being always like fixed is normal (and I guess makes for the enabling of compression in the first place)
(shower thought: is there a linux api to enable btrfs one?)

mirh commented Sep 15, 2017

NTFS compression should be totally 100% transparent to applications.

And its size, and files inside one, being always like fixed is normal (and I guess makes for the enabling of compression in the first place)
(shower thought: is there a linux api to enable btrfs one?)

@ramapcsx2 ramapcsx2 merged commit af2278c into PCSX2:master Sep 17, 2017

2 checks passed

continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@ramapcsx2

This comment has been minimized.

Show comment
Hide comment
@ramapcsx2

ramapcsx2 Sep 17, 2017

Member

Nice work, thanks! :)

Member

ramapcsx2 commented Sep 17, 2017

Nice work, thanks! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment