aboutsummaryrefslogtreecommitdiff
path: root/backends/platform/iphone
diff options
context:
space:
mode:
Diffstat (limited to 'backends/platform/iphone')
-rw-r--r--backends/platform/iphone/iphone_common.h7
-rw-r--r--backends/platform/iphone/iphone_main.m16
-rw-r--r--backends/platform/iphone/iphone_video.h33
-rw-r--r--backends/platform/iphone/iphone_video.m245
-rw-r--r--backends/platform/iphone/osys_iphone.cpp204
5 files changed, 229 insertions, 276 deletions
diff --git a/backends/platform/iphone/iphone_common.h b/backends/platform/iphone/iphone_common.h
index e46d1c0d96..57dc991e9d 100644
--- a/backends/platform/iphone/iphone_common.h
+++ b/backends/platform/iphone/iphone_common.h
@@ -62,11 +62,8 @@ void iphone_main(int argc, char *argv[]);
// On the ObjC side
void iPhone_updateScreen();
-void iPhone_updateScreenRect(int x1, int y1, int x2, int y2);
-unsigned short* iPhone_getSurface();
-void iPhone_lockSurface();
-void iPhone_unlockSurface();
-void iPhone_initSurface(int width, int height, bool landscape);
+void iPhone_updateScreenRect(unsigned short* screen, int x1, int y1, int x2, int y2);
+void iPhone_initSurface(int width, int height);
bool iPhone_fetchEvent(int *outEvent, float *outX, float *outY);
const char* iPhone_getDocumentsDir();
diff --git a/backends/platform/iphone/iphone_main.m b/backends/platform/iphone/iphone_main.m
index a9900823ed..1cda168cd0 100644
--- a/backends/platform/iphone/iphone_main.m
+++ b/backends/platform/iphone/iphone_main.m
@@ -25,6 +25,7 @@
#import <UIKit/UIKit.h>
#import <Foundation/NSThread.h>
+
#include "iphone_video.h"
void iphone_main(int argc, char *argv[]);
@@ -37,6 +38,7 @@ void iphone_main(int argc, char *argv[]);
- (void) mainLoop: (id)param;
- (iPhoneView*) getView;
- (UIWindow*) getWindow;
+- (void)didRotate:(NSNotification *)notification;
@end
static int gArgc;
@@ -90,17 +92,19 @@ int main(int argc, char** argv) {
[_window setContentView: _view];
- //[_window orderFront: self];
- //[_window makeKey: self];
-
[_window addSubview:_view];
[_window makeKeyAndVisible];
+ [[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
+ [[NSNotificationCenter defaultCenter] addObserver:self
+ selector:@selector(didRotate:)
+ name:@"UIDeviceOrientationDidChangeNotification" object:nil];
+
[NSThread detachNewThreadSelector:@selector(mainLoop:) toTarget:self withObject:nil];
}
- (void)applicationSuspend:(struct __GSEvent *)event {
- [self setApplicationBadge:NSLocalizedString(@"ON", nil)];
+ //[self setApplicationBadge:NSLocalizedString(@"ON", nil)];
[_view applicationSuspend];
}
@@ -115,8 +119,8 @@ int main(int argc, char** argv) {
[self setStatusBarHidden:YES animated:YES];
}
-- (void)deviceOrientationChanged:(struct __GSEvent *)event {
- int screenOrientation = GSEventDeviceOrientation(event);
+- (void)didRotate:(NSNotification *)notification {
+ int screenOrientation = [[UIDevice currentDevice] orientation];
[_view deviceOrientationChanged: screenOrientation];
}
diff --git a/backends/platform/iphone/iphone_video.h b/backends/platform/iphone/iphone_video.h
index 0ef21007ba..3d5715bb95 100644
--- a/backends/platform/iphone/iphone_video.h
+++ b/backends/platform/iphone/iphone_video.h
@@ -30,30 +30,16 @@
#import <Foundation/Foundation.h>
#import <QuartzCore/QuartzCore.h>
-#import "iphone_keyboard.h"
-
-void *CoreSurfaceBufferGetBaseAddress(void* surface);
-int CoreSurfaceBufferLock(void* surface, unsigned int lockType);
-int CoreSurfaceBufferUnlock(void* surface);
-void* CoreSurfaceBufferCreate(CFDictionaryRef dict);
+#import <OpenGLES/EAGL.h>
+#import <OpenGLES/ES1/gl.h>
+#import <OpenGLES/ES1/glext.h>
-extern CFStringRef kCoreSurfaceBufferGlobal;
-extern CFStringRef kCoreSurfaceBufferMemoryRegion;
-extern CFStringRef kCoreSurfaceBufferPitch;
-extern CFStringRef kCoreSurfaceBufferWidth;
-extern CFStringRef kCoreSurfaceBufferHeight;
-extern CFStringRef kCoreSurfaceBufferPixelFormat;
-extern CFStringRef kCoreSurfaceBufferAllocSize;
-
-struct __GSEvent;
-CGPoint GSEventGetLocationInWindow(struct __GSEvent *ev);
-unsigned int GSEventDeviceOrientation(struct __GSEvent *ev);
+#import "iphone_keyboard.h"
@interface iPhoneView : UIView
{
void* _screenSurface;
NSMutableArray* _events;
- NSLock* _lock;
SoftKeyboard* _keyboardView;
CALayer* _screenLayer;
@@ -61,6 +47,15 @@ unsigned int GSEventDeviceOrientation(struct __GSEvent *ev);
int _fullHeight;
int _widthOffset;
int _heightOffset;
+
+ EAGLContext* _context;
+ GLuint _viewRenderbuffer;
+ GLuint _viewFramebuffer;
+ GLint _backingWidth;
+ GLint _backingHeight;
+ GLint _visibleWidth;
+ GLint _visibleHeight;
+ GLuint _screenTexture;
}
- (id)initWithFrame:(struct CGRect)frame;
@@ -71,7 +66,7 @@ unsigned int GSEventDeviceOrientation(struct __GSEvent *ev);
- (void)initSurface;
-- (void)updateScreenRect:(id)rect;
+- (void)updateSurface;
- (id)getEvent;
diff --git a/backends/platform/iphone/iphone_video.m b/backends/platform/iphone/iphone_video.m
index 016e9d4088..1e02dd104d 100644
--- a/backends/platform/iphone/iphone_video.m
+++ b/backends/platform/iphone/iphone_video.m
@@ -33,38 +33,38 @@
static iPhoneView *sharedInstance = nil;
static int _width = 0;
static int _height = 0;
-static bool _landscape;
static CGRect _screenRect;
+static char* _textureBuffer = 0;
+static int _textureWidth = 0;
+static int _textureHeight = 0;
+NSLock* _lock = nil;
+static int _needsScreenUpdate = 0;
// static long lastTick = 0;
// static int frames = 0;
-unsigned short* iPhone_getSurface() {
- return CoreSurfaceBufferGetBaseAddress([sharedInstance getSurface]);
-}
-
void iPhone_updateScreen() {
- [sharedInstance performSelectorOnMainThread:@selector(setNeedsDisplay) withObject:nil waitUntilDone: NO];
+ if (!_needsScreenUpdate) {
+ _needsScreenUpdate = 1;
+ [sharedInstance performSelectorOnMainThread:@selector(updateSurface) withObject:nil waitUntilDone: NO];
+ }
}
-void iPhone_updateScreenRect(int x1, int y1, int x2, int y2) {
- //CGRect rect = CGRectMake(x1, y1, x2, y2);
- //[sharedInstance performSelectorOnMainThread:@selector(updateScreenRect:) withObject: [NSValue valueWithRect:rect] waitUntilDone: NO];
-}
+void iPhone_updateScreenRect(unsigned short* screen, int x1, int y1, int x2, int y2) {
+ [_lock lock];
+
+ int y;
+ for (y = y1; y < y2; ++y) {
+ memcpy(&_textureBuffer[(y * _textureWidth + x1 )* 2], &screen[y * _width + x1], (x2 - x1) * 2);
+ }
-void iPhone_lockSurface() {
- CoreSurfaceBufferLock([sharedInstance getSurface], 3);
+ [_lock unlock];
}
-void iPhone_unlockSurface() {
- CoreSurfaceBufferUnlock([sharedInstance getSurface]);
-}
-void iPhone_initSurface(int width, int height, bool landscape) {
+void iPhone_initSurface(int width, int height) {
_width = width;
_height = height;
- _landscape = landscape;
-
[sharedInstance performSelectorOnMainThread:@selector(initSurface) withObject:nil waitUntilDone: YES];
}
@@ -105,8 +105,26 @@ bool getLocalMouseCoords(CGPoint *point) {
return true;
}
+uint getSizeNextPOT(uint size) {
+ if ((size & (size - 1)) || !size) {
+ int log = 0;
+
+ while (size >>= 1)
+ ++log;
+
+ size = (2 << log);
+ }
+
+ return size;
+}
+
@implementation iPhoneView
++ (Class) layerClass
+{
+ return [CAEAGLLayer class];
+}
+
- (id)initWithFrame:(struct CGRect)frame {
[super initWithFrame: frame];
@@ -115,8 +133,11 @@ bool getLocalMouseCoords(CGPoint *point) {
_screenLayer = nil;
sharedInstance = self;
+
+ _lock = [NSLock new];
_keyboardView = nil;
- //[super setTapDelegate: self];
+ _context = nil;
+ _screenTexture = 0;
return self;
}
@@ -127,6 +148,9 @@ bool getLocalMouseCoords(CGPoint *point) {
if (_keyboardView != nil) {
[_keyboardView dealloc];
}
+
+ if (_screenTexture)
+ free(_textureBuffer);
}
- (void *)getSurface {
@@ -146,44 +170,132 @@ bool getLocalMouseCoords(CGPoint *point) {
// }
}
-- (void)updateScreenRect:(id)rect {
- // NSRect nsRect = [rect rectValue];
- // CGRect cgRect = CGRectMake(nsRect.origin.x, nsRect.origin.y, nsRect.size.width, nsRect.size.height);
- // [sharedInstance setNeedsDisplayInRect: cgRect];
+- (void)updateSurface {
+ if (!_needsScreenUpdate) {
+ return;
+ }
+ _needsScreenUpdate = 0;
+
+ GLfloat vertices[] = {
+ 0.0f + _heightOffset, 0.0f + _widthOffset,
+ _visibleWidth - _heightOffset, 0.0f + _widthOffset,
+ 0.0f + _heightOffset, _visibleHeight - _widthOffset,
+ _visibleWidth - _heightOffset, _visibleHeight - _widthOffset
+ };
+
+ float texWidth = _width / (float)_textureWidth;;
+ float texHeight = _height / (float)_textureHeight;
+
+ const GLfloat texCoords[] = {
+ texWidth, 0.0f,
+ 0.0f, 0.0f,
+ texWidth, texHeight,
+ 0.0f, texHeight
+ };
+
+ glVertexPointer(2, GL_FLOAT, 0, vertices);
+ glTexCoordPointer(2, GL_FLOAT, 0, texCoords);
+
+ [_lock lock];
+ // Unfortunately we have to update the whole texture every frame, since glTexSubImage2D is actually slower in all cases
+ // due to the iPhone internals having to convert the whole texture back from its internal format when used.
+ // In the future we could use several tiled textures instead.
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, _textureWidth, _textureHeight, 0, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, _textureBuffer);
+ [_lock unlock];
+
+ glClear(GL_COLOR_BUFFER_BIT);
+ glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
+ glBindRenderbufferOES(GL_RENDERBUFFER_OES, _viewRenderbuffer);
+ [_context presentRenderbuffer:GL_RENDERBUFFER_OES];
+
}
- (void)initSurface {
- //printf("Window: (%d, %d), Surface: (%d, %d)\n", _fullWidth, _fullHeight, _width, _height);
-
- int pitch = _width * 2;
- int allocSize = 2 * _width * _height;
- char *pixelFormat = "565L";
-
- NSDictionary* dict = [[NSDictionary alloc] initWithObjectsAndKeys:
- kCFBooleanTrue, kCoreSurfaceBufferGlobal,
- @"PurpleGFXMem", kCoreSurfaceBufferMemoryRegion,
- [NSNumber numberWithInt: pitch], kCoreSurfaceBufferPitch,
- [NSNumber numberWithInt: _width], kCoreSurfaceBufferWidth,
- [NSNumber numberWithInt: _height], kCoreSurfaceBufferHeight,
- [NSNumber numberWithInt: *(int*)pixelFormat], kCoreSurfaceBufferPixelFormat,
- [NSNumber numberWithInt: allocSize], kCoreSurfaceBufferAllocSize,
- nil
- ];
+ _textureWidth = getSizeNextPOT(_width);
+ _textureHeight = getSizeNextPOT(_height);
+
+ UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation];
- //("Allocating surface: %d\n", allocSize);
- _screenSurface = CoreSurfaceBufferCreate((CFDictionaryRef)dict);
- //printf("Surface created.\n");
- CoreSurfaceBufferLock(_screenSurface, 3);
+ //printf("Window: (%d, %d), Surface: (%d, %d), Texture(%d, %d)\n", _fullWidth, _fullHeight, _width, _height, _textureWidth, _textureHeight);
+
+ if (_context == nil) {
+ orientation = UIDeviceOrientationLandscapeRight;
+ CAEAGLLayer *eaglLayer = (CAEAGLLayer*) self.layer;
+
+ eaglLayer.opaque = YES;
+ eaglLayer.drawableProperties = [NSDictionary dictionaryWithObjectsAndKeys:
+ [NSNumber numberWithBool:FALSE], kEAGLDrawablePropertyRetainedBacking, kEAGLColorFormatRGB565, kEAGLDrawablePropertyColorFormat, nil];
+
+ _context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES1];
+ if (!_context || [EAGLContext setCurrentContext:_context]) {
+ glGenFramebuffersOES(1, &_viewFramebuffer);
+ glGenRenderbuffersOES(1, &_viewRenderbuffer);
+
+ glBindFramebufferOES(GL_FRAMEBUFFER_OES, _viewFramebuffer);
+ glBindRenderbufferOES(GL_RENDERBUFFER_OES, _viewRenderbuffer);
+ [_context renderbufferStorage:GL_RENDERBUFFER_OES fromDrawable:(id<EAGLDrawable>)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 (glCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES) != GL_FRAMEBUFFER_COMPLETE_OES) {
+ NSLog(@"Failed to make complete framebuffer object %x.", glCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES));
+ return;
+ }
+
+ glViewport(0, 0, _backingWidth, _backingHeight);
+ glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
+
+ glEnable(GL_TEXTURE_2D);
+ glEnableClientState(GL_TEXTURE_COORD_ARRAY);
+ glEnableClientState(GL_VERTEX_ARRAY);
+ }
+ }
- CALayer* screenLayer = [[CALayer layer] retain];
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+
+ if (orientation == UIDeviceOrientationLandscapeRight) {
+ glRotatef(-90, 0, 0, 1);
+ } else if (orientation == UIDeviceOrientationLandscapeLeft) {
+ glRotatef(90, 0, 0, 1);
+ } else {
+ glRotatef(180, 0, 0, 1);
+ }
+
+ glOrthof(0, _backingWidth, 0, _backingHeight, 0, 1);
+
+ if (_screenTexture > 0)
+ glDeleteTextures(1, &_screenTexture);
+ glGenTextures(1, &_screenTexture);
+ glBindTexture(GL_TEXTURE_2D, _screenTexture);
+ glEnable(GL_TEXTURE_2D);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+
+ if (_textureBuffer)
+ free(_textureBuffer);
+
+ int textureSize = _textureWidth * _textureHeight * 2;
+ _textureBuffer = (char*)malloc(textureSize);
+ memset(_textureBuffer, 0, textureSize);
+
+
+ glClear(GL_COLOR_BUFFER_BIT);
+ glBindRenderbufferOES(GL_RENDERBUFFER_OES, _viewRenderbuffer);
+ [_context presentRenderbuffer:GL_RENDERBUFFER_OES];
+
if (_keyboardView != nil) {
[_keyboardView removeFromSuperview];
[[_keyboardView inputView] removeFromSuperview];
}
- if (_landscape) {
- float ratioDifference = ((float)_width / (float)_height) / ((float)_fullWidth / (float)_fullHeight);
+ if (orientation == UIDeviceOrientationLandscapeLeft || orientation == UIDeviceOrientationLandscapeRight) {
+ _visibleHeight = _backingHeight;
+ _visibleWidth = _backingWidth;
+
+ float ratioDifference = ((float)_height / (float)_width) / ((float)_fullWidth / (float)_fullHeight);
int rectWidth, rectHeight;
if (ratioDifference < 1.0f) {
rectWidth = _fullWidth * ratioDifference;
@@ -199,15 +311,17 @@ bool getLocalMouseCoords(CGPoint *point) {
//printf("Rect: %i, %i, %i, %i\n", _widthOffset, _heightOffset, rectWidth, rectHeight);
_screenRect = CGRectMake(_widthOffset, _heightOffset, rectWidth, rectHeight);
- [screenLayer setFrame: _screenRect];
} else {
float ratio = (float)_height / (float)_width;
int height = _fullWidth * ratio;
//printf("Making rect (%u, %u)\n", _fullWidth, height);
_screenRect = CGRectMake(0, 0, _fullWidth - 1, height - 1);
- [screenLayer setFrame: _screenRect];
- //CGRect keyFrame = CGRectMake(0.0f, _screenRect.size.height, _fullWidth, _fullHeight - _screenRect.size.height);
+ _visibleHeight = height;
+ _visibleWidth = _backingWidth;
+ _heightOffset = 0.0f;
+ _widthOffset = 0.0f;
+
CGRect keyFrame = CGRectMake(0.0f, 0.0f, 0.0f, 0.0f);
if (_keyboardView == nil) {
_keyboardView = [[SoftKeyboard alloc] initWithFrame:keyFrame];
@@ -218,28 +332,6 @@ bool getLocalMouseCoords(CGPoint *point) {
[self addSubview: _keyboardView];
[[_keyboardView inputView] becomeFirstResponder];
}
-
- [screenLayer setContents: _screenSurface];
- [screenLayer setOpaque: YES];
-
- if (_screenLayer != nil) {
- [[sharedInstance layer] replaceSublayer: _screenLayer with: screenLayer];
- } else {
- [[sharedInstance layer] addSublayer: screenLayer];
- }
- _screenLayer = screenLayer;
-
- CoreSurfaceBufferUnlock(_screenSurface);
- [dict release];
-}
-
-
-- (void)lock {
- [_lock lock];
-}
-
-- (void)unlock {
- [_lock unlock];
}
- (id)getEvent {
@@ -247,25 +339,20 @@ bool getLocalMouseCoords(CGPoint *point) {
return nil;
}
- [self lock];
id event = [_events objectAtIndex: 0];
[_events removeObjectAtIndex: 0];
- [self unlock];
return event;
}
- (void)addEvent:(NSDictionary*)event {
- [self lock];
if(_events == nil)
_events = [[NSMutableArray alloc] init];
[_events addObject: event];
-
- [self unlock];
}
- (void)deviceOrientationChanged:(int)orientation {
@@ -289,7 +376,6 @@ bool getLocalMouseCoords(CGPoint *point) {
{
UITouch *touch = [[allTouches allObjects] objectAtIndex:0];
CGPoint point = [touch locationInView:self];
- //point = [self convertPoint:point fromView:nil];
if (!getLocalMouseCoords(&point))
return;
@@ -307,7 +393,6 @@ bool getLocalMouseCoords(CGPoint *point) {
{
UITouch *touch = [[allTouches allObjects] objectAtIndex:1];
CGPoint point = [touch locationInView:self];
- //point = [self convertPoint:point fromView:nil];
if (!getLocalMouseCoords(&point))
return;
@@ -333,7 +418,6 @@ bool getLocalMouseCoords(CGPoint *point) {
{
UITouch *touch = [[allTouches allObjects] objectAtIndex:0];
CGPoint point = [touch locationInView:self];
- //point = [self convertPoint:point fromView:nil];
if (!getLocalMouseCoords(&point))
return;
@@ -351,7 +435,6 @@ bool getLocalMouseCoords(CGPoint *point) {
{
UITouch *touch = [[allTouches allObjects] objectAtIndex:1];
CGPoint point = [touch locationInView:self];
- //point = [self convertPoint:point fromView:nil];
if (!getLocalMouseCoords(&point))
return;
@@ -377,7 +460,6 @@ bool getLocalMouseCoords(CGPoint *point) {
{
UITouch *touch = [[allTouches allObjects] objectAtIndex:0];
CGPoint point = [touch locationInView:self];
- //point = [self convertPoint:point fromView:nil];
if (!getLocalMouseCoords(&point))
return;
@@ -395,7 +477,6 @@ bool getLocalMouseCoords(CGPoint *point) {
{
UITouch *touch = [[allTouches allObjects] objectAtIndex:1];
CGPoint point = [touch locationInView:self];
- //point = [self convertPoint:point fromView:nil];
if (!getLocalMouseCoords(&point))
return;
diff --git a/backends/platform/iphone/osys_iphone.cpp b/backends/platform/iphone/osys_iphone.cpp
index 632d0167dd..ca7ccd3154 100644
--- a/backends/platform/iphone/osys_iphone.cpp
+++ b/backends/platform/iphone/osys_iphone.cpp
@@ -26,6 +26,8 @@
#include <unistd.h>
#include <pthread.h>
+#include <sys/time.h>
+
#include "common/scummsys.h"
#include "common/util.h"
#include "common/rect.h"
@@ -41,8 +43,7 @@
#include "gui/message.h"
#include "osys_iphone.h"
-#include "blit_arm.h"
-#include <sys/time.h>
+
const OSystem::GraphicsMode OSystem_IPHONE::s_supportedGraphicsModes[] = {
{0, 0, 0}
@@ -157,11 +158,8 @@ void OSystem_IPHONE::initSize(uint width, uint height) {
_fullscreen = (uint16 *)malloc(fullSize);
bzero(_fullscreen, fullSize);
- if (_screenOrientation != kScreenOrientationPortrait)
- iPhone_initSurface(height, width, true);
- else
- iPhone_initSurface(width, height, false);
-
+ iPhone_initSurface(width, height);
+
_fullScreenIsDirty = false;
dirtyFullScreen();
_mouseVisible = false;
@@ -270,9 +268,7 @@ void OSystem_IPHONE::updateScreen() {
internUpdateScreen();
_fullScreenIsDirty = false;
- _fullScreenOverlayIsDirty = false;
-
- //memcpy(iPhone_getSurface(), _fullscreen, _screenWidth * _screenHeight * 2);
+ _fullScreenOverlayIsDirty = false;
iPhone_updateScreen();
}
@@ -311,7 +307,7 @@ void OSystem_IPHONE::internUpdateScreen() {
drawDirtyOverlayRect(dirtyRect);
drawMouseCursorOnRectUpdate(dirtyRect, mouseRect);
- updateHardwareSurfaceForRect(dirtyRect);
+ updateHardwareSurfaceForRect(dirtyRect);
}
if (_overlayVisible) {
@@ -325,71 +321,35 @@ void OSystem_IPHONE::internUpdateScreen() {
updateHardwareSurfaceForRect(dirtyRect);
}
}
-
- //iPhone_updateScreenRect(dirtyRect.left, dirtyRect.top, dirtyRect.right, dirtyRect.bottom );
}
void OSystem_IPHONE::drawDirtyRect(const Common::Rect& dirtyRect) {
int h = dirtyRect.bottom - dirtyRect.top;
int w = dirtyRect.right - dirtyRect.left;
- switch (_screenOrientation) {
- case kScreenOrientationPortrait: {
- byte *src = &_offscreen[dirtyRect.top * _screenWidth + dirtyRect.left];
- uint16 *dst = &_fullscreen[dirtyRect.top * _screenWidth + dirtyRect.left];
- for (int y = h; y > 0; y--) {
- for (int x = w; x > 0; x--)
- *dst++ = _palette[*src++];
-
- dst += _screenWidth - w;
- src += _screenWidth - w;
- }
- break;
- }
- case kScreenOrientationLandscape: {
- byte *src = &_offscreen[(dirtyRect.bottom - 1) * _screenWidth + dirtyRect.left];
- uint16 *dst = &_fullscreen[dirtyRect.left * _screenHeight + (_screenHeight - dirtyRect.bottom)];
- blitLandscapeScreenRect8bpp(dst, src, w, h, _palette, -_screenWidth, -_screenHeight);
- break;
- }
- case kScreenOrientationFlippedLandscape: {
- byte *src = &_offscreen[dirtyRect.top * _screenWidth + dirtyRect.left];
- uint16 *dst = &_fullscreen[(_screenWidth - dirtyRect.left - 1) * _screenHeight + dirtyRect.top];
- blitLandscapeScreenRect8bpp(dst, src, w, h, _palette, _screenWidth, _screenHeight);
- break;
- }
- }
+ byte *src = &_offscreen[dirtyRect.top * _screenWidth + dirtyRect.left];
+ uint16 *dst = &_fullscreen[dirtyRect.top * _screenWidth + dirtyRect.left];
+ for (int y = h; y > 0; y--) {
+ for (int x = w; x > 0; x--)
+ *dst++ = _palette[*src++];
+
+ dst += _screenWidth - w;
+ src += _screenWidth - w;
+ }
}
void OSystem_IPHONE::drawDirtyOverlayRect(const Common::Rect& dirtyRect) {
int h = dirtyRect.bottom - dirtyRect.top;
int w = dirtyRect.right - dirtyRect.left;
- switch (_screenOrientation) {
- case kScreenOrientationPortrait: {
- uint16 *src = (uint16 *)&_overlayBuffer[dirtyRect.top * _screenWidth + dirtyRect.left];
- uint16 *dst = &_fullscreen[dirtyRect.top * _screenWidth + dirtyRect.left];
- int x = (dirtyRect.right - dirtyRect.left) * 2;
- for (int y = h; y > 0; y--) {
- memcpy(dst, src, x);
- src += _screenWidth;
- dst += _screenWidth;
- }
- break;
- }
- case kScreenOrientationLandscape: {
- uint16 *src = (uint16 *)&_overlayBuffer[(dirtyRect.bottom - 1) * _screenWidth + dirtyRect.left];
- uint16 *dst = &_fullscreen[dirtyRect.left * _screenHeight + (_screenHeight - dirtyRect.bottom)];
- blitLandscapeScreenRect16bpp(dst, src, w, h, -_screenWidth, -_screenHeight);
- break;
- }
- case kScreenOrientationFlippedLandscape: {
- uint16 *src = (uint16 *)&_overlayBuffer[dirtyRect.top * _screenWidth + dirtyRect.left];
- uint16 *dst = &_fullscreen[(_screenWidth - dirtyRect.left - 1) * _screenHeight + dirtyRect.top];
- blitLandscapeScreenRect16bpp(dst, src, dirtyRect.right - dirtyRect.left, h, _screenWidth, _screenHeight);
- break;
- }
- }
+ uint16 *src = (uint16 *)&_overlayBuffer[dirtyRect.top * _screenWidth + dirtyRect.left];
+ uint16 *dst = &_fullscreen[dirtyRect.top * _screenWidth + dirtyRect.left];
+ int x = (dirtyRect.right - dirtyRect.left) * 2;
+ for (int y = h; y > 0; y--) {
+ memcpy(dst, src, x);
+ src += _screenWidth;
+ dst += _screenWidth;
+ }
}
void OSystem_IPHONE::drawMouseCursorOnRectUpdate(const Common::Rect& updatedRect, const Common::Rect& mouseRect) {
@@ -417,104 +377,23 @@ void OSystem_IPHONE::drawMouseCursorOnRectUpdate(const Common::Rect& updatedRect
int displayHeight = _mouseHeight;
if (_mouseHeight + top > _screenHeight)
displayHeight = _screenHeight - top;
- switch (_screenOrientation) {
- case kScreenOrientationPortrait: {
- byte *src = &_mouseBuf[srcY * _mouseWidth + srcX];
- uint16 *dst = &_fullscreen[top * _screenWidth + left];
- for (int y = displayHeight; y > srcY; y--) {
- for (int x = displayWidth; x > srcX; x--) {
- if (*src != _mouseKeyColour)
- *dst = _palette[*src];
- dst++;
- src++;
- }
- dst += _screenWidth - displayWidth + srcX;
- src += _mouseWidth - displayWidth + srcX;
- }
- break;
- }
- case kScreenOrientationLandscape: {
- byte *src = &_mouseBuf[(_mouseHeight - 1 - srcY) * _mouseWidth + srcX];
- uint16 *dst = &_fullscreen[left * _screenHeight + (_screenHeight - bottom + srcY)];
- for (int x = displayWidth; x > srcX; x--) {
- for (int y = displayHeight; y > srcY; y--) {
- if (*src != _mouseKeyColour)
- *dst = _palette[*src];
- dst++;
- src -= _mouseWidth;
- }
- dst -= -_screenHeight + displayHeight - srcY;
- src += 1 - (displayHeight - srcY) * -_mouseWidth;
- }
- break;
- }
- case kScreenOrientationFlippedLandscape: {
- byte *src = &_mouseBuf[srcY * _mouseWidth + srcX];
- uint16 *dst = &_fullscreen[(_screenWidth - left - 1) * _screenHeight + top];
- for (int x = displayWidth; x > srcX; x--) {
- for (int y = displayHeight; y > srcY; y--) {
- if (*src != _mouseKeyColour)
- *dst = _palette[*src];
- dst++;
- src += _mouseWidth;
- }
- dst -= _screenHeight + displayHeight - srcY;
- src += 1 - (displayHeight - srcY) * _mouseWidth;
- }
- break;
+ byte *src = &_mouseBuf[srcY * _mouseWidth + srcX];
+ uint16 *dst = &_fullscreen[top * _screenWidth + left];
+ for (int y = displayHeight; y > srcY; y--) {
+ for (int x = displayWidth; x > srcX; x--) {
+ if (*src != _mouseKeyColour)
+ *dst = _palette[*src];
+ dst++;
+ src++;
}
+ dst += _screenWidth - displayWidth + srcX;
+ src += _mouseWidth - displayWidth + srcX;
}
}
}
void OSystem_IPHONE::updateHardwareSurfaceForRect(const Common::Rect& updatedRect) {
- uint16 *surface = iPhone_getSurface();
-
- int h = updatedRect.bottom - updatedRect.top;
- int w = updatedRect.right - updatedRect.left;
-
- if (w == _screenWidth && h == _screenHeight)
- memcpy(surface, _fullscreen, _screenWidth * _screenHeight * 2);
- else {
- switch (_screenOrientation) {
- case kScreenOrientationPortrait: {
- int width = w * 2;
- int offset = updatedRect.top * _screenWidth + updatedRect.left;
- uint16 *fs = _fullscreen + offset;
- surface += offset;
- for (int y = h; y > 0; y--) {
- memcpy(surface, fs, width);
- surface += _screenWidth;
- fs += _screenWidth;
- }
- break;
- }
- case kScreenOrientationLandscape: {
- int height = h * 2;
- int offset = updatedRect.left * _screenHeight + (_screenHeight - updatedRect.bottom);
- uint16 *fs = _fullscreen + offset;
- surface += offset;
- for (int x = w; x > 0; x--) {
- memcpy(surface, fs, height);
- surface += _screenHeight;
- fs += _screenHeight;
- }
- break;
- }
- case kScreenOrientationFlippedLandscape: {
- int height = h * 2;
- int offset = ((_screenWidth - updatedRect.left - 1) * _screenHeight + updatedRect.top);
- uint16 *fs = _fullscreen + offset;
- surface += offset;
- for (int x = w; x > 0; x--) {
- memcpy(surface, fs, height);
- surface -= _screenHeight;
- fs -= _screenHeight;
- }
- break;
- }
- }
- }
+ iPhone_updateScreenRect(_fullscreen, updatedRect.left, updatedRect.top, updatedRect.right, updatedRect.bottom );
}
Graphics::Surface *OSystem_IPHONE::lockScreen() {
@@ -1015,11 +894,8 @@ void OSystem_IPHONE::handleEvent_orientationChanged(int orientation) {
if (_screenOrientation != newOrientation) {
_screenOrientation = newOrientation;
- if (_screenOrientation != kScreenOrientationPortrait)
- iPhone_initSurface(_screenHeight, _screenWidth, true);
- else
- iPhone_initSurface(_screenWidth, _screenHeight, false);
-
+ iPhone_initSurface(_screenWidth, _screenHeight);
+
dirtyFullScreen();
if (_overlayVisible)
dirtyFullOverlayScreen();
@@ -1406,12 +1282,12 @@ void iphone_main(int argc, char *argv[]) {
//gDebugLevel = 10;
}
- system("mkdir " SCUMMVM_ROOT_PATH);
- system("mkdir " SCUMMVM_SAVE_PATH);
-
#ifdef IPHONE_OFFICIAL
chdir( iPhone_getDocumentsDir() );
#else
+ system("mkdir " SCUMMVM_ROOT_PATH);
+ system("mkdir " SCUMMVM_SAVE_PATH);
+
chdir("/var/mobile/");
#endif