[Fuse-for-macosx-commits] SF.net SVN: fuse-for-macosx: [277] branches/fusegl/fuse
Brought to you by:
fredm
From: <fr...@us...> - 2007-01-01 12:33:47
|
Revision: 277 http://svn.sourceforge.net/fuse-for-macosx/?rev=277&view=rev Author: fredm Date: 2007-01-01 04:33:46 -0800 (Mon, 01 Jan 2007) Log Message: ----------- Enable scalers other than hq[23]x. Modified Paths: -------------- branches/fusegl/fuse/TODO branches/fusegl/fuse/display.c branches/fusegl/fuse/fusepb/Fuse.xcodeproj/project.pbxproj branches/fusegl/fuse/fusepb/views/DisplayOpenGLView.m branches/fusegl/fuse/ui/cocoa/cocoadisplay.c branches/fusegl/fuse/ui/cocoa/cocoadisplay.h branches/fusegl/fuse/ui/scaler/scaler.c Added Paths: ----------- branches/fusegl/fuse/fusepb/scaler/scalers32.cpp Modified: branches/fusegl/fuse/TODO =================================================================== --- branches/fusegl/fuse/TODO 2007-01-01 07:53:04 UTC (rev 276) +++ branches/fusegl/fuse/TODO 2007-01-01 12:33:46 UTC (rev 277) @@ -20,5 +20,6 @@ * Restore activity icons * Add native joystick processing (removes SDL joystick input dependency from Fuse) +* Fix screen updating during fastloading $Id: TODO,v 1.4 2004/03/02 13:38:08 pak21 Exp $ Modified: branches/fusegl/fuse/display.c =================================================================== --- branches/fusegl/fuse/display.c 2007-01-01 07:53:04 UTC (rev 276) +++ branches/fusegl/fuse/display.c 2007-01-01 12:33:46 UTC (rev 277) @@ -2,7 +2,7 @@ Copyright (c) 1999-2006 Philip Kendall, Thomas Harte, Witold Filipczyk and Fredrick Meunier - $Id: display.c,v 1.52 2006/07/31 13:33:27 fredm Exp $ + $Id: display.c,v 1.57 2006/09/17 00:56:18 fredm Exp $ 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 @@ -39,8 +39,6 @@ #include "screenshot.h" #include "settings.h" #include "spectrum.h" -#include "tape.h" -#include "timer.h" #include "ui/ui.h" #include "ui/uidisplay.h" #include "scld.h" @@ -144,8 +142,6 @@ static int border_changes_last = 0; static struct border_change_t *border_changes = NULL; -static timer_type last_frame_time; - struct border_change_t * alloc_change(void) { @@ -226,8 +222,6 @@ display_last_border = scld_last_dec.name.hires ? display_hires_border : display_lores_border; - error = timer_get_real_time( &last_frame_time ); if( error ) return error; - return 0; } @@ -733,7 +727,7 @@ display_get_attr( int x, int y, libspectrum_byte *ink, libspectrum_byte *paper ) { - display_parse_attr( display_get_attr_byte( x, y ), ink, paper ); + display_parse_attr( display_get_attr_byte( x, y ), ink, paper ); } void @@ -951,32 +945,14 @@ int display_frame( void ) { - timer_type current_time; - float difference; - int error; - - /* Copy all the critical region to display_image[] */ + /* Copy all the critical region to the display */ copy_critical_region( DISPLAY_WIDTH_COLS, DISPLAY_HEIGHT - 1 ); critical_region_x = critical_region_y = 0; - error = timer_get_real_time( ¤t_time ); if( error ) return error; - difference = timer_get_time_difference( ¤t_time, &last_frame_time ); + update_border(); + update_dirty_rects(); + update_ui_screen(); - /* don't bother updating the screen more than 25 times a second if we are - fastloading a tape, or 50 times a second if we are running at more than 100% - speed */ - if( ( !( settings_current.fastload && tape_is_playing() ) && - ( settings_current.emulation_speed == 100 || difference >= (1.0/50.0) ) ) || - ( settings_current.fastload && tape_is_playing() && - difference >= (1.0/25.0) ) ) { - - update_border(); - update_dirty_rects(); - update_ui_screen(); - last_frame_time = current_time; - - } - if( screenshot_movie_record == 1 ) { snprintf( screenshot_movie_name, SCREENSHOT_MOVIE_FILE_MAX, Modified: branches/fusegl/fuse/fusepb/Fuse.xcodeproj/project.pbxproj =================================================================== --- branches/fusegl/fuse/fusepb/Fuse.xcodeproj/project.pbxproj 2007-01-01 07:53:04 UTC (rev 276) +++ branches/fusegl/fuse/fusepb/Fuse.xcodeproj/project.pbxproj 2007-01-01 12:33:46 UTC (rev 277) @@ -78,8 +78,6 @@ B61F45E109121DF100C8096C /* machines.h in Headers */ = {isa = PBXBuildFile; fileRef = B6AD8FEC06221FD500C70D75 /* machines.h */; }; B61F45E209121DF100C8096C /* simpleide.h in Headers */ = {isa = PBXBuildFile; fileRef = B6AD90560622B59200C70D75 /* simpleide.h */; }; B61F45E309121DF100C8096C /* if2.h in Headers */ = {isa = PBXBuildFile; fileRef = B621A11F062E92FB00F63DBC /* if2.h */; }; - B61F45E409121DF100C8096C /* hq2x.h in Headers */ = {isa = PBXBuildFile; fileRef = B6C8696A06561155003000A6 /* hq2x.h */; }; - B61F45E509121DF100C8096C /* hq3x.h in Headers */ = {isa = PBXBuildFile; fileRef = B6C8696B06561155003000A6 /* hq3x.h */; }; B61F45E609121DF100C8096C /* intern.h in Headers */ = {isa = PBXBuildFile; fileRef = B6C86978065611B3003000A6 /* intern.h */; }; B61F45E709121DF100C8096C /* zxatasp.h in Headers */ = {isa = PBXBuildFile; fileRef = B601847A065A586900B0BE59 /* zxatasp.h */; }; B61F45E809121DF100C8096C /* zxcf.h in Headers */ = {isa = PBXBuildFile; fileRef = B601847C065A586900B0BE59 /* zxcf.h */; }; @@ -208,9 +206,6 @@ B61F467009121DF100C8096C /* PokeFinderController.m in Sources */ = {isa = PBXBuildFile; fileRef = B62F3BCF059F5BF300A7009A /* PokeFinderController.m */; }; B61F467209121DF100C8096C /* MemoryBrowserController.m in Sources */ = {isa = PBXBuildFile; fileRef = B6D2989205B061CB00C2AA14 /* MemoryBrowserController.m */; }; B61F467309121DF100C8096C /* periph.c in Sources */ = {isa = PBXBuildFile; fileRef = B6C57E0005ECA05B0056F1D0 /* periph.c */; }; - B61F467509121DF100C8096C /* scalers16.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6C57E3F05ECC9260056F1D0 /* scalers16.cpp */; }; - B61F467609121DF100C8096C /* hq2x.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B65163AB05F4A11E001903BE /* hq2x.cpp */; }; - B61F467709121DF100C8096C /* hq3x.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B61EF5B905FED7930081DF70 /* hq3x.cpp */; }; B61F467809121DF100C8096C /* fuse.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CD0B9E06069F4A00847338 /* fuse.cpp */; }; B61F467909121DF100C8096C /* breakpoint.c in Sources */ = {isa = PBXBuildFile; fileRef = B66050EC0606AAF500247454 /* breakpoint.c */; }; B61F467A09121DF100C8096C /* scorpion.c in Sources */ = {isa = PBXBuildFile; fileRef = B66050F80606AB0B00247454 /* scorpion.c */; }; @@ -263,6 +258,7 @@ B650987109366CA2003AF1BF /* szx.icns in Resources */ = {isa = PBXBuildFile; fileRef = B650987009366CA2003AF1BF /* szx.icns */; }; B6825549091817F30014B5EE /* divide.c in Sources */ = {isa = PBXBuildFile; fileRef = B6825547091817F30014B5EE /* divide.c */; }; B682554A091817F30014B5EE /* divide.h in Headers */ = {isa = PBXBuildFile; fileRef = B6825548091817F30014B5EE /* divide.h */; }; + B6A24DF80B490F2100AD5B9D /* scalers32.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6A24DF70B490F2100AD5B9D /* scalers32.cpp */; }; 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 */; }; @@ -360,7 +356,6 @@ B615BFE50B4261E50082D535 /* HIDJoysticks.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = HIDJoysticks.h; path = content_arrays/HIDJoysticks.h; sourceTree = "<group>"; }; B615BFE60B4261E50082D535 /* HIDJoysticks.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; name = HIDJoysticks.m; path = content_arrays/HIDJoysticks.m; sourceTree = "<group>"; }; B619FC2E090D9BC200344F94 /* SavePanelAccessoryView.nib */ = {isa = PBXFileReference; lastKnownFileType = wrapper.nib; name = SavePanelAccessoryView.nib; path = nibs/SavePanelAccessoryView.nib; sourceTree = "<group>"; }; - B61EF5B905FED7930081DF70 /* hq3x.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = hq3x.cpp; path = scaler/hq3x.cpp; sourceTree = SOURCE_ROOT; }; B61F46A909121DF100C8096C /* Info-Fuse.plist */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = "Info-Fuse.plist"; sourceTree = "<group>"; }; B61F46AA09121DF200C8096C /* Fuse.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Fuse.app; sourceTree = BUILT_PRODUCTS_DIR; }; B6202BD105BD43D800A1EA8F /* libbz2.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = libbz2.framework; path = ../../bzip2/build/Deployment/libbz2.framework; sourceTree = SOURCE_ROOT; }; @@ -415,7 +410,6 @@ B650C40A0765988200DE7E81 /* tape_scorpion.szx */ = {isa = PBXFileReference; lastKnownFileType = file; name = tape_scorpion.szx; path = ../lib/compressed/tape_scorpion.szx; sourceTree = SOURCE_ROOT; }; B650F73E07E7CD3F00E4F3AF /* PreferencesController.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = PreferencesController.h; path = controllers/PreferencesController.h; sourceTree = SOURCE_ROOT; }; B650F73F07E7CD3F00E4F3AF /* PreferencesController.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; name = PreferencesController.m; path = controllers/PreferencesController.m; sourceTree = SOURCE_ROOT; }; - B65163AB05F4A11E001903BE /* hq2x.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = hq2x.cpp; path = scaler/hq2x.cpp; sourceTree = SOURCE_ROOT; }; B65E4C600445DB7D00A864FD /* dck.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = dck.c; path = ../dck.c; sourceTree = SOURCE_ROOT; }; B65E4C610445DB7D00A864FD /* dck.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = dck.h; path = ../dck.h; sourceTree = SOURCE_ROOT; }; B66050EC0606AAF500247454 /* breakpoint.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = breakpoint.c; path = ../debugger/breakpoint.c; sourceTree = SOURCE_ROOT; }; @@ -456,6 +450,7 @@ B68CB2C503DD920300A804BA /* debugger.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = debugger.h; path = ../debugger/debugger.h; sourceTree = "<group>"; }; B68CB2C603DD920300A804BA /* disassemble.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = disassemble.c; path = ../debugger/disassemble.c; sourceTree = "<group>"; }; B68CB2CC03DD923C00A804BA /* memory.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = memory.c; sourceTree = "<group>"; }; + B6A24DF70B490F2100AD5B9D /* scalers32.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = scalers32.cpp; path = scaler/scalers32.cpp; sourceTree = SOURCE_ROOT; }; 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>"; }; @@ -485,12 +480,9 @@ B6C3479F044B091100E1BBA7 /* ts2068.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = ts2068.png; path = resources/ts2068.png; sourceTree = SOURCE_ROOT; }; B6C57E0005ECA05B0056F1D0 /* periph.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = periph.c; path = ../periph.c; sourceTree = SOURCE_ROOT; }; B6C57E0105ECA05B0056F1D0 /* periph.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = periph.h; path = ../periph.h; sourceTree = SOURCE_ROOT; }; - B6C57E3F05ECC9260056F1D0 /* scalers16.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = scalers16.cpp; path = scaler/scalers16.cpp; sourceTree = SOURCE_ROOT; }; B6C691B704C20A42005EE041 /* joystick.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = joystick.c; path = ../joystick.c; sourceTree = SOURCE_ROOT; }; B6C740D90810BB0500AB170C /* Joysticks.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = Joysticks.h; path = content_arrays/Joysticks.h; sourceTree = SOURCE_ROOT; }; B6C740DA0810BB0500AB170C /* Joysticks.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; name = Joysticks.m; path = content_arrays/Joysticks.m; sourceTree = SOURCE_ROOT; }; - B6C8696A06561155003000A6 /* hq2x.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = hq2x.h; path = scaler/hq2x.h; sourceTree = SOURCE_ROOT; }; - B6C8696B06561155003000A6 /* hq3x.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = hq3x.h; path = scaler/hq3x.h; sourceTree = SOURCE_ROOT; }; B6C86978065611B3003000A6 /* intern.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = intern.h; path = scaler/intern.h; sourceTree = SOURCE_ROOT; }; B6C8B723076D2B1A0007B7B5 /* if1.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = if1.c; path = ../if1.c; sourceTree = SOURCE_ROOT; }; B6C8B724076D2B1A0007B7B5 /* if1.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = if1.h; path = ../if1.h; sourceTree = SOURCE_ROOT; }; @@ -961,15 +953,11 @@ F541FB5C03B0B31601FF8235 /* scaler */ = { isa = PBXGroup; children = ( - B65163AB05F4A11E001903BE /* hq2x.cpp */, - B6C8696A06561155003000A6 /* hq2x.h */, - B61EF5B905FED7930081DF70 /* hq3x.cpp */, - B6C8696B06561155003000A6 /* hq3x.h */, B6C86978065611B3003000A6 /* intern.h */, B63ABD8D042F175200A864FD /* scaler.c */, F541FB5E03B0B33401FF8235 /* scaler.h */, B60A6A3A042BEECE00D41533 /* scaler_internals.h */, - B6C57E3F05ECC9260056F1D0 /* scalers16.cpp */, + B6A24DF70B490F2100AD5B9D /* scalers32.cpp */, ); path = scaler; sourceTree = "<group>"; @@ -1195,8 +1183,6 @@ B61F45E109121DF100C8096C /* machines.h in Headers */, B61F45E209121DF100C8096C /* simpleide.h in Headers */, B61F45E309121DF100C8096C /* if2.h in Headers */, - B61F45E409121DF100C8096C /* hq2x.h in Headers */, - B61F45E509121DF100C8096C /* hq3x.h in Headers */, B61F45E609121DF100C8096C /* intern.h in Headers */, B61F45E709121DF100C8096C /* zxatasp.h in Headers */, B61F45E809121DF100C8096C /* zxcf.h in Headers */, @@ -1419,9 +1405,6 @@ B61F467009121DF100C8096C /* PokeFinderController.m in Sources */, B61F467209121DF100C8096C /* MemoryBrowserController.m in Sources */, B61F467309121DF100C8096C /* periph.c in Sources */, - B61F467509121DF100C8096C /* scalers16.cpp in Sources */, - B61F467609121DF100C8096C /* hq2x.cpp in Sources */, - B61F467709121DF100C8096C /* hq3x.cpp in Sources */, B61F467809121DF100C8096C /* fuse.cpp in Sources */, B61F467909121DF100C8096C /* breakpoint.c in Sources */, B61F467A09121DF100C8096C /* scorpion.c in Sources */, @@ -1464,6 +1447,7 @@ B6A6F10E0B3D6360000B88E9 /* cocoaerror.m in Sources */, B6A6F1200B3EA737000B88E9 /* cocoascreenshot.m in Sources */, B615BFE80B4261E50082D535 /* HIDJoysticks.m in Sources */, + B6A24DF80B490F2100AD5B9D /* scalers32.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; Copied: branches/fusegl/fuse/fusepb/scaler/scalers32.cpp (from rev 271, branches/fusegl/fuse/fusepb/scaler/scalers16.cpp) =================================================================== --- branches/fusegl/fuse/fusepb/scaler/scalers32.cpp (rev 0) +++ branches/fusegl/fuse/fusepb/scaler/scalers32.cpp 2007-01-01 12:33:46 UTC (rev 277) @@ -0,0 +1,28 @@ +/* scalers.cpp: the actual graphics scalers + * Copyright (C) 2003 Fredrick Meunier, Philip Kendall + * + * $Id: scalers16.cpp,v 1.1 2004/05/17 14:42:14 fred Exp $ + * + * Originally taken from ScummVM - Scumm Interpreter + * Copyright (C) 2001 Ludvig Strigeus + * Copyright (C) 2001/2002 The ScummVM project + * + * 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. + * + */ + +#define SCALER_DATA_SIZE 4 + +#include "ui/scaler/scalers.cpp" Modified: branches/fusegl/fuse/fusepb/views/DisplayOpenGLView.m =================================================================== --- branches/fusegl/fuse/fusepb/views/DisplayOpenGLView.m 2007-01-01 07:53:04 UTC (rev 276) +++ branches/fusegl/fuse/fusepb/views/DisplayOpenGLView.m 2007-01-01 12:33:46 UTC (rev 277) @@ -113,8 +113,8 @@ timer = nil; /* Setup some basic OpenGL stuff */ - glPixelStorei(GL_UNPACK_ALIGNMENT, 1); - glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); + glPixelStorei( GL_UNPACK_ALIGNMENT, 1 ); + glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE ); glClearColor(0.0f, 0.0f, 0.0f, 0.0f); glColor4f(0.0f, 0.0f, 0.0f, 0.0f); @@ -160,38 +160,35 @@ if( NO == screenTexInitialised ) return; /* Need to draw texture to screen here */ - memcpy(screenTex.pixels, screen.pixels, screenTex.pitch*screenTex.full_height); + memcpy( screenTex.pixels, screen->pixels, screenTex.pitch * screenTex.full_height ); [[self openGLContext] makeCurrentContext]; - glClear(GL_COLOR_BUFFER_BIT); + glClear( GL_COLOR_BUFFER_BIT ); /* Bind, update and draw new image */ - glBindTexture(GL_TEXTURE_RECTANGLE_EXT, 1); + glBindTexture( GL_TEXTURE_RECTANGLE_EXT, 1 ); - 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); + 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); + glBegin( GL_QUADS ); - glTexCoord2f((float)screenTex.image_width, (float)(screenTex.image_xoffset)); - glVertex2f(1.0f, 1.0f); + glTexCoord2f( (float)screenTex.image_width, (float)(screenTex.image_xoffset) ); + glVertex2f( 1.0f, 1.0f ); - glTexCoord2f((float)screenTex.image_width, (float)screenTex.image_height); - glVertex2f(1.0f, -1.0f); + glTexCoord2f( (float)screenTex.image_width, (float)screenTex.image_height ); + glVertex2f( 1.0f, -1.0f ); - glTexCoord2f((float)screenTex.image_xoffset, (float)screenTex.image_height); - glVertex2f(-1.0f, -1.0f); + glTexCoord2f( (float)screenTex.image_xoffset, (float)screenTex.image_height ); + glVertex2f( -1.0f, -1.0f ); - glTexCoord2f((float)screenTex.image_xoffset, (float)screenTex.image_yoffset); - glVertex2f(-1.0f, 1.0f); + glTexCoord2f( (float)screenTex.image_xoffset, (float)screenTex.image_yoffset ); + glVertex2f( -1.0f, 1.0f ); glEnd(); - /* FIXME: Probably still need to glFlush() in fullscreen mode */ - //glFlush(); - /* Swap buffer to screen */ [[self openGLContext] flushBuffer]; } @@ -201,14 +198,14 @@ { float bounds_ratio = rect.size.width/rect.size.height; - if( fabs(bounds_ratio - target_ratio) < 0.01f ) { - glViewport(0, 0, (int) rect.size.width, (int) rect.size.height); + if( fabs( bounds_ratio - target_ratio ) < 0.01f ) { + glViewport( 0, 0, (int) rect.size.width, (int) rect.size.height ); } else if( bounds_ratio > target_ratio ) { - int x_offset = (rect.size.width - (rect.size.height * target_ratio))/2.0f; - glViewport(x_offset, 0, (int)(rect.size.height*target_ratio), (int) rect.size.height); + int x_offset = ( rect.size.width - ( rect.size.height * target_ratio ) ) / 2.0f; + glViewport( x_offset, 0, (int)(rect.size.height*target_ratio), (int) rect.size.height ); } else { - int y_offset = (rect.size.height - (rect.size.width / target_ratio))/2.0f; - glViewport(0, y_offset, (int) rect.size.width, (int) (rect.size.width/target_ratio)); + int y_offset = ( rect.size.height - ( rect.size.width / target_ratio ) ) / 2.0f; + glViewport( 0, y_offset, (int) rect.size.width, (int) ( rect.size.width / target_ratio ) ); } } @@ -226,15 +223,15 @@ [self setViewPort:rect]; - glMatrixMode(GL_PROJECTION); + glMatrixMode( GL_PROJECTION ); glLoadIdentity(); - gluOrtho2D(0, rect.size.width, 0, rect.size.height); + gluOrtho2D( 0, rect.size.width, 0, rect.size.height ); - glMatrixMode(GL_MODELVIEW); + glMatrixMode( GL_MODELVIEW ); glLoadIdentity(); - [self setNeedsDisplay:true]; + [self setNeedsDisplay:YES]; } /* scrolled, moved or resized */ @@ -251,13 +248,13 @@ [self setViewPort:rect]; - glMatrixMode(GL_PROJECTION); + glMatrixMode( GL_PROJECTION ); glLoadIdentity(); - glMatrixMode(GL_MODELVIEW); + glMatrixMode( GL_MODELVIEW ); glLoadIdentity(); - [self setNeedsDisplay:true]; + [self setNeedsDisplay:YES]; } -(void) destroyTexture @@ -283,7 +280,7 @@ 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)); + 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; @@ -296,22 +293,23 @@ /* FIXME: May want to have a double buffered texture later */ for(i = 0; i < 1; i++) { - glDisable(GL_TEXTURE_2D); - glEnable(GL_TEXTURE_RECTANGLE_EXT); - glBindTexture(GL_TEXTURE_RECTANGLE_EXT, i+1); + glDisable( GL_TEXTURE_2D ); + glEnable( GL_TEXTURE_RECTANGLE_EXT ); + glBindTexture( GL_TEXTURE_RECTANGLE_EXT, i+1 ); - glTextureRangeAPPLE(GL_TEXTURE_RECTANGLE_EXT, - screenTex.full_width*screenTex.pitch, - screenTex.pixels ); + glTextureRangeAPPLE( GL_TEXTURE_RECTANGLE_EXT, + screenTex.full_width * screenTex.pitch, + screenTex.pixels ); - glTexParameteri(GL_TEXTURE_RECTANGLE_EXT, GL_TEXTURE_STORAGE_HINT_APPLE, - GL_STORAGE_CACHED_APPLE); - glPixelStorei(GL_UNPACK_CLIENT_STORAGE_APPLE, GL_TRUE ); - glTexParameteri(GL_TEXTURE_RECTANGLE_EXT, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - glTexParameteri(GL_TEXTURE_RECTANGLE_EXT, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - glTexParameteri(GL_TEXTURE_RECTANGLE_EXT, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - glTexParameteri(GL_TEXTURE_RECTANGLE_EXT, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); + glTexParameteri( GL_TEXTURE_RECTANGLE_EXT, GL_TEXTURE_STORAGE_HINT_APPLE, + GL_STORAGE_CACHED_APPLE ); + glPixelStorei( GL_UNPACK_CLIENT_STORAGE_APPLE, GL_TRUE ); + /* FIXME: Want GL_NEAREST for exact pixel ratios, GL_LINEAR otherwise */ + glTexParameteri( GL_TEXTURE_RECTANGLE_EXT, GL_TEXTURE_MIN_FILTER, GL_LINEAR ); + glTexParameteri( GL_TEXTURE_RECTANGLE_EXT, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); + glTexParameteri( GL_TEXTURE_RECTANGLE_EXT, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE ); + 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.full_width, screenTex.full_height, 0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, Modified: branches/fusegl/fuse/ui/cocoa/cocoadisplay.c =================================================================== --- branches/fusegl/fuse/ui/cocoa/cocoadisplay.c 2007-01-01 07:53:04 UTC (rev 276) +++ branches/fusegl/fuse/ui/cocoa/cocoadisplay.c 2007-01-01 12:33:46 UTC (rev 277) @@ -50,12 +50,18 @@ #include "ui/uidisplay.h" #include "utils.h" +/* The current size of the display (in units of DISPLAY_SCREEN_*) */ +static float display_current_size = 1.0f; + static int image_width; static int image_height; /* Screen texture */ -Cocoa_Texture screen; +Cocoa_Texture* screen = NULL; +Cocoa_Texture unscaled_screen; +Cocoa_Texture scaled_screen; + static uint32_t colour_values[] = { /* AARRGGBB */ 0x00000000, @@ -94,8 +100,10 @@ scaler_register( SCALER_ADVMAME2X ); scaler_register( SCALER_ADVMAME3X ); scaler_register( SCALER_DOTMATRIX ); +#if 0 scaler_register( SCALER_HQ2X ); scaler_register( SCALER_HQ3X ); +#endif } if( scaler_is_supported( current_scaler ) ) { @@ -106,27 +114,51 @@ } static int -cocoadisplay_load_gfx_mode( void ) +cocoadisplay_allocate_screen( Cocoa_Texture* screen, int height, int width, + float scaling_factor ) { - screen.image_width = image_width; - screen.image_height = image_height; + screen->image_width = image_width * display_current_size; + screen->image_height = image_height * display_current_size; /* Need some extra bytes around when using 2xSaI */ - screen.full_width = image_width+3; - screen.image_xoffset = 1; - screen.full_height = image_height+3; - screen.image_yoffset = 1; + screen->full_width = screen->image_width+3; + screen->image_xoffset = 1; + screen->full_height = screen->image_height+3; + screen->image_yoffset = 1; - screen.pixels = calloc(screen.full_width*screen.full_height, sizeof(uint32_t)); - if( !screen.pixels ) { + 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.full_width * sizeof(uint32_t); + screen->pitch = screen->full_width * sizeof(uint32_t); + return 0; +} + +static int +cocoadisplay_load_gfx_mode( void ) +{ + int error; + + display_current_size = scaler_get_scaling_factor( current_scaler ); + + error = cocoadisplay_allocate_screen( &unscaled_screen, image_height, image_width, 1.0f ); + if( error ) return error; + + screen = &unscaled_screen; + + if( current_scaler != SCALER_NORMAL ) { + error = cocoadisplay_allocate_screen( &scaled_screen, image_height, + image_width, display_current_size ); + if( error ) return error; + + screen = &scaled_screen; + } + /* Create OpenGL textures for the image in DisplayOpenGLView */ - CreateTexture(&screen); + CreateTexture( screen ); /* Redraw the entire screen... */ display_refresh_all(); @@ -159,7 +191,7 @@ uidisplay_init( int width, int height ) { int error; - error = cocoadisplay_allocate_colours( sizeof(colour_values)/sizeof(uint32_t), + error = cocoadisplay_allocate_colours( sizeof(colour_values) / sizeof(uint32_t), colour_values, bw_values ); scaler_select_scaler( SCALER_NORMAL ); @@ -169,6 +201,9 @@ init_scalers(); + if ( scaler_select_scaler( current_scaler ) ) + scaler_select_scaler( SCALER_NORMAL ); + cocoadisplay_load_gfx_mode(); /* We can now output error messages to our output device */ @@ -183,9 +218,9 @@ fuse_emulation_pause(); /* Free the old surface */ - if( screen.pixels ) { - free( screen.pixels ); - screen.pixels=NULL; + if( unscaled_screen.pixels ) { + free( unscaled_screen.pixels ); + unscaled_screen.pixels=NULL; } /* Setup the new GFX mode */ @@ -205,19 +240,19 @@ if( machine_current->timex ) { x <<= 1; y <<= 1; - dest_base = dest = (uint32_t*)( (uint8_t*)screen.pixels + - (x+screen.image_xoffset) * sizeof(uint32_t) + - (y+screen.image_yoffset) * screen.pitch); + dest_base = dest = (uint32_t*)( (uint8_t*)unscaled_screen.pixels + + (x+unscaled_screen.image_xoffset) * sizeof(uint32_t) + + (y+unscaled_screen.image_yoffset) * unscaled_screen.pitch ); *(dest++) = palette_colour; *(dest++) = palette_colour; - dest = (uint32_t*)( (uint8_t*)dest_base + screen.pitch ); + dest = (uint32_t*)( (uint8_t*)dest_base + unscaled_screen.pitch ); *(dest++) = palette_colour; *(dest++) = palette_colour; } else { - dest = (uint32_t*)( (uint8_t*)screen.pixels + - (x+screen.image_xoffset) * sizeof(uint32_t) + - (y+screen.image_yoffset) * screen.pitch ); + dest = (uint32_t*)( (uint8_t*)unscaled_screen.pixels + + (x+unscaled_screen.image_xoffset) * sizeof(uint32_t) + + (y+unscaled_screen.image_yoffset) * unscaled_screen.pitch ); *dest = palette_colour; } @@ -241,9 +276,9 @@ x <<= 4; y <<= 1; - dest_base = (uint32_t*)( (uint8_t*)screen.pixels + - (x+screen.image_xoffset) * sizeof(uint32_t) + - (y+screen.image_yoffset) * screen.pitch ); + dest_base = (uint32_t*)( (uint8_t*)unscaled_screen.pixels + + (x+unscaled_screen.image_xoffset) * sizeof(uint32_t) + + (y+unscaled_screen.image_yoffset) * unscaled_screen.pitch ); for( i=0; i<2; i++ ) { dest = dest_base; @@ -265,13 +300,13 @@ *(dest++) = ( data & 0x01 ) ? palette_ink : palette_paper; *dest = ( data & 0x01 ) ? palette_ink : palette_paper; - dest_base = (uint32_t*)( (uint8_t*)dest_base + screen.pitch ); + dest_base = (uint32_t*)( (uint8_t*)dest_base + unscaled_screen.pitch ); } } else { x <<= 3; - dest = (uint32_t*)( (uint8_t*)screen.pixels + - (x+screen.image_xoffset) * sizeof(uint32_t) + - (y+screen.image_yoffset) * screen.pitch ); + dest = (uint32_t*)( (uint8_t*)unscaled_screen.pixels + + (x+unscaled_screen.image_xoffset) * sizeof(uint32_t) + + (y+unscaled_screen.image_yoffset) * unscaled_screen.pitch ); *(dest++) = ( data & 0x80 ) ? palette_ink : palette_paper; *(dest++) = ( data & 0x40 ) ? palette_ink : palette_paper; @@ -297,9 +332,9 @@ uint32_t palette_paper = palette_values[ paper ]; x <<= 4; y <<= 1; - dest_base = (uint32_t*)( (uint8_t*)screen.pixels + (x+screen.image_xoffset) * - sizeof(uint32_t) + (y+screen.image_yoffset) * - screen.pitch ); + dest_base = (uint32_t*)( (uint8_t*)unscaled_screen.pixels + (x+unscaled_screen.image_xoffset) * + sizeof(uint32_t) + (y+unscaled_screen.image_yoffset) * + unscaled_screen.pitch ); for( i=0; i<2; i++ ) { dest = dest_base; @@ -321,32 +356,54 @@ *(dest++) = ( data & 0x0002 ) ? palette_ink : palette_paper; *dest = ( data & 0x0001 ) ? palette_ink : palette_paper; - dest_base = (uint32_t*)( (uint8_t*)dest_base + screen.pitch ); + dest_base = (uint32_t*)( (uint8_t*)dest_base + unscaled_screen.pitch ); } } void uidisplay_frame_end( void ) { - /* Send data to DisplayOpenGLView somehow? */ - /* Could set some sort of flag to tell DisplayOpenGLView there is a new - image to draw */ + /* Data is read by the DisplayOpenGLView at the end of a frame */ } void uidisplay_area( int x, int y, int width, int height ) { - /* Do nothing - will send whole framebuffer over at frame end ATM */ + int scaled_x, scaled_y; + + if( current_scaler == SCALER_NORMAL ) return; + + /* Extend the dirty region by 1 pixel for scalers that "smear" the screen, + e.g. 2xSAI */ + if( scaler_flags & SCALER_FLAGS_EXPAND ) + scaler_expander( &x, &y, &width, &height, image_width, image_height ); + + scaled_x = display_current_size * x; + scaled_y = display_current_size * y; + + /* Create scaled image */ + scaler_proc32( unscaled_screen.pixels + ( y + 1 ) * unscaled_screen.pitch + sizeof(uint32_t) * ( x + 1 ), + unscaled_screen.pitch, + scaled_screen.pixels + scaled_y * scaled_screen.pitch + sizeof(uint32_t) * scaled_x, + scaled_screen.pitch, width, height ); } int uidisplay_end( void ) { - if( screen.pixels ) { - free( screen.pixels ); - screen.pixels=NULL; + if( screen && screen->pixels ) { DestroyTexture(); } + if( unscaled_screen.pixels ) { + free( unscaled_screen.pixels ); + unscaled_screen.pixels=NULL; + } + + if( scaled_screen.pixels ) { + free( scaled_screen.pixels ); + scaled_screen.pixels=NULL; + } + return 0; } Modified: branches/fusegl/fuse/ui/cocoa/cocoadisplay.h =================================================================== --- branches/fusegl/fuse/ui/cocoa/cocoadisplay.h 2007-01-01 07:53:04 UTC (rev 276) +++ branches/fusegl/fuse/ui/cocoa/cocoadisplay.h 2007-01-01 12:33:46 UTC (rev 277) @@ -41,7 +41,7 @@ } Cocoa_Texture; /* Screen texture */ -extern Cocoa_Texture screen; +extern Cocoa_Texture* screen; extern ui_statusbar_state cocoa_disk_state, cocoa_mdr_state, cocoa_tape_state; Modified: branches/fusegl/fuse/ui/scaler/scaler.c =================================================================== --- branches/fusegl/fuse/ui/scaler/scaler.c 2007-01-01 07:53:04 UTC (rev 276) +++ branches/fusegl/fuse/ui/scaler/scaler.c 2007-01-01 12:33:46 UTC (rev 277) @@ -69,37 +69,39 @@ static struct scaler_info available_scalers[] = { { "Timex Half (smoothed)", "half", SCALER_FLAGS_NONE, SCALE_FACTOR_HALF, - scaler_Half_16, NULL, NULL }, + NULL, scaler_Half_32, NULL }, { "Timex Half (skipping)", "halfskip", SCALER_FLAGS_NONE, SCALE_FACTOR_HALF, - scaler_HalfSkip_16, NULL, NULL }, + NULL, scaler_HalfSkip_32, NULL }, { "Normal", "normal", SCALER_FLAGS_NONE, SCALE_FACTOR_ONE, - scaler_Normal1x_16, NULL, NULL }, + NULL, scaler_Normal1x_32, NULL }, { "Double size", "2x", SCALER_FLAGS_NONE, SCALE_FACTOR_TWO, - scaler_Normal2x_16, NULL, NULL }, + NULL, scaler_Normal2x_32, NULL }, { "Triple size", "3x", SCALER_FLAGS_NONE, SCALE_FACTOR_THREE, - scaler_Normal3x_16, NULL, NULL }, + NULL, scaler_Normal3x_32, NULL }, { "2xSaI", "2xsai", SCALER_FLAGS_EXPAND, SCALE_FACTOR_TWO, - scaler_2xSaI_16, NULL, expand_sai }, + NULL, scaler_2xSaI_32, expand_sai }, { "Super 2xSaI", "super2xsai", SCALER_FLAGS_EXPAND, SCALE_FACTOR_TWO, - scaler_Super2xSaI_16, NULL, expand_sai }, + NULL, scaler_Super2xSaI_32, expand_sai }, { "SuperEagle", "supereagle", SCALER_FLAGS_EXPAND, SCALE_FACTOR_TWO, - scaler_SuperEagle_16, NULL, expand_sai }, + NULL, scaler_SuperEagle_32, expand_sai }, { "AdvMAME 2x", "advmame2x", SCALER_FLAGS_EXPAND, SCALE_FACTOR_TWO, - scaler_AdvMame2x_16, NULL, expand_1 }, + NULL, scaler_AdvMame2x_32, expand_1 }, { "AdvMAME 3x", "advmame3x", SCALER_FLAGS_EXPAND, SCALE_FACTOR_THREE, - scaler_AdvMame3x_16, NULL, expand_1 }, + NULL, scaler_AdvMame3x_32, expand_1 }, { "TV 2x", "tv2x", SCALER_FLAGS_NONE, SCALE_FACTOR_TWO, - scaler_TV2x_16, NULL, NULL }, + NULL, scaler_TV2x_32, NULL }, { "Timex TV", "timextv", SCALER_FLAGS_NONE, SCALE_FACTOR_ONE, - scaler_TimexTV_16, NULL, NULL }, + NULL, scaler_TimexTV_32, NULL }, { "Dot Matrix", "dotmatrix", SCALER_FLAGS_EXPAND, SCALE_FACTOR_TWO, - scaler_DotMatrix_16, NULL, expand_dotmatrix }, + NULL, scaler_DotMatrix_32, expand_dotmatrix }, { "Timex 1.5x", "timex15x", SCALER_FLAGS_NONE, SCALE_FACTOR_ONE_HALF, - scaler_Timex1_5x_16, NULL, NULL }, + NULL, scaler_Timex1_5x_32, NULL }, +#if 0 { "HQ 2x", "hq2x", SCALER_FLAGS_EXPAND, SCALE_FACTOR_TWO, scaler_HQ2x_16, NULL, expand_1 }, { "HQ 3x", "hq3x", SCALER_FLAGS_EXPAND, SCALE_FACTOR_THREE, scaler_HQ3x_16, NULL, expand_1 }, +#endif }; scaler_type current_scaler = SCALER_NUM; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |