Selaa lähdekoodia

Platform: interrupt abstraction

Streetwalrus Einstein 10 vuotta sitten
vanhempi
commit
5254e4ed76

+ 13 - 0
platform/include/Quirks.h

@@ -0,0 +1,13 @@
+#ifndef INCLUDE_QUIRKS_H
+#define INCLUDE_QUIRKS_H
+
+namespace WalrusRPG
+{
+    namespace Quirks
+    {
+        void init();
+        void deinit();
+    }
+}
+
+#endif

+ 1 - 1
platform/nspire/Interrupts.cpp

@@ -1,7 +1,7 @@
 #include "Interrupts.h"
 #include "CXfb.h"
 
-#define INTERRUPTS WalrusRPG::Interrupts
+#define INTERRUPTS Nspire::Interrupts
 
 #define INTERRUPT_CONTROLLER 0xDC000000
 volatile uint32_t *irq_status = (uint32_t *) (INTERRUPT_CONTROLLER + 0x0);

+ 1 - 1
platform/include/Interrupts.h → platform/nspire/Interrupts.h

@@ -1,7 +1,7 @@
 #ifndef INCLUDE_INTERRUPTS_H
 #define INCLUDE_INTERRUPTS_H
 
-namespace WalrusRPG
+namespace Nspire
 {
     namespace Interrupts
     {

+ 15 - 0
platform/nspire/Quirks.cpp

@@ -0,0 +1,15 @@
+#include "Quirks.h"
+#include "Interrupts.h"
+
+#define QUIRKS WalrusRPG::Quirks
+using namespace Nspire;
+
+void QUIRKS::init()
+{
+    Interrupts::init();
+}
+
+void QUIRKS::deinit()
+{
+    Interrupts::off();
+}

+ 3 - 3
src/engine/main.cpp

@@ -1,7 +1,7 @@
 #include "StateMachine.h"
 #include "Timing.h"
 #include "Graphics.h"
-#include "Interrupts.h"
+#include "Quirks.h"
 #include "map/Map.h"
 #include "map/StateMap.h"
 #include "render/Pixel.h"
@@ -16,7 +16,7 @@ int main(int argc, char *argv[])
 
     Graphics::init();
     Timing::init();
-    Interrupts::init();
+    Quirks::init();
 
     uint16_t dungeonTest[] = {
         21, 21,  1,   1,   1,   1,   21,  22,  21,  22, 21,  22,  21,  21,  1,   22,  21,
@@ -80,7 +80,7 @@ int main(int argc, char *argv[])
     StateMachine machine(new States::StateMap(0, 0, map));
     machine.run();
 
-    Interrupts::off();
+    Quirks::deinit();
     Timing::deinit();
     Graphics::deinit();
     return 0;

+ 0 - 5
src/map/Map.cpp

@@ -1,5 +1,3 @@
-#include <cstdio>
-#include "Interrupts.h"
 #include "Map.h"
 #include "render/TileRenderer.h"
 #include "Graphics.h"
@@ -42,9 +40,6 @@ void MAP::render(WalrusRPG::Camera &camera, unsigned dt)
     signed offset_y = camera.get_y() % t_height * -1 - (camera.get_y() < 0) * t_height;
     signed start_x = camera.get_x() / t_width - (camera.get_x() < 0);
     signed start_y = camera.get_y() / t_height - (camera.get_y() < 0);
-    Interrupts::off();
-    printf("%i %i\n", start_x, start_y);
-    Interrupts::init();
 
     // pre-calculating variables to speed up loop condition check
     signed delta_x = 320 / t_width + 1;