---
mvp: yes
subsystem: rendering
---

# Rendering

The BNO 5-8 client renders entirely through GameMaker 5.3a's immediate-mode draw API. Every object that needs visible output uses a Draw event (or the default sprite-draw if no Draw event is defined). There is no batching, no atlas, no scene graph — each frame is a top-down execution of every visible instance's Draw, in `depth` order (negative depths render on top).

Two text fonts dominate the visible UI: **OCRA** (the screen-printer monospace used for menus, labels, chat, and operations) and **Fixedsys** (the smaller sans-serif used in the in-game command console). Both are referenced by `draw_set_font(font_resource_id)` calls. Phase 2 plan 02-02 closed the unknown DnD-action problem (IDs 523 and 525) by hand-porting the LateralGM "Set Font" and "Set Font (combined)" semantics — see [unknown-actions-status.md](unknown-actions-status.md). After resolution, `extracted/client-5-8/objects/0034-title/events/Draw.gml` reads cleanly:

```gml
draw_set_font(OCRA); draw_set_color(16711680); draw_set_halign(0); draw_set_valign(0)
action_draw_text(Battle Network Online Client BETA, 0, 0)  // (relative)
```

The `16711680` is `0x00FF0000` — GM 5.x stores colour as BGR, so this is pure blue (the BNO logo blue). `draw_set_halign(0)` is `fa_left`; `draw_set_valign(0)` is `fa_top`. The relative offset `(0, 0)` means "draw at this instance's `x` + offset, `y` + offset", which is GM 5.x's default for the DnD `action_draw_text` action.

The big drawing scripts live in the 200s. **Script 0263 `mb_topdraw`** renders the message-board top panel. **Script 0269 `draw_rqbar`** draws the request-queue bar (the persistent UI strip that lists pending Hexport / chat requests). **Script 0298 `iv_infodraw`** is the inventory info card. **Script 0303 `iv_datadraw`** renders the data-table portion of the inventory. **Script 0311 `iv_actiondraw`** renders the action menu. Together with `0267 mb_newdraw` and `0264 mb_repdraw` (message-board secondary panels), these cover ~90 % of the in-game UI surface.

The terrain tiles render via the Draw event of each tile object plus a handful of overlay scripts (`0337 cornerul`, `0338 cornerl`, `0341 cornerd`, etc. — see [collision.md](collision.md) for tile-edge logic). For sprite rendering, the engine relies on default per-instance sprite_index drawing; explicit `draw_sprite` / `draw_sprite_ext` calls only appear in the request-queue and inventory subsystems where multiple sprites must layer at offset positions.

## Key idioms

- **Font-set + colour-set + alignment** is the canonical preamble before `draw_text`. All four set calls (font/color/halign/valign) appear back-to-back in nearly every Draw event.
- **Colour as BGR int**. Every `draw_set_color` call uses the BGR-packed integer form (`16711680` = blue). The wiki notes this in [decomp/wiki/05-gml-vm.md](../../decomp/wiki/05-gml-vm.md).
- **Relative coordinates** in DnD `action_draw_text` mean "this instance's position + offset". Switching to absolute coordinates required toggling the `relative` checkbox in the GameMaker IDE — emitted as `relative: 1` in `.dnd.json`.
- **No alpha blending**. `draw_set_alpha` is rare; most rendering is opaque. The chat overlay is the main exception, using semi-transparent backgrounds.
- **Depth-driven layering**. Each instance's `depth` controls draw order; player and Hexport sprites swap depths via `depth_set` (script 0354) when transitioning between layered states (under-grass / over-grass / hexport-out).

## Scripts referenced in this subsystem

<!-- AUTOGEN:scripts:start -->
| Script ID | Name | Lines | Used in objects |
|-----------|------|-------|------------------|
| 0002 | script_drawlines | 14 | — |
| 0263 | mb_topdraw | 31 | — |
| 0264 | mb_repdraw | 37 | — |
| 0267 | mb_newdraw | 15 | — |
| 0269 | draw_rqbar | 115 | — |
| 0298 | iv_infodraw | 12 | — |
| 0303 | iv_datadraw | 66 | — |
| 0311 | iv_actiondraw | 26 | — |
<!-- AUTOGEN:scripts:end -->

## Objects referenced in this subsystem

<!-- AUTOGEN:objects:start -->
| Object ID | Name | Sprite | Mask | Events |
|-----------|------|--------|------|--------|
<!-- AUTOGEN:objects:end -->

## Engine functions used

<!-- AUTOGEN:gml-functions:start -->
| GML function | Call sites | Sample script | Wiki link |
|--------------|------------|---------------|-----------|
| `draw_set_font` | 0 | — | [wiki/07-gml-core-functions](../../decomp/wiki/07-gml-core-functions.md) |
| `draw_set_color` | 0 | — | [wiki/07-gml-core-functions](../../decomp/wiki/07-gml-core-functions.md) |
| `draw_set_halign` | 0 | — | [wiki/07-gml-core-functions](../../decomp/wiki/07-gml-core-functions.md) |
| `draw_set_valign` | 0 | — | [wiki/07-gml-core-functions](../../decomp/wiki/07-gml-core-functions.md) |
| `draw_text` | 10 | 0002-script_drawlines | [wiki/07-gml-core-functions](../../decomp/wiki/07-gml-core-functions.md) |
| `draw_sprite` | 2 | 0303-iv_datadraw | [wiki/07-gml-core-functions](../../decomp/wiki/07-gml-core-functions.md) |
| `draw_sprite_ext` | 1 | 0311-iv_actiondraw | [wiki/07-gml-core-functions](../../decomp/wiki/07-gml-core-functions.md) |
| `draw_rectangle` | 0 | — | [wiki/07-gml-core-functions](../../decomp/wiki/07-gml-core-functions.md) |
<!-- AUTOGEN:gml-functions:end -->

## Rebuild guidance

For the Phase 6 client (Phaser 3 or PixiJS):

- **Preserve the OCRA + Fixedsys font pair** — they are part of BNO's visual identity. Use webfonts (Google Fonts has both `Major Mono Display` as an OCRA-near analog; Fixedsys has multiple TTF re-issues). Match metrics, not just glyph shape.
- **Atlas the sprites at build time**, do NOT replicate the immediate-mode-per-frame model. Phase 6 AST-01 is the pipeline that converts `extracted/<src>/sprites/**/frames/img_NNN.bmp` → atlas PNG.
- **Convert BGR colours at the boundary**. The original BNO source uses `0x00BBGGRR`; modern libraries expect `0x00RRGGBB`. Build a `legacyColor(bgr)` helper that swaps R and B, used at the GML-port-to-TS boundary.
- **Use scene-graph depth** equivalents (Phaser's `setDepth`, Pixi's container `zIndex`) — do NOT re-implement GM's draw-event ordering.

## See also

- [decomp/wiki/05-gml-vm.md](../../decomp/wiki/05-gml-vm.md) — colour packing, draw-set semantics
- [decomp/wiki/07-gml-core-functions.md](../../decomp/wiki/07-gml-core-functions.md) — `draw_*` function reference
- [animation.md](animation.md) — `image_speed` and `sprite_index` swap idiom
- [ui-and-menus.md](ui-and-menus.md) — UI surfaces that consume rendering primitives
- [unknown-actions-status.md](unknown-actions-status.md) — DnD action 523/525 resolution
