How Do You Port Games?


Hoax

Still Fresh
Joined
Nov 25, 2009
Messages
41
Age
34
Location
New England
So are there any guides on how to port games for the wiz and all that stuff? Where do you learn to do it? I want to learn! Im sure there are other people out there interested in learning aswell. Basicaly i am asking for any information you have on porting games and dealing with software for the Wiz! Thank You!
 
I think it's essential to learn to program before or while you are porting your first game. Learn the language the game was written in, and study the apis that the game uses.
 
Most popular ported games are written in C or C++. You should try learning one of these languages: if they look too intimidating, start with a simpler language and work your way up (the general principles are the same, so programming practice in any language will be very helpful). Learn a graphics/input library like SDL (google "lazyfoo sdl" for some great tutorials on game programming), and start experimenting with getting things moving on screen. Maybe you'll find that making your own games is a lot funner than porting those of others :)

Remember though that this will require patience and hard work on your part, nothing gets done overnight. Though once you get started you'll find that you learn faster and faster as you go along.
 
Interesting question. In fact, I just asked the same in the German board :lol:
Let's say, I've got the source of a GP2x game written in C++ - what does it take to port it? I mean, it works for the Gp2x, what do I have to rewrite?
And how do you use the Linux Openwiztoolchain? I installed it on my machine but there's no man-page or manual. :(
 
Porting can be easy or really tedious (not usually hards, just tedious.) But you have to know how to code first.

ie: you don't start paintin by aiming for Mona Lisa either, right?

Start small I'm afraid ;) If it was easy, we'd automate it ;)

jeff
 
Are there some Wiz-specific things I have to pay attention for when porting/coding a game? Or can I just put my C++ code into the Linux toolchain, however? (I still don't know how to use this <.<, is there something like... a tutorial!?)
 
Trial and error at first :p. And a boatload of patience...

But seriously, the wiz toolchain is the same as gcc for any platform or architecture.
So install the development tool manpages for your Linux distro, because they are
99% the same. Then start with a C tutorial and man gcc.
 
Think your way through; ie: the obvious main points of issue are inputs and outputs. On some platforms its storage and such as well, but you can assume thats okay on a Linux box. So .. you getting inputs how..? off the metal, or using SDL, or win32 API, or which? And output.. again, SDL, or X11, or what?

As to output, consider resolution; if you've got a game that runs at 1920x1200 on one platform, with piles of information being displayed.. well, its not going to direct port to 240x320 very easily.

figure out how you're doing it on one platform, and map it to the target platform, and that spells out 3/4 of your work ;)

The actual compilation is pretty typical, but its the work you have to do to do the _port_ (adjustment to target platform) thats the trick.

jeff
 
Yeah, I would have to say don't run before you can walk. If you can't get a simple "Hello World" program (literally, a program that prints the words "Hello World" on the screen) running on a PC and your target platform, you haven't even *begun* to understand what's involved - seriously, have a shot and try it. If you can't get a "Hello World" program, written in any language, running on the machine you want you haven't even got the knowledge to *start* programming, let alone porting. And if you're not put off by the process and the code you write to make that work, then you'll probably be okay with learning a language. From there, you would then have to actually learn (parts of) a programming language - there are entire units on every university computing course devoted to *just* that task. They attract quite high drop-out rates but it's perfectly possible to teach yourself if you want (I started programming when I was 10, never really had any formal tuition until I knew how to program myself, and have never really stopped - I'm 30 now).

From there, you have to be able to create your own programs from scratch - that's much harder than it sounds when you are handling *every* aspect of the program, from the algorithms that govern gameplay up to the hideous hacks to actually make it work on a real computer. From there, it's feasible to look at other people's code and work out what needs doing to change it for another platform.

I ported Simon Tatham's Portable Puzzle Collection (the clue is in the name - portable - so it's been *designed* so that you can move it between platforms, hence the Windows, Linux, Mac, even Java and iPhone versions of the same puzzles) to the GP2X. It took me 3-6 months (depending on your definition), an intimate knowledge of C programming and computer architectures, not to mention practicalities like getting compilers running, sourcing and adding in libraries (and learning the functions and limitations of those libraries), getting the programs to compile etc. But once the port was done, someone changed one line related to the size of the font I used, and one line related to a video resolution switch, run it through a different version of gcc and produced the Dingoo A320 version. So porting can be as simple as recompiling and running and fixing crashes (which in itself probably requires a good knowledge of debuggers and compilers and being able to understand what the code does - which of the 6000 lines of code actually caused the crash, changes the resolution, etc.) or porting can involve having to write 6000 lines of original code over the course of months in order to introduce things which weren't present in the original but were necessary in the port. For example, 300 lines of that code is just related to getting the GP2X joystick to "pretend" to be a mouse so that I didn't have to rewrite every puzzle in the collection.

