-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
4,959 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
cmake_minimum_required(VERSION 2.8) | ||
|
||
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(SHORT_NAME ViOut) | ||
project(${SHORT_NAME}) | ||
include("${VITASDK}/share/vita.cmake" REQUIRED) | ||
|
||
set(VITA_APP_NAME "VitaOut") | ||
set(VITA_TITLEID "VITAOUT") | ||
set(VITA_VERSION "00.90") | ||
|
||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu11") | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") | ||
|
||
include_directories( | ||
) | ||
|
||
add_executable(${SHORT_NAME} | ||
src/main.c | ||
src/font.c | ||
src/objectConstructor.c | ||
src/inputHandler.c | ||
src/objectUpdater.c | ||
src/objectVisualizer.c | ||
) | ||
|
||
target_link_libraries(${SHORT_NAME} | ||
vita2d | ||
SceDisplay_stub | ||
SceGxm_stub | ||
SceSysmodule_stub | ||
SceCommonDialog_stub | ||
SceCtrl_stub | ||
SceTouch_stub | ||
SceAudio_stub | ||
freetype | ||
png | ||
soloud | ||
pthread | ||
m | ||
z | ||
) | ||
|
||
vita_create_self(${SHORT_NAME}.self ${SHORT_NAME}) | ||
vita_create_vpk(${SHORT_NAME}.vpk ${VITA_TITLEID} ${SHORT_NAME}.self | ||
VERSION ${VITA_VERSION} | ||
NAME ${VITA_APP_NAME} | ||
) |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#include <psp2/ctrl.h> | ||
#include <psp2/touch.h> | ||
#include "inputHandler.h" | ||
|
||
void inputHandler(Console *stVita) { | ||
SceCtrlData pad; | ||
SceTouchData touch; | ||
|
||
sceCtrlPeekBufferPositive(0, &pad, 1); | ||
sceCtrlSetSamplingMode(SCE_CTRL_MODE_ANALOG_WIDE); | ||
sceTouchSetSamplingState(SCE_TOUCH_PORT_FRONT, SCE_TOUCH_SAMPLING_STATE_START); | ||
sceTouchSetSamplingState(SCE_TOUCH_PORT_BACK, SCE_TOUCH_SAMPLING_STATE_START); | ||
|
||
stVita->xCircle = (pad.buttons & SCE_CTRL_CIRCLE); | ||
stVita->xCross = (pad.buttons & SCE_CTRL_CROSS); | ||
stVita->xTriangle = (pad.buttons & SCE_CTRL_TRIANGLE); | ||
stVita->xSquare = (pad.buttons & SCE_CTRL_SQUARE); | ||
stVita->stLeftJoy.siX = (signed char)pad.lx - 128; | ||
stVita->stLeftJoy.siY = (signed char)pad.ly - 128; | ||
stVita->stRightJoy.siX = (signed char)pad.rx - 128; | ||
stVita->stRightJoy.siY = (signed char)pad.ry - 128; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# include <stdbool.h> | ||
|
||
#ifndef _INPUTHANDLER_H_ | ||
#define _INPUTHANDLER_H_ | ||
|
||
typedef struct Joystick | ||
{ | ||
signed char siY; | ||
signed char siX; | ||
}Joystick; | ||
|
||
typedef struct Touch | ||
{ | ||
char usiY; | ||
char usiX; | ||
}Touch; | ||
|
||
typedef struct Console | ||
{ | ||
bool xCross; | ||
bool xTriangle; | ||
bool xCircle; | ||
bool xSquare; | ||
|
||
bool xUp; | ||
bool xDown; | ||
bool xLeft; | ||
bool xRight; | ||
|
||
bool xStart; | ||
bool xSelect; | ||
|
||
Joystick stLeftJoy; | ||
Joystick stRightJoy; | ||
|
||
Touch stFrontTouch; | ||
Touch stRearTouch; | ||
} Console; | ||
|
||
void inputHandler(Console *stVita); | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#include <stdio.h> | ||
|
||
#include <psp2/kernel/processmgr.h> | ||
|
||
#include "inputHandler.h" | ||
#include "objectConstructor.h" | ||
#include "objectUpdater.h" | ||
#include "objectVisualizer.h" | ||
|
||
int main() { | ||
unsigned short uiScreenWidth = 960; | ||
unsigned short uiScreenHeight = 544; | ||
|
||
Base stBall; | ||
Base stPaddle; | ||
Map stFrame; | ||
Console stVita; | ||
|
||
frameConstructor(&stFrame, uiScreenWidth, uiScreenHeight); | ||
paddleConstructor(&stPaddle); | ||
ballConstructor(&stBall); | ||
startVisualizer(); | ||
|
||
while (1) { | ||
inputHandler(&stVita); | ||
paddleUpdate(&stPaddle, &stVita); | ||
ballUpdate(&stBall, &stFrame); | ||
|
||
updateVisualizer(); | ||
frameVisualizer(&stFrame, &stVita, uiScreenWidth, uiScreenHeight); | ||
paddleVisualizer(&stPaddle); | ||
ballVisualizer(&stBall); | ||
|
||
closeVisualizer(); | ||
} | ||
|
||
finishVisualizer(); | ||
sceKernelExitProcess(0); | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
#include <stdio.h> | ||
#include "mathFunctions.h" | ||
|
||
static float rLookupTable[usiRow][usiColumn] = | ||
{ | ||
{0, .0000, 1.0000, .0000}, | ||
{1, .0175, .9998, .0175}, | ||
{2, .0349, .9994, .0349}, | ||
{3, .0523, .9986, .0524}, | ||
{4, .0698, .9976, .0699}, | ||
{5, .0872, .9962, .0875}, | ||
{6, .1045, .9945, .1051}, | ||
{7, .1219, .9925, .1228}, | ||
{8, .1392, .9903, .1405}, | ||
{9, .1564, .9877, .1584}, | ||
{10, .1736, .9848, .1763}, | ||
{11, .1908, .9816, .1944}, | ||
{12, .2079, .9781, .2126}, | ||
{13, .2250, .9744, .2309}, | ||
{14, .2419, .9703, .2493}, | ||
{15, .2588, .9659, .2679}, | ||
{16, .2756, .9613, .2867}, | ||
{17, .2924, .9563, .3057}, | ||
{18, .3090, .9511, .3249}, | ||
{19, .3256, .9455, .3443}, | ||
{20, .3420, .9397, .3640}, | ||
{21, .3584, .9336, .3839}, | ||
{22, .3746, .9272, .4040}, | ||
{23, .3907, .9205, .4245}, | ||
{24, .4067, .9135, .4452}, | ||
{25, .4226, .9063, .4663}, | ||
{26, .4384, .8988, .4877}, | ||
{27, .4540, .8910, .5095}, | ||
{28, .4695, .8829, .5317}, | ||
{29, .4848, .8746, .5543}, | ||
{30, .5000, .8660, .5774}, | ||
{31, .5150, .8572, .6009}, | ||
{32, .5299, .8480, .6249}, | ||
{33, .5446, .8387, .6494}, | ||
{34, .5592, .8290, .6745}, | ||
{35, .5736, .8192, .7002}, | ||
{36, .5878, .8090, .7265}, | ||
{37, .6018, .7986, .7536}, | ||
{38, .6157, .7880, .7813}, | ||
{39, .6293, .7771, .8098}, | ||
{40, .6428, .7660, .8391}, | ||
{41, .6561, .7547, .8693}, | ||
{42, .6691, .7431, .9004}, | ||
{43, .6820, .7314, .9325}, | ||
{44, .6947, .7193, .9657}, | ||
{45, .7071, .7071, 1.0000}, | ||
}; | ||
|
||
float sinInterpolate(unsigned char usiDegrees) | ||
{ | ||
float rAngle; | ||
unsigned char usiFunction = 1; | ||
unsigned char usiCounter; | ||
|
||
rAngle = rLookupTable[usiDegrees][usiFunction]; | ||
|
||
return rAngle; | ||
} | ||
|
||
float cosInterpolate(unsigned char usiDegrees) | ||
{ | ||
float rAngle; | ||
unsigned char usiFunction = 2; | ||
unsigned char usiCounter; | ||
|
||
rAngle = rLookupTable[usiDegrees][usiFunction]; | ||
|
||
return rAngle; | ||
} | ||
|
||
float tanInterpolate(unsigned char usiDegrees) | ||
{ | ||
float rAngle; | ||
unsigned char usiFunction = 3; | ||
unsigned char usiCounter; | ||
|
||
rAngle = rLookupTable[usiDegrees][usiFunction]; | ||
|
||
return rAngle; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#ifndef _MATHFUNCTIONS_H_ | ||
#define _MATHFUNCTIONS_H_ | ||
|
||
#define usiColumn 4 | ||
#define usiRow 46 | ||
|
||
float sinInterpolate(unsigned char usiDegrees); | ||
float cosInterpolate(unsigned char usiDegrees); | ||
float tanInterpolate(unsigned char usiDegrees); | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#include "objectConstructor.h" | ||
|
||
void frameConstructor(Map *stFrame, unsigned short uiScreenWidth, unsigned short uiScreenHeight) | ||
{ | ||
stFrame->uiFrameThickness = 10; | ||
|
||
stFrame->uiLeftBorder[1] = 0; | ||
stFrame->uiLeftBorder[2] = 0; | ||
|
||
stFrame->uiRightBorder[1] = uiScreenWidth - stFrame->uiFrameThickness; | ||
stFrame->uiRightBorder[2] = 0; | ||
|
||
stFrame->uiBottomBorder[1] = stFrame->uiFrameThickness; | ||
stFrame->uiBottomBorder[2] = uiScreenHeight - stFrame->uiFrameThickness; | ||
|
||
stFrame->uiTopBorder[1] = stFrame->uiFrameThickness; | ||
stFrame->uiTopBorder[2] = 0; | ||
} | ||
|
||
void paddleConstructor(Base *stPaddle) | ||
{ | ||
stPaddle->rXPos = 460; | ||
stPaddle->rYPos = 500; | ||
stPaddle->uiPsiPos = 0; | ||
} | ||
|
||
void ballConstructor(Base *stBall) | ||
{ | ||
stBall->rXPos = 460; | ||
stBall->rYPos = 256; | ||
stBall->uiPsiPos = 0; | ||
stBall->iSpeed = 1; | ||
stBall->iAngle = 210; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#ifndef _OBJECTCONSTRUCTOR_H_ | ||
#define _OBJECTCONSTRUCTOR_H_ | ||
|
||
typedef struct Base | ||
{ | ||
float rXPos; | ||
float rYPos; | ||
unsigned short uiPsiPos; | ||
signed short iJerk; | ||
signed short iAccel; | ||
signed short iSpeed; | ||
signed short iAngle; | ||
} Base; | ||
|
||
typedef struct Map | ||
{ | ||
unsigned short uiFrameThickness; | ||
unsigned short uiLeftBorder[2]; | ||
unsigned short uiRightBorder[2]; | ||
unsigned short uiBottomBorder[2]; | ||
unsigned short uiTopBorder[2]; | ||
} Map; | ||
|
||
void frameConstructor(Map *stFrame, unsigned short uiScreenWidth, unsigned short uiScreenHeight); | ||
void paddleConstructor(Base *stPaddle); | ||
void ballConstructor(Base *stBall); | ||
void blockConstructor(); | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#include "objectUpdater.h" | ||
|
||
#define PI 3.14159265 | ||
#define Deg2Rad PI/180 | ||
|
||
void paddleUpdate(Base *stPaddle, Console *stVita) | ||
{ | ||
if (stVita->stLeftJoy.siX > 10 | stVita->stLeftJoy.siX < -10) { | ||
stPaddle->rXPos += stVita->stLeftJoy.siX; | ||
} | ||
} | ||
|
||
void ballUpdate(Base *stBall, Map *stFrame) | ||
{ | ||
float rAngle = (float)(stBall->iAngle) * Deg2Rad; | ||
stBall->rXPos += stBall->iSpeed * cosf(rAngle); | ||
stBall->rYPos += stBall->iSpeed * sinf(rAngle); | ||
|
||
if (stBall->rYPos < stFrame->uiTopBorder[2]) | ||
{ | ||
stBall->iSpeed *= -1; | ||
stBall->iAngle += 90; | ||
} | ||
else if (stBall->rYPos > stFrame->uiBottomBorder[2]) | ||
{ | ||
stBall->iSpeed *= -1; | ||
stBall->iAngle += 90; | ||
} | ||
|
||
if (stBall->rXPos <= stFrame->uiLeftBorder[1]) | ||
{ | ||
stBall->iSpeed *= -1; | ||
stBall->iAngle += 90; | ||
} | ||
else if (stBall->rXPos > stFrame->uiRightBorder[1]) | ||
{ | ||
stBall->iSpeed *= -1; | ||
stBall->iAngle += 90; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#ifndef _OBJECTUPDATER_H_ | ||
#define _OBJECTUPDATER_H_ | ||
|
||
#include "inputHandler.h" | ||
#include "objectConstructor.h" | ||
#include <math.h> | ||
|
||
void paddleUpdate(Base *stPaddle, Console *stVita); | ||
void ballUpdate(Base *stBall, Map *stFrame); | ||
|
||
#endif |
Oops, something went wrong.