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

nolange at users.sourceforge.net nolange at users.sourceforge.net
Fri Jul 17 23:23:56 CEST 2009


Revision: 42574
          http://scummvm.svn.sourceforge.net/scummvm/?rev=42574&view=rev
Author:   nolange
Date:     2009-07-17 21:23:54 +0000 (Fri, 17 Jul 2009)

Log Message:
-----------
merge with trunk

Modified Paths:
--------------
    scummvm/branches/gsoc2009-mods/AUTHORS
    scummvm/branches/gsoc2009-mods/Makefile
    scummvm/branches/gsoc2009-mods/NEWS
    scummvm/branches/gsoc2009-mods/README
    scummvm/branches/gsoc2009-mods/backends/events/default/default-events.h
    scummvm/branches/gsoc2009-mods/backends/midi/timidity.cpp
    scummvm/branches/gsoc2009-mods/backends/platform/dc/dc.h
    scummvm/branches/gsoc2009-mods/backends/platform/dc/display.cpp
    scummvm/branches/gsoc2009-mods/backends/platform/dc/input.cpp
    scummvm/branches/gsoc2009-mods/backends/platform/ds/arm7/Makefile
    scummvm/branches/gsoc2009-mods/backends/platform/iphone/module.mk
    scummvm/branches/gsoc2009-mods/backends/platform/ps2/Gs2dScreen.cpp
    scummvm/branches/gsoc2009-mods/backends/platform/ps2/Gs2dScreen.h
    scummvm/branches/gsoc2009-mods/backends/platform/ps2/Makefile.ps2
    scummvm/branches/gsoc2009-mods/backends/platform/ps2/fileio.cpp
    scummvm/branches/gsoc2009-mods/backends/platform/ps2/fileio.h
    scummvm/branches/gsoc2009-mods/backends/platform/ps2/irxboot.cpp
    scummvm/branches/gsoc2009-mods/backends/platform/ps2/ps2input.cpp
    scummvm/branches/gsoc2009-mods/backends/platform/ps2/savefilemgr.cpp
    scummvm/branches/gsoc2009-mods/backends/platform/ps2/systemps2.cpp
    scummvm/branches/gsoc2009-mods/backends/platform/ps2/systemps2.h
    scummvm/branches/gsoc2009-mods/backends/platform/symbian/src/SymbianActions.cpp
    scummvm/branches/gsoc2009-mods/backends/platform/symbian/src/SymbianOS.cpp
    scummvm/branches/gsoc2009-mods/backends/platform/symbian/src/SymbianOS.h
    scummvm/branches/gsoc2009-mods/backends/platform/wince/CEScaler.cpp
    scummvm/branches/gsoc2009-mods/backends/platform/wince/Makefile
    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/saves/default/default-saves.cpp
    scummvm/branches/gsoc2009-mods/base/internal_version.h
    scummvm/branches/gsoc2009-mods/base/main.cpp
    scummvm/branches/gsoc2009-mods/common/array.h
    scummvm/branches/gsoc2009-mods/common/events.h
    scummvm/branches/gsoc2009-mods/common/hashmap.h
    scummvm/branches/gsoc2009-mods/common/system.h
    scummvm/branches/gsoc2009-mods/common/util.cpp
    scummvm/branches/gsoc2009-mods/common/util.h
    scummvm/branches/gsoc2009-mods/common/xmlparser.cpp
    scummvm/branches/gsoc2009-mods/configure
    scummvm/branches/gsoc2009-mods/dists/iphone/scummvm.xcodeproj/project.pbxproj
    scummvm/branches/gsoc2009-mods/dists/msvc8/agi.vcproj
    scummvm/branches/gsoc2009-mods/dists/msvc8/agos.vcproj
    scummvm/branches/gsoc2009-mods/dists/msvc8/cine.vcproj
    scummvm/branches/gsoc2009-mods/dists/msvc8/cruise.vcproj
    scummvm/branches/gsoc2009-mods/dists/msvc8/drascula.vcproj
    scummvm/branches/gsoc2009-mods/dists/msvc8/gob.vcproj
    scummvm/branches/gsoc2009-mods/dists/msvc8/groovie.vcproj
    scummvm/branches/gsoc2009-mods/dists/msvc8/igor.vcproj
    scummvm/branches/gsoc2009-mods/dists/msvc8/kyra.vcproj
    scummvm/branches/gsoc2009-mods/dists/msvc8/lure.vcproj
    scummvm/branches/gsoc2009-mods/dists/msvc8/m4.vcproj
    scummvm/branches/gsoc2009-mods/dists/msvc8/made.vcproj
    scummvm/branches/gsoc2009-mods/dists/msvc8/parallaction.vcproj
    scummvm/branches/gsoc2009-mods/dists/msvc8/queen.vcproj
    scummvm/branches/gsoc2009-mods/dists/msvc8/saga.vcproj
    scummvm/branches/gsoc2009-mods/dists/msvc8/sci.vcproj
    scummvm/branches/gsoc2009-mods/dists/msvc8/scumm.vcproj
    scummvm/branches/gsoc2009-mods/dists/msvc8/scummvm.sln
    scummvm/branches/gsoc2009-mods/dists/msvc8/scummvm.vcproj
    scummvm/branches/gsoc2009-mods/dists/msvc8/sky.vcproj
    scummvm/branches/gsoc2009-mods/dists/msvc8/sword1.vcproj
    scummvm/branches/gsoc2009-mods/dists/msvc8/sword2.vcproj
    scummvm/branches/gsoc2009-mods/dists/msvc8/tinsel.vcproj
    scummvm/branches/gsoc2009-mods/dists/msvc8/touche.vcproj
    scummvm/branches/gsoc2009-mods/dists/msvc8/tucker.vcproj
    scummvm/branches/gsoc2009-mods/dists/msvc8_to_msvc9.bat
    scummvm/branches/gsoc2009-mods/dists/msvc9/agi.vcproj
    scummvm/branches/gsoc2009-mods/dists/msvc9/agos.vcproj
    scummvm/branches/gsoc2009-mods/dists/msvc9/cine.vcproj
    scummvm/branches/gsoc2009-mods/dists/msvc9/cruise.vcproj
    scummvm/branches/gsoc2009-mods/dists/msvc9/drascula.vcproj
    scummvm/branches/gsoc2009-mods/dists/msvc9/gob.vcproj
    scummvm/branches/gsoc2009-mods/dists/msvc9/groovie.vcproj
    scummvm/branches/gsoc2009-mods/dists/msvc9/igor.vcproj
    scummvm/branches/gsoc2009-mods/dists/msvc9/kyra.vcproj
    scummvm/branches/gsoc2009-mods/dists/msvc9/lure.vcproj
    scummvm/branches/gsoc2009-mods/dists/msvc9/m4.vcproj
    scummvm/branches/gsoc2009-mods/dists/msvc9/made.vcproj
    scummvm/branches/gsoc2009-mods/dists/msvc9/parallaction.vcproj
    scummvm/branches/gsoc2009-mods/dists/msvc9/queen.vcproj
    scummvm/branches/gsoc2009-mods/dists/msvc9/saga.vcproj
    scummvm/branches/gsoc2009-mods/dists/msvc9/sci.vcproj
    scummvm/branches/gsoc2009-mods/dists/msvc9/scumm.vcproj
    scummvm/branches/gsoc2009-mods/dists/msvc9/scummvm-tfmx.vcproj
    scummvm/branches/gsoc2009-mods/dists/msvc9/scummvm.vcproj
    scummvm/branches/gsoc2009-mods/dists/msvc9/sky.vcproj
    scummvm/branches/gsoc2009-mods/dists/msvc9/sword1.vcproj
    scummvm/branches/gsoc2009-mods/dists/msvc9/sword2.vcproj
    scummvm/branches/gsoc2009-mods/dists/msvc9/tinsel.vcproj
    scummvm/branches/gsoc2009-mods/dists/msvc9/touche.vcproj
    scummvm/branches/gsoc2009-mods/dists/msvc9/tucker.vcproj
    scummvm/branches/gsoc2009-mods/dists/msvc9_to_msvc8.bat
    scummvm/branches/gsoc2009-mods/dists/redhat/scummvm.spec
    scummvm/branches/gsoc2009-mods/dists/redhat/scummvm.spec.in
    scummvm/branches/gsoc2009-mods/dists/scummvm.rc
    scummvm/branches/gsoc2009-mods/dists/scummvm.rc.in
    scummvm/branches/gsoc2009-mods/dists/slackware/scummvm.SlackBuild
    scummvm/branches/gsoc2009-mods/dists/wii/meta.xml
    scummvm/branches/gsoc2009-mods/engines/advancedDetector.cpp
    scummvm/branches/gsoc2009-mods/engines/agi/agi.h
    scummvm/branches/gsoc2009-mods/engines/agi/graphics.cpp
    scummvm/branches/gsoc2009-mods/engines/agi/op_cmd.cpp
    scummvm/branches/gsoc2009-mods/engines/agi/sound.cpp
    scummvm/branches/gsoc2009-mods/engines/agi/wagparser.cpp
    scummvm/branches/gsoc2009-mods/engines/agos/agos.cpp
    scummvm/branches/gsoc2009-mods/engines/agos/agos.h
    scummvm/branches/gsoc2009-mods/engines/agos/charset-fontdata.cpp
    scummvm/branches/gsoc2009-mods/engines/agos/charset.cpp
    scummvm/branches/gsoc2009-mods/engines/agos/draw.cpp
    scummvm/branches/gsoc2009-mods/engines/agos/event.cpp
    scummvm/branches/gsoc2009-mods/engines/agos/feeble.cpp
    scummvm/branches/gsoc2009-mods/engines/agos/gfx.cpp
    scummvm/branches/gsoc2009-mods/engines/agos/icons.cpp
    scummvm/branches/gsoc2009-mods/engines/agos/items.cpp
    scummvm/branches/gsoc2009-mods/engines/agos/menus.cpp
    scummvm/branches/gsoc2009-mods/engines/agos/oracle.cpp
    scummvm/branches/gsoc2009-mods/engines/agos/pn.cpp
    scummvm/branches/gsoc2009-mods/engines/agos/res_snd.cpp
    scummvm/branches/gsoc2009-mods/engines/agos/script_e1.cpp
    scummvm/branches/gsoc2009-mods/engines/agos/script_pn.cpp
    scummvm/branches/gsoc2009-mods/engines/agos/string.cpp
    scummvm/branches/gsoc2009-mods/engines/agos/subroutine.cpp
    scummvm/branches/gsoc2009-mods/engines/agos/verb.cpp
    scummvm/branches/gsoc2009-mods/engines/agos/vga.cpp
    scummvm/branches/gsoc2009-mods/engines/agos/vga_e2.cpp
    scummvm/branches/gsoc2009-mods/engines/agos/vga_ff.cpp
    scummvm/branches/gsoc2009-mods/engines/agos/vga_pn.cpp
    scummvm/branches/gsoc2009-mods/engines/agos/vga_s2.cpp
    scummvm/branches/gsoc2009-mods/engines/agos/vga_ww.cpp
    scummvm/branches/gsoc2009-mods/engines/agos/window.cpp
    scummvm/branches/gsoc2009-mods/engines/cine/saveload.cpp
    scummvm/branches/gsoc2009-mods/engines/cine/script_fw.cpp
    scummvm/branches/gsoc2009-mods/engines/cine/texte.cpp
    scummvm/branches/gsoc2009-mods/engines/cine/various.h
    scummvm/branches/gsoc2009-mods/engines/cruise/actor.cpp
    scummvm/branches/gsoc2009-mods/engines/cruise/cruise.cpp
    scummvm/branches/gsoc2009-mods/engines/cruise/cruise_main.cpp
    scummvm/branches/gsoc2009-mods/engines/cruise/cruise_main.h
    scummvm/branches/gsoc2009-mods/engines/cruise/ctp.cpp
    scummvm/branches/gsoc2009-mods/engines/cruise/font.cpp
    scummvm/branches/gsoc2009-mods/engines/cruise/function.cpp
    scummvm/branches/gsoc2009-mods/engines/cruise/gfxModule.cpp
    scummvm/branches/gsoc2009-mods/engines/cruise/gfxModule.h
    scummvm/branches/gsoc2009-mods/engines/cruise/menu.cpp
    scummvm/branches/gsoc2009-mods/engines/cruise/saveload.cpp
    scummvm/branches/gsoc2009-mods/engines/gob/dataio.cpp
    scummvm/branches/gsoc2009-mods/engines/gob/demos/demoplayer.cpp
    scummvm/branches/gsoc2009-mods/engines/gob/detection.cpp
    scummvm/branches/gsoc2009-mods/engines/gob/draw.cpp
    scummvm/branches/gsoc2009-mods/engines/gob/draw.h
    scummvm/branches/gsoc2009-mods/engines/gob/draw_v1.cpp
    scummvm/branches/gsoc2009-mods/engines/gob/draw_v2.cpp
    scummvm/branches/gsoc2009-mods/engines/gob/driver_vga.cpp
    scummvm/branches/gsoc2009-mods/engines/gob/driver_vga.h
    scummvm/branches/gsoc2009-mods/engines/gob/game.cpp
    scummvm/branches/gsoc2009-mods/engines/gob/game.h
    scummvm/branches/gsoc2009-mods/engines/gob/global.cpp
    scummvm/branches/gsoc2009-mods/engines/gob/global.h
    scummvm/branches/gsoc2009-mods/engines/gob/gob.cpp
    scummvm/branches/gsoc2009-mods/engines/gob/gob.h
    scummvm/branches/gsoc2009-mods/engines/gob/init.cpp
    scummvm/branches/gsoc2009-mods/engines/gob/init.h
    scummvm/branches/gsoc2009-mods/engines/gob/inter.cpp
    scummvm/branches/gsoc2009-mods/engines/gob/inter.h
    scummvm/branches/gsoc2009-mods/engines/gob/inter_bargon.cpp
    scummvm/branches/gsoc2009-mods/engines/gob/inter_v1.cpp
    scummvm/branches/gsoc2009-mods/engines/gob/inter_v2.cpp
    scummvm/branches/gsoc2009-mods/engines/gob/inter_v5.cpp
    scummvm/branches/gsoc2009-mods/engines/gob/inter_v6.cpp
    scummvm/branches/gsoc2009-mods/engines/gob/module.mk
    scummvm/branches/gsoc2009-mods/engines/gob/mult.cpp
    scummvm/branches/gsoc2009-mods/engines/gob/resources.cpp
    scummvm/branches/gsoc2009-mods/engines/gob/resources.h
    scummvm/branches/gsoc2009-mods/engines/gob/save/saveload.h
    scummvm/branches/gsoc2009-mods/engines/gob/script.cpp
    scummvm/branches/gsoc2009-mods/engines/gob/script.h
    scummvm/branches/gsoc2009-mods/engines/gob/sound/sound.cpp
    scummvm/branches/gsoc2009-mods/engines/gob/util.cpp
    scummvm/branches/gsoc2009-mods/engines/gob/util.h
    scummvm/branches/gsoc2009-mods/engines/gob/video.cpp
    scummvm/branches/gsoc2009-mods/engines/gob/video.h
    scummvm/branches/gsoc2009-mods/engines/gob/videoplayer.cpp
    scummvm/branches/gsoc2009-mods/engines/gob/videoplayer.h
    scummvm/branches/gsoc2009-mods/engines/groovie/groovie.cpp
    scummvm/branches/gsoc2009-mods/engines/groovie/music.cpp
    scummvm/branches/gsoc2009-mods/engines/groovie/music.h
    scummvm/branches/gsoc2009-mods/engines/groovie/resource.cpp
    scummvm/branches/gsoc2009-mods/engines/groovie/roq.cpp
    scummvm/branches/gsoc2009-mods/engines/groovie/script.cpp
    scummvm/branches/gsoc2009-mods/engines/igor/igor.cpp
    scummvm/branches/gsoc2009-mods/engines/igor/staticres.cpp
    scummvm/branches/gsoc2009-mods/engines/kyra/detection.cpp
    scummvm/branches/gsoc2009-mods/engines/kyra/gui.h
    scummvm/branches/gsoc2009-mods/engines/kyra/kyra_lok.cpp
    scummvm/branches/gsoc2009-mods/engines/kyra/kyra_mr.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/saveload.cpp
    scummvm/branches/gsoc2009-mods/engines/kyra/saveload_lok.cpp
    scummvm/branches/gsoc2009-mods/engines/kyra/scene_lol.cpp
    scummvm/branches/gsoc2009-mods/engines/kyra/scene_v2.cpp
    scummvm/branches/gsoc2009-mods/engines/kyra/screen.cpp
    scummvm/branches/gsoc2009-mods/engines/kyra/screen.h
    scummvm/branches/gsoc2009-mods/engines/kyra/screen_lol.cpp
    scummvm/branches/gsoc2009-mods/engines/kyra/screen_lol.h
    scummvm/branches/gsoc2009-mods/engines/kyra/script.cpp
    scummvm/branches/gsoc2009-mods/engines/kyra/script_lol.cpp
    scummvm/branches/gsoc2009-mods/engines/kyra/script_tim.cpp
    scummvm/branches/gsoc2009-mods/engines/kyra/sequences_hof.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/sound.h
    scummvm/branches/gsoc2009-mods/engines/kyra/sound_intern.h
    scummvm/branches/gsoc2009-mods/engines/kyra/sound_pcspk.cpp
    scummvm/branches/gsoc2009-mods/engines/kyra/sprites_lol.cpp
    scummvm/branches/gsoc2009-mods/engines/kyra/staticres.cpp
    scummvm/branches/gsoc2009-mods/engines/kyra/text_lol.h
    scummvm/branches/gsoc2009-mods/engines/kyra/timer_lol.cpp
    scummvm/branches/gsoc2009-mods/engines/lure/lure.h
    scummvm/branches/gsoc2009-mods/engines/parallaction/sound.h
    scummvm/branches/gsoc2009-mods/engines/queen/command.cpp
    scummvm/branches/gsoc2009-mods/engines/saga/font.cpp
    scummvm/branches/gsoc2009-mods/engines/sci/console.cpp
    scummvm/branches/gsoc2009-mods/engines/sci/console.h
    scummvm/branches/gsoc2009-mods/engines/sci/debug.h
    scummvm/branches/gsoc2009-mods/engines/sci/detection.cpp
    scummvm/branches/gsoc2009-mods/engines/sci/engine/game.cpp
    scummvm/branches/gsoc2009-mods/engines/sci/engine/gc.cpp
    scummvm/branches/gsoc2009-mods/engines/sci/engine/grammar.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/kevent.cpp
    scummvm/branches/gsoc2009-mods/engines/sci/engine/kfile.cpp
    scummvm/branches/gsoc2009-mods/engines/sci/engine/kgraphics.cpp
    scummvm/branches/gsoc2009-mods/engines/sci/engine/kmisc.cpp
    scummvm/branches/gsoc2009-mods/engines/sci/engine/kmovement.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/kstring.cpp
    scummvm/branches/gsoc2009-mods/engines/sci/engine/memobj.cpp
    scummvm/branches/gsoc2009-mods/engines/sci/engine/said.cpp
    scummvm/branches/gsoc2009-mods/engines/sci/engine/said.y
    scummvm/branches/gsoc2009-mods/engines/sci/engine/savegame.cpp
    scummvm/branches/gsoc2009-mods/engines/sci/engine/script.cpp
    scummvm/branches/gsoc2009-mods/engines/sci/engine/script.h
    scummvm/branches/gsoc2009-mods/engines/sci/engine/scriptdebug.cpp
    scummvm/branches/gsoc2009-mods/engines/sci/engine/seg_manager.cpp
    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/vm.cpp
    scummvm/branches/gsoc2009-mods/engines/sci/engine/vm.h
    scummvm/branches/gsoc2009-mods/engines/sci/gfx/font.cpp
    scummvm/branches/gsoc2009-mods/engines/sci/gfx/gfx_driver.cpp
    scummvm/branches/gsoc2009-mods/engines/sci/gfx/gfx_gui.cpp
    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_resmgr.h
    scummvm/branches/gsoc2009-mods/engines/sci/gfx/gfx_resource.h
    scummvm/branches/gsoc2009-mods/engines/sci/gfx/gfx_state_internal.h
    scummvm/branches/gsoc2009-mods/engines/sci/gfx/gfx_support.cpp
    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/gfx_widgets.cpp
    scummvm/branches/gsoc2009-mods/engines/sci/gfx/menubar.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_cursor.cpp
    scummvm/branches/gsoc2009-mods/engines/sci/gfx/res_font.cpp
    scummvm/branches/gsoc2009-mods/engines/sci/gfx/res_pal.cpp
    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/module.mk
    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/sci.h
    scummvm/branches/gsoc2009-mods/engines/sci/sfx/core.cpp
    scummvm/branches/gsoc2009-mods/engines/sci/sfx/iterator.cpp
    scummvm/branches/gsoc2009-mods/engines/sci/sfx/iterator.h
    scummvm/branches/gsoc2009-mods/engines/sci/sfx/iterator_internal.h
    scummvm/branches/gsoc2009-mods/engines/sci/sfx/seq/map-mt32-to-gm.cpp
    scummvm/branches/gsoc2009-mods/engines/sci/sfx/softseq/adlib.cpp
    scummvm/branches/gsoc2009-mods/engines/sci/sfx/softseq/amiga.cpp
    scummvm/branches/gsoc2009-mods/engines/sci/sfx/songlib.cpp
    scummvm/branches/gsoc2009-mods/engines/sci/tools.cpp
    scummvm/branches/gsoc2009-mods/engines/sci/tools.h
    scummvm/branches/gsoc2009-mods/engines/sci/vocabulary.cpp
    scummvm/branches/gsoc2009-mods/engines/sci/vocabulary.h
    scummvm/branches/gsoc2009-mods/engines/scumm/boxes.cpp
    scummvm/branches/gsoc2009-mods/engines/scumm/detection.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/he/intern_he.h
    scummvm/branches/gsoc2009-mods/engines/scumm/he/logic_he.cpp
    scummvm/branches/gsoc2009-mods/engines/scumm/he/resource_he.cpp
    scummvm/branches/gsoc2009-mods/engines/scumm/he/script_v71he.cpp
    scummvm/branches/gsoc2009-mods/engines/scumm/he/wiz_he.cpp
    scummvm/branches/gsoc2009-mods/engines/scumm/imuse_digi/dimuse_track.cpp
    scummvm/branches/gsoc2009-mods/engines/scumm/input.cpp
    scummvm/branches/gsoc2009-mods/engines/scumm/object.cpp
    scummvm/branches/gsoc2009-mods/engines/scumm/palette.cpp
    scummvm/branches/gsoc2009-mods/engines/scumm/player_v2.h
    scummvm/branches/gsoc2009-mods/engines/scumm/player_v2cms.cpp
    scummvm/branches/gsoc2009-mods/engines/scumm/resource.cpp
    scummvm/branches/gsoc2009-mods/engines/scumm/saveload.cpp
    scummvm/branches/gsoc2009-mods/engines/scumm/script.cpp
    scummvm/branches/gsoc2009-mods/engines/scumm/script_v5.cpp
    scummvm/branches/gsoc2009-mods/engines/scumm/script_v6.cpp
    scummvm/branches/gsoc2009-mods/engines/scumm/scumm-md5.h
    scummvm/branches/gsoc2009-mods/engines/scumm/scumm.cpp
    scummvm/branches/gsoc2009-mods/engines/scumm/scumm.h
    scummvm/branches/gsoc2009-mods/engines/scumm/scumm_v6.h
    scummvm/branches/gsoc2009-mods/engines/scumm/scumm_v7.h
    scummvm/branches/gsoc2009-mods/engines/scumm/smush/imuse_channel.cpp
    scummvm/branches/gsoc2009-mods/engines/scumm/sound.cpp
    scummvm/branches/gsoc2009-mods/engines/scumm/string.cpp
    scummvm/branches/gsoc2009-mods/engines/scumm/verbs.cpp
    scummvm/branches/gsoc2009-mods/engines/sky/control.cpp
    scummvm/branches/gsoc2009-mods/engines/sky/control.h
    scummvm/branches/gsoc2009-mods/engines/sky/grid.cpp
    scummvm/branches/gsoc2009-mods/engines/sky/logic.cpp
    scummvm/branches/gsoc2009-mods/engines/sky/sky.cpp
    scummvm/branches/gsoc2009-mods/engines/sword1/control.h
    scummvm/branches/gsoc2009-mods/engines/sword1/sound.cpp
    scummvm/branches/gsoc2009-mods/engines/sword1/sound.h
    scummvm/branches/gsoc2009-mods/engines/sword1/sword1.cpp
    scummvm/branches/gsoc2009-mods/engines/sword2/screen.h
    scummvm/branches/gsoc2009-mods/engines/tinsel/actors.h
    scummvm/branches/gsoc2009-mods/engines/tinsel/detection.cpp
    scummvm/branches/gsoc2009-mods/engines/tinsel/handle.cpp
    scummvm/branches/gsoc2009-mods/engines/tinsel/music.cpp
    scummvm/branches/gsoc2009-mods/engines/tinsel/pcode.cpp
    scummvm/branches/gsoc2009-mods/engines/tinsel/pcode.h
    scummvm/branches/gsoc2009-mods/engines/tinsel/pdisplay.cpp
    scummvm/branches/gsoc2009-mods/engines/tinsel/polygons.h
    scummvm/branches/gsoc2009-mods/engines/tinsel/sound.cpp
    scummvm/branches/gsoc2009-mods/engines/tinsel/sound.h
    scummvm/branches/gsoc2009-mods/engines/tinsel/tinlib.cpp
    scummvm/branches/gsoc2009-mods/engines/tinsel/tinsel.cpp
    scummvm/branches/gsoc2009-mods/engines/touche/saveload.cpp
    scummvm/branches/gsoc2009-mods/engines/tucker/locations.cpp
    scummvm/branches/gsoc2009-mods/engines/tucker/resource.cpp
    scummvm/branches/gsoc2009-mods/engines/tucker/saveload.cpp
    scummvm/branches/gsoc2009-mods/engines/tucker/sequences.cpp
    scummvm/branches/gsoc2009-mods/engines/tucker/tucker.cpp
    scummvm/branches/gsoc2009-mods/engines/tucker/tucker.h
    scummvm/branches/gsoc2009-mods/graphics/VectorRendererSpec.cpp
    scummvm/branches/gsoc2009-mods/graphics/font.cpp
    scummvm/branches/gsoc2009-mods/graphics/module.mk
    scummvm/branches/gsoc2009-mods/graphics/video/coktelvideo/coktelvideo.cpp
    scummvm/branches/gsoc2009-mods/graphics/video/mpeg_player.cpp
    scummvm/branches/gsoc2009-mods/gui/EditTextWidget.cpp
    scummvm/branches/gsoc2009-mods/gui/GuiManager.cpp
    scummvm/branches/gsoc2009-mods/gui/GuiManager.h
    scummvm/branches/gsoc2009-mods/gui/ListWidget.cpp
    scummvm/branches/gsoc2009-mods/gui/PopUpWidget.cpp
    scummvm/branches/gsoc2009-mods/gui/ThemeEngine.cpp
    scummvm/branches/gsoc2009-mods/gui/ThemeEngine.h
    scummvm/branches/gsoc2009-mods/gui/about.cpp
    scummvm/branches/gsoc2009-mods/gui/console.cpp
    scummvm/branches/gsoc2009-mods/gui/console.h
    scummvm/branches/gsoc2009-mods/gui/credits.h
    scummvm/branches/gsoc2009-mods/gui/debugger.cpp
    scummvm/branches/gsoc2009-mods/gui/launcher.cpp
    scummvm/branches/gsoc2009-mods/gui/themes/default.inc
    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/scummmodern_gfx.stx
    scummvm/branches/gsoc2009-mods/gui/themes/scummmodern/scummmodern_layout_lowres.stx
    scummvm/branches/gsoc2009-mods/gui/themes/scummmodern.zip
    scummvm/branches/gsoc2009-mods/sound/aiff.cpp
    scummvm/branches/gsoc2009-mods/sound/flac.cpp
    scummvm/branches/gsoc2009-mods/sound/module.mk
    scummvm/branches/gsoc2009-mods/sound/shorten.cpp
    scummvm/branches/gsoc2009-mods/sound/shorten.h
    scummvm/branches/gsoc2009-mods/sound/softsynth/mt32/partial.cpp
    scummvm/branches/gsoc2009-mods/sound/softsynth/mt32/synth.cpp
    scummvm/branches/gsoc2009-mods/sound/softsynth/mt32/synth.h
    scummvm/branches/gsoc2009-mods/sound/softsynth/mt32/tables.cpp
    scummvm/branches/gsoc2009-mods/sound/vorbis.cpp
    scummvm/branches/gsoc2009-mods/tools/create_kyradat/create_kyradat.cpp
    scummvm/branches/gsoc2009-mods/tools/credits.pl
    scummvm/branches/gsoc2009-mods/tools/scumm-md5.txt

Added Paths:
-----------
    scummvm/branches/gsoc2009-mods/backends/platform/iphone/osys_events.cpp
    scummvm/branches/gsoc2009-mods/backends/platform/iphone/osys_main.cpp
    scummvm/branches/gsoc2009-mods/backends/platform/iphone/osys_main.h
    scummvm/branches/gsoc2009-mods/backends/platform/iphone/osys_sound.cpp
    scummvm/branches/gsoc2009-mods/backends/platform/iphone/osys_video.cpp
    scummvm/branches/gsoc2009-mods/backends/platform/ps2/Makefile.gdb
    scummvm/branches/gsoc2009-mods/backends/platform/wince/smartLandScale.s
    scummvm/branches/gsoc2009-mods/dists/msvc8/ScummVM_Debug.vsprops
    scummvm/branches/gsoc2009-mods/dists/msvc8/ScummVM_Global.vsprops
    scummvm/branches/gsoc2009-mods/dists/msvc8/ScummVM_Release.vsprops
    scummvm/branches/gsoc2009-mods/engines/gob/hotspots.cpp
    scummvm/branches/gsoc2009-mods/engines/gob/hotspots.h
    scummvm/branches/gsoc2009-mods/engines/gob/init_v6.cpp
    scummvm/branches/gsoc2009-mods/engines/gob/save/saveload_playtoons.cpp
    scummvm/branches/gsoc2009-mods/engines/kyra/sound_adlib.h
    scummvm/branches/gsoc2009-mods/engines/sci/engine/static_selectors.cpp
    scummvm/branches/gsoc2009-mods/graphics/sjis.cpp
    scummvm/branches/gsoc2009-mods/graphics/sjis.h
    scummvm/branches/gsoc2009-mods/sound/iff_sound.cpp
    scummvm/branches/gsoc2009-mods/sound/iff_sound.h

Removed Paths:
-------------
    scummvm/branches/gsoc2009-mods/backends/platform/iphone/osys_iphone.cpp
    scummvm/branches/gsoc2009-mods/backends/platform/iphone/osys_iphone.h
    scummvm/branches/gsoc2009-mods/dists/msvc7/
    scummvm/branches/gsoc2009-mods/dists/msvc71/
    scummvm/branches/gsoc2009-mods/dists/msvc8_to_msvc7_71.bat
    scummvm/branches/gsoc2009-mods/engines/gob/game_fascin.cpp
    scummvm/branches/gsoc2009-mods/engines/gob/game_v1.cpp
    scummvm/branches/gsoc2009-mods/engines/gob/game_v2.cpp
    scummvm/branches/gsoc2009-mods/engines/gob/game_v6.cpp
    scummvm/branches/gsoc2009-mods/sound/iff.cpp
    scummvm/branches/gsoc2009-mods/sound/iff.h

Property Changed:
----------------
    scummvm/branches/gsoc2009-mods/
    scummvm/branches/gsoc2009-mods/engines/kyra/sound_amiga.cpp


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

Modified: scummvm/branches/gsoc2009-mods/AUTHORS
===================================================================
--- scummvm/branches/gsoc2009-mods/AUTHORS	2009-07-17 20:51:40 UTC (rev 42573)
+++ scummvm/branches/gsoc2009-mods/AUTHORS	2009-07-17 21:23:54 UTC (rev 42574)
@@ -57,8 +57,12 @@
 
     Cinematique evo 2:
        Vincent Hamm          - original CruisE engine author
-       Paul Gilbert
+       Paul Gilbert         
 
+    Drascula:
+       Filippos Karapetis   
+       Pawel Kolodziejski   
+
     FOTAQ:
        Gregory Montoir      
        Joost Peters         
@@ -324,7 +328,7 @@
      Dobo Balazs           - Website design
      Yaroslav Fedevych     - HTML/CSS for the website
      David Jensen          - SVG logo conversion
-     Jean Marc             - ScummVM logo
+     Jean Marc Gimenez     - ScummVM logo
      Raina                 - ScummVM forum buttons
 
   Code contributions

Modified: scummvm/branches/gsoc2009-mods/Makefile
===================================================================
--- scummvm/branches/gsoc2009-mods/Makefile	2009-07-17 20:51:40 UTC (rev 42573)
+++ scummvm/branches/gsoc2009-mods/Makefile	2009-07-17 21:23:54 UTC (rev 42574)
@@ -27,6 +27,12 @@
 CXXFLAGS+= -Wpointer-arith -Wcast-qual -Wcast-align
 CXXFLAGS+= -Wshadow -Wimplicit -Wnon-virtual-dtor -Wwrite-strings
 
+# Currently we disable this gcc flag, since it will also warn in cases,
+# where using GCC_PRINTF (means: __attribute__((format(printf, x, y))))
+# is not possible, thus it would fail compiliation with -Werror without
+# being helpful.
+#CXXFLAGS+= -Wmissing-format-attribute
+
 # Disable RTTI and exceptions, and enabled checking of pointers returned by "new"
 CXXFLAGS+= -fno-rtti -fno-exceptions -fcheck-new
 

Modified: scummvm/branches/gsoc2009-mods/NEWS
===================================================================
--- scummvm/branches/gsoc2009-mods/NEWS	2009-07-17 20:51:40 UTC (rev 42573)
+++ scummvm/branches/gsoc2009-mods/NEWS	2009-07-17 21:23:54 UTC (rev 42574)
@@ -1,7 +1,7 @@
 For a more comprehensive changelog for the latest experimental SVN code, see:
         http://scummvm.svn.sourceforge.net/viewvc/scummvm/?view=log
 
-0.14.0 (2009-??-??)
+1.0.0 (2009-??-??)
  New Games:
    - Added support for Discworld.
    - Added support for Discworld 2 - Missing Presumed ...!?.
@@ -9,6 +9,7 @@
    - Added support for Leather Goddesses of Phobos 2.
    - Added support for The Manhole.
    - Added support for Rodney's Funscreen.
+   - Added support for Cruise for a Corpse.
 
  General:
    - Added experimental AdLib emulator from DOSBox.
@@ -36,6 +37,10 @@
    - Dropped support for playing cutscene sound without the video.
    - Added support for the PlayStation version.
 
+ Gob:
+   - Introduced a new savegame format to fix a fatal flaw of the old one,
+     breaking compatibility with old savegames made on big-endian systems.
+
  KYRA:
    - Added support for PC Speaker based music and sound effects.
    - Added support for 16 color dithering in Kyrandia PC-9801 (Japanese version
@@ -323,7 +328,7 @@
    - Renamed Simon engine to AGOS.
 
  Kyrandia:
-   - Added support for FM-Towns version (both English and Japanese).
+   - Added support for FM-TOWNS version (both English and Japanese).
 
  BASS:
    - Fixed long-standing font bug. We were using the control panel font for

Modified: scummvm/branches/gsoc2009-mods/README
===================================================================
--- scummvm/branches/gsoc2009-mods/README	2009-07-17 20:51:40 UTC (rev 42573)
+++ scummvm/branches/gsoc2009-mods/README	2009-07-17 21:23:54 UTC (rev 42574)
@@ -230,10 +230,19 @@
          and the Schnibble                       [woodruff]
      Ween: The Prophecy                          [ween]
 
+MADE Games by Activision:
+     Leather Goddesses of Phobos 2               [lgop2]
+     Return to Zork                              [rtz]
+     Rodney's Funscreen                          [rodney]
+     The Manhole                                 [manhole]
+
 Other Games:
      Beneath a Steel Sky                         [sky]
      Broken Sword 1: The Shadow of the Templars  [sword1]
      Broken Sword 2: The Smoking Mirror          [sword2]
+     Cruise for a Corpse                         [cruise]
+     Discworld                                   [dw]
+     Discworld 2: Missing Presumed ...!?         [dw2]
      Drascula: The Vampire Strikes Back          [drascula]
      Flight of the Amazon Queen                  [queen]
      Future Wars                                 [fw]
@@ -297,6 +306,7 @@
      Backyard Baseball                           [baseball]
      Backyard Soccer                             [soccer]
      Blue's Birthday Adventure                   [BluesBirthday]
+     Blue's Treasure Hunt                        [BluesTreasureHunt]
      SPY Fox 3: Operation Ozone                  [spyozon]
 
 The following games are based on the SCUMM engine, but NOT supported

Modified: scummvm/branches/gsoc2009-mods/backends/events/default/default-events.h
===================================================================
--- scummvm/branches/gsoc2009-mods/backends/events/default/default-events.h	2009-07-17 20:51:40 UTC (rev 42573)
+++ scummvm/branches/gsoc2009-mods/backends/events/default/default-events.h	2009-07-17 21:23:54 UTC (rev 42574)
@@ -143,6 +143,9 @@
 	virtual int shouldQuit() const { return _shouldQuit; }
 	virtual int shouldRTL() const { return _shouldRTL; }
 	virtual void resetRTL() { _shouldRTL = false; }
+#ifdef FORCE_RTL
+	virtual void resetQuit() { _shouldQuit = false; }
+#endif
 
 #ifdef ENABLE_KEYMAPPER
 	virtual Common::Keymapper *getKeymapper() { return _keymapper; }

Modified: scummvm/branches/gsoc2009-mods/backends/midi/timidity.cpp
===================================================================
--- scummvm/branches/gsoc2009-mods/backends/midi/timidity.cpp	2009-07-17 20:51:40 UTC (rev 42573)
+++ scummvm/branches/gsoc2009-mods/backends/midi/timidity.cpp	2009-07-17 21:23:54 UTC (rev 42574)
@@ -99,7 +99,7 @@
 	int	connect_to_server(const char* hostname, unsigned short tcp_port);
 
 	/* send command to the server; printf-like; returns reply string */
-	char	*timidity_ctl_command(const char *fmt, ...);
+	char	*timidity_ctl_command(const char *fmt, ...) GCC_PRINTF(2, 3);
 
 	/* timidity data socket-related stuff */
 	void	timidity_meta_seq(int p1, int p2, int p3);

Modified: scummvm/branches/gsoc2009-mods/backends/platform/dc/dc.h
===================================================================
--- scummvm/branches/gsoc2009-mods/backends/platform/dc/dc.h	2009-07-17 20:51:40 UTC (rev 42573)
+++ scummvm/branches/gsoc2009-mods/backends/platform/dc/dc.h	2009-07-17 21:23:54 UTC (rev 42574)
@@ -194,7 +194,7 @@
   SoftKeyboard _softkbd;
 
   int _ms_cur_x, _ms_cur_y, _ms_cur_w, _ms_cur_h, _ms_old_x, _ms_old_y;
-  int _ms_hotspot_x, _ms_hotspot_y, _ms_visible, _devpoll;
+  int _ms_hotspot_x, _ms_hotspot_y, _ms_visible, _devpoll, _last_screen_refresh;
   int _current_shake_pos, _screen_w, _screen_h;
   int _overlay_x, _overlay_y;
   unsigned char *_ms_buf;
@@ -220,11 +220,15 @@
   uint initSound();
   void checkSound();
 
+  void updateScreenTextures(void);
+  void updateScreenPolygons(void);
+  void maybeRefreshScreen(void);
   void drawMouse(int xdraw, int ydraw, int w, int h,
 		 unsigned char *buf, bool visible);
 
   void setScaling();
 
+
   Common::SaveFileManager *createSavefileManager();
 };
 

