summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaweł Redman <pawel.redman@gmail.com>2018-09-25 23:51:40 +0200
committerPaweł Redman <pawel.redman@gmail.com>2018-09-25 23:53:22 +0200
commit4d84f6aabdb5b962a990486b588fee3d1919adde (patch)
tree2dfd70ce2499a31672aefe5a801eb1cf8c24d328
parent01e9a432842686bd033fba84f7524a30d4bb40c7 (diff)
An exercise in futility.
-rw-r--r--Makefile1
-rw-r--r--src/main.c4
-rw-r--r--src/mastur.c7
3 files changed, 11 insertions, 1 deletions
diff --git a/Makefile b/Makefile
index 3d16add..f069ef2 100644
--- a/Makefile
+++ b/Makefile
@@ -15,6 +15,7 @@ SRC := src/bigtab.c \
src/new32.c \
src/new32v2.c \
src/new32v3.c \
+ src/mastur.c \
src/null.c \
src/ref.c
diff --git a/src/main.c b/src/main.c
index ca3efc8..6651ff3 100644
--- a/src/main.c
+++ b/src/main.c
@@ -21,6 +21,7 @@ int new(int i, int x, int y);
int new32(int i, int x, int y);
int new32v2(int i, int x, int y);
int new32v3(int i, int x, int y);
+int mastur(int i, int x, int y);
void bigtab_init(void);
int bigtab(int i, int x, int y);
@@ -40,7 +41,8 @@ static struct solfunc solfuncs[ ] = {
{"new", new},
{"new32", new32},
{"new32v2", new32v2},
- {"new32v3", new32v3}
+ {"new32v3", new32v3},
+ {"mastur", mastur}
};
#define PASSES 5
diff --git a/src/mastur.c b/src/mastur.c
new file mode 100644
index 0000000..7826b05
--- /dev/null
+++ b/src/mastur.c
@@ -0,0 +1,7 @@
+static const int A[] = {0, 1, -1};
+static const int C[][3] = {{1, 1, -2}, {1, 1, -2}, {-2, 1, 1}};
+
+int mastur(const int i, const int x, const int y)
+{
+ return i + A[x] * C[x][i / y % 3] * y;
+}