'
'                           ___________________________________________
'         _______ _ _ _     \___           ___________________________/
'    /\  (_______) (_) |       /  //  //  /  
'   /  \  _  __  | |_| | _    /  //  //  / << version 0.86 alpha test >>
'  / /\ \| |(__| | | | || \  /  //  //  /  For FreeBASIC (v0.20b or later).
' | |__| | |     | | | |_) )/  //  //  /     
' |_|  |_|_|     |_|_|____//  //  //  /   Original Development by
'  _______________________/  //  //  /___ Adigun Azikiwe Polack for Aura Flow.
' /_____________________________________/
'
'  A  u  r  a      F  l  o  w      L  i  b  r  a  r  y      3
'_________________________________________________________________________
'
' (c)2005-2016 Adigun Azikiwe Polack/Aura Flow.  All Rights Reserved.
'
'
'
'   _____            __    ___  _  __    __  ___          __      __   
'  / ___/_________ _/ /__ |__ \| |/ /   /  |/  /___  ____/ /_  __/ /__ 
'  \__ \/ ___/ __ `/ / _ \__/ /|   /   / /|_/ / __ \/ __  / / / / / _ \
' ___/ / /__/ /_/ / /  __/ __//   |   / /  / / /_/ / /_/ / /_/ / /  __/
'/____/\___/\__,_/_/\___/____/_/|_|  /_/  /_/\____/\__,_/\__,_/_/\___/ 
'                                                                            
'
'_________________________________________________________________________
'                        ----- N O T I C E -----
'_________________________________________________________________________
' The following is this piece of source code to this version of AFlib III.
' You are free to look at it to give you some inspiring ideas in your own
' programming in FreeBASIC, but you are *never* to even change or adjust
' any of this source code whatsoever in any way, shape, or form at all.
' EVER.  ;)
'
' The reason for this is to ensure that all of the routines in this source
' code are working as properly as they should in FreeBASIC v0.20b or
' newer.  That is all.
'
' With that said, do enjoy the library and be inspired even more
' greatly than ever!!!  (^-^)//
'_________________________________________________________________________
'
'Special Thanks to Mysoft for the AWESOME Scale2X conversions to FB for
'many sorts of common full-screen graphics modes from 320x200 all the way
'up to 1280x1024 (including 1280x720 HD, also!!), all in 15-, 16-, 24-,
'and 32-bit color!!!  ;) !!

#include once "fbgfx.bi"
ScreenControl(FB.SET_DRIVER_NAME, "GDI")

Const SC2X_GFXres_X_320 = 320
Const SC2X_GFXres_Y_200 = 200
Const SC2X_GFXres_Y_240 = 240
'_________________________________________________________________________
Const SC2X_GFXres_X_400 = 400
Const SC2X_GFXres_Y_300 = 300
'_________________________________________________________________________
Const SC2X_GFXres_X_512 = 512
Const SC2X_GFXres_Y_384 = 384
'_________________________________________________________________________
Const SC2X_GFXres_X_640 = 640
Const SC2X_GFXres_Y_400 = 400
Const SC2X_GFXres_Y_480 = 480
'_________________________________________________________________________
Const SC2X_GFXres_X_720 = 720
'_________________________________________________________________________
Const SC2X_GFXres_Y_576 = 576
'_________________________________________________________________________
Const SC2X_GFXres_X_800 = 800
Const SC2X_GFXres_Y_600 = 600
'_________________________________________________________________________
Const SC2X_GFXres_X_1024 = 1024
Const SC2X_GFXres_Y_768 = 768
'_________________________________________________________________________
Const SC2X_GFXres_X_1152 = 1152
Const SC2X_GFXres_Y_864 = 864
'_________________________________________________________________________
Const SC2X_GFXres_X_1280 = 1280
Const SC2X_GFXres_Y_720 = 720
Const SC2X_GFXres_Y_800 = 800
Const SC2X_GFXres_Y_960 = 960
Const SC2X_GFXres_Y_1024 = 1024

'_________________________________________________________________________


#define SC2X_X_320x200 (SC2X_GFXres_X_320 / 2)
#define SC2X_Y_320x200 (SC2X_GFXres_Y_200 / 2)

#define SC2X_X_320x240 (SC2X_GFXres_X_320 / 2)
#define SC2X_Y_320x240 (SC2X_GFXres_Y_240 / 2)

#define SC2X_X_400x300 (SC2X_GFXres_X_400 / 2)
#define SC2X_Y_400x300 (SC2X_GFXres_Y_300 / 2)

#define SC2X_X_512x384 (SC2X_GFXres_X_512 / 2)
#define SC2X_Y_512x384 (SC2X_GFXres_Y_384 / 2)

#define SC2X_X_640x400 (SC2X_GFXres_X_640 / 2)
#define SC2X_Y_640x400 (SC2X_GFXres_Y_400 / 2)

#define SC2X_X_640x480 (SC2X_GFXres_X_640 / 2)
#define SC2X_Y_640x480 (SC2X_GFXres_Y_480 / 2)

#define SC2X_X_720x480 (SC2X_GFXres_X_720 / 2)
#define SC2X_Y_720x480 (SC2X_GFXres_Y_480 / 2)

#define SC2X_X_720x576 (SC2X_GFXres_X_720 / 2)
#define SC2X_Y_720x576 (SC2X_GFXres_Y_576 / 2)

#define SC2X_X_800x600 (SC2X_GFXres_X_800 / 2)
#define SC2X_Y_800x600 (SC2X_GFXres_Y_600 / 2)

#define SC2X_X_1024x768 (SC2X_GFXres_X_1024 / 2)
#define SC2X_Y_1024x768 (SC2X_GFXres_Y_768 / 2)

#define SC2X_X_1152x864 (SC2X_GFXres_X_1152 / 2)
#define SC2X_Y_1152x864 (SC2X_GFXres_Y_864 / 2)

#define SC2X_X_1280x720 (SC2X_GFXres_X_1280 / 2)
#define SC2X_Y_1280x720 (SC2X_GFXres_Y_720 / 2)

#define SC2X_X_1280x768 (SC2X_GFXres_X_1280 / 2)
#define SC2X_Y_1280x768 (SC2X_GFXres_Y_768 / 2)

#define SC2X_X_1280x800 (SC2X_GFXres_X_1280 / 2)
#define SC2X_Y_1280x800 (SC2X_GFXres_Y_800 / 2)

#define SC2X_X_1280x960 (SC2X_GFXres_X_1280 / 2)
#define SC2X_Y_1280x960 (SC2X_GFXres_Y_960 / 2)

#define SC2X_X_1280x1024 (SC2X_GFXres_X_1280 / 2)
#define SC2X_Y_1280x1024 (SC2X_GFXres_Y_1024 / 2)




Declare Sub AFlibIII_Scale2X_320x200
Declare Sub AFlibIII_Scale2X_320x240
Declare Sub AFlibIII_Scale2X_400x300
Declare Sub AFlibIII_Scale2X_512x384
Declare Sub AFlibIII_Scale2X_640x400
Declare Sub AFlibIII_Scale2X_640x480
Declare Sub AFlibIII_Scale2X_720x480
Declare Sub AFlibIII_Scale2X_720x576
Declare Sub AFlibIII_Scale2X_800x600
Declare Sub AFlibIII_Scale2X_1024x768
Declare Sub AFlibIII_Scale2X_1152x864
Declare Sub AFlibIII_Scale2X_1280x720
Declare Sub AFlibIII_Scale2X_1280x768
Declare Sub AFlibIII_Scale2X_1280x800
Declare Sub AFlibIII_Scale2X_1280x960
Declare Sub AFlibIII_Scale2X_1280x1024
Declare Sub AFlibIII_Scale2X_auto
Declare Sub AFlibIII_Scale4X_auto
Declare Sub AFlibIII_Scale8X_auto


Declare sub raw_Scale2X_320x200_16 (Byval PTORG as any ptr, Byval PTDST as any ptr)
Declare sub raw_Scale2X_320x200_32 (Byval PTORG as any ptr,Byval PTDST as any ptr)

Declare sub raw_Scale2X_320x240_16 (Byval PTORG as any ptr, Byval PTDST as any ptr)
Declare sub raw_Scale2X_320x240_32 (Byval PTORG as any ptr,Byval PTDST as any ptr)

Declare sub raw_Scale2X_400x300_16 (Byval PTORG as any ptr, Byval PTDST as any ptr)
Declare sub raw_Scale2X_400x300_32 (Byval PTORG as any ptr,Byval PTDST as any ptr)

Declare sub raw_Scale2X_512x384_16 (Byval PTORG as any ptr, Byval PTDST as any ptr)
Declare sub raw_Scale2X_512x384_32 (Byval PTORG as any ptr,Byval PTDST as any ptr)

Declare sub raw_Scale2X_640x400_16 (Byval PTORG as any ptr, Byval PTDST as any ptr)
Declare sub raw_Scale2X_640x400_32 (Byval PTORG as any ptr,Byval PTDST as any ptr)

Declare sub raw_Scale2X_640x480_16 (Byval PTORG as any ptr, Byval PTDST as any ptr)
Declare sub raw_Scale2X_640x480_32 (Byval PTORG as any ptr,Byval PTDST as any ptr)

Declare sub raw_Scale2X_720x480_16 (Byval PTORG as any ptr, Byval PTDST as any ptr)
Declare sub raw_Scale2X_720x480_32 (Byval PTORG as any ptr,Byval PTDST as any ptr)

Declare sub raw_Scale2X_720x576_16 (Byval PTORG as any ptr, Byval PTDST as any ptr)
Declare sub raw_Scale2X_720x576_32 (Byval PTORG as any ptr,Byval PTDST as any ptr)

Declare sub raw_Scale2X_800x600_16 (Byval PTORG as any ptr, Byval PTDST as any ptr)
Declare sub raw_Scale2X_800x600_32 (Byval PTORG as any ptr,Byval PTDST as any ptr)

Declare sub raw_Scale2X_1024x768_16 (Byval PTORG as any ptr, Byval PTDST as any ptr)
Declare sub raw_Scale2X_1024x768_32 (Byval PTORG as any ptr,Byval PTDST as any ptr)

Declare sub raw_Scale2X_1152x864_16 (Byval PTORG as any ptr, Byval PTDST as any ptr)
Declare sub raw_Scale2X_1152x864_32 (Byval PTORG as any ptr,Byval PTDST as any ptr)

Declare sub raw_Scale2X_1280x720_16 (Byval PTORG as any ptr, Byval PTDST as any ptr)
Declare sub raw_Scale2X_1280x720_32 (Byval PTORG as any ptr,Byval PTDST as any ptr)

Declare sub raw_Scale2X_1280x768_16 (Byval PTORG as any ptr, Byval PTDST as any ptr)
Declare sub raw_Scale2X_1280x768_32 (Byval PTORG as any ptr,Byval PTDST as any ptr)

Declare sub raw_Scale2X_1280x800_16 (Byval PTORG as any ptr, Byval PTDST as any ptr)
Declare sub raw_Scale2X_1280x800_32 (Byval PTORG as any ptr,Byval PTDST as any ptr)

Declare sub raw_Scale2X_1280x960_16 (Byval PTORG as any ptr, Byval PTDST as any ptr)
Declare sub raw_Scale2X_1280x960_32 (Byval PTORG as any ptr,Byval PTDST as any ptr)

Declare sub raw_Scale2X_1280x1024_16 (Byval PTORG as any ptr, Byval PTDST as any ptr)
Declare sub raw_Scale2X_1280x1024_32 (Byval PTORG as any ptr,Byval PTDST as any ptr)







'__________________________________________________________________________
Sub AFlibIII_Scale2X_320x200

Dim as Integer Gfx_horiz, Gfx_vert, GFX_depth
Dim buffer as any ptr
ScreenInfo Gfx_horiz, Gfx_vert, GFX_depth

If GFX_depth < 15 then Exit Sub
Buffer = screenptr

Dim image as any ptr

Gfx_horiz /= 2
Gfx_vert /= 2

image = ImageCreate(Gfx_horiz, Gfx_vert)
Get (0,0)-(Gfx_horiz - 1, Gfx_vert - 1), image

Select Case as Const GFX_depth
  Case 15: raw_Scale2X_320x200_16(image+sizeof(fb.image),Buffer)
  Case 16: raw_Scale2X_320x200_16(image+sizeof(fb.image),Buffer)
  Case 24: raw_Scale2X_320x200_32(image+sizeof(fb.image),Buffer)
  Case 32: raw_Scale2X_320x200_32(image+sizeof(fb.image),Buffer)
End Select

ImageDestroy image
End Sub



'__________________________________________________________________________
Sub AFlibIII_Scale2X_320x240

Dim as Integer Gfx_horiz, Gfx_vert, GFX_depth
Dim buffer as any ptr
ScreenInfo Gfx_horiz, Gfx_vert, GFX_depth

If GFX_depth < 15 then Exit Sub
Buffer = screenptr

Dim image as any ptr

Gfx_horiz /= 2
Gfx_vert /= 2

image = ImageCreate(Gfx_horiz, Gfx_vert)
Get (0,0)-(Gfx_horiz - 1, Gfx_vert - 1), image

Select Case as Const GFX_depth
  Case 15: raw_Scale2X_320x240_16(image+sizeof(fb.image),Buffer)
  Case 16: raw_Scale2X_320x240_16(image+sizeof(fb.image),Buffer)
  Case 24: raw_Scale2X_320x240_32(image+sizeof(fb.image),Buffer)
  Case 32: raw_Scale2X_320x240_32(image+sizeof(fb.image),Buffer)
End Select

ImageDestroy image
End Sub



'__________________________________________________________________________
Sub AFlibIII_Scale2X_400x300

Dim as Integer Gfx_horiz, Gfx_vert, GFX_depth
Dim buffer as any ptr
ScreenInfo Gfx_horiz, Gfx_vert, GFX_depth

If GFX_depth < 15 then Exit Sub
Buffer = screenptr

Dim image as any ptr

Gfx_horiz /= 2
Gfx_vert /= 2

image = ImageCreate(Gfx_horiz, Gfx_vert)
Get (0,0)-(Gfx_horiz - 1, Gfx_vert - 1), image

Select Case as Const GFX_depth
  Case 15: raw_Scale2X_400x300_16(image+sizeof(fb.image),Buffer)
  Case 16: raw_Scale2X_400x300_16(image+sizeof(fb.image),Buffer)
  Case 24: raw_Scale2X_400x300_32(image+sizeof(fb.image),Buffer)
  Case 32: raw_Scale2X_400x300_32(image+sizeof(fb.image),Buffer)
End Select

ImageDestroy image
End Sub



'__________________________________________________________________________
Sub AFlibIII_Scale2X_512x384

Dim as Integer Gfx_horiz, Gfx_vert, GFX_depth
Dim buffer as any ptr
ScreenInfo Gfx_horiz, Gfx_vert, GFX_depth

If GFX_depth < 15 then Exit Sub
Buffer = screenptr

Dim image as any ptr

Gfx_horiz /= 2
Gfx_vert /= 2

image = ImageCreate(Gfx_horiz, Gfx_vert)
Get (0,0)-(Gfx_horiz - 1, Gfx_vert - 1), image

Select Case as Const GFX_depth
  Case 15: raw_Scale2X_512x384_16(image+sizeof(fb.image),Buffer)
  Case 16: raw_Scale2X_512x384_16(image+sizeof(fb.image),Buffer)
  Case 24: raw_Scale2X_512x384_32(image+sizeof(fb.image),Buffer)
  Case 32: raw_Scale2X_512x384_32(image+sizeof(fb.image),Buffer)
End Select

ImageDestroy image
End Sub



'__________________________________________________________________________
Sub AFlibIII_Scale2X_640x400

Dim as Integer Gfx_horiz, Gfx_vert, GFX_depth
Dim buffer as any ptr
ScreenInfo Gfx_horiz, Gfx_vert, GFX_depth

If GFX_depth < 15 then Exit Sub
Buffer = screenptr

Dim image as any ptr

Gfx_horiz /= 2
Gfx_vert /= 2

image = ImageCreate(Gfx_horiz, Gfx_vert)
Get (0,0)-(Gfx_horiz - 1, Gfx_vert - 1), image

Select Case as Const GFX_depth
  Case 15: raw_Scale2X_640x400_16(image+sizeof(fb.image),Buffer)
  Case 16: raw_Scale2X_640x400_16(image+sizeof(fb.image),Buffer)
  Case 24: raw_Scale2X_640x400_32(image+sizeof(fb.image),Buffer)
  Case 32: raw_Scale2X_640x400_32(image+sizeof(fb.image),Buffer)
End Select

ImageDestroy image
End Sub



'__________________________________________________________________________
Sub AFlibIII_Scale2X_640x480

Dim as Integer Gfx_horiz, Gfx_vert, GFX_depth
Dim buffer as any ptr
ScreenInfo Gfx_horiz, Gfx_vert, GFX_depth

If GFX_depth < 15 then Exit Sub
Buffer = screenptr

Dim image as any ptr

Gfx_horiz /= 2
Gfx_vert /= 2

image = ImageCreate(Gfx_horiz, Gfx_vert)
Get (0,0)-(Gfx_horiz - 1, Gfx_vert - 1), image

Select Case as Const GFX_depth
  Case 15: raw_Scale2X_640x480_16(image+sizeof(fb.image),Buffer)
  Case 16: raw_Scale2X_640x480_16(image+sizeof(fb.image),Buffer)
  Case 24: raw_Scale2X_640x480_32(image+sizeof(fb.image),Buffer)
  Case 32: raw_Scale2X_640x480_32(image+sizeof(fb.image),Buffer)
End Select

ImageDestroy image
End Sub



'__________________________________________________________________________
Sub AFlibIII_Scale2X_720x480

Dim as Integer Gfx_horiz, Gfx_vert, GFX_depth
Dim buffer as any ptr
ScreenInfo Gfx_horiz, Gfx_vert, GFX_depth

If GFX_depth < 15 then Exit Sub
Buffer = screenptr

Dim image as any ptr

Gfx_horiz /= 2
Gfx_vert /= 2

image = ImageCreate(Gfx_horiz, Gfx_vert)
Get (0,0)-(Gfx_horiz - 1, Gfx_vert - 1), image

Select Case as Const GFX_depth
  Case 15: raw_Scale2X_720x480_16(image+sizeof(fb.image),Buffer)
  Case 16: raw_Scale2X_720x480_16(image+sizeof(fb.image),Buffer)
  Case 24: raw_Scale2X_720x480_32(image+sizeof(fb.image),Buffer)
  Case 32: raw_Scale2X_720x480_32(image+sizeof(fb.image),Buffer)
End Select

ImageDestroy image
End Sub



'__________________________________________________________________________
Sub AFlibIII_Scale2X_720x576

Dim as Integer Gfx_horiz, Gfx_vert, GFX_depth
Dim buffer as any ptr
ScreenInfo Gfx_horiz, Gfx_vert, GFX_depth

If GFX_depth < 15 then Exit Sub
Buffer = screenptr

Dim image as any ptr

Gfx_horiz /= 2
Gfx_vert /= 2

image = ImageCreate(Gfx_horiz, Gfx_vert)
Get (0,0)-(Gfx_horiz - 1, Gfx_vert - 1), image

Select Case as Const GFX_depth
  Case 15: raw_Scale2X_720x576_16(image+sizeof(fb.image),Buffer)
  Case 16: raw_Scale2X_720x576_16(image+sizeof(fb.image),Buffer)
  Case 24: raw_Scale2X_720x576_32(image+sizeof(fb.image),Buffer)
  Case 32: raw_Scale2X_720x576_32(image+sizeof(fb.image),Buffer)
End Select

ImageDestroy image
End Sub



'__________________________________________________________________________
Sub AFlibIII_Scale2X_800x600

Dim as Integer Gfx_horiz, Gfx_vert, GFX_depth
Dim buffer as any ptr
ScreenInfo Gfx_horiz, Gfx_vert, GFX_depth

If GFX_depth < 15 then Exit Sub
Buffer = screenptr

Dim image as any ptr

Gfx_horiz /= 2
Gfx_vert /= 2

image = ImageCreate(Gfx_horiz, Gfx_vert)
Get (0,0)-(Gfx_horiz - 1, Gfx_vert - 1), image

Select Case as Const GFX_depth
  Case 15: raw_Scale2X_800x600_16(image+sizeof(fb.image),Buffer)
  Case 16: raw_Scale2X_800x600_16(image+sizeof(fb.image),Buffer)
  Case 24: raw_Scale2X_800x600_32(image+sizeof(fb.image),Buffer)
  Case 32: raw_Scale2X_800x600_32(image+sizeof(fb.image),Buffer)
End Select

ImageDestroy image
End Sub



'__________________________________________________________________________
Sub AFlibIII_Scale2X_1024x768

Dim as Integer Gfx_horiz, Gfx_vert, GFX_depth
Dim buffer as any ptr
ScreenInfo Gfx_horiz, Gfx_vert, GFX_depth

If GFX_depth < 15 then Exit Sub
Buffer = screenptr

Dim image as any ptr

Gfx_horiz /= 2
Gfx_vert /= 2

image = ImageCreate(Gfx_horiz, Gfx_vert)
Get (0,0)-(Gfx_horiz - 1, Gfx_vert - 1), image

Select Case as Const GFX_depth
  Case 15: raw_Scale2X_1024x768_16(image+sizeof(fb.image),Buffer)
  Case 16: raw_Scale2X_1024x768_16(image+sizeof(fb.image),Buffer)
  Case 24: raw_Scale2X_1024x768_32(image+sizeof(fb.image),Buffer)
  Case 32: raw_Scale2X_1024x768_32(image+sizeof(fb.image),Buffer)
End Select

ImageDestroy image
End Sub



'__________________________________________________________________________
Sub AFlibIII_Scale2X_1152x864

Dim as Integer Gfx_horiz, Gfx_vert, GFX_depth
Dim buffer as any ptr
ScreenInfo Gfx_horiz, Gfx_vert, GFX_depth

If GFX_depth < 15 then Exit Sub
Buffer = screenptr

Dim image as any ptr

Gfx_horiz /= 2
Gfx_vert /= 2

image = ImageCreate(Gfx_horiz, Gfx_vert)
Get (0,0)-(Gfx_horiz - 1, Gfx_vert - 1), image

Select Case as Const GFX_depth
  Case 15: raw_Scale2X_1152x864_16(image+sizeof(fb.image),Buffer)
  Case 16: raw_Scale2X_1152x864_16(image+sizeof(fb.image),Buffer)
  Case 24: raw_Scale2X_1152x864_32(image+sizeof(fb.image),Buffer)
  Case 32: raw_Scale2X_1152x864_32(image+sizeof(fb.image),Buffer)
End Select

ImageDestroy image
End Sub



'__________________________________________________________________________
Sub AFlibIII_Scale2X_1280x720

Dim as Integer Gfx_horiz, Gfx_vert, GFX_depth
Dim buffer as any ptr
ScreenInfo Gfx_horiz, Gfx_vert, GFX_depth

If GFX_depth < 15 then Exit Sub
Buffer = screenptr

Dim image as any ptr

Gfx_horiz /= 2
Gfx_vert /= 2

image = ImageCreate(Gfx_horiz, Gfx_vert)
Get (0,0)-(Gfx_horiz - 1, Gfx_vert - 1), image

Select Case as Const GFX_depth
  Case 15: raw_Scale2X_1280x720_16(image+sizeof(fb.image),Buffer)
  Case 16: raw_Scale2X_1280x720_16(image+sizeof(fb.image),Buffer)
  Case 24: raw_Scale2X_1280x720_32(image+sizeof(fb.image),Buffer)
  Case 32: raw_Scale2X_1280x720_32(image+sizeof(fb.image),Buffer)
