Cleaned up code a bit
svn-id: r18031
This commit is contained in:
parent
fc5d0f2a9c
commit
74bc089702
1 changed files with 54 additions and 68 deletions
|
@ -613,118 +613,104 @@ void ScummEngine_v80he::o80_drawWizPolygon() {
|
||||||
displayWizImage(&wi);
|
displayWizImage(&wi);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScummEngine_v80he::drawLine(int x1, int y1, int x, int y, int unk2, int type, int id) {
|
/**
|
||||||
debug(0,"drawLine: x1 %d y1 %d x %d y %d, unk2 %d type %d id %d", x1, y1, x, y, unk2, type, id);
|
* Draw a 'line' between two points.
|
||||||
|
*
|
||||||
|
* @param x1 the starting x coordinate
|
||||||
|
* @param y1 the starting y coordinate
|
||||||
|
* @param x the ending x coordinate
|
||||||
|
* @param y the ending y coordinate
|
||||||
|
* @param step the step size used to render the line, only ever 'step'th point is drawn
|
||||||
|
* @param type the line type -- points are rendered by drawing actors (type == 2),
|
||||||
|
* wiz images (type == 3), or pixels (any other type)
|
||||||
|
* @param id the (optional) id of an actor or wizimage
|
||||||
|
*/
|
||||||
|
void ScummEngine_v80he::drawLine(int x1, int y1, int x, int y, int step, int type, int id) {
|
||||||
|
debug(0,"drawLine: x1 %d y1 %d x %d y %d, step %d type %d id %d", x1, y1, x, y, step, type, id);
|
||||||
|
|
||||||
int eax, ebx, ecx, edp, esi, edx;
|
if (step < 0) {
|
||||||
int var_C;
|
step = -step;
|
||||||
|
|
||||||
ebx = 0;
|
|
||||||
var_C = 0;
|
|
||||||
|
|
||||||
if (unk2 < 0) {
|
|
||||||
unk2 = -unk2;
|
|
||||||
}
|
}
|
||||||
if (unk2 == 0) {
|
if (step == 0) {
|
||||||
unk2 = 1;
|
step = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
eax = x;
|
|
||||||
ecx = x1;
|
|
||||||
int edi = y1;
|
|
||||||
|
|
||||||
const int dx = x - x1;
|
const int dx = x - x1;
|
||||||
const int dy = y - y1;
|
const int dy = y - y1;
|
||||||
|
|
||||||
edp = ABS(dx);
|
const int absDX = ABS(dx);
|
||||||
eax = ABS(dy);
|
const int absDY = ABS(dy);
|
||||||
|
|
||||||
if (eax > edp) {
|
const int maxDist = MAX(absDX, absDY);
|
||||||
esi = eax;
|
|
||||||
} else {
|
|
||||||
esi = edp;
|
|
||||||
}
|
|
||||||
|
|
||||||
y1 = eax;
|
y = y1;
|
||||||
x = x1;
|
x = x1;
|
||||||
x1 = 0;
|
|
||||||
|
const int tmpA = absDY;
|
||||||
|
int tmbB = 0;
|
||||||
|
|
||||||
if (type == 2) {
|
if (type == 2) {
|
||||||
Actor *a = derefActor(id, "drawLine");
|
Actor *a = derefActor(id, "drawLine");
|
||||||
a->drawActorToBackBuf(ecx, edi);
|
a->drawActorToBackBuf(x, y);
|
||||||
} else if (type == 3) {
|
} else if (type == 3) {
|
||||||
WizImage wi;
|
WizImage wi;
|
||||||
wi.flags = 0;
|
wi.flags = 0;
|
||||||
wi.y1 = edi;
|
wi.y1 = y;
|
||||||
wi.x1 = ecx;
|
wi.x1 = x;
|
||||||
wi.resNum = id;
|
wi.resNum = id;
|
||||||
wi.state = 0;
|
wi.state = 0;
|
||||||
displayWizImage(&wi);
|
displayWizImage(&wi);
|
||||||
} else {
|
} else {
|
||||||
drawPixel(ecx, edi, id);
|
drawPixel(x, y, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i <= esi; i++) {
|
int var_C = 0;
|
||||||
ecx = x1;
|
int ebx = 0;
|
||||||
eax = y1;
|
for (int i = 0; i <= maxDist; i++) {
|
||||||
ebx += edp;
|
ebx += absDX;
|
||||||
ecx += eax;
|
tmbB += tmpA;
|
||||||
|
|
||||||
eax ^= eax;
|
int eax = 0;
|
||||||
x1 = ecx;
|
|
||||||
|
|
||||||
if (ebx > esi) {
|
|
||||||
edx = dx;
|
|
||||||
edx -= esi;
|
|
||||||
|
|
||||||
|
if (ebx > maxDist) {
|
||||||
eax = 1;
|
eax = 1;
|
||||||
int tmp = edx;
|
if (dx >= maxDist) {
|
||||||
edx = x;
|
x++;
|
||||||
if (tmp >= 0) {
|
|
||||||
edx++;
|
|
||||||
} else {
|
} else {
|
||||||
edx--;
|
x--;
|
||||||
}
|
}
|
||||||
|
|
||||||
x = edx;
|
|
||||||
}
|
}
|
||||||
if (ecx > esi) {
|
if (tmbB > maxDist) {
|
||||||
eax = dy;
|
eax = dy;
|
||||||
ecx -= esi;
|
tmbB -= maxDist;
|
||||||
|
|
||||||
x1 = ecx;
|
if (dy >= 0) {
|
||||||
if (eax >= 0) {
|
y++;
|
||||||
edi++;
|
|
||||||
} else {
|
} else {
|
||||||
edi--;
|
y--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (eax == 0)
|
if (eax == 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
ecx = var_C;
|
var_C++;
|
||||||
eax = ecx;
|
if (((var_C - 1) % step) != 0 && maxDist != i)
|
||||||
edx = eax % unk2;
|
|
||||||
ecx++;
|
|
||||||
var_C = ecx;
|
|
||||||
|
|
||||||
if (edx != 0 && esi != i)
|
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (type == 2) {
|
if (type == 2) {
|
||||||
Actor *a = derefActor(id, "drawLine");
|
Actor *a = derefActor(id, "drawLine");
|
||||||
a->drawActorToBackBuf(x, edi);
|
a->drawActorToBackBuf(x, y);
|
||||||
} else if (type == 3) {
|
} else if (type == 3) {
|
||||||
WizImage wi;
|
WizImage wi;
|
||||||
wi.flags = 0;
|
wi.flags = 0;
|
||||||
wi.y1 = edi;
|
wi.y1 = y;
|
||||||
wi.x1 = x;
|
wi.x1 = x;
|
||||||
wi.resNum = id;
|
wi.resNum = id;
|
||||||
wi.state = 0;
|
wi.state = 0;
|
||||||
displayWizImage(&wi);
|
displayWizImage(&wi);
|
||||||
} else {
|
} else {
|
||||||
drawPixel(x, edi, id);
|
drawPixel(x, y, id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -763,9 +749,9 @@ void ScummEngine_v80he::drawPixel(int x, int y, int flags) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScummEngine_v80he::o80_drawLine() {
|
void ScummEngine_v80he::o80_drawLine() {
|
||||||
int id, unk2, x, y, x1, y1;
|
int id, step, x, y, x1, y1;
|
||||||
|
|
||||||
unk2 = pop();
|
step = pop();
|
||||||
id = pop();
|
id = pop();
|
||||||
y = pop();
|
y = pop();
|
||||||
x = pop();
|
x = pop();
|
||||||
|
@ -776,13 +762,13 @@ void ScummEngine_v80he::o80_drawLine() {
|
||||||
|
|
||||||
switch (subOp) {
|
switch (subOp) {
|
||||||
case 55:
|
case 55:
|
||||||
drawLine(x1, y1, x, y, unk2, 2, id);
|
drawLine(x1, y1, x, y, step, 2, id);
|
||||||
break;
|
break;
|
||||||
case 63:
|
case 63:
|
||||||
drawLine(x1, y1, x, y, unk2, 3, id);
|
drawLine(x1, y1, x, y, step, 3, id);
|
||||||
break;
|
break;
|
||||||
case 66:
|
case 66:
|
||||||
drawLine(x1, y1, x, y, unk2, 1, id);
|
drawLine(x1, y1, x, y, step, 1, id);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
error("o80_drawLine: default case %d", subOp);
|
error("o80_drawLine: default case %d", subOp);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue