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
| engine | what it draws |
|---|---|
| 2D, main | four background layers, 128 sprites, windows and blending; its first layer can show the 3D picture |
| 2D, sub | the same again for the other screen, without 3D |
| 3D | a geometry engine (matrices, lighting, vertices) feeding a rasteriser with textures, toon shading, edge marking, fog and anti-aliasing |
| Capture | copies 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):
- Composite. The last finished picture of her is drawn back as one flat, textured rectangle.
- Leg pass. Her legs are drawn on their own.
- 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:
- Resolution, up to 4×. The 3D is drawn at the higher resolution. Each capture the game takes also gets a sharper twin, made from the same registers and the sharper 3D. Wherever the game shows its captured picture unscaled, the twin is shown, which is how the heroine reaches the screen at full resolution.
- Smooth motion. When two captures in a row come from the same polygons, the engine draws the pose halfway between them and shows it while the game is busy, so she moves 30 times a second instead of 15, two refreshes behind.
- 3D options. Texture filtering, smooth toon shading (the game's own colour ramp, blended instead of stepped), and anti-aliasing.
- Enhanced textures and backgrounds. Each texture is identified by a hash of the bytes it uses, so it can be swapped for a hand-made replacement, or upscaled 4× with FSR. Photo backgrounds (48 or more colours) are rebuilt as whole planes, denoised and upscaled. The pixel-art interface is never upscaled: it stays crisp.
- The GPU. The 3D and the final compositing of both screens run on your graphics card. The CPU rasteriser remains the reference, and always draws the game's own captures.
How we know
- From scene facts alone, a generator rebuilt every 3D command packet of a recorded scene, 26,216 out of 26,216 at two separate moments (chapter 5), including the video memory addresses the game's allocator chooses.
- The GPU renderer was compared with the CPU reference over 508 frames, 25 million pixels: the only differences are single pixels on edges shared by two triangles, where the two disagree about which triangle owns the pixel.
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.