Smaxx refactor of LoadImage to use flags, iphone changes by koda (mostly use of rgba instead of rgb)
authornemo
Thu, 18 Jun 2009 17:48:06 +0000
changeset 2171 8208946331ba
parent 2170 aa77f2a6b4f1
child 2172 80d34c0b9dfe
Smaxx refactor of LoadImage to use flags, iphone changes by koda (mostly use of rgba instead of rgb)
hedgewars/CCHandlers.inc
hedgewars/SDLh.pas
hedgewars/hwengine.dpr
hedgewars/uConsts.pas
hedgewars/uKeys.pas
hedgewars/uLand.pas
hedgewars/uLandObjects.pas
hedgewars/uMisc.pas
hedgewars/uSound.pas
hedgewars/uStore.pas
hedgewars/uWorld.pas
--- a/hedgewars/CCHandlers.inc	Thu Jun 18 17:35:34 2009 +0000
+++ b/hedgewars/CCHandlers.inc	Thu Jun 18 17:48:06 2009 +0000
@@ -473,7 +473,11 @@
               TargetPoint.Y:= putY
               end else
               begin
-              SDL_GetMouseState(@TargetPoint.X, @TargetPoint.Y);
+			  {$IFDEF SDL13}
+              SDL_GetMouseState(0, @TargetPoint.X, @TargetPoint.Y);
+			  {$ELSE}
+			  SDL_GetMouseState(@TargetPoint.X, @TargetPoint.Y);
+			  {$ENDIF}
               dec(TargetPoint.X, WorldDx);
               dec(TargetPoint.Y, WorldDy)
               end;
--- a/hedgewars/SDLh.pas	Thu Jun 18 17:35:34 2009 +0000
+++ b/hedgewars/SDLh.pas	Thu Jun 18 17:48:06 2009 +0000
@@ -266,10 +266,11 @@
 
 {$IFDEF SDL13}
 function  SDL_GetKeyboardState(numkeys: PLongInt): PByteArray; cdecl; external SDLLibName;
+function  SDL_GetMouseState(index: LongInt; x, y: PInteger): Byte; cdecl; external SDLLibName;
 {$ELSE}
 function  SDL_GetKeyState(numkeys: PLongInt): PByteArray; cdecl; external SDLLibName;
+function  SDL_GetMouseState(x, y: PInteger): Byte; cdecl; external SDLLibName;
 {$ENDIF}
-function  SDL_GetMouseState(x, y: PInteger): Byte; cdecl; external SDLLibName;
 function  SDL_GetKeyName(key: Longword): PChar; cdecl; external SDLLibName;
 procedure SDL_WarpMouse(x, y: Word); cdecl; external SDLLibName;
 
--- a/hedgewars/hwengine.dpr	Thu Jun 18 17:35:34 2009 +0000
+++ b/hedgewars/hwengine.dpr	Thu Jun 18 17:48:06 2009 +0000
@@ -118,6 +118,8 @@
 	end;
 
 SDL_GL_SwapBuffers();
+{$IFNDEF IPHONEOS}
+//not going to make captures on the iPhone
 if flagMakeCapture then
 	begin
 	flagMakeCapture:= false;
@@ -126,6 +128,7 @@
 	MakeScreenshot(s);
 //	SDL_SaveBMP_RW(SDLPrimSurface, SDL_RWFromFile(Str2PChar(s), 'wb'), 1)
 	end;
+{$ENDIF}
 end;
 
 ////////////////////
@@ -138,7 +141,10 @@
 SendKB;
 CloseIPC;
 TTF_Quit;
+{$IFNDEF IPHONEOS}
+//i know it is not clean but it is better than a crash
 SDL_Quit;
+{$ENDIF}
 halt
 end;
 
--- a/hedgewars/uConsts.pas	Thu Jun 18 17:35:34 2009 +0000
+++ b/hedgewars/uConsts.pas	Thu Jun 18 17:48:06 2009 +0000
@@ -157,24 +157,23 @@
 	msgGettingConfig     = 'Getting game config...';
 
 const
+	ifNone        = $00000000;
+	ifAlpha       = $00000001;
+	ifCritical    = $00000002;
+	ifTransparent = $00000004;
+	ifIgnoreCaps  = $00000008;
+	
+const
 	cMaxPower     = 1500;
 	cMaxAngle     = 2048;
 	cPowerDivisor = 1500;
 
 	MAXNAMELEN = 192;
 
