gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

Coding > Which includes do you guys use?

#74923 - xproductions - Wed Mar 08, 2006 10:07 pm

I've noticed that there is no standard set of includes that people use for gbadev. Does this mean that each one of you just grab the header that was with the tutorial you learned gbadev and add stuff to it? Must be hard to use other peoples' code.

Me personally, I really like tepples pin8gba.h. I use a modified version of it that has the standard names: http://impeachgod.f2g.net/gba.h.
_________________
If you would not be forgotten
as soon as you are dead and rotten,
either write things worth reading
or do things worth writing.

-- Benjamin Franklin

#74925 - wintermute - Wed Mar 08, 2006 10:16 pm

libgba provided with devkitARM is one of the most popular where people aren't using their own cobbled together headers. They're reasonably compatible with most sets of headers found in the various tutorials and devkitARM itself is provided as one of the toolchains distributed by the devkitPro project.

For windows users an all in one installer is provided for the major toolchains currently supported.

http://www.devkitpro.org
_________________
devkitPro - professional toolchains at amateur prices
devkitPro IRC support
Personal Blog

#74953 - gauauu - Thu Mar 09, 2006 2:07 am

A lot of us do end up using cobbled-together headers though ;-)

#74955 - wintermute - Thu Mar 09, 2006 2:13 am

gauauu wrote:
A lot of us do end up using cobbled-together headers though ;-)


Sure but in a lot of cases the libgba headers are compatible with your cobbled together headers and where they aren't I'm more than happy to update with things that people find useful.

It would be fantastic if more people started using libgba as a base and sent me some example code that can be distributed with the rest of the examples. Unfortunately the GBA example code is currently quite paltry in comparison with the DS examples.
_________________
devkitPro - professional toolchains at amateur prices
devkitPro IRC support
Personal Blog

#74968 - tepples - Thu Mar 09, 2006 3:15 am

While making the CF Speed Tester, I ended up making p8libgba.h, which contains functionality from pin8gba.h that wasn't kept in libgba headers.
Code:

/* p8libgba.h
   stuff that was in pin8gba.h that was left out of libgba

   Copyright 2005 Damian Yerrick

   #include <zlib_license.h>
*/

/* Rationale

In October 2005, I decided to reorganize pin8gba.h around the libgba
that everyone else seems to be developing against.  I was willing to
give up my well-thought-out names of registers in exchange for the
better-known names after it became clear that Nintendo wasn't
planning to take legal action against use of the better-known names
that some thought were swiped from the official devkit in violation
of NDA.  But libgba still didn't use some of the more clever macros
that I had developed for pin8gba.h.  This file is an attempt to fill
the gaps in libgba's headers, with the macros from pin8gba.h renamed
to fit into the libgba naming conventions.
*/

#ifndef _p8libgba_h_
#define _p8libgba_h_


/* gba_video.h *****************************************************/
#include <gba_video.h>  /* no, nothing to do with majesco */

/* CHAR_BASE_ADR() is the direct equivalent to old PATRAM(),
   giving the base address of a chr bank.
   But my macros pinpoint the base address of a single tile.
*/
#define PATRAM4(x, tn) ((u32 *)(VRAM | (((x) << 14) + ((tn) << 5)) ))
#define PATRAM8(x, tn) ((u32 *)(VRAM | (((x) << 14) + ((tn) << 6)) ))
#define SPR_VRAM(tn) ((u32 *)(VRAM | 0x10000 | ((tn) << 5)))


/* MAP_BASE_ADR() only gives the beginning of a map.
   Some people would rawther access each cell of a text map
   using 3D array notation:
   MAP[page][y][x]
*/
typedef u16 NAMETABLE[32][32];
#define MAP ((NAMETABLE *)0x06000000)

/* Someone forgot to recognize that width and height of a
   GBA text map can (and probably should) be controlled separately.
*/
#define BG_WID_32 BG_SIZE_0
#define BG_WID_64 BG_SIZE_1
#define BG_HT_32  BG_SIZE_0
#define BG_HT_64  BG_SIZE_2