Modified: scummvm/branches/gsoc2009-mods/backends/platform/dc/display.cpp
===================================================================
--- scummvm/branches/gsoc2009-mods/backends/platform/dc/display.cpp	2009-07-17 20:51:40 UTC (rev 42573)
+++ scummvm/branches/gsoc2009-mods/backends/platform/dc/display.cpp	2009-07-17 21:23:54 UTC (rev 42574)
@@ -285,11 +285,8 @@
   _current_shake_pos = shake_pos;
 }
 
-void OSystem_Dreamcast::updateScreen(void)
+void OSystem_Dreamcast::updateScreenTextures(void)
 {
-  struct polygon_list mypoly;
-  struct packed_colour_vertex_list myvertex;
-
   if (_screen_dirty) {
 
     _screen_buffer++;
@@ -328,7 +325,13 @@
 
     _overlay_dirty = false;
   }
+}
 
+void OSystem_Dreamcast::updateScreenPolygons(void)
+{
+  struct polygon_list mypoly;
+  struct packed_colour_vertex_list myvertex;
+
   // *((volatile unsigned int *)(void*)0xa05f8040) = 0x00ff00;
 
   mypoly.cmd =
@@ -448,8 +451,23 @@
   ta_commit_frame();
 
   // *((volatile unsigned int *)(void*)0xa05f8040) = 0x0;
+
+  _last_screen_refresh = Timer();
 }
 
+void OSystem_Dreamcast::updateScreen(void)
+{
+  updateScreenTextures();
+  updateScreenPolygons();
+}
+
+void OSystem_Dreamcast::maybeRefreshScreen(void)
+{
+  unsigned int t = Timer();
+  if((int)(t-_last_screen_refresh) > USEC_TO_TIMER(30000))
+    updateScreenPolygons();
+}
+
 void OSystem_Dreamcast::drawMouse(int xdraw, int ydraw, int w, int h,
 				  unsigned char *buf, bool visible)
 {

Modified: scummvm/branches/gsoc2009-mods/backends/platform/dc/input.cpp
===================================================================
--- scummvm/branches/gsoc2009-mods/backends/platform/dc/input.cpp	2009-07-17 20:51:40 UTC (rev 42573)
+++ scummvm/branches/gsoc2009-mods/backends/platform/dc/input.cpp	2009-07-17 21:23:54 UTC (rev 42574)
@@ -202,6 +202,8 @@
   if (((int)(t-_devpoll))>=0)
     _devpoll = t + USEC_TO_TIMER(17000);
 
+  maybeRefreshScreen();
+
   int mask = getimask();
   setimask(15);
   checkSound();

Modified: scummvm/branches/gsoc2009-mods/backends/platform/ds/arm7/Makefile
===================================================================
--- scummvm/branches/gsoc2009-mods/backends/platform/ds/arm7/Makefile	2009-07-17 20:51:40 UTC (rev 42573)
+++ scummvm/branches/gsoc2009-mods/backends/platform/ds/arm7/Makefile	2009-07-17 21:23:54 UTC (rev 42574)
@@ -151,13 +151,12 @@
 #---------------------------------------------------------------------------------
 %.bin: %.elf
 	@echo built ... $(notdir $@)
-	@$(OBJCOPY) -O binary  $(TARGET).elf $@
+	$(OBJCOPY) -O binary  $(TARGET).elf $@
 
 #---------------------------------------------------------------------------------
 %.elf:
 	echo ELF
-	@echo $(LD)  $(LDFLAGS) -specs=ds_arm7.specs $(OFILES) $(LIBPATHS) $(LIBS) -o $(TARGET).elf
-	@$(LD)  $(LDFLAGS) -specs=ds_arm7.specs $(OFILES) $(LIBPATHS) $(LIBS) -o $(TARGET).elf
+	$(LD)  $(LDFLAGS) -specs=ds_arm7.specs $(OFILES) $(LIBPATHS) $(LIBS) -o $(TARGET).elf
 
 
 

Modified: scummvm/branches/gsoc2009-mods/backends/platform/iphone/module.mk
===================================================================
--- scummvm/branches/gsoc2009-mods/backends/platform/iphone/module.mk	2009-07-17 20:51:40 UTC (rev 42573)
+++ scummvm/branches/gsoc2009-mods/backends/platform/iphone/module.mk	2009-07-17 21:23:54 UTC (rev 42574)
@@ -1,7 +1,10 @@
 MODULE := backends/platform/iphone
 
 MODULE_OBJS := \
-	osys_iphone.o \
+	osys_main.o \
+	osys_events.o \
+	osys_sound.o \
+	osys_video.o \
 	iphone_main.o \
 	iphone_video.o \
 	iphone_keyboard.o \

Copied: scummvm/branches/gsoc2009-mods/backends/platform/iphone/osys_events.cpp (from rev 42568, scummvm/trunk/backends/platform/iphone/osys_events.cpp)
===================================================================
--- scummvm/branches/gsoc2009-mods/backends/platform/iphone/osys_events.cpp	                        (rev 0)
+++ scummvm/branches/gsoc2009-mods/backends/platform/iphone/osys_events.cpp	2009-07-17 21:23:54 UTC (rev 42574)
@@ -0,0 +1,514 @@
+/* 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 "gui/message.h"
+
+#include "osys_main.h"
+
+
+bool OSystem_IPHONE::pollEvent(Common::Event &event) {
+	//printf("pollEvent()\n");
+
+	long curTime = getMillis();
+
+	if (_timerCallback && (curTime >= _timerCallbackNext)) {
+		_timerCallback(_timerCallbackTimer);
+		_timerCallbackNext = curTime + _timerCallbackTimer;
+	}
+
+	if (_needEventRestPeriod) {
+		// Workaround: Some engines can't handle mouse-down and mouse-up events
+		// appearing right after each other, without a call returning no input in between.
+		_needEventRestPeriod = false;
+		return false;
+	}
+
+	if (_queuedInputEvent.type != (Common::EventType)0) {
+		event = _queuedInputEvent;
+		_queuedInputEvent.type = (Common::EventType)0;
+		return true;
+	}
+
+	int eventType;
+	float xUnit, yUnit;
+
+	if (iPhone_fetchEvent(&eventType, &xUnit, &yUnit)) {
+		int x = 0;
+		int y = 0;
+		switch (_screenOrientation) {
+			case kScreenOrientationPortrait:
+				x = (int)(xUnit * _screenWidth);
+				y = (int)(yUnit * _screenHeight);
+				break;
+			case kScreenOrientationLandscape:
+				x = (int)(yUnit * _screenWidth);
+				y = (int)((1.0 - xUnit) * _screenHeight);
+				break;
+			case kScreenOrientationFlippedLandscape:
+				x = (int)((1.0 - yUnit) * _screenWidth);
+				y = (int)(xUnit * _screenHeight);
+				break;
+		}
+
+		switch ((InputEvent)eventType) {
+			case kInputMouseDown:
+				if (!handleEvent_mouseDown(event, x, y))
+					return false;
+				break;
+
+			case kInputMouseUp:
+			if (!handleEvent_mouseUp(event, x, y))
+				return false;
+				break;
+
+			case kInputMouseDragged:
+				if (!handleEvent_mouseDragged(event, x, y))
+					return false;
+				break;
+			case kInputMouseSecondDragged:
+				if (!handleEvent_mouseSecondDragged(event, x, y))
+					return false;
+				break;
+			case kInputMouseSecondDown:
+				_secondaryTapped = true;
+				if (!handleEvent_secondMouseDown(event, x, y))
+					return false;
+				break;
+			case kInputMouseSecondUp:
+				_secondaryTapped = false;
+				if (!handleEvent_secondMouseUp(event, x, y))
+					return false;
+				break;
+			case kInputOrientationChanged:
+				handleEvent_orientationChanged((int)xUnit);
+				return false;
+				break;
+
+			case kInputApplicationSuspended:
+				suspendLoop();
+				return false;
+				break;
+
+			case kInputKeyPressed:
+				handleEvent_keyPressed(event, (int)xUnit);
+				break;
+
+			case kInputSwipe:
+				if (!handleEvent_swipe(event, (int)xUnit))
+					return false;
+				break;
+
+			default:
+				break;
+		}
+
+		return true;
+	}
+	return false;
+}
+
+bool OSystem_IPHONE::handleEvent_mouseDown(Common::Event &event, int x, int y) {
+	//printf("Mouse down at (%u, %u)\n", x, y);
+
+	// Workaround: kInputMouseSecondToggled isn't always sent when the
+	// secondary finger is lifted. Need to make sure we get out of that mode.
+	_secondaryTapped = false;
+
+	if (_touchpadModeEnabled) {
+		_lastPadX = x;
+		_lastPadY = y;
+	} else
+		warpMouse(x, y);
+
+	if (_mouseClickAndDragEnabled) {
+		event.type = Common::EVENT_LBUTTONDOWN;
+		event.mouse.x = _mouseX;
+		event.mouse.y = _mouseY;
+		return true;
+	} else {
+		_lastMouseDown = getMillis();
+	}
+	return false;
+}
+
+bool OSystem_IPHONE::handleEvent_mouseUp(Common::Event &event, int x, int y) {
+	//printf("Mouse up at (%u, %u)\n", x, y);
+
+	if (_secondaryTapped) {
+		_secondaryTapped = false;
+		if (!handleEvent_secondMouseUp(event, x, y))
+			return false;
+	}
+	else if (_mouseClickAndDragEnabled) {
+		event.type = Common::EVENT_LBUTTONUP;
+		event.mouse.x = _mouseX;
+		event.mouse.y = _mouseY;
+	} else {
+		if (getMillis() - _lastMouseDown < 250) {
+			event.type = Common::EVENT_LBUTTONDOWN;
+			event.mouse.x = _mouseX;
+			event.mouse.y = _mouseY;
+
+			_queuedInputEvent.type = Common::EVENT_LBUTTONUP;
+			_queuedInputEvent.mouse.x = _mouseX;
+			_queuedInputEvent.mouse.y = _mouseY;
+			_lastMouseTap = getMillis();
+			_needEventRestPeriod = true;
+		} else
+			return false;
+	}
+
+	return true;
+}
+
+bool OSystem_IPHONE::handleEvent_secondMouseDown(Common::Event &event, int x, int y) {
+	_lastSecondaryDown = getMillis();
+	_gestureStartX = x;
+	_gestureStartY = y;
+
+	if (_mouseClickAndDragEnabled) {
+		event.type = Common::EVENT_LBUTTONUP;
+		event.mouse.x = _mouseX;
+		event.mouse.y = _mouseY;
+
+		_queuedInputEvent.type = Common::EVENT_RBUTTONDOWN;
+		_queuedInputEvent.mouse.x = _mouseX;
+		_queuedInputEvent.mouse.y = _mouseY;
+	}
+	else
+		return false;
+
+	return true;
+}
+
+bool OSystem_IPHONE::handleEvent_secondMouseUp(Common::Event &event, int x, int y) {
+	int curTime = getMillis();
+
+	if (curTime - _lastSecondaryDown < 400 ) {
+		//printf("Right tap!\n");
+		if (curTime - _lastSecondaryTap < 400 && !_overlayVisible) {
+			//printf("Right escape!\n");
+			event.type = Common::EVENT_KEYDOWN;
+			_queuedInputEvent.type = Common::EVENT_KEYUP;
+
+			event.kbd.flags = _queuedInputEvent.kbd.flags = 0;
+			event.kbd.keycode = _queuedInputEvent.kbd.keycode = Common::KEYCODE_ESCAPE;
+			event.kbd.ascii = _queuedInputEvent.kbd.ascii = Common::ASCII_ESCAPE;
+			_needEventRestPeriod = true;
+			_lastSecondaryTap = 0;
+		} else if (!_mouseClickAndDragEnabled) {
+			//printf("Rightclick!\n");
+			event.type = Common::EVENT_RBUTTONDOWN;
+			event.mouse.x = _mouseX;
+			event.mouse.y = _mouseY;
+			_queuedInputEvent.type = Common::EVENT_RBUTTONUP;
+			_queuedInputEvent.mouse.x = _mouseX;
+			_queuedInputEvent.mouse.y = _mouseY;
+			_lastSecondaryTap = curTime;
+			_needEventRestPeriod = true;
+		} else {
+			//printf("Right nothing!\n");
+			return false;
+		}
+	}
+	if (_mouseClickAndDragEnabled) {
+		event.type = Common::EVENT_RBUTTONUP;
+		event.mouse.x = _mouseX;
+		event.mouse.y = _mouseY;
+	}
+
+	return true;
+}
+
+bool OSystem_IPHONE::handleEvent_mouseDragged(Common::Event &event, int x, int y) {
+	if (_lastDragPosX == x && _lastDragPosY == y)
+		return false;
+
+	_lastDragPosX = x;
+	_lastDragPosY = y;
+
+	//printf("Mouse dragged at (%u, %u)\n", x, y);
+	int mouseNewPosX;
+	int mouseNewPosY;
+	if (_touchpadModeEnabled ) {
+		int deltaX = _lastPadX - x;
+		int deltaY = _lastPadY - y;
+		_lastPadX = x;
+		_lastPadY = y;
+
+		mouseNewPosX = (int)(_mouseX - deltaX / 0.5f);
+		mouseNewPosY = (int)(_mouseY - deltaY / 0.5f);
+
+		if (mouseNewPosX < 0)
+			mouseNewPosX = 0;
+		else if (mouseNewPosX > _screenWidth)
+			mouseNewPosX = _screenWidth;
+
+		if (mouseNewPosY < 0)
+			mouseNewPosY = 0;
+		else if (mouseNewPosY > _screenHeight)
+			mouseNewPosY = _screenHeight;
+
+	} else {
+		mouseNewPosX = x;
+		mouseNewPosY = y;
+	}
+
+	event.type = Common::EVENT_MOUSEMOVE;
+	event.mouse.x = mouseNewPosX;
+	event.mouse.y = mouseNewPosY;
+	warpMouse(mouseNewPosX, mouseNewPosY);
+
+	return true;
+}
+
+bool OSystem_IPHONE::handleEvent_mouseSecondDragged(Common::Event &event, int x, int y) {
+	if (_gestureStartX == -1 || _gestureStartY == -1) {
+		return false;
+	}
+
+	static const int kNeededLength = 100;
+	static const int kMaxDeviation = 20;
+
+	int vecX = (x - _gestureStartX);
+	int vecY = (y - _gestureStartY);
+	
+	int absX = abs(vecX);
+	int absY = abs(vecY);
+
+	//printf("(%d, %d)\n", vecX, vecY);
+
+	if (absX >= kNeededLength || absY >= kNeededLength) { // Long enough gesture to react upon.
+		_gestureStartX = -1;
+		_gestureStartY = -1;
+
+		if (absX < kMaxDeviation && vecY >= kNeededLength) {
+			// Swipe down
+			event.type = Common::EVENT_KEYDOWN;
+			_queuedInputEvent.type = Common::EVENT_KEYUP;
+
+			event.kbd.flags = _queuedInputEvent.kbd.flags = 0;
+			event.kbd.keycode = _queuedInputEvent.kbd.keycode = Common::KEYCODE_F5;
+			event.kbd.ascii = _queuedInputEvent.kbd.ascii = Common::ASCII_F5;
+			_needEventRestPeriod = true;
+			return true;
+		}
+		
+		if (absX < kMaxDeviation && -vecY >= kNeededLength) {
+			// Swipe up
+			_mouseClickAndDragEnabled = !_mouseClickAndDragEnabled;
+			const char *dialogMsg;
+			if (_mouseClickAndDragEnabled) {
+				_touchpadModeEnabled = false;
+				dialogMsg = "Mouse-click-and-drag mode enabled.";
+			} else
+				dialogMsg = "Mouse-click-and-drag mode disabled.";
+			GUI::TimedMessageDialog dialog(dialogMsg, 1500);
+			dialog.runModal();
+			return false;
+		}
+		
+		if (absY < kMaxDeviation && vecX >= kNeededLength) {
+			// Swipe right
+			_touchpadModeEnabled = !_touchpadModeEnabled;
+			const char *dialogMsg;
+			if (_touchpadModeEnabled)
+				dialogMsg = "Touchpad mode enabled.";
+			else
+				dialogMsg = "Touchpad mode disabled.";
+			GUI::TimedMessageDialog dialog(dialogMsg, 1500);
+			dialog.runModal();
+			return false;
+
+		}
+		
+		if (absY < kMaxDeviation && -vecX >= kNeededLength) {
+			// Swipe left
+			return false;
+		}
+	}
+
+	return false;
+}
+
+void  OSystem_IPHONE::handleEvent_orientationChanged(int orientation) {
+	//printf("Orientation: %i\n", orientation);
+
+	ScreenOrientation newOrientation;
+	switch (orientation) {
+		case 1:
+			newOrientation = kScreenOrientationPortrait;
+			break;
+		case 3:
+			newOrientation = kScreenOrientationLandscape;
+			break;
+		case 4:
+			newOrientation = kScreenOrientationFlippedLandscape;
+			break;
+		default:
+			return;
+	}
+
+
+	if (_screenOrientation != newOrientation) {
+		_screenOrientation = newOrientation;
+		iPhone_initSurface(_screenWidth, _screenHeight);
+
+		dirtyFullScreen();
+		if (_overlayVisible)
+			dirtyFullOverlayScreen();
+		updateScreen();
+	}
+}
+
+void  OSystem_IPHONE::handleEvent_keyPressed(Common::Event &event, int keyPressed) {
+	int ascii = keyPressed;
+	//printf("key: %i\n", keyPressed);
+
+	// We remap some of the iPhone keyboard keys.
+	// The first ten here are the row of symbols below the numeric keys.
+	switch (keyPressed) {
+		case 45:
+			keyPressed = Common::KEYCODE_F1;
+			ascii = Common::ASCII_F1;
+			break;
+		case 47:
+			keyPressed = Common::KEYCODE_F2;
+			ascii = Common::ASCII_F2;
+			break;
+		case 58:
+			keyPressed = Common::KEYCODE_F3;
+			ascii = Common::ASCII_F3;
+			break;
+		case 59:
+			keyPressed = Common::KEYCODE_F4;
+			ascii = Common::ASCII_F4;
+			break;
+		case 40:
+			keyPressed = Common::KEYCODE_F5;
+			ascii = Common::ASCII_F5;
+			break;
+		case 41:
+			keyPressed = Common::KEYCODE_F6;
+			ascii = Common::ASCII_F6;
+			break;
+		case 36:
+			keyPressed = Common::KEYCODE_F7;
+			ascii = Common::ASCII_F7;
+			break;
+		case 38:
+			keyPressed = Common::KEYCODE_F8;
+			ascii = Common::ASCII_F8;
+			break;
+		case 64:
+			keyPressed = Common::KEYCODE_F9;
+			ascii = Common::ASCII_F9;
+			break;
+		case 34:
+			keyPressed = Common::KEYCODE_F10;
+			ascii = Common::ASCII_F10;
+			break;
+		case 10:
+			keyPressed = Common::KEYCODE_RETURN;
+			ascii = Common::ASCII_RETURN;
+			break;
+	}
+	event.type = Common::EVENT_KEYDOWN;
+	_queuedInputEvent.type = Common::EVENT_KEYUP;
+
+	event.kbd.flags = _queuedInputEvent.kbd.flags = 0;
+	event.kbd.keycode = _queuedInputEvent.kbd.keycode = (Common::KeyCode)keyPressed;
+	event.kbd.ascii = _queuedInputEvent.kbd.ascii = ascii;
+	_needEventRestPeriod = true;
+}
+
+bool OSystem_IPHONE::handleEvent_swipe(Common::Event &event, int direction) {
+	Common::KeyCode keycode = Common::KEYCODE_INVALID;
+	switch (_screenOrientation) {
+		case kScreenOrientationPortrait:
+			switch ((UIViewSwipeDirection)direction) {
+				case kUIViewSwipeUp:
+					keycode = Common::KEYCODE_UP;
+					break;
+				case kUIViewSwipeDown:
+					keycode = Common::KEYCODE_DOWN;
+					break;
+				case kUIViewSwipeLeft:
+					keycode = Common::KEYCODE_LEFT;
+					break;
+				case kUIViewSwipeRight:
+					keycode = Common::KEYCODE_RIGHT;
+					break;
+				default:
+					return false;
+			}
+			break;
+		case kScreenOrientationLandscape:
+			switch ((UIViewSwipeDirection)direction) {
+				case kUIViewSwipeUp:
+					keycode = Common::KEYCODE_LEFT;
+					break;
+				case kUIViewSwipeDown:
+					keycode = Common::KEYCODE_RIGHT;
+					break;
+				case kUIViewSwipeLeft:
+					keycode = Common::KEYCODE_DOWN;
+					break;
+				case kUIViewSwipeRight:
+					keycode = Common::KEYCODE_UP;
+					break;
+				default:
+					return false;
+			}
+			break;
+		case kScreenOrientationFlippedLandscape:
+			switch ((UIViewSwipeDirection)direction) {
+				case kUIViewSwipeUp:
+					keycode = Common::KEYCODE_RIGHT;
+					break;
+				case kUIViewSwipeDown:
+					keycode = Common::KEYCODE_LEFT;
+					break;
+				case kUIViewSwipeLeft:
+					keycode = Common::KEYCODE_UP;
+					break;
+				case kUIViewSwipeRight:
+					keycode = Common::KEYCODE_DOWN;
+					break;
+				default:
+					return false;
+			}
+			break;
+	}
+
+	event.kbd.keycode = _queuedInputEvent.kbd.keycode = keycode;
+	event.kbd.ascii = _queuedInputEvent.kbd.ascii = 0;
+	event.type = Common::EVENT_KEYDOWN;
+	_queuedInputEvent.type = Common::EVENT_KEYUP;
+	event.kbd.flags = _queuedInputEvent.kbd.flags = 0;
+	_needEventRestPeriod = true;
+
+	return true;
+}

Deleted: scummvm/branches/gsoc2009-mods/backends/platform/iphone/osys_iphone.cpp
===================================================================
--- scummvm/branches/gsoc2009-mods/backends/platform/iphone/osys_iphone.cpp	2009-07-17 20:51:40 UTC (rev 42573)
+++ scummvm/branches/gsoc2009-mods/backends/platform/iphone/osys_iphone.cpp	2009-07-17 21:23:54 UTC (rev 42574)
@@ -1,1303 +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 <unistd.h>
-#include <pthread.h>
-
-#include <sys/time.h>
-
-#include "common/scummsys.h"
-#include "common/util.h"
-#include "common/rect.h"
-#include "common/file.h"
-#include "common/fs.h"
-
-#include "base/main.h"
-
-#include "backends/saves/default/default-saves.h"
-#include "backends/timer/default/default-timer.h"
-#include "sound/mixer.h"
-#include "sound/mixer_intern.h"
-#include "gui/message.h"
-
-#include "osys_iphone.h"
-
-
-const OSystem::GraphicsMode OSystem_IPHONE::s_supportedGraphicsModes[] = {
-	{0, 0, 0}
-};
-
-AQCallbackStruct OSystem_IPHONE::s_AudioQueue;
-SoundProc OSystem_IPHONE::s_soundCallback = NULL;
-void *OSystem_IPHONE::s_soundParam = NULL;
-
-OSystem_IPHONE::OSystem_IPHONE() :
-	_savefile(NULL), _mixer(NULL), _timer(NULL), _offscreen(NULL),
-	_overlayVisible(false), _overlayBuffer(NULL), _fullscreen(NULL),
-	_mouseHeight(0), _mouseWidth(0), _mouseBuf(NULL), _lastMouseTap(0),
-	_secondaryTapped(false), _lastSecondaryTap(0), _screenOrientation(kScreenOrientationFlippedLandscape),
-	_needEventRestPeriod(false), _mouseClickAndDragEnabled(false), _touchpadModeEnabled(true),
-	_gestureStartX(-1), _gestureStartY(-1), _fullScreenIsDirty(false), _fullScreenOverlayIsDirty(false),
-	_mouseDirty(false), _timeSuspended(0), _lastDragPosX(-1), _lastDragPosY(-1), _screenChangeCount(0)
-
-{
-	_queuedInputEvent.type = (Common::EventType)0;
-	_lastDrawnMouseRect = Common::Rect(0, 0, 0, 0);
-
-	_fsFactory = new POSIXFilesystemFactory();
-}
-
-OSystem_IPHONE::~OSystem_IPHONE() {
-	AudioQueueDispose(s_AudioQueue.queue, true);
-
-	delete _fsFactory;
-	delete _savefile;
-	delete _mixer;
-	delete _timer;
-	delete _offscreen;
-	delete _fullscreen;
-}
-
-int OSystem_IPHONE::timerHandler(int t) {
-	DefaultTimerManager *tm = (DefaultTimerManager *)g_system->getTimerManager();
-	tm->handler();
-	return t;
-}
-
-void OSystem_IPHONE::initBackend() {
-#ifdef IPHONE_OFFICIAL
-	_savefile = new DefaultSaveFileManager(iPhone_getDocumentsDir());
-#else
-	_savefile = new DefaultSaveFileManager(SCUMMVM_SAVE_PATH);
-#endif
-
-	_timer = new DefaultTimerManager();
-
-	gettimeofday(&_startTime, NULL);
-
-	setupMixer();
-
-	setTimerCallback(&OSystem_IPHONE::timerHandler, 10);
-
-	OSystem::initBackend();
-}
-
-bool OSystem_IPHONE::hasFeature(Feature f) {
-	return false;
-}
-
-void OSystem_IPHONE::setFeatureState(Feature f, bool enable) {
-}
-
-bool OSystem_IPHONE::getFeatureState(Feature f) {
-	return false;
-}
-
-const OSystem::GraphicsMode* OSystem_IPHONE::getSupportedGraphicsModes() const {
-	return s_supportedGraphicsModes;
-}
-
-
-int OSystem_IPHONE::getDefaultGraphicsMode() const {
-	return -1;
-}
-
-bool OSystem_IPHONE::setGraphicsMode(const char *mode) {
-	return true;
-}
-
-bool OSystem_IPHONE::setGraphicsMode(int mode) {
-	return true;
-}
-
-int OSystem_IPHONE::getGraphicsMode() const {
-	return -1;
-}
-
-void OSystem_IPHONE::initSize(uint width, uint height) {
-	//printf("initSize(%i, %i)\n", width, height);
-
-	_screenWidth = width;
-	_screenHeight = height;
-
-	free(_offscreen);
-
-	_offscreen = (byte *)malloc(width * height);
-	bzero(_offscreen, width * height);
-
-	free(_overlayBuffer);
-
-	int fullSize = _screenWidth * _screenHeight * sizeof(OverlayColor);
-	_overlayBuffer = (OverlayColor *)malloc(fullSize);
-	clearOverlay();
-
-	free(_fullscreen);
-
-	_fullscreen = (uint16 *)malloc(fullSize);
-	bzero(_fullscreen, fullSize);
-
-	iPhone_initSurface(width, height);
-
-	_fullScreenIsDirty = false;
-	dirtyFullScreen();
-	_mouseVisible = false;
-	_screenChangeCount++;
-	updateScreen();
-}
-
-int16 OSystem_IPHONE::getHeight() {
-	return _screenHeight;
-}
-
-int16 OSystem_IPHONE::getWidth() {
-	return _screenWidth;
-}
-
-void OSystem_IPHONE::setPalette(const byte *colors, uint start, uint num) {
-	//printf("setPalette()\n");
-	const byte *b = colors;
-
-	for (uint i = start; i < start + num; ++i) {
-		_palette[i] = Graphics::RGBToColor<Graphics::ColorMasks<565> >(b[0], b[1], b[2]);
-		b += 4;
-	}
-
-	dirtyFullScreen();
-}
-
-void OSystem_IPHONE::grabPalette(byte *colors, uint start, uint num) {
-	//printf("grabPalette()\n");
-}
-
-void OSystem_IPHONE::copyRectToScreen(const byte *buf, int pitch, int x, int y, int w, int h) {
-	//printf("copyRectToScreen(%i, %i, %i, %i)\n", x, y, w, 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;
-
-	if (!_fullScreenIsDirty) {
-		_dirtyRects.push_back(Common::Rect(x, y, x + w, y + h));
-	}
-
-
-	byte *dst = _offscreen + y * _screenWidth + x;
-	if (_screenWidth == pitch && pitch == w)
-		memcpy(dst, buf, h * w);
-	else {
-		do {
-			memcpy(dst, buf, w);
-			buf += pitch;
-			dst += _screenWidth;
-		} while (--h);
-	}
-}
-
-void OSystem_IPHONE::clipRectToScreen(int16 &x, int16 &y, int16 &w, int16 &h) {
-	if (x < 0) {
-		w += x;
-		x = 0;
-	}
-
-	if (y < 0) {
-		h += y;
-		y = 0;
-	}
-
-	if (w > _screenWidth - x)
-		w = _screenWidth - x;
-
-	if (h > _screenHeight - y)
-		h = _screenHeight - y;
-
-	if (w < 0) {
-		w = 0;
-	}
-
-	if (h < 0) {
-		h = 0;
-	}
-}
-
-void OSystem_IPHONE::updateScreen() {
-	//printf("updateScreen(): %i dirty rects.\n", _dirtyRects.size());
-
-	if (_dirtyRects.size() == 0 && _dirtyOverlayRects.size() == 0 && !_mouseDirty)
-		return;
-
-	internUpdateScreen();
-	_fullScreenIsDirty = false;
-	_fullScreenOverlayIsDirty = false;
-
-	iPhone_updateScreen();
-}
-
-void OSystem_IPHONE::internUpdateScreen() {
-	int16 mouseX = _mouseX - _mouseHotspotX;
-	int16 mouseY = _mouseY - _mouseHotspotY;
-	int16 mouseWidth = _mouseWidth;
-	int16 mouseHeight = _mouseHeight;
-
-	clipRectToScreen(mouseX, mouseY, mouseWidth, mouseHeight);
-
-	Common::Rect mouseRect(mouseX, mouseY, mouseX + mouseWidth, mouseY + mouseHeight);
-
-	if (_mouseDirty) {
-		if (!_fullScreenIsDirty) {
-			_dirtyRects.push_back(_lastDrawnMouseRect);
-			_dirtyRects.push_back(mouseRect);
-		}
-		if (!_fullScreenOverlayIsDirty && _overlayVisible) {
-			_dirtyOverlayRects.push_back(_lastDrawnMouseRect);
-			_dirtyOverlayRects.push_back(mouseRect);
-		}
-		_mouseDirty = false;
-		_lastDrawnMouseRect = mouseRect;
-	}
-
-	while (_dirtyRects.size()) {
-		Common::Rect dirtyRect = _dirtyRects.remove_at(_dirtyRects.size() - 1);
-
-		//printf("Drawing: (%i, %i) -> (%i, %i)\n", dirtyRect.left, dirtyRect.top, dirtyRect.right, dirtyRect.bottom);
-
-		drawDirtyRect(dirtyRect);
-
-		if (_overlayVisible)
-			drawDirtyOverlayRect(dirtyRect);
-
-		drawMouseCursorOnRectUpdate(dirtyRect, mouseRect);
-		updateHardwareSurfaceForRect(dirtyRect);
-	}
-
-	if (_overlayVisible) {
-		while (_dirtyOverlayRects.size()) {
-			Common::Rect dirtyRect = _dirtyOverlayRects.remove_at(_dirtyOverlayRects.size() - 1);
-
-			//printf("Drawing: (%i, %i) -> (%i, %i)\n", dirtyRect.left, dirtyRect.top, dirtyRect.right, dirtyRect.bottom);
-
-			drawDirtyOverlayRect(dirtyRect);
-			drawMouseCursorOnRectUpdate(dirtyRect, mouseRect);
-			updateHardwareSurfaceForRect(dirtyRect);
-		}
-	}
-}
-
-void OSystem_IPHONE::drawDirtyRect(const Common::Rect& dirtyRect) {
-	int h = dirtyRect.bottom - dirtyRect.top;
-	int w = dirtyRect.right - dirtyRect.left;
-
-	byte  *src = &_offscreen[dirtyRect.top * _screenWidth + dirtyRect.left];
-	uint16 *dst = &_fullscreen[dirtyRect.top * _screenWidth + dirtyRect.left];
-	for (int y = h; y > 0; y--) {
-		for (int x = w; x > 0; x--)
-			*dst++ = _palette[*src++];
-
-		dst += _screenWidth - w;
-		src += _screenWidth - w;
-	}
-}
-
-void OSystem_IPHONE::drawDirtyOverlayRect(const Common::Rect& dirtyRect) {
-	int h = dirtyRect.bottom - dirtyRect.top;
-
-	uint16 *src = (uint16 *)&_overlayBuffer[dirtyRect.top * _screenWidth + dirtyRect.left];
-	uint16 *dst = &_fullscreen[dirtyRect.top * _screenWidth + dirtyRect.left];
-	int x = (dirtyRect.right - dirtyRect.left) * 2;
-	for (int y = h; y > 0; y--) {
-		memcpy(dst, src, x);
-		src += _screenWidth;
-		dst += _screenWidth;
-	}
-}
-
-void OSystem_IPHONE::drawMouseCursorOnRectUpdate(const Common::Rect& updatedRect, const Common::Rect& mouseRect) {
-	//draw mouse on top
-	if (_mouseVisible && (updatedRect.intersects(mouseRect))) {
-		int srcX = 0;
-		int srcY = 0;
-		int left = _mouseX - _mouseHotspotX;
-		if (left < 0) {
-			srcX -= left;
-			left = 0;
-		}
-		int top = _mouseY - _mouseHotspotY;
-		if (top < 0) {
-			srcY -= top;
-			top = 0;
-		}
-			//int right = left + _mouseWidth;
-		int bottom = top + _mouseHeight;
-		if (bottom > _screenWidth)
-			bottom = _screenWidth;
-			int displayWidth = _mouseWidth;
-		if (_mouseWidth + left > _screenWidth)
-			displayWidth = _screenWidth - left;
-			int displayHeight = _mouseHeight;
-		if (_mouseHeight + top > _screenHeight)
-			displayHeight = _screenHeight - top;
-		byte *src = &_mouseBuf[srcY * _mouseWidth + srcX];
-		uint16 *dst = &_fullscreen[top * _screenWidth + left];
-		for (int y = displayHeight; y > srcY; y--) {
-			for (int x = displayWidth; x > srcX; x--) {
-				if (*src != _mouseKeyColour)
-					*dst = _palette[*src];
-				dst++;
-				src++;
-			}
-			dst += _screenWidth - displayWidth + srcX;
-			src += _mouseWidth - displayWidth + srcX;
-		}
-	}
-}
-
-void OSystem_IPHONE::updateHardwareSurfaceForRect(const Common::Rect& updatedRect) {
-	iPhone_updateScreenRect(_fullscreen, updatedRect.left, updatedRect.top, updatedRect.right, updatedRect.bottom );
-}
-
-Graphics::Surface *OSystem_IPHONE::lockScreen() {
-	//printf("lockScreen()\n");
-
-	_framebuffer.pixels = _offscreen;
-	_framebuffer.w = _screenWidth;
-	_framebuffer.h = _screenHeight;
-	_framebuffer.pitch = _screenWidth;
-	_framebuffer.bytesPerPixel = 1;
-
-	return &_framebuffer;
-}
-
-void OSystem_IPHONE::unlockScreen() {
-	//printf("unlockScreen()\n");
-	dirtyFullScreen();
-}
-
-void OSystem_IPHONE::setShakePos(int shakeOffset) {
-	//printf("setShakePos(%i)\n", shakeOffset);
-}
-
-void OSystem_IPHONE::showOverlay() {
-	//printf("showOverlay()\n");
-	_overlayVisible = true;
-	dirtyFullOverlayScreen();
-}
-
-void OSystem_IPHONE::hideOverlay() {
-	//printf("hideOverlay()\n");
-	_overlayVisible = false;
-	_dirtyOverlayRects.clear();
-	dirtyFullScreen();
-}
-
-void OSystem_IPHONE::clearOverlay() {
-	//printf("clearOverlay()\n");
-	bzero(_overlayBuffer, _screenWidth * _screenHeight * sizeof(OverlayColor));
-	dirtyFullOverlayScreen();
-}
-
-void OSystem_IPHONE::grabOverlay(OverlayColor *buf, int pitch) {
-	//printf("grabOverlay()\n");
-	int h = _screenHeight;
-	OverlayColor *src = _overlayBuffer;
-
-	do {
-		memcpy(buf, src, _screenWidth * sizeof(OverlayColor));
-		src += _screenWidth;
-		buf += pitch;
-	} while (--h);
-}
-
-void OSystem_IPHONE::copyRectToOverlay(const OverlayColor *buf, int pitch, int x, int y, int w, int h) {
-	//printf("copyRectToOverlay(buf, pitch=%i, x=%i, y=%i, w=%i, h=%i)\n", pitch, x, y, w, 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;
-
-	if (!_fullScreenOverlayIsDirty) {
-		_dirtyOverlayRects.push_back(Common::Rect(x, y, x + w, y + h));
-	}
-
-	OverlayColor *dst = _overlayBuffer + (y * _screenWidth + x);
-	if (_screenWidth == pitch && pitch == w)
-		memcpy(dst, buf, h * w * sizeof(OverlayColor));
-	else {
-		do {
-			memcpy(dst, buf, w * sizeof(OverlayColor));
-			buf += pitch;
-			dst += _screenWidth;
-		} while (--h);
-	}
-}
-
-int16 OSystem_IPHONE::getOverlayHeight() {
-	return _screenHeight;
-}
-
-int16 OSystem_IPHONE::getOverlayWidth() {
-	return _screenWidth;
-}
-
-bool OSystem_IPHONE::showMouse(bool visible) {
-	bool last = _mouseVisible;
-	_mouseVisible = visible;
-	_mouseDirty = true;
-
-	return last;
-}
-
-void OSystem_IPHONE::warpMouse(int x, int y) {
-	//printf("warpMouse()\n");
-
-	_mouseX = x;
-	_mouseY = y;
-	_mouseDirty = true;
-}
-
-void OSystem_IPHONE::dirtyFullScreen() {
-	if (!_fullScreenIsDirty) {
-		_dirtyRects.clear();
-		_dirtyRects.push_back(Common::Rect(0, 0, _screenWidth, _screenHeight));
-		_fullScreenIsDirty = true;
-	}
-}
-
-void OSystem_IPHONE::dirtyFullOverlayScreen() {
-	if (!_fullScreenOverlayIsDirty) {
-		_dirtyOverlayRects.clear();
-		_dirtyOverlayRects.push_back(Common::Rect(0, 0, _screenWidth, _screenHeight));
-		_fullScreenOverlayIsDirty = true;
-	}
-}
-
-void OSystem_IPHONE::setMouseCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, byte keycolor, int cursorTargetScale) {
-	//printf("setMouseCursor(%i, %i)\n", hotspotX, hotspotY);
-
-	if (_mouseBuf != NULL && (_mouseWidth != w || _mouseHeight != h)) {
-		free(_mouseBuf);
-		_mouseBuf = NULL;
-	}
-
-	if (_mouseBuf == NULL)
-		_mouseBuf = (byte *)malloc(w * h);
-
-	_mouseWidth = w;
-	_mouseHeight = h;
-
-	_mouseHotspotX = hotspotX;
-	_mouseHotspotY = hotspotY;
-
-	_mouseKeyColour = keycolor;
-
-	memcpy(_mouseBuf, buf, w * h);
-
-	_mouseDirty = true;
-}
-
-bool OSystem_IPHONE::pollEvent(Common::Event &event) {
-	//printf("pollEvent()\n");
-
-	long curTime = getMillis();
-
-	if (_timerCallback && (curTime >= _timerCallbackNext)) {
-		_timerCallback(_timerCallbackTimer);
-		_timerCallbackNext = curTime + _timerCallbackTimer;
-	}
-
-	if (_needEventRestPeriod) {
-		// Workaround: Some engines can't handle mouse-down and mouse-up events
-		// appearing right after each other, without a call returning no input in between.
-		_needEventRestPeriod = false;
-		return false;
-	}
-
-	if (_queuedInputEvent.type != (Common::EventType)0) {
-		event = _queuedInputEvent;
-		_queuedInputEvent.type = (Common::EventType)0;
-		return true;
-	}
-
-	int eventType;
-	float xUnit, yUnit;
-
-	if (iPhone_fetchEvent(&eventType, &xUnit, &yUnit)) {
-		int x = 0;
-		int y = 0;
-		switch (_screenOrientation) {
-			case kScreenOrientationPortrait:
-				x = (int)(xUnit * _screenWidth);
-				y = (int)(yUnit * _screenHeight);
-				break;
-			case kScreenOrientationLandscape:
-				x = (int)(yUnit * _screenWidth);
-				y = (int)((1.0 - xUnit) * _screenHeight);
-				break;
-			case kScreenOrientationFlippedLandscape:
-				x = (int)((1.0 - yUnit) * _screenWidth);
-				y = (int)(xUnit * _screenHeight);
-				break;
-		}
-
-		switch ((InputEvent)eventType) {
-			case kInputMouseDown:
-				if (!handleEvent_mouseDown(event, x, y))
-					return false;
-				break;
-
-			case kInputMouseUp:
-			if (!handleEvent_mouseUp(event, x, y))
-				return false;
-				break;
-
-			case kInputMouseDragged:
-				if (!handleEvent_mouseDragged(event, x, y))
-					return false;
-				break;
-			case kInputMouseSecondDragged:
-				if (!handleEvent_mouseSecondDragged(event, x, y))
-					return false;
-				break;
-			case kInputMouseSecondDown:
-				_secondaryTapped = true;
-				if (!handleEvent_secondMouseDown(event, x, y))
-					return false;
-				break;
-			case kInputMouseSecondUp:
-				_secondaryTapped = false;
-				if (!handleEvent_secondMouseUp(event, x, y))
-					return false;
-				break;
-			case kInputOrientationChanged:
-				handleEvent_orientationChanged((int)xUnit);
-				return false;
-				break;
-
-			case kInputApplicationSuspended:
-				suspendLoop();
-				return false;
-				break;
-
-			case kInputKeyPressed:
-				handleEvent_keyPressed(event, (int)xUnit);
-				break;
-
-			case kInputSwipe:
-				if (!handleEvent_swipe(event, (int)xUnit))
-					return false;
-				break;
-
-			default:
-				break;
-		}
-
-		return true;
-	}
-	return false;
-}
-
-bool OSystem_IPHONE::handleEvent_mouseDown(Common::Event &event, int x, int y) {
-	//printf("Mouse down at (%u, %u)\n", x, y);
-
-	// Workaround: kInputMouseSecondToggled isn't always sent when the
-	// secondary finger is lifted. Need to make sure we get out of that mode.
-	_secondaryTapped = false;
-
-	if (_touchpadModeEnabled) {
-		_lastPadX = x;
-		_lastPadY = y;
-	} else
-		warpMouse(x, y);
-
-	if (_mouseClickAndDragEnabled) {
-		event.type = Common::EVENT_LBUTTONDOWN;
-		event.mouse.x = _mouseX;
-		event.mouse.y = _mouseY;
-		return true;
-	} else {
-		_lastMouseDown = getMillis();
-	}
-	return false;
-}
-
-bool OSystem_IPHONE::handleEvent_mouseUp(Common::Event &event, int x, int y) {
-	//printf("Mouse up at (%u, %u)\n", x, y);
-
-	if (_secondaryTapped) {
-		_secondaryTapped = false;
-		if (!handleEvent_secondMouseUp(event, x, y))
-			return false;
-	}
-	else if (_mouseClickAndDragEnabled) {
-		event.type = Common::EVENT_LBUTTONUP;
-		event.mouse.x = _mouseX;
-		event.mouse.y = _mouseY;
-	} else {
-		if (getMillis() - _lastMouseDown < 250) {
-			event.type = Common::EVENT_LBUTTONDOWN;
-			event.mouse.x = _mouseX;
-			event.mouse.y = _mouseY;
-
-			_queuedInputEvent.type = Common::EVENT_LBUTTONUP;
-			_queuedInputEvent.mouse.x = _mouseX;
-			_queuedInputEvent.mouse.y = _mouseY;
-			_lastMouseTap = getMillis();
-			_needEventRestPeriod = true;
-		} else
-			return false;
-	}
-
-	return true;
-}
-
-bool OSystem_IPHONE::handleEvent_secondMouseDown(Common::Event &event, int x, int y) {
-	_lastSecondaryDown = getMillis();
-	_gestureStartX = x;
-	_gestureStartY = y;
-
-	if (_mouseClickAndDragEnabled) {
-		event.type = Common::EVENT_LBUTTONUP;
-		event.mouse.x = _mouseX;
-		event.mouse.y = _mouseY;
-
-		_queuedInputEvent.type = Common::EVENT_RBUTTONDOWN;
-		_queuedInputEvent.mouse.x = _mouseX;
-		_queuedInputEvent.mouse.y = _mouseY;
-	}
-	else
-		return false;
-
-	return true;
-}
-
-bool OSystem_IPHONE::handleEvent_secondMouseUp(Common::Event &event, int x, int y) {
-	int curTime = getMillis();
-
-	if (curTime - _lastSecondaryDown < 400 ) {
-		//printf("Right tap!\n");
-		if (curTime - _lastSecondaryTap < 400 && !_overlayVisible) {
-			//printf("Right escape!\n");
-			event.type = Common::EVENT_KEYDOWN;
-			_queuedInputEvent.type = Common::EVENT_KEYUP;
-
-			event.kbd.flags = _queuedInputEvent.kbd.flags = 0;
-			event.kbd.keycode = _queuedInputEvent.kbd.keycode = Common::KEYCODE_ESCAPE;
-			event.kbd.ascii = _queuedInputEvent.kbd.ascii = Common::ASCII_ESCAPE;
-			_needEventRestPeriod = true;
-			_lastSecondaryTap = 0;
-		} else if (!_mouseClickAndDragEnabled) {
-			//printf("Rightclick!\n");
-			event.type = Common::EVENT_RBUTTONDOWN;
-			event.mouse.x = _mouseX;
-			event.mouse.y = _mouseY;
-			_queuedInputEvent.type = Common::EVENT_RBUTTONUP;
-			_queuedInputEvent.mouse.x = _mouseX;
-			_queuedInputEvent.mouse.y = _mouseY;
-			_lastSecondaryTap = curTime;
-			_needEventRestPeriod = true;
-		} else {
-			//printf("Right nothing!\n");
-			return false;
-		}
-	}
-	if (_mouseClickAndDragEnabled) {
-		event.type = Common::EVENT_RBUTTONUP;
-		event.mouse.x = _mouseX;
-		event.mouse.y = _mouseY;
-	}
-
-	return true;
-}
-
-bool OSystem_IPHONE::handleEvent_mouseDragged(Common::Event &event, int x, int y) {
-	if (_lastDragPosX == x && _lastDragPosY == y)
-		return false;
-
-	_lastDragPosX = x;
-	_lastDragPosY = y;
-
-	//printf("Mouse dragged at (%u, %u)\n", x, y);
-	int mouseNewPosX;
-	int mouseNewPosY;
-	if (_touchpadModeEnabled ) {
-		int deltaX = _lastPadX - x;
-		int deltaY = _lastPadY - y;
-		_lastPadX = x;
-		_lastPadY = y;
-
-		mouseNewPosX = (int)(_mouseX - deltaX / 0.5f);
-		mouseNewPosY = (int)(_mouseY - deltaY / 0.5f);
-
-		if (mouseNewPosX < 0)
-			mouseNewPosX = 0;
-		else if (mouseNewPosX > _screenWidth)
-			mouseNewPosX = _screenWidth;
-
-		if (mouseNewPosY < 0)
-			mouseNewPosY = 0;
-		else if (mouseNewPosY > _screenHeight)
-			mouseNewPosY = _screenHeight;
-
-	} else {
-		mouseNewPosX = x;
-		mouseNewPosY = y;
-	}
-
-	event.type = Common::EVENT_MOUSEMOVE;
-	event.mouse.x = mouseNewPosX;
-	event.mouse.y = mouseNewPosY;
-	warpMouse(mouseNewPosX, mouseNewPosY);
-
-	return true;
-}
-
-bool OSystem_IPHONE::handleEvent_mouseSecondDragged(Common::Event &event, int x, int y) {
-	if (_gestureStartX == -1 || _gestureStartY == -1) {
-		return false;
-	}
-
-	static const int kNeededLength = 100;
-	static const int kMaxDeviation = 20;
-
-	int vecX = (x - _gestureStartX);
-	int vecY = (y - _gestureStartY);
-	
-	int absX = abs(vecX);
-	int absY = abs(vecY);
-
-	//printf("(%d, %d)\n", vecX, vecY);
-
-	if (absX >= kNeededLength || absY >= kNeededLength) { // Long enough gesture to react upon.
-		_gestureStartX = -1;
-		_gestureStartY = -1;
-
-		if (absX < kMaxDeviation && vecY >= kNeededLength) {
-			// Swipe down
-			event.type = Common::EVENT_KEYDOWN;
-			_queuedInputEvent.type = Common::EVENT_KEYUP;
-
-			event.kbd.flags = _queuedInputEvent.kbd.flags = 0;
-			event.kbd.keycode = _queuedInputEvent.kbd.keycode = Common::KEYCODE_F5;
-			event.kbd.ascii = _queuedInputEvent.kbd.ascii = Common::ASCII_F5;
-			_needEventRestPeriod = true;
-			return true;
-		}
-		
-		if (absX < kMaxDeviation && -vecY >= kNeededLength) {
-			// Swipe up
-			_mouseClickAndDragEnabled = !_mouseClickAndDragEnabled;
-			const char *dialogMsg;
-			if (_mouseClickAndDragEnabled) {
-				_touchpadModeEnabled = false;
-				dialogMsg = "Mouse-click-and-drag mode enabled.";
-			} else
-				dialogMsg = "Mouse-click-and-drag mode disabled.";
-			GUI::TimedMessageDialog dialog(dialogMsg, 1500);
-			dialog.runModal();
-			return false;
-		}
-		
-		if (absY < kMaxDeviation && vecX >= kNeededLength) {
-			// Swipe right
-			_touchpadModeEnabled = !_touchpadModeEnabled;
-			const char *dialogMsg;
-			if (_touchpadModeEnabled)
-				dialogMsg = "Touchpad mode enabled.";
-			else
-				dialogMsg = "Touchpad mode disabled.";
-			GUI::TimedMessageDialog dialog(dialogMsg, 1500);
-			dialog.runModal();
-			return false;
-
-		}
-		
-		if (absY < kMaxDeviation && -vecX >= kNeededLength) {
-			// Swipe left
-			return false;
-		}
-	}
-
-	return false;
-}
-
-void  OSystem_IPHONE::handleEvent_orientationChanged(int orientation) {
-	//printf("Orientation: %i\n", orientation);
-
-	ScreenOrientation newOrientation;
-	switch (orientation) {
-		case 1:
-			newOrientation = kScreenOrientationPortrait;
-			break;
-		case 3:
-			newOrientation = kScreenOrientationLandscape;
-			break;
-		case 4:
-			newOrientation = kScreenOrientationFlippedLandscape;
-			break;
-		default:
-			return;
-	}
-
-
-	if (_screenOrientation != newOrientation) {
-		_screenOrientation = newOrientation;
-		iPhone_initSurface(_screenWidth, _screenHeight);
-
-		dirtyFullScreen();
-		if (_overlayVisible)
-			dirtyFullOverlayScreen();
-		updateScreen();
-	}
-}
-
-void  OSystem_IPHONE::handleEvent_keyPressed(Common::Event &event, int keyPressed) {
-	int ascii = keyPressed;
-	//printf("key: %i\n", keyPressed);
-
-	// We remap some of the iPhone keyboard keys.
-	// The first ten here are the row of symbols below the numeric keys.
-	switch (keyPressed) {
-		case 45:
-			keyPressed = Common::KEYCODE_F1;
-			ascii = Common::ASCII_F1;
-			break;
-		case 47:
-			keyPressed = Common::KEYCODE_F2;
-			ascii = Common::ASCII_F2;
-			break;
-		case 58:
-			keyPressed = Common::KEYCODE_F3;
-			ascii = Common::ASCII_F3;
-			break;
-		case 59:
-			keyPressed = Common::KEYCODE_F4;
-			ascii = Common::ASCII_F4;
-			break;
-		case 40:
-			keyPressed = Common::KEYCODE_F5;
-			ascii = Common::ASCII_F5;
-			break;
-		case 41:
-			keyPressed = Common::KEYCODE_F6;
-			ascii = Common::ASCII_F6;
-			break;
-		case 36:
-			keyPressed = Common::KEYCODE_F7;
-			ascii = Common::ASCII_F7;
-			break;
-		case 38:
-			keyPressed = Common::KEYCODE_F8;
-			ascii = Common::ASCII_F8;
-			break;
-		case 64:
-			keyPressed = Common::KEYCODE_F9;
-			ascii = Common::ASCII_F9;
-			break;
-		case 34:
-			keyPressed = Common::KEYCODE_F10;
-			ascii = Common::ASCII_F10;
-			break;
-		case 10:
-			keyPressed = Common::KEYCODE_RETURN;
-			ascii = Common::ASCII_RETURN;
-			break;
-	}
-	event.type = Common::EVENT_KEYDOWN;
-	_queuedInputEvent.type = Common::EVENT_KEYUP;
-
-	event.kbd.flags = _queuedInputEvent.kbd.flags = 0;
-	event.kbd.keycode = _queuedInputEvent.kbd.keycode = (Common::KeyCode)keyPressed;
-	event.kbd.ascii = _queuedInputEvent.kbd.ascii = ascii;
-	_needEventRestPeriod = true;
-}
-
-bool OSystem_IPHONE::handleEvent_swipe(Common::Event &event, int direction) {
-	Common::KeyCode keycode = Common::KEYCODE_INVALID;
-	switch (_screenOrientation) {
-		case kScreenOrientationPortrait:
-			switch ((UIViewSwipeDirection)direction) {
-				case kUIViewSwipeUp:
-					keycode = Common::KEYCODE_UP;
-					break;
-				case kUIViewSwipeDown:
-					keycode = Common::KEYCODE_DOWN;
-					break;
-				case kUIViewSwipeLeft:
-					keycode = Common::KEYCODE_LEFT;
-					break;
-				case kUIViewSwipeRight:
-					keycode = Common::KEYCODE_RIGHT;
-					break;
-				default:
-					return false;
-			}
-			break;
-		case kScreenOrientationLandscape:
-			switch ((UIViewSwipeDirection)direction) {
-				case kUIViewSwipeUp:
-					keycode = Common::KEYCODE_LEFT;
-					break;
-				case kUIViewSwipeDown:
-					keycode = Common::KEYCODE_RIGHT;
-					break;
-				case kUIViewSwipeLeft:
-					keycode = Common::KEYCODE_DOWN;
-					break;
-				case kUIViewSwipeRight:
-					keycode = Common::KEYCODE_UP;
-					break;
-				default:
-					return false;
-			}
-			break;
-		case kScreenOrientationFlippedLandscape:
-			switch ((UIViewSwipeDirection)direction) {
-				case kUIViewSwipeUp:
-					keycode = Common::KEYCODE_RIGHT;
-					break;
-				case kUIViewSwipeDown:
-					keycode = Common::KEYCODE_LEFT;
-					break;
-				case kUIViewSwipeLeft:
-					keycode = Common::KEYCODE_UP;
-					break;
-				case kUIViewSwipeRight:
-					keycode = Common::KEYCODE_DOWN;
-					break;
-				default:
-					return false;
-			}
-			break;
-	}
-
-	event.kbd.keycode = _queuedInputEvent.kbd.keycode = keycode;
-	event.kbd.ascii = _queuedInputEvent.kbd.ascii = 0;
-	event.type = Common::EVENT_KEYDOWN;
-	_queuedInputEvent.type = Common::EVENT_KEYUP;
-	event.kbd.flags = _queuedInputEvent.kbd.flags = 0;
-	_needEventRestPeriod = true;
-
-	return true;
-}
-
-void OSystem_IPHONE::suspendLoop() {
-	bool done = false;
-	int eventType;
-	float xUnit, yUnit;
-	uint32 startTime = getMillis();
-
-	stopSoundsystem();
-
-	while (!done) {
-		if (iPhone_fetchEvent(&eventType, &xUnit, &yUnit))
-			if ((InputEvent)eventType == kInputApplicationResumed)
-				done = true;
-		usleep(100000);
-	}
-
-	startSoundsystem();
-
-	_timeSuspended += getMillis() - startTime;
-}
-
-uint32 OSystem_IPHONE::getMillis() {
-	//printf("getMillis()\n");
-
-	struct timeval currentTime;
-	gettimeofday(&currentTime, NULL);
-	return (uint32)(((currentTime.tv_sec - _startTime.tv_sec) * 1000) +
-	                ((currentTime.tv_usec - _startTime.tv_usec) / 1000)) - _timeSuspended;
-}
-
-void OSystem_IPHONE::delayMillis(uint msecs) {
-	//printf("delayMillis(%d)\n", msecs);
-	usleep(msecs * 1000);
-}
-
-OSystem::MutexRef OSystem_IPHONE::createMutex(void) {
-	pthread_mutexattr_t attr;
-	pthread_mutexattr_init(&attr);
-	pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
-
-	pthread_mutex_t *mutex = (pthread_mutex_t *) malloc(sizeof(pthread_mutex_t));
-	if (pthread_mutex_init(mutex, &attr) != 0) {
-		printf("pthread_mutex_init() failed!\n");
-		free(mutex);
-		return NULL;
-	}
-
-	return (MutexRef)mutex;
-}
-
-void OSystem_IPHONE::lockMutex(MutexRef mutex) {
-	if (pthread_mutex_lock((pthread_mutex_t *) mutex) != 0) {
-		printf("pthread_mutex_lock() failed!\n");
-	}
-}
-
-void OSystem_IPHONE::unlockMutex(MutexRef mutex) {
-	if (pthread_mutex_unlock((pthread_mutex_t *) mutex) != 0) {
-		printf("pthread_mutex_unlock() failed!\n");
-	}
-}
-
-void OSystem_IPHONE::deleteMutex(MutexRef mutex) {
-	if (pthread_mutex_destroy((pthread_mutex_t *) mutex) != 0) {
-		printf("pthread_mutex_destroy() failed!\n");
-	} else {
-		free(mutex);
-	}
-}
-
-void OSystem_IPHONE::AQBufferCallback(void *in, AudioQueueRef inQ, AudioQueueBufferRef outQB) {
-	//printf("AQBufferCallback()\n");
-	if (s_AudioQueue.frameCount > 0 && s_soundCallback != NULL) {
-		outQB->mAudioDataByteSize = 4 * s_AudioQueue.frameCount;
-		s_soundCallback(s_soundParam, (byte *)outQB->mAudioData, outQB->mAudioDataByteSize);
-		AudioQueueEnqueueBuffer(inQ, outQB, 0, NULL);
-	} else {
-		AudioQueueStop(s_AudioQueue.queue, false);
-	}
-}
-
-void OSystem_IPHONE::mixCallback(void *sys, byte *samples, int len) {
-	OSystem_IPHONE *this_ = (OSystem_IPHONE *)sys;
-	assert(this_);
-
-	if (this_->_mixer) {
-		this_->_mixer->mixCallback(samples, len);
-	}
-}
-
-void OSystem_IPHONE::setupMixer() {
-	//printf("setSoundCallback()\n");
-	_mixer = new Audio::MixerImpl(this);
-
-	s_soundCallback = mixCallback;
-	s_soundParam = this;
-
-	startSoundsystem();
-}
-
-void OSystem_IPHONE::startSoundsystem() {
-	s_AudioQueue.dataFormat.mSampleRate = AUDIO_SAMPLE_RATE;
-	s_AudioQueue.dataFormat.mFormatID = kAudioFormatLinearPCM;
-	s_AudioQueue.dataFormat.mFormatFlags = kLinearPCMFormatFlagIsSignedInteger | kAudioFormatFlagIsPacked;
-	s_AudioQueue.dataFormat.mBytesPerPacket = 4;
-	s_AudioQueue.dataFormat.mFramesPerPacket = 1;
-	s_AudioQueue.dataFormat.mBytesPerFrame = 4;
-	s_AudioQueue.dataFormat.mChannelsPerFrame = 2;
-	s_AudioQueue.dataFormat.mBitsPerChannel = 16;
-	s_AudioQueue.frameCount = WAVE_BUFFER_SIZE;
-
-	if (AudioQueueNewOutput(&s_AudioQueue.dataFormat, AQBufferCallback, &s_AudioQueue, 0, kCFRunLoopCommonModes, 0, &s_AudioQueue.queue)) {
-		printf("Couldn't set the AudioQueue callback!\n");
-		_mixer->setReady(false);
-		return;
-	}
-
-	uint32 bufferBytes = s_AudioQueue.frameCount * s_AudioQueue.dataFormat.mBytesPerFrame;
-
-	for (int i = 0; i < AUDIO_BUFFERS; i++) {
-		if (AudioQueueAllocateBuffer(s_AudioQueue.queue, bufferBytes, &s_AudioQueue.buffers[i])) {
-			printf("Error allocating AudioQueue buffer!\n");
-			_mixer->setReady(false);
-			return;
-		}
-
-		AQBufferCallback(&s_AudioQueue, s_AudioQueue.queue, s_AudioQueue.buffers[i]);
-	}
-
-	AudioQueueSetParameter(s_AudioQueue.queue, kAudioQueueParam_Volume, 1.0);
-	if (AudioQueueStart(s_AudioQueue.queue, NULL)) {
-		printf("Error starting the AudioQueue!\n");
-		_mixer->setReady(false);
-		return;
-	}
-
-	_mixer->setOutputRate(AUDIO_SAMPLE_RATE);
-	_mixer->setReady(true);
-}
-
-void OSystem_IPHONE::stopSoundsystem() {
-	AudioQueueStop(s_AudioQueue.queue, true);
-
-	for (int i = 0; i < AUDIO_BUFFERS; i++) {
-		AudioQueueFreeBuffer(s_AudioQueue.queue, s_AudioQueue.buffers[i]);
-	}
-
-	AudioQueueDispose(s_AudioQueue.queue, true);
-	_mixer->setReady(false);
-}
-
-int OSystem_IPHONE::getOutputSampleRate() const {
-	return AUDIO_SAMPLE_RATE;
-}
-
-void OSystem_IPHONE::setTimerCallback(TimerProc callback, int interval) {
-	//printf("setTimerCallback()\n");
-
-	if (callback != NULL) {
-		_timerCallbackTimer = interval;
-		_timerCallbackNext = getMillis() + interval;
-		_timerCallback = callback;
-	} else
-		_timerCallback = NULL;
-}
-
-void OSystem_IPHONE::quit() {
-}
-
-void OSystem_IPHONE::getTimeAndDate(struct tm &t) const {
-	time_t curTime = time(0);
-	t = *localtime(&curTime);
-}
-
-Common::SaveFileManager *OSystem_IPHONE::getSavefileManager() {
-	assert(_savefile);
-	return _savefile;
-}
-
-Audio::Mixer *OSystem_IPHONE::getMixer() {
-	assert(_mixer);
-	return _mixer;
-}
-
-Common::TimerManager *OSystem_IPHONE::getTimerManager() {
-	assert(_timer);
-	return _timer;
-}
-
-OSystem *OSystem_IPHONE_create() {
-	return new OSystem_IPHONE();
-}
-
-Common::SeekableReadStream *OSystem_IPHONE::createConfigReadStream() {
-#ifdef IPHONE_OFFICIAL
-	char buf[256];
-	strncpy(buf, iPhone_getDocumentsDir(), 256);
-	strncat(buf, "/Preferences", 256 - strlen(buf) );
-	Common::FSNode file(buf);
-#else
-	Common::FSNode file(SCUMMVM_PREFS_PATH);
-#endif
-	return file.createReadStream();
-}
-
-Common::WriteStream *OSystem_IPHONE::createConfigWriteStream() {
-#ifdef IPHONE_OFFICIAL
-	char buf[256];
-	strncpy(buf, iPhone_getDocumentsDir(), 256);
-	strncat(buf, "/Preferences", 256 - strlen(buf) );
-	Common::FSNode file(buf);
-#else
-	Common::FSNode file(SCUMMVM_PREFS_PATH);
-#endif
-	return file.createWriteStream();
-}
-
-void OSystem_IPHONE::addSysArchivesToSearchSet(Common::SearchSet &s, int priority) {
-	// Get URL of the Resource directory of the .app bundle
-	CFURLRef fileUrl = CFBundleCopyResourcesDirectoryURL(CFBundleGetMainBundle());
-	if (fileUrl) {
-		// Try to convert the URL to an absolute path
-		UInt8 buf[MAXPATHLEN];
-		if (CFURLGetFileSystemRepresentation(fileUrl, true, buf, sizeof(buf))) {
-			// Success: Add it to the search path
-			Common::String bundlePath((const char *)buf);
-			s.add("__OSX_BUNDLE__", new Common::FSDirectory(bundlePath), priority);
-		}
-		CFRelease(fileUrl);
-	}
-}
-
-void iphone_main(int argc, char *argv[]) {
-
-	//OSystem_IPHONE::migrateApp();
-
-	FILE *newfp = fopen("/var/mobile/.scummvm.log", "a");
-	if (newfp != NULL) {
-		fclose(stdout);
-		fclose(stderr);
-		*stdout = *newfp;
-		*stderr = *newfp;
-		setbuf(stdout, NULL);
-		setbuf(stderr, NULL);
-
-		//extern int gDebugLevel;
-		//gDebugLevel = 10;
-	}
-
-#ifdef IPHONE_OFFICIAL
-	chdir( iPhone_getDocumentsDir() );
-#else
-	system("mkdir " SCUMMVM_ROOT_PATH);
-	system("mkdir " SCUMMVM_SAVE_PATH);
-
-	chdir("/var/mobile/");
-#endif
-
-	g_system = OSystem_IPHONE_create();
-	assert(g_system);
-
-	// Invoke the actual ScummVM main entry point:
-	scummvm_main(argc, argv);
-	g_system->quit();       // TODO: Consider removing / replacing this!
-}

Deleted: scummvm/branches/gsoc2009-mods/backends/platform/iphone/osys_iphone.h
===================================================================
--- scummvm/branches/gsoc2009-mods/backends/platform/iphone/osys_iphone.h	2009-07-17 20:51:40 UTC (rev 42573)
+++ scummvm/branches/gsoc2009-mods/backends/platform/iphone/osys_iphone.h	2009-07-17 21:23:54 UTC (rev 42574)
@@ -1,209 +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 "graphics/surface.h"
-#include "iphone_common.h"
-#include "backends/base-backend.h"
-#include "common/events.h"
-#include "sound/mixer_intern.h"
-#include "backends/fs/posix/posix-fs-factory.h"
-#include "graphics/colormasks.h"
-
-#include <AudioToolbox/AudioQueue.h>
-
-#define AUDIO_BUFFERS 3
-#define WAVE_BUFFER_SIZE 2048
-#define AUDIO_SAMPLE_RATE 44100
-
-#define SCUMMVM_ROOT_PATH "/var/mobile/Library/ScummVM"
-#define SCUMMVM_SAVE_PATH SCUMMVM_ROOT_PATH "/Savegames"
-#define SCUMMVM_PREFS_PATH SCUMMVM_ROOT_PATH "/Preferences"
-
-typedef void (*SoundProc)(void *param, byte *buf, int len);
-typedef int (*TimerProc)(int interval);
-
-typedef struct AQCallbackStruct {
-    AudioQueueRef queue;
-    uint32 frameCount;
-    AudioQueueBufferRef buffers[AUDIO_BUFFERS];
-    AudioStreamBasicDescription dataFormat;
-} AQCallbackStruct;
-
-class OSystem_IPHONE : public BaseBackend {
-protected:
-
-	static const OSystem::GraphicsMode s_supportedGraphicsModes[];
-	static AQCallbackStruct s_AudioQueue;
-	static SoundProc s_soundCallback;
-	static void *s_soundParam;
-
-	Common::SaveFileManager *_savefile;
-	Audio::MixerImpl *_mixer;
-	Common::TimerManager *_timer;
-
-	Graphics::Surface _framebuffer;
-	byte *_offscreen;
-	OverlayColor  *_overlayBuffer;
-	uint16 *_fullscreen;
-
-	uint16  _palette[256];
-	bool _overlayVisible;
-	uint16 _screenWidth;
-	uint16 _screenHeight;
-
-	struct timeval _startTime;
-	uint32 _timeSuspended;
-
-	bool _mouseVisible;
-	byte *_mouseBuf;
-	byte _mouseKeyColour;
-	uint _mouseWidth, _mouseHeight;
-	uint _mouseX, _mouseY;
-	int _mouseHotspotX, _mouseHotspotY;
-	bool _mouseDirty;
-	long _lastMouseDown;
-	long _lastMouseTap;
-	Common::Rect _lastDrawnMouseRect;
-	Common::Event _queuedInputEvent;
-	bool _needEventRestPeriod;
-	bool _secondaryTapped;
-	long _lastSecondaryDown;
-	long _lastSecondaryTap;
-	int _gestureStartX, _gestureStartY;
-	bool _mouseClickAndDragEnabled;
-	bool _touchpadModeEnabled;
-	int _lastPadX;
-	int _lastPadY;
-	int _lastDragPosX;
-	int _lastDragPosY;
-
-	int _timerCallbackNext;
-	int _timerCallbackTimer;
-	TimerProc _timerCallback;
-
-	Common::Array<Common::Rect> _dirtyRects;
-	Common::Array<Common::Rect> _dirtyOverlayRects;
-	ScreenOrientation _screenOrientation;
-	bool _fullScreenIsDirty;
-	bool _fullScreenOverlayIsDirty;
-	int _screenChangeCount;
-	FilesystemFactory *_fsFactory;
-
-public:
-
-	OSystem_IPHONE();
-	virtual ~OSystem_IPHONE();
-
-	virtual void initBackend();
-
-	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;
-	bool setGraphicsMode(const char *name);
-	virtual bool setGraphicsMode(int mode);
-	virtual int getGraphicsMode() const;
-	virtual void initSize(uint width, uint height);
-	virtual int16 getHeight();
-	virtual int16 getWidth();
-	virtual void setPalette(const byte *colors, uint start, uint num);
-	virtual void grabPalette(byte *colors, uint start, uint num);
-	virtual void copyRectToScreen(const byte *buf, int pitch, int x, int y, int w, int h);
-	virtual void updateScreen();
-	virtual Graphics::Surface *lockScreen();
-	virtual void unlockScreen();
-	virtual void setShakePos(int shakeOffset);
-
-	virtual void showOverlay();
-	virtual void hideOverlay();
-	virtual void clearOverlay();
-	virtual void grabOverlay(OverlayColor *buf, int pitch);
-	virtual void copyRectToOverlay(const OverlayColor *buf, int pitch, int x, int y, int w, int h);
-	virtual int16 getOverlayHeight();
-	virtual int16 getOverlayWidth();
-	virtual Graphics::PixelFormat getOverlayFormat() const { return Graphics::createPixelFormat<565>(); }
-
-	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 bool pollEvent(Common::Event &event);
-	virtual uint32 getMillis();
-	virtual void delayMillis(uint msecs);
-
-	virtual MutexRef createMutex(void);
-	virtual void lockMutex(MutexRef mutex);
-	virtual void unlockMutex(MutexRef mutex);
-	virtual void deleteMutex(MutexRef mutex);
-
-	static void mixCallback(void *sys, byte *samples, int len);
-	virtual void setupMixer(void);
-	virtual int getOutputSampleRate() const;
-	virtual void setTimerCallback(TimerProc callback, int interval);
- 	virtual int getScreenChangeID() const { return _screenChangeCount; }
-	virtual void quit();
-
-	FilesystemFactory *getFilesystemFactory() { return _fsFactory; }
-	virtual void addSysArchivesToSearchSet(Common::SearchSet &s, int priority = 0);
-	virtual void getTimeAndDate(struct tm &t) const;
-
-	virtual Common::SaveFileManager *getSavefileManager();
-	virtual Audio::Mixer *getMixer();
-	virtual Common::TimerManager *getTimerManager();
-
-	void startSoundsystem();
-	void stopSoundsystem();
-
-	virtual Common::SeekableReadStream *createConfigReadStream();
-	virtual Common::WriteStream *createConfigWriteStream();
-
-protected:
-	void internUpdateScreen();
-	void dirtyFullScreen();
-	void dirtyFullOverlayScreen();
-	void clipRectToScreen(int16 &x, int16 &y, int16 &w, int16 &h);
-	void suspendLoop();
-	void drawDirtyRect(const Common::Rect& dirtyRect);
-	void drawDirtyOverlayRect(const Common::Rect& dirtyRect);
-	void drawMouseCursorOnRectUpdate(const Common::Rect& updatedRect, const Common::Rect& mouseRect);
-	void updateHardwareSurfaceForRect(const Common::Rect& updatedRect);
-	static void AQBufferCallback(void *in, AudioQueueRef inQ, AudioQueueBufferRef outQB);
-	static int timerHandler(int t);
-
-	bool handleEvent_swipe(Common::Event &event, int direction);
-	void handleEvent_keyPressed(Common::Event &event, int keyPressed);
-	void handleEvent_orientationChanged(int orientation);
-
-	bool handleEvent_mouseDown(Common::Event &event, int x, int y);
-	bool handleEvent_mouseUp(Common::Event &event, int x, int y);
-
-	bool handleEvent_secondMouseDown(Common::Event &event, int x, int y);
-	bool handleEvent_secondMouseUp(Common::Event &event, int x, int y);
-
-	bool handleEvent_mouseDragged(Common::Event &event, int x, int y);
-	bool handleEvent_mouseSecondDragged(Common::Event &event, int x, int y);
-};

Copied: scummvm/branches/gsoc2009-mods/backends/platform/iphone/osys_main.cpp (from rev 42568, scummvm/trunk/backends/platform/iphone/osys_main.cpp)
===================================================================
--- scummvm/branches/gsoc2009-mods/backends/platform/iphone/osys_main.cpp	                        (rev 0)
+++ scummvm/branches/gsoc2009-mods/backends/platform/iphone/osys_main.cpp	2009-07-17 21:23:54 UTC (rev 42574)
@@ -0,0 +1,296 @@
+/* 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 <unistd.h>
+#include <pthread.h>
+
+#include <sys/time.h>
+
+#include "common/scummsys.h"
+#include "common/util.h"
+#include "common/rect.h"
+#include "common/file.h"
+#include "common/fs.h"
+
+#include "base/main.h"
+
+#include "backends/saves/default/default-saves.h"
+#include "backends/timer/default/default-timer.h"
+#include "sound/mixer.h"
+#include "sound/mixer_intern.h"
+
+#include "osys_main.h"
+
+
+const OSystem::GraphicsMode OSystem_IPHONE::s_supportedGraphicsModes[] = {
+	{0, 0, 0}
+};
+
+AQCallbackStruct OSystem_IPHONE::s_AudioQueue;
+SoundProc OSystem_IPHONE::s_soundCallback = NULL;
+void *OSystem_IPHONE::s_soundParam = NULL;
+
+OSystem_IPHONE::OSystem_IPHONE() :
+	_savefile(NULL), _mixer(NULL), _timer(NULL), _offscreen(NULL),
+	_overlayVisible(false), _overlayBuffer(NULL), _fullscreen(NULL),
+	_mouseHeight(0), _mouseWidth(0), _mouseBuf(NULL), _lastMouseTap(0),
+	_secondaryTapped(false), _lastSecondaryTap(0), _screenOrientation(kScreenOrientationFlippedLandscape),
+	_needEventRestPeriod(false), _mouseClickAndDragEnabled(false), _touchpadModeEnabled(true),
+	_gestureStartX(-1), _gestureStartY(-1), _fullScreenIsDirty(false), _fullScreenOverlayIsDirty(false),
+	_mouseDirty(false), _timeSuspended(0), _lastDragPosX(-1), _lastDragPosY(-1), _screenChangeCount(0)
+
+{
+	_queuedInputEvent.type = (Common::EventType)0;
+	_lastDrawnMouseRect = Common::Rect(0, 0, 0, 0);
+
+	_fsFactory = new POSIXFilesystemFactory();
+}
+
+OSystem_IPHONE::~OSystem_IPHONE() {
+	AudioQueueDispose(s_AudioQueue.queue, true);
+
+	delete _fsFactory;
+	delete _savefile;
+	delete _mixer;
+	delete _timer;
+	delete _offscreen;
+	delete _fullscreen;
+}
+
+int OSystem_IPHONE::timerHandler(int t) {
+	DefaultTimerManager *tm = (DefaultTimerManager *)g_system->getTimerManager();
+	tm->handler();
+	return t;
+}
+
+void OSystem_IPHONE::initBackend() {
+#ifdef IPHONE_OFFICIAL
+	_savefile = new DefaultSaveFileManager(iPhone_getDocumentsDir());
+#else
+	_savefile = new DefaultSaveFileManager(SCUMMVM_SAVE_PATH);
+#endif
+
+	_timer = new DefaultTimerManager();
+
+	gettimeofday(&_startTime, NULL);
+
+	setupMixer();
+
+	setTimerCallback(&OSystem_IPHONE::timerHandler, 10);
+
+	OSystem::initBackend();
+}
+
+bool OSystem_IPHONE::hasFeature(Feature f) {
+	return false;
+}
+
+void OSystem_IPHONE::setFeatureState(Feature f, bool enable) {
+}
+
+bool OSystem_IPHONE::getFeatureState(Feature f) {
+	return false;
+}
+
+void OSystem_IPHONE::suspendLoop() {
+	bool done = false;
+	int eventType;
+	float xUnit, yUnit;
+	uint32 startTime = getMillis();
+
+	stopSoundsystem();
+
+	while (!done) {
+		if (iPhone_fetchEvent(&eventType, &xUnit, &yUnit))
+			if ((InputEvent)eventType == kInputApplicationResumed)
+				done = true;
+		usleep(100000);
+	}
+
+	startSoundsystem();
+
+	_timeSuspended += getMillis() - startTime;
+}
+
+uint32 OSystem_IPHONE::getMillis() {
+	//printf("getMillis()\n");
+
+	struct timeval currentTime;
+	gettimeofday(&currentTime, NULL);
+	return (uint32)(((currentTime.tv_sec - _startTime.tv_sec) * 1000) +
+	                ((currentTime.tv_usec - _startTime.tv_usec) / 1000)) - _timeSuspended;
+}
+
+void OSystem_IPHONE::delayMillis(uint msecs) {
+	//printf("delayMillis(%d)\n", msecs);
+	usleep(msecs * 1000);
+}
+
+OSystem::MutexRef OSystem_IPHONE::createMutex(void) {
+	pthread_mutexattr_t attr;
+	pthread_mutexattr_init(&attr);
+	pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
+
+	pthread_mutex_t *mutex = (pthread_mutex_t *) malloc(sizeof(pthread_mutex_t));
+	if (pthread_mutex_init(mutex, &attr) != 0) {
+		printf("pthread_mutex_init() failed!\n");
+		free(mutex);
+		return NULL;
+	}
+
+	return (MutexRef)mutex;
+}
+
+void OSystem_IPHONE::lockMutex(MutexRef mutex) {
+	if (pthread_mutex_lock((pthread_mutex_t *) mutex) != 0) {
+		printf("pthread_mutex_lock() failed!\n");
+	}
+}
+
+void OSystem_IPHONE::unlockMutex(MutexRef mutex) {
+	if (pthread_mutex_unlock((pthread_mutex_t *) mutex) != 0) {
+		printf("pthread_mutex_unlock() failed!\n");
+	}
+}
+
+void OSystem_IPHONE::deleteMutex(MutexRef mutex) {
+	if (pthread_mutex_destroy((pthread_mutex_t *) mutex) != 0) {
+		printf("pthread_mutex_destroy() failed!\n");
+	} else {
+		free(mutex);
+	}
+}
+
+
+void OSystem_IPHONE::setTimerCallback(TimerProc callback, int interval) {
+	//printf("setTimerCallback()\n");
+
+	if (callback != NULL) {
+		_timerCallbackTimer = interval;
+		_timerCallbackNext = getMillis() + interval;
+		_timerCallback = callback;
+	} else
+		_timerCallback = NULL;
+}
+
+void OSystem_IPHONE::quit() {
+}
+
+void OSystem_IPHONE::getTimeAndDate(struct tm &t) const {
+	time_t curTime = time(0);
+	t = *localtime(&curTime);
+}
+
+Common::SaveFileManager *OSystem_IPHONE::getSavefileManager() {
+	assert(_savefile);
+	return _savefile;
+}
+
+Audio::Mixer *OSystem_IPHONE::getMixer() {
+	assert(_mixer);
+	return _mixer;
+}
+
+Common::TimerManager *OSystem_IPHONE::getTimerManager() {
+	assert(_timer);
+	return _timer;
+}
+
+OSystem *OSystem_IPHONE_create() {
+	return new OSystem_IPHONE();
+}
+
+Common::SeekableReadStream *OSystem_IPHONE::createConfigReadStream() {
+#ifdef IPHONE_OFFICIAL
+	char buf[256];
+	strncpy(buf, iPhone_getDocumentsDir(), 256);
+	strncat(buf, "/Preferences", 256 - strlen(buf) );
+	Common::FSNode file(buf);
+#else
+	Common::FSNode file(SCUMMVM_PREFS_PATH);
+#endif
+	return file.createReadStream();
+}
+
+Common::WriteStream *OSystem_IPHONE::createConfigWriteStream() {
+#ifdef IPHONE_OFFICIAL
+	char buf[256];
+	strncpy(buf, iPhone_getDocumentsDir(), 256);
+	strncat(buf, "/Preferences", 256 - strlen(buf) );
+	Common::FSNode file(buf);
+#else
+	Common::FSNode file(SCUMMVM_PREFS_PATH);
+#endif
+	return file.createWriteStream();
+}
+
+void OSystem_IPHONE::addSysArchivesToSearchSet(Common::SearchSet &s, int priority) {
+	// Get URL of the Resource directory of the .app bundle
+	CFURLRef fileUrl = CFBundleCopyResourcesDirectoryURL(CFBundleGetMainBundle());
+	if (fileUrl) {
+		// Try to convert the URL to an absolute path
+		UInt8 buf[MAXPATHLEN];
+		if (CFURLGetFileSystemRepresentation(fileUrl, true, buf, sizeof(buf))) {
+			// Success: Add it to the search path
+			Common::String bundlePath((const char *)buf);
+			s.add("__OSX_BUNDLE__", new Common::FSDirectory(bundlePath), priority);
+		}
+		CFRelease(fileUrl);
+	}
+}
+
+void iphone_main(int argc, char *argv[]) {
+
+	//OSystem_IPHONE::migrateApp();
+
+	FILE *newfp = fopen("/var/mobile/.scummvm.log", "a");
+	if (newfp != NULL) {
+		fclose(stdout);
+		fclose(stderr);
+		*stdout = *newfp;
+		*stderr = *newfp;
+		setbuf(stdout, NULL);
+		setbuf(stderr, NULL);
+
+		//extern int gDebugLevel;
+		//gDebugLevel = 10;
+	}
+
+#ifdef IPHONE_OFFICIAL
+	chdir( iPhone_getDocumentsDir() );
+#else
+	system("mkdir " SCUMMVM_ROOT_PATH);
+	system("mkdir " SCUMMVM_SAVE_PATH);
+
+	chdir("/var/mobile/");
+#endif
+
+	g_system = OSystem_IPHONE_create();
+	assert(g_system);
+
+	// Invoke the actual ScummVM main entry point:
+	scummvm_main(argc, argv);
+	g_system->quit();       // TODO: Consider removing / replacing this!
+}

Copied: scummvm/branches/gsoc2009-mods/backends/platform/iphone/osys_main.h (from rev 42568, scummvm/trunk/backends/platform/iphone/osys_main.h)
===================================================================
--- scummvm/branches/gsoc2009-mods/backends/platform/iphone/osys_main.h	                        (rev 0)
+++ scummvm/branches/gsoc2009-mods/backends/platform/iphone/osys_main.h	2009-07-17 21:23:54 UTC (rev 42574)
@@ -0,0 +1,209 @@
+/* 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 "graphics/surface.h"
+#include "iphone_common.h"
+#include "backends/base-backend.h"
+#include "common/events.h"
+#include "sound/mixer_intern.h"
+#include "backends/fs/posix/posix-fs-factory.h"
+#include "graphics/colormasks.h"
+
+#include <AudioToolbox/AudioQueue.h>
+
+#define AUDIO_BUFFERS 3
+#define WAVE_BUFFER_SIZE 2048
+#define AUDIO_SAMPLE_RATE 44100
+
+#define SCUMMVM_ROOT_PATH "/var/mobile/Library/ScummVM"
+#define SCUMMVM_SAVE_PATH SCUMMVM_ROOT_PATH "/Savegames"
+#define SCUMMVM_PREFS_PATH SCUMMVM_ROOT_PATH "/Preferences"
+
+typedef void (*SoundProc)(void *param, byte *buf, int len);
+typedef int (*TimerProc)(int interval);
+
+typedef struct AQCallbackStruct {
+    AudioQueueRef queue;
+    uint32 frameCount;
+    AudioQueueBufferRef buffers[AUDIO_BUFFERS];
+    AudioStreamBasicDescription dataFormat;
+} AQCallbackStruct;
+
+class OSystem_IPHONE : public BaseBackend {
+protected:
+
+	static const OSystem::GraphicsMode s_supportedGraphicsModes[];
+	static AQCallbackStruct s_AudioQueue;
+	static SoundProc s_soundCallback;
+	static void *s_soundParam;
+
+	Common::SaveFileManager *_savefile;
+	Audio::MixerImpl *_mixer;
+	Common::TimerManager *_timer;
+
+	Graphics::Surface _framebuffer;
+	byte *_offscreen;
+	OverlayColor  *_overlayBuffer;
+	uint16 *_fullscreen;
+
+	uint16  _palette[256];
+	bool _overlayVisible;
+	uint16 _screenWidth;
+	uint16 _screenHeight;
+
+	struct timeval _startTime;
+	uint32 _timeSuspended;
+
+	bool _mouseVisible;
+	byte *_mouseBuf;
+	byte _mouseKeyColour;
+	uint _mouseWidth, _mouseHeight;
+	uint _mouseX, _mouseY;
+	int _mouseHotspotX, _mouseHotspotY;
+	bool _mouseDirty;
+	long _lastMouseDown;
+	long _lastMouseTap;
+	Common::Rect _lastDrawnMouseRect;
+	Common::Event _queuedInputEvent;
+	bool _needEventRestPeriod;
+	bool _secondaryTapped;
+	long _lastSecondaryDown;
+	long _lastSecondaryTap;
+	int _gestureStartX, _gestureStartY;
+	bool _mouseClickAndDragEnabled;
+	bool _touchpadModeEnabled;
+	int _lastPadX;
+	int _lastPadY;
+	int _lastDragPosX;
+	int _lastDragPosY;
+
+	int _timerCallbackNext;
+	int _timerCallbackTimer;
+	TimerProc _timerCallback;
+
+	Common::Array<Common::Rect> _dirtyRects;
+	Common::Array<Common::Rect> _dirtyOverlayRects;
+	ScreenOrientation _screenOrientation;
+	bool _fullScreenIsDirty;
+	bool _fullScreenOverlayIsDirty;
+	int _screenChangeCount;
+	FilesystemFactory *_fsFactory;
+
+public:
+
+	OSystem_IPHONE();
+	virtual ~OSystem_IPHONE();
+
+	virtual void initBackend();
+
+	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;
+	bool setGraphicsMode(const char *name);
+	virtual bool setGraphicsMode(int mode);
+	virtual int getGraphicsMode() const;
+	virtual void initSize(uint width, uint height);
+	virtual int16 getHeight();
+	virtual int16 getWidth();
+	virtual void setPalette(const byte *colors, uint start, uint num);
+	virtual void grabPalette(byte *colors, uint start, uint num);
+	virtual void copyRectToScreen(const byte *buf, int pitch, int x, int y, int w, int h);
+	virtual void updateScreen();
+	virtual Graphics::Surface *lockScreen();
+	virtual void unlockScreen();
+	virtual void setShakePos(int shakeOffset);
+
+	virtual void showOverlay();
+	virtual void hideOverlay();
+	virtual void clearOverlay();
+	virtual void grabOverlay(OverlayColor *buf, int pitch);
+	virtual void copyRectToOverlay(const OverlayColor *buf, int pitch, int x, int y, int w, int h);
+	virtual int16 getOverlayHeight();
+	virtual int16 getOverlayWidth();
+	virtual Graphics::PixelFormat getOverlayFormat() const { return Graphics::createPixelFormat<565>(); }
+
+	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 bool pollEvent(Common::Event &event);
+	virtual uint32 getMillis();
+	virtual void delayMillis(uint msecs);
+
+	virtual MutexRef createMutex(void);
+	virtual void lockMutex(MutexRef mutex);
+	virtual void unlockMutex(MutexRef mutex);
+	virtual void deleteMutex(MutexRef mutex);
+
+	static void mixCallback(void *sys, byte *samples, int len);
+	virtual void setupMixer(void);
+	virtual int getOutputSampleRate() const;
+	virtual void setTimerCallback(TimerProc callback, int interval);
+ 	virtual int getScreenChangeID() const { return _screenChangeCount; }
+	virtual void quit();
+
+	FilesystemFactory *getFilesystemFactory() { return _fsFactory; }
+	virtual void addSysArchivesToSearchSet(Common::SearchSet &s, int priority = 0);
+	virtual void getTimeAndDate(struct tm &t) const;
+
+	virtual Common::SaveFileManager *getSavefileManager();
+	virtual Audio::Mixer *getMixer();
+	virtual Common::TimerManager *getTimerManager();
+
+	void startSoundsystem();
+	void stopSoundsystem();
+
+	virtual Common::SeekableReadStream *createConfigReadStream();
+	virtual Common::WriteStream *createConfigWriteStream();
+
+protected:
+	void internUpdateScreen();
+	void dirtyFullScreen();
+	void dirtyFullOverlayScreen();
+	void clipRectToScreen(int16 &x, int16 &y, int16 &w, int16 &h);
+	void suspendLoop();
+	void drawDirtyRect(const Common::Rect& dirtyRect);
+	void drawDirtyOverlayRect(const Common::Rect& dirtyRect);
+	void drawMouseCursorOnRectUpdate(const Common::Rect& updatedRect, const Common::Rect& mouseRect);
+	void updateHardwareSurfaceForRect(const Common::Rect& updatedRect);
+	static void AQBufferCallback(void *in, AudioQueueRef inQ, AudioQueueBufferRef outQB);
+	static int timerHandler(int t);
+
+	bool handleEvent_swipe(Common::Event &event, int direction);
+	void handleEvent_keyPressed(Common::Event &event, int keyPressed);
+	void handleEvent_orientationChanged(int orientation);
+
+	bool handleEvent_mouseDown(Common::Event &event, int x, int y);
+	bool handleEvent_mouseUp(Common::Event &event, int x, int y);
+
+	bool handleEvent_secondMouseDown(Common::Event &event, int x, int y);
+	bool handleEvent_secondMouseUp(Common::Event &event, int x, int y);
+
+	bool handleEvent_mouseDragged(Common::Event &event, int x, int y);
+	bool handleEvent_mouseSecondDragged(Common::Event &event, int x, int y);
+};

Copied: scummvm/branches/gsoc2009-mods/backends/platform/iphone/osys_sound.cpp (from rev 42568, scummvm/trunk/backends/platform/iphone/osys_sound.cpp)
===================================================================
--- scummvm/branches/gsoc2009-mods/backends/platform/iphone/osys_sound.cpp	                        (rev 0)
+++ scummvm/branches/gsoc2009-mods/backends/platform/iphone/osys_sound.cpp	2009-07-17 21:23:54 UTC (rev 42574)
@@ -0,0 +1,111 @@
+/* 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_main.h"
+
+void OSystem_IPHONE::AQBufferCallback(void *in, AudioQueueRef inQ, AudioQueueBufferRef outQB) {
+	//printf("AQBufferCallback()\n");
+	if (s_AudioQueue.frameCount > 0 && s_soundCallback != NULL) {
+		outQB->mAudioDataByteSize = 4 * s_AudioQueue.frameCount;
+		s_soundCallback(s_soundParam, (byte *)outQB->mAudioData, outQB->mAudioDataByteSize);
+		AudioQueueEnqueueBuffer(inQ, outQB, 0, NULL);
+	} else {
+		AudioQueueStop(s_AudioQueue.queue, false);
+	}
+}
+
+void OSystem_IPHONE::mixCallback(void *sys, byte *samples, int len) {
+	OSystem_IPHONE *this_ = (OSystem_IPHONE *)sys;
+	assert(this_);
+
+	if (this_->_mixer) {
+		this_->_mixer->mixCallback(samples, len);
+	}
+}
+
+void OSystem_IPHONE::setupMixer() {
+	//printf("setSoundCallback()\n");
+	_mixer = new Audio::MixerImpl(this);
+
+	s_soundCallback = mixCallback;
+	s_soundParam = this;
+
+	startSoundsystem();
+}
+
+void OSystem_IPHONE::startSoundsystem() {
+	s_AudioQueue.dataFormat.mSampleRate = AUDIO_SAMPLE_RATE;
+	s_AudioQueue.dataFormat.mFormatID = kAudioFormatLinearPCM;
+	s_AudioQueue.dataFormat.mFormatFlags = kLinearPCMFormatFlagIsSignedInteger | kAudioFormatFlagIsPacked;
+	s_AudioQueue.dataFormat.mBytesPerPacket = 4;
+	s_AudioQueue.dataFormat.mFramesPerPacket = 1;
+	s_AudioQueue.dataFormat.mBytesPerFrame = 4;
+	s_AudioQueue.dataFormat.mChannelsPerFrame = 2;
+	s_AudioQueue.dataFormat.mBitsPerChannel = 16;
+	s_AudioQueue.frameCount = WAVE_BUFFER_SIZE;
+
+	if (AudioQueueNewOutput(&s_AudioQueue.dataFormat, AQBufferCallback, &s_AudioQueue, 0, kCFRunLoopCommonModes, 0, &s_AudioQueue.queue)) {
+		printf("Couldn't set the AudioQueue callback!\n");
+		_mixer->setReady(false);
+		return;
+	}
+
+	uint32 bufferBytes = s_AudioQueue.frameCount * s_AudioQueue.dataFormat.mBytesPerFrame;
+
+	for (int i = 0; i < AUDIO_BUFFERS; i++) {
+		if (AudioQueueAllocateBuffer(s_AudioQueue.queue, bufferBytes, &s_AudioQueue.buffers[i])) {
+			printf("Error allocating AudioQueue buffer!\n");
+			_mixer->setReady(false);
+			return;
+		}
+
+		AQBufferCallback(&s_AudioQueue, s_AudioQueue.queue, s_AudioQueue.buffers[i]);
+	}
+
+	AudioQueueSetParameter(s_AudioQueue.queue, kAudioQueueParam_Volume, 1.0);
+	if (AudioQueueStart(s_AudioQueue.queue, NULL)) {
+		printf("Error starting the AudioQueue!\n");
+		_mixer->setReady(false);
+		return;
+	}
+
+	_mixer->setOutputRate(AUDIO_SAMPLE_RATE);
+	_mixer->setReady(true);
+}
+
+void OSystem_IPHONE::stopSoundsystem() {
+	AudioQueueStop(s_AudioQueue.queue, true);
+
+	for (int i = 0; i < AUDIO_BUFFERS; i++) {
+		AudioQueueFreeBuffer(s_AudioQueue.queue, s_AudioQueue.buffers[i]);
+	}
+
+	AudioQueueDispose(s_AudioQueue.queue, true);
+	_mixer->setReady(false);
+}
+
+int OSystem_IPHONE::getOutputSampleRate() const {
+	return AUDIO_SAMPLE_RATE;
+}

Copied: scummvm/branches/gsoc2009-mods/backends/platform/iphone/osys_video.cpp (from rev 42568, scummvm/trunk/backends/platform/iphone/osys_video.cpp)
===================================================================
--- scummvm/branches/gsoc2009-mods/backends/platform/iphone/osys_video.cpp	                        (rev 0)
+++ scummvm/branches/gsoc2009-mods/backends/platform/iphone/osys_video.cpp	2009-07-17 21:23:54 UTC (rev 42574)
@@ -0,0 +1,463 @@
+/* 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_main.h"
+
+const OSystem::GraphicsMode* OSystem_IPHONE::getSupportedGraphicsModes() const {
+	return s_supportedGraphicsModes;
+}
+
+
+int OSystem_IPHONE::getDefaultGraphicsMode() const {
+	return -1;
+}
+
+bool OSystem_IPHONE::setGraphicsMode(const char *mode) {
+	return true;
+}
+
+bool OSystem_IPHONE::setGraphicsMode(int mode) {
+	return true;
+}
+
+int OSystem_IPHONE::getGraphicsMode() const {
+	return -1;
+}
+
+void OSystem_IPHONE::initSize(uint width, uint height) {
+	//printf("initSize(%i, %i)\n", width, height);
+
+	_screenWidth = width;
+	_screenHeight = height;
+
+	free(_offscreen);
+
+	_offscreen = (byte *)malloc(width * height);
+	bzero(_offscreen, width * height);
+
+	free(_overlayBuffer);
+
+	int fullSize = _screenWidth * _screenHeight * sizeof(OverlayColor);
+	_overlayBuffer = (OverlayColor *)malloc(fullSize);
+	clearOverlay();
+
+	free(_fullscreen);
+
+	_fullscreen = (uint16 *)malloc(fullSize);
+	bzero(_fullscreen, fullSize);
+
+	iPhone_initSurface(width, height);
+
+	_fullScreenIsDirty = false;
+	dirtyFullScreen();
+	_mouseVisible = false;
+	_screenChangeCount++;
+	updateScreen();
+}
+
+int16 OSystem_IPHONE::getHeight() {
+	return _screenHeight;
+}
+
+int16 OSystem_IPHONE::getWidth() {
+	return _screenWidth;
+}
+
+void OSystem_IPHONE::setPalette(const byte *colors, uint start, uint num) {
+	//printf("setPalette()\n");
+	const byte *b = colors;
+
+	for (uint i = start; i < start + num; ++i) {
+		_palette[i] = Graphics::RGBToColor<Graphics::ColorMasks<565> >(b[0], b[1], b[2]);
+		b += 4;
+	}
+
+	dirtyFullScreen();
+}
+
+void OSystem_IPHONE::grabPalette(byte *colors, uint start, uint num) {
+	//printf("grabPalette()\n");
+}
+
+void OSystem_IPHONE::copyRectToScreen(const byte *buf, int pitch, int x, int y, int w, int h) {
+	//printf("copyRectToScreen(%i, %i, %i, %i)\n", x, y, w, 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;
+
+	if (!_fullScreenIsDirty) {
+		_dirtyRects.push_back(Common::Rect(x, y, x + w, y + h));
+	}
+
+
+	byte *dst = _offscreen + y * _screenWidth + x;
+	if (_screenWidth == pitch && pitch == w)
+		memcpy(dst, buf, h * w);
+	else {
+		do {
+			memcpy(dst, buf, w);
+			buf += pitch;
+			dst += _screenWidth;
+		} while (--h);
+	}
+}
+
+void OSystem_IPHONE::clipRectToScreen(int16 &x, int16 &y, int16 &w, int16 &h) {
+	if (x < 0) {
+		w += x;
+		x = 0;
+	}
+
+	if (y < 0) {
+		h += y;
+		y = 0;
+	}
+
+	if (w > _screenWidth - x)
+		w = _screenWidth - x;
+
+	if (h > _screenHeight - y)
+		h = _screenHeight - y;
+
+	if (w < 0) {
+		w = 0;
+	}
+
+	if (h < 0) {
+		h = 0;
+	}
+}
+
+void OSystem_IPHONE::updateScreen() {
+	//printf("updateScreen(): %i dirty rects.\n", _dirtyRects.size());
+
+	if (_dirtyRects.size() == 0 && _dirtyOverlayRects.size() == 0 && !_mouseDirty)
+		return;
+
+	internUpdateScreen();
+	_fullScreenIsDirty = false;
+	_fullScreenOverlayIsDirty = false;
+
+	iPhone_updateScreen();
+}
+
+void OSystem_IPHONE::internUpdateScreen() {
+	int16 mouseX = _mouseX - _mouseHotspotX;
+	int16 mouseY = _mouseY - _mouseHotspotY;
+	int16 mouseWidth = _mouseWidth;
+	int16 mouseHeight = _mouseHeight;
+
+	clipRectToScreen(mouseX, mouseY, mouseWidth, mouseHeight);
+
+	Common::Rect mouseRect(mouseX, mouseY, mouseX + mouseWidth, mouseY + mouseHeight);
+
+	if (_mouseDirty) {
+		if (!_fullScreenIsDirty) {
+			_dirtyRects.push_back(_lastDrawnMouseRect);
+			_dirtyRects.push_back(mouseRect);
+		}
+		if (!_fullScreenOverlayIsDirty && _overlayVisible) {
+			_dirtyOverlayRects.push_back(_lastDrawnMouseRect);
+			_dirtyOverlayRects.push_back(mouseRect);
+		}
+		_mouseDirty = false;
+		_lastDrawnMouseRect = mouseRect;
+	}
+
+	while (_dirtyRects.size()) {
+		Common::Rect dirtyRect = _dirtyRects.remove_at(_dirtyRects.size() - 1);
+
+		//printf("Drawing: (%i, %i) -> (%i, %i)\n", dirtyRect.left, dirtyRect.top, dirtyRect.right, dirtyRect.bottom);
+
+		drawDirtyRect(dirtyRect);
+
+		if (_overlayVisible)
+			drawDirtyOverlayRect(dirtyRect);
+
+		drawMouseCursorOnRectUpdate(dirtyRect, mouseRect);
+		updateHardwareSurfaceForRect(dirtyRect);
+	}
+
+	if (_overlayVisible) {
+		while (_dirtyOverlayRects.size()) {
+			Common::Rect dirtyRect = _dirtyOverlayRects.remove_at(_dirtyOverlayRects.size() - 1);
+
+			//printf("Drawing: (%i, %i) -> (%i, %i)\n", dirtyRect.left, dirtyRect.top, dirtyRect.right, dirtyRect.bottom);
+
+			drawDirtyOverlayRect(dirtyRect);
+			drawMouseCursorOnRectUpdate(dirtyRect, mouseRect);
+			updateHardwareSurfaceForRect(dirtyRect);
+		}
+	}
+}
+
+void OSystem_IPHONE::drawDirtyRect(const Common::Rect& dirtyRect) {
+	int h = dirtyRect.bottom - dirtyRect.top;
+	int w = dirtyRect.right - dirtyRect.left;
+
+	byte  *src = &_offscreen[dirtyRect.top * _screenWidth + dirtyRect.left];
+	uint16 *dst = &_fullscreen[dirtyRect.top * _screenWidth + dirtyRect.left];
+	for (int y = h; y > 0; y--) {
+		for (int x = w; x > 0; x--)
+			*dst++ = _palette[*src++];
+
+		dst += _screenWidth - w;
+		src += _screenWidth - w;
+	}
+}
+
+void OSystem_IPHONE::drawDirtyOverlayRect(const Common::Rect& dirtyRect) {
+	int h = dirtyRect.bottom - dirtyRect.top;
+
+	uint16 *src = (uint16 *)&_overlayBuffer[dirtyRect.top * _screenWidth + dirtyRect.left];
+	uint16 *dst = &_fullscreen[dirtyRect.top * _screenWidth + dirtyRect.left];
+	int x = (dirtyRect.right - dirtyRect.left) * 2;
+	for (int y = h; y > 0; y--) {
+		memcpy(dst, src, x);
+		src += _screenWidth;
+		dst += _screenWidth;
+	}
+}
+
+void OSystem_IPHONE::drawMouseCursorOnRectUpdate(const Common::Rect& updatedRect, const Common::Rect& mouseRect) {
+	//draw mouse on top
+	if (_mouseVisible && (updatedRect.intersects(mouseRect))) {
+		int srcX = 0;
+		int srcY = 0;
+		int left = _mouseX - _mouseHotspotX;
+		if (left < 0) {
+			srcX -= left;
+			left = 0;
+		}
+		int top = _mouseY - _mouseHotspotY;
+		if (top < 0) {
+			srcY -= top;
+			top = 0;
+		}
+			//int right = left + _mouseWidth;
+		int bottom = top + _mouseHeight;
+		if (bottom > _screenWidth)
+			bottom = _screenWidth;
+			int displayWidth = _mouseWidth;
+		if (_mouseWidth + left > _screenWidth)
+			displayWidth = _screenWidth - left;
+			int displayHeight = _mouseHeight;
+		if (_mouseHeight + top > _screenHeight)
+			displayHeight = _screenHeight - top;
+		byte *src = &_mouseBuf[srcY * _mouseWidth + srcX];
+		uint16 *dst = &_fullscreen[top * _screenWidth + left];
+		for (int y = displayHeight; y > srcY; y--) {
+			for (int x = displayWidth; x > srcX; x--) {
+				if (*src != _mouseKeyColour)
+					*dst = _palette[*src];
+				dst++;
+				src++;
+			}
+			dst += _screenWidth - displayWidth + srcX;
+			src += _mouseWidth - displayWidth + srcX;
+		}
+	}
+}
+
+void OSystem_IPHONE::updateHardwareSurfaceForRect(const Common::Rect& updatedRect) {
+	iPhone_updateScreenRect(_fullscreen, updatedRect.left, updatedRect.top, updatedRect.right, updatedRect.bottom );
+}
+
+Graphics::Surface *OSystem_IPHONE::lockScreen() {
+	//printf("lockScreen()\n");
+
+	_framebuffer.pixels = _offscreen;
+	_framebuffer.w = _screenWidth;
+	_framebuffer.h = _screenHeight;
+	_framebuffer.pitch = _screenWidth;
+	_framebuffer.bytesPerPixel = 1;
+
+	return &_framebuffer;
+}
+
+void OSystem_IPHONE::unlockScreen() {
+	//printf("unlockScreen()\n");
+	dirtyFullScreen();
+}
+
+void OSystem_IPHONE::setShakePos(int shakeOffset) {
+	//printf("setShakePos(%i)\n", shakeOffset);
+}
+
+void OSystem_IPHONE::showOverlay() {
+	//printf("showOverlay()\n");
+	_overlayVisible = true;
+	dirtyFullOverlayScreen();
+}
+
+void OSystem_IPHONE::hideOverlay() {
+	//printf("hideOverlay()\n");
+	_overlayVisible = false;
+	_dirtyOverlayRects.clear();
+	dirtyFullScreen();
+}
+
+void OSystem_IPHONE::clearOverlay() {
+	//printf("clearOverlay()\n");
+	bzero(_overlayBuffer, _screenWidth * _screenHeight * sizeof(OverlayColor));
+	dirtyFullOverlayScreen();
+}
+
+void OSystem_IPHONE::grabOverlay(OverlayColor *buf, int pitch) {
+	//printf("grabOverlay()\n");
+	int h = _screenHeight;
+	OverlayColor *src = _overlayBuffer;
+
+	do {
+		memcpy(buf, src, _screenWidth * sizeof(OverlayColor));
+		src += _screenWidth;
+		buf += pitch;
+	} while (--h);
+}
+
+void OSystem_IPHONE::copyRectToOverlay(const OverlayColor *buf, int pitch, int x, int y, int w, int h) {
+	//printf("copyRectToOverlay(buf, pitch=%i, x=%i, y=%i, w=%i, h=%i)\n", pitch, x, y, w, 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;
+
+	if (!_fullScreenOverlayIsDirty) {
+		_dirtyOverlayRects.push_back(Common::Rect(x, y, x + w, y + h));
+	}
+
+	OverlayColor *dst = _overlayBuffer + (y * _screenWidth + x);
+	if (_screenWidth == pitch && pitch == w)
+		memcpy(dst, buf, h * w * sizeof(OverlayColor));
+	else {
+		do {
+			memcpy(dst, buf, w * sizeof(OverlayColor));
+			buf += pitch;
+			dst += _screenWidth;
+		} while (--h);
+	}
+}
+
+int16 OSystem_IPHONE::getOverlayHeight() {
+	return _screenHeight;
+}
+
+int16 OSystem_IPHONE::getOverlayWidth() {
+	return _screenWidth;
+}
+
+bool OSystem_IPHONE::showMouse(bool visible) {
+	bool last = _mouseVisible;
+	_mouseVisible = visible;
+	_mouseDirty = true;
+
+	return last;
+}
+
+void OSystem_IPHONE::warpMouse(int x, int y) {
+	//printf("warpMouse()\n");
+
+	_mouseX = x;
+	_mouseY = y;
+	_mouseDirty = true;
+}
+
+void OSystem_IPHONE::dirtyFullScreen() {
+	if (!_fullScreenIsDirty) {
+		_dirtyRects.clear();
+		_dirtyRects.push_back(Common::Rect(0, 0, _screenWidth, _screenHeight));
+		_fullScreenIsDirty = true;
+	}
+}
+
+void OSystem_IPHONE::dirtyFullOverlayScreen() {
+	if (!_fullScreenOverlayIsDirty) {
+		_dirtyOverlayRects.clear();
+		_dirtyOverlayRects.push_back(Common::Rect(0, 0, _screenWidth, _screenHeight));
+		_fullScreenOverlayIsDirty = true;
+	}
+}
+
+void OSystem_IPHONE::setMouseCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, byte keycolor, int cursorTargetScale) {
+	//printf("setMouseCursor(%i, %i)\n", hotspotX, hotspotY);
+
+	if (_mouseBuf != NULL && (_mouseWidth != w || _mouseHeight != h)) {
+		free(_mouseBuf);
+		_mouseBuf = NULL;
+	}
+
+	if (_mouseBuf == NULL)
+		_mouseBuf = (byte *)malloc(w * h);
+
+	_mouseWidth = w;
+	_mouseHeight = h;
+
+	_mouseHotspotX = hotspotX;
+	_mouseHotspotY = hotspotY;
+
+	_mouseKeyColour = keycolor;
+
+	memcpy(_mouseBuf, buf, w * h);
+
+	_mouseDirty = true;
+}

Modified: scummvm/branches/gsoc2009-mods/backends/platform/ps2/Gs2dScreen.cpp
===================================================================
--- scummvm/branches/gsoc2009-mods/backends/platform/ps2/Gs2dScreen.cpp	2009-07-17 20:51:40 UTC (rev 42573)
+++ scummvm/branches/gsoc2009-mods/backends/platform/ps2/Gs2dScreen.cpp	2009-07-17 21:23:54 UTC (rev 42574)
@@ -337,6 +337,7 @@
 	memset(_screenBuf, 0, _width * height);
 	memset(_overlayBuf, 0, _width * height * 2);
 	memset(_clut, 0, 256 * sizeof(uint32));
+	_clut[1] = GS_RGBA(0xC0, 0xC0, 0xC0, 0);
 
 	// clear video ram
 	_dmaPipe->uploadTex(_clutPtrs[MOUSE], 64, 0, 0, GS_PSMCT32, _clut, 16, 16);
@@ -345,7 +346,8 @@
 	_dmaPipe->flush();
 	_dmaPipe->waitForDma();
 
-	_clutChanged = _screenChanged = _overlayChanged = false;
+	/*_clutChanged = */ _screenChanged = _overlayChanged = false;
+	_clutChanged = true; // reload palette on scr change
 
 	_texCoords[1].u = SCALE(_width);
 	_texCoords[1].v = SCALE(_height);
@@ -396,6 +398,13 @@
 	SignalSema(g_DmacSema);
 }
 
