From 6907a45f8b99d2a076ba965d6278f27044b19af9 Mon Sep 17 00:00:00 2001
From: Star Rauchenberger <fefferburbia@gmail.com>
Date: Fri, 27 Oct 2023 18:35:57 -0400
Subject: Can write polys now

---
 ext/wittle_generator/Panel.cpp | 14 ++++++++++++--
 ext/wittle_generator/Test.cpp  |  9 +++++----
 2 files changed, 17 insertions(+), 6 deletions(-)

(limited to 'ext/wittle_generator')

diff --git a/ext/wittle_generator/Panel.cpp b/ext/wittle_generator/Panel.cpp
index 54c7283..125636f 100644
--- a/ext/wittle_generator/Panel.cpp
+++ b/ext/wittle_generator/Panel.cpp
@@ -159,11 +159,21 @@ std::string Panel::Write() {
         } else if (symbol == Decoration::Poly) {
           serializer.writeByte(Serializer::Poly);
           serializer.writeColor(val & 0xF);
-          // TODO: write polyshape
+
+          long polyshape = (val & 0xFFFF0000) >> 16;
+          if (val & Decoration::Can_Rotate) {
+            polyshape |= (1 << 20);
+          }
+          serializer.writeLong(polyshape);
         } else if (symbol == Decoration::Negative) {
           serializer.writeByte(Serializer::Ylop);
           serializer.writeColor(val & 0xF);
-          // TODO: write polyshape
+
+          long polyshape = (val & 0xFFFF0000) >> 16;
+          if (val & Decoration::Can_Rotate) {
+            polyshape |= (1 << 20);
+          }
+          serializer.writeLong(polyshape);
         } else {
           serializer.writeByte(Serializer::Nonce);
         }
diff --git a/ext/wittle_generator/Test.cpp b/ext/wittle_generator/Test.cpp
index 1da6cd8..1a2597a 100644
--- a/ext/wittle_generator/Test.cpp
+++ b/ext/wittle_generator/Test.cpp
@@ -6,10 +6,11 @@ int main(int, char**) {
   generator.setSymbol(Decoration::Exit, 4 * 2, 0);
   /*generator.generate(4 * 2 + 1, 4 * 2 + 1,
                      {{{Decoration::Triangle | Decoration::Orange, 6}}});*/
-  generator.generate(4 * 2 + 1, 4 * 2 + 1,
-                     {{{Decoration::Star | Decoration::Color::Magenta, 4},
-                       {Decoration::Stone | Decoration::Color::Black, 4},
-                       {Decoration::Stone | Decoration::Color::White, 4}}});
+  generator.generate(
+      4 * 2 + 1, 4 * 2 + 1,
+      {{{Decoration::Poly | Decoration::Can_Rotate | Decoration::Yellow, 1},
+        {Decoration::Poly | Decoration::Yellow, 1},
+        {Decoration::Gap, 6}}});
 
   return 0;
 }
-- 
cgit 1.4.1