/r/tinycode
This subreddit is about minimalistic, often but not always simple implementations of just about everything. tiny code / minimalistic programming / yagni / kiss / dry
TL;DR: Low line count, high quality
This subreddit is about minimalistic, often but not always simple implementations of just about everything.
PLEASE NOTE: This Subreddit is NOT about CodeGolf and obfuscation!
_______Low line count, high quality!_______
I'm sure you get the idea by now ;) ...
Remember: "Tiny depends on what you're doing. A tiny box, a tiny house, and a tiny country are very different sizes." - snarkyxanf
In other words: Try to aim for stuff that makes you go "wow!" instead of "huh?" ;)
Also look into:
Other Subreddits that might interest you:
/r/tinycode
(For context see 1st place here: https://demozoo.org/parties/4760/#competition_18679 or a video of the effect here: https://www.youtube.com/watch?v=dgfG7aX1rDY)
After getting a request for the source code (and because I m proud of it), I tried to do a short write up of the inner workings of this effect. Let's start with the code:
[org 100h]
les ax,[si]
next16bitPixel:
dec ax
stosw
add ax, [es:di+bx]
rcr ax, 1
dec ax ; not-needed (only added in compo-version to speed up progression)
dec ax ; not-needed (only added in compo-version to speed up progression)
xor bl, 160
jmp next16bitPixel
How does it work:
At it's heart this effect is not a plasma, but it is a fire-effect. What those normally do is: They iterativley update video memory by replacing a pixel by the average of its neighbouring pixels and its old value. For the fire to fade out, the new value also gets decremented by a fixed amount every frame until it reaches zero.To preserve the fire burning and not turn completely black, you do add new hotspots of random noise to the image. Those then get smoothed out and slowly fade away by all the averaging and decrementing.
This is what is happening at the heart of "Text plasmosis" as well, but with the following specialties:
I first discovered this effect in graphics mode (see: https://demozoo.org/productions/337776/) and had the problem, that it was hard to get the fire started. You need enough asymmetries in video ram initially. Often the effect turned out to show the same values for all the pixels that just kept iterating through the palette. The smallest version I could get working in mode13h needed 20 bytes, so I decided to add music and release it as a 32 byte effect. In graphics mode this effect looks a bit different because it has vertical stripes that stem from the alternating high-byte and low-byte of the 16bit pixels the calculation uses.
So when realizing, that that those 16bit values perfectly matched memory layout in text mode, I got lucky trice:
The first version i had needed 14 bytes, but it did take quite long to come out of initialization phase (where the asymmetries distribute across video memory and start showing the plasma effect in the visible part of it). And because I did not want to make the audience wait for 3 minutes, I used two more bytes to speed up progression. (see code above)
That's all I can think of so far ...
---------------------------------------
p.s.:
Addendum:"... standing on the shoulders of giants."
I deeply need to thank all the others size coders whose work I built upon. For example I never would have figured out myself how to make `les ax,[si]` load 'es' with an address that can be used to write to text video memory.
It's so great to do coding in a area of demo coding, where you can have a look at the code of the amazing creations of others to learn from those, because they are sooo small. Any disassembler will do. :-)
Thanks also to all the maintainers of http://www.sizecoding.org/
... and many thanks to the orga team of https://lovebyte.party/ because they did such a great demo party and because they allowed my entry in even after the deadline and did the extra work of re-doing part of their preparation. (That was necessary, beause I had the idea for text mode during one of the competitions ... so the entry is completely party coded :-) )
p.p.s. I later found an even shorter version (only 13 bytes) of the effect with slightly different visuals using 8bit values:
[org 100h]
les ax,[si]
nextPixel:
dec ax
stosb
add al, [es:di+bx]
rcr al, 1
xor bl, 160
jmp nextPixel
edit: