[Fuse-for-macosx-commits] SF.net SVN: fuse-for-macosx: [262] branches/fusegl/fuse
Brought to you by:
fredm
From: <fr...@us...> - 2006-12-24 13:35:52
|
Revision: 262 http://svn.sourceforge.net/fuse-for-macosx/?rev=262&view=rev Author: fredm Date: 2006-12-24 05:35:50 -0800 (Sun, 24 Dec 2006) Log Message: ----------- Enable screenshot support, get project building in deployment mode. Modified Paths: -------------- branches/fusegl/fuse/TODO branches/fusegl/fuse/fusepb/Fuse.xcodeproj/project.pbxproj branches/fusegl/fuse/fusepb/content_arrays/SDLJoysticks.m branches/fusegl/fuse/fusepb/controllers/FuseController.m branches/fusegl/fuse/fusepb/thumbnail.h branches/fusegl/fuse/fusepb/thumbnail.m branches/fusegl/fuse/fusepb/views/DisplayOpenGLView.m branches/fusegl/fuse/ui/cocoa/cocoadisplay.c branches/fusegl/fuse/ui/cocoa/cocoadisplay.h Added Paths: ----------- branches/fusegl/fuse/ui/cocoa/cocoaerror.m branches/fusegl/fuse/ui/cocoa/cocoascreenshot.h branches/fusegl/fuse/ui/cocoa/cocoascreenshot.m Removed Paths: ------------- branches/fusegl/fuse/fusepb/error.m branches/fusegl/fuse/fusepb/sdlscreenshot.h branches/fusegl/fuse/fusepb/sdlscreenshot.m Modified: branches/fusegl/fuse/TODO =================================================================== --- branches/fusegl/fuse/TODO 2006-12-23 11:00:00 UTC (rev 261) +++ branches/fusegl/fuse/TODO 2006-12-24 13:35:50 UTC (rev 262) @@ -12,5 +12,6 @@ * Add native joystick processing (removes SDL joystick input dependency from Fuse) * Add native mouse processing (removes SDL mouse input dependency from Fuse) +* Restore fullscreen support $Id: TODO,v 1.4 2004/03/02 13:38:08 pak21 Exp $ Modified: branches/fusegl/fuse/fusepb/Fuse.xcodeproj/project.pbxproj =================================================================== --- branches/fusegl/fuse/fusepb/Fuse.xcodeproj/project.pbxproj 2006-12-23 11:00:00 UTC (rev 261) +++ branches/fusegl/fuse/fusepb/Fuse.xcodeproj/project.pbxproj 2006-12-24 13:35:50 UTC (rev 262) @@ -265,6 +265,12 @@ B682554A091817F30014B5EE /* divide.h in Headers */ = {isa = PBXBuildFile; fileRef = B6825548091817F30014B5EE /* divide.h */; }; B6A6F0960B3C108C000B88E9 /* coreaudiosound.c in Sources */ = {isa = PBXBuildFile; fileRef = B6A6F0950B3C108C000B88E9 /* coreaudiosound.c */; }; B6A6F0DA0B3D141B000B88E9 /* cocoaui.m in Sources */ = {isa = PBXBuildFile; fileRef = B6A6F0D90B3D141B000B88E9 /* cocoaui.m */; }; + B6A6F0EE0B3D5F9E000B88E9 /* CoreAudio.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B6A6F0ED0B3D5F9E000B88E9 /* CoreAudio.framework */; }; + B6A6F0F30B3D602F000B88E9 /* AudioUnit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B6A6F0F20B3D602F000B88E9 /* AudioUnit.framework */; }; + B6A6F1060B3D60D0000B88E9 /* OpenGL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F520C8BC038D022E01A804BA /* OpenGL.framework */; }; + B6A6F10E0B3D6360000B88E9 /* cocoaerror.m in Sources */ = {isa = PBXBuildFile; fileRef = B6A6F10D0B3D6360000B88E9 /* cocoaerror.m */; }; + B6A6F11F0B3EA737000B88E9 /* cocoascreenshot.h in Headers */ = {isa = PBXBuildFile; fileRef = B6A6F11D0B3EA737000B88E9 /* cocoascreenshot.h */; }; + B6A6F1200B3EA737000B88E9 /* cocoascreenshot.m in Sources */ = {isa = PBXBuildFile; fileRef = B6A6F11E0B3EA737000B88E9 /* cocoascreenshot.m */; }; B6CE7F400B2830A300EB65B3 /* cocoadisplay.c in Sources */ = {isa = PBXBuildFile; fileRef = B6CE7F3A0B2830A300EB65B3 /* cocoadisplay.c */; }; B6CE7F410B2830A300EB65B3 /* cocoadisplay.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CE7F3B0B2830A300EB65B3 /* cocoadisplay.h */; }; B6CE7F420B2830A300EB65B3 /* cocoajoystick.c in Sources */ = {isa = PBXBuildFile; fileRef = B6CE7F3C0B2830A300EB65B3 /* cocoajoystick.c */; }; @@ -450,6 +456,11 @@ B68CB2CC03DD923C00A804BA /* memory.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = memory.c; sourceTree = "<group>"; }; B6A6F0950B3C108C000B88E9 /* coreaudiosound.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = coreaudiosound.c; path = sound/coreaudiosound.c; sourceTree = "<group>"; }; B6A6F0D90B3D141B000B88E9 /* cocoaui.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; path = cocoaui.m; sourceTree = "<group>"; }; + B6A6F0ED0B3D5F9E000B88E9 /* CoreAudio.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreAudio.framework; path = ../../../../../../../../System/Library/Frameworks/CoreAudio.framework; sourceTree = "<group>"; }; + B6A6F0F20B3D602F000B88E9 /* AudioUnit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AudioUnit.framework; path = ../../../../../../../../System/Library/Frameworks/AudioUnit.framework; sourceTree = "<group>"; }; + B6A6F10D0B3D6360000B88E9 /* cocoaerror.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; path = cocoaerror.m; sourceTree = "<group>"; }; + B6A6F11D0B3EA737000B88E9 /* cocoascreenshot.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = cocoascreenshot.h; sourceTree = "<group>"; }; + B6A6F11E0B3EA737000B88E9 /* cocoascreenshot.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; path = cocoascreenshot.m; sourceTree = "<group>"; }; B6A7F0E904C9A11D001025EB /* NumberFormatter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NumberFormatter.h; sourceTree = "<group>"; }; B6A7F0EA04C9A11D001025EB /* NumberFormatter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NumberFormatter.m; sourceTree = "<group>"; }; B6AA8A3C03D2FC1C00FED55D /* trdos.rom */ = {isa = PBXFileReference; lastKnownFileType = file; name = trdos.rom; path = ../roms/trdos.rom; sourceTree = SOURCE_ROOT; }; @@ -626,6 +637,9 @@ B61F46A109121DF100C8096C /* gcrypt.framework in Frameworks */, B61F46A209121DF100C8096C /* libbz2.framework in Frameworks */, B64E2A170A6534A3006863D9 /* Carbon.framework in Frameworks */, + B6A6F0EE0B3D5F9E000B88E9 /* CoreAudio.framework in Frameworks */, + B6A6F0F30B3D602F000B88E9 /* AudioUnit.framework in Frameworks */, + B6A6F1060B3D60D0000B88E9 /* OpenGL.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -652,6 +666,8 @@ 1058C7A0FEA54F0111CA2CBB /* Linked Frameworks */ = { isa = PBXGroup; children = ( + B6A6F0F20B3D602F000B88E9 /* AudioUnit.framework */, + B6A6F0ED0B3D5F9E000B88E9 /* CoreAudio.framework */, B64E2A160A6534A3006863D9 /* Carbon.framework */, B6202BD105BD43D800A1EA8F /* libbz2.framework */, 1058C7A1FEA54F0111CA2CBB /* Cocoa.framework */, @@ -889,7 +905,10 @@ children = ( B6CE7F3A0B2830A300EB65B3 /* cocoadisplay.c */, B6CE7F3B0B2830A300EB65B3 /* cocoadisplay.h */, + B6A6F10D0B3D6360000B88E9 /* cocoaerror.m */, B6CE7F3C0B2830A300EB65B3 /* cocoajoystick.c */, + B6A6F11D0B3EA737000B88E9 /* cocoascreenshot.h */, + B6A6F11E0B3EA737000B88E9 /* cocoascreenshot.m */, B6CE7F3E0B2830A300EB65B3 /* cocoaui.h */, B6A6F0D90B3D141B000B88E9 /* cocoaui.m */, B6E0252B0B38AFE500E23A0F /* keysyms.m */, @@ -1207,6 +1226,7 @@ B6CE7F410B2830A300EB65B3 /* cocoadisplay.h in Headers */, B6CE7F440B2830A300EB65B3 /* cocoaui.h in Headers */, B6CE7FCD0B28FBD600EB65B3 /* DisplayOpenGLView.h in Headers */, + B6A6F11F0B3EA737000B88E9 /* cocoascreenshot.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1442,6 +1462,8 @@ B6E0252C0B38AFE500E23A0F /* keysyms.m in Sources */, B6A6F0960B3C108C000B88E9 /* coreaudiosound.c in Sources */, B6A6F0DA0B3D141B000B88E9 /* cocoaui.m in Sources */, + B6A6F10E0B3D6360000B88E9 /* cocoaerror.m in Sources */, + B6A6F1200B3EA737000B88E9 /* cocoascreenshot.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; Modified: branches/fusegl/fuse/fusepb/content_arrays/SDLJoysticks.m =================================================================== --- branches/fusegl/fuse/fusepb/content_arrays/SDLJoysticks.m 2006-12-23 11:00:00 UTC (rev 261) +++ branches/fusegl/fuse/fusepb/content_arrays/SDLJoysticks.m 2006-12-24 13:35:50 UTC (rev 262) @@ -44,7 +44,7 @@ joysticks = [NSMutableArray arrayWithCapacity:joysticks_supported+1]; [joysticks addObject:[SDLJoystick joystickWithName:@"None" andType:0]]; - +#if 0 if( joysticks_supported > 0 ){ for( i=0; i<joysticks_supported; i++ ) { [joysticks addObject: @@ -54,6 +54,7 @@ ]; } } +#endif } return joysticks; } Modified: branches/fusegl/fuse/fusepb/controllers/FuseController.m =================================================================== --- branches/fusegl/fuse/fusepb/controllers/FuseController.m 2006-12-23 11:00:00 UTC (rev 261) +++ branches/fusegl/fuse/fusepb/controllers/FuseController.m 2006-12-24 13:35:50 UTC (rev 262) @@ -52,8 +52,8 @@ #include "psg.h" #include "rzx.h" #include "screenshot.h" +#include "ui/cocoa/cocoascreenshot.h" #if 0 -#include "sdlscreenshot.h" #include "sdlui.h" #include "sdldisplay.h" #endif @@ -1026,6 +1026,8 @@ - (int)ui_statusbar_update_speed:(float)speed { [window setTitle:[NSString stringWithFormat:@"Fuse - %3.0f%%", speed]]; + + return 0; } - (BOOL)validateMenuItem:(id <NSMenuItem>)menuItem Deleted: branches/fusegl/fuse/fusepb/error.m =================================================================== --- branches/fusegl/fuse/fusepb/error.m 2006-12-23 11:00:00 UTC (rev 261) +++ branches/fusegl/fuse/fusepb/error.m 2006-12-24 13:35:50 UTC (rev 262) @@ -1,87 +0,0 @@ -/* error.m: handle errors - Copyright (c) 2002 Philip Kendall - Copyright (c) 2002-2004 Fredrick Meunier - - $Id$ - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program 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 General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - Author contact information: - - E-mail: pak...@sr... - Postal address: 15 Crescent Road, Wokingham, Berks, RG40 2DB, England - -*/ - -#include <config.h> - -#ifdef UI_SDL /* Use this iff we're using SDL */ - -#import <Foundation/NSString.h> -#import <AppKit/NSPanel.h> - -#include <stdarg.h> -#include <stdio.h> -#include <unistd.h> - -#include "fuse.h" -#include "ui/ui.h" -#include "settings.h" - -#define MESSAGE_MAX_LENGTH 256 - -int -aqua_verror( ui_error_level severity, const char *message ) -{ - NSString *title; - - /* Set the appropriate title */ - switch( severity ) { - case UI_ERROR_INFO: - title = @"Fuse - Info"; - break; - case UI_ERROR_ERROR: - title = @"Fuse - Error"; - break; - default: - title = @"Fuse - (Unknown error)"; - break; - } - - NSString *alertString = [NSString stringWithUTF8String:message]; - - switch( severity ) { - case UI_ERROR_INFO: - NSRunAlertPanel(title, alertString, nil, nil, nil); - break; - case UI_ERROR_ERROR: - default: - NSRunCriticalAlertPanel(title, alertString, nil, nil, nil); - break; - } - - return 0; -} - -int -ui_error_specific( ui_error_level severity, const char *message ) -{ - if ( !settings_current.full_screen ) { - return aqua_verror( severity, message ); - } - return 0; -} - -#endif /* #ifdef UI_SDL */ Deleted: branches/fusegl/fuse/fusepb/sdlscreenshot.h =================================================================== --- branches/fusegl/fuse/fusepb/sdlscreenshot.h 2006-12-23 11:00:00 UTC (rev 261) +++ branches/fusegl/fuse/fusepb/sdlscreenshot.h 2006-12-24 13:35:50 UTC (rev 262) @@ -1,32 +0,0 @@ -/* sdlscreenshot.h: Routines for saving .bmp screenshots - Copyright (c) 2003 Fredrick Meunier - - $Id$ - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program 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 General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - Author contact information: - - E-mail: pak...@sr... - Postal address: 15 Crescent Road, Wokingham, Berks, RG40 2DB, England - -*/ - -#ifndef SDLSCREENSHOT_H -#define SDLSCREENSHOT_H - -int screenshot_write( const char *filename ); - -#endif /* #ifndef SDLSCREENSHOT_H */ Deleted: branches/fusegl/fuse/fusepb/sdlscreenshot.m =================================================================== --- branches/fusegl/fuse/fusepb/sdlscreenshot.m 2006-12-23 11:00:00 UTC (rev 261) +++ branches/fusegl/fuse/fusepb/sdlscreenshot.m 2006-12-24 13:35:50 UTC (rev 262) @@ -1,111 +0,0 @@ -/* sdlscreenshot.m: Routines for handling external format screenshots - Copyright (c) 2003,2005 Fredrick Meunier - Copyright (C) 1997-2003 Sam Lantinga - - $Id$ - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program 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 General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - Author contact information: - - E-mail: pak...@sr... - Postal address: 15 Crescent Road, Wokingham, Berks, RG40 2DB, England - -*/ - -#include <config.h> - -#include <SDL.h> - -#include <Cocoa/Cocoa.h> - -#include "sdldisplay.h" -#include "ui/ui.h" - -// Most of the following snaffled from SDL_QuartzWM.m in SDL-1.2.9 -int -screenshot_write( const char *filename, scaler_type scaler ) -{ - size_t len = strlen(filename); - const char* extension; - NSBitmapImageRep *bits; - SDL_Surface *mergedSurface; - NSAutoreleasePool *pool; - SDL_Rect rrect; - NSBitmapImageFileType type = NSTIFFFileType; - - if( len < 4 ) { - return 1; - } - - extension = filename + len - 4; - - if( !strcmp( extension, ".png" ) ) { - type = NSPNGFileType; - } else if( !strcmp( extension, ".gif" ) ) { - type = NSGIFFileType; - } else if( !strcmp( extension, ".jpg" ) ) { - type = NSJPEGFileType; - } else if( !strcmp( extension, ".bmp" ) ) { - type = NSBMPFileType; - } - - pool = [ [ NSAutoreleasePool alloc ] init ]; - SDL_GetClipRect( sdldisplay_gc, &rrect ); - -#if SDL_BYTEORDER == SDL_BIG_ENDIAN -#define BYTEORDER_DEPENDENT_RGBA_MASKS 0xFF000000, 0x00FF0000, 0x0000FF00, 0x000000FF -#else -#define BYTEORDER_DEPENDENT_RGBA_MASKS 0x000000FF, 0x0000FF00, 0x00FF0000, 0xFF000000 -#endif - /* create an appropriate endian RGBA surface */ - mergedSurface = SDL_CreateRGBSurface( SDL_SWSURFACE|SDL_SRCALPHA, - sdldisplay_gc->w, sdldisplay_gc->h, 32, - BYTEORDER_DEPENDENT_RGBA_MASKS ); - if( mergedSurface==NULL ) { - NSLog( @"Error creating surface for merge" ); - goto freePool; - } - - if( mergedSurface->pitch != - mergedSurface->format->BytesPerPixel * mergedSurface->w ) { - NSLog( @"merged surface has wrong format" ); - SDL_FreeSurface( mergedSurface ); - goto freePool; - } - - if( SDL_BlitSurface( sdldisplay_gc,&rrect,mergedSurface,&rrect ) ) { - NSLog( @"Error blitting to mergedSurface" ); - goto freePool; - } - - bits = [ [ NSBitmapImageRep alloc] - initWithBitmapDataPlanes:(unsigned char **)&mergedSurface->pixels - pixelsWide:sdldisplay_gc->w pixelsHigh:sdldisplay_gc->h - bitsPerSample:8 samplesPerPixel:4 hasAlpha:YES isPlanar:NO - colorSpaceName:NSDeviceRGBColorSpace - bytesPerRow:sdldisplay_gc->w<<2 bitsPerPixel:32 ]; - - NSData *data = [ bits representationUsingType:type properties:nil ]; - [ data writeToFile:[NSString stringWithUTF8String:filename] atomically:NO ]; - - [ bits release ]; - SDL_FreeSurface( mergedSurface ); - -freePool: - [pool release]; - - return 0; -} Modified: branches/fusegl/fuse/fusepb/thumbnail.h =================================================================== --- branches/fusegl/fuse/fusepb/thumbnail.h 2006-12-23 11:00:00 UTC (rev 261) +++ branches/fusegl/fuse/fusepb/thumbnail.h 2006-12-24 13:35:50 UTC (rev 262) @@ -29,4 +29,8 @@ int add_screen_thumbnail_to( const char*filename ); +int get_rgb24_data( libspectrum_byte *rgb24_data, size_t stride, + size_t height, size_t width, size_t height_offset, + size_t width_offset ); + #endif /* #ifndef THUMBNAIL_H */ Modified: branches/fusegl/fuse/fusepb/thumbnail.m =================================================================== --- branches/fusegl/fuse/fusepb/thumbnail.m 2006-12-23 11:00:00 UTC (rev 261) +++ branches/fusegl/fuse/fusepb/thumbnail.m 2006-12-24 13:35:50 UTC (rev 262) @@ -37,15 +37,12 @@ #include "screenshot.h" #include "scld.h" #include "settings.h" +#include "thumbnail.h" #include "ui/scaler/scaler.h" #include "ui/scaler/scaler_internals.h" #include "ui/ui.h" #include "utils.h" -static int get_rgb24_data( libspectrum_byte *rgb24_data, size_t stride, - size_t height, size_t width, size_t height_offset, - size_t width_offset ); - int add_screen_thumbnail_to( const char*filename ) { @@ -100,7 +97,7 @@ return 0; } -static int +int get_rgb24_data( libspectrum_byte *rgb24_data, size_t stride, size_t height, size_t width, size_t height_offset, size_t width_offset ) Modified: branches/fusegl/fuse/fusepb/views/DisplayOpenGLView.m =================================================================== --- branches/fusegl/fuse/fusepb/views/DisplayOpenGLView.m 2006-12-23 11:00:00 UTC (rev 261) +++ branches/fusegl/fuse/fusepb/views/DisplayOpenGLView.m 2006-12-24 13:35:50 UTC (rev 262) @@ -165,29 +165,29 @@ if( NO == screenTexInitialised ) return; /* Need to draw texture to screen here */ - memcpy(screenTex.pixels, screen.pixels, screenTex.pitch*screenTex.height); + memcpy(screenTex.pixels, screen.pixels, screenTex.pitch*screenTex.full_height); [[self openGLContext] makeCurrentContext]; /* Bind, update and draw new image */ glBindTexture(GL_TEXTURE_RECTANGLE_EXT, 1); - glTexSubImage2D(GL_TEXTURE_RECTANGLE_EXT, 0, 0, 0, screenTex.width, - screenTex.height, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, + glTexSubImage2D(GL_TEXTURE_RECTANGLE_EXT, 0, 0, 0, screenTex.full_width, + screenTex.full_height, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, screenTex.pixels); glBegin(GL_QUADS); - glTexCoord2f((float)(screenTex.width-3), 1.0f); + glTexCoord2f((float)screenTex.image_width, (float)(screenTex.image_xoffset)); glVertex2f(1.0f, 1.0f); - glTexCoord2f((float)(screenTex.width-3), (float)(screenTex.height-3)); + glTexCoord2f((float)screenTex.image_width, (float)screenTex.image_height); glVertex2f(1.0f, -1.0f); - glTexCoord2f(1.0f, (float)(screenTex.height-3)); + glTexCoord2f((float)screenTex.image_xoffset, (float)screenTex.image_height); glVertex2f(-1.0f, -1.0f); - glTexCoord2f(1.0f, 1.0f); + glTexCoord2f((float)screenTex.image_xoffset, (float)screenTex.image_yoffset); glVertex2f(-1.0f, 1.0f); glEnd(); @@ -262,14 +262,18 @@ { GLint i; - screenTex.width = newScreen->width; - screenTex.height = newScreen->height; - screenTex.pixels = calloc(screenTex.width*screenTex.height, sizeof(uint32_t)); + screenTex.full_width = newScreen->full_width; + screenTex.full_height = newScreen->full_height; + screenTex.image_width = newScreen->image_width; + screenTex.image_height = newScreen->image_height; + screenTex.image_xoffset = newScreen->image_xoffset; + screenTex.image_yoffset = newScreen->image_yoffset; + screenTex.pixels = calloc(screenTex.full_width*screenTex.full_height, sizeof(uint32_t)); if( !screenTex.pixels ) { fprintf( stderr, "%s: couldn't create screenTex.pixels\n", fuse_progname ); return; } - screenTex.pitch = screenTex.width * sizeof(uint32_t); + screenTex.pitch = screenTex.full_width * sizeof(uint32_t); [[self openGLContext] makeCurrentContext]; [[self openGLContext] update]; @@ -281,7 +285,8 @@ glEnable(GL_TEXTURE_RECTANGLE_EXT); glBindTexture(GL_TEXTURE_RECTANGLE_EXT, i+1); - glTextureRangeAPPLE(GL_TEXTURE_RECTANGLE_EXT, screenTex.width*screenTex.pitch, + glTextureRangeAPPLE(GL_TEXTURE_RECTANGLE_EXT, + screenTex.full_width*screenTex.pitch, screenTex.pixels ); glTexParameteri(GL_TEXTURE_RECTANGLE_EXT, GL_TEXTURE_STORAGE_HINT_APPLE, @@ -293,8 +298,8 @@ glTexParameteri(GL_TEXTURE_RECTANGLE_EXT, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); - glTexImage2D( GL_TEXTURE_RECTANGLE_EXT, 0, GL_RGBA, screenTex.width, - screenTex.height, 0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, + glTexImage2D( GL_TEXTURE_RECTANGLE_EXT, 0, GL_RGBA, screenTex.full_width, + screenTex.full_height, 0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, screenTex.pixels ); } screenTexInitialised = YES; Modified: branches/fusegl/fuse/ui/cocoa/cocoadisplay.c =================================================================== --- branches/fusegl/fuse/ui/cocoa/cocoadisplay.c 2006-12-23 11:00:00 UTC (rev 261) +++ branches/fusegl/fuse/ui/cocoa/cocoadisplay.c 2006-12-24 13:35:50 UTC (rev 262) @@ -78,20 +78,52 @@ static uint32_t bw_values[16]; +static void +init_scalers( void ) +{ + scaler_register_clear(); + + scaler_register( SCALER_NORMAL ); + if( machine_current->timex ) { + scaler_register( SCALER_TIMEXTV ); + } else { + scaler_register( SCALER_TV2X ); + scaler_register( SCALER_2XSAI ); + scaler_register( SCALER_SUPER2XSAI ); + scaler_register( SCALER_SUPEREAGLE ); + scaler_register( SCALER_ADVMAME2X ); + scaler_register( SCALER_ADVMAME3X ); + scaler_register( SCALER_DOTMATRIX ); + scaler_register( SCALER_HQ2X ); + scaler_register( SCALER_HQ3X ); + } + + if( scaler_is_supported( current_scaler ) ) { + scaler_select_scaler( current_scaler ); + } else { + scaler_select_scaler( SCALER_NORMAL ); + } +} + static int cocoadisplay_load_gfx_mode( void ) { - screen.width = (image_width + 3); - screen.height = image_height+3; + screen.image_width = image_width; + screen.image_height = image_height; /* Need some extra bytes around when using 2xSaI */ - screen.pixels = calloc(screen.width*screen.height, sizeof(uint32_t)); + screen.full_width = image_width+3; + screen.image_xoffset = 1; + screen.full_height = image_height+3; + screen.image_yoffset = 1; + + screen.pixels = calloc(screen.full_width*screen.full_height, sizeof(uint32_t)); if( !screen.pixels ) { fprintf( stderr, "%s: couldn't create screen.pixels\n", fuse_progname ); return 1; } - screen.pitch = screen.width * sizeof(uint32_t); + screen.pitch = screen.full_width * sizeof(uint32_t); /* Create OpenGL textures for the image in DisplayOpenGLView */ CreateTexture(&screen); @@ -135,6 +167,8 @@ image_width = width; image_height = height; + init_scalers(); + cocoadisplay_load_gfx_mode(); /* We can now output error messages to our output device */ @@ -172,8 +206,8 @@ if( machine_current->timex ) { x <<= 1; y <<= 1; dest_base = dest = (uint32_t*)( (uint8_t*)screen.pixels + - (x+1) * sizeof(uint32_t) + - (y+1) * screen.pitch); + (x+screen.image_xoffset) * sizeof(uint32_t) + + (y+screen.image_yoffset) * screen.pitch); *(dest++) = palette_colour; *(dest++) = palette_colour; @@ -182,7 +216,8 @@ *(dest++) = palette_colour; } else { dest = (uint32_t*)( (uint8_t*)screen.pixels + - (x+1) * sizeof(uint32_t) + (y+1) * screen.pitch ); + (x+screen.image_xoffset) * sizeof(uint32_t) + + (y+screen.image_yoffset) * screen.pitch ); *dest = palette_colour; } @@ -207,7 +242,8 @@ x <<= 4; y <<= 1; dest_base = (uint32_t*)( (uint8_t*)screen.pixels + - (x+1) * sizeof(uint32_t) + (y+1) * screen.pitch ); + (x+screen.image_xoffset) * sizeof(uint32_t) + + (y+screen.image_yoffset) * screen.pitch ); for( i=0; i<2; i++ ) { dest = dest_base; @@ -233,8 +269,9 @@ } } else { x <<= 3; - dest = (uint32_t*)( (uint8_t*)screen.pixels + (x+1) * sizeof(uint32_t) + - (y+1) * screen.pitch ); + dest = (uint32_t*)( (uint8_t*)screen.pixels + + (x+screen.image_xoffset) * sizeof(uint32_t) + + (y+screen.image_yoffset) * screen.pitch ); *(dest++) = ( data & 0x80 ) ? palette_ink : palette_paper; *(dest++) = ( data & 0x40 ) ? palette_ink : palette_paper; @@ -260,8 +297,9 @@ uint32_t palette_paper = palette_values[ paper ]; x <<= 4; y <<= 1; - dest_base = (uint32_t*)( (uint8_t*)screen.pixels + (x+1) * sizeof(uint32_t) + - (y+1) * screen.pitch ); + dest_base = (uint32_t*)( (uint8_t*)screen.pixels + (x+screen.image_xoffset) * + sizeof(uint32_t) + (y+screen.image_yoffset) * + screen.pitch ); for( i=0; i<2; i++ ) { dest = dest_base; Modified: branches/fusegl/fuse/ui/cocoa/cocoadisplay.h =================================================================== --- branches/fusegl/fuse/ui/cocoa/cocoadisplay.h 2006-12-23 11:00:00 UTC (rev 261) +++ branches/fusegl/fuse/ui/cocoa/cocoadisplay.h 2006-12-24 13:35:50 UTC (rev 262) @@ -31,8 +31,12 @@ typedef struct Cocoa_Texture { void *pixels; - int height; - int width; + int full_height; + int full_width; + int image_height; + int image_width; + int image_xoffset; + int image_yoffset; int pitch; } Cocoa_Texture; Copied: branches/fusegl/fuse/ui/cocoa/cocoaerror.m (from rev 261, branches/fusegl/fuse/fusepb/error.m) =================================================================== --- branches/fusegl/fuse/ui/cocoa/cocoaerror.m (rev 0) +++ branches/fusegl/fuse/ui/cocoa/cocoaerror.m 2006-12-24 13:35:50 UTC (rev 262) @@ -0,0 +1,81 @@ +/* cocoaerror.m: handle errors for Mac OS X Cocoa UI + Copyright (c) 2002 Philip Kendall + Copyright (c) 2002-2004 Fredrick Meunier + + $Id$ + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + Author contact information: + + E-mail: pak...@sr... + Postal address: 15 Crescent Road, Wokingham, Berks, RG40 2DB, England + +*/ + +#include <config.h> + +#import <Foundation/NSString.h> +#import <AppKit/NSPanel.h> + +#include <stdarg.h> +#include <stdio.h> +#include <unistd.h> + +#include "fuse.h" +#include "ui/ui.h" +#include "settings.h" + +int +aqua_verror( ui_error_level severity, const char *message ) +{ + NSString *title; + + /* Set the appropriate title */ + switch( severity ) { + case UI_ERROR_INFO: + title = @"Fuse - Info"; + break; + case UI_ERROR_ERROR: + title = @"Fuse - Error"; + break; + default: + title = @"Fuse - (Unknown error)"; + break; + } + + NSString *alertString = [NSString stringWithUTF8String:message]; + + switch( severity ) { + case UI_ERROR_INFO: + NSRunAlertPanel(title, alertString, nil, nil, nil); + break; + case UI_ERROR_ERROR: + default: + NSRunCriticalAlertPanel(title, alertString, nil, nil, nil); + break; + } + + return 0; +} + +int +ui_error_specific( ui_error_level severity, const char *message ) +{ + if ( !settings_current.full_screen ) { + return aqua_verror( severity, message ); + } + return 0; +} Copied: branches/fusegl/fuse/ui/cocoa/cocoascreenshot.h (from rev 261, branches/fusegl/fuse/fusepb/sdlscreenshot.h) =================================================================== --- branches/fusegl/fuse/ui/cocoa/cocoascreenshot.h (rev 0) +++ branches/fusegl/fuse/ui/cocoa/cocoascreenshot.h 2006-12-24 13:35:50 UTC (rev 262) @@ -0,0 +1,30 @@ +/* cocoascreenshot.h: Routines for saving .png etc. screenshots + Copyright (c) 2006 Fredrick Meunier + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + Author contact information: + + E-mail: pak...@sr... + Postal address: 15 Crescent Road, Wokingham, Berks, RG40 2DB, England + +*/ + +#ifndef COCOASCREENSHOT_H +#define COCOASCREENSHOT_H + +int screenshot_write( const char *filename ); + +#endif /* #ifndef COCOASCREENSHOT_H */ Copied: branches/fusegl/fuse/ui/cocoa/cocoascreenshot.m (from rev 261, branches/fusegl/fuse/fusepb/sdlscreenshot.m) =================================================================== --- branches/fusegl/fuse/ui/cocoa/cocoascreenshot.m (rev 0) +++ branches/fusegl/fuse/ui/cocoa/cocoascreenshot.m 2006-12-24 13:35:50 UTC (rev 262) @@ -0,0 +1,103 @@ +/* cocoascreenshot.m: Routines for handling external format screenshots + Copyright (c) 2003,2005-2006 Fredrick Meunier + Copyright (C) 1997-2003 Sam Lantinga + + $Id$ + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + Author contact information: + + E-mail: pak...@sr... + Postal address: 15 Crescent Road, Wokingham, Berks, RG40 2DB, England + +*/ + +#include <config.h> + +#include <Cocoa/Cocoa.h> + +#include "cocoascreenshot.h" +#include "display.h" +#include "thumbnail.h" +#include "ui/ui.h" + +int +screenshot_write( const char *filename ) +{ + size_t icon_stride; + size_t base_height, base_width; + size_t base_height_offset, base_width_offset; + int error = 0; + size_t len = strlen(filename); + const char* extension; + NSBitmapImageRep *bits; + NSAutoreleasePool *pool; + NSBitmapImageFileType type = NSTIFFFileType; + + if( len < 4 ) { + return 1; + } + + extension = filename + len - 4; + + if( !strcmp( extension, ".png" ) ) { + type = NSPNGFileType; + } else if( !strcmp( extension, ".gif" ) ) { + type = NSGIFFileType; + } else if( !strcmp( extension, ".jpg" ) ) { + type = NSJPEGFileType; + } else if( !strcmp( extension, ".bmp" ) ) { + type = NSBMPFileType; + } + + if( machine_current->timex ) { + base_height = 2 * DISPLAY_SCREEN_HEIGHT; + base_width = DISPLAY_SCREEN_WIDTH; + base_height_offset = 0; + base_width_offset = 0; + icon_stride = DISPLAY_SCREEN_WIDTH * 3; + } else { + base_height = DISPLAY_SCREEN_HEIGHT; + base_width = DISPLAY_SCREEN_WIDTH/2; + base_height_offset = 0; + base_width_offset = 0 ; + icon_stride = DISPLAY_ASPECT_WIDTH * 3; + } + + pool = [ [ NSAutoreleasePool alloc ] init ]; + + bits = [ [ NSBitmapImageRep alloc] + initWithBitmapDataPlanes:NULL + pixelsWide:base_width pixelsHigh:base_height + bitsPerSample:8 samplesPerPixel:3 hasAlpha:NO isPlanar:NO + colorSpaceName:NSCalibratedRGBColorSpace + bytesPerRow:icon_stride bitsPerPixel:24 ]; + + /* Change from paletted data to RGB data */ + error = get_rgb24_data( [bits bitmapData], icon_stride, base_height, + base_width, base_height_offset, base_width_offset ); + if( error ) goto freePool; + + NSData *data = [ bits representationUsingType:type properties:nil ]; + [ data writeToFile:[NSString stringWithUTF8String:filename] atomically:NO ]; + + [ bits release ]; + +freePool: + [pool release]; + + return error; +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |