aboutsummaryrefslogtreecommitdiff
path: root/backends/platform
diff options
context:
space:
mode:
Diffstat (limited to 'backends/platform')
-rw-r--r--backends/platform/3ds/3ds.mk64
-rw-r--r--backends/platform/3ds/README185
-rw-r--r--backends/platform/3ds/app/banner.pngbin0 -> 19241 bytes
-rw-r--r--backends/platform/3ds/app/banner.wavbin0 -> 2212 bytes
-rw-r--r--backends/platform/3ds/app/icon.pngbin0 -> 3800 bytes
-rw-r--r--backends/platform/3ds/app/scummvm.rsf219
-rw-r--r--backends/platform/3ds/config.cpp87
-rw-r--r--backends/platform/3ds/config.h45
-rw-r--r--backends/platform/3ds/gui.cpp46
-rw-r--r--backends/platform/3ds/gui.h41
-rw-r--r--backends/platform/3ds/main.cpp54
-rw-r--r--backends/platform/3ds/module.mk18
-rw-r--r--backends/platform/3ds/options-dialog.cpp98
-rw-r--r--backends/platform/3ds/options-dialog.h70
-rw-r--r--backends/platform/3ds/osystem-audio.cpp110
-rw-r--r--backends/platform/3ds/osystem-events.cpp302
-rw-r--r--backends/platform/3ds/osystem-graphics.cpp517
-rw-r--r--backends/platform/3ds/osystem.cpp193
-rw-r--r--backends/platform/3ds/osystem.h221
-rw-r--r--backends/platform/3ds/shader.v.pica59
-rw-r--r--backends/platform/3ds/sprite.cpp144
-rw-r--r--backends/platform/3ds/sprite.h71
-rw-r--r--backends/platform/android/android.cpp7
-rw-r--r--backends/platform/android/android.h1
-rw-r--r--backends/platform/android/android.mk5
-rw-r--r--backends/platform/android/asset-archive.cpp480
-rw-r--r--backends/platform/android/asset-archive.h10
-rw-r--r--backends/platform/android/events.cpp21
-rw-r--r--backends/platform/android/jni.cpp39
-rw-r--r--backends/platform/android/jni.h4
-rw-r--r--backends/platform/android/org/scummvm/scummvm/ScummVM.java2
-rw-r--r--backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java19
-rw-r--r--backends/platform/android/org/scummvm/scummvm/ScummVMEvents.java2
-rw-r--r--backends/platform/androidsdl/androidsdl-main.cpp47
-rw-r--r--backends/platform/androidsdl/androidsdl-sdl.cpp48
-rw-r--r--backends/platform/androidsdl/androidsdl-sdl.h38
-rw-r--r--backends/platform/androidsdl/androidsdl.mk11
-rw-r--r--backends/platform/androidsdl/module.mk13
-rw-r--r--backends/platform/dc/README6
-rw-r--r--backends/platform/dc/dc-fs.cpp1
-rw-r--r--backends/platform/dc/dc.h21
-rw-r--r--backends/platform/dc/dcloader.cpp7
-rw-r--r--backends/platform/dc/dcloader.h2
-rw-r--r--backends/platform/dc/dcmain.cpp68
-rw-r--r--backends/platform/dc/dreamcast.mk9
-rw-r--r--backends/platform/dc/plugin.syms1
-rw-r--r--backends/platform/dc/plugin.x1
-rw-r--r--backends/platform/dc/vmsave.cpp51
-rw-r--r--backends/platform/dingux/README.GCW014
-rwxr-xr-xbackends/platform/dingux/build.gcw0.sh2
-rw-r--r--backends/platform/dingux/dingux.mk7
-rw-r--r--backends/platform/ds/arm9/source/gbampsave.cpp13
-rw-r--r--backends/platform/ds/arm9/source/gbampsave.h3
-rw-r--r--backends/platform/ds/arm9/source/osystem_ds.cpp2
-rw-r--r--backends/platform/ds/arm9/source/osystem_ds.h3
-rw-r--r--backends/platform/ios7/ios7_common.h4
-rw-r--r--backends/platform/ios7/ios7_osys_events.cpp12
-rw-r--r--backends/platform/ios7/ios7_osys_main.cpp9
-rw-r--r--backends/platform/ios7/ios7_osys_main.h3
-rw-r--r--backends/platform/ios7/ios7_osys_video.mm13
-rw-r--r--backends/platform/ios7/ios7_video.mm26
-rw-r--r--backends/platform/maemo/debian/changelog16
-rw-r--r--backends/platform/n64/framfs_save_manager.h22
-rw-r--r--backends/platform/n64/pakfs_save_manager.h23
-rw-r--r--backends/platform/ps2/eecodyvdfs.c4
-rw-r--r--backends/platform/ps2/iop/CoDyVDfs/iop/codyvdfs.c4
-rw-r--r--backends/platform/ps2/iop/CoDyVDfs/iop/fiofs.c4
-rw-r--r--backends/platform/ps2/iop/CoDyVDfs/iop/rpcfs.c4
-rw-r--r--backends/platform/ps2/irxboot.cpp2
-rw-r--r--backends/platform/ps2/savefilemgr.cpp15
-rw-r--r--backends/platform/ps2/savefilemgr.h3
-rw-r--r--backends/platform/ps2/systemps2.cpp2
-rw-r--r--backends/platform/psp/README.PSP2
-rwxr-xr-xbackends/platform/psp/build-psp.sh15
-rw-r--r--backends/platform/sdl/amigaos/amigaos-main.cpp35
-rw-r--r--backends/platform/sdl/macosx/macosx.cpp27
-rw-r--r--backends/platform/sdl/macosx/macosx.h10
-rw-r--r--backends/platform/sdl/macosx/macosx_wrapper.h31
-rw-r--r--backends/platform/sdl/macosx/macosx_wrapper.mm48
-rw-r--r--backends/platform/sdl/module.mk1
-rw-r--r--backends/platform/sdl/posix/posix-main.cpp2
-rw-r--r--backends/platform/sdl/posix/posix.cpp82
-rw-r--r--backends/platform/sdl/posix/posix.h8
-rw-r--r--backends/platform/sdl/sdl-sys.h131
-rw-r--r--backends/platform/sdl/sdl-window.cpp2
-rw-r--r--backends/platform/sdl/sdl-window.h4
-rw-r--r--backends/platform/sdl/sdl.cpp84
-rw-r--r--backends/platform/sdl/sdl.h15
-rw-r--r--backends/platform/sdl/win32/win32.cpp23
-rw-r--r--backends/platform/sdl/win32/win32.h6
-rw-r--r--backends/platform/symbian/S60/scummvm-CVS-SymbianS60v1.pkg4
-rw-r--r--backends/platform/symbian/S60/scummvm-CVS-SymbianS60v2.pkg4
-rw-r--r--backends/platform/symbian/S60v3/scummvm-CVS-SymbianS60v3.pkg4
-rw-r--r--backends/platform/symbian/S60v3/scummvm-CVS-SymbianS60v3_split.pkg7
-rw-r--r--backends/platform/symbian/S80/scummvm-CVS-SymbianS80.pkg4
-rw-r--r--backends/platform/symbian/S90/scummvm-CVS-SymbianS90.pkg4
-rw-r--r--backends/platform/symbian/UIQ2/scummvm-CVS-SymbianUIQ2.pkg4
-rw-r--r--backends/platform/symbian/UIQ2/scummvm-CVS-SymbianUIQ2_SE.pkg4
-rw-r--r--backends/platform/symbian/UIQ3/scummvm-CVS-SymbianUIQ3.pkg4
-rw-r--r--backends/platform/symbian/UIQ3/scummvm-CVS-SymbianUIQ3_split.pkg4
-rw-r--r--backends/platform/symbian/src/portdefs.h3
-rw-r--r--backends/platform/tizen/form.cpp8
-rw-r--r--backends/platform/tizen/graphics.cpp7
-rw-r--r--backends/platform/tizen/graphics.h2
-rw-r--r--backends/platform/tizen/system.cpp49
-rw-r--r--backends/platform/wince/portdefs.h3
106 files changed, 3685 insertions, 624 deletions
diff --git a/backends/platform/3ds/3ds.mk b/backends/platform/3ds/3ds.mk
new file mode 100644
index 0000000000..7ab58995f6
--- /dev/null
+++ b/backends/platform/3ds/3ds.mk
@@ -0,0 +1,64 @@
+TARGET := scummvm
+
+APP_TITLE := ScummVM
+APP_DESCRIPTION := Point-and-click adventure game engines
+APP_AUTHOR := ScummVM Team
+APP_ICON := backends/platform/3ds/app/icon.png
+
+APP_RSF := backends/platform/3ds/app/scummvm.rsf
+APP_BANNER_IMAGE:= backends/platform/3ds/app/banner.png
+APP_BANNER_AUDIO:= backends/platform/3ds/app/banner.wav
+
+ARCH := -march=armv6k -mtune=mpcore -mfloat-abi=hard -mtp=soft
+CXXFLAGS += -std=gnu++11
+ASFLAGS += -mfloat-abi=hard
+LDFLAGS += -specs=3dsx.specs $(ARCH) -L$(DEVKITPRO)/libctru/lib -L$(DEVKITPRO)/portlibs/3ds/lib
+
+.PHONY: clean_3ds
+
+clean: clean_3ds
+
+clean_3ds:
+ $(RM) $(TARGET).3dsx
+ $(RM) $(TARGET).cia
+
+$(TARGET).smdh: $(APP_ICON)
+ @bannertool makesmdh -s "$(APP_TITLE)" -l "$(APP_DESCRIPTION)" -p "$(APP_AUTHOR)" -i $(APP_ICON) -o $@
+ @echo built ... $(notdir $@)
+
+$(TARGET).3dsx: $(EXECUTABLE) $(TARGET).smdh
+ @3dsxtool $< $@ --smdh=$(TARGET).smdh
+ @echo built ... $(notdir $@)
+
+$(TARGET).bnr: $(APP_BANNER_IMAGE) $(APP_BANNER_AUDIO)
+ @bannertool makebanner -o $@ -i $(APP_BANNER_IMAGE) -a $(APP_BANNER_AUDIO)
+ @echo built ... $(notdir $@)
+
+$(TARGET).cia: $(EXECUTABLE) $(APP_RSF) $(TARGET).smdh $(TARGET).bnr
+ @makerom -f cia -target t -exefslogo -o $@ -elf $(EXECUTABLE) -rsf $(APP_RSF) -banner $(TARGET).bnr -icon $(TARGET).smdh
+ @echo built ... $(notdir $@)
+
+#---------------------------------------------------------------------------------
+# rules for assembling GPU shaders
+#---------------------------------------------------------------------------------
+define shader-as
+ $(eval FILEPATH := $(patsubst %.shbin.o,%.shbin,$@))
+ $(eval FILE := $(patsubst %.shbin.o,%.shbin,$(notdir $@)))
+ picasso -o $(FILEPATH) $1
+ bin2s $(FILEPATH) | $(AS) -o $@
+ echo "extern const u8" `(echo $(FILE) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"_end[];" > `(echo $(FILEPATH) | tr . _)`.h
+ echo "extern const u8" `(echo $(FILE) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"[];" >> `(echo $(FILEPATH) | tr . _)`.h
+ echo "extern const u32" `(echo $(FILE) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`_size";" >> `(echo $(FILEPATH) | tr . _)`.h
+endef
+
+%.shbin.o : %.v.pica %.g.pica
+ @echo $(notdir $^)
+ @$(call shader-as,$^)
+
+%.shbin.o : %.v.pica
+ @echo $(notdir $<)
+ @$(call shader-as,$<)
+
+%.shbin.o : %.shlist
+ @echo $(notdir $<)
+ @$(call shader-as,$(foreach file,$(shell cat $<),$(dir $<)/$(file)))
diff --git a/backends/platform/3ds/README b/backends/platform/3ds/README
new file mode 100644
index 0000000000..516e694f64
--- /dev/null
+++ b/backends/platform/3ds/README
@@ -0,0 +1,185 @@
+ScummVM 3DS README
+------------------------------------------------------------------------
+
+Table of Contents:
+------------------
+1.0) Installation
+ * 1.1 3DSX installation
+ * 1.2 CIA installation
+2.0) Controls
+ * 2.1 Default key mappings
+ * 2.2 Hover mode
+ * 2.3 Drag mode
+3.0) Supported Games
+4.0) Compiling
+ * 4.1 Prerequisites
+ * * 4.1.1 Compiling third-party libraries
+ * 4.2 Compiling ScummVM
+ * 4.3 Warning for 3DSX build
+
+
+
+1.0) Installation
+-----------------
+There are two possible formats to be used: 3DSX and CIA (recommended).
+The 3DSX format is exclusively used by the Homebrew Launcher and its derivatives.
+The CIA format can be installed directly to the 3DS home menu and can be launched
+using any CFW (Custom Firmware) of your choice.
+
+Installing the Homebrew Launcher or any CFW is beyond the scope of this README.
+Look elsewhere to see how to install those if you do not already have them set up.
+
+
+1.1) 3DSX installation
+----------------
+The CIA format is recommended for stability and maximum game support. If that is
+not an option, you will need one of a collection of 3DS titles installed on your
+system in order to properly launch ScummVM as a 3DSX. This is because the
+Homebrew Launcher hijacks other processes to run 3DSX homebrew, and ScummVM is a
+particularly large homebrew that can't be launched with the resources provided
+by standard system applications.
+
+You will need one of the following (installed or physically in cart slot):
+
+- Youtube
+- Monster Hunter 4 Ultimate Special Demo
+- Monster Hunter 4 Ultimate
+- Monster Hunter 4G
+- Super Smash Bros. for Nintendo 3DS Demo
+- Super Smash Bros. for Nintendo 3DS Special Demo
+- Super Smash Bros. for Nintendo 3DS
+
+Once you have one of the above, you need to merely extract all ScummVM 3DS files
+to the root of your SD card so that all files reside in the /3ds/scummvm/ directory.
+
+
+1.2) CIA installation
+---------------------
+The CIA format requires a DSP binary dump saved on your SD card as /3ds/dspfirm.cdc
+for proper audio support. You can search online to find software to dump this.
+Not having this file will cause many problems with games that need audio, sometimes
+even crashing, so this is NOT considered optional.
+
+Using any CIA installation software (search elsewhere for that), you need to install
+the scummvm.cia file. Then, just like what is done with the 3DSX installation, you
+need to extract all ScummVM 3DS files (scummvm.cia excluded) to the root of your SD
+card so that all files reside in the /3ds/scummvm/ directory.
+
+
+
+2.0) Controls
+-------------
+
+2.1) Default key mappings
+-------------------------
+The D-Pad and A/B/X/Y buttons have mirrored usage. So they do the same things
+depending on if you're right or left-handed.
+
+| Buttons | Function |
+|------------|--------------------------------|
+| A / D-left | Left-click |
+| X / D-up | Right-click |
+| B / D-down | ESC (skips cutscenes and such) |
+| L | Use virtual keyboard |
+| R | Toggle hover/drag modes |
+| Start | Open game menu |
+| Select | Open 3DS config menu |
+| Circle Pad | Move the cursor |
+
+
+2.2) Hover mode
+---------------
+When you use the touchscreen, you are simulating the mere moving of the mouse. You
+can click only with taps, meaning it is impossible to drag stuff or hold down a
+mouse button without using buttons mapped to right/left-click.
+
+
+2.3) Drag mode
+--------------
+Every time you touch and release the touchscreen, you are simulating the click and
+release of the mouse buttons. At the moment, this is only a left-click.
+
+
+
+3.0) Supported Games
+--------------------
+The full game engine compatibility list can be found here:
+http://scummvm.org/compatibility/
+
+While all the above games should run on the 3DS (report if they do not), there are
+many games which are unplayable due to the lack of CPU speed on the 3DS. So if
+you play any games that run really slow, this is not considered a bug, but rather
+a hardware limitation. Though possible GPU optimizations are always in the works.
+The New 3DS console has much better performance, but there are still many newer and
+high-resolution games that cannot be played. A list of these unplayable games and
+game engines will eventually be listed here.
+
+
+
+4.0) Compiling
+--------------
+
+4.1) Prerequisites
+------------------
+ - devkitARM (presumably with libctru, picasso and such)
+ - citro3d
+ - Optional: You should compile third-party libraries for the 3ds (commonly referred
+ to as portlibs in the devkitPRO community). Some games requires these to operate
+ properly.
+
+
+4.1.1) Compiling third-party libraries
+--------------------------------------
+Most libraries used can be compiled with same commands and configuration flags.
+
+It is assumed that you have these environment variables defined:
+ - DEVKITPRO Your root devkitPro directory
+ - DEVKITARM Your root devkitARM directory (probably same as $DEVKITPRO/devkitARM)
+ - CTRULIB Your root libctru directory (probably same as $DEVKITPRO/libctru)
+
+In the source directory of the library:
+ - $ export PORTLIBS=$DEVKITPRO/portlibs/armv6k
+ - $ export PATH=$DEVKITARM/bin:$PATH
+ - $ export PKG_CONFIG_PATH=$PORTLIBS/lib/pkgconfig
+ - $ export CFLAGS="-g -march=armv6k -mtune=mpcore -mfloat-abi=hard -O2
+ -mword-relocations -ffunction-sections -fdata-sections"
+ - $ export CPPFLAGS="-I$PORTLIBS/include -I$CTRULIB/include"
+ - $ export LDFLAGS="-L$PORTLIBS/lib"
+ - $ mkdir -p $PORTLIBS
+ - $ ./configure --prefix=$PORTLIBS --host=arm-none-eabi --disable-shared
+ --enable-static
+ - $ make
+ - $ make install
+
+Useful libraries (and special config flags needed):
+ - zlib
+ - libpng
+ - libjpeg
+ - freetype2 --without-bzip2 --without-harfbuzz
+ - libmad
+ - tremor
+ - flac --disable-cpplibs --without-flac
+ - faad
+
+
+4.2) Compiling ScummVM
+----------------------
+ - $ ./configure --host=3ds
+ - $ make
+
+Additionally compile to specific formats to be used on the 3ds:
+ - $ make scummvm.3dsx
+ - $ make scummvm.cia
+
+
+4.3) Warning for 3DSX build
+---------------------------
+The above configuration command will include all game engines by default and will
+likely be too massive to run using the 3DSX format. Until dynamic modules are figured
+out, you should configure engines like this for 3DSX builds:
+
+ - $ ./configure --host=3ds --disable-all-engines--enable-engine=scumm-7-8,myst,riven,
+ sword1,sword2,sword25,sci,lure,sky,agi,agos
+
+Choose whatever engines you want, but if the ELF's .text section exceeds ~10MB, it
+won't be playable unless it's a CIA.
diff --git a/backends/platform/3ds/app/banner.png b/backends/platform/3ds/app/banner.png
new file mode 100644
index 0000000000..a3b02150ec
--- /dev/null
+++ b/backends/platform/3ds/app/banner.png
Binary files differ
diff --git a/backends/platform/3ds/app/banner.wav b/backends/platform/3ds/app/banner.wav
new file mode 100644
index 0000000000..e0b684b62f
--- /dev/null
+++ b/backends/platform/3ds/app/banner.wav
Binary files differ
diff --git a/backends/platform/3ds/app/icon.png b/backends/platform/3ds/app/icon.png
new file mode 100644
index 0000000000..07022fbac1
--- /dev/null
+++ b/backends/platform/3ds/app/icon.png
Binary files differ
diff --git a/backends/platform/3ds/app/scummvm.rsf b/backends/platform/3ds/app/scummvm.rsf
new file mode 100644
index 0000000000..a4518949bb
--- /dev/null
+++ b/backends/platform/3ds/app/scummvm.rsf
@@ -0,0 +1,219 @@
+BasicInfo:
+ Title : ScummVM
+ ProductCode : ScummVM
+ Logo : Nintendo # Nintendo / Licensed / Distributed / iQue / iQueForSystem
+
+TitleInfo:
+ Category : Application
+ UniqueId : 0xFF321
+
+Option:
+ UseOnSD : true # true if App is to be installed to SD
+ FreeProductCode : true # Removes limitations on ProductCode
+ MediaFootPadding : false # If true CCI files are created with padding
+ EnableCrypt : false # Enables encryption for NCCH and CIA
+ EnableCompress : false # Compresses where applicable (currently only exefs:/.code)
+
+AccessControlInfo:
+ CoreVersion : 2
+
+ # Exheader Format Version
+ DescVersion : 2
+
+ # Minimum Required Kernel Version (below is for 4.5.0)
+ ReleaseKernelMajor : "02"
+ ReleaseKernelMinor : "33"
+
+ # ExtData
+ UseExtSaveData : false # enables ExtData
+ #ExtSaveDataId : 0x300 # only set this when the ID is different to the UniqueId
+
+ # FS:USER Archive Access Permissions
+ # Uncomment as required
+ FileSystemAccess:
+ #- CategorySystemApplication
+ #- CategoryHardwareCheck
+ #- CategoryFileSystemTool
+ #- Debug
+ #- TwlCardBackup
+ #- TwlNandData
+ #- Boss
+ - DirectSdmc
+ #- Core
+ #- CtrNandRo
+ #- CtrNandRw
+ #- CtrNandRoWrite
+ #- CategorySystemSettings
+ #- CardBoard
+ #- ExportImportIvs
+ #- DirectSdmcWrite
+ #- SwitchCleanup
+ #- SaveDataMove
+ #- Shop
+ #- Shell
+ #- CategoryHomeMenu
+
+ # Process Settings
+ MemoryType : Application # Application/System/Base
+ SystemMode : 64MB # 64MB(Default)/96MB/80MB/72MB/32MB
+ IdealProcessor : 0
+ AffinityMask : 1
+ Priority : 16
+ MaxCpu : 0 # Let system decide
+ HandleTableSize : 0x200
+ DisableDebug : false
+ EnableForceDebug : false
+ CanWriteSharedPage : true
+ CanUsePrivilegedPriority : false
+ CanUseNonAlphabetAndNumber : true
+ PermitMainFunctionArgument : true
+ CanShareDeviceMemory : true
+ RunnableOnSleep : false
+ SpecialMemoryArrange : true
+
+ # New3DS Exclusive Process Settings
+ SystemModeExt : 124MB # Legacy(Default)/124MB/178MB Legacy:Use Old3DS SystemMode
+ CpuSpeed : 804MHz # 268MHz(Default)/804MHz
+ EnableL2Cache : true # false(default)/true
+ CanAccessCore2 : true
+
+ # Virtual Address Mappings
+ IORegisterMapping:
+ - 1ff00000-1ff7ffff # DSP memory
+ MemoryMapping:
+ - 1f000000-1f5fffff:r # VRAM
+
+ # Accessible SVCs, <Name>:<ID>
+ SystemCallAccess:
+ ArbitrateAddress: 34
+ Break: 60
+ CancelTimer: 28
+ ClearEvent: 25
+ ClearTimer: 29
+ CloseHandle: 35
+ ConnectToPort: 45
+ ControlMemory: 1
+ CreateAddressArbiter: 33
+ CreateEvent: 23
+ CreateMemoryBlock: 30
+ CreateMutex: 19
+ CreateSemaphore: 21
+ CreateThread: 8
+ CreateTimer: 26
+ DuplicateHandle: 39
+ ExitProcess: 3
+ ExitThread: 9
+ GetCurrentProcessorNumber: 17
+ GetHandleInfo: 41
+ GetProcessId: 53
+ GetProcessIdOfThread: 54
+ GetProcessIdealProcessor: 6
+ GetProcessInfo: 43
+ GetResourceLimit: 56
+ GetResourceLimitCurrentValues: 58
+ GetResourceLimitLimitValues: 57
+ GetSystemInfo: 42
+ GetSystemTick: 40
+ GetThreadContext: 59
+ GetThreadId: 55
+ GetThreadIdealProcessor: 15
+ GetThreadInfo: 44
+ GetThreadPriority: 11
+ MapMemoryBlock: 31
+ OutputDebugString: 61
+ QueryMemory: 2
+ ReleaseMutex: 20
+ ReleaseSemaphore: 22
+ SendSyncRequest1: 46
+ SendSyncRequest2: 47
+ SendSyncRequest3: 48
+ SendSyncRequest4: 49
+ SendSyncRequest: 50
+ SetThreadPriority: 12
+ SetTimer: 27
+ SignalEvent: 24
+ SleepThread: 10
+ UnmapMemoryBlock: 32
+ WaitSynchronization1: 36
+ WaitSynchronizationN: 37
+ Backdoor: 123
+
+ # Service List
+ # Maximum 34 services (32 if firmware is prior to 9.3.0)
+ ServiceAccessControl:
+ - cfg:u
+ - fs:USER
+ - gsp::Gpu
+ - hid:USER
+ - ndm:u
+ - pxi:dev
+ - APT:U
+ - ac:u
+ - act:u
+ - am:net
+ - boss:U
+ - cam:u
+ - cecd:u
+ - dsp::DSP
+ - frd:u
+ - http:C
+ - ir:USER
+ - ir:u
+ - ir:rst
+ - ldr:ro
+ - mic:u
+ - news:u
+ - nim:aoc
+ - nwm::UDS
+ - ptm:u
+ - qtm:u
+ - soc:U
+ - ssl:C
+ - y2r:u
+ - gsp::Lcd
+
+
+SystemControlInfo:
+ SaveDataSize: 0K
+ RemasterVersion: 0
+ StackSize: 0x40000
+
+ # Modules that run services listed above should be included below
+ # Maximum 48 dependencies
+ # If a module is listed that isn't present on the 3DS, the title will get stuck at the logo (3ds waves)
+ # So act, nfc and qtm are commented for 4.x support. Uncomment if you need these.
+ # <module name>:<module titleid>
+ Dependency:
+ ac: 0x0004013000002402
+ #act: 0x0004013000003802
+ am: 0x0004013000001502
+ boss: 0x0004013000003402
+ camera: 0x0004013000001602
+ cecd: 0x0004013000002602
+ cfg: 0x0004013000001702
+ codec: 0x0004013000001802
+ csnd: 0x0004013000002702
+ dlp: 0x0004013000002802
+ dsp: 0x0004013000001a02
+ friends: 0x0004013000003202
+ gpio: 0x0004013000001b02
+ gsp: 0x0004013000001c02
+ hid: 0x0004013000001d02
+ http: 0x0004013000002902
+ i2c: 0x0004013000001e02
+ ir: 0x0004013000003302
+ mcu: 0x0004013000001f02
+ mic: 0x0004013000002002
+ ndm: 0x0004013000002b02
+ news: 0x0004013000003502
+ #nfc: 0x0004013000004002
+ nim: 0x0004013000002c02
+ nwm: 0x0004013000002d02
+ pdn: 0x0004013000002102
+ ps: 0x0004013000003102
+ ptm: 0x0004013000002202
+ #qtm: 0x0004013020004202
+ ro: 0x0004013000003702
+ socket: 0x0004013000002e02
+ spi: 0x0004013000002302
+ ssl: 0x0004013000002f02
diff --git a/backends/platform/3ds/config.cpp b/backends/platform/3ds/config.cpp
new file mode 100644
index 0000000000..bfadc5ac06
--- /dev/null
+++ b/backends/platform/3ds/config.cpp
@@ -0,0 +1,87 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "config.h"
+#include "osystem.h"
+#include "options-dialog.h"
+#include "common/config-manager.h"
+#include <3ds.h>
+
+namespace _3DS {
+
+Config config;
+static Common::String prefix = "3ds_";
+
+static bool confGetBool(Common::String key, bool defaultVal) {
+ if (ConfMan.hasKey(prefix + key))
+ return ConfMan.getBool(prefix + key);
+ return defaultVal;
+}
+
+static void confSetBool(Common::String key, bool val) {
+ ConfMan.setBool(prefix + key, val);
+}
+
+static int confGetInt(Common::String key, int defaultVal) {
+ if (ConfMan.hasKey(prefix + key))
+ return ConfMan.getInt(prefix + key);
+ return defaultVal;
+}
+
+static void confSetInt(Common::String key, int val) {
+ ConfMan.setInt(prefix + key, val);
+}
+
+void loadConfig() {
+ config.showCursor = confGetBool("showcursor", true);
+ config.snapToBorder = confGetBool("snaptoborder", true);
+ config.stretchToFit = confGetBool("stretchtofit", false);
+ config.sensitivity = confGetInt("sensitivity", -5);
+ config.screen = confGetInt("screen", kScreenBoth);
+
+ // Turn off the backlight of any screen not used
+ if (R_SUCCEEDED(gspLcdInit())) {
+ if (config.screen == kScreenTop) {
+ GSPLCD_PowerOnBacklight(GSPLCD_SCREEN_TOP);
+ GSPLCD_PowerOffBacklight(GSPLCD_SCREEN_BOTTOM);
+ } else if (config.screen == kScreenBottom) {
+ GSPLCD_PowerOnBacklight(GSPLCD_SCREEN_BOTTOM);
+ GSPLCD_PowerOffBacklight(GSPLCD_SCREEN_TOP);
+ } else
+ GSPLCD_PowerOnBacklight(GSPLCD_SCREEN_BOTH);
+ gspLcdExit();
+ }
+
+ OSystem_3DS *osys = (OSystem_3DS *)g_system;
+ osys->updateConfig();
+}
+
+void saveConfig() {
+ confSetBool("showcursor", config.showCursor);
+ confSetBool("snaptoborder", config.snapToBorder);
+ confSetBool("stretchtofit", config.stretchToFit);
+ confSetInt("sensitivity", config.sensitivity);
+ confSetInt("screen", config.screen);
+ ConfMan.flushToDisk();
+}
+
+} // namespace _3DS
diff --git a/backends/platform/3ds/config.h b/backends/platform/3ds/config.h
new file mode 100644
index 0000000000..02560b2040
--- /dev/null
+++ b/backends/platform/3ds/config.h
@@ -0,0 +1,45 @@
+/* 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.
+ *
+ */
+
+#ifndef CONFIG_3DS_H
+#define CONFIG_3DS_H
+
+#include "common/str.h"
+
+namespace _3DS {
+
+struct Config {
+ bool showCursor;
+ bool snapToBorder;
+ bool stretchToFit;
+ int sensitivity;
+ int screen;
+};
+
+extern Config config;
+
+void loadConfig();
+void saveConfig();
+
+} // namespace _3DS
+
+#endif // CONFIG_3DS_H
diff --git a/backends/platform/3ds/gui.cpp b/backends/platform/3ds/gui.cpp
new file mode 100644
index 0000000000..0883d5a102
--- /dev/null
+++ b/backends/platform/3ds/gui.cpp
@@ -0,0 +1,46 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "backends/platform/3ds/gui.h"
+#include "common/system.h"
+
+StatusMessageDialog* StatusMessageDialog::_opened = 0;
+
+StatusMessageDialog::StatusMessageDialog(const Common::String &message, uint32 duration)
+ : MessageDialog(message, 0, 0) {
+ _timer = g_system->getMillis() + duration;
+ if (_opened)
+ _opened->close();
+ _opened = this;
+}
+
+void StatusMessageDialog::handleTickle() {
+ MessageDialog::handleTickle();
+ if (g_system->getMillis() > _timer)
+ close();
+}
+
+void StatusMessageDialog::close() {
+ GUI::Dialog::close();
+ if (_opened)
+ _opened = 0;
+}
diff --git a/backends/platform/3ds/gui.h b/backends/platform/3ds/gui.h
new file mode 100644
index 0000000000..8e82c6c851
--- /dev/null
+++ b/backends/platform/3ds/gui.h
@@ -0,0 +1,41 @@
+/* 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.
+ *
+ */
+
+#ifndef GUI_3DS_H
+#define GUI_3DS_H
+
+#include "gui/message.h"
+
+class StatusMessageDialog : public GUI::MessageDialog {
+public:
+ StatusMessageDialog(const Common::String &message, uint32 duration);
+
+ void handleTickle();
+
+protected:
+ virtual void close();
+
+ uint32 _timer;
+ static StatusMessageDialog* _opened;
+};
+
+#endif // GUI_3DS_H
diff --git a/backends/platform/3ds/main.cpp b/backends/platform/3ds/main.cpp
new file mode 100644
index 0000000000..e9046d7c28
--- /dev/null
+++ b/backends/platform/3ds/main.cpp
@@ -0,0 +1,54 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "osystem.h"
+#include <3ds.h>
+
+int main(int argc, char *argv[]) {
+ // Initialize basic libctru stuff
+ gfxInitDefault();
+ cfguInit();
+ osSetSpeedupEnable(true);
+// consoleInit(GFX_TOP, NULL);
+
+ g_system = new _3DS::OSystem_3DS();
+ assert(g_system);
+
+ // Invoke the actual ScummVM main entry point
+// if (argc > 2)
+// res = scummvm_main(argc-2, &argv[2]);
+// else
+// res = scummvm_main(argc, argv);
+ scummvm_main(0, nullptr);
+
+ delete dynamic_cast<_3DS::OSystem_3DS*>(g_system);
+
+ // Turn on both screen backlights before exiting.
+ if (R_SUCCEEDED(gspLcdInit())) {
+ GSPLCD_PowerOnBacklight(GSPLCD_SCREEN_BOTH);
+ gspLcdExit();
+ }
+
+ cfguExit();
+ gfxExit();
+ return 0;
+}
diff --git a/backends/platform/3ds/module.mk b/backends/platform/3ds/module.mk
new file mode 100644
index 0000000000..3eb15aef81
--- /dev/null
+++ b/backends/platform/3ds/module.mk
@@ -0,0 +1,18 @@
+MODULE := backends/platform/3ds
+
+MODULE_OBJS := \
+ main.o \
+ shader.shbin.o \
+ sprite.o \
+ gui.o \
+ config.o \
+ options-dialog.o \
+ osystem.o \
+ osystem-graphics.o \
+ osystem-audio.o \
+ osystem-events.o
+
+# We don't use rules.mk but rather manually update OBJS and MODULE_DIRS.
+MODULE_OBJS := $(addprefix $(MODULE)/, $(MODULE_OBJS))
+OBJS := $(MODULE_OBJS) $(OBJS)
+MODULE_DIRS += $(sort $(dir $(MODULE_OBJS)))
diff --git a/backends/platform/3ds/options-dialog.cpp b/backends/platform/3ds/options-dialog.cpp
new file mode 100644
index 0000000000..60fe7f818f
--- /dev/null
+++ b/backends/platform/3ds/options-dialog.cpp
@@ -0,0 +1,98 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "options-dialog.h"
+#include "config.h"
+#include "gui/dialog.h"
+#include "gui/gui-manager.h"
+#include "gui/widgets/list.h"
+#include "gui/widgets/tab.h"
+#include "osystem.h"
+#include "engines/scumm/scumm.h"
+#include "gui/widgets/popup.h"
+
+#include "common/translation.h"
+
+namespace _3DS {
+
+bool optionMenuOpened = false;
+
+OptionsDialog::OptionsDialog() : GUI::Dialog(20, 20, 280, 200) {
+
+ optionMenuOpened = true;
+
+ new GUI::ButtonWidget(this, 120, 180, 72, 16, _("~C~lose"), 0, GUI::kCloseCmd);
+ new GUI::ButtonWidget(this, 200, 180, 72, 16, _("~S~ave"), 0, GUI::kOKCmd);
+
+ _showCursorCheckbox = new GUI::CheckboxWidget(this, 5, 5, 130, 20, _("Show mouse cursor"), 0, 0, 'T');
+ _showCursorCheckbox->setState(config.showCursor);
+
+ _snapToBorderCheckbox = new GUI::CheckboxWidget(this, 5, 22, 130, 20, _("Snap to edges"), 0, 0, 'T');
+ _snapToBorderCheckbox->setState(config.snapToBorder);
+
+ _stretchToFitCheckbox = new GUI::CheckboxWidget(this, 140, 5, 130, 20, _("Stretch to fit"), 0, 0, 'T');
+ _stretchToFitCheckbox->setState(config.stretchToFit);
+
+ new GUI::StaticTextWidget(this, 0, 60, 110, 15, _("Use Screen:"), Graphics::kTextAlignRight);
+ _screenRadioGroup = new GUI::RadiobuttonGroup(this, kScreenRadioGroup);
+ _screenTopRadioWidget = new GUI::RadiobuttonWidget(this, 120, 50, 60, 20, _screenRadioGroup, kScreenTop, _("Top"));
+ _screenBottomRadioWidget = new GUI::RadiobuttonWidget(this, 190, 50, 80, 20, _screenRadioGroup, kScreenBottom, _("Bottom"));
+ _screenBothRadioWidget = new GUI::RadiobuttonWidget(this, 155, 70, 80, 20, _screenRadioGroup, kScreenBoth, _("Both"));
+ _screenRadioGroup->setValue(config.screen);
+
+ new GUI::StaticTextWidget(this, 0, 100, 110, 15, _("C-Pad Sensitivity:"), Graphics::kTextAlignRight);
+ _sensitivity = new GUI::SliderWidget(this, 115, 100, 160, 15, "TODO: Add tooltip", 1);
+ _sensitivity->setMinValue(-15);
+ _sensitivity->setMaxValue(30);
+ _sensitivity->setValue(config.sensitivity);
+ _sensitivity->setFlags(GUI::WIDGET_CLEARBG);
+}
+
+OptionsDialog::~OptionsDialog() {
+ optionMenuOpened = false;
+}
+
+void OptionsDialog::updateConfigManager() {
+ config.showCursor = _showCursorCheckbox->getState();
+ config.snapToBorder = _snapToBorderCheckbox->getState();
+ config.stretchToFit = _stretchToFitCheckbox->getState();
+ config.sensitivity = _sensitivity->getValue();
+ config.screen = _screenRadioGroup->getValue();
+ saveConfig();
+ loadConfig();
+}
+
+void OptionsDialog::handleCommand(GUI::CommandSender *sender, uint32 cmd, uint32 data) {
+ switch(cmd) {
+ case GUI::kOKCmd:
+ updateConfigManager();
+ // Fall through
+ case GUI::kCloseCmd:
+ close();
+ break;
+ default:
+ Dialog::handleCommand(sender, cmd, data);
+ break;
+ }
+}
+
+} // namespace _3DS
diff --git a/backends/platform/3ds/options-dialog.h b/backends/platform/3ds/options-dialog.h
new file mode 100644
index 0000000000..d8c0d7bc7d
--- /dev/null
+++ b/backends/platform/3ds/options-dialog.h
@@ -0,0 +1,70 @@
+/* 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.
+ *
+ */
+
+#ifndef OPTIONS_DIALOG_3DS_H
+#define OPTIONS_DIALOG_3DS_H
+
+
+#include "common/scummsys.h"
+#include "common/str.h"
+#include "gui/object.h"
+#include "gui/widget.h"
+#include "gui/dialog.h"
+#include "gui/widgets/tab.h"
+#include "scumm/dialogs.h"
+
+namespace _3DS {
+
+enum {
+ kSave = 0x10000000,
+ kScreenRadioGroup,
+ kScreenTop,
+ kScreenBottom,
+ kScreenBoth,
+};
+
+extern bool optionMenuOpened;
+
+class OptionsDialog : public GUI::Dialog {
+
+public:
+ OptionsDialog();
+ ~OptionsDialog();
+
+protected:
+ virtual void handleCommand(GUI::CommandSender *sender, uint32 cmd, uint32 data);
+ void updateConfigManager();
+
+ GUI::SliderWidget *_sensitivity;
+ GUI::CheckboxWidget *_showCursorCheckbox;
+ GUI::CheckboxWidget *_snapToBorderCheckbox;
+ GUI::CheckboxWidget *_stretchToFitCheckbox;
+
+ GUI::RadiobuttonGroup *_screenRadioGroup;
+ GUI::RadiobuttonWidget *_screenTopRadioWidget;
+ GUI::RadiobuttonWidget *_screenBottomRadioWidget;
+ GUI::RadiobuttonWidget *_screenBothRadioWidget;
+};
+
+} // namespace _3DS
+
+#endif // OPTIONS_DIALOG_3DS_H
diff --git a/backends/platform/3ds/osystem-audio.cpp b/backends/platform/3ds/osystem-audio.cpp
new file mode 100644
index 0000000000..58262372cc
--- /dev/null
+++ b/backends/platform/3ds/osystem-audio.cpp
@@ -0,0 +1,110 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "osystem.h"
+#include "audio/mixer.h"
+
+namespace _3DS {
+
+static bool hasAudio = false;
+
+static void audioThreadFunc(void *arg) {
+ Audio::MixerImpl *mixer = (Audio::MixerImpl *)arg;
+ OSystem_3DS *osys = (OSystem_3DS *)g_system;
+
+ int i;
+ const int channel = 0;
+ int bufferIndex = 0;
+ const int bufferCount = 3;
+ const int bufferSize = 80000; // Can't be too small, based on delayMillis duration
+ const int sampleRate = mixer->getOutputRate();
+ int sampleLen = 0;
+ uint32 lastTime = osys->getMillis(true);
+ uint32 time = lastTime;
+ ndspWaveBuf buffers[bufferCount];
+
+ for (i = 0; i < bufferCount; ++i) {
+ memset(&buffers[i], 0, sizeof(ndspWaveBuf));
+ buffers[i].data_vaddr = linearAlloc(bufferSize);
+ buffers[i].looping = false;
+ buffers[i].status = NDSP_WBUF_FREE;
+ }
+
+ ndspChnReset(channel);
+ ndspChnSetInterp(channel, NDSP_INTERP_LINEAR);
+ ndspChnSetRate(channel, sampleRate);
+ ndspChnSetFormat(channel, NDSP_FORMAT_STEREO_PCM16);
+
+ while (!osys->exiting) {
+ osys->delayMillis(100); // Note: Increasing the delay requires a bigger buffer
+
+ time = osys->getMillis(true);
+ sampleLen = (time - lastTime) * 22 * 4; // sampleRate / 1000 * channelCount * sizeof(int16);
+ lastTime = time;
+
+ if (!osys->sleeping && sampleLen > 0) {
+ bufferIndex++;
+ bufferIndex %= bufferCount;
+ ndspWaveBuf *buf = &buffers[bufferIndex];
+
+ buf->nsamples = mixer->mixCallback(buf->data_adpcm, sampleLen);
+ if (buf->nsamples > 0) {
+ DSP_FlushDataCache(buf->data_vaddr, bufferSize);
+ ndspChnWaveBufAdd(channel, buf);
+ }
+ }
+ }
+
+ for (i = 0; i < bufferCount; ++i)
+ linearFree(buffers[i].data_pcm8);
+}
+
+void OSystem_3DS::initAudio() {
+ _mixer = new Audio::MixerImpl(this, 22050);
+
+ hasAudio = R_SUCCEEDED(ndspInit());
+ _mixer->setReady(false);
+
+ if (hasAudio) {
+ s32 prio = 0;
+ svcGetThreadPriority(&prio, CUR_THREAD_HANDLE);
+ audioThread = threadCreate(&audioThreadFunc, _mixer, 32 * 1048, prio - 1, -2, false);
+ }
+}
+
+void OSystem_3DS::destroyAudio() {
+ if (hasAudio) {
+ threadJoin(audioThread, U64_MAX);
+ threadFree(audioThread);
+ ndspExit();
+ }
+
+ delete _mixer;
+ _mixer = 0;
+}
+
+Audio::Mixer *OSystem_3DS::getMixer() {
+ assert(_mixer);
+ return _mixer;
+}
+
+} // namespace _3DS
diff --git a/backends/platform/3ds/osystem-events.cpp b/backends/platform/3ds/osystem-events.cpp
new file mode 100644
index 0000000000..064540fa66
--- /dev/null
+++ b/backends/platform/3ds/osystem-events.cpp
@@ -0,0 +1,302 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "backends/timer/default/default-timer.h"
+#include "engines/engine.h"
+#include "gui.h"
+#include "options-dialog.h"
+#include "config.h"
+#include "osystem.h"
+
+namespace _3DS {
+
+static Common::Mutex *eventMutex;
+static InputMode inputMode = MODE_DRAG;
+static aptHookCookie cookie;
+static bool optionMenuOpening = false;
+static Common::String messageOSD;
+static bool showMessageOSD = false;
+
+static void pushEventQueue(Common::Queue<Common::Event> *queue, Common::Event &event) {
+ Common::StackLock lock(*eventMutex);
+ queue->push(event);
+}
+
+static void eventThreadFunc(void *arg) {
+ OSystem_3DS *osys = (OSystem_3DS *)g_system;
+ auto eventQueue = (Common::Queue<Common::Event> *)arg;
+
+ uint32 touchStartTime = osys->getMillis();
+ touchPosition lastTouch = {0, 0};
+ bool isRightClick = false;
+ float cursorX = 0;
+ float cursorY = 0;
+ float cursorDeltaX = 0;
+ float cursorDeltaY = 0;
+ int circleDeadzone = 20;
+ int borderSnapZone = 6;
+ Common::Event event;
+
+ while (!osys->exiting) {
+ do {
+ osys->delayMillis(10);
+ } while (osys->sleeping && !osys->exiting);
+
+ hidScanInput();
+ touchPosition touch;
+ circlePosition circle;
+ u32 held = hidKeysHeld();
+ u32 keysPressed = hidKeysDown();
+ u32 keysReleased = hidKeysUp();
+
+ // C-Pad used to control the cursor
+ hidCircleRead(&circle);
+ if (circle.dx < circleDeadzone && circle.dx > -circleDeadzone)
+ circle.dx = 0;
+ if (circle.dy < circleDeadzone && circle.dy > -circleDeadzone)
+ circle.dy = 0;
+ cursorDeltaX = (0.0002f + config.sensitivity / 100000.f) * circle.dx * abs(circle.dx);
+ cursorDeltaY = (0.0002f + config.sensitivity / 100000.f) * circle.dy * abs(circle.dy);
+
+ // Touch screen events
+ if (held & KEY_TOUCH) {
+ hidTouchRead(&touch);
+ if (config.snapToBorder) {
+ if (touch.px < borderSnapZone)
+ touch.px = 0;
+ if (touch.px > 319 - borderSnapZone)
+ touch.px = 319;
+ if (touch.py < borderSnapZone)
+ touch.py = 0;
+ if (touch.py > 239 - borderSnapZone)
+ touch.py = 239;
+ }
+ cursorX = touch.px;
+ cursorY = touch.py;
+ osys->transformPoint(touch);
+
+ osys->warpMouse(touch.px, touch.py);
+ event.mouse.x = touch.px;
+ event.mouse.y = touch.py;
+
+ if (keysPressed & KEY_TOUCH) {
+ touchStartTime = osys->getMillis();
+ isRightClick = (held & KEY_X || held & KEY_DUP);
+ if (inputMode == MODE_DRAG) {
+ event.type = isRightClick ? Common::EVENT_RBUTTONDOWN : Common::EVENT_LBUTTONDOWN;
+ pushEventQueue(eventQueue, event);
+ }
+ } else if (touch.px != lastTouch.px || touch.py != lastTouch.py) {
+ event.type = Common::EVENT_MOUSEMOVE;
+ pushEventQueue(eventQueue, event);
+ }
+
+ lastTouch = touch;
+ } else if (keysReleased & KEY_TOUCH) {
+ event.mouse.x = lastTouch.px;
+ event.mouse.y = lastTouch.py;
+ if (inputMode == MODE_DRAG) {
+ event.type = isRightClick ? Common::EVENT_RBUTTONUP : Common::EVENT_LBUTTONUP;
+ pushEventQueue(eventQueue, event);
+ } else if (osys->getMillis() - touchStartTime < 200) {
+ // Process click in MODE_HOVER
+ event.type = Common::EVENT_MOUSEMOVE;
+ pushEventQueue(eventQueue, event);
+ event.type = isRightClick ? Common::EVENT_RBUTTONDOWN : Common::EVENT_LBUTTONDOWN;
+ pushEventQueue(eventQueue, event);
+ event.type = isRightClick ? Common::EVENT_RBUTTONUP : Common::EVENT_LBUTTONUP;
+ pushEventQueue(eventQueue, event);
+ }
+ } else if (cursorDeltaX != 0 || cursorDeltaY != 0) {
+ cursorX += cursorDeltaX;
+ cursorY -= cursorDeltaY;
+ if (cursorX < 0) cursorX = 0;
+ if (cursorY < 0) cursorY = 0;
+ if (cursorX > 320) cursorX = 320;
+ if (cursorY > 240) cursorY = 240;
+ lastTouch.px = cursorX;
+ lastTouch.py = cursorY;
+ osys->transformPoint(lastTouch);
+ osys->warpMouse(lastTouch.px, lastTouch.py);
+ event.mouse.x = lastTouch.px;
+ event.mouse.y = lastTouch.py;
+ event.type = Common::EVENT_MOUSEMOVE;
+ pushEventQueue(eventQueue, event);
+ }
+
+ // Button events
+ if (keysPressed & KEY_R) {
+ if (inputMode == MODE_DRAG) {
+ inputMode = MODE_HOVER;
+ osys->displayMessageOnOSD("Hover Mode");
+ } else {
+ inputMode = MODE_DRAG;
+ osys->displayMessageOnOSD("Drag Mode");
+ }
+ }
+ if (keysPressed & KEY_A || keysPressed & KEY_DLEFT || keysReleased & KEY_A || keysReleased & KEY_DLEFT) {
+ // SIMULATE LEFT CLICK
+ event.mouse.x = lastTouch.px;
+ event.mouse.y = lastTouch.py;
+ if (keysPressed & KEY_A || keysPressed & KEY_DLEFT)
+ event.type = Common::EVENT_LBUTTONDOWN;
+ else
+ event.type = Common::EVENT_LBUTTONUP;
+ pushEventQueue(eventQueue, event);
+ }
+ if (keysPressed & KEY_X || keysPressed & KEY_DUP || keysReleased & KEY_X || keysReleased & KEY_DUP) {
+ // SIMULATE RIGHT CLICK
+ event.mouse.x = lastTouch.px;
+ event.mouse.y = lastTouch.py;
+ if (keysPressed & KEY_X || keysPressed & KEY_DUP)
+ event.type = Common::EVENT_RBUTTONDOWN;
+ else
+ event.type = Common::EVENT_RBUTTONUP;
+ pushEventQueue(eventQueue, event);
+ }
+ if (keysPressed & KEY_L) {
+ event.type = Common::EVENT_VIRTUAL_KEYBOARD;
+ pushEventQueue(eventQueue, event);
+ }
+ if (keysPressed & KEY_START) {
+ event.type = Common::EVENT_MAINMENU;
+ pushEventQueue(eventQueue, event);
+ }
+ if (keysPressed & KEY_SELECT) {
+ if (!optionMenuOpened)
+ optionMenuOpening = true;
+ }
+ if (keysPressed & KEY_B || keysReleased & KEY_B || keysPressed & KEY_DDOWN || keysReleased & KEY_DDOWN) {
+ if (keysPressed & KEY_B || keysPressed & KEY_DDOWN)
+ event.type = Common::EVENT_KEYDOWN;
+ else
+ event.type = Common::EVENT_KEYUP;
+ event.kbd.keycode = Common::KEYCODE_ESCAPE;
+ event.kbd.ascii = Common::ASCII_ESCAPE;
+ event.kbd.flags = 0;
+ pushEventQueue(eventQueue, event);
+ }
+
+ // TODO: EVENT_PREDICTIVE_DIALOG
+ // EVENT_SCREEN_CHANGED
+ }
+}
+
+static void aptHookFunc(APT_HookType hookType, void *param) {
+ OSystem_3DS *osys = (OSystem_3DS *)g_system;
+
+ switch (hookType) {
+ case APTHOOK_ONSUSPEND:
+ case APTHOOK_ONSLEEP:
+ if (g_engine)
+ g_engine->pauseEngine(true);
+ osys->sleeping = true;
+ if (R_SUCCEEDED(gspLcdInit())) {
+ GSPLCD_PowerOnBacklight(GSPLCD_SCREEN_BOTH);
+ gspLcdExit();
+ }
+ break;
+ case APTHOOK_ONRESTORE:
+ case APTHOOK_ONWAKEUP:
+ if (g_engine)
+ g_engine->pauseEngine(false);
+ osys->sleeping = false;
+ loadConfig();
+ break;
+ default: {
+ Common::StackLock lock(*eventMutex);
+ Common::Event event;
+ event.type = Common::EVENT_QUIT;
+ g_system->getEventManager()->pushEvent(event);
+ }
+ }
+}
+
+static void timerThreadFunc(void *arg) {
+ OSystem_3DS *osys = (OSystem_3DS *)arg;
+ DefaultTimerManager *tm = (DefaultTimerManager *)osys->getTimerManager();
+ while (!osys->exiting) {
+ g_system->delayMillis(10);
+ tm->handler();
+ }
+}
+
+void OSystem_3DS::initEvents() {
+ eventMutex = new Common::Mutex();
+ s32 prio = 0;
+ svcGetThreadPriority(&prio, CUR_THREAD_HANDLE);
+ _timerThread = threadCreate(&timerThreadFunc, this, 32 * 1024, prio - 1, -2, false);
+ _eventThread = threadCreate(&eventThreadFunc, &_eventQueue, 32 * 1024, prio - 1, -2, false);
+
+ aptHook(&cookie, aptHookFunc, this);
+}
+
+void OSystem_3DS::destroyEvents() {
+ threadJoin(_timerThread, U64_MAX);
+ threadFree(_timerThread);
+
+ threadJoin(_eventThread, U64_MAX);
+ threadFree(_eventThread);
+ delete eventMutex;
+}
+
+void OSystem_3DS::transformPoint(touchPosition &point) {
+ if (!_overlayVisible) {
+ point.px = static_cast<float>(point.px) / _gameBottomTexture.getScaleX() - _gameBottomX;
+ point.py = static_cast<float>(point.py) / _gameBottomTexture.getScaleY() - _gameBottomY;
+ }
+}
+
+void OSystem_3DS::displayMessageOnOSD(const char *msg) {
+ messageOSD = msg;
+ showMessageOSD = true;
+}
+
+bool OSystem_3DS::pollEvent(Common::Event &event) {
+ if (showMessageOSD) {
+ showMessageOSD = false;
+ StatusMessageDialog dialog(messageOSD, 800);
+ dialog.runModal();
+ }
+
+ aptMainLoop(); // Call apt hook when necessary
+
+ if (optionMenuOpening) {
+ optionMenuOpening = false;
+ OptionsDialog dialog;
+ if (g_engine)
+ g_engine->pauseEngine(true);
+ dialog.runModal();
+ if (g_engine)
+ g_engine->pauseEngine(false);
+ }
+
+ Common::StackLock lock(*eventMutex);
+
+ if (_eventQueue.empty())
+ return false;
+
+ event = _eventQueue.pop();
+ return true;
+}
+
+} // namespace _3DS
diff --git a/backends/platform/3ds/osystem-graphics.cpp b/backends/platform/3ds/osystem-graphics.cpp
new file mode 100644
index 0000000000..ec60956805
--- /dev/null
+++ b/backends/platform/3ds/osystem-graphics.cpp
@@ -0,0 +1,517 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This _program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This _program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this _program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+ * USA.
+ *
+ */
+
+#include "backends/platform/3ds/osystem.h"
+#include "backends/platform/3ds/shader_shbin.h"
+#include "common/rect.h"
+#include "options-dialog.h"
+#include "config.h"
+
+// Used to transfer the final rendered display to the framebuffer
+#define DISPLAY_TRANSFER_FLAGS \
+ (GX_TRANSFER_FLIP_VERT(0) | GX_TRANSFER_OUT_TILED(0) | \
+ GX_TRANSFER_RAW_COPY(0) | GX_TRANSFER_IN_FORMAT(GX_TRANSFER_FMT_RGBA8) | \
+ GX_TRANSFER_OUT_FORMAT(GX_TRANSFER_FMT_RGB8) | \
+ GX_TRANSFER_SCALING(GX_TRANSFER_SCALE_NO))
+
+namespace _3DS {
+
+void OSystem_3DS::initGraphics() {
+ _pfGame = Graphics::PixelFormat::createFormatCLUT8();
+ _pfGameTexture = Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8, 0);
+
+ C3D_Init(C3D_DEFAULT_CMDBUF_SIZE);
+
+ // Initialize the render targets
+ _renderTargetTop =
+ C3D_RenderTargetCreate(240, 400, GPU_RB_RGBA8, GPU_RB_DEPTH24_STENCIL8);
+ C3D_RenderTargetSetClear(_renderTargetTop, C3D_CLEAR_ALL, 0x0000000, 0);
+ C3D_RenderTargetSetOutput(_renderTargetTop, GFX_TOP, GFX_LEFT,
+ DISPLAY_TRANSFER_FLAGS);
+
+ _renderTargetBottom =
+ C3D_RenderTargetCreate(240, 320, GPU_RB_RGBA8, GPU_RB_DEPTH24_STENCIL8);
+ C3D_RenderTargetSetClear(_renderTargetBottom, C3D_CLEAR_ALL, 0x00000000, 0);
+ C3D_RenderTargetSetOutput(_renderTargetBottom, GFX_BOTTOM, GFX_LEFT,
+ DISPLAY_TRANSFER_FLAGS);
+
+ // Load and bind simple default shader (shader.v.pica)
+ _dvlb = DVLB_ParseFile((u32*)shader_shbin, shader_shbin_size);
+ shaderProgramInit(&_program);
+ shaderProgramSetVsh(&_program, &_dvlb->DVLE[0]);
+ C3D_BindProgram(&_program);
+
+ _projectionLocation = shaderInstanceGetUniformLocation(_program.vertexShader, "projection");
+ _modelviewLocation = shaderInstanceGetUniformLocation(_program.vertexShader, "modelView");
+
+ C3D_AttrInfo *attrInfo = C3D_GetAttrInfo();
+ AttrInfo_Init(attrInfo);
+ AttrInfo_AddLoader(attrInfo, 0, GPU_FLOAT, 3); // v0=position
+ AttrInfo_AddLoader(attrInfo, 1, GPU_FLOAT, 2); // v1=texcoord
+
+ Mtx_OrthoTilt(&_projectionTop, 0.0, 400.0, 240.0, 0.0, 0.0, 1.0);
+ Mtx_OrthoTilt(&_projectionBottom, 0.0, 320.0, 240.0, 0.0, 0.0, 1.0);
+
+ C3D_TexEnv *env = C3D_GetTexEnv(0);
+ C3D_TexEnvSrc(env, C3D_Both, GPU_TEXTURE0, 0, 0);
+ C3D_TexEnvOp(env, C3D_Both, 0, 0, 0);
+ C3D_TexEnvFunc(env, C3D_Both, GPU_REPLACE);
+
+ C3D_DepthTest(false, GPU_GEQUAL, GPU_WRITE_ALL);
+ C3D_CullFace(GPU_CULL_NONE);
+}
+
+void OSystem_3DS::destroyGraphics() {
+ _gameScreen.free();
+ _gameTopTexture.free();
+ _gameBottomTexture.free();
+ _overlay.free();
+
+ shaderProgramFree(&_program);
+ DVLB_Free(_dvlb);
+
+ C3D_RenderTargetDelete(_renderTargetTop);
+ C3D_RenderTargetDelete(_renderTargetBottom);
+
+ C3D_Fini();
+}
+
+bool OSystem_3DS::hasFeature(OSystem::Feature f) {
+ return (f == OSystem::kFeatureCursorPalette ||
+ f == OSystem::kFeatureOverlaySupportsAlpha);
+}
+
+void OSystem_3DS::setFeatureState(OSystem::Feature f, bool enable) {
+ switch (f) {
+ case OSystem::kFeatureCursorPalette:
+ _cursorPaletteEnabled = enable;
+ flushCursor();
+ break;
+ default:
+ break;
+ }
+}
+
+bool OSystem_3DS::getFeatureState(OSystem::Feature f) {
+ switch (f) {
+ case OSystem::kFeatureCursorPalette:
+ return _cursorPaletteEnabled;
+ default:
+ return false;
+ }
+}
+
+const OSystem::GraphicsMode *
+OSystem_3DS::getSupportedGraphicsModes() const {
+ return s_graphicsModes;
+}
+
+int OSystem_3DS::getDefaultGraphicsMode() const {
+ return GFX_LINEAR;
+}
+
+bool OSystem_3DS::setGraphicsMode(int mode) {
+ return true;
+}
+
+void OSystem_3DS::resetGraphicsScale() {
+ debug("resetGraphicsScale");
+}
+
+int OSystem_3DS::getGraphicsMode() const {
+ return GFX_LINEAR;
+}
+void OSystem_3DS::initSize(uint width, uint height,
+ const Graphics::PixelFormat *format) {
+ debug("3ds initsize w:%d h:%d", width, height);
+ _gameWidth = width;
+ _gameHeight = height;
+ _gameTopTexture.create(width, height, _pfGameTexture);
+ _overlay.create(getOverlayWidth(), getOverlayHeight(), _pfGameTexture);
+
+ if (format) {
+ debug("pixelformat: %d %d %d %d %d", format->bytesPerPixel, format->rBits(), format->gBits(), format->bBits(), format->aBits());;
+ _pfGame = *format;
+ }
+
+ _gameScreen.create(width, height, _pfGame);
+
+ _focusDirty = true;
+ _focusRect = Common::Rect(_gameWidth, _gameHeight);
+
+ updateSize();
+}
+
+void OSystem_3DS::updateSize() {
+ if (config.stretchToFit) {
+ _gameTopX = _gameTopY = _gameBottomX = _gameBottomY = 0;
+ _gameTopTexture.setScale(400.f / _gameWidth, 240.f / _gameHeight);
+ _gameBottomTexture.setScale(320.f / _gameWidth, 240.f / _gameHeight);
+ } else {
+ float ratio = static_cast<float>(_gameWidth) / _gameHeight;
+
+ if (ratio > 400.f / 240.f) {
+ float r = 400.f / _gameWidth;
+ _gameTopTexture.setScale(r, r);
+ _gameTopX = 0;
+ _gameTopY = (240.f - r * _gameHeight) / 2.f;
+ } else {
+ float r = 240.f / _gameHeight;
+ _gameTopTexture.setScale(r, r);
+ _gameTopY = 0;
+ _gameTopX = (400.f - r * _gameWidth) / 2.f;
+ }
+ if (ratio > 320.f / 240.f) {
+ float r = 320.f / _gameWidth;
+ _gameBottomTexture.setScale(r, r);
+ _gameBottomX = 0;
+ _gameBottomY = (240.f - r * _gameHeight) / 2.f;
+ } else {
+ float r = 240.f / _gameHeight;
+ _gameBottomTexture.setScale(r, r);
+ _gameBottomY = 0;
+ _gameBottomX = (320.f - r * _gameWidth) / 2.f;
+ }
+ }
+ _gameTopTexture.setPosition(_gameTopX, _gameTopY);
+ _gameBottomTexture.setPosition(_gameBottomX, _gameBottomY);
+ if (_overlayVisible)
+ _cursorTexture.setScale(1.f, 1.f);
+ else if (config.screen == kScreenTop)
+ _cursorTexture.setScale(_gameTopTexture.getScaleX(), _gameTopTexture.getScaleY());
+ else
+ _cursorTexture.setScale(_gameBottomTexture.getScaleX(), _gameBottomTexture.getScaleY());
+}
+
+Common::List<Graphics::PixelFormat> OSystem_3DS::getSupportedFormats() const {
+ Common::List<Graphics::PixelFormat> list;
+ list.push_back(Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8, 0)); // GPU_RGBA8
+ list.push_back(Graphics::PixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0)); // GPU_RGB565
+// list.push_back(Graphics::PixelFormat(3, 0, 0, 0, 8, 0, 8, 16, 0)); // GPU_RGB8
+ list.push_back(Graphics::PixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0)); // RGB555 (needed for FMTOWNS?)
+ list.push_back(Graphics::PixelFormat(2, 5, 5, 5, 1, 11, 6, 1, 0)); // GPU_RGBA5551
+ list.push_back(Graphics::PixelFormat::createFormatCLUT8());
+ return list;
+}
+
+void OSystem_3DS::beginGFXTransaction() {
+ //
+}
+OSystem::TransactionError OSystem_3DS::endGFXTransaction() {
+ return OSystem::kTransactionSuccess;
+}
+
+void OSystem_3DS::setPalette(const byte *colors, uint start, uint num) {
+ assert(start + num <= 256);
+ memcpy(_palette + 3 * start, colors, 3 * num);
+
+ // Manually update all color that were changed
+ if (_gameScreen.format.bytesPerPixel == 1) {
+ flushGameScreen();
+ }
+}
+void OSystem_3DS::grabPalette(byte *colors, uint start, uint num) {
+ assert(start + num <= 256);
+ memcpy(colors, _palette + 3 * start, 3 * num);
+}
+
+void OSystem_3DS::copyRectToScreen(const void *buf, int pitch, int x,
+ int y, int w, int h) {
+ Common::Rect rect(x, y, x+w, y+h);
+ _gameScreen.copyRectToSurface(buf, pitch, x, y, w, h);
+ Graphics::Surface subSurface = _gameScreen.getSubArea(rect);
+
+ Graphics::Surface *convertedSubSurface = subSurface.convertTo(_pfGameTexture, _palette);
+ _gameTopTexture.copyRectToSurface(*convertedSubSurface, x, y, Common::Rect(w, h));
+
+ convertedSubSurface->free();
+ delete convertedSubSurface;
+ _gameTopTexture.markDirty();
+}
+
+void OSystem_3DS::flushGameScreen() {
+ Graphics::Surface *converted = _gameScreen.convertTo(_pfGameTexture, _palette);
+ _gameTopTexture.copyRectToSurface(*converted, 0, 0, Common::Rect(converted->w, converted->h));
+ _gameTopTexture.markDirty();
+ converted->free();
+ delete converted;
+}
+
+Graphics::Surface *OSystem_3DS::lockScreen() {
+ return &_gameScreen;
+}
+void OSystem_3DS::unlockScreen() {
+ flushGameScreen();
+}
+
+void OSystem_3DS::updateScreen() {
+
+ if (sleeping || exiting)
+ return;
+
+// updateFocus();
+
+ C3D_FrameBegin(C3D_FRAME_SYNCDRAW);
+ // Render top screen
+ C3D_FrameDrawOn(_renderTargetTop);
+ if (config.screen == kScreenTop || config.screen == kScreenBoth) {
+ C3D_FVUnifMtx4x4(GPU_VERTEX_SHADER, _projectionLocation, &_projectionTop);
+ C3D_FVUnifMtx4x4(GPU_VERTEX_SHADER, _modelviewLocation, _gameTopTexture.getMatrix());
+ _gameTopTexture.render();
+ _gameTopTexture.render();
+ if (_overlayVisible && config.screen == kScreenTop) {
+ C3D_FVUnifMtx4x4(GPU_VERTEX_SHADER, _modelviewLocation, _overlay.getMatrix());
+ _overlay.render();
+ }
+ if (_cursorVisible && config.showCursor && config.screen == kScreenTop) {
+ C3D_FVUnifMtx4x4(GPU_VERTEX_SHADER, _modelviewLocation, _cursorTexture.getMatrix());
+ _cursorTexture.render();
+ }
+ }
+
+ // Render bottom screen
+ C3D_FrameDrawOn(_renderTargetBottom);
+ if (config.screen == kScreenBottom || config.screen == kScreenBoth) {
+ C3D_FVUnifMtx4x4(GPU_VERTEX_SHADER, _projectionLocation, &_projectionBottom);
+ C3D_FVUnifMtx4x4(GPU_VERTEX_SHADER, _modelviewLocation, _gameBottomTexture.getMatrix());
+ _gameTopTexture.render();
+ _gameTopTexture.render();
+ if (_overlayVisible) {
+ C3D_FVUnifMtx4x4(GPU_VERTEX_SHADER, _modelviewLocation, _overlay.getMatrix());
+ _overlay.render();
+ }
+ if (_cursorVisible && config.showCursor) {
+ C3D_FVUnifMtx4x4(GPU_VERTEX_SHADER, _modelviewLocation, _cursorTexture.getMatrix());
+ _cursorTexture.render();
+ }
+ }
+ C3D_FrameEnd(0);
+}
+
+void OSystem_3DS::setShakePos(int shakeOffset) {
+ // TODO: implement this in overlay, top screen, and mouse too
+ _screenShakeOffset = shakeOffset;
+ _gameTopTexture.setPosition(_gameTopX, _gameTopY + _gameTopTexture.getScaleY() * shakeOffset);
+ _gameBottomTexture.setPosition(_gameBottomX, _gameBottomY + _gameBottomTexture.getScaleY() * shakeOffset);
+}
+
+void OSystem_3DS::setFocusRectangle(const Common::Rect &rect) {
+ debug("setfocus: %d %d %d %d", rect.left, rect.top, rect.width(), rect.height());
+ _focusRect = rect;
+ _focusDirty = true;
+ _focusClearTime = 0;
+}
+
+void OSystem_3DS::clearFocusRectangle() {
+ _focusClearTime = getMillis();
+}
+
+void OSystem_3DS::updateFocus() {
+
+ if (_focusClearTime && getMillis() - _focusClearTime > 5000) {
+ _focusClearTime = 0;
+ _focusDirty = true;
+ _focusRect = Common::Rect(_gameWidth, _gameHeight);
+ }
+
+ if (_focusDirty) {
+ float duration = 1.f / 20.f; // Focus animation in frame duration
+ float w = 400.f;
+ float h = 240.f;
+ float ratio = _focusRect.width() / _focusRect.height();
+ if (ratio > w/h) {
+ _focusTargetScaleX = w / _focusRect.width();
+ float newHeight = (float)_focusRect.width() / w/h;
+ _focusTargetScaleY = h / newHeight;
+ _focusTargetPosX = _focusTargetScaleX * _focusRect.left;
+ _focusTargetPosY = _focusTargetScaleY * ((float)_focusRect.top - (newHeight - _focusRect.height())/2.f);
+ } else {
+ _focusTargetScaleY = h / _focusRect.height();
+ float newWidth = (float)_focusRect.height() * w/h;
+ _focusTargetScaleX = w / newWidth;
+ _focusTargetPosY = _focusTargetScaleY * _focusRect.top;
+ _focusTargetPosX = _focusTargetScaleX * ((float)_focusRect.left - (newWidth - _focusRect.width())/2.f);
+ }
+ if (_focusTargetPosX < 0 && _focusTargetScaleY != 240.f / _gameHeight)
+ _focusTargetPosX = 0;
+ if (_focusTargetPosY < 0 && _focusTargetScaleX != 400.f / _gameWidth)
+ _focusTargetPosY = 0;
+ _focusStepPosX = duration * (_focusTargetPosX - _focusPosX);
+ _focusStepPosY = duration * (_focusTargetPosY - _focusPosY);
+ _focusStepScaleX = duration * (_focusTargetScaleX - _focusScaleX);
+ _focusStepScaleY = duration * (_focusTargetScaleY - _focusScaleY);
+ }
+
+ if (_focusDirty || _focusPosX != _focusTargetPosX || _focusPosY != _focusTargetPosY ||
+ _focusScaleX != _focusTargetScaleX || _focusScaleY != _focusTargetScaleY) {
+ _focusDirty = false;
+
+ if ((_focusStepPosX > 0 && _focusPosX > _focusTargetPosX) || (_focusStepPosX < 0 && _focusPosX < _focusTargetPosX))
+ _focusPosX = _focusTargetPosX;
+ else if (_focusPosX != _focusTargetPosX)
+ _focusPosX += _focusStepPosX;
+
+ if ((_focusStepPosY > 0 && _focusPosY > _focusTargetPosY) || (_focusStepPosY < 0 && _focusPosY < _focusTargetPosY))
+ _focusPosY = _focusTargetPosY;
+ else if (_focusPosY != _focusTargetPosY)
+ _focusPosY += _focusStepPosY;
+
+ if ((_focusStepScaleX > 0 && _focusScaleX > _focusTargetScaleX) || (_focusStepScaleX < 0 && _focusScaleX < _focusTargetScaleX))
+ _focusScaleX = _focusTargetScaleX;
+ else if (_focusScaleX != _focusTargetScaleX)
+ _focusScaleX += _focusStepScaleX;
+
+ if ((_focusStepScaleY > 0 && _focusScaleY > _focusTargetScaleY) || (_focusStepScaleY < 0 && _focusScaleY < _focusTargetScaleY))
+ _focusScaleY = _focusTargetScaleY;
+ else if (_focusScaleY != _focusTargetScaleY)
+ _focusScaleY += _focusStepScaleY;
+
+ Mtx_Identity(&_focusMatrix);
+ Mtx_Translate(&_focusMatrix, -_focusPosX, -_focusPosY, 0);
+ Mtx_Scale(&_focusMatrix, _focusScaleX, _focusScaleY, 1.f);
+ }
+}
+
+void OSystem_3DS::showOverlay() {
+ _overlayVisible = true;
+ updateSize();
+ updateScreen();
+}
+
+void OSystem_3DS::hideOverlay() {
+ _overlayVisible = false;
+ updateSize();
+ updateScreen();
+}
+
+Graphics::PixelFormat OSystem_3DS::getOverlayFormat() const {
+ return _pfGameTexture;
+}
+
+void OSystem_3DS::clearOverlay() {
+ _overlay.clear();
+}
+
+void OSystem_3DS::grabOverlay(void *buf, int pitch) {
+ for (int y = 0; y < getOverlayHeight(); ++y) {
+ memcpy(buf, _overlay.getBasePtr(0, y), pitch);
+ }
+}
+
+void OSystem_3DS::copyRectToOverlay(const void *buf, int pitch, int x,
+ int y, int w, int h) {
+ _overlay.copyRectToSurface(buf, pitch, x, y, w, h);
+ _overlay.markDirty();
+}
+
+int16 OSystem_3DS::getOverlayHeight() {
+ return 240;
+}
+
+int16 OSystem_3DS::getOverlayWidth() {
+ return 320;
+}
+
+bool OSystem_3DS::showMouse(bool visible) {
+ _cursorVisible = visible;
+ flushCursor();
+ return !visible;
+}
+
+void OSystem_3DS::warpMouse(int x, int y) {
+ _cursorX = x;
+ _cursorY = y;
+ warning("x:%d y:%d", x, y);
+ // TODO: adjust for _cursorScalable ?
+ int offsetx = 0;
+ int offsety = 0;
+ x -= _cursorHotspotX;
+ y -= _cursorHotspotY;
+ if (!_overlayVisible) {
+ offsetx += config.screen == kScreenTop ? _gameTopX : _gameBottomX;
+ offsety += config.screen == kScreenTop ? _gameTopY : _gameBottomY;
+ }
+ float scalex = config.screen == kScreenTop ? (float)_gameTopTexture.actualWidth / _gameWidth : 1.f;
+ float scaley = config.screen == kScreenTop ? (float)_gameTopTexture.actualHeight / _gameHeight : 1.f;
+ _cursorTexture.setPosition(scalex * x + offsetx,
+ scaley * y + offsety);
+}
+
+void OSystem_3DS::setCursorDelta(float deltaX, float deltaY) {
+ _cursorDeltaX = deltaX;
+ _cursorDeltaY = deltaY;
+}
+
+void OSystem_3DS::setMouseCursor(const void *buf, uint w, uint h,
+ int hotspotX, int hotspotY,
+ uint32 keycolor, bool dontScale,
+ const Graphics::PixelFormat *format) {
+ _cursorScalable = !dontScale;
+ _cursorHotspotX = hotspotX;
+ _cursorHotspotY = hotspotY;
+ _cursorKeyColor = keycolor;
+ _pfCursor = !format ? Graphics::PixelFormat::createFormatCLUT8() : *format;
+
+ if (w != _cursor.w || h != _cursor.h || _cursor.format != _pfCursor) {
+ _cursor.create(w, h, _pfCursor);
+ _cursorTexture.create(w, h, _pfGameTexture);
+ }
+
+ _cursor.copyRectToSurface(buf, w, 0, 0, w, h);
+ flushCursor();
+
+ warpMouse(_cursorX, _cursorY);
+}
+
+void OSystem_3DS::setCursorPalette(const byte *colors, uint start, uint num) {
+ assert(start + num <= 256);
+ memcpy(_cursorPalette + 3 * start, colors, 3 * num);
+ _cursorPaletteEnabled = true;
+ flushCursor();
+}
+
+void OSystem_3DS::flushCursor() {
+ if (_cursor.getPixels()) {
+ Graphics::Surface *converted = _cursor.convertTo(_pfGameTexture, _cursorPaletteEnabled ? _cursorPalette : _palette);
+ _cursorTexture.copyRectToSurface(*converted, 0, 0, Common::Rect(converted->w, converted->h));
+ _cursorTexture.markDirty();
+ converted->free();
+ delete converted;
+
+ if (_pfCursor.bytesPerPixel == 1) {
+ uint* dest = (uint*) _cursorTexture.getPixels();
+ byte* src = (byte*) _cursor.getPixels();
+ for (int y = 0; y < _cursor.h; ++y) {
+ for (int x = 0; x < _cursor.w; ++x) {
+ if (*src++ == _cursorKeyColor)
+ *dest++ = 0;
+ else
+ dest++;
+ }
+ dest += _cursorTexture.w - _cursorTexture.actualWidth;
+ }
+ }
+ }
+}
+
+} // namespace _3DS
diff --git a/backends/platform/3ds/osystem.cpp b/backends/platform/3ds/osystem.cpp
new file mode 100644
index 0000000000..e19ff8f8de
--- /dev/null
+++ b/backends/platform/3ds/osystem.cpp
@@ -0,0 +1,193 @@
+/* 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.
+ *
+ */
+
+#define FORBIDDEN_SYMBOL_EXCEPTION_printf
+#define FORBIDDEN_SYMBOL_EXCEPTION_time_h
+#define FORBIDDEN_SYMBOL_EXCEPTION_unistd_h
+
+#include "osystem.h"
+
+#include "backends/saves/default/default-saves.h"
+#include "backends/timer/default/default-timer.h"
+#include "backends/events/default/default-events.h"
+#include "audio/mixer_intern.h"
+#include "common/scummsys.h"
+#include "common/config-manager.h"
+#include "common/str.h"
+#include "config.h"
+
+#include "backends/fs/posix/posix-fs-factory.h"
+#include "backends/fs/posix/posix-fs.h"
+#include <unistd.h>
+#include <time.h>
+
+namespace _3DS {
+
+OSystem_3DS::OSystem_3DS():
+ _focusDirty(true),
+ _focusRect(Common::Rect(1, 1)),
+ _focusPosX(0),
+ _focusPosY(0),
+ _focusTargetPosX(0),
+ _focusTargetPosY(0),
+ _focusStepPosX(0),
+ _focusStepPosY(0),
+ _focusScaleX(1.f),
+ _focusScaleY(1.f),
+ _focusTargetScaleX(1.f),
+ _focusTargetScaleY(1.f),
+ _focusStepScaleX(0.f),
+ _focusStepScaleY(0.f),
+ _focusClearTime(0),
+ _cursorPaletteEnabled(false),
+ _cursorVisible(false),
+ _cursorScalable(false),
+ _cursorX(0),
+ _cursorY(0),
+ _cursorHotspotX(0),
+ _cursorHotspotY(0),
+ _gameTopX(0),
+ _gameTopY(0),
+ _gameBottomX(0),
+ _gameBottomY(0),
+ _gameWidth(320),
+ _gameHeight(240),
+ _overlayVisible(false),
+ exiting(false),
+ sleeping(false)
+{
+ chdir("sdmc:/");
+ _fsFactory = new POSIXFilesystemFactory();
+ Posix::assureDirectoryExists("/3ds/scummvm/saves/");
+}
+
+OSystem_3DS::~OSystem_3DS() {
+ exiting = true;
+ destroyEvents();
+ destroyAudio();
+ destroyGraphics();
+
+ delete _timerManager;
+ _timerManager = 0;
+}
+
+void OSystem_3DS::quit() {
+ printf("OSystem_3DS::quit()\n");
+}
+
+void OSystem_3DS::initBackend() {
+ loadConfig();
+ ConfMan.registerDefault("fullscreen", true);
+ ConfMan.registerDefault("aspect_ratio", true);
+ if (!ConfMan.hasKey("vkeybd_pack_name"))
+ ConfMan.set("vkeybd_pack_name", "vkeybd_small");
+ if (!ConfMan.hasKey("vkeybdpath"))
+ ConfMan.set("vkeybdpath", "/3ds/scummvm/kb");
+ if (!ConfMan.hasKey("themepath"))
+ ConfMan.set("themepath", "/3ds/scummvm");
+ if (!ConfMan.hasKey("gui_theme"))
+ ConfMan.set("gui_theme", "builtin");
+
+ _timerManager = new DefaultTimerManager();
+ _savefileManager = new DefaultSaveFileManager("/3ds/scummvm/saves/");
+
+ initGraphics();
+ initAudio();
+ initEvents();
+ EventsBaseBackend::initBackend();
+}
+
+void OSystem_3DS::updateConfig() {
+ if (_gameScreen.getPixels()) {
+ updateSize();
+ warpMouse(_cursorX, _cursorY);
+ }
+}
+
+Common::String OSystem_3DS::getDefaultConfigFileName() {
+ return "/3ds/scummvm/scummvm.ini";
+}
+
+uint32 OSystem_3DS::getMillis(bool skipRecord) {
+ return svcGetSystemTick() / TICKS_PER_MSEC;
+}
+
+void OSystem_3DS::delayMillis(uint msecs) {
+ svcSleepThread(msecs * 1000000);
+}
+
+void OSystem_3DS::getTimeAndDate(TimeDate& td) const {
+ time_t curTime = time(0);
+ struct tm t = *localtime(&curTime);
+ td.tm_sec = t.tm_sec;
+ td.tm_min = t.tm_min;
+ td.tm_hour = t.tm_hour;
+ td.tm_mday = t.tm_mday;
+ td.tm_mon = t.tm_mon;
+ td.tm_year = t.tm_year;
+ td.tm_wday = t.tm_wday;
+}
+
+OSystem::MutexRef OSystem_3DS::createMutex() {
+ RecursiveLock *mutex = new RecursiveLock();
+ RecursiveLock_Init(mutex);
+ return (OSystem::MutexRef) mutex;
+}
+void OSystem_3DS::lockMutex(MutexRef mutex) {
+ RecursiveLock_Lock((RecursiveLock*)mutex);
+}
+void OSystem_3DS::unlockMutex(MutexRef mutex) {
+ RecursiveLock_Unlock((RecursiveLock*)mutex);
+}
+void OSystem_3DS::deleteMutex(MutexRef mutex) {
+ delete (RecursiveLock*)mutex;
+}
+
+Common::String OSystem_3DS::getSystemLanguage() const {
+ u8 langcode;
+ CFGU_GetSystemLanguage(&langcode);
+ switch (langcode) {
+ case CFG_LANGUAGE_JP: return "ja_JP";
+ case CFG_LANGUAGE_EN: return "en_US";
+ case CFG_LANGUAGE_FR: return "fr_FR";
+ case CFG_LANGUAGE_DE: return "de_DE";
+ case CFG_LANGUAGE_IT: return "it_IT";
+ case CFG_LANGUAGE_ES: return "es_ES";
+ case CFG_LANGUAGE_ZH: return "zh_CN";
+ case CFG_LANGUAGE_KO: return "ko_KR";
+ case CFG_LANGUAGE_NL: return "nl_NL";
+ case CFG_LANGUAGE_PT: return "pt_BR";
+ case CFG_LANGUAGE_RU: return "ru_RU";
+ case CFG_LANGUAGE_TW: return "zh_HK";
+ default: return "en_US";
+ }
+}
+
+void OSystem_3DS::fatalError() {
+ printf("FatalError!\n");
+}
+
+void OSystem_3DS::logMessage(LogMessageType::Type type, const char *message) {
+ printf("3DS log: %s\n", message);
+}
+
+} // namespace _3DS
diff --git a/backends/platform/3ds/osystem.h b/backends/platform/3ds/osystem.h
new file mode 100644
index 0000000000..5df49fe593
--- /dev/null
+++ b/backends/platform/3ds/osystem.h
@@ -0,0 +1,221 @@
+/* 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.
+ *
+ */
+
+#ifndef PLATFORM_3DS_H
+#define PLATFORM_3DS_H
+
+#include <citro3d.h>
+#include "backends/mutex/mutex.h"
+#include "backends/base-backend.h"
+#include "graphics/palette.h"
+#include "base/main.h"
+#include "audio/mixer_intern.h"
+#include "backends/graphics/graphics.h"
+#include "backends/platform/3ds/sprite.h"
+#include "common/rect.h"
+#include "common/queue.h"
+
+#define TICKS_PER_MSEC 268123
+
+namespace _3DS {
+
+enum {
+ GFX_LINEAR = 0,
+ GFX_NEAREST = 1
+};
+
+enum InputMode {
+ MODE_HOVER,
+ MODE_DRAG,
+};
+
+static const OSystem::GraphicsMode s_graphicsModes[] = {
+ {"default", "Default Test", GFX_LINEAR},
+ { 0, 0, 0 }
+};
+
+class OSystem_3DS : public EventsBaseBackend, public PaletteManager {
+public:
+ OSystem_3DS();
+ virtual ~OSystem_3DS();
+
+ volatile bool exiting;
+ volatile bool sleeping;
+
+ virtual void initBackend();
+
+ virtual bool hasFeature(OSystem::Feature f);
+ virtual void setFeatureState(OSystem::Feature f, bool enable);
+ virtual bool getFeatureState(OSystem::Feature f);
+
+ virtual bool pollEvent(Common::Event &event);
+
+ virtual uint32 getMillis(bool skipRecord = false);
+ virtual void delayMillis(uint msecs);
+ virtual void getTimeAndDate(TimeDate &t) const;
+
+ virtual MutexRef createMutex();
+ virtual void lockMutex(MutexRef mutex);
+ virtual void unlockMutex(MutexRef mutex);
+ virtual void deleteMutex(MutexRef mutex);
+
+ virtual void logMessage(LogMessageType::Type type, const char *message);
+
+ virtual Audio::Mixer *getMixer();
+ virtual PaletteManager *getPaletteManager() { return this; }
+ virtual Common::String getSystemLanguage() const;
+ virtual void fatalError();
+ virtual void quit();
+
+ virtual Common::String getDefaultConfigFileName();
+
+ // Graphics
+ virtual const OSystem::GraphicsMode *getSupportedGraphicsModes() const;
+ int getDefaultGraphicsMode() const;
+ bool setGraphicsMode(int mode);
+ void resetGraphicsScale();
+ int getGraphicsMode() const;
+ inline Graphics::PixelFormat getScreenFormat() const { return _pfGame; }
+ virtual Common::List<Graphics::PixelFormat> getSupportedFormats() const;
+ void initSize(uint width, uint height,
+ const Graphics::PixelFormat *format = NULL);
+ virtual int getScreenChangeID() const { return 0; };
+
+ void beginGFXTransaction();
+ OSystem::TransactionError endGFXTransaction();
+ int16 getHeight(){ return _gameHeight; }
+ int16 getWidth(){ return _gameWidth; }
+ void setPalette(const byte *colors, uint start, uint num);
+ void grabPalette(byte *colors, uint start, uint num);
+ void copyRectToScreen(const void *buf, int pitch, int x, int y, int w,
+ int h);
+ Graphics::Surface *lockScreen();
+ void unlockScreen();
+ void updateScreen();
+ void setShakePos(int shakeOffset);
+ void setFocusRectangle(const Common::Rect &rect);
+ void clearFocusRectangle();
+ void showOverlay();
+ void hideOverlay();
+ Graphics::PixelFormat getOverlayFormat() const;
+ void clearOverlay();
+ void grabOverlay(void *buf, int pitch);
+ void copyRectToOverlay(const void *buf, int pitch, int x, int y, int w,
+ int h);
+ virtual int16 getOverlayHeight();
+ virtual int16 getOverlayWidth();
+ virtual void displayMessageOnOSD(const char *msg);
+
+ bool showMouse(bool visible);
+ void warpMouse(int x, int y);
+ void setMouseCursor(const void *buf, uint w, uint h, int hotspotX,
+ int hotspotY, uint32 keycolor, bool dontScale = false,
+ const Graphics::PixelFormat *format = NULL);
+ void setCursorPalette(const byte *colors, uint start, uint num);
+
+ // Transform point from touchscreen coords into gamescreen coords
+ void transformPoint(touchPosition &point);
+
+ void setCursorDelta(float deltaX, float deltaY);
+
+ void updateFocus();
+ void updateConfig();
+ void updateSize();
+
+private:
+ void initGraphics();
+ void destroyGraphics();
+ void initAudio();
+ void destroyAudio();
+ void initEvents();
+ void destroyEvents();
+
+ void flushGameScreen();
+ void flushCursor();
+
+protected:
+ Audio::MixerImpl *_mixer;
+
+private:
+ u16 _gameWidth, _gameHeight;
+ u16 _gameTopX, _gameTopY;
+ u16 _gameBottomX, _gameBottomY;
+
+ // Audio
+ Thread audioThread;
+
+ // Graphics
+ Graphics::PixelFormat _pfGame;
+ Graphics::PixelFormat _pfGameTexture;
+ Graphics::PixelFormat _pfCursor;
+ byte _palette[3 * 256];
+ byte _cursorPalette[3 * 256];
+
+ Graphics::Surface _gameScreen;
+ Sprite _gameTopTexture;
+ Sprite _gameBottomTexture;
+ Sprite _overlay;
+
+ int _screenShakeOffset;
+ bool _overlayVisible;
+
+ DVLB_s *_dvlb;
+ shaderProgram_s _program;
+ int _projectionLocation;
+ int _modelviewLocation;
+ C3D_Mtx _projectionTop;
+ C3D_Mtx _projectionBottom;
+ C3D_RenderTarget* _renderTargetTop;
+ C3D_RenderTarget* _renderTargetBottom;
+
+ // Focus
+ Common::Rect _focusRect;
+ bool _focusDirty;
+ C3D_Mtx _focusMatrix;
+ int _focusPosX, _focusPosY;
+ int _focusTargetPosX, _focusTargetPosY;
+ float _focusStepPosX, _focusStepPosY;
+ float _focusScaleX, _focusScaleY;
+ float _focusTargetScaleX, _focusTargetScaleY;
+ float _focusStepScaleX, _focusStepScaleY;
+ uint32 _focusClearTime;
+
+ // Events
+ Thread _eventThread;
+ Thread _timerThread;
+ Common::Queue<Common::Event> _eventQueue;
+
+ // Cursor
+ Graphics::Surface _cursor;
+ Sprite _cursorTexture;
+ bool _cursorPaletteEnabled;
+ bool _cursorVisible;
+ bool _cursorScalable;
+ float _cursorX, _cursorY;
+ float _cursorDeltaX, _cursorDeltaY;
+ int _cursorHotspotX, _cursorHotspotY;
+ uint32 _cursorKeyColor;
+};
+
+} // namespace _3DS
+
+#endif
diff --git a/backends/platform/3ds/shader.v.pica b/backends/platform/3ds/shader.v.pica
new file mode 100644
index 0000000000..2d18985622
--- /dev/null
+++ b/backends/platform/3ds/shader.v.pica
@@ -0,0 +1,59 @@
+;* 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.
+;*
+
+; Uniforms
+.fvec projection[4], modelView[4]
+
+; Constants
+.constf myconst(0.0, 1.0, -1.0, 0.1)
+.alias zeros myconst.xxxx ; Vector full of zeros
+.alias ones myconst.yyyy ; Vector full of ones
+
+; Outputs
+.out outpos position
+.out outtex texcoord0
+
+; Inputs (defined as aliases for convenience)
+.alias inpos v0
+.alias intex v1
+
+.proc main
+ ; Force the w component of inpos to be 1.0
+ mov r0.xyz, inpos
+ mov r0.w, ones
+
+ ; r1 = modelView * inpos
+ dp4 r1.x, modelView[0], r0
+ dp4 r1.y, modelView[1], r0
+ dp4 r1.z, modelView[2], r0
+ dp4 r1.w, modelView[3], r0
+
+ ; outpos = projection * r1
+ dp4 outpos.x, projection[0], r1
+ dp4 outpos.y, projection[1], r1
+ dp4 outpos.z, projection[2], r1
+ dp4 outpos.w, projection[3], r1
+
+ mov outtex, intex
+
+ end
+.end
+
diff --git a/backends/platform/3ds/sprite.cpp b/backends/platform/3ds/sprite.cpp
new file mode 100644
index 0000000000..842729c051
--- /dev/null
+++ b/backends/platform/3ds/sprite.cpp
@@ -0,0 +1,144 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "backends/platform/3ds/sprite.h"
+#include "common/util.h"
+#include <3ds.h>
+
+static uint nextHigher2(uint v) {
+ if (v == 0)
+ return 1;
+ v--;
+ v |= v >> 1;
+ v |= v >> 2;
+ v |= v >> 4;
+ v |= v >> 8;
+ v |= v >> 16;
+ return ++v;
+}
+
+Sprite::Sprite()
+ : dirtyPixels(true)
+ , dirtyMatrix(true)
+ , actualWidth(0)
+ , actualHeight(0)
+ , posX(0)
+ , posY(0)
+ , scaleX(1.f)
+ , scaleY(1.f)
+{
+ Mtx_Identity(&modelview);
+
+ vertices = (vertex *)linearAlloc(sizeof(vertex) * 4);
+}
+
+Sprite::~Sprite() {
+ //
+}
+
+void Sprite::create(uint16 width, uint16 height, const Graphics::PixelFormat &f) {
+ free();
+
+ actualWidth = width;
+ actualHeight = height;
+ format = f;
+ w = MAX(nextHigher2(width), 64u);
+ h = MAX(nextHigher2(height), 64u);
+ pitch = w * format.bytesPerPixel;
+ dirtyPixels = true;
+
+ if (width && height) {
+ pixels = linearAlloc(h * pitch);
+ C3D_TexInit(&texture, w, h, GPU_RGBA8);
+ C3D_TexSetFilter(&texture, GPU_LINEAR, GPU_LINEAR);
+ assert(pixels && texture.data);
+ clear();
+ }
+
+ float x = 0.f, y = 0.f;
+ float u = (float)width/w;
+ float v = (float)height/h;
+ vertex tmp[4] = {
+ {{x, y, 0.5f}, {0, 0}},
+ {{x+width, y, 0.5f}, {u, 0}},
+ {{x, y+height, 0.5f}, {0, v}},
+ {{x+width, y+height, 0.5f}, {u, v}},
+ };
+ memcpy(vertices, tmp, sizeof(vertex) * 4);
+}
+
+
+void Sprite::free() {
+ linearFree(vertices);
+ linearFree(pixels);
+ C3D_TexDelete(&texture);
+ pixels = 0;
+ w = h = pitch = 0;
+ actualWidth = actualHeight = 0;
+ format = Graphics::PixelFormat();
+}
+
+void Sprite::convertToInPlace(const Graphics::PixelFormat &dstFormat, const byte *palette) {
+ //
+}
+
+void Sprite::render() {
+ if (dirtyPixels) {
+ dirtyPixels = false;
+ GSPGPU_FlushDataCache(pixels, w * h * format.bytesPerPixel);
+ C3D_SafeDisplayTransfer((u32*)pixels, GX_BUFFER_DIM(w, h), (u32*)texture.data, GX_BUFFER_DIM(w, h), TEXTURE_TRANSFER_FLAGS);
+ gspWaitForPPF();
+ }
+ C3D_TexBind(0, &texture);
+
+ C3D_BufInfo *bufInfo = C3D_GetBufInfo();
+ BufInfo_Init(bufInfo);
+ BufInfo_Add(bufInfo, vertices, sizeof(vertex), 2, 0x10);
+ C3D_DrawArrays(GPU_TRIANGLE_STRIP, 0, 4);
+}
+
+void Sprite::clear(uint32 color) {
+ dirtyPixels = true;
+ memset(pixels, color, w * h * format.bytesPerPixel);
+}
+
+void Sprite::setScale (float x, float y) {
+ scaleX = x;
+ scaleY = y;
+ dirtyMatrix = true;
+}
+
+void Sprite::setPosition(int x, int y) {
+ posX = x;
+ posY = y;
+ dirtyMatrix = true;
+}
+
+C3D_Mtx* Sprite::getMatrix() {
+ if (dirtyMatrix) {
+ dirtyMatrix = false;
+ Mtx_Identity(&modelview);
+ Mtx_Scale(&modelview, scaleX, scaleY, 1.f);
+ Mtx_Translate(&modelview, posX, posY, 0);
+ }
+ return &modelview;
+}
diff --git a/backends/platform/3ds/sprite.h b/backends/platform/3ds/sprite.h
new file mode 100644
index 0000000000..129c2689e7
--- /dev/null
+++ b/backends/platform/3ds/sprite.h
@@ -0,0 +1,71 @@
+/* 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.
+ *
+ */
+
+#ifndef GRAPHICS_SPRITE_3DS_H
+#define GRAPHICS_SPRITE_3DS_H
+
+#include <citro3d.h>
+#include "graphics/surface.h"
+
+#define TEXTURE_TRANSFER_FLAGS \
+ (GX_TRANSFER_FLIP_VERT(1) | GX_TRANSFER_OUT_TILED(1) | GX_TRANSFER_RAW_COPY(0) | \
+ GX_TRANSFER_IN_FORMAT(GX_TRANSFER_FMT_RGBA8) | GX_TRANSFER_OUT_FORMAT(GX_TRANSFER_FMT_RGBA8) | \
+ GX_TRANSFER_SCALING(GX_TRANSFER_SCALE_NO))
+
+typedef struct {
+ float position[3];
+ float texcoord[2];
+} vertex;
+
+class Sprite : public Graphics::Surface {
+public:
+ Sprite();
+ ~Sprite();
+ void create(uint16 width, uint16 height, const Graphics::PixelFormat &format);
+ void free();
+ void convertToInPlace(const Graphics::PixelFormat &dstFormat, const byte *palette = 0);
+ void render();
+ void clear(uint32 color = 0);
+ void markDirty(){ dirtyPixels = true; }
+
+ void setPosition(int x, int y);
+ void setScale(float x, float y);
+ float getScaleX(){ return scaleX; }
+ float getScaleY(){ return scaleY; }
+ C3D_Mtx* getMatrix();
+
+ uint16 actualWidth;
+ uint16 actualHeight;
+
+private:
+ bool dirtyPixels;
+ bool dirtyMatrix;
+ C3D_Mtx modelview;
+ C3D_Tex texture;
+ vertex* vertices;
+ int posX;
+ int posY;
+ float scaleX;
+ float scaleY;
+};
+
+#endif
diff --git a/backends/platform/android/android.cpp b/backends/platform/android/android.cpp
index 798772cc24..4e4417400c 100644
--- a/backends/platform/android/android.cpp
+++ b/backends/platform/android/android.cpp
@@ -401,7 +401,8 @@ bool OSystem_Android::hasFeature(Feature f) {
f == kFeatureAspectRatioCorrection ||
f == kFeatureCursorPalette ||
f == kFeatureVirtualKeyboard ||
- f == kFeatureOverlaySupportsAlpha);
+ f == kFeatureOverlaySupportsAlpha ||
+ f == kFeatureOpenUrl);
}
void OSystem_Android::setFeatureState(Feature f, bool enable) {
@@ -586,6 +587,10 @@ Common::String OSystem_Android::getSystemLanguage() const {
getSystemProperty("persist.sys.country").c_str());
}
+bool OSystem_Android::openUrl(const Common::String &url) {
+ return JNI::openUrl(url.c_str());
+}
+
Common::String OSystem_Android::getSystemProperty(const char *name) const {
char value[PROP_VALUE_MAX];
diff --git a/backends/platform/android/android.h b/backends/platform/android/android.h
index ade84dd42d..2935d96381 100644
--- a/backends/platform/android/android.h
+++ b/backends/platform/android/android.h
@@ -286,6 +286,7 @@ public:
virtual void logMessage(LogMessageType::Type type, const char *message);
virtual void addSysArchivesToSearchSet(Common::SearchSet &s,
int priority = 0);
+ virtual bool openUrl(const Common::String &url);
virtual Common::String getSystemLanguage() const;
};
diff --git a/backends/platform/android/android.mk b/backends/platform/android/android.mk
index e11ad0724e..4a29526941 100644
--- a/backends/platform/android/android.mk
+++ b/backends/platform/android/android.mk
@@ -1,9 +1,9 @@
# Android specific build targets
# These must be incremented for each market upload
-ANDROID_VERSIONCODE = 6
+ANDROID_VERSIONCODE = 16
-ANDROID_TARGET_VERSION = 14
+ANDROID_TARGET_VERSION = 23
NDK_BUILD = $(ANDROID_NDK)/ndk-build APP_ABI=$(ABI)
SDK_ANDROID = $(ANDROID_SDK)/tools/android
@@ -20,6 +20,7 @@ RESOURCES = \
$(PATH_BUILD_RES)/layout/main.xml \
$(PATH_BUILD_RES)/drawable/scummvm.png \
$(PATH_BUILD_RES)/drawable/scummvm_big.png \
+ $(PATH_BUILD_RES)/drawable-xhdpi/leanback_icon.png \
$(PATH_BUILD_RES)/drawable-xhdpi/ouya_icon.png
DIST_ANDROID_MK = $(PATH_DIST)/jni/Android.mk
diff --git a/backends/platform/android/asset-archive.cpp b/backends/platform/android/asset-archive.cpp
index 6680081c16..0ee6efc111 100644
--- a/backends/platform/android/asset-archive.cpp
+++ b/backends/platform/android/asset-archive.cpp
@@ -22,8 +22,6 @@
#if defined(__ANDROID__)
-#include <jni.h>
-
#include <sys/types.h>
#include <unistd.h>
@@ -37,443 +35,112 @@
#include "backends/platform/android/jni.h"
#include "backends/platform/android/asset-archive.h"
-// Must match android.content.res.AssetManager.ACCESS_*
-const jint ACCESS_UNKNOWN = 0;
-const jint ACCESS_RANDOM = 1;
+#include <android/asset_manager.h>
+#include <android/asset_manager_jni.h>
-// This might be useful to someone else. Assumes markSupported() == true.
-class JavaInputStream : public Common::SeekableReadStream {
+class AssetInputStream : public Common::SeekableReadStream {
public:
- JavaInputStream(JNIEnv *env, jobject is);
- virtual ~JavaInputStream();
-
- virtual bool eos() const {
- return _eos;
- }
+ AssetInputStream(AAssetManager *as, const Common::String &path);
+ virtual ~AssetInputStream();
- virtual bool err() const {
- return _err;
- }
+ virtual bool eos() const { return _eos; }
- virtual void clearErr() {
- _eos = _err = false;
- }
+ virtual void clearErr() {_eos = false; }
virtual uint32 read(void *dataPtr, uint32 dataSize);
- virtual int32 pos() const {
- return _pos;
- }
+ virtual int32 pos() const { return _pos; }
- virtual int32 size() const {
- return _len;
- }
+ virtual int32 size() const { return _len; }
virtual bool seek(int32 offset, int whence = SEEK_SET);
private:
- void close(JNIEnv *env);
-
- jmethodID MID_mark;
- jmethodID MID_available;
- jmethodID MID_close;
- jmethodID MID_read;
- jmethodID MID_reset;
- jmethodID MID_skip;
+ void close();
+ AAsset *_asset;
- jobject _input_stream;
- jsize _buflen;
- jbyteArray _buf;
uint32 _pos;
- jint _len;
+ uint32 _len;
bool _eos;
- bool _err;
};
-JavaInputStream::JavaInputStream(JNIEnv *env, jobject is) :
- _eos(false),
- _err(false),
- _pos(0)
-{
- _input_stream = env->NewGlobalRef(is);
- _buflen = 8192;
- jobject buf = env->NewByteArray(_buflen);
- _buf = (jbyteArray)env->NewGlobalRef(buf);
- env->DeleteLocalRef(buf);
-
- jclass cls = env->GetObjectClass(_input_stream);
- MID_mark = env->GetMethodID(cls, "mark", "(I)V");
- assert(MID_mark);
- MID_available = env->GetMethodID(cls, "available", "()I");
- assert(MID_available);
- MID_close = env->GetMethodID(cls, "close", "()V");
- assert(MID_close);
- MID_read = env->GetMethodID(cls, "read", "([BII)I");
- assert(MID_read);
- MID_reset = env->GetMethodID(cls, "reset", "()V");
- assert(MID_reset);
- MID_skip = env->GetMethodID(cls, "skip", "(J)J");
- assert(MID_skip);
- env->DeleteLocalRef(cls);
-
- // Mark start of stream, so we can reset back to it.
- // readlimit is set to something bigger than anything we might
- // want to seek within.
- env->CallVoidMethod(_input_stream, MID_mark, 10 * 1024 * 1024);
- _len = env->CallIntMethod(_input_stream, MID_available);
+AssetInputStream::AssetInputStream(AAssetManager *as, const Common::String &path) :
+ _eos(false), _pos(0) {
+ _asset = AAssetManager_open(as, path.c_str(), AASSET_MODE_RANDOM);
+ _len = AAsset_getLength(_asset);
}
-JavaInputStream::~JavaInputStream() {
- JNIEnv *env = JNI::getEnv();
- close(env);
-
- env->DeleteGlobalRef(_buf);
- env->DeleteGlobalRef(_input_stream);
+AssetInputStream::~AssetInputStream() {
}
-void JavaInputStream::close(JNIEnv *env) {
- env->CallVoidMethod(_input_stream, MID_close);
-
- if (env->ExceptionCheck())
- env->ExceptionClear();
+void AssetInputStream::close() {
+ AAsset_close(_asset);
}
-uint32 JavaInputStream::read(void *dataPtr, uint32 dataSize) {
- JNIEnv *env = JNI::getEnv();
-
- if (_buflen < jint(dataSize)) {
- _buflen = dataSize;
-
- env->DeleteGlobalRef(_buf);
- jobject buf = env->NewByteArray(_buflen);
- _buf = static_cast<jbyteArray>(env->NewGlobalRef(buf));
- env->DeleteLocalRef(buf);
- }
-
- jint ret = env->CallIntMethod(_input_stream, MID_read, _buf, 0, dataSize);
-
- if (env->ExceptionCheck()) {
- warning("Exception during JavaInputStream::read(%p, %d)",
- dataPtr, dataSize);
-
- env->ExceptionDescribe();
- env->ExceptionClear();
-
- _err = true;
- ret = -1;
- } else if (ret == -1) {
+uint32 AssetInputStream::read(void *dataPtr, uint32 dataSize) {
+ uint32 readlen = AAsset_read(_asset, dataPtr, dataSize);
+ _pos += readlen;
+ if (readlen != dataSize) {
_eos = true;
- ret = 0;
- } else {
- env->GetByteArrayRegion(_buf, 0, ret, static_cast<jbyte *>(dataPtr));
- _pos += ret;
}
-
- return ret;
+ return readlen;
}
-bool JavaInputStream::seek(int32 offset, int whence) {
- JNIEnv *env = JNI::getEnv();
- uint32 newpos;
-
- switch (whence) {
- case SEEK_SET:
- newpos = offset;
- break;
- case SEEK_CUR:
- newpos = _pos + offset;
- break;
- case SEEK_END:
- newpos = _len + offset;
- break;
- default:
- debug("Unknown 'whence' arg %d", whence);
+bool AssetInputStream::seek(int32 offset, int whence) {
+ int res = AAsset_seek(_asset, offset, whence);
+ if (res == -1) {
return false;
}
-
- jlong skip_bytes;
- if (newpos > _pos) {
- skip_bytes = newpos - _pos;
- } else {
- // Can't skip backwards, so jump back to start and skip from there.
- env->CallVoidMethod(_input_stream, MID_reset);
-
- if (env->ExceptionCheck()) {
- warning("Failed to rewind to start of asset stream");
-
- env->ExceptionDescribe();
- env->ExceptionClear();
-
- return false;
- }
-
- _pos = 0;
- skip_bytes = newpos;
- }
-
- while (skip_bytes > 0) {
- jlong ret = env->CallLongMethod(_input_stream, MID_skip, skip_bytes);
-
- if (env->ExceptionCheck()) {
- warning("Failed to skip %ld bytes into asset stream",
- static_cast<long>(skip_bytes));
-
- env->ExceptionDescribe();
- env->ExceptionClear();
-
- return false;
- } else if (ret == 0) {
- warning("InputStream->skip(%ld) didn't skip any bytes. Aborting seek.",
- static_cast<long>(skip_bytes));
-
- // No point looping forever...
- return false;
- }
-
- _pos += ret;
- skip_bytes -= ret;
- }
-
- _eos = false;
- return true;
-}
-
-// Must match android.content.res.AssetFileDescriptor.UNKNOWN_LENGTH
-const jlong UNKNOWN_LENGTH = -1;
-
-// Reading directly from a fd is so much more efficient, that it is
-// worth optimising for.
-class AssetFdReadStream : public Common::SeekableReadStream {
-public:
- AssetFdReadStream(JNIEnv *env, jobject assetfd);
- virtual ~AssetFdReadStream();
-
- virtual bool eos() const {
- return _eos;
- }
-
- virtual bool err() const {
- return _err;
- }
-
- virtual void clearErr() {
- _eos = _err = false;
- }
-
- virtual uint32 read(void *dataPtr, uint32 dataSize);
-
- virtual int32 pos() const {
- return _pos;
- }
-
- virtual int32 size() const {
- return _declared_len;
- }
-
- virtual bool seek(int32 offset, int whence = SEEK_SET);
-
-private:
- void close(JNIEnv *env);
-
- int _fd;
- jmethodID MID_close;
- jobject _assetfd;
- jlong _start_off;
- jlong _declared_len;
- uint32 _pos;
- bool _eos;
- bool _err;
-};
-
-AssetFdReadStream::AssetFdReadStream(JNIEnv *env, jobject assetfd) :
- _eos(false),
- _err(false),
- _pos(0)
-{
- _assetfd = env->NewGlobalRef(assetfd);
-
- jclass cls = env->GetObjectClass(_assetfd);
- MID_close = env->GetMethodID(cls, "close", "()V");
- assert(MID_close);
-
- jmethodID MID_getStartOffset =
- env->GetMethodID(cls, "getStartOffset", "()J");
- assert(MID_getStartOffset);
- _start_off = env->CallLongMethod(_assetfd, MID_getStartOffset);
-
- jmethodID MID_getDeclaredLength =
- env->GetMethodID(cls, "getDeclaredLength", "()J");
- assert(MID_getDeclaredLength);
- _declared_len = env->CallLongMethod(_assetfd, MID_getDeclaredLength);
-
- jmethodID MID_getFileDescriptor =
- env->GetMethodID(cls, "getFileDescriptor",
- "()Ljava/io/FileDescriptor;");
- assert(MID_getFileDescriptor);
- jobject javafd = env->CallObjectMethod(_assetfd, MID_getFileDescriptor);
- assert(javafd);
-
- jclass fd_cls = env->GetObjectClass(javafd);
- jfieldID FID_descriptor = env->GetFieldID(fd_cls, "descriptor", "I");
- assert(FID_descriptor);
- env->DeleteLocalRef(fd_cls);
-
- _fd = env->GetIntField(javafd, FID_descriptor);
- env->DeleteLocalRef(javafd);
-
- env->DeleteLocalRef(cls);
-}
-
-AssetFdReadStream::~AssetFdReadStream() {
- JNIEnv *env = JNI::getEnv();
- env->CallVoidMethod(_assetfd, MID_close);
-
- if (env->ExceptionCheck())
- env->ExceptionClear();
-
- env->DeleteGlobalRef(_assetfd);
-}
-
-uint32 AssetFdReadStream::read(void *dataPtr, uint32 dataSize) {
- if (_declared_len != UNKNOWN_LENGTH) {
- jlong cap = _declared_len - _pos;
- if (dataSize > cap)
- dataSize = cap;
- }
-
- int ret = ::read(_fd, dataPtr, dataSize);
-
- if (ret == 0)
- _eos = true;
- else if (ret == -1)
- _err = true;
- else
- _pos += ret;
-
- return ret;
-}
-
-bool AssetFdReadStream::seek(int32 offset, int whence) {
- if (whence == SEEK_SET) {
- if (_declared_len != UNKNOWN_LENGTH && offset > _declared_len)
- offset = _declared_len;
-
- offset += _start_off;
- } else if (whence == SEEK_END && _declared_len != UNKNOWN_LENGTH) {
- whence = SEEK_SET;
- offset = _start_off + _declared_len + offset;
+ if (whence == SEEK_CUR) {
+ _pos += offset;
+ } else if (whence == SEEK_SET) {
+ _pos = offset;
+ } else if (whence == SEEK_END) {
+ _pos = _len + offset;
}
-
- int ret = lseek(_fd, offset, whence);
-
- if (ret == -1)
- return false;
-
- _pos = ret - _start_off;
+ assert(_pos <= _len);
_eos = false;
-
return true;
}
-AndroidAssetArchive::AndroidAssetArchive(jobject am) {
+AndroidAssetArchive::AndroidAssetArchive(jobject am) : _hasCached(false) {
JNIEnv *env = JNI::getEnv();
- _am = env->NewGlobalRef(am);
- jclass cls = env->GetObjectClass(_am);
- MID_open = env->GetMethodID(cls, "open",
- "(Ljava/lang/String;I)Ljava/io/InputStream;");
- assert(MID_open);
-
- MID_openFd = env->GetMethodID(cls, "openFd", "(Ljava/lang/String;)"
- "Landroid/content/res/AssetFileDescriptor;");
- assert(MID_openFd);
-
- MID_list = env->GetMethodID(cls, "list",
- "(Ljava/lang/String;)[Ljava/lang/String;");
- assert(MID_list);
- env->DeleteLocalRef(cls);
+ _am = AAssetManager_fromJava(env, am);
}
AndroidAssetArchive::~AndroidAssetArchive() {
- JNIEnv *env = JNI::getEnv();
- env->DeleteGlobalRef(_am);
}
bool AndroidAssetArchive::hasFile(const Common::String &name) const {
- JNIEnv *env = JNI::getEnv();
- jstring path = env->NewStringUTF(name.c_str());
- jobject result = env->CallObjectMethod(_am, MID_open, path, ACCESS_UNKNOWN);
- if (env->ExceptionCheck()) {
- // Assume FileNotFoundException
- //warning("Error while calling AssetManager->open(%s)", name.c_str());
- //env->ExceptionDescribe();
- env->ExceptionClear();
- env->DeleteLocalRef(path);
-
- return false;
+ AAsset *asset = AAssetManager_open(_am, name.c_str(), AASSET_MODE_RANDOM);
+ bool exists = false;
+ if (asset != NULL) {
+ exists = true;
+ AAsset_close(asset);
}
-
- env->DeleteLocalRef(result);
- env->DeleteLocalRef(path);
-
- return true;
+ return exists;
}
int AndroidAssetArchive::listMembers(Common::ArchiveMemberList &member_list) const {
- JNIEnv *env = JNI::getEnv();
- Common::List<Common::String> dirlist;
- dirlist.push_back("");
+ if (_hasCached) {
+ member_list.insert(member_list.end(), _cachedMembers.begin(), _cachedMembers.end());
+ return _cachedMembers.size();
+ }
int count = 0;
- while (!dirlist.empty()) {
- const Common::String dir = dirlist.back();
- dirlist.pop_back();
-
- jstring jpath = env->NewStringUTF(dir.c_str());
- jobjectArray jpathlist =
- (jobjectArray)env->CallObjectMethod(_am, MID_list, jpath);
-
- if (env->ExceptionCheck()) {
- warning("Error while calling AssetManager->list(%s). Ignoring.",
- dir.c_str());
- env->ExceptionDescribe();
- env->ExceptionClear();
-
- // May as well keep going ...
- continue;
- }
-
- env->DeleteLocalRef(jpath);
+ AAssetDir *dir = AAssetManager_openDir(_am, "");
+ const char *file = AAssetDir_getNextFileName(dir);
- for (jsize i = 0; i < env->GetArrayLength(jpathlist); ++i) {
- jstring elem = (jstring)env->GetObjectArrayElement(jpathlist, i);
- const char *p = env->GetStringUTFChars(elem, 0);
-
- if (strlen(p)) {
- Common::String thispath = dir;
-
- if (!thispath.empty())
- thispath += "/";
-
- thispath += p;
-
- // Assume files have a . in them, and directories don't
- if (strchr(p, '.')) {
- member_list.push_back(getMember(thispath));
- ++count;
- } else {
- // AssetManager is ridiculously slow and we don't care
- // about subdirectories at the moment, so ignore them.
- // dirlist.push_back(thispath);
- }
- }
-
- env->ReleaseStringUTFChars(elem, p);
- env->DeleteLocalRef(elem);
- }
-
- env->DeleteLocalRef(jpathlist);
+ while (file) {
+ member_list.push_back(getMember(file));
+ ++count;
+ file = AAssetDir_getNextFileName(dir);
}
+ AAssetDir_close(dir);
+
+ _cachedMembers = Common::ArchiveMemberList(member_list);
+ _hasCached = true;
return count;
}
@@ -483,39 +150,10 @@ const Common::ArchiveMemberPtr AndroidAssetArchive::getMember(const Common::Stri
}
Common::SeekableReadStream *AndroidAssetArchive::createReadStreamForMember(const Common::String &path) const {
- JNIEnv *env = JNI::getEnv();
- jstring jpath = env->NewStringUTF(path.c_str());
-
- // Try openFd() first ...
- jobject afd = env->CallObjectMethod(_am, MID_openFd, jpath);
-
- if (env->ExceptionCheck())
- env->ExceptionClear();
- else if (afd != 0) {
- // success :)
- Common::SeekableReadStream *stream = new AssetFdReadStream(env, afd);
- env->DeleteLocalRef(jpath);
- env->DeleteLocalRef(afd);
- return stream;
+ if (!hasFile(path)) {
+ return nullptr;
}
-
- // ... and fallback to normal open() if that doesn't work
- jobject is = env->CallObjectMethod(_am, MID_open, jpath, ACCESS_RANDOM);
-
- if (env->ExceptionCheck()) {
- // Assume FileNotFoundException
- //warning("Error opening %s", path.c_str());
- //env->ExceptionDescribe();
- env->ExceptionClear();
- env->DeleteLocalRef(jpath);
-
- return 0;
- }
-
- Common::SeekableReadStream *stream = new JavaInputStream(env, is);
- env->DeleteLocalRef(jpath);
- env->DeleteLocalRef(is);
- return stream;
+ return new AssetInputStream(_am, path);
}
#endif
diff --git a/backends/platform/android/asset-archive.h b/backends/platform/android/asset-archive.h
index 6a0033d24e..8ae55b22c9 100644
--- a/backends/platform/android/asset-archive.h
+++ b/backends/platform/android/asset-archive.h
@@ -32,6 +32,8 @@
#include "common/util.h"
#include "common/archive.h"
+#include <android/asset_manager.h>
+
class AndroidAssetArchive : public Common::Archive {
public:
AndroidAssetArchive(jobject am);
@@ -43,11 +45,9 @@ public:
virtual Common::SeekableReadStream *createReadStreamForMember(const Common::String &name) const;
private:
- jmethodID MID_open;
- jmethodID MID_openFd;
- jmethodID MID_list;
-
- jobject _am;
+ AAssetManager *_am;
+ mutable Common::ArchiveMemberList _cachedMembers;
+ mutable bool _hasCached;
};
#endif
diff --git a/backends/platform/android/events.cpp b/backends/platform/android/events.cpp
index 8039981a92..b146945a01 100644
--- a/backends/platform/android/events.cpp
+++ b/backends/platform/android/events.cpp
@@ -101,7 +101,9 @@ enum {
JKEYCODE_MEDIA_NEXT = 87,
JKEYCODE_MEDIA_PREVIOUS = 88,
JKEYCODE_MEDIA_REWIND = 89,
- JKEYCODE_MEDIA_FAST_FORWARD = 90
+ JKEYCODE_MEDIA_FAST_FORWARD = 90,
+ JKEYCODE_MEDIA_PLAY = 126,
+ JKEYCODE_MEDIA_PAUSE = 127
};
// five-way navigation control
@@ -380,6 +382,19 @@ void OSystem_Android::pushEvent(int type, int arg1, int arg2, int arg3,
return;
+ case JKEYCODE_MEDIA_PAUSE:
+ case JKEYCODE_MEDIA_PLAY:
+ case JKEYCODE_MEDIA_PLAY_PAUSE:
+ if (arg1 == JACTION_DOWN) {
+ e.type = Common::EVENT_MAINMENU;
+
+ lockMutex(_event_queue_lock);
+ _event_queue.push(e);
+ unlockMutex(_event_queue_lock);
+ }
+
+ return;
+
case JKEYCODE_CAMERA:
case JKEYCODE_SEARCH:
if (arg1 == JACTION_DOWN)
@@ -888,6 +903,10 @@ void OSystem_Android::pushEvent(int type, int arg1, int arg2, int arg3,
e.kbd.ascii = Common::ASCII_ESCAPE;
break;
+ case JKEYCODE_BUTTON_Y:
+ e.type = Common::EVENT_MAINMENU;
+ break;
+
default:
LOGW("unmapped gamepad key: %d", arg2);
return;
diff --git a/backends/platform/android/jni.cpp b/backends/platform/android/jni.cpp
index 22e6a749c2..256ae09ef8 100644
--- a/backends/platform/android/jni.cpp
+++ b/backends/platform/android/jni.cpp
@@ -76,6 +76,8 @@ bool JNI::_ready_for_events = 0;
jmethodID JNI::_MID_getDPI = 0;
jmethodID JNI::_MID_displayMessageOnOSD = 0;
+jmethodID JNI::_MID_openUrl = 0;
+jmethodID JNI::_MID_isConnectionLimited = 0;
jmethodID JNI::_MID_setWindowCaption = 0;
jmethodID JNI::_MID_showVirtualKeyboard = 0;
jmethodID JNI::_MID_getSysArchives = 0;
@@ -232,6 +234,41 @@ void JNI::displayMessageOnOSD(const char *msg) {
env->DeleteLocalRef(java_msg);
}
+bool JNI::openUrl(const char *url) {
+ bool success = true;
+ JNIEnv *env = JNI::getEnv();
+ jstring javaUrl = env->NewStringUTF(url);
+
+ env->CallVoidMethod(_jobj, _MID_openUrl, javaUrl);
+
+ if (env->ExceptionCheck()) {
+ LOGE("Failed to open URL");
+
+ env->ExceptionDescribe();
+ env->ExceptionClear();
+ success = false;
+ }
+
+ env->DeleteLocalRef(javaUrl);
+ return success;
+}
+
+bool JNI::isConnectionLimited() {
+ bool limited = false;
+ JNIEnv *env = JNI::getEnv();
+ limited = env->CallBooleanMethod(_jobj, _MID_isConnectionLimited);
+
+ if (env->ExceptionCheck()) {
+ LOGE("Failed to check whether connection's limited");
+
+ env->ExceptionDescribe();
+ env->ExceptionClear();
+ limited = true;
+ }
+
+ return limited;
+}
+
void JNI::setWindowCaption(const char *caption) {
JNIEnv *env = JNI::getEnv();
jstring java_caption = env->NewStringUTF(caption);
@@ -411,6 +448,8 @@ void JNI::create(JNIEnv *env, jobject self, jobject asset_manager,
FIND_METHOD(, setWindowCaption, "(Ljava/lang/String;)V");
FIND_METHOD(, getDPI, "([F)V");
FIND_METHOD(, displayMessageOnOSD, "(Ljava/lang/String;)V");
+ FIND_METHOD(, openUrl, "(Ljava/lang/String;)V");
+ FIND_METHOD(, isConnectionLimited, "()Z");
FIND_METHOD(, showVirtualKeyboard, "(Z)V");
FIND_METHOD(, getSysArchives, "()[Ljava/lang/String;");
FIND_METHOD(, initSurface, "()Ljavax/microedition/khronos/egl/EGLSurface;");
diff --git a/backends/platform/android/jni.h b/backends/platform/android/jni.h
index 70feaaf72a..0798db448a 100644
--- a/backends/platform/android/jni.h
+++ b/backends/platform/android/jni.h
@@ -58,6 +58,8 @@ public:
static void setWindowCaption(const char *caption);
static void getDPI(float *values);
static void displayMessageOnOSD(const char *msg);
+ static bool openUrl(const char *url);
+ static bool isConnectionLimited();
static void showVirtualKeyboard(bool enable);
static void addSysArchivesToSearchSet(Common::SearchSet &s, int priority);
@@ -89,6 +91,8 @@ private:
static jmethodID _MID_getDPI;
static jmethodID _MID_displayMessageOnOSD;
+ static jmethodID _MID_openUrl;
+ static jmethodID _MID_isConnectionLimited;
static jmethodID _MID_setWindowCaption;
static jmethodID _MID_showVirtualKeyboard;
static jmethodID _MID_getSysArchives;
diff --git a/backends/platform/android/org/scummvm/scummvm/ScummVM.java b/backends/platform/android/org/scummvm/scummvm/ScummVM.java
index 3b370a583d..47dcb32b22 100644
--- a/backends/platform/android/org/scummvm/scummvm/ScummVM.java
+++ b/backends/platform/android/org/scummvm/scummvm/ScummVM.java
@@ -53,6 +53,8 @@ public abstract class ScummVM implements SurfaceHolder.Callback, Runnable {
// Callbacks from C++ peer instance
abstract protected void getDPI(float[] values);
abstract protected void displayMessageOnOSD(String msg);
+ abstract protected void openUrl(String url);
+ abstract protected boolean isConnectionLimited();
abstract protected void setWindowCaption(String caption);
abstract protected void showVirtualKeyboard(boolean enable);
abstract protected String[] getSysArchives();
diff --git a/backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java b/backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java
index 5b2dcae175..225496ca0d 100644
--- a/backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java
+++ b/backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java
@@ -2,9 +2,13 @@ package org.scummvm.scummvm;
import android.app.Activity;
import android.app.AlertDialog;
+import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.media.AudioManager;
+import android.net.Uri;
+import android.net.wifi.WifiManager;
+import android.net.wifi.WifiInfo;
import android.os.Build;
import android.os.Bundle;
import android.os.Environment;
@@ -75,6 +79,21 @@ public class ScummVMActivity extends Activity {
}
@Override
+ protected void openUrl(String url) {
+ startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
+ }
+
+ @Override
+ protected boolean isConnectionLimited() {
+ WifiManager wifiMgr = (WifiManager)getSystemService(Context.WIFI_SERVICE);
+ if (wifiMgr != null && wifiMgr.isWifiEnabled()) {
+ WifiInfo wifiInfo = wifiMgr.getConnectionInfo();
+ return (wifiInfo == null || wifiInfo.getNetworkId() == -1); //WiFi is on, but it's not connected to any network
+ }
+ return true;
+ }
+
+ @Override
protected void setWindowCaption(final String caption) {
runOnUiThread(new Runnable() {
public void run() {
diff --git a/backends/platform/android/org/scummvm/scummvm/ScummVMEvents.java b/backends/platform/android/org/scummvm/scummvm/ScummVMEvents.java
index 32c65d3395..e81000d8b1 100644
--- a/backends/platform/android/org/scummvm/scummvm/ScummVMEvents.java
+++ b/backends/platform/android/org/scummvm/scummvm/ScummVMEvents.java
@@ -119,6 +119,8 @@ public class ScummVMEvents implements
case KeyEvent.KEYCODE_MENU:
case KeyEvent.KEYCODE_CAMERA:
case KeyEvent.KEYCODE_SEARCH:
+ case KeyEvent.KEYCODE_MEDIA_PLAY:
+ case KeyEvent.KEYCODE_MEDIA_PAUSE:
break;
default:
diff --git a/backends/platform/androidsdl/androidsdl-main.cpp b/backends/platform/androidsdl/androidsdl-main.cpp
new file mode 100644
index 0000000000..364d686c1b
--- /dev/null
+++ b/backends/platform/androidsdl/androidsdl-main.cpp
@@ -0,0 +1,47 @@
+/* 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.
+ *
+ */
+
+#define FORBIDDEN_SYMBOL_EXCEPTION_system
+
+#include "backends/platform/androidsdl/androidsdl-sdl.h"
+#include "base/main.h"
+
+int main(int argc, char *argv[]) {
+
+ // Copy over config file from previous version of ScummVM if applicable
+ system("ls $DATADIR/.config/scummvm/scummvm.ini || (mkdir -p $DATADIR/.config/scummvm && cp $APPDIR/scummvmrc $DATADIR/.config/scummvm/scummvm.ini )");
+
+ // Create our OSystem instance
+ g_system = new OSystem_ANDROIDSDL();
+ assert(g_system);
+
+ // Pre initialize the backend
+ ((OSystem_POSIX *)g_system)->init();
+
+ // Invoke the actual ScummVM main entry point:
+ int res = scummvm_main(argc, argv);
+
+ // Free OSystem
+ delete (OSystem_ANDROIDSDL *)g_system;
+
+ return res;
+}
diff --git a/backends/platform/androidsdl/androidsdl-sdl.cpp b/backends/platform/androidsdl/androidsdl-sdl.cpp
new file mode 100644
index 0000000000..d04512475a
--- /dev/null
+++ b/backends/platform/androidsdl/androidsdl-sdl.cpp
@@ -0,0 +1,48 @@
+/* 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.
+ *
+ */
+
+#define FORBIDDEN_SYMBOL_EXCEPTION_getenv(a)
+
+#include "common/config-manager.h"
+
+#include "backends/platform/androidsdl/androidsdl-sdl.h"
+#include "backends/events/androidsdl/androidsdl-events.h"
+#include "backends/graphics/androidsdl/androidsdl-graphics.h"
+
+void OSystem_ANDROIDSDL::initBackend() {
+ // Create the backend custom managers
+
+ if (_eventSource == 0)
+ _eventSource = new AndroidSdlEventSource();
+
+ if (_graphicsManager == 0)
+ _graphicsManager = new AndroidSdlGraphicsManager(_eventSource, _window);
+
+ if (!ConfMan.hasKey("browser_lastpath"))
+ ConfMan.set("browser_lastpath", getenv("SDCARD"));
+
+ if (!ConfMan.hasKey("gfx_mode"))
+ ConfMan.set("gfx_mode", "2x");
+
+ // Call parent implementation of this method
+ OSystem_POSIX::initBackend();
+}
diff --git a/backends/platform/androidsdl/androidsdl-sdl.h b/backends/platform/androidsdl/androidsdl-sdl.h
new file mode 100644
index 0000000000..6ebe5022eb
--- /dev/null
+++ b/backends/platform/androidsdl/androidsdl-sdl.h
@@ -0,0 +1,38 @@
+/* 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.
+ *
+ */
+
+#ifndef PLATFORM_SDL_ANDROIDSDL_H
+#define PLATFORM_SDL_ANDROIDSDL_H
+
+#include "backends/platform/sdl/posix/posix.h"
+
+class OSystem_ANDROIDSDL : public OSystem_POSIX {
+public:
+ virtual void initBackend();
+
+#ifdef ENABLE_KEYMAPPER
+ // FIXME: This just calls parent methods, is it needed?
+ virtual Common::HardwareInputSet *getHardwareInputSet();
+#endif
+};
+
+#endif
diff --git a/backends/platform/androidsdl/androidsdl.mk b/backends/platform/androidsdl/androidsdl.mk
new file mode 100644
index 0000000000..1defb81b97
--- /dev/null
+++ b/backends/platform/androidsdl/androidsdl.mk
@@ -0,0 +1,11 @@
+# Special target to create an AndroidSDL snapshot
+androidsdl:
+ $(MKDIR) release
+ $(INSTALL) -c -m 644 $(DIST_FILES_THEMES) $(DIST_FILES_ENGINEDATA) release
+ $(INSTALL) -c -m 644 $(DIST_FILES_DOCS) release
+ $(CP) $(srcdir)/backends/vkeybd/packs/vkeybd_default.zip release
+ zip -j scummvm190-git-appdata.zip release/*
+ split -d -b 1000000 scummvm190-git-appdata.zip scummvm190-git-appdata.zip0
+ $(RM) -r scummvm190-git-appdata.zip
+
+.PHONY: androidsdl
diff --git a/backends/platform/androidsdl/module.mk b/backends/platform/androidsdl/module.mk
new file mode 100644
index 0000000000..df927163b8
--- /dev/null
+++ b/backends/platform/androidsdl/module.mk
@@ -0,0 +1,13 @@
+MODULE := backends/platform/androidsdl
+
+MODULE_OBJS := \
+ androidsdl-main.o \
+ androidsdl-sdl.o
+
+# We don't use rules.mk but rather manually update OBJS and MODULE_DIRS.
+MODULE_OBJS := $(addprefix $(MODULE)/, $(MODULE_OBJS))
+OBJS := $(MODULE_OBJS) $(OBJS)
+MODULE_DIRS += $(sort $(dir $(MODULE_OBJS)))
+
+# Hack to ensure the SDL backend is built so we can use OSystem_SDL.
+-include $(srcdir)/backends/platform/sdl/module.mk
diff --git a/backends/platform/dc/README b/backends/platform/dc/README
index e26df500e8..3524f57bac 100644
--- a/backends/platform/dc/README
+++ b/backends/platform/dc/README
@@ -4,13 +4,13 @@ Compiling ScummVM for SEGA Dreamcast
If you want to compile ScummVM for your Dreamcast,
you'll need the following:
-* gcc-3.4.2 configured as a cross-compiler for `sh-elf'
+* gcc-4.6.3 configured as a cross-compiler for `sh-elf'
* binutils-2.18 configured likewise
-* newlib for sh-elf : <URL:http://mc.pp.se/dc/files/newlib-1.12.0.tar.gz>
+* newlib for sh-elf : <URL:http://mc.pp.se/dc/files/newlib-1.19.0.tar.gz>
-* libronin-0.5 : <URL:http://peter.bortas.org/scumm/libronin-0.5.tar.gz>
+* libronin-0.6 : <URL:http://peter.bortas.org/scumm/libronin-0.6.tar.gz>
* libmad : <URL:http://mc.pp.se/dc/files/libmad-0.15.1b.tar.gz>
diff --git a/backends/platform/dc/dc-fs.cpp b/backends/platform/dc/dc-fs.cpp
index 77fe4143dd..4bd7e5a777 100644
--- a/backends/platform/dc/dc-fs.cpp
+++ b/backends/platform/dc/dc-fs.cpp
@@ -57,6 +57,7 @@ public:
virtual Common::SeekableReadStream *createReadStream();
virtual Common::WriteStream *createWriteStream() { return 0; }
+ virtual bool create(bool isDirectory) { return false; }
static AbstractFSNode *makeFileNodePath(const Common::String &path);
};
diff --git a/backends/platform/dc/dc.h b/backends/platform/dc/dc.h
index d8ab549c3a..6cd938ec9c 100644
--- a/backends/platform/dc/dc.h
+++ b/backends/platform/dc/dc.h
@@ -57,21 +57,16 @@ class DCHardware {
};
class DCCDManager : public DefaultAudioCDManager {
- // Initialize the specified CD drive for audio playback.
- bool openCD(int drive);
-
- // Poll cdrom status
- // Returns true if cd audio is playing
- bool pollCD();
-
- // Play cdrom audio track
- void playCD(int track, int num_loops, int start_frame, int duration);
+public:
+ // Poll cdrom status
+ // Returns true if cd audio is playing
+ bool isPlaying() const;
- // Stop cdrom audio track
- void stopCD();
+ // Play cdrom audio track
+ bool play(int track, int numLoops, int startFrame, int duration, bool onlyEmulate = false);
- // Update cdrom audio status
- void updateCD();
+ // Stop cdrom audio track
+ void stop();
};
class OSystem_Dreamcast : private DCHardware, public EventsBaseBackend, public PaletteManager, public FilesystemFactory
diff --git a/backends/platform/dc/dcloader.cpp b/backends/platform/dc/dcloader.cpp
index bc5e3a733b..2627773b13 100644
--- a/backends/platform/dc/dcloader.cpp
+++ b/backends/platform/dc/dcloader.cpp
@@ -26,6 +26,8 @@
#include "dcloader.h"
+#include <cxxabi.h>
+
#ifdef DL_DEBUG
#define DBG(x) reportf x
#else
@@ -345,6 +347,7 @@ bool DLObject::open(const char *path)
ctors_end = symbol("__plugin_ctors_end");
dtors_start = symbol("__plugin_dtors");
dtors_end = symbol("__plugin_dtors_end");
+ dso_handle = symbol("__dso_handle");
if (ctors_start == NULL || ctors_end == NULL || dtors_start == NULL ||
dtors_end == NULL) {
@@ -364,6 +367,10 @@ bool DLObject::open(const char *path)
bool DLObject::close()
{
+ if (dso_handle != NULL) {
+ __cxxabiv1::__cxa_finalize(dso_handle);
+ dso_handle = NULL;
+ }
if (dtors_start != NULL && dtors_end != NULL)
for (void (**f)(void) = (void (**)(void))dtors_start; f != dtors_end; f++)
(**f)();
diff --git a/backends/platform/dc/dcloader.h b/backends/platform/dc/dcloader.h
index 074ae7aa29..daa2802ec4 100644
--- a/backends/platform/dc/dcloader.h
+++ b/backends/platform/dc/dcloader.h
@@ -34,7 +34,7 @@ class DLObject {
void *segment, *symtab;
char *strtab;
int symbol_cnt;
- void *dtors_start, *dtors_end;
+ void *dtors_start, *dtors_end, *dso_handle;
void seterror(const char *fmt, ...);
void unload();
diff --git a/backends/platform/dc/dcmain.cpp b/backends/platform/dc/dcmain.cpp
index eede796991..c84aef9c47 100644
--- a/backends/platform/dc/dcmain.cpp
+++ b/backends/platform/dc/dcmain.cpp
@@ -90,43 +90,53 @@ static bool find_track(int track, int &first_sec, int &last_sec)
return false;
}
-void DCCDManager::playCD(int track, int num_loops, int start_frame, int duration)
-{
- int first_sec, last_sec;
+bool DCCDManager::play(int track, int numLoops, int startFrame, int duration, bool onlyEmulate) {
+ DefaultAudioCDManager::play(track, numLoops, startFrame, duration, onlyEmulate);
+
+ // If we're playing now return here
+ if (isPlaying()) {
+ return true;
+ }
+
+ // If we should only play emulated tracks stop here.
+ if (onlyEmulate) {
+ return false;
+ }
+
+ int firstSec, lastSec;
#if 1
- if (num_loops)
- --num_loops;
+ if (numLoops)
+ --numLoops;
#endif
- if (num_loops>14) num_loops=14;
- else if (num_loops<0) num_loops=15; // infinity
- if (!find_track(track, first_sec, last_sec))
- return;
- if (duration)
- last_sec = first_sec + start_frame + duration;
- first_sec += start_frame;
- play_cdda_sectors(first_sec, last_sec, num_loops);
-}
-void DCCDManager::stopCD()
-{
- stop_cdda();
-}
+ if (numLoops > 14)
+ numLoops = 14;
+ else if (numLoops < 0)
+ numLoops = 15; // infinity
-bool DCCDManager::pollCD()
-{
- extern int getCdState();
- return getCdState() == 3;
+ if (!find_track(track, firstSec, lastSec))
+ return false;
+
+ if (duration)
+ lastSec = firstSec + startFrame + duration;
+
+ firstSec += startFrame;
+ play_cdda_sectors(firstSec, lastSec, numLoops);
+
+ return true;
}
-void DCCDManager::updateCD()
-{
- // Dummy. The CD drive takes care of itself.
+void DCCDManager::stop() {
+ DefaultAudioCDManager::stop();
+ stop_cdda();
}
-bool DCCDManager::openCD(int drive)
-{
- // Dummy.
- return true;
+bool DCCDManager::isPlaying() const {
+ if (DefaultAudioCDManager::isPlaying())
+ return true;
+
+ extern int getCdState();
+ return getCdState() == 3;
}
void OSystem_Dreamcast::setWindowCaption(const char *caption)
diff --git a/backends/platform/dc/dreamcast.mk b/backends/platform/dc/dreamcast.mk
index 9d8a53e25a..98b5bae087 100644
--- a/backends/platform/dc/dreamcast.mk
+++ b/backends/platform/dc/dreamcast.mk
@@ -6,6 +6,8 @@ ASFLAGS := $(CXXFLAGS)
dist : SCUMMVM.BIN IP.BIN plugin_dist
+clean : dcclean
+
plugin_dist : plugins
@[ -z "$(PLUGINS)" ] || for p in $(or $(PLUGINS),none); do \
t="`basename \"$$p\" | LC_CTYPE=C tr '[:lower:]' '[:upper:]'`"; \
@@ -37,3 +39,10 @@ ip.txt : $(srcdir)/backends/platform/dc/ip.txt.in
dcdist : dist
mkdir -p dcdist/scummvm
cp scummvm.elf SCUMMVM.BIN IP.BIN *.PLG dcdist/scummvm/
+
+dcclean :
+ $(RM) backends/platform/dc/plugin_head.o
+ $(RM) scummvm.bin SCUMMVM.BIN ip.txt IP.BIN *.PLG
+ $(RM_REC) dcdist
+
+.PHONY: dcclean
diff --git a/backends/platform/dc/plugin.syms b/backends/platform/dc/plugin.syms
index 2cab08c9c7..9340ca20b8 100644
--- a/backends/platform/dc/plugin.syms
+++ b/backends/platform/dc/plugin.syms
@@ -6,3 +6,4 @@ ___plugin_ctors
___plugin_ctors_end
___plugin_dtors
___plugin_dtors_end
+___dso_handle
diff --git a/backends/platform/dc/plugin.x b/backends/platform/dc/plugin.x
index 2c8469a335..039fca81cf 100644
--- a/backends/platform/dc/plugin.x
+++ b/backends/platform/dc/plugin.x
@@ -9,6 +9,7 @@ SECTIONS
. = 0;
.text :
{
+ ___dso_handle = .;
*(.text .stub .text.* .gnu.linkonce.t.*)
*(.gnu.warning)
} :plugin =0
diff --git a/backends/platform/dc/vmsave.cpp b/backends/platform/dc/vmsave.cpp
index 75fc1ed0df..df02813b67 100644
--- a/backends/platform/dc/vmsave.cpp
+++ b/backends/platform/dc/vmsave.cpp
@@ -266,18 +266,19 @@ public:
{ return ::readSaveGame(buffer, _size, filename); }
};
-class OutVMSave : public Common::OutSaveFile {
+class OutVMSave : public Common::WriteStream {
private:
char *buffer;
- int pos, size, committed;
+ int _pos, size, committed;
char filename[16];
bool iofailed;
public:
uint32 write(const void *buf, uint32 cnt);
+ virtual int32 pos() const { return _pos; }
OutVMSave(const char *_filename)
- : pos(0), committed(-1), iofailed(false)
+ : _pos(0), committed(-1), iofailed(false)
{
strncpy(filename, _filename, 16);
buffer = new char[size = MAX_SAVE_SIZE];
@@ -291,12 +292,34 @@ public:
};
class VMSaveManager : public Common::SaveFileManager {
+private:
+ static int nameCompare(const unsigned char *entry, const char *match) {
+ return !scumm_strnicmp(reinterpret_cast<const char *>(entry), match, 12);
+ }
+
public:
+ virtual void updateSavefilesList(Common::StringArray &lockedFiles) {
+ // TODO: implement this (locks files, preventing them from being listed, saved or loaded)
+ }
- virtual Common::OutSaveFile *openForSaving(const Common::String &filename, bool compress = true) {
- OutVMSave *s = new OutVMSave(filename.c_str());
- return compress ? Common::wrapCompressedWriteStream(s) : s;
- }
+ VMSaveManager() {
+ vmsfs_name_compare_function = nameCompare;
+ }
+
+ virtual Common::InSaveFile *openRawFile(const Common::String &filename) {
+ InVMSave *s = new InVMSave();
+ if (s->readSaveGame(filename.c_str())) {
+ return s;
+ } else {
+ delete s;
+ return NULL;
+ }
+ }
+
+ virtual Common::OutSaveFile *openForSaving(const Common::String &filename, bool compress = true) {
+ OutVMSave *s = new OutVMSave(filename.c_str());
+ return new Common::OutSaveFile(compress ? Common::wrapCompressedWriteStream(s) : s);
+ }
virtual Common::InSaveFile *openForLoading(const Common::String &filename) {
InVMSave *s = new InVMSave();
@@ -320,14 +343,14 @@ void OutVMSave::finalize()
extern const char *gGameName;
extern Icon icon;
- if (committed >= pos)
+ if (committed >= _pos)
return;
char *data = buffer;
- int len = pos;
+ int len = _pos;
vmsaveResult r = writeSaveGame(gGameName, data, len, filename, icon);
- committed = pos;
+ committed = _pos;
if (r != VMSAVE_OK)
iofailed = true;
displaySaveResult(r);
@@ -386,13 +409,13 @@ bool InVMSave::seek(int32 offs, int whence)
uint32 OutVMSave::write(const void *buf, uint32 cnt)
{
int nbyt = cnt;
- if (pos + nbyt > size) {
- cnt = (size - pos);
+ if (_pos + nbyt > size) {
+ cnt = (size - _pos);
nbyt = cnt;
}
if (nbyt)
- memcpy(buffer + pos, buf, nbyt);
- pos += nbyt;
+ memcpy(buffer + _pos, buf, nbyt);
+ _pos += nbyt;
return cnt;
}
diff --git a/backends/platform/dingux/README.GCW0 b/backends/platform/dingux/README.GCW0
index 1875e5323a..95438084c2 100644
--- a/backends/platform/dingux/README.GCW0
+++ b/backends/platform/dingux/README.GCW0
@@ -24,3 +24,17 @@ It's pretty simple if you are running Linux on an x86/amd64 machine:
3. Run backends/platform/dingux/build.gcw0.sh script
4. Copy the resulting file scummvm.opk to your device
5. Enjoy
+
+Troubleshooting
+===============
+Please be advised that currently games with a resolution above 320x240
+are disabled due to the limited screen resolution on the GCW0. This could be
+changed in the future, but higher resolution games will require use of
+an HDMI connection.
+
+In case you need to submit a bugreport, you may find the log file at the
+following path:
+
+ /var/tmp/scummvm.log
+
+The log file is being overwritten at every ScummVM run.
diff --git a/backends/platform/dingux/build.gcw0.sh b/backends/platform/dingux/build.gcw0.sh
index c4bb9d2641..7a31d4fd27 100755
--- a/backends/platform/dingux/build.gcw0.sh
+++ b/backends/platform/dingux/build.gcw0.sh
@@ -3,4 +3,4 @@
export PATH=/opt/gcw0-toolchain/usr/bin:$PATH
# Disable high resolution engines since we have 320x240 hardware
-./configure --host=gcw0 --enable-plugins --default-dynamic --enable-release --disable-engine=mohawk,neverhood,sword25,toltecs,wintermute,zvision --disable-mt32emu --disable-hq-scalers && make -j6 gcw-opk && ls -l scummvm.opk
+./configure --host=gcw0 --enable-plugins --default-dynamic --enable-release && make -j6 gcw-opk && ls -l scummvm.opk
diff --git a/backends/platform/dingux/dingux.mk b/backends/platform/dingux/dingux.mk
index 56c26c3be1..dc87e41241 100644
--- a/backends/platform/dingux/dingux.mk
+++ b/backends/platform/dingux/dingux.mk
@@ -59,19 +59,20 @@ endif
echo >> $(gcw0_bundle)/README.man.txt
echo '[General README]' >> $(gcw0_bundle)/README.man.txt
echo >> $(gcw0_bundle)/README.man.txt
- cat README >> $(gcw0_bundle)/README.man.txt
+ cat $(srcdir)/README | sed -e 's/\[/⟦/g' -e 's/\]/⟧/g' -e '/^1\.1)/,$$ s/^[0-9][0-9]*\.[0-9][0-9]*.*/\[&\]/' >> $(gcw0_bundle)/README.man.txt
+
# $(CP) GeneralUser\ GS\ FluidSynth\ v1.44.sf2 $(gcw0_bundle)/
gcw0-opk-unstripped: $(gcw0_bundle)
$(CP) $(PLUGINS) $(gcw0_bundle)/plugins/
$(CP) $(EXECUTABLE) $(gcw0_bundle)/scummvm
- ./dists/gcw0/opk_make.sh -d $(gcw0_bundle) -o scummvm
+ $(srcdir)/dists/gcw0/opk_make.sh -d $(gcw0_bundle) -o scummvm
gcw-opk: $(gcw0_bundle)
$(STRIP) $(gcw0_bundle)/plugins/*
$(STRIP) $(gcw0_bundle)/scummvm
- ./dists/gcw0/opk_make.sh -d $(gcw0_bundle) -o scummvm
+ $(srcdir)/dists/gcw0/opk_make.sh -d $(gcw0_bundle) -o scummvm
GeneralUser_GS_1.44-FluidSynth.zip:
curl -s http://www.scummvm.org/frs/extras/SoundFont/GeneralUser_GS_1.44-FluidSynth.zip -o GeneralUser_GS_1.44-FluidSynth.zip
diff --git a/backends/platform/ds/arm9/source/gbampsave.cpp b/backends/platform/ds/arm9/source/gbampsave.cpp
index ef6091e2a2..9991a3253a 100644
--- a/backends/platform/ds/arm9/source/gbampsave.cpp
+++ b/backends/platform/ds/arm9/source/gbampsave.cpp
@@ -45,6 +45,17 @@ static Common::String getSavePath() {
// GBAMP Save File Manager
//////////////////////////
+void GBAMPSaveFileManager::updateSavefilesList(Common::StringArray &lockedFiles) {
+ // TODO: implement this
+ // in this method manager should remember lockedFiles
+ // these files must not be opened for loading or saving, or listed by listSavefiles()
+}
+
+Common::InSaveFile *GBAMPSaveFileManager::openRawFile(const Common::String &filename) {
+ // TODO: make sure it returns raw file, not uncompressed save contents
+ return openForLoading(filename);
+}
+
Common::OutSaveFile *GBAMPSaveFileManager::openForSaving(const Common::String &filename, bool compress) {
Common::String fileSpec = getSavePath();
if (fileSpec.lastChar() != '/')
@@ -56,7 +67,7 @@ Common::OutSaveFile *GBAMPSaveFileManager::openForSaving(const Common::String &f
Common::WriteStream *stream = DS::DSFileStream::makeFromPath(fileSpec, true);
// Use a write buffer
stream = Common::wrapBufferedWriteStream(stream, SAVE_BUFFER_SIZE);
- return stream;
+ return new Common::OutSaveFile(stream);
}
Common::InSaveFile *GBAMPSaveFileManager::openForLoading(const Common::String &filename) {
diff --git a/backends/platform/ds/arm9/source/gbampsave.h b/backends/platform/ds/arm9/source/gbampsave.h
index d86db2ec70..065ea7de68 100644
--- a/backends/platform/ds/arm9/source/gbampsave.h
+++ b/backends/platform/ds/arm9/source/gbampsave.h
@@ -27,6 +27,9 @@
class GBAMPSaveFileManager : public Common::SaveFileManager {
public:
+ virtual void updateSavefilesList(Common::StringArray &lockedFiles);
+ virtual Common::InSaveFile *openRawFile(const Common::String &filename);
+
virtual Common::OutSaveFile *openForSaving(const Common::String &filename, bool compress = true);
virtual Common::InSaveFile *openForLoading(const Common::String &filename);
diff --git a/backends/platform/ds/arm9/source/osystem_ds.cpp b/backends/platform/ds/arm9/source/osystem_ds.cpp
index c53f57523d..f23192cd9d 100644
--- a/backends/platform/ds/arm9/source/osystem_ds.cpp
+++ b/backends/platform/ds/arm9/source/osystem_ds.cpp
@@ -715,7 +715,7 @@ void OSystem_DS::deleteMutex(MutexRef mutex) {
// and should be replaced by an AudioCDManager subclass,
// see backends/audiocd/ and common/system.h
-bool OSystem_DS::openCD(int drive) {
+bool OSystem_DS::openCD() {
return DS::CD::checkCD();
}
diff --git a/backends/platform/ds/arm9/source/osystem_ds.h b/backends/platform/ds/arm9/source/osystem_ds.h
index f4dbac66f7..9f73e125c2 100644
--- a/backends/platform/ds/arm9/source/osystem_ds.h
+++ b/backends/platform/ds/arm9/source/osystem_ds.h
@@ -130,7 +130,8 @@ public:
// FIXME/TODO: The CD API as follows is *obsolete*
// and should be replaced by an AudioCDManager subclass,
// see backends/audiocd/ and common/system.h
- virtual bool openCD(int drive);
+ virtual bool openCD();
+ virtual void closeCD() {}
virtual bool pollCD();
virtual void playCD(int track, int num_loops, int start_frame, int duration);
virtual void stopCD();
diff --git a/backends/platform/ios7/ios7_common.h b/backends/platform/ios7/ios7_common.h
index 12740d4ae9..3609387efd 100644
--- a/backends/platform/ios7/ios7_common.h
+++ b/backends/platform/ios7/ios7_common.h
@@ -62,7 +62,6 @@ enum UIViewTapDescription {
};
enum GraphicsModes {
- kGraphicsModeLinear = 0,
kGraphicsModeNone = 1,
kGraphicsMode2xSaI,
@@ -80,7 +79,7 @@ struct VideoContext {
VideoContext() : asprectRatioCorrection(), screenWidth(), screenHeight(), overlayVisible(false),
overlayWidth(), overlayHeight(), mouseX(), mouseY(),
mouseHotspotX(), mouseHotspotY(), mouseWidth(), mouseHeight(),
- mouseIsVisible(), graphicsMode(kGraphicsModeNone), shakeOffsetY() {
+ mouseIsVisible(), graphicsMode(kGraphicsModeNone), filtering(false), shakeOffsetY() {
}
// Game screen state
@@ -102,6 +101,7 @@ struct VideoContext {
// Misc state
GraphicsModes graphicsMode;
+ bool filtering;
int shakeOffsetY;
};
diff --git a/backends/platform/ios7/ios7_osys_events.cpp b/backends/platform/ios7/ios7_osys_events.cpp
index 3621c084db..da467cf5d6 100644
--- a/backends/platform/ios7/ios7_osys_events.cpp
+++ b/backends/platform/ios7/ios7_osys_events.cpp
@@ -91,16 +91,16 @@ bool OSystem_iOS7::pollEvent(Common::Event &event) {
if (!handleEvent_secondMouseUp(event, internalEvent.value1, internalEvent.value2))
return false;
break;
-
+
case kInputKeyPressed:
handleEvent_keyPressed(event, internalEvent.value1);
break;
-
+
case kInputSwipe:
if (!handleEvent_swipe(event, internalEvent.value1, internalEvent.value2))
return false;
break;
-
+
case kInputTap:
if (!handleEvent_tap(event, (UIViewTapDescription) internalEvent.value1, internalEvent.value2))
return false;
@@ -109,7 +109,7 @@ bool OSystem_iOS7::pollEvent(Common::Event &event) {
default:
break;
}
-
+
return true;
}
return false;
@@ -499,14 +499,14 @@ bool OSystem_iOS7::handleEvent_swipe(Common::Event &event, int direction, int to
}
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;
_queuedEventTime = getMillis() + kQueuedInputEventDelay;
-
+
return true;
}
else if (touches == 2) {
diff --git a/backends/platform/ios7/ios7_osys_main.cpp b/backends/platform/ios7/ios7_osys_main.cpp
index 25d9cbed15..3a627478f9 100644
--- a/backends/platform/ios7/ios7_osys_main.cpp
+++ b/backends/platform/ios7/ios7_osys_main.cpp
@@ -52,8 +52,7 @@
const OSystem::GraphicsMode OSystem_iOS7::s_supportedGraphicsModes[] = {
- { "none", "No filtering", kGraphicsModeNone },
- { "linear", "Linear filtering", kGraphicsModeLinear },
+ { "none", "Normal", kGraphicsModeNone },
#ifdef ENABLE_IOS7_SCALERS
#ifdef USE_SCALERS
@@ -171,6 +170,7 @@ void OSystem_iOS7::initBackend() {
bool OSystem_iOS7::hasFeature(Feature f) {
switch (f) {
case kFeatureCursorPalette:
+ case kFeatureFilteringMode:
return true;
default:
@@ -187,6 +187,9 @@ void OSystem_iOS7::setFeatureState(Feature f, bool enable) {
_mouseCursorPaletteEnabled = enable;
}
break;
+ case kFeatureFilteringMode:
+ _videoContext->filtering = enable;
+ break;
case kFeatureAspectRatioCorrection:
_videoContext->asprectRatioCorrection = enable;
break;
@@ -200,6 +203,8 @@ bool OSystem_iOS7::getFeatureState(Feature f) {
switch (f) {
case kFeatureCursorPalette:
return _mouseCursorPaletteEnabled;
+ case kFeatureFilteringMode:
+ return _videoContext->filtering;
case kFeatureAspectRatioCorrection:
return _videoContext->asprectRatioCorrection;
diff --git a/backends/platform/ios7/ios7_osys_main.h b/backends/platform/ios7/ios7_osys_main.h
index 174c160bd6..0f89cf7aa5 100644
--- a/backends/platform/ios7/ios7_osys_main.h
+++ b/backends/platform/ios7/ios7_osys_main.h
@@ -123,6 +123,9 @@ public:
static OSystem_iOS7 *sharedInstance();
virtual void initBackend();
+
+ virtual void engineInit();
+ virtual void engineDone();
virtual bool hasFeature(Feature f);
virtual void setFeatureState(Feature f, bool enable);
diff --git a/backends/platform/ios7/ios7_osys_video.mm b/backends/platform/ios7/ios7_osys_video.mm
index 6784cf46f5..1ec0defd7e 100644
--- a/backends/platform/ios7/ios7_osys_video.mm
+++ b/backends/platform/ios7/ios7_osys_video.mm
@@ -61,6 +61,18 @@ void OSystem_iOS7::fatalError() {
}
}
+void OSystem_iOS7::engineInit() {
+ EventsBaseBackend::engineInit();
+ // Prevent the device going to sleep during game play (and in particular cut scenes)
+ [[UIApplication sharedApplication] setIdleTimerDisabled:YES];
+}
+
+void OSystem_iOS7::engineDone() {
+ EventsBaseBackend::engineDone();
+ // Allow the device going to sleep if idle while in the Launcher
+ [[UIApplication sharedApplication] setIdleTimerDisabled:NO];
+}
+
void OSystem_iOS7::initVideoContext() {
_videoContext = [[iOS7AppDelegate iPhoneView] getVideoContext];
}
@@ -76,7 +88,6 @@ int OSystem_iOS7::getDefaultGraphicsMode() const {
bool OSystem_iOS7::setGraphicsMode(int mode) {
switch (mode) {
case kGraphicsModeNone:
- case kGraphicsModeLinear:
case kGraphicsMode2xSaI:
case kGraphicsModeSuper2xSaI:
case kGraphicsModeSuperEagle:
diff --git a/backends/platform/ios7/ios7_video.mm b/backends/platform/ios7/ios7_video.mm
index 5c0434d43e..5baa83e8e8 100644
--- a/backends/platform/ios7/ios7_video.mm
+++ b/backends/platform/ios7/ios7_video.mm
@@ -442,26 +442,7 @@ uint getSizeNextPOT(uint size) {
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, tex); printOpenGLError();
- GLint filter = GL_LINEAR;
-
- switch (_videoContext.graphicsMode) {
- case kGraphicsModeNone:
- filter = GL_NEAREST;
- break;
-
- case kGraphicsModeLinear:
- case kGraphicsMode2xSaI:
- case kGraphicsModeSuper2xSaI:
- case kGraphicsModeSuperEagle:
- case kGraphicsModeAdvMame2x:
- case kGraphicsModeAdvMame3x:
- case kGraphicsModeHQ2x:
- case kGraphicsModeHQ3x:
- case kGraphicsModeTV2x:
- case kGraphicsModeDotMatrix:
- filter = GL_LINEAR;
- break;
- }
+ GLint filter = _videoContext.filtering ? GL_LINEAR : GL_NEAREST;
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filter); printOpenGLError();
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filter); printOpenGLError();
@@ -478,9 +459,6 @@ uint getSizeNextPOT(uint size) {
int scalerScale = 1;
switch (_videoContext.graphicsMode) {
- case kGraphicsModeLinear:
- break;
-
case kGraphicsModeNone:
break;
#ifdef USE_SCALERS
@@ -931,7 +909,7 @@ uint getSizeNextPOT(uint size) {
CGPoint point = [touch locationInView:self];
if (![self getMouseCoords:point eventX:&x eventY:&y])
return;
-
+
[self addEvent:InternalEvent(kInputMouseSecondDragged, x, y)];
}
}
diff --git a/backends/platform/maemo/debian/changelog b/backends/platform/maemo/debian/changelog
index 6b6d1aebd8..0d7d07443e 100644
--- a/backends/platform/maemo/debian/changelog
+++ b/backends/platform/maemo/debian/changelog
@@ -1,8 +1,20 @@
-scummvm (1.9.0~git) unstable; urgency=low
+scummvm (1.10.0~git) unstable; urgency=low
* Development snapshot
- -- Tarek Soliman <tsoliman@scummvm.org> Fri, 26 Feb 2016 21:11:20 -0600
+ -- Tarek Soliman <tsoliman@scummvm.org> Mon, 10 Oct 2016 20:35:19 -0500
+
+scummvm (1.9.0) unstable; urgency=low
+
+ * 1.9.0 release
+
+ -- Tarek Soliman <tsoliman@scummvm.org> Mon, 10 Oct 2016 20:35:18 -0500
+
+scummvm (1.8.1) unstable; urgency=low
+
+ * 1.8.1 release
+
+ -- Tarek Soliman <tsoliman@scummvm.org> Fri, 20 May 2016 20:05:11 -0500
scummvm (1.8.0) unstable; urgency=low
diff --git a/backends/platform/n64/framfs_save_manager.h b/backends/platform/n64/framfs_save_manager.h
index a066854aab..24f9bf10ce 100644
--- a/backends/platform/n64/framfs_save_manager.h
+++ b/backends/platform/n64/framfs_save_manager.h
@@ -65,12 +65,15 @@ public:
}
};
-class OutFRAMSave : public Common::OutSaveFile {
+class OutFRAMSave : public Common::WriteStream {
private:
FRAMFILE *fd;
public:
uint32 write(const void *buf, uint32 cnt);
+ virtual int32 pos() const {
+ return framfs_tell(fd);
+ }
OutFRAMSave(const char *_filename) : fd(NULL) {
fd = framfs_open(_filename, "w");
@@ -99,11 +102,26 @@ public:
class FRAMSaveManager : public Common::SaveFileManager {
public:
+ virtual void updateSavefilesList(Common::StringArray &lockedFiles) {
+ // this method is used to lock saves while cloud syncing
+ // as there is no network on N64, this method wouldn't be used
+ // thus it's not implemtented
+ }
+
+ virtual Common::InSaveFile *openRawFile(const Common::String &filename) {
+ InFRAMSave *s = new InFRAMSave();
+ if (s->readSaveGame(filename.c_str())) {
+ return s;
+ } else {
+ delete s;
+ return 0;
+ }
+ }
virtual Common::OutSaveFile *openForSaving(const Common::String &filename, bool compress = true) {
OutFRAMSave *s = new OutFRAMSave(filename.c_str());
if (!s->err()) {
- return compress ? Common::wrapCompressedWriteStream(s) : s;
+ return new Common::OutSaveFile(compress ? Common::wrapCompressedWriteStream(s) : s);
} else {
delete s;
return 0;
diff --git a/backends/platform/n64/pakfs_save_manager.h b/backends/platform/n64/pakfs_save_manager.h
index ec66c80b73..8e16d1fce4 100644
--- a/backends/platform/n64/pakfs_save_manager.h
+++ b/backends/platform/n64/pakfs_save_manager.h
@@ -65,13 +65,17 @@ public:
}
};
-class OutPAKSave : public Common::OutSaveFile {
+class OutPAKSave : public Common::WriteStream {
private:
PAKFILE *fd;
public:
uint32 write(const void *buf, uint32 cnt);
+ virtual int32 pos() const {
+ return pakfs_tell(fd);
+ }
+
OutPAKSave(const char *_filename) : fd(NULL) {
fd = pakfs_open(_filename, "w");
}
@@ -100,11 +104,26 @@ public:
class PAKSaveManager : public Common::SaveFileManager {
public:
+ virtual void updateSavefilesList(Common::StringArray &lockedFiles) {
+ // this method is used to lock saves while cloud syncing
+ // as there is no network on N64, this method wouldn't be used
+ // thus it's not implemtented
+ }
+
+ virtual Common::InSaveFile *openRawFile(const Common::String &filename) {
+ InPAKSave *s = new InPAKSave();
+ if (s->readSaveGame(filename.c_str())) {
+ return s;
+ } else {
+ delete s;
+ return NULL;
+ }
+ }
virtual Common::OutSaveFile *openForSaving(const Common::String &filename, bool compress = true) {
OutPAKSave *s = new OutPAKSave(filename.c_str());
if (!s->err()) {
- return compress ? Common::wrapCompressedWriteStream(s) : s;
+ return new Common::OutSaveFile(compress ? Common::wrapCompressedWriteStream(s) : s);
} else {
delete s;
return NULL;
diff --git a/backends/platform/ps2/eecodyvdfs.c b/backends/platform/ps2/eecodyvdfs.c
index f410b0c8ec..a4d60a7501 100644
--- a/backends/platform/ps2/eecodyvdfs.c
+++ b/backends/platform/ps2/eecodyvdfs.c
@@ -8,12 +8,12 @@
* 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.
diff --git a/backends/platform/ps2/iop/CoDyVDfs/iop/codyvdfs.c b/backends/platform/ps2/iop/CoDyVDfs/iop/codyvdfs.c
index 2a94560843..3fe0d408c4 100644
--- a/backends/platform/ps2/iop/CoDyVDfs/iop/codyvdfs.c
+++ b/backends/platform/ps2/iop/CoDyVDfs/iop/codyvdfs.c
@@ -8,12 +8,12 @@
* 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.
diff --git a/backends/platform/ps2/iop/CoDyVDfs/iop/fiofs.c b/backends/platform/ps2/iop/CoDyVDfs/iop/fiofs.c
index 611211a715..dcf9074916 100644
--- a/backends/platform/ps2/iop/CoDyVDfs/iop/fiofs.c
+++ b/backends/platform/ps2/iop/CoDyVDfs/iop/fiofs.c
@@ -8,12 +8,12 @@
* 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.
diff --git a/backends/platform/ps2/iop/CoDyVDfs/iop/rpcfs.c b/backends/platform/ps2/iop/CoDyVDfs/iop/rpcfs.c
index 983ae38716..6d12a451e3 100644
--- a/backends/platform/ps2/iop/CoDyVDfs/iop/rpcfs.c
+++ b/backends/platform/ps2/iop/CoDyVDfs/iop/rpcfs.c
@@ -8,12 +8,12 @@
* 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.
diff --git a/backends/platform/ps2/irxboot.cpp b/backends/platform/ps2/irxboot.cpp
index 0e05047c6e..64d6e989d6 100644
--- a/backends/platform/ps2/irxboot.cpp
+++ b/backends/platform/ps2/irxboot.cpp
@@ -151,7 +151,7 @@ int loadIrxModules(int device, const char *irxPath, IrxReference **modules, IrxT
irxFiles = irxType[type];
numFiles = numIrx[type];
resModules = (IrxReference *)memalign(64, numFiles * sizeof(IrxReference));
- curModule = resModules;
+ curModule = resModules;
for (int i = 0; i < numFiles; i++) {
curModule->fileRef = irxFiles + i;
diff --git a/backends/platform/ps2/savefilemgr.cpp b/backends/platform/ps2/savefilemgr.cpp
index 4fd2b1c72b..4cd988074e 100644
--- a/backends/platform/ps2/savefilemgr.cpp
+++ b/backends/platform/ps2/savefilemgr.cpp
@@ -82,7 +82,11 @@ void Ps2SaveFileManager::mcSplit(char *full, char *game, char *ext) {
// TODO
}
-Common::InSaveFile *Ps2SaveFileManager::openForLoading(const Common::String &filename) {
+void Ps2SaveFileManager::updateSavefilesList(Common::StringArray &lockedFiles) {
+ // TODO: implement this (locks files, preventing them from being listed, saved or loaded)
+}
+
+Common::InSaveFile *Ps2SaveFileManager::openRawFile(const Common::String &filename) {
Common::FSNode savePath(ConfMan.get("savepath")); // TODO: is this fast?
Common::SeekableReadStream *sf;
@@ -141,7 +145,12 @@ Common::InSaveFile *Ps2SaveFileManager::openForLoading(const Common::String &fil
// _screen->wantAnim(false);
- return Common::wrapCompressedReadStream(sf);
+ return sf;
+}
+
+Common::InSaveFile *Ps2SaveFileManager::openForLoading(const Common::String &filename) {
+ Common::SeekableReadStream *sf = openRawFile(filename);
+ return (sf == NULL ? NULL : Common::wrapCompressedReadStream(sf));
}
Common::OutSaveFile *Ps2SaveFileManager::openForSaving(const Common::String &filename, bool compress) {
@@ -192,7 +201,7 @@ Common::OutSaveFile *Ps2SaveFileManager::openForSaving(const Common::String &fil
}
_screen->wantAnim(false);
- return compress ? Common::wrapCompressedWriteStream(sf) : sf;
+ return new Common::OutSaveFile(compress ? Common::wrapCompressedWriteStream(sf) : sf);
}
bool Ps2SaveFileManager::removeSavefile(const Common::String &filename) {
diff --git a/backends/platform/ps2/savefilemgr.h b/backends/platform/ps2/savefilemgr.h
index 547f16fa77..3d45382c64 100644
--- a/backends/platform/ps2/savefilemgr.h
+++ b/backends/platform/ps2/savefilemgr.h
@@ -34,6 +34,9 @@ public:
Ps2SaveFileManager(OSystem_PS2 *system, Gs2dScreen *screen);
virtual ~Ps2SaveFileManager();
+ virtual void updateSavefilesList(Common::StringArray &lockedFiles);
+ virtual Common::InSaveFile *openRawFile(const Common::String &filename);
+
virtual Common::InSaveFile *openForLoading(const Common::String &filename);
virtual Common::OutSaveFile *openForSaving(const Common::String &filename, bool compress = true);
virtual Common::StringArray listSavefiles(const Common::String &pattern);
diff --git a/backends/platform/ps2/systemps2.cpp b/backends/platform/ps2/systemps2.cpp
index 1aa74b7d9b..e914cdb9c9 100644
--- a/backends/platform/ps2/systemps2.cpp
+++ b/backends/platform/ps2/systemps2.cpp
@@ -628,7 +628,7 @@ bool OSystem_PS2::usbMassPresent(void) {
}
bool OSystem_PS2::netPresent(void) {
- if (_useNet)
+ if (_useNet)
return true;
return false;
diff --git a/backends/platform/psp/README.PSP b/backends/platform/psp/README.PSP
index 9467d4b993..46e027f4f7 100644
--- a/backends/platform/psp/README.PSP
+++ b/backends/platform/psp/README.PSP
@@ -1,4 +1,4 @@
-ScummVM-PSP 1.9.0git README
+ScummVM-PSP 1.10.0git README
==============================================================================
Installation
diff --git a/backends/platform/psp/build-psp.sh b/backends/platform/psp/build-psp.sh
new file mode 100755
index 0000000000..1fbeb408a1
--- /dev/null
+++ b/backends/platform/psp/build-psp.sh
@@ -0,0 +1,15 @@
+#!/bin/bash
+
+export PATH=/opt/toolchains/psp/bin:$PATH
+export PSPDEV=/opt/toolchains/psp
+CXXFLAGS="-isystem /opt/toolchains/psp/include"
+export CXXFLAGS
+export LDFLAGS=-L/opt/toolchains/psp/lib
+export LD_LIBRARY_PATH=/opt/toolchains/legacy-shared-objects
+make distclean
+./configure --host=psp --disable-debug --enable-plugins --default-dynamic --enable-release
+make -j4
+mkdir scummvm-1.9.0
+cp -r AUTHORS COPYING COPYING.LGPL COPYING.BSD COPYRIGHT NEWS README gui/themes/translations.dat gui/themes/scummclassic.zip gui/themes/scummmodern.zip dists/engine-data/access.dat dists/engine-data/drascula.dat dists/engine-data/hugo.dat dists/engine-data/kyra.dat dists/engine-data/lure.dat dists/engine-data/mort.dat dists/engine-data/neverhood.dat dists/engine-data/queen.tbl dists/engine-data/sky.cpt dists/engine-data/teenagent.dat dists/engine-data/tony.dat dists/engine-data/toon.dat dists/engine-data/wintermute.zip dists/pred.dic EBOOT.PBP plugins backends/platform/psp/kbd.zip scummvm-1.9.0
+zip -r9 scummvm-1.9.0-psp.zip scummvm-1.9.0
+
diff --git a/backends/platform/sdl/amigaos/amigaos-main.cpp b/backends/platform/sdl/amigaos/amigaos-main.cpp
index 65da6bbf85..7bbf8d1fff 100644
--- a/backends/platform/sdl/amigaos/amigaos-main.cpp
+++ b/backends/platform/sdl/amigaos/amigaos-main.cpp
@@ -24,13 +24,44 @@
#if defined(__amigaos4__)
+#include "backends/fs/amigaos4/amigaos4-fs.h"
#include "backends/platform/sdl/amigaos/amigaos.h"
#include "backends/plugins/sdl/sdl-provider.h"
#include "base/main.h"
int main(int argc, char *argv[]) {
- // Set up a stack cookie to avoid crashes due to too few stack set by users
+ // The following will gather the application name and add the install path
+ // to a variable in AmigaOS4's ENV(ARC) system. It will be placed in AppPaths
+ // so that ScummVM can become AmiUpdate aware
+ const char *const appname = "ScummVM";
+
+ BPTR lock;
+ APTR oldwin;
+
+ // Obtain a lock to the home directory
+ if ((lock = IDOS->GetProgramDir())) {
+ TEXT progpath[2048];
+ TEXT apppath[1024] = "AppPaths";
+
+ if (IDOS->DevNameFromLock(lock,
+ progpath,
+ sizeof(progpath),
+ DN_FULLPATH)) {
+
+ // Stop any "Insert volume..." type requesters
+ oldwin = IDOS->SetProcWindow((APTR)-1);
+
+ // Finally, set the variable to the path the executable was run from
+ IDOS->AddPart( apppath, appname, 1024);
+ IDOS->SetVar( apppath, progpath, -1, GVF_GLOBAL_ONLY|GVF_SAVE_VAR );
+
+ // Turn system requesters back on
+ IDOS->SetProcWindow( oldwin );
+ }
+ }
+
+ // Set up a stack cookie to avoid crashes from a stack set too low
static const char *stack_cookie __attribute__((used)) = "$STACK: 600000";
// Create our OSystem instance
@@ -44,7 +75,7 @@ int main(int argc, char *argv[]) {
PluginManager::instance().addPluginProvider(new SDLPluginProvider());
#endif
- // Invoke the actual ScummVM main entry point:
+ // Invoke the actual ScummVM main entry point
int res = scummvm_main(argc, argv);
// Free OSystem
diff --git a/backends/platform/sdl/macosx/macosx.cpp b/backends/platform/sdl/macosx/macosx.cpp
index 38a2d7441c..e90d459e67 100644
--- a/backends/platform/sdl/macosx/macosx.cpp
+++ b/backends/platform/sdl/macosx/macosx.cpp
@@ -27,11 +27,13 @@
#ifdef MACOSX
-#include "backends/platform/sdl/macosx/macosx.h"
+#include "backends/audiocd/macosx/macosx-audiocd.h"
#include "backends/mixer/doublebuffersdl/doublebuffersdl-mixer.h"
#include "backends/platform/sdl/macosx/appmenu_osx.h"
+#include "backends/platform/sdl/macosx/macosx.h"
#include "backends/updates/macosx/macosx-updates.h"
#include "backends/taskbar/macosx/macosx-taskbar.h"
+#include "backends/platform/sdl/macosx/macosx_wrapper.h"
#include "common/archive.h"
#include "common/config-manager.h"
@@ -54,7 +56,7 @@ void OSystem_MacOSX::init() {
// Initialize taskbar manager
_taskbarManager = new MacOSXTaskbarManager();
#endif
-
+
// Invoke parent implementation of this method
OSystem_POSIX::init();
}
@@ -105,7 +107,7 @@ void OSystem_MacOSX::addSysArchivesToSearchSet(Common::SearchSet &s, int priorit
}
bool OSystem_MacOSX::hasFeature(Feature f) {
- if (f == kFeatureDisplayLogFile)
+ if (f == kFeatureDisplayLogFile || f == kFeatureClipboardSupport || f == kFeatureOpenUrl)
return true;
return OSystem_POSIX::hasFeature(f);
}
@@ -123,6 +125,21 @@ bool OSystem_MacOSX::displayLogFile() {
return err != noErr;
}
+bool OSystem_MacOSX::hasTextInClipboard() {
+ return hasTextInClipboardMacOSX();
+}
+
+Common::String OSystem_MacOSX::getTextFromClipboard() {
+ return getTextFromClipboardMacOSX();
+}
+
+bool OSystem_MacOSX::openUrl(const Common::String &url) {
+ CFURLRef urlRef = CFURLCreateWithBytes (NULL, (UInt8*)url.c_str(), url.size(), kCFStringEncodingASCII, NULL);
+ OSStatus err = LSOpenCFURLRef(urlRef, NULL);
+ CFRelease(urlRef);
+ return err != noErr;
+}
+
Common::String OSystem_MacOSX::getSystemLanguage() const {
#if defined(USE_DETECTLANG) && defined(USE_TRANSLATION)
CFArrayRef availableLocalizations = CFBundleCopyBundleLocalizations(CFBundleGetMainBundle());
@@ -170,4 +187,8 @@ Common::String OSystem_MacOSX::getSystemLanguage() const {
#endif // USE_DETECTLANG
}
+AudioCDManager *OSystem_MacOSX::createAudioCDManager() {
+ return createMacOSXAudioCDManager();
+}
+
#endif
diff --git a/backends/platform/sdl/macosx/macosx.h b/backends/platform/sdl/macosx/macosx.h
index c8b4beaeec..72bb4a4787 100644
--- a/backends/platform/sdl/macosx/macosx.h
+++ b/backends/platform/sdl/macosx/macosx.h
@@ -33,11 +33,21 @@ public:
virtual bool displayLogFile();
+ virtual bool hasTextInClipboard();
+ virtual Common::String getTextFromClipboard();
+
+ virtual bool openUrl(const Common::String &url);
+
virtual Common::String getSystemLanguage() const;
virtual void init();
virtual void initBackend();
virtual void addSysArchivesToSearchSet(Common::SearchSet &s, int priority = 0);
+
+protected:
+ // Override createAudioCDManager() to get our Mac-specific
+ // version.
+ virtual AudioCDManager *createAudioCDManager();
};
#endif
diff --git a/backends/platform/sdl/macosx/macosx_wrapper.h b/backends/platform/sdl/macosx/macosx_wrapper.h
new file mode 100644
index 0000000000..3b346fc486
--- /dev/null
+++ b/backends/platform/sdl/macosx/macosx_wrapper.h
@@ -0,0 +1,31 @@
+/* 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.
+ *
+ */
+
+#ifndef PLATFORM_SDL_MACOSX_WRAPPER_H
+#define PLATFORM_SDL_MACOSX_WRAPPER_H
+
+#include <common/str.h>
+
+bool hasTextInClipboardMacOSX();
+Common::String getTextFromClipboardMacOSX();
+
+#endif
diff --git a/backends/platform/sdl/macosx/macosx_wrapper.mm b/backends/platform/sdl/macosx/macosx_wrapper.mm
new file mode 100644
index 0000000000..8ec9eac5ac
--- /dev/null
+++ b/backends/platform/sdl/macosx/macosx_wrapper.mm
@@ -0,0 +1,48 @@
+/* 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.
+ *
+ */
+
+// Disable symbol overrides so that we can use system headers.
+#define FORBIDDEN_SYMBOL_ALLOW_ALL
+
+#include "backends/platform/sdl/macosx/macosx_wrapper.h"
+
+#include <AppKit/NSPasteboard.h>
+#include <Foundation/NSArray.h>
+
+bool hasTextInClipboardMacOSX() {
+ return [[NSPasteboard generalPasteboard] availableTypeFromArray:[NSArray arrayWithObject:NSStringPboardType]] != nil;
+}
+
+Common::String getTextFromClipboardMacOSX() {
+ if (!hasTextInClipboardMacOSX())
+ return Common::String();
+ // Note: on OS X 10.6 and above it is recommanded to use NSPasteboardTypeString rather than NSStringPboardType.
+ // But since we still target older version use NSStringPboardType.
+ NSPasteboard *pb = [NSPasteboard generalPasteboard];
+ NSString* str = [pb stringForType:NSStringPboardType];
+ if (str == nil)
+ return Common::String();
+ // If the string cannot be represented using the requested encoding we get a null pointer below.
+ // This is fine as ScummVM would not know what to do with non-ASCII characters (although maybe
+ // we should use NSISOLatin1StringEncoding?).
+ return Common::String([str cStringUsingEncoding:NSASCIIStringEncoding]);
+}
diff --git a/backends/platform/sdl/module.mk b/backends/platform/sdl/module.mk
index 74dd506d31..84ce272d3c 100644
--- a/backends/platform/sdl/module.mk
+++ b/backends/platform/sdl/module.mk
@@ -14,6 +14,7 @@ ifdef MACOSX
MODULE_OBJS += \
macosx/macosx-main.o \
macosx/macosx.o \
+ macosx/macosx_wrapper.o \
macosx/appmenu_osx.o
endif
diff --git a/backends/platform/sdl/posix/posix-main.cpp b/backends/platform/sdl/posix/posix-main.cpp
index d07db11b0c..5deebb0ae3 100644
--- a/backends/platform/sdl/posix/posix-main.cpp
+++ b/backends/platform/sdl/posix/posix-main.cpp
@@ -22,7 +22,7 @@
#include "common/scummsys.h"
-#if defined(POSIX) && !defined(MACOSX) && !defined(SAMSUNGTV) && !defined(MAEMO) && !defined(WEBOS) && !defined(LINUXMOTO) && !defined(GPH_DEVICE) && !defined(GP2X) && !defined(DINGUX) && !defined(OPENPANDORA) && !defined(PLAYSTATION3)
+#if defined(POSIX) && !defined(MACOSX) && !defined(SAMSUNGTV) && !defined(MAEMO) && !defined(WEBOS) && !defined(LINUXMOTO) && !defined(GPH_DEVICE) && !defined(GP2X) && !defined(DINGUX) && !defined(OPENPANDORA) && !defined(PLAYSTATION3) && !defined(ANDROIDSDL)
#include "backends/platform/sdl/posix/posix.h"
#include "backends/plugins/sdl/sdl-provider.h"
diff --git a/backends/platform/sdl/posix/posix.cpp b/backends/platform/sdl/posix/posix.cpp
index 525c74a91a..b805a452cf 100644
--- a/backends/platform/sdl/posix/posix.cpp
+++ b/backends/platform/sdl/posix/posix.cpp
@@ -25,6 +25,7 @@
#define FORBIDDEN_SYMBOL_EXCEPTION_exit
#define FORBIDDEN_SYMBOL_EXCEPTION_unistd_h
#define FORBIDDEN_SYMBOL_EXCEPTION_time_h //On IRIX, sys/stat.h includes sys/time.h
+#define FORBIDDEN_SYMBOL_EXCEPTION_system
#include "common/scummsys.h"
@@ -36,6 +37,14 @@
#include "backends/fs/posix/posix-fs.h"
#include "backends/taskbar/unity/unity-taskbar.h"
+#ifdef USE_LINUXCD
+#include "backends/audiocd/linux/linux-audiocd.h"
+#endif
+
+#include "common/textconsole.h"
+
+#include <stdlib.h>
+#include <errno.h>
#include <sys/stat.h>
#include <sys/wait.h>
#include <unistd.h>
@@ -73,7 +82,7 @@ void OSystem_POSIX::initBackend() {
}
bool OSystem_POSIX::hasFeature(Feature f) {
- if (f == kFeatureDisplayLogFile)
+ if (f == kFeatureDisplayLogFile || f == kFeatureOpenUrl)
return true;
return OSystem_SDL::hasFeature(f);
}
@@ -136,6 +145,24 @@ Common::String OSystem_POSIX::getDefaultConfigFileName() {
return configFile;
}
+void OSystem_POSIX::addSysArchivesToSearchSet(Common::SearchSet &s, int priority) {
+#ifdef DATA_PATH
+ const char *snap = getenv("SNAP");
+ if (snap) {
+ Common::String dataPath = Common::String(snap) + DATA_PATH;
+ Common::FSNode dataNode(dataPath);
+ if (dataNode.exists() && dataNode.isDirectory()) {
+ // This is the same priority which is used for the data path (below),
+ // but we insert this one first, so it will be searched first.
+ s.add(dataPath, new Common::FSDirectory(dataNode, 4), priority);
+ }
+ }
+#endif
+
+ // For now, we always add the data path, just in case SNAP doesn't make sense.
+ OSystem_SDL::addSysArchivesToSearchSet(s, priority);
+}
+
Common::WriteStream *OSystem_POSIX::createLogFile() {
// Start out by resetting _logFilePath, so that in case
// of a failure, we know that no log file is open.
@@ -238,5 +265,58 @@ bool OSystem_POSIX::displayLogFile() {
return WIFEXITED(status) && WEXITSTATUS(status) == 0;
}
+bool OSystem_POSIX::openUrl(const Common::String &url) {
+ // inspired by Qt's "qdesktopservices_x11.cpp"
+
+ // try "standards"
+ if (launchBrowser("xdg-open", url))
+ return true;
+ if (launchBrowser(getenv("DEFAULT_BROWSER"), url))
+ return true;
+ if (launchBrowser(getenv("BROWSER"), url))
+ return true;
+
+ // try desktop environment specific tools
+ if (launchBrowser("gnome-open", url)) // gnome
+ return true;
+ if (launchBrowser("kfmclient openURL", url)) // kde
+ return true;
+ if (launchBrowser("exo-open", url)) // xfce
+ return true;
+
+ // try browser names
+ if (launchBrowser("firefox", url))
+ return true;
+ if (launchBrowser("mozilla", url))
+ return true;
+ if (launchBrowser("netscape", url))
+ return true;
+ if (launchBrowser("opera", url))
+ return true;
+ if (launchBrowser("chromium-browser", url))
+ return true;
+ if (launchBrowser("google-chrome", url))
+ return true;
+
+ warning("openUrl() (POSIX) failed to open URL");
+ return false;
+}
+
+bool OSystem_POSIX::launchBrowser(const Common::String& client, const Common::String &url) {
+ // FIXME: system's input must be heavily escaped
+ // well, when url's specified by user
+ // it's OK now (urls are hardcoded somewhere in GUI)
+ Common::String cmd = client + " " + url;
+ return (system(cmd.c_str()) != -1);
+}
+
+
+AudioCDManager *OSystem_POSIX::createAudioCDManager() {
+#ifdef USE_LINUXCD
+ return createLinuxAudioCDManager();
+#else
+ return OSystem_SDL::createAudioCDManager();
+#endif
+}
#endif
diff --git a/backends/platform/sdl/posix/posix.h b/backends/platform/sdl/posix/posix.h
index f67515ddb3..bd3a069d5b 100644
--- a/backends/platform/sdl/posix/posix.h
+++ b/backends/platform/sdl/posix/posix.h
@@ -35,9 +35,13 @@ public:
virtual bool displayLogFile();
+ virtual bool openUrl(const Common::String &url);
+
virtual void init();
virtual void initBackend();
+ virtual void addSysArchivesToSearchSet(Common::SearchSet &s, int priority = 0);
+
protected:
/**
* Base string for creating the default path and filename for the
@@ -59,6 +63,10 @@ protected:
virtual Common::String getDefaultConfigFileName();
virtual Common::WriteStream *createLogFile();
+
+ virtual AudioCDManager *createAudioCDManager();
+
+ bool launchBrowser(const Common::String& client, const Common::String &url);
};
#endif
diff --git a/backends/platform/sdl/sdl-sys.h b/backends/platform/sdl/sdl-sys.h
index 219755219f..9ebd123bb4 100644
--- a/backends/platform/sdl/sdl-sys.h
+++ b/backends/platform/sdl/sdl-sys.h
@@ -52,6 +52,72 @@ typedef struct { int FAKE; } FAKE_FILE;
#define strncasecmp FAKE_strncasecmp
#endif
+#if !defined(FORBIDDEN_SYMBOL_ALLOW_ALL) && !defined(FORBIDDEN_SYMBOL_EXCEPTION_exit)
+#undef exit
+#define exit FAKE_exit
+#endif
+
+#if !defined(FORBIDDEN_SYMBOL_ALLOW_ALL) && !defined(FORBIDDEN_SYMBOL_EXCEPTION_abort)
+#undef abort
+#define abort FAKE_abort
+#endif
+
+#if !defined(FORBIDDEN_SYMBOL_ALLOW_ALL) && !defined(FORBIDDEN_SYMBOL_EXCEPTION_system)
+#undef system
+#define system FAKE_system
+#endif
+
+// Fix compilation with MacPorts SDL 2
+// It needs various (usually forbidden) symbols from time.h
+#ifndef FORBIDDEN_SYMBOL_EXCEPTION_time_h
+
+ #if !defined(FORBIDDEN_SYMBOL_ALLOW_ALL) && !defined(FORBIDDEN_SYMBOL_EXCEPTION_asctime)
+ #undef asctime
+ #define asctime FAKE_asctime
+ #endif
+
+ #if !defined(FORBIDDEN_SYMBOL_ALLOW_ALL) && !defined(FORBIDDEN_SYMBOL_EXCEPTION_clock)
+ #undef clock
+ #define clock FAKE_clock
+ #endif
+
+ #if !defined(FORBIDDEN_SYMBOL_ALLOW_ALL) && !defined(FORBIDDEN_SYMBOL_EXCEPTION_ctime)
+ #undef ctime
+ #define ctime FAKE_ctime
+ #endif
+
+ #if !defined(FORBIDDEN_SYMBOL_ALLOW_ALL) && !defined(FORBIDDEN_SYMBOL_EXCEPTION_difftime)
+ #undef difftime
+ #define difftime FAKE_difftime
+ #endif
+
+ #if !defined(FORBIDDEN_SYMBOL_ALLOW_ALL) && !defined(FORBIDDEN_SYMBOL_EXCEPTION_getdate)
+ #undef getdate
+ #define getdate FAKE_getdate
+ #endif
+
+ #if !defined(FORBIDDEN_SYMBOL_ALLOW_ALL) && !defined(FORBIDDEN_SYMBOL_EXCEPTION_gmtime)
+ #undef gmtime
+ #define gmtime FAKE_gmtime
+ #endif
+
+ #if !defined(FORBIDDEN_SYMBOL_ALLOW_ALL) && !defined(FORBIDDEN_SYMBOL_EXCEPTION_localtime)
+ #undef localtime
+ #define localtime FAKE_localtime
+ #endif
+
+ #if !defined(FORBIDDEN_SYMBOL_ALLOW_ALL) && !defined(FORBIDDEN_SYMBOL_EXCEPTION_mktime)
+ #undef mktime
+ #define mktime FAKE_mktime
+ #endif
+
+ #if !defined(FORBIDDEN_SYMBOL_ALLOW_ALL) && !defined(FORBIDDEN_SYMBOL_EXCEPTION_time)
+ #undef time
+ #define time FAKE_time
+ #endif
+
+#endif // FORBIDDEN_SYMBOL_EXCEPTION_time_h
+
// HACK: SDL might include windows.h which defines its own ARRAYSIZE.
// However, we want to use the version from common/util.h. Thus, we make sure
// that we actually have this definition after including the SDL headers.
@@ -146,6 +212,71 @@ typedef struct { int FAKE; } FAKE_FILE;
#define strncasecmp FORBIDDEN_SYMBOL_REPLACEMENT
#endif
+#if !defined(FORBIDDEN_SYMBOL_ALLOW_ALL) && !defined(FORBIDDEN_SYMBOL_EXCEPTION_exit)
+#undef exit
+#define exit(a) FORBIDDEN_SYMBOL_REPLACEMENT
+#endif
+
+#if !defined(FORBIDDEN_SYMBOL_ALLOW_ALL) && !defined(FORBIDDEN_SYMBOL_EXCEPTION_abort)
+#undef abort
+#define abort() FORBIDDEN_SYMBOL_REPLACEMENT
+#endif
+
+#if !defined(FORBIDDEN_SYMBOL_ALLOW_ALL) && !defined(FORBIDDEN_SYMBOL_EXCEPTION_system)
+#undef system
+#define system(a) FORBIDDEN_SYMBOL_REPLACEMENT
+#endif
+
+// re-forbid all those time.h symbols again (if they were forbidden)
+#ifndef FORBIDDEN_SYMBOL_EXCEPTION_time_h
+
+ #if !defined(FORBIDDEN_SYMBOL_ALLOW_ALL) && !defined(FORBIDDEN_SYMBOL_EXCEPTION_asctime)
+ #undef asctime
+ #define asctime(a) FORBIDDEN_SYMBOL_REPLACEMENT
+ #endif
+
+ #if !defined(FORBIDDEN_SYMBOL_ALLOW_ALL) && !defined(FORBIDDEN_SYMBOL_EXCEPTION_clock)
+ #undef clock
+ #define clock() FORBIDDEN_SYMBOL_REPLACEMENT
+ #endif
+
+ #if !defined(FORBIDDEN_SYMBOL_ALLOW_ALL) && !defined(FORBIDDEN_SYMBOL_EXCEPTION_ctime)
+ #undef ctime
+ #define ctime(a) FORBIDDEN_SYMBOL_REPLACEMENT
+ #endif
+
+ #if !defined(FORBIDDEN_SYMBOL_ALLOW_ALL) && !defined(FORBIDDEN_SYMBOL_EXCEPTION_difftime)
+ #undef difftime
+ #define difftime(a,b) FORBIDDEN_SYMBOL_REPLACEMENT
+ #endif
+
+ #if !defined(FORBIDDEN_SYMBOL_ALLOW_ALL) && !defined(FORBIDDEN_SYMBOL_EXCEPTION_getdate)
+ #undef getdate
+ #define getdate(a) FORBIDDEN_SYMBOL_REPLACEMENT
+ #endif
+
+ #if !defined(FORBIDDEN_SYMBOL_ALLOW_ALL) && !defined(FORBIDDEN_SYMBOL_EXCEPTION_gmtime)
+ #undef gmtime
+ #define gmtime(a) FORBIDDEN_SYMBOL_REPLACEMENT
+ #endif
+
+ #if !defined(FORBIDDEN_SYMBOL_ALLOW_ALL) && !defined(FORBIDDEN_SYMBOL_EXCEPTION_localtime)
+ #undef localtime
+ #define localtime(a) FORBIDDEN_SYMBOL_REPLACEMENT
+ #endif
+
+ #if !defined(FORBIDDEN_SYMBOL_ALLOW_ALL) && !defined(FORBIDDEN_SYMBOL_EXCEPTION_mktime)
+ #undef mktime
+ #define mktime(a) FORBIDDEN_SYMBOL_REPLACEMENT
+ #endif
+
+ #if !defined(FORBIDDEN_SYMBOL_ALLOW_ALL) && !defined(FORBIDDEN_SYMBOL_EXCEPTION_time)
+ #undef time
+ #define time(a) FORBIDDEN_SYMBOL_REPLACEMENT
+ #endif
+
+#endif // FORBIDDEN_SYMBOL_EXCEPTION_time_h
+
// SDL 2 has major API changes. We redefine constants which got renamed to
// ease the transition. This is sometimes dangerous because the values changed
// too!
diff --git a/backends/platform/sdl/sdl-window.cpp b/backends/platform/sdl/sdl-window.cpp
index 6d35f77ae0..609186a061 100644
--- a/backends/platform/sdl/sdl-window.cpp
+++ b/backends/platform/sdl/sdl-window.cpp
@@ -150,7 +150,7 @@ bool SdlWindow::hasMouseFocus() const {
void SdlWindow::warpMouseInWindow(uint x, uint y) {
#if SDL_VERSION_ATLEAST(2, 0, 0)
- if (_window) {
+ if (_window && hasMouseFocus()) {
SDL_WarpMouseInWindow(_window, x, y);
}
#else
diff --git a/backends/platform/sdl/sdl-window.h b/backends/platform/sdl/sdl-window.h
index 58b898f824..b62860960d 100644
--- a/backends/platform/sdl/sdl-window.h
+++ b/backends/platform/sdl/sdl-window.h
@@ -81,7 +81,7 @@ public:
SDL_Window *getSDLWindow() const { return _window; }
/**
- * Creates a new SDL window (and destroies the old one).
+ * Creates a new SDL window (and destroys the old one).
*
* @param width Width of the window.
* @param height Height of the window.
@@ -91,7 +91,7 @@ public:
bool createWindow(int width, int height, uint32 flags);
/**
- * Destroies the current SDL window.
+ * Destroys the current SDL window.
*/
void destroyWindow();
diff --git a/backends/platform/sdl/sdl.cpp b/backends/platform/sdl/sdl.cpp
index fffb9d56d9..74c40ade10 100644
--- a/backends/platform/sdl/sdl.cpp
+++ b/backends/platform/sdl/sdl.cpp
@@ -60,6 +60,14 @@
#endif // !WIN32
#endif
+#ifdef USE_SDL_NET
+#include <SDL_net.h>
+#endif
+
+#if SDL_VERSION_ATLEAST(2, 0, 0)
+#include <SDL_clipboard.h>
+#endif
+
OSystem_SDL::OSystem_SDL()
:
#ifdef USE_OPENGL
@@ -73,6 +81,9 @@ OSystem_SDL::OSystem_SDL()
#endif
_inited(false),
_initedSDL(false),
+#ifdef USE_SDL_NET
+ _initedSDLnet(false),
+#endif
_logger(0),
_mixerManager(0),
_eventSource(0),
@@ -120,6 +131,10 @@ OSystem_SDL::~OSystem_SDL() {
delete _logger;
_logger = 0;
+#ifdef USE_SDL_NET
+ if (_initedSDLnet) SDLNet_Quit();
+#endif
+
SDL_Quit();
}
@@ -160,6 +175,13 @@ void OSystem_SDL::init() {
}
+bool OSystem_SDL::hasFeature(Feature f) {
+#if SDL_VERSION_ATLEAST(2, 0, 0)
+ if (f == kFeatureClipboardSupport) return true;
+#endif
+ return ModularBackend::hasFeature(f);
+}
+
void OSystem_SDL::initBackend() {
// Check if backend has not been initialized
assert(!_inited);
@@ -245,15 +267,7 @@ void OSystem_SDL::initBackend() {
_timerManager = new SdlTimerManager();
#endif
- if (_audiocdManager == 0) {
- // Audio CD support was removed with SDL 2.0
-#if SDL_VERSION_ATLEAST(2, 0, 0)
- _audiocdManager = new DefaultAudioCDManager();
-#else
- _audiocdManager = new SdlAudioCDManager();
-#endif
-
- }
+ _audiocdManager = createAudioCDManager();
// Setup a custom program icon.
_window->setupIcon();
@@ -302,6 +316,17 @@ void OSystem_SDL::initSDL() {
_initedSDL = true;
}
+
+#ifdef USE_SDL_NET
+ // Check if SDL_net has not been initialized
+ if (!_initedSDLnet) {
+ // Initialize SDL_net
+ if (SDLNet_Init() == -1)
+ error("Could not initialize SDL_net: %s", SDLNet_GetError());
+
+ _initedSDLnet = true;
+ }
+#endif
}
void OSystem_SDL::addSysArchivesToSearchSet(Common::SearchSet &s, int priority) {
@@ -439,6 +464,30 @@ Common::String OSystem_SDL::getSystemLanguage() const {
#endif // USE_DETECTLANG
}
+bool OSystem_SDL::hasTextInClipboard() {
+#if SDL_VERSION_ATLEAST(2, 0, 0)
+ return SDL_HasClipboardText() == SDL_TRUE;
+#else
+ return false;
+#endif
+}
+
+Common::String OSystem_SDL::getTextFromClipboard() {
+ if (!hasTextInClipboard()) return "";
+
+#if SDL_VERSION_ATLEAST(2, 0, 0)
+ char *text = SDL_GetClipboardText();
+ Common::String strText = text;
+ SDL_free(text);
+
+ // FIXME: The string returned by SDL is in UTF-8, it is not clear
+ // what encoding should be used for the returned string.
+ return strText;
+#else
+ return "";
+#endif
+}
+
uint32 OSystem_SDL::getMillis(bool skipRecord) {
uint32 millis = SDL_GetTicks();
@@ -491,6 +540,23 @@ Common::TimerManager *OSystem_SDL::getTimerManager() {
#endif
}
+AudioCDManager *OSystem_SDL::createAudioCDManager() {
+ // Audio CD support was removed with SDL 2.0
+#if SDL_VERSION_ATLEAST(2, 0, 0)
+ return new DefaultAudioCDManager();
+#else
+ return new SdlAudioCDManager();
+#endif
+}
+
+Common::SaveFileManager *OSystem_SDL::getSavefileManager() {
+#ifdef ENABLE_EVENTRECORDER
+ return g_eventRec.getSaveManager(_savefileManager);
+#else
+ return _savefileManager;
+#endif
+}
+
#ifdef USE_OPENGL
const OSystem::GraphicsMode *OSystem_SDL::getSupportedGraphicsModes() const {
diff --git a/backends/platform/sdl/sdl.h b/backends/platform/sdl/sdl.h
index 5ee56d0568..17b4e9b001 100644
--- a/backends/platform/sdl/sdl.h
+++ b/backends/platform/sdl/sdl.h
@@ -55,6 +55,8 @@ public:
*/
virtual SdlMixerManager *getMixerManager();
+ virtual bool hasFeature(Feature f);
+
// Override functions from ModularBackend and OSystem
virtual void initBackend();
#if defined(USE_TASKBAR)
@@ -69,6 +71,10 @@ public:
virtual Common::String getSystemLanguage() const;
+ // Clipboard
+ virtual bool hasTextInClipboard();
+ virtual Common::String getTextFromClipboard();
+
virtual void setWindowCaption(const char *caption);
virtual void addSysArchivesToSearchSet(Common::SearchSet &s, int priority = 0);
virtual uint32 getMillis(bool skipRecord = false);
@@ -76,10 +82,14 @@ public:
virtual void getTimeAndDate(TimeDate &td) const;
virtual Audio::Mixer *getMixer();
virtual Common::TimerManager *getTimerManager();
+ virtual Common::SaveFileManager *getSavefileManager();
protected:
bool _inited;
bool _initedSDL;
+#ifdef USE_SDL_NET
+ bool _initedSDLnet;
+#endif
/**
* Mixer manager that configures and setups SDL for
@@ -104,6 +114,11 @@ protected:
*/
virtual void initSDL();
+ /**
+ * Create the audio CD manager
+ */
+ virtual AudioCDManager *createAudioCDManager();
+
// Logging
virtual Common::WriteStream *createLogFile() { return 0; }
Backends::Log::Log *_logger;
diff --git a/backends/platform/sdl/win32/win32.cpp b/backends/platform/sdl/win32/win32.cpp
index 0f70c00b40..99c71a49e0 100644
--- a/backends/platform/sdl/win32/win32.cpp
+++ b/backends/platform/sdl/win32/win32.cpp
@@ -35,11 +35,13 @@
#include "common/error.h"
#include "common/textconsole.h"
+#include "backends/audiocd/win32/win32-audiocd.h"
#include "backends/platform/sdl/win32/win32.h"
#include "backends/platform/sdl/win32/win32-window.h"
#include "backends/saves/windows/windows-saves.h"
#include "backends/fs/windows/windows-fs-factory.h"
#include "backends/taskbar/win32/win32-taskbar.h"
+#include "backends/updates/win32/win32-updates.h"
#include "common/memstream.h"
@@ -81,13 +83,18 @@ void OSystem_Win32::initBackend() {
if (_savefileManager == 0)
_savefileManager = new WindowsSaveFileManager();
+#if defined(USE_SPARKLE)
+ // Initialize updates manager
+ _updateManager = new Win32UpdateManager();
+#endif
+
// Invoke parent implementation of this method
OSystem_SDL::initBackend();
}
bool OSystem_Win32::hasFeature(Feature f) {
- if (f == kFeatureDisplayLogFile)
+ if (f == kFeatureDisplayLogFile || f == kFeatureOpenUrl)
return true;
return OSystem_SDL::hasFeature(f);
@@ -128,6 +135,16 @@ bool OSystem_Win32::displayLogFile() {
return false;
}
+bool OSystem_Win32::openUrl(const Common::String &url) {
+ const uint64 result = (uint64)ShellExecute(0, 0, /*(wchar_t*)nativeFilePath.utf16()*/url.c_str(), 0, 0, SW_SHOWNORMAL);
+ // ShellExecute returns a value greater than 32 if successful
+ if (result <= 32) {
+ warning("ShellExecute failed: error = %u", result);
+ return false;
+ }
+ return true;
+}
+
Common::String OSystem_Win32::getDefaultConfigFileName() {
char configFile[MAXPATHLEN];
@@ -318,4 +335,8 @@ void OSystem_Win32::addSysArchivesToSearchSet(Common::SearchSet &s, int priority
OSystem_SDL::addSysArchivesToSearchSet(s, priority);
}
+AudioCDManager *OSystem_Win32::createAudioCDManager() {
+ return createWin32AudioCDManager();
+}
+
#endif
diff --git a/backends/platform/sdl/win32/win32.h b/backends/platform/sdl/win32/win32.h
index 473e78ff0b..636ebae88f 100644
--- a/backends/platform/sdl/win32/win32.h
+++ b/backends/platform/sdl/win32/win32.h
@@ -36,6 +36,8 @@ public:
virtual bool displayLogFile();
+ virtual bool openUrl(const Common::String &url);
+
protected:
/**
* The path of the currently open log file, if any.
@@ -49,6 +51,10 @@ protected:
virtual Common::String getDefaultConfigFileName();
virtual Common::WriteStream *createLogFile();
+
+ // Override createAudioCDManager() to get our Mac-specific
+ // version.
+ virtual AudioCDManager *createAudioCDManager();
};
#endif
diff --git a/backends/platform/symbian/S60/scummvm-CVS-SymbianS60v1.pkg b/backends/platform/symbian/S60/scummvm-CVS-SymbianS60v1.pkg
index da69d455d7..6ec03557be 100644
--- a/backends/platform/symbian/S60/scummvm-CVS-SymbianS60v1.pkg
+++ b/backends/platform/symbian/S60/scummvm-CVS-SymbianS60v1.pkg
@@ -8,12 +8,12 @@
; 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.
diff --git a/backends/platform/symbian/S60/scummvm-CVS-SymbianS60v2.pkg b/backends/platform/symbian/S60/scummvm-CVS-SymbianS60v2.pkg
index 0d22c9d016..fddf772b7f 100644
--- a/backends/platform/symbian/S60/scummvm-CVS-SymbianS60v2.pkg
+++ b/backends/platform/symbian/S60/scummvm-CVS-SymbianS60v2.pkg
@@ -8,12 +8,12 @@
; 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.
diff --git a/backends/platform/symbian/S60v3/scummvm-CVS-SymbianS60v3.pkg b/backends/platform/symbian/S60v3/scummvm-CVS-SymbianS60v3.pkg
index 4c83b32805..30d2aa3db6 100644
--- a/backends/platform/symbian/S60v3/scummvm-CVS-SymbianS60v3.pkg
+++ b/backends/platform/symbian/S60v3/scummvm-CVS-SymbianS60v3.pkg
@@ -7,12 +7,12 @@
; 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.
diff --git a/backends/platform/symbian/S60v3/scummvm-CVS-SymbianS60v3_split.pkg b/backends/platform/symbian/S60v3/scummvm-CVS-SymbianS60v3_split.pkg
index 3d55584d28..8c953d30ea 100644
--- a/backends/platform/symbian/S60v3/scummvm-CVS-SymbianS60v3_split.pkg
+++ b/backends/platform/symbian/S60v3/scummvm-CVS-SymbianS60v3_split.pkg
@@ -7,19 +7,16 @@
; 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$
-;
;
;;;
diff --git a/backends/platform/symbian/S80/scummvm-CVS-SymbianS80.pkg b/backends/platform/symbian/S80/scummvm-CVS-SymbianS80.pkg
index c3563b4041..cfff4be7c5 100644
--- a/backends/platform/symbian/S80/scummvm-CVS-SymbianS80.pkg
+++ b/backends/platform/symbian/S80/scummvm-CVS-SymbianS80.pkg
@@ -8,12 +8,12 @@
; 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.
diff --git a/backends/platform/symbian/S90/scummvm-CVS-SymbianS90.pkg b/backends/platform/symbian/S90/scummvm-CVS-SymbianS90.pkg
index 457f41998b..9057eb66a5 100644
--- a/backends/platform/symbian/S90/scummvm-CVS-SymbianS90.pkg
+++ b/backends/platform/symbian/S90/scummvm-CVS-SymbianS90.pkg
@@ -8,12 +8,12 @@
; 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.
diff --git a/backends/platform/symbian/UIQ2/scummvm-CVS-SymbianUIQ2.pkg b/backends/platform/symbian/UIQ2/scummvm-CVS-SymbianUIQ2.pkg
index e2b8a85162..26038f4875 100644
--- a/backends/platform/symbian/UIQ2/scummvm-CVS-SymbianUIQ2.pkg
+++ b/backends/platform/symbian/UIQ2/scummvm-CVS-SymbianUIQ2.pkg
@@ -8,12 +8,12 @@
; 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.
diff --git a/backends/platform/symbian/UIQ2/scummvm-CVS-SymbianUIQ2_SE.pkg b/backends/platform/symbian/UIQ2/scummvm-CVS-SymbianUIQ2_SE.pkg
index 8284f64611..7d1e2bc249 100644
--- a/backends/platform/symbian/UIQ2/scummvm-CVS-SymbianUIQ2_SE.pkg
+++ b/backends/platform/symbian/UIQ2/scummvm-CVS-SymbianUIQ2_SE.pkg
@@ -8,12 +8,12 @@
; 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.
diff --git a/backends/platform/symbian/UIQ3/scummvm-CVS-SymbianUIQ3.pkg b/backends/platform/symbian/UIQ3/scummvm-CVS-SymbianUIQ3.pkg
index 8ac6f97d9f..adb869f078 100644
--- a/backends/platform/symbian/UIQ3/scummvm-CVS-SymbianUIQ3.pkg
+++ b/backends/platform/symbian/UIQ3/scummvm-CVS-SymbianUIQ3.pkg
@@ -8,12 +8,12 @@
; 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.
diff --git a/backends/platform/symbian/UIQ3/scummvm-CVS-SymbianUIQ3_split.pkg b/backends/platform/symbian/UIQ3/scummvm-CVS-SymbianUIQ3_split.pkg
index 4c46be50a1..528e39adee 100644
--- a/backends/platform/symbian/UIQ3/scummvm-CVS-SymbianUIQ3_split.pkg
+++ b/backends/platform/symbian/UIQ3/scummvm-CVS-SymbianUIQ3_split.pkg
@@ -8,12 +8,12 @@
; 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.
diff --git a/backends/platform/symbian/src/portdefs.h b/backends/platform/symbian/src/portdefs.h
index f9da09d3eb..e2465e4767 100644
--- a/backends/platform/symbian/src/portdefs.h
+++ b/backends/platform/symbian/src/portdefs.h
@@ -65,7 +65,8 @@ typedef signed long int int32;
#undef remove
#endif
-#define SMALL_SCREEN_DEVICE
+#define GUI_ONLY_FULLSCREEN
+#define GUI_ENABLE_KEYSDIALOG
#define DISABLE_COMMAND_LINE
#define USE_RGB_COLOR
diff --git a/backends/platform/tizen/form.cpp b/backends/platform/tizen/form.cpp
index 568829dc96..2a9a3967cc 100644
--- a/backends/platform/tizen/form.cpp
+++ b/backends/platform/tizen/form.cpp
@@ -318,16 +318,16 @@ void TizenAppForm::invokeShortcut() {
case kControlMouse:
setButtonShortcut();
break;
-
+
case kEscapeKey:
pushKey(Common::KEYCODE_ESCAPE);
break;
-
+
case kGameMenu:
_buttonState = kLeftButton;
pushKey(Common::KEYCODE_F5);
break;
-
+
case kShowKeypad:
showKeypad();
break;
@@ -338,7 +338,7 @@ void TizenAppForm::showKeypad() {
// display the soft keyboard
if (_state == kActiveState) {
_buttonState = kLeftButton;
-
+
Common::Event e;
e.type = Common::EVENT_VIRTUAL_KEYBOARD;
if (_eventQueueLock) {
diff --git a/backends/platform/tizen/graphics.cpp b/backends/platform/tizen/graphics.cpp
index 759c4e519d..85dbbd2c08 100644
--- a/backends/platform/tizen/graphics.cpp
+++ b/backends/platform/tizen/graphics.cpp
@@ -56,6 +56,7 @@ result TizenGraphicsManager::Construct() {
loadEgl();
// Notify the OpenGL code about our context.
+ setContextType(OpenGL::kContextGLES);
// We default to RGB565 and RGBA5551 which is closest to the actual output
// mode we setup.
@@ -102,7 +103,7 @@ Common::List<Graphics::PixelFormat> TizenGraphicsManager::getSupportedFormats()
}
bool TizenGraphicsManager::hasFeature(OSystem::Feature f) {
- bool result =
+ bool result =
(f == OSystem::kFeatureVirtualKeyboard ||
OpenGLGraphicsManager::hasFeature(f));
return result;
@@ -206,3 +207,7 @@ bool TizenGraphicsManager::loadVideoMode(uint requestedWidth, uint requestedHeig
void TizenGraphicsManager::refreshScreen() {
eglSwapBuffers(_eglDisplay, _eglSurface);
}
+
+void *TizenGraphicsManager::getProcAddress(const char *name) const {
+ return eglGetProcAddress(name);
+}
diff --git a/backends/platform/tizen/graphics.h b/backends/platform/tizen/graphics.h
index 1522d66bbe..1798b078d8 100644
--- a/backends/platform/tizen/graphics.h
+++ b/backends/platform/tizen/graphics.h
@@ -63,6 +63,8 @@ protected:
void refreshScreen();
+ void *getProcAddress(const char *name) const;
+
const Graphics::Font *getFontOSD();
private:
diff --git a/backends/platform/tizen/system.cpp b/backends/platform/tizen/system.cpp
index a235456670..1820a28791 100644
--- a/backends/platform/tizen/system.cpp
+++ b/backends/platform/tizen/system.cpp
@@ -81,36 +81,41 @@ struct TizenSaveFileManager : public DefaultSaveFileManager {
};
bool TizenSaveFileManager::removeSavefile(const Common::String &filename) {
- Common::String savePathName = getSavePath();
+ // Assure the savefile name cache is up-to-date.
+ assureCached(getSavePath());
+ if (getError().getCode() != Common::kNoError)
+ return false;
- checkPath(Common::FSNode(savePathName));
- if (getError().getCode() != Common::kNoError) {
+ // Obtain node if exists.
+ SaveFileCache::const_iterator file = _saveFileCache.find(filename);
+ if (file == _saveFileCache.end()) {
return false;
- }
+ } else {
+ const Common::FSNode fileNode = file->_value;
+ // Remove from cache, this invalidates the 'file' iterator.
+ _saveFileCache.erase(file);
+ file = _saveFileCache.end();
- // recreate FSNode since checkPath may have changed/created the directory
- Common::FSNode savePath(savePathName);
- Common::FSNode file = savePath.getChild(filename);
+ String unicodeFileName;
+ StringUtil::Utf8ToString(fileNode.getPath().c_str(), unicodeFileName);
- String unicodeFileName;
- StringUtil::Utf8ToString(file.getPath().c_str(), unicodeFileName);
+ switch (Tizen::Io::File::Remove(unicodeFileName)) {
+ case E_SUCCESS:
+ return true;
- switch (Tizen::Io::File::Remove(unicodeFileName)) {
- case E_SUCCESS:
- return true;
+ case E_ILLEGAL_ACCESS:
+ setError(Common::kWritePermissionDenied, "Search or write permission denied: " +
+ file.getName());
+ break;
- case E_ILLEGAL_ACCESS:
- setError(Common::kWritePermissionDenied, "Search or write permission denied: " +
- file.getName());
- break;
+ default:
+ setError(Common::kPathDoesNotExist, "removeSavefile: '" + file.getName() +
+ "' does not exist or path is invalid");
+ break;
+ }
- default:
- setError(Common::kPathDoesNotExist, "removeSavefile: '" + file.getName() +
- "' does not exist or path is invalid");
- break;
+ return false;
}
-
- return false;
}
//
diff --git a/backends/platform/wince/portdefs.h b/backends/platform/wince/portdefs.h
index 3304ee0893..c74fc39169 100644
--- a/backends/platform/wince/portdefs.h
+++ b/backends/platform/wince/portdefs.h
@@ -30,7 +30,8 @@
// Missing string/stdlib/assert declarations for WinCE 2.xx
#if _WIN32_WCE < 300
- #define SMALL_SCREEN_DEVICE
+ #define GUI_ONLY_FULLSCREEN
+ #define GUI_ENABLE_KEYSDIALOG
void *calloc(size_t n, size_t s);
int isalnum(int c);