End Select

ImageDestroy image
End Sub



'__________________________________________________________________________
Sub AFlibIII_Scale2X_1280x768

Dim as Integer Gfx_horiz, Gfx_vert, GFX_depth
Dim buffer as any ptr
ScreenInfo Gfx_horiz, Gfx_vert, GFX_depth

If GFX_depth < 15 then Exit Sub
Buffer = screenptr

Dim image as any ptr

Gfx_horiz /= 2
Gfx_vert /= 2

image = ImageCreate(Gfx_horiz, Gfx_vert)
Get (0,0)-(Gfx_horiz - 1, Gfx_vert - 1), image

Select Case as Const GFX_depth
  Case 15: raw_Scale2X_1280x768_16(image+sizeof(fb.image),Buffer)
  Case 16: raw_Scale2X_1280x768_16(image+sizeof(fb.image),Buffer)
  Case 24: raw_Scale2X_1280x768_32(image+sizeof(fb.image),Buffer)
  Case 32: raw_Scale2X_1280x768_32(image+sizeof(fb.image),Buffer)
End Select

ImageDestroy image
End Sub



'__________________________________________________________________________
Sub AFlibIII_Scale2X_1280x800

Dim as Integer Gfx_horiz, Gfx_vert, GFX_depth
Dim buffer as any ptr
ScreenInfo Gfx_horiz, Gfx_vert, GFX_depth

If GFX_depth < 15 then Exit Sub
Buffer = screenptr

Dim image as any ptr

Gfx_horiz /= 2
Gfx_vert /= 2

image = ImageCreate(Gfx_horiz, Gfx_vert)
Get (0,0)-(Gfx_horiz - 1, Gfx_vert - 1), image

Select Case as Const GFX_depth
  Case 15: raw_Scale2X_1280x800_16(image+sizeof(fb.image),Buffer)
  Case 16: raw_Scale2X_1280x800_16(image+sizeof(fb.image),Buffer)
  Case 24: raw_Scale2X_1280x800_32(image+sizeof(fb.image),Buffer)
  Case 32: raw_Scale2X_1280x800_32(image+sizeof(fb.image),Buffer)
End Select

ImageDestroy image
End Sub



'__________________________________________________________________________
Sub AFlibIII_Scale2X_1280x960

Dim as Integer Gfx_horiz, Gfx_vert, GFX_depth
Dim buffer as any ptr
ScreenInfo Gfx_horiz, Gfx_vert, GFX_depth

If GFX_depth < 15 then Exit Sub
Buffer = screenptr

Dim image as any ptr

Gfx_horiz /= 2
Gfx_vert /= 2

image = ImageCreate(Gfx_horiz, Gfx_vert)
Get (0,0)-(Gfx_horiz - 1, Gfx_vert - 1), image

Select Case as Const GFX_depth
  Case 15: raw_Scale2X_1280x960_16(image+sizeof(fb.image),Buffer)
  Case 16: raw_Scale2X_1280x960_16(image+sizeof(fb.image),Buffer)
  Case 24: raw_Scale2X_1280x960_32(image+sizeof(fb.image),Buffer)
  Case 32: raw_Scale2X_1280x960_32(image+sizeof(fb.image),Buffer)
End Select

ImageDestroy image
End Sub



'__________________________________________________________________________
Sub AFlibIII_Scale2X_1280x1024

Dim as Integer Gfx_horiz, Gfx_vert, GFX_depth
Dim buffer as any ptr
ScreenInfo Gfx_horiz, Gfx_vert, GFX_depth

If GFX_depth < 15 then Exit Sub
Buffer = screenptr

Dim image as any ptr

Gfx_horiz /= 2
Gfx_vert /= 2

image = ImageCreate(Gfx_horiz, Gfx_vert)
Get (0,0)-(Gfx_horiz - 1, Gfx_vert - 1), image

Select Case as Const GFX_depth
  Case 15: raw_Scale2X_1280x1024_16(image+sizeof(fb.image),Buffer)
  Case 16: raw_Scale2X_1280x1024_16(image+sizeof(fb.image),Buffer)
  Case 24: raw_Scale2X_1280x1024_32(image+sizeof(fb.image),Buffer)
  Case 32: raw_Scale2X_1280x1024_32(image+sizeof(fb.image),Buffer)
End Select

ImageDestroy image
End Sub



'__________________________________________________________________________
Sub AFlibIII_Scale2X_auto

  Dim as Integer Gfx_horiz, Gfx_vert, GFX_depth
  ScreenInfo Gfx_horiz, Gfx_vert, GFX_depth

  If GFX_depth < 15 then Exit Sub

  If Gfx_horiz = 320 then
    If Gfx_vert = 200 then AFlibIII_Scale2X_320x200
    If Gfx_vert = 240 then AFlibIII_Scale2X_320x240
  End if

  If Gfx_horiz = 400 and Gfx_vert = 300 then AFlibIII_Scale2X_400x300

  If Gfx_horiz = 512 and Gfx_vert = 384 then AFlibIII_Scale2X_512x384

  If Gfx_horiz = 640 then
    If Gfx_vert = 400 then AFlibIII_Scale2X_640x400
    If Gfx_vert = 480 then AFlibIII_Scale2X_640x480
  End if

  If Gfx_horiz = 720 then
    If Gfx_vert = 480 then AFlibIII_Scale2X_720x480
    If Gfx_vert = 576 then AFlibIII_Scale2X_720x576
  End if

  If Gfx_horiz = 800 and Gfx_vert = 600 then AFlibIII_Scale2X_800x600

  If Gfx_horiz = 1024 and Gfx_vert = 768 then AFlibIII_Scale2X_1024x768

  If Gfx_horiz = 1152 and Gfx_vert = 864 then AFlibIII_Scale2X_1152x864

  If Gfx_horiz = 1280 then
    If Gfx_vert = 720 then AFlibIII_Scale2X_1280x720
    If Gfx_vert = 768 then AFlibIII_Scale2X_1280x768
    If Gfx_vert = 800 then AFlibIII_Scale2X_1280x800
    If Gfx_vert = 960 then AFlibIII_Scale2X_1280x960
    If Gfx_vert = 1024 then AFlibIII_Scale2X_1280x1024
  End if

End Sub



'__________________________________________________________________________
Sub AFlibIII_Scale4X_auto
  
  AFlibIII_Scale2X_auto
  AFlibIII_Scale2X_auto
End Sub  



'__________________________________________________________________________
Sub AFlibIII_Scale8X_auto
  
  AFlibIII_Scale2X_auto
  AFlibIII_Scale2X_auto
  AFlibIII_Scale2X_auto
End Sub





Private Sub raw_Scale2X_320x200_16 (Byval PTORG as any ptr, Byval PTDST as any ptr)
  static as integer Y  
  Y = SC2X_Y_320x200
  
  #define ESZ 2  
  
  const PILI = SC2X_X_320x200
  const PILIS = SC2X_X_320x200-1
  const OPI = ESZ
  const TPI = ESZ*2  
  const OLIS = (SC2X_X_320x200-1)*ESZ
  const OLIA = (SC2X_X_320x200+1)*ESZ
  const TLISS = ((SC2X_X_320x200*2)-2)*ESZ
  const TLIS = ((SC2X_X_320x200*2)-1)*ESZ
  const TLI = ((SC2X_X_320x200*2))*ESZ
  const TLIA = ((SC2X_X_320x200*2)+1)*ESZ
  
  asm        
    mov ESI,[PTORG]
    mov EDI,[PTDST]
    lodsw
    stosw
    stosw
    mov [EDI+TLISS],AX
    mov [EDI+TLIS],AX
    mov ECX,PILIS
    _Sc2X16_320x200_FLNEXTPOINT_:
    lodsw
    mov BX,[ESI]
    mov DX,[ESI]
    cmp BX,[ESI+OLIS]
    je _Sc2X16_320x200_FLBEHODEF_
    cmp [ESI-TPI],DX
    je _Sc2X16_320x200_FLBEHODEF_
    cmp BX,[ESI-TPI]
    je _Sc2X16_320x200_FLNOCHGE0_
    mov BX,AX
    _Sc2X16_320x200_FLNOCHGE0_:
    mov [EDI],BX
    cmp [ESI],DX
    je _Sc2X16_320x200_FLNOCHGE1_
    mov DX,AX
    _Sc2X16_320x200_FLNOCHGE1_:
    mov [EDI+OPI],DX
    mov BX,[ESI-TPI]
    mov DX,[ESI+OLIS]
    cmp BX,DX
    je _Sc2X16_320x200_FLNOCHGE2_
    mov BX,AX
    _Sc2X16_320x200_FLNOCHGE2_:
    mov [EDI+TLI],BX
    cmp DX,[ESI]
    je _Sc2X16_320x200_FLNOCHGE3_
    mov DX,AX
    _Sc2X16_320x200_FLNOCHGE3_:
    mov [EDI+TLIA],DX
    add EDI,TPI
    dec ECX
    jnz _Sc2X16_320x200_FLNEXTPOINT_
    add EDI,TLI
    dec dword ptr [Y]
    jnz _Sc2X16_320x200_NEXTLINE_
    _Sc2X16_320x200_FLBEHODEF_:
    stosw
    stosw
    mov [EDI+TLISS],AX
    mov [EDI+TLIS],AX
    dec ECX
    jnz _Sc2X16_320x200_FLNEXTPOINT_
    add EDI,TLI
    dec dword ptr [Y]
    _Sc2X16_320x200_NEXTLINE_:
    mov ECX,PILI
    _Sc2X16_320x200_NEXTPOINT_:
    lodsw
    mov BX,[ESI-OLIA]
    mov DX,[ESI]
    cmp BX,[ESI+OLIS]
    je _Sc2X16_320x200_BEHODEF_
    cmp [ESI-TPI],DX
    je _Sc2X16_320x200_BEHODEF_
    cmp BX,[ESI-TPI]
    je _Sc2X16_320x200_NOCHGE0_
    mov BX,AX
    _Sc2X16_320x200_NOCHGE0_:
    mov [EDI],BX
    cmp [ESI-OLIA],DX
    je _Sc2X16_320x200_NOCHGE1_
    mov DX,AX
    _Sc2X16_320x200_NOCHGE1_:
    mov [EDI+OPI],DX
    mov BX,[ESI-TPI]
    mov DX,[ESI+OLIS]
    cmp BX,DX
    je _Sc2X16_320x200_NOCHGE2_
    mov BX,AX
    _Sc2X16_320x200_NOCHGE2_:
    mov [EDI+TLI],BX
    cmp DX,[ESI]
    je _Sc2X16_320x200_NOCHGE3_
    mov DX,AX
    _Sc2X16_320x200_NOCHGE3_:
    mov [EDI+TLIA],DX
    add EDI,TPI
    dec ECX
    jnz _Sc2X16_320x200_NEXTPOINT_
    add EDI,TLI
    dec dword ptr [Y]
    jnz _Sc2X16_320x200_NEXTLINE_
    jmp _Sc2X16_320x200_FINALEND_
    _Sc2X16_320x200_BEHODEF_:
    stosw
    stosw
    mov [EDI+TLISS],AX
    mov [EDI+TLIS],AX
    dec ECX
    jnz _Sc2X16_320x200_NEXTPOINT_
    add EDI,TLI
    dec dword ptr [Y]
    jnz _Sc2X16_320x200_NEXTLINE_
    _Sc2X16_320x200_FINALEND_:
  end asm  
end sub


Private Sub raw_Scale2X_320x200_32 (Byval PTORG as any ptr, Byval PTDST as any ptr)
  static as integer Y  
  Y = SC2X_Y_320x200
  
  #define ESZ 4  
  
  const PILI = SC2X_X_320x200
  const PILIS = SC2X_X_320x200-1
  const OPI = ESZ
  const TPI = ESZ*2  
  const OLIS = (SC2X_X_320x200-1)*ESZ
  const OLIA = (SC2X_X_320x200+1)*ESZ
  const TLISS = ((SC2X_X_320x200*2)-2)*ESZ
  const TLIS = ((SC2X_X_320x200*2)-1)*ESZ
  const TLI = ((SC2X_X_320x200*2))*ESZ
  const TLIA = ((SC2X_X_320x200*2)+1)*ESZ
  
  asm        
    mov ESI,[PTORG]
    mov EDI,[PTDST]
    lodsd
    stosd
    stosd
    mov [EDI+TLISS],EAX
    mov [EDI+TLIS],EAX
    mov ECX,PILIS
    _Sc2X32_320x200_FLNEXTPOINT_:
    lodsd
    mov EBX,[ESI]
    mov EDX,[ESI]
    cmp EBX,[ESI+OLIS]
    je _Sc2X32_320x200_FLBEHODEF_
    cmp [ESI-TPI],EDX
    je _Sc2X32_320x200_FLBEHODEF_
    cmp EBX,[ESI-TPI]
    je _Sc2X32_320x200_FLNOCHGE0_
    mov EBX,EAX
    _Sc2X32_320x200_FLNOCHGE0_:
    mov [EDI],EBX
    cmp [ESI],EDX
    je _Sc2X32_320x200_FLNOCHGE1_
    mov EDX,EAX
    _Sc2X32_320x200_FLNOCHGE1_:
    mov [EDI+OPI],EDX
    mov EBX,[ESI-TPI]
    mov EDX,[ESI+OLIS]
    cmp EBX,EDX
    je _Sc2X32_320x200_FLNOCHGE2_
    mov EBX,EAX
    _Sc2X32_320x200_FLNOCHGE2_:
    mov [EDI+TLI],EBX
    cmp EDX,[ESI]
    je _Sc2X32_320x200_FLNOCHGE3_
    mov EDX,EAX
    _Sc2X32_320x200_FLNOCHGE3_:
    mov [EDI+TLIA],EDX
    add EDI,TPI
    dec ECX
    jnz _Sc2X32_320x200_FLNEXTPOINT_
    add EDI,TLI
    dec dword ptr [Y]
    jnz _Sc2X32_320x200_NEXTLINE_
    _Sc2X32_320x200_FLBEHODEF_:
    stosd
    stosd
    mov [EDI+TLISS],EAX
    mov [EDI+TLIS],EAX
    dec ECX
    jnz _Sc2X32_320x200_FLNEXTPOINT_
    add EDI,TLI
    dec dword ptr [Y]
    _Sc2X32_320x200_NEXTLINE_:
    mov ECX,PILI
    _Sc2X32_320x200_NEXTPOINT_:
    lodsd
    mov EBX,[ESI-OLIA]
    mov EDX,[ESI]
    cmp EBX,[ESI+OLIS]
    je _Sc2X32_320x200_BEHODEF_
    cmp [ESI-TPI],EDX
    je _Sc2X32_320x200_BEHODEF_
    cmp EBX,[ESI-TPI]
    je _Sc2X32_320x200_NOCHGE0_
    mov EBX,EAX
    _Sc2X32_320x200_NOCHGE0_:
    mov [EDI],EBX
    cmp [ESI-OLIA],EDX
    je _Sc2X32_320x200_NOCHGE1_
    mov EDX,EAX
    _Sc2X32_320x200_NOCHGE1_:
    mov [EDI+OPI],EDX
    mov EBX,[ESI-TPI]
    mov EDX,[ESI+OLIS]
    cmp EBX,EDX
    je _Sc2X32_320x200_NOCHGE2_
    mov EBX,EAX
    _Sc2X32_320x200_NOCHGE2_:
    mov [EDI+TLI],EBX
    cmp EDX,[ESI]
    je _Sc2X32_320x200_NOCHGE3_
    mov EDX,EAX
    _Sc2X32_320x200_NOCHGE3_:
    mov [EDI+TLIA],EDX
    add EDI,TPI
    dec ECX
    jnz _Sc2X32_320x200_NEXTPOINT_
    add EDI,TLI
    dec dword ptr [Y]
    jnz _Sc2X32_320x200_NEXTLINE_
    jmp _Sc2X32_320x200_FINALEND_
    _Sc2X32_320x200_BEHODEF_:
    stosd
    stosd
    mov [EDI+TLISS],EAX
    mov [EDI+TLIS],EAX
    dec ECX
    jnz _Sc2X32_320x200_NEXTPOINT_
    add EDI,TLI
    dec dword ptr [Y]
    jnz _Sc2X32_320x200_NEXTLINE_
    _Sc2X32_320x200_FINALEND_:
  end asm  
end sub


Private Sub raw_Scale2X_320x240_16 (Byval PTORG as any ptr, Byval PTDST as any ptr)
  static as integer Y  
  Y = SC2X_Y_320x240
  
  #define ESZ 2  
  
  const PILI = SC2X_X_320x240
  const PILIS = SC2X_X_320x240-1
  const OPI = ESZ
  const TPI = ESZ*2  
  const OLIS = (SC2X_X_320x240-1)*ESZ
  const OLIA = (SC2X_X_320x240+1)*ESZ
  const TLISS = ((SC2X_X_320x240*2)-2)*ESZ
  const TLIS = ((SC2X_X_320x240*2)-1)*ESZ
  const TLI = ((SC2X_X_320x240*2))*ESZ
  const TLIA = ((SC2X_X_320x240*2)+1)*ESZ
  
  asm        
    mov ESI,[PTORG]
    mov EDI,[PTDST]
    lodsw
    stosw
    stosw
    mov [EDI+TLISS],AX
    mov [EDI+TLIS],AX
    mov ECX,PILIS
    _Sc2X16_320x240_FLNEXTPOINT_:
    lodsw
    mov BX,[ESI]
    mov DX,[ESI]
    cmp BX,[ESI+OLIS]
    je _Sc2X16_320x240_FLBEHODEF_
    cmp [ESI-TPI],DX
    je _Sc2X16_320x240_FLBEHODEF_
    cmp BX,[ESI-TPI]
    je _Sc2X16_320x240_FLNOCHGE0_
    mov BX,AX
    _Sc2X16_320x240_FLNOCHGE0_:
    mov [EDI],BX
    cmp [ESI],DX
    je _Sc2X16_320x240_FLNOCHGE1_
    mov DX,AX
    _Sc2X16_320x240_FLNOCHGE1_:
    mov [EDI+OPI],DX
    mov BX,[ESI-TPI]
    mov DX,[ESI+OLIS]
    cmp BX,DX
    je _Sc2X16_320x240_FLNOCHGE2_
    mov BX,AX
    _Sc2X16_320x240_FLNOCHGE2_:
    mov [EDI+TLI],BX
    cmp DX,[ESI]
    je _Sc2X16_320x240_FLNOCHGE3_
    mov DX,AX
    _Sc2X16_320x240_FLNOCHGE3_:
    mov [EDI+TLIA],DX
    add EDI,TPI
    dec ECX
    jnz _Sc2X16_320x240_FLNEXTPOINT_
    add EDI,TLI
    dec dword ptr [Y]
    jnz _Sc2X16_320x240_NEXTLINE_
    _Sc2X16_320x240_FLBEHODEF_:
    stosw
    stosw
    mov [EDI+TLISS],AX
    mov [EDI+TLIS],AX
    dec ECX
    jnz _Sc2X16_320x240_FLNEXTPOINT_
    add EDI,TLI
    dec dword ptr [Y]
    _Sc2X16_320x240_NEXTLINE_:
    mov ECX,PILI
    _Sc2X16_320x240_NEXTPOINT_:
    lodsw
    mov BX,[ESI-OLIA]
    mov DX,[ESI]
    cmp BX,[ESI+OLIS]
    je _Sc2X16_320x240_BEHODEF_
    cmp [ESI-TPI],DX
    je _Sc2X16_320x240_BEHODEF_
    cmp BX,[ESI-TPI]
    je _Sc2X16_320x240_NOCHGE0_
    mov BX,AX
    _Sc2X16_320x240_NOCHGE0_:
    mov [EDI],BX
    cmp [ESI-OLIA],DX
    je _Sc2X16_320x240_NOCHGE1_
    mov DX,AX
    _Sc2X16_320x240_NOCHGE1_:
    mov [EDI+OPI],DX
    mov BX,[ESI-TPI]
    mov DX,[ESI+OLIS]
    cmp BX,DX
    je _Sc2X16_320x240_NOCHGE2_
    mov BX,AX
    _Sc2X16_320x240_NOCHGE2_:
    mov [EDI+TLI],BX
    cmp DX,[ESI]
    je _Sc2X16_320x240_NOCHGE3_
    mov DX,AX
    _Sc2X16_320x240_NOCHGE3_:
    mov [EDI+TLIA],DX
    add EDI,TPI
    dec ECX
    jnz _Sc2X16_320x240_NEXTPOINT_
    add EDI,TLI
    dec dword ptr [Y]
    jnz _Sc2X16_320x240_NEXTLINE_
    jmp _Sc2X16_320x240_FINALEND_
    _Sc2X16_320x240_BEHODEF_:
    stosw
    stosw
    mov [EDI+TLISS],AX
    mov [EDI+TLIS],AX
    dec ECX
    jnz _Sc2X16_320x240_NEXTPOINT_
    add EDI,TLI
    dec dword ptr [Y]
    jnz _Sc2X16_320x240_NEXTLINE_
    _Sc2X16_320x240_FINALEND_:
  end asm  
end sub


