Initial commit

This commit is contained in:
2026-02-02 04:50:13 +01:00
commit 5b11698731
22592 changed files with 7677434 additions and 0 deletions

View File

@@ -0,0 +1,551 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
/*
* aarot.c --- anti-aliased rotation for Allegro
*
* This file is gift-ware. This file is given to you freely
* as a gift. You may use, modify, redistribute, and generally hack
* it about in any way you like, and you do not have to give anyone
* anything in return.
*
* I do not accept any responsibility for any effects, adverse or
* otherwise, that this code may have on just about anything that
* you can think of. Use it at your own risk.
*
* Copyright (C) 1998, 1999 Michael Bukin
*/
#include "ags/lib/aastr-0.1.1/aastr.h"
#include "ags/lib/aastr-0.1.1/aautil.h"
namespace AGS3 {
/*
* Engine of anti-aliased rotation.
*/
static void _aa_rotate_bitmap(BITMAP *_src, BITMAP *_dst, int _x, int _y, fixed _angle,
fixed _scalex, fixed _scaley, int _masked) {
int sw, sh, dw, dh;
fixed fx0, fy0, fux, fuy, fvx, fvy;
fixed fdw, fdh, fsinangle, fcosangle;
struct {
int dx, dy;
int sx, sy;
} point[4], *lpoint1, *lpoint2, *rpoint1, *rpoint2;
int ledge[4], redge[4], lindex, rindex;
int xbeg, xend, ybeg, yend;
int sx, sy, dx, dy, dsx, dsy;
int ldx, lsx, lsy, *lsc;
int rdx, rsx, rsy, *rsc;
int ldxinc, ldxdd, ldxi1, ldxi2;
int rdxinc, rdxdd, rdxi1, rdxi2;
int lscinc, lscdd, lsci1, lsci2;
int rscinc, rscdd, rsci1, rsci2;
int sxinc, sxdd, sxi1, sxi2;
int syinc, sydd, syi1, syi2;
uint32_t num;
void (*add)(BITMAP * _src, int _sx1, int _sx2, int _sy1, int _sy2, uint32_t _num);
void (*put)(byte * _addr, int _x);
if (_dst->clip) {
xbeg = _dst->cl;
xend = _dst->cr;
ybeg = _dst->ct;
yend = _dst->cb;
} else {
xbeg = 0;
xend = _dst->w;
ybeg = 0;
yend = _dst->h;
}
if ((xbeg >= xend) || (ybeg >= yend))
return;
/* Convert angle to [0, 256) range. */
_angle %= itofix(256);
if (_angle < 0)
_angle += itofix(256);
/* Width and height of source and destination. */
sw = _src->w;
sh = _src->h;
fdw = fixmul(ABS(_scalex), itofix(sw));
fdh = fixmul(ABS(_scaley), itofix(sh));
dw = fixtoi(fdw);
dh = fixtoi(fdh);
if ((dw <= 0) || (dh <= 0))
return;
fdw /= 2;
fdh /= 2;
/* Center of destination. */
fx0 = itofix(_x);
fy0 = itofix(_y);
fsinangle = fixsin(_angle);
fcosangle = fixcos(_angle);
/* Map source (half) edges onto destination. */
fux = fixmul(fdw, fcosangle);
fuy = fixmul(fdw, fsinangle);
fvx = -fixmul(fdh, fsinangle);
fvy = fixmul(fdh, fcosangle);
/* Coordinates of corners in destination. */
point[0].dx = fixtoi(fx0 - fux - fvx);
point[1].dx = fixtoi(fx0 + fux - fvx);
point[2].dx = fixtoi(fx0 - fux + fvx);
point[3].dx = fixtoi(fx0 + fux + fvx);
point[0].dy = fixtoi(fy0 - fuy - fvy);
point[1].dy = fixtoi(fy0 + fuy - fvy);
point[2].dy = fixtoi(fy0 - fuy + fvy);
point[3].dy = fixtoi(fy0 + fuy + fvy);
sw <<= aa_BITS;
dsx = sw / dw;
if (dsx < (int)aa_SIZE)
dsx = aa_SIZE;
sw -= dsx;
sh <<= aa_BITS;
dsy = sh / dh;
if (dsy < (int)aa_SIZE)
dsy = aa_SIZE;
sh -= dsy;
num = dsx * dsy;
/* Avoid overflow. */
if (num > aa_MAX_NUM) {
if (dsx > (int)aa_MAX_SIZE)
dsx = aa_MAX_SIZE;
if (dsy > (int)aa_MAX_SIZE)
dsy = aa_MAX_SIZE;
num = dsx * dsy;
}
/* Coordinates of corners in source. */
if (_scalex < 0) {
point[0].sx = sw;
point[1].sx = 0;
point[2].sx = sw;
point[3].sx = 0;
} else {
point[0].sx = 0;
point[1].sx = sw;
point[2].sx = 0;
point[3].sx = sw;
}
if (_scaley < 0) {
point[0].sy = sh;
point[1].sy = sh;
point[2].sy = 0;
point[3].sy = 0;
} else {
point[0].sy = 0;
point[1].sy = 0;
point[2].sy = sh;
point[3].sy = sh;
}
/* Sort left and right edges. */
if ((_angle < itofix(32)) || (_angle >= itofix(128 + 64 + 32))) {
if (point[0].dy < point[1].dy) {
ledge[0] = 0;
ledge[1] = 2;
ledge[2] = 3;
redge[0] = 0;
redge[1] = 1;
redge[2] = 3;
} else if (point[0].dy > point[1].dy) {
ledge[0] = 1;
ledge[1] = 0;
ledge[2] = 2;
redge[0] = 1;
redge[1] = 3;
redge[2] = 2;
} else {
ledge[0] = 0;
ledge[1] = 2;
ledge[2] = 3;
redge[0] = 1;
redge[1] = 3;
redge[2] = 2;
}
} else if (_angle < itofix(64 + 32)) {
if (point[0].dy < point[2].dy) {
ledge[0] = 0;
ledge[1] = 2;
ledge[2] = 3;
redge[0] = 0;
redge[1] = 1;
redge[2] = 3;
} else if (point[0].dy > point[2].dy) {
ledge[0] = 2;
ledge[1] = 3;
ledge[2] = 1;
redge[0] = 2;
redge[1] = 0;
redge[2] = 1;
} else {
ledge[0] = 2;
ledge[1] = 3;
ledge[2] = 1;
redge[0] = 0;
redge[1] = 1;
redge[2] = 3;
}
} else if (_angle < itofix(128 + 32)) {
if (point[2].dy < point[3].dy) {
ledge[0] = 2;
ledge[1] = 3;
ledge[2] = 1;
redge[0] = 2;
redge[1] = 0;
redge[2] = 1;
} else if (point[2].dy > point[3].dy) {
ledge[0] = 3;
ledge[1] = 1;
ledge[2] = 0;
redge[0] = 3;
redge[1] = 2;
redge[2] = 0;
} else {
ledge[0] = 3;
ledge[1] = 1;
ledge[2] = 0;
redge[0] = 2;
redge[1] = 0;
redge[2] = 1;
}
} else {
if (point[1].dy < point[3].dy) {
ledge[0] = 1;
ledge[1] = 0;
ledge[2] = 2;
redge[0] = 1;
redge[1] = 3;
redge[2] = 2;
} else if (point[1].dy > point[3].dy) {
ledge[0] = 3;
ledge[1] = 1;
ledge[2] = 0;
redge[0] = 3;
redge[1] = 2;
redge[2] = 0;
} else {
ledge[0] = 1;
ledge[1] = 0;
ledge[2] = 2;
redge[0] = 3;
redge[1] = 2;
redge[2] = 0;
}
}
/* Remove wrong edges on bottom. */
if (point[ledge[0]].dy == point[ledge[1]].dy) {
ledge[0] = ledge[1];
ledge[1] = ledge[2];
}
if (point[ledge[1]].dy >= point[ledge[2]].dy)
ledge[2] = -1;
ledge[3] = -1;
if (point[redge[0]].dy == point[redge[1]].dy) {
redge[0] = redge[1];
redge[1] = redge[2];
}
if (point[redge[1]].dy >= point[redge[2]].dy)
redge[2] = -1;
redge[3] = -1;
/* Completely clipped by y? */
if ((point[ledge[0]].dy >= yend)
|| ((ledge[2] == -1) && (point[ledge[1]].dy < ybeg))
|| (point[ledge[2]].dy < ybeg))
return;
/* Color manipulation routines. */
if (is_screen_bitmap(_src))
return;
else {
switch (bitmap_color_depth(_src)) {
case 8:
add = ((_masked != 0) ? _aa_masked_add_rgb8 : _aa_add_rgb8);
break;
#ifdef ALLEGRO_COLOR16
case 15:
add = ((_masked != 0) ? _aa_masked_add_rgb15 : _aa_add_rgb15);
break;
case 16:
add = ((_masked != 0) ? _aa_masked_add_rgb16 : _aa_add_rgb16);
break;
#endif
#ifdef ALLEGRO_COLOR24
case 24:
add = ((_masked != 0) ? _aa_masked_add_rgb24 : _aa_add_rgb24);
_aa_prepare_for_24bpp();
break;
#endif
#ifdef ALLEGRO_COLOR32
case 32:
add = ((_masked != 0) ? _aa_masked_add_rgb32 : _aa_add_rgb32);
break;
#endif
default:
return;
}
}
if (is_planar_bitmap(_dst))
return;
else {
switch (bitmap_color_depth(_dst)) {
case 8:
put = ((_masked != 0) ? _aa_masked_put_rgb8 : _aa_put_rgb8);
break;
#ifdef ALLEGRO_COLOR16
case 15:
put = ((_masked != 0) ? _aa_masked_put_rgb15 : _aa_put_rgb15);
break;
case 16:
put = ((_masked != 0) ? _aa_masked_put_rgb16 : _aa_put_rgb16);
break;
#endif
#ifdef ALLEGRO_COLOR24
case 24:
put = ((_masked != 0) ? _aa_masked_put_rgb24 : _aa_put_rgb24);
_aa_prepare_for_24bpp();
break;
#endif
#ifdef ALLEGRO_COLOR32
case 32:
put = ((_masked != 0) ? _aa_masked_put_rgb32 : _aa_put_rgb32);
break;
#endif
default:
return;
}
}
lindex = 1;
rindex = 1;
lpoint1 = &point[ledge[0]];
lpoint2 = &point[ledge[1]];
rpoint1 = &point[redge[0]];
rpoint2 = &point[redge[1]];
dy = lpoint1->dy;
if (ledge[2] == -1) {
if (point[ledge[1]].dy < yend)
yend = point[ledge[1]].dy + 1;
} else if (point[ledge[2]].dy < yend)
yend = point[ledge[2]].dy + 1;
ldx = lpoint1->dx;
aa_PREPARE(ldxinc, ldxdd, ldxi1, ldxi2,
lpoint2->dx - lpoint1->dx, lpoint2->dy - lpoint1->dy);
lsx = lpoint1->sx;
lsy = lpoint1->sy;
if (lpoint1->sx != lpoint2->sx) {
lsc = &lsx;
aa_PREPARE(lscinc, lscdd, lsci1, lsci2,
lpoint2->sx - lpoint1->sx, lpoint2->dy - lpoint1->dy);
} else {
lsc = &lsy;
aa_PREPARE(lscinc, lscdd, lsci1, lsci2,
lpoint2->sy - lpoint1->sy, lpoint2->dy - lpoint1->dy);
}
rdx = rpoint1->dx;
aa_PREPARE(rdxinc, rdxdd, rdxi1, rdxi2,
rpoint2->dx - rpoint1->dx, rpoint2->dy - rpoint1->dy);
rsx = rpoint1->sx;
rsy = rpoint1->sy;
if (rpoint1->sx != rpoint2->sx) {
rsc = &rsx;
aa_PREPARE(rscinc, rscdd, rsci1, rsci2,
rpoint2->sx - rpoint1->sx, rpoint2->dy - rpoint1->dy);
} else {
rsc = &rsy;
aa_PREPARE(rscinc, rscdd, rsci1, rsci2,
rpoint2->sy - rpoint1->sy, rpoint2->dy - rpoint1->dy);
}
/* Skip region clipped on top. */
while (dy < ybeg) {
dy++;
if (dy > lpoint2->dy) {
if (ledge[++lindex] == -1)
return;
lpoint1 = lpoint2;
lpoint2 = &point[ledge[lindex]];
if (lpoint1->sx != lpoint2->sx) {
lsc = &lsx;
aa_PREPARE(lscinc, lscdd, lsci1, lsci2,
lpoint2->sx - lpoint1->sx, lpoint2->dy - lpoint1->dy);
} else {
lsc = &lsy;
aa_PREPARE(lscinc, lscdd, lsci1, lsci2,
lpoint2->sy - lpoint1->sy, lpoint2->dy - lpoint1->dy);
}
aa_PREPARE(ldxinc, ldxdd, ldxi1, ldxi2,
lpoint2->dx - lpoint1->dx, lpoint2->dy - lpoint1->dy);
}
aa_ADVANCE(*lsc, lscinc, lscdd, lsci1, lsci2);
aa_ADVANCE(ldx, ldxinc, ldxdd, ldxi1, ldxi2);
if (dy > rpoint2->dy) {
if (redge[++rindex] == -1)
return;
rpoint1 = rpoint2;
rpoint2 = &point[redge[rindex]];
if (rpoint1->sx != rpoint2->sx) {
rsc = &rsx;
aa_PREPARE(rscinc, rscdd, rsci1, rsci2,
rpoint2->sx - rpoint1->sx, rpoint2->dy - rpoint1->dy);
} else {
rsc = &rsy;
aa_PREPARE(rscinc, rscdd, rsci1, rsci2,
rpoint2->sy - rpoint1->sy, rpoint2->dy - rpoint1->dy);
}
aa_PREPARE(rdxinc, rdxdd, rdxi1, rdxi2,
rpoint2->dx - rpoint1->dx, rpoint2->dy - rpoint1->dy);
}
aa_ADVANCE(*rsc, rscinc, rscdd, rsci1, rsci2);
aa_ADVANCE(rdx, rdxinc, rdxdd, rdxi1, rdxi2);
}
bmp_select(_dst);
/* Stretch lines. */
while (dy < yend) {
byte *daddr = bmp_write_line(_dst, dy);
if ((ldx < xend) && (rdx >= xbeg)) {
int curxend;
aa_PREPARE(sxinc, sxdd, sxi1, sxi2,
rsx - lsx, rdx - ldx);
aa_PREPARE(syinc, sydd, syi1, syi2,
rsy - lsy, rdx - ldx);
for (sx = lsx, sy = lsy, dx = ldx; dx < xbeg; dx++) {
aa_ADVANCE(sx, sxinc, sxdd, sxi1, sxi2);
aa_ADVANCE(sy, syinc, sydd, syi1, syi2);
}
curxend = (rdx < xend) ? (rdx + 1) : xend;
for (; dx < curxend; dx++) {
(*add)(_src, sx, sx + dsx, sy, sy + dsy, num);
(*put)(daddr, dx);
aa_ADVANCE(sx, sxinc, sxdd, sxi1, sxi2);
aa_ADVANCE(sy, syinc, sydd, syi1, syi2);
}
}
dy++;
if (dy > lpoint2->dy) {
if (ledge[++lindex] == -1)
return;
lpoint1 = lpoint2;
lpoint2 = &point[ledge[lindex]];
if (lpoint1->sx != lpoint2->sx) {
lsc = &lsx;
aa_PREPARE(lscinc, lscdd, lsci1, lsci2,
lpoint2->sx - lpoint1->sx, lpoint2->dy - lpoint1->dy);
} else {
lsc = &lsy;
aa_PREPARE(lscinc, lscdd, lsci1, lsci2,
lpoint2->sy - lpoint1->sy, lpoint2->dy - lpoint1->dy);
}
aa_PREPARE(ldxinc, ldxdd, ldxi1, ldxi2,
lpoint2->dx - lpoint1->dx, lpoint2->dy - lpoint1->dy);
}
aa_ADVANCE(*lsc, lscinc, lscdd, lsci1, lsci2);
aa_ADVANCE(ldx, ldxinc, ldxdd, ldxi1, ldxi2);
if (dy > rpoint2->dy) {
if (redge[++rindex] == -1)
return;
rpoint1 = rpoint2;
rpoint2 = &point[redge[rindex]];
if (rpoint1->sx != rpoint2->sx) {
rsc = &rsx;
aa_PREPARE(rscinc, rscdd, rsci1, rsci2,
rpoint2->sx - rpoint1->sx, rpoint2->dy - rpoint1->dy);
} else {
rsc = &rsy;
aa_PREPARE(rscinc, rscdd, rsci1, rsci2,
rpoint2->sy - rpoint1->sy, rpoint2->dy - rpoint1->dy);
}
aa_PREPARE(rdxinc, rdxdd, rdxi1, rdxi2,
rpoint2->dx - rpoint1->dx, rpoint2->dy - rpoint1->dy);
}
aa_ADVANCE(*rsc, rscinc, rscdd, rsci1, rsci2);
aa_ADVANCE(rdx, rdxinc, rdxdd, rdxi1, rdxi2);
}
}
/*
* Anti-aliased bitmap rotation with scaling.
*/
void aa_rotate_scaled_bitmap(BITMAP *_src, BITMAP *_dst, int _x, int _y, fixed _angle,
fixed _scalex, fixed _scaley) {
_aa_rotate_bitmap(_src, _dst, _x, _y, _angle, _scalex, _scaley, 0);
}
/*
* Anti-aliased bitmap rotation with scaling (masked).
*/
void aa_rotate_scaled_sprite(BITMAP *_dst, BITMAP *_src, int _x, int _y, fixed _angle,
fixed _scalex, fixed _scaley) {
_aa_rotate_bitmap(_src, _dst, _x, _y, _angle, _scalex, _scaley, 1);
}
/*
* Anti-aliased bitmap rotation.
*/
void aa_rotate_bitmap(BITMAP *_src, BITMAP *_dst, int _x, int _y, fixed _angle) {
_aa_rotate_bitmap(_src, _dst, _x, _y, _angle, itofix(1), itofix(1), 0);
}
/*
* Anti-aliased bitmap rotation (masked).
*/
void aa_rotate_sprite(BITMAP *_dst, BITMAP *_src, int _x, int _y, fixed _angle) {
_aa_rotate_bitmap(_src, _dst, _x, _y, _angle, itofix(1), itofix(1), 1);
}
} // namespace AGS3