+void Gs2dScreen::fillScreen(uint32 col) {
+	WaitSema(g_DmacSema);
+	memset(_screenBuf, col, _width * _height);
+	_screenChanged = true;
+	SignalSema(g_DmacSema);
+}
+
 Graphics::Surface *Gs2dScreen::lockScreen() {
 	WaitSema(g_DmacSema);
 
@@ -541,11 +550,11 @@
 }
 
 int16 Gs2dScreen::getOverlayWidth(void) {
-	return _videoMode.overlayWidth;
+	return _width; // _videoMode.overlayWidth;
 }
 
 int16 Gs2dScreen::getOverlayHeight(void) {
-	return _videoMode.overlayHeight;
+	return _height; // _videoMode.overlayHeight;
 }
 
 void Gs2dScreen::setShakePos(int shake) {

Modified: scummvm/branches/gsoc2009-mods/backends/platform/ps2/Gs2dScreen.h
===================================================================
--- scummvm/branches/gsoc2009-mods/backends/platform/ps2/Gs2dScreen.h	2009-07-17 20:51:40 UTC (rev 42573)
+++ scummvm/branches/gsoc2009-mods/backends/platform/ps2/Gs2dScreen.h	2009-07-17 21:23:54 UTC (rev 42574)
@@ -61,6 +61,7 @@
 	void copyPrintfOverlay(const uint8* buf);
 	void clearPrintfOverlay(void);
 	void clearScreen(void);
+	void fillScreen(uint32 col);
 
 	Graphics::Surface *lockScreen();
 	void unlockScreen();

Copied: scummvm/branches/gsoc2009-mods/backends/platform/ps2/Makefile.gdb (from rev 42568, scummvm/trunk/backends/platform/ps2/Makefile.gdb)
===================================================================
--- scummvm/branches/gsoc2009-mods/backends/platform/ps2/Makefile.gdb	                        (rev 0)
+++ scummvm/branches/gsoc2009-mods/backends/platform/ps2/Makefile.gdb	2009-07-17 21:23:54 UTC (rev 42574)
@@ -0,0 +1,94 @@
+# $Header: Exp $
+ include $(PS2SDK)/Defs.make
+
+PS2_EXTRA = /media/disk/nw8240/extras/scummvm/ports
+PS2_EXTRA_INCS = /zlib/include /libmad/ee/include /SjPcm/ee/src /tremor
+PS2_EXTRA_LIBS = /zlib/lib /libmad/ee/lib /SjPcm/ee/lib /tremor/tremor
+
+ENABLED=STATIC_PLUGIN
+
+#control build
+DISABLE_SCALERS = true
+DISABLE_HQ_SCALERS = true
+
+ENABLE_SCUMM = $(ENABLED)
+ENABLE_SCUMM_7_8 = $(ENABLED)
+#ENABLE_HE = $(ENABLED)
+#ENABLE_AGI = $(ENABLED)
+#ENABLE_AGOS = $(ENABLED)
+#ENABLE_CINE = $(ENABLED)
+#ENABLE_CRUISE = $(ENABLED)
+#ENABLE_DRASCULA = $(ENABLED)
+#ENABLE_GOB = $(ENABLED)
+#ENABLE_IGOR = $(ENABLED)
+#ENABLE_KYRA = $(ENABLED)
+#ENABLE_LURE = $(ENABLED)
+ # ENABLE_M4 = $(ENABLED)
+#ENABLE_MADE = $(ENABLED)
+#ENABLE_PARALLACTION = $(ENABLED)
+#ENABLE_QUEEN = $(ENABLED)
+#ENABLE_SAGA = $(ENABLED)

@@ 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