Not logged in, Join Here! or Log In Below:  
 
News Articles Search    
 


Submitted by Jaap Suter, posted on August 17, 2001




Image Description, by Jaap Suter



Here are some shots of my very first Gameboy Advance (GBA) programming adventure. The past few weeks I've been on vacation in France, and every afternoon I would do some GBA programming on my laptop. Lying by the side of the pool, programming, with a view on the mountains. Very nice!

Anyway, I started working on a project called Socrates. It's an object oriented library for the GBA written completely in C. Object Orientation in C? Yes, it's possible.

The library is written for MODE-4 graphics. This is the only full-screen video mode that supports double buffering. The only drawback is that it's a 8 bits palettized mode, and that you can only plot two pixels at a time. So if you have to write one pixel, you must read-modify-write. However, this proved to be quite a funny obstacle in my polygon drawing routines.

About the images, from top to bottom, left to right.
  • 1. Some crossfading of images. Speeding this up was quite difficult. It's still not at full speed. I probably gonna need some ASM for this.
  • 2. Shows a couple of flatshaded cubes, with frustum clipping as well.
  • 3. A couple of flatshaded cubes without frustum clipping.
  • 4. Title-screen.
  • 5. Kind of texturemapping, plasma, -ish effect
  • 6. Two texturemapped cubes with frustum clipping
  • 7. 8. 9. 10. More of the same.
  • The 3D engine is completely fixed point and I'm quite happy with the speed raw C delivers. Soon I'll add some inline ASM to speed thing up, but for now I'm focusing on getting some more functionality done. Though, Quake like 6DOF is not gonna happen on GBA. Unless somebody proves me wrong.

    Currently I'm working on a voxel landscape on GBA but I'm rather pessimistic on performance issues. I suppose I'll have to start doing some sprite, tile, background scrolling stuff soon.

    Overall, I love it. Working for a machine with low performance but a complete set of fixed functionality. No more compatibility issues. Jippie.

    By the way, it works on the real thing as well. Thanks DarkFader.


    [prev]
    Image of the Day Gallery
    www.flipcode.com

    [next]

     
    Message Center / Reader Comments: ( To Participate in the Discussion, Join the Community )
     
    Archive Notice: This thread is old and no longer active. It is here for reference purposes. This thread was created on an older version of the flipcode forums, before the site closed in 2005. Please keep that in mind as you view this thread, as many of the topics and opinions may be outdated.
     
    SamS

    August 17, 2001, 02:58 PM

    So when you say "Object Orientation in C" you are just talking about using structs with function pointers instead of classes right? Not inheritence of classes.

    Anyway, nice work.. it's cool to see some GBA work. It would be cool to see some Gamecube and XBOX work from game developers too :) (hint, hint). How easy was it to learn the API for the GBA?

     
    Jaap Suter

    August 17, 2001, 03:04 PM

    "So when you say "Object Orientation in C" you are just talking about using structs with function pointers instead of classes right? Not inheritence of classes."

    Very true. But you'd be surprised to find out how many people exist that think that C++ and Java (and Eiffel, etc) are the only languages suitable for OOP.

    Using an explicit 'this' pointer is a good step towards an object oriented way of programming.

    And true, all of this is open for debate. Do we need inheritance for good OOP? I don't know. Let's not start a discussion about it :). My point was just that you can program in an OOP kind of way in C as well.

    Learning the API for GBA was very very easy. Well, if you could call it an API. There is no real 'interface'. There is just a list of places in memory where you can do special stuff :). Check out www.gbadev.org or www.devrs.com/gba/

    Setting up the compiler was the hardest part actually, using GCC that is. Using the ARM-sdk is supposedly easier.

    Anyway, thanks for your comment! I sure hope we get to see some GC and XBox stuff as well.

    Jape

     
    Bramz

    August 17, 2001, 03:08 PM

    Oh, so *this* is GBA :)

    Bramz

     
    Kanda

    August 17, 2001, 03:14 PM

    Reallly fun !!!
    I remember a cool man , wich as wrote some demos on Ataris St who said that it was as fun as on the St to code on GBA, because you can really optimise your routines !!! Looks very sweet and idlike to try it a day.

    Keep on funny work !

     
    Garett Bass

    August 17, 2001, 03:32 PM

    Very cool, nice work. This reminds me of some thoughts I had a few months ago...

    I was thinking of an ideal application for 3D on PDA/GBA equipment: Warcraft/UO style gfx. How about using orthogonal 3D to render the 3/4 view overhead map? The renderer could draw only at the edges of the screen, and scroll the contents of the screen left/right/up/down.

    Ortho rendering should lend itself well to a variety of high speed optimizations. The dataset for maps could be well compressed since each terrain and architechture are a collection of tiles, textures, and simple geometry. Characters could be more complex 3D objects since they are small onscreen, and could be quickly overdrawn and rendered. Obviously this wouldn't require double-buffering

     
    Bramz

    August 17, 2001, 03:33 PM

    No pics of a 'Flying Jaap' this year ? Have you really been snowboarding? ;)

    Brampie

     
    Phil Carlisle

    August 17, 2001, 04:04 PM

    Jaap: How did you develop the GBA stuff? using an emulator? can you tell me which one? and which compiler and such?

    I'd like to relive some of my old days of Snes and what have you, but cant be bothered to track down which of the emu's and such actually work ok.

    Tile based scrollers rock man! :)

    Rockman... hmmm :)

    Phil.

     
    Revolver

    August 17, 2001, 04:34 PM

    OOP is a paradigm, not a language construct. The class and struct keywords of C++ are simply language enablers for OOP, and aren't strictly necessary.

    You can create an OOP application in C++ that doesn't use the class or struct keywords.

     
    Kanda

    August 17, 2001, 04:38 PM

    Look at :
    http://leonard.oxg.free.fr/

    In project section and there's some link to find cool stuff for coding on GBA

     
    Buster

    August 17, 2001, 04:55 PM

    What kind of game is it?

     
    TheDeathLord

    August 17, 2001, 05:10 PM

    *smack*

     
    Jaap Suter

    August 17, 2001, 05:46 PM

    Very true.

    Jaap

     
    Jaap Suter

    August 17, 2001, 05:49 PM

    Yeah, I think doing 3d programming that requires no perspective projection is definitely an option for GBA. As soon as I have time, I'm gonna experiment with different projections.

    Btw, I think Tony Hawk 2 for GBA uses such a projection (non-perspective) for their skater. Even then, it's one hell of an achievment though. They did some nice coding, check out the game!

    Jape

     
    Jaap Suter

    August 17, 2001, 05:54 PM

    I use the BoyCottAdvance and the IGBA emulators.
    Futhermore, I use GCC to compile stuff.
    Last but not least, I develop in Visual Studio. It's the environment I'm used to, and using NMake and some macros, I have created a very efficient and easy work-environment. Easy building, easy adding a file to a project, easy running, etc...

    I know what you mean about really starting to code for GBA. At first it seems a bit overwhelming, starting for a new system. But isn't that the case with every system? Once you got your work-environment setup and you plotted your first pixel, the real fun starts!!

    I can send you my workspace, makefile, etc. etc. if you want to. You can be coding in 5 minutes.

    Grz,

    Jape.

    Btw, I highly agree about the tile-based scrollers. They rule, and are fun to code as well. Think 3D is hard? Think again, and do some real 2D coding! Look out for Gradius Advance, it's some hardcore 2D shooting.

     
    Jaap Suter

    August 17, 2001, 05:59 PM

    Btw, two things I forgot to mention is that I build a simple font for debugging purposes. For example, my matrix type has a DebugDraw method that prints it's contents to the screen. This proved to be very handy, since I couldn't really find a debugger yet. And I don't believe there is a source-level debugger anyway. Joat (Mappy) is creating one as we speak, but I'm not sure when it'll be finished.

    The other thing is about the tools I made. I made my own tools that convert Jasc-Palettes, images and textures to header file structures that can easily be imported into your project. Textures including already calculated pitchshifts, wrapmasks, etc. No big deal, but handy anyway :).

    I'll release this stuff soon, so drop me a line if you're interested. I'm gonna release the GBA code itself probably as well.

    Grz,

    Jaap Suter

    Btw, speaking of matrices. This is actually the first time I made a transform system (euler angles + translation + scale) and build my matrices from that every frame. 32 bit fixed point numbers aren't really suitable for accumulating precision errors. I could speed things up there a little (do it only every 5 frames for ex. but hey, who cares? :) hehe).

    Seeya'll

     
    Peter Mackay

    August 17, 2001, 06:00 PM

    Blimey!

    Looks sweet, I was talking to one of the guys in work today about homebrewn GBA development, so this is nice to see!

     
    Mr_Bribe

    August 17, 2001, 06:01 PM

    Woah! texture mapped 3d on a handheld!!! What kind of framerate are you getting?

     
    Jaap Suter

    August 17, 2001, 06:04 PM

    I haven't seen it myself on the real thing, somebody else tried it for me and he said he got about 6 fps. However, that was still an optimized version. I think it should do about 12 now. But it is a really wild guess. And like I said, GBA is really too slow for perspective 6DOF 3D.

    However, non perspective with special tricks, we are going to see some nice shit by proffesional gamecompanies and amateurs in the future, I'm sure of that.

    Speaking of which, somebody already did bumpmapped cubes in mode 5 (smaller resolution, and 16 bit, double buffered). I still have to check that demo though.

    Grz,

    Jaap Suter

     
    Jaap Suter

    August 17, 2001, 06:04 PM

    I haven't seen it myself on the real thing, somebody else tried it for me and he said he got about 6 fps. However, that was still an optimized version. I think it should do about 12 now. But it is a really wild guess. And like I said, GBA is really too slow for perspective 6DOF 3D.

    However, non perspective with special tricks, we are going to see some nice shit by proffesional gamecompanies and amateurs in the future, I'm sure of that.

    Speaking of which, somebody already did bumpmapped cubes in mode 5 (smaller resolution, and 16 bit, double buffered). I still have to check that demo though.

    Grz,

    Jaap Suter

     
    Dr.Mosh

    August 17, 2001, 07:56 PM

    Very cool!!
    I love my GBA and since I got it I was wondering about SDKs and suchlike.
    HOw did you get started? HOw do you get your games across to the GBA??!
    I need info on this fast! :)

     
    Dr.Mosh

    August 17, 2001, 07:56 PM

    Very cool!!
    I love my GBA and since I got it I was wondering about SDKs and suchlike.
    HOw did you get started? HOw do you get your games across to the GBA??!
    I need info on this fast! :)

     
    XoR

    August 17, 2001, 08:59 PM

    sweet =]
    now all we need is a little TMU with filtering in hand helds.

     
    Tim Wojtaszek

    August 17, 2001, 09:37 PM

    pardon my ignorance, but wouldn't your objects be limited to predefined datatypes and arrays? I mean practically here, not something where you would allocate memory and cast the offsets to your type of choice (this is the only way I can think of controlling the interface..for now)?

    I can understand creating a struct, typedef'ing to create an opaque pointer, then passing this pointer around all the functions. But without a struct, what other choice do you have than to allocate memory and track the offsets and datatypes manually?

     
    Tim Wojtaszek

    August 17, 2001, 09:45 PM

    I was practically made for handhelds!

     
    Machin Shin

    August 17, 2001, 10:32 PM

    well..you can simulate all the effects of c++ based object orientation in C using function pointers..but yah..everything's done manually ..
    you construct manually.. you destruct manually... etc..
    when you construct manually .. you associate the fp's there..
    like .. (and i hope i remember my function pointer syntax right, here, i just don't use it very often in c++ :) .. the language takes care of all that for me :P )
    :


    typedef struct vector
    {
    /*no data hiding, since c has no concept of privacy ;) */
    float x,y,z;

    vector* (*add)(vector *p_this , vector *p_rhs);
    float (*dot)(vector *p_this, vector *p_rhs);
    vector* (*cross) (vector *p_this , vector *p_rhs);

    };

    vector* vector_add( vector *p_this , vector *p_rhs)
    {
    /*do add*/
    }

    float vector_dot_product (vector *p_this, vector *p_rhs){}

    vector* vector_cross_product (vector *p_this , vector *p_rhs){}

    vector_create( vector *p,float x, float y, float z)
    {
    p->add = vector_add;
    p->dot = vector_dot_product;
    p->cross = vector_cross_product;
    /*and other ops, like subtract & whatnot */
    p->x = x;
    p->y = y;
    p->z = z;
    }

    int main()
    {
    vector p, q;
    vector_create(&p, 1.0, 2.0 , 3.0);
    vector_create(&q , 3.0 , 15.2 , 0.0);
    float d = p.dot(p,q);
    printf ("wouldn't overloaded >> and << be nicer than this? ;), %s,%s,%s",p.x,p.y,p.z);
    }





    --vat

     
    disableddan

    August 18, 2001, 12:29 AM

    You should seriously make a 3D game with that and distribute it. Nintendo would even be impressed! I had no idea the GBA could do that.

     
    DirtyPunk

    August 18, 2001, 02:11 AM

    Yo suternes, looks great! :)

    I wouldn't be suprised if you could get this running very quick with some asm in those inner loops. These sort of processors are notorious for having "tricks" which make such optimisation easy :)

    Affine texture mappers will probably be a good idea - Most play station games used affine mapping on a bigger screen, so you can get away with it on a gba I would imagine.

     
    tcs

    August 18, 2001, 05:48 AM

    Wow, nice. I though these 2 1/2D doom style engines where the max that the GBA could do. And now I see that somebody's FIRST try to make a GBA engine can do real 3D, even without asm...

    Well, imagine what you could do when you are very experienced with this system and unitlize asm... Great work anyway !

    Tim

     
    Nick

    August 18, 2001, 06:50 AM

    My twin brother made a similar game for Psion 3 / 5 and compatible devices: ZherØes. He is doing the finishing touch for the Psion 5 version right now, and he will release version 1.0 very soon! It doesn't have that much features as the real Worms and the gameplay is much slower, but it's still fun.

    I'll tell him about this IOTD to show what a GBA is capable of. Unfortunatly I don't think he likes to develop on an emulator, he has made ZherØes entirely on his Psion although he also has an emulator. The programming language on that Psion is OPL, but now he wants to buy a netBook to program in C / C++ / Java / asm...

     
    Murazor

    August 18, 2001, 07:02 AM

    Go Jaap!

    it looks cool, but I liked it even better when you showed the running demo.. :)
    Too bad there is no demo party which allows contest entries for the GBA... (or are there? I haven't seen any..)

    Murazor

     
    This thread contains 37 messages.
    First Previous ( To view more messages, select a page: 0 1 ... out of 1) Next Last
     
     
    Hosting by Solid Eight Studios, maker of PhotoTangler Collage Maker.