Home
Admin | Edit

Halite - x86/DOS (386+) 256 bytes

link

My first 256b x86 (386+) / DOS real mode (16-bit) procedural graphics program released at Lovebyte 2024, it use Mode 13h (320x200 256 colors) and render a subdivided / carved isometric cube (Octree-like) with drop shadow and a wavy background gradient.

Although untested this probably works on mid 80s original hardware with VGA graphics, it was tested on DOSBox and Bochs + FreeDOS, rendering took 15 seconds on Bochs.

The main inspiration for this came from the 4k procedural graphics 20230419_fillercube by 0b5vr.

This was made as the Lovebyte deadline approached, ~20 days before the event.

This came after an unsuccessful attempt in December to create a 256b procedural graphics for Linux, it turned out to be too large due to ELF headers and framebuffer setup. This setback led me to explore light header platforms, i settled on DOS for the obvious reason that my code was x86 code and that DOS require very little setup and COM file has no headers.

My DOS port also faced difficulties though, mainly due to my inexperience in that new environment and my need for high resolution (VESA) which is tricky. I had nothing at this point to release at Lovebyte so i just iterated on some archive code without plans, iterations were fruitful and led to something worth to release which i failed again to port on DOS, i tried to simplify the idea to make it feasible and this led to this entry many iterations later.

It took a lot of work to shrink this but i am satisfied of the result, i was unsure during the whole process that all the content would fit in 256b, especially the colors + wavy background and cube structure / shading.

All these iterations made me discover new tricks on rendering tiny isometric objects compared to the early experimentation i did on that subject in early 2023, most unexpected moment was discovering that i just needed 4 bytes to render the smallest "unit cube" and then just use this to fill bigger ones... it is even possible to do the unit cube with only 3 bytes although there might be some artifacts on the edges, it is also possible to pack most infos for it into a byte.

The code may be adapted to run on 80186+ (1982), probably just have to replace the two movzx / movsx by equivalent set of instructions.

Technical

  • Palette code is taken from Tomcat page and about half of the colors are unused, could have chosen a full blueish palette but i liked the slightly visible waves
  • The wavy background use a ~9 instructions minsky circle (~22 bytes), depth buffer is cleared at the same time as the gradient is computed
  • The cube is drawn progressively per subdivision layer, from "unit cube" first (smallest) to bigger cubes, depth buffer ensure everything is in order for a small byte cost (~10 bytes)
  • The cheap shadow (~12 bytes) is just the cubes drawn once again in the same pass, checking the depth buffer first and offsetting, this produce slight artifacts on the lower edges
  • Shading and carving use logical operators (x ^ (y >> 1) ^ z) << 2, perhaps the part where i took plenty shortcuts compared to the initial prototype, ended up ok, i like the cracks

Iterations

Note : This started at a higher resolution and i then adjusted to the 320x200 target, i tweaked the palette for a contrasted one instead of the medical blue for the release.

early grayscale version, probably around the time i decided it would end up as a 256b

gradient and reflection, reflection was the initial idea instead of the shadow, couldn't pull it off with palette but may work with greyscale

waves and different reflection shading, felt more like being on liquids, quite like the left one

adaptation to 320x200 and structural changes which i liked

trying structural distortions

going away from greyscale with a version with less levels (right), this was tempting :)

having fun with different structures, playing with the depth buffer (right)

playing with different palette and shading, quite like the chrome feel of this one but too big

more pleasing reflection and shading (left) but couldn't pull it off then simplified shading (right)

Inspiration

Inspiration also came from many other small intros which use similar render method (most below without name are by sensenstahl), there is also Wooden Structure 4k intro which made strong impression on me (although not using the same render method) :


Hydraulic Pixels by iONic

v.i.e.w.m.e. by sensenstahl

LABDA by Tomcat


star blazer


8 seasons of light


the inner sanctum

armada


vision of the architect


mantra


immediate railways by Digimind

Pixel Town by Digimind

City by gfbtm (looks like raycast though ?)

back to topLicence Creative Commons