
        .386
        .MODEL FLAT
        LOCALS @@

        DATASEG

        PUBLIC _RB_Dx, _RB_Dy
_RB_Dx DD 0
_RB_Dy DD 0

ix DD 0
iy DD 0

        CODESEG

;extern void RB_DoRaster(byte *dest, const byte *org, const byte (*table)[256],
;                        sint32 sx, sint32 sy);
;#pragma aux RB_DoRaster parm [EDI] [ESI] [EBX] [EDX] [ECX]
PUBLIC RB_DoRaster_
RB_DoRaster_:
        PUSH    EBP
        
        ADD     EDX,256 SHL 16
        ADD     ECX,256 SHL 16

        SHL     EDX,16-9
        SHL     ECX,16-9
        MOV     EAX,[_RB_Dx]
        SHL     EAX,16-9
        MOV     [ix],EAX
        MOV     EAX,[_RB_Dy]
        SHL     EAX,16-9
        MOV     [iy],EAX
        MOV     EBP,EDX         ; Free EDX
        XOR     EDX,EDX

        i = 0
        REPT 320
                MOV     EAX,ECX
                SHR     EAX,32-9        ; Higher bits of sy
                ADD     ECX,[iy]
                SHLD    EAX,EBP,9       ; Higher bits of sx
                ADD     EBP,[ix]
                MOV     DH,[ESI+EAX]
                MOV     DL,[EDI+i]
                MOV     DL,[EBX+EDX]
                MOV     [EDI+i],DL
                i = i + 1
        ENDM

        POP     EBP
        RET



END

