Sega Genesis >> PicoDrive
支援中文檔名(倚天字型)
程式如下:
diff -Naur old/platform/common/main.c new/platform/common/main.c --- old/platform/common/main.c 2019-11-09 21:40:34.877667476 -0500 +++ new/platform/common/main.c 2019-11-09 22:01:11.423148014 -0500 @@ -6,6 +6,7 @@ * See COPYING file in the top-level directory. */ +#include <iconv.h> #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -18,7 +19,7 @@ #include "version.h" #include <cpu/debug.h> - +iconv_t cd=0; static int load_state_slot = -1; char **g_argv; @@ -76,6 +77,13 @@ { g_argv = argv; + cd = iconv_open("big5", "utf-8"); + printf("iconv_open: 0x%x\n", cd); + if(cd == 0){ + printf("failed to open iconv !\n"); + return -1; + } + plat_early_init(); in_init(); @@ -145,7 +153,7 @@ } endloop: - + iconv_close(cd); emu_finish(); plat_finish(); plat_target_finish(); diff -Naur old/platform/libpicofe/menu.c new/platform/libpicofe/menu.c --- old/platform/libpicofe/menu.c 2019-11-09 21:40:56.657656220 -0500 +++ new/platform/libpicofe/menu.c 2019-11-09 22:01:11.443147921 -0500 @@ -15,7 +15,9 @@ #include <stdarg.h> #include <time.h> #include <locale.h> // savestate date +#include <iconv.h> +#include "big5font.h" #include "menu.h" #include "fonts.h" #include "readpng.h" @@ -24,6 +26,7 @@ #include "plat.h" #include "posix.h" +extern iconv_t cd; static char static_buff[64]; static int menu_error_time = 0; char menu_error_msg[64] = { 0, }; @@ -89,34 +92,34 @@ for (i = 0; i < len; i++) { - unsigned char *src = menu_font_data + (unsigned int)text[i] * me_mfont_w * me_mfont_h / 2; - unsigned short *dst = dest; - int u, l; - - for (l = 0; l < lh; l++, dst += g_menuscreen_pp - me_mfont_w) - { - for (u = me_mfont_w / 2; u > 0; u--, src++) - { - int c, r, g, b; - c = *src >> 4; - r = (*dst & 0xf800) >> 8; - g = (*dst & 0x07e0) >> 3; - b = (*dst & 0x001f) << 3; - r = (c^0xf)*r/15 + c*tr/15; - g = (c^0xf)*g/15 + c*tg/15; - b = (c^0xf)*b/15 + c*tb/15; - *dst++ = ((r<<8)&0xf800) | ((g<<3)&0x07e0) | (b>>3); - c = *src & 0xf; - r = (*dst & 0xf800) >> 8; - g = (*dst & 0x07e0) >> 3; - b = (*dst & 0x001f) << 3; - r = (c^0xf)*r/15 + c*tr/15; - g = (c^0xf)*g/15 + c*tg/15; - b = (c^0xf)*b/15 + c*tb/15; - *dst++ = ((r<<8)&0xf800) | ((g<<3)&0x07e0) | (b>>3); - } - } - dest += me_mfont_w; + unsigned char *src = menu_font_data + (unsigned int)text[i] * me_mfont_w * me_mfont_h / 2; + unsigned short *dst = dest; + int u, l; + + for (l = 0; l < lh; l++, dst += g_menuscreen_pp - me_mfont_w) + { + for (u = me_mfont_w / 2; u > 0; u--, src++) + { + int c, r, g, b; + c = *src >> 4; + r = (*dst & 0xf800) >> 8; + g = (*dst & 0x07e0) >> 3; + b = (*dst & 0x001f) << 3; + r = (c^0xf)*r/15 + c*tr/15; + g = (c^0xf)*g/15 + c*tg/15; + b = (c^0xf)*b/15 + c*tb/15; + *dst++ = ((r<<8)&0xf800) | ((g<<3)&0x07e0) | (b>>3); + c = *src & 0xf; + r = (*dst & 0xf800) >> 8; + g = (*dst & 0x07e0) >> 3; + b = (*dst & 0x001f) << 3; + r = (c^0xf)*r/15 + c*tr/15; + g = (c^0xf)*g/15 + c*tg/15; + b = (c^0xf)*b/15 + c*tb/15; + *dst++ = ((r<<8)&0xf800) | ((g<<3)&0x07e0) | (b>>3); + } + } + dest += me_mfont_w; } if (x < border_left) @@ -154,8 +157,7 @@ { unsigned char *src; unsigned short *dst; - int multiplier = me_sfont_w / 6; - int i; + int i, multiplier = me_sfont_w / 6, acc_x=0; for (i = 0;; i++, x += me_sfont_w) { @@ -165,26 +167,76 @@ if (!c || c == '\n') break; - src = fontdata6x8[c]; - dst = (unsigned short *)g_menuscreen_ptr + x + y * g_menuscreen_pp; - - while (h--) - { - int m, w2, h2; - for (h2 = multiplier; h2 > 0; h2--) - { - for (m = 0x20; m; m >>= 1) { - if (*src & m) - for (w2 = multiplier; w2 > 0; w2--) - *dst++ = color; - else - dst += multiplier; - } - - dst += g_menuscreen_pp - me_sfont_w; - } - src++; - } + if(c < 0x80){ + src = fontdata6x8[c]; + dst = (unsigned short *)g_menuscreen_ptr + x + y * g_menuscreen_pp + acc_x; + + while (h--) + { + int m, w2, h2; + for (h2 = multiplier; h2 > 0; h2--) + { + for (m = 0x20; m; m >>= 1) { + if (*src & m) + for (w2 = multiplier; w2 > 0; w2--) + *dst++ = color; + else + dst += multiplier; + } + + dst += g_menuscreen_pp - me_sfont_w; + } + src++; + } + } + else{ + char *sin; + char *sout; + size_t in_len=0; + size_t out_len=0; + char in_buf[4]={0}; + char out_buf[4]={0}; + unsigned int high, low; + unsigned char top[30]={0}; + + in_buf[0] = texto[i++]; + in_buf[1] = texto[i++]; + in_buf[2] = texto[i]; + sin = in_buf; + sout = out_buf; + in_len = 3; + out_len = sizeof(out_buf); + memset(out_buf, 0, out_len); + iconv(cd, &sin, &in_len, &sout, &out_len); + low = (unsigned char)out_buf[1]; + high = 157 * (unsigned char)((unsigned char)out_buf[0] - 164); + if(low < 127){ + low-= 64; + } + else{ + low-= 98; + } + memcpy(top, &big5font[(high + low) * 30], 30); + dst = (unsigned short *)g_menuscreen_ptr + x + y * g_menuscreen_w + acc_x; + + int x, y, z, t, cnt=0; + for(y=0; y<15;y++){ + for(z=0; z<2;z++){ + t = top[cnt++]; + for(x=0; x<8;x++){ + if(t & 0x80){ + *dst++ = color; + } + else{ + dst+= 1; + } + t<<=1; + } + } + dst += g_menuscreen_w - 16; + } + acc_x+= (16 - me_sfont_w); + } } }
修改前
修改後