size_t num_chunks = file_size / region->chunk_size;
for (size_t i = 0; i < num_chunks; i++)
{
/*
* We have to check bounds because LoadROMs() may attempt to load
* regions whose size was computed incorrectly because a file was
* missing.
*
* It is also possible for ROM memory not to have been allocated at
* all in such a case, hence the check for that.
*/
size_t dest_offset = file->offset + i * region->stride;
size_t src_offset = i * region->chunk_size;
size_t bytes_to_copy = region->chunk_size;
if ((dest_offset + bytes_to_copy) > rom->size || (src_offset + bytes_to_copy) > file_size)
{
ErrorLog("ROM region '%s' could not be created or loaded.", region->region_name.c_str());
error |= true;
break;
}
if (!rom->data.get() || !tmp.get())
{
ErrorLog("ROM region '%s' could not be created or loaded.", region->region_name.c_str());
error |= true;
break;
}
CopyBytes(rom->data.get(), dest_offset, tmp.get(), src_offset, region->chunk_size, region->byte_swap);
}
Ian wrote:Bart, if you are updating the code again can you optimise the loading code? Or specifically this
- Code: Select all
size_t num_chunks = file_size / region->chunk_size;
for (size_t i = 0; i < num_chunks; i++)
{
/*
* We have to check bounds because LoadROMs() may attempt to load
* regions whose size was computed incorrectly because a file was
* missing.
*
* It is also possible for ROM memory not to have been allocated at
* all in such a case, hence the check for that.
*/
size_t dest_offset = file->offset + i * region->stride;
size_t src_offset = i * region->chunk_size;
size_t bytes_to_copy = region->chunk_size;
if ((dest_offset + bytes_to_copy) > rom->size || (src_offset + bytes_to_copy) > file_size)
{
ErrorLog("ROM region '%s' could not be created or loaded.", region->region_name.c_str());
error |= true;
break;
}
if (!rom->data.get() || !tmp.get())
{
ErrorLog("ROM region '%s' could not be created or loaded.", region->region_name.c_str());
error |= true;
break;
}
CopyBytes(rom->data.get(), dest_offset, tmp.get(), src_offset, region->chunk_size, region->byte_swap);
}
It's still slow as hell in debug mode. By slow I mean it takes 40 seconds to load a rom, which for testing is really nightmarish.
If stride = 1, surely you can just copy the whole thing with 1 memcpy
if (!rom->data.get() || !tmp.get()) you can pull out of the loop.
I'd also cache these
rom->data.get()
As in debug mode it'll literally call a function every time to get the pointer.
CiroConsentino wrote:Good to see an official games database. My frontend Emu Loader supports Supermodel emulator but I had to create a .xml file with Supermod3l games and I always have to update it for new emulator builds.
When games.xml is more complete and with a final layout, I'll add support for it in my frontend.
Games defined in Config/Games.xml:
ROM Set Title
------- -----
bass Sega Bass Fishing (Japan)
bassdx Sega Bass Fishing Deluxe (Japan)
dayto2pe Daytona USA 2 - Power Edition
daytona2 Daytona USA 2 - Battle on the Edge (Revision A)
dirtdvls Dirt Devils (Export, Revision A)
dirtdvlsa Dirt Devils (Australia, Revision A)
eca Emergency Call Ambulance (Export)
ecap Emergency Call Ambulance (US location test?)
ecau Emergency Call Ambulance (USA)
fvipers2 Fighting Vipers 2 (Japan, Revision A)
getbass Get Bass
harley Harley-Davidson and L.A. Riders (Revision B)
harleya Harley-Davidson and L.A. Riders (Revision A)
lamachin L.A. Machineguns: Rise of the Machines (Japan)
lemans24 Le Mans 24 (Revision B)
lostwsga The Lost World (Japan, Revision A)
magtruck Magical Truck Adventure (Japan)
oceanhun The Ocean Hunter
scud Scud Race Twin (Australia)
scuda Scud Race Twin (Export)
scudj Scud Race Deluxe (Japan)
scudplus Scud Race Plus (Revision A)
scudplusa Scud Race Plus
skichamp Ski Champ (Japan)
spikeofe Spikeout Final Edition
spikeout Spikeout (Revision C)
srally2 Sega Rally 2
srally2x Sega Rally 2 DX
swtrilgy Star Wars Trilogy (Revision A)
swtrilgya Star Wars Trilogy
vf3 Virtua Fighter 3 (Revision D)
vf3a Virtua Fighter 3 (Revision A)
vf3c Virtua Fighter 3 (Revision C)
vf3tb Virtua Fighter 3 Team Battle
von2 Virtual On 2: Oratorio Tangram (Revision B)
von254g Virtual On 2: Oratorio Tangram (Ver 5.4g)
von2a Virtual On 2: Oratorio Tangram (Revision A)
vs2 Virtua Striker 2 (Step 2.0)
vs215 Virtua Striker 2 (Step 1.5)
vs215o Virtua Striker 2 (Step 1.5, older)
vs298 Virtua Striker 2 '98 (Step 2.0)
vs29815 Virtua Striker 2 '98 (Step 1.5)
vs299 Virtua Striker 2 '99
vs29915 Virtua Striker 2 '99 (Step 1.5)
vs299a Virtua Striker 2 '99 (Revision A)
vs299b Virtua Striker 2 '99 (Revision B)
vs2v991 Virtua Striker 2 '99.1 (Revision B)
Users browsing this forum: No registered users and 1 guest