2002/03/19: HAM v2.18a released
Little but important update to HAMlib 2.18. Fixes a severe bug in the Tile/Map memory
deallocation functions. Get it now on the download page.
2002/03/18: HAM v2.18 released
Pretty busy these days :) HAM 2.18 brings some refreshing new things for all HAM fans. Thanks
to a lot of productive feedback, here is the latest changes to HAM, lots of new stuff, lots
of fixes :)
- Three new code samples! See the screenshots page for details
- Sprite rotation functions, using the full flexibility of the GBA OBJ system, yet very easy to manage
- DMA3 implementation
- Better support for people with both Flash cart and MBV2, see the build target "flambv2"
- RAM footprint of HAM reduced by another 200bytes
- Vital fixes to the BG VRAM memory manager. It used to error if you requested a really really tiny piece of VRAM
- New, more powerful BG rotation/scaling functions
- ...and more. Get HAM v2.18 either as full distribution, as update from 2.15(or 2.16), or go and
register now!
2002/03/08: HAM v2.15 released
HAM 2.15 is now available as an update from 2.1. Fixes are critical, I highly suggest you upgrade.
For a full discussion of the fixes, please see the Version history in the HAM documentation. The most
important news are:
- One new example! See the screenshots section for more information
- New Sprite functions, including Sprite animation service functions
- Fixed missing Sprite bug reported by a few people
- Fixed several problems with memory macros and sprite positioning
- Fixed the nonsense 16kb limit for allocating TileSets to the full 64kb
- ....and many more....
2002/02/26: HAM v2.1 released
In the download section, find HAM 2.1 . Most important changes include the switch to GNU make, Sprite and Help fixes,
an improved installer, and a much smaller file size due to cleanup of compiler files that were unneccessary.
2002/02/18: HAM v2 released! HAMlib released!
I am very pleased, proud and tired to finally offer the next big update to
the HAM development system. This version has been majorly revamped, and, for the
first time includes a function library called HAMlib. Also, a complete documentation
and new example source is available. What are you waiting for? Also, feel free to subscribe
to the HAM development mailing list by sending an empty email here.
2002/01/01: HAM 1.40sr1 now available in the Download section!
HAM is a GBA development environment currently targeted at Win32 based systems,
and uses GCC and NMAKE for code generation. I wrote HAM starting March 2001, in
lack of a devkit that suited my needs. HAM was designed to:
- have a *very* small memory footprint
- be very fast and efficient
- be easy to use
- be flexible end extensible, and wells structured.
Some of the core features of HAM include:
- True 1-click setup with GUI installer
- No further applications required
- over 600 easy-to-read Macros for every subsystem of the
GBA.
- GBA Machine monitor with MBV2 support
- Easy service routines for Interrupt control and BG handling,
as well as included Font-printing routines.
- clean, fast and small in final code size
- Supports multiple installations on same system
How do I install / use HAM ?
- get the download, unpack it
- run Setup.exe and follow the instructions.
- Once installed, click "startham.bat" in the installation directory
- To compile a source, as example the ones in sample/mosaic, type
"cd samples\mosaic" followed by "nmake"
- To rebuild, type "nmake clean"
How does HAM differ from libgba or similar?
a typical HAM program looks like this:
...
while(TRUE)
{
if(F_CTRLINPUT_A_PRESSED)
{
M_MOSAIC_SET(2,2,0,0)
}
else
{
M_MOSAIC_SET(0,0,0,0)
}
}
...
This program should be very self-explaining. Notice something? HAM is
very easy to read :) In case you are not yet familiar with the GBA, you might
wonder what it does though , so we'll quickly walk you through a few concepts here:
F_CTRLINPUT_A_PRESSED
starts with an "F_", and this denominates a function
in HAM. A function is declared to always return a value into the context it was
placed into. In this case, it will
return 1 (TRUE) if the A button on the joypad is currently pressed, or 0 if not.
After the "F_" follows the HAM Register name. In this case "CTRLINPUT" refers
to the hardware location where the controller ports are located. After that, the
function or Macro name follows, in this case "_A_PRESSED".
M_MOSAIC_SET(bg_x, bg_y, obj_x, obj_y)
Now it gets interesting. We learned that
"F_" denominates a function (that is required to return a value). "M_" denotes a
Macro. Simply put, a macro can do stuff on its' own, suchas changing the
Scrolling value of a background, or , in this case, set the mosaic function for the
background, and/or the sprites. "MOSAIC", again, is the "HAM register name", and
"_SET" is a common macro name for putting a value directly into the register.
There is a total of well over 600 of these Macros in the current HAM release version,
all documented in the mygba.h file that is located in the include folder.
TOOL macros in HAM
There are a few macros in HAM that do not directly interact with the Hardware,
but instead are referred to as a "collection" of macro calls. Simply put, these
are convienience macros for repetitive tasks, such as display setup or Sprite
initialization. For example, to turn on a GBA OBJ (= a Sprite), all you do is
call TOOL_OAM_OBJ_SETUP() with a few parameters that describe what you want to do,
and ...voila, it's there :) an overview of the tool defines and their documentation
is found at the end of mygba.h .
Memory access defines/macros in HAM
People are not good at remembering numbers. Especially, if you dealt with the GBA
before, you will know that writing to specific base blocks in VRAM can result in
hard to read code. For this reason, HAM provides a heap of Memory access service defines,
all of them can be read about in ...you guessed it, mygba.h ... refering to the example
of accessing VRAM character base block 5, all you do in HAM is write:
MEM_CHR_BB_PTR(5)=yourvalue.
Also, these macros integrate well into otherwise messy libc functions. Think about
you want to copy a screenful of BGMode 3 graphics into VRAM, in HAM, this would look
like:
memcpy(MEM_BG_MODE3_PTR, pointer_to_your_data, MEM_BG_MODE3_BUFSIZE);
There are much more of these service defines worth checking out. See mygba.h for
more details.
Conversion Macros
Pretty standard stuff here, RGB -> BGR conversion, Radians to degrees, and so on.
Noteworthy would be a complete set of defines to convert integers into fixed point
numbers, but nothing special here, really.
Wow
You are still reading. I am impressed.
The real Meat: Hardware Macros
This is the main scetion of HAM, a typical set of macros for a piece of hardware
in the GBA is operated like this using HAM:
The example uses the Display Controller Register, it is used to setup display parameters:
M_DISCNT_FRCBLK_ENA // halt display operation
M_DISCNT_BG2_ON // enable BG number 2
M_DISCNT_BGMODE_SET(3) // set up BG mode 3 (bitmap mode 256cols)
M_DISCNT_FRCBLK_DIS // re enable display
As always, the usual Macro naming conventions apply. M_ for macro (does stuff on its own and does
not return a value) DISCNT as the register name, and the rest being the actual command.
However, you can still go easier by setting up the display using a TOOL_ define called
TOOL_INIT_DISPLAY(bgmode), which does all the work for you ;-)...
Hardware macros are available for ALL the GBA subsystems with the exception of
Serial IO (at the time of this writing) and DirectSound (to be added very soon).
A serial MBV2 builtin machine monitor
HAM comes with an optional, easy-to-integrate machine monitor that allows you,
if you have a MBV2 cable, to halt your program execution and look at register
values and even memory pages. All you need is to add debug.o to your list of
targets in the Makefile, and then call dbg_Show() during execution. Then follow
the commands printed on the console. Help is available when pressing the "h" key.
Much will still be improved in this section, anyone up for it ? :)
Really Really Easy Interrupt Controls for all :)
Ever hated the fact your interrupts didn't work as you wanted them to? HAM
integrates a very easy Interrupt Control System, which can best be described
by showing the full code needed to drive a VBL Interrupt:
// ---
// VBL IRQ handler
// Is invoked by the system on every VBLIRQ
// ---
void f_VBL_Handler()
{
// update number of frames, or any other code.
g_frames_rendered++;
}
void main()
{
// some init code for your app here
....
// enable VBL processing: assign the VBL Interrupt to
// our Function above
sys_int_Handler_Set(INT_TYPE_VBL,f_VBL_Handler);
// Turn the VBL interrupt on in the Display Status Register
M_DISSTAT_VBLIRQR_ON
// and enable the interrupt in the INTENA Register
M_INTENA_VBL_ENABLE
// Turn on Interrupts generally, using the Master Interrupt Register
M_INTMST_ENABLE
}
Actually, there is something new here, the first real "C" function in HAM.
Yes, there are a few real functions in HAM, all contained in system/mygba_sys.c
These will eventually go away and get available as a new product called HAMlib.
For now, you might want to know about what functions there are:
- Interrupt Setup
- Display BG Mode Datastorage
The BG Mode storage is *very* handy, you might want to check it out in the example
sources that came with HAM.
Makefiles/Linker Scripts made easy
HAM includes a simplified Makefile, which allows you to only change
3-4 well documented switches, and off you go. It is very easy, have a
look in the makefile's and see for yourself.
....and much more
there is quite a bit more to HAM than I was able to write up, but I am tired now.
Some Samples to get you started
There are currently a few samples for HAM, including a 3D spinning cube, a full Arkanoid
clone, a simple Hello World Program, and a mod-player example.
Licensing / Restrictions
All the terms are contained in the Readme.txt that comes with HAM.