-{$IFDEF IPHONEOS}
-//gotta rework this for compatibility; is it really needed anyway?
-	LAND_WIDTH = 1024;
-    LAND_HEIGHT = 512;
-    LAND_WIDTH_MASK  = $FFFFFC00;
-    LAND_HEIGHT_MASK = $FFFFFE00;
-{$ELSE}
     LAND_WIDTH = 4096;
     LAND_HEIGHT = 2048;
     LAND_WIDTH_MASK  = $FFFFF000;
     LAND_HEIGHT_MASK = $FFFFF800;
-{$ENDIF}
 
 	COLOR_LAND           = $FFFFFFFF;  // white
 	COLOR_INDESTRUCTIBLE = $FF0000FF;  // red
--- a/hedgewars/uKeys.pas	Thu Jun 18 17:35:34 2009 +0000
+++ b/hedgewars/uKeys.pas	Thu Jun 18 17:48:06 2009 +0000
@@ -63,18 +63,16 @@
           and (CurrentHedgehog^.BotLevel = 0);
 
 {$IFDEF SDL13}
-pkbd:= SDL_GetKeyboardState(nil);
+pkbd := SDL_GetKeyboardState(nil);
+i	 := SDL_GetMouseState(0, nil, nil);
 {$ELSE}
-pkbd:= SDL_GetKeyState(nil);
+pkbd := SDL_GetKeyState(nil);
+i	 := SDL_GetMouseState(nil, nil);
 {$ENDIF}
-{$IFDEF IPHONEOS}
-//SDL_GetMouseState currently broken in sdl13
-i:=1;
-{$ELSE}
-i:=SDL_GetMouseState(nil, nil);
-{$ENDIF}
+
 pkbd^[1]:= (i and 1);
 pkbd^[2]:= ((i shr 1) and 1);
+
 {$IFDEF DARWIN}
 //    normal right click     ||      ctrl (left/right) + left click	  
 pkbd^[3]:= ((i shr 2) and 1) or ((i and 1) and (pkbd^[306] or pkbd^[305]));
@@ -103,14 +101,17 @@
 var i, t: LongInt;
     pkbd: PByteArray;
 begin
+
 {$IFDEF SDL13}
 pkbd:= PByteArray(SDL_GetKeyboardState(@i));
 {$ELSE}
 pkbd:= PByteArray(SDL_GetKeyState(@i));
 {$ENDIF}
 TryDo(i < cKeyMaxIndex, 'SDL keys number is more than expected (' + inttostr(i) + ')', true);
+
 for t:= 0 to Pred(i) do
     tkbd[i]:= pkbd^[i]
+
 end;
 
 procedure InitKbdKeyTable;
--- a/hedgewars/uLand.pas	Thu Jun 18 17:35:34 2009 +0000
+++ b/hedgewars/uLand.pas	Thu Jun 18 17:48:06 2009 +0000
@@ -315,21 +315,26 @@
     r, rr: TSDL_Rect;
     x, yd, yu: LongInt;
 begin
-tmpsurf:= LoadImage(Pathz[ptCurrTheme] + '/LandTex', false, true, false);
+tmpsurf:= LoadImage(Pathz[ptCurrTheme] + '/LandTex', ifCritical or ifIgnoreCaps);
 r.y:= 0;
 while r.y < LAND_HEIGHT do
 	begin
 	r.x:= 0;
 	while r.x < LAND_WIDTH do
 		begin
+		{$IFDEF IPHONEOS}
+		//does not draw border with SDL_UpperBlit function, so we will use our own copy
+		copyToXY(tmpsurf,Surface, r.x,r.y);
+		{$ELSE}
 		SDL_UpperBlit(tmpsurf, nil, Surface, @r);
+		{$ENDIF}
 		inc(r.x, tmpsurf^.w)
 		end;
 	inc(r.y, tmpsurf^.h)
 	end;
 SDL_FreeSurface(tmpsurf);
 
-tmpsurf:= LoadImage(Pathz[ptCurrTheme] + '/Border', false, true, true);
+tmpsurf:= LoadImage(Pathz[ptCurrTheme] + '/Border', ifCritical or ifIgnoreCaps or ifTransparent);
 for x:= 0 to LAND_WIDTH - 1 do
 	begin
 	yd:= LAND_HEIGHT - 1;
