unofficial version 0.6: first major updates
[netris.git] / shapes.c
index 5ae8ac920da50518dc7b753091b6a51e50be96d0..42fdf514e26a3740cb87ccb6d045d942dd41a26c 100644 (file)
--- a/shapes.c
+++ b/shapes.c
 #define PreDecl(name, dir) \
        static Shape ShapeName(name, dir)
 
-#define StdShape(name, cmdName, mirror, type, realDir, dir, nextDir) \
-       static Shape ShapeName(name, dir) = { &ShapeName(name, nextDir), \
-               0, 0, mirror, D_ ## realDir, type, cmds_ ## cmdName }
+#define StdShape(name, cmdName, mirror, type, realDir, dir, nextDir, prevDir) \
+       static Shape ShapeName(name, dir) = { \
+               &ShapeName(name, nextDir), &ShapeName(name, prevDir), \
+               0, 0, mirror, D_ ## realDir, type, cmds_ ## cmdName \
+       }
 
 #define FourWayDecl(name, cmdName, mirror, type) \
        PreDecl(name, down); \
-       StdShape(name, cmdName, mirror, type, left, left, down); \
-       StdShape(name, cmdName, mirror, type, up, up, left); \
-       StdShape(name, cmdName, mirror, type, right, right, up); \
-       StdShape(name, cmdName, mirror, type, down, down, right)
+       PreDecl(name, up); \
+       StdShape(name, cmdName, mirror, type, left, left, up, down); \
+       PreDecl(name, right); \
+       StdShape(name, cmdName, mirror, type, up, up, right, left); \
+       StdShape(name, cmdName, mirror, type, right, right, down, up); \
+       StdShape(name, cmdName, mirror, type, down, down, left, right)
 
 #define TwoWayDecl(name, cmdName, mirror, type) \
        PreDecl(name, vert); \
-       StdShape(name, cmdName, mirror, type, right, horiz, vert); \
-       StdShape(name, cmdName, mirror, type, down, vert, horiz)
+       StdShape(name, cmdName, mirror, type, right, horiz, vert, vert); \
+       StdShape(name, cmdName, mirror, type, down, vert, horiz, horiz)
 
 static Cmd cmds_long[] = { C_back, C_plot, C_forw, C_plot, C_forw, C_plot,
        C_forw, C_plot, C_end };
@@ -50,12 +54,12 @@ TwoWayDecl(long, long, 0, BT_blue);
 
 static Cmd cmds_square[] = { C_plot, C_forw, C_left, C_plot, C_forw, C_left,
        C_plot, C_forw, C_left, C_plot, C_end };
-static Shape shape_square = { &shape_square, 0, 0, D_up, 0, BT_magenta,
-       cmds_square };
+static Shape shape_square = { &shape_square, &shape_square, 0, 0, D_up, 0,
+       BT_magenta, cmds_square };
 
 static Cmd cmds_l[] = { C_right, C_back, C_plot, C_forw, C_plot, C_forw,
        C_plot, C_left, C_forw, C_plot, C_end };
-FourWayDecl(l, l, 0, BT_cyan);
+FourWayDecl(l, l, 0, BT_cyan); 
 FourWayDecl(l1, l, 1, BT_yellow);
 
 static Cmd cmds_t[] = { C_plot, C_forw, C_plot, C_back, C_right, C_forw,
@@ -117,7 +121,7 @@ ExtFunc Dir RotateDir(Dir dir, int delta)
 }
 
 ExtFunc int ShapeIterate(Shape *s, int scr, int y, int x, int falling,
-ExtFunc                                ShapeDrawFunc func, void *data)
+ExtFunc                                                        ShapeDrawFunc func, void *data)
 {
        int i, mirror, result;
        Dir dir;