;컴컴컴컴컴컴컴컴�
; by Cazz/Zombie �
; may '97        �
;컴컴컴컴컴컴컴컴�
model	tpascal
.386
locals

codeseg

; local variables
v1      dd      ?
v2      dd      ?

; in pascal: rotozoomer(x0,y0,xx,xy,yx,yy:longint;src,dest:pointer);
public  rotozoomer

; HELP MEEEeeee... (make it faster)
rotozoomer      proc	near
arg	x0:dword,y0:dword,xx:dword,xy:dword,yx:dword,yy:dword,src:dword,dest:dword
; xx is actually not needed here, but you need it if you want to
; do standard rotozoomer, not twisting.
        push    ds

        lds     si,src
        les     di,dest
        xor     di,di
        mov     si,word ptr yx

        mov     eax,y0
        sal     eax,8
        add     eax,x0
        mov     v1,eax
        xor     eax,eax
        mov     v2,eax

@outer:
        mov     bx,word ptr v1
        mov     dx,word ptr v2

; theoretical minimum of clocks per pixel on 486 is 6, but probably
; it needs more because of delays from/to memory read/write and cache
; misses and AGIs and... i can't say it's fast, rather slow :(

        xor     eax,eax
        XXX=320

; let's unroll the loop to save more some ticks
rept    160
        mov     al,dh
        mov     ah,bh
        add     bx,si
        add     dx,XXX
        XXX=XXX-1
        mov     cl,[eax]                ; AGI :(
        mov     al,dh
        mov     ah,bh
        add     bx,si
        add     dx,XXX
        XXX=XXX-1
        add     di,2                    ; to exclude AGI
        mov     ch,[eax]
        mov     es:[di-2],cx
endm

        mov     eax,yy
        add     [v1],eax
        mov     eax,xy
        add     [v2],eax

        cmp     di,64000
        jnz     @outer

        pop     ds
        ret
endp    rotozoomer

        end