14 RANDVAL equ code_end + 4
15 SIERP_VERTS equ code_end + 8
23 jz .notblank ; loop while vblank bit is 0 (visible area)
40 ; "allocate" the next segment for the framebuffer
48 ; clear the framebuffer
56 mov byte [setcol + 1], 199 ; shadow color
60 mov byte [setcol + 1], 2 ; fractal color
63 ; copy framebuffer to video ram
66 ; point ds:si (source) to es:0
70 ; point es:di (dest) to a000:0
83 in al, 60h ; read pending scancode from the keyboard port (if any)
84 dec al ; ESC is 1, so decrement ...
85 jnz mainloop ; ... and loop as long as the result was not 0
87 ; switch back to text mode (mode 3)
94 ; draw sierpinski triangle
96 ; start from one of the vertices
98 mov bx, [sierp_verts + 2]
100 mov [SIERP_PT + 2], bx
101 ; number of iterations in cx
103 dsloop: ; pick a vertex at random and move half-way there
107 div bx ; dx is now rand % 3
108 ; put the vertex address in bx
112 ; add to SIERP_PT and divide by 2 to move half-way there
116 mov [SIERP_PT], ax ; store the resulting X back to [SIERP_PT]
117 mov di, ax ; save X coordinate in di
119 add ax, [SIERP_PT + 2]
121 mov [SIERP_PT + 2], ax ; store the reuslting Y back to [SIERP_PT + 2]
122 add ax, si ; add offset
126 add bx, ax ; bx = Y * 320
128 mov byte [es:bx + di], al
142 bounds dw 200 - SHADOW_OFFS
153 mov ax, [di] ; grab vertex X
154 add ax, [si] ; add velocity X
156 cmp ax, [bx + bounds - 2]
160 sub ax, [si] ; revert to previous X
161 neg word [si] ; negate velocity X
163 mov [di], ax ; update vertex X
165 ; to do the same for Y increment edi and esi by 2
175 ; random number generator
187 ; mul dword [randmul]
189 ; and eax, 0x7fffffff
194 ;randmul dd 1103515245
199 times 510-($-$$) db 0