From 518d98ad5f9eec0cf4124375bdbb84d1296b3f3f Mon Sep 17 00:00:00 2001 From: Sebastiano Tronto Date: Thu, 4 Jul 2024 17:09:55 +0200 Subject: (almost) added getcube --- src/cube_public.h | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) (limited to 'src/cube_public.h') diff --git a/src/cube_public.h b/src/cube_public.h index fe003c9..b537019 100644 --- a/src/cube_public.h +++ b/src/cube_public.h @@ -2,6 +2,16 @@ _static int64_t write_result(cube_t, char [static 22]); +/* TODO: add option to get DR, maybe C-only, E-only, eo... */ +#define GETCUBE_OPTIONS(S, F) { .option = S, .fix = F } +struct { + char *option; + void (*fix)(int64_t *, int64_t *, int64_t *, int64_t *); +} getcube_options[] = { + GETCUBE_OPTIONS("fix", getcube_fix), + GETCUBE_OPTIONS(NULL, NULL) +}; + _static int64_t write_result(cube_t cube, char result[static 22]) { @@ -105,15 +115,25 @@ nissy_convert( } int64_t -nissy_gencube( - uint8_t id[16], +nissy_getcube( + int64_t ep, + int64_t eo, + int64_t cp, + int64_t co, const char *options, char result[static 22] ) { - /* TODO: compute cube from id % (number of positions) */ - /* options can be used for generating e.g. DR-state cube */ - return -1; + int i; + cube_t c; + + for (i = 0; getcube_options[i].option != NULL; i++) + if (!strcmp(options, getcube_options[i].option)) + getcube_options[i].fix(&ep, &eo, &cp, &co); + + c = getcube(ep, eo, cp, co); + + return write_result(c, result); } int64_t -- cgit v1.3