Skip to content

Commit

Permalink
Switch: add switch port
Browse files Browse the repository at this point in the history
  • Loading branch information
rsn8887 committed Oct 27, 2018
1 parent 8ef2b1e commit c811834
Show file tree
Hide file tree
Showing 12 changed files with 503 additions and 47 deletions.
71 changes: 54 additions & 17 deletions README.MD
@@ -1,12 +1,12 @@
Overview
=====
This is my Vita port of Cannonball, an enhanced Outrun engine by djyt.
This is my Vita and Switch port of Cannonball, an enhanced Outrun engine by djyt.

Thanks djyt for writing such a great program and making sure it is easily portable.

Thanks to ScHlAuChi for testing.

Thanks to my Patreon supporters: Andyways, CountDuckula, and Sean Ritzo.
Thanks to my Patreon supporters: Andyways, CountDuckula, Matthew Machnee and Sean Ritzo.

NOTE: Arcade roms for Outrun Version B are required to run this engine. The roms are NOT included in the download (see installation instructions).

Expand All @@ -15,34 +15,58 @@ NOTE: Arcade roms for Outrun Version B are required to run this engine. The roms
A detailed Manual and FAQ are here:
https://github.com/djyt/cannonball/wiki

Notes about Vita version
Switch Installation Instructions
=====
- Default difficulty is set to easy, but can be changed to normal or hard in the menu.
- The game runs at full speed with almost constant 60 fps. The exception is some slowdown at the beginning of the race. That slowdown can also be eliminated by turning of widescreen mode in the menu, but then the picture is a bit smaller. The high-resolution hack should not be enabled, it causes too much slow-down.
Arcade roms from Outrun version B are required to run this homebrew, they are not included.

- Extract the contents of cannonball_switch.zip into the folder `switch/` on your sdcard. You should have a folder `switch/Cannonball_Switch/`.
- Obtain the arcade roms for Outrun Version B and extract them into `switch/Cannonball_Switch/roms`
- Launch the .nro file using your favorite homebrew launcher, enjoy Outrun in almost perfect 60 fps.
- This version of Cannonball is called "Cannonball_Switch" to distinguish it from Lantus' port

Switch Controls
=====
Note: Buttons can be re-mapped in menu

Minus = insert coin
Plus = start
Y = gas / OK in menu
B = brake
X = change gears
L = change in-game camera
R = menu
Dpad = menu navigation and digital steering wheel controls
Left stick = analog steering wheel if analog is set to ON or WHEEL ONLY, otherwise this is digital.
Right stick = analog gas/brake if analog is set to ON

Vita Installation Instructions
=====
Arcade roms from Outrun version B are required to run this homebrew, they are not included.

- Install the .vpk
- Extract the contents of data.zip into ux0:data/ (it is just two folders and an info file for roms)
- Obtain the arcade roms for Outrun Version B and extract them into ux0:data/cannonball/roms
- Launch the bubble, enjoy Outrun in almost perfect 60 fps.

Vita Controls
=====
Note: Buttons can be re-mapped in menu

L = insert coin
R = menu
Square = start
Triangle = gas / enter letter on hi-score screen
Circle = brake
Cross = change gears
Select = change in-game camera
R = menu
Dpad = menu navigation and digital steering wheel controls
Left stick = analog steering wheel if analog is set to ON or WHEEL ONLY, otherwise this is digital.
Right stick = analog gas/brake if analog is set to ON

Installation Instructions
Notes about Vita version
=====
Arcade roms from Outrun version B are required to run this homebrew, they are not included.

- Install the .vpk
- Extract the contents of data.zip into ux0:data/ (it is just two folders and an info file for roms)
- Obtain the arcade roms for Outrun Version B and extract them into ux0:data/cannonball/roms
- Launch the bubble, enjoy Outrun in almost perfect 60 fps.
- Default difficulty is set to easy, but can be changed to normal or hard in the menu.
- The game runs at full speed with almost constant 60 fps. The exception is some slowdown at the beginning of the race. That slowdown can also be eliminated by turning of widescreen mode in the menu, but then the picture is a bit smaller. The high-resolution hack should not be enabled, it causes too much slow-down.

Rom names
======
Expand Down Expand Up @@ -112,23 +136,36 @@ Build Instructions
=====
Cannonball needs some boost header-only libraries. To prepare compilation:
- Download and extract boost_1_66_0.zip from [here](https://dl.bintray.com/boostorg/release/1.66.0/source/boost_1_66_0.zip)
- copy the subfolder boost from that archive to $VITASDK/arm-vita-eabi/include/boost
- you should now have a file $VITASDK/arm-vita-eabi/include/boost/version.hpp and hundreds of other Boost header files.
- copy the subfolder boost from that archive to $VITASDK/arm-vita-eabi/include/boost for Vita, or to $DEVKITPRO/portlibs/switch/include/boost for Switch
- you should now have a file $VITASDK/arm-vita-eabi/include/boost/version.hpp, or $DEVKITPRO/portlibs/switch/include/boos/version.hpp and hundreds of other Boost header files.
- Now that boost is installed, proceed to compile cannonball:
````
cd cannonball
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Release ../cmake
````
and then
````
cmake -BUILD_PSP2=ON -DCMAKE_BUILD_TYPE=Release ../cmake
make Cannonball.vpk -j10
````
for Vita, or
````
cmake -BUILD_NX=ON -DCMAKE_BUILD_TYPE=Release ../cmake
make Cannonball_Switch.zip -j10
````
for Switch.

Note: The source depends on FrangarCJ's Vita2d fbo branch with shader support here: https://github.com/Cpasjuste/vita2dlib/tree/fbo
Note: The Vita source depends on FrangarCJ's Vita2d fbo branch with shader support here: https://github.com/Cpasjuste/vita2dlib/tree/fbo
and FrangarCJ's vita-shader-collection gtu branch here: https://github.com/frangarcj/vita-shader-collection/tree/gtu
Those are both included as binaries and linked automatically.

Changelog
=====
1.05switch

- added Switch release

1.05

- dpad works now if analog="off"
Expand Down
84 changes: 66 additions & 18 deletions cmake/CMakeLists.txt
@@ -1,15 +1,45 @@
cmake_minimum_required(VERSION 2.8)

#VITA
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!")
# Cannonball version
set(VERSION_MAJOR 1)
set(VERSION_MINOR 05)

if(BUILD_PSP2)
set(CMAKE_SYSTEM_NAME "Generic")
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()
endif()
set(TARGET vita)
#END VITA

set(TARGET vita)
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_C_FLAGS "-march=armv8-a -mtune=cortex-a57 -mtp=soft -fPIE -I${DEVKITPRO}/libnx/include -I${DEVKITPRO}/portlibs/switch/include" CACHE STRING "C flags")
#-ffast-math -ffunction-sections -fdata-sections
set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -fpermissive" CACHE STRING "C++ flags")
#-fno-rtti -fno-exceptions -std=gnu++11
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)

set(TARGET switch)
endif (BUILD_NX)

project (Cannonball)

Expand Down Expand Up @@ -274,9 +304,7 @@ SOURCE_GROUP(src\\cannonboard FILES ${src_cannonboard})
SOURCE_GROUP(src\\engine FILES ${src_engine})
SOURCE_GROUP(src\\engine\\audio FILES ${src_engine_audio})


#VITA
if(VITA)
if(BUILD_PSP2)
set(src_vita
"${main_cpp_base}/psp2/psp2_shader.h"

Expand Down Expand Up @@ -305,9 +333,8 @@ else()
${src_cannonboard}
${src_engine}
${src_engine_audio}
${src_vita}
)
endif(VITA)
endif(BUILD_PSP2)