@@ -610,7 +615,7 @@
 procedure MakeFortsMap;
 var tmpsurf: PSDL_Surface;
 begin
-// For now, defining a fort's playable area as 3072x1200 - there are no tall forts.  The extra height is to avoid triggering border with current code, also if user turns on a border, it'll give a bit more maneuvering room.
+// For now, defining a fort is playable area as 3072x1200 - there are no tall forts.  The extra height is to avoid triggering border with current code, also if user turns on a border, it will give a bit more maneuvering room.
 playHeight:= 1200;
 playWidth:= 2560;
 leftX:= (LAND_WIDTH - playWidth) div 2;
@@ -619,11 +624,11 @@
 
 WriteLnToConsole('Generating forts land...');
 
-tmpsurf:= LoadImage(Pathz[ptForts] + '/' + ClansArray[0]^.Teams[0]^.FortName + 'L', true, true, true);
+tmpsurf:= LoadImage(Pathz[ptForts] + '/' + ClansArray[0]^.Teams[0]^.FortName + 'L', ifAlpha or ifCritical or ifTransparent or ifIgnoreCaps);
 BlitImageAndGenerateCollisionInfo(leftX+150, LAND_HEIGHT - tmpsurf^.h, tmpsurf^.w, tmpsurf);
 SDL_FreeSurface(tmpsurf);
 
-tmpsurf:= LoadImage(Pathz[ptForts] + '/' + ClansArray[1]^.Teams[0]^.FortName + 'R', true, true, true);
+tmpsurf:= LoadImage(Pathz[ptForts] + '/' + ClansArray[1]^.Teams[0]^.FortName + 'R', ifAlpha or ifCritical or ifTransparent or ifIgnoreCaps);
 BlitImageAndGenerateCollisionInfo(rightX - 150 - tmpsurf^.w, LAND_HEIGHT - tmpsurf^.h, tmpsurf^.w, tmpsurf);
 SDL_FreeSurface(tmpsurf);
 end;
@@ -639,7 +644,7 @@
     p: PLongwordArray;
     x, y, cpX, cpY: Longword;
 begin
-tmpsurf:= LoadImage(Pathz[ptMapCurrent] + '/mask', true, false, true);
+tmpsurf:= LoadImage(Pathz[ptMapCurrent] + '/mask', ifAlpha or ifTransparent or ifIgnoreCaps);
 if (tmpsurf <> nil) and (tmpsurf^.w <= LAND_WIDTH) and (tmpsurf^.h <= LAND_HEIGHT) and (tmpsurf^.format^.BytesPerPixel = 4) then
     begin
 	cpX:= (LAND_WIDTH - tmpsurf^.w) div 2;
@@ -673,7 +678,7 @@
 begin
 WriteLnToConsole('Loading land from file...');
 AddProgress;
-tmpsurf:= LoadImage(Pathz[ptMapCurrent] + '/map', true, true, true);
+tmpsurf:= LoadImage(Pathz[ptMapCurrent] + '/map', ifAlpha or ifCritical or ifTransparent or ifIgnoreCaps);
 TryDo((tmpsurf^.w <= LAND_WIDTH) and (tmpsurf^.h <= LAND_HEIGHT), 'Map dimensions too big!', true);
 
 // unC0Rr - should this be passed from the GUI? I am not sure which layer does what
--- a/hedgewars/uLandObjects.pas	Thu Jun 18 17:35:34 2009 +0000
+++ b/hedgewars/uLandObjects.pas	Thu Jun 18 17:48:06 2009 +0000
@@ -189,8 +189,8 @@
 if x1 > 0 then
 	begin
 	Result:= true;
-	tmpsurf:= LoadImage(Pathz[ptCurrTheme] + '/Girder', false, false, true);
-	if tmpsurf = nil then tmpsurf:= LoadImage(Pathz[ptGraphics] + '/Girder', false, true, true);
+	tmpsurf:= LoadImage(Pathz[ptCurrTheme] + '/Girder', ifTransparent or ifIgnoreCaps);
+	if tmpsurf = nil then tmpsurf:= LoadImage(Pathz[ptGraphics] + '/Girder', ifCritical or ifTransparent or ifIgnoreCaps);
 	
 	rr.x:= x1;
 	while rr.x < x2 do
