comment +

For compilation  use:

Turbo  Assembler 2.02
tasm /m2 recurse.asm
tlink /t recurse.obj

code: bitl/7dump

comment end! +

x = 0
y = 2
d = 4
q = 6
m = 8
v50 = 10
qq  = 12


.model tiny
.data
x_     DW 160  ; 0
y_     DW 100  ; 2
d_     DW 50   ; 4
q_     DW 0    ; 6
m_     DW 0    ; 8
v50_   DW 50   ; 10
qq_    DW 0    ; 12

.code
.486
org 0100h

start:

mov al, 13h
int 10h

add dh, al              ; cs + 1300h
mov fs, dx              ; segment for buffer

    xor ax, ax
    xor bx, bx
    mov dx, 03c8h
    out dx, al
    inc dx
    mov cx, 64
setpalette:
    mov al, bl
    out dx, al
    out dx, al
    out dx, al
    inc bl
loop setpalette


;**********************************************************************
; MAIN LOOP
;**********************************************************************
@mainloop:
inc word ptr q_
xor bp, bp
call fractal

;---------------- BLUR----------------------------
push ds
mov ax, fs
mov ds, ax
mov es, ax

    xor di, di
    mov si, di
    mov cx, 320*200/4+160
@Loooooop:
    mov eax, [di-320]
    add eax, [di+320]
    add eax, [di-1]
    add eax, [di+1]
    and eax, 0fcfcfcfch
    shr eax, 2
    stosd
    dec cx
    jnz @Loooooop

pop ds
;--------------------------------------------------



     mov  dx, 3DAh      ; Wait for vertical retrace
@w1:
;     in   al, dx
;     test al, 8
;     jnz  @w1
@w2:
     in   al, dx
     test al, 8
     jz   @w2


                        ; move buffer to screen
     push 0a000h
     pop es
     xor si, 320*4
     mov di, si
;     xor eax, eax
     mov cx, (64000 -320*8)/4
     @ll:
     db 64h
     movsd
;     mov fs:[si-4], eax
     loop @ll
in al, 60h              ; wait for ESC
dec al

jnz @mainloop

;**********************************************************************
; EXIT
;**********************************************************************
mov ax, 3               ; back to text
int 10h                 ; mode
ret

PROC fractal
  lea si, x_
;  cmp bp, 3
;  jbe @skip_draw

     imul di, [si+y], 320
     add di, [si+x]
     mov byte ptr fs:[di], 63
  @skip_draw:

  ;{if depth>2 then exit;}
  cmp bp, 5
  ja @exit


   mov cx, 3
   @l:
     push word ptr [si+x]
     push word ptr [si+y]
     push word ptr [si+d]
     push bp
     push cx

     ;{inc(bp)}
     ;{qq:=q*depth;}
     mov ax, word ptr [si+q]
     inc bp
     imul bp
     mov word ptr [si+qq], ax

    ;{fractal_circle(round(cos(qq/50+(pi*2/3)*m)*dd+xx),
    ; round(sin(qq/50+(pi*2/3)*m)*dd+yy), dd div 2, depth+1);}
      shl cx, 1
      mov word ptr [si+m], cx
      finit
      fild  word ptr [si+qq]
      fidiv word ptr [si+v50]
      fiadd word ptr [si+m]

      fsincos
      fimul word ptr [si+d]
      fiadd word ptr [si+x]
      fistp word ptr [si+x]
      fimul word ptr [si+d]
      fiadd word ptr [si+y]
      fistp word ptr [si+y]

      shr word ptr [si+d], 1

      call fractal

      pop cx
      pop bp
      pop word ptr [si+d]
      pop word ptr [si+y]
      pop word ptr [si+x]

  dec cx
  jnz @l

  @exit:

  ret
ENDP fractal

end start
