GBA Static Image Demos

tested on mbv2, visoly flash, and visualboyadvance


This program for Game Boy Advance combines the following demos
into one smaller download:

* Gamma test (hardcoded to gamma = 4)
* 6 pixel wide tiles
* A mirror
* Interlace test


The build process involves bin2h.c, which is NOT a GBA program.  It
is a PC program that converts binary files specified on the command
line to a C include file on stdout.  In other words:

  bin2h foo.bin bar.bin > foo_bin.h

produces a file foo_bin.h that contains

  unsigned char foo_bin[4096] = { ... };
  unsigned char bar_bin[1536] = { ... };

To compile bin2h, bring your NATIVE compiler (NOT your ARM toolchain)
into the PATH and then run this command:
  gcc -Wall -O3 -s bin2h.c -o bin2h.exe

To compile the test program, get fenix's Unofficial Game Boy Advance
Software Development Kit (http://www.io.com/~fenix/devkitadv/)
and bring it into the PATH.  Then run this command:
  mk
It will produce a GBA executable 'static.mb.gba' that you can flash
to a cartridge or run over MBV2.  It does not currently replace the
header information (although that would be lawful fair use).


=== Gamma test ===

The Game Boy Advance handheld game system has a very dark display.
We can measure nonlinearity of a display system by applying a
measurement called "gamma."  Raising a pixel value to the gamma power
will produce its real intensity; raising an intensity to the power
(1/gamma) will produce the correct value.  CRT displays typically
have a gamma between 2.2 and 2.5; GBA's is closer to 4.

The GBA program gamma.c displays 30 shades of gray and dithered
approximations, which are more likely to have a linear response.
It uses a gamma value of 4, determined after several rounds of
testing on the real hardware.  To test the program on your display
(which may have different characteristics), compile it (the package
includes a batch file mk.bat compatible with the Cygwin version of
devkit-advance) and send it over the MBV2 cable to a GBA system.

To counteract the GBA display's gamma correction, you will need
to gamma-correct your palettes by raising each component to the
0.25 power if they're linear, or to the 0.55 power if they're
sRGB.  A simple lookup table will do, or you can precompute them
during compilation.


=== 6 pixel wide tiles ===

Often, in puzzle games, you want to fit more than 10 tiles vertically
on the Game Boy Advance's 160 pixel tall display without having to
drop down to 8-pixel tiles.  I have solved this problem with Mode 7.

Mode 7 refers to affine mapping of the coordinates of pixels on a
scanline to texels on a plane.  It originated on the Super NES
console, where the display mode was actually numbered 0x07.  Several
Amiga games and PC games (such as Tetanus On Drugs) create a Mode 7
effect in software.  The GBA has at least one layer of hardware
Mode 7 in two tiled display modes: mode 1 (BG0 and BG1 direct,
BG2 affine) and mode 2 (BG2 and BG3 affine).

Essentially, I pre-scale tile images from their drawn width to eight
pixels wide and then program the affine registers to scale them
back down to six pixels wide.  This lets me address each 6x8 tile
individually but wreaks havoc with "High Resolution Mode 7" options
in emulators; turn them off (instead turning on Super 2xSAI) or run
programs on real hardware.

You can draw 6 pixel tall tiles by making appropriate modifications
to the BGAFFINE registers using DMA, skipping the last two scanlines
of each tile.  This can also be done without Mode 7, but the tiles
end up stretched out horizontally (8x6) unless you do use Mode 7.
Making the tiles only 6 pixels tall (two tiles equaling 12 pixels)
lets you do the 12-line-tall playfields required by such games as
Puyo Puyo, Panel de Pon, and Wario's Woods.


=== Mirror ===

The GBA display is very reflective.  Simply by turning the display
black, you can get a decent reflection just off the scratch shield.
Select Mirror to blacken the display; press A to return to the menu.


=== Interlace ===

Like the Game Boy Color, the Game Boy Advance has an interlaced
display that runs asynchronously of the rest of the hardware.  Like a
TV, it draws even scanlines in even-numbered frames and odd scanlines
in odd frames.  This could be used to advantage in a demo that uses
mode 3, 4, or 5 to double the effective fill rate.


=== Legal information ===

<license type="permissive" name="Expat License">
Copyright 2001-2002 Damian Yerrick

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
IN THE SOFTWARE.
</license>

Pin Eight and Tetanus On Drugs are trademarks of Damian Yerrick.
Nintendo, Game Boy, and Super NES, are trademarks of nintendo.
Amiga is a trademark of Amiga Inc.
All other trademark are belong to their respective owners.

