Jump to content
Sign In to follow this  
GoaSkin

found out why the Mac version is much slower than the windows version

9 posts in this topic Last Reply

Highlighted Posts

Posted:
Last Online: A long, long time ago... 
 

Code of higher programming languages like C++ is beeing converted into assembler code when compiling it. The instructions of the C++ code are replaced be something with the same effect what the machine can interpret directly. Different CPUs do have a different assembler syntax but the sense of all is the same. There are other registers and some different commands - but almost for the same purpose.

Furthermore - depending on the compiler, the compiler settings and the style you code there may be different solutions in the machine language (assembler) - different instructions for the same goal but if the machine code is more complicated, the program is less performant.

On the Mac binary, something bad happened: 32Bit Integers are always splitted into 16Bit Integers to be saved on two 16 Bit registers - puzzled together again when needed. Each time, the value es needed, three instructions are needed instead of one. To explain that by an example, the code tests here if a variable has the following value. In C, the syntax is
if(variable==0x299237BF) {commands...}

The assembler code for the X86 (windows) version is like this...
cmpl $0x299237bf,%eax
je {new address containing the commands if the value check before is true}

On the PPC (Mac version), you find not just the simular with other grammatics:
lis r2,0x2992
addi r0,r2,0x37bf
cmpw r31,r0
beq {new address containing the commands if the value check before is true}

This means one half of the constant is put into r2 at first, then the whole variable if copied with the second part into a new variable (r0) and then compared if r31 has the same value like the before staticly puzzled constant. It would be more easy if there would be simply the instruction

cmpw r31,0x299237BF

and would save two instructions. Complications like this are everywhere in the program. And needing three times the instructions what are really needed makes the game slow.

Share this post


Link to post
Share on other sites
Posted:
Last Online:  
 

Perhaps that is why after installing the Universal Update for SC4, mine began to run much faster than before, even though I'm on a PPC system. Perhaps the recient updates to the C & C++ libraries that were done to create universal Apps finally removed the 16-bit integer limitation, which had to have been there for backward compatibility with 68k systems, whose registers were limited to 16-bits. So this problem had been in most Mac Apps, long after the 68k processors had been retired.

TEG

Share this post


Link to post
Share on other sites
  • Original Poster
  • Posted:
    Last Online: A long, long time ago... 
     

    Apple delivers different SDKs for their operating systems. One that needs OS 10.2 or higher, one for 10.3 or higher and the last for 10.4 (which supports universal binaries). Each newer version has advantages but may not be compatible to older Mac OS versions.

    Each SDK comes with their own version of compilers, precompiled headers, static objects to link in etc. That means that they must use a different compiler to create universal binaries than before.



    Well... I have examined to binaries to find out a way to add new menus to the game (to tidy up the large LOT lists). Now I know what assembler instructions to insert but have no idea how this editing procedure may be done (because the file size must not be changed).

    Share this post


    Link to post
    Share on other sites
    Posted:
    Last Online:  
     

    Well... I have examined to binaries to find out a way to add new menus to the game (to tidy up the large LOT lists). Now I know what assembler instructions to insert but have no idea how this editing procedure may be done (because the file size must not be changed)quote>

    well good luck with that and I want to see where you get with this.

    Share this post


    Link to post
    Share on other sites
    Posted:
    Last Online:  
     

    You could maybe work with Aspyr on this. I spoke with them and as we all know they dont have the time our resources to work on this game. The may be willing to "hire" you, that way access to the EA property, source codes, etc. would be legal. After all its an old game that I am sure is not generating too much profit for them so they have nothing to lose. It never hurts to ask. I am just glad I figured out my video card performance issue on got the game to perform well on my new iMac! They are asking for the changes I have made so they can relay it to customers who have the same performance issues. Takes two seconds to do really.

    Share this post


    Link to post
    Share on other sites
  • Original Poster
  • Posted:
    Last Online: A long, long time ago... 
     

    The easiest way would be if they can offer some single C++ functions what we can modify. The Windows version has an interface to read in them alternatively as a DLL. This interface does not exist on the Mac version what means that the binary itself must be updated.



    Well... EA was asked very often and all the times there wasn't any answer. By the way, ASPYR wouldn't have much to do for fixing the light-nighting problem. They must only recompile the game using some replacement functions by MAXIS.

    Share this post


    Link to post
    Share on other sites
    Posted:
    Last Online:  
     

    I own an iMac. Anyway, I will buy SC4 for Mac, even thou it will run slow, ay least I can now know why is that, thanks!!

    Share this post


    Link to post
    Share on other sites
    Posted:
    Last Online:  
     

    There are two "slow" issues with the Mac version. The one referred to in this thread is just overall game play speed. The game can seem to perform fine, but building construction speed, etc is slower on the mac. Car movement speed, etc, is the same.

    Then there is the other "speed" issue. This is a video config issue. I have a fix for this I am still testing out. Its nothing major, but the game scrolls much better with the fix and also the number of artifacts is greatly reduced. I will post the config files in a couple days. It is important that you do NOT update to the latest version which is a universal binary. Its intended for Intel Macs but my fix will not work with it. Also, if you do update to the UB you may have issues plopping certain BATs. That was something I could not fix at all and seems to be a flaw created by the update. Essentially if you place a certain BAT the game will freeze up.

    Share this post


    Link to post
    Share on other sites

    Sign In or register to comment...

    To comment in reply, you must be a community member

    Sign In  

    Already have an account? Sign in here.

    Sign In Now

    Create an Account  

    Sign up to join our friendly community. It's easy!  

    Register a New Account

    Sign In to follow this  

    • Recently Browsing   0 members

      No registered users viewing this page.

    ×

    Thank You for the Continued Support!

    Simtropolis depends on donations to fund site maintenance costs.
    Without your support, we just would not be in our 24th year online!  You really help make this a great community. *:thumb:

    But we still need your support to stay online. If you're able to, please consider a donation to help us stay up and running. This helps sustain a platform where we can share our community creations for years to come.

    Make a Donation, Get a Gift!

    Expand your city with the best from the Simtropolis Exchange.
    Make a Donation and get one or all three discs today!

    STEX Collections

    By way of a "Thank You" gift, we'd like to send you our STEX Collector's DVD. It's some of the best buildings, lots, maps and mods collected for you over the years. Check out the STEX Collections for more info.

    Each donation helps keep Simtropolis online, open and free!

    Thank you for reading and enjoy the site!

    More About STEX Collections