Difference between revisions of "Memories"
(→Scrolling tilted plane) |
(→Parallax checkerboards) |
||
Line 21: | Line 21: | ||
===Parallax checkerboards=== | ===Parallax checkerboards=== | ||
− | The parallax checkerboards have been released by me as 32 bytes effect "Projektbeschreibung" in 2018. It was the direct attempt to bring "Follow the light" (https://www.pouet.net/prod.php?which=28543) from "Digimind" (2006) or my own "Lucy" (2014)(https://www.pouet.net/prod.php?which=63293) down to 32 bytes. Very helpful inspirations came from "Rrrolas" "Paralaxa" (32 bytes, 2007, https://www.pouet.net/prod.php?which=32281) and "Sensenstahl"s "Byteropolis" (2013) (https://www.pouet.net/prod.php?which=61075). In fact Rrrolas rendering approach was already close to the final solution, the code was modified to correct the | + | The parallax checkerboards have been released by me as 32 bytes effect "Projektbeschreibung" in 2018. It was the direct attempt to bring "Follow the light" (https://www.pouet.net/prod.php?which=28543) from "Digimind" (2006) or my own "Lucy" (2014)(https://www.pouet.net/prod.php?which=63293) down to 32 bytes. Very helpful inspirations came from "Rrrolas" "Paralaxa" (32 bytes, 2007, https://www.pouet.net/prod.php?which=32281) and "Sensenstahl"s "Byteropolis" (2013) (https://www.pouet.net/prod.php?which=61075). In fact Rrrolas rendering approach was already close to the final solution, the code was modified to correct the planes arrangement, change the shape from triangles to checkerboards and improve on the colors. In "Memories", the coloring of "Digimind"s version was used. |
===Sierpinski rotozoomer=== | ===Sierpinski rotozoomer=== |
Revision as of 14:00, 18 April 2020
Contents
Introduction
Hello! My name is "HellMood" and this is not a usual wiki style article. It will be written from my point of view, in first person. This article is all about a tiny MS DOS program called "Memories". This program has a size of 256 bytes and won the "PC 256 byte" competition of the event "Revision" in 2020, as well as the whole event (public choice award). You can watch a video of the output of this program here (https://www.youtube.com/watch?v=Imquk_3oFf4) and a video including live reactions of online audience and moderators here (https://www.twitch.tv/videos/589179638?t=7h02m40s). You can download the release and comment here (https://www.pouet.net/prod.php?which=85227). This wiki article will give you an indepth analysis of the program and point out historical references as well as development steps. In case you did not notice, you are now on the "sizecoding wiki". This will help you not only to understand the interior of "Memories", but also enable you to produce something like this yourself. Feel free to look around!
Disclaimer
This article discusses the submitted DosBox version (256 bytes). The available archive contains versions for FreeDos and Windows XP Dos, which at the time of writing, don't work on all computers. These alternative versions were included as proof of concept, to show that this program does not only run on the emulator "DosBox". For the "PC 256 bytes" competition of the event "Revision" in 2020, it was allowed to specify either "FreeDos" or "DosBox" as platform, the latter with a specific configuration. It is in fact possible to modify the DosBox version to work on FreeDos, MS DOS, WinXP and Win98 as the released alternative versions showcase, but this is not the focus of this article. Anyway, safe versions for all platform and all computers are in the works.
History of tiny effects
Sizecoders think in size categories. For MSDOS, these categories are 256b, 128b, 64b and 32b. These are the standards of one of the biggest demoscene archives, http://www.pouet.net. There is no 16b category, although many tiny effects can be implemented in 16 bytes. Almost all of the effects of "Memories" have been coded and optimized by me before, and mostly the implementations were attempts to reduce an already existing effect in size, or do something similar in less size. Reducing the size in this case means, reducing it to the (one of the) next lower 2^N category. For example i might have seen an effect done in 33 to 64 bytes, and then reduced the size to 32 bytes or less. Almost everytime i moved an effect to a lower category, i submitted the resulting tiny program to a demoscene party which allowed remote entries in the 256b category and/or published the result to http://www.pouet.net . In this section i will introduce the effects and mention the origins and authors.
Array of chessboards
The origin of this effect is my own "Kasparov 16b" from 2018 (https://www.pouet.net/prod.php?which=75912) apparently i "had this piece lying around, stuck at 17 bytes and not that beautiful, until i found a trick ;)" (quote from the release notes) There was a similar effect in 32 bytes before : "ew" by headcrash from 2003 . (https://www.pouet.net/prod.php?which=17567) In this case, my design goal was to show "real" chessboards of 8x8 fields and recognizable dark and light squares, as well as the correct orientation of the single chessboards, meaning that the bottom left corner (a1) has to be a dark square. (source!) For "Memories", the effect had to be reimplemented with another approach of writing to the screen to work with the framework, also the scrolling direction was changed to be different from the "scrolling tilted plane" effect.
Zooming circles
The zooming circles were supposed to be entered to a demoparty as a 32 bytes intro, but i never actually did it. There is no real predecessor in 64 bytes, because in the 64b category much more complex effects are possible. The zooming circles were the result of desperately trying to reach the 32b category for a circular "tunnel" effect, for that my own record is still 52 bytes ("Neontube" - 2016)(https://www.pouet.net/prod.php?which=66808) which in turn was the optimization of the all-time-classic "constant evolution" from ryg/Farbrausch (2003) (https://www.pouet.net/prod.php?which=8697). In the zooming circles routine, the distance and the angle are removed/ignored, so that the 32b category could be reached.
Scrolling tilted plane
The scrolling tilted plane is one of my own releases, "floorcast 32b" from 2018. Floorcasts have its own history in sizecoding, the effect was brought down stepwise from 256 bytes to 32 bytes. The versions differ in the number of planes, some show two planes, others only one. For the "floorcast 32b" release i specifically decided against the "XOR" texture, whereas in "Memories" i used it again, but disguised with another final touch of "AND".
- "rain_storm version 2008 - 256 bytes - https://www.pouet.net/prod.php?which=50479
- "org_100h" version 2008 - 128 bytes - https://www.pouet.net/prod.php?which=63271
- "Baudsurfer" version 2013 - 86 bytes - https://www.pouet.net/prod.php?which=61070
- "Baudsurfer" version 2014 - 64 bytes - https://www.pouet.net/prod.php?which=63305
- "HellMood" version 2018 - 32 bytes - https://www.pouet.net/prod.php?which=77774
Parallax checkerboards
The parallax checkerboards have been released by me as 32 bytes effect "Projektbeschreibung" in 2018. It was the direct attempt to bring "Follow the light" (https://www.pouet.net/prod.php?which=28543) from "Digimind" (2006) or my own "Lucy" (2014)(https://www.pouet.net/prod.php?which=63293) down to 32 bytes. Very helpful inspirations came from "Rrrolas" "Paralaxa" (32 bytes, 2007, https://www.pouet.net/prod.php?which=32281) and "Sensenstahl"s "Byteropolis" (2013) (https://www.pouet.net/prod.php?which=61075). In fact Rrrolas rendering approach was already close to the final solution, the code was modified to correct the planes arrangement, change the shape from triangles to checkerboards and improve on the colors. In "Memories", the coloring of "Digimind"s version was used.
Sierpinski rotozoomer
This consists of two effects, the rotozoomer and the sierpinski effect as a texture. The sierpinski effect is based on my own "Colpinski 16b" from 2013 (https://www.pouet.net/prod.php?which=62079) where "frag" from "fsqrt" helped pushing the limits. There is no real predecessor to that, because it is known that this effect can be done directly by combining X and Y, instead of an IFS approach. The rotozoomer was released as 32b intro "rotastic" by me in 2017 (https://www.pouet.net/prod.php?which=70112), it is based on the ideas of "ryg" from "Farbrausch" (51 bytes, 2002, https://www.pouet.net/prod.php?which=5015) and "Gargaj" from "Conspiracy" (49 bytes, 2002, https://www.pouet.net/prod.php?which=6088).
Raycast bent tunnel
The raycast bent tunnel is a tweaked version of my own 64 bytes "Into a new era" release (2018, https://www.pouet.net/prod.php?which=78044). The custom colors were exchanged for colors of the standard palette, the geometry was tweaked a bit and changed accordingly, so that no depth effect was used for the calculation of texture values. The standalone version of this effect has a size of 50 bytes. The two main inspirations for the 64 bytes version were two 128 byte intros, "Spongy" from "TBC" (2009, https://www.pouet.net/prod.php?which=53871) and "Wolf128" from "Baudsurfer" (2014, https://www.pouet.net/prod.php?which=63518), while the particular algorithm was developed independently.
Ocean night to day
The ocean effect is based on my own 64 bytes release "Ocean" from 2016 (https://www.pouet.net/prod.php?which=66857). The custom color generation and music generation have been stripped from the original, both were not compatible with the main framework of "Memories" without consuming a LOT of extra space. The special effect of "dawn" happens as a by product of the general framework approach. This will be explained in the next chapter.
Fading effect
The transition between two effects is itself an own effect, which has no real predecessor. It is rather an idea that evolved over the years, and might have been done by many others in similar ways. In a nutshell, while calculating a frame, each pixel position is randomized and the time - which determines the effect to use - is offset by a this randomization value which is downscaled before. This allows the usage of the standard VGA palette (picture, source) rather than creating custom colors for real crossfading and thus saves space.
Tiny Megademo Framework
For putting many tiny effects together into a "megademo", they have all to use the same approach and they have to be mostly free of assumptions (contents of memory and registers). Also they have to use the same timing values and be tuned to a shared timing in general. Preparing the single effects to be includeable in a frame work like this took quite some time and required a lot of extra space initially. It has to be noted, that - sadly - some of my most impressive effects (judged by audience reactions and views on social media) could not be included at all, because the approaches were not combineable without a HUGE overhead. Once all effects were streamlined, i could think about "factoring" out common calculations which repeatedly occur, resulting in a few saved bytes. The framework does the following:
- Setting up screen mode to 320 x 200 pixels in 256 colors
- Initializing a pointer to the screen
- Installing a callback for timing and music
- Mainloop
- Calculation of X and X from the current screen location
- P = Pseudorandom value from screen location
- Offset current time T by a scaled value P'
- Selection of effect number N according to T'
- Execution of effect N (X,Y) for current pixel
- Triple diagonal interlacing for smoothing
- Repeat until frame is complete
- Set timer to a tempo of ~35 FPS
- Check keyboard for ESC
- Quit on ESC, otherwise continue
Code of framework
org 100h
s:
mov al,0x13
int 0x10
xchg bp,ax
push 0xa000-10
pop es
mov ax,0x251c
mov dl,timer
int 0x21
top:
mov ax,0xcccd
mul di
add al,ah
xor ah,ah
add ax,bp
shr ax,9
and al,15
xchg bx,ax
mov bh,1
mov bl,[byte bx+table]
call bx
stosb
inc di
inc di
jnz top
mov al,tempo
out 40h,al
in al,0x60
dec al
jnz top
sounds:
db 0xc3 ; is MIDI/RET
Explaination of effects
Array of chessboards
Zooming circles
Scrolling tilted plane
Parallax checkerboards
Sierpinski rotozoomer
Raycast bent tunnel
Ocean night to day
Fading Effect
MIDI music part
Release Code (complete)
; "memories" by HellMood/DESiRE
; the tiny megademo, 256 byte msdos intro
; shown in April 2020 @ REVISION
;
; (= WILL BE COMMENTED IN DETAIL LATER =)
;
; create : nasm.exe memories.asm -fbin -o memories.com
; CHOOSE YOUR TARGET PLATFORM (compo version is dosbox)
; be sure to use the dosbox.conf from this archive!
; only ONE of the defines should be active!
%define dosbox ; size : 256 bytes
;%define freedos ; size : 230 bytes
;%define winxpdos ; size : 263 bytes
; DON'T TOUCH THESE UNLESS YOU KNOW WHAT YOU'RE DOING
%ifdef winxpdos
%define music
%define switch_uart
%define safe_dx
%define safe_segment
%endif
%ifdef freedos
%define safe_dx
%endif
%ifdef dosbox
%define music
;%define safe_dx ; sometimes needed
%endif
; GLOBAL PARAMETERS, TUNE WITH CARE!
%define volume 127 ; not used on dosbox (optimization)
%define instrument 11
%define scale_mod -19*32*4;
%define time_mask 7
%define targetFPS 35
%define tempo 1193182/256/targetFPS
%define sierp_color 0x2A
%define tunnel_base_color 20
%define tunnel_pattern 6
%define tilt_plate_pattern 4+8+16
%define circles_pattern 8+16
org 100h
s:
%ifdef freedos
mov fs,ax
mov [fs:0x46c],ax
%endif
mov al,0x13
int 0x10
xchg bp,ax
push 0xa000-10
pop es
%ifndef freedos
mov ax,0x251c
%ifdef safe_dx
mov dx,timer
%else ; assume DH=1, mostly true on DosBox
mov dl,timer
%endif
int 0x21
%endif
top:
%ifdef freedos
mov bp,[fs:0x46c]
%endif
mov ax,0xcccd
mul di
add al,ah
xor ah,ah
add ax,bp
shr ax,9
and al,15
xchg bx,ax
mov bh,1
mov bl,[byte bx+table]
call bx
stosb
inc di
inc di
jnz top
mov al,tempo
out 40h,al
in al,0x60
dec al
jnz top
sounds:
db 0xc3 ; is MIDI/RET
%ifdef music
db instrument,0x93
%ifdef switch_uart
db volume ; without switch, volume is in table
db 0x3f
%endif
%endif
table: ; first index is volume, change order with care!
db fx2-s,fx1-s,fx0-s,fx3-s,fx4-s,fx5-s,fx6-s,sounds-s,stop-s
stop:
pop ax
ret
timer:
%ifndef freedos
%ifdef safe_segment
push cs
pop ds
%endif
inc bp
%ifdef music
test bp, time_mask
jnz nomuse
mov dx,0x330
mov si,sounds
outsb
outsb
outsb
imul ax,bp,scale_mod
shr ax,10
add al,22
out dx,al
outsb
%ifdef switch_uart
inc dx
outsb
%endif
%endif
nomuse:
iret
%endif
fx0: ; tilted plane, scrolling
mov ax,0x1329
add dh,al
div dh
xchg dx,ax
imul dl
sub dx,bp
xor ah,dl
mov al,ah
and al,tilt_plate_pattern
ret
fx2: ; board of chessboards
xchg dx,ax
sub ax,bp
xor al,ah
or al,0xDB
add al,13h
ret
fx1: ; circles, zooming
mov al,dh
sub al,100
imul al
xchg dx,ax
imul al
add dh,ah
mov al,dh
add ax,bp
and al,circles_pattern
ret
fx3: ; parallax checkerboards
mov cx,bp
mov bx,-16
fx3L:
add cx,di
mov ax,819
imul cx
ror dx,1
inc bx
ja fx3L
lea ax,[bx+31]
ret
fx4: ; sierpinski rotozoomer
lea cx,[bp-2048]
sal cx,3
movzx ax,dh
movsx dx,dl
mov bx,ax
imul bx,cx
add bh,dl
imul dx,cx
sub al,dh
and al,bh
and al,0b11111100
salc ; VERY slow on dosbox, but ok
jnz fx4q
mov al,sierp_color
fx4q:
ret
fx5: ; raycast bent tunnel
mov cl,-9
fx5L:
push dx
mov al,dh
sub al,100
imul cl
xchg ax,dx
add al,cl
imul cl
mov al,dh
xor al,ah
add al,4
test al,-8
pop dx
loopz fx5L
sub cx,bp
xor al,cl
aam tunnel_pattern; VERY slow on dosbox, but ok
add al,tunnel_base_color
ret
fx6: ; ocean night / to day sky
sub dh,120
js fx6q
mov [bx+si],dx
fild word [bx+si]
fidivr dword [bx+si]
fstp dword [bx+si-1]
mov ax,[bx+si]
add ax,bp
and al,128
dec ax
fx6q:
ret
Further tweaks
Do be done ;)