GameBoy Advance Programming Tiles. Atari 196?: As an engineering student at the University of Utah,...
-
Upload
tabitha-banks -
Category
Documents
-
view
218 -
download
1
Transcript of GameBoy Advance Programming Tiles. Atari 196?: As an engineering student at the University of Utah,...
![Page 1: GameBoy Advance Programming Tiles. Atari 196?: As an engineering student at the University of Utah, Nolan Bushnell liked to sneak into the computer labs.](https://reader035.fdocuments.us/reader035/viewer/2022062517/56649efd5503460f94c11916/html5/thumbnails/1.jpg)
GameBoy AdvanceProgramming
Tiles
![Page 2: GameBoy Advance Programming Tiles. Atari 196?: As an engineering student at the University of Utah, Nolan Bushnell liked to sneak into the computer labs.](https://reader035.fdocuments.us/reader035/viewer/2022062517/56649efd5503460f94c11916/html5/thumbnails/2.jpg)
Atari• 196?: As an engineering student at the University of Utah,
Nolan Bushnell liked to sneak into the computer labs late at night to play computer games on the university's $7 million mainframes.
• 1972: Bushnell founded Atari with $250 of his own money and another $250 from business partner Ted Dabney. They then created and commercialized the world's first commercial video game, Pong. Bushnell was 27 years old.
• 1976: Warner Communications buys Atari from Bushnell for $28 million.
• 1977: Atari introduces the Atari Video Computer System (VCS), later renamed the Atari 2600
• 1978: December - Atari announces the Atari 400 and 800 personal computers.
• 1979: October - Atari begins shipping the Atari 400 and Atari 800 personal computers.
![Page 3: GameBoy Advance Programming Tiles. Atari 196?: As an engineering student at the University of Utah, Nolan Bushnell liked to sneak into the computer labs.](https://reader035.fdocuments.us/reader035/viewer/2022062517/56649efd5503460f94c11916/html5/thumbnails/3.jpg)
![Page 4: GameBoy Advance Programming Tiles. Atari 196?: As an engineering student at the University of Utah, Nolan Bushnell liked to sneak into the computer labs.](https://reader035.fdocuments.us/reader035/viewer/2022062517/56649efd5503460f94c11916/html5/thumbnails/4.jpg)
Typical Atari 800 Screenshot
![Page 5: GameBoy Advance Programming Tiles. Atari 196?: As an engineering student at the University of Utah, Nolan Bushnell liked to sneak into the computer labs.](https://reader035.fdocuments.us/reader035/viewer/2022062517/56649efd5503460f94c11916/html5/thumbnails/5.jpg)
Atari Graphics
• Graphics and Text Modes
• Display List
• Customizable Fonts– Area in memory that described fonts
(characters)– Area in memory that was what went on screen
• Player/Missile Graphics
![Page 6: GameBoy Advance Programming Tiles. Atari 196?: As an engineering student at the University of Utah, Nolan Bushnell liked to sneak into the computer labs.](https://reader035.fdocuments.us/reader035/viewer/2022062517/56649efd5503460f94c11916/html5/thumbnails/6.jpg)
GBA Tiles
• Logical extension of the customizable character sets. Some of the terms used today are based on the historical derivation of the technology
• (The logical extension of the player/missile graphics is sprites)
![Page 7: GameBoy Advance Programming Tiles. Atari 196?: As an engineering student at the University of Utah, Nolan Bushnell liked to sneak into the computer labs.](https://reader035.fdocuments.us/reader035/viewer/2022062517/56649efd5503460f94c11916/html5/thumbnails/7.jpg)
Mode 3 Bitmaps
Video Processing Circuitry
Screen
Video Memory
What color to make a certain pixel
![Page 8: GameBoy Advance Programming Tiles. Atari 196?: As an engineering student at the University of Utah, Nolan Bushnell liked to sneak into the computer labs.](https://reader035.fdocuments.us/reader035/viewer/2022062517/56649efd5503460f94c11916/html5/thumbnails/8.jpg)
Mode 4 Bitmaps
Video Processing Circuitry
Screen
Video Memory
What color number to make a certain pixel
Palette Memory
What color is that?
![Page 9: GameBoy Advance Programming Tiles. Atari 196?: As an engineering student at the University of Utah, Nolan Bushnell liked to sneak into the computer labs.](https://reader035.fdocuments.us/reader035/viewer/2022062517/56649efd5503460f94c11916/html5/thumbnails/9.jpg)
Mode 0 Tilemaps
Video Processing Circuitry
Screen
Video Memory
What tile number to make a groupof pixels
Palette Memory
What color is that?
TileImages(Character Blocks)
What does that tile look like?
![Page 10: GameBoy Advance Programming Tiles. Atari 196?: As an engineering student at the University of Utah, Nolan Bushnell liked to sneak into the computer labs.](https://reader035.fdocuments.us/reader035/viewer/2022062517/56649efd5503460f94c11916/html5/thumbnails/10.jpg)
Tiles On Screen
30
20
![Page 11: GameBoy Advance Programming Tiles. Atari 196?: As an engineering student at the University of Utah, Nolan Bushnell liked to sneak into the computer labs.](https://reader035.fdocuments.us/reader035/viewer/2022062517/56649efd5503460f94c11916/html5/thumbnails/11.jpg)
Tiles & Tilemaps
• Tile– 8x8 bitmap image
• Treated like big pixels, as the building block of an image
– 16 or 256 colors– 32 or 64 bytes
• Tile Map– 2D array of tile indexes– Tile : Tilemap :: Pixel : Bitmap
![Page 12: GameBoy Advance Programming Tiles. Atari 196?: As an engineering student at the University of Utah, Nolan Bushnell liked to sneak into the computer labs.](https://reader035.fdocuments.us/reader035/viewer/2022062517/56649efd5503460f94c11916/html5/thumbnails/12.jpg)
Tradeoff
• 8 bpp = 256 colors– Lots of colors– All tiles share the same palette.– Tile images take more space
• 4 bpp = 16 palettes of 16 colors apiece– Still have 256 colors
• More constraints• More flexibility
– Tile images smaller (i.e. can have more)
![Page 13: GameBoy Advance Programming Tiles. Atari 196?: As an engineering student at the University of Utah, Nolan Bushnell liked to sneak into the computer labs.](https://reader035.fdocuments.us/reader035/viewer/2022062517/56649efd5503460f94c11916/html5/thumbnails/13.jpg)
Illustrations from Tonc
![Page 14: GameBoy Advance Programming Tiles. Atari 196?: As an engineering student at the University of Utah, Nolan Bushnell liked to sneak into the computer labs.](https://reader035.fdocuments.us/reader035/viewer/2022062517/56649efd5503460f94c11916/html5/thumbnails/14.jpg)
GBA Tile Mode Features
• Up to 4 tiled background layers– Up to 1024x1024 pixels each
• Hardware scrolling– Maps can be larger than the screen
• Hardware Parallax (optional)– Layers scroll at different speeds to simulate
depth
• Affine transformation (optional)– Rotation and scaling effects
![Page 15: GameBoy Advance Programming Tiles. Atari 196?: As an engineering student at the University of Utah, Nolan Bushnell liked to sneak into the computer labs.](https://reader035.fdocuments.us/reader035/viewer/2022062517/56649efd5503460f94c11916/html5/thumbnails/15.jpg)
Steps to Tiles
• Create tile images
• Create screen image
• Create a palette
• Store tile images in a character block
• Store screen image in one or more screen blocks
• Store palette in palette memory area
• Set image control buffer and Mode
![Page 16: GameBoy Advance Programming Tiles. Atari 196?: As an engineering student at the University of Utah, Nolan Bushnell liked to sneak into the computer labs.](https://reader035.fdocuments.us/reader035/viewer/2022062517/56649efd5503460f94c11916/html5/thumbnails/16.jpg)
Steps to Tiles
1. Create tile images
2. Create screen image
3. Create a palette
4. Store tile images in a character block
5. Store screen image in one or more screen blocks
6. Store palette in palette memory area
7. Set image control buffer and Mode
![Page 17: GameBoy Advance Programming Tiles. Atari 196?: As an engineering student at the University of Utah, Nolan Bushnell liked to sneak into the computer labs.](https://reader035.fdocuments.us/reader035/viewer/2022062517/56649efd5503460f94c11916/html5/thumbnails/17.jpg)
1&2&3. gfx2gba• Usagegfx2gba -fsrc -t8 -mm file.bmp
gfx2gba -fsrc -t8 -mm -c16 file.bmp
• -fsrc means produce c source files• -t8 means 8 bit tiles• -m Optimize tile images (remove duplicates, flip,
etc.• -c16 4bpp• file.bmp should be a 256 color (8bpp) image.• Add files to your project and extern them in your
other files.
![Page 18: GameBoy Advance Programming Tiles. Atari 196?: As an engineering student at the University of Utah, Nolan Bushnell liked to sneak into the computer labs.](https://reader035.fdocuments.us/reader035/viewer/2022062517/56649efd5503460f94c11916/html5/thumbnails/18.jpg)
1&2&3. usenti
![Page 19: GameBoy Advance Programming Tiles. Atari 196?: As an engineering student at the University of Utah, Nolan Bushnell liked to sneak into the computer labs.](https://reader035.fdocuments.us/reader035/viewer/2022062517/56649efd5503460f94c11916/html5/thumbnails/19.jpg)
4,5&6. Video Memory
CBB0 CBB1 CBB2 CBB3 CBB4 CBB5
![Page 20: GameBoy Advance Programming Tiles. Atari 196?: As an engineering student at the University of Utah, Nolan Bushnell liked to sneak into the computer labs.](https://reader035.fdocuments.us/reader035/viewer/2022062517/56649efd5503460f94c11916/html5/thumbnails/20.jpg)
4,5&6. Video Memory
CBB0 CBB1 CBB2 CBB3 CBB4 CBB5
Tile Palette: 0x5000000
![Page 21: GameBoy Advance Programming Tiles. Atari 196?: As an engineering student at the University of Utah, Nolan Bushnell liked to sneak into the computer labs.](https://reader035.fdocuments.us/reader035/viewer/2022062517/56649efd5503460f94c11916/html5/thumbnails/21.jpg)
4,5&6. Video Memory
CBB0 CBB1 CBB2 CBB3 CBB4 CBB5
Character Blocks 4 for tile images and maps 0x6000000
16kb 2kb
![Page 22: GameBoy Advance Programming Tiles. Atari 196?: As an engineering student at the University of Utah, Nolan Bushnell liked to sneak into the computer labs.](https://reader035.fdocuments.us/reader035/viewer/2022062517/56649efd5503460f94c11916/html5/thumbnails/22.jpg)
4,5&6. Video Memory
CBB0 CBB1 CBB2 CBB3 CBB4 CBB5
Tile Palette: 0x5000000
Character Blocks 4 for tile images and maps 0x6000000
16kb 2kb
![Page 23: GameBoy Advance Programming Tiles. Atari 196?: As an engineering student at the University of Utah, Nolan Bushnell liked to sneak into the computer labs.](https://reader035.fdocuments.us/reader035/viewer/2022062517/56649efd5503460f94c11916/html5/thumbnails/23.jpg)
4,5&6. Video Memory
CBB0 CBB1 CBB2 CBB3 CBB4 CBB5
0
1
2
3
4
0 0 0 00 2 3 02 1 1 34 4 4 4
Stop Here
![Page 24: GameBoy Advance Programming Tiles. Atari 196?: As an engineering student at the University of Utah, Nolan Bushnell liked to sneak into the computer labs.](https://reader035.fdocuments.us/reader035/viewer/2022062517/56649efd5503460f94c11916/html5/thumbnails/24.jpg)
Tile Size
• One 256 color tile has 8x8 8-bit indexes for a total of 64 bytes. One character block will hold 256 of these tile images.
• One 16 color tile has 8x8 4-bit indexes for a total of 32 bytes. One character block will hold 512 of these images
• Recall that there are 4 screen blocks but space for the tile map must be allocated.
![Page 25: GameBoy Advance Programming Tiles. Atari 196?: As an engineering student at the University of Utah, Nolan Bushnell liked to sneak into the computer labs.](https://reader035.fdocuments.us/reader035/viewer/2022062517/56649efd5503460f94c11916/html5/thumbnails/25.jpg)
Do the Math
• Suppose you had an image that was very complex?
![Page 26: GameBoy Advance Programming Tiles. Atari 196?: As an engineering student at the University of Utah, Nolan Bushnell liked to sneak into the computer labs.](https://reader035.fdocuments.us/reader035/viewer/2022062517/56649efd5503460f94c11916/html5/thumbnails/26.jpg)
![Page 27: GameBoy Advance Programming Tiles. Atari 196?: As an engineering student at the University of Utah, Nolan Bushnell liked to sneak into the computer labs.](https://reader035.fdocuments.us/reader035/viewer/2022062517/56649efd5503460f94c11916/html5/thumbnails/27.jpg)
Can we tile this image?
![Page 28: GameBoy Advance Programming Tiles. Atari 196?: As an engineering student at the University of Utah, Nolan Bushnell liked to sneak into the computer labs.](https://reader035.fdocuments.us/reader035/viewer/2022062517/56649efd5503460f94c11916/html5/thumbnails/28.jpg)
How big are things
• 16 color tiles are 32 bytes apiece
• 256 color tiles are 64 bytes apiece
![Page 29: GameBoy Advance Programming Tiles. Atari 196?: As an engineering student at the University of Utah, Nolan Bushnell liked to sneak into the computer labs.](https://reader035.fdocuments.us/reader035/viewer/2022062517/56649efd5503460f94c11916/html5/thumbnails/29.jpg)
Can we tile this image?
• Mode 3 video memory is 38400 shorts of 76800 bytes or 75KB
• In tile mode at 8bpp (same as Mode 4) we will use 38400 bytes
• In tile mode at 4 bpp we would use only 19200 bytes
• EXCEPT!!!!
![Page 30: GameBoy Advance Programming Tiles. Atari 196?: As an engineering student at the University of Utah, Nolan Bushnell liked to sneak into the computer labs.](https://reader035.fdocuments.us/reader035/viewer/2022062517/56649efd5503460f94c11916/html5/thumbnails/30.jpg)
Max Number of Tiles
• In the tile map 10 bits are allocated to identify which tile goes in each position
• 10 bits means we can only have 1024 unique tiles – We can actually make it look like more since
tiles can be flipped or be colored differently
• The screen is 20x30 tiles or 600 so we cannot tile an image that is > 1024 unique tiles!
![Page 31: GameBoy Advance Programming Tiles. Atari 196?: As an engineering student at the University of Utah, Nolan Bushnell liked to sneak into the computer labs.](https://reader035.fdocuments.us/reader035/viewer/2022062517/56649efd5503460f94c11916/html5/thumbnails/31.jpg)
Mode & BG Specifics
• Mode Backgrounds Rotation/Scaling
• 0 0, 1, 2, 3 No• 1 0, 1, 2 Yes (only background 2)
• 2 2, 3 YesBackground Resolution Rotation/Scaling• 0 512 x 512 No• 1 512 x 512 No• 2 128 to 1024 Yes• 3 128 to 1024 Yes
![Page 32: GameBoy Advance Programming Tiles. Atari 196?: As an engineering student at the University of Utah, Nolan Bushnell liked to sneak into the computer labs.](https://reader035.fdocuments.us/reader035/viewer/2022062517/56649efd5503460f94c11916/html5/thumbnails/32.jpg)
Background Layers
• 0 & 1– Max Resolution 512x512– Tile map of 16 bit numbers
• 2 & 3– Resolution from 128x128 to 1024x1024– Rotation & Scaling– Tile map of 8 bit numbers
![Page 33: GameBoy Advance Programming Tiles. Atari 196?: As an engineering student at the University of Utah, Nolan Bushnell liked to sneak into the computer labs.](https://reader035.fdocuments.us/reader035/viewer/2022062517/56649efd5503460f94c11916/html5/thumbnails/33.jpg)
Color
• 256 color tiles– 8 bits per pixel– Tiles share one 256 color palette
• 16 color tiles– 4 bits per pixel– Tiles use one of 16 palettes, 16 colors each– Note: Total palette is still 256 colors
Correct Incorrect: 256 color tiles being displayed as 16 color tiles
![Page 34: GameBoy Advance Programming Tiles. Atari 196?: As an engineering student at the University of Utah, Nolan Bushnell liked to sneak into the computer labs.](https://reader035.fdocuments.us/reader035/viewer/2022062517/56649efd5503460f94c11916/html5/thumbnails/34.jpg)
Tile Memory
• Double the sprite memory compared with bitmap modes
• Tile data video in video buffer– From 0x6000000 to 0x600FFFF– On 16k boundary (any of 4 spots)
• Tile map also stored in video buffer– On 2k boundary (any of 32 spots)
• Tile data and Tile map are in same space but normally would not overlap.
![Page 35: GameBoy Advance Programming Tiles. Atari 196?: As an engineering student at the University of Utah, Nolan Bushnell liked to sneak into the computer labs.](https://reader035.fdocuments.us/reader035/viewer/2022062517/56649efd5503460f94c11916/html5/thumbnails/35.jpg)
Video Memory
CBB0 CBB1 CBB2 CBB3 CBB4 CBB5
Tile Palette: 0x5000000
Character Blocks 4 for tile images and maps 0x6000000
16kb 2kb
![Page 36: GameBoy Advance Programming Tiles. Atari 196?: As an engineering student at the University of Utah, Nolan Bushnell liked to sneak into the computer labs.](https://reader035.fdocuments.us/reader035/viewer/2022062517/56649efd5503460f94c11916/html5/thumbnails/36.jpg)
Tile Data and Tile Map
• The tile map is stored in the same location as the video buffer (in the bitmap video modes), an array of numbers that point to the tile images.
• In text backgrounds (0 and 1) the tile map is
comprised of 16-bit numbers, while the rotation backgrounds (2 and 3) store 8-bit numbers in the tile map.
• When working with tile-based modes, video memory is divided into 4 logical char base blocks, which are made up of 32 smaller screen base blocks, as shown on the next slide.
![Page 37: GameBoy Advance Programming Tiles. Atari 196?: As an engineering student at the University of Utah, Nolan Bushnell liked to sneak into the computer labs.](https://reader035.fdocuments.us/reader035/viewer/2022062517/56649efd5503460f94c11916/html5/thumbnails/37.jpg)
Techniques
• Tile images must start at the beginning of a character block
• Tile maps must start at the beginning of a screen block
• How do we determine the correct address
• How do we do this in a C program?
![Page 38: GameBoy Advance Programming Tiles. Atari 196?: As an engineering student at the University of Utah, Nolan Bushnell liked to sneak into the computer labs.](https://reader035.fdocuments.us/reader035/viewer/2022062517/56649efd5503460f94c11916/html5/thumbnails/38.jpg)
4&5. Technique 1
• Calculate the address of each character block and each screen block and create a bunch of #defines for each one#define CHARACTERBLOCK0 0x6000000
#define CHARACTERBLOCK1 0x6004000
...
#define SCREENBLOCK0 0x6000000
#define SCREENBLOCK1 0x6000800
...
![Page 39: GameBoy Advance Programming Tiles. Atari 196?: As an engineering student at the University of Utah, Nolan Bushnell liked to sneak into the computer labs.](https://reader035.fdocuments.us/reader035/viewer/2022062517/56649efd5503460f94c11916/html5/thumbnails/39.jpg)
4&5. Technique 2
• Write macros to calculate the addresses#define CHARBLOCK(n) \
(unsigned short *) (0x6000000+(n)*0x4000)
#define SCREENBLOCK(n) \
(unsigned short *) (0x6000000+(n)*0x800)
![Page 40: GameBoy Advance Programming Tiles. Atari 196?: As an engineering student at the University of Utah, Nolan Bushnell liked to sneak into the computer labs.](https://reader035.fdocuments.us/reader035/viewer/2022062517/56649efd5503460f94c11916/html5/thumbnails/40.jpg)
4&5. Technique 3
• Let C do all the work!• Define structures: typedef struct { u16 tileimg[8192]; }
charblock;
typedef struct { u16 tilemap[1024]; }
screenblock;
• Define pointers charblock *charblockBase = (charblock *)0x6000000;
screenblock *screenblockBase =
(screenblock *)0x6000000;
![Page 41: GameBoy Advance Programming Tiles. Atari 196?: As an engineering student at the University of Utah, Nolan Bushnell liked to sneak into the computer labs.](https://reader035.fdocuments.us/reader035/viewer/2022062517/56649efd5503460f94c11916/html5/thumbnails/41.jpg)
4&5. Technique 3 Continued
• Now you can directly access the block you want using array indexing!!!!for(i=0; i<PicTileLen; i++){
charblockBase[1].tileimg[i] = picTile[i];
}
• What if i exceeds 8192???
![Page 42: GameBoy Advance Programming Tiles. Atari 196?: As an engineering student at the University of Utah, Nolan Bushnell liked to sneak into the computer labs.](https://reader035.fdocuments.us/reader035/viewer/2022062517/56649efd5503460f94c11916/html5/thumbnails/42.jpg)
6. Palette
• No different than Mode 4!
![Page 43: GameBoy Advance Programming Tiles. Atari 196?: As an engineering student at the University of Utah, Nolan Bushnell liked to sneak into the computer labs.](https://reader035.fdocuments.us/reader035/viewer/2022062517/56649efd5503460f94c11916/html5/thumbnails/43.jpg)
7. Control Registers
//background offset registers
#define REG_BG0HOFS *(volatile unsigned short *)0x04000010
#define REG_BG1HOFS *(volatile unsigned short *)0x04000014
#define REG_BG2HOFS *(volatile unsigned short *)0x04000018
#define REG_BG3HOFS *(volatile unsigned short *)0x0400001C
#define REG_BG0VOFS *(volatile unsigned short *)0x04000012
#define REG_BG1VOFS *(volatile unsigned short *)0x04000016
#define REG_BG2VOFS *(volatile unsigned short *)0x0400001A
#define REG_BG3VOFS *(volatile unsigned short *)0x0400001E
//background control registers
#define REG_BG0CNT *(volatile unsigned short*)0x4000008
#define REG_BG1CNT *(volatile unsigned short*)0x400000A
#define REG_BG2CNT *(volatile unsigned short*)0x400000C
#define REG_BG3CNT *(volatile unsigned short*)0x400000E
![Page 44: GameBoy Advance Programming Tiles. Atari 196?: As an engineering student at the University of Utah, Nolan Bushnell liked to sneak into the computer labs.](https://reader035.fdocuments.us/reader035/viewer/2022062517/56649efd5503460f94c11916/html5/thumbnails/44.jpg)
7. BGxCNT
bits name description
0-1 Pr Priority. Determines drawing order of backgrounds.
2-3 CBB Character Base Block. Sets the charblock that serves as the base
for character/tile indexing. Values: 0-3.
6 Mos Mosaic flag. Enables mosaic effect.
7 CM Color Mode. 16 colors (4bpp) if cleared; 256 colors (8bpp) if set.
8-12 SBB Screen Base Block. Sets the screenblock that serves as the base
for screen-entry/map indexing. Values: 0-31.
13 Wr Affine Wrapping flag. If set, affine background wrap around at their
edges. Has no effect on regular backgrounds as they wrap around
by default.
14-15 Sz Background Size. Regular and affine backgrounds have different
sizes available to them.
15 14 13 12 11 10 09 08 07 06 05 04 03 02 01 00
0F 0E 0D 0C 0B 0A 09 08 07 06 05 04 03 02 01 00
PrCBBMCMSBBWrSz
![Page 45: GameBoy Advance Programming Tiles. Atari 196?: As an engineering student at the University of Utah, Nolan Bushnell liked to sneak into the computer labs.](https://reader035.fdocuments.us/reader035/viewer/2022062517/56649efd5503460f94c11916/html5/thumbnails/45.jpg)
BGxCNT #defines
//macros and bit constants for setting the background control register specifics
#define SBB(num) num << 8
#define CBB(num) num << 2
#define COLOR256 1 << 7
// Cols x Row
#define BG_SIZE0 0<<14 // 32 x 32 tiles
#define BG_SIZE1 1<<14 // 64 x 32
#define BG_SIZE2 2<<14 // 32 x 64
#define BG_SIZE3 3<<14 // 64 x 64
![Page 46: GameBoy Advance Programming Tiles. Atari 196?: As an engineering student at the University of Utah, Nolan Bushnell liked to sneak into the computer labs.](https://reader035.fdocuments.us/reader035/viewer/2022062517/56649efd5503460f94c11916/html5/thumbnails/46.jpg)
Tile Maps
bits name description
0-9 TID Tile ID 0-511 (Thus maximum number of tiles per background is 512
10 HF Horizontal flip if set
11 VF Vertical flip if set
12-15 PB Palette bank in 4bpp (16 color) mode. Ignored in 8bpp (256 color)
mode
15 14 13 12 11 10 09 08 07 06 05 04 03 02 01 00
0F 0E 0D 0C 0B 0A 09 08 07 06 05 04 03 02 01 00
PB VF HF TID
![Page 47: GameBoy Advance Programming Tiles. Atari 196?: As an engineering student at the University of Utah, Nolan Bushnell liked to sneak into the computer labs.](https://reader035.fdocuments.us/reader035/viewer/2022062517/56649efd5503460f94c11916/html5/thumbnails/47.jpg)
Moving on a Big Map
![Page 48: GameBoy Advance Programming Tiles. Atari 196?: As an engineering student at the University of Utah, Nolan Bushnell liked to sneak into the computer labs.](https://reader035.fdocuments.us/reader035/viewer/2022062517/56649efd5503460f94c11916/html5/thumbnails/48.jpg)
What's your model?Screen Moves?
MAP
SCREEN
![Page 49: GameBoy Advance Programming Tiles. Atari 196?: As an engineering student at the University of Utah, Nolan Bushnell liked to sneak into the computer labs.](https://reader035.fdocuments.us/reader035/viewer/2022062517/56649efd5503460f94c11916/html5/thumbnails/49.jpg)
What's your model?
MAP
SCREEN
![Page 50: GameBoy Advance Programming Tiles. Atari 196?: As an engineering student at the University of Utah, Nolan Bushnell liked to sneak into the computer labs.](https://reader035.fdocuments.us/reader035/viewer/2022062517/56649efd5503460f94c11916/html5/thumbnails/50.jpg)
What's your model?
MAP
SCREEN
![Page 51: GameBoy Advance Programming Tiles. Atari 196?: As an engineering student at the University of Utah, Nolan Bushnell liked to sneak into the computer labs.](https://reader035.fdocuments.us/reader035/viewer/2022062517/56649efd5503460f94c11916/html5/thumbnails/51.jpg)
What's your model?
MAP
MAP
MAP
MAP
SCREEN
![Page 52: GameBoy Advance Programming Tiles. Atari 196?: As an engineering student at the University of Utah, Nolan Bushnell liked to sneak into the computer labs.](https://reader035.fdocuments.us/reader035/viewer/2022062517/56649efd5503460f94c11916/html5/thumbnails/52.jpg)
Or Map Moves?
MAP
SCREEN
![Page 53: GameBoy Advance Programming Tiles. Atari 196?: As an engineering student at the University of Utah, Nolan Bushnell liked to sneak into the computer labs.](https://reader035.fdocuments.us/reader035/viewer/2022062517/56649efd5503460f94c11916/html5/thumbnails/53.jpg)
What's your model?
MAP MAP
SCREEN
![Page 54: GameBoy Advance Programming Tiles. Atari 196?: As an engineering student at the University of Utah, Nolan Bushnell liked to sneak into the computer labs.](https://reader035.fdocuments.us/reader035/viewer/2022062517/56649efd5503460f94c11916/html5/thumbnails/54.jpg)
What's your model?
MAP MAP
SCREEN
![Page 55: GameBoy Advance Programming Tiles. Atari 196?: As an engineering student at the University of Utah, Nolan Bushnell liked to sneak into the computer labs.](https://reader035.fdocuments.us/reader035/viewer/2022062517/56649efd5503460f94c11916/html5/thumbnails/55.jpg)
What's your model?
MAP
MAPMAP
MAP
SCREEN
![Page 56: GameBoy Advance Programming Tiles. Atari 196?: As an engineering student at the University of Utah, Nolan Bushnell liked to sneak into the computer labs.](https://reader035.fdocuments.us/reader035/viewer/2022062517/56649efd5503460f94c11916/html5/thumbnails/56.jpg)
What's your model?
MAP
SCREEN
Either Works!
![Page 57: GameBoy Advance Programming Tiles. Atari 196?: As an engineering student at the University of Utah, Nolan Bushnell liked to sneak into the computer labs.](https://reader035.fdocuments.us/reader035/viewer/2022062517/56649efd5503460f94c11916/html5/thumbnails/57.jpg)
I like the screen moves
MAP
SCREEN
hoffvoff
The signs make more sense!
![Page 58: GameBoy Advance Programming Tiles. Atari 196?: As an engineering student at the University of Utah, Nolan Bushnell liked to sneak into the computer labs.](https://reader035.fdocuments.us/reader035/viewer/2022062517/56649efd5503460f94c11916/html5/thumbnails/58.jpg)
Use map coordinates
MAP
SCREEN
hoffvoff Row
Col
![Page 59: GameBoy Advance Programming Tiles. Atari 196?: As an engineering student at the University of Utah, Nolan Bushnell liked to sneak into the computer labs.](https://reader035.fdocuments.us/reader035/viewer/2022062517/56649efd5503460f94c11916/html5/thumbnails/59.jpg)
Where to draw it?
MAP
SCREEN
hoffvoff Row
Col
Screen coordinates for objectrowscreen = row -voffcolscreen = col -hoff
![Page 60: GameBoy Advance Programming Tiles. Atari 196?: As an engineering student at the University of Utah, Nolan Bushnell liked to sneak into the computer labs.](https://reader035.fdocuments.us/reader035/viewer/2022062517/56649efd5503460f94c11916/html5/thumbnails/60.jpg)
Questions?
![Page 61: GameBoy Advance Programming Tiles. Atari 196?: As an engineering student at the University of Utah, Nolan Bushnell liked to sneak into the computer labs.](https://reader035.fdocuments.us/reader035/viewer/2022062517/56649efd5503460f94c11916/html5/thumbnails/61.jpg)
Tile Setup//background setup registers and data#define REG_BG0CNT *(volatile unsigned short*)0x4000008#define REG_BG1CNT *(volatile unsigned short*)0x400000A#define REG_BG2CNT *(volatile unsigned short*)0x400000C#define REG_BG3CNT *(volatile unsigned short*)0x400000E#define BG_COLOR256 0x80#define CHAR_SHIFT 2#define SCREEN_SHIFT 8#define WRAPAROUND 0x1
//background tile bitmap sizes#define TEXTBG_SIZE_256x256 0x0#define TEXTBG_SIZE_256x512 0x8000#define TEXTBG_SIZE_512x256 0x4000#define TEXTBG_SIZE_512x512 0xC000
//background memory offset macros#define CharBaseBlock(n) (((n)*0x4000)+0x6000000)#define ScreenBaseBlock(n) (((n)*0x800)+0x6000000)
//background mode identifiers#define BG0_ENABLE 0x100#define BG1_ENABLE 0x200#define BG2_ENABLE 0x400#define BG3_ENABLE 0x800
![Page 62: GameBoy Advance Programming Tiles. Atari 196?: As an engineering student at the University of Utah, Nolan Bushnell liked to sneak into the computer labs.](https://reader035.fdocuments.us/reader035/viewer/2022062517/56649efd5503460f94c11916/html5/thumbnails/62.jpg)
Tile setup (cont)//video identifiers
#define REG_DISPCNT *(unsigned int*)0x4000000
#define BGPaletteMem ((unsigned short*)0x5000000)
#define SetMode(mode) REG_DISPCNT = (mode)
//vertical refresh register
#define REG_DISPSTAT *(volatile unsigned short*)0x4000004
//button identifiers
#define BUTTON_RIGHT 16
#define BUTTON_LEFT 32
#define BUTTON_UP 64
#define BUTTON_DOWN 128
#define BUTTONS (*(volatile unsigned int*)0x04000130)
![Page 63: GameBoy Advance Programming Tiles. Atari 196?: As an engineering student at the University of Utah, Nolan Bushnell liked to sneak into the computer labs.](https://reader035.fdocuments.us/reader035/viewer/2022062517/56649efd5503460f94c11916/html5/thumbnails/63.jpg)
Tile setup(cont)int main(void)
{
//create a pointer to background 0 tilemap buffer
unsigned short* bg0map =(unsigned short*)ScreenBaseBlock(31);
//set up background 0
REG_BG0CNT = BG_COLOR256 | TEXTBG_SIZE_256x256 | (31 << SCREEN_SHIFT) | WRAPAROUND;
//set video mode 0 with background 0
SetMode(0 | BG0_ENABLE);
//copy the palette into the background palette memory
DMAFastCopy((void*)test_Palette, (void*)BGPaletteMem, 256, DMA_16NOW);
//copy the tile images into the tile memory
DMAFastCopy((void*)test_Tiles, (void*)CharBaseBlock(0), 57984/4, DMA_32NOW);
//copy the tile map into background 0
DMAFastCopy((void*)test_Map, (void*)bg0map, 512, DMA_32NOW);
![Page 64: GameBoy Advance Programming Tiles. Atari 196?: As an engineering student at the University of Utah, Nolan Bushnell liked to sneak into the computer labs.](https://reader035.fdocuments.us/reader035/viewer/2022062517/56649efd5503460f94c11916/html5/thumbnails/64.jpg)
Input & Tile Scrolling
//main game loopwhile(1){ //wait for vertical refreshWaitVBlank();
//D-pad moves backgroundif(!(BUTTONS & BUTTON_LEFT)) x--;if(!(BUTTONS & BUTTON_RIGHT)) x++;if(!(BUTTONS & BUTTON_UP)) y--;if(!(BUTTONS & BUTTON_DOWN)) y++;
//use hardware background scrollingREG_BG0VOFS = y ;REG_BG0HOFS = x ;
//wait for vertical refreshWaitVBlank();
for(n = 0; n < 4000; n++);}return 0;}
![Page 65: GameBoy Advance Programming Tiles. Atari 196?: As an engineering student at the University of Utah, Nolan Bushnell liked to sneak into the computer labs.](https://reader035.fdocuments.us/reader035/viewer/2022062517/56649efd5503460f94c11916/html5/thumbnails/65.jpg)
Questions?
![Page 66: GameBoy Advance Programming Tiles. Atari 196?: As an engineering student at the University of Utah, Nolan Bushnell liked to sneak into the computer labs.](https://reader035.fdocuments.us/reader035/viewer/2022062517/56649efd5503460f94c11916/html5/thumbnails/66.jpg)