@@ -371,8 +371,10 @@
 Readln(f, c1.r, c1.g, c1. b);
 Readln(f, c2.r, c2.g, c2. b);
 // read water gradient colors
-Readln(f, WaterColorArray[0].r, WaterColorArray[0].g, WaterColorArray[0]. b);
-Readln(f, WaterColorArray[2].r, WaterColorArray[2].g, WaterColorArray[2]. b);
+Readln(f, WaterColorArray[0].r, WaterColorArray[0].g, WaterColorArray[0].b);
+Readln(f, WaterColorArray[2].r, WaterColorArray[2].g, WaterColorArray[2].b);
+WaterColorArray[0].a := 255;
+WaterColorArray[2].a := 255;
 WaterColorArray[1]:= WaterColorArray[0];
 WaterColorArray[3]:= WaterColorArray[2];
 
@@ -393,7 +395,7 @@
 	Readln(f, s); // filename
 	with ThemeObjects.objs[i] do
 			begin
-			Surf:= LoadImage(Pathz[ptCurrTheme] + '/' + s, false, true, true);
+			Surf:= LoadImage(Pathz[ptCurrTheme] + '/' + s, ifCritical or ifTransparent or ifIgnoreCaps);
 			Width:= Surf^.w;
 			Height:= Surf^.h;
 			with inland do
@@ -420,7 +422,7 @@
     Readln(f, s); // filename
     with SprayObjects.objs[i] do
          begin
-         Surf:= LoadImage(Pathz[ptCurrTheme] + '/' + s, false, true, true);
+         Surf:= LoadImage(Pathz[ptCurrTheme] + '/' + s, ifCritical or ifTransparent or ifIgnoreCaps);
          Width:= Surf^.w;
          Height:= Surf^.h;
          ReadLn(f, Maxcnt)
--- a/hedgewars/uMisc.pas	Thu Jun 18 17:35:34 2009 +0000
+++ b/hedgewars/uMisc.pas	Thu Jun 18 17:48:06 2009 +0000
@@ -118,11 +118,11 @@
 
 	AttackBar: LongInt = 0; // 0 - none, 1 - just bar at the right-down corner, 2 - like in WWP
 
-type HwColor3f = record
-		r, g, b: byte
+type HwColor4f = record
+		r, g, b, a: byte
 		end;
 
-var WaterColorArray: array[0..3] of HwColor3f;
+var WaterColorArray: array[0..3] of HwColor4f;
 
 function hwSign(r: hwFloat): LongInt;
 function Min(a, b: LongInt): LongInt;
@@ -364,7 +364,7 @@
 		{$IFDEF IPHONEOS}
 		modeFormat:= GL_BGR;
 		{$ELSE}
-		modeFormat:=modeIntFormat;
+		modeFormat:= modeIntFormat;
 		{$ENDIF}
 	end
 else
@@ -372,9 +372,9 @@
 	begin
 		modeIntFormat:= GL_RGBA;
 		{$IFDEF IPHONEOS}
-		modeFormat:=GL_BGRA;
+		modeFormat:= GL_BGRA;
 		{$ELSE}
-		modeFormat:=modeIntFormat;
+		modeFormat:= modeIntFormat;
 		{$ENDIF}
 	end
 else
--- a/hedgewars/uSound.pas	Thu Jun 18 17:35:34 2009 +0000
+++ b/hedgewars/uSound.pas	Thu Jun 18 17:48:06 2009 +0000
@@ -121,7 +121,10 @@
 				begin
 				s:= Pathz[Soundz[i].Path] + '/' + voicepacks[t].name + '/' + Soundz[i].FileName;
 				WriteToConsole(msgLoading + s + ' ');
+				{$IFNDEF IPHONEOS}
+				//broken for unknown reasons (most likely poor SDL_Mixer)
 				voicepacks[t].chunks[i]:= Mix_LoadWAV_RW(SDL_RWFromFile(Str2PChar(s), 'rb'), 1);
+				{$ENDIF}
 				if voicepacks[t].chunks[i] = nil then
 					WriteLnToConsole(msgFailed)
 				else
--- a/hedgewars/uStore.pas	Thu Jun 18 17:35:34 2009 +0000
+++ b/hedgewars/uStore.pas	Thu Jun 18 17:48:06 2009 +0000
@@ -53,7 +53,7 @@
 procedure RenderHealth(var Hedgehog: THedgehog);
 procedure AddProgress;
 procedure FinishProgress;
-function  LoadImage(const filename: string; hasAlpha, critical, setTransparent: boolean): PSDL_Surface;
+function  LoadImage(const filename: string; imageFlags: Integer): PSDL_Surface;
 procedure SetupOpenGL;
 procedure SetScale(f: GLfloat);
 
@@ -174,7 +174,7 @@
 					NameTagTex:= RenderStringTex(Name, Clan^.Color, fnt16);
 					if Hat <> 'NoHat' then
 						begin
-						texsurf:= LoadImage(Pathz[ptHats] + '/' + Hat, false, false, false);
+						texsurf:= LoadImage(Pathz[ptHats] + '/' + Hat, ifNone);
 						if texsurf <> nil then
 							begin
 							HatTex:= Surface2Tex(texsurf);
@@ -191,7 +191,7 @@
 		Color, i: Longword;
 	begin
 	s:= Pathz[ptGraphics] + '/' + cCHFileName;
-	tmpsurf:= LoadImage(s, true, true, false);
+	tmpsurf:= LoadImage(s, ifAlpha or ifCritical);
 
 	for t:= 0 to Pred(TeamsCount) do
 		with TeamsArray[t]^ do
@@ -246,7 +246,7 @@
 		with TeamsArray[t]^ do
 			begin
 			if GraveName = '' then GraveName:= 'Simple';
-			texsurf:= LoadImage(Pathz[ptGraves] + '/' + GraveName, false, true, true);
+			texsurf:= LoadImage(Pathz[ptGraves] + '/' + GraveName, ifCritical or ifTransparent);
 			GraveTex:= Surface2Tex(texsurf);
 			SDL_FreeSurface(texsurf)
 			end
@@ -282,11 +282,11 @@
            ((ii <> sprSky) and (ii <> sprHorizont) and (ii <> sprFlake)) then
 			begin
 			if AltPath = ptNone then
-				tmpsurf:= LoadImage(Pathz[Path] + '/' + FileName, true, true, true)
+				tmpsurf:= LoadImage(Pathz[Path] + '/' + FileName, ifAlpha or ifCritical or ifTransparent)
 			else begin
-				tmpsurf:= LoadImage(Pathz[Path] + '/' + FileName, true, false, true);
+				tmpsurf:= LoadImage(Pathz[Path] + '/' + FileName, ifAlpha or ifTransparent);
 				if tmpsurf = nil then
-					tmpsurf:= LoadImage(Pathz[AltPath] + '/' + FileName, true, true, true)
+					tmpsurf:= LoadImage(Pathz[AltPath] + '/' + FileName, ifALpha or ifCritical or ifTransparent)
 				end;
 			if Width = 0 then Width:= tmpsurf^.w;
 			if Height = 0 then Height:= tmpsurf^.h;
@@ -296,7 +296,7 @@
 
 AddProgress;
 
-tmpsurf:= LoadImage(Pathz[ptGraphics] + '/' + cHHFileName, true, true, true);
+tmpsurf:= LoadImage(Pathz[ptGraphics] + '/' + cHHFileName, ifAlpha or ifCritical or ifTransparent);
 HHTexture:= Surface2Tex(tmpsurf);
 SDL_FreeSurface(tmpsurf);
 
@@ -874,7 +874,8 @@
 Hedgehog.HealthTagTex:= RenderStringTex(s, Hedgehog.Team^.Clan^.Color, fnt16)
 end;
 
-function  LoadImage(const filename: string; hasAlpha: boolean; critical, setTransparent: boolean): PSDL_Surface;
+// hasAlpha: boolean; critical, setTransparent: boolean
+function  LoadImage(const filename: string; imageFlags: Integer): PSDL_Surface;
 var tmpsurf: PSDL_Surface;
     //Result: PSDL_Surface;
     s: shortstring;
@@ -891,19 +892,19 @@
 
 if tmpsurf = nil then
 	begin
-	OutError(msgFailed, critical);
+	OutError(msgFailed, (imageFlags and ifCritical) <> 0);
 	exit(nil)
 	end;
 
