Skip to content

Commit 46af17d

Browse files
author
Megan Leet
committed
Parse Megadrive console name for "Platform" field correctly
1 parent 0a63695 commit 46af17d

File tree

3 files changed

+37
-30
lines changed

3 files changed

+37
-30
lines changed

ROMniscience.sln

+3-3
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
1212
EndProjectSection
1313
EndProject
1414
Global
15-
GlobalSection(Performance) = preSolution
16-
HasPerformanceSessions = true
17-
EndGlobalSection
1815
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1916
Debug|Any CPU = Debug|Any CPU
2017
Release|Any CPU = Release|Any CPU
@@ -40,4 +37,7 @@ Global
4037
GlobalSection(Performance) = preSolution
4138
HasPerformanceSessions = true
4239
EndGlobalSection
40+
GlobalSection(Performance) = preSolution
41+
HasPerformanceSessions = true
42+
EndGlobalSection
4343
EndGlobal

ROMniscience/Handlers/MegaCD.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class MegaCD : CDBasedSystem {
3333
public override string name => "Mega CD";
3434

3535
public override void addROMInfo(ROMInfo info, ROMFile file, WrappedInputStream stream) {
36-
Megadrive.parseMegadriveROM(info, stream);
36+
Megadrive.parseMegadriveROM(info, stream, true);
3737
//There's also a "MAIN SEGAOS" at 0x3000 followed by what appears to be some kind of title. Does that mean anything? I don't know
3838
//Some more info:
3939
//https://forums.sonicretro.org/index.php?showtopic=30588

ROMniscience/Handlers/Megadrive.cs

+33-26
Original file line numberDiff line numberDiff line change
@@ -214,44 +214,51 @@ public static int calcChecksum(WrappedInputStream s) {
214214
}
215215
}
216216

217-
private static readonly Regex copyrightRegex = new Regex(@"\(C\)(\S{4}.)(\d{4})\.(.{3})");
218-
public static void parseMegadriveROM(ROMInfo info, WrappedInputStream s) {
219-
220-
bool isCD = "SEGADISCSYSTEM ".Equals(s.read(15, Encoding.ASCII));
221-
222-
s.Position = 0x100;
223-
224-
string consoleName = s.read(16, Encoding.ASCII).TrimEnd('\0', ' ');
225-
info.addInfo("Console name", consoleName);
226-
227-
//Is this actually the console name filed on Sega CD games? For Mega CD it definitely says "SEGA MEGA DRIVE"
228-
bool isUSA = consoleName.StartsWith("SEGA GENESIS");
229-
217+
static string getPlatformFromConsoleName(string consoleName, bool isCD) {
230218
if (consoleName.StartsWith("SEGA 32X")) {
231-
// There are a few homebrew apps (32xfire, Shymmer) and also Doom
232-
// that misuse this field and say something else, so I've used
233-
// startswith instead, which should be safe, and picks up those three
234-
// except for 32xfire which claims to be a Megadrive game (it has
235-
// "32X GAME" as the domestic and overseas name)
236-
// Some cheeky buggers just use SEGA MEGADRIVE or SEGA GENESIS anyway even when they're 32X
237-
// Note that the TMSS present in Model 2 and Mega 3 Genesis/Megadrives requires
238-
// games to have something starting with "SEGA" or " SEGA" here
239-
info.addInfo("Platform", "Sega 32X");
219+
return "Sega 32X";
220+
} else if (consoleName.Equals("SAMSUNG PICO")) {
221+
return "Samsung Pico";
222+
} else if (consoleName.Equals("SEGA PICO") || consoleName.Equals("SEGATOYS PICO") || consoleName.Equals("SEGA TOYS PICO")
223+
|| consoleName.Equals("IMA IKUNOJYUKU") || consoleName.Equals("IMA IKUNOUJYUKU")) {
224+
//I... have zero idea what those last two are about, but they're a thing in some Sega Pico titles
225+
return "Sega Pico";
240226
} else {
227+
bool isUSA = consoleName.StartsWith("SEGA GENESIS");
228+
bool isMD = consoleName.StartsWith("SEGA MEGA DRIVE") || consoleName.StartsWith("SEGA MEGADRIVE");
241229
if (isCD) {
242230
if (isUSA) {
243-
info.addInfo("Platform", "Sega CD");
231+
return "Sega CD";
232+
} else if (isMD) {
233+
return "Mega CD";
244234
} else {
245-
info.addInfo("Platform", "Mega CD");
235+
return "Sega CD/Mega CD";
246236
}
247237
} else {
248238
if (isUSA) {
249-
info.addInfo("Platform", "Sega Genesis");
239+
return "Sega Genesis";
240+
} else if (isMD) {
241+
return "Sega Mega Drive";
250242
} else {
251-
info.addInfo("Platform", "Sega Megadrive");
243+
return "Sega Genesis/Mega Drive";
252244
}
253245
}
254246
}
247+
}
248+
249+
private static readonly Regex copyrightRegex = new Regex(@"\(C\)(\S{4}.)(\d{4})\.(.{3})");
250+
public static void parseMegadriveROM(ROMInfo info, WrappedInputStream s, bool isCD = false) {
251+
s.Position = 0x100;
252+
253+
//While we're here, it should be noted that some allegedly official licensed and final don't have correct header information
254+
//of any kind, and as such you will see plain garbage all across here. Even the console name, which results in them not being
255+
//able to boot on real Model 2 and Model 3 hardware. Point at them and laugh.
256+
//These games are: Zany Golf (rev 0) and Budokan: The Martial Spirit, among others which aren't actually licensed.
257+
//Anyway, I just thought that was interesting enough to comment on. I found it fascinating. Am I just kinda weird? Oh well.
258+
259+
string consoleName = s.read(16, Encoding.ASCII).TrimEnd('\0', ' ');
260+
info.addInfo("Console name", consoleName);
261+
info.addInfo("Platform", getPlatformFromConsoleName(consoleName.TrimStart(' '), isCD));
255262

256263
string copyright = s.read(16, Encoding.ASCII).TrimEnd('\0', ' ');
257264
info.addInfo("Copyright", copyright);

0 commit comments

Comments
 (0)