Make MyRectangle an alias of SDL_Rect

This commit is contained in:
kichikuou
2021-01-09 13:43:21 +09:00
parent 34e2d60ab4
commit e18bb6cb75
22 changed files with 181 additions and 296 deletions
+5 -5
View File
@@ -289,9 +289,9 @@ static void ntmsg_out(int wNum, int wSize, int wColorR, int wColorG, int wColorB
// Waitなしの出力は最後にupdate
if (needupdate) {
uparea.width = sp->cursize.width;
uparea.height = min(sp->cursize.height, uparea.y - sp->u.msg.dspcur.y + wLineSpace + wLineSpace);
nt_sp_updateme_part(sp, uparea.x, uparea.y, uparea.width, uparea.height);
uparea.w = sp->cursize.width;
uparea.h = min(sp->cursize.height, uparea.y - sp->u.msg.dspcur.y + wLineSpace + wLineSpace);
nt_sp_updateme_part(sp, uparea.x, uparea.y, uparea.w, uparea.h);
}
}
@@ -459,8 +459,8 @@ int ntmsg_update(sprite_t *sp, MyRectangle *r) {
// -> 説明スプライトのように、SetShowされたときに対応できないからだめ
//if (sact.msgbufempty) return OK;
update.width = r->width;
update.height = r->height;
update.width = r->w;
update.height = r->h;
dx = sp->cur.x - r->x;
dy = sp->cur.y - r->y;
+4 -4
View File
@@ -60,8 +60,8 @@ int nt_sp_draw2(sprite_t *sp, cginfo_t *cg, MyRectangle *r) {
if (cg->sf == NULL) return NG;
// 更新領域の確定
update.width = r->width;
update.height = r->height;
update.width = r->w;
update.height = r->h;
sx = 0;
sy = 0;
dx = sp->cur.x - r->x;
@@ -116,8 +116,8 @@ int nt_sp_draw_scg(sprite_t *sp, MyRectangle *r) {
if (cg->sf == NULL) return NG;
// 更新領域の確定
update.width = r->width;
update.height = r->height;
update.width = r->w;
update.height = r->h;
sx = 0;
sy = 0;
dx = sp->cur.x - r->x;
+13 -47
View File
@@ -43,46 +43,15 @@ static SList *updatearea;
// 再描画するスプライトのリスト
static SList *updatelist;
static void intersection(MyRectangle *r1, MyRectangle *r2, MyRectangle *rst);
static void disjunction(void* region, void* data);
static MyRectangle get_updatearea();
static void do_update_each(void* data, void* userdata);
// 領域1と領域2の積を計算
static void intersection(MyRectangle *r1, MyRectangle *r2, MyRectangle *rst) {
int x1 = max(r1->x, r2->x);
int x2 = min(r1->x + r1->width, r2->x + r2->width);
int y1 = max(r1->y, r2->y);
int y2 = min(r1->y + r1->height, r2->y + r2->height);
rst->x = x1;
rst->y = y1;
rst->width = x2 - x1;
rst->height = y2 - y1;
}
// 領域1と領域2をすべて含む矩形領域を計算
static void disjunction(void* region, void* data) {
MyRectangle *r1 = (MyRectangle *)region;
MyRectangle *r2 = (MyRectangle *)data;
int x1, x2, y1, y2;
if (r2->width == 0) {
r2->x = r1->x;
r2->y = r1->y;
r2->width = r1->width;
r2->height = r1->height;
} else {
x1 = min(r1->x, r2->x);
x2 = max(r1->x + r1->width, r2->x + r2->width);
y1 = min(r1->y, r2->y);
y2 = max(r1->y + r1->height, r2->y + r2->height);
r2->x = x1;
r2->y = y1;
r2->width = x2 - x1;
r2->height = y2 - y1;
}
SDL_UnionRect(r1, r2, r2);
free(r1);
}
@@ -98,11 +67,10 @@ static MyRectangle get_updatearea() {
updatearea = NULL;
// surface0との領域の積をとる
intersection(&rsf0, &clip, &result);
SDL_IntersectRect(&rsf0, &clip, &result);
SACT_DEBUG("clipped area x=%d y=%d w=%d h=%d\n",
result.x, result.y,
result.width, result.height);
result.x, result.y, result.w, result.h);
return result;
}
@@ -153,16 +121,14 @@ int nt_sp_update_clipped() {
// 更新領域の確定
r = get_updatearea();
// 幅または高さが 0 の時はなにもしない
if (r.width == 0 || r.height == 0) {
if (SDL_RectEmpty(&r))
return OK;
}
// 更新領域に入っているスプライトの再描画
slist_foreach(updatelist, do_update_each, &r);
// 更新領域を Window に転送
ags_updateArea(r.x, r.y, r.width, r.height);
ags_updateArea(r.x, r.y, r.w, r.h);
return OK;
}
@@ -180,13 +146,13 @@ int nt_sp_updateme(sprite_t *sp) {
r = malloc(sizeof(MyRectangle));
r->x = sp->cur.x;
r->y = sp->cur.y;
r->width = sp->cursize.width;
r->height = sp->cursize.height;
r->w = sp->cursize.width;
r->h = sp->cursize.height;
updatearea = slist_append(updatearea, r);
SACT_DEBUG("x = %d, y = %d, spno = %d w=%d,h=%d\n",
r->x, r->y, sp->no, r->width, r->height);
r->x, r->y, sp->no, r->w, r->h);
return OK;
}
@@ -208,13 +174,13 @@ int nt_sp_updateme_part(sprite_t *sp, int x, int y, int w, int h) {
r = malloc(sizeof(MyRectangle));
r->x = sp->cur.x + x;
r->y = sp->cur.y + y;
r->width = w;
r->height = h;
r->w = w;
r->h = h;
updatearea = slist_append(updatearea, r);
SACT_DEBUG("x = %d, y = %d, spno = %d w=%d,h=%d\n",
r->x, r->y, sp->no, r->width, r->height);
r->x, r->y, sp->no, r->w, r->h);
return OK;
}
@@ -247,8 +213,8 @@ int nt_sp_draw_wall(sprite_t *sp, MyRectangle *area) {
sx = area->x;
sy = area->y;
w = area->width;
h = area->height;
w = area->w;
h = area->h;
gr_fill(sf0, sx, sy, w, h, 0, 0, 0);
SACT_DEBUG("do update no=%d, sx=%d, sy=%d, w=%d, h=%d, \n",
+2 -2
View File
@@ -77,8 +77,8 @@ static int sp_draw_wall(sprite_t *sp) {
sx = sact.updaterect.x;
sy = sact.updaterect.y;
w = sact.updaterect.width;
h = sact.updaterect.height;
w = sact.updaterect.w;
h = sact.updaterect.h;
gr_fill(sf0, sx, sy, w, h, 0, 0, 0);
SACT_DEBUG("do update no=%d, sx=%d, sy=%d, w=%d, h=%d, \n",
+2 -2
View File
@@ -101,8 +101,8 @@ int sp_draw2(sprite_t *sp, cginfo_t *cg) {
if (cg->sf == NULL) return NG;
// 更新領域の確定
update.width = sact.updaterect.width;
update.height = sact.updaterect.height;
update.width = sact.updaterect.w;
update.height = sact.updaterect.h;
sx = 0;
sy = 0;
dx = sp->cur.x - sact.updaterect.x;
+5 -5
View File
@@ -336,9 +336,9 @@ void smsg_out(int wNum, int wSize, int wColorR, int wColorG, int wColorB, int wF
// Waitなしの出力は最後にupdate
if (needupdate) {
uparea.width = sp->cursize.width;
uparea.height = min(sp->cursize.height, uparea.y - sp->u.msg.dspcur.y + wLineSpace + wLineSpace + wRSize);
sp_updateme_part(sp, uparea.x, uparea.y, uparea.width, uparea.height);
uparea.w = sp->cursize.width;
uparea.h = min(sp->cursize.height, uparea.y - sp->u.msg.dspcur.y + wLineSpace + wLineSpace + wRSize);
sp_updateme_part(sp, uparea.x, uparea.y, uparea.w, uparea.h);
}
// ????
@@ -438,8 +438,8 @@ int smsg_update(sprite_t *sp) {
// -> 説明スプライトのように、SetShowされたときに対応できないからだめ
//if (sact.msgbufempty) return OK;
update.width = sact.updaterect.width;
update.height = sact.updaterect.height;
update.width = sact.updaterect.w;
update.height = sact.updaterect.h;
dx = sp->cur.x - sact.updaterect.x;
dy = sp->cur.y - sact.updaterect.y;
+2 -2
View File
@@ -70,8 +70,8 @@ static boolean sp_is_insprite2(sprite_t *sp, int x, int y, int margin) {
r.x = sp->cur.x + margin;
r.y = sp->cur.y + margin;
r.width = curcg->sf->width - 2 * margin;
r.height = curcg->sf->height - 2 * margin;
r.w = curcg->sf->width - 2 * margin;
r.h = curcg->sf->height - 2 * margin;
return ags_regionContains(&r, x, y);
}
+13 -46
View File
@@ -39,46 +39,15 @@
// スプライト再描画間の間に変更のあったスプライトの領域の和
static SList *updatearea;
static void intersection(MyRectangle *r1, MyRectangle *r2, MyRectangle *rst);
static void disjunction(void* region, void* data);
static void get_updatearea();
static void do_update_each(void* data, void* userdata);
// 領域1と領域2の積を計算
static void intersection(MyRectangle *r1, MyRectangle *r2, MyRectangle *rst) {
int x1 = max(r1->x, r2->x);
int x2 = min(r1->x + r1->width, r2->x + r2->width);
int y1 = max(r1->y, r2->y);
int y2 = min(r1->y + r1->height, r2->y + r2->height);
rst->x = x1;
rst->y = y1;
rst->width = x2 - x1;
rst->height = y2 - y1;
}
// 領域1と領域2をすべて含む矩形領域を計算
static void disjunction(void* region, void* data) {
MyRectangle *r1 = (MyRectangle *)region;
MyRectangle *r2 = (MyRectangle *)data;
int x1, x2, y1, y2;
if (r2->width == 0) {
r2->x = r1->x;
r2->y = r1->y;
r2->width = r1->width;
r2->height = r1->height;
} else {
x1 = min(r1->x, r2->x);
x2 = max(r1->x + r1->width, r2->x + r2->width);
y1 = min(r1->y, r2->y);
y2 = max(r1->y + r1->height, r2->y + r2->height);
r2->x = x1;
r2->y = y1;
r2->width = x2 - x1;
r2->height = y2 - y1;
}
SDL_UnionRect(r1, r2, r2);
free(r1);
}
@@ -93,11 +62,11 @@ static void get_updatearea() {
updatearea = NULL;
// surface0との領域の積をとる
intersection(&rsf0, &clip, &sact.updaterect);
SDL_IntersectRect(&rsf0, &clip, &sact.updaterect);
SACT_DEBUG("clipped area x=%d y=%d w=%d h=%d\n",
sact.updaterect.x, sact.updaterect.y,
sact.updaterect.width, sact.updaterect.height);
sact.updaterect.w, sact.updaterect.h);
return;
}
@@ -135,8 +104,8 @@ int sp_update_all(boolean syncscreen) {
// 画面全体を更新領域に
sact.updaterect.x = 0;
sact.updaterect.y = 0;
sact.updaterect.width = sf0->width;
sact.updaterect.height = sf0->height;
sact.updaterect.w = sf0->width;
sact.updaterect.h = sf0->height;
// updatelistに登録してあるスプライトを再描画
// updatelistはスプライトの番号順に並んでいる
@@ -164,10 +133,8 @@ int sp_update_clipped() {
// 更新領域の確定
get_updatearea();
// 幅または高さが 0 の時はなにもしない
if (sact.updaterect.width == 0 || sact.updaterect.height == 0) {
if (SDL_RectEmpty(&sact.updaterect))
return OK;
}
// 更新領域に入っているスプライトの再描画
slist_foreach(sact.updatelist, do_update_each, NULL);
@@ -178,7 +145,7 @@ int sp_update_clipped() {
}
// 更新領域を Window に転送
ags_updateArea(sact.updaterect.x, sact.updaterect.y, sact.updaterect.width, sact.updaterect.height);
ags_updateArea(sact.updaterect.x, sact.updaterect.y, sact.updaterect.w, sact.updaterect.h);
return OK;
}
@@ -196,13 +163,13 @@ int sp_updateme(sprite_t *sp) {
r = malloc(sizeof(MyRectangle));
r->x = sp->cur.x;
r->y = sp->cur.y;
r->width = sp->cursize.width;
r->height = sp->cursize.height;
r->w = sp->cursize.width;
r->h = sp->cursize.height;
updatearea = slist_append(updatearea, r);
SACT_DEBUG("x = %d, y = %d, spno = %d w=%d,h=%d\n",
r->x, r->y, sp->no, r->width, r->height);
r->x, r->y, sp->no, r->w, r->h);
return OK;
}
@@ -224,13 +191,13 @@ int sp_updateme_part(sprite_t *sp, int x, int y, int w, int h) {
r = malloc(sizeof(MyRectangle));
r->x = sp->cur.x + x;
r->y = sp->cur.y + y;
r->width = w;
r->height = h;
r->w = w;
r->h = h;
updatearea = slist_append(updatearea, r);
SACT_DEBUG("x = %d, y = %d, spno = %d w=%d,h=%d\n",
r->x, r->y, sp->no, r->width, r->height);
r->x, r->y, sp->no, r->w, r->h);
return OK;
}
+12 -15
View File
@@ -402,8 +402,8 @@ static void SetAnimeRect() {
maprect.x = x;
maprect.y = y;
maprect.width = w;
maprect.height = h;
maprect.w = w;
maprect.h = h;
}
static void SetAnimeBack() {
@@ -428,8 +428,8 @@ static void SetAnimeBack() {
mapback.x = sx;
mapback.y = sy;
mapback.width = w;
mapback.height = h;
mapback.w = w;
mapback.h = h;
mapback_p5 = p5;
mapback_p6 = p6;
}
@@ -487,9 +487,8 @@ static void PlayAnimeData() {
if (!is_backcopied) {
is_backcopied = TRUE;
ags_copyArea(mapback.x, mapback.y,
mapback.width, mapback.height,
mapback_p5, mapback_p6);
ags_copyArea(mapback.x, mapback.y, mapback.w, mapback.h,
mapback_p5, mapback_p6);
}
if (wavno != 0) {
@@ -541,14 +540,12 @@ static void PlayAnimeData() {
// printf("wavPlay %d\n", wavno % 256);
}
}
if (is_backcopied && maprect.width != 0 && maprect.height != 0) {
ags_updateArea(maprect.x, maprect.y, maprect.width, maprect.height);
}
{
int now = get_high_counter(SYSTEMCOUNTER_MSEC);
if (now - cnt < interval) {
sdl_sleep(interval - (now-cnt));
}
if (is_backcopied && !SDL_RectEmpty(&maprect))
ags_updateArea(maprect.x, maprect.y, maprect.w, maprect.h);
int now = get_high_counter(SYSTEMCOUNTER_MSEC);
if (now - cnt < interval) {
sdl_sleep(interval - (now-cnt));
}
}
}
+30 -53
View File
@@ -43,10 +43,8 @@
#define check_param ags_check_param
#define check_param_xy ags_check_param_xy
#define intersection ags_intersection
static void initPal(Palette256 *sys_pal);
static boolean intersects(MyRectangle *r1, MyRectangle *r2);
static Palette256 pal_256;
static boolean need_update = TRUE;
@@ -67,25 +65,8 @@ static void initPal(Palette256 *pal) {
}
boolean ags_regionContains(MyRectangle *r, int x, int y) {
return x >= r->x && x < r->x + r->width && y >= r->y && y < r->y + r->height;
}
static boolean intersects(MyRectangle *r1, MyRectangle *r2) {
return !((r2->x + r2->width <= r1->x) ||
(r2->y + r2->height <= r1->y) ||
(r2->x >= r1->x + r1->width) ||
(r2->y >= r1->y + r1->height));
}
void ags_intersection(MyRectangle *r1, MyRectangle *r2, MyRectangle *rst) {
int x1 = max(r1->x, r2->x);
int x2 = min(r1->x + r1->width, r2->x + r2->width);
int y1 = max(r1->y, r2->y);
int y2 = min(r1->y + r1->height, r2->y + r2->height);
rst->x = x1;
rst->y = y1;
rst->width = x2 - x1;
rst->height = y2 - y1;
MyPoint p = {x, y};
return SDL_PointInRect(&p, r);
}
boolean ags_check_param(int *x, int *y, int *w, int *h) {
@@ -134,8 +115,8 @@ void ags_init() {
nact->sys_world_depth = SYS35_DEFAULT_DEPTH;
nact->sys_view_area.x = 0;
nact->sys_view_area.y = 0;
nact->sys_view_area.width = SYS35_DEFAULT_WIDTH;
nact->sys_view_area.height = SYS35_DEFAULT_HEIGHT;
nact->sys_view_area.w = SYS35_DEFAULT_WIDTH;
nact->sys_view_area.h = SYS35_DEFAULT_HEIGHT;
sdl_Initilize();
font_init();
@@ -176,8 +157,8 @@ void ags_setViewArea(int x, int y, int width, int height) {
nact->sys_view_area.x = x;
nact->sys_view_area.y = y;
nact->sys_view_area.width = width;
nact->sys_view_area.height = height;
nact->sys_view_area.w = width;
nact->sys_view_area.h = height;
sdl_setWindowSize(x, y, width, height);
}
@@ -204,8 +185,8 @@ void ags_getDIBInfo(DispInfo *info) {
void ags_getViewAreaInfo(DispInfo *info) {
sdl_getWindowInfo(info);
info->width = nact->sys_view_area.width;
info->height = nact->sys_view_area.height;
info->width = nact->sys_view_area.w;
info->height = nact->sys_view_area.h;
}
void ags_getWindowInfo(DispInfo *info) {
@@ -217,35 +198,31 @@ void ags_setExposeSwitch(boolean bool) {
}
void ags_updateArea(int x, int y, int w, int h) {
MyRectangle r, update;
MyPoint p;
if (fade_outed) return;
if (need_update) {
r.x = x; r.y = y; r.width = w; r.height = h;
if (intersects(&nact->sys_view_area, &r)) {
intersection(&nact->sys_view_area, &r, &update);
p.x = update.x - nact->sys_view_area.x;
p.y = update.y - nact->sys_view_area.y;
sdl_updateArea(&update, &p);
}
if (fade_outed || !need_update)
return;
MyRectangle r = {x, y, w, h}, update;
if (SDL_IntersectRect(&nact->sys_view_area, &r, &update)) {
MyPoint p = {
update.x - nact->sys_view_area.x,
update.y - nact->sys_view_area.y
};
sdl_updateArea(&update, &p);
}
}
void ags_updateFull() {
if (fade_outed || !need_update)
return;
MyRectangle r = {
nact->sys_view_area.x,
nact->sys_view_area.y,
min(nact->sys_view_area.w, nact->sys_world_size.width),
min(nact->sys_view_area.h, nact->sys_world_size.height)
};
MyPoint p = {0, 0};
MyRectangle r;
if (fade_outed) return;
if (need_update) {
r.x = nact->sys_view_area.x;
r.y = nact->sys_view_area.y;
r.width = min(nact->sys_view_area.width, nact->sys_world_size.width);
r.height = min(nact->sys_view_area.height, nact->sys_world_size.height);
sdl_updateArea(&r, &p);
}
sdl_updateArea(&r, &p);
}
void ags_setPalettes(Palette256 *src_pal, int src, int dst, int cnt) {
@@ -550,8 +527,8 @@ MyRectangle* ags_imageFlood(int x, int y, int c) {
flood(x, y, pixcel);
rec.x = updatePointTop.x;
rec.y = updatePointTop.y;
rec.width = updatePointEnd.x - updatePointTop.x + 1;
rec.height = updatePointEnd.y - updatePointTop.y + 1;
rec.w = updatePointEnd.x - updatePointTop.x + 1;
rec.h = updatePointEnd.y - updatePointTop.y + 1;
return &rec;
}
}
-1
View File
@@ -151,7 +151,6 @@ extern void ags_getViewAreaInfo(DispInfo *info);
extern boolean ags_regionContains(MyRectangle *r, int x, int y);
extern boolean ags_check_param(int *x, int *y, int *w, int *h);
extern boolean ags_check_param_xy(int *x, int *y);
extern void ags_intersection(MyRectangle *r1, MyRectangle *r2, MyRectangle *rst);
extern agsurface_t *ags_getDIB();
/* 画面更新 */
+3 -3
View File
@@ -517,13 +517,13 @@ void cg_get_info(int no, MyRectangle *info) {
MyPoint p;
if (cg == NULL) {
info->x = info->y = info->width = info->height = 0;
info->x = info->y = info->w = info->h = 0;
} else {
p = set_display_loc(cg);
info->x = p.x;
info->y = p.y;
info->width = cg->width;
info->height = cg->height;
info->w = cg->width;
info->h = cg->height;
}
}
+2 -5
View File
@@ -811,11 +811,8 @@ void commands2F4C() {
int eWidth = getCaliValue();
int eHeight = getCaliValue();
MyRectangle r;
MyPoint p;
r.x = eSrcX; r.y = eSrcY; r.width = eWidth; r.height = eHeight;
p.x = eX, p.y = eY;
MyRectangle r = {eSrcX, eSrcY, eWidth, eHeight};
MyPoint p = {eX, eY};
sdl_updateArea(&r, &p);
+1 -1
View File
@@ -256,7 +256,7 @@ void commandCP() {
MyRectangle* rec = ags_imageFlood(x, y, color);
if (rec != NULL) {
ags_updateArea(rec->x, rec->y, rec->width, rec->height);
ags_updateArea(rec->x, rec->y, rec->w, rec->h);
}
DEBUG_COMMAND("CP %d,%d,%d:\n", x, y, color);
+15 -15
View File
@@ -42,11 +42,11 @@ void commandES() {
int width = getCaliValue();
int height = getCaliValue();
tbl[num - 1].r.x = x;
tbl[num - 1].r.y = y;
tbl[num - 1].r.width = width;
tbl[num - 1].r.height = height;
tbl[num - 1].pal = pal;
tbl[num - 1].r.x = x;
tbl[num - 1].r.y = y;
tbl[num - 1].r.w = width;
tbl[num - 1].r.h = height;
tbl[num - 1].pal = pal;
DEBUG_COMMAND("ES %d,%d,%d,%d,%d,%d:\n", num, pal, x, y, width, height);
}
@@ -58,13 +58,13 @@ void commandEC() {
if (num == 0) {
r = &nact->sys_view_area;
ags_fillRectangle(r->x, r->y, r->width, r->height, 0);
ags_updateArea(r->x, r->y, r->width, r->height);
ags_fillRectangle(r->x, r->y, r->w, r->h, 0);
ags_updateArea(r->x, r->y, r->w, r->h);
} else {
int adj = (nact->patch_ec == 0) ? -1 : 0;
e = &tbl[num - 1];
ags_fillRectangle(e->r.x, e->r.y, e->r.width + adj, e->r.height + adj, e->pal);
ags_updateArea(e->r.x, e->r.y, e->r.width + adj, e->r.height + adj);
ags_fillRectangle(e->r.x, e->r.y, e->r.w + adj, e->r.h + adj, e->pal);
ags_updateArea(e->r.x, e->r.y, e->r.w + adj, e->r.h + adj);
}
DEBUG_COMMAND("EC %d:\n", num);
}
@@ -78,8 +78,8 @@ void commandEG() {
*x = tbl[num -1].r.x;
*y = tbl[num -1].r.y;
*width = tbl[num -1].r.width;
*height = tbl[num -1].r.height;
*width = tbl[num -1].r.w;
*height = tbl[num -1].r.h;
DEBUG_COMMAND("EG %d,%d,%d,%d,%d:\n", num, *x, *y, *width, *height);
}
@@ -92,8 +92,8 @@ void commandEM() {
MyRectangle r = tbl[num - 1].r;
if (nact->patch_emen == 0) {
r.width -= 1;
r.height -= 1;
r.w -= 1;
r.h -= 1;
}
*var = ags_regionContains(&r, x, y) ? 1 : 0;
DEBUG_COMMAND("EM %d,%d,%d,%d:\n", num, *var, x, y);
@@ -113,8 +113,8 @@ void commandEN() {
for (i = min; i <= max; i++) {
r = tbl[i - 1].r;
if (nact->patch_emen == 0) {
r.width -= 1;
r.height -= 1;
r.w -= 1;
r.h -= 1;
}
if (ags_regionContains(&r, x, y)) *var = i;
}
+2 -2
View File
@@ -68,8 +68,8 @@ void commandGS() {
cg_get_info(num - 1, &r);
var[0] = r.x;
var[1] = r.y;
var[2] = r.width;
var[3] = r.height;
var[2] = r.w;
var[3] = r.h;
DEBUG_COMMAND("GS %d,%p:\n",num,var);
}
+15 -22
View File
@@ -65,16 +65,11 @@ static int get_ecounter(void) {
}
static void eCopyUpdateArea(int sx, int sy, int w, int h, int dx, int dy) {
MyRectangle src;
MyPoint dst;
src.x = sx;
src.y = sy;
src.width = w;
src.height = h;
dst.x = dx - nact->sys_view_area.x;
dst.y = dy - nact->sys_view_area.y;
MyRectangle src = {sx, sy, w, h};
MyPoint dst = {
dx - nact->sys_view_area.x,
dy - nact->sys_view_area.y
};
sdl_updateArea(&src, &dst);
}
@@ -1069,20 +1064,20 @@ static void eCopyArea43(int step) {
}
if (step == slice) {
ags_scaledCopyArea(ecp.sx, ecp.sy, ecp.w, ecp.h,
nact->sys_view_area.x, nact->sys_view_area.y,
nact->sys_view_area.width, nact->sys_view_area.height, 0);
nact->sys_view_area.x, nact->sys_view_area.y,
nact->sys_view_area.w, nact->sys_view_area.h, 0);
ags_updateFull();
return;
}
deltax = (ecp.sx - nact->sys_view_area.x) * step / slice;
deltay = (ecp.sy - nact->sys_view_area.y) * step / slice;
deltaw = (nact->sys_view_area.width - ecp.w) * step / slice;
deltah = (nact->sys_view_area.height - ecp.h) * step / slice;
deltaw = (nact->sys_view_area.w - ecp.w) * step / slice;
deltah = (nact->sys_view_area.h - ecp.h) * step / slice;
ags_zoom(nact->sys_view_area.x + deltax,
nact->sys_view_area.y + deltay,
nact->sys_view_area.width - deltaw,
nact->sys_view_area.height - deltah);
nact->sys_view_area.w - deltaw,
nact->sys_view_area.h - deltah);
}
static void eCopyArea44(int step) {
@@ -1261,12 +1256,10 @@ void ags_eCopyArea(int sx, int sy, int w, int h, int dx, int dy, int sw, int opt
ags_copyAreaSP(sx, sy, w, h, dx, dy, spCol);
}
{
MyRectangle r, update;
r.x = dx; r.y = dy; r.width = w; r.height = h;
ags_intersection(&nact->sys_view_area, &r, &update);
w = update.width;
h = update.height;
MyRectangle r = {dx, dy, w, h}, update;
SDL_IntersectRect(&nact->sys_view_area, &r, &update);
w = update.w;
h = update.h;
}
}
+3 -10
View File
@@ -25,6 +25,7 @@
#define __GRAPHICS__
#include "portab.h"
#include <SDL_rect.h>
typedef struct {
BYTE red[256];
@@ -37,22 +38,14 @@ typedef struct {
DWORD pixel;
} Palette;
typedef struct {
int x;
int y;
} MyPoint;
typedef SDL_Point MyPoint;
typedef struct {
int width;
int height;
} MyDimension;
typedef struct {
int x;
int y;
int width;
int height;
} MyRectangle;
typedef SDL_Rect MyRectangle;
typedef struct {
int width;
+17 -17
View File
@@ -132,38 +132,38 @@ void msg_putMessage(const char *m) {
switch(msgDecorateType) {
case 0:
default:
adj.x = 0; adj.y = 0; adj.width = 0; adj.height = 0;
adj.x = 0; adj.y = 0; adj.w = 0; adj.h = 0;
break;
case 1:
ags_drawString(msgcur.x, msgcur.y +1, m, msgDecorateColor);
adj.x = 0; adj.y = 0; adj.width = 0; adj.height = 1;
adj.x = 0; adj.y = 0; adj.w = 0; adj.h = 1;
break;
case 2:
ags_drawString(msgcur.x +1, msgcur.y, m, msgDecorateColor);
adj.x = 0; adj.y = 0; adj.width = 1; adj.height = 0;
adj.x = 0; adj.y = 0; adj.w = 1; adj.h = 0;
break;
case 3:
ags_drawString(msgcur.x +1, msgcur.y +1, m, msgDecorateColor);
adj.x = 0; adj.y = 0; adj.width = 1; adj.height = 1;
adj.x = 0; adj.y = 0; adj.w = 1; adj.h = 1;
break;
case 4:
ags_drawString(msgcur.x -1, msgcur.y, m, msgDecorateColor);
ags_drawString(msgcur.x +1, msgcur.y, m, msgDecorateColor);
ags_drawString(msgcur.x, msgcur.y -1, m, msgDecorateColor);
ags_drawString(msgcur.x, msgcur.y +1, m, msgDecorateColor);
adj.x = -1; adj.y = -1; adj.width = 2; adj.height = 2;
adj.x = -1; adj.y = -1; adj.w = 2; adj.h = 2;
break;
case 6:
ags_drawString(msgcur.x +1, msgcur.y, m, msg.MsgFontColor);
adj.x = 0; adj.y = 0; adj.width = 1; adj.height = 0;
adj.x = 0; adj.y = 0; adj.w = 1; adj.h = 0;
break;
case 7:
ags_drawString(msgcur.x, msgcur.y +1, m, msg.MsgFontColor);
adj.x = 0; adj.y = 0; adj.width = 0; adj.height = 1;
adj.x = 0; adj.y = 0; adj.w = 0; adj.h = 1;
break;
case 8:
ags_drawString(msgcur.x +1, msgcur.y +1, m, msg.MsgFontColor);
adj.x = 0; adj.y = 0; adj.width = 1; adj.height = 1;
adj.x = 0; adj.y = 0; adj.w = 1; adj.h = 1;
break;
case 10:
ags_drawString(msgcur.x -1, msgcur.y , m, msgDecorateColor);
@@ -171,25 +171,25 @@ void msg_putMessage(const char *m) {
ags_drawString(msgcur.x , msgcur.y -1, m, msgDecorateColor);
ags_drawString(msgcur.x , msgcur.y +1, m, msgDecorateColor);
ags_drawString(msgcur.x +2, msgcur.y +2, m, msgDecorateColor);
adj.x = -1; adj.y = -1; adj.width = 3; adj.height = 3;
adj.x = -1; adj.y = -1; adj.w = 3; adj.h = 3;
break;
}
MyRectangle drawn = ags_drawString(msgcur.x, msgcur.y, m, msg.MsgFontColor);
msgcur.x += drawn.width;
msgcur.x += drawn.w;
drawn.x += adj.x;
drawn.y += adj.y;
drawn.width += adj.width;
drawn.height += adj.height;
drawn.w += adj.w;
drawn.h += adj.h;
if (nact->messagewait_enable && !nact->messagewait_cancelled && !msgskip_isSkipping()) {
int x;
for (x = 0; x < drawn.width; x+=16) {
ags_updateArea(drawn.x + x, drawn.y, 16, drawn.height);
for (x = 0; x < drawn.w; x+=16) {
ags_updateArea(drawn.x + x, drawn.y, 16, drawn.h);
if (nact->messagewait_cancel) {
if (sys_getInputInfo()) {
nact->messagewait_cancelled = TRUE;
ags_updateArea(drawn.x, drawn.y, drawn.width, drawn.height);
ags_updateArea(drawn.x, drawn.y, drawn.w, drawn.h);
break;
}
sdl_sleep(nact->messagewait_time * 10);
@@ -197,7 +197,7 @@ void msg_putMessage(const char *m) {
nact->callback();
}
} else {
ags_updateArea(drawn.x, drawn.y, drawn.width, drawn.height);
ags_updateArea(drawn.x, drawn.y, drawn.w, drawn.h);
}
}
@@ -335,7 +335,7 @@ void msg_hitAnyKey() {
MyRectangle r = ags_drawString(msg.win->x + msg.win->width - msg.MsgFontSize,
msg.win->y + msg.win->height - msg.MsgFontSize,
prompt[nact->encoding], msg.HitAnyKeyMsgColor);
ags_updateArea(r.x, r.y, r.width, r.height);
ags_updateArea(r.x, r.y, r.w, r.h);
}
static void drawLineFrame(Bcom_WindowInfo *i) {
-1
View File
@@ -31,7 +31,6 @@ typedef int emscripten_align1_int;
#endif
#include "portab.h"
#include "cg.h"
#include "windowframe.h"
#define SAVE_MAXNUMBER (26)
+2 -5
View File
@@ -103,12 +103,9 @@ void sdl_wait_vsync() {
/* off-screen の指定領域を Main Window へ転送 */
void sdl_updateArea(MyRectangle *src, MyPoint *dst) {
SDL_Rect rect_s, rect_d;
SDL_Rect rect_d = {winoffset_x + dst->x, winoffset_y + dst->y, src->w, src->h};
setRect(rect_s, src->x, src->y, src->width, src->height);
setRect(rect_d, winoffset_x + dst->x, winoffset_y + dst->y, src->width, src->height);
SDL_BlitSurface(sdl_dib, &rect_s, sdl_display, &rect_d);
SDL_BlitSurface(sdl_dib, src, sdl_display, &rect_d);
sdl_dirty = TRUE;
}
+33 -33
View File
@@ -239,32 +239,32 @@ static void init_selwindow() {
int i;
MyRectangle r;
r.x = sel.win->x;
r.y = sel.win->y;
r.width = 4 + (sel.WinResizeWidth ? sel.MsgFontSize * maxElementLength : sel.win->width);
r.height = 2 + (sel.WinResizeHeight ? (sel.MsgFontSize +2) * regnum : max((sel.MsgFontSize +2) * regnum, sel.win->height));
r.x = sel.win->x;
r.y = sel.win->y;
r.w = 4 + (sel.WinResizeWidth ? sel.MsgFontSize * maxElementLength : sel.win->width);
r.h = 2 + (sel.WinResizeHeight ? (sel.MsgFontSize +2) * regnum : max((sel.MsgFontSize +2) * regnum, sel.win->height));
if (sel.win->save) {
saveArea.x = r.x - sel.Framedot;
saveArea.y = r.y - sel.Framedot;
saveArea.width = r.width + 2 * sel.Framedot;
saveArea.height = r.height + 2 * sel.Framedot;
saveimg = ags_saveRegion(saveArea.x, saveArea.y, saveArea.width, saveArea.height);
saveArea.w = r.w + 2 * sel.Framedot;
saveArea.h = r.h + 2 * sel.Framedot;
saveimg = ags_saveRegion(saveArea.x, saveArea.y, saveArea.w, saveArea.h);
} else {
saveArea = r;
}
if (sel.WinBackgroundTransparent == 255) {
ags_fillRectangle(r.x, r.y, r.width, r.height, sel.WinBackgroundColor);
ags_fillRectangle(r.x, r.y, r.w, r.h, sel.WinBackgroundColor);
} else {
ags_wrapColor(r.x, r.y, r.width, r.height, sel.WinBackgroundColor, sel.WinBackgroundTransparent);
ags_wrapColor(r.x, r.y, r.w, r.h, sel.WinBackgroundColor, sel.WinBackgroundTransparent);
}
switch(sel.WindowFrameType) {
case WINDOW_FRAME_EMPTY:
break;
case WINDOW_FRAME_LINE:
drawLineFrame(r.x, r.y, r.width, r.height);
drawLineFrame(r.x, r.y, r.w, r.h);
break;
case WINDOW_FRAME_CG:
printf("frameType is CG %d,%d,%d\n",sel.FrameCgNoTop, sel.FrameCgNoMid, sel.FrameCgNoBot);
@@ -278,30 +278,30 @@ static void init_selwindow() {
DEBUG_MESSAGE("%d:%s\n", i +1, elm[i]);
ags_drawString(r.x +2, r.y + i * (sel.MsgFontSize +2) +1, elm[i], sel.MsgFontColor);
}
ags_updateArea(saveArea.x, saveArea.y, saveArea.width, saveArea.height);
ags_updateArea(saveArea.x, saveArea.y, saveArea.w, saveArea.h);
/* マウスカーソルの自動移動 */
if (default_element == 0) {
MyPoint p;
sys_getMouseInfo(&p, TRUE);
if (p.y < r.y) {
ags_setCursorLocation(r.x + r.width * MOUSE_INIT_X_RATIO/100,
ags_setCursorLocation(r.x + r.w * MOUSE_INIT_X_RATIO/100,
r.y + (sel.MsgFontSize +2) * MOUSE_INIT_Y_RATIO/100,
TRUE);
} else if (p.y > (r.y + r.height)) {
ags_setCursorLocation(r.x + r.width * MOUSE_INIT_X_RATIO/100,
} else if (p.y > (r.y + r.h)) {
ags_setCursorLocation(r.x + r.w * MOUSE_INIT_X_RATIO/100,
r.y + (sel.MsgFontSize +2) * regnum * MOUSE_INIT_Y_RATIO/100,
TRUE);
} else {
ags_setCursorLocation(r.x + r.width * MOUSE_INIT_X_RATIO/100,
ags_setCursorLocation(r.x + r.w * MOUSE_INIT_X_RATIO/100,
p.y * MOUSE_INIT_Y_RATIO/100,
TRUE);
}
} else if (default_element < regnum) {
ags_setCursorLocation(r.x + r.width * MOUSE_INIT_X_RATIO/100,
ags_setCursorLocation(r.x + r.w * MOUSE_INIT_X_RATIO/100,
r.y + (sel.MsgFontSize +2) * default_element * MOUSE_INIT_Y_RATIO/100, TRUE);
} else if (default_element < 1000) {
ags_setCursorLocation(r.x + r.width * MOUSE_INIT_X_RATIO/100,
ags_setCursorLocation(r.x + r.w * MOUSE_INIT_X_RATIO/100,
r.y + (sel.MsgFontSize +2) * regnum * MOUSE_INIT_Y_RATIO/100, TRUE);
}
}
@@ -309,7 +309,7 @@ static void init_selwindow() {
static void remove_selwindow() {
if (sel.win->save) {
ags_restoreRegion(saveimg, saveArea.x, saveArea.y);
ags_updateArea(saveArea.x, saveArea.y, saveArea.width, saveArea.height);
ags_updateArea(saveArea.x, saveArea.y, saveArea.w, saveArea.h);
saveimg = NULL;
}
}
@@ -333,8 +333,8 @@ static int whereElement(void) {
mpy = p.y;
for (i = 0; i < regnum; i++) {
if (p.x >= r[i].x && p.x < r[i].x + r[i].width &&
p.y >= r[i].y && p.y < r[i].y + r[i].height) {
if (p.x >= r[i].x && p.x < r[i].x + r[i].w &&
p.y >= r[i].y && p.y < r[i].y + r[i].h) {
return i;
}
}
@@ -342,10 +342,10 @@ static int whereElement(void) {
}
static void lineEncloseElement(MyRectangle *r, int col, boolean thick) {
ags_drawRectangle(r->x, r->y, r->width + 2, r->height + 2, col);
ags_drawRectangle(r->x, r->y, r->w + 2, r->h + 2, col);
if (thick)
ags_drawRectangle(r->x + 1, r->y + 1, r->width, r->height, col);
ags_updateArea(r->x, r->y, r->width + 2, r->height + 2);
ags_drawRectangle(r->x + 1, r->y + 1, r->w, r->h, col);
ags_updateArea(r->x, r->y, r->w + 2, r->h + 2);
}
static void encloseElement(int sw, int no) {
@@ -354,7 +354,7 @@ static void encloseElement(int sw, int no) {
if (sw == 0) { /* off */
if (sel.WinBackgroundTransparent != 255) {
ags_restoreRegion(saveimg2, r->x, r->y);
ags_updateArea(r->x, r->y, r->width +2, r->height +2);
ags_updateArea(r->x, r->y, r->w +2, r->h +2);
saveimg2 = NULL;
} else {
switch(sel.EncloseType) {
@@ -363,9 +363,9 @@ static void encloseElement(int sw, int no) {
case 1:
lineEncloseElement(r, sel.WinBackgroundColor, FALSE); break;
case 2:
ags_fillRectangle(r->x, r->y, r->width +2, r->height +2, sel.WinBackgroundColor);
ags_fillRectangle(r->x, r->y, r->w +2, r->h +2, sel.WinBackgroundColor);
ags_drawString(r->x +2, r->y +1, elm[no], sel.MsgFontColor);
ags_updateArea(r->x, r->y, r->width +2, r->height +2);
ags_updateArea(r->x, r->y, r->w +2, r->h +2);
break;
default:
break;
@@ -374,7 +374,7 @@ static void encloseElement(int sw, int no) {
} else { /* on */
if (sel.WinBackgroundTransparent != 255) {
saveimg2 = ags_saveRegion(r->x, r->y, r->width +2, r->height +2);
saveimg2 = ags_saveRegion(r->x, r->y, r->w +2, r->h +2);
}
switch(sel.EncloseType) {
case 0:
@@ -382,9 +382,9 @@ static void encloseElement(int sw, int no) {
case 1:
lineEncloseElement(r, 255, FALSE); break;
case 2:
ags_fillRectangle(r->x, r->y, r->width +2, r->height +2, sel.MsgFontColor);
ags_fillRectangle(r->x, r->y, r->w +2, r->h +2, sel.MsgFontColor);
ags_drawString(r->x +2, r->y +1, elm[no], sel.WinBackgroundColor);
ags_updateArea(r->x, r->y, r->width +2, r->height +2);
ags_updateArea(r->x, r->y, r->w +2, r->h +2);
break;
default:
break;
@@ -424,10 +424,10 @@ void sel_select() {
}
for (i = 0; i < regnum; i++) {
workR[i].x = sel.win->x;
workR[i].y = sel.win->y + i * (sel.MsgFontSize +2);
workR[i].width = 2 + (sel.WinResizeWidth ? sel.MsgFontSize * maxElementLength : sel.win->width);
workR[i].height = 2 + sel.MsgFontSize;
workR[i].x = sel.win->x;
workR[i].y = sel.win->y + i * (sel.MsgFontSize +2);
workR[i].w = 2 + (sel.WinResizeWidth ? sel.MsgFontSize * maxElementLength : sel.win->width);
workR[i].h = 2 + sel.MsgFontSize;
}
sys_key_releasewait(SYS35KEY_RET, FALSE);