Skip to content

Commit c829335

Browse files
committed
Add SYS_SetFontEncoding
Use original TV format
1 parent d42d96a commit c829335

File tree

3 files changed

+26
-12
lines changed

3 files changed

+26
-12
lines changed

gc/ogc/system.h

+5-1
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,9 @@ distribution.
147147
#define SYS_VIDEO_PAL 1
148148
#define SYS_VIDEO_MPAL 2
149149

150+
#define SYS_FONTENC_ANSI 0
151+
#define SYS_FONTENC_SJIS 1
152+
150153
#define SYS_FONTSIZE_ANSI (288 + 131072)
151154
#define SYS_FONTSIZE_SJIS (3840 + 1179648)
152155

@@ -384,7 +387,8 @@ u16 SYS_GetGBSMode(void);
384387
void SYS_SetGBSMode(u16 mode);
385388

386389
u32 SYS_GetConsoleType(void);
387-
u32 SYS_GetFontEncoding(void);
390+
u16 SYS_GetFontEncoding(void);
391+
u16 SYS_SetFontEncoding(u16 enc);
388392
u32 SYS_InitFont(sys_fontheader *font_data);
389393
void SYS_GetFontTexture(s32 c,void **image,s32 *xpos,s32 *ypos,s32 *width);
390394
void SYS_GetFontTexel(s32 c,void *image,s32 pos,s32 stride,s32 *width);

libogc/card.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -1650,7 +1650,7 @@ static s32 __card_read(s32 chn,u32 address,u32 block_len,void *buffer,cardcallba
16501650
return ret;
16511651
}
16521652

1653-
static s32 __card_formatregion(s32 chn,u32 encode,cardcallback callback)
1653+
static s32 __card_formatregion(s32 chn,u16 encode,cardcallback callback)
16541654
{
16551655
s32 ret;
16561656
u16 tmp;
@@ -2991,7 +2991,7 @@ s32 CARD_DeleteEntry(s32 chn,card_dir *dir_entry)
29912991

29922992
s32 CARD_FormatAsync(s32 chn,cardcallback callback)
29932993
{
2994-
u32 enc;
2994+
u16 enc;
29952995

29962996
enc = SYS_GetFontEncoding();
29972997
return __card_formatregion(chn,enc,callback);
@@ -3000,7 +3000,7 @@ s32 CARD_FormatAsync(s32 chn,cardcallback callback)
30003000
s32 CARD_Format(s32 chn)
30013001
{
30023002
s32 ret;
3003-
u32 enc;
3003+
u16 enc;
30043004

30053005
enc = SYS_GetFontEncoding();
30063006
if((ret=__card_formatregion(chn,enc,__card_synccallback))>=0) {

libogc/system.c

+18-8
Original file line numberDiff line numberDiff line change
@@ -711,7 +711,7 @@ static u32 __unlocksram(u32 write,u32 loc)
711711
//returns the size of font
712712
static u32 __read_font(void *buffer)
713713
{
714-
if(SYS_GetFontEncoding()==1) __SYS_ReadROM(buffer,315392,1769216);
714+
if(SYS_GetFontEncoding()==SYS_FONTENC_SJIS) __SYS_ReadROM(buffer,315392,1769216);
715715
else __SYS_ReadROM(buffer,12288,2084608);
716716
return __get_fontsize(buffer);
717717
}
@@ -1556,26 +1556,36 @@ void* SYS_AllocateFramebuffer(GXRModeObj *rmode)
15561556
return memalign(32, VIDEO_GetFrameBufferSize(rmode));
15571557
}
15581558

1559-
u32 SYS_GetFontEncoding(void)
1559+
u16 SYS_GetFontEncoding(void)
15601560
{
1561-
u32 ret,tv_mode;
1561+
u16 ret;
1562+
u32 tv;
15621563

1563-
if(sys_fontenc<=0x0001) return sys_fontenc;
1564+
if(sys_fontenc!=0xffff) return sys_fontenc;
15641565

1565-
ret = 0;
1566-
tv_mode = VIDEO_GetCurrentTvMode();
1567-
if(tv_mode==VI_NTSC && _viReg[55]&0x0002) ret = 1;
1566+
ret = SYS_FONTENC_ANSI;
1567+
tv = *((u32*)0x800000cc);
1568+
if(tv==VI_NTSC && _viReg[55]&0x0002) ret = SYS_FONTENC_SJIS;
15681569
sys_fontenc = ret;
15691570
return ret;
15701571
}
15711572

1573+
u16 SYS_SetFontEncoding(u16 enc)
1574+
{
1575+
u16 ret;
1576+
1577+
ret = SYS_GetFontEncoding();
1578+
if(enc<=SYS_FONTENC_SJIS) sys_fontenc = enc;
1579+
return ret;
1580+
}
1581+
15721582
u32 SYS_InitFont(sys_fontheader *font_data)
15731583
{
15741584
void *packed_data = NULL;
15751585

15761586
if(!font_data) return 0;
15771587

1578-
if(SYS_GetFontEncoding()==1) {
1588+
if(SYS_GetFontEncoding()==SYS_FONTENC_SJIS) {
15791589
memset(font_data,0,SYS_FONTSIZE_SJIS);
15801590
packed_data = (void*)((u32)font_data+868096);
15811591
} else {

0 commit comments

Comments
 (0)