Selaa lähdekoodia

Proof of concept prototype. Lacks a lot of things, like timing and alternative to exceptions.

Eiyeron Fulmincendii 9 vuotta sitten
vanhempi
commit
f4b6c0bb18

+ 1 - 1
Makefile

@@ -15,7 +15,7 @@ CFLAGS = $(CFLAGS_COMMON) -std=gnu11
 CPPFLAGS = $(CFLAGS_COMMON) -std=gnu++11
 
 LIBS = -lz
-LDFLAGS = $(CFLAGS_COMMON) -fuse-ld=gold
+LDFLAGS = 
 
 SRCS_C :=
 SRCS_CPP :=

+ 0 - 0
WalrusRPG.map


+ 1 - 0
external/lodepng

@@ -0,0 +1 @@
+platform/nspire/lodepng/

+ 4 - 0
external/rules.mk

@@ -2,5 +2,9 @@ external_LOCAL_PATH := $(call whereami)
 
 include $(wildcard $(external_LOCAL_PATH)/*/rules.mk)
 
+CPPFLAGS += -DLODEPNG_NO_COMPILE_CPP
+INCLUDE_EXT += $(external_LOCAL_PATH)/lodepng
+SRCS_CPP += $(external_LOCAL_PATH)/lodepng/lodepng.cpp
+
 INCLUDE_EXT += $(external_LOCAL_PATH)/tinystl/include
 

+ 1 - 1
mkconfig

@@ -1,6 +1,6 @@
 #!/bin/bash
 
-TARGET_LIST=("nspire" "sfml")
+TARGET_LIST=("nspire" "sfml" "3ds")
 
 create_configuration() {
 	echo "Creating $1 configuration"

+ 159 - 0
platform/3ds/Graphics.cpp

@@ -0,0 +1,159 @@
+#include "Graphics.h"
+#include "render/Pixel.h"
+#include "utility/Rect.h"
+#include "Logger.h"
+#include "utility/misc.h"
+#include "utility/minmax.h"
+#include <3ds.h>
+#include <sf2d.h>
+
+using namespace WalrusRPG; /*::Graphics*/
+using WalrusRPG::Graphics::Pixel;
+using WalrusRPG::Utils::Rect;
+
+sf2d_rendertarget* target = nullptr;
+
+inline u32 pixel2u32(const Pixel &pix)
+{
+  return RGBA8(pix.r<<3, pix.g<<2, pix.b<<3, 0xFF);
+}
+
+namespace {
+  constexpr int OFFSET_X = 40;
+  constexpr int OFFSET_Y = 0;
+  void set_scissor()
+  {
+    sf2d_set_scissor_test(GPU_SCISSOR_NORMAL, 80, 0, 320, 240);
+  }
+}
+
+void Graphics::init()
+{
+    // Logger::log("Graphics init");
+    sf2d_init();
+  	sf2d_set_clear_color(0);
+  	sf2d_set_3D(0);
+    sf2d_set_vblank_wait(1);
+    set_scissor();
+}
+
+void Graphics::deinit()
+{
+    Logger::log("Graphics deinit");
+    sf2d_free_target(target);
+    sf2d_fini();
+}
+
+void Graphics::frame_begin()
+{
+  sf2d_start_frame(GFX_TOP, GFX_LEFT);
+}
+
+void Graphics::frame_end()
+{
+  sf2d_draw_rectangle(0, 0, OFFSET_X, 240, 0xFF000000);
+  sf2d_draw_rectangle(320+OFFSET_X, 0, OFFSET_X, 240, 0xFF000000);
+  sf2d_end_frame();
+  sf2d_swapbuffers();
+}
+
+void Graphics::put_sprite(const Texture &sheet, int x, int y, const Rect &window)
+{
+    sf2d_draw_texture_part(sheet.data, x+OFFSET_X, y+OFFSET_Y, window.x, window.y, window.width, window.height);
+}
+
+void Graphics::put_sprite_tint(const Texture &sheet, int x, int y, const Rect &window,
+                               const Pixel &color)
+{
+  sf2d_draw_texture_part_blend(sheet.data, x+OFFSET_X, y+OFFSET_Y, window.x, window.y, window.width, window.height, pixel2u32(color));
+}
+
+void Graphics::put_sprite_clipping(const Texture &sheet, int x, int y,
+                                   const Rect &sprite_window, const Rect &clipping_window)
+{
+  sf2d_set_scissor_test(GPU_SCISSOR_NORMAL, clipping_window.x+OFFSET_X, clipping_window.y+OFFSET_Y, clipping_window.width, clipping_window.height);
+  sf2d_draw_texture_part(sheet.data, x, y, sprite_window.x, sprite_window.y, sprite_window.width, sprite_window.height);
+  set_scissor();
+}
+
+
+void Graphics::fill(const Pixel &color)
+{
+    sf2d_clear_target(target, pixel2u32(color));
+}
+
+void Graphics::put_pixel(uint16_t x, uint16_t y, const Pixel &color)
+{
+  sf2d_set_pixel(&(target->texture), x+OFFSET_X, y+OFFSET_Y, pixel2u32(color));
+}
+
+void Graphics::put_horizontal_line(uint16_t x, uint16_t x2, uint16_t y,
+                                   const Pixel &color)
+{
+  // Because sf2dlib has issues with lines, let's port Nspire's functions.
+  if (x > x2)
+  {
+      uint16_t temp = x;
+      x = x2;
+      x2 = temp;
+  }
+  for (; x <= x2; x++)
+  {
+      put_pixel(x+OFFSET_X, y+OFFSET_Y, color);
+  }
+}
+
+void Graphics::put_vertical_line(uint16_t x, uint16_t y, uint16_t y2, const Pixel &color)
+{
+  // Because sf2dlib has issues with lines, let's port Nspire's functions.
+  if (y > y2)
+  {
+      uint16_t temp = y;
+      y = y2;
+      y2 = temp;
+  }
+  for (; y <= y2; y++)
+  {
+      put_pixel(x+OFFSET_X, y+OFFSET_Y, color);
+  }}
+
+void Graphics::put_line(uint16_t x, uint16_t y, uint16_t x2, uint16_t y2,
+                        const Pixel &color)
+{
+  // Because sf2dlib has issues with lines, let's port Nspire's functions.
+  if (x == x2)
+  {
+      put_vertical_line(x+OFFSET_X, y+OFFSET_Y, y2+OFFSET_Y, color);
+      return;
+  }
+  else if (y == y2)
+  {
+      put_horizontal_line(x+OFFSET_X, x2+OFFSET_X, y+OFFSET_Y, color);
+      return;
+  }
+  int dx = abs(x - x2), sx = x < x2 ? 1 : -1;
+  int dy = abs(y - y2), sy = y < y2 ? 1 : -1;
+  int err = (dx > dy ? dx : -dy) / 2, e2;
+
+  for (;;)
+  {
+      put_pixel(x+OFFSET_X, y+OFFSET_Y, color);
+      if (x == x2 && y == y2)
+          break;
+      e2 = err;
+      if (e2 > -dx)
+      {
+          err -= dy;
+          x += sx;
+      }
+      if (e2 < dy)
+      {
+          err += dx;
+          y += sy;
+      }
+  }}
+
+void Graphics::put_rectangle(const Rect &rect, const Pixel &color)
+{
+  sf2d_draw_rectangle(rect.x+OFFSET_X, rect.y+OFFSET_Y, rect.width, rect.height, pixel2u32(color));
+}

+ 72 - 0
platform/3ds/Logger.cpp

@@ -0,0 +1,72 @@
+#include "Logger.h"
+#include <stdio.h>
+#include <stdarg.h>
+#include <time.h>
+#include <3ds/console.h>
+
+using namespace WalrusRPG;
+
+namespace
+{
+    PrintConsole* console;
+    // TODO : Find a better name
+    /**
+     * Prints the timestamp and the message category/type.
+     */
+    void print_premessage(const char *type)
+    {
+        char date_buffer[256];
+        time_t now = time(0);
+        strftime(date_buffer, 256, "%H:%M:%S", localtime(&now));
+        printf("%s %5s : ", date_buffer, type);
+    }
+}
+
+// NOTE : I really wish there would be a better way to handle these stupid va_lists. So
+// much redundant code...
+
+void Logger::init()
+{
+  console = consoleInit(GFX_BOTTOM, NULL);
+}
+
+void Logger::log(const char *fmt, ...)
+{
+
+    print_premessage("  [LOG]");
+    va_list args;
+    va_start(args, fmt);
+    vprintf(fmt, args);
+    va_end(args);
+    puts("");
+}
+
+void Logger::debug(const char *fmt, ...)
+{
+    print_premessage("[DEBUG]");
+    va_list args;
+    va_start(args, fmt);
+    vprintf(fmt, args);
+    va_end(args);
+    puts("");
+}
+
+void Logger::warn(const char *fmt, ...)
+{
+    print_premessage(" [WARN]");
+    va_list args;
+    va_start(args, fmt);
+    vprintf(fmt, args);
+    va_end(args);
+    puts("");
+}
+
+void Logger::error(const char *fmt, ...)
+{
+    print_premessage("[ERROR]");
+    va_list args;
+    va_start(args, fmt);
+    vprintf(fmt, args);
+    va_end(args);
+    puts("");
+}

+ 51 - 0
platform/3ds/Quirks.cpp

@@ -0,0 +1,51 @@
+#include "Quirks.h"
+#include <cstddef>
+#include <cstring>
+#include <memory>
+#include "Logger.h"
+
+using namespace WalrusRPG;
+
+void Quirks::init(const char *argv_0)
+{
+  WalrusRPG::Logger::log("Quirks init");
+}
+
+void Quirks::deinit()
+{
+  WalrusRPG::Logger::log("Quirks deinit");
+}
+
+std::unique_ptr<char> Quirks::solve_absolute_path(const char *path)
+{
+  std::unique_ptr<char> result(new char[strlen(path) + 1]);
+  strcpy(result.get(), path);
+  return result;
+}
+
+#include <stdlib.h>
+#include <unistd.h>  /* for write(), also available on Windows */
+extern "C" void* emulate_cc_new(unsigned len) { \
+  void *p = malloc(len);
+  if (p == 0) {
+    /* Don't use stdio (e.g. fputs), because that may want to allocate more
+     * memory.
+     */
+    (void)!write(2, "out of memory\n", 14);
+    abort();
+  }
+  return p;
+}
+extern "C" void emulate_cc_delete(void* p) {
+  if (p != 0)
+    free(p);
+}
+void* operator new  (unsigned len) __attribute__((alias("emulate_cc_new")));
+void* operator new[](unsigned len) __attribute__((alias("emulate_cc_new")));
+void  operator delete  (void* p)   __attribute__((alias("emulate_cc_delete")));
+void  operator delete[](void* p)   __attribute__((alias("emulate_cc_delete")));
+
+extern "C" void __cxa_pure_virtual()
+{
+  //while (1);
+}

+ 54 - 0
platform/3ds/Texture.cpp

@@ -0,0 +1,54 @@
+#include "Texture.h"
+#include <cstdint>
+#include <cstdlib>
+#include <cstring>
+#include "utility/misc.h"
+#include "render/Pixel.h"
+#include "lodepng.h"
+#include <3ds.h>
+#include <sf2d.h>
+
+using namespace WalrusRPG::Graphics; /*Texture*/
+using WalrusRPG::Graphics::Pixel;
+using WalrusRPG::PIAF::File;
+using WalrusRPG::Utils::Rect;
+
+#include "Logger.h"
+
+Texture::Texture(char *data) : data()
+{
+    uint16_t *data_16 = (uint16_t *) data;
+    this->data = sf2d_create_texture(data_16[0], data_16[1], TEXFMT_RGB565, SF2D_PLACE_VRAM);
+    memcpy(this->data->data, &data_16[3], data_16[0]*data_16[1]*sizeof(uint16_t));
+}
+
+Texture::Texture(WalrusRPG::PIAF::File entry)
+{
+  unsigned char *pic;
+  unsigned width, height;
+
+  signed result =
+  lodepng_decode32(&pic, &width, &height, (unsigned char *) entry.get(),
+  entry.file_size);
+
+  data = sf2d_create_texture_mem_RGBA8(pic, width, height, TEXFMT_RGBA8, SF2D_PLACE_RAM);
+
+  Logger::debug("Ready : %p", data);
+  free(pic);
+}
+
+Texture::~Texture()
+{
+  sf2d_free_texture(data);
+}
+
+const Rect Texture::get_dimensions()
+{
+  return {0, 0, data->width, data->height};
+}
+
+const Pixel Texture::get_pixel(unsigned x, unsigned y)
+{
+  u32 pixel = sf2d_get_pixel(data, x, y);
+    return Pixel(RGBA8_GET_R(pixel), RGBA8_GET_G(pixel), RGBA8_GET_B(pixel));
+}

+ 20 - 0
platform/3ds/Timing.cpp

@@ -0,0 +1,20 @@
+#include "Timing.h"
+#include "Logger.h"
+#include <cstdio>
+
+using namespace WalrusRPG; /*Timing*/
+
+void Timing::init()
+{
+    Logger::log("Timing init");
+}
+
+void Timing::deinit()
+{
+    Logger::log("Timing deinit");
+}
+
+unsigned Timing::gettime()
+{
+  return 1;
+}

+ 13 - 0
platform/3ds/public/platform.h

@@ -0,0 +1,13 @@
+#ifndef INCLUDE_PLATFORM_H
+#define INCLUDE_PLATFORM_H
+
+#include <cstdint>
+#include <3ds.h>
+#include <sf2d.h>
+
+#define TIMER_FREQ 32768
+
+typedef sf2d_texture* texture_data_t;
+typedef unsigned keycode_t;
+
+#endif

+ 27 - 0
platform/3ds/rules.mk

@@ -0,0 +1,27 @@
+tds_LOCAL_PATH := $(call whereami)
+include $(DEVKITARM)/3ds_rules
+
+SRCS_C += $(wildcard $(tds_LOCAL_PATH)/platform/*.c)
+SRCS_CPP += $(wildcard $(tds_LOCAL_PATH)/*.cpp)
+INCLUDE += $(tds_LOCAL_PATH)/public
+
+LIBDIRS	:= $(CTRULIB) $(CURDIR)/../libsf2d $(PORTLIBS)
+INCLUDE_EXT += $(sfml_LOCAL_PATH)/public $(foreach dir,$(LIBDIRS),$(dir)/include)
+
+ARCH = -march=armv6k -mtune=mpcore -mfloat-abi=hard
+
+LIBS = -lm -lctru -lsf2d -lz
+LDFLAGS += -specs=3dsx.specs -g -march=armv6k -mtune=mpcore -mfloat-abi=hard $(ARCH) -Wl,--gc-sections,-Map,$(notdir $*.map) $(foreach dir,$(LIBDIRS),-L$(dir)/lib)
+
+CFLAGS_COMMON += -DTARGET_3DS=1 -DARM11 -D_3DS -fno-rtti -fno-exceptions
+
+APP_TITLE		:= SF2DLIB sample
+APP_DESCRIPTION	:= SF2DLIB sample
+APP_AUTHOR		:= xerpi
+
+CC = arm-none-eabi-gcc
+CPP = arm-none-eabi-g++
+
+EXE = $(OUT)/$(NAME).3dsx
+
+run: all

+ 2 - 1
platform/include/Logger.h

@@ -6,6 +6,7 @@ namespace WalrusRPG
     // eventually in a file (for nspire?)
     namespace Logger
     {
+        void init();
         void log(const char *fmt, ...);
         void debug(const char *fmt, ...);
         void warn(const char *fmt, ...);
@@ -13,4 +14,4 @@ namespace WalrusRPG
     }
 }
 
-#endif
+#endif

+ 2 - 2
platform/sfml/rules.mk

@@ -8,8 +8,8 @@ LIBS += -lstdc++ -lsfml-window -lsfml-graphics -lsfml-system
 
 CFLAGS_COMMON += -DTARGET_SFML=1
 
-CC = clang
-CPP = clang++
+CC = gcc
+CPP = g++
 
 EXE = $(OUT)/$(NAME)
 

+ 4 - 4
rules.mk

@@ -15,16 +15,16 @@ RELEASE_MISC_FILES=$(addprefix $(RELEASE_DIRECTORY)/, $(notdir $(MISC_FILES)))
 $(OUT)/%.o: %.c | $(BUILT_SRCS)
 	@echo "CC: $@"
 	@mkdir -p $(dir $@)
-	@$(CC) $(CFLAGS) -c $< -o $@
+	$(CC) $(CFLAGS) -c $< -o $@
 
 %.o: %.c | $(BUILT_SRCS)
 	@echo "CC: $@"
-	@$(CC) $(CFLAGS) -c $< -o $@
+	$(CC) $(CFLAGS) -c $< -o $@
 
 $(OUT)/%.o: %.cpp | $(BUILT_SRCS)
 	@echo "CPP: $@"
 	@mkdir -p $(dir $@)
-	@$(CPP) $(CPPFLAGS) -c $< -o $@
+	$(CPP) $(CPPFLAGS) -c $< -o $@
 
 %.o: %.cpp | $(BUILT_SRCS)
 	@echo "CPP: $@"
@@ -33,7 +33,7 @@ $(OUT)/%.o: %.cpp | $(BUILT_SRCS)
 $(ELF): $(OBJS)
 	@mkdir -p $(dir $@)
 	@echo "CCLD: $@"
-	@+$(CC) $(LDFLAGS) $(LIBS) $^ -o $(ELF)
+	+$(CC) $(LDFLAGS) $^ $(LIBS) -o $(ELF)
 
 clean:
 	@echo "RM: $(OUT)"

+ 14 - 5
src/engine/main.cpp

@@ -14,19 +14,26 @@ using WalrusRPG::PIAF::Archive;
 using WalrusRPG::Graphics::Texture;
 using namespace WalrusRPG::Graphics;
 
+
 int main(int argc, char *argv[])
 {
     UNUSED(argc);
-    Logger::log("WalrusRPG Init");
+
     Graphics::init();
+    Logger::init();
+    Logger::log("WalrusRPG Init");
     Timing::init();
     Quirks::init(argv[0]);
-    Text::init();
 
+    Logger::debug("Before Text");
+    Text::init();
+    Logger::debug("Text done");
+    Logger::debug("Before Archive");
     Archive arc("data/wip_data.wrf");
     Texture tex(arc.get("ov.png"));
     WalrusRPG::PIAF::File f1 = arc.get("l1.bin");
     WalrusRPG::PIAF::File f2 = arc.get("l2.bin");
+    Logger::debug("Files ready");
 
     const uint8_t *l1 = f1.get();
     const uint8_t *l2 = f2.get();
@@ -57,12 +64,14 @@ int main(int argc, char *argv[])
 
     Logger::log("WalrusRPG Deinit");
     StateMachine::deinit();
+    Text::deinit();
+
     Quirks::deinit();
     Timing::deinit();
-    Graphics::deinit();
-    delete[] dungeonTest;
-    delete[] dungeonTest2;
+    // delete[] dungeonTest;
+    // delete[] dungeonTest2;
     Logger::log("WalrusRPG Exit");
+    Graphics::deinit();
 
     return 0;
 }

+ 43 - 5
src/input/Input.cpp

@@ -43,6 +43,20 @@ static InputMap key_map[] = {
     {Key::K_START, KEY_NSPIRE_DOC}, {Key::K_SELECT, KEY_NSPIRE_ESC},
 };
 #endif
+#ifdef TARGET_3DS
+static InputMap key_map[] = {
+    {Key::K_A, KEY_A},    {Key::K_B, KEY_B},
+    {Key::K_L, KEY_L},     {Key::K_R, KEY_R},
+
+    {Key::K_UP, KEY_UP},      {Key::K_DOWN, KEY_DOWN},
+    {Key::K_LEFT, KEY_LEFT},    {Key::K_RIGHT, KEY_RIGHT},
+
+    {Key::K_START, KEY_START}, {Key::K_SELECT, KEY_SELECT},
+};
+u32 kDown = 0;
+u32 kHeld = 0;
+u32 kUp = 0;
+#endif
 
 KeyState Input::key_get_state(Key key)
 {
@@ -62,26 +76,50 @@ KeyState Input::key_get_state(Key key)
 
 void Input::key_poll()
 {
-    for (unsigned i = 0; i < K_SIZE; i++)
-    {
-        key_states[i].previous = key_states[i].current;
-        key_states[i].current = WalrusRPG::Quirks::get_key(key_map[i].key_code);
-    }
+  #ifdef TARGET_3DS
+    hidScanInput();
+    kDown = hidKeysDown();
+    kHeld = hidKeysHeld();
+    kUp = hidKeysUp();
+  #else
+  for (unsigned i = 0; i < K_SIZE; i++)
+  {
+      key_states[i].previous = key_states[i].current;
+      key_states[i].current = WalrusRPG::Quirks::get_key(key_map[i].key_code);
+  }
+  #endif
 }
 
 bool Input::key_pressed(Key key)
 {
+  #ifdef TARGET_3DS
+    return kDown & key_map[key].key_code;
+  #else
     return !key_states[key].previous && key_states[key].current;
+  #endif
 }
+
 bool Input::key_released(Key key)
 {
+  #ifdef TARGET_3DS
+    return kUp & key_map[key].key_code;
+  #else
     return key_states[key].previous && !key_states[key].current;
+  #endif
 }
 bool Input::key_down(Key key)
 {
+  #ifdef TARGET_3DS
+    return kHeld & key_map[key].key_code;
+  #else
     return key_states[key].current;
+  #endif
 }
 bool Input::key_up(Key key)
 {
+  #ifdef TARGET_3DS
+    return !(~kDown & key_map[key].key_code);
+  #else
     return !key_states[key].current;
+  #endif
 }

+ 2 - 0
src/map/StateMap.cpp

@@ -3,6 +3,7 @@
 #include "input/Input.h"
 #include "render/Text.h"
 #include "piaf/Archive.h"
+#include "Logger.h"
 
 using WalrusRPG::States::StateMap;
 using namespace WalrusRPG;
@@ -39,6 +40,7 @@ StateMap::StateMap(int x, int y, Map &map)
       tex_haeccity(data.get("t_haecci")), txt(tex_haeccity, data.get("f_haecci")),
       box(txt)
 {
+  Logger::debug("Start");
     box.set_text((
         char *) "Hello world! I am "
                 "\xFF\x01\xf0\x00\x00Howard\xFF\x01\xff\xff\x00"

+ 26 - 16
src/piaf/Archive.cpp

@@ -76,7 +76,8 @@ Archive::Archive(const char *filepath)
     // Null pointer exception trigger
     if (filepath == nullptr)
     {
-        throw PIAF::PIAFException("%s: Null path given", __FILE__);
+      Logger::error("%s: Null path given", __FILE__);
+      //throw PIAF::PIAFException("%s: Null path given", __FILE__);
     }
     // Solves the absolute path for given relative path.
     // Must be needed in targets like Ndless as it doesn't support environment
@@ -88,7 +89,8 @@ Archive::Archive(const char *filepath)
     // Again another null pointer trigger
     if (file == nullptr || file == NULL)
     {
-        throw PIAF::PIAFException("%s: Missing file : %s", __FILE__, filepath);
+      Logger::error("%s: Missing file : %s", __FILE__, filepath);
+        //throw PIAF::PIAFException("%s: Missing file : %s", __FILE__, filepath);
     }
 
     // Loading stuff happens NOW
@@ -99,8 +101,10 @@ Archive::Archive(const char *filepath)
     // File to small exception trigger
     if (filesize < 32)
     {
-        throw PIAF::PIAFException("%s: File too small (%s): %d", __FILE__, filepath,
+        Logger::error("%s: File too small (%s): %d", __FILE__, filepath,
                                   filesize);
+        //throw PIAF::PIAFException("%s: File too small (%s): %d", __FILE__, filepath,
+        //                          filesize);
     }
 
     // Tempoary buffer to contain the header.
@@ -108,15 +112,16 @@ Archive::Archive(const char *filepath)
     // Read the headers and trigger exceptions on errors
     if (fread(header_container, sizeof(char), 32, file) != 32)
     {
-        throw PIAF::PIAFException("%s: Errorneous header : %s", __FILE__, filepath);
+        Logger::error("%s: Errorneous header : %s", __FILE__, filepath);
+        //throw PIAF::PIAFException("%s: Errorneous header : %s", __FILE__, filepath);
     }
     // Check if the magic cookie is the same.
     // It's a first way to detect if the file is correctly an archive.
     if (strncmp(header_container, "WRPGPIAF", 8) != 0)
     {
         // TODO throw bad header
-        // fprintf(stderr, "Bad header magic word\n");
-        throw PIAF::PIAFException("%s: Magic cookie mismatch : %s", __FILE__, filepath);
+        Logger::error("%s: Magic cookie mismatch : %s", __FILE__, filepath);
+        //throw PIAF::PIAFException("%s: Magic cookie mismatch : %s", __FILE__, filepath);
     }
     // Checksum time! Let's check if the header hasn"t been altered.
     uint32_t expected_checksum = read_big_endian_value<uint32_t>(&header_container[8]);
@@ -124,9 +129,8 @@ Archive::Archive(const char *filepath)
     if (expected_checksum != calculated_checksum)
     {
         // TODO throw bad checksum
-        // fprintf(stderr, "Bad header checksum : %x != %x\n", expected_checksum,
-        // calculated_checksum);
-        throw PIAF::PIAFException("%s: Bad checksum : %s", __FILE__, filepath);
+        Logger::error("%s: Bad checksum : %s", __FILE__, filepath);
+        //throw PIAF::PIAFException("%s: Bad checksum : %s", __FILE__, filepath);
     }
 
     // TODO : version checking
@@ -135,8 +139,10 @@ Archive::Archive(const char *filepath)
     {
         // std::exception up;
         // throw up; // haha
-        throw PIAF::PIAFException("%s: Wrong(%s) : %08x is not supported by %08x",
-                                  __FILE__, filepath, version, ARCHIVE_VERSION);
+        Logger::error("%s: Wrong(%s) : %08x is not supported by %08x",
+                                 __FILE__, filepath, version, ARCHIVE_VERSION);
+        //throw PIAF::PIAFException("%s: Wrong(%s) : %08x is not supported by %08x",
+        //                          __FILE__, filepath, version, ARCHIVE_VERSION);
     }
 
 
@@ -153,7 +159,8 @@ Archive::Archive(const char *filepath)
     {
         // fprintf(stderr, "Bad data size : expected %u, got %lld\n", data_size,
         // calculated_data_size);
-        throw PIAF::PIAFException("Data size mismatch", __LINE__, filepath);
+        Logger::error("Data size mismatch", __LINE__, filepath);
+        //throw PIAF::PIAFException("Data size mismatch", __LINE__, filepath);
     }
     // Check if there are files to manage.
     if (nb_files != 0)
@@ -166,14 +173,16 @@ Archive::Archive(const char *filepath)
         fseek(file, 32, SEEK_SET);
         if (fread(file_entry_data, sizeof(char), 24 * nb_files, file) < 24 * nb_files)
         {
-            throw PIAF::PIAFException("Can't read file entry data", __LINE__, filepath);
+           Logger::error("Can't read file entry data", __LINE__, filepath);
+          //  throw PIAF::PIAFException("Can't read file entry data", __LINE__, filepath);
         }
         // Compare and trigger an exception if the checksum doesn't match.
         if (expected_filetable_checksum !=
             crc32(0L, (unsigned char *) file_entry_data, 24 * nb_files))
         {
             // fprintf(stderr, "Bad filetable checksum\n");
-            throw PIAF::PIAFException("Bad Filetable checksum", __LINE__, filepath);
+           Logger::error("Bad Filetable checksum", __LINE__, filepath);
+          //  throw PIAF::PIAFException("Bad Filetable checksum", __LINE__, filepath);
         }
         // Create the filetable.
         entries = new File[nb_files];
@@ -195,6 +204,7 @@ Archive::Archive(const char *filepath)
 #if TARGET_NSPIRE
     Interrupts::init();
 #endif
+  Logger::debug("File done");
 }
 
 Archive::~Archive()
@@ -248,8 +258,8 @@ File Archive::get(const char *filename)
                 if (fread(data, sizeof(uint8_t), entries[index].file_size, file) !=
                     entries[index].file_size)
                 {
-                    throw PIAF::PIAFException("%s: couldn't load %s from an archive.",
-                                              filename);
+                  //  throw PIAF::PIAFException("%s: couldn't load %s from an archive.",
+                  //                            filename);
                 }
                 else
                 {

+ 3 - 0
src/render/Text.cpp

@@ -20,8 +20,11 @@ void Text::init()
 {
     log("Text init.");
     Archive arc("data/wrpg_core.wrf");
+    debug("Loading Texure.");
     tex = new Texture(arc.get("t_dbgfnt"));
+    debug("Tex ready.");
     fnt = new Font(*tex, arc.get("f_dbgfnt"));
+    debug("Fnt ready.");
 }
 
 void Text::deinit()