GP32 What Exactly Do You Do To The Source Code?


Josquius

Member
Joined
Mar 1, 2004
Messages
389
Age
37
Location
Co.Durham
Website
www.josquius.tsx.org
Before you start- I do know about programming and the way it works in general. So no explaining exactly what the source code is and all that.

I'm curious though- you get the source code for the PC game, how exactly do you go about changing it to run on the GP32 (or GP2X).
Surely its not just a simple case of running it through something that compiles it into a format for the GP rather then a exe, apart from changing which input does what though I can't think what you do.
 
In a nutshell, you recode all the platform specific code (eg display code, user input etc)to work with new target platform..

Floating point to fix point.
Memeory issues.
Optimisiation

etc

eg (if you know C++)
Code:
#include <iostream>
using namespace std;

int main(void)
{
    int age = 0;
    cout << "What is your age?" << endl;
    cin >> age;
    cout << "Your age is " << age << endl;
    return 0;
}
Now translate that to the GP32 and look at the issues that are there..
 
Nah I don't know any form of C, just java (still working on that one...) , javascript and a few types of basic.

So the GP doesn't accept floating point numbers in anyway?
 
gp2x runs a floating point emu in the background but that is sloooooooowwwwwww.
However, gcc3.4+'s soft float is pretty good and not that slow, but still damn slow compared to fixed point math.
 
Lets be really obvious..

Say you've got a game with a win32 GUI on it and you want to port it; obviously the GUI won't port to a handheld (barring Pocket PC of course), so you have to rewrite that. The rendering code in a game _might_ port without too many changes, if its halfway decently written.. but the supportingf frrameworks, like GUIs, input handling, audio playback etc likely all need to be ported.

jeff
 
...Unless it uses SDL for that. Then you only have to change the parts that use SDL (video, input, sound, and etc.) to fit the slight differences in the GP port of SDL.

Then of course, there is the job of getting that to compile. This mainly envolves screwing with the makefile until it works in your dev environment, usually the first headache any porter has to endure.
 
You take a look at the source you're porting from... How it initialises the screen, audio, memory, input. Hopefully the source is well written or commented. Or you know the API's

You take a look at the SDK you're porting too. It does the same things .. just differently.

You recode the bits from the first to fit with the second.

That's a quick n dirty port with no optimisations.


Then you take a look at what the program does. How big is the graphics area, what audio format it uses, how much data it uses. How it translates user input.
And you look to fit that into the footprint of the target device (GPxx)
You may want to resample and prescale audio and graphics.
Precalculate maths functions. etc.

This means understanding how the program works, or just attacking bits of the code you think may be slow until they work again
Whichever your programming style fits B)
 
Wow. That sounds time consuming and challenging. I thought because they use a RISC (Really Incredible Super Computer) chip, all you had to do was change the filename extension. I thought the chip would then select the right instruction set and configure the memory and ports to match the original hardware. You learn something new every day on these boards.
:lol:
 
Nah, you don't even need to rename the extensin. Just write the file to floppy, then get a knife and pry apart the plastic sides of the floppy. take the magnetic inner bit (careful! don't get any finger prints on it!) then fold it until it fits in the SD slot. Make sure that the bottom of the magnetic strip stays on the bottom.

Of course, only works for programs that fit on a 1.4" floppy.
 
Nah, you don't even need to rename the extensin. Just write the file to floppy, then get a knife and pry apart the plastic sides of the floppy. take the magnetic inner bit (careful! don't get any finger prints on it!) then fold it until it fits in the SD slot. Make sure that the bottom of the magnetic strip stays on the bottom.

Of course, only works for programs that fit on a 1.4" floppy.
wow!, I never knew that thanks :) I'll try it today...
 
Last edited by a moderator:
Hey whats with the aggression?

hmm this developing for diffeerent systems stuff sounds odd... With everything I've done so far you just put in to output sound or graphics or what have you and the computer sorts out exactly how itself.
 
Hey whats with the aggression?

hmm this developing for diffeerent systems stuff sounds odd... With everything I've done so far you just put in to output sound or graphics or what have you and the computer sorts out exactly how itself.
aha...what have you done so far, if I may ask?
 
Last edited by a moderator:
On the roughly the same subject I started learning C++ in my spare time a month or so ago and I'd like to do something for the GP2X even if its just a quick hello world.

The basic coding I'm fine with however i tried to follow the Wiki page for getting started and i got myself a bit overwhelmed.
Am i right in thinking software wise all i need is GCC and SDL on my windows PC?
I'm a Windows, Network and Hardware technician by trade who feels like branching out a bit so i'm sure i'll get the hang of it when i get going properly.
Sorry for being such a Programming Noob but we all were at one point :p

EDIT: Just noticed I'm in the GP32 section, i came direct from the front page. Sorry!
 
You guys arent going to beleive me. Guess what I just made! My first C++ PROGRAM EVER!!!!!!!!!! Woooo I am soo happy. :p Yeah I know haha At least I am trying.

Code:
//ZodiacfreaK's First C++ Program!

#include <iostream.h>
main ()
{
char fname [10];
cout <<"Enter your Palm Pilot/Handheld type:";
cin >> fname;
cout << "The Tapwave Zodiac is better than the " <<
fname << '\n'; 
return 0;
}
Actually that is my very first C++ program, no kidding. :)
 
Does that actually compile? I think I can see at least three errors there?

#include <iostream.h> should be #include <iostream> (uses the newer library)
missing using namespace std or should have std:: at the beginning of cin and cout
main should have a return type of int.
 
:Shrugs shoulders: I dont know. It compiles and runs fine for me (wondows xp). I dont realy know a whole lot as you can tell :p but were you talking about it wouldnt run on GP2X or computer? Because it works fine for me on the computer.
 
Visual C is highly forgiving and makes a lot of assumptions; this makes people lazy and leads to problems when porting code of course :)

jeff
 
Back
Top