Skip to content

Commit

Permalink
Move 2.0.0 tree
Browse files Browse the repository at this point in the history
- GUI feature
- no more needs app switch
- support 3.65
  • Loading branch information
d3m3vilurr committed Apr 9, 2018
1 parent a1015de commit 66f4a7e
Show file tree
Hide file tree
Showing 13 changed files with 1,048 additions and 1,117 deletions.
17 changes: 14 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ add_definitions(-DSQLITE_OS_OTHER=1)
add_definitions(-DSQLITE_TEMP_STORE=3)
add_definitions(-DSQLITE_THREADSAFE=0)
add_definitions(-DVERSION=\"${VERSION}\")
#add_definitions(-DUSE_DEBUG=1)
#add_definitions(-DDEBUG_IP=\"127.0.0.1\")

set(CMAKE_C_FLAGS "-Wl,-q -Wall -O3 -std=c99")

Expand All @@ -37,12 +39,13 @@ include_directories(
)

add_executable(${PROJECT_NAME}.elf
src/console.c
src/appdb.c
src/file.c
src/font.c
src/button.c
src/display.c
src/input.c
src/config.c
src/util.c
src/main.c
src/vita_sqlite.c

Expand All @@ -52,7 +55,8 @@ add_executable(${PROJECT_NAME}.elf

target_link_libraries(${PROJECT_NAME}.elf
-lvita2d
-lfreetype
#-lfreetype
-lpng
-lz
-lm
-lSceIofilemgr_stub
Expand All @@ -64,8 +68,15 @@ target_link_libraries(${PROJECT_NAME}.elf
-lSceAppUtil_stub
-lSceSysmodule_stub
-lSceCtrl_stub
-lSceTouch_stub
-lScePgf_stub
-lSceShellSvc_stub
-ltaihen_stub
-lVitaShellUser_stub_weak

-ldebugnet
-lSceNetCtl_stub
-lSceNet_stub
)

add_custom_target(${PROJECT_NAME}.vpk ALL
Expand Down
45 changes: 39 additions & 6 deletions src/appdb.c
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include "sqlite3.h"
#include "appdb.h"

#define APP_DB "ur0:shell/db/app.db"
#define APP_DB "ur0:/shell/db/app.db"

static int get_applist_callback(void *data, int argc, char **argv, char **cols) {
applist *list = (applist*)data;
appinfo *info = malloc(sizeof(appinfo));
memset(info, 0, sizeof(appinfo));
appinfo *info = calloc(1, sizeof(appinfo));
if (list->count == 0) {
list->items = info;
} else {
Expand All @@ -25,6 +26,7 @@ static int get_applist_callback(void *data, int argc, char **argv, char **cols)
strcpy(info->title, argv[2]);
strcpy(info->eboot, argv[3]);
strcpy(info->dev, argv[4]);
strcpy(info->iconpath, argv[5]);
for (int i = 0; i < 256; i++) {
if (info->title[i] == '\n') {
info->title[i] = ' ';
Expand All @@ -35,7 +37,8 @@ static int get_applist_callback(void *data, int argc, char **argv, char **cols)

int get_applist(applist *list) {
char *query = "select a.titleid, b.realid, c.title, d.ebootbin,"
" rtrim(substr(d.ebootbin, 0, 5), ':') as dev"
" rtrim(substr(d.ebootbin, 0, 5), ':') as dev,"
" e.iconpath"
" from (select titleid"
" from tbl_appinfo"
" where key = 566916785"
Expand All @@ -47,10 +50,14 @@ int get_applist(applist *list) {
" tbl_appinfo_icon c,"
" (select titleid, val as ebootbin"
" from tbl_appinfo"
" where key = 3022202214) d"
" where key = 3022202214) d,"
" (select titleid, iconpath"
" from tbl_appinfo_icon"
" where type = 0) e"
" where a.titleid = b.titleid"
" and a.titleid = c.titleid"
" and a.titleid = d.titleid";
" and a.titleid = d.titleid"
" and a.titleid = e.titleid";

sqlite3 *db;
int ret = sqlite3_open(APP_DB, &db);
Expand All @@ -70,3 +77,29 @@ int get_applist(applist *list) {
}
return 0;
}

void load_icon(appinfo *info) {
if (info->icon.texture) {
return;
}

if (!info->icon.buf) {
info->icon.buf = calloc(sizeof(uint8_t), ICON_BUF_SIZE);
FILE *f = fopen(info->iconpath, "r");
fread(info->icon.buf, sizeof(uint8_t), ICON_BUF_SIZE, f);
fclose(f);
}

info->icon.texture = vita2d_load_PNG_buffer(info->icon.buf);
}

void unload_icon(appinfo *info) {
if (info->icon.buf) {
free(info->icon.buf);
info->icon.buf = NULL;
}
if (info->icon.texture) {
vita2d_free_texture(info->icon.texture);
info->icon.texture = NULL;
}
}
7 changes: 7 additions & 0 deletions src/appdb.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,17 @@
#define __APPDB_H__

#include <stdint.h>
#include <vita2d.h>
#include "common.h"

typedef struct appinfo {
char title_id[16];
char real_id[16];
char title[256];
char eboot[256];
char dev[5];
char iconpath[256];
icon_data icon;
struct appinfo *next;
struct appinfo *prev;
} appinfo;
Expand All @@ -19,4 +23,7 @@ typedef struct applist {
} applist;

int get_applist(applist *list);

void load_icon(appinfo *info);
void unload_icon(appinfo *icon);
#endif
45 changes: 0 additions & 45 deletions src/button.c

This file was deleted.

8 changes: 0 additions & 8 deletions src/button.h

This file was deleted.

116 changes: 111 additions & 5 deletions src/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,93 @@
#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 orange RGBA8(0xFF, 0xA5, 0x00, 0xFF)

#define SCREEN_WIDTH 960
#define SCREEN_HEIGHT 544
#define SCREEN_HALF_WIDTH (SCREEN_WIDTH / 2)
#define SCREEN_HALF_HEIGHT (SCREEN_HEIGHT / 2)
#define HEADER_HEIGHT 40
#define FOOTER_HEIGHT 0
#define ITEM_ROW 4
#define ITEM_COL 7

#define ITEMS_PANEL_PADDING 5
#define ITEMS_PANEL_WIDTH (SCREEN_WIDTH)
#define ITEMS_PANEL_INNER_WIDTH (ITEMS_PANEL_WIDTH - (ITEMS_PANEL_PADDING * 2))
#define ITEMS_PANEL_HEIGHT (SCREEN_HEIGHT - HEADER_HEIGHT - FOOTER_HEIGHT)
#define ITEMS_PANEL_INNER_HEIGHT (ITEMS_PANEL_HEIGHT - (ITEMS_PANEL_PADDING * 2))
#define ITEMS_PANEL_TOP (HEADER_HEIGHT)
#define ITEMS_PANEL_LEFT (0)
#define ITEMS_INNER_TOP (ITEMS_PANEL_TOP + ITEMS_PANEL_PADDING)
#define ITEMS_INNER_LEFT (ITEMS_PANEL_LEFT + ITEMS_PANEL_PADDING)
#define ITEM_BOX_MARGIN 5
#define ITEM_BOX_PADDING 0
#define ITEM_BOX_WIDTH (int)((ITEMS_PANEL_INNER_WIDTH - (ITEM_BOX_MARGIN * (ITEM_COL + 1))) / ITEM_COL)
#define ITEM_BOX_HEIGHT (int)((ITEMS_PANEL_INNER_HEIGHT - (ITEM_BOX_MARGIN * (ITEM_ROW + 1))) / ITEM_ROW)
#define ICON_WIDTH (ITEM_BOX_WIDTH - (ITEM_BOX_PADDING * 2))
#define ICON_HEIGHT (ITEM_BOX_HEIGHT - (ITEM_BOX_PADDING * 2))

#define ITEM_BOX_TOP(y) (ITEMS_INNER_TOP + (ITEM_BOX_MARGIN * ((y) + 1)) + (ITEM_BOX_HEIGHT * (y)))
#define ITEM_BOX_LEFT(x) (ITEMS_INNER_LEFT + (ITEM_BOX_MARGIN * ((x) + 1)) + (ITEM_BOX_WIDTH * (x)))
#define ICON_TOP(y) (ITEM_BOX_TOP((y)) + ITEM_BOX_PADDING)
#define ICON_LEFT(x) (ITEM_BOX_LEFT((x)) + ITEM_BOX_PADDING)

#define APPINFO_PANEL_TOP (ITEMS_PANEL_TOP)
#define APPINFO_PANEL_LEFT (ITEMS_PANEL_LEFT)
#define APPINFO_PANEL_WIDTH (ITEMS_PANEL_WIDTH / 2)
#define APPINFO_PANEL_HEIGHT (ITEMS_PANEL_HEIGHT)
#define APPINFO_PANEL_PADDING 5

#define APPINFO_DESC_TOP (int)(APPINFO_PANEL_TOP + (APPINFO_PANEL_HEIGHT / 2) + APPINFO_PANEL_PADDING)
#define APPINFO_DESC_LEFT (APPINFO_PANEL_LEFT + APPINFO_PANEL_PADDING)
#define APPINFO_DESC_WIDTH (APPINFO_PANEL_WIDTH - (APPINFO_PANEL_PADDING * 2))
#define APPINFO_DESC_HEIGHT (int)((APPINFO_PANEL_HEIGHT / 2) - (APPINFO_PANEL_PADDING * 2))
#define APPINFO_DESC_PADDING 5

#define APPINFO_ICON_PADDING 40
#define APPINFO_ICON_TOP (APPINFO_PANEL_TOP + APPINFO_PANEL_PADDING + APPINFO_ICON_PADDING)
#define APPINFO_ICON_LEFT (APPINFO_PANEL_LEFT + APPINFO_PANEL_PADDING + APPINFO_ICON_PADDING)
#define APPINFO_ICON_WIDTH (int)((APPINFO_PANEL_WIDTH / 2) - (APPINFO_PANEL_PADDING * 2) - (APPINFO_ICON_PADDING * 2))
#define APPINFO_ICON_HEIGHT (int)((APPINFO_PANEL_HEIGHT / 2) - (APPINFO_PANEL_PADDING * 2) - (APPINFO_ICON_PADDING * 2))

#define APPINFO_BUTTONS_TOP (APPINFO_PANEL_TOP + APPINFO_PANEL_PADDING)
#define APPINFO_BUTTONS_LEFT (int)(APPINFO_PANEL_LEFT + (APPINFO_PANEL_WIDTH / 2) + APPINFO_PANEL_PADDING)
#define APPINFO_BUTTONS_WIDTH (int)((APPINFO_PANEL_WIDTH / 2) - (APPINFO_PANEL_PADDING * 2))
#define APPINFO_BUTTONS_HEIGHT (int)((APPINFO_PANEL_HEIGHT / 2) - (APPINFO_PANEL_PADDING * 2))

#define APPINFO_BUTTON 4
#define APPINFO_BUTTON_MARGIN 5
#define APPINFO_BUTTON_WIDTH (int)(APPINFO_BUTTONS_WIDTH - (APPINFO_BUTTON_MARGIN * 2))
#define APPINFO_BUTTON_HEIGHT (int)((APPINFO_BUTTONS_HEIGHT - (APPINFO_BUTTON_MARGIN * (APPINFO_BUTTON + 1))) / APPINFO_BUTTON)
#define APPINFO_BUTTON_LEFT (APPINFO_BUTTONS_LEFT + APPINFO_BUTTON_MARGIN)
#define APPINFO_BUTTON_TOP(x) (APPINFO_BUTTONS_TOP + APPINFO_BUTTON_MARGIN + (APPINFO_BUTTON_HEIGHT + APPINFO_BUTTON_MARGIN) * (x))

#define SLOT_PANEL_TOP (ITEMS_PANEL_TOP)
#define SLOT_PANEL_LEFT (APPINFO_PANEL_LEFT + APPINFO_PANEL_WIDTH)
#define SLOT_PANEL_WIDTH (ITEMS_PANEL_WIDTH / 2)
#define SLOT_PANEL_HEIGHT (ITEMS_PANEL_HEIGHT)
#define SLOT_PANEL_PADDING 5

#define SLOT_HEADER_TOP (ITEMS_PANEL_TOP + SLOT_PANEL_PADDING)
#define SLOT_HEADER_LEFT (ITEMS_PANEL_LEFT + SLOT_PANEL_PADDING)
#define SLOT_HEADER_HEIGHT 40

#define SLOT_BUTTONS_TOP (SLOT_HEADER_TOP + SLOT_HEADER_HEIGHT)
#define SLOT_BUTTONS_HEIGHT (SLOT_PANEL_HEIGHT - SLOT_HEADER_HEIGHT - (SLOT_PANEL_PADDING * 2))
#define SLOT_BUTTON 10
#define SLOT_BUTTON_MARGIN 5
#define SLOT_BUTTON_WIDTH (int)(SLOT_PANEL_WIDTH - (SLOT_BUTTON_MARGIN * 2))
#define SLOT_BUTTON_HEIGHT (int)((SLOT_BUTTONS_HEIGHT - (SLOT_BUTTON_MARGIN * (SLOT_BUTTON + 1))) / SLOT_BUTTON)
#define SLOT_BUTTON_LEFT (SLOT_PANEL_LEFT + SLOT_BUTTON_MARGIN)
#define SLOT_BUTTON_TOP(x) (SLOT_BUTTONS_TOP + SLOT_BUTTON_MARGIN + (SLOT_BUTTON_HEIGHT + SLOT_BUTTON_MARGIN) * (x))

#define ICON_BUF_SIZE (50 * 1024)

#define BLACK RGBA8(0x00, 0x00, 0x00, 0xFF)
#define LIGHT_SLATE_GRAY RGBA8(0x77, 0x88, 0x99, 0xFF)
#define LIGHT_GRAY RGBA8(0xD3, 0xD3, 0xD3, 0xD3)
#define WHITE RGBA8(0xFF, 0xFF, 0xFF, 0xFF)
#define LIGHT_SKY_BLUE RGBA8(0x87, 0xCE, 0xEB, 0xFF)

#define TEMP_FILE "ux0:data/savemgr/tmp"
#define CONFIG_FILE "ux0:data/savemgr/config.ini"
Expand All @@ -33,4 +115,28 @@ extern int SCE_CTRL_CANCEL;
extern char ICON_ENTER[4];
extern char ICON_CANCEL[4];

extern vita2d_pgf* font;
extern char *confirm_msg;
extern int confirm_msg_width;
extern char *close_msg;
extern int close_msg_width;

typedef struct point {
int x;
int y;
} point;

typedef struct rectangle {
int left;
int top;
int right;
int bottom;
} rectangle;

typedef struct icon_data {
uint8_t *buf;
vita2d_texture *texture;
rectangle touch_area;
} icon_data;

#endif
6 changes: 1 addition & 5 deletions src/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "config.h"
#include "file.h"
#include "ini.h"
#include "util.h"

char app_titleid[16];
char app_title[256];
Expand Down Expand Up @@ -39,9 +40,4 @@ void load_config() {
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);
}
1 change: 0 additions & 1 deletion src/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ extern char app_title[256];
typedef struct configure {
const char *base;
const char *slot_format;
const char *full_path_format;
} configure;

extern configure config;
Expand Down
Loading

0 comments on commit 66f4a7e

Please sign in to comment.