Expand description
Parser for MILK_IMG.INI — MilkDrop’s sprite definition file.
The MilkDrop sprite system (key K) loads up to 100 indexed sprites
from a single INI file. Each sprite entry references an image file
and carries an init block plus up to 8 per-frame equation blocks
(code_1..code_8). At runtime the per-frame block updates the
sprite’s x, y, sx, sy, rot, blendmode, a, r, g, b, … variables,
and the renderer draws a textured quad accordingly.
File shape (lifted from winamp_milkdrop_help.txt):
[img01]
img=sprite.tga
init_1=foo = 0.5;
code_1=x = .5 + sin(time)*.3;
code_2=y = .5 + cos(time)*.3;
code_3=
...
code_8=
burn=0
[img02]
img=other.png
...Per-frame variable contract (the MilkDrop sprite VM exposes these to the equations — names handled by the engine, not the parser):
x, y: centre position in[0, 1](top-left origin).sx, sy: per-axis scale (1.0 = native sprite size).rot: rotation in radians.flipx, flipy: 0/1 mirror toggles.repeatx, repeaty: tile counts for> 1; 1 = single quad.blendmode: 0=alpha, 1=decal, 2=additive (others rarely used).a, r, g, b: uniform tint (a alpha, rgb multiplier).a1..a4, r1..r4, g1..g4, b1..b4: per-corner colour (gradient).time, frame: passthrough from the engine.done: write 1 to mark the sprite for removal.
The parser is liberal: unknown keys, bad section names, missing
img= fields are simply skipped (matching MD2’s tolerant load),
returning whatever valid entries it could extract.
Structs§
- Sprite
Def - A single sprite slot parsed from a
[imgNN]section.
Functions§
- parse_
milk_ img_ ini - Parse a
MILK_IMG.INIfile body. Returns oneSpriteDefper[imgNN]section that carries a non-emptyimg=field. Sections whose name doesn’t match the expected pattern, sections with no image, and unknown keys are silently dropped (matches MD2’s fail-open behaviour — a malformed entry shouldn’t break the bank).