View File

@@ -0,0 +1,218 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
/*
* aastr.c --- anti-aliased stretching for Allegro
*
* This file is gift-ware. This file is given to you freely
* as a gift. You may use, modify, redistribute, and generally hack
* it about in any way you like, and you do not have to give anyone
* anything in return.
*
* I do not accept any responsibility for any effects, adverse or
* otherwise, that this code may have on just about anything that
* you can think of. Use it at your own risk.
*
* Copyright (C) 1998, 1999 Michael Bukin
*/
#include "ags/lib/aastr-0.1.1/aastr.h"
#include "ags/lib/aastr-0.1.1/aautil.h"
namespace AGS3 {
/*
* Engine of anti-aliased stretching.
*/
static void _aa_stretch_blit(BITMAP *_src, BITMAP *_dst,
int _sx, int _sy, int _sw, int _sh,
int _dx, int _dy, int _dw, int _dh, int _masked) {
int sx, sy, dx, dy, ydx, ysx;
int xinc, yinc, dsx, dsy;
int xi1, xi2, xdd, yxdd;
int yi1, yi2, ydd;
int dxbeg, dxend, dybeg, dyend;
uint32_t num;
void (*add)(BITMAP * _src, int _sx1, int _sx2, int _sy1, int _sy2, uint32_t _num);
void (*put)(byte * _addr, int _x);
if ((_dw <= 0) || (_dh <= 0) || (_sw <= 0) || (_sh <= 0))
return;
if (_dst->clip) {
dybeg = ((_dy > _dst->ct) ? _dy : _dst->ct);
dyend = (((_dy + _dh) < _dst->cb) ? (_dy + _dh) : _dst->cb);
if (dybeg >= dyend)
return;
dxbeg = ((_dx > _dst->cl) ? _dx : _dst->cl);
dxend = (((_dx + _dw) < _dst->cr) ? (_dx + _dw) : _dst->cr);
if (dxbeg >= dxend)
return;
} else {
dxbeg = _dx;
dybeg = _dy;
dxend = _dx + _dw;
dyend = _dy + _dh;
}
_sx <<= aa_BITS;
_sw <<= aa_BITS;
dsx = _sw / _dw;
if (dsx < (int)aa_SIZE) {
/* Exploding by x. */
_dw--;
_sw -= aa_SIZE;
dsx = aa_SIZE;
}
_sy <<= aa_BITS;
_sh <<= aa_BITS;
dsy = _sh / _dh;
if (dsy < (int)aa_SIZE) {
/* Exploding by y. */
_dh--;
_sh -= aa_SIZE;
dsy = aa_SIZE;
}
num = dsx * dsy;
if (num > aa_MAX_NUM) {
if (dsx > (int)aa_MAX_SIZE)
dsx = aa_MAX_SIZE;
if (dsy > (int)aa_MAX_SIZE)
dsy = aa_MAX_SIZE;
num = dsx * dsy;
}
/* Walk in x direction up to dxbeg and save Bresenham state there.
* Later, it will be used to restart at any line. */
aa_PREPARE(xinc, yxdd, xi1, xi2, _sw, _dw);
for (ydx = _dx, ysx = _sx; ydx < dxbeg; ydx++) {
aa_ADVANCE(ysx, xinc, yxdd, xi1, xi2);
}
/* Color manipulation routines. */
if (is_screen_bitmap(_src))
return;
else {
switch (bitmap_color_depth(_src)) {
case 8:
add = ((_masked != 0) ? _aa_masked_add_rgb8 : _aa_add_rgb8);
break;
#ifdef ALLEGRO_COLOR16
case 15:
add = ((_masked != 0) ? _aa_masked_add_rgb15 : _aa_add_rgb15);
break;
case 16:
add = ((_masked != 0) ? _aa_masked_add_rgb16 : _aa_add_rgb16);
break;
#endif
#ifdef ALLEGRO_COLOR24
case 24:
add = ((_masked != 0) ? _aa_masked_add_rgb24 : _aa_add_rgb24);
_aa_prepare_for_24bpp();
break;
#endif
#ifdef ALLEGRO_COLOR32
case 32:
add = ((_masked != 0) ? _aa_masked_add_rgb32 : _aa_add_rgb32);
break;
#endif
default:
return;
}
}
if (is_planar_bitmap(_dst))
return;
else {
switch (bitmap_color_depth(_dst)) {
case 8:
put = ((_masked != 0) ? _aa_masked_put_rgb8 : _aa_put_rgb8);
break;
#ifdef ALLEGRO_COLOR16
case 15:
put = ((_masked != 0) ? _aa_masked_put_rgb15 : _aa_put_rgb15);
break;
case 16:
put = ((_masked != 0) ? _aa_masked_put_rgb16 : _aa_put_rgb16);
break;
#endif
#ifdef ALLEGRO_COLOR24
case 24:
put = ((_masked != 0) ? _aa_masked_put_rgb24 : _aa_put_rgb24);
_aa_prepare_for_24bpp();
break;
#endif
#ifdef ALLEGRO_COLOR32
case 32:
put = ((_masked != 0) ? _aa_masked_put_rgb32 : _aa_put_rgb32);
break;
#endif
default:
return;
}
}
/* Walk in y until we reach first non-clipped line. */
aa_PREPARE(yinc, ydd, yi1, yi2, _sh, _dh);
for (dy = _dy, sy = _sy; dy < dybeg; dy++) {
aa_ADVANCE(sy, yinc, ydd, yi1, yi2);
}
bmp_select(_dst);
/* Stretch all non-clipped lines. */
for (; dy < dyend; dy++) {
byte *daddr = bmp_write_line(_dst, dy);
for (dx = ydx, sx = ysx, xdd = yxdd; dx < dxend; dx++) {
(*add)(_src, sx, sx + dsx, sy, sy + dsy, num);
(*put)(daddr, dx);
aa_ADVANCE(sx, xinc, xdd, xi1, xi2);
}
aa_ADVANCE(sy, yinc, ydd, yi1, yi2);
}
}
/*
* Anti-aliased bitmap stretching with blit.
*/
void aa_stretch_blit(BITMAP *_src, BITMAP *_dst,
int _sx, int _sy, int _sw, int _sh,
int _dx, int _dy, int _dw, int _dh) {
_aa_stretch_blit(_src, _dst, _sx, _sy, _sw, _sh, _dx, _dy, _dw, _dh, 0);
}
/*
* Anti-aliased bitmap stretching with blit (masked).
*/
void aa_stretch_sprite(BITMAP *_dst, BITMAP *_src, int _dx, int _dy, int _dw, int _dh) {
_aa_stretch_blit(_src, _dst, 0, 0, _src->w, _src->h, _dx, _dy, _dw, _dh, 1);
}
} // namespace AGS3

