asdf

Dependencies:   mbed

Fork of manworm_ticker_tv by Bayley Wang

Revision:
7:25acb844f424
Parent:
6:0a34891a82c7
Child:
8:caeb6582cdc1
diff -r 0a34891a82c7 -r 25acb844f424 main.cpp
--- a/main.cpp	Mon Nov 20 06:28:29 2017 +0000
+++ b/main.cpp	Mon Nov 20 10:54:42 2017 +0000
@@ -216,9 +216,9 @@
 uint8_t sprite_manl[] = {
 0,0,0,1,0,0,0,
 0,0,1,1,1,0,0,
-0,0,0,1,0,0,1,
+1,0,0,1,0,0,0,
 0,1,1,1,1,1,0,
-1,0,1,1,1,0,0,
+0,0,1,1,1,0,1,
 0,0,1,1,1,0,0,
 0,1,0,0,0,1,0,
 0,1,0,0,0,0,0};
@@ -345,6 +345,10 @@
 float rc_cos = cosf(0.03f);
 float rc_sin = sinf(0.03f);
 
+//mode7 variables
+float m7_theta = 0.8f;
+float m7_x = mapWidth/2, m7_y=mapHeight/2;
+
 DigitalIn p1_in(A1);
 DigitalIn p2_in(A0);
 
@@ -996,11 +1000,51 @@
     }
 }
 
+void update_m7() {
+    int w = SX_MAX-SX_MIN;
+    int h = SY_MAX-SY_MIN;
+    float c = cosf(m7_theta);
+    float s = sinf(m7_theta);
+    for (int y = 0; y < h; y++) {
+        for (int x = 0; x < w; x++) {
+            float xx, yy;
+            yy = y;
+            xx = (x-w/2)*(h-yy)/h+w/2;
+            xx = xx * (float) mapWidth / w - m7_x;
+            yy = yy * (float) mapHeight / h - 2*m7_y;
+
+            float xx_old = xx;
+            float yy_old = yy;
+            xx = xx_old*c-yy_old*s;
+            yy = xx_old*s+yy_old*c;
+            xx *= 1.0f;
+            yy *= 1.0f;
+            
+            xx += m7_x;
+            yy += m7_y;
+
+            if (xx < 0 || xx >= mapWidth+1 || yy < 0 || yy > mapHeight+1) {
+                im_line_va[H_RES*(SY_MIN+y)+x+SX_MIN] = 0;
+            } else if (worldMap[(int)yy][(int)xx] == 0) {
+                im_line_va[H_RES*(SY_MIN+y)+x+SX_MIN] = 0;
+            } else {
+                im_line_va[H_RES*(SY_MIN+y)+x+SX_MIN] = 1;
+            }
+        }
+    }
+    int cmd1 = p1_in.read();
+    int cmd2 = p2_in.read();
+    if (!cmd1) m7_theta+=0.03f;
+    if (!cmd2) m7_theta-=0.03f;
+}
+
 int main() {
     potato:
     init_buffers();
     t.attach_us(&isr,63);
     
+    for(;;){update_m7();}
+    
     int bmi = 0;
     
     for(int y = SY_MIN; y < SY_MIN + BY2; y++)
@@ -1012,27 +1056,6 @@
         }
     }
     
-    /*
-    dispchr(4, BY2+1, chr_P);
-    dispchr(11, BY2+1, chr_A);
-    dispchr(18, BY2+1, chr_N);
-    dispchr(25, BY2+1, chr_G);
-    
-    dispchr(4, BY2+9, chr_F);
-    dispchr(11, BY2+9, chr_A);
-    dispchr(18, BY2+9, chr_S);
-    dispchr(25, BY2+9, chr_H);
-    
-    dispchr(4, BY2+17, chr_D);
-    dispchr(11, BY2+17, chr_A);
-    dispchr(18, BY2+17, chr_M);
-    dispchr(25, BY2+17, chr_O);
-    
-    dispchr(4, BY2+25, chr_D);
-    dispchr(11, BY2+25, chr_R);
-    dispchr(18, BY2+25, chr_A);
-    dispchr(25, BY2+25, chr_V);
-    */
     int cursor_pos = 0;
     int menu_offs = 0;