ags: Consolidate display info accessors

This commit is contained in:
kichikuou
2026-07-24 21:04:25 +09:00
parent 1785e93fcc
commit da3cc5d900
5 changed files with 46 additions and 59 deletions
+27 -14
View File
@@ -202,20 +202,33 @@ void ags_setWindowTitle(const char *title_utf8) {
gfx_setWindowTitle(buf);
}
void ags_getDIBInfo(DispInfo *info) {
info->width = nact->ags.world_width;
info->height = nact->ags.world_height;
info->depth = nact->ags.world_depth;
}
void ags_getViewAreaInfo(DispInfo *info) {
gfx_getDisplayInfo(NULL, NULL, &info->depth);
info->width = nact->ags.view_area.w;
info->height = nact->ags.view_area.h;
}
void ags_getWindowInfo(DispInfo *info) {
gfx_getDisplayInfo(&info->width, &info->height, &info->depth);
void ags_getDisplayInfo(enum ags_display display, int *width, int *height, int *depth) {
SDL_DisplayMode dm;
switch (display) {
case AGS_DISPLAY_CURRENT:
SDL_GetCurrentDisplayMode(0, &dm);
*width = dm.w;
*height = dm.h;
*depth = SDL_BITSPERPIXEL(dm.format);
break;
case AGS_DISPLAY_DIB:
*width = nact->ags.world_width;
*height = nact->ags.world_height;
*depth = nact->ags.world_depth;
break;
case AGS_DISPLAY_VIEW_AREA:
SDL_GetCurrentDisplayMode(0, &dm);
*width = nact->ags.view_area.w;
*height = nact->ags.view_area.h;
*depth = SDL_BITSPERPIXEL(dm.format);
break;
case AGS_DISPLAY_DESKTOP:
SDL_GetDesktopDisplayMode(0, &dm);
*width = dm.w;
*height = dm.h;
*depth = SDL_BITSPERPIXEL(dm.format);
break;
}
}
void ags_setExposeSwitch(bool expose) {
+7 -8
View File
@@ -102,11 +102,12 @@ typedef struct {
uint32_t index;
} PixelColor;
typedef struct {
int width;
int height;
int depth;
} DispInfo;
enum ags_display {
AGS_DISPLAY_CURRENT,
AGS_DISPLAY_DIB,
AGS_DISPLAY_VIEW_AREA,
AGS_DISPLAY_DESKTOP,
};
struct _ags {
SDL_Color pal[256]; /* system palette */
@@ -145,9 +146,7 @@ void ags_reset(void);
extern void ags_setWorldSize(int width, int height, int depth);
extern void ags_setViewArea(int x, int y, int width, int height);
extern void ags_setWindowTitle(const char *title_utf8);
extern void ags_getDIBInfo(DispInfo *info);
extern void ags_getWindowInfo(DispInfo *info);
extern void ags_getViewAreaInfo(DispInfo *info);
extern void ags_getDisplayInfo(enum ags_display display, int *width, int *height, int *depth);
extern bool ags_check_param(int *x, int *y, int *w, int *h);
extern bool ags_check_param_xy(int *x, int *y);
extern surface_t *ags_getDIB();
+12 -28
View File
@@ -53,6 +53,14 @@ static uint32_t get_counter(int num) {
return sys_get_ticks() - counters[num].base;
}
static void write_display_info(vmvar_t *var, enum ags_display display) {
int width, height, depth;
ags_getDisplayInfo(display, &width, &height, &depth);
var[0] = width;
var[1] = height;
var[2] = depth;
}
void commandZC() {
/* システムの使用環境を変更する */
int m = getCaliValue();
@@ -394,39 +402,21 @@ void commandZZ2() {
void commandZZ3() {
/* WINDOWSの全画面サイズや表示色数を変数列に返す */
vmvar_t *var = getCaliVariable();
DispInfo info;
ags_getWindowInfo(&info);
*var = info.width;
*(var + 1) = info.height;
*(var + 2) = info.depth;
write_display_info(var, AGS_DISPLAY_CURRENT);
TRACE("ZZ3 %p:",var);
}
void commandZZ4() {
/* DIB の全画面 サイズや色数を変数列に返す */
vmvar_t *var = getCaliVariable();
DispInfo info;
ags_getDIBInfo(&info);
*var = info.width;
*(var + 1) = info.height;
*(var + 2) = info.depth;
write_display_info(var, AGS_DISPLAY_DIB);
TRACE("ZZ4 %p:",var);
}
void commandZZ5() {
/* SYSTEM3.5用表示画面 の サイズや色数を変数列に返す */
vmvar_t *var = getCaliVariable();
DispInfo info;
ags_getViewAreaInfo(&info);
*var = info.width;
*(var + 1) = info.height;
*(var + 2) = info.depth;
write_display_info(var, AGS_DISPLAY_VIEW_AREA);
TRACE("ZZ5 %p:",var);
}
@@ -449,13 +439,7 @@ void commandZZ8() {
void commandZZ9() {
/* 起動時のスクリーンサイズを取得する */
vmvar_t *var = getCaliVariable();
DispInfo info;
ags_getWindowInfo(&info);
*var = info.width;
*(var + 1) = info.height;
*(var + 2) = info.depth;
write_display_info(var, AGS_DISPLAY_DESKTOP);
TRACE("ZZ9 %p:",var);
}
-1
View File
@@ -38,7 +38,6 @@ SDL_Window *gfx_getWindow(void);
void gfx_warpMouse(int x, int y);
SDL_Rect gfx_viewToWindowRect(SDL_Rect rect);
void gfx_setWindowTitle(char *name);
void gfx_getDisplayInfo(int *width, int *height, int *depth);
void gfx_setFullscreen(bool on);
bool gfx_isFullscreen(void);
void gfx_raiseWindow(void);
-8
View File
@@ -170,14 +170,6 @@ void gfx_setWorldSize(int width, int height, int depth) {
SDL_FillRect(main_surface, NULL, 0);
}
void gfx_getDisplayInfo(int *width, int *height, int *depth) {
SDL_DisplayMode dm;
SDL_GetCurrentDisplayMode(0, &dm);
if (width) *width = dm.w;
if (height) *height = dm.h;
if (depth) *depth = SDL_BITSPERPIXEL(dm.format);
}
void gfx_getViewSize(int *width, int *height) {
if (width)
*width = view_w;