Private Sub raw_Scale2X_320x240_32 (Byval PTORG as any ptr, Byval PTDST as any ptr)
  static as integer Y  
  Y = SC2X_Y_320x240
  
  #define ESZ 4  
  
  const PILI = SC2X_X_320x240
  const PILIS = SC2X_X_320x240-1
  const OPI = ESZ
  const TPI = ESZ*2  
  const OLIS = (SC2X_X_320x240-1)*ESZ
  const OLIA = (SC2X_X_320x240+1)*ESZ
  const TLISS = ((SC2X_X_320x240*2)-2)*ESZ
  const TLIS = ((SC2X_X_320x240*2)-1)*ESZ
  const TLI = ((SC2X_X_320x240*2))*ESZ
  const TLIA = ((SC2X_X_320x240*2)+1)*ESZ
  
  asm        
    mov ESI,[PTORG]
    mov EDI,[PTDST]
    lodsd
    stosd
    stosd
    mov [EDI+TLISS],EAX
    mov [EDI+TLIS],EAX
    mov ECX,PILIS
    _Sc2X32_320x240_FLNEXTPOINT_:
    lodsd
    mov EBX,[ESI]
    mov EDX,[ESI]
    cmp EBX,[ESI+OLIS]
    je _Sc2X32_320x240_FLBEHODEF_
    cmp [ESI-TPI],EDX
    je _Sc2X32_320x240_FLBEHODEF_
    cmp EBX,[ESI-TPI]
    je _Sc2X32_320x240_FLNOCHGE0_
    mov EBX,EAX
    _Sc2X32_320x240_FLNOCHGE0_:
    mov [EDI],EBX
    cmp [ESI],EDX
    je _Sc2X32_320x240_FLNOCHGE1_
    mov EDX,EAX
    _Sc2X32_320x240_FLNOCHGE1_:
    mov [EDI+OPI],EDX
    mov EBX,[ESI-TPI]
    mov EDX,[ESI+OLIS]
    cmp EBX,EDX
    je _Sc2X32_320x240_FLNOCHGE2_
    mov EBX,EAX
    _Sc2X32_320x240_FLNOCHGE2_:
    mov [EDI+TLI],EBX
    cmp EDX,[ESI]
    je _Sc2X32_320x240_FLNOCHGE3_
    mov EDX,EAX
    _Sc2X32_320x240_FLNOCHGE3_:
    mov [EDI+TLIA],EDX
    add EDI,TPI
    dec ECX
    jnz _Sc2X32_320x240_FLNEXTPOINT_
    add EDI,TLI
    dec dword ptr [Y]
    jnz _Sc2X32_320x240_NEXTLINE_
    _Sc2X32_320x240_FLBEHODEF_:
    stosd
    stosd
    mov [EDI+TLISS],EAX
    mov [EDI+TLIS],EAX
    dec ECX
    jnz _Sc2X32_320x240_FLNEXTPOINT_
    add EDI,TLI
    dec dword ptr [Y]
    _Sc2X32_320x240_NEXTLINE_:
    mov ECX,PILI
    _Sc2X32_320x240_NEXTPOINT_:
    lodsd
    mov EBX,[ESI-OLIA]
    mov EDX,[ESI]
    cmp EBX,[ESI+OLIS]
    je _Sc2X32_320x240_BEHODEF_
    cmp [ESI-TPI],EDX
    je _Sc2X32_320x240_BEHODEF_
    cmp EBX,[ESI-TPI]
    je _Sc2X32_320x240_NOCHGE0_
    mov EBX,EAX
    _Sc2X32_320x240_NOCHGE0_:
    mov [EDI],EBX
    cmp [ESI-OLIA],EDX
    je _Sc2X32_320x240_NOCHGE1_
    mov EDX,EAX
    _Sc2X32_320x240_NOCHGE1_:
    mov [EDI+OPI],EDX
    mov EBX,[ESI-TPI]
    mov EDX,[ESI+OLIS]
    cmp EBX,EDX
    je _Sc2X32_320x240_NOCHGE2_
    mov EBX,EAX
    _Sc2X32_320x240_NOCHGE2_:
    mov [EDI+TLI],EBX
    cmp EDX,[ESI]
    je _Sc2X32_320x240_NOCHGE3_
    mov EDX,EAX
    _Sc2X32_320x240_NOCHGE3_:
    mov [EDI+TLIA],EDX
    add EDI,TPI
    dec ECX
    jnz _Sc2X32_320x240_NEXTPOINT_
    add EDI,TLI
    dec dword ptr [Y]
    jnz _Sc2X32_320x240_NEXTLINE_
    jmp _Sc2X32_320x240_FINALEND_
    _Sc2X32_320x240_BEHODEF_:
    stosd
    stosd
    mov [EDI+TLISS],EAX
    mov [EDI+TLIS],EAX
    dec ECX
    jnz _Sc2X32_320x240_NEXTPOINT_
    add EDI,TLI
    dec dword ptr [Y]
    jnz _Sc2X32_320x240_NEXTLINE_
    _Sc2X32_320x240_FINALEND_:
  end asm  
end sub


Private Sub raw_Scale2X_400x300_16 (Byval PTORG as any ptr, Byval PTDST as any ptr)
  static as integer Y  
  Y = SC2X_Y_400x300
  
  #define ESZ 2  
  
  const PILI = SC2X_X_400x300
  const PILIS = SC2X_X_400x300-1
  const OPI = ESZ
  const TPI = ESZ*2  
  const OLIS = (SC2X_X_400x300-1)*ESZ
  const OLIA = (SC2X_X_400x300+1)*ESZ
  const TLISS = ((SC2X_X_400x300*2)-2)*ESZ
  const TLIS = ((SC2X_X_400x300*2)-1)*ESZ
  const TLI = ((SC2X_X_400x300*2))*ESZ
  const TLIA = ((SC2X_X_400x300*2)+1)*ESZ
  
  asm        
    mov ESI,[PTORG]
    mov EDI,[PTDST]
    lodsw
    stosw
    stosw
    mov [EDI+TLISS],AX
    mov [EDI+TLIS],AX
    mov ECX,PILIS
    _Sc2X16_400x300_FLNEXTPOINT_:
    lodsw
    mov BX,[ESI]
    mov DX,[ESI]
    cmp BX,[ESI+OLIS]
    je _Sc2X16_400x300_FLBEHODEF_
    cmp [ESI-TPI],DX
    je _Sc2X16_400x300_FLBEHODEF_
    cmp BX,[ESI-TPI]
    je _Sc2X16_400x300_FLNOCHGE0_
    mov BX,AX
    _Sc2X16_400x300_FLNOCHGE0_:
    mov [EDI],BX
    cmp [ESI],DX
    je _Sc2X16_400x300_FLNOCHGE1_
    mov DX,AX
    _Sc2X16_400x300_FLNOCHGE1_:
    mov [EDI+OPI],DX
    mov BX,[ESI-TPI]
    mov DX,[ESI+OLIS]
    cmp BX,DX
    je _Sc2X16_400x300_FLNOCHGE2_
    mov BX,AX
    _Sc2X16_400x300_FLNOCHGE2_:
    mov [EDI+TLI],BX
    cmp DX,[ESI]
    je _Sc2X16_400x300_FLNOCHGE3_
    mov DX,AX
    _Sc2X16_400x300_FLNOCHGE3_:
    mov [EDI+TLIA],DX
    add EDI,TPI
    dec ECX
    jnz _Sc2X16_400x300_FLNEXTPOINT_
    add EDI,TLI
    dec dword ptr [Y]
    jnz _Sc2X16_400x300_NEXTLINE_
    _Sc2X16_400x300_FLBEHODEF_:
    stosw
    stosw
    mov [EDI+TLISS],AX
    mov [EDI+TLIS],AX
    dec ECX
    jnz _Sc2X16_400x300_FLNEXTPOINT_
    add EDI,TLI
    dec dword ptr [Y]
    _Sc2X16_400x300_NEXTLINE_:
    mov ECX,PILI
    _Sc2X16_400x300_NEXTPOINT_:
    lodsw
    mov BX,[ESI-OLIA]
    mov DX,[ESI]
    cmp BX,[ESI+OLIS]
    je _Sc2X16_400x300_BEHODEF_
    cmp [ESI-TPI],DX
    je _Sc2X16_400x300_BEHODEF_
    cmp BX,[ESI-TPI]
    je _Sc2X16_400x300_NOCHGE0_
    mov BX,AX
    _Sc2X16_400x300_NOCHGE0_:
    mov [EDI],BX
    cmp [ESI-OLIA],DX
    je _Sc2X16_400x300_NOCHGE1_
    mov DX,AX
    _Sc2X16_400x300_NOCHGE1_:
    mov [EDI+OPI],DX
    mov BX,[ESI-TPI]
    mov DX,[ESI+OLIS]
    cmp BX,DX
    je _Sc2X16_400x300_NOCHGE2_
    mov BX,AX
    _Sc2X16_400x300_NOCHGE2_:
    mov [EDI+TLI],BX
    cmp DX,[ESI]
    je _Sc2X16_400x300_NOCHGE3_
    mov DX,AX
    _Sc2X16_400x300_NOCHGE3_:
    mov [EDI+TLIA],DX
    add EDI,TPI
    dec ECX
    jnz _Sc2X16_400x300_NEXTPOINT_
    add EDI,TLI
    dec dword ptr [Y]
    jnz _Sc2X16_400x300_NEXTLINE_
    jmp _Sc2X16_400x300_FINALEND_
    _Sc2X16_400x300_BEHODEF_:
    stosw
    stosw
    mov [EDI+TLISS],AX
    mov [EDI+TLIS],AX
    dec ECX
    jnz _Sc2X16_400x300_NEXTPOINT_
    add EDI,TLI
    dec dword ptr [Y]
    jnz _Sc2X16_400x300_NEXTLINE_
    _Sc2X16_400x300_FINALEND_:
  end asm  
end sub


Private Sub raw_Scale2X_400x300_32 (Byval PTORG as any ptr, Byval PTDST as any ptr)
  static as integer Y  
  Y = SC2X_Y_400x300
  
  #define ESZ 4  
  
  const PILI = SC2X_X_400x300
  const PILIS = SC2X_X_400x300-1
  const OPI = ESZ
  const TPI = ESZ*2  
  const OLIS = (SC2X_X_400x300-1)*ESZ
  const OLIA = (SC2X_X_400x300+1)*ESZ
  const TLISS = ((SC2X_X_400x300*2)-2)*ESZ
  const TLIS = ((SC2X_X_400x300*2)-1)*ESZ
  const TLI = ((SC2X_X_400x300*2))*ESZ
  const TLIA = ((SC2X_X_400x300*2)+1)*ESZ
  
  asm        
    mov ESI,[PTORG]
    mov EDI,[PTDST]
    lodsd
    stosd
    stosd
    mov [EDI+TLISS],EAX
    mov [EDI+TLIS],EAX
    mov ECX,PILIS
    _Sc2X32_400x300_FLNEXTPOINT_:
    lodsd
    mov EBX,[ESI]
    mov EDX,[ESI]
    cmp EBX,[ESI+OLIS]
    je _Sc2X32_400x300_FLBEHODEF_
    cmp [ESI-TPI],EDX
    je _Sc2X32_400x300_FLBEHODEF_
    cmp EBX,[ESI-TPI]
    je _Sc2X32_400x300_FLNOCHGE0_
    mov EBX,EAX
    _Sc2X32_400x300_FLNOCHGE0_:
    mov [EDI],EBX
    cmp [ESI],EDX
    je _Sc2X32_400x300_FLNOCHGE1_
    mov EDX,EAX
    _Sc2X32_400x300_FLNOCHGE1_:
    mov [EDI+OPI],EDX
    mov EBX,[ESI-TPI]
    mov EDX,[ESI+OLIS]
    cmp EBX,EDX
    je _Sc2X32_400x300_FLNOCHGE2_
    mov EBX,EAX
    _Sc2X32_400x300_FLNOCHGE2_:
    mov [EDI+TLI],EBX
    cmp EDX,[ESI]
    je _Sc2X32_400x300_FLNOCHGE3_
    mov EDX,EAX
    _Sc2X32_400x300_FLNOCHGE3_:
    mov [EDI+TLIA],EDX
    add EDI,TPI
    dec ECX
    jnz _Sc2X32_400x300_FLNEXTPOINT_
    add EDI,TLI
    dec dword ptr [Y]
    jnz _Sc2X32_400x300_NEXTLINE_
    _Sc2X32_400x300_FLBEHODEF_:
    stosd
    stosd
    mov [EDI+TLISS],EAX
    mov [EDI+TLIS],EAX
    dec ECX
    jnz _Sc2X32_400x300_FLNEXTPOINT_
    add EDI,TLI
    dec dword ptr [Y]
    _Sc2X32_400x300_NEXTLINE_:
    mov ECX,PILI
    _Sc2X32_400x300_NEXTPOINT_:
    lodsd
    mov EBX,[ESI-OLIA]
    mov EDX,[ESI]
    cmp EBX,[ESI+OLIS]
    je _Sc2X32_400x300_BEHODEF_
    cmp [ESI-TPI],EDX
    je _Sc2X32_400x300_BEHODEF_
    cmp EBX,[ESI-TPI]
    je _Sc2X32_400x300_NOCHGE0_
    mov EBX,EAX
    _Sc2X32_400x300_NOCHGE0_:
    mov [EDI],EBX
    cmp [ESI-OLIA],EDX
    je _Sc2X32_400x300_NOCHGE1_
    mov EDX,EAX
    _Sc2X32_400x300_NOCHGE1_:
    mov [EDI+OPI],EDX
    mov EBX,[ESI-TPI]
    mov EDX,[ESI+OLIS]
    cmp EBX,EDX
    je _Sc2X32_400x300_NOCHGE2_
    mov EBX,EAX
    _Sc2X32_400x300_NOCHGE2_:
    mov [EDI+TLI],EBX
    cmp EDX,[ESI]
    je _Sc2X32_400x300_NOCHGE3_
    mov EDX,EAX
    _Sc2X32_400x300_NOCHGE3_:
    mov [EDI+TLIA],EDX
    add EDI,TPI
    dec ECX
    jnz _Sc2X32_400x300_NEXTPOINT_
    add EDI,TLI
    dec dword ptr [Y]
    jnz _Sc2X32_400x300_NEXTLINE_
    jmp _Sc2X32_400x300_FINALEND_
    _Sc2X32_400x300_BEHODEF_:
    stosd
    stosd
    mov [EDI+TLISS],EAX
    mov [EDI+TLIS],EAX
    dec ECX
    jnz _Sc2X32_400x300_NEXTPOINT_
    add EDI,TLI
    dec dword ptr [Y]
    jnz _Sc2X32_400x300_NEXTLINE_
    _Sc2X32_400x300_FINALEND_:
  end asm  
end sub


Private Sub raw_Scale2X_512x384_16 (Byval PTORG as any ptr, Byval PTDST as any ptr)
  static as integer Y  
  Y = SC2X_Y_512x384
  
  #define ESZ 2  
  
  const PILI = SC2X_X_512x384
  const PILIS = SC2X_X_512x384-1
  const OPI = ESZ
  const TPI = ESZ*2  
  const OLIS = (SC2X_X_512x384-1)*ESZ
  const OLIA = (SC2X_X_512x384+1)*ESZ
  const TLISS = ((SC2X_X_512x384*2)-2)*ESZ
  const TLIS = ((SC2X_X_512x384*2)-1)*ESZ
  const TLI = ((SC2X_X_512x384*2))*ESZ
  const TLIA = ((SC2X_X_512x384*2)+1)*ESZ
  
  asm        
    mov ESI,[PTORG]
    mov EDI,[PTDST]
    lodsw
    stosw
    stosw
    mov [EDI+TLISS],AX
    mov [EDI+TLIS],AX
    mov ECX,PILIS
    _Sc2X16_512x384_FLNEXTPOINT_:
    lodsw
    mov BX,[ESI]
    mov DX,[ESI]
    cmp BX,[ESI+OLIS]
    je _Sc2X16_512x384_FLBEHODEF_
    cmp [ESI-TPI],DX
    je _Sc2X16_512x384_FLBEHODEF_
    cmp BX,[ESI-TPI]
    je _Sc2X16_512x384_FLNOCHGE0_
    mov BX,AX
    _Sc2X16_512x384_FLNOCHGE0_:
    mov [EDI],BX
    cmp [ESI],DX
    je _Sc2X16_512x384_FLNOCHGE1_
    mov DX,AX
    _Sc2X16_512x384_FLNOCHGE1_:
    mov [EDI+OPI],DX
    mov BX,[ESI-TPI]
    mov DX,[ESI+OLIS]
    cmp BX,DX
    je _Sc2X16_512x384_FLNOCHGE2_
    mov BX,AX
    _Sc2X16_512x384_FLNOCHGE2_:
    mov [EDI+TLI],BX
    cmp DX,[ESI]
    je _Sc2X16_512x384_FLNOCHGE3_
    mov DX,AX
    _Sc2X16_512x384_FLNOCHGE3_:
    mov [EDI+TLIA],DX
    add EDI,TPI
    dec ECX
    jnz _Sc2X16_512x384_FLNEXTPOINT_
    add EDI,TLI
    dec dword ptr [Y]
    jnz _Sc2X16_512x384_NEXTLINE_
    _Sc2X16_512x384_FLBEHODEF_:
    stosw
    stosw
    mov [EDI+TLISS],AX
    mov [EDI+TLIS],AX
    dec ECX
    jnz _Sc2X16_512x384_FLNEXTPOINT_
    add EDI,TLI
    dec dword ptr [Y]
    _Sc2X16_512x384_NEXTLINE_:
    mov ECX,PILI
    _Sc2X16_512x384_NEXTPOINT_:
    lodsw
    mov BX,[ESI-OLIA]
    mov DX,[ESI]
    cmp BX,[ESI+OLIS]
    je _Sc2X16_512x384_BEHODEF_
    cmp [ESI-TPI],DX
    je _Sc2X16_512x384_BEHODEF_
    cmp BX,[ESI-TPI]
    je _Sc2X16_512x384_NOCHGE0_
    mov BX,AX
    _Sc2X16_512x384_NOCHGE0_:
    mov [EDI],BX
    cmp [ESI-OLIA],DX
    je _Sc2X16_512x384_NOCHGE1_
    mov DX,AX
    _Sc2X16_512x384_NOCHGE1_:
    mov [EDI+OPI],DX
    mov BX,[ESI-TPI]
    mov DX,[ESI+OLIS]
    cmp BX,DX
    je _Sc2X16_512x384_NOCHGE2_
    mov BX,AX
    _Sc2X16_512x384_NOCHGE2_:
    mov [EDI+TLI],BX
    cmp DX,[ESI]
    je _Sc2X16_512x384_NOCHGE3_
    mov DX,AX
    _Sc2X16_512x384_NOCHGE3_:
    mov [EDI+TLIA],DX
    add EDI,TPI
    dec ECX
    jnz _Sc2X16_512x384_NEXTPOINT_
    add EDI,TLI
    dec dword ptr [Y]
    jnz _Sc2X16_512x384_NEXTLINE_
    jmp _Sc2X16_512x384_FINALEND_
    _Sc2X16_512x384_BEHODEF_:
    stosw
    stosw
    mov [EDI+TLISS],AX
    mov [EDI+TLIS],AX
    dec ECX
    jnz _Sc2X16_512x384_NEXTPOINT_
    add EDI,TLI
    dec dword ptr [Y]
    jnz _Sc2X16_512x384_NEXTLINE_
    _Sc2X16_512x384_FINALEND_:
  end asm  
end sub


Private Sub raw_Scale2X_512x384_32 (Byval PTORG as any ptr, Byval PTDST as any ptr)
  static as integer Y  
  Y = SC2X_Y_512x384
  
  #define ESZ 4  
  
  const PILI = SC2X_X_512x384
  const PILIS = SC2X_X_512x384-1
  const OPI = ESZ
  const TPI = ESZ*2  
  const OLIS = (SC2X_X_512x384-1)*ESZ
  const OLIA = (SC2X_X_512x384+1)*ESZ
  const TLISS = ((SC2X_X_512x384*2)-2)*ESZ
  const TLIS = ((SC2X_X_512x384*2)-1)*ESZ
  const TLI = ((SC2X_X_512x384*2))*ESZ
  const TLIA = ((SC2X_X_512x384*2)+1)*ESZ
  
  asm        
    mov ESI,[PTORG]
    mov EDI,[PTDST]
    lodsd
    stosd
    stosd
    mov [EDI+TLISS],EAX
    mov [EDI+TLIS],EAX
    mov ECX,PILIS
    _Sc2X32_512x384_FLNEXTPOINT_:
    lodsd
    mov EBX,[ESI]
    mov EDX,[ESI]
    cmp EBX,[ESI+OLIS]
    je _Sc2X32_512x384_FLBEHODEF_
    cmp [ESI-TPI],EDX
    je _Sc2X32_512x384_FLBEHODEF_
    cmp EBX,[ESI-TPI]
    je _Sc2X32_512x384_FLNOCHGE0_
    mov EBX,EAX
    _Sc2X32_512x384_FLNOCHGE0_:
    mov [EDI],EBX
    cmp [ESI],EDX
    je _Sc2X32_512x384_FLNOCHGE1_
    mov EDX,EAX
    _Sc2X32_512x384_FLNOCHGE1_:
    mov [EDI+OPI],EDX
    mov EBX,[ESI-TPI]
    mov EDX,[ESI+OLIS]
    cmp EBX,EDX
    je _Sc2X32_512x384_FLNOCHGE2_
    mov EBX,EAX
    _Sc2X32_512x384_FLNOCHGE2_:
    mov [EDI+TLI],EBX
    cmp EDX,[ESI]
    je _Sc2X32_512x384_FLNOCHGE3_
    mov EDX,EAX
    _Sc2X32_512x384_FLNOCHGE3_:
    mov [EDI+TLIA],EDX
    add EDI,TPI
    dec ECX
    jnz _Sc2X32_512x384_FLNEXTPOINT_
    add EDI,TLI
    dec dword ptr [Y]
    jnz _Sc2X32_512x384_NEXTLINE_
    _Sc2X32_512x384_FLBEHODEF_:
    stosd
    stosd
    mov [EDI+TLISS],EAX
    mov [EDI+TLIS],EAX
    dec ECX
    jnz _Sc2X32_512x384_FLNEXTPOINT_
    add EDI,TLI
    dec dword ptr [Y]
    _Sc2X32_512x384_NEXTLINE_:
    mov ECX,PILI
    _Sc2X32_512x384_NEXTPOINT_:
    lodsd
    mov EBX,[ESI-OLIA]
    mov EDX,[ESI]
    cmp EBX,[ESI+OLIS]
    je _Sc2X32_512x384_BEHODEF_
    cmp [ESI-TPI],EDX
    je _Sc2X32_512x384_BEHODEF_
    cmp EBX,[ESI-TPI]
    je _Sc2X32_512x384_NOCHGE0_
    mov EBX,EAX
    _Sc2X32_512x384_NOCHGE0_:
    mov [EDI],EBX
    cmp [ESI-OLIA],EDX
    je _Sc2X32_512x384_NOCHGE1_
    mov EDX,EAX
    _Sc2X32_512x384_NOCHGE1_:
    mov [EDI+OPI],EDX
    mov EBX,[ESI-TPI]
    mov EDX,[ESI+OLIS]
    cmp EBX,EDX
    je _Sc2X32_512x384_NOCHGE2_
    mov EBX,EAX
    _Sc2X32_512x384_NOCHGE2_:
    mov [EDI+TLI],EBX
    cmp EDX,[ESI]
    je _Sc2X32_512x384_NOCHGE3_
    mov EDX,EAX
    _Sc2X32_512x384_NOCHGE3_:
    mov [EDI+TLIA],EDX
    add EDI,TPI
    dec ECX
    jnz _Sc2X32_512x384_NEXTPOINT_
    add EDI,TLI
    dec dword ptr [Y]
    jnz _Sc2X32_512x384_NEXTLINE_
    jmp _Sc2X32_512x384_FINALEND_
    _Sc2X32_512x384_BEHODEF_:
    stosd
    stosd
    mov [EDI+TLISS],EAX
    mov [EDI+TLIS],EAX
    dec ECX
    jnz _Sc2X32_512x384_NEXTPOINT_
    add EDI,TLI
    dec dword ptr [Y]
    jnz _Sc2X32_512x384_NEXTLINE_
    _Sc2X32_512x384_FINALEND_:
  end asm  
end sub


Private Sub raw_Scale2X_640x400_16 (Byval PTORG as any ptr, Byval PTDST as any ptr)
  static as integer Y  
  Y = SC2X_Y_640x400
  
  #define ESZ 2  
  
  const PILI = SC2X_X_640x400
  const PILIS = SC2X_X_640x400-1
  const OPI = ESZ
  const TPI = ESZ*2  
  const OLIS = (SC2X_X_640x400-1)*ESZ
  const OLIA = (SC2X_X_640x400+1)*ESZ
  const TLISS = ((SC2X_X_640x400*2)-2)*ESZ
  const TLIS = ((SC2X_X_640x400*2)-1)*ESZ
  const TLI = ((SC2X_X_640x400*2))*ESZ
  const TLIA = ((SC2X_X_640x400*2)+1)*ESZ
  
  asm        
    mov ESI,[PTORG]
    mov EDI,[PTDST]
    lodsw
    stosw
    stosw
    mov [EDI+TLISS],AX
    mov [EDI+TLIS],AX
    mov ECX,PILIS
    _Sc2X16_640x400_FLNEXTPOINT_:
    lodsw
    mov BX,[ESI]
    mov DX,[ESI]
    cmp BX,[ESI+OLIS]
    je _Sc2X16_640x400_FLBEHODEF_
    cmp [ESI-TPI],DX
    je _Sc2X16_640x400_FLBEHODEF_
    cmp BX,[ESI-TPI]
    je _Sc2X16_640x400_FLNOCHGE0_
    mov BX,AX
    _Sc2X16_640x400_FLNOCHGE0_:
    mov [EDI],BX
    cmp [ESI],DX
    je _Sc2X16_640x400_FLNOCHGE1_
    mov DX,AX
    _Sc2X16_640x400_FLNOCHGE1_:
    mov [EDI+OPI],DX
    mov BX,[ESI-TPI]
    mov DX,[ESI+OLIS]
    cmp BX,DX
    je _Sc2X16_640x400_FLNOCHGE2_
    mov BX,AX
    _Sc2X16_640x400_FLNOCHGE2_:
    mov [EDI+TLI],BX
    cmp DX,[ESI]
    je _Sc2X16_640x400_FLNOCHGE3_
    mov DX,AX
    _Sc2X16_640x400_FLNOCHGE3_:
    mov [EDI+TLIA],DX
    add EDI,TPI
    dec ECX
    jnz _Sc2X16_640x400_FLNEXTPOINT_
    add EDI,TLI
    dec dword ptr [Y]
    jnz _Sc2X16_640x400_NEXTLINE_
    _Sc2X16_640x400_FLBEHODEF_:
    stosw
    stosw
    mov [EDI+TLISS],AX
    mov [EDI+TLIS],AX
    dec ECX
    jnz _Sc2X16_640x400_FLNEXTPOINT_
    add EDI,TLI
    dec dword ptr [Y]
    _Sc2X16_640x400_NEXTLINE_:
    mov ECX,PILI
    _Sc2X16_640x400_NEXTPOINT_:
    lodsw
    mov BX,[ESI-OLIA]
    mov DX,[ESI]
    cmp BX,[ESI+OLIS]
    je _Sc2X16_640x400_BEHODEF_
    cmp [ESI-TPI],DX
    je _Sc2X16_640x400_BEHODEF_
    cmp BX,[ESI-TPI]
    je _Sc2X16_640x400_NOCHGE0_
    mov BX,AX
    _Sc2X16_640x400_NOCHGE0_:
    mov [EDI],BX
    cmp [ESI-OLIA],DX
    je _Sc2X16_640x400_NOCHGE1_
    mov DX,AX
    _Sc2X16_640x400_NOCHGE1_:
    mov [EDI+OPI],DX
    mov BX,[ESI-TPI]
    mov DX,[ESI+OLIS]
    cmp BX,DX
    je _Sc2X16_640x400_NOCHGE2_
    mov BX,AX
    _Sc2X16_640x400_NOCHGE2_:
    mov [EDI+TLI],BX
    cmp DX,[ESI]
    je _Sc2X16_640x400_NOCHGE3_
    mov DX,AX
    _Sc2X16_640x400_NOCHGE3_:
    mov [EDI+TLIA],DX
    add EDI,TPI
    dec ECX
    jnz _Sc2X16_640x400_NEXTPOINT_
    add EDI,TLI
    dec dword ptr [Y]
    jnz _Sc2X16_640x400_NEXTLINE_
    jmp _Sc2X16_640x400_FINALEND_
    _Sc2X16_640x400_BEHODEF_:
    stosw
    stosw
    mov [EDI+TLISS],AX
    mov [EDI+TLIS],AX
    dec ECX
    jnz _Sc2X16_640x400_NEXTPOINT_
    add EDI,TLI
    dec dword ptr [Y]
    jnz _Sc2X16_640x400_NEXTLINE_
    _Sc2X16_640x400_FINALEND_:
  end asm  
end sub


Private Sub raw_Scale2X_640x400_32 (Byval PTORG as any ptr, Byval PTDST as any ptr)
  static as integer Y  
  Y = SC2X_Y_640x400
  
  #define ESZ 4  
  
  const PILI = SC2X_X_640x400
  const PILIS = SC2X_X_640x400-1
  const OPI = ESZ
  const TPI = ESZ*2  
  const OLIS = (SC2X_X_640x400-1)*ESZ
  const OLIA = (SC2X_X_640x400+1)*ESZ
  const TLISS = ((SC2X_X_640x400*2)-2)*ESZ
  const TLIS = ((SC2X_X_640x400*2)-1)*ESZ
  const TLI = ((SC2X_X_640x400*2))*ESZ
  const TLIA = ((SC2X_X_640x400*2)+1)*ESZ
  
  asm        
    mov ESI,[PTORG]
    mov EDI,[PTDST]
    lodsd
    stosd
    stosd
    mov [EDI+TLISS],EAX
    mov [EDI+TLIS],EAX
    mov ECX,PILIS
    _Sc2X32_640x400_FLNEXTPOINT_:
    lodsd
    mov EBX,[ESI]
    mov EDX,[ESI]
    cmp EBX,[ESI+OLIS]
    je _Sc2X32_640x400_FLBEHODEF_
    cmp [ESI-TPI],EDX
    je _Sc2X32_640x400_FLBEHODEF_
    cmp EBX,[ESI-TPI]
    je _Sc2X32_640x400_FLNOCHGE0_
    mov EBX,EAX
    _Sc2X32_640x400_FLNOCHGE0_:
    mov [EDI],EBX
    cmp [ESI],EDX
    je _Sc2X32_640x400_FLNOCHGE1_
    mov EDX,EAX
    _Sc2X32_640x400_FLNOCHGE1_:
    mov [EDI+OPI],EDX
    mov EBX,[ESI-TPI]
    mov EDX,[ESI+OLIS]
    cmp EBX,EDX
    je _Sc2X32_640x400_FLNOCHGE2_
    mov EBX,EAX
    _Sc2X32_640x400_FLNOCHGE2_:
    mov [EDI+TLI],EBX
    cmp EDX,[ESI]
    je _Sc2X32_640x400_FLNOCHGE3_
    mov EDX,EAX
    _Sc2X32_640x400_FLNOCHGE3_:
    mov [EDI+TLIA],EDX
    add EDI,TPI
    dec ECX
    jnz _Sc2X32_640x400_FLNEXTPOINT_
    add EDI,TLI
    dec dword ptr [Y]
    jnz _Sc2X32_640x400_NEXTLINE_
    _Sc2X32_640x400_FLBEHODEF_:
    stosd
    stosd
    mov [EDI+TLISS],EAX
    mov [EDI+TLIS],EAX
    dec ECX
    jnz _Sc2X32_640x400_FLNEXTPOINT_
    add EDI,TLI
    dec dword ptr [Y]
    _Sc2X32_640x400_NEXTLINE_:
    mov ECX,PILI
    _Sc2X32_640x400_NEXTPOINT_:
    lodsd
    mov EBX,[ESI-OLIA]
    mov EDX,[ESI]
    cmp EBX,[ESI+OLIS]
    je _Sc2X32_640x400_BEHODEF_
    cmp [ESI-TPI],EDX
    je _Sc2X32_640x400_BEHODEF_
    cmp EBX,[ESI-TPI]
    je _Sc2X32_640x400_NOCHGE0_
    mov EBX,EAX
    _Sc2X32_640x400_NOCHGE0_:
    mov [EDI],EBX
    cmp [ESI-OLIA],EDX
    je _Sc2X32_640x400_NOCHGE1_
    mov EDX,EAX
    _Sc2X32_640x400_NOCHGE1_:
    mov [EDI+OPI],EDX
    mov EBX,[ESI-TPI]
    mov EDX,[ESI+OLIS]
    cmp EBX,EDX
    je _Sc2X32_640x400_NOCHGE2_
    mov EBX,EAX
    _Sc2X32_640x400_NOCHGE2_:
    mov [EDI+TLI],EBX
    cmp EDX,[ESI]
    je _Sc2X32_640x400_NOCHGE3_
    mov EDX,EAX
    _Sc2X32_640x400_NOCHGE3_:
    mov [EDI+TLIA],EDX
    add EDI,TPI
    dec ECX
    jnz _Sc2X32_640x400_NEXTPOINT_
    add EDI,TLI
    dec dword ptr [Y]
    jnz _Sc2X32_640x400_NEXTLINE_
    jmp _Sc2X32_640x400_FINALEND_
    _Sc2X32_640x400_BEHODEF_:
    stosd
    stosd
    mov [EDI+TLISS],EAX
    mov [EDI+TLIS],EAX
    dec ECX
    jnz _Sc2X32_640x400_NEXTPOINT_
    add EDI,TLI
    dec dword ptr [Y]
    jnz _Sc2X32_640x400_NEXTLINE_
    _Sc2X32_640x400_FINALEND_:
  end asm  
end sub


Private Sub raw_Scale2X_640x480_16 (Byval PTORG as any ptr, Byval PTDST as any ptr)
  static as integer Y  
  Y = SC2X_Y_640x480
  
  #define ESZ 2  
  
  const PILI = SC2X_X_640x480
  const PILIS = SC2X_X_640x480-1
  const OPI = ESZ
  const TPI = ESZ*2  
  const OLIS = (SC2X_X_640x480-1)*ESZ
  const OLIA = (SC2X_X_640x480+1)*ESZ
  const TLISS = ((SC2X_X_640x480*2)-2)*ESZ
  const TLIS = ((SC2X_X_640x480*2)-1)*ESZ
  const TLI = ((SC2X_X_640x480*2))*ESZ
  const TLIA = ((SC2X_X_640x480*2)+1)*ESZ
  
  asm        
    mov ESI,[PTORG]
    mov EDI,[PTDST]
    lodsw
    stosw
    stosw
    mov [EDI+TLISS],AX
    mov [EDI+TLIS],AX
    mov ECX,PILIS
    _Sc2X16_640x480_FLNEXTPOINT_:
    lodsw
    mov BX,[ESI]
    mov DX,[ESI]
    cmp BX,[ESI+OLIS]
    je _Sc2X16_640x480_FLBEHODEF_
    cmp [ESI-TPI],DX
    je _Sc2X16_640x480_FLBEHODEF_
    cmp BX,[ESI-TPI]
    je _Sc2X16_640x480_FLNOCHGE0_
    mov BX,AX
    _Sc2X16_640x480_FLNOCHGE0_:
    mov [EDI],BX
    cmp [ESI],DX
    je _Sc2X16_640x480_FLNOCHGE1_
    mov DX,AX
    _Sc2X16_640x480_FLNOCHGE1_:
    mov [EDI+OPI],DX
    mov BX,[ESI-TPI]
    mov DX,[ESI+OLIS]
    cmp BX,DX
    je _Sc2X16_640x480_FLNOCHGE2_
    mov BX,AX
    _Sc2X16_640x480_FLNOCHGE2_:
    mov [EDI+TLI],BX
    cmp DX,[ESI]
    je _Sc2X16_640x480_FLNOCHGE3_
    mov DX,AX
    _Sc2X16_640x480_FLNOCHGE3_:
    mov [EDI+TLIA],DX
    add EDI,TPI
    dec ECX
    jnz _Sc2X16_640x480_FLNEXTPOINT_
    add EDI,TLI
    dec dword ptr [Y]
    jnz _Sc2X16_640x480_NEXTLINE_
    _Sc2X16_640x480_FLBEHODEF_:
    stosw
    stosw
    mov [EDI+TLISS],AX
    mov [EDI+TLIS],AX
    dec ECX
    jnz _Sc2X16_640x480_FLNEXTPOINT_
    add EDI,TLI
    dec dword ptr [Y]
    _Sc2X16_640x480_NEXTLINE_:
    mov ECX,PILI
    _Sc2X16_640x480_NEXTPOINT_:
    lodsw
    mov BX,[ESI-OLIA]
    mov DX,[ESI]
    cmp BX,[ESI+OLIS]
    je _Sc2X16_640x480_BEHODEF_
    cmp [ESI-TPI],DX
    je _Sc2X16_640x480_BEHODEF_
    cmp BX,[ESI-TPI]
    je _Sc2X16_640x480_NOCHGE0_
    mov BX,AX
    _Sc2X16_640x480_NOCHGE0_:
    mov [EDI],BX
    cmp [ESI-OLIA],DX
    je _Sc2X16_640x480_NOCHGE1_
    mov DX,AX
    _Sc2X16_640x480_NOCHGE1_:
    mov [EDI+OPI],DX
    mov BX,[ESI-TPI]
    mov DX,[ESI+OLIS]
    cmp BX,DX
    je _Sc2X16_640x480_NOCHGE2_
    mov BX,AX
    _Sc2X16_640x480_NOCHGE2_:
    mov [EDI+TLI],BX
    cmp DX,[ESI]
    je _Sc2X16_640x480_NOCHGE3_
    mov DX,AX
    _Sc2X16_640x480_NOCHGE3_:
    mov [EDI+TLIA],DX
    add EDI,TPI
    dec ECX
    jnz _Sc2X16_640x480_NEXTPOINT_
    add EDI,TLI
    dec dword ptr [Y]
    jnz _Sc2X16_640x480_NEXTLINE_
    jmp _Sc2X16_640x480_FINALEND_
    _Sc2X16_640x480_BEHODEF_:
    stosw
    stosw
    mov [EDI+TLISS],AX
    mov [EDI+TLIS],AX
    dec ECX
    jnz _Sc2X16_640x480_NEXTPOINT_
    add EDI,TLI
    dec dword ptr [Y]
    jnz _Sc2X16_640x480_NEXTLINE_
    _Sc2X16_640x480_FINALEND_:
  end asm  
end sub


Private Sub raw_Scale2X_640x480_32 (Byval PTORG as any ptr, Byval PTDST as any ptr)
  static as integer Y  
  Y = SC2X_Y_640x480
  
  #define ESZ 4  
  
  const PILI = SC2X_X_640x480
  const PILIS = SC2X_X_640x480-1
  const OPI = ESZ
  const TPI = ESZ*2  
  const OLIS = (SC2X_X_640x480-1)*ESZ
  const OLIA = (SC2X_X_640x480+1)*ESZ
  const TLISS = ((SC2X_X_640x480*2)-2)*ESZ
  const TLIS = ((SC2X_X_640x480*2)-1)*ESZ
  const TLI = ((SC2X_X_640x480*2))*ESZ
  const TLIA = ((SC2X_X_640x480*2)+1)*ESZ
  
  asm        
    mov ESI,[PTORG]
    mov EDI,[PTDST]
    lodsd
    stosd
    stosd
    mov [EDI+TLISS],EAX
    mov [EDI+TLIS],EAX
    mov ECX,PILIS
    _Sc2X32_640x480_FLNEXTPOINT_:
    lodsd
    mov EBX,[ESI]
    mov EDX,[ESI]
    cmp EBX,[ESI+OLIS]
    je _Sc2X32_640x480_FLBEHODEF_
    cmp [ESI-TPI],EDX
    je _Sc2X32_640x480_FLBEHODEF_
    cmp EBX,[ESI-TPI]
    je _Sc2X32_640x480_FLNOCHGE0_
    mov EBX,EAX
    _Sc2X32_640x480_FLNOCHGE0_:
    mov [EDI],EBX
    cmp [ESI],EDX
    je _Sc2X32_640x480_FLNOCHGE1_
    mov EDX,EAX
    _Sc2X32_640x480_FLNOCHGE1_:
    mov [EDI+OPI],EDX
    mov EBX,[ESI-TPI]
    mov EDX,[ESI+OLIS]
    cmp EBX,EDX
    je _Sc2X32_640x480_FLNOCHGE2_
    mov EBX,EAX
    _Sc2X32_640x480_FLNOCHGE2_:
    mov [EDI+TLI],EBX
    cmp EDX,[ESI]
    je _Sc2X32_640x480_FLNOCHGE3_
    mov EDX,EAX
    _Sc2X32_640x480_FLNOCHGE3_:
    mov [EDI+TLIA],EDX
    add EDI,TPI
    dec ECX
    jnz _Sc2X32_640x480_FLNEXTPOINT_
    add EDI,TLI
    dec dword ptr [Y]
    jnz _Sc2X32_640x480_NEXTLINE_
    _Sc2X32_640x480_FLBEHODEF_:
    stosd
    stosd
    mov [EDI+TLISS],EAX
    mov [EDI+TLIS],EAX
    dec ECX
    jnz _Sc2X32_640x480_FLNEXTPOINT_
    add EDI,TLI
    dec dword ptr [Y]
    _Sc2X32_640x480_NEXTLINE_:
    mov ECX,PILI
    _Sc2X32_640x480_NEXTPOINT_:
    lodsd
    mov EBX,[ESI-OLIA]
    mov EDX,[ESI]
    cmp EBX,[ESI+OLIS]
    je _Sc2X32_640x480_BEHODEF_
    cmp [ESI-TPI],EDX
    je _Sc2X32_640x480_BEHODEF_
    cmp EBX,[ESI-TPI]
    je _Sc2X32_640x480_NOCHGE0_
    mov EBX,EAX
    _Sc2X32_640x480_NOCHGE0_:
    mov [EDI],EBX
    cmp [ESI-OLIA],EDX
    je _Sc2X32_640x480_NOCHGE1_
    mov EDX,EAX
    _Sc2X32_640x480_NOCHGE1_:
    mov [EDI+OPI],EDX
    mov EBX,[ESI-TPI]
    mov EDX,[ESI+OLIS]
    cmp EBX,EDX
    je _Sc2X32_640x480_NOCHGE2_
    mov EBX,EAX
    _Sc2X32_640x480_NOCHGE2_:
    mov [EDI+TLI],EBX
    cmp EDX,[ESI]
    je _Sc2X32_640x480_NOCHGE3_
    mov EDX,EAX
    _Sc2X32_640x480_NOCHGE3_:
    mov [EDI+TLIA],EDX
    add EDI,TPI
    dec ECX
    jnz _Sc2X32_640x480_NEXTPOINT_
    add EDI,TLI
    dec dword ptr [Y]
    jnz _Sc2X32_640x480_NEXTLINE_
    jmp _Sc2X32_640x480_FINALEND_
    _Sc2X32_640x480_BEHODEF_:
    stosd
    stosd
    mov [EDI+TLISS],EAX
    mov [EDI+TLIS],EAX
    dec ECX
    jnz _Sc2X32_640x480_NEXTPOINT_
    add EDI,TLI
    dec dword ptr [Y]
    jnz _Sc2X32_640x480_NEXTLINE_
    _Sc2X32_640x480_FINALEND_:
  end asm  
end sub


Private Sub raw_Scale2X_720x480_16 (Byval PTORG as any ptr, Byval PTDST as any ptr)
  static as integer Y  
  Y = SC2X_Y_720x480
  
  #define ESZ 2  
  
  const PILI = SC2X_X_720x480
  const PILIS = SC2X_X_720x480-1
  const OPI = ESZ
  const TPI = ESZ*2  
  const OLIS = (SC2X_X_720x480-1)*ESZ
  const OLIA = (SC2X_X_720x480+1)*ESZ
  const TLISS = ((SC2X_X_720x480*2)-2)*ESZ
  const TLIS = ((SC2X_X_720x480*2)-1)*ESZ
  const TLI = ((SC2X_X_720x480*2))*ESZ
  const TLIA = ((SC2X_X_720x480*2)+1)*ESZ
  
  asm        
    mov ESI,[PTORG]
    mov EDI,[PTDST]
    lodsw
    stosw
    stosw
    mov [EDI+TLISS],AX
    mov [EDI+TLIS],AX
    mov ECX,PILIS
    _Sc2X16_720x480_FLNEXTPOINT_:
    lodsw
    mov BX,[ESI]
    mov DX,[ESI]
    cmp BX,[ESI+OLIS]
    je _Sc2X16_720x480_FLBEHODEF_
    cmp [ESI-TPI],DX
    je _Sc2X16_720x480_FLBEHODEF_
    cmp BX,[ESI-TPI]
    je _Sc2X16_720x480_FLNOCHGE0_
    mov BX,AX
    _Sc2X16_720x480_FLNOCHGE0_:
    mov [EDI],BX
    cmp [ESI],DX
    je _Sc2X16_720x480_FLNOCHGE1_
    mov DX,AX
    _Sc2X16_720x480_FLNOCHGE1_:
    mov [EDI+OPI],DX
    mov BX,[ESI-TPI]
    mov DX,[ESI+OLIS]
    cmp BX,DX
    je _Sc2X16_720x480_FLNOCHGE2_
    mov BX,AX
    _Sc2X16_720x480_FLNOCHGE2_:
    mov [EDI+TLI],BX
    cmp DX,[ESI]
    je _Sc2X16_720x480_FLNOCHGE3_
    mov DX,AX
    _Sc2X16_720x480_FLNOCHGE3_:
    mov [EDI+TLIA],DX
    add EDI,TPI
    dec ECX
    jnz _Sc2X16_720x480_FLNEXTPOINT_
    add EDI,TLI
    dec dword ptr [Y]
    jnz _Sc2X16_720x480_NEXTLINE_
    _Sc2X16_720x480_FLBEHODEF_:
    stosw
    stosw
    mov [EDI+TLISS],AX
    mov [EDI+TLIS],AX
    dec ECX
    jnz _Sc2X16_720x480_FLNEXTPOINT_
    add EDI,TLI
    dec dword ptr [Y]
    _Sc2X16_720x480_NEXTLINE_:
    mov ECX,PILI
    _Sc2X16_720x480_NEXTPOINT_:
    lodsw
    mov BX,[ESI-OLIA]
    mov DX,[ESI]
    cmp BX,[ESI+OLIS]
    je _Sc2X16_720x480_BEHODEF_
    cmp [ESI-TPI],DX
    je _Sc2X16_720x480_BEHODEF_
    cmp BX,[ESI-TPI]
    je _Sc2X16_720x480_NOCHGE0_
    mov BX,AX
    _Sc2X16_720x480_NOCHGE0_:
    mov [EDI],BX
    cmp [ESI-OLIA],DX
    je _Sc2X16_720x480_NOCHGE1_
    mov DX,AX
    _Sc2X16_720x480_NOCHGE1_:
    mov [EDI+OPI],DX
    mov BX,[ESI-TPI]
    mov DX,[ESI+OLIS]
    cmp BX,DX
    je _Sc2X16_720x480_NOCHGE2_
    mov BX,AX
    _Sc2X16_720x480_NOCHGE2_:
    mov [EDI+TLI],BX
    cmp DX,[ESI]
    je _Sc2X16_720x480_NOCHGE3_
    mov DX,AX
    _Sc2X16_720x480_NOCHGE3_:
    mov [EDI+TLIA],DX
    add EDI,TPI
    dec ECX
    jnz _Sc2X16_720x480_NEXTPOINT_
    add EDI,TLI
    dec dword ptr [Y]
    jnz _Sc2X16_720x480_NEXTLINE_
    jmp _Sc2X16_720x480_FINALEND_
    _Sc2X16_720x480_BEHODEF_:
    stosw
    stosw
    mov [EDI+TLISS],AX
    mov [EDI+TLIS],AX
    dec ECX
    jnz _Sc2X16_720x480_NEXTPOINT_
    add EDI,TLI
    dec dword ptr [Y]
    jnz _Sc2X16_720x480_NEXTLINE_
    _Sc2X16_720x480_FINALEND_:
  end asm  
end sub


