From a115ff2edd86e330518ff71e85658f4e4a7221e0 Mon Sep 17 00:00:00 2001 From: StackSmith Date: Thu, 29 Jun 2023 11:56:57 -0400 Subject: [PATCH] ok --- Makefile | 4 ++++ eleven.core.c | 29 +++++++++++++++++++++++++++++ eleven.h | 3 ++- 3 files changed, 35 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 90335c0..526ef5d 100644 --- a/Makefile +++ b/Makefile @@ -14,6 +14,10 @@ eleven.term: eleven.core.o eleven.term.o gcc $(CFLAGS) -o eleven eleven.core.o eleven.term.o strip eleven +elevenr: eleven.core.o eleven.termrot.o + gcc $(CFLAGS) -o elevenr eleven.core.o eleven.termrot.o + strip elevenr + clean: rm -f *.o rm -f eleven diff --git a/eleven.core.c b/eleven.core.c index 3ab6184..c1b49e7 100644 --- a/eleven.core.c +++ b/eleven.core.c @@ -27,6 +27,15 @@ void pr(U8* tiles){ }} */ #define RND (rand()%SIZE) +/* Orientation of the board, as shown by a bar: + * 0 = bottom + * 1 = left + * 2 = top + * 3 = right +*/ + +int orientation = 0; + void twist(U8* tiles){ int i,j; @@ -139,3 +148,23 @@ U32 move(U8* tiles, int way){ return n; } + + +U32 moverot(U8* tiles, int way){ + //if (way / 2) twist(tiles); + //if (way % 2) flip(tiles); + twist(tiles); + flip(tiles); + orientation = (orientation + 1) & 0x3; + if(way==2) { + twist(tiles); + flip(tiles); + twist(tiles); + flip(tiles); + orientation = (orientation + 2) & 0x3; + } + U32 n = step(tiles); + + //if (way / 2) flip(tiles); + return n; +} diff --git a/eleven.h b/eleven.h index af832c6..0d34168 100644 --- a/eleven.h +++ b/eleven.h @@ -16,5 +16,6 @@ enum { void init(U8* tiles); -U32 move(U8* tiles, int way); +U32 move(U8* tiles, int way); +U32 moverot(U8* tiles, int way);