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.

    Image of the Day Gallery


    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.
    Jason Perkins

    August 18, 2001, 08:26 AM

    I, for one, would be very interested in your build config stuff. The only reason I haven't tried coding for the GBA yet is that I haven't had the time (read: motivation) to set up the build environment. Could you you throw it up on a website?

    Seeing that 3D is possible really gets me thinking...


    Wim Libaers

    August 18, 2001, 10:37 AM

    Actually, what you are doing here is even more flexible than the C++ virtual functions, because you can change the functions independently and at any time. C++ only allows one set of functions per class via the vtable, which is determined at the time of creation of that class. The function pointer method is much more interesting.


    August 18, 2001, 11:07 AM

    Well, yeah, but keep in mind this consumes a lot of memory, especially when you have lots of pseudo-virtual functions and lots of instances of particular classes. As you said, normal C++ virtual function calling is done by the vtable, but there is only one table per class, shared by every instance of that class.


    August 18, 2001, 01:37 PM

    I'm glad you said it like this. It definately needed to be said.

    "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."

    I would add that simply coding something in C++, or any other language with OO features, does not make your code object oriented.

    Arne Rosenfeldt

    August 19, 2001, 03:45 AM

    Doing pure 3d on a GBA means not using 90% of its silicon?
    I think its a bad idea

    Why is the GBA not designed for 3d,
    as far a I read it can do zoom and rotation from there the step to affine texture mapping is small.

    Does it have shading (making sprites darker and or lighter)?

    Do zoom and rotation take the BGR subpixel order into account?


    August 20, 2001, 05:57 AM

    this is the reason i am using C++ function pointers (which are hellish to setup) in my filesystem library (so i get calls to pointers and thus save time on figuring out how to call things like MyFileSystem.readbyte() :)

    function pointers rule!

    they also hurt when they go wrong. :(

    Dean Harding

    August 21, 2001, 03:58 AM

    Actually, while you can't really do inheritance with structs, you can sort of accomplish the same thing (without member overloads anyway) with some tricky casting. Try this:

    struct Class1
    int a;

    struct Class2
    struct Class1 base;
    int b;

    In this case, Class2 "inherits" from Class1. See the GTK sources for an example of how this is put to really good use. They don't use function pointers to get member functions, they use functions with a specific naming style, but all their objects support inheritance, and you can cast up and down the inheritance tree at will. Here's a quick example:

    GtkWindow *window = gtk_window_create();
    gtk_container_set_border( GTK_CONTAINER(window), 10 );

    Here, gtk_window_create() creates a GtkWindow object, and gtk_container_set_border() sets the border width of a container object (a window "is a" container, so you can cast with GTK_CONTAINER()). The really cool thing about how they worked it is that it's all type safe as well!

    PS. My GTK is a bit rusty, so I may have messed up function names or whatever.

    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.