Mode 2 ScreenSections Guide

From Uzebox Wiki
Jump to: navigation, search

Hello there. Welcome to Day #2 of my summer of tutorials

I did a guide for sprite in Mode 2 yesterday. I'm now going to talk about screen sections. Screen sections are divisions in the screen. Their width can not be changed, they automatically fill the screen going from left to right. But you can change the height to anything you want. (Except for 0). But the total height of all screen sections needs to be 208. Anything after that is cut off. Anything under that and bad things happen. (I've never tried it, but my guess is random noise will be displayed)

To use screen sections you first need to define how many you want with the compiler option "-DSCREEN_SECTIONS_COUNT="

So -DSCREEN_SECTIONS_COUNT=2 means you will have to screen Sections.

You access them like so:

           screenSections[0].tileTableAdress = MyTiles;

The different variables you can change are: (This is take right out of the sprite Demo)

  • scrollX: x displacement
  • scrollY: y displacement
  • height: section height in scanlines
  • vramBaseAdress: location in vram where this section starts rendering
  • tileTableAdress: tile set to use when rendering this section
  • wrapLine: Define at what Y scroll within that section Y-wrap will happen (Normally Y-Wrap happens at 0xff). So instead of wrapping each 32 tiles you can wrap each 12 or 12 tiles+ 3 lines, etc.
  • flags: 1=sprites will be drawn on top of this section. 0=sprites will be under.

So lets start with scrollX. If scrollX is increased the display window moves to the right. (Which means all the tiles move to the left). It is a char so at 255 it wraps. However, due to the fact that tile width is 6 pixels, the caller needs to perform X wrapping before setting the screen section's scrollX variable. Wrapping happens at value X_SCROLL_WRAP.

if(sx>=X_SCROLL_WRAP) sx=0;

Next is scrollY. If scrollY is increased the display window moves down. (Which means all the tiles move up.) It is also a char so at 255 it wraps.

height is the height in scanlines (scanlines = pixels)

-vramBaseAdress is by default set to zero. If you were to set it to 32 * 4, then when scrollY is zero, the first row of tiles is the fourth row in vram.

tiletable address is the tile table you use.

wrapLine- You can have a screen section wrap at a line other then the very bottom. This is useful because if you set vram to be less then 32 tiles high you will want your wrapline to be less. Remember though, if you set the wrapline to 176 (for example) scrollY should reset back to zero at 176 also.

-flags, I think the above description says it best.

Thats about it. Have Fun.