    .386p
    .model flat, c
    locals
;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
; EQUATES
;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
                .code
                extrn pic2:dword
                extrn pic1:dword
                public ory1,orx1


Frames          = 10
FramesNum       = 1                    ; Fazisok szama
PageDist        = DeltaDist*FramesNum   ; Lapok tavolsaga
DefDist         = PageDist*5            ; A legnagyobb tavolsag
DeltaDist       = 55                    ; A kozeledes sebessege
PageRot         = 16                    ; Lapok elforgatasa
DeltaRot        = 2                     ; Forgasi sebesseg
orx1            dw      32768
SzinMelyseg     db      0

Random          macro
                mov esi, 00046ch
                add ax, [esi]
                add ax, [RandSeed]
                add ax, [esi]
                mov [RandSeed], ax
endm

inp             macro port
                mov dx, port
                in al, dx
endm

outp            macro port, value
                mov dx, port
                mov al, value
                out dx, al
endm

outpw           macro port, value
                mov dx, port
                mov ax, value
                out dx, ax
endm

SXL_DX_1        macro
                db 0c1h
                db 0e2h
                db 001h
endm

;о∙по∙по∙по∙по∙по∙по∙по∙по∙по∙по∙по∙по∙по∙по∙по∙по∙по∙по∙по∙по∙по∙по∙по∙по∙п
; DATA
;о∙по∙по∙по∙по∙по∙по∙по∙по∙по∙по∙по∙по∙по∙по∙по∙по∙по∙по∙по∙по∙по∙по∙по∙по∙п
DDX1            dw 0
DDY1            dw 0
DDX2            dw 0
DDY2            dw 0
I               dw ?
J               dw ?
Rot5            db ?                    ; Aktualis szog
Rot4            db ?                    ; Aktualis szog
Rot3            db ?                    ; A Rotx byte-oknak lenyeges a sor-
Rot2            db ?                    ; rendje, mert dword-kent is vannak
Rot1            db ?                    ; egyutt kezelve!
Dist1           dw ?                    ; Aktualis tavolsag
Dist2           dw ?                    ;
Dist3           dw ?                    ;
Dist4           dw ?                    ;
Dist5           dw ?                    ;
FramesCount     dw 0                    ; A fazisok szama
ory1            dw 32768                ; Lasd a neveben!
RandSeed        dw 091ch
Filler          db 000h                 ; A hatter szine, ilyennel nem rajzol
                                        ; illetve, ezzel tolti fel a hianyzo
                                        ; reszt
;ўўўўўўўўўўўўўўўўўўўўўўўўўўўўўўўўўўўўўўўўўўўўўўўўўўўўўўўўўўўўўўўўўўўўўўўўўўў
; CODE
;ўўўўўўўўўўўўўўўўўўўўўўўўўўўўўўўўўўўўўўўўўўўўўўўўўўўўўўўўўўўўўўўўўўўўўўўўўўў
MakeMath        macro szog, tavolsag
                ; ddx1 := (CosTable[rot]*dist) div 256;
                ; ddy1 := (SinTable[rot]*dist) div 256;
                ; ddx2 := (Cos2Table[rot]*dist) div 256;
                ; ddy2 := (Sin2Table[rot]*dist) div 256;
                ; i := x-ddx1*160-ddx2*50; j := y-ddy1*160-ddy2*50;
                mov cx, orx1
                mov di, [ory1]
                xor ebx, ebx
                mov bl, szog            ; rot -> bx
                mov ax, word ptr Cosinus1[ebx*2]      ; cos1(rot) -> ax
;mov tavolsag,ax
                imul tavolsag           ; cos1(rot)*scale
                shld dx, ax, 8
                mov [DDX1], dx          ; cos1(rot)*scale/256 -> ddx1
                sal dx, 4
                sub cx, dx              ; i = i-32*ddx1
                sal dx, 2
                sub cx, dx              ; i = i-128*ddx1
                mov ax, word ptr Sinus1[ebx*2]      ; sin1(rot) -> ax
