diff options
Diffstat (limited to 'backends')
26 files changed, 498 insertions, 357 deletions
diff --git a/backends/fs/abstract-fs.h b/backends/fs/abstract-fs.h index 8125ad7d95..97de40a2fc 100644 --- a/backends/fs/abstract-fs.h +++ b/backends/fs/abstract-fs.h @@ -64,7 +64,7 @@ protected: * * @param name String containing the name of the child to create a new node. */ - virtual AbstractFilesystemNode *getChild(const String &name) const = 0; + virtual AbstractFilesystemNode *getChild(const Common::String &name) const = 0; /** * The parent node of this directory. @@ -100,7 +100,7 @@ public: * * @note By default, this method returns the value of getName(). */ - virtual String getDisplayName() const { return getName(); } + virtual Common::String getDisplayName() const { return getName(); } /** * Returns the last component of the path pointed by this FilesystemNode. @@ -111,12 +111,12 @@ public: * * @note This method is very architecture dependent, please check the concrete implementation for more information. */ - virtual String getName() const = 0; + virtual Common::String getName() const = 0; /** * Returns the 'path' of the current node, usable in fopen(). */ - virtual String getPath() const = 0; + virtual Common::String getPath() const = 0; /** * Indicates whether this path refers to a directory or not. diff --git a/backends/fs/posix/posix-fs.cpp b/backends/fs/posix/posix-fs.cpp index 5cde32c851..10782a9057 100644 --- a/backends/fs/posix/posix-fs.cpp +++ b/backends/fs/posix/posix-fs.cpp @@ -42,8 +42,8 @@ */ class POSIXFilesystemNode : public AbstractFilesystemNode { protected: - String _displayName; - String _path; + Common::String _displayName; + Common::String _path; bool _isDirectory; bool _isValid; @@ -59,17 +59,17 @@ public: * @param path String with the path the new node should point to. * @param verify true if the isValid and isDirectory flags should be verified during the construction. */ - POSIXFilesystemNode(const String &path, bool verify); + POSIXFilesystemNode(const Common::String &path, bool verify); virtual bool exists() const { return access(_path.c_str(), F_OK) == 0; } - virtual String getDisplayName() const { return _displayName; } - virtual String getName() const { return _displayName; } - virtual String getPath() const { return _path; } + virtual Common::String getDisplayName() const { return _displayName; } + virtual Common::String getName() const { return _displayName; } + virtual Common::String getPath() const { return _path; } virtual bool isDirectory() const { return _isDirectory; } virtual bool isReadable() const { return access(_path.c_str(), R_OK) == 0; } virtual bool isWritable() const { return access(_path.c_str(), W_OK) == 0; } - virtual AbstractFilesystemNode *getChild(const String &n) const; + virtual AbstractFilesystemNode *getChild(const Common::String &n) const; virtual bool getChildren(AbstractFSList &list, ListMode mode, bool hidden) const; virtual AbstractFilesystemNode *getParent() const; @@ -119,7 +119,7 @@ POSIXFilesystemNode::POSIXFilesystemNode() { _isDirectory = true; } -POSIXFilesystemNode::POSIXFilesystemNode(const String &p, bool verify) { +POSIXFilesystemNode::POSIXFilesystemNode(const Common::String &p, bool verify) { assert(p.size() > 0); // Expand "~/" to the value of the HOME env variable @@ -142,12 +142,12 @@ POSIXFilesystemNode::POSIXFilesystemNode(const String &p, bool verify) { } } -AbstractFilesystemNode *POSIXFilesystemNode::getChild(const String &n) const { +AbstractFilesystemNode *POSIXFilesystemNode::getChild(const Common::String &n) const { // FIXME: Pretty lame implementation! We do no error checking to speak // of, do not check if this is a special node, etc. assert(_isDirectory); - String newPath(_path); + Common::String newPath(_path); if (_path.lastChar() != '/') newPath += '/'; newPath += n; @@ -175,7 +175,7 @@ bool POSIXFilesystemNode::getChildren(AbstractFSList &myList, ListMode mode, boo continue; } - String newPath(_path); + Common::String newPath(_path); if (newPath.lastChar() != '/') newPath += '/'; newPath += dp->d_name; @@ -236,7 +236,7 @@ AbstractFilesystemNode *POSIXFilesystemNode::getParent() const { const char *start = _path.c_str(); const char *end = lastPathComponent(_path); - return new POSIXFilesystemNode(String(start, end - start), true); + return new POSIXFilesystemNode(Common::String(start, end - start), true); } #endif //#if defined(UNIX) diff --git a/backends/fs/windows/windows-fs.cpp b/backends/fs/windows/windows-fs.cpp index cbb93e8cd6..ac2f521e21 100644 --- a/backends/fs/windows/windows-fs.cpp +++ b/backends/fs/windows/windows-fs.cpp @@ -245,7 +245,7 @@ WindowsFilesystemNode::WindowsFilesystemNode(const String &p, const bool current _isDirectory = ((fileAttribs & FILE_ATTRIBUTE_DIRECTORY) != 0); _isValid = true; // Add a trailing slash, if necessary. - if (_path.lastChar() != '\\') { + if (_isDirectory && _path.lastChar() != '\\') { _path += '\\'; } } diff --git a/backends/platform/PalmOS/Src/be_base.cpp b/backends/platform/PalmOS/Src/be_base.cpp index afb3f15bae..32e68bde9f 100644 --- a/backends/platform/PalmOS/Src/be_base.cpp +++ b/backends/platform/PalmOS/Src/be_base.cpp @@ -30,6 +30,9 @@ #include "backends/timer/default/default-timer.h" #include "sound/mixer.h" +#define DEFAULT_SAVE_PATH "/PALM/Programs/ScummVM/Saved" + + OSystem_PalmBase::OSystem_PalmBase() { _overlayVisible = false; @@ -100,7 +103,7 @@ void OSystem_PalmBase::initBackend() { // Create the savefile manager, if none exists yet (we check for this to // allow subclasses to provide their own). if (_saveMgr == 0) { - _saveMgr = new DefaultSaveFileManager(); + _saveMgr = new DefaultSaveFileManager(DEFAULT_SAVE_PATH); } // Create and hook up the mixer, if none exists yet (we check for this to diff --git a/backends/platform/gp2x/gp2x.cpp b/backends/platform/gp2x/gp2x.cpp index c138f6c54d..e5f062ed35 100644 --- a/backends/platform/gp2x/gp2x.cpp +++ b/backends/platform/gp2x/gp2x.cpp @@ -219,7 +219,7 @@ void OSystem_GP2X::initBackend() { // Create the savefile manager, if none exists yet (we check for this to // allow subclasses to provide their own). if (_savefile == 0) { - _savefile = new DefaultSaveFileManager(); + _savefile = new DefaultSaveFileManager(savePath); } // Create and hook up the mixer, if none exists yet (we check for this to diff --git a/backends/platform/iphone/blit_arm.s b/backends/platform/iphone/blit_arm.s index ae31fdcce4..417f3741cf 100644 --- a/backends/platform/iphone/blit_arm.s +++ b/backends/platform/iphone/blit_arm.s @@ -36,47 +36,47 @@ _blitLandscapeScreenRect16bpp: @ r3 = h @ <> = _screenWidth @ <> = _screenHeight - MOV r12,r13 - STMFD r13!,{r4-r11,r14} - LDMFD r12,{r12,r14} @ r12 = _screenWidth + mov r12,r13 + stmfd r13!,{r4-r11,r14} + ldmfd r12,{r12,r14} @ r12 = _screenWidth @ r14 = _screenHeight - ADD r14,r14,r3 @ r14 = _screenHeight + h - MVN r11,#0 - MLA r11,r3,r12,r11 @ r11= _screenWidth*h-1 - ADD r12,r12,r12 + add r14,r14,r3 @ r14 = _screenHeight + h + mvn r11,#0 + mla r11,r3,r12,r11 @ r11= _screenWidth*h-1 + add r12,r12,r12 xloop: - SUBS r4,r3,#5 @ r4 = y = h - BLE thin + subs r4,r3,#5 @ r4 = y = h + ble thin yloop: - LDRH r5, [r1],r12 @ r5 = *src src += _screenWidth - LDRH r6, [r1],r12 @ r6 = *src src += _screenWidth - LDRH r7, [r1],r12 @ r7 = *src src += _screenWidth - LDRH r8, [r1],r12 @ r8 = *src src += _screenWidth - LDRH r9, [r1],r12 @ r9 = *src src += _screenWidth - LDRH r10,[r1],r12 @ r10= *src src += _screenWidth - SUBS r4,r4,#6 - STRH r5, [r0],#2 @ *dst++ = r5 - STRH r6, [r0],#2 @ *dst++ = r6 - STRH r7, [r0],#2 @ *dst++ = r7 - STRH r8, [r0],#2 @ *dst++ = r8 - STRH r9, [r0],#2 @ *dst++ = r9 - STRH r10,[r0],#2 @ *dst++ = r10 - BGT yloop + ldrh r5, [r1],r12 @ r5 = *src src += _screenWidth + ldrh r6, [r1],r12 @ r6 = *src src += _screenWidth + ldrh r7, [r1],r12 @ r7 = *src src += _screenWidth + ldrh r8, [r1],r12 @ r8 = *src src += _screenWidth + ldrh r9, [r1],r12 @ r9 = *src src += _screenWidth + ldrh r10,[r1],r12 @ r10= *src src += _screenWidth + subs r4,r4,#6 + strh r5, [r0],#2 @ *dst++ = r5 + strh r6, [r0],#2 @ *dst++ = r6 + strh r7, [r0],#2 @ *dst++ = r7 + strh r8, [r0],#2 @ *dst++ = r8 + strh r9, [r0],#2 @ *dst++ = r9 + strh r10,[r0],#2 @ *dst++ = r10 + bgt yloop thin: - ADDS r4,r4,#5 - BEQ lineend + adds r4,r4,#5 + beq lineend thin_loop: - LDRH r5,[r1],r12 @ r5 = *src src += _screenWidth - SUBS r4,r4,#1 - STRH r5,[r0],#2 @ *dst++ = r5 - BGT thin_loop + ldrh r5,[r1],r12 @ r5 = *src src += _screenWidth + subs r4,r4,#1 + strh r5,[r0],#2 @ *dst++ = r5 + bgt thin_loop lineend: - SUB r0,r0,r14,LSL #1 @ dst -= _screenHeight + h - SUB r1,r1,r11,LSL #1 @ src += 1-_screenWidth*h - SUBS r2,r2,#1 - BGT xloop + sub r0,r0,r14,LSL #1 @ dst -= _screenHeight + h + sub r1,r1,r11,LSL #1 @ src += 1-_screenWidth*h + subs r2,r2,#1 + bgt xloop - LDMFD r13!,{r4-r11,PC} + ldmfd r13!,{r4-r11,PC} _blitLandscapeScreenRect8bpp: @ r0 = dst @@ -86,55 +86,55 @@ _blitLandscapeScreenRect8bpp: @ <> = _palette @ <> = _screenWidth @ <> = _screenHeight - MOV r12,r13 - STMFD r13!,{r4-r11,r14} - LDMFD r12,{r11,r12,r14} @ r11 = _palette + mov r12,r13 + stmfd r13!,{r4-r11,r14} + ldmfd r12,{r11,r12,r14} @ r11 = _palette @ r12 = _screenWidth @ r14 = _screenHeight - ADD r14,r14,r3 @ r14 = _screenHeight + h - MVN r6,#0 - MLA r6,r3,r12,r6 @ r6 = _screenWidth*h-1 + add r14,r14,r3 @ r14 = _screenHeight + h + mvn r6,#0 + mla r6,r3,r12,r6 @ r6 = _screenWidth*h-1 xloop8: - MOV r4,r3 @ r4 = y = h - SUBS r4,r3,#4 @ r4 = y = h - BLE thin8 + mov r4,r3 @ r4 = y = h + subs r4,r3,#4 @ r4 = y = h + ble thin8 yloop8: - LDRB r5, [r1],r12 @ r5 = *src src += _screenWidth - LDRB r7, [r1],r12 @ r7 = *src src += _screenWidth - LDRB r8, [r1],r12 @ r8 = *src src += _screenWidth - LDRB r9, [r1],r12 @ r9 = *src src += _screenWidth - LDRB r10,[r1],r12 @ r10= *src src += _screenWidth - ADD r5, r5, r5 - ADD r7, r7, r7 - ADD r8, r8, r8 - ADD r9, r9, r9 - ADD r10,r10,r10 - LDRH r5, [r11,r5] - LDRH r7, [r11,r7] - LDRH r8, [r11,r8] - LDRH r9, [r11,r9] - LDRH r10,[r11,r10] - SUBS r4,r4,#5 - STRH r5, [r0],#2 @ *dst++ = r5 - STRH r7, [r0],#2 @ *dst++ = r7 - STRH r8, [r0],#2 @ *dst++ = r8 - STRH r9, [r0],#2 @ *dst++ = r9 - STRH r10,[r0],#2 @ *dst++ = r10 - BGT yloop8 + ldrb r5, [r1],r12 @ r5 = *src src += _screenWidth + ldrb r7, [r1],r12 @ r7 = *src src += _screenWidth + ldrb r8, [r1],r12 @ r8 = *src src += _screenWidth + ldrb r9, [r1],r12 @ r9 = *src src += _screenWidth + ldrb r10,[r1],r12 @ r10= *src src += _screenWidth + add r5, r5, r5 + add r7, r7, r7 + add r8, r8, r8 + add r9, r9, r9 + add r10,r10,r10 + ldrh r5, [r11,r5] + ldrh r7, [r11,r7] + ldrh r8, [r11,r8] + ldrh r9, [r11,r9] + ldrh r10,[r11,r10] + subs r4,r4,#5 + strh r5, [r0],#2 @ *dst++ = r5 + strh r7, [r0],#2 @ *dst++ = r7 + strh r8, [r0],#2 @ *dst++ = r8 + strh r9, [r0],#2 @ *dst++ = r9 + strh r10,[r0],#2 @ *dst++ = r10 + bgt yloop8 thin8: - ADDS r4,r4,#4 - BEQ lineend8 + adds r4,r4,#4 + beq lineend8 thin_loop8: - LDRB r5,[r1],r12 @ r5 = *src src += _screenWidth - ADD r5,r5,r5 - LDRH r5,[r11,r5] - SUBS r4,r4,#1 - STRH r5,[r0],#2 @ *dst++ = r5 - BGT thin_loop8 + ldrb r5,[r1],r12 @ r5 = *src src += _screenWidth + add r5,r5,r5 + ldrh r5,[r11,r5] + subs r4,r4,#1 + strh r5,[r0],#2 @ *dst++ = r5 + bgt thin_loop8 lineend8: - SUB r0,r0,r14,LSL #1 @ dst -= _screenHeight + h - SUB r1,r1,r6 @ src += 1-_screenWidth*h - SUBS r2,r2,#1 - BGT xloop8 + sub r0,r0,r14,LSL #1 @ dst -= _screenHeight + h + sub r1,r1,r6 @ src += 1-_screenWidth*h + subs r2,r2,#1 + bgt xloop8 - LDMFD r13!,{r4-r11,PC} + ldmfd r13!,{r4-r11,PC} diff --git a/backends/platform/iphone/iphone_keyboard.h b/backends/platform/iphone/iphone_keyboard.h index 17a3836efd..6d381d561d 100644 --- a/backends/platform/iphone/iphone_keyboard.h +++ b/backends/platform/iphone/iphone_keyboard.h @@ -26,11 +26,7 @@ #import <UIKit/UIKit.h> #import <UIKit/UITextView.h> -@protocol KeyboardInputProtocol -- (void)handleKeyPress:(unichar)c; -@end - -@interface SoftKeyboard : UIKeyboard<KeyboardInputProtocol> { +@interface SoftKeyboard : UIView { id inputDelegate; UITextView* inputView; } diff --git a/backends/platform/iphone/iphone_keyboard.m b/backends/platform/iphone/iphone_keyboard.m index dc2d417746..bd4948e30a 100644 --- a/backends/platform/iphone/iphone_keyboard.m +++ b/backends/platform/iphone/iphone_keyboard.m @@ -25,19 +25,6 @@ #import "iphone_keyboard.h" -// Override settings of the default keyboard implementation -@implementation UIKeyboardImpl (DisableFeatures) - -- (BOOL)autoCapitalizationPreference { - return false; -} - -- (BOOL)autoCorrectionPreference { - return false; -} - -@end - @implementation TextInputHandler - (id)initWithKeyboard:(SoftKeyboard*)keyboard; { @@ -67,7 +54,8 @@ @implementation SoftKeyboard - (id)initWithFrame:(CGRect)frame { - self = [super initWithFrame:frame]; + //self = [super initWithFrame:frame]; + self = [super initWithFrame:CGRectMake(0.0f, 0.0f, 0.0f, 0.0f)]; inputDelegate = nil; inputView = [[TextInputHandler alloc] initWithKeyboard:self]; return self; diff --git a/backends/platform/iphone/iphone_main.m b/backends/platform/iphone/iphone_main.m index f7f5667bb5..b01e9f3f34 100644 --- a/backends/platform/iphone/iphone_main.m +++ b/backends/platform/iphone/iphone_main.m @@ -46,9 +46,14 @@ int main(int argc, char** argv) { gArgc = argc; gArgv = argv; - [[NSAutoreleasePool alloc] init]; - - return UIApplicationMain(argc, argv, [iPhoneMain class]); + NSAutoreleasePool *autoreleasePool = [ + [ NSAutoreleasePool alloc ] init + ]; + + UIApplicationUseLegacyEvents(1); + int returnCode = UIApplicationMain(argc, argv, [iPhoneMain class]); + [ autoreleasePool release ]; + return returnCode; } @implementation iPhoneMain @@ -74,7 +79,10 @@ int main(int argc, char** argv) { - (void)applicationDidFinishLaunching:(NSNotification *)aNotification { // hide the status bar [UIHardware _setStatusBarHeight:0.0f]; - [self setStatusBarMode:2 orientation:0 duration:0.0f fenceID:0]; + //[self setStatusBarMode:2 orientation:0 duration:0.0f fenceID:0]; + + //[self setStatusBarStyle:UIStatusBarStyleBlackTranslucent animated:NO]; + [self setStatusBarHidden:YES animated:YES]; _window = [[UIWindow alloc] initWithContentRect: [UIHardware fullScreenApplicationContentRect]]; [_window retain]; @@ -96,7 +104,7 @@ int main(int argc, char** argv) { - (void)applicationResume:(GSEventRef)event { [self removeApplicationBadge]; [UIHardware _setStatusBarHeight:0.0f]; - [self setStatusBarMode:2 orientation:0 duration:0.0f fenceID:0]; + [self setStatusBarHidden:YES animated:YES]; [_view applicationResume]; } diff --git a/backends/platform/iphone/iphone_video.h b/backends/platform/iphone/iphone_video.h index 615b2e5345..6e4b446926 100644 --- a/backends/platform/iphone/iphone_video.h +++ b/backends/platform/iphone/iphone_video.h @@ -27,12 +27,11 @@ #define _IPHONE_VIDEO__H #import <UIKit/UIKit.h> -#import <UIKit/UIView-Geometry.h> #import <GraphicsServices/GraphicsServices.h> #import <Foundation/Foundation.h> #import <CoreSurface/CoreSurface.h> -#import <LayerKit/LKLayer.h> +#import <QuartzCore/QuartzCore.h> #import "iphone_keyboard.h" @interface iPhoneView : UIView @@ -41,7 +40,7 @@ NSMutableArray* _events; NSLock* _lock; SoftKeyboard* _keyboardView; - LKLayer* _screenLayer; + CALayer* _screenLayer; int _fullWidth; int _fullHeight; diff --git a/backends/platform/iphone/iphone_video.m b/backends/platform/iphone/iphone_video.m index 6c6944045e..89f159c1d9 100644 --- a/backends/platform/iphone/iphone_video.m +++ b/backends/platform/iphone/iphone_video.m @@ -31,8 +31,8 @@ #import <GraphicsServices/GraphicsServices.h> #import <Foundation/Foundation.h> #import <CoreSurface/CoreSurface.h> -#import <LayerKit/LKLayer.h> #import <UIKit/UIKeyboardLayoutQWERTY.h> +#import <QuartzCore/QuartzCore.h> static iPhoneView *sharedInstance = nil; static int _width = 0; @@ -53,8 +53,8 @@ void iPhone_updateScreen() { } void iPhone_updateScreenRect(int x1, int y1, int x2, int y2) { - NSRect rect = NSMakeRect(x1, y1, x2, y2); - [sharedInstance performSelectorOnMainThread:@selector(updateScreenRect:) withObject: [NSValue valueWithRect:rect] waitUntilDone: NO]; + //CGRect rect = CGRectMake(x1, y1, x2, y2); + //[sharedInstance performSelectorOnMainThread:@selector(updateScreenRect:) withObject: [NSValue valueWithRect:rect] waitUntilDone: NO]; } void iPhone_lockSurface() { @@ -146,9 +146,9 @@ 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]; + // NSRect nsRect = [rect rectValue]; + // CGRect cgRect = CGRectMake(nsRect.origin.x, nsRect.origin.y, nsRect.size.width, nsRect.size.height); + // [sharedInstance setNeedsDisplayInRect: cgRect]; } - (void)initSurface { @@ -178,7 +178,7 @@ bool getLocalMouseCoords(CGPoint *point) { //printf("Surface created.\n"); CoreSurfaceBufferLock(_screenSurface, 3); - LKLayer* screenLayer = [[LKLayer layer] retain]; + CALayer* screenLayer = [[CALayer layer] retain]; if (_keyboardView != nil) { [_keyboardView removeFromSuperview]; @@ -213,7 +213,7 @@ bool getLocalMouseCoords(CGPoint *point) { _keyboardView = [[SoftKeyboard alloc] initWithFrame:keyFrame]; [_keyboardView setInputDelegate:self]; } - + [self addSubview:[_keyboardView inputView]]; [self addSubview: _keyboardView]; [[_keyboardView inputView] becomeFirstResponder]; @@ -283,11 +283,13 @@ bool getLocalMouseCoords(CGPoint *point) { } - (void)mouseDown:(GSEvent*)event { - struct CGPoint point = GSEventGetLocationInWindow(event); - + //printf("mouseDown()\n"); + CGRect rect = GSEventGetLocationInWindow(event); + CGPoint point = CGPointMake(rect.origin.x, rect.origin.y); + if (!getLocalMouseCoords(&point)) return; - + [self addEvent: [[NSDictionary alloc] initWithObjectsAndKeys: [NSNumber numberWithInt:kInputMouseDown], @"type", @@ -298,12 +300,18 @@ bool getLocalMouseCoords(CGPoint *point) { ]; } +- (void)touchesBegan { + //printf("touchesBegan()\n"); +} + - (void)mouseUp:(GSEvent*)event { - struct CGPoint point = GSEventGetLocationInWindow(event); - + //printf("mouseUp()\n"); + CGRect rect = GSEventGetLocationInWindow(event); + CGPoint point = CGPointMake(rect.origin.x, rect.origin.y); + if (!getLocalMouseCoords(&point)) return; - + [self addEvent: [[NSDictionary alloc] initWithObjectsAndKeys: [NSNumber numberWithInt:kInputMouseUp], @"type", @@ -316,11 +324,12 @@ bool getLocalMouseCoords(CGPoint *point) { - (void)mouseDragged:(GSEvent*)event { //printf("mouseDragged()\n"); - struct CGPoint point = GSEventGetLocationInWindow(event); - + CGRect rect = GSEventGetLocationInWindow(event); + CGPoint point = CGPointMake(rect.origin.x, rect.origin.y); + if (!getLocalMouseCoords(&point)) return; - + [self addEvent: [[NSDictionary alloc] initWithObjectsAndKeys: [NSNumber numberWithInt:kInputMouseDragged], @"type", @@ -333,19 +342,21 @@ bool getLocalMouseCoords(CGPoint *point) { - (void)mouseEntered:(GSEvent*)event { //printf("mouseEntered()\n"); - // struct CGPoint point = GSEventGetLocationInWindow(event); - // - // if (!getLocalMouseCoords(&point)) - // return; - // - // [self addEvent: - // [[NSDictionary alloc] initWithObjectsAndKeys: - // [NSNumber numberWithInt:kInputMouseSecondToggled], @"type", - // [NSNumber numberWithFloat:point.x], @"x", - // [NSNumber numberWithFloat:point.y], @"y", - // nil - // ] - // ]; + CGRect rect = GSEventGetLocationInWindow(event); + CGPoint point = CGPointMake(rect.origin.x, rect.origin.y); + + + if (!getLocalMouseCoords(&point)) + return; + + [self addEvent: + [[NSDictionary alloc] initWithObjectsAndKeys: + [NSNumber numberWithInt:kInputMouseSecondToggled], @"type", + [NSNumber numberWithFloat:point.x], @"x", + [NSNumber numberWithFloat:point.y], @"y", + nil + ] + ]; } - (void)mouseExited:(GSEvent*)event { @@ -361,19 +372,19 @@ bool getLocalMouseCoords(CGPoint *point) { - (void)mouseMoved:(GSEvent*)event { //printf("mouseMoved()\n"); - struct CGPoint point = GSEventGetLocationInWindow(event); - - if (!getLocalMouseCoords(&point)) - return; - - [self addEvent: - [[NSDictionary alloc] initWithObjectsAndKeys: - [NSNumber numberWithInt:kInputMouseSecondToggled], @"type", - [NSNumber numberWithFloat:point.x], @"x", - [NSNumber numberWithFloat:point.y], @"y", - nil - ] - ]; + // struct CGPoint point = GSEventGetLocationInWindow(event); + // + // if (!getLocalMouseCoords(&point)) + // return; + // + // [self addEvent: + // [[NSDictionary alloc] initWithObjectsAndKeys: + // [NSNumber numberWithInt:kInputMouseSecondToggled], @"type", + // [NSNumber numberWithFloat:point.x], @"x", + // [NSNumber numberWithFloat:point.y], @"y", + // nil + // ] + // ]; } - (void)handleKeyPress:(unichar)c { @@ -391,7 +402,7 @@ bool getLocalMouseCoords(CGPoint *point) { return TRUE; } -- (int)swipe:(UIViewSwipeDirection)num withEvent:(GSEvent*)event { +- (int)swipe:(int)num withEvent:(GSEvent*)event { //printf("swipe: %i\n", num); [self addEvent: diff --git a/backends/platform/iphone/osys_iphone.cpp b/backends/platform/iphone/osys_iphone.cpp index 4cb90d35b9..3d5571cf3a 100644 --- a/backends/platform/iphone/osys_iphone.cpp +++ b/backends/platform/iphone/osys_iphone.cpp @@ -25,8 +25,6 @@ #if defined(IPHONE_BACKEND) -#include <CoreGraphics/CGDirectDisplay.h> -#include <CoreSurface/CoreSurface.h> #include <unistd.h> #include <pthread.h> @@ -41,10 +39,15 @@ #include "backends/saves/default/default-saves.h" #include "backends/timer/default/default-timer.h" #include "sound/mixer.h" +#include "sound/mixer_intern.h" #include "gui/message.h" #include "osys_iphone.h" #include "blit_arm.h" +#include <sys/time.h> + +#include <CoreGraphics/CGDirectDisplay.h> +#include <CoreSurface/CoreSurface.h> const OSystem::GraphicsMode OSystem_IPHONE::s_supportedGraphicsModes[] = { {0, 0, 0} @@ -85,13 +88,13 @@ int OSystem_IPHONE::timerHandler(int t) { } void OSystem_IPHONE::initBackend() { - _savefile = new DefaultSaveFileManager(); - _mixer = new Audio::Mixer(); + _savefile = new DefaultSaveFileManager(SCUMMVM_SAVE_PATH); _timer = new DefaultTimerManager(); gettimeofday(&_startTime, NULL); - setSoundCallback(Audio::Mixer::mixCallback, _mixer); + setupMixer(); + setTimerCallback(&OSystem_IPHONE::timerHandler, 10); OSystem::initBackend(); @@ -871,7 +874,7 @@ bool OSystem_IPHONE::pollEvent(Common::Event &event) { suspendLoop(); break; - case kInputKeyPressed: + case kInputKeyPressed: { int keyPressed = (int)xUnit; int ascii = keyPressed; //printf("key: %i\n", keyPressed); @@ -932,6 +935,7 @@ bool OSystem_IPHONE::pollEvent(Common::Event &event) { event.kbd.ascii = _queuedInputEvent.kbd.ascii = ascii; _needEventRestPeriod = true; break; + } case kInputSwipe: { Common::KeyCode keycode = Common::KEYCODE_INVALID; @@ -1088,10 +1092,21 @@ void OSystem_IPHONE::AQBufferCallback(void *in, AudioQueueRef inQ, AudioQueueBuf AudioQueueStop(s_AudioQueue.queue, false); } -bool OSystem_IPHONE::setSoundCallback(SoundProc proc, void *param) { +void OSystem_IPHONE::mixCallback(void *sys, byte *samples, int len) { + OSystem_IPHONE *this_ = (OSystem_IPHONE *)sys; + assert(this_); + + if (this_->_mixer) + this_->_mixer->mixCallback(samples, len); +} + +void OSystem_IPHONE::setupMixer() { //printf("setSoundCallback()\n"); - s_soundCallback = proc; - s_soundParam = param; + _mixer = new Audio::MixerImpl(this); + + s_soundCallback = mixCallback; + s_soundParam = this; + s_AudioQueue.dataFormat.mSampleRate = AUDIO_SAMPLE_RATE; s_AudioQueue.dataFormat.mFormatID = kAudioFormatLinearPCM; @@ -1105,7 +1120,8 @@ bool OSystem_IPHONE::setSoundCallback(SoundProc proc, void *param) { if (AudioQueueNewOutput(&s_AudioQueue.dataFormat, AQBufferCallback, &s_AudioQueue, 0, kCFRunLoopCommonModes, 0, &s_AudioQueue.queue)) { printf("Couldn't set the AudioQueue callback!\n"); - return false; + _mixer->setReady(false); + return; } uint32 bufferBytes = s_AudioQueue.frameCount * s_AudioQueue.dataFormat.mBytesPerFrame; @@ -1113,7 +1129,8 @@ bool OSystem_IPHONE::setSoundCallback(SoundProc proc, void *param) { for (int i = 0; i < AUDIO_BUFFERS; i++) { if (AudioQueueAllocateBuffer(s_AudioQueue.queue, bufferBytes, &s_AudioQueue.buffers[i])) { printf("Error allocating AudioQueue buffer!\n"); - return false; + _mixer->setReady(false); + return; } AQBufferCallback(&s_AudioQueue, s_AudioQueue.queue, s_AudioQueue.buffers[i]); @@ -1122,10 +1139,12 @@ bool OSystem_IPHONE::setSoundCallback(SoundProc proc, void *param) { AudioQueueSetParameter(s_AudioQueue.queue, kAudioQueueParam_Volume, 1.0); if (AudioQueueStart(s_AudioQueue.queue, NULL)) { printf("Error starting the AudioQueue!\n"); - return false; + _mixer->setReady(false); + return; } - - return true; + + _mixer->setOutputRate(AUDIO_SAMPLE_RATE); + _mixer->setReady(true); } int OSystem_IPHONE::getOutputSampleRate() const { @@ -1146,6 +1165,11 @@ void OSystem_IPHONE::setTimerCallback(TimerProc callback, int interval) { void OSystem_IPHONE::quit() { } +void OSystem_IPHONE::getTimeAndDate(struct tm &t) const { + time_t curTime = time(0); + t = *localtime(&curTime); +} + void OSystem_IPHONE::setWindowCaption(const char *caption) { } @@ -1169,17 +1193,7 @@ OSystem *OSystem_IPHONE_create() { } const char* OSystem_IPHONE::getConfigPath() { - if (s_is113OrHigher) - return SCUMMVM_PREFS_PATH; - else - return SCUMMVM_OLD_PREFS_PATH; -} - -const char* OSystem_IPHONE::getSavePath() { - if (s_is113OrHigher) - return SCUMMVM_SAVE_PATH; - else - return SCUMMVM_OLD_SAVE_PATH; + return SCUMMVM_PREFS_PATH; } void OSystem_IPHONE::migrateApp() { @@ -1193,7 +1207,7 @@ void OSystem_IPHONE::migrateApp() { if (!file.exists()) { system("mkdir " SCUMMVM_ROOT_PATH); system("mkdir " SCUMMVM_SAVE_PATH); - + // Copy over the prefs file system("cp " SCUMMVM_OLD_PREFS_PATH " " SCUMMVM_PREFS_PATH); @@ -1207,24 +1221,24 @@ void OSystem_IPHONE::migrateApp() { void iphone_main(int argc, char *argv[]) { - OSystem_IPHONE::migrateApp(); - - // Redirect stdout and stderr if we're launching from the Springboard. - if (argc == 2 && strcmp(argv[1], "--launchedFromSB") == 0) { - FILE *newfp = fopen("/tmp/scummvm.log", "a"); - if (newfp != NULL) { - fclose(stdout); - fclose(stderr); - *stdout = *newfp; - *stderr = *newfp; - setbuf(stdout, NULL); - setbuf(stderr, NULL); - - //extern int gDebugLevel; - //gDebugLevel = 10; - } + //OSystem_IPHONE::migrateApp(); + + FILE *newfp = fopen("/var/mobile/.scummvm.log", "a"); + if (newfp != NULL) { + fclose(stdout); + fclose(stderr); + *stdout = *newfp; + *stderr = *newfp; + setbuf(stdout, NULL); + setbuf(stderr, NULL); + + //extern int gDebugLevel; + //gDebugLevel = 10; } + system("mkdir " SCUMMVM_ROOT_PATH); + system("mkdir " SCUMMVM_SAVE_PATH); + g_system = OSystem_IPHONE_create(); assert(g_system); diff --git a/backends/platform/iphone/osys_iphone.h b/backends/platform/iphone/osys_iphone.h index a01cad480a..c058686c8c 100644 --- a/backends/platform/iphone/osys_iphone.h +++ b/backends/platform/iphone/osys_iphone.h @@ -29,6 +29,8 @@ #include "iphone_common.h" #include "common/system.h" #include "common/events.h" +#include "sound/mixer_intern.h" +#include "backends/fs/posix/posix-fs-factory.h" #include <AudioToolbox/AudioQueue.h> @@ -62,7 +64,7 @@ protected: static bool s_is113OrHigher; Common::SaveFileManager *_savefile; - Audio::Mixer *_mixer; + Audio::MixerImpl *_mixer; Common::TimerManager *_timer; Graphics::Surface _framebuffer; @@ -152,12 +154,16 @@ public: virtual void unlockMutex(MutexRef mutex); virtual void deleteMutex(MutexRef mutex); - virtual bool setSoundCallback(SoundProc proc, void *param); + static void mixCallback(void *sys, byte *samples, int len); + virtual void setupMixer(void); virtual int getOutputSampleRate() const; virtual void setTimerCallback(TimerProc callback, int interval); virtual void quit(); + FilesystemFactory *getFilesystemFactory() { return &POSIXFilesystemFactory::instance(); } + virtual void getTimeAndDate(struct tm &t) const; + virtual void setWindowCaption(const char *caption); virtual Common::SaveFileManager *getSavefileManager(); @@ -166,7 +172,6 @@ public: static void migrateApp(); static const char* getConfigPath(); - static const char* getSavePath(); protected: inline void addDirtyRect(int16 x1, int16 y1, int16 w, int16 h); diff --git a/backends/platform/sdl/sdl.cpp b/backends/platform/sdl/sdl.cpp index 76ac91c282..75bac0f536 100644 --- a/backends/platform/sdl/sdl.cpp +++ b/backends/platform/sdl/sdl.cpp @@ -26,6 +26,11 @@ #include "backends/platform/sdl/sdl.h" #include "common/config-manager.h" #include "common/events.h" +#include "common/file.h" +#if defined(WIN32) && defined(ARRAYSIZE) +// winnt.h defines ARRAYSIZE, but we want our own one... - this is needed before including util.h +#undef ARRAYSIZE +#endif #include "common/util.h" #include "backends/saves/default/default-saves.h" @@ -40,6 +45,7 @@ #define SAMPLES_PER_SEC 22050 //#define SAMPLES_PER_SEC 44100 + /* * Include header files needed for the getFilesystemFactory() method. */ @@ -52,6 +58,18 @@ #endif +#if defined(UNIX) +#ifdef MACOSX +#define DEFAULT_CONFIG_FILE "Library/Preferences/ScummVM Preferences" +#else +#define DEFAULT_CONFIG_FILE ".scummvmrc" +#endif +#else +#define DEFAULT_CONFIG_FILE "scummvm.ini" +#endif + + + static Uint32 timer_handler(Uint32 interval, void *param) { ((DefaultTimerManager *)param)->handler(); return interval; @@ -170,6 +188,10 @@ OSystem_SDL::OSystem_SDL() _joystick(0), _currentShakePos(0), _newShakePos(0), _paletteDirtyStart(0), _paletteDirtyEnd(0), +#ifdef MIXER_DOUBLE_BUFFERING + _soundMutex(0), _soundCond(0), _soundThread(0), + _soundThreadIsRunning(false), _soundThreadShouldQuit(false), +#endif _savefile(0), _mixer(0), _timer(0), @@ -241,6 +263,92 @@ FilesystemFactory *OSystem_SDL::getFilesystemFactory() { #endif } +static Common::String getDefaultConfigFileName() { + char configFile[MAXPATHLEN]; +#if defined (WIN32) && !defined(_WIN32_WCE) && !defined(__SYMBIAN32__) + OSVERSIONINFO win32OsVersion; + ZeroMemory(&win32OsVersion, sizeof(OSVERSIONINFO)); + win32OsVersion.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); + GetVersionEx(&win32OsVersion); + // Check for non-9X version of Windows. + if (win32OsVersion.dwPlatformId != VER_PLATFORM_WIN32_WINDOWS) { + // Use the Application Data directory of the user profile. + if (win32OsVersion.dwMajorVersion >= 5) { + if (!GetEnvironmentVariable("APPDATA", configFile, sizeof(configFile))) + error("Unable to access application data directory"); + } else { + if (!GetEnvironmentVariable("USERPROFILE", configFile, sizeof(configFile))) + error("Unable to access user profile directory"); + + strcat(configFile, "\\Application Data"); + CreateDirectory(configFile, NULL); + } + + strcat(configFile, "\\ScummVM"); + CreateDirectory(configFile, NULL); + strcat(configFile, "\\" DEFAULT_CONFIG_FILE); + + if (fopen(configFile, "r") == NULL) { + // Check windows directory + char oldConfigFile[MAXPATHLEN]; + GetWindowsDirectory(oldConfigFile, MAXPATHLEN); + strcat(oldConfigFile, "\\" DEFAULT_CONFIG_FILE); + if (fopen(oldConfigFile, "r")) { + printf("The default location of the config file (scummvm.ini) in ScummVM has changed,\n"); + printf("under Windows NT4/2000/XP/Vista. You may want to consider moving your config\n"); + printf("file from the old default location:\n"); + printf("%s\n", oldConfigFile); + printf("to the new default location:\n"); + printf("%s\n\n", configFile); + strcpy(configFile, oldConfigFile); + } + } + } else { + // Check windows directory + GetWindowsDirectory(configFile, MAXPATHLEN); + strcat(configFile, "\\" DEFAULT_CONFIG_FILE); + } +#elif defined(UNIX) + // On UNIX type systems, by default we store the config file inside + // to the HOME directory of the user. + // + // GP2X is Linux based but Home dir can be read only so do not use + // it and put the config in the executable dir. + // + // On the iPhone, the home dir of the user when you launch the app + // from the Springboard, is /. Which we don't want. + const char *home = getenv("HOME"); + if (home != NULL && strlen(home) < MAXPATHLEN) + snprintf(configFile, MAXPATHLEN, "%s/%s", home, DEFAULT_CONFIG_FILE); + else + strcpy(configFile, DEFAULT_CONFIG_FILE); +#else + strcpy(configFile, DEFAULT_CONFIG_FILE); +#endif + + return configFile; +} + +Common::SeekableReadStream *OSystem_SDL::openConfigFileForReading() { + Common::File *confFile = new Common::File(); + assert(confFile); + if (!confFile->open(getDefaultConfigFileName())) { + delete confFile; + confFile = 0; + } + return confFile; +} + +Common::WriteStream *OSystem_SDL::openConfigFileForWriting() { + Common::DumpFile *confFile = new Common::DumpFile(); + assert(confFile); + if (!confFile->open(getDefaultConfigFileName())) { + delete confFile; + confFile = 0; + } + return confFile; +} + void OSystem_SDL::setWindowCaption(const char *caption) { SDL_WM_SetCaption(caption, caption); } diff --git a/backends/platform/sdl/sdl.h b/backends/platform/sdl/sdl.h index 4ad588f5f5..1c1381ec5c 100644 --- a/backends/platform/sdl/sdl.h +++ b/backends/platform/sdl/sdl.h @@ -210,6 +210,9 @@ public: virtual Common::SaveFileManager *getSavefileManager(); virtual FilesystemFactory *getFilesystemFactory(); + virtual Common::SeekableReadStream *openConfigFileForReading(); + virtual Common::WriteStream *openConfigFileForWriting(); + protected: bool _inited; diff --git a/backends/platform/symbian/BuildPackageUpload_LocalSettings.pl b/backends/platform/symbian/BuildPackageUpload_LocalSettings.pl index 5d85fc03a2..12e5f8f0c4 100644 --- a/backends/platform/symbian/BuildPackageUpload_LocalSettings.pl +++ b/backends/platform/symbian/BuildPackageUpload_LocalSettings.pl @@ -2,12 +2,11 @@ ################################################################################################################## @WorkingEngines = qw( - scumm agos sky queen gob saga - kyra lure agi + scumm agos sky queen gob saga drascula + kyra lure agi touche parallaction ); @TestingEngines = qw( - cine cruise touche parallaction - drascula igor made m4 + cruise igor made m4 cine ); @BrokenEngines = qw( sword1 @@ -29,21 +28,21 @@ ); # these are normally enabled for each variation - $DefaultFeatures = qw(zlib tremor); - #$DefaultFeatures = qw(zlib mad tremor); + #$DefaultFeatures = qw(zlib,mad); + $DefaultFeatures = qw(zlib,mad,tremor); - # you can use these below for speed & clarity or override with custom settings - $DefaultTopMacros = " - MACRO USE_ZLIB // LIB:zlib.lib - //MACRO USE_MAD // LIB:libmad.lib - MACRO USE_TREMOR // LIB:libtremor.lib - "; + # you can use these below for speed & clarity or override with custom settings + $DefaultTopMacros = " + MACRO USE_ZLIB // LIB:zlib.lib + MACRO USE_MAD // LIB:libmad.lib + MACRO USE_TREMOR // LIB:libtremor.lib + "; - $DefaultBottomMacros = " - MACRO DISABLE_SWORD1 // LIB:scummvm_sword1.lib - MACRO DISABLE_SWORD2 // LIB:scummvm_sword2.lib - "; + $DefaultBottomMacros = " + MACRO DISABLE_SWORD1 // LIB:scummvm_sword1.lib + MACRO DISABLE_SWORD2 // LIB:scummvm_sword2.lib + "; ################################################################################################################## ## diff --git a/backends/platform/symbian/S60v3/ScummVM_S60v3.mmp.in b/backends/platform/symbian/S60v3/ScummVM_S60v3.mmp.in index 3fea916e43..8daf76138c 100644 --- a/backends/platform/symbian/S60v3/ScummVM_S60v3.mmp.in +++ b/backends/platform/symbian/S60v3/ScummVM_S60v3.mmp.in @@ -50,7 +50,7 @@ LANG SC END EPOCSTACKSIZE 80000 -EPOCHEAPSIZE 3000000 64000000 +EPOCHEAPSIZE 5000000 64000000 START BITMAP ScummVM.mbm TARGETPATH \Resource\Apps diff --git a/backends/platform/symbian/UIQ3/ScummVM_UIQ3.mmp.in b/backends/platform/symbian/UIQ3/ScummVM_UIQ3.mmp.in index 0013d061ca..cf3d0c1d7b 100644 --- a/backends/platform/symbian/UIQ3/ScummVM_UIQ3.mmp.in +++ b/backends/platform/symbian/UIQ3/ScummVM_UIQ3.mmp.in @@ -51,7 +51,7 @@ LANG SC END EPOCSTACKSIZE 80000 -EPOCHEAPSIZE 3000000 64000000 +EPOCHEAPSIZE 5000000 64000000 START BITMAP ScummVM.mbm TARGETPATH \Resource\Apps diff --git a/backends/platform/symbian/src/SymbianActions.cpp b/backends/platform/symbian/src/SymbianActions.cpp index 8fc35e9f8d..da127eaec6 100644 --- a/backends/platform/symbian/src/SymbianActions.cpp +++ b/backends/platform/symbian/src/SymbianActions.cpp @@ -140,6 +140,8 @@ void SymbianActions::initInstanceGame() { bool is_touche = (gameid == "touche"); bool is_agi = (gameid == "agi"); bool is_parallaction = (gameid == "parallaction"); + bool is_lure = (gameid == "lure"); + bool is_feeble = (gameid == "feeble"); Actions::initInstanceGame(); @@ -175,7 +177,7 @@ void SymbianActions::initInstanceGame() { // Skip text if (!is_cine && !is_parallaction) _action_enabled[ACTION_SKIP_TEXT] = true; - if (is_simon || is_sky || is_sword2 || is_queen || is_sword1 || is_gob || is_saga || is_kyra || is_touche) + if (is_simon || is_sky || is_sword2 || is_queen || is_sword1 || is_gob || is_saga || is_kyra || is_touche || is_lure || is_feeble) _key_action[ACTION_SKIP_TEXT].setKey(Common::KEYCODE_ESCAPE, Common::KEYCODE_ESCAPE); // Escape key else { _key_action[ACTION_SKIP_TEXT].setKey(SDLK_PERIOD); diff --git a/backends/platform/symbian/src/SymbianOS.cpp b/backends/platform/symbian/src/SymbianOS.cpp index 660b0c69ed..0ce44d1704 100644 --- a/backends/platform/symbian/src/SymbianOS.cpp +++ b/backends/platform/symbian/src/SymbianOS.cpp @@ -30,6 +30,7 @@ #include "backends/platform/symbian/src/SymbianActions.h" #include "common/config-manager.h" #include "common/events.h" +#include "common/file.h" #include "gui/Actions.h" #include "gui/Key.h" #include "gui/message.h" @@ -42,6 +43,10 @@ #define SAMPLES_PER_SEC 16000 #endif + +#define DEFAULT_CONFIG_FILE "scummvm.ini" + + #define KInputBufferLength 128 // Symbian libc file functionality in order to provide shared file handles struct TSymbianFileEntry { @@ -122,6 +127,34 @@ FilesystemFactory *OSystem_SDL_Symbian::getFilesystemFactory() { return &SymbianFilesystemFactory::instance(); } +static Common::String getDefaultConfigFileName() { + char configFile[MAXPATHLEN]; + strcpy(configFile, Symbian::GetExecutablePath()); + strcat(configFile, DEFAULT_CONFIG_FILE); + return configFile; +} + +Common::SeekableReadStream *OSystem_SDL_Symbian::openConfigFileForReading() { + Common::File *confFile = new Common::File(); + assert(confFile); + if (!confFile->open(getDefaultConfigFileName())) { + delete confFile; + confFile = 0; + } + return confFile; +} + +Common::WriteStream *OSystem_SDL_Symbian::openConfigFileForWriting() { + Common::DumpFile *confFile = new Common::DumpFile(); + assert(confFile); + if (!confFile->open(getDefaultConfigFileName())) { + delete confFile; + confFile = 0; + } + return confFile; +} + + OSystem_SDL_Symbian::zoneDesc OSystem_SDL_Symbian::_zones[TOTAL_ZONES] = { { 0, 0, 320, 145 }, { 0, 145, 150, 55 }, @@ -617,9 +650,13 @@ bool symbian_feof(FILE* handle) { long int symbian_ftell(FILE* handle) { TInt pos = 0; + TSymbianFileEntry* entry = ((TSymbianFileEntry*)(handle)); - ((TSymbianFileEntry*)(handle))->iFileHandle.Seek(ESeekCurrent, pos); - + entry->iFileHandle.Seek(ESeekCurrent, pos); + if(entry->iInputPos != KErrNotFound) + { + pos+=(entry->iInputPos - entry->iInputBufferLen); + } return pos; } @@ -627,6 +664,7 @@ int symbian_fseek(FILE* handle, long int offset, int whence) { TSeek seekMode = ESeekStart; TInt pos = offset; + TSymbianFileEntry* entry = ((TSymbianFileEntry*)(handle)); switch(whence) { case SEEK_SET: @@ -634,6 +672,9 @@ int symbian_fseek(FILE* handle, long int offset, int whence) { break; case SEEK_CUR: seekMode = ESeekCurrent; + if(entry->iInputPos != KErrNotFound) { + pos+=(entry->iInputPos - entry->iInputBufferLen); + } break; case SEEK_END: seekMode = ESeekEnd; @@ -641,9 +682,9 @@ int symbian_fseek(FILE* handle, long int offset, int whence) { } - ((TSymbianFileEntry*)(handle))->iInputPos = KErrNotFound; + entry->iInputPos = KErrNotFound; - return ((TSymbianFileEntry*)(handle))->iFileHandle.Seek(seekMode, pos); + return entry->iFileHandle.Seek(seekMode, pos); } void symbian_clearerr(FILE* /*handle*/) { diff --git a/backends/platform/symbian/src/SymbianOS.h b/backends/platform/symbian/src/SymbianOS.h index 71d24f6286..68a6fb492f 100644 --- a/backends/platform/symbian/src/SymbianOS.h +++ b/backends/platform/symbian/src/SymbianOS.h @@ -71,6 +71,9 @@ protected: static void symbianMixCallback(void *s, byte *samples, int len); virtual FilesystemFactory *getFilesystemFactory(); + + virtual Common::SeekableReadStream *openConfigFileForReading(); + virtual Common::WriteStream *openConfigFileForWriting(); public: // vibration support #ifdef USE_VIBRA_SE_PXXX diff --git a/backends/platform/symbian/src/main_features.inl b/backends/platform/symbian/src/main_features.inl index f572ddb3dd..30bbbea52c 100644 --- a/backends/platform/symbian/src/main_features.inl +++ b/backends/platform/symbian/src/main_features.inl @@ -27,62 +27,61 @@ // we want a list of supported engines visible in the program, // because we also release special builds with only one engine -#ifndef DISABLE_SCUMM +#ifdef ENABLE_SCUMM "SCUMM " #endif -#ifndef DISABLE_AGOS +#ifdef ENABLE_AGOS "AGOS " #endif -#ifndef DISABLE_SKY +#ifdef ENABLE_SKY "Sky " #endif -#ifndef DISABLE_QUEEN +#ifdef ENABLE_QUEEN "Queen " #endif -#ifndef DISABLE_GOB +#ifdef ENABLE_GOB "Gob " #endif -#ifndef DISABLE_SAGA +#ifdef ENABLE_SAGA "Saga " #endif -#ifndef DISABLE_KYRA +#ifdef ENABLE_KYRA "Kyra " #endif -#ifndef DISABLE_SWORD1 +#ifdef ENABLE_SWORD1 "Sword1 " #endif -#ifndef DISABLE_SWORD2 +#ifdef ENABLE_SWORD2 "Sword2 " #endif -#ifndef DISABLE_CINE +#ifdef ENABLE_CINE "Cine " #endif -#ifndef DISABLE_LURE +#ifdef ENABLE_LURE "Lure " #endif -#ifndef DISABLE_AGI +#ifdef ENABLE_AGI "AGI " #endif -#ifndef DISABLE_TOUCHE +#ifdef ENABLE_TOUCHE "Touche " #endif -#ifndef DISABLE_DRASCULA +#ifdef ENABLE_DRASCULA "Drascula " #endif -#ifndef DISABLE_IGOR +#ifdef ENABLE_IGOR "Igor " #endif -#ifndef DISABLE_PARALLACTION +#ifdef ENABLE_PARALLACTION "Parallaction " #endif -#ifndef DISABLE_CRUISE +#ifdef ENABLE_CRUISE "Cruise " #endif -#ifndef DISABLE_MADE +#ifdef ENABLE_MADE "MADE " #endif - -#ifndef DISABLE_M4 +#ifdef ENABLE_M4 "M4 " #endif diff --git a/backends/platform/symbian/src/portdefs.h b/backends/platform/symbian/src/portdefs.h index 06a4cf374c..4577824b33 100644 --- a/backends/platform/symbian/src/portdefs.h +++ b/backends/platform/symbian/src/portdefs.h @@ -157,5 +157,6 @@ void inline *scumm_bsearch(const void *key, const void *base, size_t nmemb, size namespace Symbian { extern void FatalError(const char *msg); extern char* GetExecutablePath(); +#define DYNAMIC_MODULES 1 } #endif diff --git a/backends/plugins/win32/win32-provider.cpp b/backends/plugins/win32/win32-provider.cpp index 64636d8096..b8fdd3d802 100644 --- a/backends/plugins/win32/win32-provider.cpp +++ b/backends/plugins/win32/win32-provider.cpp @@ -50,21 +50,14 @@ protected: virtual VoidFunc findSymbol(const char *symbol) { #ifndef _WIN32_WCE - void *func = (void *)GetProcAddress((HMODULE)_dlHandle, symbol); + FARPROC func = GetProcAddress((HMODULE)_dlHandle, symbol); #else - void *func = (void *)GetProcAddress((HMODULE)_dlHandle, toUnicode(symbol)); + FARPROC func = GetProcAddress((HMODULE)_dlHandle, toUnicode(symbol)); #endif if (!func) debug("Failed loading symbol '%s' from plugin '%s'", symbol, _filename.c_str()); - // FIXME HACK: This is a HACK to circumvent a clash between the ISO C++ - // standard and POSIX: ISO C++ disallows casting between function pointers - // and data pointers, but dlsym always returns a void pointer. For details, - // see e.g. <http://www.trilithium.com/johan/2004/12/problem-with-dlsym/>. - assert(sizeof(VoidFunc) == sizeof(func)); - VoidFunc tmp; - memcpy(&tmp, &func, sizeof(VoidFunc)); - return tmp; + return (void (*)())func; } public: diff --git a/backends/saves/default/default-saves.cpp b/backends/saves/default/default-saves.cpp index 21bc56e441..dc5e8adca7 100644 --- a/backends/saves/default/default-saves.cpp +++ b/backends/saves/default/default-saves.cpp @@ -41,79 +41,42 @@ #include <sys/stat.h> #endif - -class StdioSaveFile : public Common::InSaveFile, public Common::OutSaveFile { -private: - FILE *fh; -public: - StdioSaveFile(const char *filename, bool saveOrLoad) { - fh = ::fopen(filename, (saveOrLoad? "wb" : "rb")); - } - ~StdioSaveFile() { - if (fh) - ::fclose(fh); - } - - bool eos() const { return feof(fh) != 0; } - bool ioFailed() const { return ferror(fh) != 0; } - void clearIOFailed() { clearerr(fh); } - - bool isOpen() const { return fh != 0; } - - uint32 read(void *dataPtr, uint32 dataSize) { - assert(fh); - return fread(dataPtr, 1, dataSize, fh); - } - uint32 write(const void *dataPtr, uint32 dataSize) { - assert(fh); - return fwrite(dataPtr, 1, dataSize, fh); - } - - uint32 pos() const { - assert(fh); - return ftell(fh); - } - uint32 size() const { - assert(fh); - uint32 oldPos = ftell(fh); - fseek(fh, 0, SEEK_END); - uint32 length = ftell(fh); - fseek(fh, oldPos, SEEK_SET); - return length; - } - - void seek(int32 offs, int whence = SEEK_SET) { - assert(fh); - fseek(fh, offs, whence); - } -}; - -static void join_paths(const char *filename, const char *directory, - char *buf, int bufsize) { - buf[bufsize-1] = '\0'; - strncpy(buf, directory, bufsize-1); - -#ifdef WIN32 - // Fix for Win98 issue related with game directory pointing to root drive ex. "c:\" - if ((buf[0] != 0) && (buf[1] == ':') && (buf[2] == '\\') && (buf[3] == 0)) { - buf[2] = 0; - } +#ifdef UNIX +#ifdef MACOSX +#define DEFAULT_SAVE_PATH "Documents/ScummVM Savegames" +#else +#define DEFAULT_SAVE_PATH ".scummvm" #endif - - const int dirLen = strlen(buf); - - if (dirLen > 0) { -#if defined(__MORPHOS__) || defined(__amigaos4__) - if (buf[dirLen-1] != ':' && buf[dirLen-1] != '/') +#elif defined(__SYMBIAN32__) +#define DEFAULT_SAVE_PATH "Savegames" #endif -#if !defined(__GP32__) - strncat(buf, "/", bufsize-1); // prevent double / -#endif +DefaultSaveFileManager::DefaultSaveFileManager() { + // Register default savepath + // TODO: Remove this code here, and instead leave setting the + // default savepath to the ports using this class. +#ifdef DEFAULT_SAVE_PATH + Common::String savePath; +#if defined(UNIX) && !defined(IPHONE) + const char *home = getenv("HOME"); + if (home && *home && strlen(home) < MAXPATHLEN) { + savePath = home; + savePath += "/" DEFAULT_SAVE_PATH; + ConfMan.registerDefault("savepath", savePath); } - strncat(buf, filename, bufsize-1); +#elif defined(__SYMBIAN32__) + savePath = Symbian::GetExecutablePath(); + savePath += DEFAULT_SAVE_PATH "\\"; + ConfMan.registerDefault("savepath", savePath); +#endif +#endif // #ifdef DEFAULT_SAVE_PATH +} + +DefaultSaveFileManager::DefaultSaveFileManager(const Common::String &defaultSavepath) { + ConfMan.registerDefault("savepath", defaultSavepath); } + Common::StringList DefaultSaveFileManager::listSavefiles(const char *pattern) { FilesystemNode savePath(getSavePath()); FSList savefiles; @@ -129,7 +92,8 @@ Common::StringList DefaultSaveFileManager::listSavefiles(const char *pattern) { return results; } -void DefaultSaveFileManager::checkPath(const Common::String &path) { +void DefaultSaveFileManager::checkPath(const FilesystemNode &dir) { + const Common::String path = dir.getPath(); clearError(); #if defined(UNIX) || defined(__SYMBIAN32__) @@ -196,23 +160,27 @@ void DefaultSaveFileManager::checkPath(const Common::String &path) { setError(SFM_DIR_NOTDIR, "The given savepath is not a directory: "+path); } } +#else + if (!dir.exists()) { + // TODO: We could try to mkdir the directory here; or rather, we could + // add a mkdir method to FilesystemNode and invoke that here. + setError(SFM_DIR_NOENT, "A component of the path does not exist, or the path is an empty string: "+path); + } else if (!dir.isDirectory()) { + setError(SFM_DIR_NOTDIR, "The given savepath is not a directory: "+path); + } #endif } Common::InSaveFile *DefaultSaveFileManager::openForLoading(const char *filename) { // Ensure that the savepath is valid. If not, generate an appropriate error. - char buf[256]; - Common::String savePath = getSavePath(); + FilesystemNode savePath(getSavePath()); checkPath(savePath); if (getError() == SFM_NO_ERROR) { - join_paths(filename, savePath.c_str(), buf, sizeof(buf)); - StdioSaveFile *sf = new StdioSaveFile(buf, false); + FilesystemNode file = savePath.getChild(filename); - if (!sf->isOpen()) { - delete sf; - sf = 0; - } + // Open the file for reading + Common::SeekableReadStream *sf = file.openForReading(); return wrapInSaveFile(sf); } else { @@ -222,18 +190,14 @@ Common::InSaveFile *DefaultSaveFileManager::openForLoading(const char *filename) Common::OutSaveFile *DefaultSaveFileManager::openForSaving(const char *filename) { // Ensure that the savepath is valid. If not, generate an appropriate error. - char buf[256]; - Common::String savePath = getSavePath(); + FilesystemNode savePath(getSavePath()); checkPath(savePath); if (getError() == SFM_NO_ERROR) { - join_paths(filename, savePath.c_str(), buf, sizeof(buf)); - StdioSaveFile *sf = new StdioSaveFile(buf, true); + FilesystemNode file = savePath.getChild(filename); - if (!sf->isOpen()) { - delete sf; - sf = 0; - } + // Open the file for saving + Common::WriteStream *sf = file.openForWriting(); return wrapOutSaveFile(sf); } else { @@ -242,18 +206,19 @@ Common::OutSaveFile *DefaultSaveFileManager::openForSaving(const char *filename) } bool DefaultSaveFileManager::removeSavefile(const char *filename) { - char buf[256]; clearError(); - Common::String filenameStr; - join_paths(filename, getSavePath().c_str(), buf, sizeof(buf)); - if (remove(buf) != 0) { + FilesystemNode savePath(getSavePath()); + FilesystemNode file = savePath.getChild(filename); + + // TODO: Add new method FilesystemNode::remove() + if (remove(file.getPath().c_str()) != 0) { #ifndef _WIN32_WCE if (errno == EACCES) - setError(SFM_DIR_ACCESS, "Search or write permission denied: "+filenameStr); + setError(SFM_DIR_ACCESS, "Search or write permission denied: "+file.getName()); if (errno == ENOENT) - setError(SFM_DIR_NOENT, "A component of the path does not exist, or the path is an empty string: "+filenameStr); + setError(SFM_DIR_NOENT, "A component of the path does not exist, or the path is an empty string: "+file.getName()); #endif return false; } else { diff --git a/backends/saves/default/default-saves.h b/backends/saves/default/default-saves.h index f3e0ec5b35..97845c4623 100644 --- a/backends/saves/default/default-saves.h +++ b/backends/saves/default/default-saves.h @@ -34,6 +34,9 @@ */ class DefaultSaveFileManager : public Common::SaveFileManager { public: + DefaultSaveFileManager(); + DefaultSaveFileManager(const Common::String &defaultSavepath); + virtual Common::StringList listSavefiles(const char *pattern); virtual Common::InSaveFile *openForLoading(const char *filename); virtual Common::OutSaveFile *openForSaving(const char *filename); @@ -51,7 +54,7 @@ protected: * Checks the given path for read access, existence, etc. * Sets the internal error and error message accordingly. */ - void checkPath(const Common::String &path); + void checkPath(const FilesystemNode &dir); }; #endif |
