Skip to content

Commit

Permalink
First Vita port commit
Browse files Browse the repository at this point in the history
  • Loading branch information
rsn8887 committed Mar 3, 2018
1 parent 0c0814d commit bf411a3
Show file tree
Hide file tree
Showing 16 changed files with 255 additions and 75 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Expand Up @@ -262,3 +262,6 @@ pip-log.txt

# Mac crap
.DS_Store

# Build Dir
build
38 changes: 32 additions & 6 deletions cmake/CMakeLists.txt
@@ -1,5 +1,17 @@
cmake_minimum_required (VERSION 2.6.2)
project (cannonball)
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!")
endif()
endif()
set(TARGET vita)
#END VITA

project (Cannonball)

set(DCMAKE default.cmake)
set(CMDIR ../cmake)
Expand All @@ -14,7 +26,6 @@ set(main_cpp_base ../src/main)
if(TARGET)
set(TCMAKE ${TARGET}.cmake)
if(EXISTS ${CMDIR}/${TCMAKE})
message("CMake files for ${TARGET} found, using ${TCMAKE}")
include(${TCMAKE})
else()
message("CMake files for ${TARGET} not found, using ${DCMAKE}")
Expand All @@ -25,8 +36,8 @@ else()
include(${DCMAKE})
endif(TARGET)

set(BOOST_INCLUDEDIR ${lib_base}/boost_1_54_0)
find_package(Boost REQUIRED)
set(BOOST_INCLUDEDIR ${lib_base}/boost)
#find_package(Boost REQUIRED)

# Include
include_directories(
Expand Down Expand Up @@ -292,7 +303,9 @@ if(CANNONBOARD)
add_definitions(-DCANNONBOARD)
endif()

add_executable(cannonball ${SRCS})
add_executable(${PROJECT_NAME} ${SRCS})

target_compile_options(${PROJECT_NAME} PRIVATE ${FLAGS})

# Copy Configuration file to current build

Expand All @@ -313,3 +326,16 @@ configure_file(../res/tilemap.bin ./res/tilemap.bin
configure_file(../res/tilepatch.bin ./res/tilepatch.bin
COPYONLY
)

#VITA
vita_create_self(${PROJECT_NAME}.self ${PROJECT_NAME} ${UNSAFE_FLAG})
add_custom_target(${PROJECT_NAME}.vpk
DEPENDS ${PROJECT_NAME}.self
COMMAND rm -rf vpk && mkdir -p vpk/sce_sys
COMMAND ${VITASDK}/bin/vita-mksfoex -s TITLE_ID=${TITLEID} "${PROJECT_NAME}" vpk/sce_sys/param.sfo
COMMAND cp ${PROJECT_NAME}.self vpk/eboot.bin
COMMAND cp -r ${CMAKE_SOURCE_DIR}/../psp2data/* vpk
COMMAND cp -r res vpk
COMMAND cd vpk && zip -r ../Cannonball.vpk . && cd ..
)
#END VITA
59 changes: 59 additions & 0 deletions cmake/vita.cmake
@@ -0,0 +1,59 @@
# Vita CMake Setup.

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

set(TITLEID "CANNONBAL")

set(lib_base $ENV{VITASDK}/arm-vita-eabi/lib)
set(sdl_root $ENV{VITASDK}/arm-vita-eabi/include/SDL2)

include_directories(
"${sdl_root}"
)

link_libraries(
SDL2
Vita2d
# VitaGL
SceSysmodule_stub
SceDisplay_stub
SceGxm_stub
SceCtrl_stub
ScePgf_stub
ScePower_stub
SceCommonDialog_stub
SceAudio_stub
SceShellSvc_stub
SceHid_stub
SceTouch_stub
png
jpeg
z
m
c
)

# Linking
link_directories(
"${lib_base}"
)

add_definitions(-O3 -DSDL2)

# Location for Cannonball to create save files
# Used to auto-generate setup.hpp with various file paths
set(xml_directory ux0:/data/cannonball/)
#set(sdl_flags "SDL_DOUBLEBUF | SDL_HWSURFACE")
set(sdl_flags "0")

# Set SDL2 instead of SDL1
set(SDL2 1)
#set(OPENGL 1)

set(FLAGS
-marm -mfpu=neon -mcpu=cortex-a9 -march=armv7-a -mfloat-abi=hard -ffast-math
-fno-asynchronous-unwind-tables -funroll-loops
-mword-relocations -fno-unwind-tables -fno-optimize-sibling-calls
-mvectorize-with-neon-quad -funsafe-math-optimizations
-mlittle-endian -munaligned-access
)
Binary file added psp2data/sce_sys/icon0.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 psp2data/sce_sys/livearea/contents/bg.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 psp2data/sce_sys/livearea/contents/startup.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions psp2data/sce_sys/livearea/contents/template.xml
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>

<livearea style="a1" format-ver="01.00" content-rev="1">
<livearea-background>
<image>bg.png</image>
</livearea-background>

<gate>
<startup-image>startup.png</startup-image>
</gate>
</livearea>
8 changes: 8 additions & 0 deletions src/main/engine/omusic.cpp
Expand Up @@ -39,13 +39,21 @@ bool OMusic::load_widescreen_map()
if (tilemap == NULL)
{
tilemap = new RomLoader();
#ifdef __vita__
status += tilemap->load_binary("app0:/res/tilemap.bin");
#else
status += tilemap->load_binary("res/tilemap.bin");
#endif
}

if (tile_patch == NULL)
{
tile_patch = new RomLoader();
#ifdef __vita__
status += tile_patch->load_binary("app0:/res/tilepatch.bin");
#else
status += tile_patch->load_binary("res/tilepatch.bin");
#endif
}

return status == 0;
Expand Down
1 change: 0 additions & 1 deletion src/main/frontend/config.cpp
Expand Up @@ -244,7 +244,6 @@ bool Config::save(const std::string &filename)
ttrial.laps = pt_config.get("time_trial.laps", 5);
ttrial.traffic = pt_config.get("time_trial.traffic", 3);
cont_traffic = pt_config.get("continuous.traffic", 3);

try
{
write_xml(filename, pt_config, std::locale(), xml_writer_settings('\t', 1)); // Tab space 1
Expand Down
4 changes: 3 additions & 1 deletion src/main/frontend/menu.cpp
Expand Up @@ -210,7 +210,7 @@ void Menu::populate()
menu_musictest.push_back(ENTRY_MUSIC4);
menu_musictest.push_back(ENTRY_BACK);

menu_about.push_back("CANNONBALL 0.3 © CHRIS WHITE 2014");
menu_about.push_back("CANNONBALL 0.3 CHRIS WHITE 2014");
menu_about.push_back("REASSEMBLER.BLOGSPOT.COM");
menu_about.push_back(" ");
menu_about.push_back("CANNONBALL IS FREE AND MAY NOT BE SOLD.");
Expand Down Expand Up @@ -1021,7 +1021,9 @@ void Menu::restart_video()
if (config.sound.enabled)
cannonball::audio.stop_audio();
#endif
#ifndef __vita__
video.disable();
#endif
video.init(&roms, &config.video);
#ifdef COMPILE_SOUND_CODE
osoundint.init();
Expand Down
15 changes: 14 additions & 1 deletion src/main/main.cpp
Expand Up @@ -48,6 +48,10 @@
// Initialize Shared Variables
using namespace cannonball;

#ifdef __vita__
#include <psp2/power.h>
#endif

int cannonball::state = STATE_BOOT;
double cannonball::frame_ms = 0;
int cannonball::frame = 0;
Expand All @@ -70,7 +74,9 @@ static void quit_func(int code)
forcefeedback::close();
delete menu;
SDL_Quit();
#ifndef __vita__
exit(code);
#endif
}

static void process_events(void)
Expand Down Expand Up @@ -210,7 +216,7 @@ static void tick()
cannonboard.write(outrun.outputs->dig_out, outrun.outputs->hw_motor_control);

// Draw SDL Video
video.draw_frame();
video.draw_frame();
}

static void main_loop()
Expand Down Expand Up @@ -271,6 +277,13 @@ int main(int argc, char* argv[])
return 1;
}

#ifdef __vita__
scePowerSetArmClockFrequency(444);
scePowerSetGpuClockFrequency(222);
scePowerSetBusClockFrequency(222);
scePowerSetGpuXbarClockFrequency(222);
#endif

menu = new Menu(&cannonboard);

bool loaded = false;
Expand Down
5 changes: 4 additions & 1 deletion src/main/romloader.cpp
Expand Up @@ -56,8 +56,11 @@ int RomLoader::load(const char* filename, const int offset, const int length, co
CFRelease(resourcesURL);
chdir(bundlepath);
#endif

#ifdef __vita__
std::string path = "ux0:/data/cannonball/roms/";
#else
std::string path = "roms/";
#endif
path += std::string(filename);

// Open rom file
Expand Down

0 comments on commit bf411a3

Please sign in to comment.