test96
auto test96 =
q{--- test96
// splitting and spilling
void tran_thong(i32 xstart, i32 ystart, i32 xend, i32 yend, void function(void*, i32, i32) callback, void* userData)
{
i32 x = xstart;
i32 y = ystart;
i32 deltax;
i32 signdx;
if (xend >= xstart) {
deltax = xend - xstart;
signdx = 1;
} else {
deltax = xstart - xend;
signdx = -1;
}
i32 deltay;
i32 signdy;
if (yend >= ystart) {
deltay = yend - ystart;
signdy = 1;
} else {
deltay = ystart - yend;
signdy = -1;
}
i32 test;
if (signdy == -1)
test = -1;
else
test = 0;
if (deltax >= deltay) {
test = (deltax + test) >> 1;
for (i32 i = 1; i < deltax; ++i) {
test -= deltay;
x += signdx;
if (test < 0) {
y += signdy;
test += deltax;
}
callback(userData, x, y);
}
} else {
test = (deltay + test) >> 1;
for (i32 i = 1; i < deltay; ++i) {
test -= deltax;
y += signdy;
if (test < 0) {
x += signdx;
test += deltay;
}
callback(userData, x, y);
}
}
}
};
tests passing
functionsvariables