[Scummvm-cvs-logs] SF.net SVN: scummvm:[43701] scummvm/branches/gsoc2009-mods

nolange at users.sourceforge.net nolange at users.sourceforge.net
Mon Aug 24 19:51:52 CEST 2009


Revision: 43701
          http://scummvm.svn.sourceforge.net/scummvm/?rev=43701&view=rev
Author:   nolange
Date:     2009-08-24 17:51:47 +0000 (Mon, 24 Aug 2009)

Log Message:
-----------
Merge with trunk

Modified Paths:
--------------
    scummvm/branches/gsoc2009-mods/AUTHORS
    scummvm/branches/gsoc2009-mods/COPYRIGHT
    scummvm/branches/gsoc2009-mods/Makefile
    scummvm/branches/gsoc2009-mods/Makefile.common
    scummvm/branches/gsoc2009-mods/NEWS
    scummvm/branches/gsoc2009-mods/README
    scummvm/branches/gsoc2009-mods/backends/fs/psp/psp-fs-factory.cpp
    scummvm/branches/gsoc2009-mods/backends/fs/psp/psp-fs.cpp
    scummvm/branches/gsoc2009-mods/backends/module.mk
    scummvm/branches/gsoc2009-mods/backends/platform/dc/dc.h
    scummvm/branches/gsoc2009-mods/backends/platform/dc/display.cpp
    scummvm/branches/gsoc2009-mods/backends/platform/gp2x/gp2x-common.h
    scummvm/branches/gsoc2009-mods/backends/platform/gp2x/graphics.cpp
    scummvm/branches/gsoc2009-mods/backends/platform/iphone/osys_main.h
    scummvm/branches/gsoc2009-mods/backends/platform/iphone/osys_video.cpp
    scummvm/branches/gsoc2009-mods/backends/platform/psp/Makefile
    scummvm/branches/gsoc2009-mods/backends/platform/psp/README.PSP.in
    scummvm/branches/gsoc2009-mods/backends/platform/psp/module.mk
    scummvm/branches/gsoc2009-mods/backends/platform/psp/osys_psp.cpp
    scummvm/branches/gsoc2009-mods/backends/platform/psp/osys_psp.h
    scummvm/branches/gsoc2009-mods/backends/platform/psp/psp.mk
    scummvm/branches/gsoc2009-mods/backends/platform/psp/psp.spec
    scummvm/branches/gsoc2009-mods/backends/platform/psp/psp_main.cpp
    scummvm/branches/gsoc2009-mods/backends/platform/sdl/events.cpp
    scummvm/branches/gsoc2009-mods/backends/platform/sdl/graphics.cpp
    scummvm/branches/gsoc2009-mods/backends/platform/sdl/main.cpp
    scummvm/branches/gsoc2009-mods/backends/platform/sdl/sdl.cpp
    scummvm/branches/gsoc2009-mods/backends/platform/sdl/sdl.h
    scummvm/branches/gsoc2009-mods/backends/platform/wii/osystem.cpp
    scummvm/branches/gsoc2009-mods/backends/platform/wii/osystem.h
    scummvm/branches/gsoc2009-mods/backends/platform/wii/osystem_gfx.cpp
    scummvm/branches/gsoc2009-mods/backends/platform/wince/CEScaler.cpp
    scummvm/branches/gsoc2009-mods/backends/platform/wince/wince-sdl.cpp
    scummvm/branches/gsoc2009-mods/backends/platform/wince/wince-sdl.h
    scummvm/branches/gsoc2009-mods/backends/timer/default/default-timer.cpp
    scummvm/branches/gsoc2009-mods/base/main.cpp
    scummvm/branches/gsoc2009-mods/base/version.cpp
    scummvm/branches/gsoc2009-mods/common/EventRecorder.cpp
    scummvm/branches/gsoc2009-mods/common/error.h
    scummvm/branches/gsoc2009-mods/common/system.h
    scummvm/branches/gsoc2009-mods/configure
    scummvm/branches/gsoc2009-mods/dists/msvc8/ScummVM_Global.vsprops
    scummvm/branches/gsoc2009-mods/dists/msvc8/groovie.vcproj
    scummvm/branches/gsoc2009-mods/dists/msvc8/sci.vcproj
    scummvm/branches/gsoc2009-mods/dists/msvc8/scumm.vcproj
    scummvm/branches/gsoc2009-mods/dists/msvc8/scummvm.vcproj
    scummvm/branches/gsoc2009-mods/dists/msvc9/ScummVM_Global.vsprops
    scummvm/branches/gsoc2009-mods/dists/msvc9/sci.vcproj
    scummvm/branches/gsoc2009-mods/dists/msvc9/scumm.vcproj
    scummvm/branches/gsoc2009-mods/dists/msvc9/scummvm.vcproj
    scummvm/branches/gsoc2009-mods/engines/agi/agi.cpp
    scummvm/branches/gsoc2009-mods/engines/agi/cycle.cpp
    scummvm/branches/gsoc2009-mods/engines/agi/menu.cpp
    scummvm/branches/gsoc2009-mods/engines/agos/agos.cpp
    scummvm/branches/gsoc2009-mods/engines/agos/rooms.cpp
    scummvm/branches/gsoc2009-mods/engines/agos/saveload.cpp
    scummvm/branches/gsoc2009-mods/engines/cine/pal.h
    scummvm/branches/gsoc2009-mods/engines/cruise/cruise.cpp
    scummvm/branches/gsoc2009-mods/engines/cruise/cruise.h
    scummvm/branches/gsoc2009-mods/engines/cruise/cruise_main.cpp
    scummvm/branches/gsoc2009-mods/engines/cruise/detection.cpp
    scummvm/branches/gsoc2009-mods/engines/cruise/menu.cpp
    scummvm/branches/gsoc2009-mods/engines/drascula/drascula.cpp
    scummvm/branches/gsoc2009-mods/engines/engine.cpp
    scummvm/branches/gsoc2009-mods/engines/engine.h
    scummvm/branches/gsoc2009-mods/engines/gob/demos/demoplayer.cpp
    scummvm/branches/gsoc2009-mods/engines/gob/inter.h
    scummvm/branches/gsoc2009-mods/engines/gob/inter_playtoons.cpp
    scummvm/branches/gsoc2009-mods/engines/gob/save/savehandler.cpp
    scummvm/branches/gsoc2009-mods/engines/gob/save/savehandler.h
    scummvm/branches/gsoc2009-mods/engines/gob/save/saveload.h
    scummvm/branches/gsoc2009-mods/engines/gob/save/saveload_playtoons.cpp
    scummvm/branches/gsoc2009-mods/engines/gob/save/saveload_v2.cpp
    scummvm/branches/gsoc2009-mods/engines/gob/save/saveload_v3.cpp
    scummvm/branches/gsoc2009-mods/engines/gob/save/saveload_v4.cpp
    scummvm/branches/gsoc2009-mods/engines/gob/save/saveload_v6.cpp
    scummvm/branches/gsoc2009-mods/engines/gob/sound/cdrom.cpp
    scummvm/branches/gsoc2009-mods/engines/gob/video_v2.cpp
    scummvm/branches/gsoc2009-mods/engines/gob/video_v6.cpp
    scummvm/branches/gsoc2009-mods/engines/groovie/graphics.cpp
    scummvm/branches/gsoc2009-mods/engines/groovie/groovie.cpp
    scummvm/branches/gsoc2009-mods/engines/groovie/groovie.h
    scummvm/branches/gsoc2009-mods/engines/groovie/music.cpp
    scummvm/branches/gsoc2009-mods/engines/groovie/music.h
    scummvm/branches/gsoc2009-mods/engines/groovie/roq.cpp
    scummvm/branches/gsoc2009-mods/engines/groovie/script.cpp
    scummvm/branches/gsoc2009-mods/engines/groovie/script.h
    scummvm/branches/gsoc2009-mods/engines/groovie/vdx.cpp
    scummvm/branches/gsoc2009-mods/engines/kyra/animator_lok.cpp
    scummvm/branches/gsoc2009-mods/engines/kyra/animator_lok.h
    scummvm/branches/gsoc2009-mods/engines/kyra/gui.cpp
    scummvm/branches/gsoc2009-mods/engines/kyra/gui_lok.cpp
    scummvm/branches/gsoc2009-mods/engines/kyra/kyra_v1.cpp
    scummvm/branches/gsoc2009-mods/engines/kyra/lol.cpp
    scummvm/branches/gsoc2009-mods/engines/kyra/lol.h
    scummvm/branches/gsoc2009-mods/engines/kyra/screen.cpp
    scummvm/branches/gsoc2009-mods/engines/kyra/screen.h
    scummvm/branches/gsoc2009-mods/engines/kyra/script_hof.cpp
    scummvm/branches/gsoc2009-mods/engines/kyra/script_lok.cpp
    scummvm/branches/gsoc2009-mods/engines/kyra/script_mr.cpp
    scummvm/branches/gsoc2009-mods/engines/kyra/sequences_lok.cpp
    scummvm/branches/gsoc2009-mods/engines/kyra/sequences_lol.cpp
    scummvm/branches/gsoc2009-mods/engines/kyra/staticres.cpp
    scummvm/branches/gsoc2009-mods/engines/kyra/text_lok.cpp
    scummvm/branches/gsoc2009-mods/engines/lure/res.cpp
    scummvm/branches/gsoc2009-mods/engines/m4/script.h
    scummvm/branches/gsoc2009-mods/engines/made/made.cpp
    scummvm/branches/gsoc2009-mods/engines/made/pmvplayer.cpp
    scummvm/branches/gsoc2009-mods/engines/made/resource.cpp
    scummvm/branches/gsoc2009-mods/engines/made/screen.cpp
    scummvm/branches/gsoc2009-mods/engines/saga/actor.h
    scummvm/branches/gsoc2009-mods/engines/saga/music.cpp
    scummvm/branches/gsoc2009-mods/engines/sci/detection.cpp
    scummvm/branches/gsoc2009-mods/engines/sci/engine/game.cpp
    scummvm/branches/gsoc2009-mods/engines/sci/engine/kernel.cpp
    scummvm/branches/gsoc2009-mods/engines/sci/engine/kernel.h
    scummvm/branches/gsoc2009-mods/engines/sci/engine/klists.cpp
    scummvm/branches/gsoc2009-mods/engines/sci/engine/kmisc.cpp
    scummvm/branches/gsoc2009-mods/engines/sci/engine/kpathing.cpp
    scummvm/branches/gsoc2009-mods/engines/sci/engine/kscripts.cpp
    scummvm/branches/gsoc2009-mods/engines/sci/engine/ksound.cpp
    scummvm/branches/gsoc2009-mods/engines/sci/engine/savegame.cpp
    scummvm/branches/gsoc2009-mods/engines/sci/engine/seg_manager.cpp
    scummvm/branches/gsoc2009-mods/engines/sci/engine/seg_manager.h
    scummvm/branches/gsoc2009-mods/engines/sci/engine/state.cpp
    scummvm/branches/gsoc2009-mods/engines/sci/engine/state.h
    scummvm/branches/gsoc2009-mods/engines/sci/engine/static_selectors.cpp
    scummvm/branches/gsoc2009-mods/engines/sci/engine/vm.cpp
    scummvm/branches/gsoc2009-mods/engines/sci/exereader.cpp
    scummvm/branches/gsoc2009-mods/engines/sci/exereader.h
    scummvm/branches/gsoc2009-mods/engines/sci/gfx/gfx_driver.cpp
    scummvm/branches/gsoc2009-mods/engines/sci/gfx/gfx_driver.h
    scummvm/branches/gsoc2009-mods/engines/sci/gfx/gfx_pixmap_scale.cpp
    scummvm/branches/gsoc2009-mods/engines/sci/gfx/gfx_resmgr.cpp
    scummvm/branches/gsoc2009-mods/engines/sci/gfx/gfx_resource.h
    scummvm/branches/gsoc2009-mods/engines/sci/gfx/gfx_system.h
    scummvm/branches/gsoc2009-mods/engines/sci/gfx/gfx_tools.cpp
    scummvm/branches/gsoc2009-mods/engines/sci/gfx/operations.cpp
    scummvm/branches/gsoc2009-mods/engines/sci/gfx/operations.h
    scummvm/branches/gsoc2009-mods/engines/sci/gfx/res_pic.cpp
    scummvm/branches/gsoc2009-mods/engines/sci/gfx/res_view.cpp
    scummvm/branches/gsoc2009-mods/engines/sci/resource.cpp
    scummvm/branches/gsoc2009-mods/engines/sci/resource.h
    scummvm/branches/gsoc2009-mods/engines/sci/sci.cpp
    scummvm/branches/gsoc2009-mods/engines/sci/sfx/core.cpp
    scummvm/branches/gsoc2009-mods/engines/scumm/actor.cpp
    scummvm/branches/gsoc2009-mods/engines/scumm/actor.h
    scummvm/branches/gsoc2009-mods/engines/scumm/akos.cpp
    scummvm/branches/gsoc2009-mods/engines/scumm/akos.h
    scummvm/branches/gsoc2009-mods/engines/scumm/base-costume.cpp
    scummvm/branches/gsoc2009-mods/engines/scumm/base-costume.h
    scummvm/branches/gsoc2009-mods/engines/scumm/charset.cpp
    scummvm/branches/gsoc2009-mods/engines/scumm/costume.cpp
    scummvm/branches/gsoc2009-mods/engines/scumm/costume.h
    scummvm/branches/gsoc2009-mods/engines/scumm/cursor.cpp
    scummvm/branches/gsoc2009-mods/engines/scumm/detection_tables.h
    scummvm/branches/gsoc2009-mods/engines/scumm/dialogs.cpp
    scummvm/branches/gsoc2009-mods/engines/scumm/dialogs.h
    scummvm/branches/gsoc2009-mods/engines/scumm/gfx.cpp
    scummvm/branches/gsoc2009-mods/engines/scumm/gfx.h
    scummvm/branches/gsoc2009-mods/engines/scumm/gfxARM.s
    scummvm/branches/gsoc2009-mods/engines/scumm/he/animation_he.cpp
    scummvm/branches/gsoc2009-mods/engines/scumm/he/animation_he.h
    scummvm/branches/gsoc2009-mods/engines/scumm/he/intern_he.h
    scummvm/branches/gsoc2009-mods/engines/scumm/he/palette_he.cpp
    scummvm/branches/gsoc2009-mods/engines/scumm/he/script_v100he.cpp
    scummvm/branches/gsoc2009-mods/engines/scumm/he/script_v60he.cpp
    scummvm/branches/gsoc2009-mods/engines/scumm/he/script_v72he.cpp
    scummvm/branches/gsoc2009-mods/engines/scumm/he/script_v80he.cpp
    scummvm/branches/gsoc2009-mods/engines/scumm/he/script_v90he.cpp
    scummvm/branches/gsoc2009-mods/engines/scumm/he/sound_he.cpp
    scummvm/branches/gsoc2009-mods/engines/scumm/he/wiz_he.cpp
    scummvm/branches/gsoc2009-mods/engines/scumm/he/wiz_he.h
    scummvm/branches/gsoc2009-mods/engines/scumm/palette.cpp
    scummvm/branches/gsoc2009-mods/engines/scumm/resource.cpp
    scummvm/branches/gsoc2009-mods/engines/scumm/saveload.cpp
    scummvm/branches/gsoc2009-mods/engines/scumm/saveload.h
    scummvm/branches/gsoc2009-mods/engines/scumm/scumm.cpp
    scummvm/branches/gsoc2009-mods/engines/scumm/scumm.h
    scummvm/branches/gsoc2009-mods/engines/scumm/sound.cpp
    scummvm/branches/gsoc2009-mods/engines/scumm/vars.cpp
    scummvm/branches/gsoc2009-mods/engines/tinsel/pcode.cpp
    scummvm/branches/gsoc2009-mods/engines/tinsel/polygons.cpp
    scummvm/branches/gsoc2009-mods/engines/tinsel/tinsel.cpp
    scummvm/branches/gsoc2009-mods/graphics/cursorman.cpp
    scummvm/branches/gsoc2009-mods/graphics/cursorman.h
    scummvm/branches/gsoc2009-mods/graphics/module.mk
    scummvm/branches/gsoc2009-mods/graphics/pixelformat.h
    scummvm/branches/gsoc2009-mods/graphics/scaler.cpp
    scummvm/branches/gsoc2009-mods/graphics/sjis.cpp
    scummvm/branches/gsoc2009-mods/graphics/video/coktelvideo/coktelvideo.cpp
    scummvm/branches/gsoc2009-mods/gui/ListWidget.cpp
    scummvm/branches/gsoc2009-mods/gui/ListWidget.h
    scummvm/branches/gsoc2009-mods/gui/ThemeEngine.cpp
    scummvm/branches/gsoc2009-mods/gui/ThemeEngine.h
    scummvm/branches/gsoc2009-mods/gui/credits.h
    scummvm/branches/gsoc2009-mods/gui/saveload.cpp
    scummvm/branches/gsoc2009-mods/gui/themes/default.inc
    scummvm/branches/gsoc2009-mods/gui/themes/scummclassic/THEMERC
    scummvm/branches/gsoc2009-mods/gui/themes/scummclassic/classic_gfx.stx
    scummvm/branches/gsoc2009-mods/gui/themes/scummclassic/classic_layout.stx
    scummvm/branches/gsoc2009-mods/gui/themes/scummclassic/classic_layout_lowres.stx
    scummvm/branches/gsoc2009-mods/gui/themes/scummclassic.zip
    scummvm/branches/gsoc2009-mods/gui/themes/scummmodern/THEMERC
    scummvm/branches/gsoc2009-mods/gui/themes/scummmodern/scummmodern_gfx.stx
    scummvm/branches/gsoc2009-mods/gui/themes/scummmodern/scummmodern_layout.stx
    scummvm/branches/gsoc2009-mods/gui/themes/scummmodern/scummmodern_layout_lowres.stx
    scummvm/branches/gsoc2009-mods/gui/themes/scummmodern.zip
    scummvm/branches/gsoc2009-mods/ports.mk
    scummvm/branches/gsoc2009-mods/rules.mk
    scummvm/branches/gsoc2009-mods/sound/audiocd.h
    scummvm/branches/gsoc2009-mods/sound/audiostream.cpp
    scummvm/branches/gsoc2009-mods/sound/audiostream.h
    scummvm/branches/gsoc2009-mods/sound/mods/maxtrax.cpp
    scummvm/branches/gsoc2009-mods/sound/mods/tfmx.cpp
    scummvm/branches/gsoc2009-mods/sound/shorten.h
    scummvm/branches/gsoc2009-mods/sound/voc.cpp
    scummvm/branches/gsoc2009-mods/test/module.mk
    scummvm/branches/gsoc2009-mods/tools/credits.pl
    scummvm/branches/gsoc2009-mods/tools/module.mk
    scummvm/branches/gsoc2009-mods/tools/skycpt/Makefile

Added Paths:
-----------
    scummvm/branches/gsoc2009-mods/backends/platform/linuxmoto/
    scummvm/branches/gsoc2009-mods/dists/motoezx/

Removed Paths:
-------------
    scummvm/branches/gsoc2009-mods/backends/platform/psp/osys_psp_gu.cpp
    scummvm/branches/gsoc2009-mods/backends/platform/psp/osys_psp_gu.h

Property Changed:
----------------
    scummvm/branches/gsoc2009-mods/
    scummvm/branches/gsoc2009-mods/backends/platform/iphone/osys_main.cpp
    scummvm/branches/gsoc2009-mods/backends/platform/iphone/osys_main.h
    scummvm/branches/gsoc2009-mods/sound/iff_sound.cpp
    scummvm/branches/gsoc2009-mods/sound/iff_sound.h
    scummvm/branches/gsoc2009-mods/tools/


