redo LANDSCAPE MODE in a saner way with lots of fps
authorkoda
Sat, 30 Jan 2010 01:46:23 +0000
changeset 2724 601158aaa201
parent 2723 eaa6ac1e95ea
child 2725 89908847b155
redo LANDSCAPE MODE in a saner way with lots of fps uWorld cleaned a little with widgets moved to fit the new interface (mouse handling is messed up though)
cocoaTouch/SDLOverrides/SDL_uikitopengles.h
cocoaTouch/SDLOverrides/SDL_uikitopengles.m
cocoaTouch/SDLOverrides/SDL_uikitopenglview.h
cocoaTouch/SDLOverrides/SDL_uikitopenglview.m
cocoaTouch/SDLOverrides/SDL_uikitview.h
cocoaTouch/SDLOverrides/SDL_uikitview.m
hedgewars/CCHandlers.inc
hedgewars/uStore.pas
hedgewars/uWorld.pas
--- a/cocoaTouch/SDLOverrides/SDL_uikitopengles.h	Fri Jan 29 00:55:14 2010 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,38 +0,0 @@
-/*
-    SDL - Simple DirectMedia Layer
-    Copyright (C) 1997-2010 Sam Lantinga
-
-    This library is free software; you can redistribute it and/or
-    modify it under the terms of the GNU Lesser General Public
-    License as published by the Free Software Foundation; either
-    version 2.1 of the License, or (at your option) any later version.
-
-    This library is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-    Lesser General Public License for more details.
-
-    You should have received a copy of the GNU Lesser General Public
-    License along with this library; if not, write to the Free Software
-    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-
-    Sam Lantinga
-    slouken@libsdl.org
-*/
-
-#include "SDL_config.h"
-
-#ifndef _SDL_uikitopengles
-#define _SDL_uikitopengles
-
-#include "SDL_uikitvideo.h"
-
-extern int UIKit_GL_MakeCurrent(_THIS, SDL_Window * window,
-                                SDL_GLContext context);
-extern void UIKit_GL_SwapWindow(_THIS, SDL_Window * window);
-extern SDL_GLContext UIKit_GL_CreateContext(_THIS, SDL_Window * window);
-extern void UIKit_GL_DeleteContext(_THIS, SDL_GLContext context);
-extern void *UIKit_GL_GetProcAddress(_THIS, const char *proc);
-extern int UIKit_GL_LoadLibrary(_THIS, const char *path);
-
-#endif
--- a/cocoaTouch/SDLOverrides/SDL_uikitopengles.m	Fri Jan 29 00:55:14 2010 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,128 +0,0 @@
-/*
- SDL - Simple DirectMedia Layer
- Copyright (C) 1997-2009 Sam Lantinga
- 
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
- 
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- Lesser General Public License for more details.
- 
- You should have received a copy of the GNU Lesser General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
- 
- Sam Lantinga
- slouken@libsdl.org
- */
-
-#include "SDL_uikitopengles.h"
-#include "SDL_uikitopenglview.h"
-#include "SDL_uikitappdelegate.h"
-#include "SDL_uikitwindow.h"
-#include "jumphack.h"
-#include "SDL_sysvideo.h"
-#include "SDL_loadso.h"
-#include <dlfcn.h>
-
-static int UIKit_GL_Initialize(_THIS);
-
-void *
-UIKit_GL_GetProcAddress(_THIS, const char *proc) {	
-	/* Look through all SO's for the proc symbol.  Here's why:
-	 -Looking for the path to the OpenGL Library seems not to work in the iPhone Simulator.
-	 -We don't know that the path won't change in the future.
-	 */
-	return SDL_LoadFunction(RTLD_DEFAULT, proc);
-}
-
-/*
- note that SDL_GL_Delete context makes it current without passing the window
- */
-int UIKit_GL_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context) {
-	
-	if (context) {
-		SDL_WindowData *data = (SDL_WindowData *)window->driverdata;
-		[data->view setCurrentContext];
-	}
-	else {
-		[EAGLContext setCurrentContext: nil];
-	}
-	
-	return 0;
-}
-
-int UIKit_GL_LoadLibrary(_THIS, const char *path) {
-	/* 
-	 shouldn't be passing a path into this function 
-	 why?  Because we've already loaded the library
-	 and because the SDK forbids loading an external SO
-	 */
-	if (path != NULL) {
-		SDL_SetError("iPhone GL Load Library just here for compatibility");
-		return -1;
-	}
-	return 0;
-}
-
-void UIKit_GL_SwapWindow(_THIS, SDL_Window * window) {
-	
-	SDL_WindowData *data = (SDL_WindowData *)window->driverdata;
-	
-	if (nil == data->view) {
-		return;
-	}
-	[data->view swapBuffers];
-	/* since now we've got something to draw
-	 make the window visible */
-	[data->uiwindow makeKeyAndVisible];
-	
-	/* we need to let the event cycle run, or the OS won't update the OpenGL view! */
-	SDL_PumpEvents();
-	
-}
-
-SDL_GLContext UIKit_GL_CreateContext(_THIS, SDL_Window * window) {
-	
-	SDL_uikitopenglview *view;
-	SDL_WindowData *data = (SDL_WindowData *)window->driverdata;
-	
-	/* construct our view, passing in SDL's OpenGL configuration data */
-	view = [[SDL_uikitopenglview alloc] initWithFrame: [[UIScreen mainScreen] applicationFrame] \
-					    retainBacking: _this->gl_config.retained_backing \
-						    rBits: _this->gl_config.red_size \
-						    gBits: _this->gl_config.green_size \
-						    bBits: _this->gl_config.blue_size \
-						    aBits: _this->gl_config.alpha_size \
-						depthBits: _this->gl_config.depth_size ];
-	
-	data->view = view;
-	view.tag = 54321;
-	// rotate view
-	[view setTransform:CGAffineTransformMakeRotation(M_PI/2.0f)];
-	/* add the view to our window */
-	[data->uiwindow addSubview: view];
-	
-	/* Don't worry, the window retained the view */
-	[view release];
-	
-	if ( UIKit_GL_MakeCurrent(_this, window, view) < 0 ) {
-		UIKit_GL_DeleteContext(_this, view);
-		return NULL;
-	}
-	
-	return view;
-}
-
-void UIKit_GL_DeleteContext(_THIS, SDL_GLContext context) {
-	/* the delegate has retained the view, this will release him */
-	SDL_uikitopenglview *view = (SDL_uikitopenglview *)context;
-	/* this will also delete it */
-	[view removeFromSuperview];
-	
-	return;
-}
--- a/cocoaTouch/SDLOverrides/SDL_uikitopenglview.h	Fri Jan 29 00:55:14 2010 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,65 +0,0 @@
-/*
-    SDL - Simple DirectMedia Layer
-    Copyright (C) 1997-2010 Sam Lantinga
-
-    This library is free software; you can redistribute it and/or
-    modify it under the terms of the GNU Lesser General Public
-    License as published by the Free Software Foundation; either
-    version 2.1 of the License, or (at your option) any later version.
-
-    This library is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-    Lesser General Public License for more details.
-
-    You should have received a copy of the GNU Lesser General Public
-    License along with this library; if not, write to the Free Software
-    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-
-    Sam Lantinga
-    slouken@libsdl.org
-*/
-
-#import <UIKit/UIKit.h>
-#import <OpenGLES/EAGL.h>
-#import <OpenGLES/ES1/gl.h>
-#import <OpenGLES/ES1/glext.h>
-#import "SDL_uikitview.h"
-/*
-	This class wraps the CAEAGLLayer from CoreAnimation into a convenient UIView subclass.
-	The view content is basically an EAGL surface you render your OpenGL scene into.
-	Note that setting the view non-opaque will only work if the EAGL surface has an alpha channel.
- */
-/* *INDENT-OFF* */
-@interface SDL_uikitopenglview : SDL_uikitview {
-	
-@private
-	/* The pixel dimensions of the backbuffer */
-	GLint backingWidth;
-	GLint backingHeight;
-	
-	EAGLContext *context;
-	
-	/* OpenGL names for the renderbuffer and framebuffers used to render to this view */
-	GLuint viewRenderbuffer, viewFramebuffer;
-	
-	/* OpenGL name for the depth buffer that is attached to viewFramebuffer, if it exists (0 if it does not exist) */
-	GLuint depthRenderbuffer;
-	
-}
-
-@property (nonatomic, retain, readonly) EAGLContext *context;
-
-- (void)swapBuffers;
-- (void)setCurrentContext;
-
-- (id)initWithFrame:(CGRect)frame
-	retainBacking:(BOOL)retained \
-	rBits:(int)rBits \
-	gBits:(int)gBits \
-	bBits:(int)bBits \
-	aBits:(int)aBits \
-	depthBits:(int)depthBits;
-
-@end
-/* *INDENT-ON* */
--- a/cocoaTouch/SDLOverrides/SDL_uikitopenglview.m	Fri Jan 29 00:55:14 2010 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,171 +0,0 @@
-/*
- SDL - Simple DirectMedia Layer
- Copyright (C) 1997-2009 Sam Lantinga
- 
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
- 
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- Lesser General Public License for more details.
- 
- You should have received a copy of the GNU Lesser General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
- 
- Sam Lantinga
- slouken@libsdl.org
- */
-
-#import <QuartzCore/QuartzCore.h>
-#import <OpenGLES/EAGLDrawable.h>
-#import "SDL_uikitopenglview.h"
-
-@interface SDL_uikitopenglview (privateMethods)
-
-- (BOOL) createFramebuffer;
-- (void) destroyFramebuffer;
-
-@end
-
-
-@implementation SDL_uikitopenglview
-
-@synthesize context;
-
-+ (Class)layerClass {
-	return [CAEAGLLayer class];
-}
-
-- (id)initWithFrame:(CGRect)frame \
-retainBacking:(BOOL)retained \
-rBits:(int)rBits \
-gBits:(int)gBits \
-bBits:(int)bBits \
-aBits:(int)aBits \
-depthBits:(int)depthBits \
-{
-	
-	NSString *colorFormat=nil;
-	GLuint depthBufferFormat;
-	BOOL useDepthBuffer;
-	
-	if (rBits == 8 && gBits == 8 && bBits == 8) {
-		/* if user specifically requests rbg888 or some color format higher than 16bpp */
-		colorFormat = kEAGLColorFormatRGBA8;
-	}
-	else {
-		/* default case (faster) */
-		colorFormat = kEAGLColorFormatRGB565;
-	}
-	
-	if (depthBits == 24) {
-		useDepthBuffer = YES;
-		depthBufferFormat = GL_DEPTH_COMPONENT24_OES;
-	}
-	else if (depthBits == 0) {
-		useDepthBuffer = NO;
-	}
-	else {
-		/* default case when depth buffer is not disabled */
-		/* 
-		 strange, even when we use this, we seem to get a 24 bit depth buffer on iPhone.
-		 perhaps that's the only depth format iPhone actually supports
-		 */
-		useDepthBuffer = YES;
-		depthBufferFormat = GL_DEPTH_COMPONENT16_OES;
-	}
-	
-	
-	// we invert heigh and size to get q landscape mode up
-	CGRect rect = [[UIScreen mainScreen] bounds];
-	float swapTemp = rect.size.height;
-	rect.size.width = rect.size.height;
-	rect.size.height = swapTemp;
-	
-	if ((self = [super initWithFrame:rect])) {
-		// Get the layer
-		CAEAGLLayer *eaglLayer = (CAEAGLLayer *)self.layer;
-		
-		eaglLayer.opaque = YES;
-		eaglLayer.drawableProperties = [NSDictionary dictionaryWithObjectsAndKeys:
-						[NSNumber numberWithBool: retained], kEAGLDrawablePropertyRetainedBacking, colorFormat, kEAGLDrawablePropertyColorFormat, nil];
-		
-		context = [[EAGLContext alloc] initWithAPI: kEAGLRenderingAPIOpenGLES1];
-		
-		if (!context || ![EAGLContext setCurrentContext:context]) {
-			[self release];
-			return nil;
-		}
-		
-		/* create the buffers */
-		glGenFramebuffersOES(1, &viewFramebuffer);
-		glGenRenderbuffersOES(1, &viewRenderbuffer);
-		
-		glBindFramebufferOES(GL_FRAMEBUFFER_OES, viewFramebuffer);
-		glBindRenderbufferOES(GL_RENDERBUFFER_OES, viewRenderbuffer);
-		[context renderbufferStorage:GL_RENDERBUFFER_OES fromDrawable:(CAEAGLLayer*)self.layer];
-		glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_COLOR_ATTACHMENT0_OES, GL_RENDERBUFFER_OES, viewRenderbuffer);
-		
-		glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_WIDTH_OES, &backingWidth);
-		glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_HEIGHT_OES, &backingHeight);
-		
-		if (useDepthBuffer) {
-			glGenRenderbuffersOES(1, &depthRenderbuffer);
-			glBindRenderbufferOES(GL_RENDERBUFFER_OES, depthRenderbuffer);
-			glRenderbufferStorageOES(GL_RENDERBUFFER_OES, depthBufferFormat, backingWidth, backingHeight);
-			glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_DEPTH_ATTACHMENT_OES, GL_RENDERBUFFER_OES, depthRenderbuffer);
-		}
-		
-		if(glCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES) != GL_FRAMEBUFFER_COMPLETE_OES) {
-			return NO;
-		}
-		/* end create buffers */
-	}
-	return self;
-}
-
-- (void)setCurrentContext {
-	[EAGLContext setCurrentContext:context];
-}
-
-
-- (void)swapBuffers {
-	glBindRenderbufferOES(GL_RENDERBUFFER_OES, viewRenderbuffer);
-	[context presentRenderbuffer:GL_RENDERBUFFER_OES];
-}
-
-
-- (void)layoutSubviews {
-	[EAGLContext setCurrentContext:context];
-}
-
-- (void)destroyFramebuffer {
-	
-	glDeleteFramebuffersOES(1, &viewFramebuffer);
-	viewFramebuffer = 0;
-	glDeleteRenderbuffersOES(1, &viewRenderbuffer);
-	viewRenderbuffer = 0;
-	
-	if (depthRenderbuffer) {
-		glDeleteRenderbuffersOES(1, &depthRenderbuffer);
-		depthRenderbuffer = 0;
-	}
-}
-
-
-- (void)dealloc {
-	
-	[self destroyFramebuffer];
-	if ([EAGLContext currentContext] == context) {
-		[EAGLContext setCurrentContext:nil];
-	}
-	[context release];	
-	[super dealloc];
-	
-}
-
-@end
--- a/cocoaTouch/SDLOverrides/SDL_uikitview.h	Fri Jan 29 00:55:14 2010 +0000
+++ b/cocoaTouch/SDLOverrides/SDL_uikitview.h	Sat Jan 30 01:46:23 2010 +0000
@@ -37,14 +37,14 @@
 // constants for telling which input has been received
 #define kMinimumPinchDelta	100
 #define kMinimumGestureLength	10
