diff --git a/Makefile b/Makefile index 41a795c..6c9f693 100644 --- a/Makefile +++ b/Makefile @@ -24,6 +24,7 @@ OBJS = src/fileio.o \ src/sys/nact_input.o \ src/sys/nact_sys3.o \ src/win/nact_dialog.o \ + src/win/unicode.o \ src/res3/Script1.o DEPS := $(OBJS:%.o=%.d) diff --git a/src/common.h b/src/common.h index f85c605..7dffb41 100644 --- a/src/common.h +++ b/src/common.h @@ -21,24 +21,14 @@ typedef char _TCHAR; #define _stprintf_s sprintf_s // type definition -#ifndef uint8 typedef unsigned char uint8; -#endif -#ifndef uint16 typedef unsigned short uint16; -#endif -#ifndef uint32 typedef unsigned long uint32; -#endif - -#ifndef int8 typedef signed char int8; -#endif -#ifndef int16 typedef signed short int16; -#endif -#ifndef int32 typedef signed long int32; -#endif + +// utilities +uint16 sjis_to_unicode(uint16 sjis); #endif diff --git a/src/sys/ags_text.cpp b/src/sys/ags_text.cpp index 35725f7..da308fb 100644 --- a/src/sys/ags_text.cpp +++ b/src/sys/ags_text.cpp @@ -5,7 +5,6 @@ */ #include "ags.h" -#include void AGS::draw_text(char string[]) { @@ -54,24 +53,7 @@ void AGS::draw_text(char string[]) void AGS::draw_char(int dest, int dest_x, int dest_y, uint16 code, int size, uint8 color) { - char string[3]; - int length; - SDL_Color white = {0xff, 0xff, 0xff}; - // パターン取得 - if(code > 0xff) { - string[0] = code >> 8; - string[1] = code & 0xff; - string[2] = '\0'; - length = 2; - } else { - string[0] = code & 0xff; - string[1] = '\0'; - length = 1; - } - Uint16 buf[2]; - MultiByteToWideChar(CP_ACP, 0, string, length, (LPWSTR)buf, 2); - TTF_Font* font = NULL; switch (size) { case 16: font = hFont16; break; @@ -81,7 +63,8 @@ void AGS::draw_char(int dest, int dest_x, int dest_y, uint16 code, int size, uin case 64: font = hFont64; break; } - SDL_Surface* fs = TTF_RenderGlyph_Solid(font, buf[0], white); + SDL_Color white = {0xff, 0xff, 0xff}; + SDL_Surface* fs = TTF_RenderGlyph_Solid(font, sjis_to_unicode(code), white); // パターン出力 // TODO: Blit? diff --git a/src/win/unicode.cpp b/src/win/unicode.cpp new file mode 100644 index 0000000..28dad02 --- /dev/null +++ b/src/win/unicode.cpp @@ -0,0 +1,22 @@ +#include "common.h" +#include + +uint16 sjis_to_unicode(uint16 code) +{ + char string[3]; + int length; + + if(code > 0xff) { + string[0] = code >> 8; + string[1] = code & 0xff; + string[2] = '\0'; + length = 2; + } else { + string[0] = code & 0xff; + string[1] = '\0'; + length = 1; + } + uint16 buf[2]; + MultiByteToWideChar(CP_ACP, 0, string, length, (LPWSTR)buf, 2); + return buf[0]; +}