diff --git a/Common/Common.vcxproj b/Common/Common.vcxproj
index 060207d0b3..421bbcc8b6 100644
--- a/Common/Common.vcxproj
+++ b/Common/Common.vcxproj
@@ -66,7 +66,7 @@
Use
Level3
Disabled
- WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)
+ WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions);_CRT_SECURE_NO_WARNINGS
stdafx.h
MultiThreadedDebugDLL
@@ -102,7 +102,7 @@
MaxSpeed
true
true
- WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)
+ WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions);_CRT_SECURE_NO_WARNINGS
stdafx.h
false
StreamingSIMDExtensions2
diff --git a/Core/Core.vcxproj b/Core/Core.vcxproj
index 50c55c3a01..ddcc0190f6 100644
--- a/Core/Core.vcxproj
+++ b/Core/Core.vcxproj
@@ -67,7 +67,7 @@
Level3
Disabled
../common;..;../native;../native/ext/glew;../ext/zlib
- WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)
+ WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions);_CRT_SECURE_NO_WARNINGS
StreamingSIMDExtensions2
Fast
@@ -98,6 +98,7 @@
false
StreamingSIMDExtensions2
Fast
+ _MBCS;%(PreprocessorDefinitions);_CRT_SECURE_NO_WARNINGS
true
diff --git a/Core/Core.vcxproj.filters b/Core/Core.vcxproj.filters
index aeafbe3ada..aa18c230f8 100644
--- a/Core/Core.vcxproj.filters
+++ b/Core/Core.vcxproj.filters
@@ -375,6 +375,7 @@
MIPS\ARM
+
@@ -695,6 +696,7 @@
MIPS\ARM
+
diff --git a/Core/HLE/sceFont.cpp b/Core/HLE/sceFont.cpp
index 867d7ea664..bcc6246576 100644
--- a/Core/HLE/sceFont.cpp
+++ b/Core/HLE/sceFont.cpp
@@ -6,6 +6,310 @@
#include "../MIPS/MIPS.h"
#include "ChunkFile.h"
+
+/******************************************************************************/
+
+static int get_value(int bpe, u8 *buf, int *pos)
+{
+ int i, v;
+
+ v = 0;
+ for(i=0; i> ((*pos)%8) ) &1 ) << i;
+ (*pos)++;
+ }
+
+ return v;
+}
+
+static int read_table(u8 *buf, int *table, int num, int bpe)
+{
+ int i, p, len;
+
+ len = ((num*bpe+31)/32)*4;
+
+ p = 0;
+ for(i=0; ibuf;
+ n_charmap = ph->charmap_len;
+
+ for(i=0; icharmap[i]==ptr){
+ return i+ph->charmap_min;
+ }
+ }
+
+ return 0xffff;
+}
+
+static int have_shadow(PGF_FONT *pgft, u32 ucs)
+{
+ PGF_HEADER *ph;
+ int i, n_shadowmap;
+
+ ph = (PGF_HEADER*)pgft->buf;
+ n_shadowmap = ph->shadowmap_len;
+
+ for(i=0; ishadowmap[i]==ucs){
+ return 1;
+ }
+ }
+
+ return 0;
+}
+
+static void get_bitmap(PGF_GLYPH *glyph)
+{
+ int i, j, p, nb, data, len;
+ u8 *bmp, temp_buf[64*64];
+
+ i = 0;
+ p = 0;
+ len = glyph->width * glyph->height;
+ if((glyph->flag&3)==2){
+ bmp = temp_buf;
+ }else{
+ bmp = glyph->bmp;
+ }
+
+ while(idata, &p);
+ if(nb<8){
+ data = get_value(4, glyph->data, &p);
+ for(j=0; jdata, &p);
+ bmp[i] = data;
+ i++;
+ }
+ }
+ }
+
+ if((glyph->flag&3)==2){
+ int h, v;
+
+ i = 0;
+ for(h=0; hwidth; h++){
+ for(v=0; vheight; v++){
+ glyph->bmp[v*glyph->width+h] = bmp[i];
+ i++;
+ }
+ }
+ }
+
+}
+
+static void load_shadow_glyph(u8 *ptr, PGF_GLYPH *glyph)
+{
+ int pos;
+
+ pos = 0;
+
+ glyph->size = get_value(14, ptr, &pos);
+ glyph->width = get_value(7, ptr, &pos);
+ glyph->height = get_value(7, ptr, &pos);
+ glyph->left = get_value(7, ptr, &pos);
+ glyph->top = get_value(7, ptr, &pos);
+ glyph->flag = get_value(6, ptr, &pos);
+
+ if(glyph->left>63) glyph->left |= 0xffffff80;
+ if(glyph->top >63) glyph->top |= 0xffffff80;
+
+ glyph->data = ptr+(pos/8);
+ glyph->bmp = (u8*)malloc(glyph->width*glyph->height);
+ get_bitmap(glyph);
+}
+
+static void load_char_glyph(PGF_FONT *pgft, int index, PGF_GLYPH *glyph)
+{
+ int id, pos;
+ u8 *ptr;
+
+ ptr = pgft->glyphdata + pgft->charptr[index];
+ pos = 0;
+
+ glyph->index = index;
+ glyph->have_shadow = have_shadow(pgft, glyph->ucs);
+
+ glyph->size = get_value(14, ptr, &pos);
+ glyph->width = get_value( 7, ptr, &pos);
+ glyph->height = get_value( 7, ptr, &pos);
+ glyph->left = get_value( 7, ptr, &pos);
+ glyph->top = get_value( 7, ptr, &pos);
+ glyph->flag = get_value( 6, ptr, &pos);
+
+ if(glyph->left>63) glyph->left |= 0xffffff80;
+ if(glyph->top >63) glyph->top |= 0xffffff80;
+
+ /* read extension info */
+ glyph->shadow_flag = get_value(7, ptr, &pos);
+ glyph->shadow_id = get_value(9, ptr, &pos);
+ if(glyph->flag&0x04){
+ id = get_value(8, ptr, &pos);
+ glyph->dimension.h = pgft->dimension[id].h;
+ glyph->dimension.v = pgft->dimension[id].v;
+ }else{
+ glyph->dimension.h = get_value(32, ptr, &pos);
+ glyph->dimension.v = get_value(32, ptr, &pos);
+ }
+ if(glyph->flag&0x08){
+ id = get_value(8, ptr, &pos);
+ glyph->bearingX.h = pgft->bearingX[id].h;
+ glyph->bearingX.v = pgft->bearingX[id].v;
+ }else{
+ glyph->bearingX.h = get_value(32, ptr, &pos);
+ glyph->bearingX.v = get_value(32, ptr, &pos);
+ }
+ if(glyph->flag&0x10){
+ id = get_value(8, ptr, &pos);
+ glyph->bearingY.h = pgft->bearingY[id].h;
+ glyph->bearingY.v = pgft->bearingY[id].v;
+ }else{
+ glyph->bearingY.h = get_value(32, ptr, &pos);
+ glyph->bearingY.v = get_value(32, ptr, &pos);
+ }
+ if(glyph->flag&0x20){
+ id = get_value(8, ptr, &pos);
+ glyph->advance.h = pgft->advance[id].h;
+ glyph->advance.v = pgft->advance[id].v;
+ }else{
+ glyph->advance.h = get_value(32, ptr, &pos);
+ glyph->advance.v = get_value(32, ptr, &pos);
+ }
+
+ glyph->data = ptr+(pos/8);
+ glyph->bmp = (u8*)malloc(glyph->width*glyph->height);
+ get_bitmap(glyph);
+
+ if(glyph->have_shadow){
+ id = glyph->shadow_id;
+ pgft->shadow_glyph[id] = (PGF_GLYPH*)malloc(sizeof(PGF_GLYPH));
+ memset(pgft->shadow_glyph[id], 0, sizeof(PGF_GLYPH));
+ load_shadow_glyph(ptr+glyph->size, pgft->shadow_glyph[id]);
+ }
+
+}
+
+
+int load_all_glyph(PGF_FONT *pgft)
+{
+ PGF_GLYPH *glyph;
+ PGF_HEADER *ph;
+ int i, n_chars, ucs;
+
+ ph = (PGF_HEADER*)pgft->buf;
+ n_chars = ph->charptr_len;
+
+ for(i=0; iucs = ucs;
+ pgft->char_glyph[ucs] = glyph;
+ load_char_glyph(pgft, i, glyph);
+ }
+
+ return 0;
+}
+
+
+PGF_FONT *load_pgf_from_buf(u8 *buf, int length)
+{
+ PGF_FONT *pgft;
+ PGF_HEADER *ph;
+ int i;
+
+ pgft = (PGF_FONT*)malloc(sizeof(PGF_FONT));
+ memset(pgft, 0, sizeof(PGF_FONT));
+
+ pgft->buf = buf;
+
+ /* pgf header */
+ ph = (PGF_HEADER*)buf;
+ buf += ph->header_len;
+
+ /* dimension table */
+ pgft->dimension = (F26_PAIRS*)buf;
+ buf += (ph->dimension_len*8);
+
+ /* left bearing table */
+ pgft->bearingX = (F26_PAIRS*)buf;
+ buf += (ph->bearingX_len*8);
+
+ /* top bearing table */
+ pgft->bearingY = (F26_PAIRS*)buf;
+ buf += (ph->bearingY_len*8);
+
+ /* advance table */
+ pgft->advance = (F26_PAIRS*)buf;
+ buf += (ph->advance_len*8);
+
+ /* read shadowmap table */
+ if(ph->shadowmap_len){
+ pgft->shadowmap = (int*)malloc(ph->shadowmap_len*4);
+ buf += read_table(buf, pgft->shadowmap, ph->shadowmap_len, ph->shadowmap_bpe);
+ }
+
+ /* read charmap table */
+ pgft->charmap = (int*)malloc(ph->charmap_len*4);
+ buf += read_table(buf, pgft->charmap, ph->charmap_len, ph->charmap_bpe);
+
+ /* read charptr table */
+ pgft->charptr = (int*)malloc(ph->charptr_len*4);
+ buf += read_table(buf, pgft->charptr, ph->charptr_len, ph->charptr_bpe);
+ for(i=0; icharptr_len; i++){
+ pgft->charptr[i] *= ph->charptr_scale;
+ }
+
+ /* font glyph data */
+ pgft->glyphdata = buf;
+
+ load_all_glyph(pgft);
+
+ return pgft;
+}
+
+PGF_GLYPH *get_glyph(PGF_FONT *pgft, int ucs)
+{
+ return pgft->char_glyph[ucs];
+}
+
+void free_glyph(PGF_FONT *pgft, PGF_GLYPH *glyph)
+{
+ int ucs;
+
+ ucs = glyph->ucs;
+ free(glyph->bmp);
+ free(glyph);
+ pgft->char_glyph[ucs] = 0;
+}
+
+void free_pgf_font(PGF_FONT *pgft)
+{
+
+
+}
+
+
+
+/******************************************************************************/
+
typedef u32 FontLibraryHandle;
typedef u32 FontHandle;
diff --git a/Core/HLE/sceFont.h b/Core/HLE/sceFont.h
index 81d095c5bb..c1802a9082 100644
--- a/Core/HLE/sceFont.h
+++ b/Core/HLE/sceFont.h
@@ -6,3 +6,132 @@ void Register_sceFont();
void __FontInit();
void __FontDoState(PointerWrap &p);
+
+
+typedef unsigned int u32;
+typedef unsigned short u16;
+typedef unsigned char u8;
+
+typedef struct f26_pairs {
+ int h;
+ int v;
+} F26_PAIRS;
+
+typedef struct pgf_header_t {
+ /* 0x0000 */
+ u16 header_start;
+ u16 header_len;
+ u8 pgf_id[4];
+ u32 revision;
+ u32 version;
+
+ /* 0x0010 */
+ int charmap_len;
+ int charptr_len;
+ int charmap_bpe;
+ int charptr_bpe;
+
+ /* 0x0020 */
+ u8 unk_20[2]; /* 04 04 */
+ u8 bpp; /* 04 */
+ u8 unk_23; /* 00 */
+
+ u32 h_size;
+ u32 v_size;
+ u32 h_res;
+ u32 v_res;
+
+ u8 unk_34; /* 00 */
+ u8 font_name[64]; /* "FTT-NewRodin Pro DB" */
+ u8 font_type[64]; /* "Regular" */
+ u8 unk_B5; /* 00 */
+
+ u16 charmap_min;
+ u16 charmap_max;
+
+ /* 0x00BA */
+ u16 unk_BA; /* 0x0000 */
+ u32 unk_BC; /* 0x00010000 */
+ u32 unk_C0; /* 0x00000000 */
+ u32 unk_C4; /* 0x00000000 */
+ u32 unk_C8; /* 0x00010000 */
+ u32 unk_CC; /* 0x00000000 */
+ u32 unk_D0; /* 0x00000000 */
+
+ int ascender;
+ int descender;
+ int max_h_bearingX;
+ int max_h_bearingY;
+ int min_v_bearingX;
+ int max_v_bearingY;
+ int max_h_advance;
+ int max_v_advance;
+ int max_h_dimension;
+ int max_v_dimension;
+ u16 max_glyph_w;
+ u16 max_glyph_h;
+
+ /* 0x0100 */
+ u16 charptr_scale; /* 0004 */
+ u8 dimension_len;
+ u8 bearingX_len;
+ u8 bearingY_len;
+ u8 advance_len;
+ u8 unk_106[102]; /* 00 00 ... ... 00 */
+
+ u32 shadowmap_len;
+ u32 shadowmap_bpe;
+ u32 unk_174;
+ u32 shadowscale_x;
+ u32 shadowscale_y;
+ u32 unk_180;
+ u32 unk_184;
+} PGF_HEADER;
+
+typedef struct glyph_t {
+ int index;
+ int ucs;
+ int have_shadow;
+
+ int size; /* 14bits */
+ int width; /* 7bits */
+ int height; /* 7bits */
+ int left; /* 7bits signed */
+ int top; /* 7bits signed */
+ int flag; /* 6bits: 2+1+1+1+1 */
+
+ int shadow_flag;/* 7bits: 2+2+3 */
+ int shadow_id; /* 9bits */
+
+ F26_PAIRS dimension;
+ F26_PAIRS bearingX;
+ F26_PAIRS bearingY;
+ F26_PAIRS advance;
+
+ u8 *data;
+ u8 *bmp;
+} PGF_GLYPH;
+
+typedef struct pgf_font_t {
+ u8 *buf;
+
+ PGF_HEADER *ph;
+
+ struct f26_pairs *dimension;
+ struct f26_pairs *bearingX;
+ struct f26_pairs *bearingY;
+ struct f26_pairs *advance;
+
+ int *charmap;
+ int *charptr;
+ int *shadowmap;
+
+ u8 *glyphdata;
+ PGF_GLYPH *char_glyph[65536];
+ PGF_GLYPH *shadow_glyph[512];
+
+} PGF_FONT;
+
+
+
+
diff --git a/GPU/GPU.vcxproj b/GPU/GPU.vcxproj
index 4a6262b411..445739ea5a 100644
--- a/GPU/GPU.vcxproj
+++ b/GPU/GPU.vcxproj
@@ -69,6 +69,7 @@
Level3
Disabled
../common;..;../native;../native/ext/glew;
+ _MBCS;%(PreprocessorDefinitions);_CRT_SECURE_NO_WARNINGS
true
@@ -94,6 +95,7 @@
false
StreamingSIMDExtensions2
Fast
+ _MBCS;%(PreprocessorDefinitions);_CRT_SECURE_NO_WARNINGS
true
diff --git a/Windows/PPSSPP.vcxproj b/Windows/PPSSPP.vcxproj
index 019fde5bcc..cd964dba60 100644
--- a/Windows/PPSSPP.vcxproj
+++ b/Windows/PPSSPP.vcxproj
@@ -96,7 +96,7 @@
Disabled
- WIN32;_DEBUG;%(PreprocessorDefinitions)
+ WIN32;_DEBUG;%(PreprocessorDefinitions);_CRT_SECURE_NO_WARNINGS
true
Sync
Use
@@ -151,7 +151,7 @@
true
Speed
true
- WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)
+ WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions);_CRT_SECURE_NO_WARNINGS
true
Sync
MultiThreadedDLL
diff --git a/ext/libkirk/libkirk.vcxproj b/ext/libkirk/libkirk.vcxproj
index 20cba7c8c2..e4e5f463b0 100644
--- a/ext/libkirk/libkirk.vcxproj
+++ b/ext/libkirk/libkirk.vcxproj
@@ -95,6 +95,7 @@
false
StreamingSIMDExtensions2
Fast
+ _MBCS;%(PreprocessorDefinitions);_CRT_SECURE_NO_WARNINGS
true
diff --git a/ext/zlib/zlib.vcxproj b/ext/zlib/zlib.vcxproj
index be9c34926c..e7ec0a542f 100644
--- a/ext/zlib/zlib.vcxproj
+++ b/ext/zlib/zlib.vcxproj
@@ -99,7 +99,7 @@
Level3
Disabled
- WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)
+ WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions);_CRT_SECURE_NO_WARNINGS
Windows
@@ -127,7 +127,7 @@
MaxSpeed
true
true
- WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)
+ WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions);_CRT_SECURE_NO_WARNINGS
StreamingSIMDExtensions2
false
Fast
diff --git a/headless/Headless.vcxproj b/headless/Headless.vcxproj
index ecfadbd1ab..ef0e4a9945 100644
--- a/headless/Headless.vcxproj
+++ b/headless/Headless.vcxproj
@@ -80,7 +80,7 @@
NotUsing
Level3
Disabled
- WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)
+ WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions);_CRT_SECURE_NO_WARNINGS
../Common;..;../Core;../native/ext/glew;../native
Default
@@ -111,7 +111,7 @@
MaxSpeed
true
true
- WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
+ WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);_CRT_SECURE_NO_WARNINGS
../Common;..;../Core;../native/ext/glew;../native
false
StreamingSIMDExtensions2
diff --git a/unittest/UnitTests.vcxproj b/unittest/UnitTests.vcxproj
index ca9cb9312e..757c39ee66 100644
--- a/unittest/UnitTests.vcxproj
+++ b/unittest/UnitTests.vcxproj
@@ -85,7 +85,7 @@
Level3
Disabled
- WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)
+ WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions);_CRT_SECURE_NO_WARNINGS
../common;..;../native;../native/ext/glew;../ext/zlib
@@ -117,7 +117,7 @@
MaxSpeed
true
true
- WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)
+ WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions);_CRT_SECURE_NO_WARNINGS
../common;..;../native;../native/ext/glew;../ext/zlib