-
Notifications
You must be signed in to change notification settings - Fork 40
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
15 changed files
with
469 additions
and
228 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,3 @@ | ||
[submodule "extern/inih"] | ||
path = extern/inih | ||
url = https://github.com/benhoyt/inih |
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
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
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 <psp2/ctrl.h> | ||
|
||
#include "common.h" | ||
#include "button.h" | ||
|
||
int read_btn() { | ||
SceCtrlData pad = {0}; | ||
static int old; | ||
static int hold_times; | ||
int curr, btn; | ||
|
||
sceCtrlPeekBufferPositive(0, &pad, 1); | ||
|
||
if (pad.ly < 0x10) { | ||
pad.buttons |= SCE_CTRL_UP; | ||
} else if (pad.ly > 0xef) { | ||
pad.buttons |= SCE_CTRL_DOWN; | ||
} | ||
curr = pad.buttons; | ||
btn = pad.buttons & ~old; | ||
if (curr && old == curr) { | ||
hold_times += 1; | ||
if (hold_times >= 10) { | ||
btn = curr; | ||
hold_times = 10; | ||
btn |= SCE_CTRL_HOLD; | ||
} | ||
} else { | ||
hold_times = 0; | ||
old = curr; | ||
} | ||
return btn; | ||
} | ||
|
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,6 @@ | ||
#ifndef __BUTTON_H__ | ||
#define __BUTTON_H__ | ||
|
||
int read_btn(); | ||
|
||
#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,32 @@ | ||
#ifndef __COMMON_H__ | ||
#define __COMMON_H__ | ||
|
||
#include <vita2d.h> | ||
|
||
#define SAVE_MANAGER "SAVEMGR00" | ||
|
||
#define ICON_CIRCLE "\xe2\x97\x8b" | ||
#define ICON_CROSS "\xe2\x95\xb3" | ||
#define ICON_SQUARE "\xe2\x96\xa1" | ||
#define ICON_TRIANGLE "\xe2\x96\xb3" | ||
#define ICON_UPDOWN "\xe2\x86\x95" | ||
|
||
#define black RGBA8(0x00, 0x00, 0x00, 0xFF) | ||
#define white RGBA8(0xFF, 0xFF, 0xFF, 0xFF) | ||
#define green RGBA8(0x00, 0xFF, 0x00, 0xFF) | ||
#define red RGBA8(0xFF, 0x00, 0x00, 0xFF) | ||
|
||
#define TEMP_FILE "ux0:data/savemgr/tmp" | ||
#define CONFIG_FILE "ux0:data/savemgr/config.ini" | ||
|
||
#define DEFAULT_BASE_SAVEDIR "/data/rinCheat" | ||
#define DEFAULT_SAVE_SLOT_FORMAT "%s_SAVEDATA_SLOT%d" | ||
|
||
#define SCE_CTRL_HOLD 0x80000000 | ||
|
||
extern int SCE_CTRL_ENTER; | ||
extern int SCE_CTRL_CANCEL; | ||
extern char ICON_ENTER[4]; | ||
extern char ICON_CANCEL[4]; | ||
|
||
#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,47 @@ | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include <string.h> | ||
|
||
#include <psp2/io/fcntl.h> | ||
#include <psp2/appmgr.h> | ||
|
||
#include "common.h" | ||
#include "config.h" | ||
#include "file.h" | ||
#include "ini.h" | ||
|
||
char app_titleid[16]; | ||
char app_title[256]; | ||
|
||
configure config = {0}; | ||
|
||
static int handler(void* out, | ||
const char* section, const char* name, const char* value) { | ||
configure *p = (configure*)out; | ||
|
||
if (strcmp(name, "base") == 0) { | ||
p->base = strdup(value); | ||
} else if (strcmp(name, "slot_format") == 0) { | ||
p->slot_format = strdup(value); | ||
} | ||
return 1; | ||
} | ||
|
||
void load_config() { | ||
sceAppMgrAppParamGetString(0, 9, app_title , 256); | ||
sceAppMgrAppParamGetString(0, 12, app_titleid , 16); | ||
|
||
ini_parse(CONFIG_FILE, handler, &config); | ||
|
||
if (!config.base) { | ||
config.base = strdup(DEFAULT_BASE_SAVEDIR); | ||
} | ||
if (!config.slot_format) { | ||
config.slot_format = strdup(DEFAULT_SAVE_SLOT_FORMAT); | ||
} | ||
int length = strlen(config.base) + strlen(config.slot_format) + 6; | ||
char format[length]; | ||
memset(format, 0, length); | ||
snprintf(format, length, "ux0:%s/%s", config.base, config.slot_format); | ||
config.full_path_format = strdup(format); | ||
} |
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,17 @@ | ||
#ifndef __CONFIG_H__ | ||
#define __CONFIG_H__ | ||
|
||
extern char app_titleid[16]; | ||
extern char app_title[256]; | ||
|
||
typedef struct configure { | ||
const char *base; | ||
const char *slot_format; | ||
const char *full_path_format; | ||
} configure; | ||
|
||
extern configure config; | ||
|
||
void load_config(); | ||
|
||
#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,80 @@ | ||
#include <string.h> | ||
|
||
#include <psp2/types.h> | ||
#include <psp2/system_param.h> | ||
#include <psp2/apputil.h> | ||
#include <psp2/ctrl.h> | ||
|
||
#include <vita2d.h> | ||
|
||
#include "common.h" | ||
#include "button.h" | ||
#include "font.h" | ||
|
||
#define SCREEN_ROW 27 | ||
#define ROW_HEIGHT 20 | ||
|
||
static vita2d_pgf* debug_font; | ||
|
||
int SCE_CTRL_ENTER; | ||
int SCE_CTRL_CANCEL; | ||
char ICON_ENTER[4]; | ||
char ICON_CANCEL[4]; | ||
|
||
|
||
void init_console() { | ||
vita2d_set_clear_color(black); | ||
|
||
debug_font = load_system_fonts(); | ||
|
||
SceAppUtilInitParam init_param = {0}; | ||
SceAppUtilBootParam boot_param = {0}; | ||
sceAppUtilInit(&init_param, &boot_param); | ||
|
||
int enter_button; | ||
|
||
sceAppUtilSystemParamGetInt(SCE_SYSTEM_PARAM_ID_ENTER_BUTTON, &enter_button); | ||
if (enter_button == SCE_SYSTEM_PARAM_ENTER_BUTTON_CIRCLE) { | ||
SCE_CTRL_ENTER = SCE_CTRL_CIRCLE; | ||
SCE_CTRL_CANCEL = SCE_CTRL_CROSS; | ||
strcpy(ICON_ENTER, ICON_CIRCLE); | ||
strcpy(ICON_CANCEL, ICON_CROSS); | ||
} else { | ||
SCE_CTRL_ENTER = SCE_CTRL_CROSS; | ||
SCE_CTRL_CANCEL = SCE_CTRL_CIRCLE; | ||
strcpy(ICON_ENTER, ICON_CROSS); | ||
strcpy(ICON_CANCEL, ICON_CIRCLE); | ||
} | ||
|
||
sceCtrlSetSamplingMode(SCE_CTRL_MODE_ANALOG_WIDE); | ||
} | ||
|
||
void draw_start() { | ||
vita2d_start_drawing(); | ||
vita2d_clear_screen(); | ||
} | ||
|
||
void draw_end() { | ||
vita2d_end_drawing(); | ||
vita2d_wait_rendering_done(); | ||
vita2d_swap_buffers(); | ||
} | ||
|
||
void draw_text(uint32_t y, const char* text, uint32_t color) { | ||
for (int i = 0; i < 3; i++){ | ||
vita2d_start_drawing(); | ||
vita2d_pgf_draw_text(debug_font, 2, (y + 1) * ROW_HEIGHT, color, 1.0, text); | ||
draw_end(); | ||
} | ||
} | ||
|
||
void draw_loop_text(uint32_t y, const char *text, uint32_t color) { | ||
vita2d_pgf_draw_text(debug_font, 2, (y + 1) * ROW_HEIGHT, color, 1.0, text); | ||
} | ||
|
||
void clear_screen() { | ||
for (int i = 0; i < 3; i++){ | ||
draw_start(); | ||
draw_end(); | ||
} | ||
} |
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 __CONSOLE_H__ | ||
#define __CONSOLE_H__ | ||
|
||
void init_console(); | ||
void draw_start(); | ||
void draw_end(); | ||
void draw_text(uint32_t y, const char* text, uint32_t color); | ||
void draw_loop_text(uint32_t y, const char *text, uint32_t color); | ||
void clear_screen(); | ||
|
||
#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
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
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 |
---|---|---|
|
@@ -4,5 +4,6 @@ | |
#include <vita2d.h> | ||
|
||
vita2d_pgf* load_system_fonts(); | ||
|
||
#endif | ||
|
Oops, something went wrong.