14 RANDVAL equ code_end + 4
22 jz .notblank ; loop while vblank bit is 0 (visible area)
39 ; "allocate" the next segment for the framebuffer
47 ; clear the framebuffer
55 mov byte [setcol + 1], 199 ; shadow color
59 mov byte [setcol + 1], 2 ; fractal color
62 ; copy framebuffer to video ram
65 ; point ds:si (source) to es:0
69 ; point es:di (dest) to a000:0
82 in al, 60h ; read pending scancode from the keyboard port (if any)
83 dec al ; ESC is 1, so decrement ...
84 jnz mainloop ; ... and loop as long as the result was not 0
86 ; switch back to text mode (mode 3)
93 ; draw sierpinski triangle
95 ; start from one of the vertices
97 mov bx, [sierp_verts + 2]
99 mov [SIERP_PT + 2], bx
100 ; number of iterations in cx
102 dsloop: ; pick a vertex at random and move half-way there
106 div bx ; dx is now rand % 3
107 ; put the vertex address in bx
111 ; add to SIERP_PT and divide by 2 to move half-way there
115 mov [SIERP_PT], ax ; store the resulting X back to [SIERP_PT]
116 mov di, ax ; save X coordinate in di
118 add ax, [SIERP_PT + 2]
120 mov [SIERP_PT + 2], ax ; store the reuslting Y back to [SIERP_PT + 2]
121 add ax, si ; add offset
125 add bx, ax ; bx = Y * 320
127 mov byte [es:bx + di], al
141 bounds dw 200 - SHADOW_OFFS
152 mov ax, [di] ; grab vertex X
153 add ax, [si] ; add velocity X
155 cmp ax, [ebx * 2 + bounds - 2]
159 sub ax, [si] ; revert to previous X
160 neg word [si] ; negate velocity X
162 mov [di], ax ; update vertex X
164 ; to do the same for Y increment edi and esi by 2
174 ; random number generator
186 ; mul dword [randmul]
188 ; and eax, 0x7fffffff
193 ;randmul dd 1103515245
198 times 510-($-$$) db 0