Performance tweak

This commit is contained in:
kichikuou
2017-04-30 21:31:11 +09:00
parent 7c233fd9a0
commit ba359b4b59
3 changed files with 29 additions and 45 deletions
+15 -11
View File
@@ -21,7 +21,7 @@ inline uint16 sjis_to_unicode(uint16 code)
void AGS::draw_text(char string[])
{
int p = 0;
int screen, *dest_x, dest_y, font_size;
int screen, dest_x, dest_y, font_size;
uint8 font_color;
uint8 antialias_cache[256*7];
@@ -30,13 +30,13 @@ void AGS::draw_text(char string[])
if (draw_menu) {
screen = 2;
dest_x = &menu_dest_x;
dest_x = menu_dest_x;
dest_y = menu_dest_y;
font_size = menu_font_size;
font_color = menu_font_color;
} else {
screen = dest_screen;
dest_x = &text_dest_x;
dest_x = text_dest_x;
dest_y = text_dest_y;
font_size = text_font_size;
font_color = text_font_color;
@@ -58,19 +58,23 @@ void AGS::draw_text(char string[])
// 文字出力
if((0xeb9f <= code && code <= 0xebfc) || (0xec40 <= code && code <= 0xec9e)) {
draw_gaiji(screen, *dest_x, dest_y, code, font_size, font_color);
draw_gaiji(screen, dest_x, dest_y, code, font_size, font_color);
} else {
if (antialias)
draw_char_antialias(screen, *dest_x, dest_y, code, font_size, font_color, antialias_cache);
draw_char_antialias(screen, dest_x, dest_y, code, font_size, font_color, antialias_cache);
else
draw_char(screen, *dest_x, dest_y, code, font_size, font_color);
}
// 画面更新
if(screen == 0) {
draw_screen(*dest_x, dest_y, (code & 0xff00) ? font_size : (font_size >> 1), font_size);
draw_char(screen, dest_x, dest_y, code, font_size, font_color);
}
// 出力位置の更新
*dest_x += (code & 0xff00) ? font_size : (font_size >> 1);
dest_x += (code & 0xff00) ? font_size : (font_size >> 1);
}
if (draw_menu)
menu_dest_x = dest_x;
else {
// 画面更新
if(screen == 0)
draw_screen(text_dest_x, dest_y, dest_x - text_dest_x, font_size);
text_dest_x = dest_x;
}
}
+2 -4
View File
@@ -144,8 +144,6 @@ void NACT::mainloop()
// 512コマンド実行毎にSleep(10)
if(!(sleep_cnt = (sleep_cnt + 1) & 0x1ff)) {
SDL_Delay(10);
} else {
SDL_Delay(0);
}
}
}
@@ -323,7 +321,7 @@ void NACT::execute()
if(dwTime <= SDL_GetTicks()) {
break;
}
SDL_Delay(10);
SDL_Delay(16);
}
}
@@ -356,7 +354,7 @@ void NACT::execute()
if(dwTime <= SDL_GetTicks()) {
break;
}
SDL_Delay(10);
SDL_Delay(16);
}
}
+12 -30
View File
@@ -163,7 +163,7 @@ int NACT::menu_select(int num_items)
if(!get_key()) {
break;
}
SDL_Delay(10);
SDL_Delay(16);
}
// メニュー表示
@@ -197,7 +197,7 @@ int NACT::menu_select(int num_items)
if(abs(my - current_my) > 3) {
break;
}
SDL_Delay(10);
SDL_Delay(16);
}
if(val) {
for(;;) {
@@ -207,7 +207,7 @@ int NACT::menu_select(int num_items)
if(!get_key()) {
break;
}
SDL_Delay(10);
SDL_Delay(16);
}
}
@@ -442,9 +442,9 @@ void NACT::cmd_a()
if(get_key()) {
break;
}
SDL_Delay(10);
SDL_Delay(16);
}
SDL_Delay(100);
SDL_Delay(30);
for(;;) {
if(terminate) {
return;
@@ -452,7 +452,7 @@ void NACT::cmd_a()
if(!(get_key() & 0x18)) {
break;
}
SDL_Delay(10);
SDL_Delay(16);
}
}
@@ -725,7 +725,7 @@ void NACT::cmd_k()
return;
}
}
SDL_Delay(10);
SDL_Delay(16);
}
if(cmd != 0 && cmd != 4) {
RND = val;
@@ -741,7 +741,7 @@ void NACT::cmd_k()
if(!(val = get_key())) {
break;
}
SDL_Delay(10);
SDL_Delay(16);
}
}
@@ -1306,7 +1306,7 @@ void NACT::cmd_y()
if(dwTime <= SDL_GetTicks()) {
break;
}
SDL_Delay(10);
SDL_Delay(16);
}
}
break;
@@ -1397,16 +1397,7 @@ void NACT::cmd_y()
Uint32 dwStart = SDL_GetTicks();
for(int i = 0; i < 16; i++) {
ags->fade_in(i);
Uint32 dwTime = dwStart + param * 1000 / 60 * i;
for(;;) {
if(terminate) {
return;
}
if(dwTime <= SDL_GetTicks()) {
break;
}
SDL_Delay(0);
}
SDL_Delay(dwStart + param * 1000 / 60 * i - SDL_GetTicks());
}
ags->fade_end();
}
@@ -1418,16 +1409,7 @@ void NACT::cmd_y()
Uint32 dwStart = SDL_GetTicks();
for(int i = 0; i < 16; i++) {
ags->fade_out(i, (cmd == 41) ? false : true);
Uint32 dwTime = dwStart + param * 1000 / 60 * i;
for(;;) {
if(terminate) {
return;
}
if(dwTime <= SDL_GetTicks()) {
break;
}
SDL_Delay(0);
}
SDL_Delay(dwStart + param * 1000 / 60 * i - SDL_GetTicks());
}
}
break;
@@ -1465,7 +1447,7 @@ void NACT::cmd_y()
if(!get_key()) {
break;
}
SDL_Delay(0);
SDL_Delay(16);
}
}
} else if(param == 3) {