AGS: Refactor Box struct

This commit is contained in:
kichikuou
2025-01-18 15:37:15 +09:00
parent fad34f7bb9
commit ff00165f47
5 changed files with 44 additions and 56 deletions
-30
View File
@@ -15,14 +15,6 @@ extern SDL_Window* g_window;
extern SDL_Renderer* g_renderer;
static SDL_Surface* display_surface;
#define SET_BOX(n, c, x1, y1, x2, y2) { \
box[n].color = c; \
box[n].sx = x1; \
box[n].sy = y1; \
box[n].ex = x2; \
box[n].ey = y2; \
}
namespace {
const uint32 SCANLINE_ALPHA = 0x38; // 0-255
@@ -197,28 +189,6 @@ AGS::AGS(const Config& config, const GameId& game_id) : game_id(game_id), dirty(
init_windows();
// Eコマンド
for(int i = 0; i < 20; i++) {
// SET_BOX(i, 0, 0, 0, 631, 399);
SET_BOX(i, 0, 0, 0, 639, 399);
}
if (game_id.sys_ver == 2) {
if (game_id.is(GameId::SDPS_TONO) || game_id.is(GameId::SDPS_KAIZOKU)) {
SET_BOX(0, 0, 40, 8, 598, 271);
} else if (game_id.is(GameId::PROG_FD)) {
SET_BOX(0, 0, 64, 13, 407, 289);
SET_BOX(1, 0, 24, 298, 111, 390);
SET_BOX(2, 0, 0, 0, 639, 307);
SET_BOX(3, 0, 0, 0, 319, 399);
SET_BOX(4, 0, (16*8), 310, ((77*8)-1), 390);
SET_BOX(5, 0, (4*8), 310, ((76*8)-1), 390);
SET_BOX(6, 0, (2*8), 317, ((56*8)-1), 389);
SET_BOX(7, 15, 64, 13, 407, 289);
SET_BOX(8, 0, 0, 0, 319, 399);
SET_BOX(9, 0, 320, 0, 639, 40);
}
}
// 画面選択
src_screen = dest_screen = 0;
+14 -10
View File
@@ -130,6 +130,10 @@ public:
menu_w[index - 1].frame = frame;
}
void set_box(int index, uint8 color, int sx, int sy, int ex, int ey) {
box[index - 1] = {color, sx, sy, ex, ey};
}
void load_cursor(int page);
void select_cursor();
void translate_mouse_coords(int* x, int* y);
@@ -171,16 +175,6 @@ public:
bool draw_hankaku;
bool draw_menu;
// ボックス (E, Y7コマンド)
typedef struct {
uint8 color;
int sx;
int sy;
int ex;
int ey;
} BOX;
BOX box[20];
// CG表示
bool set_cg_dest;
int cg_dest_x;
@@ -218,6 +212,16 @@ private:
Window text_w[10];
void init_windows();
// Box (E and Y7 commands)
struct Box {
uint8 color = 0;
int sx = 0;
int sy = 0;
int ex = 639;
int ey = 399;
};
Box box[20];
Dri acg;
const char* bmp_prefix = NULL;
};
+5 -10
View File
@@ -160,16 +160,11 @@ void AGS::draw_box(int index)
return;
}
int sx = box[index - 1].sx;
int sy = box[index - 1].sy;
int ex = box[index - 1].ex;
int ey = box[index - 1].ey;
uint8 color = box[index - 1].color;
if(1 <= index && index <= 10) {
box_fill(dest_screen, sx, sy, ex, ey, color);
} else if(11 <= index && index <= 20) {
box_line(dest_screen, sx, sy, ex, ey, color);
Box& b = box[index - 1];
if (1 <= index && index <= 10) {
box_fill(dest_screen, b.sx, b.sy, b.ex, b.ey, b.color);
} else if (11 <= index && index <= 20) {
box_line(dest_screen, b.sx, b.sy, b.ex, b.ey, b.color);
}
}
+20 -1
View File
@@ -19,7 +19,7 @@ namespace {
class NACT_Sys2 : public NACT {
public:
NACT_Sys2(const Config& config, const GameId& game_id) : NACT(config, game_id) {}
NACT_Sys2(const Config& config, const GameId& game_id);
protected:
void cmd_branch() override;
@@ -82,6 +82,25 @@ private:
#define WAIT(tm) do { wait_impl(tm); if (terminate) return; } while(0)
#define WAIT_KEYQUIT(tm) do { wait_keyquit_impl(tm); if (terminate) return; } while(0)
NACT_Sys2::NACT_Sys2(const Config& config, const GameId& game_id)
: NACT(config, game_id)
{
if (game_id.is(GameId::SDPS_TONO) || game_id.is(GameId::SDPS_KAIZOKU)) {
ags->set_box(0, 0, 40, 8, 598, 271);
} else if (game_id.is(GameId::PROG_FD)) {
ags->set_box(0, 0, 64, 13, 407, 289);
ags->set_box(1, 0, 24, 298, 111, 390);
ags->set_box(2, 0, 0, 0, 639, 307);
ags->set_box(3, 0, 0, 0, 319, 399);
ags->set_box(4, 0, (16*8), 310, ((77*8)-1), 390);
ags->set_box(5, 0, (4*8), 310, ((76*8)-1), 390);
ags->set_box(6, 0, (2*8), 317, ((56*8)-1), 389);
ags->set_box(7, 15, 64, 13, 407, 289);
ags->set_box(8, 0, 0, 0, 319, 399);
ags->set_box(9, 0, 320, 0, 639, 40);
}
}
void NACT_Sys2::cmd_branch()
{
int condition = cali();
+5 -5
View File
@@ -292,11 +292,11 @@ void NACT_Sys3::cmd_e()
TRACE("E %d,%d,%d,%d,%d,%d:", index, color, sx, sy, ex, ey);
ags->box[index - 1].color = color;
ags->box[index - 1].sx = column ? sx * 8 : sx;
ags->box[index - 1].sy = sy;
ags->box[index - 1].ex = column ? ex * 8 - 1 : ex; // ?
ags->box[index - 1].ey = ey;
if (column) {
sx = sx * 8;
ex = ex * 8 - 1;
}
ags->set_box(index, color, sx, sy, ex, ey);
}
void NACT_Sys3::cmd_g()