To get STPPC2x to come alive, I had to write 6000 lines of C (that's just the part that *I* wrote from scratch - I needed knowledge of about as many again and that was only a small proportion of the code I was porting), include and understand about a dozen SDL libraries, include and understand and INI-file writing library (I could have done it myself but that could have been another 3000 lines of C, easily), understand aspects and limitations of the GP2X hardware (including things like touchscreen when I don't have a touchscreen to test it on). And a substantial proportion of that time and effort was just spent getting the *existing* code to run properly on the GP2X - the customisation to actually make it work with a joystick instead of a mouse, to use the smaller screens, to be able to change settings (by programming my own menu system), to make it "nice" by including artwork, menus, sounds, etc. was more than just running an automated process on some existing code.

Go have a look at http://code.google.com/p/stppc2x/source/browse/#svn/trunk - that's the code. It's for the GP2X / Dingoo (but probably compiles straight into a Wiz version too, without any changes to the code at all) but it'll give you an idea of the amount of understanding involved.

Try something like: install Cygwin with the necessary libraries on your Windows PC (or most Linux distributions hav gcc and the libraries bundled with it, if you run that), "checkout" that code using subversion, and try to get a working Windows program out of it. Then try to get a GP2X version to compile (it doesn't matter if you don't have a GP2X, you can still get it to compile). All the coding work is already done for you, because I know it compiles and runs on Windows and Linux and that both versions can produce a GP2X or Dingoo version. All that's left are the practicalities of sourcing, installing and testing a compiler - that's like saying the house is built, all you have to do is work out how to open the front door. I'll even give you hints to things, like it uses the Open2x toolchain and libraries. If you can't get past that stage, it wouldn't be sensible to start thinking about porting something or learning a programming language.

Porting something is like taking that house, moving it to another country brick by brick, and compensating for the new slope of the land, the new climate, etc. A damn sight harder than just opening that front door. But the front door is your starting block - do that, and the rest will follow naturally if you work at it. I guarantee you that if you're not already programming, you'll find it quite overwhelming to even get a compiler working for cross-compilation. It's not impossible - everyone on these boards that has written a program has had to do it in the past, and probably does it several times a year - but that's the *easy* stage and 99% of the people who come to me wanting to "learn programming" can't even get a working compiler on their system to even start. That's like wanting to learn to drive, but not being able to work out how to book a driving instructor.

Seriously - give it a shot. Almost every programmer starts as a complete amateur. But the drop-out rate on my university course for Java programming (something considered quite simple back in those days because it didn't have quite so much junk in the language back then) was about 70-80% before the second lecture even started.
 
Alex. said:
(google "lazyfoo sdl" for some great tutorials on game programming)

The SDL they used is not compatible with my 64 bit Vista OS, darn...
 
Last edited by a moderator:
ledow said:
Try something like: install Cygwin with the necessary libraries on your Windows PC (or most Linux distributions hav gcc and the libraries bundled with it, if you run that), "checkout" that code using subversion, and try to get a working Windows program out of it. Then try to get a GP2X version to compile (it doesn't matter if you don't have a GP2X, you can still get it to compile). All the coding work is already done for you, because I know it compiles and runs on Windows and Linux and that both versions can produce a GP2X or Dingoo version. All that's left are the practicalities of sourcing, installing and testing a compiler - that's like saying the house is built, all you have to do is work out how to open the front door. I'll even give you hints to things, like it uses the Open2x toolchain and libraries. If you can't get past that stage, it wouldn't be sensible to start thinking about porting something or learning a programming language.


Awesome, thanks everybody for all the info! I think im going to attempt ledow's suggestion and then take it from there. Cygwin apears to be compatible with my OS.
 
Last edited by a moderator:
Or if you wanted to learn another OS as well (may be too much to bite off at once), you could set up a VM with Linux or BSD within it. ie: Get vmware player or VirtualBox or others, and install another OS into it. I use piles of VMs, but I also keep a couple handy VMs on a flash drive in my bag, so I jack USB in anywhere, fire up a VM and have a full environment with useflu tools and development stuff anywhere, etc. Why rely on your host machine to be your environment, when oyu cna take your preferred setup everywhere :) (or be a nutbar, and check your VMs into a GIT repository, and then you can check them out anywhere. Also lets you keep version control, for the really broken headed :)

jeff
 
Back
Top