♥ lp-engine

Chapter 7

Drawing

The DS has two screens, two 2D engines and one 3D engine that can only feed one screen at a time. LovePlus+ gets a fully shaded heroine, a photo background and a busy interface out of that by drawing her in passes and photographing the result.

The hardware

enginewhat it draws
2D, mainfour background layers, 128 sprites, windows and blending; its first layer can show the 3D picture
2D, subthe same again for the other screen, without 3D
3Da geometry engine (matrices, lighting, vertices) feeding a rasteriser with textures, toon shading, edge marking, fog and anti-aliasing
Capturecopies a finished picture, the 3D layer or the whole screen, into video memory, where it can be shown again as a bitmap

Video memory is a set of banks the game assigns to roles as scenes change: background tiles for one engine, sprites for the other, textures for the 3D, a capture target. The game manages the banks itself, with a simple allocator that hands out space in load order.

The heroine's four-frame cycle

In her scenes, the game runs a cycle that the capture unit makes possible (Capture3D_GetCurrentPhase):

  1. Composite. The last finished picture of her is drawn back as one flat, textured rectangle.
  2. Leg pass. Her legs are drawn on their own.
  3. Main pass. The rest of her is drawn over them, and the result is captured into video memory.

Capturing the result means the finished picture can be shown, faded or blended like any other image while the 3D engine moves on to the next pass. The cost is speed: the main pass waits two screen refreshes, so the cycle takes four, and she's redrawn 15 times a second. That's how she looked on the DS too. Gfx_RenderCapturedFrame puts the captured picture back on screen, and VramBank_Process holds the pace.

The look

Everything about her look comes from fixed settings: textures, alpha blending, anti-aliasing, edge marking and toon shading all on, every polygon toon-shaded with no culling, and two lights turned by the camera preset (chapter 5). The background behind her is a photo: a background layer, 16 colours per tile, with 125 to 166 colours in a whole picture. Frames, menus and text use 15 or fewer.

The interface

Menus, the date header, the stats panel and the buttons are 2D: background layers made of 8×8 tiles, and sprites assembled from cells. Text is drawn into tiles at run time, glyph by glyph, from the game's bitmap fonts (chapter 9). Sprite_DrawAll rebuilds every sprite's entry each frame; in measured play it's one of the busiest parts of the game.

In lp-engine

The engine reimplements all four parts of the hardware, and the game drives them exactly as it drove the DS. At 1× with every option off, the picture is the DS's. Above that, lp-engine changes how the picture is shown, never what the game does:

How we know

Where to read more. Every rendering rule, with the evidence behind it, is in docs/RENDER_PRIMITIVES.md. The engine's presentation layer is described in docs/RUNTIME.md.