Skip to content

Commit

Permalink
Merge pull request #745 from Cruel/3ds
Browse files Browse the repository at this point in the history
3DS: New Backend
  • Loading branch information
sev- committed May 16, 2016
2 parents 9178fba + 1531b4d commit 2cd0a99
Show file tree
Hide file tree
Showing 28 changed files with 2,617 additions and 13 deletions.
3 changes: 3 additions & 0 deletions AUTHORS
Expand Up @@ -302,6 +302,9 @@ ScummVM Team
Frantisek Dufka - (retired)
Tarek Soliman

Nintendo 3DS:
Thomas Edvalson

Nintendo 64:
Fabio Battaglia

Expand Down
64 changes: 64 additions & 0 deletions 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)))
185 changes: 185 additions & 0 deletions 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.
Binary file added backends/platform/3ds/app/banner.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added backends/platform/3ds/app/banner.wav
Binary file not shown.
Binary file added backends/platform/3ds/app/icon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 2cd0a99

Please sign in to comment.