BG CONTROL REGISTER

Controls the visibility of the BG

u8 in RAM at 0xE000 called BG0_CONTROL
u8 in RAM at 0xE020 called BG1_CONTROL
u8 in RAM at 0xE040 called BG2_CONTROL
u8 in RAM at 0xE060 called BG3_CONTROL

76543210
VxxxxxDD

V: RW Visible (1=visible, 0=hidden)
D: RW Depth (0=at the back, 3=in foreground)

BG PIXEL SCROLL X (first visible pixel within the first cell)

u8 in RAM at 0xE001 called BG0_PIXELSCROLLX
u8 in RAM at 0xE021 called BG1_PIXELSCROLLX
u8 in RAM at 0xE041 called BG2_PIXELSCROLLX
u8 in RAM at 0xE061 called BG3_PIXELSCROLLX

76543210
xxxxxSSS

S: RW Scroll Value (0..7)

BG CELL SCROLL X (first visible cell within the map)

u8 in RAM at 0xE002 called BG0_CELLSCROLLX
u8 in RAM at 0xE022 called BG1_CELLSCROLLX
u8 in RAM at 0xE042 called BG2_CELLSCROLLX
u8 in RAM at 0xE062 called BG3_CELLSCROLLX

76543210
xSSSSSSS

S: RW Scroll Value (0..127)

BG PIXEL SCROLL Y (first visible pixel within the first cell)

u8 in RAM at 0xE003 called BG0_PIXELSCROLLY
u8 in RAM at 0xE023 called BG1_PIXELSCROLLY
u8 in RAM at 0xE043 called BG2_PIXELSCROLLY
u8 in RAM at 0xE063 called BG3_PIXELSCROLLY

76543210
xxxxxSSS

S: RW Scroll Value (0..7)

BG CELL SCROLL Y (first visible cell within the map)

u8 in RAM at 0xE004 called BG0_CELLSCROLLY
u8 in RAM at 0xE024 called BG1_CELLSCROLLY
u8 in RAM at 0xE044 called BG2_CELLSCROLLY
u8 in RAM at 0xE064 called BG3_CELLSCROLLY

76543210
xxSSSSSS

S: RW Scroll Value (0..63)

BG BASE PALETTE

u8 in RAM at 0xE005 called BG0_BASEPALETTE
u8 in RAM at 0xE025 called BG1_BASEPALETTE
u8 in RAM at 0xE045 called BG2_BASEPALETTE
u8 in RAM at 0xE065 called BG3_BASEPALETTE

76543210
xBBBBB00

B: RW Palette# to use 0..127 (bottom two bits are ignored)
NOTE: The bottom two bits actually come from the ColorMap data.
NOTE: Default for BG0 is 0 (ColorMap data offers palettes 0..3)
NOTE: Default for BG1 is 4 (ColorMap data offers palettes 4..7)
NOTE: Default for BG2 is 8 (ColorMap data offers palettes 8..11)
NOTE: Default for BG3 is 12 (ColorMap data offers palettes 12..15)

BG CURSOR CONTROL

u8 in RAM at 0xE006 called BG0_CURSOR_CONTROL
u8 in RAM at 0xE026 called BG1_CURSOR_CONTROL
u8 in RAM at 0xE046 called BG2_CURSOR_CONTROL
u8 in RAM at 0xE066 called BG3_CURSOR_CONTROL

76543210
xxxxxxRE

E: RW Enabled (1=Cursor is enabled, 0=Cursor is disabled)
R: .W ResetFlash (1=Reset Flash timeout, and make cursor visible, 0=no change)

BG CURSOR X POSITION

u8 in RAM at 0xE007 called BG0_CURSOR_X
u8 in RAM at 0xE027 called BG1_CURSOR_X
u8 in RAM at 0xE047 called BG2_CURSOR_X
u8 in RAM at 0xE067 called BG3_CURSOR_X

76543210
xVVVVVVV

V: RW XPOS (0..127)

BG CURSOR Y POSITION

u8 in RAM at 0xE008 called BG0_CURSOR_Y
u8 in RAM at 0xE028 called BG1_CURSOR_Y
u8 in RAM at 0xE048 called BG2_CURSOR_Y
u8 in RAM at 0xE068 called BG3_CURSOR_Y

76543210
xxVVVVVV

V: RW YPOS (0..63)

BG CLIP-RECT CONTROL

u8 in RAM at 0xE009 called BG0_CLIPRECT_CONTROL
u8 in RAM at 0xE029 called BG1_CLIPRECT_CONTROL
u8 in RAM at 0xE049 called BG2_CLIPRECT_CONTROL
u8 in RAM at 0xE069 called BG3_CLIPRECT_CONTROL

76543210
EIxxxxAB

E: RW Enable (0=cliprect is ignored, 1=cliprect is functional)
I: RW Inverse (0=remove what's inside the box, 1=keep only what's inside the box)
A: RW X2BIT8 (The 9th (high) bit of the X2 coordinate)
B: RW X1BIT8 (The 9th (high) bit of the X1 coordinate)

BG CLIP-RECT X1

u8 in RAM at 0xE00A called BG0_CLIPRECT_X1
u8 in RAM at 0xE02A called BG1_CLIPRECT_X1
u8 in RAM at 0xE04A called BG2_CLIPRECT_X1
u8 in RAM at 0xE06A called BG3_CLIPRECT_X1

76543210
VVVVVVVV

V: RW X1 (The low 8 bits of the X1 coordinate)
NOTE: The high bit is in the cliprect control

BG CLIP-RECT Y1

u8 in RAM at 0xE00B called BG0_CLIPRECT_Y1
u8 in RAM at 0xE02B called BG1_CLIPRECT_Y1
u8 in RAM at 0xE04B called BG2_CLIPRECT_Y1
u8 in RAM at 0xE06B called BG3_CLIPRECT_Y1

76543210
VVVVVVVV

V: RW Y1 (The Y1 coordinate)

BG CLIP-RECT X2

u8 in RAM at 0xE00C called BG0_CLIPRECT_X2
u8 in RAM at 0xE02C called BG1_CLIPRECT_X2
u8 in RAM at 0xE04C called BG2_CLIPRECT_X2
u8 in RAM at 0xE06C called BG3_CLIPRECT_X2

76543210
VVVVVVVV

V: RW X2 (The low 8 bits of the X2 coordinate)
NOTE: The high bit is in the cliprect control

BG CLIP-RECT Y2

u8 in RAM at 0xE00D called BG0_CLIPRECT_Y2
u8 in RAM at 0xE02D called BG1_CLIPRECT_Y2
u8 in RAM at 0xE04D called BG2_CLIPRECT_Y2
u8 in RAM at 0xE06D called BG3_CLIPRECT_Y2

76543210
VVVVVVVV

V: RW Y2 (The Y2 coordinate)

const BGCONTROL_VISIBLE


BGCONTROL_VISIBLE = 128

const BGCONTROL_HIDDEN


BGCONTROL_HIDDEN = 0

const BGCONTROL_DEPTH_MASK


BGCONTROL_DEPTH_MASK = 3

Macro/Inline

#define BGCONTROL_DEPTH(n) ((n)&BGCONTROL_DEPTH_MASK)

const BGCURSOR_ENABLE


BGCURSOR_ENABLE = 1

const BGCURSOR_DISABLE


BGCURSOR_DISABLE = 0

const BGCURSOR_RESET_FLASH


BGCURSOR_RESET_FLASH = 2