Skip to content

Commit e4e4c7f

Browse files
authored
Update PCE.ino
Add compatibility for "Games Express CD Card (Japan) (Green Version)"
1 parent 24b7c2f commit e4e4c7f

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

Cart_Reader/PCE.ino

+17-7
Original file line numberDiff line numberDiff line change
@@ -314,9 +314,10 @@ uint32_t detect_rom_size_PCE(void) {
314314
uint32_t rom_size;
315315
uint8_t read_byte;
316316
uint8_t current_byte;
317-
uint8_t detect_32, detect_128, detect_256, detect_512, detect_768;
317+
uint8_t detect_16, detect_32, detect_128, detect_256, detect_512, detect_768;
318318

319319
//Initialize variables
320+
detect_16 = 0;
320321
detect_32 = 0;
321322
detect_128 = 0;
322323
detect_256 = 0;
@@ -326,16 +327,23 @@ uint32_t detect_rom_size_PCE(void) {
326327
//Set pins to read PC Engine cart
327328
pin_read_write_PCE();
328329

329-
//Confirm where mirror address start from (32KB, 128KB, 256KB, 512KB, 768KB, or 1024KB)
330+
//Confirm where mirror address start from (16KB, 32KB, 128KB, 256KB, 512KB, 768KB, or 1024KB)
330331
for (current_byte = 0; current_byte < DETECTION_SIZE; current_byte++) {
331-
if ((current_byte != detect_32) && (current_byte != detect_128) && (current_byte != detect_256) && (current_byte != detect_512) && (current_byte != detect_768)) {
332+
if ((current_byte != detect_16) && (current_byte != detect_32) && (current_byte != detect_128) && (current_byte != detect_256) && (current_byte != detect_512) && (current_byte != detect_768)) {
332333
//If none matched, it is 1024KB
333334
break;
334335
}
335336

336-
//read byte for 32KB, 128KB, 256KB, 512KB detection
337+
//read byte for 16KB, 32KB, 128KB, 256KB, 512KB detection
337338
read_byte = read_byte_PCE(current_byte);
338339

340+
//16KB detection
341+
if (current_byte == detect_16) {
342+
if (read_byte_PCE(current_byte + 16UL * 1024UL) == read_byte) {
343+
detect_16++;
344+
}
345+
}
346+
339347
//32KB detection
340348
if (current_byte == detect_32) {
341349
if (read_byte_PCE(current_byte + 32UL * 1024UL) == read_byte) {
@@ -374,11 +382,13 @@ uint32_t detect_rom_size_PCE(void) {
374382
}
375383

376384
//debug
377-
//sprintf(fileName, "%d %d %d %d %d", detect_32, detect_128, detect_256, detect_512, detect_768); //using filename global variable as string. Initialzed in below anyways.
385+
//sprintf(fileName, "%d %d %d %d %d %d", detect_16, detect_32, detect_128, detect_256, detect_512, detect_768); //using filename global variable as string. Initialzed in below anyways.
378386
//println_Msg(fileName);
379387

380388
//ROM size detection by result
381-
if (detect_32 == DETECTION_SIZE) {
389+
if (detect_16 == DETECTION_SIZE) {
390+
rom_size = 16;
391+
} else if (detect_32 == DETECTION_SIZE) {
382392
rom_size = 32;
383393
} else if (detect_128 == DETECTION_SIZE) {
384394
rom_size = 128;
@@ -408,7 +418,7 @@ uint32_t detect_rom_size_PCE(void) {
408418
if (read_byte_PCE(0x1F26) == 'P' && read_byte_PCE(0x1F27) == 'O' && read_byte_PCE(0x1F28) == 'P' && read_byte_PCE(0x1F29) == 'U' && read_byte_PCE(0x1F2A) == 'L' && read_byte_PCE(0x1F2B) == 'O' && read_byte_PCE(0x1F2C) == 'U' && read_byte_PCE(0x1F2D) == 'S') {
409419
rom_size = 512;
410420
}
411-
//Dinoforce (World)
421+
//Dinoforce (Japan)
412422
if (read_byte_PCE(0x15A) == 'D' && read_byte_PCE(0x15B) == 'I' && read_byte_PCE(0x15C) == 'N' && read_byte_PCE(0x15D) == 'O' && read_byte_PCE(0x15E) == '-' && read_byte_PCE(0x15F) == 'F' && read_byte_PCE(0x160) == 'O' && read_byte_PCE(0x161) == 'R' && read_byte_PCE(0x162) == 'C' && read_byte_PCE(0x163) == 'E') {
413423
rom_size = 512;
414424
}

0 commit comments

Comments
 (0)