@@ -314,9 +314,10 @@ uint32_t detect_rom_size_PCE(void) {
314
314
uint32_t rom_size;
315
315
uint8_t read_byte;
316
316
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;
318
318
319
319
// Initialize variables
320
+ detect_16 = 0 ;
320
321
detect_32 = 0 ;
321
322
detect_128 = 0 ;
322
323
detect_256 = 0 ;
@@ -326,16 +327,23 @@ uint32_t detect_rom_size_PCE(void) {
326
327
// Set pins to read PC Engine cart
327
328
pin_read_write_PCE ();
328
329
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)
330
331
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)) {
332
333
// If none matched, it is 1024KB
333
334
break ;
334
335
}
335
336
336
- // read byte for 32KB, 128KB, 256KB, 512KB detection
337
+ // read byte for 16KB, 32KB, 128KB, 256KB, 512KB detection
337
338
read_byte = read_byte_PCE (current_byte);
338
339
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
+
339
347
// 32KB detection
340
348
if (current_byte == detect_32) {
341
349
if (read_byte_PCE (current_byte + 32UL * 1024UL ) == read_byte) {
@@ -374,11 +382,13 @@ uint32_t detect_rom_size_PCE(void) {
374
382
}
375
383
376
384
// 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.
378
386
// println_Msg(fileName);
379
387
380
388
// 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) {
382
392
rom_size = 32 ;
383
393
} else if (detect_128 == DETECTION_SIZE) {
384
394
rom_size = 128 ;
@@ -408,7 +418,7 @@ uint32_t detect_rom_size_PCE(void) {
408
418
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' ) {
409
419
rom_size = 512 ;
410
420
}
411
- // Dinoforce (World )
421
+ // Dinoforce (Japan )
412
422
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' ) {
413
423
rom_size = 512 ;
414
424
}
0 commit comments