X-Git-Url: https://plomlompom.com/repos/foo.html?a=blobdiff_plain;f=libplomrogue.c;fp=libplomrogue.c;h=385eb713fa150b26bd57229e2af13fa498012b93;hb=2906acb0d93705435ce737285ead26fd015e20be;hp=eb108c4eb966b0fcca3834052df3efa68f444366;hpb=9d8a0624521995ed5b2ad96453c272abcd0029e7;p=plomrogue
diff --git a/libplomrogue.c b/libplomrogue.c
index eb108c4..385eb71 100644
--- a/libplomrogue.c
+++ b/libplomrogue.c
@@ -1,3 +1,4 @@
+#include /* NULL */
#include /* uint8_t, uint16_t, uint32_t, INT8_MIN, INT8_MAX */
@@ -114,21 +115,30 @@ static int8_t mv_yx_in_dir_legal(char dir, struct yx_uint8 * yx)
-/* Wrapper around mv_yx_in_dir_legal() that stores the new coordinate in the
- * globals res_y, res_x.
+/* Wrapper around mv_yx_in_dir_legal() that stores new coordinate in res_y/x,
+ * (return with result_y/x()), and immediately resets the wrapping.
*/
-uint8_t res_y = 0;
-uint8_t res_x = 0;
+static uint8_t res_y = 0;
+static uint8_t res_x = 0;
extern uint8_t mv_yx_in_dir_legal_wrap(char dir, uint8_t y, uint8_t x)
{
struct yx_uint8 yx;
yx.y = y;
yx.x = x;
uint8_t result = mv_yx_in_dir_legal(dir, &yx);
+ mv_yx_in_dir_legal(0, NULL);
res_y = yx.y;
res_x = yx.x;
return result;
}
+extern uint8_t result_y()
+{
+ return res_y;
+}
+extern uint8_t result_x()
+{
+ return res_x;
+}