Back

Line-Ram

there are 30 "line registers". they are set via "line ram", which allows choosing different values for each scanline (if you've heard of SNES's HDMA, it's sorta like that)

"Lineram" is a list of per-scanline graphics settings.  Almost everything is controlled by lineram, with the exception of: tile data and global scroll for tilemaps/pivot; extend mode; various video signal settings; the sprite data; and textures of course.

In principle, it's very simple: there are 30 16-bit Line Registers, and each one is read from an array of 256 values (one for each scanline).  The complexity comes from features which let you apply the same settings to many scanlines, without having to write the same data many times (though most games do that anyway).

Lineram has 8 "sections" (traditionally referred to as 4000,5000,...,A000,B000 because that's where every game maps them).  Each section can be mapped to one of 16 possible locations within the $62.... block of graphics ram (though, the first two would interfere with other things).

Each section contains four "subsections" (traditionally named 000,200,400,600).  Each subsection can occur in one of two positions within its section: either at its base address, or that address plus $800

Each subsection contains a list of 256 words, which control some settings on each scanline.

The mapping of sections and subsections, and latching (reusing the same parameters across multiple scanlines) is controlled by the "latches".  at $620000, there is a latch per scanline per section (todo: better language to describe arrays-of-arrays)

Lineram Section Latches

Address ($620000+)

⋯,0,1,0,0,0,0,0,section:3,scanline:8,-
section
section number (0-7)
scanline
scanline number (0-255)

Data

.:2,map:4,.:2,a3,a2,a1,a0,l3,l2,l1,l0
map
section data location: maps this section to address $620000 + $1000*m
an
subsection n: bank (note: only matters if latch is 1)
1
add $800 to the address of this subsection
ln
subsection n: latch
1
read parameter from lineram
0
reuse previous value
(note: the latched value presists across frames. e.g. if 0 on the first scanline)

Line Register Values

Address ($620000+)

⋯,0,1,0,map:4,a,sub:2,scanline:8,-
map
section mapping (from the section's latches)
usually at (section + $4)
a
subsection bank (from the section's latches)
usually 0
sub
subsection number
scanline
scanline number
most of the data about the line registers themselves is repeated on the relevant pages. we should probably either get rid of the definitions on this page (replace with links to the other pages) or generate them automatically from data in one place

note: section 0 is missing its first 2 subsections (0.0 "4000" and 0.1 "4200"), so per-line y scroll adjust and alternate tilemap are only available on tilemaps 2 and 3.

Line Register 0.2 "4400"

1R,1L,0R,0L,?:2,alt,yscroll:9
yscroll
Tilemap 2: Y Scroll Adjust
alt
Tilemap 2: Alternate Tile Data
0L
Clip Window 0: Left (upper bit)
0R
Clip Window 0: Right (upper bit)
1L
Clip Window 1: Left (upper bit)
1R
Clip Window 1: Right (upper bit)

Line Register 0.3 "4600"

(same as 0.2, but for Tilemap 3 and Clip Windows 2 and 3)

Line Register 1.0 "5000" - Clip Window 0 Values

right:8,left:8
left
Clip Window 0: Left (lower bits)
right
Clip Window 0: Right (lower bits)

Line Register 1.1 "5200"

(same as 1.0, but for Clip Window 1)

Line Register 1.2 "5400"

(same as 1.0, but for Clip Window 2)

Line Register 1.3 "5600"

(same as 1.0, but for Clip Window 3)

Line Register 2.0 "6000" - Misc Blending, Pivot Mode

B,?,P,?,y,b,p,h,s3:2,s2:2,s1:2,s0:2
sN
Sprite Group N: Blend Mode
h
Highcolor Layer: Alpha Select
p
Pivot Layer: Alpha Select
b
Background Color: Alpha Select
y
Tilemaps: Y Scroll Sync
P
Pivot Layer: Tile Mode (text/pixel)
B
Pivot Layer: Pixel Data Bank

Line Register 2.1 "6200" - Blend Alpha Values

B1:4,B0:4,A1:4,A0:4
A0
half-pixel A, blend select = 0
alpha = clamp((15-value)/8, 0, 1)
$0-$7
100%
$B
50%
$F
0%
A1
half-pixel A, blend select = 1
B0
half-pixel B, blend select = 0
B1
half-pixel B, blend select = 1

Line Register 2.2 "6400" - Mosaic and Fda Settings

fda:2,blur:2,sh:2,h,s,mosaic:4,p3,p2,p1,p0
pN
Tilemap N: Mosaic Enable
mosaic
Mosaic: Pixelation Amount
samples every [16−m] pixelswe don't have a page for this effect yet
s
Sprite Layer: Mosaic Enable
h
Highcolor Layer: Mosaic Enable
sh
Shadow Mode
0,1
off
2
shadow 2
3
shadow 3
blur
Fda: Blur Mode
0,1
blurred
2,3
normal
fda
Fda: Mode
0
legacy color mode (15-bit rgb)
1
normal mode
2
no blending, display half-pixels separately (debug mode?)
3
invalid? first pixel's color repeats all the way across (but alpha still functions)

Line Register 2.3 "6600" - Background Color

.:3,color:13
color
Background Color: Color Id (0-8191)

Line Register 3.0 "7000" - Highcolor Layer Blending

bm:2,clip:10,prio:4
prio
Highcolor Layer: Priority
clip
Highcolor Layer: Clip Settings
bm
Highcolor Layer: Blend Mode

Line Register 3.1 "7200" - Pivot Layer Blending

bm,?,clip:10,prio:4
prio
Pivot Layer: Priority
clip
Pivot Layer: Clip Settings
bm
Pivot Layer: Blend Mode (note different interpretation than elsewhere)

Line Register 3.2 "7400" - Sprite Blending

s3,s2,s1,s0,?,?,clip:10
clip
Sprite Layer: Clip Settings
sN
Sprite Group N: Alpha Select

Line Register 3.3 "7600" - Sprite Priorities

prio3:4,prio2:4,prio1:4,prio0:4
prioN
Sprite Group N: Priority

Line Register 4.0 "8000" - Tilemap 0 Zoom

hzoom:8,vzoom:8
vzoom
Tilemap 0: Vertical Zoom
factor = 1 / (zoom/128)
$00
∞×
$40
2×
$80
1×
$C0
0.667×
$FF
0.502×
hzoom
Tilemap 0: Horizontal Zoom
factor = 1 / (1 - zoom/256)
$00
1×
$40
1.333×
$80
2×
$C0
4×
$FF
256×

Line Register 4.1 "8200" - Tilemap 1 Zoom

hzoom:8,vzoom:8
vzoom
Tilemap 3*: Vertical Zoom
*bug: tilemaps 1 and 3 have their vertical zooms swapped
hzoom
Tilemap 1: Horizontal Zoom

Line Register 4.2 "8400" - Tilemap 2 Zoom

hzoom:8,vzoom:8
vzoom
Tilemap 2: Vertical Zoom
hzoom
Tilemap 2: Horizontal Zoom

Line Register 4.3 "8600" - Tilemap 3 Zoom

hzoom:8,vzoom:8
vzoom
Tilemap 1*: Vertical Zoom
hzoom
Tilemap 3: Horizontal Zoom

Line Register 5.0 "9000" - Tilemap 0 "Palette Add"

.:10,palette:6
palette
Tilemap 0: Palette Adjust

Line Register 5.1 "9200"

(same as 5.0, but for Tilemap 1)

Line Register 5.2 "9400"

(same as 5.0, but for Tilemap 2)

Line Register 5.3 "9600"

(same as 5.0, but for Tilemap 3)

Line Register 6.0 "A000" - Tilemap 0 "Rowscroll"

xscroll:16
xscroll
Tilemap 0: X Scroll Adjust

Line Register 6.1 "A000" - Tilemap 1 "Rowscroll"

(same as 6.0, but for Tilemap 1)

Line Register 6.2 "A000" - Tilemap 2 "Rowscroll"

(same as 6.0, but for Tilemap 2)

Line Register 6.3 "A000" - Tilemap 3 "Rowscroll"

(same as 6.0, but for Tilemap 3)

Line Register 7.0 "B000" - Tilemap 0 Blending

bm:2,clip:10,prio:4
prio
Tilemap 0: Priority
clip
Tilemap 0: Clip Settings
bm
Tilemap 0: Blend Mode

Line Register 7.1 "B200" - Tilemap 1 Blending

(same as 7.0, but for tilemap 1)

Line Register 7.2 "B400" - Tilemap 2 Blending

(same as 7.0, but for tilemap 2)

Line Register 7.3 "B600" - Tilemap 3 Blending

(same as 7.0, but for tilemap 3)