REMOVING USELESS CODE (PART I):I wanted to try something new.... at least I think it's new, because in the source I have it still hasn't been done. As I learn a bit more about how this code works every time I'm looking at it, I had the idea to try something. I thought I might be able to trim the fat. It takes anywhere from 10 to 13 minutes to make a new build of MAME every time and this might make it take just a little less when it's done. Plus the code will be a lot cleaner. Let me show you an example of what I've tested and found doesn't effect the working parent at all and can potentially cut out a ton of code that is useless.
In this example, we will use Championship Sprint:
QUOTE
Found in Atarisy2.c
GAME( 1986, csprint, 0, sprint, csprint, csprint, ROT0, "Atari Games", "Championship Sprint (rev 3)" )
GAME( 1986, csprint2, csprint, sprint, csprint, csprint, ROT0, "Atari Games", "Championship Sprint (rev 2)" )
GAME( 1986, csprint1, csprint, sprint, csprint, csprint, ROT0, "Atari Games", "Championship Sprint (rev 1)" )
GAME( 1986, csprintg, csprint, sprint, csprint, csprint, ROT0, "Atari Games", "Championship Sprint (German, rev 2)" )
GAME( 1986, cspring1, csprint, sprint, csprint, csprint, ROT0, "Atari Games", "Championship Sprint (German, rev 1)" )
GAME( 1986, csprintf, csprint, sprint, csprint, csprint, ROT0, "Atari Games", "Championship Sprint (French)" )
GAME( 1986, csprints, csprint, sprint, csprint, csprint, ROT0, "Atari Games", "Championship Sprint (Spanish, rev 2)" )
GAME( 1986, csprins1, csprint, sprint, csprint, csprint, ROT0, "Atari Games", "Championship Sprint (Spanish, rev 1)" )
First, I would cut
(rev 3) from the name of it to make it look good in the GUI. But more importantly, except for the highlighted line, the rest of this code is completely unnesessary. Cut it.....
But that isn't all you have to do. This act alone will give you compile errors.
Now we get rid of every other instance of the clones in the code. First I did a search on csprint2
QUOTE
Also found in driver Atarisy2.c (This is where it tells MAME which roms to load up for the game):
ROM_START( csprint2 )
ROM_REGION( 0x90000, REGION_CPU1, 0 ) /* 9*64k for T11 code */
ROM_LOAD16_BYTE( "2126-7l.045", 0x008000, 0x004000, CRC(0ff83de8) SHA1(23f90b8f3ebd3d3bbd7a68aaecae5f45f1b477c0) )
ROM_LOAD16_BYTE( "1127-7n.045", 0x008001, 0x004000, CRC(e3e37258) SHA1(64f48c1acbb02cc8f6b76232d142382007485fb2) )
ROM_LOAD16_BYTE( "1125-6f.045", 0x010000, 0x008000, CRC(650623d2) SHA1(036cb441aba64d08f3b50f72cb22fed3b4766341) )
ROM_LOAD16_BYTE( "1122-6n.045", 0x010001, 0x008000, CRC(ca1b1cbf) SHA1(98674b75a1d38db32ceb24d57f6dba836bdc8566) )
ROM_LOAD16_BYTE( "1124-6k.045", 0x050000, 0x008000, CRC(47efca1f) SHA1(ab2fb8479c8606d8f180657734d8d320815c5408) )
ROM_LOAD16_BYTE( "1121-6r.045", 0x050001, 0x008000, CRC(6ca404bb) SHA1(27ceda243410edcff0dc0aa08fb6466d0c6c80c7) )
ROM_LOAD16_BYTE( "1123-6l.045", 0x070000, 0x008000, CRC(0a4d216a) SHA1(53a4af7673c9dae1f6f2f13dce3c38a31ee12ee2) )
ROM_LOAD16_BYTE( "1120-6s.045", 0x070001, 0x008000, CRC(103f3fde) SHA1(9a0e82c3294369858b7a6c978143d8145a8df5a2) )
ROM_REGION( 0x10000, REGION_CPU2, 0 ) /* 64k for 6502 code */
ROM_LOAD( "1118-2bc.045", 0x008000, 0x004000, CRC(eba41b2f) SHA1(a0d6e9f4609f2587b0fad6845e75653c10bf4249) )
ROM_LOAD( "1119-2d.045", 0x00c000, 0x004000, CRC(9e49043a) SHA1(ec467fe1cd59c51e43c3acd83d300f5b3309a47a) )
ROM_REGION( 0x80000, REGION_GFX1, ROMREGION_DISPOSE )
ROM_LOAD( "1105-6a.045", 0x000000, 0x008000, CRC(3773bfbb) SHA1(beca29d8b9296d723304aab391dd9589a830a150) )
ROM_LOAD( "1106-6b.045", 0x008000, 0x008000, CRC(13a24886) SHA1(a1ac9ca04a60fdb38c6d81e451e5638bdb537c8f) )
ROM_LOAD( "1101-7a.045", 0x030000, 0x008000, CRC(5a55f931) SHA1(b2f8e8f3488a9d3840ca9a15fa53896ae4013e0a) )
ROM_CONTINUE( 0x010000, 0x008000 )
ROM_LOAD( "1102-7b.045", 0x018000, 0x008000, CRC(37548a60) SHA1(f3395df534cdc75d4e1b2b415ee2cd6683e49204) )
ROM_LOAD( "1107-6c.045", 0x040000, 0x008000, CRC(e35e354e) SHA1(fa07737eb2ca19bf96ce15d8bbae7513c7dddd3c) )
ROM_LOAD( "1108-6de.045", 0x048000, 0x008000, CRC(361db8b7) SHA1(fb85e63c6e9122ab3d62eb7d0f5f715d8936910b) )
ROM_LOAD( "1104-7de.045", 0x070000, 0x008000, CRC(d1f8fe7b) SHA1(2612a397fdebe6062f66d26060c36af4a9ca28dc) )
ROM_CONTINUE( 0x050000, 0x008000 )
ROM_LOAD( "1103-7c.045", 0x058000, 0x008000, CRC(8f8c9692) SHA1(57418c5dd3554055e5bce8c2a15f6f6fc3201d99) )
ROM_REGION( 0x40000, REGION_GFX2, ROMREGION_DISPOSE | ROMREGION_INVERT )
ROM_LOAD( "1112-6l.045", 0x000000, 0x008000, CRC(f869b0fc) SHA1(d8bf0df492bbe5d228748be0976d8f68254ffb3f) )
ROM_LOAD( "1111-6k.045", 0x008000, 0x008000, CRC(abcbc114) SHA1(5d11fdfd7ed968949d884f1245571aed052abe46) )
ROM_LOAD( "1110-6hj.045", 0x010000, 0x008000, CRC(9e91e734) SHA1(d9424a46dec2885fdc1ebe973f7deebfcb6ff19e) )
ROM_LOAD( "1109-6fh.045", 0x018000, 0x008000, CRC(3a051f36) SHA1(1f74d53e1950447fd79a552d934038c4661124cf) )
ROM_LOAD( "1116-6rs.045", 0x020000, 0x008000, CRC(b15c1b90) SHA1(a3d517919fe267f30383cff4142dd0d6e1102492) )
ROM_LOAD( "1115-6pr.045", 0x028000, 0x008000, CRC(1dcdd5aa) SHA1(99eb230597132f04aa7d4d66907a14596f780365) )
ROM_LOAD( "1114-6n.045", 0x030000, 0x008000, CRC(fb5677d9) SHA1(fa3190af7eaf0ef738fd86a8280c1c0b0556415f) )
ROM_LOAD( "1113-6m.045", 0x038000, 0x008000, CRC(35e70a8d) SHA1(953bb609143f2660e5e5ca980691b962c1e7a81e) )
ROM_REGION( 0x4000, REGION_GFX3, ROMREGION_DISPOSE )
ROM_LOAD( "1117-6t.045", 0x000000, 0x004000, CRC(82da786d) SHA1(929cc4ebac3d4404e1a8b22b80aae975e0c9da85) )
ROM_END
Delete it all.
Lastly, we would need to delete the original driver call for the game in "driver.h" Searching the entire project for csprint2 till you find it will work. It will be the only instance of it left in the project. It looks like this:
QUOTE
Found in Driver.h:
DRIVER( csprint2 ) /* 136045 © 1986 */
You can also remove all of that code for csprint1, csprintg, cspring1, csprintf, csprints and csprins1 as well by searching for them and deleting all of the code. (just make sure you don't delete anything for Working parent csprint).
That may not be a HUGE dent in the overall MAME code, but as you can see, there is potential for trimming quite a bit of the code right from MAME. This serves two purposes.
1) Code is a lot cleaner (probably doesn't matter to most other people)
2) If code is smaller, build would have to be smaller and perhaps there would be just a tad more room for memory to get a few more games working. No one will know the answer to that until it is done (unless they already know the answer and that's why it's never been tried before). I think this would have to help with size of the emulator though because there are over 5000 games with all of the clones. You can cut about 3500 of them right out of the code this way.
Incidentally, after only removing extra useless code for Championship Sprint in Atarisy2.c, the size of the file shrunk to 164kb from 189kb. I could still remove all the extra code for Paperboy, 720 Degrees, Super Sprint, and APB. So after doing that, we had a final size of Atarisy2.c was 66.7 kb, wiping out a whopping 122.3kb of useless code.
I don't imagine the ratio will be nearly that great across the board (65% reduction in size), but if we hypothetically said that it was, we would be able to eliminate 18.7 MB of code from the drivers section!!!
It probably won't be that much, but it could be huge. Maybe the emu only uses code that is currently being used in memory too, so the effect might be nil, but it's a cool concept anyways. Worst case scenario, it's got many MB less to compile every time I build and it should be much quicker when I get done with that.