Reorganize ags.h

This commit is contained in:
kichikuou
2026-09-03 13:41:39 +09:00
parent 9e1e0e91b3
commit 5570962a38
+70 -72
View File
@@ -34,56 +34,23 @@ enum CgFlags {
class AGS
{
protected:
const GameId& game_id;
private:
SDL_Texture* sdlTexture;
SDL_Texture* scanline_texture;
// Surface
SDL_Surface* hBmpScreen[NR_SCREENS]; // 8bpp
uint8_t (*vram[NR_SCREENS])[640]; // convenience pointer to hBmpScreen[i]->pixels
SDL_Palette* program_palette;
SDL_Palette* screen_palette;
// フォント
SDL_RWops* rw_font;
TTF_Font* hFont16;
TTF_Font* hFont24;
TTF_Font* hFont32;
TTF_Font* hFont48;
TTF_Font* hFont64;
// カーソル
SDL_Cursor* hCursor[10];
// AGS
CG load_gm3(const std::vector<uint8_t>& data, int transparent, uint8_t flags); // Intruder -桜屋敷の探索-
CG load_vsp2l(const std::vector<uint8_t>& data, int transparent, uint8_t flags); // Little Vampire
CG load_gl3(const std::vector<uint8_t>& data, bool set_palette, int transparent, uint8_t flags);
CG load_pms(int page, const std::vector<uint8_t>& data, bool set_palette, int transparent, uint8_t flags);
CG load_vsp(const std::vector<uint8_t>& data, bool set_palette, int transparent, uint8_t flags);
void draw_char(ScreenId dest, int dest_x, int dest_y, uint16 code, TTF_Font* font, uint8 color);
void draw_char_antialias(ScreenId dest, int dest_x, int dest_y, uint16 code, TTF_Font* font, uint8 color, uint8 cache[]);
uint8_t palR(uint8_t col) const { return screen_palette->colors[col].r; }
uint8_t palG(uint8_t col) const { return screen_palette->colors[col].g; }
uint8_t palB(uint8_t col) const { return screen_palette->colors[col].b; }
int nearest_color(int r, int g, int b);
uint8 gaiji[188][32];
int fade_level = 0; // 0-255
int fade_color = 0; // 0: black, 255: white
public:
AGS(const Config& config, const GameId& game_id);
~AGS();
// screen
void update_screen();
void invalidate_screen(int sx, int sy, int width, int height);
bool get_scanline_mode() const { return scanline_texture; }
void set_scanline_mode(bool enable);
bool save_screenshot(const char* path);
int scroll = 0;
int window_width, window_height;
int screen_width, screen_height;
// CG
void set_cg_file(const char *file_name);
void load_cg(int page, int transparent, uint8_t flags);
// Decodes a CG without drawing it, but still updates the palette.
CG load_cg_surface(int page, int transparent, uint8_t flags);
@@ -91,21 +58,23 @@ public:
std::vector<uint8_t> load_cg_data(int page) { return acg.load(page); }
void blit_cg(ScreenId dest, CG& cg, const SDL_Rect* src, int dx, int dy);
void blit_cg(CG& dest, CG& cg, const SDL_Rect* src, int dx, int dy);
void set_cg_file(const char *file_name);
CG create_offscreen(int width, int height);
void load_censor_list(const char* fname);
std::optional<SDL_Point> cg_dest;
std::unordered_set<int> ignore_palette;
int palette_bank;
// palette
void set_palette(int index, uint8_t r, uint8_t g, uint8_t b);
std::vector<uint32_t> get_screen_palette() const;
uint8 get_pixel(ScreenId dest, int x, int y) const { return vram[dest][y][x]; }
void set_pixel(ScreenId dest, int x, int y, uint8 color) { vram[dest][y][x] = color; }
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 set_fade_color(bool white) { fade_color = white ? 255 : 0; }
void set_fade_level(int level) { fade_level = level; }
// draw
uint8 get_pixel(ScreenId dest, int x, int y) const { return vram[dest][y][x]; }
void set_pixel(ScreenId dest, int x, int y, uint8 color) { vram[dest][y][x] = color; }
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);
}
@@ -117,41 +86,70 @@ public:
void box_fill(ScreenId dest, int sx, int sy, int ex, int ey, uint8 color);
void box_line(ScreenId dest, int sx, int sy, int ex, int ey, uint8 color);
void draw_window(int sx, int sy, int ex, int ey, bool frame, uint8 frame_color, uint8 back_color);
CG save_rect(int x, int y, int width, int height);
void restore_rect(const CG& cg);
int draw_text(ScreenId dest, int x, int y, std::u16string_view codes, int font_size, uint8 color);
void load_cursor(int page, uint8_t flags);
void select_cursor();
void translate_mouse_coords(int* x, int* y);
bool get_scanline_mode() const { return scanline_texture; }
void set_scanline_mode(bool enable);
bool save_screenshot(const char* path);
SDL_Rect dirty_rect = {};
ScreenId src_screen = SCREEN_FRONT;
ScreenId dest_screen = SCREEN_FRONT;
int scroll = 0;
int window_width, window_height;
int screen_width, screen_height;
// text
int draw_text(ScreenId dest, int x, int y, std::u16string_view codes, int font_size, uint8 color);
void draw_gaiji(ScreenId dest, int dest_x, int dest_y, const uint8_t bitmap[32], int size, uint8 color);
// CG表示
std::optional<SDL_Point> cg_dest;
std::unordered_set<int> censor_list;
std::unordered_set<int> ignore_palette;
int palette_bank;
// mouse
void load_cursor(int page, uint8_t flags);
void select_cursor();
void translate_mouse_coords(int* x, int* y);
// マウスカーソル
int cursor_index;
private:
const GameId& game_id;
// screen
SDL_Texture* sdlTexture;
SDL_Texture* scanline_texture;
SDL_Surface* hBmpScreen[NR_SCREENS]; // 8bpp
uint8_t (*vram[NR_SCREENS])[640]; // convenience pointer to hBmpScreen[i]->pixels
SDL_Rect dirty_rect = {};
// CG
CG load_gm3(const std::vector<uint8_t>& data, int transparent, uint8_t flags); // Intruder -桜屋敷の探索-
CG load_vsp2l(const std::vector<uint8_t>& data, int transparent, uint8_t flags); // Little Vampire
CG load_gl3(const std::vector<uint8_t>& data, bool set_palette, int transparent, uint8_t flags);
CG load_pms(int page, const std::vector<uint8_t>& data, bool set_palette, int transparent, uint8_t flags);
CG load_vsp(const std::vector<uint8_t>& data, bool set_palette, int transparent, uint8_t flags);
Dri acg;
const char* bmp_prefix = NULL;
std::unordered_set<int> censor_list;
// palette
SDL_Palette* program_palette;
SDL_Palette* screen_palette;
uint8_t palR(uint8_t col) const { return screen_palette->colors[col].r; }
uint8_t palG(uint8_t col) const { return screen_palette->colors[col].g; }
uint8_t palB(uint8_t col) const { return screen_palette->colors[col].b; }
int nearest_color(int r, int g, int b);
int fade_level = 0; // 0-255
int fade_color = 0; // 0: black, 255: white
// font
SDL_RWops* rw_font;
TTF_Font* hFont16;
TTF_Font* hFont24;
TTF_Font* hFont32;
TTF_Font* hFont48;
TTF_Font* hFont64;
uint8 gaiji[188][32];
void draw_char(ScreenId dest, int dest_x, int dest_y, uint16 code, TTF_Font* font, uint8 color);
void draw_char_antialias(ScreenId dest, int dest_x, int dest_y, uint16 code, TTF_Font* font, uint8 color, uint8 cache[]);
// mouse
SDL_Cursor* hCursor[10];
};
extern "C" void ags_setAntialiasedStringMode(int on);