Introduction
A version 5 formula is a Mandelbulb 3D formula file with .Version = 5. Sixty-one of
the 714 files examined have it (thirty-two different files). Most are four-dimensional
formulas: names such as Barnsley4Dc, Lambda4Dnc, Hopf4D,
Mandel4DBiC, CommQuat and the add-ons _Rotate4d,
_setw, _ScaleC4d and _Rpow3_4d. A four-dimensional formula
iterates a fourth number, w, as well as x, y and z; the program’s readme describes the 4D
formulas as using the w variable.
The file is Windows text, lines ending in CR LF, and the code is 32-bit x87 machine code
written as hexadecimal digits. In a few files .Version is the third option line, not the
first (they put .DEoption before it).
Layout
| Part | Starts with | Holds |
|---|---|---|
| Options | [OPTIONS] | One line for each setting or option. .Version = 5 is among the first. |
| Constants | [CONSTANTS] | Optional; 16 of the 61 files have it. |
| Code | [CODE] | The machine code as hexadecimal digits, 64 digits (32 bytes) to a line. |
| End | [END] | Ends the code. Some files, such as _Rotate4d, end here, with no description at all. |
| Description | a blank line, then Description: | Free text to the end of the file, when there is any. |
Option lines
| Line | In version 5 files |
|---|---|
.Version = 5 | All 61. |
.DEoption = n | 58 files: 4 in 46, 5 in 8, -1 in 2, 2 in 2. Three have none. |
.DEscale, .SIpower, .RStop | 53, 49 and 10 files. |
.Double, .Integer, .Single | 55, 18 and 2 files. |
.3SingleAngles, .6SingleAngles | 2 files each. 6SingleAngles holds six angles (the rotation of _Rotate4d below). |
.Boxscale | 4 files. |
No version 5 file has an .SSE2 or .SSE3 flag, or a 2Doubles option.
Machine code
The code is a procedure that starts 55 8B EC (push ebp; mov ebp, esp),
loads [ebp+8] and the pointer at offset 0x30 to its option values, and
ends with C2 08 00 (ret 8). It reaches x, y and z through
eax, edx and ecx, and the fourth number, w, at
[ecx + 8], directly after z in memory. This is read off the disassembly of the
sample files.
A worked example
_Rotate4d.m3f is 365 bytes with no description. It has one option, a
6SingleAngles rotation.
00000000 5B 4F 50 54 49 4F 4E 53 5D 0D 0A 2E 56 65 72 73 [OPTIONS] .Vers
00000010 69 6F 6E 20 3D 20 35 0D 0A 2E 44 45 6F 70 74 69 ion = 5 .DEopti
00000020 6F 6E 20 3D 20 2D 31 0D 0A 2E 36 53 69 6E 67 6C on = -1 .6Singl
00000030 65 41 6E 67 6C 65 73 20 52 6F 74 61 74 69 6F 6E eAngles Rotation
00000040 20 3D 20 30 0D 0A 5B 43 4F 44 45 5D 0D 0A 35 35 = 0 [CODE] 55
00000050 38 42 45 43 35 36 38 42 37 35 30 38 38 42 37 36 8BEC568B75088B76
_Rotate4d.m3f: the option line .6SingleAngles Rotation = 0, then the code from offset 0x4EThe code is 135 bytes. After the prologue it loads four numbers (fld qword ptr
[ecx+8] is w, then [ecx], [edx], [eax]), multiplies them
by sixteen single-precision values (fmul dword ptr [esi - 0xc] and the like) in four
groups of four, adding each group into one number, and stores the four results back: it reads like a 4×4 matrix
multiply. The sixteen values it reads at negative offsets from the option pointer are not the
six angles themselves, so the program must work them out from the angles; how it does so has not
been checked.
Quirks
- A byte is never split across two hex lines; the last hex line is shorter.
- A file may end at
[END], with no blank line or description after it. - In a few files
.DEoptioncomes before.Version. - Text in the description may use Windows-1252 characters.
Not described
What this page and the explorer leave out or only infer for version 5 files.
- Reference: what version 5 changes from version 4 is not known; that most files are four-dimensional is read from their names and DE options (4 to 6 are the four-dimensional types in the source), not from a statement about the version.
- Reference:
.DEoption2 seen here has no stated meaning; the 4×4 matrix reading of_Rotate4dand the position of w are inferred from the disassembly, and how the program turns the six angles into the sixteen values was not checked. - Viewer: the machine code is a linear disassembly (no jump following, no data/code separation, constants not shown beside the code); options are not linked to the code that reads them.
Variants
- Version 2 – the commonest: x87 code with a push ebp prologue, many add-ons
- Version 3 – twelve files, among them David Makin’s formulas, with SSE2 and SSE3 flags
- Version 4 – twenty-eight files, the reciprocal add-ons and Amazing Box variants
- Version 5 – sixty-one files, mostly four-dimensional formulas
- Version 6 – one hundred and ninety files, mostly the dIFS formulas
- Version 8 – six files, the newest number seen
Links
Software
- Mandelbulb 3D – the Windows program that loads these formulas (Windows)
Reference
- M3P file format – the parameter files that name the formulas in use