Commit d3f28e85 authored by Tom Barbalet's avatar Tom Barbalet

Clean up

parent 41aa4925
Pipeline #121431589 failed with stages
in 1 minute and 6 seconds
Subproject commit 287446eeccf3704ce2919b7131ac5db255a1bd99
Subproject commit b7f73da228b62e76cd02836d696605a982619d63
......@@ -45,7 +45,6 @@ COMMANDLINEE=-DCOMMAND_LINE_EXPLICIT
fi
gcc ${CFLAGS} ${COMMANDLINEE} -c ./apetoolkit/*.c -lz -lm -lpthread -w
gcc ${CFLAGS} ${COMMANDLINEE} -c ./toolkit2/*.c -lz -lm -lpthread -w
gcc ${CFLAGS} ${COMMANDLINEE} -c ./script/*.c -lz -lm -lpthread -w
gcc ${CFLAGS} ${COMMANDLINEE} -c ./sim/*.c -lz -lm -lpthread -w
gcc ${CFLAGS} ${COMMANDLINEE} -c ./entity/*.c -lz -lm -lpthread -w
......
......@@ -37,7 +37,6 @@
#define SIMULATEDAPE_ENTITY_H
#include "../apetoolkit/toolkit.h"
#include "../toolkit2/toolkit2.h"
#include "../script/script.h"
#include "../sim/sim.h"
#include "../universe/universe.h"
......
......@@ -35,7 +35,8 @@
#include <math.h>
#include "graph.h"
#include "../apetoolkit/toolkit.h"
#include "entity.h"
#define MAX_SKELETON_DIAGRAM_POINTS 200000
......@@ -241,6 +242,133 @@ const n_vect2 bone_ribs[] =
{35,-20}, {416,-20}, /* shoulders */
};
/**
* @brief Returns an array of 2D points used for drawing diagrams
* @param source_points Array of 2D points which is the template
* @param no_of_source_points Number of 2D points in the template
* @param extra_points The number of points to be returned via the extra parameters
* @param x The starting x coordinate
* @param y The starting y coordinate
* @param mirror Flip in the vertical axis
* @param scale Horizontal scaling factor x1000
* @param angle Rotation angle of the result
*/
static void outline_points(const n_vect2 * source_points,
n_int no_of_source_points, n_int extra_points,
n_int x, n_int y,
n_byte mirror,
n_vect2 * scale,
n_int angle,
n_vect2 *axis,
n_vect2 *extra_1,
n_vect2 *extra_2,
n_vect2 *extra_3,
n_vect2 *extra_4,
n_points * collection)
{
n_vect2 ds, location, vector;
n_int i, axis_length,point_length;
n_double axis_angle, point_angle;
n_double ang = angle*TWO_PI/7200;
vect2_populate(&location, x, y);
vect2_subtract(&ds, (n_vect2 *)&source_points[1], (n_vect2 *)source_points);
vect2_multiplier(&ds, &ds, scale, 1, 1000);
/** length of the object */
axis_length = (n_int)math_root(vect2_dot(&ds, &ds, 1, 1));
if (axis_length < 1) axis_length=1;
/** invert around the vertical axis if needed */
if (mirror != 0)
{
ds.x = -ds.x;
}
/** find the orientation angle of the axis */
axis_angle = (float)acos(ds.x/(float)axis_length);
if (ds.y < 0)
{
axis_angle = TWO_PI-axis_angle;
}
vect2_populate(&vector, (n_int)(axis_length*sin(ang+(TWO_PI/4)-axis_angle)),
(n_int)(axis_length*cos(ang+(TWO_PI/4)-axis_angle)));
/** calculate the position of the end point of the axis */
vect2_add(axis, &location, &vector);
/** draw lines between each point */
for (i = 2; i < no_of_source_points + 2 + extra_points; i++)
{
n_vect2 point;
vect2_subtract(&ds, (n_vect2 *)&source_points[i], (n_vect2 *)source_points);
vect2_multiplier(&ds, &ds, scale, 1, 1000);
point_length = (n_int)math_root(vect2_dot(&ds, &ds, 1, 1));
if (point_length < 1)
{
point_length = 1;
}
/** invert the line around the vertical axis if necessary */
if (mirror != 0)
{
ds.x = -ds.x;
}
/** angle of the line */
point_angle = (float)acos(ds.x/(float)point_length);
if (ds.y < 0)
{
point_angle = (TWO_PI)-point_angle;
}
/** position of the end of the line */
vect2_populate(&vector, (n_int)(point_length*sin(ang+point_angle-axis_angle)),
(n_int)(point_length*cos(ang+point_angle-axis_angle)));
vect2_add(&point, &location, &vector);
/** store the calculated point positions in an array */
if (collection->no_of_points < collection->max_points)
{
if (i < no_of_source_points + 2)
{
vect2_copy(&collection->points[collection->no_of_points], &point);
collection->no_of_points++;
}
}
/* TODO
else
{
(void)SHOW_ERROR("Maximum number of skeleton points reached");
}
*/
/** This is a crude way of keeping track of the last few points
so that they can be returned by the function */
vect2_copy(extra_1, extra_2);
vect2_copy(extra_2, extra_3);
vect2_copy(extra_3, extra_4);
vect2_copy(extra_4, &point);
}
if (collection->no_of_points > -1 && collection->no_of_points < collection->max_points)
{
collection->points[collection->no_of_points].x = 9999;
collection->points[collection->no_of_points].y = 9999;
collection->no_of_points++;
}
else
{
SHOW_ERROR("Outside point range for drawing");
}
}
/**
* @brief Returns vertical and horizontal scaling factors based upon the
* genetics for a particular body segment
......
/****************************************************************
graph.c
=============================================================
Copyright 1996-2020 Tom Barbalet. All rights reserved.
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or
sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
This software is a continuing work of Tom Barbalet, begun on
13 June 1996. No apes or cats were harmed in the writing of
this software.
****************************************************************/
#ifndef _WIN32
#include "../apetoolkit/toolkit.h"
#include "../toolkit2/toolkit2.h"
#include "../script/script.h"
#include "../sim/sim.h"
#include "../universe/universe.h"
#include "../entity/entity.h"
#include "../gui/gui.h"
#else
#include "..\toolkit\toolkit.h"
#include "..\toolkit2\toolkit2.h"
#include "..\script\script.h"
#include "..\sim\sim.h"
#include "..\universe\universe.h"
#include "..\entity\entity.h"
#include "..\gui\gui.h"
#endif
#include <math.h>
#include "graph.h"
/**
* @brief Returns an array of 2D points used for drawing diagrams
* @param source_points Array of 2D points which is the template
* @param no_of_source_points Number of 2D points in the template
* @param extra_points The number of points to be returned via the extra parameters
* @param x The starting x coordinate
* @param y The starting y coordinate
* @param mirror Flip in the vertical axis
* @param scale Horizontal scaling factor x1000
* @param angle Rotation angle of the result
*/
void outline_points(const n_vect2 * source_points,
n_int no_of_source_points, n_int extra_points,
n_int x, n_int y,
n_byte mirror,
n_vect2 * scale,
n_int angle,
n_vect2 *axis,
n_vect2 *extra_1,
n_vect2 *extra_2,
n_vect2 *extra_3,
n_vect2 *extra_4,
n_points * collection)
{
n_vect2 ds, location, vector;
n_int i, axis_length,point_length;
n_double axis_angle, point_angle;
n_double ang = angle*TWO_PI/7200;
vect2_populate(&location, x, y);
vect2_subtract(&ds, (n_vect2 *)&source_points[1], (n_vect2 *)source_points);
vect2_multiplier(&ds, &ds, scale, 1, 1000);
/** length of the object */
axis_length = (n_int)math_root(vect2_dot(&ds, &ds, 1, 1));
if (axis_length < 1) axis_length=1;
/** invert around the vertical axis if needed */
if (mirror != 0)
{
ds.x = -ds.x;
}
/** find the orientation angle of the axis */
axis_angle = (float)acos(ds.x/(float)axis_length);
if (ds.y < 0)
{
axis_angle = TWO_PI-axis_angle;
}
vect2_populate(&vector, (n_int)(axis_length*sin(ang+(TWO_PI/4)-axis_angle)),
(n_int)(axis_length*cos(ang+(TWO_PI/4)-axis_angle)));
/** calculate the position of the end point of the axis */
vect2_add(axis, &location, &vector);
/** draw lines between each point */
for (i = 2; i < no_of_source_points + 2 + extra_points; i++)
{
n_vect2 point;
vect2_subtract(&ds, (n_vect2 *)&source_points[i], (n_vect2 *)source_points);
vect2_multiplier(&ds, &ds, scale, 1, 1000);
point_length = (n_int)math_root(vect2_dot(&ds, &ds, 1, 1));
if (point_length < 1)
{
point_length = 1;
}
/** invert the line around the vertical axis if necessary */
if (mirror != 0)
{
ds.x = -ds.x;
}
/** angle of the line */
point_angle = (float)acos(ds.x/(float)point_length);
if (ds.y < 0)
{
point_angle = (TWO_PI)-point_angle;
}
/** position of the end of the line */
vect2_populate(&vector, (n_int)(point_length*sin(ang+point_angle-axis_angle)),
(n_int)(point_length*cos(ang+point_angle-axis_angle)));
vect2_add(&point, &location, &vector);
/** store the calculated point positions in an array */
if (collection->no_of_points < collection->max_points)
{
if (i < no_of_source_points + 2)
{
vect2_copy(&collection->points[collection->no_of_points], &point);
collection->no_of_points++;
}
}
/* TODO
else
{
(void)SHOW_ERROR("Maximum number of skeleton points reached");
}
*/
/** This is a crude way of keeping track of the last few points
so that they can be returned by the function */
vect2_copy(extra_1, extra_2);
vect2_copy(extra_2, extra_3);
vect2_copy(extra_3, extra_4);
vect2_copy(extra_4, &point);
}
if (collection->no_of_points > -1 && collection->no_of_points < collection->max_points)
{
collection->points[collection->no_of_points].x = 9999;
collection->points[collection->no_of_points].y = 9999;
collection->no_of_points++;
}
else
{
SHOW_ERROR("Outside point range for drawing");
}
}
/****************************************************************
graph.h
=============================================================
Copyright 1996-2020 Tom Barbalet. All rights reserved.
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or
sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
This software is a continuing work of Tom Barbalet, begun on
13 June 1996. No apes or cats were harmed in the writing of
this software.
****************************************************************/
#ifndef SIMULATEDAPE_GRAPH_H
#define SIMULATEDAPE_GRAPH_H
#ifndef _WIN32
#include "../apetoolkit/toolkit.h"
#include "../toolkit2/toolkit2.h"
#include "../script/script.h"
#include "../sim/sim.h"
#include "../universe/universe.h"
#include "../entity/entity.h"
#else
#include "..\toolkit\toolkit.h"
#include "..\toolkit2\toolkit2.h"
#include "..\script\script.h"
#include "..\sim\sim.h"
#include "..\universe\universe.h"
#include "..\entity\entity.h"
#endif
void outline_points(const n_vect2 * source_points,
n_int no_of_source_points, n_int extra_points,
n_int x, n_int y,
n_byte mirror,
n_vect2 * scale,
n_int angle,
n_vect2 *axis,
n_vect2 *extra_1,
n_vect2 *extra_2,
n_vect2 *extra_3,
n_vect2 *extra_4,
n_points * collection);
#endif /* SIMULATEDAPE_GRAPH_H */
......@@ -39,21 +39,10 @@
#ifndef _WIN32
#ifndef _WIN32
#include "../apetoolkit/toolkit.h"
#include "../toolkit2/toolkit2.h"
#include "../script/script.h"
#include "../sim/sim.h"
#else
#include "..\toolkit\toolkit.h"
#include "..\toolkit2\toolkit2.h"
#include "..\script\script.h"
#include "..\sim\sim.h"
#endif
#ifdef SIMULATED_APE_CLIENT
#include "client.h"
......@@ -64,12 +53,6 @@
#else
#include "..\apetoolkit\toolkit.h"
#include "..\toolkit2\toolkit2.h"
#include "..\script\script.h"
#include "..\sim\sim.h"
#ifdef SIMULATED_APE_CLIENT
#include "client.h"
#else
......
......@@ -33,26 +33,10 @@
****************************************************************/
#ifndef _WIN32
#include "../apetoolkit/toolkit.h"
#include "../toolkit2/toolkit2.h"
#include "../script/script.h"
#include "../sim/sim.h"
#include "../universe/universe.h"
#else
#include "..\toolkit\toolkit.h"
#include "..\toolkit2\toolkit2.h"
#include "..\script\script.h"
#include "..\sim\sim.h"
#include "..\universe\universe.h"
#endif
#include "../apetoolkit/shared.h"
#import "ASDefaults.h"
......
......@@ -47,7 +47,6 @@ COMMANDLINEE=-DCOMMAND_LINE_EXPLICIT
fi
gcc ${CFLAGS} ${COMMANDLINEE} -c ../apetoolkit/*.c -lz -lm -lpthread -w
gcc ${CFLAGS} ${COMMANDLINEE} -c ../toolkit2/*.c -lz -lm -lpthread -w
gcc ${CFLAGS} ${COMMANDLINEE} -c ../script/*.c -lz -lm -lpthread -w
gcc ${CFLAGS} ${COMMANDLINEE} -c ../sim/*.c -lz -lm -lpthread -w
......@@ -69,4 +68,4 @@ then
exit 1
fi
rm test_gui.o
\ No newline at end of file
rm test_gui.o
......@@ -47,7 +47,6 @@ COMMANDLINEE=-DCOMMAND_LINE_EXPLICIT
fi
gcc ${CFLAGS} ${COMMANDLINEE} -c ../apetoolkit/*.c -lz -lm -lpthread -w
gcc ${CFLAGS} ${COMMANDLINEE} -c ../toolkit2/*.c -lz -lm -lpthread -w
gcc ${CFLAGS} ${COMMANDLINEE} -c ../script/*.c -lz -lm -lpthread -w
......
This diff is collapsed.
/****************************************************************
compress.c
=============================================================
Copyright 1996-2020 Tom Barbalet. All rights reserved.
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or
sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
This software is a continuing work of Tom Barbalet, begun on
13 June 1996. No apes or cats were harmed in the writing of
this software.
****************************************************************/
#include "../apetoolkit/toolkit.h"
#include "toolkit2.h"
#include <stdio.h>
static n_byte brain_index_compressed[384];
static n_byte brain_index[1024];
static n_byte brain_compressed[ 32 * 32 * 32 * 2];
static n_uint brain_location;
/*static n_byte brain_base85[ (((32 * 32 * 32 * 2) + 384) * 5) / 4 ];
static n_uint brain_base85_location;*/
static void compress_bytes_to_base85(n_byte * bytes, n_byte * base85)
{
n_uint combined = bytes[0] + (bytes[1] * 256) + (bytes[2] * 256 * 256) + (bytes[3] * 256 * 256 * 256);
base85[0] = 33 + (combined % 83);
base85[1] = 33 + (combined / 83) % 83;
base85[2] = 33 + (combined / (83 * 83)) % 83;
base85[3] = 33 + (combined / (83 * 83 * 83)) % 83;
base85[4] = 33 + (combined / (83 * 83 * 83 * 83)) % 83;
}
static void compress_base85_to_bytes(n_byte * base85, n_byte * bytes)
{
n_uint combined;
n_byte delta[5];
delta[0] = base85[0] - 33;
delta[1] = base85[1] - 33;
delta[2] = base85[2] - 33;
delta[3] = base85[3] - 33;
delta[4] = base85[4] - 33;
combined = delta[0] + (delta[1] * 83) + (delta[2] * 83 * 83) + (delta[3] * 83 * 83 * 83) + (delta[3] * 83 * 83 * 83 * 83);
bytes[0] = combined & 255;
bytes[1] = (combined >> 8) & 255;
bytes[2] = (combined >> 16) & 255;
bytes[3] = (combined >> 24) & 255;
}
void compress_buffer(n_byte * input, n_byte * output, n_int n, n_int compressed)
{
n_int total_bits = n * 8;
n_int loop = 0;
n_int a_result, b_result, c_result, d_result;
while (loop < total_bits)
{
if (compressed)
{
a_result = loop & 7;
b_result = loop >> 3;
c_result = loop % n;
d_result = loop / n;
}
else
{
a_result = loop % n;
b_result = loop / n;
c_result = loop & 7;
d_result = loop >> 3;
}
if (c_result == 0)
{
output[d_result] = 0;
}
output[d_result] += ((input[b_result] >> a_result) & 1) << c_result;
loop++;
}
}
void compress_buffer_run(n_byte * input, n_byte * output, n_int n, n_int compressed, n_int number)
{
n_int input_add, output_add;
n_int input_loop_end, input_loop = 0, output_loop = 0;
if (compressed)
{
input_add = n;
output_add = 8;
}
else
{
input_add = 8;
output_add = n;
}
input_loop_end = input_add * number;
while (input_loop < input_loop_end)
{
compress_buffer(&input[input_loop], &output[output_loop], n, compressed);
input_loop += input_add;
output_loop += output_add;
}
}
static void compress_brain_index_compress(void)
{
n_int three_loop = 0;
n_int eight_loop = 0;
while (three_loop < 384)
{
compress_buffer(&brain_index[eight_loop], &brain_index_compressed[three_loop], 3, 1);
eight_loop += 8;
three_loop += 3;
}
}
static void compress_brain_index_expand(void)
{
n_int three_loop = 0;
n_int eight_loop = 0;
while (three_loop < 384)
{
compress_buffer(&brain_index_compressed[three_loop], &brain_index[eight_loop], 3, 0);
eight_loop += 8;
three_loop += 3;
}
}
static n_byte compresed_find_level(n_byte value)
{
if (value < 2)
{
return 0;
}
if (value < 4)
{
return 1;
}
if (value < 8)
{
return 2;
}
if (value < 16)
{
return 3;
}
if (value < 32)
{
return 4;
}
if (value < 64)
{
return 5;
}
if (value < 128)
{
return 6;
}
return 7;
}
void compress_brain_compressed(n_byte * brain)
{
n_int pz = 0;
brain_location = 0;
while (pz < 8)
{
n_int py = 0;
while (py < 8)
{
n_int px = 0;
while (px < 8)
{
n_int old = 0;
while (old < 2)
{
n_byte array[4 * 4 * 4] = {0};
n_byte min = 255;
n_byte max = 0;
n_int sz = 0;
while (sz < 4)
{
n_int lz = (pz * 4) + sz;
n_int sy = 0;
while (sy < 4)
{