浏览代码

Nspire : Statically initialized Archives doesn't load because of the QUirks path solver

Eiyeron Fulmincendii 9 年之前
父节点
当前提交
2ffdc65436
共有 4 个文件被更改,包括 53 次插入43 次删除
  1. 6 0
      platform/nspire/Interrupts.cpp
  2. 5 5
      src/engine/StateMachine.cpp
  3. 36 38
      src/map/StateMap.cpp
  4. 6 0
      src/map/StateMap.h

+ 6 - 0
platform/nspire/Interrupts.cpp

@@ -17,8 +17,12 @@ uint32_t interrupt_pointer_bkp;
 // Interrupt source 21 is the LCD
 #define INTERRUPT_MASK (1 << 21)
 
+static bool is_on = false;
+
 void INTERRUPTS::init()
 {
+    is_on = true;
+
     interrupt_select_bkp = *interrupt_select;
     *interrupt_select = 0; // All IRQ for now
 
@@ -41,6 +45,8 @@ void INTERRUPTS::init()
 
 void INTERRUPTS::off()
 {
+    if(!is_on) return;
+    is_on = false;
     // Disable IRQ in the CPU
     asm(
         "mrs r1, cpsr \n\t"

+ 5 - 5
src/engine/StateMachine.cpp

@@ -102,11 +102,11 @@ void STATEMACHINE::run()
             last_frame = frame_stamp;
 
             // Text::print_format(0, 0, "WalrusRPG test build %s", git_version);
-            // if (frame_time != 0 && update_time != 0)
-            // {
-            //     Text::print_format(0, 240 - 8, "%ufps, %uups", TIMER_FREQ / frame_time,
-            //                        TIMER_FREQ / update_time);
-            // }
+            if (frame_time != 0 && update_time != 0)
+            {
+                Text::print_format(0, 240 - 8, "%ufps, %uups", TIMER_FREQ / frame_time,
+                                   TIMER_FREQ / update_time);
+            }
             // draw_buttons();
             Graphics::frame_end();
         }

+ 36 - 38
src/map/StateMap.cpp

@@ -16,8 +16,6 @@ using WalrusRPG::Graphics::Texture;
 namespace
 {
 
-    Archive arc("data/haeccity.wrf");
-    Texture tex_haeccity(arc.get("haeccity"));
     // x, y, width, height, xoffset, yoffset
     const int16_t haeccity[][6] = {
         ///*32*/{0, 0, 0, 0},
@@ -247,7 +245,7 @@ namespace
 /*255*/{76, 23, 4, 8, 0, 2}
     };
 
-    const char haeccity_kernings[][3] = {
+    const int8_t haeccity_kernings[][3] = {
         {66, 74, -1},
         {67, 74, -1},
         {68, 74, -1},
@@ -337,42 +335,43 @@ namespace
         Text::print_format(0, 16, "MAP : W: %d, H:%d", map.get_width(), map.get_height());
     }
 
-    void putchar_haeccity(unsigned char c, unsigned x, unsigned y)
-    {
-            if(c <= 32) return;
-            c -= 33;
-            Rect letter{haeccity[c][0], haeccity[c][1], haeccity[c][2], haeccity[c][3]};
-            put_sprite(tex_haeccity, x + haeccity[c][4], y + haeccity[c][5], letter);        
-    }
+}
 
-    void putchar_haeccity_tint(unsigned char c, unsigned x, unsigned y, const Pixel& col)
-    {
-            if(c <= 32) return;
-            c -= 33;
-            Rect letter{haeccity[c][0], haeccity[c][1], haeccity[c][2], haeccity[c][3]};
-            put_sprite_tint(tex_haeccity, x + haeccity[c][4], y + haeccity[c][5], letter, col);  
-    }
+void STATEMAP::putchar_haeccity(unsigned char c, unsigned x, unsigned y)
+{
+        if(c <= 32) return;
+        c -= 33;
+        Rect letter{haeccity[c][0], haeccity[c][1], haeccity[c][2], haeccity[c][3]};
+        put_sprite(tex_haeccity, x + haeccity[c][4], y + haeccity[c][5], letter);        
+}
+
+void STATEMAP::putchar_haeccity_tint(unsigned char c, unsigned x, unsigned y, const Pixel& col)
+{
+        if(c <= 32) return;
+        c -= 33;
+        Rect letter{haeccity[c][0], haeccity[c][1], haeccity[c][2], haeccity[c][3]};
+        put_sprite_tint(tex_haeccity, x + haeccity[c][4], y + haeccity[c][5], letter, col);  
+}
 
 
-        void print_haeccity(const char *str, unsigned x, unsigned y, const Pixel& col = White)
+void STATEMAP::print_haeccity(const char *str, unsigned x, unsigned y, const Pixel& col = White)
+{
+    const bool must_tint = (col != White);
+    for(unsigned i = 0; str[i] && x < 320; i++)
     {
-        const bool must_tint = (col != White);
-        for(unsigned i = 0; str[i] && x < 320; i++)
-        {
-            unsigned char c = str[i];
-            if(c < 32) continue;
-            if(c == 32) {x+=2; continue;}
-            // printf("%c = %d\n", c, c);
-            if(must_tint)
-                putchar_haeccity_tint(c, x, y, col);
-            else
-                putchar_haeccity(c, x, y);
-            x += haeccity[c-33][2] +1;
-        }
+        unsigned char c = str[i];
+        if(c < 32) continue;
+        if(c == 32) {x+=2; continue;}
+        // printf("%c = %d\n", c, c);
+        if(must_tint)
+            putchar_haeccity_tint(c, x, y, col);
+        else
+            putchar_haeccity(c, x, y);
+        x += haeccity[c-33][2] +1;
     }
 }
 
-STATEMAP::StateMap(int x, int y, Map &map) : camera(x, y), map(map)
+STATEMAP::StateMap(int x, int y, Map &map) : camera(x, y), map(map), arc_haeccity("data/haeccity.wrf"), tex_haeccity(arc_haeccity.get("haeccity"))
 {
 }
 
@@ -383,8 +382,8 @@ void STATEMAP::update(unsigned dt)
 
 void STATEMAP::render(unsigned dt)
 {
-    fill(Black);
-    // map.render(camera, dt);
+    // fill(Black);
+    map.render(camera, dt);
 
     // print_debug_camera_data(camera);
     // print_debug_map_data(map);
@@ -393,15 +392,14 @@ void STATEMAP::render(unsigned dt)
     print_haeccity("This is a quick prototype to see if variable-wdith fonts works.", 0, 18);
     print_haeccity("Builting it myself allows me to make it work on calc too.", 0, 27, Yellow);
     print_haeccity("( I wonder if a conditionnal to tint the text slows down a lot the process. )", 0, 36, Gray);
+    print_haeccity("Oh well, I hope I'll get to do a pretty textbox like in games !", 0, 45);
 
-    print_haeccity("Oh well, I hope I'll get to do a pretty textbox like in games !", 0, 54);
-    /*
     for (int i = 0; i < 16; ++i)
     {
         for (int j = 0; j < 16; ++j)
         {
-            putchar_haeccity(16*j + i+32, 16*i, 16*j);
+            putchar_haeccity_tint(16*j + i+32, 6*i, 9*j + 54, Pixel(i*16, j*16, 255));
         }
     }
-    */
+    
 }

+ 6 - 0
src/map/StateMap.h

@@ -2,6 +2,7 @@
 #define INCLUDE_STATEMAP_H
 
 #include "engine/State.h"
+#include "piaf/Archive.h"
 #include "Map.h"
 
 namespace WalrusRPG
@@ -11,6 +12,8 @@ namespace WalrusRPG
         class StateMap : public State
         {
           protected:
+            WalrusRPG::PIAF::Archive arc_haeccity;
+            WalrusRPG::Graphics::Texture tex_haeccity;
             Camera camera;
             Map &map;
 
@@ -18,6 +21,9 @@ namespace WalrusRPG
             StateMap(int x, int y, Map &map);
             void render(unsigned dt);
             void update(unsigned dt);
+            void putchar_haeccity(unsigned char c, unsigned x, unsigned y);
+            void putchar_haeccity_tint(unsigned char c, unsigned x, unsigned y, const WalrusRPG::Graphics::Pixel& col);
+            void print_haeccity(const char *str, unsigned x, unsigned y, const WalrusRPG::Graphics::Pixel& col);
         };
     }
 }