| 469 | } |
| 470 | |
| 471 | static int rom_init_path(const char *filename, const char *logicalFilename) |
| 472 | { |
| 473 | int type = ROM_NDS; |
| 474 | |
| 475 | path.init(logicalFilename); |
| 476 | |
| 477 | if ( path.isdsgba(path.path)) { |
| 478 | type = ROM_DSGBA; |
| 479 | loadrom(path.path); |
| 480 | } |
| 481 | else if ( !strcasecmp(path.extension().c_str(), "nds")) { |
| 482 | type = ROM_NDS; |
| 483 | loadrom(path.path); //n.b. this does nothing if the file can't be found (i.e. if it was an extracted tempfile)... |
| 484 | //...but since the data was extracted to gameInfo then it is ok |
| 485 | } |
| 486 | //ds.gba in archives, it's already been loaded into memory at this point |
| 487 | else if (path.isdsgba(std::string(logicalFilename))) { |
| 488 | type = ROM_DSGBA; |
| 489 | } else { |
| 490 | //well, try to load it as an nds rom anyway |
| 491 | type = ROM_NDS; |
| 492 | loadrom(path.path); |
| 493 | } |
| 494 | |
| 495 | if(type == ROM_DSGBA) |
| 496 | { |
| 497 | std::vector<char> v(gameInfo.romdata + DSGBA_LOADER_SIZE, gameInfo.romdata + gameInfo.romsize); |
| 498 | gameInfo.loadData(&v[0],gameInfo.romsize - DSGBA_LOADER_SIZE); |
| 499 | } |
| 500 | |
| 501 | //check that size is at least the size of the header |
| 502 | if (gameInfo.romsize < 352) { |
| 503 | return -1; |
| 504 | } |
| 505 | |
| 506 | return 1; |
| 507 | } |
| 508 | #else |
| 509 | static int rom_init_path(const char *filename, const char *logicalFilename) |
| 510 | { |
no test coverage detected