Private Sub raw_Scale2X_720x480_32 (Byval PTORG as any ptr, Byval PTDST as any ptr)
  static as integer Y  
  Y = SC2X_Y_720x480
  
  #define ESZ 4  
  
  const PILI = SC2X_X_720x480
  const PILIS = SC2X_X_720x480-1
  const OPI = ESZ
  const TPI = ESZ*2  
  const OLIS = (SC2X_X_720x480-1)*ESZ
  const OLIA = (SC2X_X_720x480+1)*ESZ
  const TLISS = ((SC2X_X_720x480*2)-2)*ESZ
  const TLIS = ((SC2X_X_720x480*2)-1)*ESZ
  const TLI = ((SC2X_X_720x480*2))*ESZ
  const TLIA = ((SC2X_X_720x480*2)+1)*ESZ
  
  asm        
    mov ESI,[PTORG]
    mov EDI,[PTDST]
    lodsd
    stosd
    stosd
    mov [EDI+TLISS],EAX
    mov [EDI+TLIS],EAX
    mov ECX,PILIS
    _Sc2X32_720x480_FLNEXTPOINT_:
    lodsd
    mov EBX,[ESI]
    mov EDX,[ESI]
    cmp EBX,[ESI+OLIS]
    je _Sc2X32_720x480_FLBEHODEF_
    cmp [ESI-TPI],EDX
    je _Sc2X32_720x480_FLBEHODEF_
    cmp EBX,[ESI-TPI]
    je _Sc2X32_720x480_FLNOCHGE0_
    mov EBX,EAX
    _Sc2X32_720x480_FLNOCHGE0_:
    mov [EDI],EBX
    cmp [ESI],EDX
    je _Sc2X32_720x480_FLNOCHGE1_
    mov EDX,EAX
    _Sc2X32_720x480_FLNOCHGE1_:
    mov [EDI+OPI],EDX
    mov EBX,[ESI-TPI]
    mov EDX,[ESI+OLIS]
    cmp EBX,EDX
    je _Sc2X32_720x480_FLNOCHGE2_
    mov EBX,EAX
    _Sc2X32_720x480_FLNOCHGE2_:
    mov [EDI+TLI],EBX
    cmp EDX,[ESI]
    je _Sc2X32_720x480_FLNOCHGE3_
    mov EDX,EAX
    _Sc2X32_720x480_FLNOCHGE3_:
    mov [EDI+TLIA],EDX
    add EDI,TPI
    dec ECX
    jnz _Sc2X32_720x480_FLNEXTPOINT_
    add EDI,TLI
    dec dword ptr [Y]
    jnz _Sc2X32_720x480_NEXTLINE_
    _Sc2X32_720x480_FLBEHODEF_:
    stosd
    stosd
    mov [EDI+TLISS],EAX
    mov [EDI+TLIS],EAX
    dec ECX
    jnz _Sc2X32_720x480_FLNEXTPOINT_
    add EDI,TLI
    dec dword ptr [Y]
    _Sc2X32_720x480_NEXTLINE_:
    mov ECX,PILI
    _Sc2X32_720x480_NEXTPOINT_:
    lodsd
    mov EBX,[ESI-OLIA]
    mov EDX,[ESI]
    cmp EBX,[ESI+OLIS]
    je _Sc2X32_720x480_BEHODEF_
    cmp [ESI-TPI],EDX
    je _Sc2X32_720x480_BEHODEF_
    cmp EBX,[ESI-TPI]
    je _Sc2X32_720x480_NOCHGE0_
    mov EBX,EAX
    _Sc2X32_720x480_NOCHGE0_:
    mov [EDI],EBX
    cmp [ESI-OLIA],EDX
    je _Sc2X32_720x480_NOCHGE1_
    mov EDX,EAX
    _Sc2X32_720x480_NOCHGE1_:
    mov [EDI+OPI],EDX
    mov EBX,[ESI-TPI]
    mov EDX,[ESI+OLIS]
    cmp EBX,EDX
    je _Sc2X32_720x480_NOCHGE2_
    mov EBX,EAX
    _Sc2X32_720x480_NOCHGE2_:
    mov [EDI+TLI],EBX
    cmp EDX,[ESI]
    je _Sc2X32_720x480_NOCHGE3_
    mov EDX,EAX
    _Sc2X32_720x480_NOCHGE3_:
    mov [EDI+TLIA],EDX
    add EDI,TPI
    dec ECX
    jnz _Sc2X32_720x480_NEXTPOINT_
    add EDI,TLI
    dec dword ptr [Y]
    jnz _Sc2X32_720x480_NEXTLINE_
    jmp _Sc2X32_720x480_FINALEND_
    _Sc2X32_720x480_BEHODEF_:
    stosd
    stosd
    mov [EDI+TLISS],EAX
    mov [EDI+TLIS],EAX
    dec ECX
    jnz _Sc2X32_720x480_NEXTPOINT_
    add EDI,TLI
    dec dword ptr [Y]
    jnz _Sc2X32_720x480_NEXTLINE_
    _Sc2X32_720x480_FINALEND_:
  end asm  
end sub


Private Sub raw_Scale2X_720x576_16 (Byval PTORG as any ptr, Byval PTDST as any ptr)
  static as integer Y  
  Y = SC2X_Y_720x576
  
  #define ESZ 2  
  
  const PILI = SC2X_X_720x576
  const PILIS = SC2X_X_720x576-1
  const OPI = ESZ
  const TPI = ESZ*2  
  const OLIS = (SC2X_X_720x576-1)*ESZ
  const OLIA = (SC2X_X_720x576+1)*ESZ
  const TLISS = ((SC2X_X_720x576*2)-2)*ESZ
  const TLIS = ((SC2X_X_720x576*2)-1)*ESZ
  const TLI = ((SC2X_X_720x576*2))*ESZ
  const TLIA = ((SC2X_X_720x576*2)+1)*ESZ
  
  asm        
    mov ESI,[PTORG]
    mov EDI,[PTDST]
    lodsw
    stosw
    stosw
    mov [EDI+TLISS],AX
    mov [EDI+TLIS],AX
    mov ECX,PILIS
    _Sc2X16_720x576_FLNEXTPOINT_:
    lodsw
    mov BX,[ESI]
    mov DX,[ESI]
    cmp BX,[ESI+OLIS]
    je _Sc2X16_720x576_FLBEHODEF_
    cmp [ESI-TPI],DX
    je _Sc2X16_720x576_FLBEHODEF_
    cmp BX,[ESI-TPI]
    je _Sc2X16_720x576_FLNOCHGE0_
    mov BX,AX
    _Sc2X16_720x576_FLNOCHGE0_:
    mov [EDI],BX
    cmp [ESI],DX
    je _Sc2X16_720x576_FLNOCHGE1_
    mov DX,AX
    _Sc2X16_720x576_FLNOCHGE1_:
    mov [EDI+OPI],DX
    mov BX,[ESI-TPI]
    mov DX,[ESI+OLIS]
    cmp BX,DX
    je _Sc2X16_720x576_FLNOCHGE2_
    mov BX,AX
    _Sc2X16_720x576_FLNOCHGE2_:
    mov [EDI+TLI],BX
    cmp DX,[ESI]
    je _Sc2X16_720x576_FLNOCHGE3_
    mov DX,AX
    _Sc2X16_720x576_FLNOCHGE3_:
    mov [EDI+TLIA],DX
    add EDI,TPI
    dec ECX
    jnz _Sc2X16_720x576_FLNEXTPOINT_
    add EDI,TLI
    dec dword ptr [Y]
    jnz _Sc2X16_720x576_NEXTLINE_
    _Sc2X16_720x576_FLBEHODEF_:
    stosw
    stosw
    mov [EDI+TLISS],AX
    mov [EDI+TLIS],AX
    dec ECX
    jnz _Sc2X16_720x576_FLNEXTPOINT_
    add EDI,TLI
    dec dword ptr [Y]
    _Sc2X16_720x576_NEXTLINE_:
    mov ECX,PILI
    _Sc2X16_720x576_NEXTPOINT_:
    lodsw
    mov BX,[ESI-OLIA]
    mov DX,[ESI]
    cmp BX,[ESI+OLIS]
    je _Sc2X16_720x576_BEHODEF_
    cmp [ESI-TPI],DX
    je _Sc2X16_720x576_BEHODEF_
    cmp BX,[ESI-TPI]
    je _Sc2X16_720x576_NOCHGE0_
    mov BX,AX
    _Sc2X16_720x576_NOCHGE0_:
    mov [EDI],BX
    cmp [ESI-OLIA],DX
    je _Sc2X16_720x576_NOCHGE1_
    mov DX,AX
    _Sc2X16_720x576_NOCHGE1_:
    mov [EDI+OPI],DX
    mov BX,[ESI-TPI]
    mov DX,[ESI+OLIS]
    cmp BX,DX
    je _Sc2X16_720x576_NOCHGE2_
    mov BX,AX
    _Sc2X16_720x576_NOCHGE2_:
    mov [EDI+TLI],BX
    cmp DX,[ESI]
    je _Sc2X16_720x576_NOCHGE3_
    mov DX,AX
    _Sc2X16_720x576_NOCHGE3_:
    mov [EDI+TLIA],DX
    add EDI,TPI
    dec ECX
    jnz _Sc2X16_720x576_NEXTPOINT_
    add EDI,TLI
    dec dword ptr [Y]
    jnz _Sc2X16_720x576_NEXTLINE_
    jmp _Sc2X16_720x576_FINALEND_
    _Sc2X16_720x576_BEHODEF_:
    stosw
    stosw
    mov [EDI+TLISS],AX
    mov [EDI+TLIS],AX
    dec ECX
    jnz _Sc2X16_720x576_NEXTPOINT_
    add EDI,TLI
    dec dword ptr [Y]
    jnz _Sc2X16_720x576_NEXTLINE_
    _Sc2X16_720x576_FINALEND_:
  end asm  
end sub


Private Sub raw_Scale2X_720x576_32 (Byval PTORG as any ptr, Byval PTDST as any ptr)
  static as integer Y  
  Y = SC2X_Y_720x576
  
  #define ESZ 4  
  
  const PILI = SC2X_X_720x576
  const PILIS = SC2X_X_720x576-1
  const OPI = ESZ
  const TPI = ESZ*2  
  const OLIS = (SC2X_X_720x576-1)*ESZ
  const OLIA = (SC2X_X_720x576+1)*ESZ
  const TLISS = ((SC2X_X_720x576*2)-2)*ESZ
  const TLIS = ((SC2X_X_720x576*2)-1)*ESZ
  const TLI = ((SC2X_X_720x576*2))*ESZ
  const TLIA = ((SC2X_X_720x576*2)+1)*ESZ
  
  asm        
    mov ESI,[PTORG]
    mov EDI,[PTDST]
    lodsd
    stosd
    stosd
    mov [EDI+TLISS],EAX
    mov [EDI+TLIS],EAX
    mov ECX,PILIS
    _Sc2X32_720x576_FLNEXTPOINT_:
    lodsd
    mov EBX,[ESI]
    mov EDX,[ESI]
    cmp EBX,[ESI+OLIS]
    je _Sc2X32_720x576_FLBEHODEF_
    cmp [ESI-TPI],EDX
    je _Sc2X32_720x576_FLBEHODEF_
    cmp EBX,[ESI-TPI]
    je _Sc2X32_720x576_FLNOCHGE0_
    mov EBX,EAX
    _Sc2X32_720x576_FLNOCHGE0_:
    mov [EDI],EBX
    cmp [ESI],EDX
    je _Sc2X32_720x576_FLNOCHGE1_
    mov EDX,EAX
    _Sc2X32_720x576_FLNOCHGE1_:
    mov [EDI+OPI],EDX
    mov EBX,[ESI-TPI]
    mov EDX,[ESI+OLIS]
    cmp EBX,EDX
    je _Sc2X32_720x576_FLNOCHGE2_
    mov EBX,EAX
    _Sc2X32_720x576_FLNOCHGE2_:
    mov [EDI+TLI],EBX
    cmp EDX,[ESI]
    je _Sc2X32_720x576_FLNOCHGE3_
    mov EDX,EAX
    _Sc2X32_720x576_FLNOCHGE3_:
    mov [EDI+TLIA],EDX
    add EDI,TPI
    dec ECX
    jnz _Sc2X32_720x576_FLNEXTPOINT_
    add EDI,TLI
    dec dword ptr [Y]
    jnz _Sc2X32_720x576_NEXTLINE_
    _Sc2X32_720x576_FLBEHODEF_:
    stosd
    stosd
    mov [EDI+TLISS],EAX
    mov [EDI+TLIS],EAX
    dec ECX
    jnz _Sc2X32_720x576_FLNEXTPOINT_
    add EDI,TLI
    dec dword ptr [Y]
    _Sc2X32_720x576_NEXTLINE_:
    mov ECX,PILI
    _Sc2X32_720x576_NEXTPOINT_:
    lodsd
    mov EBX,[ESI-OLIA]
    mov EDX,[ESI]
    cmp EBX,[ESI+OLIS]
    je _Sc2X32_720x576_BEHODEF_
    cmp [ESI-TPI],EDX
    je _Sc2X32_720x576_BEHODEF_
    cmp EBX,[ESI-TPI]
    je _Sc2X32_720x576_NOCHGE0_
    mov EBX,EAX
    _Sc2X32_720x576_NOCHGE0_:
    mov [EDI],EBX
    cmp [ESI-OLIA],EDX
    je _Sc2X32_720x576_NOCHGE1_
    mov EDX,EAX
    _Sc2X32_720x576_NOCHGE1_:
    mov [EDI+OPI],EDX
    mov EBX,[ESI-TPI]
    mov EDX,[ESI+OLIS]
    cmp EBX,EDX
    je _Sc2X32_720x576_NOCHGE2_
    mov EBX,EAX
    _Sc2X32_720x576_NOCHGE2_:
    mov [EDI+TLI],EBX
    cmp EDX,[ESI]
    je _Sc2X32_720x576_NOCHGE3_
    mov EDX,EAX
    _Sc2X32_720x576_NOCHGE3_:
    mov [EDI+TLIA],EDX
    add EDI,TPI
    dec ECX
    jnz _Sc2X32_720x576_NEXTPOINT_
    add EDI,TLI
    dec dword ptr [Y]
    jnz _Sc2X32_720x576_NEXTLINE_
    jmp _Sc2X32_720x576_FINALEND_
    _Sc2X32_720x576_BEHODEF_:
    stosd
    stosd
    mov [EDI+TLISS],EAX
    mov [EDI+TLIS],EAX
    dec ECX
    jnz _Sc2X32_720x576_NEXTPOINT_
    add EDI,TLI
    dec dword ptr [Y]
    jnz _Sc2X32_720x576_NEXTLINE_
    _Sc2X32_720x576_FINALEND_:
  end asm  
end sub


Private Sub raw_Scale2X_800x600_16 (Byval PTORG as any ptr, Byval PTDST as any ptr)
  static as integer Y  
  Y = SC2X_Y_800x600
  
  #define ESZ 2  
  
  const PILI = SC2X_X_800x600
  const PILIS = SC2X_X_800x600-1
  const OPI = ESZ
  const TPI = ESZ*2  
  const OLIS = (SC2X_X_800x600-1)*ESZ
  const OLIA = (SC2X_X_800x600+1)*ESZ
  const TLISS = ((SC2X_X_800x600*2)-2)*ESZ
  const TLIS = ((SC2X_X_800x600*2)-1)*ESZ
  const TLI = ((SC2X_X_800x600*2))*ESZ
  const TLIA = ((SC2X_X_800x600*2)+1)*ESZ
  
  asm        
    mov ESI,[PTORG]
    mov EDI,[PTDST]
    lodsw
    stosw
    stosw
    mov [EDI+TLISS],AX
    mov [EDI+TLIS],AX
    mov ECX,PILIS
    _Sc2X16_800x600_FLNEXTPOINT_:
    lodsw
    mov BX,[ESI]
    mov DX,[ESI]
    cmp BX,[ESI+OLIS]
    je _Sc2X16_800x600_FLBEHODEF_
    cmp [ESI-TPI],DX
    je _Sc2X16_800x600_FLBEHODEF_
    cmp BX,[ESI-TPI]
    je _Sc2X16_800x600_FLNOCHGE0_
    mov BX,AX
    _Sc2X16_800x600_FLNOCHGE0_:
    mov [EDI],BX
    cmp [ESI],DX
    je _Sc2X16_800x600_FLNOCHGE1_
    mov DX,AX
    _Sc2X16_800x600_FLNOCHGE1_:
    mov [EDI+OPI],DX
    mov BX,[ESI-TPI]
    mov DX,[ESI+OLIS]
    cmp BX,DX
    je _Sc2X16_800x600_FLNOCHGE2_
    mov BX,AX
    _Sc2X16_800x600_FLNOCHGE2_:
    mov [EDI+TLI],BX
    cmp DX,[ESI]
    je _Sc2X16_800x600_FLNOCHGE3_
    mov DX,AX
    _Sc2X16_800x600_FLNOCHGE3_:
    mov [EDI+TLIA],DX
    add EDI,TPI
    dec ECX
    jnz _Sc2X16_800x600_FLNEXTPOINT_
    add EDI,TLI
    dec dword ptr [Y]
    jnz _Sc2X16_800x600_NEXTLINE_
    _Sc2X16_800x600_FLBEHODEF_:
    stosw
    stosw
    mov [EDI+TLISS],AX
    mov [EDI+TLIS],AX
    dec ECX
    jnz _Sc2X16_800x600_FLNEXTPOINT_
    add EDI,TLI
    dec dword ptr [Y]
    _Sc2X16_800x600_NEXTLINE_:
    mov ECX,PILI
    _Sc2X16_800x600_NEXTPOINT_:
    lodsw
    mov BX,[ESI-OLIA]
    mov DX,[ESI]
    cmp BX,[ESI+OLIS]
    je _Sc2X16_800x600_BEHODEF_
    cmp [ESI-TPI],DX
    je _Sc2X16_800x600_BEHODEF_
    cmp BX,[ESI-TPI]
    je _Sc2X16_800x600_NOCHGE0_
    mov BX,AX
    _Sc2X16_800x600_NOCHGE0_:
    mov [EDI],BX
    cmp [ESI-OLIA],DX
    je _Sc2X16_800x600_NOCHGE1_
    mov DX,AX
    _Sc2X16_800x600_NOCHGE1_:
    mov [EDI+OPI],DX
    mov BX,[ESI-TPI]
    mov DX,[ESI+OLIS]
    cmp BX,DX
    je _Sc2X16_800x600_NOCHGE2_
    mov BX,AX
    _Sc2X16_800x600_NOCHGE2_:
    mov [EDI+TLI],BX
    cmp DX,[ESI]
    je _Sc2X16_800x600_NOCHGE3_
    mov DX,AX
    _Sc2X16_800x600_NOCHGE3_:
    mov [EDI+TLIA],DX
    add EDI,TPI
    dec ECX
    jnz _Sc2X16_800x600_NEXTPOINT_
    add EDI,TLI
    dec dword ptr [Y]
    jnz _Sc2X16_800x600_NEXTLINE_
    jmp _Sc2X16_800x600_FINALEND_
    _Sc2X16_800x600_BEHODEF_:
    stosw
    stosw
    mov [EDI+TLISS],AX
    mov [EDI+TLIS],AX
    dec ECX
    jnz _Sc2X16_800x600_NEXTPOINT_
    add EDI,TLI
    dec dword ptr [Y]
    jnz _Sc2X16_800x600_NEXTLINE_
    _Sc2X16_800x600_FINALEND_:
  end asm  
end sub


Private Sub raw_Scale2X_800x600_32 (Byval PTORG as any ptr, Byval PTDST as any ptr)
  static as integer Y  
  Y = SC2X_Y_800x600
  
  #define ESZ 4  
  
  const PILI = SC2X_X_800x600
  const PILIS = SC2X_X_800x600-1
  const OPI = ESZ
  const TPI = ESZ*2  
  const OLIS = (SC2X_X_800x600-1)*ESZ
  const OLIA = (SC2X_X_800x600+1)*ESZ
  const TLISS = ((SC2X_X_800x600*2)-2)*ESZ
  const TLIS = ((SC2X_X_800x600*2)-1)*ESZ
  const TLI = ((SC2X_X_800x600*2))*ESZ
  const TLIA = ((SC2X_X_800x600*2)+1)*ESZ
  
  asm        
    mov ESI,[PTORG]
    mov EDI,[PTDST]
    lodsd
    stosd
    stosd
    mov [EDI+TLISS],EAX
    mov [EDI+TLIS],EAX
    mov ECX,PILIS
    _Sc2X32_800x600_FLNEXTPOINT_:
    lodsd
    mov EBX,[ESI]
    mov EDX,[ESI]
    cmp EBX,[ESI+OLIS]
    je _Sc2X32_800x600_FLBEHODEF_
    cmp [ESI-TPI],EDX
    je _Sc2X32_800x600_FLBEHODEF_
    cmp EBX,[ESI-TPI]
    je _Sc2X32_800x600_FLNOCHGE0_
    mov EBX,EAX
    _Sc2X32_800x600_FLNOCHGE0_:
    mov [EDI],EBX
    cmp [ESI],EDX
    je _Sc2X32_800x600_FLNOCHGE1_
    mov EDX,EAX
    _Sc2X32_800x600_FLNOCHGE1_:
    mov [EDI+OPI],EDX
    mov EBX,[ESI-TPI]
    mov EDX,[ESI+OLIS]
    cmp EBX,EDX
    je _Sc2X32_800x600_FLNOCHGE2_
    mov EBX,EAX
    _Sc2X32_800x600_FLNOCHGE2_:
    mov [EDI+TLI],EBX
    cmp EDX,[ESI]
    je _Sc2X32_800x600_FLNOCHGE3_
    mov EDX,EAX
    _Sc2X32_800x600_FLNOCHGE3_:
    mov [EDI+TLIA],EDX
    add EDI,TPI
    dec ECX
    jnz _Sc2X32_800x600_FLNEXTPOINT_
    add EDI,TLI
    dec dword ptr [Y]
    jnz _Sc2X32_800x600_NEXTLINE_
    _Sc2X32_800x600_FLBEHODEF_:
    stosd
    stosd
    mov [EDI+TLISS],EAX
    mov [EDI+TLIS],EAX
    dec ECX
    jnz _Sc2X32_800x600_FLNEXTPOINT_
    add EDI,TLI
    dec dword ptr [Y]
    _Sc2X32_800x600_NEXTLINE_:
    mov ECX,PILI
    _Sc2X32_800x600_NEXTPOINT_:
    lodsd
    mov EBX,[ESI-OLIA]
    mov EDX,[ESI]
    cmp EBX,[ESI+OLIS]
    je _Sc2X32_800x600_BEHODEF_
    cmp [ESI-TPI],EDX
    je _Sc2X32_800x600_BEHODEF_
    cmp EBX,[ESI-TPI]
    je _Sc2X32_800x600_NOCHGE0_
    mov EBX,EAX
    _Sc2X32_800x600_NOCHGE0_:
    mov [EDI],EBX
    cmp [ESI-OLIA],EDX
    je _Sc2X32_800x600_NOCHGE1_
    mov EDX,EAX
    _Sc2X32_800x600_NOCHGE1_:
    mov [EDI+OPI],EDX
    mov EBX,[ESI-TPI]
    mov EDX,[ESI+OLIS]
    cmp EBX,EDX
    je _Sc2X32_800x600_NOCHGE2_
    mov EBX,EAX
    _Sc2X32_800x600_NOCHGE2_:
    mov [EDI+TLI],EBX
    cmp EDX,[ESI]
    je _Sc2X32_800x600_NOCHGE3_
    mov EDX,EAX
    _Sc2X32_800x600_NOCHGE3_:
    mov [EDI+TLIA],EDX
    add EDI,TPI
    dec ECX
    jnz _Sc2X32_800x600_NEXTPOINT_
    add EDI,TLI
    dec dword ptr [Y]
    jnz _Sc2X32_800x600_NEXTLINE_
    jmp _Sc2X32_800x600_FINALEND_
    _Sc2X32_800x600_BEHODEF_:
    stosd
    stosd
    mov [EDI+TLISS],EAX
    mov [EDI+TLIS],EAX
    dec ECX
    jnz _Sc2X32_800x600_NEXTPOINT_
    add EDI,TLI
    dec dword ptr [Y]
    jnz _Sc2X32_800x600_NEXTLINE_
    _Sc2X32_800x600_FINALEND_:
  end asm  