Property changes on: scummvm/branches/gsoc2009-mods
___________________________________________________________________
Modified: svn:mergeinfo
   - /scummvm/trunk:41377-43475
   + /scummvm/trunk:41377-43700

Modified: scummvm/branches/gsoc2009-mods/AUTHORS
===================================================================
--- scummvm/branches/gsoc2009-mods/AUTHORS	2009-08-24 16:07:46 UTC (rev 43700)
+++ scummvm/branches/gsoc2009-mods/AUTHORS	2009-08-24 17:51:47 UTC (rev 43701)
@@ -159,6 +159,9 @@
     iPhone:
        Oystein Eftevaag     
 
+    LinuxMoto:
+       Lubomyr Lisen        
+
     Maemo:
        Frantisek Dufka      
 
@@ -314,6 +317,7 @@
      Andreas Karlsson      - Initial port for SymbianOS
      Claudio Matsuoka      - Daily Linux builds
      Thomas Mayer          - PSP port contributions
+     Yotam Barnoy          - PSP port suspend/resume support
      Sean Murray           - ScummVM tools GUI application (GSoC 2007 task)
      n0p                   - Windows CE port aspect ratio correction scaler
                              and right click input method

Modified: scummvm/branches/gsoc2009-mods/COPYRIGHT
===================================================================
--- scummvm/branches/gsoc2009-mods/COPYRIGHT	2009-08-24 16:07:46 UTC (rev 43700)
+++ scummvm/branches/gsoc2009-mods/COPYRIGHT	2009-08-24 17:51:47 UTC (rev 43701)
@@ -205,3 +205,4 @@
 Xanathar "xanathar"
 Grant Yeager "glo_kidd"
 Benjamin W. Zale "junior_aepi"
+Yotam Barnoy "bluddy"

Modified: scummvm/branches/gsoc2009-mods/Makefile
===================================================================
--- scummvm/branches/gsoc2009-mods/Makefile	2009-08-24 16:07:46 UTC (rev 43700)
+++ scummvm/branches/gsoc2009-mods/Makefile	2009-08-24 17:51:47 UTC (rev 43701)
@@ -68,7 +68,7 @@
 ifeq "$(findstring config.mk,$(MAKEFILE_LIST))" "config.mk"
 	@echo "Running $(srcdir)/configure with the last specified parameters"
 	@sleep 2
-	LDFLAGS="$(SAVED_LDFLAGS)" CXX="$(SAVED_CXX)" CXXFLAGS="$(SAVED_CXXFLAGS)" CPPFLAGS="$(SAVED_CPPFLAGS)" \
+	LDFLAGS="$(SAVED_LDFLAGS)" CXX="$(SAVED_CXX)" CXXFLAGS="$(SAVED_CXXFLAGS)" CPPFLAGS="$(SAVED_CPPFLAGS)" ASFLAGS="$(SAVED_ASFLAGS)" \
 		$(srcdir)/configure $(SAVED_CONFIGFLAGS)
 else
 	$(error You need to run $(srcdir)/configure before you can run make. Check $(srcdir)/configure --help for a list of parameters)

Modified: scummvm/branches/gsoc2009-mods/Makefile.common
===================================================================
--- scummvm/branches/gsoc2009-mods/Makefile.common	2009-08-24 16:07:46 UTC (rev 43700)
+++ scummvm/branches/gsoc2009-mods/Makefile.common	2009-08-24 17:51:47 UTC (rev 43701)
@@ -62,9 +62,25 @@
 # the build date in gScummVMBuildDate is correct.
 base/version.o: $(filter-out base/libbase.a,$(OBJS))
 
+# Replace regular output with quiet messages
+ifneq ($(findstring $(MAKEFLAGS),s),s)
+ifneq ($(VERBOSE_BUILD),1)
+ifneq ($(VERBOSE_BUILD),yes)
+QUIET_CXX    = @echo '   ' C++ '    ' $@;
+QUIET_AS     = @echo '   ' AS '     ' $@;
+QUIET_NASM   = @echo '   ' NASM '   ' $@;
+QUIET_AR     = @echo '   ' AR '     ' $@;
+QUIET_RANLIB = @echo '   ' RANLIB ' ' $@;
+QUIET_PLUGIN = @echo '   ' PLUGIN ' ' $@;
+QUIET_LINK   = @echo '   ' LINK '   ' $@;
+QUIET        = @
+endif
+endif
+endif
+
 # The build rule for the ScummVM executable
 $(EXECUTABLE): $(OBJS)
-	$(CXX) $(LDFLAGS) $(PRE_OBJS_FLAGS) $+ $(POST_OBJS_FLAGS) $(LIBS) -o $@
+	$(QUIET_LINK)$(CXX) $(LDFLAGS) $(PRE_OBJS_FLAGS) $+ $(POST_OBJS_FLAGS) $(LIBS) -o $@
 
 distclean: clean
 	$(RM) config.h config.mk config.log
@@ -83,27 +99,30 @@
 # If you use GCC, disable the above and enable this for intelligent
 # dependency tracking.
 %.o: %.cpp
-	$(MKDIR) $(*D)/$(DEPDIR)
-	$(CXX) -Wp,-MMD,"$(*D)/$(DEPDIR)/$(*F).d2" $(CXXFLAGS) $(CPPFLAGS) -c $(<) -o $*.o
-	$(ECHO) "$(*D)/" > $(*D)/$(DEPDIR)/$(*F).d
-	$(CAT) "$(*D)/$(DEPDIR)/$(*F).d2" >> "$(*D)/$(DEPDIR)/$(*F).d"
-	$(RM) "$(*D)/$(DEPDIR)/$(*F).d2"
+	$(QUIET)$(MKDIR) $(*D)/$(DEPDIR)
+	$(QUIET_CXX)$(CXX) -Wp,-MMD,"$(*D)/$(DEPDIR)/$(*F).d2" $(CXXFLAGS) $(CPPFLAGS) -c $(<) -o $*.o
+	$(QUIET)$(ECHO) "$(*D)/" > $(*D)/$(DEPDIR)/$(*F).d
+	$(QUIET)$(CAT) "$(*D)/$(DEPDIR)/$(*F).d2" >> "$(*D)/$(DEPDIR)/$(*F).d"
+	$(QUIET)$(RM) "$(*D)/$(DEPDIR)/$(*F).d2"
 else
 # If you even have GCC 3.x, you can use this build rule, which is safer; the above
 # rule can get you into a bad state if you Ctrl-C at the wrong moment.
 # Also, with this GCC inserts additional dummy rules for the involved headers,
 # which ensures a smooth compilation even if said headers become obsolete.
 %.o: %.cpp
-	$(MKDIR) $(*D)/$(DEPDIR)
-	$(CXX) -Wp,-MMD,"$(*D)/$(DEPDIR)/$(*F).d",-MQ,"$@",-MP $(CXXFLAGS) $(CPPFLAGS) -c $(<) -o $*.o
+	$(QUIET)$(MKDIR) $(*D)/$(DEPDIR)
+	$(QUIET_CXX)$(CXX) -Wp,-MMD,"$(*D)/$(DEPDIR)/$(*F).d",-MQ,"$@",-MP $(CXXFLAGS) $(CPPFLAGS) -c $(<) -o $*.o
 %.o: %.m
-	$(MKDIR) $(*D)/$(DEPDIR)
-	$(CXX) -Wp,-MMD,"$(*D)/$(DEPDIR)/$(*F).d",-MQ,"$@",-MP $(OBJCFLAGS) -c $(<) -o $*.o
+	$(QUIET)$(MKDIR) $(*D)/$(DEPDIR)
+	$(QUIET_CXX)$(CXX) -Wp,-MMD,"$(*D)/$(DEPDIR)/$(*F).d",-MQ,"$@",-MP $(OBJCFLAGS) -c $(<) -o $*.o
 endif
 
+%.o: %.s
+	$(QUIET_AS)$(AS) $(ASFLAGS) $(<) -o $*.o
+
 ifdef HAVE_NASM
 %.o: %.asm
-	$(NASM) -O1 $(NASMFLAGS) -g -o $*.o $(<)
+	$(QUIET_NASM)$(NASM) -O1 $(NASMFLAGS) -g -o $*.o $(<)
 endif
 
 # Include the dependency tracking files.

Modified: scummvm/branches/gsoc2009-mods/NEWS
===================================================================
--- scummvm/branches/gsoc2009-mods/NEWS	2009-08-24 16:07:46 UTC (rev 43700)
+++ scummvm/branches/gsoc2009-mods/NEWS	2009-08-24 17:51:47 UTC (rev 43701)
@@ -2,6 +2,12 @@
         http://scummvm.svn.sourceforge.net/viewvc/scummvm/?view=log
 
 1.1.0 (????-??-??)
+ New Games:
+   - Added support for Blue's Art Time Activities.
+   - Added support for Blue's Reading Time Activities.
+   - Added support for Freddi Fish 5: The Case of the Creature of Coral Cave.
+   - Added support for Pajama Sam: Games to Play on Any Day.
+
  General:
    - Added support for a custom SJIS font for FM-TOWNS and PC98 games.
 
@@ -9,7 +15,7 @@
    - Added support for the Amiga version of The Legend of Kyrandia.
    - Adapted KYRA to support the custom SJIS font.
 
-1.0.0 (2009-??-??)
+1.0.0rc1 (2009-08-31)
  New Games:
    - Added support for Discworld.
    - Added support for Discworld 2 - Missing Presumed ...!?.
@@ -59,6 +65,9 @@
    - Added support for PC Speaker based music and sound effects.
    - Added support for 16 color dithering in Kyrandia PC-9801.
 
+ PSP port:
+   - Added support for sleep mode (suspend/resume).
+
  WinCE port:
     - Speed optimized versions of low-res Smartphone and 2x scalers.
     - New aspect correction scaler for VGA (or higher) devices.

Modified: scummvm/branches/gsoc2009-mods/README
===================================================================
--- scummvm/branches/gsoc2009-mods/README	2009-08-24 16:07:46 UTC (rev 43700)
+++ scummvm/branches/gsoc2009-mods/README	2009-08-24 17:51:47 UTC (rev 43701)
@@ -260,6 +260,8 @@
      Big Thinkers Kindergarten                   [thinkerk]
      Blue's 123 Time Activities                  [Blues123Time]
      Blue's ABC Time Activities                  [BluesABCTime]
+     Blue's Art Time Activities                  [arttime]
+     Blue's Reading Time Activities              [readtime]
      Fatty Bear's Birthday Surprise              [fbear]
      Fatty Bear's Fun Pack                       [fbpack]
      Freddi Fish 1: The Case of the Missing
@@ -270,6 +272,8 @@
          Conch Shell                             [freddi3]
      Freddi Fish 4: The Case of the Hogfish
          Rustlers of Briny Gulch                 [freddi4]
+     Freddi Fish 5: The Case of the Creature
+          of Coral Cave                          [freddicove]
      Freddi Fish and Luther's Maze Madness       [maze]
      Freddi Fish and Luther's Water Worries      [water]
      Let's Explore the Airport with Buzzy        [airport]
@@ -295,6 +299,7 @@
      Putt-Putt's Fun Pack                        [funpack]
      SPY Fox 1: Dry Cereal                       [spyfox]
      SPY Fox 2: Some Assembly Required           [spyfox2]
+     SPY Fox 3: Operation Ozone                  [spyozon]
      SPY Fox in Cheese Chase                     [chase]
      SPY Fox in Hold the Mustard                 [mustard]
 
@@ -304,10 +309,15 @@
 and view the compatibility chart.
 
      Backyard Baseball                           [baseball]
+     Backyard Baseball 2001                      [baseball2001]
+     Backyard Baseball 2003                      [baseball2003]
+     Backyard Football 2002                      [football2002]
      Backyard Soccer                             [soccer]
+     Backyard Soccer MLS                         [soccermls]
+     Backyard Soccer 2004                        [soccer2004]
      Blue's Birthday Adventure                   [BluesBirthday]
      Blue's Treasure Hunt                        [BluesTreasureHunt]
-     SPY Fox 3: Operation Ozone                  [spyozon]
+     Pajama Sam: Games to Play on Any Day        [pjgames]
 
 The following games are based on the SCUMM engine, but NOT supported
 by ScummVM (yet):

Modified: scummvm/branches/gsoc2009-mods/backends/fs/psp/psp-fs-factory.cpp
===================================================================
--- scummvm/branches/gsoc2009-mods/backends/fs/psp/psp-fs-factory.cpp	2009-08-24 16:07:46 UTC (rev 43700)
+++ scummvm/branches/gsoc2009-mods/backends/fs/psp/psp-fs-factory.cpp	2009-08-24 17:51:47 UTC (rev 43701)
@@ -34,7 +34,13 @@
 
 AbstractFSNode *PSPFilesystemFactory::makeCurrentDirectoryFileNode() const {
 	char buf[MAXPATHLEN];
-	return getcwd(buf, MAXPATHLEN) ? new PSPFilesystemNode(buf) : NULL;
+	char * ret = 0;
+
+	PowerMan.beginCriticalSection();
+	ret = getcwd(buf, MAXPATHLEN);
+	PowerMan.endCriticalSection();
+
+	return (ret ? new PSPFilesystemNode(buf) : NULL);
 }
 
 AbstractFSNode *PSPFilesystemFactory::makeFileNodePath(const Common::String &path) const {

Modified: scummvm/branches/gsoc2009-mods/backends/fs/psp/psp-fs.cpp
===================================================================
--- scummvm/branches/gsoc2009-mods/backends/fs/psp/psp-fs.cpp	2009-08-24 16:07:46 UTC (rev 43700)
+++ scummvm/branches/gsoc2009-mods/backends/fs/psp/psp-fs.cpp	2009-08-24 17:51:47 UTC (rev 43701)
@@ -26,7 +26,8 @@
 
 #include "engines/engine.h"
 #include "backends/fs/abstract-fs.h"
-#include "backends/fs/stdiostream.h"
+#include "backends/fs/psp/psp-stream.h"
+#include "backends/platform/psp/powerman.h"
 
 #include <sys/stat.h>
 #include <unistd.h>
@@ -35,6 +36,9 @@
 
 #define	ROOT_PATH	"ms0:/"
 
+#include "backends/platform/psp/trace.h"
+
+
 /**
  * Implementation of the ScummVM file system API based on PSPSDK API.
  *
@@ -61,13 +65,13 @@
 	 */
 	PSPFilesystemNode(const Common::String &p, bool verify = true);
 
-	virtual bool exists() const { return access(_path.c_str(), F_OK) == 0; }
+	virtual bool exists() const;
 	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 bool isReadable() const;
+	virtual bool isWritable() const;
 
 	virtual AbstractFSNode *getChild(const Common::String &n) const;
 	virtual bool getChildren(AbstractFSList &list, ListMode mode, bool hidden) const;
@@ -94,11 +98,44 @@
 
 	if (verify) {
 		struct stat st;
+		PowerMan.beginCriticalSection();
 		_isValid = (0 == stat(_path.c_str(), &st));
+		PowerMan.endCriticalSection();
 		_isDirectory = S_ISDIR(st.st_mode);
 	}
 }
 
+bool PSPFilesystemNode::exists() const {
+	int ret = 0;
+
+	PowerMan.beginCriticalSection();	// Make sure to block in case of suspend
+	ret = access(_path.c_str(), F_OK);
+	PowerMan.endCriticalSection();
+	
+	return ret == 0;
+}
+
+bool PSPFilesystemNode::isReadable() const {
+	int ret = 0;
+
+	PowerMan.beginCriticalSection();	// Make sure to block in case of suspend
+	ret = access(_path.c_str(), R_OK);
+	PowerMan.endCriticalSection();
+	
+	return ret == 0;
+}
+
+bool PSPFilesystemNode::isWritable() const {
+	int ret = 0;
+
+	PowerMan.beginCriticalSection();	// Make sure to block in case of suspend
+	ret = access(_path.c_str(), W_OK);
+	PowerMan.endCriticalSection();
+	
+	return ret == 0;
+}
+
+
 AbstractFSNode *PSPFilesystemNode::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.
@@ -117,6 +154,10 @@
 
 	//TODO: honor the hidden flag
 
+	bool ret = true;
+
+	PowerMan.beginCriticalSection();	// Make sure to block in case of suspend
+	
 	int dfd  = sceIoDopen(_path.c_str());
 	if (dfd > 0) {
 		SceIoDirent dir;
@@ -149,10 +190,13 @@
 		}
 
 		sceIoDclose(dfd);
-		return true;
-	} else {
-		return false;
+		ret = true;
+	} else { // dfd <= 0
+		ret = false;
 	}
+
+	PowerMan.endCriticalSection();
+	return ret;
 }
 
 AbstractFSNode *PSPFilesystemNode::getParent() const {
@@ -166,11 +210,11 @@
 }
 
 Common::SeekableReadStream *PSPFilesystemNode::createReadStream() {
-	return StdioStream::makeFromPath(getPath().c_str(), false);
+	return PSPIoStream::makeFromPath(getPath(), false);
 }
 
 Common::WriteStream *PSPFilesystemNode::createWriteStream() {
-	return StdioStream::makeFromPath(getPath().c_str(), true);
+	return PSPIoStream::makeFromPath(getPath(), true);
 }
 
 #endif //#ifdef __PSP__

Modified: scummvm/branches/gsoc2009-mods/backends/module.mk
===================================================================
--- scummvm/branches/gsoc2009-mods/backends/module.mk	2009-08-24 16:07:46 UTC (rev 43700)
+++ scummvm/branches/gsoc2009-mods/backends/module.mk	2009-08-24 17:51:47 UTC (rev 43701)
@@ -11,6 +11,7 @@
 	fs/posix/posix-fs-factory.o \
 	fs/ps2/ps2-fs-factory.o \
 	fs/psp/psp-fs-factory.o \
+	fs/psp/psp-stream.o \
 	fs/symbian/symbian-fs-factory.o \
 	fs/windows/windows-fs-factory.o \
 	fs/wii/wii-fs-factory.o \

Modified: scummvm/branches/gsoc2009-mods/backends/platform/dc/dc.h
===================================================================
--- scummvm/branches/gsoc2009-mods/backends/platform/dc/dc.h	2009-08-24 16:07:46 UTC (rev 43700)
+++ scummvm/branches/gsoc2009-mods/backends/platform/dc/dc.h	2009-08-24 17:51:47 UTC (rev 43701)
@@ -84,7 +84,7 @@
 
   // Set the size of the video bitmap.
   // Typically, 320x200
-  void initSize(uint w, uint h);
+  void initSize(uint w, uint h, const Graphics::PixelFormat *format);
   int16 getHeight() { return _screen_h; }
   int16 getWidth() { return _screen_w; }
 
@@ -105,7 +105,7 @@
   void warpMouse(int x, int y);
 
   // Set the bitmap that's used when drawing the cursor.
-  void setMouseCursor(const byte *buf, uint w, uint h, int hotspot_x, int hotspot_y, byte keycolor, int cursorTargetScale);
+  void setMouseCursor(const byte *buf, uint w, uint h, int hotspot_x, int hotspot_y, uint32 keycolor, int cursorTargetScale, const Graphics::PixelFormat *format);
 
   // Replace the specified range of cursor the palette with new colors.
   void setCursorPalette(const byte *colors, uint start, uint num);

Modified: scummvm/branches/gsoc2009-mods/backends/platform/dc/display.cpp
===================================================================
--- scummvm/branches/gsoc2009-mods/backends/platform/dc/display.cpp	2009-08-24 16:07:46 UTC (rev 43700)
+++ scummvm/branches/gsoc2009-mods/backends/platform/dc/display.cpp	2009-08-24 17:51:47 UTC (rev 43701)
@@ -193,7 +193,7 @@
   }
 }
 