;imul ax
;mov I,ax
                imul tavolsag           ; sin1(rot)*scale
                shld dx, ax, 8
                mov [DDY1], dx          ; sin1(rot)*scale/256 -> ddy1
                sal dx, 4               ; i = i-32*ddy1
                sub di, dx
                sal dx, 2               ; i = i-128*ddy1
                sub di, dx
                mov ax, word ptr Cosinus2[ebx*2]      ; cos2(rot) -> ax
                imul tavolsag           ; cos2(rot)*scale
                shld dx, ax, 8
                mov [DDX2], dx          ; cos2(rot)*scale/256 -> ddx2
                SXL_DX_1
                sub cx, dx              ; i = i-4*ddx2
                sal dx, 3
                sub cx, dx              ; i = i-32*ddx2
                SXL_DX_1
                sub cx, dx              ; i = i-64*ddx2
                mov ax, word ptr Sinus2[ebx*2]      ; sin2(rot) -> ax
                imul tavolsag           ; sin2(rot)*scale
;                imul ax
                shld dx, ax, 8
                mov [DDY2], dx          ; sin2(rot)*scale/256 -> ddy2
;                SXL_DX_1
                sub di, dx              ; j = j-4*ddx2
                sal dx, 3
                sub di, dx              ; j = j-32*ddx2
                SXL_DX_1
                sub di, dx              ; j = j-64*ddx2

                mov [I], cx
                mov [J], di
endm

MakePic         macro
                local @@VLoop, @@HLoop, @@Kitolto, @@Kell, @@nemgonosz
                mov edi, pic2
                mov si, [I]
                mov ebp, 100
                xor ebx, ebx
         @@VLoop:
                mov ax, si
                mov dx, [J]
                mov cx, 160
         @@HLoop:
                add ax, [DDX1]
                add dx, [DDY1]
                mov bl, ah
                mov bh, dh

                push ebp
                mov ebp,pic1
                mov bl, [byte ptr ebp+ebx]
                pop ebp
IF Kell? EQ 1
                cmp bl, [Filler]
                je @@Kitolto
ENDIF
                cmp bl,SzinMelyseg
                jae @@nemgonosz
                mov bl,SzinMelyseg
@@nemgonosz:
                sub bl,SzinMelyseg
                mov bh,bl
                mov [edi], bx
                mov [edi+320], bx
@@Kitolto:
                inc edi
                inc edi
                dec cx
                jnz @@HLoop
                mov dx, [DDY2]
                add si, [DDX2]
                add edi, 320
                add [J], dx
                dec ebp
                jnz @@VLoop             ; Eddig
endm               
                public Effect2Init
Effect2Init:
                pushad
                mov [Rot1], 0*PageRot
                mov [Dist1], DefDist-0*PageDist
                mov [Rot2], 1*PageRot
                mov [Dist2], DefDist-1*PageDist
                mov [Rot3], 2*PageRot
                mov [Dist3], DefDist-2*PageDist
                mov [Rot4], 3*PageRot
                mov [Dist4], DefDist-3*PageDist
                mov [Rot5], 4*PageRot
                mov [Dist5], DefDist-4*PageDist
                mov [FramesCount], FramesNum
                popad
                ret

                public Effect2
Effect2:
                pushad
Kell? = 0
                mov     SzinMelyseg,35
                MakeMath [Rot1], [Dist1]
                MakePic
                add [Rot1], DeltaRot
                sub [Dist1], DeltaDist
                add [Rot2], DeltaRot
                sub [Dist2], DeltaDist
                add [Rot3], DeltaRot
                sub [Dist3], DeltaDist
                add [Rot4], DeltaRot
                sub [Dist4], DeltaDist
                add [Rot5], DeltaRot
                sub [Dist5], DeltaDist
                dec [FramesCount]
                jnz @@NonDefault
                ror [dword ptr Rot5], 8 ; Rot-ok csereje
                mov al, [Rot1]
                mov [Rot2], al
                ;Random
                ;mov [Rot1], al
                add [Rot1],16
                mov [Dist1], DefDist-0*PageDist
                mov [Dist2], DefDist-1*PageDist
                mov [Dist3], DefDist-2*PageDist
                mov [Dist4], DefDist-3*PageDist
                mov [Dist5], DefDist-4*PageDist
                mov [FramesCount], FramesNum
        @@NonDefault:
                popad
                ret
Sinus1:
                dw 0, 6, 13, 19, 25, 31, 38, 44, 50
                dw 56, 62, 68, 74, 80, 86, 92, 98
                dw 104, 109, 115, 121, 126, 132, 137, 142
                dw 147, 152, 157, 162, 167, 172, 177, 181
                dw 185, 190, 194, 198, 202, 206, 209, 213
                dw 216, 220, 223, 226, 229, 231, 234, 237
                dw 239, 241, 243, 245, 247, 248, 250, 251
                dw 252, 253, 254, 255, 255, 256, 256, 256
                dw 256, 256, 255, 255, 254, 253, 252, 251
                dw 250, 248, 247, 245, 243, 241, 239, 237
                dw 234, 231, 229, 226, 223, 220, 216, 213
                dw 209, 206, 202, 198, 194, 190, 185, 181
                dw 177, 172, 167, 162, 157, 152, 147, 142
                dw 137, 132, 126, 121, 115, 109, 104, 98
                dw 92, 86, 80, 74, 68, 62, 56, 50
                dw 44, 38, 31, 25, 19, 13, 6, 0
                dw -6, -13, -19, -25, -31, -38, -44, -50
                dw -56, -62, -68, -74, -80, -86, -92, -98
                dw -104, -109, -115, -121, -126, -132, -137, -142
                dw -147, -152, -157, -162, -167, -172, -177, -181
                dw -185, -190, -194, -198, -202, -206, -209, -213
                dw -216, -220, -223, -226, -229, -231, -234, -237
                dw -239, -241, -243, -245, -247, -248, -250, -251
                dw -252, -253, -254, -255, -255, -256, -256, -256
                dw -256, -256, -255, -255, -254, -253, -252, -251
                dw -250, -248, -247, -245, -243, -241, -239, -237
                dw -234, -231, -229, -226, -223, -220, -216, -213
                dw -209, -206, -202, -198, -194, -190, -185, -181
                dw -177, -172, -167, -162, -157, -152, -147, -142
                dw -137, -132, -126, -121, -115, -109, -104, -98
                dw -92, -86, -80, -74, -68, -62, -56, -50
                dw -44, -38, -31, -25, -19, -13, -6

Cosinus1:
                dw 256, 256, 256, 255, 255, 254, 253, 252, 251
                dw 250, 248, 247, 245, 243, 241, 239, 237
                dw 234, 231, 229, 226, 223, 220, 216, 213
                dw 209, 206, 202, 198, 194, 190, 185, 181
                dw 177, 172, 167, 162, 157, 152, 147, 142
                dw 137, 132, 126, 121, 115, 109, 104, 98
                dw 92, 86, 80, 74, 68, 62, 56, 50
                dw 44, 38, 31, 25, 19, 13, 6, 0
                dw -6, -13, -19, -25, -31, -38, -44, -50
                dw -56, -62, -68, -74, -80, -86, -92, -98
                dw -104, -109, -115, -121, -126, -132, -137, -142
                dw -147, -152, -157, -162, -167, -172, -177, -181
                dw -185, -190, -194, -198, -202, -206, -209, -213
                dw -216, -220, -223, -226, -229, -231, -234, -237
                dw -239, -241, -243, -245, -247, -248, -250, -251
                dw -252, -253, -254, -255, -255, -256, -256, -256
                dw -256, -256, -255, -255, -254, -253, -252, -251
                dw -250, -248, -247, -245, -243, -241, -239, -237
                dw -234, -231, -229, -226, -223, -220, -216, -213
                dw -209, -206, -202, -198, -194, -190, -185, -181
                dw -177, -172, -167, -162, -157, -152, -147, -142
                dw -137, -132, -126, -121, -115, -109, -104, -98
                dw -92, -86, -80, -74, -68, -62, -56, -50
                dw -44, -38, -31, -25, -19, -13, -6, 0
                dw 6, 13, 19, 25, 31, 38, 44, 50
                dw 56, 62, 68, 74, 80, 86, 92, 98
                dw 104, 109, 115, 121, 126, 132, 137, 142
                dw 147, 152, 157, 162, 167, 172, 177, 181
                dw 185, 190, 194, 198, 202, 206, 209, 213
                dw 216, 220, 223, 226, 229, 231, 234, 237
                dw 239, 241, 243, 245, 247, 248, 250, 251
                dw 252, 253, 254, 255, 255, 256, 256

Sinus2:
                dw 307, 307, 307, 306, 306, 305, 304, 303, 301
                dw 300, 298, 296, 294, 292, 289, 287, 284
                dw 281, 278, 274, 271, 267, 263, 260, 255
                dw 251, 247, 242, 237, 233, 228, 222, 217
                dw 212, 206, 201, 195, 189, 183, 177, 171
                dw 164, 158, 151, 145, 138, 131, 124, 118
                dw 111, 103, 96, 89, 82, 75, 67, 60
                dw 53, 45, 38, 30, 23, 15, 8, 0
                dw -8, -15, -23, -30, -38, -45, -53, -60
                dw -67, -75, -82, -89, -96, -103, -111, -118
                dw -124, -131, -138, -145, -151, -158, -164, -171
                dw -177, -183, -189, -195, -201, -206, -212, -217
                dw -222, -228, -233, -237, -242, -247, -251, -255
                dw -260, -263, -267, -271, -274, -278, -281, -284
                dw -287, -289, -292, -294, -296, -298, -300, -301
                dw -303, -304, -305, -306, -306, -307, -307, -307
                dw -307, -307, -306, -306, -305, -304, -303, -301
                dw -300, -298, -296, -294, -292, -289, -287, -284
                dw -281, -278, -274, -271, -267, -263, -260, -255
                dw -251, -247, -242, -237, -233, -228, -222, -217
                dw -212, -206, -201, -195, -189, -183, -177, -171
                dw -164, -158, -151, -145, -138, -131, -124, -118
                dw -111, -103, -96, -89, -82, -75, -67, -60
                dw -53, -45, -38, -30, -23, -15, -8, 0
                dw 8, 15, 23, 30, 38, 45, 53, 60
                dw 67, 75, 82, 89, 96, 103, 111, 118
                dw 124, 131, 138, 145, 151, 158, 164, 171
                dw 177, 183, 189, 195, 201, 206, 212, 217
                dw 222, 228, 233, 237, 242, 247, 251, 255
                dw 260, 263, 267, 271, 274, 278, 281, 284
                dw 287, 289, 292, 294, 296, 298, 300, 301
                dw 303, 304, 305, 306, 306, 307, 307

Cosinus2:
                dw 0, -8, -15, -23, -30, -38, -45, -53, -60
                dw -67, -75, -82, -89, -96, -103, -111, -118
                dw -124, -131, -138, -145, -151, -158, -164, -171
                dw -177, -183, -189, -195, -201, -206, -212, -217
                dw -222, -228, -233, -237, -242, -247, -251, -255
                dw -260, -263, -267, -271, -274, -278, -281, -284
                dw -287, -289, -292, -294, -296, -298, -300, -301
                dw -303, -304, -305, -306, -306, -307, -307, -307
                dw -307, -307, -306, -306, -305, -304, -303, -301
                dw -300, -298, -296, -294, -292, -289, -287, -284
                dw -281, -278, -274, -271, -267, -263, -260, -255
                dw -251, -247, -242, -237, -233, -228, -222, -217
                dw -212, -206, -201, -195, -189, -183, -177, -171
                dw -164, -158, -151, -145, -138, -131, -124, -118
                dw -111, -103, -96, -89, -82, -75, -67, -60
                dw -53, -45, -38, -30, -23, -15, -8, 0
                dw 8, 15, 23, 30, 38, 45, 53, 60
                dw 67, 75, 82, 89, 96, 103, 111, 118
                dw 124, 131, 138, 145, 151, 158, 164, 171
                dw 177, 183, 189, 195, 201, 206, 212, 217
                dw 222, 228, 233, 237, 242, 247, 251, 255
                dw 260, 263, 267, 271, 274, 278, 281, 284
                dw 287, 289, 292, 294, 296, 298, 300, 301
                dw 303, 304, 305, 306, 306, 307, 307, 307
                dw 307, 307, 306, 306, 305, 304, 303, 301
                dw 300, 298, 296, 294, 292, 289, 287, 284
                dw 281, 278, 274, 271, 267, 263, 260, 255
                dw 251, 247, 242, 237, 233, 228, 222, 217
                dw 212, 206, 201, 195, 189, 183, 177, 171
                dw 164, 158, 151, 145, 138, 131, 124, 118
                dw 111, 103, 96, 89, 82, 75, 67, 60
                dw 53, 45, 38, 30, 23, 15, 8

                end