-#define kMaximumVariance	4
+#define kMaximumVariance	3
 
 /* *INDENT-OFF* */
-//#if SDL_IPHONE_KEYBOARD
-//@interface SDL_uikitview : UIView<UITextFieldDelegate> {
-//#else
+#if SDL_IPHONE_KEYBOARD
+@interface SDL_uikitview : UIView<UITextFieldDelegate> {
+#else
 @interface SDL_uikitview : UIView {
-//#endif
+#endif
 	SDL_Mouse mice[MAX_SIMULTANEOUS_TOUCHES];
 	CGFloat initialDistance;
 	CGPoint gestureStartPoint;
--- a/cocoaTouch/SDLOverrides/SDL_uikitview.m	Fri Jan 29 00:55:14 2010 +0000
+++ b/cocoaTouch/SDLOverrides/SDL_uikitview.m	Sat Jan 30 01:46:23 2010 +0000
@@ -65,6 +65,9 @@
 		SDL_AddMouse(&mice[i], "Mouse", 0, 0, 1);
 	}
 
+	self.multipleTouchEnabled = YES;
+
+	// custom code
 	attackButton = [[UIButton alloc] initWithFrame:CGRectMake(30, 480, 260,50)];
 	[attackButton setBackgroundImage:[UIImage imageNamed:@"Default.png"] forState:UIControlStateNormal];
 	[attackButton setBackgroundImage:[UIImage imageNamed:@"Default.png"] forState:UIControlStateHighlighted];
@@ -77,7 +80,6 @@
 	[menuButton addTarget:[self superclass] action:@selector(attackButtonPressed) forControlEvents:UIControlEventTouchUpInside];
 	[self addSubview:menuButton];
 
-	self.multipleTouchEnabled = YES;
 
 	return self;
 }
@@ -166,7 +168,11 @@
 
 	// one tap - single click
 	if (1 == [touch tapCount] ) {
-		//SDL_WarpMouseInWindow([SDLUIKitDelegate sharedAppDelegate].window, gestureStartPoint.x, gestureStartPoint.y);
+		CGFloat oldX = gestureStartPoint.x;
+		gestureStartPoint.x = gestureStartPoint.y;
+		gestureStartPoint.y = 320 - oldX;
+
+		SDL_WarpMouseInWindow([SDLUIKitDelegate sharedAppDelegate].window, gestureStartPoint.x, gestureStartPoint.y);
 		HW_click();
 	}
 	
@@ -191,7 +197,6 @@
 
 - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
 	initialDistance = 0;
-//	NSLog(@"touches ended, sigh");
 	
 	HW_allKeysUp();
 	/*NSEnumerator *enumerator = [touches objectEnumerator];
@@ -227,8 +232,9 @@
 	UITouch *touch = [touches anyObject];
 	CGPoint currentPosition = [touch locationInView:self];
 	
-	CGFloat Xdiff = gestureStartPoint.x - currentPosition.x;
-	CGFloat Ydiff = gestureStartPoint.y - currentPosition.y;
+	// remember that we have x and y inverted
+	CGFloat Xdiff = gestureStartPoint.y - currentPosition.y;
+	CGFloat Ydiff = gestureStartPoint.x - currentPosition.x;
 	CGFloat deltaX = fabsf(Xdiff);
 	CGFloat deltaY = fabsf(Ydiff);
     
@@ -236,8 +242,7 @@
 		NSLog(@"Horizontal swipe detected, begX:%f curX:%f", gestureStartPoint.x, currentPosition.x);
 		if (Xdiff > 0) HW_walkLeft();
 		else HW_walkRight();
-	}
-	else if (deltaY >= kMinimumGestureLength && deltaX <= kMaximumVariance){
+	} else if (deltaY >= kMinimumGestureLength && deltaX <= kMaximumVariance){
 		NSLog(@"Vertical swipe detected, begY:%f curY:%f", gestureStartPoint.y, currentPosition.y);
 		if (Ydiff > 0) HW_aimUp();
 		else HW_aimDown();
--- a/hedgewars/CCHandlers.inc	Fri Jan 29 00:55:14 2010 +0000
+++ b/hedgewars/CCHandlers.inc	Sat Jan 30 01:46:23 2010 +0000
@@ -628,7 +628,8 @@
 	end;
 	
 {$IFDEF SDL13}
-	window:= SDL_CreateWindow('Hedgewars', 0, 0, cScreenWidth, cScreenHeight,
+	window:= SDL_CreateWindow('Hedgewars', 0, 0,
+		{$IFDEF IPHONEOS}cScreenHeight, cScreenWidth,{$ELSE}cScreenWidth, cScreenHeight,{$ENDIF}
 		SDL_WINDOW_OPENGL or SDL_WINDOW_SHOWN 	 
 	        {$IFDEF IPHONEOS} or SDL_WINDOW_BORDERLESS{$ENDIF}); 	 
 	SDL_CreateRenderer(window, -1, 0); 	 
--- a/hedgewars/uStore.pas	Fri Jan 29 00:55:14 2010 +0000
+++ b/hedgewars/uStore.pas	Sat Jan 30 01:46:23 2010 +0000
@@ -1136,11 +1136,18 @@
 {$ENDIF}
 
 	// set view port to whole window
+{$IFDEF IPHONEOS}
+	glViewport(0, 0, cScreenHeight, cScreenWidth);
+{$ELSE}
 	glViewport(0, 0, cScreenWidth, cScreenHeight);
+{$ENDIF}
 
 	glMatrixMode(GL_MODELVIEW);
 	// prepare default translation/scaling
 	glLoadIdentity();
+{$IFDEF IPHONEOS}
+	glRotatef(-90, 0, 0, 1);
+{$ENDIF}
 	glScalef(2.0 / cScreenWidth, -2.0 / cScreenHeight, 1.0);
 	glTranslatef(0, -cScreenHeight / 2, 0);
 
@@ -1150,15 +1157,24 @@
 end;
 
 procedure SetScale(f: GLfloat);
+var
+{$IFDEF IPHONEOS}
+scale: GLfloat = 1.5;
+{$ELSE}
+scale: GLfloat = 2.0;
+{$ENDIF}
 begin
 	// leave immediately if scale factor did not change
 	if f = cScaleFactor then exit;
 
-	if f = 2.0 then glPopMatrix // "return" to default scaling
-	else // other scaling
+	if f = scale then glPopMatrix	// "return" to default scaling
+	else				// other scaling
 	begin
-		glPushMatrix; // save default scaling
+		glPushMatrix;		// save default scaling
 		glLoadIdentity;
+{$IFDEF IPHONEOS}
+		glRotatef(-90, 0, 0, 1);
+{$ENDIF}
 		glScalef(f / cScreenWidth, -f / cScreenHeight, 1.0);
 		glTranslatef(0, -cScreenHeight / 2, 0);
 	end;
--- a/hedgewars/uWorld.pas	Fri Jan 29 00:55:14 2010 +0000
+++ b/hedgewars/uWorld.pas	Sat Jan 30 01:46:23 2010 +0000
@@ -341,10 +341,8 @@
     tdx, tdy: Double;
     grp: TCapGroup;
     s: string[15];
-{$IFDEF IPHONEOS}
-    x,y: LongInt;
-{$ENDIF}
     offset: LongInt;
+    scale: GLfloat;
 begin
 if ZoomValue < zoom then
 	begin
@@ -364,10 +362,6 @@
 //glPushMatrix;
 //glScalef(1.0, 1.0, 1.0);
 
-{$IFDEF IPHONEOS}
-SDL_GetMouseState(@x, @y);
-//WriteLnToConsole('x; ' + inttostr(x) + ' y: ' + inttostr(y));
-{$ENDIF}
 if not isPaused then MoveCamera;
 
 if not cReducedQuality then
@@ -427,16 +421,18 @@
 {$WARNINGS OFF}
 // Target
 if TargetPoint.X <> NoPointX then DrawSprite(sprTargetP, TargetPoint.X + WorldDx - 16, TargetPoint.Y + WorldDy - 16, 0);
-
 {$WARNINGS ON}
-SetScale(2.0);
 
 {$IFDEF IPHONEOS}
-offset:= 465;
+scale:= 1.5;
 {$ELSE}
+scale:= 2.0;
+{$ENDIF}
+SetScale(scale);
+
+
+// Turn time
 offset:= 48;
-{$ENDIF}
-// Turn time
 if TurnTimeLeft <> 0 then
    begin
    i:= Succ(Pred(TurnTimeLeft) div 1000);
@@ -501,17 +497,18 @@
 
 // Captions
 {$IFDEF IPHONEOS}
-i:= 53;
+offset:= 49;
 {$ELSE}
-if ((TrainingFlags and tfTimeTrial) <> 0) and (TimeTrialStartTime > 0) then i:= 48 else i:= 8;
+if ((TrainingFlags and tfTimeTrial) <> 0) and (TimeTrialStartTime > 0) then offset:= 48
+else offset:= 8;
 {$ENDIF}
 
 	for grp:= Low(TCapGroup) to High(TCapGroup) do
 		with Captions[grp] do
 			if Tex <> nil then
 			begin
-				DrawCentered(0, i, Tex);
-				inc(i, Tex^.h + 2);
+				DrawCentered(0, offset, Tex);
+				inc(offset, Tex^.h + 2);
 				if EndTime <= RealTicks then
 				begin
 					FreeTexture(Tex);
@@ -544,7 +541,7 @@
 
 // Wind bar
 {$IFDEF IPHONEOS}
-offset:= 450;
+offset:= 305;
 {$ELSE}
 offset:= 30;
 {$ENDIF}
@@ -577,14 +574,17 @@
 if isCursorVisible and bShowAmmoMenu then
    DrawSprite(sprArrow, CursorPoint.X, cScreenHeight - CursorPoint.Y, (RealTicks shr 6) mod 8);
 
-{$IFNDEF IPHONEOS}
-{* do not draw the chat because a) no input b) too little space*}
 DrawChat;
-{$ENDIF}
 
 if fastUntilLag then DrawCentered(0, (cScreenHeight shr 1), SyncTexture);
 if isPaused then DrawCentered(0, (cScreenHeight shr 1), PauseTexture);
 
+// fps
+{$IFDEF IPHONEOS}
+offset:= 40;
+{$ELSE}
+offset:= 10;
+{$ENDIF}
 inc(Frames);
 if cShowFPS then
    begin
@@ -602,9 +602,10 @@
       SDL_FreeSurface(tmpSurface)
       end;
    if fpsTexture <> nil then
-      DrawTexture((cScreenWidth shr 1) - 50, 10, fpsTexture);
+      DrawTexture((cScreenWidth shr 1) - 50, offset, fpsTexture);
    end;
 
+// lag warning (?)
 inc(SoundTimerTicks, Lag);
 if SoundTimerTicks >= 50 then
    begin
@@ -616,7 +617,8 @@
       end
    end;
 
-if GameState = gsConfirm then DrawCentered(0, cScreenHeight div 2, ConfirmTexture);
+if GameState = gsConfirm then
+	DrawCentered(0, cScreenHeight div 2, ConfirmTexture);
 
 SetScale(zoom);