# Add Icon For Windows Builds
if(WIN32)
Expand Down Expand Up @@ -350,12 +377,10 @@ configure_file(../res/tilepatch.bin ./res/tilepatch.bin
COPYONLY
)

#VITA
if(VITA)
if(BUILD_PSP2)
configure_file(../res/config_vita.xml ./config.xml
COPYONLY
)
endif()
vita_create_self(${PROJECT_NAME}.self ${PROJECT_NAME} ${UNSAFE_FLAG})
add_custom_target(${PROJECT_NAME}.vpk
DEPENDS ${PROJECT_NAME}.self
Expand All @@ -366,4 +391,27 @@ add_custom_target(${PROJECT_NAME}.vpk
COMMAND cp -r res vpk
COMMAND cd vpk && zip -r ../Cannonball.vpk . && cd ..
)
#END VITA
endif(BUILD_PSP2)

if(BUILD_NX)
configure_file(../res/config_switch.xml ./config.xml
COPYONLY
)
add_executable(${PROJECT_NAME}.elf ${SRCS})
set_target_properties(${PROJECT_NAME}.elf PROPERTIES LINK_FLAGS "-specs=${DEVKITPRO}/libnx/switch.specs")
add_custom_target(${PROJECT_NAME}_Switch.nro
DEPENDS ${PROJECT_NAME}.elf
COMMAND ${DEVKITPRO}/tools/bin/nacptool --create "${PROJECT_NAME}_Switch" "rsn8887" "${VERSION_MAJOR}.${VERSION_MINOR}" Cannonball_Switch.nacp
COMMAND ${DEVKITPRO}/tools/bin/elf2nro ${PROJECT_NAME}.elf ${PROJECT_NAME}_Switch.nro --icon=${CMAKE_SOURCE_DIR}/../switchdata/icon0.jpg --nacp=Cannonball_Switch.nacp
)
add_custom_target(${PROJECT_NAME}_Switch.zip
DEPENDS ${PROJECT_NAME}_Switch.nro
COMMAND rm -rf ${CMAKE_BINARY_DIR}/release/Cannonball_Switch
COMMAND mkdir -p ${CMAKE_BINARY_DIR}/release/Cannonball_Switch
COMMAND mkdir -p ${CMAKE_BINARY_DIR}/release/Cannonball_Switch/roms
COMMAND cp -f ${CMAKE_BINARY_DIR}/Cannonball_Switch.nro ${CMAKE_BINARY_DIR}/release/Cannonball_Switch/Cannonball_Switch.nro
COMMAND cp -r ${CMAKE_BINARY_DIR}/config.xml ${CMAKE_BINARY_DIR}/release/Cannonball_Switch/config.xml
COMMAND cp -r ${CMAKE_BINARY_DIR}/res ${CMAKE_BINARY_DIR}/release/Cannonball_Switch/res
COMMAND cd ${CMAKE_BINARY_DIR}/release && zip -r ../${PROJECT_NAME}_${VERSION_MAJOR}.${VERSION_MINOR}_Switch.zip Cannonball_Switch && cd ${CMAKE_BINARY_DIR}
)
endif(BUILD_NX)
31 changes: 31 additions & 0 deletions cmake/switch.cmake
@@ -0,0 +1,31 @@
# Switch CMake Setup.

set(sdl_root $ENV{DEVKITPRO}/portlibs/switch/include/SDL2)

include_directories(
"${sdl_root}"
)

link_libraries(
SDL2
EGL
GLESv2
glapi
drm_nouveau
nx
png
jpeg
z
m
c
)

add_definitions(-O3 -DSDL2 -D__SWITCH__)

# Location for Cannonball to create save files
# Used to auto-generate setup.hpp with various file paths
set(xml_directory ./)
set(sdl_flags "0")

# Set SDL2 instead of SDL1
set(SDL2 1)

0 comments on commit c811834

Please sign in to comment.