rendered paste body#include <tigcclib.h>
#include "extgraph.h"
int row,col,height,width,depth,mode;
int hori,vert;
HANDLE xh;
HANDLE yh;
int* x;
int* y;
void _main(void)
{
char sine[] = {0,2,4,7,9,11,13,16,18,20,22,24,27,29,31,33,35,37,40,42,44,46,48,50,52,54,56,58,60,62,64,66,68,70,72,73,75,77,79,81,82,84,86,87,89,91,92,94,95,97,98,99,101,102,104,105,106,107,109,110,111,112,113,114,115,116,117,118,119,119,120,121,122,122,123,124,124,125,125,126,126,126,127,127,127,128,128,128,128,128,128,128,128,128,128,128,127,127,127,126,126,126,125,125,124,124,123,122,122,121,120,119,119,118,117,116,115,114,113,112,111,110,109,107,106,105,104,102,101,99,98,97,95,94,92,91,89,87,86,84,82,81,79,77,75,73,72,70,68,66,64,62,60,58,56,54,52,50,48,46,44,42,40,37,35,33,31,29,27,24,22,20,18,16,13,11,9,7,4,2,0,-2,-4,-7,-9,-11,-13,-16,-18,-20,-22,-24,-27,-29,-31,-33,-35,-37,-40,-42,-44,-46,-48,-50,-52,-54,-56,-58,-60,-62,-64,-66,-68,-70,-72,-73,-75,-77,-79,-81,-82,-84,-86,-87,-89,-91,-92,-94,-95,-97,-98,-99,-101,-102,-104,-105,-106,-107,-109,-110,-111,-112,-113,-114,-115,-116,-117,-118,-119,-119,-120,-121,-122,-122,-123,-124,-124,-125,-125,-126,-126,-126,-127,-127,-127,-128,-128,-128,-128,-128,-128,-128,-128,-128,-128,-128,-127,-127,-127,-126,-126,-126,-125,-125,-124,-124,-123,-122,-122,-121,-120,-119,-119,-118,-117,-116,-115,-114,-113,-112,-111,-110,-109,-107,-106,-105,-104,-102,-101,-99,-98,-97,-95,-94,-92,-91,-89,-87,-86,-84,-82,-81,-79,-77,-75,-73,-72,-70,-68,-66,-64,-62,-60,-58,-56,-54,-52,-50,-48,-46,-44,-42,-40,-37,-35,-33,-31,-29,-27,-24,-22,-20,-18,-16,-13,-11,-9,-7,-4,-2,-0,2,4,7,9,11,13,16,18,20,22,24,27,29,31,33,35,37,40,42,44,46,48,50,52,54,56,58,60,62,64,66,68,70,72,73,75,77,79,81,82,84,86,87,89,91,92,94,95,97,98,99,101,102,104,105,106,107,109,110,111,112,113,114,115,116,117,118,119,119,120,121,122,122,123,124,124,125,125,126,126,126,127,127,127,128,128,128,128,128,128};
unsigned char arctangent[] = {0,45,63,72,76,79,81,82,83,84,84,85,85,86,86,86,86,87,87,87,87,87,87,88,88,88,88,88,88,88,88,88,88,88,88,88,88,88,88,89,89,89,89,89,89,89,89,89,89,89,89,89,89,89,89,89,89,89,89,89,89,89,89,89,89,89,89,89,89,89,89,89,89,89,89,89,89,89,89,89,89,89,89,89,89,89,89,89,89,89,89,89,89,89,89,89,89,89,89,89,89,89,89,89,89,89,89,89,89,89,89,89,89,89,89,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90};
ESI argptr = top_estack;
if(RemainingArgCnt(argptr)<8)
ER_throw(TOO_FEW_ARGS_ERROR);
row = GetIntArg (argptr);
col = GetIntArg (argptr);
depth = GetIntArg (argptr);
hori = GetIntArg (argptr);
vert = GetIntArg (argptr);
mode = GetIntArg (argptr);
xh=HeapAlloc(6);
yh=HeapAlloc(6);
if(xh==H_NULL || yh==H_NULL){
HeapFree(xh);
HeapFree(yh);
return;
}
HeapLock(xh);
HeapLock(yh);
x=HeapDeref(xh);
y=HeapDeref(yh);
unsigned short counter = 2;
while (GetArgType (argptr) != END_TAG){
*(x+(counter-2))=GetIntArg(argptr);
HeapUnlock(xh);
HeapRealloc(xh,4*counter);
HeapLock(xh);
x=HeapDeref(xh);
*(y+(counter-2))=GetIntArg(argptr);
HeapUnlock(yh);
HeapRealloc(yh,4*counter);
HeapLock(yh);
y=HeapDeref(yh);
counter++;
}
// modes:
// normal - 1
// xor - 2
// or - 5
// reverse - 0
// replace - 4
clrscr(); //for debugging purposes
unsigned short line;
float radius,radius2;
unsigned short angle,angle2;
for(line=0;line<counter-3;line++){
radius = hypot((float)*x,(float)*y);
radius2 = hypot((float)*(x+1),(float)*(y+1));
//angle = (unsigned short)arctangent[(int)(*y)/(*x)];
//angle2 = (unsigned short)arctangent[(int)(*(y+1))/(*(x+1))];
angle = (unsigned short)(atan((*y)/(*x))*57.2957795131);
angle2 = (unsigned short)(atan((*(y+1))/(*(x+1)))*57.2957795131);
printf("\n%hd,%hd,%hd,%hd,%d,%d,%d,%d,%f,%f",(((short)(radius*sine[90-hori-angle])) >> 7)+col,(((short)(radius*sine[hori+angle])) >> 7)+col,(((short)(radius2*sine[90-hori-angle2])) >> 7)+row,(((short)(radius2*sine[hori+angle2])) >> 7)+row,*x,*y,angle,angle2,radius,radius2);
ngetchx();
FastDrawLine_R(LCD_MEM,(((short)(radius*sine[90-hori-angle])) >> 7)+col,(((short)(radius*sine[hori+angle])) >> 7)+col,(((short)(radius2*sine[90-hori-angle2])) >> 7)+row,(((short)(radius2*sine[hori+angle2])) >> 7)+row,mode);
//FastDrawLine_R(LCD_MEM,col+*x,row+*y,col+*(x+1),row+*(y+1),mode);
x++;
y++;
}
ngetchx(); // for debugging purposes
HeapFree(xh);
HeapFree(yh);
}