const signed long sin_cos_table[256+64+256] ={
0x00000000,0x00000006,0x0000000c,0x00000012,0x00000019,0x0000001f,0x00000025,0x0000002b,
0x00000031,0x00000038,0x0000003e,0x00000044,0x0000004a,0x00000050,0x00000056,0x0000005c,
0x00000061,0x00000067,0x0000006d,0x00000073,0x00000078,0x0000007e,0x00000083,0x00000088,
0x0000008e,0x00000093,0x00000098,0x0000009d,0x000000a2,0x000000a7,0x000000ab,0x000000b0,
0x000000b5,0x000000b9,0x000000bd,0x000000c1,0x000000c5,0x000000c9,0x000000cd,0x000000d1,
0x000000d4,0x000000d8,0x000000db,0x000000de,0x000000e1,0x000000e4,0x000000e7,0x000000ea,
0x000000ec,0x000000ee,0x000000f1,0x000000f3,0x000000f4,0x000000f6,0x000000f8,0x000000f9,
0x000000fb,0x000000fc,0x000000fd,0x000000fe,0x000000fe,0x000000ff,0x000000ff,0x000000ff,
0x00000100,0x000000ff,0x000000ff,0x000000ff,0x000000fe,0x000000fe,0x000000fd,0x000000fc,
0x000000fb,0x000000f9,0x000000f8,0x000000f6,0x000000f4,0x000000f3,0x000000f1,0x000000ee,
0x000000ec,0x000000ea,0x000000e7,0x000000e4,0x000000e1,0x000000de,0x000000db,0x000000d8,
0x000000d4,0x000000d1,0x000000cd,0x000000c9,0x000000c5,0x000000c1,0x000000bd,0x000000b9,
0x000000b5,0x000000b0,0x000000ab,0x000000a7,0x000000a2,0x0000009d,0x00000098,0x00000093,
0x0000008e,0x00000088,0x00000083,0x0000007e,0x00000078,0x00000073,0x0000006d,0x00000067,
0x00000061,0x0000005c,0x00000056,0x00000050,0x0000004a,0x00000044,0x0000003e,0x00000038,
0x00000031,0x0000002b,0x00000025,0x0000001f,0x00000019,0x00000012,0x0000000c,0x00000006,
0x00000000,0xfffffffa,0xfffffff4,0xffffffee,0xffffffe7,0xffffffe1,0xffffffdb,0xffffffd5,
0xffffffcf,0xffffffc8,0xffffffc2,0xffffffbc,0xffffffb6,0xffffffb0,0xffffffaa,0xffffffa4,
0xffffff9f,0xffffff99,0xffffff93,0xffffff8d,0xffffff88,0xffffff82,0xffffff7d,0xffffff78,
0xffffff72,0xffffff6d,0xffffff68,0xffffff63,0xffffff5e,0xffffff59,0xffffff55,0xffffff50,
0xffffff4b,0xffffff47,0xffffff43,0xffffff3f,0xffffff3b,0xffffff37,0xffffff33,0xffffff2f,
0xffffff2c,0xffffff28,0xffffff25,0xffffff22,0xffffff1f,0xffffff1c,0xffffff19,0xffffff16,
0xffffff14,0xffffff12,0xffffff0f,0xffffff0d,0xffffff0c,0xffffff0a,0xffffff08,0xffffff07,
0xffffff05,0xffffff04,0xffffff03,0xffffff02,0xffffff02,0xffffff01,0xffffff01,0xffffff01,
0xffffff00,0xffffff01,0xffffff01,0xffffff01,0xffffff02,0xffffff02,0xffffff03,0xffffff04,
0xffffff05,0xffffff07,0xffffff08,0xffffff0a,0xffffff0c,0xffffff0d,0xffffff0f,0xffffff12,
0xffffff14,0xffffff16,0xffffff19,0xffffff1c,0xffffff1f,0xffffff22,0xffffff25,0xffffff28,
0xffffff2c,0xffffff2f,0xffffff33,0xffffff37,0xffffff3b,0xffffff3f,0xffffff43,0xffffff47,
0xffffff4b,0xffffff50,0xffffff55,0xffffff59,0xffffff5e,0xffffff63,0xffffff68,0xffffff6d,
0xffffff72,0xffffff78,0xffffff7d,0xffffff82,0xffffff88,0xffffff8d,0xffffff93,0xffffff99,
0xffffff9f,0xffffffa4,0xffffffaa,0xffffffb0,0xffffffb6,0xffffffbc,0xffffffc2,0xffffffc8,
0xffffffcf,0xffffffd5,0xffffffdb,0xffffffe1,0xffffffe7,0xffffffee,0xfffffff4,0xfffffffa,
0x00000000,0x00000006,0x0000000c,0x00000012,0x00000019,0x0000001f,0x00000025,0x0000002b,
0x00000031,0x00000038,0x0000003e,0x00000044,0x0000004a,0x00000050,0x00000056,0x0000005c,
0x00000061,0x00000067,0x0000006d,0x00000073,0x00000078,0x0000007e,0x00000083,0x00000088,
0x0000008e,0x00000093,0x00000098,0x0000009d,0x000000a2,0x000000a7,0x000000ab,0x000000b0,
0x000000b5,0x000000b9,0x000000bd,0x000000c1,0x000000c5,0x000000c9,0x000000cd,0x000000d1,
0x000000d4,0x000000d8,0x000000db,0x000000de,0x000000e1,0x000000e4,0x000000e7,0x000000ea,
0x000000ec,0x000000ee,0x000000f1,0x000000f3,0x000000f4,0x000000f6,0x000000f8,0x000000f9,
0x000000fb,0x000000fc,0x000000fd,0x000000fe,0x000000fe,0x000000ff,0x000000ff,0x000000ff,
/* repeat once */
0x00000100,0x000000ff,0x000000ff,0x000000ff,0x000000fe,0x000000fe,0x000000fd,0x000000fc,
0x000000fb,0x000000f9,0x000000f8,0x000000f6,0x000000f4,0x000000f3,0x000000f1,0x000000ee,
0x000000ec,0x000000ea,0x000000e7,0x000000e4,0x000000e1,0x000000de,0x000000db,0x000000d8,
0x000000d4,0x000000d1,0x000000cd,0x000000c9,0x000000c5,0x000000c1,0x000000bd,0x000000b9,
0x000000b5,0x000000b0,0x000000ab,0x000000a7,0x000000a2,0x0000009d,0x00000098,0x00000093,
0x0000008e,0x00000088,0x00000083,0x0000007e,0x00000078,0x00000073,0x0000006d,0x00000067,
0x00000061,0x0000005c,0x00000056,0x00000050,0x0000004a,0x00000044,0x0000003e,0x00000038,
0x00000031,0x0000002b,0x00000025,0x0000001f,0x00000019,0x00000012,0x0000000c,0x00000006,
0x00000000,0xfffffffa,0xfffffff4,0xffffffee,0xffffffe7,0xffffffe1,0xffffffdb,0xffffffd5,
0xffffffcf,0xffffffc8,0xffffffc2,0xffffffbc,0xffffffb6,0xffffffb0,0xffffffaa,0xffffffa4,
0xffffff9f,0xffffff99,0xffffff93,0xffffff8d,0xffffff88,0xffffff82,0xffffff7d,0xffffff78,
0xffffff72,0xffffff6d,0xffffff68,0xffffff63,0xffffff5e,0xffffff59,0xffffff55,0xffffff50,
0xffffff4b,0xffffff47,0xffffff43,0xffffff3f,0xffffff3b,0xffffff37,0xffffff33,0xffffff2f,
0xffffff2c,0xffffff28,0xffffff25,0xffffff22,0xffffff1f,0xffffff1c,0xffffff19,0xffffff16,
0xffffff14,0xffffff12,0xffffff0f,0xffffff0d,0xffffff0c,0xffffff0a,0xffffff08,0xffffff07,
0xffffff05,0xffffff04,0xffffff03,0xffffff02,0xffffff02,0xffffff01,0xffffff01,0xffffff01,
0xffffff00,0xffffff01,0xffffff01,0xffffff01,0xffffff02,0xffffff02,0xffffff03,0xffffff04,
0xffffff05,0xffffff07,0xffffff08,0xffffff0a,0xffffff0c,0xffffff0d,0xffffff0f,0xffffff12,
0xffffff14,0xffffff16,0xffffff19,0xffffff1c,0xffffff1f,0xffffff22,0xffffff25,0xffffff28,
0xffffff2c,0xffffff2f,0xffffff33,0xffffff37,0xffffff3b,0xffffff3f,0xffffff43,0xffffff47,
0xffffff4b,0xffffff50,0xffffff55,0xffffff59,0xffffff5e,0xffffff63,0xffffff68,0xffffff6d,
0xffffff72,0xffffff78,0xffffff7d,0xffffff82,0xffffff88,0xffffff8d,0xffffff93,0xffffff99,
0xffffff9f,0xffffffa4,0xffffffaa,0xffffffb0,0xffffffb6,0xffffffbc,0xffffffc2,0xffffffc8,
0xffffffcf,0xffffffd5,0xffffffdb,0xffffffe1,0xffffffe7,0xffffffee,0xfffffff4,0xfffffffa,
0x00000000,0x00000006,0x0000000c,0x00000012,0x00000019,0x0000001f,0x00000025,0x0000002b,
0x00000031,0x00000038,0x0000003e,0x00000044,0x0000004a,0x00000050,0x00000056,0x0000005c,
0x00000061,0x00000067,0x0000006d,0x00000073,0x00000078,0x0000007e,0x00000083,0x00000088,
0x0000008e,0x00000093,0x00000098,0x0000009d,0x000000a2,0x000000a7,0x000000ab,0x000000b0,
0x000000b5,0x000000b9,0x000000bd,0x000000c1,0x000000c5,0x000000c9,0x000000cd,0x000000d1,
0x000000d4,0x000000d8,0x000000db,0x000000de,0x000000e1,0x000000e4,0x000000e7,0x000000ea,
0x000000ec,0x000000ee,0x000000f1,0x000000f3,0x000000f4,0x000000f6,0x000000f8,0x000000f9,
0x000000fb,0x000000fc,0x000000fd,0x000000fe,0x000000fe,0x000000ff,0x000000ff,0x000000ff,
};
/* For angle 0-255: */
int trigx (char angle, int distance)
{
return 320/2 + ( ( sin_cos_table[angle&0xff] * distance ) >> 8);
}
int trigy (char angle, int distance)
{
return 240/2 + ( ( sin_cos_table[(angle+64)&0xff] * distance ) >> 8);
}