View File

@@ -0,0 +1,73 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
/*
* aastr.h --- anti-aliased stretching and rotation for Allegro
*
* This file is gift-ware. This file is given to you freely
* as a gift. You may use, modify, redistribute, and generally hack
* it about in any way you like, and you do not have to give anyone
* anything in return.
*
* I do not accept any responsibility for any effects, adverse or
* otherwise, that this code may have on just about anything that
* you can think of. Use it at your own risk.
*
* Copyright (C) 1998, 1999 Michael Bukin
*/
#ifndef AGS_LIB_AASTR_AASTR_H
#define AGS_LIB_AASTR_AASTR_H
#include "ags/lib/allegro.h"
namespace AGS3 {
#ifdef __cplusplus
extern "C" {
#endif
/* Stretching. */
void aa_stretch_blit(BITMAP *src, BITMAP *dst,
int sx, int sy, int sw, int sh,
int dx, int dy, int dw, int dh);
void aa_stretch_sprite(BITMAP *dst, BITMAP *src,
int dx, int dy, int dw, int dh);
/* Rotation. */
void aa_rotate_scaled_bitmap(BITMAP *src, BITMAP *dst,
int x, int y, fixed angle,
fixed scalex, fixed scaley);
void aa_rotate_scaled_sprite(BITMAP *dst, BITMAP *src,
int x, int y, fixed angle,
fixed scalex, fixed scaley);
void aa_rotate_bitmap(BITMAP *src, BITMAP *dst,
int x, int y, fixed angle);
void aa_rotate_sprite(BITMAP *dst, BITMAP *src,
int x, int y, fixed angle);
#ifdef __cplusplus
}
#endif
} // namespace AGS3
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,165 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
/*
* aautil.h --- helpers for anti-aliasing routines for Allegro
*
* This file is gift-ware. This file is given to you freely
* as a gift. You may use, modify, redistribute, and generally hack
* it about in any way you like, and you do not have to give anyone
* anything in return.
*
* I do not accept any responsibility for any effects, adverse or
* otherwise, that this code may have on just about anything that
* you can think of. Use it at your own risk.
*
* Copyright (C) 1998, 1999 Michael Bukin
*/
#ifndef AGS_LIB_AASTR_AAUTIL_H
#define AGS_LIB_AASTR_AAUTIL_H
#include "ags/lib/allegro.h"
namespace AGS3 {
/*
* Change aa_BITS, and never aa_SIZE or aa_MASK.
* 8 or 4 are probably the fastest for i386+.
* Recompile the package after changing aa_BITS.
*/
#ifdef aa_BITS
#undef aa_BITS
#endif
#define aa_BITS 8
#if ((aa_BITS < 0) || (aa_BITS > 12))
#error aa_BITS must be (0 <= aa_BITS <= 12)
#endif
#define aa_SIZE (1UL << aa_BITS)
#define aa_MASK (aa_SIZE - 1)
#define aa_MAX_SIZE (1UL << 12)
#define aa_MAX_NUM (aa_MAX_SIZE * aa_MAX_SIZE)
/* Prepare Bresenham line parameters. */
#define aa_PREPARE(inc,dd,i1,i2,_yw,_xw) \
{ \
int xw = (_xw); \
int yw = (_yw); \
\
if ((xw == 0) || ((yw < xw) && (yw > -xw))) { \
(inc) = 0; \
} \
else { \
(inc) = yw / xw; \
yw %= xw; \
} \
if (yw < 0) { \
(inc) -= 1; \
yw += xw; \
} \
(i2) = ((dd) = ((i1) = 2 * yw) - xw) - xw; \
}
/* Advance to the next point. */
#define aa_ADVANCE(y,inc,dd,i1,i2) \
{ \
if ((dd) >= 0) \
(y) += (inc) + 1, (dd) += (i2); \
else \
(y) += (inc), (dd) += (i1); \
}
#ifdef __cplusplus
extern "C" {
#endif
/* Prepare offsets for direct access to 24bpp bitmap. */
void _aa_prepare_for_24bpp(void);
/* Add r,g,b values from source bitmap. */
void _aa_add_rgb8(BITMAP *_src, int _sx1, int _sx2, int _sy1, int _sy2, uint32_t _num);
#ifdef ALLEGRO_COLOR16
void _aa_add_rgb15(BITMAP *_src, int _sx1, int _sx2, int _sy1, int _sy2, uint32_t _num);
void _aa_add_rgb16(BITMAP *_src, int _sx1, int _sx2, int _sy1, int _sy2, uint32_t _num);
#endif
#ifdef ALLEGRO_COLOR24
void _aa_add_rgb24(BITMAP *_src, int _sx1, int _sx2, int _sy1, int _sy2, uint32_t _num);
#endif
#ifdef ALLEGRO_COLOR32
void _aa_add_rgb32(BITMAP *_src, int _sx1, int _sx2, int _sy1, int _sy2, uint32_t _num);
#endif
/* Put pixel to destination bitmap. */
void _aa_put_rgb8(byte *addr, int _x);
#ifdef ALLEGRO_COLOR16
void _aa_put_rgb15(byte *addr, int _x);
void _aa_put_rgb16(byte *addr, int _x);
#endif
#ifdef ALLEGRO_COLOR24
void _aa_put_rgb24(byte *addr, int _x);
#endif
#ifdef ALLEGRO_COLOR32
void _aa_put_rgb32(byte *addr, int _x);
#endif
/* Add r,g,b and transparency values from source bitmap. */
void _aa_masked_add_rgb8(BITMAP *_src, int _sx1, int _sx2, int _sy1, int _sy2,
uint32_t _num);
#ifdef ALLEGRO_COLOR16
void _aa_masked_add_rgb15(BITMAP *_src, int _sx1, int _sx2, int _sy1, int _sy2,
uint32_t _num);
void _aa_masked_add_rgb16(BITMAP *_src, int _sx1, int _sx2, int _sy1, int _sy2,
uint32_t _num);
#endif
#ifdef ALLEGRO_COLOR24
void _aa_masked_add_rgb24(BITMAP *_src, int _sx1, int _sx2, int _sy1, int _sy2,
uint32_t _num);
#endif
#ifdef ALLEGRO_COLOR32
void _aa_masked_add_rgb32(BITMAP *_src, int _sx1, int _sx2, int _sy1, int _sy2,
uint32_t _num);
#endif
/* Put masked pixel to destination bitmap. */
void _aa_masked_put_rgb8(byte *addr, int _x);
#ifdef ALLEGRO_COLOR16
void _aa_masked_put_rgb15(byte *addr, int _x);
void _aa_masked_put_rgb16(byte *addr, int _x);
#endif
#ifdef ALLEGRO_COLOR24
void _aa_masked_put_rgb24(byte *addr, int _x);
#endif
#ifdef ALLEGRO_COLOR32
void _aa_masked_put_rgb32(byte *addr, int _x);
#endif
#ifdef __cplusplus
}
#endif
} // namespace AGS3
#endif