;컴컴컴컴컴컴컴컴�
; by Cazz/Zombie �
; may '97        �
;컴컴컴컴컴컴컴컴� 
model tpascal
.386
locals

codeseg

; local variables
v1      dd      ?
v2      dd      ?
v3      dd      ?
v4      dd      ?
v5      dd      ?

; in pascal: rotozoomer(x0,y0,xx,xy,yx,yy:longint;src,dest:pointer);
public  rotozoomer2

; HELP MEEEeeee... (make it faster)
rotozoomer2     proc	near
arg	x0:dword,y0:dword,xx:dword,xy:dword,yx:dword,yy:dword,src:dword,dest:dword
        push    ds

        lds     si,src
        les     di,dest
        xor     di,di

        mov     eax,y0
        sal     eax,8
        add     eax,x0
        mov     v1,eax
        xor     eax,eax
        mov     v2,eax

        mov     eax,yy  ; if yy and xy and xx are in code segment
        mov     v3,eax  ; then i don't have to use stack to get
        mov     eax,xy  ; the values later and ebp is free for
        mov     v4,eax	; other calculations :-)
        mov     eax,xx
        mov     v5,eax

        push    bp      ; but save it anyway, pascal needs it, i don't
        mov     bp,word ptr yx
	mov	si,word ptr v5
@@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. i can't say it's fast, rather slow :(

        xor     eax,eax

; unrolled loop to save some more ticks
rept    160
        mov     al,dh
        mov     ah,bh
        add     bx,bp
        add     dx,si
        mov     cl,[eax]                ; AGI :(
        mov     al,dh
        mov     ah,bh
        add     bx,bp
        add     dx,si
        add     di,2                    ; to exclude AGI
        mov     ch,[eax]
        mov     es:[di-2],cx
endm

        mov     eax,v3
        add     v1,eax
        mov     eax,v4
        add     v2,eax

        cmp     di,64000
        jnz     @@outer
        pop     bp

        pop     ds
        ret
endp    rotozoomer2

        end