diff --git a/include/xsystem4.h b/include/xsystem4.h index 050f05f..db99bbe 100644 --- a/include/xsystem4.h +++ b/include/xsystem4.h @@ -63,4 +63,6 @@ void get_time(int *hour, int *min, int *sec, int *ms); #define XSYS4_DATA_DIR "/usr/local/share/xsystem4" #endif +extern bool game_rance02_mg; + #endif /* XSYSTEM4_H */ diff --git a/src/hacks.c b/src/hacks.c index 12d877b..8bc5218 100644 --- a/src/hacks.c +++ b/src/hacks.c @@ -29,6 +29,8 @@ #include "hll/hll.h" +bool game_rance02_mg = false; + static void write_instruction0(struct buffer *out, enum opcode op) { buffer_write_int16(out, op); @@ -99,6 +101,8 @@ static void apply_rance02_hacks(struct ain *ain) write_instruction0(&out, RETURN); write_instruction1(&out, ENDFUNC, fno); + + game_rance02_mg = true; } void apply_game_specific_hacks(struct ain *ain) diff --git a/src/hll/CharSpriteManager.c b/src/hll/CharSpriteManager.c index 412ee8c..0edb7e0 100644 --- a/src/hll/CharSpriteManager.c +++ b/src/hll/CharSpriteManager.c @@ -164,7 +164,9 @@ static void charsprite_render(struct charsprite *cs) char ch[3]; extract_sjis_char(cs->ch->text, ch); - if (ch[0] == '}' && !strcmp(config.game_name, "Rance 02")) { + // XXX: this is handled here and not in gfx_render_text because of the + // width calculation below + if (ch[0] == '}' && game_rance02_mg) { ch[0] = 0x81; ch[1] = 0x5c; ch[2] = 0; diff --git a/src/text.c b/src/text.c index 26ffe0d..09db76e 100644 --- a/src/text.c +++ b/src/text.c @@ -320,15 +320,14 @@ static int _gfx_render_text(Texture *dst, Point pos, char *msg, struct text_metr set_font_style(sact_to_sdl_fontstyle(tm->weight)); int width; - char *conv = sjis2utf(msg, strlen(msg)); - TTF_SizeUTF8(font->font, conv, &width, NULL); + TTF_SizeUTF8(font->font, msg, &width, NULL); pos.y -= (TTF_FontAscent(font->font) - font->size * 0.9); glBlendEquationSeparate(GL_FUNC_ADD, GL_MAX); if (tm->outline_left || tm->outline_up || tm->outline_right || tm->outline_down) { Texture outline; - get_glyph(font->font, &outline, conv, tm->outline_color); + get_glyph(font->font, &outline, msg, tm->outline_color); // XXX: This wont work if the outline size is larger than the stroke size // of the font itself. if (tm->outline_left) { @@ -351,12 +350,11 @@ static int _gfx_render_text(Texture *dst, Point pos, char *msg, struct text_metr } Texture glyph; - get_glyph(font->font, &glyph, conv, tm->color); + get_glyph(font->font, &glyph, msg, tm->color); render_glyph(dst, &glyph, pos); gfx_delete_texture(&glyph); glBlendEquationSeparate(GL_FUNC_ADD, GL_FUNC_ADD); - free(conv); return width; } @@ -380,7 +378,13 @@ int gfx_render_text(Texture *dst, Point pos, char *msg, struct text_metrics *tm, int original_x = pos.x; while (*msg) { int len = extract_sjis_char(msg, c); - _gfx_render_text(dst, pos, c, tm); + if (msg[0] == '^' && game_rance02_mg) { + _gfx_render_text(dst, pos, "\xc3\xa9", tm); + } else { + char *utf = sjis2utf(c, len); + _gfx_render_text(dst, pos, utf, tm); + free(utf); + } pos.x += (len == 2 ? tm->size : tm->size / 2) + char_space; msg += len; }