/* Symbolic names for the rot/scale map sizes are appreciated as well. */
#define ROTBG_SIZE_16  BG_SIZE_0
#define ROTBG_SIZE_32  BG_SIZE_1
#define ROTBG_SIZE_64  BG_SIZE_2
#define ROTBG_SIZE_128 BG_SIZE_3


/* gba_sprites.h ***************************************************/
#include <gba_sprites.h>

#define OBJ_TRANSLUCENT OBJ_MODE(1)
#define OBJ_OBJWINDOW   OBJ_MODE(2)
#define OBJ_SQUARE      OBJ_SHAPE(0)
#define OBJ_WIDE        OBJ_SHAPE(1)
#define OBJ_TALL        OBJ_SHAPE(2)


/* gba_sound.h *****************************************************/

/* Most of the well-known names for the sound registers make 0 sense.
   I'll just use the pin8gba names wholesale in a separate header
   file to be included instead of gba_sound.h.
*/


/* End *************************************************************/
#endif

At the time, I was only looking for porting the minimum functionality to get AGBTTY to compile, as I found AGBTTY to be 20 kilobytes smaller than the libgba TTY.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#75667 - Dilyias - Wed Mar 15, 2006 1:09 am

wintermute wrote:
gauauu wrote:
A lot of us do end up using cobbled-together headers though ;-)


Sure but in a lot of cases the libgba headers are compatible with your cobbled together headers and where they aren't I'm more than happy to update with things that people find useful.

It would be fantastic if more people started using libgba as a base and sent me some example code that can be distributed with the rest of the examples. Unfortunately the GBA example code is currently quite paltry in comparison with the DS examples.


Well, about a week ago I decided to check into GBA programming and downloaded and installed devkitpro on my winxp box and am using the libgba headers. :-)

I downloaded BoyScout too, but couldn't get it to sound right so I wrote my own player (which I found out last night runs on the real GBA hardware perfectly). I wrote a .Net app that converts the big .BSF files to a small header file that my player uses.. Spent a lot of time in the hex editor figuring out the internal BSF format. I'm going to eventually make it output a compressed bin file so I don't have to compile the the header..

Anyways, I'm using the libgba headers as a base. They made it real easy to make bios calls for stuff like battery friendly vwaiting.

When following the tuts, I just looked for the 0xaddresses in the libgba files to figure out which to use.

I also really appreciated the VC6 example projects, they helped get me started.

Eric

#78813 - wintermute - Sun Apr 09, 2006 11:54 pm

tepples wrote:
While making the CF Speed Tester, I ended up making p8libgba.h, which contains functionality from pin8gba.h that wasn't kept in libgba headers.


I've just committed these updates to libgba as well as adding the sound defines from pn8.h to gba_sound.h. There will be a new stable release shortly, I'm just finishing up testing on the latest toolchain so devkitARM release 18 is now imminent. I'll release new stables of the libraries at the same time.

Thanks for those, all suggestions and especially updated code is greatly appreciated.

Quote:

At the time, I was only looking for porting the minimum functionality to get AGBTTY to compile, as I found AGBTTY to be 20 kilobytes smaller than the libgba TTY.


The libgba TTY implements hooks into newlibs stdio functions which allow printf and friends to work directly. Unfortunately some parts of newlib are quite heavy so you will see some marked increase in binary size when using these functions. I plan to do some further work in the newlib patches and reduce some of the overhead but it might take a while. Others on the newlib mailing list are also addressing this issue for various embedded systems so hopefully further updates will reduce the newlib overhead.

Writing your own implementations is a good way to reduce the dependency of newlib and nothing requires you to use the libgba/libnds hooks into newlib.
_________________
devkitPro - professional toolchains at amateur prices
devkitPro IRC support
Personal Blog