Spell Book Interface - HoraceAndTheSpider/Bloodwych-68k GitHub Wiki

Spell book interface

This page describes the SPS 439 spell-book presentation and input path. Spell success and mana rules are covered by Spell Casting Mechanics.

Book, pages and runes

Prepare_AndDrawSpellBookSurface draws the 96×62 book image from GFX_Pockets+$4100. The page state at PlayerX_Data+$2A is always even: 0, 2, 4, or 6. Each value identifies one two-page spread, giving four spreads, eight pages, and 32 four-rune spells.

Draw_SpellBookRunePage reads 16 lowercase characters from SpellBookRunes for each page. Four adjacent characters make one spell. The eight entries on a spread are the four spells on the left page followed by the four on the right; book order is not a repeated class order. Champion bytes $0C–$0F hold the ownership nibbles: each page uses one nibble, and its high-to-low bits select that page's four spells.

Unowned entries are grey. Owned entries use their spell class colour: Serpent green, Chaos yellow, Dragon red, or Moon blue. The selected entry is white.

Page turn

Click_TurnSpellBookPage changes the spread by two pages and wraps the state with $0007. Draw_SpellBookPageTurn draws four 32×56 frames beginning at GFX_Pockets+$4130. Consecutive frames advance the source by 16 bytes and the destination by 16 pixels, so their 16-pixel overlap forms one continuous page curl rather than independent tiles.

The routine redraws old and new rune columns at different points in the four-frame sequence. This hides the page-content swap beneath the curl; the short-lived rune pixels are recoloured from the source page class mask and are not literal new page text.

Controls and selected spell

The top controls are previous spread, close, and next spread. The centre pair of arrows is one close hit target. Eight rune targets select the visible spell entries. Selecting an unavailable rune clears champion byte $13 to $FF. Selecting an owned rune stores its index and clears byte $14, the prepared cast-power adjustment.

When a spell is prepared, the two lower end-stars use its class colour and the middle decorations disappear. The left star launches the prepared spell and the right star views it. Leaving the spell-book page does not clear the queued spell: the normal multi-function control remains its coloured class star and can launch it. The CAST display belongs to the spell-book presentation and is not retained after that page is closed.

The selected name begins at X=$F0, Y=$4A. The COST stream begins at X=$F0, Y=$52; the source text stream's grid origin is (30,10), followed by the text renderer's $0050 base. COST is pink, its two digits yellow, and glyphs $04/$05 are the red up/down controls.

Spell points and CAST

Draw_SpellPointValues displays current and maximum spell points as two digits each, including a leading zero, in SP.PTS nn/nn.

The CAST bar is 52 pixels wide and five pixels high. It maps the negated signed quality through the 20-byte percentage table at $6760; its endpoints are adjacent to the two font-arrow decorations. Raising cast power increases both mana cost and signed quality. Lowering it can reduce the calculated cost to one point, but never to zero. A charged matching magic ring instead uses one ring charge, forces byte $14 to zero, and leaves the normal unboosted CAST calculation in effect.