CS2260 Media Device Architectures GBA Tile Modes - PowerPoint PPT Presentation

1 / 16
About This Presentation
Title:

CS2260 Media Device Architectures GBA Tile Modes

Description:

Tile modes support multiple backgrounds ... 2, 3 or 4 background layers to draw in ... For the rotation backgrounds, each entry in a tile map is only 8 bits ... – PowerPoint PPT presentation

Number of Views:121
Avg rating:3.0/5.0
Slides: 17
Provided by: michael1692
Category:

less

Transcript and Presenter's Notes

Title: CS2260 Media Device Architectures GBA Tile Modes


1
CS2260 Media Device ArchitecturesGBA Tile Modes
2
Tiles modes
  • Modes 0, 1 and 2 are the tile modes
  • In the tile modes, the primitives you draw with
    are tiles rather than pixels
  • Tiles are bitmaps hence theyre made out of
    pixels
  • But you define your tiles offline using special
    tools your code manipulates the tiles rather
    than the individual pixels
  • Tiles are 8x8 bitmaps
  • A full screen consists of 30 tiles across (240)
    by 20 tiles down (160)

3
Tiles and tile maps
  • Creating a screen image in the tile modes
    requires defining two things
  • The tiles themselves (the 8x8 bitmaps)
  • A tile map
  • A tile map consists of indices into the tiles
  • Analogous to bitmap mode 4, where the screen
    image consists of indices into the palette
  • The size of the tile map
  • The screen is 30x20 tiles
  • A tile index is 16 bits (in a moment well see
    that sometimes you use 8 bit indices)
  • So a tilemap that files the screen takes up 30
    20 2 1200 bytes
  • Compare this to the number of bytes needed to
    specify all the pixels on the screen 240 160
    2 76800 bytes
  • So with a well designed tile map, you can
    inexpensively (in bytes) define many many
    different screen images

4
Example of tiles and tile maps
Tiles
Image
Tile map
Unsigned short tileMap64 0, 0, 0, 0, 0, 0,
0, 0, 0, 2, 2, 2, 2, 2, 2, 0, 0, 2, 1, 1, 1, 1,
2, 0, 0, 2, 1, 3, 3, 1, 2, 0, 0, 2, 1, 3, 3, 1,
2, 0, 0, 2, 1, 1, 1, 1, 2, 0, 0, 2, 2, 2, 2, 2,
2, 0, 0, 0, 0, 0, 0, 0, 0, 0
5
Tile modes support multiple backgrounds
  • In the bitmap modes, we only had one layer
    (background) to draw in
  • E.g. SetMode(MODE_3 BG2_ENABLE)
  • In the tile modes we have 2, 3 or 4 background
    layers to draw in
  • The GBA hardware automatically keeps track of
    occlusions with multiple layers
  • Thus we can easily create layered images

6
Scrolling
  • Tile maps can be bigger than the screen
  • The tile modes support hardware scrolling across
    the tile map
  • Scroll in both x and y
  • Thus, easy to define a game level bigger than the
    screen (a large tile map) and scroll the screen
    as the player moves around in the level
  • With multiple layers scrolling, can easily
    implement paralax scrolling
  • Lets think about what it would take to do this
    manually in the bitmap modes

7
Rotation and scaling
  • In some of the tile modes, there is hardware
    support for rotation and scaling and tile maps
  • Scaling can be used to zoom in and pull out of
    your tile map
  • Of course, the hardware cant automatically
    create more detail for you the hardware is
    simply doing pixel doubling

8
Tile modes and backgrounds
Tiled Video Modes Mode Background Rotation/Scali
ng 0 0, 1, 2, 3 No 1 0, 1, 2 Yes (2) 2 2,
3 Yes (2, 3) Backgrounds Background Max
Resolution (pixels) Rotation/Scaling 0 512x512
No 1 512x512 No 2 1024x1024 Yes 3 1024
x1024 Yes
9
Storing the tile data and tile map
  • The tile data and tile map are both stored in
    video memory
  • Tile data (the 8x8 bitmaps for tiles) can be
    stored anywhere in VRAM, but the tile data must
    begin on a 16K boundary
  • The tile map can be stored anwhere in VRAM, but
    the tile map must begin on a 2K boundary

10
VRAM map in tile modes
11
The tile bitmaps use a palette
  • The tile data (tile bitmaps) are not specified as
    direct colors, but rather as indices into a
    palette (like mode 4)
  • Two choices
  • 8 bit indices into a 256 color palette (like mode
    4)
  • 4 bit indices into a 16 color palette
  • If you use a 16 color palette, you can specify up
    to 16 palettes

12
Background control registers
  • As usual on the GBA, each background has a
    control register
  • REG_BGxCNT

Bit Function 15-14 Background size 13 Wrap
tile map repeats at edge (only applicable to
rotation backgrounds, text backgrounds always
wrap 12-8 Screen base block for tile map
(0-31) 7 Color mode (1 then 256 color else 16
color) 6 Mosaic enable (screen pixilation
effect) 5-4 Unused 3-2 Char base block for tile
data (0-4) 1-0 Priority (which background is on
top)
13
Screen size
  • Screen size is indicated with 2 bits in the
    background control register

14
Specifying tile maps
  • For the rotation backgrounds, each entry in a
    tile map is only 8 bits
  • This means that the background can use a maximum
    of 256 possible tiles
  • But rotation tile maps are small
  • For the text backgrounds, each entry in a tile
    map is 16 bits

Bit Function 15-12 Palette number (ignored in
256 color mode) 11 Vertical flip 10 Horizontal
flip 9-0 Tile number
15
Text tile maps
  • Can use more tiles in a background
  • Can individually flip tiles (creating more
    variation with same size tile map)
  • Each tile displayed in the map can use a separate
    16 color pallette

16
Scrolling rotation
  • You scroll a tile background using the REG_BGxX
    and REG_BGxY registers
  • You rotate a tile background using
  • REG_BGxPA
  • REG_BGxPB
  • REG_BGxPC
  • REG_BGxPD
  • (these are the four elements of a 2D affine
    transformation matrix) !?!
Write a Comment
User Comments (0)
About PowerShow.com