end sub


Private Sub raw_Scale2X_1024x768_16 (Byval PTORG as any ptr, Byval PTDST as any ptr)
  static as integer Y  
  Y = SC2X_Y_1024x768
  
  #define ESZ 2  
  
  const PILI = SC2X_X_1024x768
  const PILIS = SC2X_X_1024x768-1
  const OPI = ESZ
  const TPI = ESZ*2  
  const OLIS = (SC2X_X_1024x768-1)*ESZ
  const OLIA = (SC2X_X_1024x768+1)*ESZ
  const TLISS = ((SC2X_X_1024x768*2)-2)*ESZ
  const TLIS = ((SC2X_X_1024x768*2)-1)*ESZ
  const TLI = ((SC2X_X_1024x768*2))*ESZ
  const TLIA = ((SC2X_X_1024x768*2)+1)*ESZ
  
  asm        
    mov ESI,[PTORG]
    mov EDI,[PTDST]
    lodsw
    stosw
    stosw
    mov [EDI+TLISS],AX
    mov [EDI+TLIS],AX
    mov ECX,PILIS
    _Sc2X16_1024x768_FLNEXTPOINT_:
    lodsw
    mov BX,[ESI]
    mov DX,[ESI]
    cmp BX,[ESI+OLIS]
    je _Sc2X16_1024x768_FLBEHODEF_
    cmp [ESI-TPI],DX
    je _Sc2X16_1024x768_FLBEHODEF_
    cmp BX,[ESI-TPI]
    je _Sc2X16_1024x768_FLNOCHGE0_
    mov BX,AX
    _Sc2X16_1024x768_FLNOCHGE0_:
    mov [EDI],BX
    cmp [ESI],DX
    je _Sc2X16_1024x768_FLNOCHGE1_
    mov DX,AX
    _Sc2X16_1024x768_FLNOCHGE1_:
    mov [EDI+OPI],DX
    mov BX,[ESI-TPI]
    mov DX,[ESI+OLIS]
    cmp BX,DX
    je _Sc2X16_1024x768_FLNOCHGE2_
    mov BX,AX
    _Sc2X16_1024x768_FLNOCHGE2_:
    mov [EDI+TLI],BX
    cmp DX,[ESI]
    je _Sc2X16_1024x768_FLNOCHGE3_
    mov DX,AX
    _Sc2X16_1024x768_FLNOCHGE3_:
    mov [EDI+TLIA],DX
    add EDI,TPI
    dec ECX
    jnz _Sc2X16_1024x768_FLNEXTPOINT_
    add EDI,TLI
    dec dword ptr [Y]
    jnz _Sc2X16_1024x768_NEXTLINE_
    _Sc2X16_1024x768_FLBEHODEF_:
    stosw
    stosw
    mov [EDI+TLISS],AX
    mov [EDI+TLIS],AX
    dec ECX
    jnz _Sc2X16_1024x768_FLNEXTPOINT_
    add EDI,TLI
    dec dword ptr [Y]
    _Sc2X16_1024x768_NEXTLINE_:
    mov ECX,PILI
    _Sc2X16_1024x768_NEXTPOINT_:
    lodsw
    mov BX,[ESI-OLIA]
    mov DX,[ESI]
    cmp BX,[ESI+OLIS]
    je _Sc2X16_1024x768_BEHODEF_
    cmp [ESI-TPI],DX
    je _Sc2X16_1024x768_BEHODEF_
    cmp BX,[ESI-TPI]
    je _Sc2X16_1024x768_NOCHGE0_
    mov BX,AX
    _Sc2X16_1024x768_NOCHGE0_:
    mov [EDI],BX
    cmp [ESI-OLIA],DX
    je _Sc2X16_1024x768_NOCHGE1_
    mov DX,AX
    _Sc2X16_1024x768_NOCHGE1_:
    mov [EDI+OPI],DX
    mov BX,[ESI-TPI]
    mov DX,[ESI+OLIS]
    cmp BX,DX
    je _Sc2X16_1024x768_NOCHGE2_
    mov BX,AX
    _Sc2X16_1024x768_NOCHGE2_:
    mov [EDI+TLI],BX
    cmp DX,[ESI]
    je _Sc2X16_1024x768_NOCHGE3_
    mov DX,AX
    _Sc2X16_1024x768_NOCHGE3_:
    mov [EDI+TLIA],DX
    add EDI,TPI
    dec ECX
    jnz _Sc2X16_1024x768_NEXTPOINT_
    add EDI,TLI
    dec dword ptr [Y]
    jnz _Sc2X16_1024x768_NEXTLINE_
    jmp _Sc2X16_1024x768_FINALEND_
    _Sc2X16_1024x768_BEHODEF_:
    stosw
    stosw
    mov [EDI+TLISS],AX
    mov [EDI+TLIS],AX
    dec ECX
    jnz _Sc2X16_1024x768_NEXTPOINT_
    add EDI,TLI
    dec dword ptr [Y]
    jnz _Sc2X16_1024x768_NEXTLINE_
    _Sc2X16_1024x768_FINALEND_:
  end asm  
end sub


Private Sub raw_Scale2X_1024x768_32 (Byval PTORG as any ptr, Byval PTDST as any ptr)
  static as integer Y  
  Y = SC2X_Y_1024x768
  
  #define ESZ 4  
  
  const PILI = SC2X_X_1024x768
  const PILIS = SC2X_X_1024x768-1
  const OPI = ESZ
  const TPI = ESZ*2  
  const OLIS = (SC2X_X_1024x768-1)*ESZ
  const OLIA = (SC2X_X_1024x768+1)*ESZ
  const TLISS = ((SC2X_X_1024x768*2)-2)*ESZ
  const TLIS = ((SC2X_X_1024x768*2)-1)*ESZ
  const TLI = ((SC2X_X_1024x768*2))*ESZ
  const TLIA = ((SC2X_X_1024x768*2)+1)*ESZ
  
  asm        
    mov ESI,[PTORG]
    mov EDI,[PTDST]
    lodsd
    stosd
    stosd
    mov [EDI+TLISS],EAX
    mov [EDI+TLIS],EAX
    mov ECX,PILIS
    _Sc2X32_1024x768_FLNEXTPOINT_:
    lodsd
    mov EBX,[ESI]
    mov EDX,[ESI]
    cmp EBX,[ESI+OLIS]
    je _Sc2X32_1024x768_FLBEHODEF_
    cmp [ESI-TPI],EDX
    je _Sc2X32_1024x768_FLBEHODEF_
    cmp EBX,[ESI-TPI]
    je _Sc2X32_1024x768_FLNOCHGE0_
    mov EBX,EAX
    _Sc2X32_1024x768_FLNOCHGE0_:
    mov [EDI],EBX
    cmp [ESI],EDX
    je _Sc2X32_1024x768_FLNOCHGE1_
    mov EDX,EAX
    _Sc2X32_1024x768_FLNOCHGE1_:
    mov [EDI+OPI],EDX
    mov EBX,[ESI-TPI]
    mov EDX,[ESI+OLIS]
    cmp EBX,EDX
    je _Sc2X32_1024x768_FLNOCHGE2_
    mov EBX,EAX
    _Sc2X32_1024x768_FLNOCHGE2_:
    mov [EDI+TLI],EBX
    cmp EDX,[ESI]
    je _Sc2X32_1024x768_FLNOCHGE3_
    mov EDX,EAX
    _Sc2X32_1024x768_FLNOCHGE3_:
    mov [EDI+TLIA],EDX
    add EDI,TPI
    dec ECX
    jnz _Sc2X32_1024x768_FLNEXTPOINT_
    add EDI,TLI
    dec dword ptr [Y]
    jnz _Sc2X32_1024x768_NEXTLINE_
    _Sc2X32_1024x768_FLBEHODEF_:
    stosd
    stosd
    mov [EDI+TLISS],EAX
    mov [EDI+TLIS],EAX
    dec ECX
    jnz _Sc2X32_1024x768_FLNEXTPOINT_
    add EDI,TLI
    dec dword ptr [Y]
    _Sc2X32_1024x768_NEXTLINE_:
    mov ECX,PILI
    _Sc2X32_1024x768_NEXTPOINT_:
    lodsd
    mov EBX,[ESI-OLIA]
    mov EDX,[ESI]
    cmp EBX,[ESI+OLIS]
    je _Sc2X32_1024x768_BEHODEF_
    cmp [ESI-TPI],EDX
    je _Sc2X32_1024x768_BEHODEF_
    cmp EBX,[ESI-TPI]
    je _Sc2X32_1024x768_NOCHGE0_
    mov EBX,EAX
    _Sc2X32_1024x768_NOCHGE0_:
    mov [EDI],EBX
    cmp [ESI-OLIA],EDX
    je _Sc2X32_1024x768_NOCHGE1_
    mov EDX,EAX
    _Sc2X32_1024x768_NOCHGE1_:
    mov [EDI+OPI],EDX
    mov EBX,[ESI-TPI]
    mov EDX,[ESI+OLIS]
    cmp EBX,EDX
    je _Sc2X32_1024x768_NOCHGE2_
    mov EBX,EAX
    _Sc2X32_1024x768_NOCHGE2_:
    mov [EDI+TLI],EBX
    cmp EDX,[ESI]
    je _Sc2X32_1024x768_NOCHGE3_
    mov EDX,EAX
    _Sc2X32_1024x768_NOCHGE3_:
    mov [EDI+TLIA],EDX
    add EDI,TPI
    dec ECX
    jnz _Sc2X32_1024x768_NEXTPOINT_
    add EDI,TLI
    dec dword ptr [Y]
    jnz _Sc2X32_1024x768_NEXTLINE_
    jmp _Sc2X32_1024x768_FINALEND_
    _Sc2X32_1024x768_BEHODEF_:
    stosd
    stosd
    mov [EDI+TLISS],EAX
    mov [EDI+TLIS],EAX
    dec ECX
    jnz _Sc2X32_1024x768_NEXTPOINT_
    add EDI,TLI
    dec dword ptr [Y]
    jnz _Sc2X32_1024x768_NEXTLINE_
    _Sc2X32_1024x768_FINALEND_:
  end asm  
end sub


Private Sub raw_Scale2X_1152x864_16 (Byval PTORG as any ptr, Byval PTDST as any ptr)
  static as integer Y  
  Y = SC2X_Y_1152x864
  
  #define ESZ 2  
  
  const PILI = SC2X_X_1152x864
  const PILIS = SC2X_X_1152x864-1
  const OPI = ESZ
  const TPI = ESZ*2  
  const OLIS = (SC2X_X_1152x864-1)*ESZ
  const OLIA = (SC2X_X_1152x864+1)*ESZ
  const TLISS = ((SC2X_X_1152x864*2)-2)*ESZ
  const TLIS = ((SC2X_X_1152x864*2)-1)*ESZ
  const TLI = ((SC2X_X_1152x864*2))*ESZ
  const TLIA = ((SC2X_X_1152x864*2)+1)*ESZ
  
  asm        
    mov ESI,[PTORG]
    mov EDI,[PTDST]
    lodsw
    stosw
    stosw
    mov [EDI+TLISS],AX
    mov [EDI+TLIS],AX
    mov ECX,PILIS
    _Sc2X16_1152x864_FLNEXTPOINT_:
    lodsw
    mov BX,[ESI]
    mov DX,[ESI]
    cmp BX,[ESI+OLIS]
    je _Sc2X16_1152x864_FLBEHODEF_
    cmp [ESI-TPI],DX
    je _Sc2X16_1152x864_FLBEHODEF_
    cmp BX,[ESI-TPI]
    je _Sc2X16_1152x864_FLNOCHGE0_
    mov BX,AX
    _Sc2X16_1152x864_FLNOCHGE0_:
    mov [EDI],BX
    cmp [ESI],DX
    je _Sc2X16_1152x864_FLNOCHGE1_
    mov DX,AX
    _Sc2X16_1152x864_FLNOCHGE1_:
    mov [EDI+OPI],DX
    mov BX,[ESI-TPI]
    mov DX,[ESI+OLIS]
    cmp BX,DX
    je _Sc2X16_1152x864_FLNOCHGE2_
    mov BX,AX
    _Sc2X16_1152x864_FLNOCHGE2_:
    mov [EDI+TLI],BX
    cmp DX,[ESI]
    je _Sc2X16_1152x864_FLNOCHGE3_
    mov DX,AX
    _Sc2X16_1152x864_FLNOCHGE3_:
    mov [EDI+TLIA],DX
    add EDI,TPI
    dec ECX
    jnz _Sc2X16_1152x864_FLNEXTPOINT_
    add EDI,TLI
    dec dword ptr [Y]
    jnz _Sc2X16_1152x864_NEXTLINE_
    _Sc2X16_1152x864_FLBEHODEF_:
    stosw
    stosw
    mov [EDI+TLISS],AX
    mov [EDI+TLIS],AX
    dec ECX
    jnz _Sc2X16_1152x864_FLNEXTPOINT_
    add EDI,TLI
    dec dword ptr [Y]
    _Sc2X16_1152x864_NEXTLINE_:
    mov ECX,PILI
    _Sc2X16_1152x864_NEXTPOINT_:
    lodsw
    mov BX,[ESI-OLIA]
    mov DX,[ESI]
    cmp BX,[ESI+OLIS]
    je _Sc2X16_1152x864_BEHODEF_
    cmp [ESI-TPI],DX
    je _Sc2X16_1152x864_BEHODEF_
    cmp BX,[ESI-TPI]
    je _Sc2X16_1152x864_NOCHGE0_
    mov BX,AX
    _Sc2X16_1152x864_NOCHGE0_:
    mov [EDI],BX
    cmp [ESI-OLIA],DX
    je _Sc2X16_1152x864_NOCHGE1_
    mov DX,AX
    _Sc2X16_1152x864_NOCHGE1_:
    mov [EDI+OPI],DX
    mov BX,[ESI-TPI]
    mov DX,[ESI+OLIS]
    cmp BX,DX
    je _Sc2X16_1152x864_NOCHGE2_
    mov BX,AX
    _Sc2X16_1152x864_NOCHGE2_:
    mov [EDI+TLI],BX
    cmp DX,[ESI]
    je _Sc2X16_1152x864_NOCHGE3_
    mov DX,AX
    _Sc2X16_1152x864_NOCHGE3_:
    mov [EDI+TLIA],DX
    add EDI,TPI
    dec ECX
    jnz _Sc2X16_1152x864_NEXTPOINT_
    add EDI,TLI
    dec dword ptr [Y]
    jnz _Sc2X16_1152x864_NEXTLINE_
    jmp _Sc2X16_1152x864_FINALEND_
    _Sc2X16_1152x864_BEHODEF_:
    stosw
    stosw
    mov [EDI+TLISS],AX
    mov [EDI+TLIS],AX
    dec ECX
    jnz _Sc2X16_1152x864_NEXTPOINT_
    add EDI,TLI
    dec dword ptr [Y]
    jnz _Sc2X16_1152x864_NEXTLINE_
    _Sc2X16_1152x864_FINALEND_:
  end asm  
end sub


Private Sub raw_Scale2X_1152x864_32 (Byval PTORG as any ptr, Byval PTDST as any ptr)
  static as integer Y  
  Y = SC2X_Y_1152x864
  
  #define ESZ 4  
  
  const PILI = SC2X_X_1152x864
  const PILIS = SC2X_X_1152x864-1
  const OPI = ESZ
  const TPI = ESZ*2  
  const OLIS = (SC2X_X_1152x864-1)*ESZ
  const OLIA = (SC2X_X_1152x864+1)*ESZ
  const TLISS = ((SC2X_X_1152x864*2)-2)*ESZ
  const TLIS = ((SC2X_X_1152x864*2)-1)*ESZ
  const TLI = ((SC2X_X_1152x864*2))*ESZ
  const TLIA = ((SC2X_X_1152x864*2)+1)*ESZ
  
  asm        
    mov ESI,[PTORG]
    mov EDI,[PTDST]
    lodsd
    stosd
    stosd
    mov [EDI+TLISS],EAX
    mov [EDI+TLIS],EAX
    mov ECX,PILIS
    _Sc2X32_1152x864_FLNEXTPOINT_:
    lodsd
    mov EBX,[ESI]
    mov EDX,[ESI]
    cmp EBX,[ESI+OLIS]
    je _Sc2X32_1152x864_FLBEHODEF_
    cmp [ESI-TPI],EDX
    je _Sc2X32_1152x864_FLBEHODEF_
    cmp EBX,[ESI-TPI]
    je _Sc2X32_1152x864_FLNOCHGE0_
    mov EBX,EAX
    _Sc2X32_1152x864_FLNOCHGE0_:
    mov [EDI],EBX
    cmp [ESI],EDX
    je _Sc2X32_1152x864_FLNOCHGE1_
    mov EDX,EAX
    _Sc2X32_1152x864_FLNOCHGE1_:
    mov [EDI+OPI],EDX
    mov EBX,[ESI-TPI]
    mov EDX,[ESI+OLIS]
    cmp EBX,EDX
    je _Sc2X32_1152x864_FLNOCHGE2_
    mov EBX,EAX
    _Sc2X32_1152x864_FLNOCHGE2_:
    mov [EDI+TLI],EBX
    cmp EDX,[ESI]
    je _Sc2X32_1152x864_FLNOCHGE3_
    mov EDX,EAX
    _Sc2X32_1152x864_FLNOCHGE3_:
    mov [EDI+TLIA],EDX
    add EDI,TPI
    dec ECX
    jnz _Sc2X32_1152x864_FLNEXTPOINT_
    add EDI,TLI
    dec dword ptr [Y]
    jnz _Sc2X32_1152x864_NEXTLINE_
    _Sc2X32_1152x864_FLBEHODEF_:
    stosd
    stosd
    mov [EDI+TLISS],EAX
    mov [EDI+TLIS],EAX
    dec ECX
    jnz _Sc2X32_1152x864_FLNEXTPOINT_
    add EDI,TLI
    dec dword ptr [Y]
    _Sc2X32_1152x864_NEXTLINE_:
    mov ECX,PILI
    _Sc2X32_1152x864_NEXTPOINT_:
    lodsd
    mov EBX,[ESI-OLIA]
    mov EDX,[ESI]
    cmp EBX,[ESI+OLIS]
    je _Sc2X32_1152x864_BEHODEF_
    cmp [ESI-TPI],EDX
    je _Sc2X32_1152x864_BEHODEF_
    cmp EBX,[ESI-TPI]
    je _Sc2X32_1152x864_NOCHGE0_
    mov EBX,EAX
    _Sc2X32_1152x864_NOCHGE0_:
    mov [EDI],EBX
    cmp [ESI-OLIA],EDX
    je _Sc2X32_1152x864_NOCHGE1_
    mov EDX,EAX
    _Sc2X32_1152x864_NOCHGE1_:
    mov [EDI+OPI],EDX
    mov EBX,[ESI-TPI]
    mov EDX,[ESI+OLIS]
    cmp EBX,EDX
    je _Sc2X32_1152x864_NOCHGE2_
    mov EBX,EAX
    _Sc2X32_1152x864_NOCHGE2_:
    mov [EDI+TLI],EBX
    cmp EDX,[ESI]
    je _Sc2X32_1152x864_NOCHGE3_
    mov EDX,EAX
    _Sc2X32_1152x864_NOCHGE3_:
    mov [EDI+TLIA],EDX
    add EDI,TPI
    dec ECX
    jnz _Sc2X32_1152x864_NEXTPOINT_
    add EDI,TLI
    dec dword ptr [Y]
    jnz _Sc2X32_1152x864_NEXTLINE_
    jmp _Sc2X32_1152x864_FINALEND_
    _Sc2X32_1152x864_BEHODEF_:
    stosd
    stosd
    mov [EDI+TLISS],EAX
    mov [EDI+TLIS],EAX
    dec ECX
    jnz _Sc2X32_1152x864_NEXTPOINT_
    add EDI,TLI
    dec dword ptr [Y]
    jnz _Sc2X32_1152x864_NEXTLINE_
    _Sc2X32_1152x864_FINALEND_:
  end asm  
end sub


Private Sub raw_Scale2X_1280x720_16 (Byval PTORG as any ptr, Byval PTDST as any ptr)
  static as integer Y  
  Y = SC2X_Y_1280x720
  
  #define ESZ 2  
  
  const PILI = SC2X_X_1280x720
  const PILIS = SC2X_X_1280x720-1
  const OPI = ESZ
  const TPI = ESZ*2  
  const OLIS = (SC2X_X_1280x720-1)*ESZ
  const OLIA = (SC2X_X_1280x720+1)*ESZ
  const TLISS = ((SC2X_X_1280x720*2)-2)*ESZ
  const TLIS = ((SC2X_X_1280x720*2)-1)*ESZ
  const TLI = ((SC2X_X_1280x720*2))*ESZ
  const TLIA = ((SC2X_X_1280x720*2)+1)*ESZ
  
  asm        
    mov ESI,[PTORG]
    mov EDI,[PTDST]
    lodsw
    stosw
    stosw
    mov [EDI+TLISS],AX
    mov [EDI+TLIS],AX
    mov ECX,PILIS
    _Sc2X16_1280x720_FLNEXTPOINT_:
    lodsw
    mov BX,[ESI]
    mov DX,[ESI]
    cmp BX,[ESI+OLIS]
    je _Sc2X16_1280x720_FLBEHODEF_
    cmp [ESI-TPI],DX
    je _Sc2X16_1280x720_FLBEHODEF_
    cmp BX,[ESI-TPI]
    je _Sc2X16_1280x720_FLNOCHGE0_
    mov BX,AX
    _Sc2X16_1280x720_FLNOCHGE0_:
    mov [EDI],BX
    cmp [ESI],DX
    je _Sc2X16_1280x720_FLNOCHGE1_
    mov DX,AX
    _Sc2X16_1280x720_FLNOCHGE1_:
    mov [EDI+OPI],DX
    mov BX,[ESI-TPI]
    mov DX,[ESI+OLIS]
    cmp BX,DX
    je _Sc2X16_1280x720_FLNOCHGE2_
    mov BX,AX
    _Sc2X16_1280x720_FLNOCHGE2_:
    mov [EDI+TLI],BX
    cmp DX,[ESI]
    je _Sc2X16_1280x720_FLNOCHGE3_
    mov DX,AX
    _Sc2X16_1280x720_FLNOCHGE3_:
    mov [EDI+TLIA],DX
    add EDI,TPI
    dec ECX
    jnz _Sc2X16_1280x720_FLNEXTPOINT_
    add EDI,TLI
    dec dword ptr [Y]
    jnz _Sc2X16_1280x720_NEXTLINE_
    _Sc2X16_1280x720_FLBEHODEF_:
    stosw
    stosw
    mov [EDI+TLISS],AX
    mov [EDI+TLIS],AX
    dec ECX
    jnz _Sc2X16_1280x720_FLNEXTPOINT_
    add EDI,TLI
    dec dword ptr [Y]
    _Sc2X16_1280x720_NEXTLINE_:
    mov ECX,PILI
    _Sc2X16_1280x720_NEXTPOINT_:
    lodsw
    mov BX,[ESI-OLIA]
    mov DX,[ESI]
    cmp BX,[ESI+OLIS]
    je _Sc2X16_1280x720_BEHODEF_
    cmp [ESI-TPI],DX
    je _Sc2X16_1280x720_BEHODEF_
    cmp BX,[ESI-TPI]
    je _Sc2X16_1280x720_NOCHGE0_
    mov BX,AX
    _Sc2X16_1280x720_NOCHGE0_:
    mov [EDI],BX
    cmp [ESI-OLIA],DX
    je _Sc2X16_1280x720_NOCHGE1_
    mov DX,AX
    _Sc2X16_1280x720_NOCHGE1_:
    mov [EDI+OPI],DX
    mov BX,[ESI-TPI]
    mov DX,[ESI+OLIS]
    cmp BX,DX
    je _Sc2X16_1280x720_NOCHGE2_
    mov BX,AX
    _Sc2X16_1280x720_NOCHGE2_:
    mov [EDI+TLI],BX
    cmp DX,[ESI]
    je _Sc2X16_1280x720_NOCHGE3_
    mov DX,AX
    _Sc2X16_1280x720_NOCHGE3_:
    mov [EDI+TLIA],DX
    add EDI,TPI
    dec ECX
    jnz _Sc2X16_1280x720_NEXTPOINT_
    add EDI,TLI
    dec dword ptr [Y]
    jnz _Sc2X16_1280x720_NEXTLINE_
    jmp _Sc2X16_1280x720_FINALEND_
    _Sc2X16_1280x720_BEHODEF_:
    stosw
    stosw
    mov [EDI+TLISS],AX
    mov [EDI+TLIS],AX
    dec ECX
    jnz _Sc2X16_1280x720_NEXTPOINT_
    add EDI,TLI
    dec dword ptr [Y]
    jnz _Sc2X16_1280x720_NEXTLINE_
    _Sc2X16_1280x720_FINALEND_:
  end asm  
