Articles & Documents

Back to index

MAngband Hacking

This document describes some technical notes/aspects of MAngband/Angband that I learned while writing an SDL2 interface (so I could play MAngband "unencumbered" on various platforms).

z-terms

MAngband, being a derivative of Angband, uses the concept of "virtual terminals" or "z-term"s. A z-term is a matrix of rows*columns of cells that correspond to a basic terminal device. Each cell in a z-term may have an "attribute", such as a color, as well as a "character". Characters may be drawn at arbitrary locations within the matrix and the z-term does various intelligent checks to ensure that the minimal amount of updates are triggered to signify an update to whatever the front-end may be.

Getting into the topic of front-ends, z-terms provide a set of a function pointers that act as hooks and are expected to handle certain types of data/information. These hooks are intended to be used to create, draw, and destroy a "z-term" and its interface. These hooks are:

In the case of MAngband, there are console(cap,ibm,gcu), SDL, X11, Xaw, and Windows "z-term" implementations. Each one of these implementations handles the interfacing of at least 1 "z-term" to the user interface of the implementation.

The base-line requirements for a "z-term" interface is to:

MAngband z-term usage

MAngband can use a total of 8 z-terms, the first of which is the only required one. These terms and their function descriptions are:

Basic MAngband logic

The main "connected" loop for MAngband is:

MAngband commands and keymaps

One of the more difficult aspects of interfacing with the "z-term" is understanding the proper way to pass keyboard input.