Ready.
The landscape generator “Fraktal-Landschaft” from Happy-Computer 6/87, later published in 64'er as Apfelsee and Fraktsee, reconstructed from the original program and rebuilt pixel by pixel.
Complete Analysis+X points up to the lake tip, +Y to the left. Left mouse button: location, right: view direction.
From special issue 33, locations estimated from the overhead map. At the bottom edge height 2 here instead of 1.0–1.5.
| Spot | X | Y | Height | View |
|---|
From special issue 57, view directions converted to the map (0° = up).
| Spot | X | Y | Height | View |
|---|
The idea of turning a Mandelbrot set into a landscape you can walk through comes from the German magazine Happy-Computer. Issue 6/87 (June 1987) printed the program “Fraktal-Landschaft” (fractal landscape) under the title “Eine fantastische Reise” (a fantastic journey). Frank Göldner wrote the article; according to the listing, the C64 version is by H. Woerrlein. The issue also contained versions for the Amiga, Atari ST, Atari XL/XE and Schneider CPC, and mentions an MS-DOS version. The C64 listing consists of barely two dozen BASIC lines plus 304 bytes of machine code in DATA lines.
The same method later appeared twice in the 64'er magazine. In special issue 33, David Mehlhausen presented “Apfelsee” (apple lake), a version written entirely in machine code with a menu, joystick control and a ready-made overhead map of the lake; its article explicitly names the Happy-Computer publication as its model. Special issue 57 followed with “Fraktsee” (fractal lake) by Frank Michlik, featuring a title screen “Fractal Calculate” by “The Highlight Company 3001” and English prompts.
The program files show how closely the three are related. Fraktsee is the Happy-Computer listing run through the Blitz! compiler: the decompiled code matches the printed program line by line, and the 304 bytes of machine code are identical byte for byte. Even the explanation of the view direction in the Fraktsee article is copied almost word for word from Happy-Computer. Apfelsee is an independent rewrite in machine code, but it uses the same iteration and the same constants: 0.0187 for the field of view, 0.7 and 0.3 for the smoothing, 0.2 as the shadow threshold, −0.0001 for the lake and 0.05 per iteration step.
This page computes with exactly that shared program code. The map, the way the view direction is counted, the excursion spots and the panorama come from the Apfelsee article.
| Feature | Fraktal-Landschaft (Happy-Computer 6/87) | Apfelsee (64'er special issue 33) | Fraktsee (64'er special issue 57) |
|---|---|---|---|
| Author | Frank Göldner (article), C64 version by H. Woerrlein | David Mehlhausen | Frank Michlik; title screen “Fractal Calculate”, “The Highlight Company 3001”, 1987 |
| Computer | C64, Amiga, Atari ST, Atari XL/XE, Schneider CPC; MS-DOS mentioned | C64, adapted to the 4 MHz Turboprocess accelerator card | C64 |
| Distribution | Short BASIC listing with 304 bytes of machine code in DATA lines, to be typed in | Three listings for the MSE typing aid: APFELSEE, F1 C000 and AUFSICHT PACKED | One packed file on the magazine disk; the first RUN unpacks it, the second starts it |
| Technique | Interpreted BASIC, four drawing routines in machine code at $C000 | Entirely machine code, computing with the floating-point routines of the BASIC ROM | The Happy-Computer program compiled to P-code with Blitz!; drawing routines unchanged |
| Operation | Prompts “X=”, “Y=”, “Deine Höhe” (your height), “Blickrichtung=” (view direction) | Menu: view, load, save or create an image | Title screen, then the same prompts in English (“X-Axsle”, “Your height”, “Visual angle”) |
| Choosing a location | Typed coordinates; a map in the magazine shows where the photos were taken | Joystick crosshair on the supplied overhead map | Typed coordinates; a “route map to fractal land” with 15 spots in the magazine |
| Eye height | 0.2 to 1 above the location recommended; too low restarts | 0.3 to 1.0 above the location recommended | As in Happy-Computer |
| View direction | According to the text 0° = +X (north), 90° = +Y (east); the code is offset by 90° | 0° up on the overhead map, 90° right, 180° down, 270° left | Text and computation as in Happy-Computer |
| Rendering time | Several hours on the C64; Atari ST 10 to 20 minutes, 7 to 15 when compiled | About two hours, about half an hour with Turboprocess | Several hours |
| Saving | Not provided on the C64; the other versions save to disk | Save menu item; ← aborts, unfinished images can be saved too | Not provided; save with “Super-Saver”, restore colours with “Fraktlader” |
The Happy-Computer article describes the method itself and confirms the decompilation: the variable V runs through the screen lines from the horizon downward, HO runs across the screen, much like ray tracing. Every screen point is drawn as a “rod” made of a dot in the surface colour, a dark line and a bright line. Because the first images looked very jagged, the program got a “damping function” that weighs the current value at only 30 percent and the neighbour at 70 percent. The CPC and Atari XL versions also paint clouds into the sky.
In speed the three are far apart. The Happy-Computer original runs in the BASIC interpreter and is the slowest. Thanks to the compiler, Fraktsee no longer translates every line at run time, but every command still passes through the runtime library, and the drawing routines receive their parameters as text. Apfelsee calls the BASIC ROM's arithmetic routines directly from machine code and needs about two hours per image.
One detail stands out in the “Fraktlader”, the loader used to display a saved Fraktsee image. It writes the value 81 into screen memory, while the program itself uses 49 ($31). The lower nibble (white) is correct, but the upper one gives green instead of cyan, so an image loaded this way shows its columns green instead of light blue. To see it as intended, replace 81 with 49 in line 46. The loader also doesn't set the border to black as the program does.
The Happy-Computer article already swaps the X and Y axes relative to the program code: the map in the magazine puts the lake tip on the Y axis and the text puts north on the X axis, while the code does the opposite. Fraktsee copied this description. For the view from the bottom edge of the map, Apfelsee recommends an eye height of 1.0 to 1.5; here it takes about 2. Since Apfelsee uses the same formula and constants, this is probably due to estimating the location from the overhead map in the magazine.
The file fraktsee.prg is 4,891 bytes long and packed three times; two of the packer stages carry the signature “</> THC 3001”. A small 6502 emulator ran the unpackers. What came out was not pure machine code but a BASIC program compiled with the Blitz! compiler. From address $1792 there is so-called P-code, a compact intermediate code executed by a bundled runtime library, plus a variable table at $1AC7 and 304 bytes of machine code at $C000.
With a description of the Blitz! opcodes, the P-code could be translated back into BASIC instruction by instruction. The result is, line for line, the C64 listing from Happy-Computer 6/87; Fraktsee only adds a title screen and English prompts, and restarts with CLR instead of RUN when the eye height is too low. This is the original:
0 REM C64-VERSION VON H.WOERRLEIN
1 XQ=49152:XW=49241:FOR I=0 TO 303:READ A:POKE XQ+I,A:NEXT
20 POKE 53281,6:POKE 53280,0:POKE 646,1:INPUT"X=";X1:INPUT"Y=";Y1
50 Z=2:XC=X1:YC=Y1:XA=0:YA=0:GOSUB 270
60 PRINT"HIER IST ES ";Z;"HOCH":INPUT"DEINE HOEHE";H:IF H<Z THEN RUN
70 INPUT"BLICKRICHTUNG=";KU:KU=KU*π/180:SI=SIN(KU):CO=COS(KU)
80 SYS XQ:FOR V=1 TO 600 STEP 2:E=H/V*10:FOR HO=-80 TO 80
130 FA=3:Z=2:HC=E*HO*.0187:XA=0:YA=0:XC=X1+HC*CO+E*SI:YC=Y1-HC*SI+E*CO
160 GOSUB 270:Z=ZA*.7+Z*.3:IF Z<0 THEN FA=0:Z=-1E-4
250 C=Z-H:C=C*V/H:ZA=Z:IF ABS(C)>98 THEN C=98*SGN(C)
261 SYS 49385,81+HO,98-C,199,2:IF C<0 THEN SYS XW,80+HO,99-C,FA
264 IF C>CA+.2 THEN SYS 49368,80+HO,99-C,99-CA,0
265 SYS XW,80+HO,98-C,FA:CA=C:NEXT HO,V
266 GOTO 266
270 X2=ABS(XA):Y2=ABS(YA):XN=X2-Y2-XC:YA=XA*YA:YA=YA+YA-YC:XA=XN:Z=Z-.05
271 IF Z<0 OR X2+Y2>400 THEN RETURN
272 GOTO 270
32000–32015 DATA … (304 Bytes Maschinensprache für $C000)
Drawing is done by four small routines at $C000 that the BASIC program calls with SYS. The parameters follow the SYS command as text and are read with the ROM routine GETBYT ($B79B).
SYS 49152 ($C000) switches on multicolor graphics with the bitmap at $2000 and clears it. The four colours are fixed: blue background for sky and lake, cyan and white from screen memory, green from colour RAM. SYS 49241 ($C059) sets a point in the 160 × 200 multicolor grid. SYS 49368 ($C0D8) draws a vertical line from top to bottom. SYS 49385 ($C0E9) draws a double column: column x in white and the column to its left in cyan, one line longer.
For every point of the plane the program iterates x ← |x| − |y| − cx and y ← 2xy − cy. That is not the classic Mandelbrot set, which would use x² − y², but a variant of its own with absolute values. The overhead map in the Apfelsee article shows exactly this shape with its neck, wide body and notch, which confirms the reconstruction.
The height starts at 2 and drops by 0.05 with every step. The computation stops when |x| + |y| exceeds 400 or the height falls below zero. Points that never escape become lake. There is a subtlety in the C64's 5-byte floating-point numbers: 0.05 is stored slightly too large. After 40 steps a tiny positive remainder is left, and only the 41st step gives −0.05. This decides how quickly a lake asserts itself through the smoothing, so this page reproduces it exactly.
Drawing uses the painter's algorithm, from back to front. The variable V runs from 1 to 600 in steps of two and stands for the screen line below the horizon; it gives the distance E = 10·H/V. For each of the 161 columns, HC = E·HO·0.0187 gives the sideways offset, which corresponds to a field of view of about 112°. A point's height on screen is C = (Z − H)·V/H.
Each column is filled from this height down to the bottom of the screen, and nearer lines paint over farther ones. Everything behind a hill disappears without the program having to compute visibility.
Each column's height is taken 70 % from the column to its left; this causes the typical diagonal stripes. The Apfelsee article explains why V runs up to 600 although the screen ends much earlier: a blind spot. Even when you look straight ahead, you need to know how high the ground in front of your feet is.
In multicolor mode each 4 × 8 pixel cell may show only four colours. Fraktsee sets them once for the whole screen and gives each a job. Green is the surface: in every screen line the program colours only the top one or two pixels of a column green. On flat ground the lines are at most two pixels apart, so the green edges merge into a closed meadow. Where the terrain gets steep, the lines move apart and cyan, the columns' fill colour, shows in between; it looks like rock on a slope. Blue is the background colour and has to serve three purposes: sky, lake water and shadow. Because sky and lake share the same colour, the water looks as if it reflected the sky.
There is no real lighting computation with surface slopes or cast shadows. The impression of a light source on the right comes solely from the drawing order and the comparison with neighbouring columns. Routine $C0E9 paints each column in cyan and, one column further right, a white stripe. The next column paints over that stripe with cyan from its own top edge down. If it lies lower, a piece of white remains above it: slopes that fall away to the right glow as if lit by the sun. Conversely, when the terrain rises by more than 0.2 compared with the column to the left, the program draws a blue line from the new to the old top edge. These flanks face away from the light and appear dark. It is a pseudo-shadow: it only colours the slopes facing away and never falls onto the terrain behind. Together with the diagonal stripes of the smoothing, this is enough to turn four colours into a three-dimensional landscape.
The “Modern view” option draws the same landscape with the Voxel Space technique that NovaLogic developed in 1992 for the helicopter simulator Comanche. There are no polygons and no textures: the landscape is a map of vertical voxel columns, each with a height and a colour of its own. For each screen column the map is sampled from front to back; each sample paints a vertical stripe from its height up to the highest point drawn so far in that column. This is essentially the Fraktsee method, only reversed from front to back, so hidden parts are never drawn at all, and with smooth colours instead of four fixed ones.
It is based on exactly the heights of the Fraktsee formula on a grid of 1024 × 1024 columns, slightly smoothed, with a lake bed that gets deeper toward the middle. Each column's colour follows from height, steepness and location: beach, meadow, forest floor, heath and rock. Light and shadow from a fixed sun are baked into the colours, as in Comanche. Camera, field of view and horizon match the original.
Trees, bushes, reeds and flowers are bitmaps (sprites), as in the games of that era, but painted smoothly with soft edges. They are scaled down with filtering as they recede, hidden behind the landscape by depth and reflected in the water near the shore. The water itself reflects shore and sky through a second ray that runs from the water surface across the height map, and it darkens toward the middle. Everything is computed on the CPU, without any graphics card.
This page can fix four errors of the original. The smoothing is not reset at the end of a line, so the right edge of the image affects the left edge of the next line. The last column draws past the right edge and lands eight pixels lower on the left. Because the screen height is clamped to ±98, the bottom lines never get their surface colour and stay light blue. And when you stand only just above the terrain, the computation ends after 600 lines before the nearby ground reaches the bottom of the screen, leaving light-blue lines and stripes. Here the ground colour of the last line is continued down to the edge.
The program's overhead map looks stretched 2:1 because multicolor pixels are twice as wide as they are tall; it is computed undistorted. The option “Lake as in the C64 overview” draws the map with double-wide pixels in the same way and takes the lake shore in the landscape straight from the formula instead of the smoothed value. As in Apfelsee, the view direction is counted from the lake tip; the Fraktsee code itself is offset by 90°, and the spots from its route map are converted accordingly. With the options switched off and the field of view set to “Original”, the page computes pixel for pixel like the C64 program.