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 > GBA.H

#1658 - AnthC - Tue Jan 21, 2003 4:30 am

Hi
Which gba.h/agb.h are you lot using?
It would be nice if I had one with most if nto all of the hardware registers in it and maybe some bit equates also?
(I tried looking for eloist's but could only find a site with an emulator on it)
Any thoughts?
Cheers
Tony

#1662 - sloat - Tue Jan 21, 2003 4:54 am

i wrote my own for goldroad. i based them off of knoth's gbatek.
for c stuff, i used the ones from the pern project, but i fixed the spelling errors.
_________________
http://sloat.bradsoft.net/

#1663 - tepples - Tue Jan 21, 2003 5:00 am

I'm using my own custom "pin8gba.h" header. Its register names are different from the purported "official" names because my names
1. make better sense to me and
2. won't incur liability for dealing in what may be a Nintendo trade secret.

I've also done some slick tricks such as declaring several registers as an array or as an array of structs. For example:
Code:

#define BGCTRL ((volatile u16 *)0x04000008)
#define BGCTRL_PAT(m)    ((m) << 2)
#define BGCTRL_16C       0x0000
#define BGCTRL_256C      0X0080
#define BGCTRL_NAME(m)   ((m) << 8)
8< 8< 8< more defines here 8< 8< 8<
#define BGCTRL_M7_64     0x8000
#define BGCTRL_M7_128    0xc000


struct BGPOINT
{
  u16 x, y;
};
#define BGSCROLL ((volatile struct BGPOINT *)0x04000010)


struct DMACHN
{
  const void *src;
  void *dst;
  u16 count;
  u16 control;
};
#define DMA ((volatile struct DMACHN *)0x040000b0)
#define DMA_DSTINC      0x0000
#define DMA_DSTDEC      0x0020
#define DMA_DSTUNCH     0x0040
#define DMA_DSTINCRESET 0x0060
8< 8< 8< more defines here 8< 8< 8<
#define DMA_IRQ         0x4000
#define DMA_ENABLE      0x8000

which can be addressed as BGCTRL[2], BGSCROLL[0].y, DMA[3].dst, etc.

The header is heavily commented and acts as a reference covering the GBA's registers. It's not 100 percent complete, but it has most of the subsystems covered, even including the GB tone generators.

You can find pin8gba.h in any of my projects.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#1683 - AnthC - Tue Jan 21, 2003 4:16 pm

Cool thanks for your replies.
Took your advice and started writing my own.
AnthC

#1758 - gb_feedback - Wed Jan 22, 2003 5:14 pm

tepples: I was just about to recommend the header I saw in TOD and then I realised that you were using a different handle here and had mentioned it yourself! I came across it a few days ago while I was trying to sort out some problems on my midi player, and I was impressed. The header looks like a lot more thought went into it than usual.

OT

I liked the mixer stuff too. I'd like to ask you some questions sometime if you don't mind. (Just some lame stuff which shows I haven't spent enough time reading your code).

Anyway, enough sycophancy...