Major code change pushed

Technical discussion for those interested in Supermodel development and Model 3 reverse engineering. Prospective contributors welcome.
Forum rules
Keep it classy!

  • No ROM requests or links.
  • Do not ask to be a play tester.
  • Do not ask about release dates.
  • No drama!

Re: Major code change pushed

Postby Ian » Sun Apr 02, 2017 3:58 am

Bart, I hate to be that guy. But even with your new code I get the same debug assertion in visual studio
Ian
 
Posts: 1220
Joined: Tue Feb 23, 2016 9:23 am

Re: Major code change pushed

Postby Bart » Sun Apr 02, 2017 8:56 am

Aaaaaaargh!

It's ok. I got it :) I'll just include a custom UnorderedSetDifference() function. I've been rewriting a big chunk of the ROM loading once more, so I expect to commit that today.
User avatar
Bart
Site Admin
 
Posts: 2058
Joined: Thu Sep 01, 2011 2:13 pm
Location: New York City

Re: Major code change pushed

Postby Ian » Sun Apr 02, 2017 12:51 pm

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.
Ian
 
Posts: 1220
Joined: Tue Feb 23, 2016 9:23 am

Re: Major code change pushed

Postby CiroConsentino » Sun Apr 02, 2017 5:39 pm

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.
CiroConsentino
 
Posts: 19
Joined: Sun Sep 25, 2011 4:50 am
Location: Brazil

Re: Major code change pushed

Postby Bart » Sun Apr 02, 2017 6:05 pm

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.


Done. Let me know how it looks for you now. I also rewrote a ton of the code again. I think now I'm pretty happy with how it handles merged ROMs. You should be able to combine ROM files in all kinds of whacky ways and it will behave in a mostly sensible manner (in terms of error reporting and so forth). I removed those checks above as I don't think they are important anymore now that I pre-merge the ROM set definitions. But let me know if you ever encounter a crash or unexpected ROM loading behavior.
User avatar
Bart
Site Admin
 
Posts: 2058
Joined: Thu Sep 01, 2011 2:13 pm
Location: New York City

Re: Major code change pushed

Postby Bart » Sun Apr 02, 2017 6:06 pm

Let me know if set_difference() is working now. Turns out that although I was building sorted vectors, I was forgetting to pass them to the function. D'oh! Should work now. If it still fails, I have an UnorderedSetDifference() function ready to plug in.
User avatar
Bart
Site Admin
 
Posts: 2058
Joined: Thu Sep 01, 2011 2:13 pm
Location: New York City

Re: Major code change pushed

Postby Bart » Sun Apr 02, 2017 6:07 pm

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.


Nice! But yeah, let's wait at least a couple more weeks if that's okay with you. I should have Games.xml mostly finished in the next couple of days (I'm very close, I just have to add Virtua Striker 2 -- *groaaan*). I'd like people in the forum to start testing to see if it all makes sense. I think it's doing the right thing with regards to ROM sets.
User avatar
Bart
Site Admin
 
Posts: 2058
Joined: Thu Sep 01, 2011 2:13 pm
Location: New York City

Re: Major code change pushed

Postby Ian » Mon Apr 03, 2017 1:37 am

Bart,
no more debug assert, loads in half the time :)
Ian
 
Posts: 1220
Joined: Tue Feb 23, 2016 9:23 am

Re: Major code change pushed

Postby Ian » Mon Apr 03, 2017 5:06 am

Okay it now loads 300% quicker :)
From yesterday it took 40~ seconds to load, now it's about 5 :)
Ian
 
Posts: 1220
Joined: Tue Feb 23, 2016 9:23 am

Re: Major code change pushed

Postby HarryTuttle » Tue Apr 04, 2017 4:50 am

Bart, Ian, I saw some people in other forum posted an updated version of "Games.xml". I've rewritten most of it aligning to current MAME romsets.

There're lots of roms & sets renaming and also some set added. I fixed also 2nd player controls in some games, added driveboard controller in some Scud set, and added the placeholder for Get Bass I/O controller and SW Trilogy force feedback controller (both not emulated).

I've also stripped the variant indication from the "title" node and put that in the appropriate "version" node and, accordingly, changed <Main.cpp> and <Model3.cpp> to chain them again when displaying to the console the game info or printing the list of supported games. If you want to revert this last behavior I'll rewrite the Games.xml and merge again the "version" in the "title" definition.

This is the complete list:
Code: Select all
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)

So if you have MAME roms, now you can point to them directly and play.

UPDATE:
I've re-uploaded the patch with updated <Model3.cpp> to deal with some new romset names in rom patching section.
Attachments
patch.zip
(16.24 KiB) Downloaded 47 times
Last edited by HarryTuttle on Tue Apr 04, 2017 5:19 am, edited 1 time in total.
User avatar
HarryTuttle
 
Posts: 558
Joined: Thu Mar 09, 2017 8:57 am

PreviousNext

Return to The Dark Room

Who is online

Users browsing this forum: No registered users and 2 guests