-void OSystem_Dreamcast::initSize(uint w, uint h)
+void OSystem_Dreamcast::initSize(uint w, uint h, const Graphics::PixelFormat *format)
 {
   assert(w <= SCREEN_W && h <= SCREEN_H);
 
@@ -263,7 +263,7 @@
 
 void OSystem_Dreamcast::setMouseCursor(const byte *buf, uint w, uint h,
 				       int hotspot_x, int hotspot_y,
-				       byte keycolor, int cursorTargetScale)
+				       uint32 keycolor, int cursorTargetScale, const Graphics::PixelFormat *format)
 {
   _ms_cur_w = w;
   _ms_cur_h = h;
@@ -271,7 +271,7 @@
   _ms_hotspot_x = hotspot_x;
   _ms_hotspot_y = hotspot_y;
 
-  _ms_keycolor = keycolor;
+  _ms_keycolor = (byte)keycolor;
 
   if (_ms_buf)
     free(_ms_buf);

Modified: scummvm/branches/gsoc2009-mods/backends/platform/gp2x/gp2x-common.h
===================================================================
--- scummvm/branches/gsoc2009-mods/backends/platform/gp2x/gp2x-common.h	2009-08-24 16:07:46 UTC (rev 43700)
+++ scummvm/branches/gsoc2009-mods/backends/platform/gp2x/gp2x-common.h	2009-08-24 17:51:47 UTC (rev 43701)
@@ -58,7 +58,7 @@
 
 	// Set the size of the video bitmap.
 	// Typically, 320x200
-	void initSize(uint w, uint h);
+	void initSize(uint w, uint h, const Graphics::PixelFormat *format);
 
 	int getScreenChangeID() const { return _screenChangeCount; }
 
@@ -87,7 +87,7 @@
 	void warpMouse(int x, int y);
 
 	// Set the bitmap that's used when drawing the cursor.
-	void setMouseCursor(const byte *buf, uint w, uint h, int hotspot_x, int hotspot_y, byte keycolor, int cursorTargetScale);
+	void setMouseCursor(const byte *buf, uint w, uint h, int hotspot_x, int hotspot_y, uint32 keycolor, int cursorTargetScale, const Graphics::PixelFormat *format);
 
 	// Set colors of cursor palette
 	void setCursorPalette(const byte *colors, uint start, uint num);

Modified: scummvm/branches/gsoc2009-mods/backends/platform/gp2x/graphics.cpp
===================================================================
--- scummvm/branches/gsoc2009-mods/backends/platform/gp2x/graphics.cpp	2009-08-24 16:07:46 UTC (rev 43700)
+++ scummvm/branches/gsoc2009-mods/backends/platform/gp2x/graphics.cpp	2009-08-24 17:51:47 UTC (rev 43701)
@@ -240,9 +240,27 @@
 	return _videoMode.mode;
 }
 
-void OSystem_GP2X::initSize(uint w, uint h){
+void OSystem_GP2X::initSize(uint w, uint h, const Graphics::PixelFormat *format) {
 	assert(_transactionMode == kTransactionActive);
 
+#ifdef USE_RGB_COLOR
+	//avoid redundant format changes
+	Graphics::PixelFormat newFormat;
+	if (!format)
+		newFormat = Graphics::PixelFormat::createFormatCLUT8();
+	else
+		newFormat = *format;
+
+	assert(newFormat.bytesPerPixel > 0);
+
+	if (newFormat != _videoMode.format)
+	{
+		_videoMode.format = newFormat;
+		_transactionDetails.formatChanged = true;
+		_screenFormat = newFormat;
+	}
+#endif
+
 	// Avoid redundant res changes
 	if ((int)w == _videoMode.screenWidth && (int)h == _videoMode.screenHeight)
 		return;
@@ -1212,7 +1230,17 @@
 	}
 }
 
-void OSystem_GP2X::setMouseCursor(const byte *buf, uint w, uint h, int hotspot_x, int hotspot_y, byte keycolor, int cursorTargetScale) {
+void OSystem_GP2X::setMouseCursor(const byte *buf, uint w, uint h, int hotspot_x, int hotspot_y, uint32 keycolor, int cursorTargetScale, const Graphics::PixelFormat *format) {
+#ifdef USE_RGB_COLOR
+	if (!format)
+		_cursorFormat = Graphics::PixelFormat::createFormatCLUT8();
+	else if (format->bytesPerPixel <= _screenFormat.bytesPerPixel)
+		_cursorFormat = *format;
+	keycolor &= (1 << (_cursorFormat.bytesPerPixel << 3)) - 1;
+#else
+	keycolor &= 0xFF;
+#endif
+
 	if (w == 0 || h == 0)
 		return;
 
@@ -1246,16 +1274,26 @@
 	}
 
 	free(_mouseData);
-
+#ifdef USE_RGB_COLOR
+	_mouseData = (byte *)malloc(w * h * _cursorFormat.bytesPerPixel);
+	memcpy(_mouseData, buf, w * h * _cursorFormat.bytesPerPixel);
+#else
 	_mouseData = (byte *)malloc(w * h);
 	memcpy(_mouseData, buf, w * h);
+#endif
+
 	blitCursor();
 }
 
 void OSystem_GP2X::blitCursor() {
 	byte *dstPtr;
 	const byte *srcPtr = _mouseData;
+#ifdef USE_RGB_COLOR
+	uint32 color;
+	uint32 colormask = (1 << (_cursorFormat.bytesPerPixel << 3)) - 1;
+#else
 	byte color;
+#endif
 	int w, h, i, j;
 
 	if (!_mouseOrigSurface || !_mouseData)
@@ -1289,13 +1327,29 @@
 
 	for (i = 0; i < h; i++) {
 		for (j = 0; j < w; j++) {
-			color = *srcPtr;
-			if (color != _mouseKeyColor) {	// transparent, don't draw
-				*(uint16 *)dstPtr = SDL_MapRGB(_mouseOrigSurface->format,
-					palette[color].r, palette[color].g, palette[color].b);
+#ifdef USE_RGB_COLOR
+			if (_cursorFormat.bytesPerPixel > 1) {
+				color = (*(uint32 *) srcPtr) & colormask;
+				if (color != _mouseKeyColor) {	// transparent, don't draw
+					uint8 r,g,b;
+					_cursorFormat.colorToRGB(color,r,g,b);
+					*(uint16 *)dstPtr = SDL_MapRGB(_mouseOrigSurface->format,
+						r, g, b);
+				}
+				dstPtr += 2;
+				srcPtr += _cursorFormat.bytesPerPixel;
+			} else {
+#endif
+				color = *srcPtr;
+				if (color != _mouseKeyColor) {	// transparent, don't draw
+					*(uint16 *)dstPtr = SDL_MapRGB(_mouseOrigSurface->format,
+						palette[color].r, palette[color].g, palette[color].b);
+				}
+				dstPtr += 2;
+				srcPtr++;
+#ifdef USE_RGB_COLOR
 			}
-			dstPtr += 2;
-			srcPtr++;
+#endif
 		}
 		dstPtr += _mouseOrigSurface->pitch - w * 2;
 	}


Property changes on: scummvm/branches/gsoc2009-mods/backends/platform/iphone/osys_main.cpp
___________________________________________________________________
Modified: svn:mergeinfo
   - /scummvm/trunk/backends/platform/iphone/osys_main.cpp:42569-43475
   + /scummvm/trunk/backends/platform/iphone/osys_main.cpp:42569-43700

Modified: scummvm/branches/gsoc2009-mods/backends/platform/iphone/osys_main.h
===================================================================
--- scummvm/branches/gsoc2009-mods/backends/platform/iphone/osys_main.h	2009-08-24 16:07:46 UTC (rev 43700)
+++ scummvm/branches/gsoc2009-mods/backends/platform/iphone/osys_main.h	2009-08-24 17:51:47 UTC (rev 43701)
@@ -126,7 +126,7 @@
 	bool setGraphicsMode(const char *name);
 	virtual bool setGraphicsMode(int mode);
 	virtual int getGraphicsMode() const;
-	virtual void initSize(uint width, uint height);
+	virtual void initSize(uint width, uint height, const Graphics::PixelFormat *format);
 	virtual int16 getHeight();
 	virtual int16 getWidth();
 	virtual void setPalette(const byte *colors, uint start, uint num);
@@ -149,7 +149,7 @@
 	virtual bool showMouse(bool visible);
 
 	virtual void warpMouse(int x, int y);
-	virtual void setMouseCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, byte keycolor = 255, int cursorTargetScale = 1);
+	virtual void setMouseCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor = 255, int cursorTargetScale = 1, const Graphics::PixelFormat *format = NULL);
 
 	virtual bool pollEvent(Common::Event &event);
 	virtual uint32 getMillis();


Property changes on: scummvm/branches/gsoc2009-mods/backends/platform/iphone/osys_main.h
___________________________________________________________________
Modified: svn:mergeinfo
   - /scummvm/trunk/backends/platform/iphone/osys_main.h:42569-43475
   + /scummvm/trunk/backends/platform/iphone/osys_main.h:42569-43700

Modified: scummvm/branches/gsoc2009-mods/backends/platform/iphone/osys_video.cpp
===================================================================
--- scummvm/branches/gsoc2009-mods/backends/platform/iphone/osys_video.cpp	2009-08-24 16:07:46 UTC (rev 43700)
+++ scummvm/branches/gsoc2009-mods/backends/platform/iphone/osys_video.cpp	2009-08-24 17:51:47 UTC (rev 43701)
@@ -46,7 +46,7 @@
 	return -1;
 }
 
-void OSystem_IPHONE::initSize(uint width, uint height) {
+void OSystem_IPHONE::initSize(uint width, uint height, const Graphics::PixelFormat *format) {
 	//printf("initSize(%i, %i)\n", width, height);
 
 	_screenWidth = width;
@@ -438,7 +438,7 @@
 	}
 }
 
