Mode 52 Quickstart

From Uzebox Wiki
Jump to navigation Jump to search

Video mode 52 offers a great deal of options for setting up a screen, allowing for quite complex displays with several palettes and split-screen regions.

Mode 52 Lisunov Li-2 Demo
Mode 52 Lisunov Li-2 Demo

To see the mode in action, you could look at the examples provided in the mode's directory: [[1]]

Documentations are provided in the video mode's various components:

Note that the repository paths will change in the future when the mode is merged into the Uzebox master. Then the links here will be changed accordingly.

Compiling the examples

The examples can be compiled after you succesfully built Uzebox components by the main Makefile (issuing Make from the root of the repository). This is necessary so the packrom tool is built, which is used to create .UZE files. Then you can compile each example using its own Makefile. Binaries will be placed in _bin_ directories which can be used right away.

The row descriptor array

The row descriptor array (m52_rowdesc) defines how each of the 32 logical tile rows (256 scanlines worth of graphics) should be displayed. These include things like where the VRAM of that row is located, the X shift (in-tile scroll of 0-7 pixels to the left), the width of the row in tiles, its palette and likes.

By setting up the members of this arrays proper, you set up the available display elements for your screen. To see how it works exactly, you may look into the "Tile row modes overwiev" section of the Developer's Manual. Note that defines are also provided for the individual features for writing easir to read code.

The row selector

While the row descriptor defines the available display resources, the row selector controls where each of the scanlines should end up on the screen. This is the m52_rowsel_p pointer which points at a list defining screen split points.

The first byte of this list is the logical scanline position where the display should start (topmost visible scanline). Then byte pairs follow: a scanline to act on, and a logical scanline where the display may continue. The list may be ended by setting an unreachable scanline to act on value (such as 255).

This list allows for setting up any number of screen splits.

Sprites

Mode 52's sprite support contrary to the normal (Mode 3) kernel doesn't provide "sprites" as such, it rather provides a capability to blit 8x8 transparent sprite tiles on the display (a bit lower level support). You can use this to realize your own high-level sprite support fitting for the game you are designing (see for example Flight of a Dragon, a Mode 74 game). The RAM tile support however is very similar to that of the normal kernel, so it can semi-automatically restore the screen clearing away previously drawn sprites.

So a frame routine normally should restore the screen (M52_VramRestore()), perform any operation it wants to do with the VRAM (such as scrolling), then blit sprites to their new locations (M52_BlitSprite()).

Sprite coordinates are always relative to the logical screen (as set up in the row descriptor array), the coordinates specifying where the sprite's lower right corner should end up.

Scrolling

There are several options to implement free-directional scrolling in this mode.

Horizontal sub-tile scrolling is done by the X shift values of rows, vertical sub-tile scrolling can be done using the row selector, specifying the first logical scanline to display (note that this affects sprite positions as they use the logical screen as reference).

The simplest to handle is possibly just copying around the VRAM as necessary: when you scroll a full tile in either direction, copy the entire VRAM to match the new location. It isn't slow, the AVR is fast enough to handle it just fine.

If you want to avoid those copies, you may utilize the capability of setting the VRAM row pointers in the row descriptor. By this, you can create a scrolling mechanism which works with very little copying.