-
-
Notifications
You must be signed in to change notification settings - Fork 119
Add support for sending GameID information to MemCardPRO GC #51
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
Open
Arrghus8
wants to merge
21
commits into
wiidev:enhanced
Choose a base branch
from
Arrghus8:enhanced
base: enhanced
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 13 commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
f4641ca
Add MemCardPro GameID support (using Swiss implementation)
jllottes d39bf64
Added "Off"/"Full ID"/"Short ID" options.
jllottes b3bbe92
Update README.md
Arrghus8 0e03757
Added "Off"/"Full ID"/"Short ID" options.
jllottes c8f1816
Replace spaces with tabs. Add Swiss copyright information to `MemCard…
jllottes fd79549
Replace spaces with tabs. Add Swiss copyright information to `MemCard…
jllottes 2751853
Replace spaces with tabs. Add Swiss copyright information to `MemCard…
jllottes 10539bb
Replace spaces with tabs. Add Swiss copyright information to `MemCard…
jllottes badf8c8
Send GameID information within `BootDevolution`, `BootNintendont`, an…
jllottes 2aeb648
Send GameID information within `BootDevolution`, `BootNintendont`, an…
jllottes 394fdea
Cleaning up, send GameID with (c)MIOS, fix `BootDIOSMIOS` GameID
jllottes 2b4a0b8
Cleaning up, send GameID with (c)MIOS, fix `BootDIOSMIOS` GameID
jllottes 2f8efe8
Cleaning up, send GameID with (c)MIOS, fix `BootDIOSMIOS` GameID
jllottes a82bc3c
Move "MemCardPro GameID" setting above "GameCube Mode" setting.
jllottes d6f41b6
Move "MemCardPro GameID" setting above "GameCube Mode" setting.
jllottes 830f876
Move "MemCardPro GameID" setting above "GameCube Mode" setting.
jllottes 468bf0c
Change setting name "MemCardPro GameID" -> "MemCard PRO Game ID"
jllottes 17eca89
Change setting name "MemCard PRO Game ID" -> "MemCard PRO GameID"
jllottes 7076bdc
Change setting name "MemCard PRO GameID" -> "MemCard PRO"
jllottes b1dfe4c
Move "MemCard PRO" setting below "GameCube Mode" in `LoaderSettings.cpp`
jllottes ed0959a
Fix incompability with MemCard PRO GC firmware 3.x.x
jllottes File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,142 @@ | ||
| /* | ||
| * Copyright (c) 2022, Extrems <extrems@extremscorner.org> | ||
| * | ||
| * This file is part of Swiss. | ||
| * | ||
| * Swiss is free software: you can redistribute it and/or modify | ||
| * it under the terms of the GNU General Public License as published by | ||
| * the Free Software Foundation; either version 2 of the License, or | ||
| * (at your option) any later version. | ||
| * | ||
| * Swiss is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| * GNU General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU General Public License | ||
| * with Swiss. If not, see <https://www.gnu.org/licenses/>. | ||
| */ | ||
|
|
||
| /* | ||
| * Lightly modified from Swiss, mcp.c | ||
| */ | ||
|
|
||
| #include <stdbool.h> | ||
| #include <string.h> | ||
| #include <ogc/card.h> | ||
| #include <ogc/exi.h> | ||
| #include "usbloader/disc.h" | ||
| #include "MemCardPro.h" | ||
|
|
||
| static const char digits[] = "0123456789ABCDEF"; | ||
|
|
||
| s32 MCP_ProbeEx(s32 chan) | ||
| { | ||
| return CARD_ProbeEx(chan, NULL, NULL); | ||
| } | ||
|
|
||
| s32 MCP_GetDeviceID(s32 chan, u32 *id) | ||
| { | ||
| bool err = false; | ||
| u8 cmd[2]; | ||
|
|
||
| if (!EXI_Lock(chan, EXI_DEVICE_0, NULL)) return MCP_RESULT_BUSY; | ||
| if (!EXI_Select(chan, EXI_DEVICE_0, EXI_SPEED16MHZ)) { | ||
| EXI_Unlock(chan); | ||
| return MCP_RESULT_NOCARD; | ||
| } | ||
|
|
||
| cmd[0] = 0x8B; | ||
| cmd[1] = 0x00; | ||
|
|
||
| err |= !EXI_Imm(chan, cmd, 2, EXI_WRITE, NULL); | ||
| err |= !EXI_Sync(chan); | ||
| err |= !EXI_Imm(chan, id, 4, EXI_READ, NULL); | ||
| err |= !EXI_Sync(chan); | ||
| err |= !EXI_Deselect(chan); | ||
| EXI_Unlock(chan); | ||
|
|
||
| if (err) | ||
| return MCP_RESULT_NOCARD; | ||
| else if (*id >> 16 != 0x3842) | ||
| return MCP_RESULT_WRONGDEVICE; | ||
| else | ||
| return MCP_RESULT_READY; | ||
| } | ||
|
|
||
| s32 MCP_SetDiskID(s32 chan, const dvddiskid *diskID, bool shortID) | ||
| { | ||
| bool err = false; | ||
| u8 cmd[12]; | ||
|
|
||
| if (!EXI_Lock(chan, EXI_DEVICE_0, NULL)) return MCP_RESULT_BUSY; | ||
| if (!EXI_Select(chan, EXI_DEVICE_0, EXI_SPEED16MHZ)) { | ||
| EXI_Unlock(chan); | ||
| return MCP_RESULT_NOCARD; | ||
| } | ||
|
|
||
| memset(cmd, 0, sizeof(cmd)); | ||
| cmd[0] = 0x8B; | ||
| cmd[1] = 0x11; | ||
|
|
||
| if (diskID) { | ||
| memcpy(&cmd[2], diskID->gamename, 4); | ||
| if (!shortID){ | ||
| memcpy(&cmd[6], diskID->company, 2); | ||
| cmd[8] = digits[diskID->disknum / 16]; | ||
| cmd[9] = digits[diskID->disknum % 16]; | ||
| cmd[10] = digits[diskID->gamever / 16]; | ||
| cmd[11] = digits[diskID->gamever % 16]; | ||
| } | ||
| } | ||
|
|
||
| err |= !EXI_ImmEx(chan, cmd, sizeof(cmd), EXI_WRITE); | ||
| err |= !EXI_Deselect(chan); | ||
| EXI_Unlock(chan); | ||
|
|
||
| return err ? MCP_RESULT_NOCARD : MCP_RESULT_READY; | ||
| } | ||
|
|
||
| s32 MCP_SetDiskInfo(s32 chan, const char diskInfo[64]) | ||
| { | ||
| bool err = false; | ||
| u8 cmd[2]; | ||
|
|
||
| if (!EXI_Lock(chan, EXI_DEVICE_0, NULL)) return MCP_RESULT_BUSY; | ||
| if (!EXI_Select(chan, EXI_DEVICE_0, EXI_SPEED16MHZ)) { | ||
| EXI_Unlock(chan); | ||
| return MCP_RESULT_NOCARD; | ||
| } | ||
|
|
||
| cmd[0] = 0x8B; | ||
| cmd[1] = 0x13; | ||
|
|
||
| err |= !EXI_Imm(chan, cmd, 2, EXI_WRITE, NULL); | ||
| err |= !EXI_Sync(chan); | ||
| err |= !EXI_ImmEx(chan, (char *)diskInfo, 64, EXI_WRITE); | ||
| err |= !EXI_Deselect(chan); | ||
| EXI_Unlock(chan); | ||
|
|
||
| return err ? MCP_RESULT_NOCARD : MCP_RESULT_READY; | ||
| } | ||
|
|
||
| /* | ||
| * Lightly modified from Swiss, gameid.c | ||
| */ | ||
|
|
||
| void gameID_early_set(const discHdr *header, bool shortID) | ||
| { | ||
| for (s32 chan = 0; chan < 2; chan++) { | ||
| u32 id; | ||
| s32 ret; | ||
|
|
||
| while ((ret = MCP_ProbeEx(chan)) == MCP_RESULT_BUSY); | ||
| if (ret < 0) continue; | ||
| while ((ret = MCP_GetDeviceID(chan, &id)) == MCP_RESULT_BUSY); | ||
| if (ret < 0) continue; | ||
| while ((ret = MCP_SetDiskID(chan, (dvddiskid *)header, shortID)) == MCP_RESULT_BUSY); | ||
| if (ret < 0) continue; | ||
| while ((ret = MCP_SetDiskInfo(chan, header->title)) == MCP_RESULT_BUSY); | ||
| if (ret < 0) continue; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| /* | ||
| * Copyright (c) 2022, Extrems <extrems@extremscorner.org> | ||
| * | ||
| * This file is part of Swiss. | ||
| * | ||
| * Swiss is free software: you can redistribute it and/or modify | ||
| * it under the terms of the GNU General Public License as published by | ||
| * the Free Software Foundation; either version 2 of the License, or | ||
| * (at your option) any later version. | ||
| * | ||
| * Swiss is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| * GNU General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU General Public License | ||
| * with Swiss. If not, see <https://www.gnu.org/licenses/>. | ||
| */ | ||
|
|
||
| /* | ||
| * Lightly modified from Swiss, mcp.h | ||
| */ | ||
|
|
||
| #ifndef __MCP_H__ | ||
| #define __MCP_H__ | ||
|
|
||
| #include <gctypes.h> | ||
| #include <ogc/dvd.h> | ||
| #include "usbloader/disc.h" | ||
|
|
||
| #define MCP_RESULT_READY 0 | ||
| #define MCP_RESULT_BUSY -1 | ||
| #define MCP_RESULT_WRONGDEVICE -2 | ||
| #define MCP_RESULT_NOCARD -3 | ||
| #define MCP_RESULT_FATAL_ERROR -128 | ||
|
|
||
| #ifdef __cplusplus | ||
| extern "C" { | ||
| #endif | ||
|
|
||
| s32 MCP_ProbeEx(s32 chan); | ||
| s32 MCP_GetDeviceID(s32 chan, u32 *id); | ||
| s32 MCP_SetDiskID(s32 chan, const dvddiskid *diskID, bool shortID); | ||
| s32 MCP_SetDiskInfo(s32 chan, const char diskInfo[64]); | ||
| void gameID_early_set(const discHdr *header, bool shortID); | ||
|
|
||
| #ifdef __cplusplus | ||
| } | ||
| #endif | ||
|
|
||
| #endif |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.