From 0e75005a3fcf9b464b3ffdbb6cd83352b8834c12 Mon Sep 17 00:00:00 2001 From: Silica Date: Thu, 19 Apr 2018 21:42:51 +1200 Subject: [PATCH] Add files via upload --- debugScreen.h | 176 +++++++++++++ debugScreenFont.c | 111 ++++++++ main.c | 643 ++++++++++++++++++++++++++++++++++++++++++++++ np.h | 98 +++++++ 4 files changed, 1028 insertions(+) create mode 100644 debugScreen.h create mode 100644 debugScreenFont.c create mode 100644 main.c create mode 100644 np.h diff --git a/debugScreen.h b/debugScreen.h new file mode 100644 index 0000000..d6bd63f --- /dev/null +++ b/debugScreen.h @@ -0,0 +1,176 @@ +#ifndef DEBUG_SCREEN_H +#define DEBUG_SCREEN_H + +#include +#include +#include +#include + +typedef struct PsvDebugScreenFont { + unsigned char* glyphs, width, height, first, last, size_w, size_h; +} PsvDebugScreenFont; + +#include "debugScreenFont.c" + +#define SCREEN_WIDTH (960) +#define SCREEN_HEIGHT (544) +#define SCREEN_FB_WIDTH (960) +#define SCREEN_FB_SIZE (2 * 1024 * 1024) //Must be 256KB aligned +#ifndef SCREEN_TAB_SIZE /* this allow easy overriding */ +#define SCREEN_TAB_SIZE (8) +#endif +#define SCREEN_TAB_W ((F.size_w) * SCREEN_TAB_SIZE) +#define F psvDebugScreenFont + +#define FROM_GREY(c ) ((((c)*9) <<16) | (((c)*9) <<8) | ((c)*9)) +#define FROM_3BIT(c,dark) (((!!((c)&4))<<23) | ((!!((c)&2))<<15) | ((!!((c)&1))<<7) | (dark ? 0 : 0x7F7F7F)) +#define FROM_6BIT(c ) ((((c)%6)*(51<<16)) | ((((c)/6)%6)*(51<<8)) | ((((c)/36)%6)*51)) +#define FROM_FULL(r,g,b ) ((r<<16) | (g<<8) | (b)) +#define CLEARSCRN(H,toH,W,toW) for(int h = H; h < toH; h++)for(int w = W; w < toW; w++)((uint32_t*)base)[h*SCREEN_FB_WIDTH + w] = colorBg; + +static int mutex, coordX, savedX, coordY, savedY; +static uint32_t defaultFg = 0xFFFFFFFF, colorFg = 0xFFFFFFFF; +static uint32_t defaultBg = 0xFF000000, colorBg = 0xFF000000; + + +#ifdef __vita__ +#include +#include +#include +static void* base; // pointer to frame buffer +#else +#define sceKernelLockMutex(m,v,x) m=v +#define sceKernelUnlockMutex(m,v) m=v +static char base[SCREEN_FB_WIDTH * SCREEN_HEIGHT * 4]; +#endif + +static size_t psvDebugScreenEscape(const unsigned char *str) { + for(unsigned i = 0, argc = 0, arg[32] = {0}; argc < (sizeof(arg)/sizeof(*arg)) && str[i]!='\0'; i++) + switch(str[i]) { + case '0':case '1':case '2':case '3':case '4':case '5':case '6':case '7':case '8':case '9': + arg[argc]=(arg[argc]*10) + (str[i] - '0');continue; + case ';': argc++;continue; + case 's': savedX = coordX; savedY = coordY; return i; + case 'u': coordX = savedX; coordY = savedY; return i; + case 'A': coordY -= arg[0] * (F.size_h); return i; + case 'B': coordY += arg[0] * (F.size_h); return i; + case 'C': coordX += arg[0] * (F.size_w); return i; + case 'D': coordX -= arg[0] * (F.size_w); return i; + case 'E': coordY += arg[0] * (F.size_h); coordX = 0; return i; + case 'F': coordY -= arg[0] * (F.size_h); coordX = 0; return i; + case 'G': coordX = (arg[0]-1) * (F.size_w); return i; + case 'H': + case 'f': coordY = (arg[0]-1) * (F.size_h); + coordX = (arg[1]-1) * (F.size_w); return i; + case 'J': //clear part of (J=screen, K=Line) so J code reuse part of K + case 'K': if(arg[0]==0)CLEARSCRN(coordY, coordY + F.size_h, coordX, SCREEN_WIDTH);//from curosr to end + if(arg[0]==1)CLEARSCRN(coordY, coordY + F.size_h, 0, coordX);//from begining to cursor + if(arg[0]==2)CLEARSCRN(coordY, coordY + F.size_h, 0, SCREEN_WIDTH);//whole line + if(str[i]=='K')return i; + if(arg[0]==0)CLEARSCRN(coordY, SCREEN_HEIGHT, 0, SCREEN_WIDTH); + if(arg[0]==1)CLEARSCRN(0, coordY, 0, SCREEN_WIDTH); + if(arg[0]==2)CLEARSCRN(0, SCREEN_HEIGHT, 0, SCREEN_WIDTH); + return i; + case 'm':// Color + if(!arg[0]) {arg[0] = 39;arg[1] = 49;argc = 1;}//no/0 args == reset BG + FG + for(unsigned c = 0; c <= argc; c++) { + uint32_t unit = arg[c] % 10, mode = arg[c] / 10, *color = mode&1 ? &colorFg : &colorBg; + if (arg[c]==1)colorFg|=0x808080; + if (arg[c]==2)colorFg&=0x7F7F7F; + if (mode!=3 && mode!=4 && mode!=9 && mode!=10)continue;//skip unsported modes + if (unit == 9){ // reset FG or BG + *color = mode&1 ? defaultFg : defaultBg; + } else if ((unit==8) && (arg[c+1]==5)) { // 8bit : [0-15][16-231][232-256] color map + c+=2;*color = arg[c]<=15?FROM_3BIT(arg[c],mode<9):arg[c]>=232?FROM_GREY(arg[c]-232):FROM_6BIT(arg[c]-16); + } else if ((unit==8) && (arg[c+1]==2)) { // 24b color space + *color = FROM_FULL(arg[c+4], arg[c+3], arg[c+2]);c+=4; + } else *color = FROM_3BIT(unit,mode<9); // standard 8+8 colors + } + return i; + } + return 0; +} +int psvDebugScreenInit() { +#ifdef NO_psvDebugScreenInit + return 0;/* avoid linking non-initializer (prx) with sceDisplay/sceMemory */ +#else + mutex = sceKernelCreateMutex("log_mutex", 0, 0, NULL); + SceUID displayblock = sceKernelAllocMemBlock("display", SCE_KERNEL_MEMBLOCK_TYPE_USER_CDRAM_RW, SCREEN_FB_SIZE, NULL); + sceKernelGetMemBlockBase(displayblock, (void**)&base); + SceDisplayFrameBuf frame = { sizeof(frame), base, SCREEN_FB_WIDTH, 0, SCREEN_WIDTH, SCREEN_HEIGHT}; + return sceDisplaySetFrameBuf(&frame, SCE_DISPLAY_SETBUF_NEXTFRAME); +#endif +} + +int psvDebugScreenPuts(const char * _text) { + const unsigned char*text = (const unsigned char*)_text; + int bytes_per_glyph = (F.width * F.height) / 8; + sceKernelLockMutex(mutex, 1, NULL); + int c; + for (c = 0; text[c] ; c++) { + unsigned char t = text[c]; + if (t == '\t') { + coordX += SCREEN_TAB_W - coordX % SCREEN_TAB_W; + continue; + } + if (coordX + F.width > SCREEN_WIDTH) { + coordY += F.size_h; + coordX = 0; + } + if (coordY + F.height > SCREEN_HEIGHT) { + coordX = coordY = 0; + } + if (t == '\n') { + coordX = 0; + coordY += F.size_h; + continue; + } else if (t == '\r') { + coordX = 0; + continue; + } else if ((t == '\e') && (text[c+1] == '[')) { + c += psvDebugScreenEscape(text + c + 2) + 2; + if(coordX < 0)coordX = 0;// CSI position are 1-based, + if(coordY < 0)coordY = 0;// prevent 0-based coordiate from producing a negativ X/Y + continue; + }else if ((t > F.last) || (t < F.first)) + continue; // skip non printable glyph + uint32_t *vram = ((uint32_t*)base) + coordX + coordY * SCREEN_FB_WIDTH; + uint8_t *font = &F.glyphs[ (t - F.first) * bytes_per_glyph]; + for (int row = 0, mask = 1 << 7; row < F.height; row++, vram += SCREEN_FB_WIDTH) { + for (uint32_t *pixel = vram, col = 0; col < F.width ; col++, mask>>=1) { + if (!mask) {font++; mask = 1 << 7;}// no more mask : we exausted this byte + *pixel++ = (*font&mask)?colorFg:colorBg; + } + for (uint32_t *pixel = vram + F.width, col = F.width; col < F.size_w ; col++) + *pixel++ = colorBg;// right margin + } + for (int row = F.height; row < F.size_h; row++, vram += SCREEN_FB_WIDTH) + for (uint32_t *pixel = vram, col = 0; col < F.size_w ; col++) + *pixel++ = colorBg;// bottom margin + coordX += F.size_w; + } + sceKernelUnlockMutex(mutex, 1); + return c; +} + +__attribute__((__format__ (__printf__, 1, 2))) +int psvDebugScreenPrintf(const char *format, ...) { + char buf[4096]; + + va_list opt; + va_start(opt, format); + int ret = vsnprintf(buf, sizeof(buf), format, opt); + psvDebugScreenPuts(buf); + va_end(opt); + + return ret; +} + +void psvDebugScreenSetFgColor(uint32_t rgb){ + psvDebugScreenPrintf("\e[38;2;%lu;%lu;%lum", (rgb>>16)&0xFF, (rgb>>8)&0xFF, rgb&0xFF); +} +void psvDebugScreenSetBgColor(uint32_t rgb){ + psvDebugScreenPrintf("\e[48;2;%lu;%lu;%lum", (rgb>>16)&0xFF, (rgb>>8)&0xFF, rgb&0xFF); +} +#undef F +#endif diff --git a/debugScreenFont.c b/debugScreenFont.c new file mode 100644 index 0000000..cc7f41c --- /dev/null +++ b/debugScreenFont.c @@ -0,0 +1,111 @@ +/* + * PSP Software Development Kit - http://www.pspdev.org + * ----------------------------------------------------------------------- + * Licensed under the BSD license, see LICENSE in PSPSDK root for details. + * + * font.c - Debug Font. + * + * Copyright (c) 2005 Marcus R. Brown + * Copyright (c) 2005 James Forshaw + * Copyright (c) 2005 John Kelley + * + * $Id: font.c 540 2005-07-08 19:35:10Z warren $ + */ + +PsvDebugScreenFont psvDebugScreenFont = { glyphs:(unsigned char*) +"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" // +"\x01\x80\x03\xC0\x03\xC0\x03\xC0\x03\xC0\x03\xC0\x03\xC0\x03\xC0\x03\xC0\x03\x80\x01\x80\x01\x80\x01\x80\x00\x00\x00\x00\x01\x80\x03\xC0\x03\xC0\x01\x80\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" // ! +"\x00\x00\x00\x00\x06\x30\x06\x30\x0C\x60\x0C\x60\x0E\x70\x0E\x70\x06\x30\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" // " +"\x00\x00\x00\x00\x03\x18\x03\x18\x07\x38\x07\x38\x3F\xFC\x3F\xFC\x06\x70\x0E\x70\x0E\x70\x0E\x60\x3F\xFC\x3F\xFC\x1C\xE0\x1C\xE0\x1C\xC0\x18\xC0\x18\xC0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" // # +"\x01\x80\x01\x80\x07\xC0\x1F\xF0\x1F\xF8\x3D\xB8\x39\xB8\x39\x98\x3D\x80\x1F\x80\x0F\xF0\x03\xF8\x01\xBC\x31\x9C\x39\x9C\x39\x9C\x3D\xB8\x1F\xF8\x07\xE0\x01\x80\x01\x80\x01\x80\x00\x00\x00\x00" // $ +"\x00\x00\x78\x10\xF8\x30\xCC\x20\xCC\x60\xCC\x40\xCC\xC0\xCC\x80\x79\x80\x01\x3C\x03\x66\x02\x66\x06\x66\x0C\x66\x0C\x66\x18\x3C\x10\x3C\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" // % +"\x00\x00\x00\x00\x00\x00\x00\x00\x07\x80\x0F\xC0\x1C\xE0\x1C\xE0\x1C\xE0\x0F\xC0\x07\x00\x1F\x08\x3B\x9C\x71\xD8\x71\xF8\x70\xF0\x78\xFC\x3F\xDE\x0F\x8C\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" // & +"\x00\xE0\x00\xC0\x01\xC0\x01\x80\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" // ' +"\x00\x40\x00\xC0\x01\xC0\x01\x80\x03\x80\x03\x80\x07\x00\x07\x00\x07\x00\x07\x00\x07\x00\x07\x00\x07\x00\x07\x00\x03\x80\x03\x80\x01\x80\x01\xC0\x00\xC0\x00\x40\x00\x00\x00\x00\x00\x00\x00\x00" // ( +"\x02\x00\x03\x00\x03\x80\x01\x80\x01\xC0\x01\xC0\x00\xE0\x00\xE0\x00\xE0\x00\xE0\x00\xE0\x00\xE0\x00\xE0\x00\xE0\x01\xC0\x01\xC0\x01\x80\x03\x80\x03\x00\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00" // ) +"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xC0\x00\xC0\x00\xC0\x06\xD8\x07\xF8\x00\xC0\x01\xE0\x03\x30\x03\x10\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" // * +"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x80\x01\x80\x01\x80\x01\x80\x1F\xF8\x1F\xF8\x01\x80\x01\x80\x01\x80\x01\x80\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" // + +"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x03\x00\x03\x80\x03\x80\x01\x80\x01\x80\x03\x00\x00\x00\x00\x00" // , +"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0F\xF0\x0F\xF0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" // - +"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x03\x80\x03\x80\x03\x80\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" // . +"\x00\x30\x00\x70\x00\x70\x00\x60\x00\xE0\x00\xE0\x00\xE0\x00\xC0\x01\xC0\x01\xC0\x01\xC0\x01\x80\x03\x80\x03\x80\x03\x80\x03\x00\x07\x00\x07\x00\x06\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" // / +"\x00\x00\x07\xE0\x0F\xF0\x1F\xF8\x1C\x38\x38\x1C\x38\x1C\x38\x1C\x38\x1C\x38\x1C\x38\x1C\x38\x1C\x38\x1C\x38\x1C\x38\x1C\x1C\x38\x1F\xF8\x0F\xF0\x07\xE0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" // 0 +"\x00\x00\x00\x60\x00\xE0\x01\xE0\x03\xE0\x07\xE0\x1F\xE0\x1C\xE0\x18\xE0\x00\xE0\x00\xE0\x00\xE0\x00\xE0\x00\xE0\x00\xE0\x00\xE0\x00\xE0\x00\xE0\x00\xE0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" // 1 +"\x00\x00\x07\xE0\x1F\xF8\x1F\xF8\x3C\x3C\x38\x1C\x38\x1C\x00\x1C\x00\x38\x00\x78\x00\xF0\x03\xE0\x07\x80\x0F\x00\x1E\x00\x3C\x00\x3F\xF8\x3F\xFC\x3F\xFC\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" // 2 +"\x00\x00\x07\xE0\x0F\xF0\x1F\xF8\x3C\x78\x38\x38\x00\x38\x00\x78\x01\xF0\x01\xF0\x00\xF8\x00\x3C\x30\x1C\x38\x1C\x38\x3C\x3C\x78\x1F\xF8\x0F\xF0\x07\xE0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" // 3 +"\x00\x00\x00\x60\x00\xF0\x00\xF0\x01\xF0\x03\xF0\x03\x70\x07\x70\x0E\x70\x0C\x70\x1C\x70\x38\x70\x38\x70\x3F\xFC\x3F\xFC\x00\x70\x00\x70\x00\x70\x00\x70\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" // 4 +"\x00\x00\x1F\xFC\x1F\xFC\x1F\xF8\x1C\x00\x1C\x00\x1C\x00\x1F\xE0\x1F\xF0\x1F\xF8\x1C\x3C\x00\x1C\x00\x1C\x00\x1C\x38\x1C\x3C\x38\x3F\xF8\x1F\xF0\x07\xE0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" // 5 +"\x00\x00\x03\xE0\x0F\xF0\x1F\xF8\x1C\x38\x3C\x18\x38\x00\x38\x00\x3B\xE0\x3F\xF0\x3F\xF8\x3C\x3C\x38\x1C\x38\x1C\x38\x1C\x1C\x3C\x1F\xF8\x0F\xF0\x03\xE0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" // 6 +"\x00\x00\x3F\xFC\x3F\xFC\x1F\xFC\x00\x38\x00\x70\x00\x70\x00\xE0\x01\xC0\x01\xC0\x03\x80\x03\x80\x03\x80\x07\x80\x07\x00\x07\x00\x07\x00\x07\x00\x06\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" // 7 +"\x00\x00\x07\xE0\x0F\xF0\x1F\xF8\x1E\x78\x1C\x38\x1C\x38\x1E\x78\x0F\xF0\x0F\xF0\x1C\x38\x38\x1C\x38\x1C\x38\x1C\x38\x1C\x3C\x3C\x1F\xF8\x0F\xF0\x07\xE0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" // 8 +"\x00\x00\x07\xC0\x0F\xF0\x1F\xF8\x3C\x38\x38\x1C\x38\x1C\x38\x1C\x3C\x3C\x1F\xFC\x0F\xFC\x07\xDC\x00\x1C\x00\x1C\x18\x3C\x1C\x38\x1F\xF8\x0F\xF0\x07\xC0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" // 9 +"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x03\x80\x03\x80\x03\x80\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x03\x80\x03\x80\x03\x80\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" // : +"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x03\x80\x03\x80\x03\x80\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x03\x00\x03\x80\x03\x80\x01\x80\x01\x80\x03\x00\x02\x00\x00\x00" // ; +"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x08\x00\x38\x00\xF8\x03\xF8\x0F\xC0\x1F\x00\x1C\x00\x1F\x00\x0F\xC0\x03\xF8\x00\xF8\x00\x38\x00\x08\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" // < +"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x3F\xFC\x3F\xFC\x3F\xFC\x00\x00\x00\x00\x3F\xFC\x3F\xFC\x3F\xFC\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" // = +"\x00\x00\x00\x00\x00\x00\x10\x00\x1C\x00\x1F\x00\x1F\xC0\x03\xF0\x00\xF8\x00\x38\x00\xF8\x03\xF0\x1F\xC0\x1F\x00\x1C\x00\x10\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" // > +"\x07\xC0\x0F\xF0\x1F\xF0\x3C\x78\x38\x38\x38\x38\x30\x38\x00\x70\x00\xF0\x01\xE0\x03\xC0\x03\x80\x03\x80\x01\x00\x00\x00\x03\x80\x03\x80\x03\x80\x03\x80\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" // ? +"\x00\x00\x00\x00\x00\x00\x00\x00\x03\xE0\x0F\xF8\x1C\x1C\x10\x04\x23\xB6\x27\xF2\x4C\x72\x5C\x62\x58\x62\x58\x62\x58\x64\x58\xEC\x6F\xF8\x27\x70\x30\x06\x18\x0C\x0F\xFC\x03\xF0\x00\x00\x00\x00" // @ +"\x00\x00\x00\x00\x01\x80\x03\xC0\x03\xC0\x07\xE0\x07\xE0\x0E\x60\x0E\x70\x0E\x70\x1C\x78\x1C\x38\x1C\x38\x3F\xFC\x3F\xFC\x38\x1C\x70\x0E\x70\x0E\x60\x0E\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" // A +"\x00\x00\x00\x00\x3F\xE0\x3F\xF0\x38\x78\x38\x38\x38\x38\x38\x38\x38\x38\x3F\xF0\x3F\xF0\x38\x38\x38\x1C\x38\x1C\x38\x1C\x38\x1C\x38\x3C\x3F\xF8\x3F\xF0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" // B +"\x00\x00\x00\x00\x07\xE0\x0F\xF0\x1E\x78\x3C\x3C\x38\x1C\x78\x0C\x70\x00\x70\x00\x70\x00\x70\x00\x70\x0C\x70\x0C\x38\x1C\x3C\x3C\x1E\x78\x0F\xF0\x07\xE0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" // C +"\x00\x00\x00\x00\x3F\xC0\x3F\xF0\x38\xF0\x38\x78\x38\x38\x38\x1C\x38\x1C\x38\x1C\x38\x1C\x38\x1C\x38\x1C\x38\x1C\x38\x38\x38\x78\x38\xF0\x3F\xF0\x3F\xC0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" // D +"\x00\x00\x00\x00\x1F\xFC\x1F\xFC\x1C\x00\x1C\x00\x1C\x00\x1C\x00\x1C\x00\x1F\xF8\x1F\xF8\x1C\x00\x1C\x00\x1C\x00\x1C\x00\x1C\x00\x1C\x00\x1F\xFC\x1F\xFC\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" // E +"\x00\x00\x00\x00\x0F\xFC\x0F\xFC\x0E\x00\x0E\x00\x0E\x00\x0E\x00\x0E\x00\x0F\xF8\x0F\xF8\x0E\x00\x0E\x00\x0E\x00\x0E\x00\x0E\x00\x0E\x00\x0E\x00\x0E\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" // F +"\x00\x00\x00\x00\x03\xE0\x0F\xF8\x1C\x3C\x38\x1C\x38\x0E\x70\x0C\x70\x00\x70\x00\x70\xFE\x70\xFE\x70\x0E\x70\x0E\x38\x0E\x38\x0E\x1C\x3E\x0F\xFC\x03\xF0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" // G +"\x00\x00\x00\x00\x38\x1C\x38\x1C\x38\x1C\x38\x1C\x38\x1C\x38\x1C\x38\x1C\x3F\xFC\x3F\xFC\x38\x1C\x38\x1C\x38\x1C\x38\x1C\x38\x1C\x38\x1C\x38\x1C\x38\x1C\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" // H +"\x00\x00\x00\x00\x03\x80\x03\x80\x03\x80\x03\x80\x03\x80\x03\x80\x03\x80\x03\x80\x03\x80\x03\x80\x03\x80\x03\x80\x03\x80\x03\x80\x03\x80\x03\x80\x03\x80\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" // I +"\x00\x00\x00\x00\x00\xE0\x00\xE0\x00\xE0\x00\xE0\x00\xE0\x00\xE0\x00\xE0\x00\xE0\x00\xE0\x00\xE0\x70\xE0\x70\xE0\x70\xE0\x79\xE0\x3F\xC0\x3F\xC0\x0F\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" // J +"\x00\x00\x00\x00\x38\x0C\x38\x1C\x38\x3C\x38\x78\x38\xF0\x39\xE0\x3B\xC0\x3F\xC0\x3F\xE0\x3E\xF0\x3C\x70\x38\x78\x38\x3C\x38\x3C\x38\x1E\x38\x0E\x38\x0E\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" // K +"\x00\x00\x00\x00\x1C\x00\x1C\x00\x1C\x00\x1C\x00\x1C\x00\x1C\x00\x1C\x00\x1C\x00\x1C\x00\x1C\x00\x1C\x00\x1C\x00\x1C\x00\x1C\x00\x1C\x00\x1F\xF8\x1F\xF8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" // L +"\x00\x00\x00\x00\xF8\x1F\xF8\x1F\xFC\x3F\xFC\x3F\xFC\x3F\xEC\x37\xEE\x77\xEE\x77\xEE\x77\xE6\x67\xE7\xE7\xE7\xE7\xE7\xE7\xE3\xC7\xE3\xC7\xE3\xC7\xE1\x87\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" // M +"\x00\x00\x00\x00\x18\x1C\x3C\x1C\x3C\x1C\x3E\x1C\x3E\x1C\x3F\x1C\x3B\x1C\x3B\x9C\x39\x9C\x39\xDC\x38\xDC\x38\xFC\x38\x7C\x38\x7C\x38\x3C\x38\x3C\x38\x1C\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" // N +"\x00\x00\x00\x00\x07\xE0\x0F\xF0\x1F\xF8\x3C\x3C\x38\x1C\x78\x1E\x70\x0E\x70\x0E\x70\x0E\x70\x0E\x70\x0E\x78\x1E\x38\x1C\x3C\x3C\x1F\xF8\x0F\xF0\x07\xE0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" // O +"\x00\x00\x00\x00\x3F\xF0\x3F\xF8\x38\x3C\x38\x1C\x38\x1C\x38\x1C\x38\x1C\x38\x38\x3F\xF8\x3F\xE0\x38\x00\x38\x00\x38\x00\x38\x00\x38\x00\x38\x00\x38\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" // P +"\x00\x00\x00\x00\x07\xE0\x0F\xF0\x1F\xF8\x3C\x3C\x38\x1C\x78\x0E\x70\x0E\x70\x0E\x70\x0E\x70\x0E\x70\x0E\x79\x9E\x38\xFC\x3C\x7C\x1F\xF8\x0F\xFE\x07\xEF\x00\x07\x00\x00\x00\x00\x00\x00\x00\x00" // Q +"\x00\x00\x00\x00\x3F\xF8\x3F\xFC\x38\x1E\x38\x0E\x38\x0E\x38\x0E\x38\x1E\x3F\xFC\x3F\xF0\x38\xE0\x38\x70\x38\x78\x38\x3C\x38\x3C\x38\x1E\x38\x0E\x38\x0E\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" // R +"\x00\x00\x00\x00\x07\xE0\x1F\xF0\x1C\x38\x38\x38\x38\x18\x3C\x00\x3F\x00\x1F\xE0\x0F\xF8\x01\xF8\x00\x3C\x30\x1C\x38\x1C\x38\x1C\x3C\x38\x1F\xF8\x07\xE0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" // S +"\x00\x00\x00\x00\x7F\xFC\x7F\xFC\x03\x80\x03\x80\x03\x80\x03\x80\x03\x80\x03\x80\x03\x80\x03\x80\x03\x80\x03\x80\x03\x80\x03\x80\x03\x80\x03\x80\x03\x80\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" // T +"\x00\x00\x00\x00\x38\x1C\x38\x1C\x38\x1C\x38\x1C\x38\x1C\x38\x1C\x38\x1C\x38\x1C\x38\x1C\x38\x1C\x38\x1C\x38\x1C\x38\x1C\x3C\x38\x1F\xF8\x0F\xF0\x07\xE0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" // U +"\x00\x00\x00\x00\x38\x06\x38\x0E\x38\x0E\x1C\x1C\x1C\x1C\x1C\x1C\x0E\x18\x0E\x38\x0E\x38\x0E\x30\x07\x70\x07\x70\x07\x60\x03\xE0\x03\xE0\x03\xC0\x01\xC0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" // V +"\x00\x00\x00\x00\xC1\x83\xC3\xC3\xE3\xC7\xE3\xC7\xE3\xC7\x63\xC6\x66\x66\x66\x66\x76\x6E\x76\x6E\x36\x6C\x3C\x3C\x3C\x3C\x3C\x3C\x3C\x3C\x1C\x38\x18\x18\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" // W +"\x00\x00\x00\x00\x30\x0C\x38\x1E\x3C\x1C\x1C\x3C\x1E\x78\x0F\xF0\x07\xF0\x07\xE0\x03\xC0\x07\xE0\x0F\xF0\x1F\xF8\x1E\x78\x3C\x3C\x78\x1E\x78\x1E\x70\x0E\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" // X +"\x00\x00\x00\x00\x30\x18\x78\x1C\x38\x38\x3C\x38\x1C\x70\x1E\xF0\x0E\xE0\x07\xC0\x07\xC0\x03\x80\x03\x80\x03\x80\x03\x80\x03\x80\x03\x80\x03\x80\x03\x80\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" // Y +"\x00\x00\x00\x00\x3F\xF8\x3F\xF8\x00\x78\x00\x78\x00\xF0\x01\xF0\x01\xE0\x03\xC0\x07\x80\x07\x80\x0F\x00\x1E\x00\x1E\x00\x3C\x00\x78\x00\x7F\xFC\x7F\xFC\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" // Z +"\x00\x00\x01\xE0\x01\xE0\x01\x80\x01\x80\x01\x80\x01\x80\x01\x80\x01\x80\x01\x80\x01\x80\x01\x80\x01\x80\x01\x80\x01\x80\x01\x80\x01\x80\x01\x80\x01\x80\x01\x80\x01\xE0\x01\xE0\x00\x00\x00\x00" // [ +"\x00\x00\x00\x00\x0C\x00\x1E\x00\x0E\x00\x0F\x00\x07\x00\x07\x00\x07\x80\x03\x80\x03\x80\x03\xC0\x01\xC0\x01\xC0\x01\xE0\x00\xE0\x00\xE0\x00\xF0\x00\x70\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" // +"\x00\x00\x0F\x80\x0F\x80\x01\x80\x01\x80\x01\x80\x01\x80\x01\x80\x01\x80\x01\x80\x01\x80\x01\x80\x01\x80\x01\x80\x01\x80\x01\x80\x01\x80\x01\x80\x01\x80\x01\x80\x0F\x80\x0F\x80\x00\x00\x00\x00" // ] +"\x00\x00\x00\x00\x03\x80\x07\x80\x07\x80\x07\xC0\x0E\xC0\x0C\xE0\x1C\xE0\x1C\x60\x38\x70\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" // ^ +"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xFF\xFF\x00\x00\x00\x00\x00\x00\x00\x00" // _ +"\x00\x00\x00\x00\x1C\x00\x3E\x00\x63\x00\x63\x00\x63\x00\x3E\x00\x1C\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" // ` +"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0F\xC0\x1F\xE0\x18\x70\x10\x70\x00\xF0\x0F\xF0\x1E\x70\x38\x70\x38\x70\x38\xF0\x1F\xF0\x0E\x38\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" // a +"\x00\x00\x00\x00\x1C\x00\x1C\x00\x1C\x00\x1C\x00\x1C\x00\x1D\xF0\x1F\xF8\x1E\x38\x1E\x1C\x1C\x1C\x1C\x1C\x1C\x1C\x1C\x1C\x1E\x1C\x1E\x38\x1F\xF8\x1D\xE0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" // b +"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x07\xC0\x0F\xF0\x1C\x70\x3C\x38\x38\x10\x38\x00\x38\x00\x38\x10\x3C\x38\x1C\x78\x0F\xF0\x07\xC0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" // c +"\x00\x00\x00\x00\x00\x38\x00\x38\x00\x38\x00\x38\x00\x38\x0F\xB8\x1F\xF8\x1C\x78\x38\x78\x38\x38\x38\x38\x38\x38\x38\x38\x38\x78\x1C\x78\x1F\xF8\x07\xB8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" // d +"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x07\xC0\x0F\xE0\x1C\x70\x38\x38\x38\x38\x3F\xF8\x3F\xF0\x38\x00\x38\x10\x1C\x38\x0F\xF0\x07\xC0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" // e +"\x00\x00\x00\x00\x03\xE0\x07\xE0\x07\x00\x07\x00\x07\x00\x1F\xC0\x1F\xC0\x07\x00\x07\x00\x07\x00\x07\x00\x07\x00\x07\x00\x07\x00\x07\x00\x07\x00\x07\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" // f +"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0F\xB8\x1F\xF8\x1C\x78\x38\x38\x38\x38\x38\x38\x38\x38\x38\x38\x38\x38\x1C\x78\x1F\xF8\x07\xB8\x10\x38\x38\x38\x1C\x70\x1F\xF0\x07\xC0" // g +"\x00\x00\x00\x00\x38\x00\x38\x00\x38\x00\x38\x00\x38\x00\x3B\xC0\x3F\xE0\x3C\xF0\x38\x70\x38\x70\x38\x70\x38\x70\x38\x70\x38\x70\x38\x70\x38\x70\x38\x70\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" // h +"\x00\x00\x00\x00\x03\x80\x03\x80\x03\x80\x00\x00\x00\x00\x03\x80\x03\x80\x03\x80\x03\x80\x03\x80\x03\x80\x03\x80\x03\x80\x03\x80\x03\x80\x03\x80\x03\x80\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" // i +"\x00\x00\x00\x00\x03\x80\x03\x80\x03\x80\x00\x00\x00\x00\x03\x80\x03\x80\x03\x80\x03\x80\x03\x80\x03\x80\x03\x80\x03\x80\x03\x80\x03\x80\x03\x80\x03\x80\x03\x80\x03\x80\x03\x80\x1F\x80\x1F\x00" // j +"\x00\x00\x00\x00\x0E\x00\x0E\x00\x0E\x00\x0E\x00\x0E\x00\x0E\x18\x0E\x38\x0E\x70\x0E\xE0\x0F\xC0\x0F\xE0\x0F\x70\x0E\x70\x0E\x38\x0E\x38\x0E\x1C\x0E\x0C\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" // k +"\x00\x00\x00\x00\x03\x80\x03\x80\x03\x80\x03\x80\x03\x80\x03\x80\x03\x80\x03\x80\x03\x80\x03\x80\x03\x80\x03\x80\x03\x80\x03\x80\x03\x80\x03\x80\x03\x80\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" // l +"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xEF\x9E\xFF\xFF\xF1\xE7\xE1\xC7\xE1\xC7\xE1\xC7\xE1\xC7\xE1\xC7\xE1\xC7\xE1\xC7\xE1\xC7\xE1\xC7\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" // m +"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x1D\xE0\x1F\xF0\x1E\x78\x1C\x38\x1C\x38\x1C\x38\x1C\x38\x1C\x38\x1C\x38\x1C\x38\x1C\x38\x1C\x38\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" // n +"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0F\x80\x1F\xC0\x38\xE0\x70\x70\x70\x70\x70\x70\x70\x70\x70\x70\x70\x70\x38\xE0\x1F\xC0\x0F\x80\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" // o +"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x3B\xC0\x3F\xF0\x3C\x70\x3C\x38\x38\x38\x38\x38\x38\x38\x38\x38\x3C\x38\x3C\x70\x3F\xF0\x3B\xC0\x38\x00\x38\x00\x38\x00\x38\x00\x38\x00" // p +"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x07\xB8\x1F\xF8\x1C\x78\x38\x78\x38\x38\x38\x38\x38\x38\x38\x38\x38\x78\x1C\x78\x1F\xF8\x07\xB8\x00\x38\x00\x38\x00\x38\x00\x38\x00\x38" // q +"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0E\xE0\x0F\xF0\x0F\x10\x0E\x00\x0E\x00\x0E\x00\x0E\x00\x0E\x00\x0E\x00\x0E\x00\x0E\x00\x0E\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" // r +"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x07\xC0\x0F\xF0\x1C\x70\x1C\x30\x1F\x00\x0F\xE0\x03\xF0\x00\x78\x1C\x38\x1E\x38\x0F\xF0\x07\xE0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" // s +"\x00\x00\x00\x00\x03\x80\x03\x80\x03\x80\x03\x80\x03\x80\x07\xE0\x0F\xE0\x03\x80\x03\x80\x03\x80\x03\x80\x03\x80\x03\x80\x03\x80\x03\x80\x03\xF0\x01\xF0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" // t +"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x1C\x38\x1C\x38\x1C\x38\x1C\x38\x1C\x38\x1C\x38\x1C\x38\x1C\x38\x1C\x38\x1E\x78\x0F\xF8\x07\xB8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" // u +"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x18\x18\x1C\x38\x1C\x38\x0C\x30\x0E\x70\x0E\x70\x06\x60\x07\xE0\x03\xC0\x03\xC0\x03\xC0\x01\x80\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" // v +"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xC1\x83\xE3\xC7\xE3\xC7\x63\xC6\x67\xE6\x76\x6E\x36\x6C\x36\x6C\x3E\x7C\x1C\x38\x1C\x38\x1C\x38\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" // w +"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x38\x38\x3C\x78\x1E\xF0\x0F\xE0\x07\xC0\x07\xC0\x0F\xE0\x0E\xE0\x1E\xF0\x3C\x78\x38\x38\x30\x38\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" // x +"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x18\x18\x1C\x38\x1C\x38\x0C\x30\x0E\x70\x0E\x70\x06\x60\x07\x60\x07\xE0\x03\xC0\x03\xC0\x03\xC0\x01\x80\x03\x80\x03\x80\x1F\x00\x1E\x00" // y +"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x3F\xF8\x3F\xF8\x00\x78\x00\xF0\x01\xE0\x03\xC0\x07\x80\x07\x00\x0E\x00\x1E\x00\x3F\xF8\x3F\xF8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" // z +"\x00\x70\x00\xF0\x01\xF0\x01\xC0\x01\xC0\x01\xC0\x01\xC0\x01\xC0\x01\xC0\x03\x80\x07\x80\x07\x80\x03\x80\x01\xC0\x01\xC0\x01\xC0\x01\xC0\x01\xC0\x01\xC0\x01\xF0\x00\xF0\x00\x70\x00\x00\x00\x00" // { +"\x03\x80\x03\x80\x03\x80\x03\x80\x03\x80\x03\x80\x03\x80\x03\x80\x03\x80\x03\x80\x03\x80\x03\x80\x03\x80\x03\x80\x03\x80\x03\x80\x03\x80\x03\x80\x03\x80\x03\x80\x03\x80\x03\x80\x00\x00\x00\x00" // | +"\x1C\x00\x1E\x00\x1F\x00\x07\x00\x07\x00\x07\x00\x07\x00\x07\x00\x07\x00\x03\x80\x03\xC0\x03\xC0\x03\x80\x07\x00\x07\x00\x07\x00\x07\x00\x07\x00\x07\x00\x1F\x00\x1E\x00\x1C\x00\x00\x00\x00\x00" // } +"\x00\x00\x00\x00\x00\x00\x1E\x08\x3F\xF8\x3F\xF8\x20\xF0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", // ~ +width:16, height:24, first:32, last:126, size_w:16, size_h:24}; \ No newline at end of file diff --git a/main.c b/main.c new file mode 100644 index 0000000..74b6575 --- /dev/null +++ b/main.c @@ -0,0 +1,643 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "debugScreen.h" +#include "np.h" + +#define printf psvDebugScreenPrintf +#define F psvDebugScreenFont +#define SCREEN_COL (SCREEN_WIDTH / F.size_w) +#define SCREEN_ROW (SCREEN_HEIGHT / F.size_h) +#define CENTERX(buf) ((SCREEN_COL - strlen(buf)) / 2) +#define CENTERY (SCREEN_ROW / 2) +#define WINDOW_HEIGHT (SCREEN_ROW - 4) +#define DISPLAY_COLOR_FORMAT SCE_GXM_COLOR_FORMAT_A8B8G8R8 + + +SceCtrlData pad; + +/* + * FUCK YOU SONY + * + * MAKING ME FUCKIN INIT libGxm + */ + +#define DISPLAY_WIDTH 960 +#define DISPLAY_HEIGHT 544 +#define DISPLAY_STRIDE_IN_PIXELS 1024 +#define DISPLAY_BUFFER_COUNT 2 +#define DISPLAY_MAX_PENDING_SWAPS 1 +#define ALIGN(x, a) (((x) + ((a) - 1)) & ~((a) - 1)) + +typedef struct{ + void*data; + SceGxmSyncObject*sync; + SceGxmColorSurface surf; + SceUID uid; +}displayBuffer; + +void gxm_vsync_cb(const void *callback_data){ + sceDisplaySetFrameBuf(&(SceDisplayFrameBuf){sizeof(SceDisplayFrameBuf), + *((void **)callback_data),DISPLAY_STRIDE_IN_PIXELS, 0, + DISPLAY_WIDTH,DISPLAY_HEIGHT}, SCE_DISPLAY_SETBUF_NEXTFRAME); +} + +displayBuffer dbuf[DISPLAY_BUFFER_COUNT]; + +void *dram_alloc(unsigned int size, SceUID *uid){ + void *mem; + *uid = sceKernelAllocMemBlock("gpu_mem", SCE_KERNEL_MEMBLOCK_TYPE_USER_CDRAM_RW, ALIGN(size,256*1024), NULL); + sceKernelGetMemBlockBase(*uid, &mem); + sceGxmMapMemory(mem, ALIGN(size,256*1024), SCE_GXM_MEMORY_ATTRIB_READ | SCE_GXM_MEMORY_ATTRIB_WRITE); + return mem; +} + +void gxm_init(){ + int ret = 0; + ret = sceGxmInitialize(&(SceGxmInitializeParams){0,DISPLAY_MAX_PENDING_SWAPS,gxm_vsync_cb,sizeof(void *),SCE_GXM_DEFAULT_PARAMETER_BUFFER_SIZE}); + + if(ret < 0){ + printf("sceGxmInitialize() failed. ret = 0x%x\n", ret); + while(1){}; + } + + unsigned int i; + for (i = 0; i < DISPLAY_BUFFER_COUNT; i++) { + dbuf[i].data = dram_alloc(4*DISPLAY_STRIDE_IN_PIXELS*DISPLAY_HEIGHT, &dbuf[i].uid); + sceGxmColorSurfaceInit(&dbuf[i].surf,SCE_GXM_COLOR_FORMAT_A8B8G8R8,SCE_GXM_COLOR_SURFACE_LINEAR,SCE_GXM_COLOR_SURFACE_SCALE_NONE,SCE_GXM_OUTPUT_REGISTER_SIZE_32BIT,DISPLAY_WIDTH,DISPLAY_HEIGHT,DISPLAY_STRIDE_IN_PIXELS,dbuf[i].data); + sceGxmSyncObjectCreate(&dbuf[i].sync); + } +} + + +/* + * FUCK YOU SONY + * + * MAKING ME FUCKIN INIT libGxm + */ + + + +char titleid[12]; +char g_currentMount[16]; +char g_currentPath[PATH_MAX]; + +typedef struct paths { +char path[1024]; +} paths; + + +void updateCommonDiag() +{ + int ret = 0; + SceCommonDialogUpdateParam updateParam; + ScePVoid color; + + memset(&updateParam, 0, sizeof(updateParam)); + updateParam.renderTarget.colorFormat = DISPLAY_COLOR_FORMAT; + updateParam.renderTarget.surfaceType = SCE_GXM_COLOR_SURFACE_LINEAR; + updateParam.renderTarget.width = DISPLAY_WIDTH; + updateParam.renderTarget.height = DISPLAY_HEIGHT; + updateParam.renderTarget.strideInPixels = DISPLAY_STRIDE_IN_PIXELS; + + updateParam.renderTarget.colorSurfaceData = color; + ret = sceCommonDialogUpdate(&updateParam); + if(ret < 0){ + printf("sceCommonDialogUpdate() failed. ret = 0x%x\n", ret); + while(1){}; + } +} +int isSceCommonDiagRunning() +{ + + SceCommonDialogStatus cdStatus; + + cdStatus = sceNpTrophySetupDialogGetStatus(); + + + + if (cdStatus == SCE_COMMON_DIALOG_STATUS_RUNNING) + { + return 1; + } + else if (cdStatus == SCE_COMMON_DIALOG_STATUS_FINISHED) + { + return 0; + } + else + { + return -1; + } +} + + +int WriteFile(char *file, void *buf, int size) { + SceUID fd = sceIoOpen(file, SCE_O_RDWR | SCE_O_CREAT, 0777); + if (fd < 0) + return fd; + + int written = sceIoWrite(fd, buf, size); + + sceIoClose(fd); + return written; +} + +int ReadFile(char *file, void *buf, int size) { + SceUID fd = sceIoOpen(file,SCE_O_RDONLY, 0777); + if (fd < 0) + return fd; + + int read = sceIoRead(fd, buf, size); + + sceIoClose(fd); + return read; +} + + + +int getFileSize(const char *file) { + SceUID fd = sceIoOpen(file, SCE_O_RDONLY, 0); + if (fd < 0) + return fd; + int fileSize = sceIoLseek(fd, 0, SCE_SEEK_END); + sceIoClose(fd); + return fileSize; +} + + + + +int knomn_pfs_ids[] = { + 0x3E8, + 0x12F, +}; + +int pfsMount(const char *path) { + int ret; + char klicensee[0x10]; + SceAppMgrMountIdArgs args; + + memset(klicensee, 0, sizeof(klicensee)); + + args.process_titleid = titleid; + args.path = path; + args.desired_mount_point = NULL; + args.klicensee = klicensee; + args.mount_point = g_currentMount; + + for(int i=0;i= 0){ + + return ret; + + } + + } + + return ret; +} + + + +void sceNpTrophySetupDialogParamInit(SceNpTrophySetupDialogParam* param) +{ + sceClibMemset( param, 0x0, sizeof(SceNpTrophySetupDialogParam) ); + _sceCommonDialogSetMagicNumber( ¶m->commonParam ); + param->sdkVersion = 0x03550011; + param->context = -1; + param->options = 0; +} + + + + +int main() { + gxm_init(); +start: + psvDebugScreenInit(); + + + int size = 0; + + int dfd = sceIoDopen("ur0:user/00/trophy/data/"); + int res; + do { + SceIoDirent dir; + memset(&dir, 0, sizeof(SceIoDirent)); + res = sceIoDread(dfd, &dir); + if (res > 0 && SCE_S_ISDIR(dir.d_stat.st_mode) && strcmp(dir.d_name,"sce_trop") != 0) { + size += 1; + }} while (res > 0); + sceIoDclose(dfd); + + + paths *title_list = malloc(sizeof(paths)*size); + + int a = 0; + dfd = sceIoDopen("ur0:/user/00/trophy/data/"); + do { + SceIoDirent dir; + memset(&dir, 0, sizeof(SceIoDirent)); + res = sceIoDread(dfd, &dir); + if (res > 0 && SCE_S_ISDIR(dir.d_stat.st_mode) && strcmp(dir.d_name,"sce_trop") != 0) { + char path[1024]; + sprintf(path,"ur0:/user/00/trophy/conf/%s/TROP.SFM",dir.d_name); + int sfmsize = getFileSize(path); + char *sfm = malloc(sfmsize); + char titledest[256]; + + ReadFile(path,sfm,sfmsize); + + int len = strstr(sfm,"") - (strstr(sfm,"") + sizeof("")) - 1; + len += 2; + memcpy(&titledest, strstr(sfm,"") + sizeof("") - 1, len); + titledest[len] = 0; + + char name[1024]; + sprintf(name,"%s (%s)\n",titledest,dir.d_name); + + strcpy(title_list[a].path, name); + a += 1; + }} while (res > 0); + sceIoDclose(dfd); + + int x = 1, y = 1, selection = 0, window = 0; + + + + + + do + { + char buf[256]; + strncpy(buf, "**** TropHax SE ****", sizeof(buf)); + printf("\e[%i;%iH%s", 1, CENTERX(buf), buf); + strncpy(buf, "Choose a game", sizeof(buf)); + printf("\e[%i;%iH%s", 2, CENTERX(buf), buf); + y = 3; + int max = (size < WINDOW_HEIGHT) ? size : WINDOW_HEIGHT; + for (int i=0; i < max; i++) { + if (i+window == selection) + psvDebugScreenSetFgColor(0xFF0000); + printf("\e[%i;%iH%s", y, x, title_list[i+window].path); + y += 1; + psvDebugScreenSetFgColor(0xFFFFFF); + } + strncpy(buf, "U/D: Select Game X: Confirm O: Exit", sizeof(buf)); + printf("\e[%i;%iH%s", SCREEN_ROW, CENTERX(buf), buf); + memset(&pad, 0, sizeof(pad)); + sceCtrlPeekBufferPositive(0, &pad, 1); + + if (pad.buttons == SCE_CTRL_UP) + { + if (selection <= size - WINDOW_HEIGHT) + window -= 1; + if (window < 0) + window = 0; + selection -= 1; + if (selection < 0) + selection = 0; + sceKernelDelayThread(150000); + } + if (pad.buttons == SCE_CTRL_DOWN) + { + if (selection >= WINDOW_HEIGHT - 1) + + window += 1; + if (window > size - WINDOW_HEIGHT) + window = (size - WINDOW_HEIGHT < 0) ? 0 : size - WINDOW_HEIGHT; + selection += 1; + if (selection + 1 > size - 1) + selection = size - 1; + sceKernelDelayThread(150000); + } + if (pad.buttons == SCE_CTRL_CROSS) + { + psvDebugScreenInit(); + printf("\n"); + printf("Preforming TrophyPatcher Operations Please wait ..."); + + int ret = sceAppMgrUmount("app0:"); + if(ret < 0){ + printf("sceAppMgrUmount() failed. ret = 0x%x\n", ret); + while(1){}; + } + + char kplugin_path[0x200]; + char uplugin_path[0x200]; + sceAppMgrAppParamGetString(0, 12, titleid , 256); + + sprintf(kplugin_path, "ux0:app/%s/module/kernel.skprx", titleid); + sprintf(uplugin_path, "ux0:app/%s/module/user.suprx", titleid); + + int kernel_modid, user_modid; + + kernel_modid = taiLoadStartKernelModule(kplugin_path, 0, NULL, 0); + user_modid = sceKernelLoadStartModule(uplugin_path, 0, NULL, 0, NULL, NULL); + + + char trophy_path[0x200]; + + + + + SceUChar8 commid[256]; + memset(commid,0,256); + char name[1024]; + memset(name,0,256); + char titleidOfGame[256]; + memset(titleidOfGame,0,256); + char trptranspath[1024]; + memset(trptranspath,0,1024); + char trptitlepath[1024]; + memset(trptitlepath,0,1024); + SceUChar8 commsign[160]; + memset(commsign,0,160); + + char path[1024]; + + SceUID fd; + int len; + int size; + + + sprintf(name,"%s",title_list[selection].path); + len = strstr(name,")") - (strstr(name,"(") + sizeof("(")) - 1; + len +=2; + memcpy(&commid, strstr(name,"(") + sizeof("(") - 1, len); + commid[len] = 0; + sprintf(trophy_path, "ur0:user/00/trophy/data/%s/", commid); + ret = pfsMount(trophy_path); + if(ret < 0){ + printf("pfsMount() failed. ret = 0x%x\n", ret); + while(1){}; + } + + + sprintf(trptitlepath,"%s/TRPTITLE.DAT",g_currentMount); + + fd = sceIoOpen(trptitlepath,SCE_O_RDONLY, 0777); + sceIoLseek(fd,0x290,SCE_SEEK_SET); + sceIoRead(fd,titleidOfGame,0x0A); + sceIoClose(fd); + + sprintf(trptranspath,"%s/TRPTRANS.DAT",g_currentMount); + + fd = sceIoOpen(trptranspath,SCE_O_RDONLY, 0777); + sceIoLseek(fd,0x190,SCE_SEEK_SET); + sceIoRead(fd,commsign,160); + sceIoClose(fd); + + ret = sceAppMgrUmount(g_currentMount); + if(ret < 0){ + printf("sceAppMgrUmount() failed. ret = 0x%x\n", ret); + while(1){}; + } + + + if (strcmp(titleidOfGame,"NPXS10007") == 0) + { + ret = sceAppMgrGameDataMount("pd0:/app/NPXS10007",0,0,g_currentMount); + if(ret < 0){ + printf("sceAppMgrGameDataMount() failed. ret = 0x%x\n", ret); + while(1){}; + } + } + else + { + sprintf(path,"ux0:/app/%s",titleidOfGame); + ret = sceAppMgrGameDataMount(path,0,0,g_currentMount); + if(ret < 0){ + printf("sceAppMgrGameDataMount() failed. ret = 0x%x\n", ret); + while(1){}; + } + } + + + + memset(path,0,1024); + sprintf(path,"%s/sce_sys/trophy/%s/TROPHY.TRP",g_currentMount,commid); + size = getFileSize(path); + if (size >=0) + { + char *trpfile = malloc(size); + memset(trpfile,0,size); + ret = ReadFile(path,trpfile,size); + if(ret < 0){ + printf("ReadFile() failed. ret = 0x%x\n", ret); + while(1){}; + } + ret = ReadFile(path,trpfile,size); + if(ret < 0){ + printf("ReadFile() failed. ret = 0x%x\n", ret); + while(1){}; + } + + memset(path,0,1024); + sprintf(path,"ux0:app/%s/sce_sys",titleid); + sceIoMkdir(path,0006); + sprintf(path,"ux0:app/%s/sce_sys/trophy",titleid); + sceIoMkdir(path,0006); + sprintf(path,"ux0:app/%s/sce_sys/trophy/%s",titleid,commid); + sceIoMkdir(path,0006); + sprintf(path,"ux0:app/%s/sce_sys/trophy/%s/TROPHY.TRP",titleid,commid); + + ret = WriteFile(path,trpfile,size); + if(ret < 0){ + printf("WriteFile() failed. ret = 0x%x\n", ret); + while(1){}; + } + } + else + { + printf("getFileSize() failed. ret: 0x%x\n",size); + if (ret == 0x80010002) + { + printf("Possibly the game is not installed?\n"); + } + + while(1){}; + + } + ret = sceAppMgrUmount(g_currentMount); + if(ret < 0){ + printf("sceAppMgrUmount() failed. ret = 0x%x\n", ret); + while(1){}; + } + + + // remount app0 + // CelesteBlue TAKE NOTES. + memset(path,0,1024); + sprintf(path,"ux0:/app/%s",titleid); + ret = pfsMount(path); + if(ret < 0){ + printf("pfsMount() failed. ret = 0x%x\n", ret); + while(1){}; + } + + + printf("OK!\n"); + //Setup trophys + + printf("Setting up Trophys! Please wait ..."); + + ret = sceSysmoduleLoadModule(SCE_SYSMODULE_NP); + + if (ret < 0) { + printf("sceSysmoduleLoadModule(SCE_SYSMODULE_NP) failed. ret = 0x%x\n", ret); + while(1){}; + } + + ret = sceSysmoduleLoadModule(SCE_SYSMODULE_NP_TROPHY); + if (ret < 0) { + printf("sceSysmoduleLoadModule(SCE_SYSMODULE_NP_TROPHY) failed. ret = 0x%x\n", ret); + while(1){}; + } + + ret = sceNpTrophyInit(NULL); + if (ret < 0) { + printf("sceNpTrophyInit() failed. ret = 0x%x\n", ret); + while(1){}; + } + + SceNpTrophyContext trophyContext = -1; + + SceNpCommunicationId npCommId = {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},0,0,0}; + memcpy(npCommId.data,commid,9); + SceNpCommunicationSignature npCommSign; + memcpy(npCommSign.data,commsign,160); + SceNpTrophyHandle handle = -1; + + + ret = sceNpTrophyCreateContext(&trophyContext,&npCommId,&npCommSign,0); + if (ret < 0) { + printf("sceNpTrophyCreateContext() failed. ret = 0x%x\n", ret); + while(1){}; + } + + ret = sceNpTrophyCreateHandle(&handle); + if (ret < 0) { + printf("sceNpTrophyCreateHandle() failed. ret = 0x%x\n", ret); + while(1){}; + } + + + SceNpTrophySetupDialogParam setupParam; + + sceNpTrophySetupDialogParamInit(&setupParam); + + setupParam.context = trophyContext; + + ret = sceCommonDialogSetConfigParam(&(SceCommonDialogConfigParam){}); + if(ret < 0) { + printf("sceCommonDialogSetConfigParam() failed. ret = 0x%x\n", ret); + while(1){}; + } + + ret = sceNpTrophySetupDialogInit(&setupParam); + if(ret < 0){ + printf("sceNpTrophySetupDialogInit() failed. ret = 0x%x\n", ret); + while(1){}; + } + + + while(isSceCommonDiagRunning()) + { + updateCommonDiag(); + } + + SceNpTrophySetupDialogResult setupResult; + memset(&setupResult, 0, sizeof(setupResult)); + + ret = sceNpTrophySetupDialogGetResult(&setupResult); + if(ret < 0){ + printf("sceNpTrophySetupDialogGetResult() failed. ret = 0x%x\n", ret); + while(1){}; + } + + ret = sceNpTrophySetupDialogTerm(); + if(ret < 0){ + printf("sceNpTrophySetupDialogTerm() failed. ret = 0x%x\n", ret); + while(1){}; + } + + if (setupResult.result != SCE_COMMON_DIALOG_RESULT_OK){ + printf("Failed! %lx",setupResult.result); + while(1){} + } + + printf("OK!\n"); + + SceNpTrophyId id = 0; + SceNpTrophyId platid; + + while (1) + { + ret = sceNpTrophyUnlockTrophy(trophyContext,handle,id,&platid); + if(ret < 0){ + printf("sceNpTrophyUnlockTrophy() failed. ret = 0x%x\n", ret); + if(ret == 0x8055160e) + { + printf("All trophys unlocked!\n"); + break; + } + } + else + { + printf("Unlocked Trophy: %li ret: 0x%x\n",id,ret); + } + + id ++; + } + + ret = sceNpTrophyDestroyContext(trophyContext); + if(ret < 0){ + printf("sceNpTrophyDestroyContext() failed. ret = 0x%x\n", ret); + while(1){}; + } + + ret = sceNpTrophyDestroyHandle(handle); + if(ret < 0){ + printf("sceNpTrophyDestroyHandle() failed. ret = 0x%x\n", ret); + while(1){}; + } + + ret = sceNpTrophyTerm(); + if(ret < 0){ + printf("sceNpTrophyTerm() failed. ret = 0x%x\n", ret); + while(1){}; + } + + + sceKernelStopUnloadModule(user_modid, 0, NULL, 0, NULL, NULL); + taiStopUnloadKernelModule(kernel_modid, 0, NULL, 0, NULL, NULL); + + goto start; + + } + } while (pad.buttons != SCE_CTRL_CIRCLE); + + + + + sceKernelExitProcess(0); + return 0; +} + diff --git a/np.h b/np.h new file mode 100644 index 0000000..5d79f07 --- /dev/null +++ b/np.h @@ -0,0 +1,98 @@ +//define structs: + +//sceNpOptParam +typedef struct SceNpOptParam { + SceSize optParamSize; +} SceNpOptParam; + +//SceNpCommunicationId +/*typedef struct SceNpCommunicationId { + char data[9]; + char term; + SceUChar8 num; + char dummy; +} SceNpCommunicationId; + +allready in vitasdk?*/ + + +//SceNpCommunicationPassphrase +#define SCE_NP_COMMUNICATION_PASSPHRASE_SIZE (128) +typedef struct SceNpCommunicationPassphrase { + SceUChar8 data[SCE_NP_COMMUNICATION_PASSPHRASE_SIZE]; +} SceNpCommunicationPassphrase; + +//SceNpCommunicationSignature +#define SCE_NP_COMMUNICATION_SIGNATURE_SIZE (160) +typedef struct SceNpCommunicationSignature { + SceUChar8 data[SCE_NP_COMMUNICATION_SIGNATURE_SIZE]; +} SceNpCommunicationSignature; + +//SceNpCommunicationConfig +typedef struct SceNpCommunicationConfig { + const SceNpCommunicationId *commId; + const SceNpCommunicationPassphrase *commPassphrase; + const SceNpCommunicationSignature *commSignature; +} SceNpCommunicationConfig; + + + +//Define SceNpInit +int sceNpInit(const SceNpCommunicationConfig *commConf,SceNpOptParam *opt); + +//NP TROPHY: + +//structs: +typedef SceInt32 SceNpTrophyHandle; +typedef SceInt32 SceNpTrophyContext; +typedef SceInt32 SceNpTrophyId; +typedef SceInt32 SceNpTrophyGroupId; +typedef SceInt32 SceNpTrophyGrade; + +//functions + + +//Define sceNpTrophyInit +int sceNpTrophyInit(void *opt); +//Define sceNpTrophyCreateContext +int sceNpTrophyCreateContext(SceNpTrophyContext *context,const SceNpCommunicationId *commId,const SceNpCommunicationSignature *commSign,SceUInt64 options); +//Define sceNpTrophyCreateHandle +int sceNpTrophyCreateHandle(SceNpTrophyHandle *handle); +//Define sceNpTrophyUnlockTrophy +int sceNpTrophyUnlockTrophy(SceNpTrophyContext context,SceNpTrophyHandle handle,SceNpTrophyId trophyId,SceNpTrophyId *platinumId); +//Define sceNpTrophyDestroyContext +int sceNpTrophyDestroyContext(SceNpTrophyContext context); +//Define sceNpTrophyDestroyHandle +int sceNpTrophyDestroyHandle(SceNpTrophyHandle handle); +//Define sceNpTrophyTerm +int sceNpTrophyTerm(void); + + +//NPTrophySetupDialog + +//structs: +typedef struct SceNpTrophySetupDialogParam { + SceUInt32 sdkVersion; + SceCommonDialogParam commonParam; + SceNpTrophyContext context; + SceUInt32 options; + SceUInt8 reserved[128]; +} SceNpTrophySetupDialogParam; + +typedef struct SceNpTrophySetupDialogResult { + SceInt32 result; + SceUInt8 reserved[128]; +} SceNpTrophySetupDialogResult; + +//functions + +//Define sceNpTrophySetupDialogInit +SceInt32 sceNpTrophySetupDialogInit(SceNpTrophySetupDialogParam* param); +//Define sceNpTrophySetupDialogTerm +SceInt32 sceNpTrophySetupDialogTerm(void); +//Define sceNpTrophySetupDialogGetStatus +SceCommonDialogStatus sceNpTrophySetupDialogGetStatus(void); +//Define sceNpTrophySetupDialogGetResult +SceInt32 sceNpTrophySetupDialogGetResult(SceNpTrophySetupDialogResult* result); + +