changeset 2161:6a954675d634

Improved detection of bogus device headers
author Michael Pavone <pavone@retrodev.com>
date Tue, 24 May 2022 18:49:38 -0700
parents 3f09312685e3
children 1270fe86eb89
files romdb.c
diffstat 1 files changed, 30 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/romdb.c	Tue May 24 18:31:12 2022 -0700
+++ b/romdb.c	Tue May 24 18:49:38 2022 -0700
@@ -472,12 +472,38 @@
 	info.wants_cd = 0;
 	for (uint32_t offset = 0x190; offset < rom_size && offset < 0x1A0; offset++)
 	{
-		if (rom[offset] == 'F') {
-			// probably a codemasters game with a garbage header
+		uint8_t invalid = 0;
+		switch(rom[offset])
+		{
+		case 'J':
+		case '6':
+		case '0':
+		case 'A':
+		case '4':
+		case 'G':
+		case 'L':
+		case 'M':
+		case 'B':
+		case 'K':
+		case 'R':
+		case 'D':
+			//valid device letter
+			//TODO: do something with these
 			break;
+		case 'F':
+		case 'T':
+		case 'P':
+			//unreleased peripheral, probably garbage
+			invalid = 1;
+			break;
+		case 'C':
+			info.wants_cd = 1;
+			break;
+		default:
+			invalid = 1;
 		}
-		if (rom[offset] == 'C') {
-			info.wants_cd = 1;
+		if (invalid) {
+			info.wants_cd = 0;
 			break;
 		}
 	}