Skip to content

Commit

Permalink
Switch: Switch version working
Browse files Browse the repository at this point in the history
  • Loading branch information
rsn8887 committed Feb 1, 2019
1 parent 649b9ae commit dbe9d07
Show file tree
Hide file tree
Showing 46 changed files with 1,321 additions and 85 deletions.
194 changes: 171 additions & 23 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,33 +1,57 @@
cmake_minimum_required(VERSION 3.0)
#set(CMAKE_VERBOSE_MAKEFILE ON)

set(VERSION_MAJOR 1)
set(VERSION_MINOR 12)

if(BUILD_PSP2)
if (NOT DEFINED CMAKE_TOOLCHAIN_FILE)
if (DEFINED ENV{VITASDK})
set(CMAKE_TOOLCHAIN_FILE "$ENV{VITASDK}/share/vita.toolchain.cmake" CACHE PATH "toolchain file")
else ()
message(FATAL_ERROR "Please define VITASDK to point to your SDK path!")
endif ()
endif ()

execute_process(COMMAND "date" "+%Y.%m.%d"
OUTPUT_VARIABLE BUILD_DATE OUTPUT_STRIP_TRAILING_WHITESPACE)

if(CMAKE_BUILD_TYPE STREQUAL "Debug")
set(BUILD_DEBUG true CACHE BOOL "Build with psp2shell support")
endif()
endif(BUILD_PSP2)

if(BUILD_NX)
set(CMAKE_SYSTEM_NAME "Generic")
set(DEVKITPRO $ENV{DEVKITPRO})
set(CMAKE_SYSTEM_PROCESSOR "armv8-a")
set(CMAKE_C_COMPILER "${DEVKITPRO}/devkitA64/bin/aarch64-none-elf-gcc")
set(CMAKE_CXX_COMPILER "${DEVKITPRO}/devkitA64/bin/aarch64-none-elf-g++")
set(CMAKE_ASM_COMPILER "${DEVKITPRO}/devkitA64/bin/aarch64-none-elf-as")
set(CMAKE_AR "${DEVKITPRO}/devkitA64/bin/aarch64-none-elf-gcc-ar" CACHE STRING "")
set(CMAKE_RANLIB "${DEVKITPRO}/devkitA64/bin/aarch64-none-elf-gcc-ranlib" CACHE STRING "")
set(CMAKE_FIND_ROOT_PATH ${DEVKITPRO} ${DEVKITPRO}/devkitA64 ${DEVKITPRO}/libnx ${DEVKITPRO}/portlibs/switch)
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
set(BUILD_SHARED_LIBS OFF CACHE INTERNAL "Shared libs not available")
link_directories(${DEVKITPRO}/libnx/lib ${DEVKITPRO}/portlibs/switch/lib)
endif(BUILD_NX)

execute_process(COMMAND "date" "+%Y.%m.%d"
OUTPUT_VARIABLE BUILD_DATE OUTPUT_STRIP_TRAILING_WHITESPACE)

enable_language(ASM)

project(enigma)
include("${VITASDK}/share/vita.cmake" REQUIRED)

if(BUILD_PSP2)
enable_language(ASM)

include("${VITASDK}/share/vita.cmake" REQUIRED)
endif(BUILD_PSP2)

set(TITLEID "ENIGMA000")

set(SRC_FILES
src/psp2/psp2-dirent.c
src/psp2/psp2_touch.c
src/psp2/psp2_input.c
src/psp2/psp2_kbdvita.c
src/AttributeDescriptor.cc
src/DOMErrorReporter.cc
src/DOMSchemaResolver.cc
Expand Down Expand Up @@ -68,9 +92,6 @@ set(SRC_FILES
src/lua-global.cc
src/lua.cc
src/main.cc
src/net_enet.cc
src/netgame.cc
src/network.cc
src/nls.cc
src/options.cc
src/ox_extra.cc
Expand Down Expand Up @@ -226,13 +247,6 @@ set(SRC_FILES
src/lev/ScoreManager.cc
src/lev/SubProxy.cc
src/lev/VolatileIndex.cc
lib-src/vita-enet/callbacks.c
lib-src/vita-enet/host.c
lib-src/vita-enet/list.c
lib-src/vita-enet/packet.c
lib-src/vita-enet/peer.c
lib-src/vita-enet/protocol.c
lib-src/vita-enet/vita.c
lib-src/lua/lapi.c
lib-src/lua/lauxlib.c
lib-src/lua/lbaselib.c
Expand Down Expand Up @@ -311,20 +325,17 @@ set(SRC_FILES
)

include_directories(
${VITASDK}/arm-vita-eabi/include/
${VITASDK}/arm-vita-eabi/include/SDL
${VITASDK}/arm-vita-eabi/include/xercesc
include
src
src/psp2
src/switch
src/actors
src/floors
src/stones
src/gui
src/items
src/lev
lib-src
lib-src/vita-enet/include
lib-src/lua
lib-src/zipios++
lib-src/zipios++/zipios++
Expand All @@ -333,6 +344,31 @@ include_directories(
lib-src/oxydlib
)

if(BUILD_PSP2)
set(PSP2_SRC_FILES
src/psp2/psp2-dirent.c
src/psp2/psp2_touch.c
src/psp2/psp2_kbdvita.c
src/net_enet.cc
src/netgame.cc
src/network.cc
lib-src/vita-enet/callbacks.c
lib-src/vita-enet/host.c
lib-src/vita-enet/list.c
lib-src/vita-enet/packet.c
lib-src/vita-enet/peer.c
lib-src/vita-enet/protocol.c
lib-src/vita-enet/vita.c
)
set(SRC_FILES ${PSP2_SRC_FILES} ${SRC_FILES})

include_directories(
${VITASDK}/arm-vita-eabi/include/
${VITASDK}/arm-vita-eabi/include/SDL
${VITASDK}/arm-vita-eabi/include/xercesc
lib-src/vita-enet/include
)

set(FLAGS
-std=c++11
-std=c11
Expand Down Expand Up @@ -408,4 +444,116 @@ add_custom_target(${PROJECT_NAME}.vpk
COMMAND cp -r ${CMAKE_SOURCE_DIR}/psp2data/* vpk
# COMMAND cp -r ${CMAKE_SOURCE_DIR}/data vpk/data
COMMAND cd vpk && zip -r ../enigma.vpk . && cd ..
)
)
endif(BUILD_PSP2)

if(BUILD_NX)
set(NX_SRC_FILES
src/switch/switch_touch.c
src/switch/switch_kbd.c
src/switch/sdl2_to_sdl1.cpp
)
set(SRC_FILES ${NX_SRC_FILES} ${SRC_FILES})

include_directories(
${DEVKITPRO}/portlibs/switch/include/SDL2
${DEVKITPRO}/libnx/include
${DEVKITPRO}/portlibs/switch/include
)

add_definitions(
-D__SWITCH__
-DUSE_SDL2
-DSYSTEM_DATA_DIR="/switch/enigma/data"
-DDOCDIR="/switch/enigma/doc"
-DLOCALEDIR="/switch/enigma/locale"
# -DCXXLUA
-DHAVE_STDINT_H
-DHAVE_STDLIB_H
-DHAVE_STRING_H
-DHAVE_LIBXERCES_C
-DHAVE_LIBSDL_TTF
-DHAVE_DIRENT_H
-DHAVE_SYS_TYPES_H
-DPACKAGE="enigma"
-DHAS_SOCKLEN_T
-DPACKAGE_NAME="enigma"
-DPACKAGE_STRING="enigma 1.21"
-DPACKAGE_TARNAME="enigma"
-DPACKAGE_URL=""
-DPACKAGE_VERSION="1.21"
)

set(FLAGS
-Wno-write-strings
-march=armv8-a
-mtune=cortex-a57
-mtp=soft
#-fPIE is neccessary to prevent crash on startup
-fPIE
-O3
-ffast-math
-fno-asynchronous-unwind-tables
-funroll-loops
-fno-unwind-tables
-fno-optimize-sibling-calls
-funsafe-math-optimizations
-mlittle-endian
-ffunction-sections
)

set(LIBS
SDL2_image
SDL2_ttf
SDL2_mixer
SDL2
EGL
GLESv2
glapi
drm_nouveau
stdc++
xerces-c
curl
png
jpeg
z
m
c
vorbisidec
ogg
modplug
mpg123
freetype
ssl
crypto
bz2
nx
)

foreach(flag ${FLAGS})
set(FLAGS_GENERAL "${FLAGS_GENERAL} ${flag}")
endforeach(flag ${FLAGS})

#set(CMAKE_C_FLAGS "${FLAGS_GENERAL}" CACHE STRING "C Flags" FORCE)
#set(CMAKE_CXX_FLAGS "${FLAGS_GENERAL}" CACHE STRING "C++ Flags" FORCE)

set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${FLAGS_GENERAL} -specs=${DEVKITPRO}/libnx/switch.specs --verbose")

add_executable(${PROJECT_NAME}.elf ${SRC_FILES})
target_compile_options(${PROJECT_NAME}.elf PRIVATE ${FLAGS})
target_link_libraries(${PROJECT_NAME}.elf PRIVATE ${LIBS})
add_custom_target(${PROJECT_NAME}.nro
DEPENDS ${PROJECT_NAME}.elf
COMMAND ${DEVKITPRO}/tools/bin/nacptool --create "${PROJECT_NAME}" "rsn8887" "${VERSION_MAJOR}.${VERSION_MINOR}" ${PROJECT_NAME}.nacp
COMMAND ${DEVKITPRO}/tools/bin/elf2nro ${PROJECT_NAME}.elf ${PROJECT_NAME}.nro --icon=${CMAKE_SOURCE_DIR}/switchdata/icon0.jpg --nacp=${PROJECT_NAME}.nacp
)
add_custom_target(${PROJECT_NAME}_switch.zip
DEPENDS ${PROJECT_NAME}.nro
COMMAND rm -rf ${CMAKE_BINARY_DIR}/release/${PROJECT_NAME}
COMMAND mkdir -p ${CMAKE_BINARY_DIR}/release/${PROJECT_NAME}
COMMAND cp -f ${CMAKE_BINARY_DIR}/${PROJECT_NAME}.nro ${CMAKE_BINARY_DIR}/release/${PROJECT_NAME}/${PROJECT_NAME}.nro
COMMAND unzip ${CMAKE_SOURCE_DIR}/switchdata/data.zip -d${CMAKE_BINARY_DIR}/release/
COMMAND cd ${CMAKE_BINARY_DIR}/release && zip -r ../${PROJECT_NAME}_${VERSION_MAJOR}.${VERSION_MINOR}_switch.zip ${PROJECT_NAME} && cd ${CMAKE_BINARY_DIR}
)
endif(BUILD_NX)

61 changes: 45 additions & 16 deletions README.MD
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Overview
=====
This is my Vita port of Enigma, a skill/puzzle game inspired by Oxyd on the Atari ST and Rock'n'Roll on the Amiga.
This is my Vita and Switch port of Enigma, a skill/puzzle game inspired by Oxyd on the Atari ST and Rock'n'Roll on the Amiga.

![](screenshots/enigma_vita_4.jpg)

Expand All @@ -13,7 +13,7 @@ http://www.nongnu.org/enigma/index.html

Thanks
======
Thanks to my supporters on Patreon: Andyways, CountDuckula, and Sean Ritzo.
Thanks to my supporters on Patreon: Andyways, CountDuckula, Greg Gibson, Jesse Harlin, Özgür Karter, Matthew Machnee, and RadicalR.

Thanks to @usineur for his libkbd-vita code for easy use of touch keyboard text entry.

Expand All @@ -27,45 +27,50 @@ Special thanks to Meinolf Schneider / Amekudzi for the original Oxyd games on At

Installation Instructions
=====
Vita:
- Install the .vpk
- Extract the contents of data.zip into ux0:data/

NOTE: I recommend using FTP transfer to copy the files over (~10,000 small files in data.zip). There is one report (thanks @ji11x38) that using the Vitashell "SELECT Button: USB" option to copy files directly from a MacOS computer to the Vita via USB caused the files to not transfer correctly, causing Enigma to crash on startup.

Vita-exclusive features
Switch:
- Extract the contents of Enigma_Switch.zip into the `switch` folder on your SD card, so that you have a folder `switch/enigma` with `enigma.nro` and more folders and files inside.

Vita/Switch-exclusive features
=====
- game controller support: analog joystick mouse controls and button mappings
- front and rear touch controls with left/right mouse click gestures
- complete level packages with >3,000 levels and pre-calculated preview screenshots
- Bluetooth keyboard and mouse combo support (Vita supports only a limited number of BT devices, tested working with Jelly Bean BT keyboard and mouse combo ASIN:B06Y56BBYP and with the standalone Jelly Comb Bluetooth Wireless Mouse ASIN:B075HBDWCF)
- Bluetooth/USB keyboard and mouse support. The Vita supports only a limited number of BT devices, tested working with Jelly Bean BT keyboard and mouse combo ASIN:B06Y56BBYP and with the standalone Jelly Comb Bluetooth Wireless Mouse ASIN:B075HBDWCF. The Switch supports only a limited number of USB mice. Tested working with Logitech M187.

Vita Controls (controls updated with version 1.08)
Controls (controls updated with version 1.08)
=====
Left analog stick = analog control of the marble and mouse pointer
Square / L-trigger = select menu items, use object in game (left mouse button)
Triangle / R-trigger = cycle through inventory items (right mouse button)
Cross = ok in menu (return)
Circle = back / in-game menu (escape key)
Start = help screen (F1)
Select = destroy marble and remove one life (F3)
R-trigger + Select = restart level (shift-F3)
Square / Y / L-trigger = select menu items, use object in game (left mouse button)
Triangle / X / R-trigger = cycle through inventory items (right mouse button)
Cross / A = ok in menu (return)
Circle / B = back / in-game menu (escape key)
Start / Plus = help screen (F1)
Select / Minus = destroy marble and remove one life (F3)
R-trigger + Select / R-trigger + Minus = restart level (shift-F3)

Dpad in menu = quick-select menu items (arrow keys)
Dpad left/right in game = quick-change mouse speed
Dpad up/down in game = cycle through previous messages

Front touch = analog control of the marble and mouse pointer
Rear touch = analog control of the marble and mouse pointer
Rear touch = analog control of the marble and mouse pointer (Vita only)
Single finger tap = select menu items, use object in game (left mouse button)
Dual finger tap = cycle through inventory items (right mouse button)

Dual finger tap works by holding one finger down and quickly tapping with a second finger somewhere else.

Mouse sensitivity can be adjusted in options or in-game via dpad left/right. The setting affects analog joystick, touch, and real bluetooth mice.
Mouse sensitivity can be adjusted in options or in-game via dpad left/right. The setting affects analog joystick, touch, and real bluetooth/USB mice.

Build Instructions
=====
Enigma needs xerces-c and inet. To prepare compilation:
Vita:
On Vita, Enigma needs xerces-c and inet. To prepare compilation:

- with a text-editor, load the file $VITASDK/arm-vita-eabi/include/netinet/in.h. Inside the file, replace "struct" with "inline struct" on line 45 and 49.
- download or clone my xerces-c repo from [here](https://www.github.com/rsn8887/xerces-c) into a folder called xerces
Expand All @@ -89,12 +94,36 @@ $VITASDK/arm-vita-eabi/include/xercesc/
````
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Release ../Enigma
cmake ../Enigma/ -DBUILD_PSP2=ON -DCMAKE_BUILD_TYPE=Release
make enigma.vpk -j10
````

Switch:
On Switch, Enigma needs xerces-c. To prepare compilation:

- download or clone my xerces-c Switch branch from [here](https://www.github.com/rsn8887/xerces-c1) into a folder called xerces (use `git checkout switch` to make sure you are on the switch branch)
````
cmake -DCMAKE_TOOLCHAIN_FILE=../xerces-c-1/switch.toolchain.cmake -Dtranscoder=iconv -Dmutex-manager=nothreads -Dnetwork=OFF -Dsse2=OFF -Dthreads=OFF -DBUILD_SHARED_LIBS=OFF -Dxmlch-type=uint16_t -DULONG_MAX=4294967295 ../xerces-c-1/
cmake -DCMAKE_TOOLCHAIN_FILE=../xerces-c-1/switch.toolchain.cmake -Dtranscoder=iconv -Dmutex-manager=nothreads -Dnetwork=OFF -Dsse2=OFF -Dthreads=OFF -DBUILD_SHARED_LIBS=OFF -Dxmlch-type=uint16_t -DULONG_MAX=4294967295 ../xerces-c-1/
cmake -DCMAKE_TOOLCHAIN_FILE=../xerces-c-1/switch.toolchain.cmake -Dtranscoder=iconv -Dmutex-manager=nothreads -Dnetwork=OFF -Dsse2=OFF -Dthreads=OFF -DBUILD_SHARED_LIBS=OFF -Dxmlch-type=uint16_t -DULONG_MAX=4294967295 ../xerces-c-1/
make -j10
sudo -E make install
````
- Clone the Enigma repo into a folder called Enigma and compile
````
mkdir build
cd build
cmake ../Enigma/ -DBUILD_NX=ON -DCMAKE_BUILD_TYPE=Release
make enigma_switch.zip -j10
````

Changelog
=====
1.12 (Switch only)

- Add Switch version

1.11

- Improve response to diagonal stick directions
Expand Down
Loading

0 comments on commit dbe9d07

Please sign in to comment.