end sub


Private Sub raw_Scale2X_1280x720_32 (Byval PTORG as any ptr, Byval PTDST as any ptr)
  static as integer Y  
  Y = SC2X_Y_1280x720
  
  #define ESZ 4  
  
  const PILI = SC2X_X_1280x720
  const PILIS = SC2X_X_1280x720-1
  const OPI = ESZ
  const TPI = ESZ*2  
  const OLIS = (SC2X_X_1280x720-1)*ESZ
  const OLIA = (SC2X_X_1280x720+1)*ESZ
  const TLISS = ((SC2X_X_1280x720*2)-2)*ESZ
  const TLIS = ((SC2X_X_1280x720*2)-1)*ESZ
  const TLI = ((SC2X_X_1280x720*2))*ESZ
  const TLIA = ((SC2X_X_1280x720*2)+1)*ESZ
  
  asm        
    mov ESI,[PTORG]
    mov EDI,[PTDST]
    lodsd
    stosd
    stosd
    mov [EDI+TLISS],EAX
    mov [EDI+TLIS],EAX
    mov ECX,PILIS
    _Sc2X32_1280x720_FLNEXTPOINT_:
    lodsd
    mov EBX,[ESI]
    mov EDX,[ESI]
    cmp EBX,[ESI+OLIS]
    je _Sc2X32_1280x720_FLBEHODEF_
    cmp [ESI-TPI],EDX
    je _Sc2X32_1280x720_FLBEHODEF_
    cmp EBX,[ESI-TPI]
    je _Sc2X32_1280x720_FLNOCHGE0_
    mov EBX,EAX
    _Sc2X32_1280x720_FLNOCHGE0_:
    mov [EDI],EBX
    cmp [ESI],EDX
    je _Sc2X32_1280x720_FLNOCHGE1_
    mov EDX,EAX
    _Sc2X32_1280x720_FLNOCHGE1_:
    mov [EDI+OPI],EDX
    mov EBX,[ESI-TPI]
    mov EDX,[ESI+OLIS]
    cmp EBX,EDX
    je _Sc2X32_1280x720_FLNOCHGE2_
    mov EBX,EAX
    _Sc2X32_1280x720_FLNOCHGE2_:
    mov [EDI+TLI],EBX
    cmp EDX,[ESI]
    je _Sc2X32_1280x720_FLNOCHGE3_
    mov EDX,EAX
    _Sc2X32_1280x720_FLNOCHGE3_:
    mov [EDI+TLIA],EDX
    add EDI,TPI
    dec ECX
    jnz _Sc2X32_1280x720_FLNEXTPOINT_
    add EDI,TLI
    dec dword ptr [Y]
    jnz _Sc2X32_1280x720_NEXTLINE_
    _Sc2X32_1280x720_FLBEHODEF_:
    stosd
    stosd
    mov [EDI+TLISS],EAX
    mov [EDI+TLIS],EAX
    dec ECX
    jnz _Sc2X32_1280x720_FLNEXTPOINT_
    add EDI,TLI
    dec dword ptr [Y]
    _Sc2X32_1280x720_NEXTLINE_:
    mov ECX,PILI
    _Sc2X32_1280x720_NEXTPOINT_:
    lodsd
    mov EBX,[ESI-OLIA]
    mov EDX,[ESI]
    cmp EBX,[ESI+OLIS]
    je _Sc2X32_1280x720_BEHODEF_
    cmp [ESI-TPI],EDX
    je _Sc2X32_1280x720_BEHODEF_
    cmp EBX,[ESI-TPI]
    je _Sc2X32_1280x720_NOCHGE0_
    mov EBX,EAX
    _Sc2X32_1280x720_NOCHGE0_:
    mov [EDI],EBX
    cmp [ESI-OLIA],EDX
    je _Sc2X32_1280x720_NOCHGE1_
    mov EDX,EAX
    _Sc2X32_1280x720_NOCHGE1_:
    mov [EDI+OPI],EDX
    mov EBX,[ESI-TPI]
    mov EDX,[ESI+OLIS]
    cmp EBX,EDX
    je _Sc2X32_1280x720_NOCHGE2_
    mov EBX,EAX
    _Sc2X32_1280x720_NOCHGE2_:
    mov [EDI+TLI],EBX
    cmp EDX,[ESI]
    je _Sc2X32_1280x720_NOCHGE3_
    mov EDX,EAX
    _Sc2X32_1280x720_NOCHGE3_:
    mov [EDI+TLIA],EDX
    add EDI,TPI
    dec ECX
    jnz _Sc2X32_1280x720_NEXTPOINT_
    add EDI,TLI
    dec dword ptr [Y]
    jnz _Sc2X32_1280x720_NEXTLINE_
    jmp _Sc2X32_1280x720_FINALEND_
    _Sc2X32_1280x720_BEHODEF_:
    stosd
    stosd
    mov [EDI+TLISS],EAX
    mov [EDI+TLIS],EAX
    dec ECX
    jnz _Sc2X32_1280x720_NEXTPOINT_
    add EDI,TLI
    dec dword ptr [Y]
    jnz _Sc2X32_1280x720_NEXTLINE_
    _Sc2X32_1280x720_FINALEND_:
  end asm  
end sub


Private Sub raw_Scale2X_1280x768_16 (Byval PTORG as any ptr, Byval PTDST as any ptr)
  static as integer Y  
  Y = SC2X_Y_1280x768
  
  #define ESZ 2  
  
  const PILI = SC2X_X_1280x768
  const PILIS = SC2X_X_1280x768-1
  const OPI = ESZ
  const TPI = ESZ*2  
  const OLIS = (SC2X_X_1280x768-1)*ESZ
  const OLIA = (SC2X_X_1280x768+1)*ESZ
  const TLISS = ((SC2X_X_1280x768*2)-2)*ESZ
  const TLIS = ((SC2X_X_1280x768*2)-1)*ESZ
  const TLI = ((SC2X_X_1280x768*2))*ESZ
  const TLIA = ((SC2X_X_1280x768*2)+1)*ESZ
  
  asm        
    mov ESI,[PTORG]
    mov EDI,[PTDST]
    lodsw
    stosw
    stosw
    mov [EDI+TLISS],AX
    mov [EDI+TLIS],AX
    mov ECX,PILIS
    _Sc2X16_1280x768_FLNEXTPOINT_:
    lodsw
    mov BX,[ESI]
    mov DX,[ESI]
    cmp BX,[ESI+OLIS]
    je _Sc2X16_1280x768_FLBEHODEF_
    cmp [ESI-TPI],DX
    je _Sc2X16_1280x768_FLBEHODEF_
    cmp BX,[ESI-TPI]
    je _Sc2X16_1280x768_FLNOCHGE0_
    mov BX,AX
    _Sc2X16_1280x768_FLNOCHGE0_:
    mov [EDI],BX
    cmp [ESI],DX
    je _Sc2X16_1280x768_FLNOCHGE1_
    mov DX,AX
    _Sc2X16_1280x768_FLNOCHGE1_:
    mov [EDI+OPI],DX
    mov BX,[ESI-TPI]
    mov DX,[ESI+OLIS]
    cmp BX,DX
    je _Sc2X16_1280x768_FLNOCHGE2_
    mov BX,AX
    _Sc2X16_1280x768_FLNOCHGE2_:
    mov [EDI+TLI],BX
    cmp DX,[ESI]
    je _Sc2X16_1280x768_FLNOCHGE3_
    mov DX,AX
    _Sc2X16_1280x768_FLNOCHGE3_:
    mov [EDI+TLIA],DX
    add EDI,TPI
    dec ECX
    jnz _Sc2X16_1280x768_FLNEXTPOINT_
    add EDI,TLI
    dec dword ptr [Y]
    jnz _Sc2X16_1280x768_NEXTLINE_
    _Sc2X16_1280x768_FLBEHODEF_:
    stosw
    stosw
    mov [EDI+TLISS],AX
    mov [EDI+TLIS],AX
    dec ECX
    jnz _Sc2X16_1280x768_FLNEXTPOINT_
    add EDI,TLI
    dec dword ptr [Y]
    _Sc2X16_1280x768_NEXTLINE_:
    mov ECX,PILI
    _Sc2X16_1280x768_NEXTPOINT_:
    lodsw
    mov BX,[ESI-OLIA]
    mov DX,[ESI]
    cmp BX,[ESI+OLIS]
    je _Sc2X16_1280x768_BEHODEF_
    cmp [ESI-TPI],DX
    je _Sc2X16_1280x768_BEHODEF_
    cmp BX,[ESI-TPI]
    je _Sc2X16_1280x768_NOCHGE0_
    mov BX,AX
    _Sc2X16_1280x768_NOCHGE0_:
    mov [EDI],BX
    cmp [ESI-OLIA],DX
    je _Sc2X16_1280x768_NOCHGE1_
    mov DX,AX
    _Sc2X16_1280x768_NOCHGE1_:
    mov [EDI+OPI],DX
    mov BX,[ESI-TPI]
    mov DX,[ESI+OLIS]
    cmp BX,DX
    je _Sc2X16_1280x768_NOCHGE2_
    mov BX,AX
    _Sc2X16_1280x768_NOCHGE2_:
    mov [EDI+TLI],BX
    cmp DX,[ESI]
    je _Sc2X16_1280x768_NOCHGE3_
    mov DX,AX
    _Sc2X16_1280x768_NOCHGE3_:
    mov [EDI+TLIA],DX
    add EDI,TPI
    dec ECX
    jnz _Sc2X16_1280x768_NEXTPOINT_
    add EDI,TLI
    dec dword ptr [Y]
    jnz _Sc2X16_1280x768_NEXTLINE_
    jmp _Sc2X16_1280x768_FINALEND_
    _Sc2X16_1280x768_BEHODEF_:
    stosw
    stosw
    mov [EDI+TLISS],AX
    mov [EDI+TLIS],AX
    dec ECX
    jnz _Sc2X16_1280x768_NEXTPOINT_
    add EDI,TLI
    dec dword ptr [Y]
    jnz _Sc2X16_1280x768_NEXTLINE_
    _Sc2X16_1280x768_FINALEND_:
  end asm  
end sub


Private Sub raw_Scale2X_1280x768_32 (Byval PTORG as any ptr, Byval PTDST as any ptr)
  static as integer Y  
  Y = SC2X_Y_1280x768
  
  #define ESZ 4  
  
  const PILI = SC2X_X_1280x768
  const PILIS = SC2X_X_1280x768-1
  const OPI = ESZ
  const TPI = ESZ*2  
  const OLIS = (SC2X_X_1280x768-1)*ESZ
  const OLIA = (SC2X_X_1280x768+1)*ESZ
  const TLISS = ((SC2X_X_1280x768*2)-2)*ESZ
  const TLIS = ((SC2X_X_1280x768*2)-1)*ESZ
  const TLI = ((SC2X_X_1280x768*2))*ESZ
  const TLIA = ((SC2X_X_1280x768*2)+1)*ESZ
  
  asm        
    mov ESI,[PTORG]
    mov EDI,[PTDST]
    lodsd
    stosd
    stosd
    mov [EDI+TLISS],EAX
    mov [EDI+TLIS],EAX
    mov ECX,PILIS
    _Sc2X32_1280x768_FLNEXTPOINT_:
    lodsd
    mov EBX,[ESI]
    mov EDX,[ESI]
    cmp EBX,[ESI+OLIS]
    je _Sc2X32_1280x768_FLBEHODEF_
    cmp [ESI-TPI],EDX
    je _Sc2X32_1280x768_FLBEHODEF_
    cmp EBX,[ESI-TPI]
    je _Sc2X32_1280x768_FLNOCHGE0_
    mov EBX,EAX
    _Sc2X32_1280x768_FLNOCHGE0_:
    mov [EDI],EBX
    cmp [ESI],EDX
    je _Sc2X32_1280x768_FLNOCHGE1_
    mov EDX,EAX
    _Sc2X32_1280x768_FLNOCHGE1_:
    mov [EDI+OPI],EDX
    mov EBX,[ESI-TPI]
    mov EDX,[ESI+OLIS]
    cmp EBX,EDX
    je _Sc2X32_1280x768_FLNOCHGE2_
    mov EBX,EAX
    _Sc2X32_1280x768_FLNOCHGE2_:
    mov [EDI+TLI],EBX
    cmp EDX,[ESI]
    je _Sc2X32_1280x768_FLNOCHGE3_
    mov EDX,EAX
    _Sc2X32_1280x768_FLNOCHGE3_:
    mov [EDI+TLIA],EDX
    add EDI,TPI
    dec ECX
    jnz _Sc2X32_1280x768_FLNEXTPOINT_
    add EDI,TLI
    dec dword ptr [Y]
    jnz _Sc2X32_1280x768_NEXTLINE_
    _Sc2X32_1280x768_FLBEHODEF_:
    stosd
    stosd
    mov [EDI+TLISS],EAX
    mov [EDI+TLIS],EAX
    dec ECX
    jnz _Sc2X32_1280x768_FLNEXTPOINT_
    add EDI,TLI
    dec dword ptr [Y]
    _Sc2X32_1280x768_NEXTLINE_:
    mov ECX,PILI
    _Sc2X32_1280x768_NEXTPOINT_:
    lodsd
    mov EBX,[ESI-OLIA]
    mov EDX,[ESI]
    cmp EBX,[ESI+OLIS]
    je _Sc2X32_1280x768_BEHODEF_
    cmp [ESI-TPI],EDX
    je _Sc2X32_1280x768_BEHODEF_
    cmp EBX,[ESI-TPI]
    je _Sc2X32_1280x768_NOCHGE0_
    mov EBX,EAX
    _Sc2X32_1280x768_NOCHGE0_:
    mov [EDI],EBX
    cmp [ESI-OLIA],EDX
    je _Sc2X32_1280x768_NOCHGE1_
    mov EDX,EAX
    _Sc2X32_1280x768_NOCHGE1_:
    mov [EDI+OPI],EDX
    mov EBX,[ESI-TPI]
    mov EDX,[ESI+OLIS]
    cmp EBX,EDX
    je _Sc2X32_1280x768_NOCHGE2_
    mov EBX,EAX
    _Sc2X32_1280x768_NOCHGE2_:
    mov [EDI+TLI],EBX
    cmp EDX,[ESI]
    je _Sc2X32_1280x768_NOCHGE3_
    mov EDX,EAX
    _Sc2X32_1280x768_NOCHGE3_:
    mov [EDI+TLIA],EDX
    add EDI,TPI
    dec ECX
    jnz _Sc2X32_1280x768_NEXTPOINT_
    add EDI,TLI
    dec dword ptr [Y]
    jnz _Sc2X32_1280x768_NEXTLINE_
    jmp _Sc2X32_1280x768_FINALEND_
    _Sc2X32_1280x768_BEHODEF_:
    stosd
    stosd
    mov [EDI+TLISS],EAX
    mov [EDI+TLIS],EAX
    dec ECX
    jnz _Sc2X32_1280x768_NEXTPOINT_
    add EDI,TLI
    dec dword ptr [Y]
    jnz _Sc2X32_1280x768_NEXTLINE_
    _Sc2X32_1280x768_FINALEND_:
  end asm  
end sub


Private Sub raw_Scale2X_1280x800_16 (Byval PTORG as any ptr, Byval PTDST as any ptr)
  static as integer Y  
  Y = SC2X_Y_1280x800
  
  #define ESZ 2  
  
  const PILI = SC2X_X_1280x800
  const PILIS = SC2X_X_1280x800-1
  const OPI = ESZ
  const TPI = ESZ*2  
  const OLIS = (SC2X_X_1280x800-1)*ESZ
  const OLIA = (SC2X_X_1280x800+1)*ESZ
  const TLISS = ((SC2X_X_1280x800*2)-2)*ESZ
  const TLIS = ((SC2X_X_1280x800*2)-1)*ESZ
  const TLI = ((SC2X_X_1280x800*2))*ESZ
  const TLIA = ((SC2X_X_1280x800*2)+1)*ESZ
  
  asm        
    mov ESI,[PTORG]
    mov EDI,[PTDST]
    lodsw
    stosw
    stosw
    mov [EDI+TLISS],AX
    mov [EDI+TLIS],AX
    mov ECX,PILIS
    _Sc2X16_1280x800_FLNEXTPOINT_:
    lodsw
    mov BX,[ESI]
    mov DX,[ESI]
    cmp BX,[ESI+OLIS]
    je _Sc2X16_1280x800_FLBEHODEF_
    cmp [ESI-TPI],DX
    je _Sc2X16_1280x800_FLBEHODEF_
    cmp BX,[ESI-TPI]
    je _Sc2X16_1280x800_FLNOCHGE0_
    mov BX,AX
    _Sc2X16_1280x800_FLNOCHGE0_:
    mov [EDI],BX
    cmp [ESI],DX
    je _Sc2X16_1280x800_FLNOCHGE1_
    mov DX,AX
    _Sc2X16_1280x800_FLNOCHGE1_:
    mov [EDI+OPI],DX
    mov BX,[ESI-TPI]
    mov DX,[ESI+OLIS]
    cmp BX,DX
    je _Sc2X16_1280x800_FLNOCHGE2_
    mov BX,AX
    _Sc2X16_1280x800_FLNOCHGE2_:
    mov [EDI+TLI],BX
    cmp DX,[ESI]
    je _Sc2X16_1280x800_FLNOCHGE3_
    mov DX,AX
    _Sc2X16_1280x800_FLNOCHGE3_:
    mov [EDI+TLIA],DX
    add EDI,TPI
    dec ECX
    jnz _Sc2X16_1280x800_FLNEXTPOINT_
    add EDI,TLI
    dec dword ptr [Y]
    jnz _Sc2X16_1280x800_NEXTLINE_
    _Sc2X16_1280x800_FLBEHODEF_:
    stosw
    stosw
    mov [EDI+TLISS],AX
    mov [EDI+TLIS],AX
    dec ECX
    jnz _Sc2X16_1280x800_FLNEXTPOINT_
    add EDI,TLI
    dec dword ptr [Y]
    _Sc2X16_1280x800_NEXTLINE_:
    mov ECX,PILI
    _Sc2X16_1280x800_NEXTPOINT_:
    lodsw
    mov BX,[ESI-OLIA]
    mov DX,[ESI]
    cmp BX,[ESI+OLIS]
    je _Sc2X16_1280x800_BEHODEF_
    cmp [ESI-TPI],DX
    je _Sc2X16_1280x800_BEHODEF_
    cmp BX,[ESI-TPI]
    je _Sc2X16_1280x800_NOCHGE0_
    mov BX,AX
    _Sc2X16_1280x800_NOCHGE0_:
    mov [EDI],BX
    cmp [ESI-OLIA],DX
    je _Sc2X16_1280x800_NOCHGE1_
    mov DX,AX
    _Sc2X16_1280x800_NOCHGE1_:
    mov [EDI+OPI],DX
    mov BX,[ESI-TPI]
    mov DX,[ESI+OLIS]
    cmp BX,DX
    je _Sc2X16_1280x800_NOCHGE2_
    mov BX,AX
    _Sc2X16_1280x800_NOCHGE2_:
    mov [EDI+TLI],BX
    cmp DX,[ESI]
    je _Sc2X16_1280x800_NOCHGE3_
    mov DX,AX
    _Sc2X16_1280x800_NOCHGE3_:
    mov [EDI+TLIA],DX
    add EDI,TPI
    dec ECX
    jnz _Sc2X16_1280x800_NEXTPOINT_
    add EDI,TLI
    dec dword ptr [Y]
    jnz _Sc2X16_1280x800_NEXTLINE_
    jmp _Sc2X16_1280x800_FINALEND_
    _Sc2X16_1280x800_BEHODEF_:
    stosw
    stosw
    mov [EDI+TLISS],AX
    mov [EDI+TLIS],AX
    dec ECX
    jnz _Sc2X16_1280x800_NEXTPOINT_
    add EDI,TLI
    dec dword ptr [Y]
    jnz _Sc2X16_1280x800_NEXTLINE_
    _Sc2X16_1280x800_FINALEND_:
  end asm  
end sub


Private Sub raw_Scale2X_1280x800_32 (Byval PTORG as any ptr, Byval PTDST as any ptr)
  static as integer Y  
  Y = SC2X_Y_1280x800
  
  #define ESZ 4  
  
  const PILI = SC2X_X_1280x800
  const PILIS = SC2X_X_1280x800-1
  const OPI = ESZ
  const TPI = ESZ*2  
  const OLIS = (SC2X_X_1280x800-1)*ESZ
  const OLIA = (SC2X_X_1280x800+1)*ESZ
  const TLISS = ((SC2X_X_1280x800*2)-2)*ESZ
  const TLIS = ((SC2X_X_1280x800*2)-1)*ESZ
  const TLI = ((SC2X_X_1280x800*2))*ESZ
  const TLIA = ((SC2X_X_1280x800*2)+1)*ESZ
  
  asm        
    mov ESI,[PTORG]
    mov EDI,[PTDST]
    lodsd
    stosd
    stosd
    mov [EDI+TLISS],EAX
    mov [EDI+TLIS],EAX
    mov ECX,PILIS
    _Sc2X32_1280x800_FLNEXTPOINT_:
    lodsd
    mov EBX,[ESI]
    mov EDX,[ESI]
    cmp EBX,[ESI+OLIS]
    je _Sc2X32_1280x800_FLBEHODEF_
    cmp [ESI-TPI],EDX
    je _Sc2X32_1280x800_FLBEHODEF_
    cmp EBX,[ESI-TPI]
    je _Sc2X32_1280x800_FLNOCHGE0_
    mov EBX,EAX
    _Sc2X32_1280x800_FLNOCHGE0_:
    mov [EDI],EBX
    cmp [ESI],EDX
    je _Sc2X32_1280x800_FLNOCHGE1_
    mov EDX,EAX
    _Sc2X32_1280x800_FLNOCHGE1_:
    mov [EDI+OPI],EDX
    mov EBX,[ESI-TPI]
    mov EDX,[ESI+OLIS]
    cmp EBX,EDX
    je _Sc2X32_1280x800_FLNOCHGE2_
    mov EBX,EAX
    _Sc2X32_1280x800_FLNOCHGE2_:
    mov [EDI+TLI],EBX
    cmp EDX,[ESI]
    je _Sc2X32_1280x800_FLNOCHGE3_
    mov EDX,EAX
    _Sc2X32_1280x800_FLNOCHGE3_:
    mov [EDI+TLIA],EDX
    add EDI,TPI
    dec ECX
    jnz _Sc2X32_1280x800_FLNEXTPOINT_
    add EDI,TLI
    dec dword ptr [Y]
    jnz _Sc2X32_1280x800_NEXTLINE_
    _Sc2X32_1280x800_FLBEHODEF_:
    stosd
    stosd
    mov [EDI+TLISS],EAX
    mov [EDI+TLIS],EAX
    dec ECX
    jnz _Sc2X32_1280x800_FLNEXTPOINT_
    add EDI,TLI
    dec dword ptr [Y]
    _Sc2X32_1280x800_NEXTLINE_:
    mov ECX,PILI
    _Sc2X32_1280x800_NEXTPOINT_:
    lodsd
    mov EBX,[ESI-OLIA]
    mov EDX,[ESI]
    cmp EBX,[ESI+OLIS]
    je _Sc2X32_1280x800_BEHODEF_
    cmp [ESI-TPI],EDX
    je _Sc2X32_1280x800_BEHODEF_
    cmp EBX,[ESI-TPI]
    je _Sc2X32_1280x800_NOCHGE0_
    mov EBX,EAX
    _Sc2X32_1280x800_NOCHGE0_:
    mov [EDI],EBX
    cmp [ESI-OLIA],EDX
    je _Sc2X32_1280x800_NOCHGE1_
    mov EDX,EAX
    _Sc2X32_1280x800_NOCHGE1_:
    mov [EDI+OPI],EDX
    mov EBX,[ESI-TPI]
    mov EDX,[ESI+OLIS]
    cmp EBX,EDX
    je _Sc2X32_1280x800_NOCHGE2_
    mov EBX,EAX
    _Sc2X32_1280x800_NOCHGE2_:
    mov [EDI+TLI],EBX
    cmp EDX,[ESI]
    je _Sc2X32_1280x800_NOCHGE3_
    mov EDX,EAX
    _Sc2X32_1280x800_NOCHGE3_:
    mov [EDI+TLIA],EDX
    add EDI,TPI
    dec ECX
    jnz _Sc2X32_1280x800_NEXTPOINT_
    add EDI,TLI
    dec dword ptr [Y]
    jnz _Sc2X32_1280x800_NEXTLINE_
    jmp _Sc2X32_1280x800_FINALEND_
    _Sc2X32_1280x800_BEHODEF_:
    stosd
    stosd
    mov [EDI+TLISS],EAX
    mov [EDI+TLIS],EAX
    dec ECX
    jnz _Sc2X32_1280x800_NEXTPOINT_
    add EDI,TLI
    dec dword ptr [Y]
    jnz _Sc2X32_1280x800_NEXTLINE_
    _Sc2X32_1280x800_FINALEND_:
  end asm  
end sub


Private Sub raw_Scale2X_1280x960_16 (Byval PTORG as any ptr, Byval PTDST as any ptr)
  static as integer Y  
  Y = SC2X_Y_1280x960
  
  #define ESZ 2  
  
  const PILI = SC2X_X_1280x960
  const PILIS = SC2X_X_1280x960-1
  const OPI = ESZ
  const TPI = ESZ*2  
  const OLIS = (SC2X_X_1280x960-1)*ESZ
  const OLIA = (SC2X_X_1280x960+1)*ESZ
  const TLISS = ((SC2X_X_1280x960*2)-2)*ESZ
  const TLIS = ((SC2X_X_1280x960*2)-1)*ESZ
  const TLI = ((SC2X_X_1280x960*2))*ESZ
  const TLIA = ((SC2X_X_1280x960*2)+1)*ESZ
  
  asm        
    mov ESI,[PTORG]
    mov EDI,[PTDST]
    lodsw
    stosw
    stosw
    mov [EDI+TLISS],AX
    mov [EDI+TLIS],AX
    mov ECX,PILIS
    _Sc2X16_1280x960_FLNEXTPOINT_:
    lodsw
    mov BX,[ESI]
    mov DX,[ESI]
    cmp BX,[ESI+OLIS]
    je _Sc2X16_1280x960_FLBEHODEF_
    cmp [ESI-TPI],DX
    je _Sc2X16_1280x960_FLBEHODEF_
    cmp BX,[ESI-TPI]
    je _Sc2X16_1280x960_FLNOCHGE0_
    mov BX,AX
    _Sc2X16_1280x960_FLNOCHGE0_:
    mov [EDI],BX
    cmp [ESI],DX
    je _Sc2X16_1280x960_FLNOCHGE1_
    mov DX,AX
    _Sc2X16_1280x960_FLNOCHGE1_:
    mov [EDI+OPI],DX
    mov BX,[ESI-TPI]
    mov DX,[ESI+OLIS]
    cmp BX,DX
    je _Sc2X16_1280x960_FLNOCHGE2_
    mov BX,AX
    _Sc2X16_1280x960_FLNOCHGE2_:
    mov [EDI+TLI],BX
    cmp DX,[ESI]
    je _Sc2X16_1280x960_FLNOCHGE3_
    mov DX,AX
    _Sc2X16_1280x960_FLNOCHGE3_:
    mov [EDI+TLIA],DX
    add EDI,TPI
    dec ECX
    jnz _Sc2X16_1280x960_FLNEXTPOINT_
    add EDI,TLI
    dec dword ptr [Y]
    jnz _Sc2X16_1280x960_NEXTLINE_
    _Sc2X16_1280x960_FLBEHODEF_:
    stosw
    stosw
    mov [EDI+TLISS],AX
    mov [EDI+TLIS],AX
    dec ECX
    jnz _Sc2X16_1280x960_FLNEXTPOINT_
    add EDI,TLI
    dec dword ptr [Y]
    _Sc2X16_1280x960_NEXTLINE_:
    mov ECX,PILI
    _Sc2X16_1280x960_NEXTPOINT_:
    lodsw
    mov BX,[ESI-OLIA]
    mov DX,[ESI]
    cmp BX,[ESI+OLIS]
    je _Sc2X16_1280x960_BEHODEF_
    cmp [ESI-TPI],DX
    je _Sc2X16_1280x960_BEHODEF_
    cmp BX,[ESI-TPI]
    je _Sc2X16_1280x960_NOCHGE0_
    mov BX,AX
    _Sc2X16_1280x960_NOCHGE0_:
    mov [EDI],BX
    cmp [ESI-OLIA],DX
    je _Sc2X16_1280x960_NOCHGE1_
    mov DX,AX
    _Sc2X16_1280x960_NOCHGE1_:
    mov [EDI+OPI],DX
    mov BX,[ESI-TPI]
    mov DX,[ESI+OLIS]
    cmp BX,DX
    je _Sc2X16_1280x960_NOCHGE2_
    mov BX,AX
    _Sc2X16_1280x960_NOCHGE2_:
    mov [EDI+TLI],BX
    cmp DX,[ESI]
    je _Sc2X16_1280x960_NOCHGE3_
    mov DX,AX
    _Sc2X16_1280x960_NOCHGE3_:
    mov [EDI+TLIA],DX
    add EDI,TPI
    dec ECX
    jnz _Sc2X16_1280x960_NEXTPOINT_
    add EDI,TLI
    dec dword ptr [Y]
    jnz _Sc2X16_1280x960_NEXTLINE_
    jmp _Sc2X16_1280x960_FINALEND_
    _Sc2X16_1280x960_BEHODEF_:
    stosw
    stosw
    mov [EDI+TLISS],AX
    mov [EDI+TLIS],AX
    dec ECX
    jnz _Sc2X16_1280x960_NEXTPOINT_
    add EDI,TLI
    dec dword ptr [Y]
    jnz _Sc2X16_1280x960_NEXTLINE_
    _Sc2X16_1280x960_FINALEND_:
  end asm  
end sub


Private Sub raw_Scale2X_1280x960_32 (Byval PTORG as any ptr, Byval PTDST as any ptr)
  static as integer Y  
  Y = SC2X_Y_1280x960
  
  #define ESZ 4  
  
  const PILI = SC2X_X_1280x960
  const PILIS = SC2X_X_1280x960-1
  const OPI = ESZ
  const TPI = ESZ*2  
  const OLIS = (SC2X_X_1280x960-1)*ESZ
  const OLIA = (SC2X_X_1280x960+1)*ESZ
  const TLISS = ((SC2X_X_1280x960*2)-2)*ESZ
  const TLIS = ((SC2X_X_1280x960*2)-1)*ESZ
  const TLI = ((SC2X_X_1280x960*2))*ESZ
  const TLIA = ((SC2X_X_1280x960*2)+1)*ESZ
  
  asm        
    mov ESI,[PTORG]
    mov EDI,[PTDST]
    lodsd
    stosd
    stosd
    mov [EDI+TLISS],EAX
    mov [EDI+TLIS],EAX
    mov ECX,PILIS
    _Sc2X32_1280x960_FLNEXTPOINT_:
    lodsd
    mov EBX,[ESI]
    mov EDX,[ESI]
    cmp EBX,[ESI+OLIS]
    je _Sc2X32_1280x960_FLBEHODEF_
    cmp [ESI-TPI],EDX
    je _Sc2X32_1280x960_FLBEHODEF_
    cmp EBX,[ESI-TPI]
    je _Sc2X32_1280x960_FLNOCHGE0_
    mov EBX,EAX
    _Sc2X32_1280x960_FLNOCHGE0_:
    mov [EDI],EBX
    cmp [ESI],EDX
    je _Sc2X32_1280x960_FLNOCHGE1_
    mov EDX,EAX
    _Sc2X32_1280x960_FLNOCHGE1_:
    mov [EDI+OPI],EDX
    mov EBX,[ESI-TPI]
    mov EDX,[ESI+OLIS]
    cmp EBX,EDX
    je _Sc2X32_1280x960_FLNOCHGE2_
    mov EBX,EAX
    _Sc2X32_1280x960_FLNOCHGE2_:
    mov [EDI+TLI],EBX
    cmp EDX,[ESI]
    je _Sc2X32_1280x960_FLNOCHGE3_
    mov EDX,EAX
    _Sc2X32_1280x960_FLNOCHGE3_:
    mov [EDI+TLIA],EDX
    add EDI,TPI
    dec ECX
    jnz _Sc2X32_1280x960_FLNEXTPOINT_
    add EDI,TLI
    dec dword ptr [Y]
    jnz _Sc2X32_1280x960_NEXTLINE_
    _Sc2X32_1280x960_FLBEHODEF_:
    stosd
    stosd
    mov [EDI+TLISS],EAX
    mov [EDI+TLIS],EAX
    dec ECX
    jnz _Sc2X32_1280x960_FLNEXTPOINT_
    add EDI,TLI
    dec dword ptr [Y]
    _Sc2X32_1280x960_NEXTLINE_:
    mov ECX,PILI
    _Sc2X32_1280x960_NEXTPOINT_:
    lodsd
    mov EBX,[ESI-OLIA]
    mov EDX,[ESI]
    cmp EBX,[ESI+OLIS]
    je _Sc2X32_1280x960_BEHODEF_
    cmp [ESI-TPI],EDX
    je _Sc2X32_1280x960_BEHODEF_
    cmp EBX,[ESI-TPI]
    je _Sc2X32_1280x960_NOCHGE0_
    mov EBX,EAX
    _Sc2X32_1280x960_NOCHGE0_:
    mov [EDI],EBX
    cmp [ESI-OLIA],EDX
    je _Sc2X32_1280x960_NOCHGE1_
    mov EDX,EAX
    _Sc2X32_1280x960_NOCHGE1_:
    mov [EDI+OPI],EDX
    mov EBX,[ESI-TPI]
    mov EDX,[ESI+OLIS]
    cmp EBX,EDX
    je _Sc2X32_1280x960_NOCHGE2_
    mov EBX,EAX
    _Sc2X32_1280x960_NOCHGE2_:
    mov [EDI+TLI],EBX
    cmp EDX,[ESI]
    je _Sc2X32_1280x960_NOCHGE3_
    mov EDX,EAX
    _Sc2X32_1280x960_NOCHGE3_:
    mov [EDI+TLIA],EDX
    add EDI,TPI
    dec ECX
    jnz _Sc2X32_1280x960_NEXTPOINT_
    add EDI,TLI
    dec dword ptr [Y]
    jnz _Sc2X32_1280x960_NEXTLINE_
    jmp _Sc2X32_1280x960_FINALEND_
    _Sc2X32_1280x960_BEHODEF_:
    stosd
    stosd
    mov [EDI+TLISS],EAX
    mov [EDI+TLIS],EAX
    dec ECX
    jnz _Sc2X32_1280x960_NEXTPOINT_
    add EDI,TLI
    dec dword ptr [Y]
    jnz _Sc2X32_1280x960_NEXTLINE_
    _Sc2X32_1280x960_FINALEND_:
  end asm  
end sub


Private Sub raw_Scale2X_1280x1024_16 (Byval PTORG as any ptr, Byval PTDST as any ptr)
  static as integer Y  
  Y = SC2X_Y_1280x1024
  
  #define ESZ 2  
  
  const PILI = SC2X_X_1280x1024
  const PILIS = SC2X_X_1280x1024-1
  const OPI = ESZ
  const TPI = ESZ*2  
  const OLIS = (SC2X_X_1280x1024-1)*ESZ
  const OLIA = (SC2X_X_1280x1024+1)*ESZ
  const TLISS = ((SC2X_X_1280x1024*2)-2)*ESZ
  const TLIS = ((SC2X_X_1280x1024*2)-1)*ESZ
  const TLI = ((SC2X_X_1280x1024*2))*ESZ
  const TLIA = ((SC2X_X_1280x1024*2)+1)*ESZ
  
  asm        
    mov ESI,[PTORG]
    mov EDI,[PTDST]
    lodsw
    stosw
    stosw
    mov [EDI+TLISS],AX
    mov [EDI+TLIS],AX
    mov ECX,PILIS
    _Sc2X16_1280x1024_FLNEXTPOINT_:
    lodsw
    mov BX,[ESI]
    mov DX,[ESI]
    cmp BX,[ESI+OLIS]
    je _Sc2X16_1280x1024_FLBEHODEF_
    cmp [ESI-TPI],DX
    je _Sc2X16_1280x1024_FLBEHODEF_
    cmp BX,[ESI-TPI]
    je _Sc2X16_1280x1024_FLNOCHGE0_
    mov BX,AX
    _Sc2X16_1280x1024_FLNOCHGE0_:
    mov [EDI],BX
    cmp [ESI],DX
    je _Sc2X16_1280x1024_FLNOCHGE1_
    mov DX,AX
    _Sc2X16_1280x1024_FLNOCHGE1_:
    mov [EDI+OPI],DX
    mov BX,[ESI-TPI]
    mov DX,[ESI+OLIS]
    cmp BX,DX
    je _Sc2X16_1280x1024_FLNOCHGE2_
    mov BX,AX
    _Sc2X16_1280x1024_FLNOCHGE2_:
    mov [EDI+TLI],BX
    cmp DX,[ESI]
    je _Sc2X16_1280x1024_FLNOCHGE3_
    mov DX,AX
    _Sc2X16_1280x1024_FLNOCHGE3_:
    mov [EDI+TLIA],DX
    add EDI,TPI
    dec ECX
    jnz _Sc2X16_1280x1024_FLNEXTPOINT_
    add EDI,TLI
    dec dword ptr [Y]
    jnz _Sc2X16_1280x1024_NEXTLINE_
    _Sc2X16_1280x1024_FLBEHODEF_:
    stosw
    stosw
    mov [EDI+TLISS],AX
    mov [EDI+TLIS],AX
    dec ECX
    jnz _Sc2X16_1280x1024_FLNEXTPOINT_
    add EDI,TLI
    dec dword ptr [Y]
    _Sc2X16_1280x1024_NEXTLINE_:
    mov ECX,PILI
    _Sc2X16_1280x1024_NEXTPOINT_:
    lodsw
    mov BX,[ESI-OLIA]
    mov DX,[ESI]
    cmp BX,[ESI+OLIS]
    je _Sc2X16_1280x1024_BEHODEF_
    cmp [ESI-TPI],DX
    je _Sc2X16_1280x1024_BEHODEF_
    cmp BX,[ESI-TPI]
    je _Sc2X16_1280x1024_NOCHGE0_
    mov BX,AX
    _Sc2X16_1280x1024_NOCHGE0_:
    mov [EDI],BX
    cmp [ESI-OLIA],DX
    je _Sc2X16_1280x1024_NOCHGE1_
    mov DX,AX
    _Sc2X16_1280x1024_NOCHGE1_:
    mov [EDI+OPI],DX
    mov BX,[ESI-TPI]
    mov DX,[ESI+OLIS]
    cmp BX,DX
    je _Sc2X16_1280x1024_NOCHGE2_
    mov BX,AX
    _Sc2X16_1280x1024_NOCHGE2_:
    mov [EDI+TLI],BX
    cmp DX,[ESI]
    je _Sc2X16_1280x1024_NOCHGE3_
    mov DX,AX
    _Sc2X16_1280x1024_NOCHGE3_:
    mov [EDI+TLIA],DX
    add EDI,TPI
    dec ECX
    jnz _Sc2X16_1280x1024_NEXTPOINT_
    add EDI,TLI
    dec dword ptr [Y]
    jnz _Sc2X16_1280x1024_NEXTLINE_
    jmp _Sc2X16_1280x1024_FINALEND_
    _Sc2X16_1280x1024_BEHODEF_:
    stosw
    stosw
    mov [EDI+TLISS],AX
    mov [EDI+TLIS],AX
    dec ECX
    jnz _Sc2X16_1280x1024_NEXTPOINT_
    add EDI,TLI
    dec dword ptr [Y]
    jnz _Sc2X16_1280x1024_NEXTLINE_
    _Sc2X16_1280x1024_FINALEND_:
  end asm  
end sub


Private Sub raw_Scale2X_1280x1024_32 (Byval PTORG as any ptr, Byval PTDST as any ptr)
  static as integer Y  
  Y = SC2X_Y_1280x1024
  
  #define ESZ 4  
  
  const PILI = SC2X_X_1280x1024
  const PILIS = SC2X_X_1280x1024-1
  const OPI = ESZ
  const TPI = ESZ*2  
  const OLIS = (SC2X_X_1280x1024-1)*ESZ
  const OLIA = (SC2X_X_1280x1024+1)*ESZ
  const TLISS = ((SC2X_X_1280x1024*2)-2)*ESZ
  const TLIS = ((SC2X_X_1280x1024*2)-1)*ESZ
  const TLI = ((SC2X_X_1280x1024*2))*ESZ
  const TLIA = ((SC2X_X_1280x1024*2)+1)*ESZ
  
  asm        
    mov ESI,[PTORG]
    mov EDI,[PTDST]
    lodsd
    stosd
    stosd
    mov [EDI+TLISS],EAX
    mov [EDI+TLIS],EAX
    mov ECX,PILIS
    _Sc2X32_1280x1024_FLNEXTPOINT_:
    lodsd
    mov EBX,[ESI]
    mov EDX,[ESI]
    cmp EBX,[ESI+OLIS]
    je _Sc2X32_1280x1024_FLBEHODEF_
    cmp [ESI-TPI],EDX
    je _Sc2X32_1280x1024_FLBEHODEF_
    cmp EBX,[ESI-TPI]
    je _Sc2X32_1280x1024_FLNOCHGE0_
    mov EBX,EAX
    _Sc2X32_1280x1024_FLNOCHGE0_:
    mov [EDI],EBX
    cmp [ESI],EDX
    je _Sc2X32_1280x1024_FLNOCHGE1_
    mov EDX,EAX
    _Sc2X32_1280x1024_FLNOCHGE1_:
    mov [EDI+OPI],EDX
    mov EBX,[ESI-TPI]
    mov EDX,[ESI+OLIS]
    cmp EBX,EDX
    je _Sc2X32_1280x1024_FLNOCHGE2_
    mov EBX,EAX
    _Sc2X32_1280x1024_FLNOCHGE2_:
    mov [EDI+TLI],EBX
    cmp EDX,[ESI]
    je _Sc2X32_1280x1024_FLNOCHGE3_
    mov EDX,EAX
    _Sc2X32_1280x1024_FLNOCHGE3_:
    mov [EDI+TLIA],EDX
    add EDI,TPI
    dec ECX
    jnz _Sc2X32_1280x1024_FLNEXTPOINT_
    add EDI,TLI
    dec dword ptr [Y]
    jnz _Sc2X32_1280x1024_NEXTLINE_
    _Sc2X32_1280x1024_FLBEHODEF_:
    stosd
    stosd
    mov [EDI+TLISS],EAX
    mov [EDI+TLIS],EAX
    dec ECX
    jnz _Sc2X32_1280x1024_FLNEXTPOINT_
    add EDI,TLI
    dec dword ptr [Y]
    _Sc2X32_1280x1024_NEXTLINE_:
    mov ECX,PILI
    _Sc2X32_1280x1024_NEXTPOINT_:
    lodsd
    mov EBX,[ESI-OLIA]
    mov EDX,[ESI]
    cmp EBX,[ESI+OLIS]
    je _Sc2X32_1280x1024_BEHODEF_
    cmp [ESI-TPI],EDX
    je _Sc2X32_1280x1024_BEHODEF_
    cmp EBX,[ESI-TPI]
    je _Sc2X32_1280x1024_NOCHGE0_
    mov EBX,EAX
    _Sc2X32_1280x1024_NOCHGE0_:
    mov [EDI],EBX
    cmp [ESI-OLIA],EDX
    je _Sc2X32_1280x1024_NOCHGE1_
    mov EDX,EAX
    _Sc2X32_1280x1024_NOCHGE1_:
    mov [EDI+OPI],EDX
    mov EBX,[ESI-TPI]
    mov EDX,[ESI+OLIS]
    cmp EBX,EDX
    je _Sc2X32_1280x1024_NOCHGE2_
    mov EBX,EAX
    _Sc2X32_1280x1024_NOCHGE2_:
    mov [EDI+TLI],EBX
    cmp EDX,[ESI]
    je _Sc2X32_1280x1024_NOCHGE3_
    mov EDX,EAX
    _Sc2X32_1280x1024_NOCHGE3_:
    mov [EDI+TLIA],EDX
    add EDI,TPI
    dec ECX
    jnz _Sc2X32_1280x1024_NEXTPOINT_
    add EDI,TLI
    dec dword ptr [Y]
    jnz _Sc2X32_1280x1024_NEXTLINE_
    jmp _Sc2X32_1280x1024_FINALEND_
    _Sc2X32_1280x1024_BEHODEF_:
    stosd
    stosd
    mov [EDI+TLISS],EAX
    mov [EDI+TLIS],EAX
    dec ECX
    jnz _Sc2X32_1280x1024_NEXTPOINT_
    add EDI,TLI
    dec dword ptr [Y]
    jnz _Sc2X32_1280x1024_NEXTLINE_
    _Sc2X32_1280x1024_FINALEND_:
  end asm  
end sub
