Why is source code needed to port games?

Discussion in 'Mac Programming' started by taelan28, Oct 14, 2014.

  1. taelan28 macrumors regular

    Jan 15, 2014
    Most computer centric board Im part of so you guys get the answer.

    I found a pair of Japanese version Panzer Dragoon Sagas at a market in Seoul, so I contacted James Mielke who wrote a sick retrospective on the Panzer Dragoon series years ago. I asked him why Panzer Dragoon Saga couldnt be ported.

    He said the source code was needed. I asked him why the game code on the CD wouldnt be enough to start a port (really why wouldnt it?) and he said that the retail version is only enough code to run the game but not port it.

    Can someone explain why source code is necessary for porting?
  2. rboerdijk macrumors newbie


    Nov 11, 2010
    Each platform has it's own compiler and libraries. The compiler (for example microsoft visual studio - for windows) puts all "sourcecode" together and generates a executable. For windows that's a .exe file which contains references to operating-system specific stuff ( like which dll's to load).

    Other operating systems, like osx however have no clue what to do with a windows .exe file - nor with referenced dll's like user32.dll, kernel32.dll. A windows game is likely to require directX. These are calls in the sourcecode to windows-specific parts - so that obviously is not going to work on non-windows platforms.

    So even if you have the source-code you will have to make ( non-trivial ) changes to make it work. In the above case, you can start xcode (osx-specific) and then start "porting" the sourcecode. Much of the "game-logic" is likely to be easy to port since it won't need platform-specific calls - but in the above case you would need an alternative for directX... For example openGL - changing that is non-trivial ( or at the least quite a bit of work). Depending on how complex the sourcecode is it might take weeks to months.

    The alternative is to use an emulator - since that program "pretends" to be another operating system, you generally need a way faster computer. But you have e.g. commodore 64 emulators for PC which will be able to "pretend" they are a commodore so the game runs.

  3. mfram macrumors 65816

    Jan 23, 2010
    San Diego, CA USA
    Because computers operate using "machine code", the low-level language that computers use. Programmer hardly ever use machine code, it's too hard to use. Instead they use "source code" which human can more easily understand. A computer program called a "compiler" will turn source code (what humans read) into machine code (what computers read).

    It's kinda like cooking. Humans read a recipe and put together ingredients. Then the item is cooked. And you eat it. You can't really un-cook a cake back to the ingredients. In a similar way it's difficult to "de-compile" machine code back into source code. It can be done, but it's very, very time consuming.

    So unless someone has a lot of time, motivation, or money you need the source code to port software. And even then it can be difficult.
  4. JustMartin macrumors 6502a

    Feb 28, 2012
    ok - I'll see if I can simplify without being simplistic.

    Computer programs, such as games, are written in a programming language. That language is one that programmers understand and that can then be translated (compiled) to a set of instructions that the processor will understand. Those instructions are specific to that processor or class of processor.

    So, code that will run on one kind of processor will not run on another kind of processor. You have to go back to the source code and compile it for each specific CPU. Well, I say CPU, these days, it's much the graphics processor as the central one.

    Additionally. Computers differ from each other (and I'm including anything with a processor here) and the manufacturers will provide different ways of getting results from things like the screen, filing system etc. These all have to be bolted into the source code somehow and then everything compiled together.

    The process of porting is taking the source code that was originally designed for one box and making it run on another. From quick wikipedia search, it would seem that these games you're talking about ran on Sega systems years ago. They're not going to run out of the box on a Mac unless someone has written a Sega emulator for the mac that would run the compiled code unchanged. Hence the need to port it.
  5. jtara macrumors 65816

    Mar 23, 2009
    Best summary I've seen:

  6. Eric5h5 macrumors 68020

    Dec 9, 2004
    In the olde days, it wasn't uncommon for games to be ported without source code, but that's because they were essentially re-created from scratch. (And therefore they usually played a little differently on different platforms.) Most games these days are too complex for that to be feasible anymore.

  7. robvas macrumors 68030

    Mar 29, 2009
    You can probably emulate it now! What game system were the games written for?
  8. ArtOfWarfare macrumors G3


    Nov 26, 2007
    I liked the analogy that you can't unbake a cake.

    Here's another one: Are you familiar with the game Telestrations? It's a really great party game, fun for all ages if you're not... see the video on this page - http://www.telestrations.com/how-play

    There's a lot of ways to go from a picture (compiled code) to a description (source code). Supposedly a picture is worth 1000 words, but lists of 1000 words will differ between different observers creating that list.

    So basically when you're asking to make a port without the source code, you're talking about going from compiled code -> source code -> compiled code.

    A third analogy: It's like taking a phrase in English, then translating it to Japanese, then translating it to Hebrew. Metaphors and analogies generally get lost in translation. Things that make sense in one culture may not make sense in another. Are you familiar with the phrase "Lost in Translation"? You have to go through 2 translation phases - twice as much opportunity for things to be lost.

Share This Page