-void OSystem_IPHONE::setMouseCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, byte keycolor, int cursorTargetScale) {
+void OSystem_IPHONE::setMouseCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor, int cursorTargetScale, const Graphics::PixelFormat *format) {
 	//printf("setMouseCursor(%i, %i)\n", hotspotX, hotspotY);
 
 	if (_mouseBuf != NULL && (_mouseWidth != w || _mouseHeight != h)) {
@@ -455,7 +455,7 @@
 	_mouseHotspotX = hotspotX;
 	_mouseHotspotY = hotspotY;
 
-	_mouseKeyColour = keycolor;
+	_mouseKeyColour = (byte)keycolor;
 
 	memcpy(_mouseBuf, buf, w * h);
 

Modified: scummvm/branches/gsoc2009-mods/backends/platform/psp/Makefile
===================================================================
--- scummvm/branches/gsoc2009-mods/backends/platform/psp/Makefile	2009-08-24 16:07:46 UTC (rev 43700)
+++ scummvm/branches/gsoc2009-mods/backends/platform/psp/Makefile	2009-08-24 17:51:47 UTC (rev 43701)
@@ -49,7 +49,7 @@
 MKDIR	= mkdir -p
 RM	= rm -f
 RM_REC	= rm -rf
-MKSFO	= mksfo
+MKSFO	= mksfoex -d MEMSIZE=1
 PACK_PBP = pack-pbp
 FIXUP	= psp-fixup-imports
 
@@ -62,7 +62,7 @@
 INCDIR   := $(srcdir) . $(srcdir)/engines/ . $(PSPSDK)/include
 LIBDIR   := $(LIBDIR) . $(PSPSDK)/lib
 
-CXXFLAGS = -O2 -Wall -D__PSP__ -DNONSTANDARD_PORT -DDISABLE_TEXT_CONSOLE -DDISABLE_COMMAND_LINE -DUSE_ZLIB -Wno-multichar `$(PSPBIN)/sdl-config --cflags`
+CXXFLAGS = -O3 -Wall -D__PSP__ -DNONSTANDARD_PORT -DDISABLE_TEXT_CONSOLE -DDISABLE_COMMAND_LINE -DUSE_ZLIB -DDISABLE_DOSBOX_OPL -Wno-multichar `$(PSPBIN)/sdl-config --cflags`
 CXXFLAGS:= $(addprefix -I,$(INCDIR)) $(CXXFLAGS)
 LDFLAGS := $(addprefix -L,$(LIBDIR)) $(LDFLAGS)
 LIBS     =
@@ -75,14 +75,14 @@
 CXXFLAGS+= -DUSE_VORBIS -DUSE_TREMOR
 LIBS	+= -lvorbisidec
 
-LIBS    += `$(PSPBIN)/sdl-config --libs` -lz -lstdc++ -lc -lpspdisplay -lpspgu -lpspctrl -lpspsdk -lpspnet -lpspnet_inet -lpsputility -lpspsdk -lpspuser
+LIBS    += `$(PSPBIN)/sdl-config --libs` -lz -lstdc++ -lc -lpspdisplay -lpspgu -lpspctrl -lpspsdk -lpspnet -lpspnet_inet -lpsputility -lpspuser -lpsppower
 
 CXXFLAGS := $(CXXFLAGS) -fno-exceptions -fno-rtti
 
 TARGET = scummvm-psp
-OBJS := psp_main.o \
+OBJS := powerman.o \
+	psp_main.o \
 	osys_psp.o \
-	osys_psp_gu.o \
 	kbd_ss_c.o \
 	kbd_s_c.o \
 	kbd_ls_c.o \

Modified: scummvm/branches/gsoc2009-mods/backends/platform/psp/README.PSP.in
===================================================================
--- scummvm/branches/gsoc2009-mods/backends/platform/psp/README.PSP.in	2009-08-24 16:07:46 UTC (rev 43700)
+++ scummvm/branches/gsoc2009-mods/backends/platform/psp/README.PSP.in	2009-08-24 17:51:47 UTC (rev 43701)
@@ -13,15 +13,17 @@
 ========
 
 Left trigger		- ESC
-Right trigger		- Enter
+Right trigger		- Modifier key (see below for uses)
 Analog			- Mouse movement
+Right trigger + Analog	- Fine control mouse
 Directionals		- Mouse movement
-Analog + triangle	- Fine control mouse
+Triangle		- Enter
 Cross			- Mouse button 1
 Circle			- Mouse button 2
 Square			- '.' (skip dialogue in some games)
 Select			- Show/Hide Virtual Keyboard
 Start			- F5
+Right trigger + Start	- Return-To-Launcher menu
 
 Notes
 =====
@@ -32,9 +34,6 @@
   As such, it is recommended to play games in their original, uncompressed,
   form whenever possible.
 
-- Sleep/Suspend mode currently isn't supported, so don't use it when
-  running ScummVM.
-
 - This README may be outdated, for more up-to-date instructions and notes see
   the PSP Port Wiki: http://wiki.scummvm.org/index.php/PlayStation_Portable
 

Modified: scummvm/branches/gsoc2009-mods/backends/platform/psp/module.mk
===================================================================
--- scummvm/branches/gsoc2009-mods/backends/platform/psp/module.mk	2009-08-24 16:07:46 UTC (rev 43700)
+++ scummvm/branches/gsoc2009-mods/backends/platform/psp/module.mk	2009-08-24 17:51:47 UTC (rev 43701)
@@ -1,9 +1,9 @@
 MODULE := backends/platform/psp
 
 MODULE_OBJS := \
+	powerman.o \
 	psp_main.o \
 	osys_psp.o \
-	osys_psp_gu.o \
 	kbd_ss_c.o \
 	kbd_s_c.o \
 	kbd_ls_c.o \

Modified: scummvm/branches/gsoc2009-mods/backends/platform/psp/osys_psp.cpp
===================================================================
--- scummvm/branches/gsoc2009-mods/backends/platform/psp/osys_psp.cpp	2009-08-24 16:07:46 UTC (rev 43700)
+++ scummvm/branches/gsoc2009-mods/backends/platform/psp/osys_psp.cpp	2009-08-24 17:51:47 UTC (rev 43701)
@@ -23,43 +23,76 @@
  *
  */
 
+#include <pspgu.h>
+#include <pspdisplay.h>
+
+#include <time.h>
+#include <zlib.h>
+
 #include "common/config-manager.h"
 #include "common/events.h"
-#include "common/rect.h"
 #include "common/scummsys.h"
 
 #include "osys_psp.h"
+#include "trace.h"
 
 #include "backends/saves/psp/psp-saves.h"
 #include "backends/timer/default/default-timer.h"
 #include "graphics/surface.h"
-#include "graphics/scaler.h"
 #include "sound/mixer_intern.h"
 
-#include <pspgu.h>
-#include <pspdisplay.h>
 
-#include <time.h>
+#define	SAMPLES_PER_SEC	44100
 
-#include "./trace.h"
 
-#define	SAMPLES_PER_SEC	44100
+#define PIXEL_SIZE (4)
+#define BUF_WIDTH (512)
+#define	PSP_SCREEN_WIDTH	480
+#define	PSP_SCREEN_HEIGHT	272
+#define PSP_FRAME_SIZE (BUF_WIDTH * PSP_SCREEN_HEIGHT * PIXEL_SIZE)
+#define MOUSE_SIZE	128
+#define	KBD_DATA_SIZE	130560
 
-#define	SCREEN_WIDTH	480
-#define	SCREEN_HEIGHT	272
+#define	MAX_FPS	30
 
+unsigned int __attribute__((aligned(16))) displayList[262144];
+unsigned short __attribute__((aligned(16))) clut256[256];
+unsigned short __attribute__((aligned(16))) mouseClut[256];
+unsigned short __attribute__((aligned(16))) cursorPalette[256];
+unsigned short __attribute__((aligned(16))) kbClut[256];
+//unsigned int __attribute__((aligned(16))) offscreen256[640*480];
+//unsigned int __attribute__((aligned(16))) overlayBuffer256[640*480*2];
+unsigned int __attribute__((aligned(16))) mouseBuf256[MOUSE_SIZE*MOUSE_SIZE];
 
-unsigned short *DrawBuffer = (unsigned short *)0x44044000;
-unsigned short *DisplayBuffer = (unsigned short *)0x44000000;
+extern unsigned int  size_keyboard_symbols_compressed;
+extern unsigned char keyboard_symbols_compressed[];
+extern unsigned int  size_keyboard_symbols_shift_compressed;
+extern unsigned char keyboard_symbols_shift_compressed[];
+extern unsigned int  size_keyboard_letters_compressed;
+extern unsigned char keyboard_letters_compressed[];
+extern unsigned int  size_keyboard_letters_shift_compressed;
+extern unsigned char keyboard_letters_shift_compressed[];
+unsigned char *keyboard_symbols;
+unsigned char *keyboard_symbols_shift;
+unsigned char *keyboard_letters;
+unsigned char *keyboard_letters_shift;
 
+unsigned char kbd_ascii[] = {'1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '-', '=', '[', ']', '\\', ';', '\'', ',', '.', '/', '`'};
+Common::KeyCode  kbd_code[] = {Common::KEYCODE_1, Common::KEYCODE_2, Common::KEYCODE_3, Common::KEYCODE_4, Common::KEYCODE_5, Common::KEYCODE_6, Common::KEYCODE_7, Common::KEYCODE_8, Common::KEYCODE_9, Common::KEYCODE_0, Common::KEYCODE_MINUS, Common::KEYCODE_EQUALS, Common::KEYCODE_LEFTBRACKET, Common::KEYCODE_RIGHTBRACKET,
+							Common::KEYCODE_BACKSLASH, Common::KEYCODE_SEMICOLON, Common::KEYCODE_QUOTE, Common::KEYCODE_COMMA, Common::KEYCODE_PERIOD, Common::KEYCODE_SLASH, Common::KEYCODE_BACKQUOTE};
+unsigned char kbd_ascii_cl[] = {'!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '_', '+', '{', '}', '|', ':', '"', '<', '>', '?', '~'};
+Common::KeyCode  kbd_code_cl[]  = {Common::KEYCODE_EXCLAIM, Common::KEYCODE_AT, Common::KEYCODE_HASH, Common::KEYCODE_DOLLAR, (Common::KeyCode)37, Common::KEYCODE_CARET, Common::KEYCODE_AMPERSAND, Common::KEYCODE_ASTERISK, Common::KEYCODE_LEFTPAREN, Common::KEYCODE_RIGHTPAREN, Common::KEYCODE_UNDERSCORE,
+								Common::KEYCODE_PLUS, (Common::KeyCode)123, (Common::KeyCode)125, (Common::KeyCode)124, Common::KEYCODE_COLON, Common::KEYCODE_QUOTEDBL, Common::KEYCODE_LESS, Common::KEYCODE_GREATER, Common::KEYCODE_QUESTION, (Common::KeyCode)126};
+#define CAPS_LOCK	(1 << 0)
+#define SYMBOLS		(1 << 1)
+
+
+
+
 unsigned long RGBToColour(unsigned long r, unsigned long g, unsigned long b) {
 	return (((b >> 3) << 10) | ((g >> 3) << 5) | ((r >> 3) << 0)) | 0x8000;
 }
 
-void putPixel(uint16 x, uint16 y, unsigned long colour) {
-	*(unsigned short *)(DrawBuffer + (y << 9) + x ) = colour;
-}
-
 static int timer_handler(int t) {
 	DefaultTimerManager *tm = (DefaultTimerManager *)g_system->getTimerManager();
 	tm->handler();
@@ -75,25 +108,88 @@
 };
 
 
-OSystem_PSP::OSystem_PSP() : _screenWidth(0), _screenHeight(0), _overlayWidth(0), _overlayHeight(0), _offscreen(0), _overlayBuffer(0), _overlayVisible(false), _shakePos(0), _mouseBuf(0), _prevButtons(0), _lastPadCheck(0), _padAccel(0), _mixer(0) {
-
+OSystem_PSP::OSystem_PSP() : _screenWidth(0), _screenHeight(0), _overlayWidth(0), _overlayHeight(0), _offscreen(0), _overlayBuffer(0), _overlayVisible(false), _shakePos(0), _lastScreenUpdate(0), _mouseBuf(0), _prevButtons(0), _lastPadCheck(0), _padAccel(0), _mixer(0) {
 	memset(_palette, 0, sizeof(_palette));
 
+	_cursorPaletteDisabled = true;
+
 	_samplesPerSec = 0;
 
 	//init SDL
 	uint32	sdlFlags = SDL_INIT_AUDIO | SDL_INIT_TIMER;
 	SDL_Init(sdlFlags);
 
-	sceDisplaySetMode(0, SCREEN_WIDTH, SCREEN_HEIGHT);
-	sceDisplaySetFrameBuf((char *)DisplayBuffer, 512, 1, 1);
+
+	//decompress keyboard data
+	uLongf kbdSize = KBD_DATA_SIZE;
+	keyboard_letters = (unsigned char *)memalign(16, KBD_DATA_SIZE);
+	if (Z_OK != uncompress((Bytef *)keyboard_letters, &kbdSize, (const Bytef *)keyboard_letters_compressed, size_keyboard_letters_compressed))
+		error("OSystem_PSP: uncompressing keyboard_letters failed");
+
+	kbdSize = KBD_DATA_SIZE;
+	keyboard_letters_shift = (unsigned char *)memalign(16, KBD_DATA_SIZE);
+	if (Z_OK != uncompress((Bytef *)keyboard_letters_shift, &kbdSize, (const Bytef *)keyboard_letters_shift_compressed, size_keyboard_letters_shift_compressed))
+		error("OSystem_PSP: uncompressing keyboard_letters_shift failed");
+
+	kbdSize = KBD_DATA_SIZE;
+	keyboard_symbols = (unsigned char *)memalign(16, KBD_DATA_SIZE);
+	if (Z_OK != uncompress((Bytef *)keyboard_symbols, &kbdSize, (const Bytef *)keyboard_symbols_compressed, size_keyboard_symbols_compressed))
+		error("OSystem_PSP: uncompressing keyboard_symbols failed");
+
+	kbdSize = KBD_DATA_SIZE;
+	keyboard_symbols_shift = (unsigned char *)memalign(16, KBD_DATA_SIZE);
+	if (Z_OK != uncompress((Bytef *)keyboard_symbols_shift, &kbdSize, (const Bytef *)keyboard_symbols_shift_compressed, size_keyboard_symbols_shift_compressed))
+		error("OSystem_PSP: uncompressing keyboard_symbols_shift failed");
+
+	_keyboardVisible = false;
+	_clut = (unsigned short *)(((unsigned int)clut256) | 0x40000000);
+	_kbdClut = (unsigned short *)(((unsigned int)kbClut) | 0x40000000);
+	_mouseBuf = (byte *)mouseBuf256;
+	_graphicMode = STRETCHED_480X272;
+	_keySelected = 1;
+	_keyboardMode = 0;
+	_mouseX = PSP_SCREEN_WIDTH >> 1;
+	_mouseY = PSP_SCREEN_HEIGHT >> 1;
+
+
+	//sceKernelDcacheWritebackAll();
+
+	// setup
+	sceGuInit();
+	sceGuStart(0, displayList);
+	sceGuDrawBuffer(GU_PSM_8888, (void *)0, BUF_WIDTH);
+	sceGuDispBuffer(PSP_SCREEN_WIDTH, PSP_SCREEN_HEIGHT, (void*)PSP_FRAME_SIZE, BUF_WIDTH);
+	sceGuDepthBuffer((void*)(PSP_FRAME_SIZE * 2), BUF_WIDTH);
+	sceGuOffset(2048 - (PSP_SCREEN_WIDTH/2), 2048 - (PSP_SCREEN_HEIGHT/2));
+	sceGuViewport(2048, 2048, PSP_SCREEN_WIDTH, PSP_SCREEN_HEIGHT);
+	sceGuDepthRange(0xC350, 0x2710);
+	sceGuScissor(0, 0, PSP_SCREEN_WIDTH, PSP_SCREEN_HEIGHT);
+	sceGuEnable(GU_SCISSOR_TEST);
+	sceGuFrontFace(GU_CW);
+	sceGuEnable(GU_TEXTURE_2D);
+	sceGuClear(GU_COLOR_BUFFER_BIT|GU_DEPTH_BUFFER_BIT);
+	sceGuFinish();
+	sceGuSync(0,0);
+
 	sceDisplayWaitVblankStart();
+	sceGuDisplay(1);
+
 }
 
 OSystem_PSP::~OSystem_PSP() {
+	free(keyboard_symbols_shift);
+	free(keyboard_symbols);
+	free(keyboard_letters_shift);
+	free(keyboard_letters);
+
 	free(_offscreen);
 	free(_overlayBuffer);
 	free(_mouseBuf);
+
+	_offscreen = 0;
+	_overlayBuffer = 0;
+	_mouseBuf = 0;
+	 sceGuTerm();
 }
 
 
@@ -110,14 +206,14 @@
 
 
 bool OSystem_PSP::hasFeature(Feature f) {
-	return false;
+	return (f == kFeatureOverlaySupportsAlpha || f == kFeatureCursorHasPalette);
 }
 
 void OSystem_PSP::setFeatureState(Feature f, bool enable) {
 }
 
 bool OSystem_PSP::getFeatureState(Feature f) {
-	return (f == kFeatureOverlaySupportsAlpha);
+	return false;
 }
 
 const OSystem::GraphicsMode* OSystem_PSP::getSupportedGraphicsModes() const {
@@ -126,36 +222,56 @@
 
 
 int OSystem_PSP::getDefaultGraphicsMode() const {
-	return -1;
+	return STRETCHED_480X272;
 }
 
 bool OSystem_PSP::setGraphicsMode(int mode) {
+	_graphicMode = mode;
 	return true;
 }
 
 bool OSystem_PSP::setGraphicsMode(const char *name) {
-	return true;
+	int i = 0;
+
+	while (s_supportedGraphicsModes[i].name) {
+		if (!strcmpi(s_supportedGraphicsModes[i].name, name)) {
+			_graphicMode = s_supportedGraphicsModes[i].id;
+			return true;
+		}
+		i++;
+	}
+
+	return false;
 }
 
 int OSystem_PSP::getGraphicsMode() const {
-	return -1;
+	return _graphicMode;
 }
 
-void OSystem_PSP::initSize(uint width, uint height) {
-	_overlayWidth = _screenWidth = width;
-	_overlayHeight = _screenHeight = height;
+void OSystem_PSP::initSize(uint width, uint height, const Graphics::PixelFormat *format) {
+	PSPDebugTrace("initSize\n");
+	_screenWidth = width;
+	_screenHeight = height;
 
-	free(_offscreen);
+	_overlayWidth = PSP_SCREEN_WIDTH;	//width;
+	_overlayHeight = PSP_SCREEN_HEIGHT;	//height;
 
-	_offscreen = (byte *)malloc(width * height);
+//	_offscreen = (byte *)offscreen256;
+	_overlayBuffer = (OverlayColor *)0x44000000 + PSP_FRAME_SIZE;
 
-	free(_overlayBuffer);
-
-	_overlayBuffer = (OverlayColor *)malloc(_overlayWidth * _overlayHeight * sizeof(OverlayColor));
+	_offscreen = (byte *)_overlayBuffer + _overlayWidth * _overlayHeight * sizeof(OverlayColor);
 	bzero(_offscreen, width * height);
 	clearOverlay();
+	memset(_palette, 0xFFFF, 256 * sizeof(unsigned short));
+	_kbdClut[0] = 0xFFFF;
+	_kbdClut[246] = 0x4CCC;
+	_kbdClut[247] = 0x0000;
 
+	for (int i = 1; i < 31; i++)
+		_kbdClut[i] = 0xF888;
+
 	_mouseVisible = false;
+	sceKernelDcacheWritebackAll();
 }
 
 int16 OSystem_PSP::getWidth() {
@@ -173,8 +289,36 @@
 		_palette[start + i] = RGBToColour(b[0], b[1], b[2]);
 		b += 4;
 	}
+
+	//copy to CLUT
+	memcpy(_clut, _palette, 256 * sizeof(unsigned short));
+
+	//force update of mouse CLUT as well, as it may have been set up before this palette was set
+	memcpy(mouseClut, _palette, 256 * sizeof(unsigned short));
+	mouseClut[_mouseKeyColour] = 0;
+
+	sceKernelDcacheWritebackAll();
 }
 
+void OSystem_PSP::setCursorPalette(const byte *colors, uint start, uint num) {
+	const byte *b = colors;
+
+	for (uint i = 0; i < num; ++i) {
+		cursorPalette[start + i] = RGBToColour(b[0], b[1], b[2]);
+		b += 4;
+	}
+
+	cursorPalette[0] = 0;
+
+	_cursorPaletteDisabled = false;
+
+	sceKernelDcacheWritebackAll();
+}
+
+void OSystem_PSP::disableCursorPalette(bool disable) {
+	_cursorPaletteDisabled = disable;
+}
+
 void OSystem_PSP::copyRectToScreen(const byte *buf, int pitch, int x, int y, int w, int h) {
 	//Clip the coordinates
 	if (x < 0) {
@@ -202,10 +346,21 @@
 
 
 	byte *dst = _offscreen + y * _screenWidth + x;
-	if (_screenWidth == pitch && pitch == w) {
+
+	if (_screenWidth == pitch && pitch == w)
+	{
 		memcpy(dst, buf, h * w);
-	} else {
-		do {
+/*
+		sceGuStart(0, displayList);
+		sceGuCopyImage( 3, 0, 0, w/2, h, w/2, (void *)buf, x/2, y, _screenWidth /2, _offscreen);
+		sceGuFinish();
+		sceGuSync(0,0);
+*/
+	}
+	 else
+	{
+		do
+		{
 			memcpy(dst, buf, w);
 			buf += pitch;
 			dst += _screenWidth;
@@ -228,52 +383,205 @@
 }
 
 void OSystem_PSP::updateScreen() {
-	unsigned short *temp;
+	u32 now = getMillis();
+	if (now - _lastScreenUpdate < 1000 / MAX_FPS)
+		return;
 
-	uint xStart = (SCREEN_WIDTH >> 1) - (_screenWidth >> 1);
-	uint yStart = (SCREEN_HEIGHT >> 1) - (_screenHeight >> 1);
+	_lastScreenUpdate = now;
 
-	for (int i = 0; i < _screenHeight; ++i) {
-		for (int j = 0; j < _screenWidth; ++j) {
-			putPixel(xStart + j, yStart + i, _palette[_offscreen[i * _screenWidth +j]]);
-		}
+
+	sceGuStart(0, displayList);
+
+	sceGuClearColor(0xFF000000);
+	sceGuClear(GU_COLOR_BUFFER_BIT);
+
+	sceGuClutMode(GU_PSM_5551, 0, 0xFF, 0);
+	sceGuClutLoad(32, clut256); // upload 32*8 entries (256)
+	sceGuTexMode(GU_PSM_T8, 0, 0, 0); // 8-bit image
+	if (_screenWidth == 320)
+			sceGuTexImage(0, 512, 256, _screenWidth, _offscreen);
+	else
+			sceGuTexImage(0, 512, 512, _screenWidth, _offscreen);
+	sceGuTexFunc(GU_TFX_REPLACE, GU_TCC_RGB);
+	sceGuTexFilter(GU_LINEAR, GU_LINEAR);
+	sceGuTexOffset(0,0);
+	sceGuAmbientColor(0xFFFFFFFF);
+	sceGuColor(0xFFFFFFFF);
+
+	struct Vertex* vertices = (struct Vertex*)sceGuGetMemory(2 * sizeof(struct Vertex));
+	vertices[0].u = 0.5; vertices[0].v = 0.5;
+	vertices[1].u = _screenWidth - 0.5; vertices[1].v = _screenHeight - 0.5;
+	switch(_graphicMode) {
+		case CENTERED_320X200:
+			vertices[0].x = (PSP_SCREEN_WIDTH - 320) / 2; vertices[0].y = (PSP_SCREEN_HEIGHT - 200) / 2; vertices[0].z = 0;
+			vertices[1].x = PSP_SCREEN_WIDTH - (PSP_SCREEN_WIDTH - 320) / 2; vertices[1].y = PSP_SCREEN_HEIGHT - (PSP_SCREEN_HEIGHT - 200) / 2; vertices[1].z = 0;
+		break;
+		case CENTERED_435X272:
+			vertices[0].x = (PSP_SCREEN_WIDTH - 435) / 2; vertices[0].y = 0; vertices[0].z = 0;
+			vertices[1].x = PSP_SCREEN_WIDTH - (PSP_SCREEN_WIDTH - 435) / 2; vertices[1].y = PSP_SCREEN_HEIGHT; vertices[1].z = 0;
+		break;
+		case STRETCHED_480X272:
+			vertices[0].x = 0; vertices[0].y = 0; vertices[0].z = 0;
+			vertices[1].x = PSP_SCREEN_WIDTH; vertices[1].y = PSP_SCREEN_HEIGHT; vertices[1].z = 0;
+		break;
+		case CENTERED_362X272:
+			vertices[0].x = (PSP_SCREEN_WIDTH - 362) / 2; vertices[0].y = 0; vertices[0].z = 0;
+			vertices[1].x = PSP_SCREEN_WIDTH - (PSP_SCREEN_WIDTH - 362) / 2; vertices[1].y = PSP_SCREEN_HEIGHT; vertices[1].z = 0;
+		break;
 	}
 
+	if (_shakePos) {
+		vertices[0].y += _shakePos;
+		vertices[1].y += _shakePos;
+	}
+
+	sceGuDrawArray(GU_SPRITES, GU_TEXTURE_32BITF|GU_VERTEX_32BITF|GU_TRANSFORM_2D, 2, 0, vertices);
+	if (_screenWidth == 640) {
+		sceGuTexImage(0, 512, 512, _screenWidth, _offscreen+512);
+		vertices[0].u = 512 + 0.5; vertices[1].v = _screenHeight - 0.5;
+		vertices[0].x += (vertices[1].x - vertices[0].x) * 511 / 640; vertices[0].y = 0; vertices[0].z = 0;
+		sceGuDrawArray(GU_SPRITES, GU_TEXTURE_32BITF|GU_VERTEX_32BITF|GU_TRANSFORM_2D, 2, 0, vertices);
+	}
+
+
+	// draw overlay
 	if (_overlayVisible) {
-		for (int i = 0; i < _screenHeight; ++i) {
-			for (int j = 0; j < _screenWidth; ++j) {
+		vertices[0].x = 0; vertices[0].y = 0; vertices[0].z = 0;
+		vertices[1].x = PSP_SCREEN_WIDTH; vertices[1].y = PSP_SCREEN_HEIGHT; vertices[1].z = 0;
+		vertices[0].u = 0.5; vertices[0].v = 0.5;
+		vertices[1].u = _overlayWidth - 0.5; vertices[1].v = _overlayHeight - 0.5;
+		sceGuTexMode(GU_PSM_4444, 0, 0, 0); // 16-bit image
+		sceGuDisable(GU_ALPHA_TEST);
+		sceGuEnable(GU_BLEND);
 
-				OverlayColor pixel = _overlayBuffer[(i * _overlayWidth +j)];
+		//sceGuBlendFunc(GU_ADD, GU_SRC_ALPHA, GU_ONE_MINUS_SRC_ALPHA, 0, 0);
+		sceGuBlendFunc(GU_ADD, GU_FIX, GU_ONE_MINUS_SRC_ALPHA, 0xFFFFFFFF, 0);
 
-				if (pixel & 0x8000)
-					putPixel(xStart + j, yStart + i, pixel);
-			}
+		if (_overlayWidth > 320)
+			sceGuTexImage(0, 512, 512, _overlayWidth, _overlayBuffer);
+		else
+			sceGuTexImage(0, 512, 256, _overlayWidth, _overlayBuffer);
+
+		sceGuTexFunc(GU_TFX_REPLACE, GU_TCC_RGBA);
+		sceGuDrawArray(GU_SPRITES,GU_TEXTURE_32BITF|GU_VERTEX_32BITF|GU_TRANSFORM_2D,2,0,vertices);
+		// need to render twice for textures > 512
+		if ( _overlayWidth > 512) {
+			sceGuTexImage(0, 512, 512, _overlayWidth, _overlayBuffer + 512);
+			vertices[0].u = 512 + 0.5; vertices[1].v = _overlayHeight - 0.5;
+			vertices[0].x = PSP_SCREEN_WIDTH * 512 / 640; vertices[0].y = 0; vertices[0].z = 0;
+			sceGuDrawArray(GU_SPRITES, GU_TEXTURE_32BITF|GU_VERTEX_32BITF|GU_TRANSFORM_2D, 2, 0, vertices);
 		}
+		sceGuDisable(GU_BLEND);
 	}
 
-	//draw mouse on top
+	// draw mouse
 	if (_mouseVisible) {
-		for (int y = 0; y < _mouseHeight; ++y) {
-			for (int x = 0; x < _mouseWidth; ++x) {
-				if (_mouseBuf[y * _mouseHeight + x] != _mouseKeyColour) {
-					int my = _mouseY + y; // + _mouseHotspotY;
-					int mx = _mouseX + x; // + _mouseHotspotX;
+		sceGuTexMode(GU_PSM_T8, 0, 0, 0); // 8-bit image
+		sceGuClutMode(GU_PSM_5551, 0, 0xFF, 0);
+		sceGuClutLoad(32, _cursorPaletteDisabled ? mouseClut : cursorPalette); // upload 32*8 entries (256)
+		sceGuAlphaFunc(GU_GREATER, 0, 0xFF);
+		sceGuEnable(GU_ALPHA_TEST);
+		sceGuTexImage(0, MOUSE_SIZE, MOUSE_SIZE, MOUSE_SIZE, _mouseBuf);
+		sceGuTexFunc(GU_TFX_MODULATE, GU_TCC_RGBA);
 
-					if (mx >= 0 && mx < _screenWidth && my >= 0 && my < _screenHeight)
-						putPixel(xStart + mx, yStart + my, _palette[_mouseBuf[y * _mouseHeight + x]]);
-				}
+		vertices[0].u = 0.5; vertices[0].v = 0.5;
+		vertices[1].u = _mouseWidth - 0.5; vertices[1].v = _mouseHeight - 0.5;
+
+		//adjust cursor position
+		int mX = _mouseX - _mouseHotspotX;
+		int mY = _mouseY - _mouseHotspotY;
+
+		if (_overlayVisible) {
+			float scalex, scaley;
+
+			scalex = (float)PSP_SCREEN_WIDTH /_overlayWidth;
+			scaley = (float)PSP_SCREEN_HEIGHT /_overlayHeight;
+
+			vertices[0].x = mX * scalex; vertices[0].y = mY * scaley; vertices[0].z = 0;
+			vertices[1].x = vertices[0].x + _mouseWidth * scalex; vertices[1].y = vertices[0].y + _mouseHeight * scaley; vertices[0].z = 0;
+		} else
+			switch(_graphicMode) {
+			case CENTERED_320X200:
+				vertices[0].x = (PSP_SCREEN_WIDTH - 320) / 2 + mX; vertices[0].y = (PSP_SCREEN_HEIGHT - 200) / 2 + mY; vertices[0].z = 0;
+				vertices[1].x = vertices[0].x+_mouseWidth; vertices[1].y = vertices[0].y + _mouseHeight; vertices[1].z = 0;
+			break;
+			case CENTERED_435X272:
+			{
+				float scalex, scaley;
+
+				scalex = 435.0f / _screenWidth;
+				scaley = 272.0f / _screenHeight;
+
+				vertices[0].x = (PSP_SCREEN_WIDTH - 435) / 2 + mX * scalex; vertices[0].y = mY * scaley; vertices[0].z = 0;
+				vertices[1].x = vertices[0].x + _mouseWidth * scalex; vertices[1].y = vertices[0].y + _mouseHeight * scaley; vertices[0].z = 0;
+
 			}
+			break;
+			case CENTERED_362X272:
+			{
+				float scalex, scaley;
+
+				scalex = 362.0f / _screenWidth;
+				scaley = 272.0f / _screenHeight;
+
+				vertices[0].x = (PSP_SCREEN_WIDTH - 362) / 2 + mX * scalex; vertices[0].y = mY * scaley; vertices[0].z = 0;
+				vertices[1].x = vertices[0].x + _mouseWidth * scalex; vertices[1].y = vertices[0].y + _mouseHeight * scaley; vertices[0].z = 0;
+			}
+			break;
+			case STRETCHED_480X272:
+			{
+				float scalex, scaley;
+
+				scalex = (float)PSP_SCREEN_WIDTH / _screenWidth;
+				scaley = (float)PSP_SCREEN_HEIGHT / _screenHeight;
+
+				vertices[0].x = mX * scalex; vertices[0].y = mY * scaley; vertices[0].z = 0;
+				vertices[1].x = vertices[0].x + _mouseWidth * scalex; vertices[1].y = vertices[0].y + _mouseHeight * scaley; vertices[0].z = 0;
+			}
+			break;
 		}
+		sceGuDrawArray(GU_SPRITES, GU_TEXTURE_32BITF|GU_VERTEX_32BITF|GU_TRANSFORM_2D, 2, 0, vertices);
 	}
 
+	if (_keyboardVisible) {
+		sceGuTexMode(GU_PSM_T8, 0, 0, 0); // 8-bit image
+		sceGuClutMode(GU_PSM_4444, 0, 0xFF, 0);
+		sceGuClutLoad(32, kbClut); // upload 32*8 entries (256)
+		sceGuDisable(GU_ALPHA_TEST);
+		sceGuEnable(GU_BLEND);
+		sceGuBlendFunc(GU_ADD, GU_SRC_ALPHA, GU_ONE_MINUS_SRC_ALPHA, 0, 0);
+		switch(_keyboardMode) {
+			case 0:
+				sceGuTexImage(0, 512, 512, 480, keyboard_letters);
+				break;
+			case CAPS_LOCK:
+				sceGuTexImage(0, 512, 512, 480, keyboard_letters_shift);
+				break;
+			case SYMBOLS:
+				sceGuTexImage(0, 512, 512, 480, keyboard_symbols);
+				break;
+			case (CAPS_LOCK | SYMBOLS):
+				sceGuTexImage(0, 512, 512, 480, keyboard_symbols_shift);
+				break;
+		}
+		sceGuTexFunc(GU_TFX_REPLACE, GU_TCC_RGBA);
 
-	// switch buffers
-	temp = DrawBuffer;
-	DrawBuffer = DisplayBuffer;
-	DisplayBuffer = temp;
+		vertices[0].u = 0.5; vertices[0].v = 0.5;
+		vertices[1].u = PSP_SCREEN_WIDTH-0.5; vertices[1].v = PSP_SCREEN_HEIGHT-0.5;
+		vertices[0].x = 0; vertices[0].y = 0; vertices[0].z = 0;
+		vertices[1].x = PSP_SCREEN_WIDTH; vertices[1].y = PSP_SCREEN_HEIGHT; vertices[0].z = 0;
+		sceGuDrawArray(GU_SPRITES,GU_TEXTURE_32BITF|GU_VERTEX_32BITF|GU_TRANSFORM_2D,2,0,vertices);
+		sceGuDisable(GU_BLEND);
+	}
+	sceKernelDcacheWritebackAll();
+
+	sceGuFinish();
+	sceGuSync(0,0);
+
 	sceDisplayWaitVblankStart();
-	sceDisplaySetFrameBuf((char *)DisplayBuffer, 512, 1, 1);
+	sceGuSwapBuffers();
 
+	//sceKernelDcacheWritebackAll();
 }
 
 void OSystem_PSP::setShakePos(int shakeOffset) {
@@ -380,7 +688,7 @@
 	_mouseY = y;
 }
 
-void OSystem_PSP::setMouseCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, byte keycolor, int cursorTargetScale) {
+void OSystem_PSP::setMouseCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor, int cursorTargetScale, const Graphics::PixelFormat *format) {
 	//TODO: handle cursorTargetScale
 	_mouseWidth = w;
 	_mouseHeight = h;
@@ -388,18 +696,20 @@
 	_mouseHotspotX = hotspotX;
 	_mouseHotspotY = hotspotY;
 
-	_mouseKeyColour = keycolor;
+	_mouseKeyColour = keycolor & 0xFF;
 
-	free(_mouseBuf);
+	memcpy(mouseClut, _palette, 256 * sizeof(unsigned short));
+	mouseClut[_mouseKeyColour] = 0;
+	sceKernelDcacheWritebackAll();
 
-	_mouseBuf = (byte *)malloc(w * h);
-	memcpy(_mouseBuf, buf, w * h);
+	for (unsigned int i = 0; i < h; i++)
+		memcpy(_mouseBuf + i * MOUSE_SIZE, buf + i * w, w);
 }
 
 #define PAD_CHECK_TIME	40
 #define PAD_DIR_MASK	(PSP_CTRL_UP | PSP_CTRL_DOWN | PSP_CTRL_LEFT | PSP_CTRL_RIGHT)
 
-bool OSystem_PSP::pollEvent(Common::Event &event) {
+bool OSystem_PSP::processInput(Common::Event &event) {
 	s8 analogStepAmountX = 0;
 	s8 analogStepAmountY = 0;
 /*
@@ -411,7 +721,7 @@
 */
 	uint32 buttonsChanged = pad.Buttons ^ _prevButtons;
 
-	if (buttonsChanged & (PSP_CTRL_CROSS | PSP_CTRL_CIRCLE | PSP_CTRL_LTRIGGER | PSP_CTRL_RTRIGGER | PSP_CTRL_START | PSP_CTRL_SELECT | PSP_CTRL_SQUARE)) {
+	if (buttonsChanged & (PSP_CTRL_CROSS | PSP_CTRL_CIRCLE | PSP_CTRL_LTRIGGER | PSP_CTRL_RTRIGGER | PSP_CTRL_START | PSP_CTRL_SELECT | PSP_CTRL_SQUARE | PSP_CTRL_TRIANGLE)) {
 		if (buttonsChanged & PSP_CTRL_CROSS) {
 			event.type = (pad.Buttons & PSP_CTRL_CROSS) ? Common::EVENT_LBUTTONDOWN : Common::EVENT_LBUTTONUP;
 		} else if (buttonsChanged & PSP_CTRL_CIRCLE) {
@@ -419,23 +729,29 @@
 		} else {
 			//any of the other buttons.
 			event.type = buttonsChanged & pad.Buttons ? Common::EVENT_KEYDOWN : Common::EVENT_KEYUP;
+			event.kbd.ascii = 0;
 			event.kbd.flags = 0;
 
 			if (buttonsChanged & PSP_CTRL_LTRIGGER) {
 				event.kbd.keycode = Common::KEYCODE_ESCAPE;
 				event.kbd.ascii = 27;
-			} else if (buttonsChanged & PSP_CTRL_RTRIGGER) {
-				event.kbd.keycode = Common::KEYCODE_RETURN;
-				event.kbd.ascii = 13;
 			} else if (buttonsChanged & PSP_CTRL_START) {
 				event.kbd.keycode = Common::KEYCODE_F5;
 				event.kbd.ascii = Common::ASCII_F5;
+				if (pad.Buttons & PSP_CTRL_RTRIGGER) {
+					event.kbd.flags = Common::KBD_CTRL;	// Main menu to allow RTL
+				}
 /*			} else if (buttonsChanged & PSP_CTRL_SELECT) {
 				event.kbd.keycode = Common::KEYCODE_0;
 				event.kbd.ascii = '0';
 */			} else if (buttonsChanged & PSP_CTRL_SQUARE) {
 				event.kbd.keycode = Common::KEYCODE_PERIOD;
 				event.kbd.ascii = '.';
+			} else if (buttonsChanged & PSP_CTRL_TRIANGLE) {
+				event.kbd.keycode = Common::KEYCODE_RETURN;
+				event.kbd.ascii = 13;
+			} else if (pad.Buttons & PSP_CTRL_RTRIGGER) {
+				event.kbd.flags |= Common::KBD_SHIFT;
 			}
 
 		}
@@ -484,7 +800,7 @@
 				newY += _padAccel >> 2;
 
 			// If no movement then this has no effect
-			if (pad.Buttons & PSP_CTRL_TRIANGLE) {
+			if (pad.Buttons & PSP_CTRL_RTRIGGER) {
 				// Fine control mode for analog
 					if (analogStepAmountX != 0) {
 						if (analogStepAmountX > 0)
@@ -535,6 +851,136 @@
 	return false;
 }
 
+bool OSystem_PSP::pollEvent(Common::Event &event) {
+	float nub_angle = -1;
+	int x, y;
+
+	sceCtrlSetSamplingCycle(0);
+	sceCtrlSetSamplingMode(1);
+	sceCtrlReadBufferPositive(&pad, 1);
+
+	uint32 buttonsChanged = pad.Buttons ^ _prevButtons;
+
+	if  ((buttonsChanged & PSP_CTRL_SELECT) || (pad.Buttons & PSP_CTRL_SELECT)) {
+		if ( !(pad.Buttons & PSP_CTRL_SELECT) )
+			_keyboardVisible = !_keyboardVisible;
+		_prevButtons = pad.Buttons;
+		return false;
+	}
+
+	if (!_keyboardVisible)
+		return processInput(event);
+
+	if ( (buttonsChanged & PSP_CTRL_RTRIGGER) && !(pad.Buttons & PSP_CTRL_RTRIGGER))
+		_keyboardMode ^= CAPS_LOCK;
+
+	if ( (buttonsChanged & PSP_CTRL_LTRIGGER) && !(pad.Buttons & PSP_CTRL_LTRIGGER))
+		_keyboardMode ^= SYMBOLS;
+
+	if ( (buttonsChanged & PSP_CTRL_LEFT) && !(pad.Buttons & PSP_CTRL_LEFT)) {
+		event.kbd.flags = 0;
+		event.kbd.ascii = 0;
+		event.kbd.keycode = Common::KEYCODE_LEFT;
+		_prevButtons = pad.Buttons;
+		return true;
+	}
+
+	if ( (buttonsChanged & PSP_CTRL_RIGHT) && !(pad.Buttons & PSP_CTRL_RIGHT)) {
+		event.kbd.flags = 0;
+		event.kbd.ascii = 0;
+		event.kbd.keycode = Common::KEYCODE_RIGHT;
+		_prevButtons = pad.Buttons;
+		return true;
+	}
+
+	if ( (buttonsChanged & PSP_CTRL_UP) && !(pad.Buttons & PSP_CTRL_UP)) {
+		event.kbd.flags = 0;
+		event.kbd.ascii = 0;
+		event.kbd.keycode = Common::KEYCODE_UP;
+		_prevButtons = pad.Buttons;
+		return true;
+	}
+
+	if ( (buttonsChanged & PSP_CTRL_DOWN) && !(pad.Buttons & PSP_CTRL_DOWN)) {
+		event.kbd.flags = 0;
+		event.kbd.ascii = 0;
+		event.kbd.keycode = Common::KEYCODE_DOWN;
+		_prevButtons = pad.Buttons;
+		return true;
+	}
+
+	// compute nub direction
+	x = pad.Lx-128;
+	y = pad.Ly-128;
+	_kbdClut[_keySelected] = 0xf888;
+	if (x*x + y*y > 10000) {
+		nub_angle = atan2(y, x);
+		_keySelected = (int)(1 + (M_PI + nub_angle) * 30 / (2 * M_PI));
+		_keySelected -= 2;
+		if (_keySelected < 1)
+			_keySelected += 30;
+		_kbdClut[_keySelected] = 0xFFFF;
+
+		if  (buttonsChanged & PSP_CTRL_CROSS) {
+			event.type = (pad.Buttons & PSP_CTRL_CROSS) ? Common::EVENT_KEYDOWN : Common::EVENT_KEYUP;
+			if (_keySelected > 26) {
+				event.kbd.flags = 0;
+				switch(_keySelected) {
+					case 27:
+						event.kbd.ascii = ' ';
+						event.kbd.keycode = Common::KEYCODE_SPACE;
+					break;
+					case 28:
+						event.kbd.ascii = 127;
+						event.kbd.keycode = Common::KEYCODE_DELETE;
+					break;
+					case 29:
+						event.kbd.ascii = 8;
+						event.kbd.keycode = Common::KEYCODE_BACKSPACE;
+					break;
+					case 30:
+						event.kbd.ascii = 13;
+						event.kbd.keycode = Common::KEYCODE_RETURN;
+					break;
+				}
+			} else {
+				switch( _keyboardMode) {
+					case 0:
+						event.kbd.flags = 0;
+						event.kbd.ascii = 'a'+_keySelected-1;
+						event.kbd.keycode = (Common::KeyCode)(Common::KEYCODE_a + _keySelected-1);
+						break;
+					case CAPS_LOCK:
+						event.kbd.ascii = 'A'+_keySelected-1;
+						event.kbd.keycode = (Common::KeyCode)(Common::KEYCODE_a + _keySelected-1);
+						event.kbd.flags = Common::KBD_SHIFT;
+						break;
+					case SYMBOLS:
+						if (_keySelected < 21) {
+							event.kbd.flags = 0;
+							event.kbd.ascii = kbd_ascii[_keySelected-1];
+							event.kbd.keycode = kbd_code[ _keySelected-1];
+						}
+						break;
+					case (SYMBOLS|CAPS_LOCK):
+						if (_keySelected < 21) {
+							event.kbd.flags = 0;
+							event.kbd.ascii = kbd_ascii_cl[_keySelected-1];
+							event.kbd.keycode = kbd_code_cl[ _keySelected-1];
+						}
+						break;
+				}
+			}
+			_prevButtons = pad.Buttons;
+			return true;
+		}
+	}
+
+	_prevButtons = pad.Buttons;
+	return false;
+}
+
+
 uint32 OSystem_PSP::getMillis() {
 	return SDL_GetTicks();
 }

Modified: scummvm/branches/gsoc2009-mods/backends/platform/psp/osys_psp.h
===================================================================
--- scummvm/branches/gsoc2009-mods/backends/platform/psp/osys_psp.h	2009-08-24 16:07:46 UTC (rev 43700)
+++ scummvm/branches/gsoc2009-mods/backends/platform/psp/osys_psp.h	2009-08-24 17:51:47 UTC (rev 43701)
@@ -23,6 +23,9 @@
  *
  */
 
+#ifndef OSYS_PSP_H
+#define OSYS_PSP_H
+
 #include "common/scummsys.h"
 #include "graphics/surface.h"
 #include "graphics/colormasks.h"
@@ -47,6 +50,11 @@
 	static OSystem *instance();
 
 protected:
+	struct Vertex {
+		float u,v;
+		float x,y,z;
+	};
+
 	uint16	_screenWidth;
 	uint16	_screenHeight;
 	uint16  _overlayWidth;
@@ -56,6 +64,7 @@
 	uint16  _palette[256];
 	bool	_overlayVisible;
 	uint32	_shakePos;
+	uint32	_lastScreenUpdate;
 
 	Graphics::Surface _framebuffer;
 
@@ -65,7 +74,16 @@
 	int	_mouseHotspotX, _mouseHotspotY;
 	byte	_mouseKeyColour;
 	byte	*_mouseBuf;
+	bool	_cursorPaletteDisabled;
 
+	int _graphicMode;
+	Vertex *_vertices;
+	unsigned short* _clut;
+	unsigned short* _kbdClut;
+	bool _keyboardVisible;
+	int _keySelected;
+	int _keyboardMode;
+
 	uint32	_prevButtons;
 	uint32	_lastPadCheck;
 	uint32	_padAccel;
@@ -78,7 +96,6 @@
 	Common::TimerManager *_timer;
 
 public:
-
 	OSystem_PSP();
 	virtual ~OSystem_PSP();
 
@@ -87,15 +104,21 @@
 	virtual bool hasFeature(Feature f);
 	virtual void setFeatureState(Feature f, bool enable);
 	virtual bool getFeatureState(Feature f);
+
 	virtual const GraphicsMode *getSupportedGraphicsModes() const;
 	virtual int getDefaultGraphicsMode() const;
 	virtual bool setGraphicsMode(int mode);
 	bool setGraphicsMode(const char *name);
 	virtual int getGraphicsMode() const;
-	virtual void initSize(uint width, uint height);
+
+	virtual void initSize(uint width, uint height, const Graphics::PixelFormat *format);
 	virtual int16 getWidth();
 	virtual int16 getHeight();
+
 	virtual void setPalette(const byte *colors, uint start, uint num);
+	virtual void grabPalette(byte *colors, uint start, uint num);
+	virtual void setCursorPalette(const byte *colors, uint start, uint num);
+	virtual void disableCursorPalette(bool disable);
 	virtual void copyRectToScreen(const byte *buf, int pitch, int x, int y, int w, int h);
 	virtual Graphics::Surface *lockScreen();
 	virtual void unlockScreen();
@@ -109,15 +132,15 @@
 	virtual void copyRectToOverlay(const OverlayColor *buf, int pitch, int x, int y, int w, int h);
 	virtual int16 getOverlayHeight();
 	virtual int16 getOverlayWidth();
-	virtual void grabPalette(byte *colors, uint start, uint num);
 	virtual Graphics::PixelFormat getOverlayFormat() const { return Graphics::createPixelFormat<4444>(); }
 
 	virtual bool showMouse(bool visible);
-
 	virtual void warpMouse(int x, int y);
-	virtual void setMouseCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, byte keycolor = 255, int cursorTargetScale = 1);
+	virtual void setMouseCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor, int cursorTargetScale, const Graphics::PixelFormat *format);
 
 	virtual bool pollEvent(Common::Event &event);
+	virtual bool processInput(Common::Event &event);
+
 	virtual uint32 getMillis();
 	virtual void delayMillis(uint msecs);
 
@@ -144,3 +167,5 @@
 	virtual Common::WriteStream *createConfigWriteStream();
 };
 
+
+#endif /* OSYS_PSP_H */

Deleted: scummvm/branches/gsoc2009-mods/backends/platform/psp/osys_psp_gu.cpp
===================================================================
--- scummvm/branches/gsoc2009-mods/backends/platform/psp/osys_psp_gu.cpp	2009-08-24 16:07:46 UTC (rev 43700)
+++ scummvm/branches/gsoc2009-mods/backends/platform/psp/osys_psp_gu.cpp	2009-08-24 17:51:47 UTC (rev 43701)
@@ -1,601 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * $URL$
- * $Id$
- */
-
-#include "osys_psp_gu.h"
-#include "trace.h"
-#include "common/events.h"
-
-#include <zlib.h>
-
-#include <pspdisplay.h>
-
-#define PIXEL_SIZE (4)
-#define BUF_WIDTH (512)
-#define	PSP_SCREEN_WIDTH	480
-#define	PSP_SCREEN_HEIGHT	272
-#define PSP_FRAME_SIZE (BUF_WIDTH * PSP_SCREEN_HEIGHT * PIXEL_SIZE)
-#define MOUSE_SIZE	128
-#define	KBD_DATA_SIZE	130560
-
-unsigned int __attribute__((aligned(16))) list[262144];
-unsigned short __attribute__((aligned(16))) clut256[256];
-unsigned short __attribute__((aligned(16))) mouseClut[256];
-unsigned short __attribute__((aligned(16))) kbClut[256];
-//unsigned int __attribute__((aligned(16))) offscreen256[640*480];
-//unsigned int __attribute__((aligned(16))) overlayBuffer256[640*480*2];
-unsigned int __attribute__((aligned(16))) mouseBuf256[MOUSE_SIZE*MOUSE_SIZE];
-
-extern unsigned long RGBToColour(unsigned long r, unsigned long g, unsigned long b);
-
-extern unsigned int  size_keyboard_symbols_compressed;
-extern unsigned char keyboard_symbols_compressed[];
-extern unsigned int  size_keyboard_symbols_shift_compressed;
-extern unsigned char keyboard_symbols_shift_compressed[];
-extern unsigned int  size_keyboard_letters_compressed;
-extern unsigned char keyboard_letters_compressed[];
-extern unsigned int  size_keyboard_letters_shift_compressed;
-extern unsigned char keyboard_letters_shift_compressed[];
-unsigned char *keyboard_symbols;
-unsigned char *keyboard_symbols_shift;
-unsigned char *keyboard_letters;
-unsigned char *keyboard_letters_shift;
-
-unsigned char kbd_ascii[] = {'1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '-', '=', '[', ']', '\\', ';', '\'', ',', '.', '/', '`'};
-Common::KeyCode  kbd_code[] = {Common::KEYCODE_1, Common::KEYCODE_2, Common::KEYCODE_3, Common::KEYCODE_4, Common::KEYCODE_5, Common::KEYCODE_6, Common::KEYCODE_7, Common::KEYCODE_8, Common::KEYCODE_9, Common::KEYCODE_0, Common::KEYCODE_MINUS, Common::KEYCODE_EQUALS, Common::KEYCODE_LEFTBRACKET, Common::KEYCODE_RIGHTBRACKET,
-							Common::KEYCODE_BACKSLASH, Common::KEYCODE_SEMICOLON, Common::KEYCODE_QUOTE, Common::KEYCODE_COMMA, Common::KEYCODE_PERIOD, Common::KEYCODE_SLASH, Common::KEYCODE_BACKQUOTE};
-unsigned char kbd_ascii_cl[] = {'!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '_', '+', '{', '}', '|', ':', '"', '<', '>', '?', '~'};
-Common::KeyCode  kbd_code_cl[]  = {Common::KEYCODE_EXCLAIM, Common::KEYCODE_AT, Common::KEYCODE_HASH, Common::KEYCODE_DOLLAR, (Common::KeyCode)37, Common::KEYCODE_CARET, Common::KEYCODE_AMPERSAND, Common::KEYCODE_ASTERISK, Common::KEYCODE_LEFTPAREN, Common::KEYCODE_RIGHTPAREN, Common::KEYCODE_UNDERSCORE,
-								Common::KEYCODE_PLUS, (Common::KeyCode)123, (Common::KeyCode)125, (Common::KeyCode)124, Common::KEYCODE_COLON, Common::KEYCODE_QUOTEDBL, Common::KEYCODE_LESS, Common::KEYCODE_GREATER, Common::KEYCODE_QUESTION, (Common::KeyCode)126};
-#define CAPS_LOCK	(1 << 0)
-#define SYMBOLS		(1 << 1)
-
-
-OSystem_PSP_GU::OSystem_PSP_GU() {
-	//sceKernelDcacheWritebackAll();
-
-	// setup
-	sceGuInit();
-	sceGuStart(0, list);
-	sceGuDrawBuffer(GU_PSM_8888, (void *)0, BUF_WIDTH);
-	sceGuDispBuffer(PSP_SCREEN_WIDTH, PSP_SCREEN_HEIGHT, (void*)PSP_FRAME_SIZE, BUF_WIDTH);
-	sceGuDepthBuffer((void*)(PSP_FRAME_SIZE * 2), BUF_WIDTH);
-	sceGuOffset(2048 - (PSP_SCREEN_WIDTH/2), 2048 - (PSP_SCREEN_HEIGHT/2));
-	sceGuViewport(2048, 2048, PSP_SCREEN_WIDTH, PSP_SCREEN_HEIGHT);
-	sceGuDepthRange(0xc350, 0x2710);
-	sceGuScissor(0, 0, PSP_SCREEN_WIDTH, PSP_SCREEN_HEIGHT);
-	sceGuEnable(GU_SCISSOR_TEST);
-	sceGuFrontFace(GU_CW);
-	sceGuEnable(GU_TEXTURE_2D);
-	sceGuClear(GU_COLOR_BUFFER_BIT|GU_DEPTH_BUFFER_BIT);
-	sceGuFinish();
-	sceGuSync(0,0);
-
-	sceDisplayWaitVblankStart();
-	sceGuDisplay(1);
-
-	//decompress keyboard data
-	uLongf kbdSize = KBD_DATA_SIZE;
-	keyboard_letters = (unsigned char *)memalign(16, KBD_DATA_SIZE);
-	if (Z_OK != uncompress((Bytef *)keyboard_letters, &kbdSize, (const Bytef *)keyboard_letters_compressed, size_keyboard_letters_compressed))
-		error("OSystem_PSP_GU: uncompressing keyboard_letters failed");
-
-	kbdSize = KBD_DATA_SIZE;
-	keyboard_letters_shift = (unsigned char *)memalign(16, KBD_DATA_SIZE);
-	if (Z_OK != uncompress((Bytef *)keyboard_letters_shift, &kbdSize, (const Bytef *)keyboard_letters_shift_compressed, size_keyboard_letters_shift_compressed))
-		error("OSystem_PSP_GU: uncompressing keyboard_letters_shift failed");
-
-	kbdSize = KBD_DATA_SIZE;
-	keyboard_symbols = (unsigned char *)memalign(16, KBD_DATA_SIZE);
-	if (Z_OK != uncompress((Bytef *)keyboard_symbols, &kbdSize, (const Bytef *)keyboard_symbols_compressed, size_keyboard_symbols_compressed))
-		error("OSystem_PSP_GU: uncompressing keyboard_symbols failed");
-
-	kbdSize = KBD_DATA_SIZE;
-	keyboard_symbols_shift = (unsigned char *)memalign(16, KBD_DATA_SIZE);
-	if (Z_OK != uncompress((Bytef *)keyboard_symbols_shift, &kbdSize, (const Bytef *)keyboard_symbols_shift_compressed, size_keyboard_symbols_shift_compressed))
-		error("OSystem_PSP_GU: uncompressing keyboard_symbols_shift failed");
-
-	_keyboardVisible = false;
-	_clut = (unsigned short*)(((unsigned int)clut256)|0x40000000);
-	_kbdClut = (unsigned short*)(((unsigned int)kbClut)|0x40000000);
-	_mouseBuf = (byte *)mouseBuf256;
-	_graphicMode = STRETCHED_480X272;
-	_keySelected = 1;
-	_keyboardMode = 0;
-	_mouseX = PSP_SCREEN_WIDTH >> 1;
-	_mouseY = PSP_SCREEN_HEIGHT >> 1;
-}
-
-OSystem_PSP_GU::~OSystem_PSP_GU() {
-	free(keyboard_symbols_shift);
-	free(keyboard_symbols);
-	free(keyboard_letters_shift);
-	free(keyboard_letters);
-
-	_offscreen = 0;
-	_overlayBuffer = 0;
-	_mouseBuf = 0;
-	 sceGuTerm();
-}
-
-void OSystem_PSP_GU::initSize(uint width, uint height) {
-	PSPDebugTrace("initSize\n");
-	_screenWidth = width;
-	_screenHeight = height;
-
-	_overlayWidth = PSP_SCREEN_WIDTH;	//width;
-	_overlayHeight = PSP_SCREEN_HEIGHT;	//height;
-
-//	_offscreen = (byte *)offscreen256;
-	_overlayBuffer = (OverlayColor *)0x44000000 + PSP_FRAME_SIZE;
-
-	_offscreen = (byte *)_overlayBuffer + _overlayWidth * _overlayHeight * sizeof(OverlayColor);
-	bzero(_offscreen, width * height);
-	clearOverlay();
-	memset(_palette, 0xffff, 256 * sizeof(unsigned short));
-	_kbdClut[0] = 0xffff;
-	_kbdClut[246] = 0x4ccc;
-	_kbdClut[247] = 0x0000;
-	for (int i=1;i<31;i++)
-		_kbdClut[i] = 0xf888;
-	_mouseVisible = false;
-	sceKernelDcacheWritebackAll();
-}
-
-int OSystem_PSP_GU::getDefaultGraphicsMode() const {
-	return STRETCHED_480X272;
-}
-
-bool OSystem_PSP_GU::setGraphicsMode(int mode) {
-	_graphicMode = mode;
-	return true;
-}
-
-bool OSystem_PSP_GU::setGraphicsMode(const char *name) {
-	int i = 0;
-
-	while (s_supportedGraphicsModes[i].name) {
-		if (!strcmpi(s_supportedGraphicsModes[i].name, name)) {
-			_graphicMode = s_supportedGraphicsModes[i].id;
-			return true;
-		}
-		i++;
-	}
-
-	return false;
-}
-
-int OSystem_PSP_GU::getGraphicsMode() const {
-	return _graphicMode;
-}
-
-void OSystem_PSP_GU::setMouseCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, byte keycolor, int cursorTargetScale) {
-	//TODO: handle cursorTargetScale
-	_mouseWidth = w;
-	_mouseHeight = h;
-
-	_mouseHotspotX = hotspotX;
-	_mouseHotspotY = hotspotY;
-
-	_mouseKeyColour = keycolor;
-
-	memcpy(mouseClut, _palette, 256*sizeof(unsigned short));
-	mouseClut[_mouseKeyColour] = 0;
-	sceKernelDcacheWritebackAll();
-
-	for (unsigned int i=0;i<h;i++)
-		memcpy(_mouseBuf+i*MOUSE_SIZE, buf+i*w, w);
-}
-
-void OSystem_PSP_GU::setPalette(const byte *colors, uint start, uint num) {
-	const byte *b = colors;
-
-	for (uint i = 0; i < num; ++i) {
-		_palette[start + i] = RGBToColour(b[0], b[1], b[2]);
-		b += 4;
-	}
-
-	//copy to CLUT
-	memcpy(_clut, _palette, 256*sizeof(unsigned short));
-
-	//force update of mouse CLUT as well, as it may have been set up before this palette was set
-	memcpy(mouseClut, _palette, 256*sizeof(unsigned short));
-	mouseClut[_mouseKeyColour] = 0;
-
-	sceKernelDcacheWritebackAll();
-}
-
-
-void OSystem_PSP_GU::copyRectToScreen(const byte *buf, int pitch, int x, int y, int w, int h) {
-	//Clip the coordinates
-	if (x < 0) {
-		w += x;
-		buf -= x;
-		x = 0;
-	}
-
-	if (y < 0) {
-		h += y;
-		buf -= y * pitch;
-		y = 0;
-	}
-
-	if (w > _screenWidth - x) {
-		w = _screenWidth - x;
-	}
-
-	if (h > _screenHeight - y) {
-		h = _screenHeight - y;
-	}
-
-	if (w <= 0 || h <= 0)
-		return;
-
-
-	byte *dst = _offscreen + y * _screenWidth + x;
-
-	if (_screenWidth == pitch && pitch == w)
-	{
-		memcpy(dst, buf, h * w);
-/*
-		sceGuStart(0,list);
-		sceGuCopyImage( 3, 0, 0, w/2, h, w/2, (void *)buf, x/2, y, _screenWidth /2, _offscreen);
-		sceGuFinish();
-		sceGuSync(0,0);
-*/
-	}
-	 else
-	{
-		do
-		{
-			memcpy(dst, buf, w);
-			buf += pitch;
-			dst += _screenWidth;
-		} while (--h);
-	}
-}
-
-void OSystem_PSP_GU::updateScreen() {
-	sceGuStart(0,list);
-
-	sceGuClearColor(0xff000000);
-	sceGuClear(GU_COLOR_BUFFER_BIT);
-
-	sceGuClutMode(GU_PSM_5551, 0, 0xff, 0);
-	sceGuClutLoad(32, clut256); // upload 32*8 entries (256)
-	sceGuTexMode(GU_PSM_T8, 0, 0, 0); // 8-bit image
-	if (_screenWidth == 320)
-			sceGuTexImage(0, 512, 256, _screenWidth, _offscreen);
-	else
-			sceGuTexImage(0, 512, 512, _screenWidth, _offscreen);
-	sceGuTexFunc(GU_TFX_REPLACE, GU_TCC_RGB);
-	sceGuTexFilter(GU_LINEAR, GU_LINEAR);
-	sceGuTexOffset(0,0);
-	sceGuAmbientColor(0xffffffff);
-	sceGuColor(0xffffffff);
-
-	struct Vertex* vertices = (struct Vertex*)sceGuGetMemory(2 * sizeof(struct Vertex));
-	vertices[0].u = 0.5; vertices[0].v = 0.5;
-	vertices[1].u = _screenWidth - 0.5; vertices[1].v = _screenHeight - 0.5;
-	switch(_graphicMode) {
-		case CENTERED_320X200:
-			vertices[0].x = (PSP_SCREEN_WIDTH - 320) / 2; vertices[0].y = (PSP_SCREEN_HEIGHT - 200) / 2; vertices[0].z = 0;
-			vertices[1].x = PSP_SCREEN_WIDTH - (PSP_SCREEN_WIDTH - 320) / 2; vertices[1].y = PSP_SCREEN_HEIGHT - (PSP_SCREEN_HEIGHT - 200) / 2; vertices[1].z = 0;
-		break;
-		case CENTERED_435X272:
-			vertices[0].x = (PSP_SCREEN_WIDTH - 435) / 2; vertices[0].y = 0; vertices[0].z = 0;
-			vertices[1].x = PSP_SCREEN_WIDTH - (PSP_SCREEN_WIDTH - 435) / 2; vertices[1].y = PSP_SCREEN_HEIGHT; vertices[1].z = 0;
-		break;
-		case STRETCHED_480X272:
-			vertices[0].x = 0; vertices[0].y = 0; vertices[0].z = 0;
-			vertices[1].x = PSP_SCREEN_WIDTH; vertices[1].y = PSP_SCREEN_HEIGHT; vertices[1].z = 0;
-		break;
-		case CENTERED_362X272:
-			vertices[0].x = (PSP_SCREEN_WIDTH - 362) / 2; vertices[0].y = 0; vertices[0].z = 0;
-			vertices[1].x = PSP_SCREEN_WIDTH - (PSP_SCREEN_WIDTH - 362) / 2; vertices[1].y = PSP_SCREEN_HEIGHT; vertices[1].z = 0;
-		break;
-	}
-
-	if (_shakePos) {
-		vertices[0].y += _shakePos;
-		vertices[1].y += _shakePos;
-	}
-
-	sceGuDrawArray(GU_SPRITES, GU_TEXTURE_32BITF|GU_VERTEX_32BITF|GU_TRANSFORM_2D, 2, 0, vertices);
-	if (_screenWidth == 640) {
-		sceGuTexImage(0, 512, 512, _screenWidth, _offscreen+512);
-		vertices[0].u = 512 + 0.5; vertices[1].v = _screenHeight - 0.5;
-		vertices[0].x += (vertices[1].x - vertices[0].x) * 511 / 640; vertices[0].y = 0; vertices[0].z = 0;
-		sceGuDrawArray(GU_SPRITES, GU_TEXTURE_32BITF|GU_VERTEX_32BITF|GU_TRANSFORM_2D, 2, 0, vertices);
-	}
-
-
-	// draw overlay
-	if (_overlayVisible) {
-		vertices[0].x = 0; vertices[0].y = 0; vertices[0].z = 0;
-		vertices[1].x = PSP_SCREEN_WIDTH; vertices[1].y = PSP_SCREEN_HEIGHT; vertices[1].z = 0;
-		vertices[0].u = 0.5; vertices[0].v = 0.5;
-		vertices[1].u = _overlayWidth - 0.5; vertices[1].v = _overlayHeight - 0.5;
-		sceGuTexMode(GU_PSM_4444, 0, 0, 0); // 16-bit image
-		sceGuDisable(GU_ALPHA_TEST);
-		sceGuEnable(GU_BLEND);
-
-		//sceGuBlendFunc(GU_ADD, GU_SRC_ALPHA, GU_ONE_MINUS_SRC_ALPHA, 0, 0);
-		sceGuBlendFunc(GU_ADD, GU_FIX, GU_ONE_MINUS_SRC_ALPHA, 0xFFFFFFFF, 0);
-
-		if (_overlayWidth > 320)
-			sceGuTexImage(0, 512, 512, _overlayWidth, _overlayBuffer);
-		else
-			sceGuTexImage(0, 512, 256, _overlayWidth, _overlayBuffer);
-
-		sceGuTexFunc(GU_TFX_REPLACE, GU_TCC_RGBA);
-		sceGuDrawArray(GU_SPRITES,GU_TEXTURE_32BITF|GU_VERTEX_32BITF|GU_TRANSFORM_2D,2,0,vertices);
-		// need to render twice for textures > 512
-		if ( _overlayWidth > 512) {
-			sceGuTexImage(0, 512, 512, _overlayWidth, _overlayBuffer + 512);
-			vertices[0].u = 512 + 0.5; vertices[1].v = _overlayHeight - 0.5;
-			vertices[0].x = PSP_SCREEN_WIDTH * 512 / 640; vertices[0].y = 0; vertices[0].z = 0;
-			sceGuDrawArray(GU_SPRITES, GU_TEXTURE_32BITF|GU_VERTEX_32BITF|GU_TRANSFORM_2D, 2, 0, vertices);
-		}
-		sceGuDisable(GU_BLEND);
-	}
-
-	// draw mouse
-	if (_mouseVisible) {
-		sceGuTexMode(GU_PSM_T8, 0, 0, 0); // 8-bit image
-		sceGuClutMode(GU_PSM_5551, 0, 0xff, 0);
-		sceGuClutLoad(32, mouseClut); // upload 32*8 entries (256)
-		sceGuAlphaFunc(GU_GREATER,0,0xff);
-		sceGuEnable(GU_ALPHA_TEST);
-		sceGuTexImage(0, MOUSE_SIZE, MOUSE_SIZE, MOUSE_SIZE, _mouseBuf);
-		sceGuTexFunc(GU_TFX_MODULATE, GU_TCC_RGBA);
-
-		vertices[0].u = 0.5; vertices[0].v = 0.5;
-		vertices[1].u = _mouseWidth - 0.5; vertices[1].v = _mouseHeight - 0.5;
-
-		//adjust cursor position
-		int mX = _mouseX - _mouseHotspotX;
-		int mY = _mouseY - _mouseHotspotY;
-
-		if (_overlayVisible) {
-			float scalex, scaley;
-
-			scalex = (float)PSP_SCREEN_WIDTH /_overlayWidth;
-			scaley = (float)PSP_SCREEN_HEIGHT /_overlayHeight;
-
-			vertices[0].x = mX * scalex; vertices[0].y = mY * scaley; vertices[0].z = 0;
-			vertices[1].x = vertices[0].x + _mouseWidth * scalex; vertices[1].y = vertices[0].y + _mouseHeight * scaley; vertices[0].z = 0;
-		} else
-			switch(_graphicMode) {
-			case CENTERED_320X200:
-				vertices[0].x = (PSP_SCREEN_WIDTH - 320) / 2 + mX; vertices[0].y = (PSP_SCREEN_HEIGHT - 200) / 2 + mY; vertices[0].z = 0;
-				vertices[1].x = vertices[0].x+_mouseWidth; vertices[1].y = vertices[0].y + _mouseHeight; vertices[1].z = 0;
-			break;
-			case CENTERED_435X272:
-			{
-				float scalex, scaley;
-
-				scalex = 435.0f / _screenWidth;
-				scaley = 272.0f / _screenHeight;
-
-				vertices[0].x = (PSP_SCREEN_WIDTH - 435) / 2 + mX * scalex; vertices[0].y = mY * scaley; vertices[0].z = 0;
-				vertices[1].x = vertices[0].x + _mouseWidth * scalex; vertices[1].y = vertices[0].y + _mouseHeight * scaley; vertices[0].z = 0;
-
-			}
-			break;
-			case CENTERED_362X272:
-			{
-				float scalex, scaley;
-
-				scalex = 362.0f / _screenWidth;
-				scaley = 272.0f / _screenHeight;
-
-				vertices[0].x = (PSP_SCREEN_WIDTH - 362) / 2 + mX * scalex; vertices[0].y = mY * scaley; vertices[0].z = 0;
-				vertices[1].x = vertices[0].x + _mouseWidth * scalex; vertices[1].y = vertices[0].y + _mouseHeight * scaley; vertices[0].z = 0;
-			}
-			break;
-			case STRETCHED_480X272:
-			{
-				float scalex, scaley;
-
-				scalex = (float)PSP_SCREEN_WIDTH / _screenWidth;
-				scaley = (float)PSP_SCREEN_HEIGHT / _screenHeight;
-
-				vertices[0].x = mX * scalex; vertices[0].y = mY * scaley; vertices[0].z = 0;
-				vertices[1].x = vertices[0].x + _mouseWidth * scalex; vertices[1].y = vertices[0].y + _mouseHeight * scaley; vertices[0].z = 0;
-			}
-			break;
-		}
-		sceGuDrawArray(GU_SPRITES, GU_TEXTURE_32BITF|GU_VERTEX_32BITF|GU_TRANSFORM_2D, 2, 0, vertices);
-	}
-
-	if (_keyboardVisible) {
-		sceGuTexMode(GU_PSM_T8, 0, 0, 0); // 8-bit image
-		sceGuClutMode(GU_PSM_4444, 0, 0xff, 0);
-		sceGuClutLoad(32, kbClut); // upload 32*8 entries (256)
-		sceGuDisable(GU_ALPHA_TEST);
-		sceGuEnable(GU_BLEND);
-		sceGuBlendFunc(GU_ADD, GU_SRC_ALPHA, GU_ONE_MINUS_SRC_ALPHA, 0, 0);
-		switch(_keyboardMode) {
-			case 0:
-				sceGuTexImage(0, 512, 512, 480, keyboard_letters);
-				break;
-			case CAPS_LOCK:
-				sceGuTexImage(0, 512, 512, 480, keyboard_letters_shift);
-				break;
-			case SYMBOLS:
-				sceGuTexImage(0, 512, 512, 480, keyboard_symbols);
-				break;
-			case (CAPS_LOCK | SYMBOLS):
-				sceGuTexImage(0, 512, 512, 480, keyboard_symbols_shift);
-				break;
-		}
-		sceGuTexFunc(GU_TFX_REPLACE, GU_TCC_RGBA);
-
-		vertices[0].u = 0.5; vertices[0].v = 0.5;
-		vertices[1].u = PSP_SCREEN_WIDTH-0.5; vertices[1].v = PSP_SCREEN_HEIGHT-0.5;
-		vertices[0].x = 0; vertices[0].y = 0; vertices[0].z = 0;
-		vertices[1].x = PSP_SCREEN_WIDTH; vertices[1].y = PSP_SCREEN_HEIGHT; vertices[0].z = 0;
-		sceGuDrawArray(GU_SPRITES,GU_TEXTURE_32BITF|GU_VERTEX_32BITF|GU_TRANSFORM_2D,2,0,vertices);
-		sceGuDisable(GU_BLEND);
-	}
-	sceKernelDcacheWritebackAll();
-
-	sceGuFinish();
-	sceGuSync(0,0);
-
-	sceDisplayWaitVblankStart();
-	sceGuSwapBuffers();
-
-	//sceKernelDcacheWritebackAll();
-}
-
-bool OSystem_PSP_GU::pollEvent(Common::Event &event) {
-	float nub_angle = -1;
-	int x, y;
-
-	sceCtrlSetSamplingCycle(0);
-	sceCtrlSetSamplingMode(1);
-	sceCtrlReadBufferPositive(&pad, 1);
-
-	uint32 buttonsChanged = pad.Buttons ^ _prevButtons;
-
-	if  ((buttonsChanged & PSP_CTRL_SELECT) || (pad.Buttons & PSP_CTRL_SELECT)) {
-		if ( !(pad.Buttons & PSP_CTRL_SELECT) )
-			_keyboardVisible = !_keyboardVisible;
-		_prevButtons = pad.Buttons;
-		return false;
-	}
-
-	if (!_keyboardVisible)
-		return OSystem_PSP::pollEvent(event);
-
-	if ( (buttonsChanged & PSP_CTRL_RTRIGGER) && !(pad.Buttons & PSP_CTRL_RTRIGGER))
-		_keyboardMode ^= CAPS_LOCK;
-
-	if ( (buttonsChanged & PSP_CTRL_LTRIGGER) && !(pad.Buttons & PSP_CTRL_LTRIGGER))
-		_keyboardMode ^= SYMBOLS;
-
-	if ( (buttonsChanged & PSP_CTRL_LEFT) && !(pad.Buttons & PSP_CTRL_LEFT)) {
-		event.kbd.flags = 0;
-		event.kbd.ascii = 0;
-		event.kbd.keycode = Common::KEYCODE_LEFT;
-		_prevButtons = pad.Buttons;
-		return true;
-	}
-
-	if ( (buttonsChanged & PSP_CTRL_RIGHT) && !(pad.Buttons & PSP_CTRL_RIGHT)) {
-		event.kbd.flags = 0;
-		event.kbd.ascii = 0;
-		event.kbd.keycode = Common::KEYCODE_RIGHT;
-		_prevButtons = pad.Buttons;
-		return true;
-	}
-
-	if ( (buttonsChanged & PSP_CTRL_UP) && !(pad.Buttons & PSP_CTRL_UP)) {
-		event.kbd.flags = 0;
-		event.kbd.ascii = 0;
-		event.kbd.keycode = Common::KEYCODE_UP;
-		_prevButtons = pad.Buttons;
-		return true;
-	}
-
-	if ( (buttonsChanged & PSP_CTRL_DOWN) && !(pad.Buttons & PSP_CTRL_DOWN)) {
-		event.kbd.flags = 0;
-		event.kbd.ascii = 0;
-		event.kbd.keycode = Common::KEYCODE_DOWN;
-		_prevButtons = pad.Buttons;
-		return true;
-	}
-
-	// compute nub direction
-	x = pad.Lx-128;
-	y = pad.Ly-128;
-	_kbdClut[_keySelected] = 0xf888;
-	if (x*x + y*y > 10000) {
-		nub_angle = atan2(y, x);
-		_keySelected = (int)(1 + (M_PI + nub_angle) * 30 / (2 * M_PI));
-		_keySelected -= 2;
-		if (_keySelected < 1)
-			_keySelected += 30;
-		_kbdClut[_keySelected] = 0xffff;
-
-		if  (buttonsChanged & PSP_CTRL_CROSS) {
-			event.type = (pad.Buttons & PSP_CTRL_CROSS) ? Common::EVENT_KEYDOWN : Common::EVENT_KEYUP;
-			if (_keySelected > 26) {
-				event.kbd.flags = 0;
-				switch(_keySelected) {
-					case 27:
-						event.kbd.ascii = ' ';
-						event.kbd.keycode = Common::KEYCODE_SPACE;
-					break;
-					case 28:
-						event.kbd.ascii = 127;
-						event.kbd.keycode = Common::KEYCODE_DELETE;
-					break;
-					case 29:
-						event.kbd.ascii = 8;
-						event.kbd.keycode = Common::KEYCODE_BACKSPACE;
-					break;
-					case 30:
-						event.kbd.ascii = 13;
-						event.kbd.keycode = Common::KEYCODE_RETURN;
-					break;
-				}
-			} else {
-				switch( _keyboardMode) {
-					case 0:
-						event.kbd.flags = 0;
-						event.kbd.ascii = 'a'+_keySelected-1;
-						event.kbd.keycode = (Common::KeyCode)(Common::KEYCODE_a + _keySelected-1);
-						break;
-					case CAPS_LOCK:
-						event.kbd.ascii = 'A'+_keySelected-1;
-						event.kbd.keycode = (Common::KeyCode)(Common::KEYCODE_a + _keySelected-1);
-						event.kbd.flags = Common::KBD_SHIFT;
-						break;
-					case SYMBOLS:
-						if (_keySelected < 21) {
-							event.kbd.flags = 0;
-							event.kbd.ascii = kbd_ascii[_keySelected-1];
-							event.kbd.keycode = kbd_code[ _keySelected-1];
-						}
-						break;
-					case (SYMBOLS|CAPS_LOCK):
-						if (_keySelected < 21) {
-							event.kbd.flags = 0;
-							event.kbd.ascii = kbd_ascii_cl[_keySelected-1];
-							event.kbd.keycode = kbd_code_cl[ _keySelected-1];
-						}
-						break;
-				}
-			}
-			_prevButtons = pad.Buttons;
-			return true;
-		}
-	}
-
-	_prevButtons = pad.Buttons;
-	return false;
-}
-

Deleted: scummvm/branches/gsoc2009-mods/backends/platform/psp/osys_psp_gu.h
===================================================================
--- scummvm/branches/gsoc2009-mods/backends/platform/psp/osys_psp_gu.h	2009-08-24 16:07:46 UTC (rev 43700)
+++ scummvm/branches/gsoc2009-mods/backends/platform/psp/osys_psp_gu.h	2009-08-24 17:51:47 UTC (rev 43701)
@@ -1,59 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- *
- */
-
-#include <pspgu.h>
-#include "common/scummsys.h"
-
-#include "common/rect.h"
-#include "osys_psp.h"
-
-class OSystem_PSP_GU : public OSystem_PSP
-{
-public:
-	struct Vertex
-	{
-		float u,v;
-		float x,y,z;
-	};
-
-	OSystem_PSP_GU();
-	~OSystem_PSP_GU();
-	void updateScreen();
-	void initSize(uint width, uint height);
-	int getDefaultGraphicsMode() const;
-	bool setGraphicsMode(int mode);
-	bool setGraphicsMode(const char *name);
-	int getGraphicsMode() const;
-	void setMouseCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, byte keycolor, int cursorTargetScale);
-	void copyRectToScreen(const byte *buf, int pitch, int x, int y, int w, int h) ;
-	void setPalette(const byte *colors, uint start, uint num);
-	bool pollEvent(Common::Event &event);
-	int _graphicMode;
-	struct Vertex *_vertices;
-	unsigned short* _clut;
-	unsigned short* _kbdClut;
-	bool _keyboardVisible;
-	int _keySelected;
-	int _keyboardMode;
-};
-

Modified: scummvm/branches/gsoc2009-mods/backends/platform/psp/psp.mk
===================================================================
--- scummvm/branches/gsoc2009-mods/backends/platform/psp/psp.mk	2009-08-24 16:07:46 UTC (rev 43700)
+++ scummvm/branches/gsoc2009-mods/backends/platform/psp/psp.mk	2009-08-24 17:51:47 UTC (rev 43701)
@@ -9,7 +9,7 @@
 PSP_EBOOT_TITLE = ScummVM-PSP
 DATE = $(shell date +%Y%m%d)
 
-MKSFO = mksfo
+MKSFO = mksfoex -d MEMSIZE=1
 PACK_PBP = pack-pbp
 
 $(PSP_EXE_STRIPPED): $(PSP_EXE)

Modified: scummvm/branches/gsoc2009-mods/backends/platform/psp/psp.spec
===================================================================
--- scummvm/branches/gsoc2009-mods/backends/platform/psp/psp.spec	2009-08-24 16:07:46 UTC (rev 43700)
+++ scummvm/branches/gsoc2009-mods/backends/platform/psp/psp.spec	2009-08-24 17:51:47 UTC (rev 43701)
@@ -1,3 +1,3 @@
 %rename lib	old_lib
 *lib:
-%(old_lib) -lpspdebug -lpspgu -lpspctrl -lpspge -lpspdisplay -lpsphprm -lpspsdk -lpsprtc -lpspaudio -lc -lpspuser -lpsputility -lpspkernel -lpspnet_inet -lz -lstdc++ -lc -lpspdisplay -lpspgu -lpspctrl -lpspsdk -lpspnet -lpspnet_inet -lpsputility -lpspsdk -lpspuser 
+%(old_lib) -lpspdebug -lpspgu -lpspctrl -lpspge -lpspdisplay -lpsphprm -lpspsdk -lpsprtc -lpspaudio -lc -lpspuser -lpsputility -lpspkernel -lpspnet_inet -lz -lstdc++ -lc -lpspdisplay -lpspgu -lpspctrl -lpspsdk -lpspnet -lpspnet_inet -lpsputility -lpspuser -lpsppower 

Modified: scummvm/branches/gsoc2009-mods/backends/platform/psp/psp_main.cpp
===================================================================
--- scummvm/branches/gsoc2009-mods/backends/platform/psp/psp_main.cpp	2009-08-24 16:07:46 UTC (rev 43700)
+++ scummvm/branches/gsoc2009-mods/backends/platform/psp/psp_main.cpp	2009-08-24 17:51:47 UTC (rev 43701)
@@ -31,12 +31,16 @@
 #include <pspdebug.h>
 #endif
 
+#include <psppower.h>
+
 #include <common/system.h>
 #include <engines/engine.h>
 #include <base/main.h>
 #include <base/plugins.h>
+#include "backends/platform/psp/powerman.h"
 
-#include "osys_psp_gu.h"
+
+#include "osys_psp.h"
 #include "./trace.h"
 
 
@@ -58,9 +62,8 @@
  * code (crt0.c) starts this program in to be in usermode
  * even though the module was started in kernelmode
  */
-#ifndef USERSPACE_ONLY
 PSP_MAIN_THREAD_ATTR(THREAD_ATTR_USER | THREAD_ATTR_VFPU);
-#endif
+PSP_HEAP_SIZE_KB(-128);	//Leave 128kb for thread stacks, etc.
 
 
 #ifndef USERSPACE_ONLY
@@ -91,18 +94,37 @@
 #endif
 
 /* Exit callback */
-SceKernelCallbackFunction exit_callback(int /*arg1*/, int /*arg2*/, void * /*common*/) {
+int exit_callback(void) {
 	sceKernelExitGame();
 	return 0;
 }
 
+/* Function for handling suspend/resume */
+void power_callback(int , int powerinfo) {
+	if (powerinfo & PSP_POWER_CB_POWER_SWITCH || powerinfo & PSP_POWER_CB_SUSPENDING) {
+		PowerMan.suspend();
+	} else if (powerinfo & PSP_POWER_CB_RESUME_COMPLETE) {
+		PowerMan.resume();
+	}
+}
+
 /* Callback thread */
 int CallbackThread(SceSize /*size*/, void *arg) {
 	int cbid;
 
 	cbid = sceKernelCreateCallback("Exit Callback", (SceKernelCallbackFunction)exit_callback, NULL);
 	sceKernelRegisterExitCallback(cbid);
+	/* Set up callbacks for PSPIoStream */
 
+	cbid = sceKernelCreateCallback("Power Callback", (SceKernelCallbackFunction)power_callback, 0);
+	if (cbid >= 0) {
+		if(scePowerRegisterCallback(-1, cbid) < 0) {
+			PSPDebugTrace("SetupCallbacks(): Couldn't register callback for power_callback\n");
+		}
+	} else {
+		PSPDebugTrace("SetupCallbacks(): Couldn't create a callback for power_callback\n");
+	}
+
 	sceKernelSleepThreadCB();
 	return 0;
 }
@@ -119,18 +141,25 @@
 
 #undef main
 int main(void) {
+	//change clock rate to 333mhz
+	scePowerSetClockFrequency(333, 333, 166);
+
+	PowerManager::instance();	// Setup power manager
+
 	SetupCallbacks();
 
 	static const char *argv[] = { "scummvm", NULL };
 	static int argc = sizeof(argv)/sizeof(char *)-1;
 
-	g_system = new OSystem_PSP_GU();
+	g_system = new OSystem_PSP();
 	assert(g_system);
 
 	int res = scummvm_main(argc, argv);
 
 	g_system->quit();	// TODO: Consider removing / replacing this!
 
+	PowerManager::destroy();	// get rid of PowerManager
+
 	sceKernelSleepThread();
 
 	return res;

Modified: scummvm/branches/gsoc2009-mods/backends/platform/sdl/events.cpp
===================================================================
--- scummvm/branches/gsoc2009-mods/backends/platform/sdl/events.cpp	2009-08-24 16:07:46 UTC (rev 43700)
+++ scummvm/branches/gsoc2009-mods/backends/platform/sdl/events.cpp	2009-08-24 17:51:47 UTC (rev 43701)
@@ -186,6 +186,8 @@
 	}
 
 	while (SDL_PollEvent(&ev)) {
+		preprocessEvents(&ev);
+
 		switch (ev.type) {
 		case SDL_KEYDOWN:{
 			b = event.kbd.flags = SDLModToOSystemKeyFlags(SDL_GetModState());

Modified: scummvm/branches/gsoc2009-mods/backends/platform/sdl/graphics.cpp
===================================================================
--- scummvm/branches/gsoc2009-mods/backends/platform/sdl/graphics.cpp	2009-08-24 16:07:46 UTC (rev 43700)
+++ scummvm/branches/gsoc2009-mods/backends/platform/sdl/graphics.cpp	2009-08-24 17:51:47 UTC (rev 43701)
@@ -26,6 +26,9 @@
 #include "backends/platform/sdl/sdl.h"
 #include "common/mutex.h"
 #include "common/util.h"
+#ifdef USE_RGB_COLOR
+#include "common/list.h"
+#endif
 #include "graphics/font.h"
 #include "graphics/fontman.h"
 #include "graphics/scaler.h"
@@ -97,6 +100,9 @@
 	_transactionDetails.needUpdatescreen = false;
 
 	_transactionDetails.normal1xScaler = false;
+#ifdef USE_RGB_COLOR
+	_transactionDetails.formatChanged = false;
+#endif
 
 	_oldVideoMode = _videoMode;
 }
@@ -120,6 +126,13 @@
 
 			_videoMode.mode = _oldVideoMode.mode;
 			_videoMode.scaleFactor = _oldVideoMode.scaleFactor;
+#ifdef USE_RGB_COLOR
+		} else if (_videoMode.format != _oldVideoMode.format) {
+			errors |= kTransactionFormatNotSupported;
+
+			_videoMode.format = _oldVideoMode.format;
+			_screenFormat = _videoMode.format;
+#endif
 		} else if (_videoMode.screenWidth != _oldVideoMode.screenWidth || _videoMode.screenHeight != _oldVideoMode.screenHeight) {
 			errors |= kTransactionSizeChangeFailed;
 
@@ -143,7 +156,11 @@
 		}
 	}
 
+#ifdef USE_RGB_COLOR
+	if (_transactionDetails.sizeChanged || _transactionDetails.formatChanged) {
+#else
 	if (_transactionDetails.sizeChanged) {
+#endif
 		unloadGFXMode();
 		if (!loadGFXMode()) {
 			if (_oldVideoMode.setup) {
@@ -186,12 +203,94 @@
 	} else if (_transactionDetails.needUpdatescreen) {
 		setGraphicsModeIntern();
 		internUpdateScreen();
-	}
+	} 
 
 	_transactionMode = kTransactionNone;
 	return (TransactionError)errors;
 }
 
+#ifdef USE_RGB_COLOR
+const Graphics::PixelFormat RGBList[] = {
+#ifdef ENABLE_32BIT
+	// RGBA8888, ARGB8888, RGB888
+	Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8, 0),
+	Graphics::PixelFormat(4, 8, 8, 8, 8, 16, 8, 0, 24),
+	Graphics::PixelFormat(3, 8, 8, 8, 0, 16, 8, 0, 0),
+#endif
+	// RGB565, XRGB1555, RGB555, RGBA4444, ARGB4444
+	Graphics::PixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0),
+	Graphics::PixelFormat(2, 5, 5, 5, 1, 10, 5, 0, 15),
+	Graphics::PixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0),
+	Graphics::PixelFormat(2, 4, 4, 4, 4, 12, 8, 4, 0),
+	Graphics::PixelFormat(2, 4, 4, 4, 4, 8, 4, 0, 12)
+};
+const Graphics::PixelFormat BGRList[] = {
+#ifdef ENABLE_32BIT
+	// ABGR8888, BGRA8888, BGR888
+	Graphics::PixelFormat(4, 8, 8, 8, 8, 0, 8, 16, 24),
+	Graphics::PixelFormat(4, 8, 8, 8, 8, 8, 16, 24, 0),
+	Graphics::PixelFormat(3, 8, 8, 8, 0, 0, 8, 16, 0),
+#endif
+	// BGR565, XBGR1555, BGR555, ABGR4444, BGRA4444
+	Graphics::PixelFormat(2, 5, 6, 5, 0, 0, 5, 11, 0),
+	Graphics::PixelFormat(2, 5, 5, 5, 1, 0, 5, 10, 15),
+	Graphics::PixelFormat(2, 5, 5, 5, 0, 0, 5, 10, 0),
+	Graphics::PixelFormat(2, 4, 4, 4, 4, 0, 4, 8, 12),
+	Graphics::PixelFormat(2, 4, 4, 4, 4, 4, 8, 12, 0)
+};
+
+// TODO: prioritize matching alpha masks
+Common::List<Graphics::PixelFormat> OSystem_SDL::getSupportedFormats() {
+	static Common::List<Graphics::PixelFormat> list;
+	static bool inited = false;
+
+	if (inited)
+		return list;
+
+	bool BGR = false;
+	int listLength = ARRAYSIZE(RGBList);
+
+	Graphics::PixelFormat format = Graphics::PixelFormat::createFormatCLUT8();
+	if (_hwscreen) {
+		// Get our currently set hardware format
+		format = Graphics::PixelFormat(_hwscreen->format->BytesPerPixel, 
+			8 - _hwscreen->format->Rloss, 8 - _hwscreen->format->Gloss, 
+			8 - _hwscreen->format->Bloss, 8 - _hwscreen->format->Aloss, 
+			_hwscreen->format->Rshift, _hwscreen->format->Gshift, 
+			_hwscreen->format->Bshift, _hwscreen->format->Ashift);
+
+		// Workaround to MacOSX SDL not providing an accurate Aloss value.
+		if (_hwscreen->format->Amask == 0)
+			format.aLoss = 8;
+
+		// Push it first, as the prefered format.
+		list.push_back(format);
+
+		if (format.bShift > format.rShift)
+			BGR = true;
+
+		// Mark that we don't need to do this any more.
+		inited = true;
+	}
+
+	for (int i = 0; i < listLength; i++) {
+		if (inited && (RGBList[i].bytesPerPixel > format.bytesPerPixel))
+			continue;
+		if (BGR) {
+			if (BGRList[i] != format)
+				list.push_back(BGRList[i]);
+			list.push_back(RGBList[i]);
+		} else {
+			if (RGBList[i] != format)
+				list.push_back(RGBList[i]);
+			list.push_back(BGRList[i]);
+		}
+	}
+	list.push_back(Graphics::PixelFormat::createFormatCLUT8());
+	return list;
+}
+#endif
+
 bool OSystem_SDL::setGraphicsMode(int mode) {
 	Common::StackLock lock(_graphicsMutex);
 
@@ -340,9 +439,27 @@
 	return _videoMode.mode;
 }
 
-void OSystem_SDL::initSize(uint w, uint h) {
+void OSystem_SDL::initSize(uint w, uint h, const Graphics::PixelFormat *format) {
 	assert(_transactionMode == kTransactionActive);
 
+#ifdef USE_RGB_COLOR
+	//avoid redundant format changes
+	Graphics::PixelFormat newFormat;
+	if (!format)
+		newFormat = Graphics::PixelFormat::createFormatCLUT8();
+	else
+		newFormat = *format;
+
+	assert(newFormat.bytesPerPixel > 0);
+
+	if (newFormat != _videoMode.format)
+	{
+		_videoMode.format = newFormat;
+		_transactionDetails.formatChanged = true;
+		_screenFormat = newFormat;
+	}
+#endif
+
 	// Avoid redundant res changes
 	if ((int)w == _videoMode.screenWidth && (int)h == _videoMode.screenHeight)
 		return;
@@ -426,9 +543,21 @@
 	//
 	// Create the surface that contains the 8 bit game data
 	//
+#ifdef USE_RGB_COLOR
+	_screen = SDL_CreateRGBSurface(SDL_SWSURFACE, _videoMode.screenWidth, _videoMode.screenHeight, 
+						_screenFormat.bytesPerPixel << 3, 
+						((1 << _screenFormat.rBits()) - 1) << _screenFormat.rShift ,
+						((1 << _screenFormat.gBits()) - 1) << _screenFormat.gShift ,
+						((1 << _screenFormat.bBits()) - 1) << _screenFormat.bShift ,
+						((1 << _screenFormat.aBits()) - 1) << _screenFormat.aShift );
+	if (_screen == NULL)
+		error("allocating _screen failed");
+
+#else
 	_screen = SDL_CreateRGBSurface(SDL_SWSURFACE, _videoMode.screenWidth, _videoMode.screenHeight, 8, 0, 0, 0, 0);
 	if (_screen == NULL)
 		error("allocating _screen failed");
+#endif
 
 	//
 	// Create the surface that contains the scaled graphics in 16 bit mode
@@ -571,8 +700,8 @@
 	// Keep around the old _screen & _overlayscreen so we can restore the screen data
 	// after the mode switch.
 	SDL_Surface *old_screen = _screen;
+	_screen = NULL;
 	SDL_Surface *old_overlayscreen = _overlayscreen;
-	_screen = NULL;
 	_overlayscreen = NULL;
 
 	// Release the HW screen surface
@@ -846,30 +975,6 @@
 		 * and just updates those, on the actual display. */
 		addDirtyRgnAuto(src);
 	} else {
-		/* Clip the coordinates */
-		if (x < 0) {
-			w += x;
-			src -= x;
-			x = 0;
-		}
-
-		if (y < 0) {
-			h += y;
-			src -= y * pitch;
-			y = 0;
-		}
-
-		if (w > _videoMode.screenWidth - x) {
-			w = _videoMode.screenWidth - x;
-		}
-
-		if (h > _videoMode.screenHeight - y) {
-			h = _videoMode.screenHeight - y;
-		}
-
-		if (w <= 0 || h <= 0)
-			return;
-
 		_cksumValid = false;
 		addDirtyRect(x, y, w, h);
 	}
@@ -878,8 +983,19 @@
 	if (SDL_LockSurface(_screen) == -1)
 		error("SDL_LockSurface failed: %s", SDL_GetError());
 
+#ifdef USE_RGB_COLOR
+	byte *dst = (byte *)_screen->pixels + y * _videoMode.screenWidth * _screenFormat.bytesPerPixel + x * _screenFormat.bytesPerPixel;
+	if (_videoMode.screenWidth == w && pitch == w * _screenFormat.bytesPerPixel) {
+		memcpy(dst, src, h*w*_screenFormat.bytesPerPixel);
+	} else {
+		do {
+			memcpy(dst, src, w * _screenFormat.bytesPerPixel);
+			src += pitch;
+			dst += _videoMode.screenWidth * _screenFormat.bytesPerPixel;
+		} while (--h);
+	}
+#else
 	byte *dst = (byte *)_screen->pixels + y * _videoMode.screenWidth + x;
-
 	if (_videoMode.screenWidth == pitch && pitch == w) {
 		memcpy(dst, src, h*w);
 	} else {
@@ -889,6 +1005,7 @@
 			dst += _videoMode.screenWidth;
 		} while (--h);
 	}
+#endif
 
 	// Unlock the screen surface
 	SDL_UnlockSurface(_screen);
@@ -912,7 +1029,11 @@
 	_framebuffer.w = _screen->w;
 	_framebuffer.h = _screen->h;
 	_framebuffer.pitch = _screen->pitch;
+#ifdef USE_RGB_COLOR
+	_framebuffer.bytesPerPixel = _screenFormat.bytesPerPixel;
+#else
 	_framebuffer.bytesPerPixel = 1;
+#endif
 
 	return &_framebuffer;
 }
@@ -1096,6 +1217,11 @@
 void OSystem_SDL::setPalette(const byte *colors, uint start, uint num) {
 	assert(colors);
 
+#ifdef USE_RGB_COLOR
+	if (_screenFormat.bytesPerPixel > 1)
+		return; //not using a paletted pixel format
+#endif
+
 	// Setting the palette before _screen is created is allowed - for now -
 	// since we don't actually set the palette until the screen is updated.
 	// But it could indicate a programming error, so let's warn about it.
@@ -1149,10 +1275,10 @@
 	}
 
 	_cursorPaletteDisabled = false;
-
 	blitCursor();
 }
 
+
 void OSystem_SDL::setShakePos(int shake_pos) {
 	assert (_transactionMode == kTransactionNone);
 
@@ -1357,7 +1483,17 @@
 	}
 }
 
-void OSystem_SDL::setMouseCursor(const byte *buf, uint w, uint h, int hotspot_x, int hotspot_y, byte keycolor, int cursorTargetScale) {
+void OSystem_SDL::setMouseCursor(const byte *buf, uint w, uint h, int hotspot_x, int hotspot_y, uint32 keycolor, int cursorTargetScale, const Graphics::PixelFormat *format) {
+#ifdef USE_RGB_COLOR
+	if (!format)
+		_cursorFormat = Graphics::PixelFormat::createFormatCLUT8();
+	else if (format->bytesPerPixel <= _screenFormat.bytesPerPixel)
+		_cursorFormat = *format;
+	keycolor &= (1 << (_cursorFormat.bytesPerPixel << 3)) - 1;
+#else
+	keycolor &= 0xFF;
+#endif
+
 	if (w == 0 || h == 0)
 		return;
 
@@ -1391,16 +1527,26 @@
 	}
 
 	free(_mouseData);
-
+#ifdef USE_RGB_COLOR
+	_mouseData = (byte *)malloc(w * h * _cursorFormat.bytesPerPixel);
+	memcpy(_mouseData, buf, w * h * _cursorFormat.bytesPerPixel);
+#else
 	_mouseData = (byte *)malloc(w * h);
 	memcpy(_mouseData, buf, w * h);
+#endif
+
 	blitCursor();
 }
 
 void OSystem_SDL::blitCursor() {
 	byte *dstPtr;
 	const byte *srcPtr = _mouseData;
+#ifdef USE_RGB_COLOR
+	uint32 color;
+	uint32 colormask = (1 << (_cursorFormat.bytesPerPixel << 3)) - 1;
+#else
 	byte color;
+#endif
 	int w, h, i, j;
 
 	if (!_mouseOrigSurface || !_mouseData)
@@ -1434,13 +1580,29 @@
 
 	for (i = 0; i < h; i++) {
 		for (j = 0; j < w; j++) {
-			color = *srcPtr;
-			if (color != _mouseKeyColor) {	// transparent, don't draw
-				*(uint16 *)dstPtr = SDL_MapRGB(_mouseOrigSurface->format,
-					palette[color].r, palette[color].g, palette[color].b);
+#ifdef USE_RGB_COLOR
+			if (_cursorFormat.bytesPerPixel > 1) {
+				color = (*(uint32 *) srcPtr) & colormask;
+				if (color != _mouseKeyColor) {	// transparent, don't draw
+					uint8 r,g,b;
+					_cursorFormat.colorToRGB(color,r,g,b);
+					*(uint16 *)dstPtr = SDL_MapRGB(_mouseOrigSurface->format,
+						r, g, b);
+				}
+				dstPtr += 2;
+				srcPtr += _cursorFormat.bytesPerPixel;
+			} else {
+#endif
+				color = *srcPtr;
+				if (color != _mouseKeyColor) {	// transparent, don't draw
+					*(uint16 *)dstPtr = SDL_MapRGB(_mouseOrigSurface->format,
+						palette[color].r, palette[color].g, palette[color].b);
+				}
+				dstPtr += 2;
+				srcPtr++;
+#ifdef USE_RGB_COLOR
 			}
-			dstPtr += 2;
-			srcPtr++;
+#endif
 		}
 		dstPtr += _mouseOrigSurface->pitch - w * 2;
 	}

Modified: scummvm/branches/gsoc2009-mods/backends/platform/sdl/main.cpp
===================================================================
--- scummvm/branches/gsoc2009-mods/backends/platform/sdl/main.cpp	2009-08-24 16:07:46 UTC (rev 43700)
+++ scummvm/branches/gsoc2009-mods/backends/platform/sdl/main.cpp	2009-08-24 17:51:47 UTC (rev 43701)
@@ -37,7 +37,7 @@
 #include "SymbianOs.h"
 #endif
 
-#if !defined(__MAEMO__) && !defined(_WIN32_WCE) && !defined(GP2XWIZ)
+#if !defined(__MAEMO__) && !defined(_WIN32_WCE) && !defined(GP2XWIZ)&& !defined(LINUXMOTO)
 
 #if defined (WIN32)
 int __stdcall WinMain(HINSTANCE /*hInst*/, HINSTANCE /*hPrevInst*/,  LPSTR /*lpCmdLine*/, int /*iShowCmd*/) {

Modified: scummvm/branches/gsoc2009-mods/backends/platform/sdl/sdl.cpp
===================================================================
--- scummvm/branches/gsoc2009-mods/backends/platform/sdl/sdl.cpp	2009-08-24 16:07:46 UTC (rev 43700)
+++ scummvm/branches/gsoc2009-mods/backends/platform/sdl/sdl.cpp	2009-08-24 17:51:47 UTC (rev 43701)
@@ -222,6 +222,10 @@
 	_osdSurface(0), _osdAlpha(SDL_ALPHA_TRANSPARENT), _osdFadeStartTime(0),
 #endif
 	_hwscreen(0), _screen(0), _tmpscreen(0),
+#ifdef USE_RGB_COLOR
+	_screenFormat(Graphics::PixelFormat::createFormatCLUT8()),
+	_cursorFormat(Graphics::PixelFormat::createFormatCLUT8()),
+#endif
 	_overlayVisible(false),
 	_overlayscreen(0), _tmpscreen2(0),
 	_samplesPerSec(0),
@@ -691,7 +695,6 @@
 
 void OSystem_SDL::setupMixer() {
 	SDL_AudioSpec desired;
-	SDL_AudioSpec obtained;
 
 	// Determine the desired output sampling frequency.
 	_samplesPerSec = 0;
@@ -721,7 +724,7 @@
 	_mixer = new Audio::MixerImpl(this);
 	assert(_mixer);
 
-	if (SDL_OpenAudio(&desired, &obtained) != 0) {
+	if (SDL_OpenAudio(&desired, &_obtainedRate) != 0) {
 		warning("Could not open audio device: %s", SDL_GetError());
 		_samplesPerSec = 0;
 		_mixer->setReady(false);
@@ -729,7 +732,7 @@
 		// Note: This should be the obtained output rate, but it seems that at
 		// least on some platforms SDL will lie and claim it did get the rate
 		// even if it didn't. Probably only happens for "weird" rates, though.
-		_samplesPerSec = obtained.freq;
+		_samplesPerSec = _obtainedRate.freq;
 		debug(1, "Output sample rate: %d Hz", _samplesPerSec);
 
 		// Tell the mixer that we are ready and start the sound processing
@@ -737,7 +740,7 @@
 		_mixer->setReady(true);
 
 #ifdef MIXER_DOUBLE_BUFFERING
-		initThreadedMixer(_mixer, obtained.samples * 4);
+		initThreadedMixer(_mixer, _obtainedRate.samples * 4);
 #endif
 
 		// start the sound system

Modified: scummvm/branches/gsoc2009-mods/backends/platform/sdl/sdl.h
===================================================================
--- scummvm/branches/gsoc2009-mods/backends/platform/sdl/sdl.h	2009-08-24 16:07:46 UTC (rev 43700)
+++ scummvm/branches/gsoc2009-mods/backends/platform/sdl/sdl.h	2009-08-24 17:51:47 UTC (rev 43701)
@@ -93,10 +93,18 @@
 	void beginGFXTransaction(void);
 	TransactionError endGFXTransaction(void);
 
-	// Set the size of the video bitmap.
-	// Typically, 320x200
-	virtual void initSize(uint w, uint h); // overloaded by CE backend
+#ifdef USE_RGB_COLOR
+	// Game screen
+	virtual Graphics::PixelFormat getScreenFormat() const { return _screenFormat; }
 
+	// Highest supported
+	virtual Common::List<Graphics::PixelFormat> getSupportedFormats();
+#endif
+
+	// Set the size and format of the video bitmap.
+	// Typically, 320x200 CLUT8
+	virtual void initSize(uint w, uint h, const Graphics::PixelFormat *format); // overloaded by CE backend
+
 	virtual int getScreenChangeID() const { return _screenChangeCount; }
 
 	// Set colors of the palette
@@ -124,7 +132,7 @@
 	virtual void warpMouse(int x, int y); // overloaded by CE backend (FIXME)
 
 	// Set the bitmap that's used when drawing the cursor.
-	virtual void setMouseCursor(const byte *buf, uint w, uint h, int hotspot_x, int hotspot_y, byte keycolor, int cursorTargetScale); // overloaded by CE backend (FIXME)
+	virtual void setMouseCursor(const byte *buf, uint w, uint h, int hotspot_x, int hotspot_y, uint32 keycolor, int cursorTargetScale, const Graphics::PixelFormat *format); // overloaded by CE backend (FIXME)
 
 	// Set colors of cursor palette
 	void setCursorPalette(const byte *colors, uint start, uint num);
@@ -186,6 +194,7 @@
 
 	// Overlay
 	virtual Graphics::PixelFormat getOverlayFormat() const { return _overlayFormat; }
+
 	virtual void showOverlay();
 	virtual void hideOverlay();
 	virtual void clearOverlay();
@@ -207,6 +216,7 @@
 	virtual bool hasFeature(Feature f);

@@ Diff output truncated at 100000 characters. @@

This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list