Remove g_nact references from ags.cpp

This commit is contained in:
kichikuou
2026-09-03 13:25:51 +09:00
parent 3f98902d98
commit 9e1e0e91b3
6 changed files with 57 additions and 52 deletions
-45
View File
@@ -7,7 +7,6 @@
#include "ags.h"
#include <ctype.h>
#include <string.h>
#include "nact.h"
#include "game_id.h"
#include "config.h"
#include "fileio.h"
@@ -261,36 +260,6 @@ std::vector<uint32_t> AGS::get_screen_palette() const
return palette;
}
void AGS::fade_out(int duration_ms, bool white)
{
if (fade_level)
return;
fade_color = white ? 255 : 0;
Uint32 dwStart = SDL_GetTicks();
while (fade_level < 255) {
g_nact->sys_sleep(16);
int t = SDL_GetTicks() - dwStart;
fade_level = t >= duration_ms ? 255 : t * 255 / duration_ms;
}
update_screen();
}
void AGS::fade_in(int duration_ms)
{
if (fade_level == 0)
return;
Uint32 dwStart = SDL_GetTicks();
while (fade_level > 0) {
g_nact->sys_sleep(16);
int t = SDL_GetTicks() - dwStart;
fade_level = t >= duration_ms ? 0 : (duration_ms - t) * 255 / duration_ms;
}
update_screen();
}
void AGS::invalidate_screen(int sx, int sy, int width, int height)
{
SDL_Rect rect = {sx, sy, width, height};
@@ -403,17 +372,3 @@ void AGS::load_censor_list(const char* fname)
fclose(fp);
}
#ifdef __EMSCRIPTEN__
extern "C" {
bool EMSCRIPTEN_KEEPALIVE save_screenshot(const char* path) {
return g_nact->ags->save_screenshot(path);
}
void EMSCRIPTEN_KEEPALIVE load_censor_list(const char *path) {
return g_nact->ags->load_censor_list(path);
}
}
#endif
+2 -3
View File
@@ -103,9 +103,8 @@ public:
void invalidate_screen(int sx, int sy, int width, int height);
void draw_gaiji(ScreenId dest, int dest_x, int dest_y, const uint8_t bitmap[32], int size, uint8 color);
bool is_faded() const { return fade_level != 0; }
void fade_out(int duration_ms, bool white);
void fade_in(int duration_ms);
void set_fade_color(bool white) { fade_color = white ? 255 : 0; }
void set_fade_level(int level) { fade_level = level; }
void copy(int sx, int sy, int ex, int ey, int dx, int dy) {
copy_screen(src_screen, dest_screen, sx, sy, ex, ey, dx, dy);
+48
View File
@@ -721,6 +721,40 @@ void NACT::wait_after_open_menu()
wait_key_release();
}
void NACT::fade_out(int duration_ms, bool white)
{
if (ags->is_faded())
return;
ags->set_fade_color(white);
uint32_t start = SDL_GetTicks();
int level = 0;
while (level < 255) {
sys_sleep(16);
int t = SDL_GetTicks() - start;
level = t >= duration_ms ? 255 : t * 255 / duration_ms;
ags->set_fade_level(level);
}
ags->update_screen();
}
void NACT::fade_in(int duration_ms)
{
if (!ags->is_faded())
return;
uint32_t start = SDL_GetTicks();
int level = 255;
while (level > 0) {
sys_sleep(16);
int t = SDL_GetTicks() - start;
level = t >= duration_ms ? 0 : (duration_ms - t) * 255 / duration_ms;
ags->set_fade_level(level);
}
ags->update_screen();
}
void NACT::sys_sleep(int ms) {
pump_events();
ags->update_screen();
@@ -757,3 +791,17 @@ NACT* NACT::create(const Config& config, const GameId& game_id) {
return create_system3(config, game_id);
}
}
#ifdef __EMSCRIPTEN__
extern "C" {
bool EMSCRIPTEN_KEEPALIVE save_screenshot(const char* path) {
return g_nact->ags->save_screenshot(path);
}
void EMSCRIPTEN_KEEPALIVE load_censor_list(const char *path) {
return g_nact->ags->load_censor_list(path);
}
}
#endif
+3
View File
@@ -236,6 +236,9 @@ protected:
int menu_select();
void wait_after_open_menu();
void fade_out(int duration_ms, bool white);
void fade_in(int duration_ms);
uint8 get_key(bool notify_texthook = true);
void wait_key_release(uint8_t mask = 0xff);
+2 -2
View File
@@ -755,11 +755,11 @@ void NACT_Sys2::cmd_y()
break;
case 40:
case 42:
ags->fade_in(param * 16 * 1000 / 60);
fade_in(param * 16 * 1000 / 60);
break;
case 41:
case 43:
ags->fade_out(param * 16 * 1000 / 60, cmd == 43);
fade_out(param * 16 * 1000 / 60, cmd == 43);
break;
case 221:
case 222:
+2 -2
View File
@@ -794,11 +794,11 @@ void NACT_Sys3::exec_y(int cmd, int param)
break;
case 40:
case 42:
ags->fade_in(param * 16 * 1000 / 60);
fade_in(param * 16 * 1000 / 60);
break;
case 41:
case 43:
ags->fade_out(param * 16 * 1000 / 60, cmd == 43);
fade_out(param * 16 * 1000 / 60, cmd == 43);
break;
case 45:
if (param) {