45 static const n_int new_sd[256] =
47 0, 659, 1318, 1977, 2634, 3290, 3944, 4595, 5244, 5889, 6531, 7169, 7802, 8431, 9055, 9673,
48 10286, 10892, 11492, 12085, 12671, 13249, 13819, 14380, 14933, 15477, 16012, 16537, 17052, 17557, 18051, 18534,
49 19007, 19467, 19916, 20353, 20778, 21190, 21590, 21976, 22349, 22709, 23055, 23387, 23706, 24009, 24299, 24573,
50 24833, 25078, 25308, 25523, 25722, 25906, 26074, 26226, 26363, 26484, 26589, 26677, 26750, 26807, 26847, 26871,
51 26880, 26871, 26847, 26807, 26750, 26677, 26589, 26484, 26363, 26226, 26074, 25906, 25722, 25523, 25308, 25078,
52 24833, 24573, 24299, 24009, 23706, 23387, 23055, 22709, 22349, 21976, 21590, 21190, 20778, 20353, 19916, 19467,
53 19007, 18534, 18051, 17557, 17052, 16537, 16012, 15477, 14933, 14380, 13819, 13249, 12671, 12085, 11492, 10892,
54 10286, 9673, 9055, 8431, 7802, 7169, 6531, 5889, 5244, 4595, 3944, 3290, 2634, 1977, 1318, 659,
55 0, -659, -1318, -1977, -2634, -3290, -3944, -4595, -5244, -5889, -6531, -7169, -7802, -8431, -9055, -9673,
56 -10286, -10892, -11492, -12085, -12671, -13249, -13819, -14380, -14933, -15477, -16012, -16537, -17052, -17557, -18051, -18534,
57 -19007, -19467, -19916, -20353, -20778, -21190, -21590, -21976, -22349, -22709, -23055, -23387, -23706, -24009, -24299, -24573,
58 -24833, -25078, -25308, -25523, -25722, -25906, -26074, -26226, -26363, -26484, -26589, -26677, -26750, -26807, -26847, -26871,
59 -26880, -26871, -26847, -26807, -26750, -26677, -26589, -26484, -26363, -26226, -26074, -25906, -25722, -25523, -25308, -25078,
60 -24833, -24573, -24299, -24009, -23706, -23387, -23055, -22709, -22349, -21976, -21590, -21190, -20778, -20353, -19916, -19467,
61 -19007, -18534, -18051, -17557, -17052, -16537, -16012, -15477, -14933, -14380, -13819, -13249, -12671, -12085, -11492, -10892,
62 -10286, -9673, -9055, -8431, -7802, -7169, -6531, -5889, -5244, -4595, -3944, -3290, -2634, -1977, -1318, -659
75 if (converter == 0L)
return;
76 if (input == 0L)
return;
78 converter->
x = input[0];
79 converter->
y = input[1];
94 if (equals == 0L)
return;
95 if (initial == 0L)
return;
96 if (second == 0L)
return;
98 equals->
x = initial->
x + second->
x;
99 equals->
y = initial->
y + second->
y;
106 center->
x = center->
x / 2;
107 center->
y = center->
y / 2;
122 if (equals == 0L)
return;
123 if (initial == 0L)
return;
124 if (second == 0L)
return;
126 equals->
x = initial->
x - second->
x;
127 equals->
y = initial->
y - second->
y;
146 if (equals == 0L)
return;
147 if (initial == 0L)
return;
148 if (second == 0L)
return;
149 if (divisor == 0L)
return;
151 equals->
x = (multiplier * initial->
x * second->
x) / divisor;
152 equals->
y = (multiplier * initial->
y * second->
y) / divisor;
169 if (initial == 0L)
return;
170 if (second == 0L)
return;
171 if (divisor == 0L)
return;
173 initial->
x += ( (multiplier * second->
x) / divisor);
174 initial->
y += ( (multiplier * second->
y) / divisor);
192 if (initial == 0L)
return 0;
193 if (second == 0L)
return 0;
195 return (multiplier * ((initial->
x * second->
x) + (initial->
y * second->
y))) / divisor;
207 return new_sd[(direction)&255] / (divisor);
213 rotation->
y = 0 - rotation->
x;
227 initial->
x = ((new_sd[((direction)+64)&255]) / (divisor));
228 initial->
y = ((new_sd[(direction)&255]) / (divisor));
235 if (initial == 0L)
return;
246 if (converter == 0L)
return;
247 if (output == 0L)
return;
249 if (converter->
x > 65535) converter->
x = 65535;
250 if (converter->
y > 65535) converter->
y = 65535;
251 if (converter->
x < 0) converter->
x = 0;
252 if (converter->
y < 0) converter->
y = 0;
274 temp.
x = ((location->
x * rotation->
x) + (location->
y * rotation->
y)) /
SINE_MAXIMUM;
275 temp.
y = ((location->
x * rotation->
y) - (location->
y * rotation->
x)) /
SINE_MAXIMUM;
277 location->
x = temp.
x;
278 location->
y = temp.
y;
283 return ((nonzero->
x != 0) || (nonzero->
y != 0));
304 n_int px = points[loop].
x;
305 n_int py = points[loop].
y;
306 if (px < maxmin[0].x)
310 if (py < maxmin[0].y)
315 if (px > maxmin[1].x)
319 if (py > maxmin[1].y)
342 #define POSITIVE_TILE_COORD(num) ((num+(3*MAP_DIMENSION))&(MAP_DIMENSION-1))
354 n_int span_minor = 0;
356 while (span_minor < 6)
361 if ((span_minor&1) == 0)
371 while (py < local_tile_dimension)
374 while (px < local_tile_dimension)
383 sum += front[(*mem_func)((px+tx),(py+ty))];
388 back[(*mem_func)((px),(py))] = (
n_byte)(sum / 9);
405 static void math_round_smarter_scan(
void * void_mrss,
void * xlocation,
void * unused)
415 n_int running_sum = front[(*mem_func)((px-1),(py-1))];
416 running_sum += front[(*mem_func)((px+0),(py-1))];
417 running_sum += front[(*mem_func)((px+1),(py-1))];
419 running_sum += front[(*mem_func)((px-1),(py+0))];
420 running_sum += front[(*mem_func)((px+0),(py+0))];
421 running_sum += front[(*mem_func)((px+1),(py+0))];
423 running_sum += front[(*mem_func)((px-1),(py+1))];
424 running_sum += front[(*mem_func)((px+0),(py+1))];
425 running_sum += front[(*mem_func)((px+1),(py+1))];
427 while (py < local_tile_dimension)
429 back[(*mem_func)((px),(py))] = (
n_byte)(running_sum / 9);
431 running_sum -= front[(*mem_func)((px-1),(py-1))];
432 running_sum -= front[(*mem_func)((px+0),(py-1))];
433 running_sum -= front[(*mem_func)((px+1),(py-1))];
437 running_sum += front[(*mem_func)((px-1),(py+1))];
438 running_sum += front[(*mem_func)((px+0),(py+1))];
439 running_sum += front[(*mem_func)((px+1),(py+1))];
447 n_int span_minor = 0;
454 while (span_minor < 6)
457 if ((span_minor&1) == 0)
459 mrss.
front = local_map;
464 mrss.
front = scratch;
465 mrss.
back = local_map;
473 #ifdef EXECUTE_THREADED
476 math_round_smarter_scan((
void*)&mrss, xlocation, 0L);
482 #ifdef EXECUTE_THREADED
504 const n_int span_minor = (64 >> ((refine&7)^7));
505 const n_int span_major = (1 << ((refine&7)^7));
513 while (tile_y < local_tiles)
517 while (tile_x < local_tiles)
521 while (py < span_minor)
524 while (px < span_minor)
527 n_int val1 = ((px << 2) + (py << 10));
529 n_int tseed = (*func)(arg);
536 n_int val2 = (tseed >> (tx | (ty << 2)));
537 n_int val3 = ((((val2 & 1) << 1)-1) * 20);
540 val2 = (tx | (ty << 8));
542 while (my < span_major)
545 while (mx < span_major)
547 n_int point = ((mx | (my << 8)) + (span_major * (val1 + val2)));
548 n_int pointx = (point & 255);
549 n_int pointy = (point >> 8);
553 n_int pointx_tmp = pointx + pointy;
554 pointy = pointx - pointy;
559 n_uint newloc = (*mem_func)((pointx + (tile_x<<8)) ,(pointy + (tile_y<<8)));
560 n_int local_map_point = local_map[newloc] + val3;
561 if (local_map_point < 0) local_map_point = 0;
562 if (local_map_point > 255) local_map_point = 255;
563 local_map[newloc] = (
n_byte)local_map_point;
604 if (draw == 0L)
return 1;
610 NA_ASSERT(local_draw,
"local_draw NULL");
611 NA_ASSERT(local_info,
"local_info NULL");
613 if ((*local_draw)(px, py, 0, 0, local_info))
617 if ((dx == 0) && (dy == 0))
625 n_int sdx = (dxabs != 0);
626 n_int sdy = (dyabs != 0);
639 n_int y2 = dxabs >> 1;
650 if ((*local_draw)(px, py, sdx, sdy, local_info))
656 n_int x2 = dyabs >> 1;
667 if ((*local_draw)(px, py, sdx, sdy, local_info))
684 return math_join(point1->
x, point1->
y, delta.
x, delta.
y, draw);
698 hash = (16777619 * hash) ^ (*key++);
712 n_byte2 round[5]= {0xfa78, 0xfad7, 0x53e7, 0xa728, 0x2c81};
720 while( loop < length)
723 round[1]^=values[loop++];
729 big_round[0] = round[0];
730 big_round[1] = round[1];
731 big_round[2] = round[2];
732 big_round[3] = round[3];
734 return big_round[0] | (big_round[1]<<16) | (big_round[2] << 32) | (big_round[3]<<48);
739 round[1]^=values[loop++];
742 return round[0] | (round[1]<<16);
745 #define NUMBER_TURN_TOWARDS_POINTS 8
761 64, 64, 32, 16, 8, 4, 2, 1
772 best_p =
vect2_dot(p, &vector_facing, 1, 1);
776 n_int loc_track = track[loop];
777 n_int loc_f = (best_f + loc_track) & 255;
781 project1 =
vect2_dot(p, &vector_facing, 1, 1);
783 if (project1 > best_p)
790 n_int loc_f2 = (best_f + 256 - loc_track) & 255;
794 project2 =
vect2_dot(p, &vector_facing, 1, 1);
796 if (project2 > best_p)
832 if (local == 0L)
return 0;
841 local[1] = (
n_byte2)(tmp1 ^ (tmp0 >> 1) ^ 0xd028);
844 local[1] = (
n_byte2)(tmp1 ^ (tmp0 >> 2) ^ 0xae08);
847 local[1] = (
n_byte2)(tmp1 ^ (tmp0 >> 3) ^ 0x6320);
850 local[1] = (
n_byte2)(tmp1 ^ (tmp0 >> 1));
873 if (side512 == 0L)
return;
874 if (data == 0L)
return;
882 n_int mic_x = ( loop_x & 7);
884 n_int mic_y = ( loop_y & 7);
886 n_int mac_x = (loop_x >> 3);
887 n_int mac_y = (loop_y >> 3);
895 n_int z00 = side512[px0|py0];
897 n_int z01 = side512[px1|py0];
898 n_int z10 = side512[px0|py1] - z00;
899 n_int z11 = side512[px1|py1] - z01 - z10;
903 z01 = (z01 - z00) << 3;
906 value = (
n_byte)((z00 + (((z01 * mic_x) + (z10 * mic_y) + (z11 * mic_x * mic_y) ) >> 6)));
909 data[(point<<1)|1] = data[point<<1] = value;
936 op = op - (res + one);
962 n_int braincode_min_loop)
965 switch( instruction )
970 addr0[0] &= addr1[0];
981 addr0[0] |= addr1[0];
990 if ((!is_constant0) && (!is_constant1))
996 addr1[0] = (
n_byte)value0;
1002 n_int ptr0, ptr1, n, instructions_to_copy, dat = 0;
1017 while (dat < instructions_to_copy)
1039 addr1[n] = addr0[n];
1053 if ((!is_constant0) && (!is_constant1))
1055 addr1[0] += addr0[0];
1064 if ((!is_constant0) && (!is_constant1))
1066 addr1[0] -= addr0[0];
1075 if ((!is_constant0) && (!is_constant1))
1077 addr1[0] *= addr0[0];
1086 if ((!is_constant0) && (!is_constant1))
1088 addr1[0] >>= (addr0[0]%4);
1092 addr1[0] >>= (value0%4);
1097 if ((!is_constant0) && (!is_constant1))
1101 addr1[0] %= addr0[0];
1140 n_int v0 = is_const0;
1141 n_int v1 = is_const1;
1145 if ((*i-i2) < braincode_min_loop)
1147 i2 = *i - braincode_min_loop;
1157 n_int v0 = is_const0;
1165 if ((*i-i2) < braincode_min_loop)
1167 i2 = *i - braincode_min_loop;
1178 n_int v0 = is_const0;
1184 if ((*i-i2) < braincode_min_loop)
1186 i2 = *i - braincode_min_loop;
1196 if (addr0[0]-1 != 0)
1203 if ((*i-i2) < braincode_min_loop)
1205 i2 = *i - braincode_min_loop;
1214 if ((!is_constant0) && (!is_constant1))
1216 if (addr1[0] == addr0[0])
1223 if (addr1[0] == value0)
1231 if ((!is_constant0) && (!is_constant1))
1233 if (addr1[0] != addr0[0])
1240 if (addr1[0] != value0)
1248 if ((!is_constant0) && (!is_constant1))
1250 if (addr1[0] < addr0[0])
1257 if (addr1[0] < value0)
1271 addr0[0] = addr1[0];
1279 addr0[0] = 255 - addr0[0];
1283 addr1[0] = 255 - addr1[0];