-if (tmpsurf^.w > MaxTextureSize) or (tmpsurf^.h > MaxTextureSize) then
+if ((imageFlags and ifIgnoreCaps) = 0) and ((tmpsurf^.w > MaxTextureSize) or (tmpsurf^.h > MaxTextureSize)) then
 	begin
 	SDL_FreeSurface(tmpsurf);
-	OutError(msgFailedSize, critical);
+	OutError(msgFailedSize, (imageFlags and ifCritical) <> 0);
 	exit(SDL_CreateRGBSurface(SDL_SWSURFACE, 32, 32, 32, RMask, GMask, BMask, AMask))
 	end;
 
-if setTransparent then TryDo(SDL_SetColorKey(tmpsurf, SDL_SRCCOLORKEY, 0) = 0, errmsgTransparentSet, true);
-//if hasAlpha then Result:= SDL_DisplayFormatAlpha(tmpsurf)
+if (imageFlags and ifTransparent) <> 0 then TryDo(SDL_SetColorKey(tmpsurf, SDL_SRCCOLORKEY, 0) = 0, errmsgTransparentSet, true);
+//if (imageFlags and ifAlpha) <> 0 then Result:= SDL_DisplayFormatAlpha(tmpsurf)
 //            else Result:= SDL_DisplayFormat(tmpsurf);
 WriteLnToConsole('(' + inttostr(tmpsurf^.w) + ',' + inttostr(tmpsurf^.h) + ') ');
 WriteLnToConsole(msgOK);
@@ -946,7 +947,7 @@
 if Step = 0 then
    begin
    WriteToConsole(msgLoading + 'progress sprite: ');
-   texsurf:= LoadImage(Pathz[ptGraphics] + '/Progress', false, true, true);
+   texsurf:= LoadImage(Pathz[ptGraphics] + '/Progress', ifCritical or ifTransparent);
    ProgrTex:= Surface2Tex(texsurf);
    SDL_FreeSurface(texsurf)
    end;
--- a/hedgewars/uWorld.pas	Thu Jun 18 17:35:34 2009 +0000
+++ b/hedgewars/uWorld.pas	Thu Jun 18 17:48:06 2009 +0000
@@ -202,11 +202,11 @@
 	VertexBuffer[3].Y:= lh;
 
 	glEnableClientState (GL_COLOR_ARRAY);
-	glColorPointer(3, GL_UNSIGNED_BYTE, 0, @WaterColorArray[0]);
+	glColorPointer(4, GL_UNSIGNED_BYTE, 0, @WaterColorArray[0]);
 
 	glEnableClientState(GL_VERTEX_ARRAY);
 	glVertexPointer(2, GL_FLOAT, 0, @VertexBuffer[0]);
-	
+
 	glDrawArrays(GL_TRIANGLE_FAN, 0, Length(VertexBuffer));
 
 	glEnableClientState(GL_COLOR_ARRAY);
@@ -425,9 +425,7 @@
       CountTicks:= 0;
       s:= inttostr(FPS) + ' fps';
       if fpsTexture <> nil then FreeTexture(fpsTexture);
-{$IFNDEF IPHONEOS}
       tmpSurface:= TTF_RenderUTF8_Blended(Fontz[fnt16].Handle, Str2PChar(s), $FFFFFF);
-{$ENDIF}
       fpsTexture:= Surface2Tex(tmpSurface);
       SDL_FreeSurface(tmpSurface)
       end;
@@ -472,13 +470,16 @@
 const PrevSentPointTime: LongWord = 0;
 var EdgesDist, cw: LongInt;
 begin
+
 cw:= round(cScreenWidth / cScaleFactor);
 
-
-if (not (CurrentTeam^.ExtDriven and isCursorVisible))
-	and cHasFocus then
+if (not (CurrentTeam^.ExtDriven and isCursorVisible)) and cHasFocus then
 	begin
+{$IFDEF SDL13}
+	SDL_GetMouseState(0, @CursorPoint.X, @CursorPoint.Y);
+{$ELSE}
 	SDL_GetMouseState(@CursorPoint.X, @CursorPoint.Y);
+{$ENDIF}
 	CursorPoint.X:= CursorPoint.X - cScreenWidth div 2;
 //	CursorPoint.X:= round((CursorPoint.X - cScreenWidth / 2) * 2 / cScaleFactor);
 //	CursorPoint.Y:= round(CursorPoint.Y * 2 / cScaleFactor);