Prefer Gekko processor but fallback to normal PowerPC if not present.

This commit is contained in:
James Benton 2019-10-02 21:30:57 +01:00
parent dc715cfb81
commit 3eda80f7c5
2 changed files with 24 additions and 5 deletions

View File

@ -1,5 +1,6 @@
<opinions>
<constraint loader="Wii U Executable (RPX/RPL)" compilerSpecID="default">
<constraint primary="0" processor="PowerPC" endian="big" size="32" />
<constraint loader="Wii U / CafeOS Binary (RPX/RPL)" compilerSpecID="default">
<constraint primary="wiiu" processor="PowerPC" endian="big" size="32" variant="Gekko/Broadway" />
<constraint primary="wiiu" processor="PowerPC" endian="big" size="32" variant="default" />
</constraint>
</opinions>

View File

@ -28,8 +28,26 @@ public class CafeLoader extends ElfLoader {
List<LoadSpec> loadSpecs = new ArrayList<>();
if (Arrays.equals(provider.readBytes(0, header.length), header)) {
loadSpecs.add(new LoadSpec(this, 0, new LanguageCompilerSpecPair("PowerPC:BE:32:Gekko_Broadway", "default"), true));
return loadSpecs;
List<QueryResult> results = QueryOpinionService.query(getName(), "wiiu", null);
boolean hasGekkoProcessor = false;
for (QueryResult result : results) {
if (result.pair.languageID.getIdAsString().contains("Gekko")) {
hasGekkoProcessor = true;
}
}
for (QueryResult result : results) {
if (result.pair.languageID.getIdAsString().contains("Gekko")) {
loadSpecs.add(new LoadSpec(this, 0, new QueryResult(result.pair, true)));
} else {
loadSpecs.add(new LoadSpec(this, 0, new QueryResult(result.pair, hasGekkoProcessor ? false : result.preferred)));
}
}
if (loadSpecs.isEmpty()) {
loadSpecs.add(new LoadSpec(this, 0, new LanguageCompilerSpecPair("PowerPC:BE:32:default", "default"), true));
}
}
return loadSpecs;