foxygit / fake-08-xbox360 Log in
commit 681ea794b26d803e254f4ad8cc2002004421de7f
Author:     Jon Bell <jondbell@protonmail.com>
AuthorDate: Fri Apr 10 21:56:43 2020 -0600
Commit:     Jon Bell <jondbell@protonmail.com>
CommitDate: Fri Apr 10 21:56:43 2020 -0600

    Migrate to cpp and implement print
---
 source/{fakecart.c => fakecart.cpp} |   7 +-
 source/fontdata.cpp                 | 132 ++++++++++++++++++++++++++++++++++++
 source/fontdata.h                   | 127 +---------------------------------
 source/{graphics.c => graphics.cpp} |  99 ++++++++++++++++++---------
 source/graphics.h                   |  26 ++++---
 source/{main.c => main.cpp}         |  11 ++-
 source/picointernals.cpp            |  12 ++++
 source/picointernals.h              |   1 +
 8 files changed, 240 insertions(+), 175 deletions(-)

diff --git a/source/fakecart.c b/source/fakecart.cpp
similarity index 90%
rename from source/fakecart.c
rename to source/fakecart.cpp
index 6ab5448..84e4b75 100644
--- a/source/fakecart.c
+++ b/source/fakecart.cpp
@@ -1,4 +1,3 @@
-#include <3ds.h>

 #include "graphics.h"

@@ -25,7 +24,9 @@ void _draw() {

     cls();

-    rectfill(0, 0, 127, 127, 10);
+    rectfill(0, 0, 127, 127, 0);
+
+    print("abcdefghijklmnopqrstuvwxyz", 0, 0, 7);

     rectfill(50, -1, 60, 10, 11);

@@ -48,6 +49,8 @@ void _draw() {
     circ(90, 90, 30, 8);

     circfill(100, 100, 15, 9);
+
+    print("test str", 64, 64, 7);
 }

 void _update() {
diff --git a/source/fontdata.cpp b/source/fontdata.cpp
new file mode 100644
index 0000000..961dd7d
--- /dev/null
+++ b/source/fontdata.cpp
@@ -0,0 +1,132 @@
+
+//taken from tac08: https://github.com/0xcafed00d/tac08
+#include <string>
+
+const char* font_ss_str = R"(77700000000000000000000000000000000000000000000000700000700000007770000000000000707000000000000000000000000000007070000007000000
+77700000777000007770000070700000707000007070000007700000770000007000000000700000777000000000000000000000000000007070000070700000
+77700000777000007070000007000000000000007070000077700000777000007000000000700000070000000700000000000000000000000000000007000000
+77700000777000007770000070700000707000007070000007700000770000007000000000700000777000000000000070000000770000000000000000000000
+77700000000000000000000000000000000000000000000000700000700000000000000077700000070000000000000007000000770000000000000000000000
+00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
+00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
+00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
+00000000070000007070000070700000777000007070000077000000070000000700000007000000707000000000000000000000000000000000000000700000
+00000000070000007070000077700000770000000070000077000000700000007000000000700000070000000700000000000000000000000000000007000000
+00000000070000000000000070700000077000000700000077000000000000007000000000700000777000007770000000000000777000000000000007000000
+00000000000000000000000077700000777000007000000070700000000000007000000000700000070000000700000007000000000000000000000007000000
+00000000070000000000000070700000070000007070000077700000000000000700000007000000707000000000000070000000000000000700000070000000
+00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
+00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
+00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
+77700000770000007770000077700000707000007770000070000000777000007770000077700000000000000000000000700000000000007000000077700000
+70700000070000000070000000700000707000007000000070000000007000007070000070700000070000000700000007000000777000000700000000700000
+70700000070000007770000007700000777000007770000077700000007000007770000077700000000000000000000070000000000000000070000007700000
+70700000070000007000000000700000007000000070000070700000007000007070000000700000070000000700000007000000777000000700000000000000
+77700000777000007770000077700000007000007770000077700000007000007770000000700000000000007000000000700000000000007000000007000000
+00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
+00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
+00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
+07000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
+70700000777000007700000077700000770000007770000077700000777000007070000077700000777000007070000070000000777000007700000007700000
+70700000707000007700000070000000707000007700000077000000700000007070000007000000070000007700000070000000777000007070000070700000
+70000000777000007070000070000000707000007000000070000000707000007770000007000000070000007070000070000000707000007070000070700000
+07700000707000007770000077700000770000007770000070000000777000007070000077700000770000007070000077700000707000007070000077000000
+00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
+00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
+00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
+00000000000000000000000000000000000000000000000000000000000000000000000000000000000000007700000070000000077000000700000000000000
+77700000070000007770000007700000777000007070000070700000707000007070000070700000777000007000000007000000007000007070000000000000
+70700000707000007070000070000000070000007070000070700000707000000700000077700000007000007000000007000000007000000000000000000000
+77700000770000007700000000700000070000007070000077700000777000007070000000700000700000007000000007000000007000000000000000000000
+70000000077000007070000077000000070000000770000007000000777000007070000077700000777000007700000000700000077000000000000077700000
+00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
+00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
+00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
+07000000777000007770000007700000770000007770000077700000077000007070000077700000777000007070000070000000777000007700000007700000
+00700000707000007070000070000000707000007000000070000000700000007070000007000000070000007070000070000000777000007070000070700000
+00000000777000007700000070000000707000007700000077000000700000007770000007000000070000007700000070000000707000007070000070700000
+00000000707000007070000070000000707000007000000070000000707000007070000007000000070000007070000070000000707000007070000070700000
+00000000707000007770000007700000777000007770000070000000777000007070000077700000770000007070000077700000707000007070000077000000
+00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
+00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
+00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
+77700000070000007770000007700000777000007070000070700000707000007070000070700000777000000770000007000000770000000000000000000000
+70700000707000007070000070000000070000007070000070700000707000007070000070700000007000000700000007000000070000000070000007000000
+77700000707000007700000077700000070000007070000070700000707000000700000077700000070000007700000007000000077000007770000070700000
+70000000770000007070000000700000070000007070000077700000777000007070000000700000700000000700000007000000070000007000000070700000
+70000000077000007070000077000000070000000770000007000000777000007070000077700000777000000770000007000000770000000000000077700000
+00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
+00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
+00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
+77777770707070707000007007777700700070000070000000777000077077000077700000777000007770000777770077777770000777000777770000070000
+77777770070707007777777077000770007000700077770007770700077777000770770000777000077777007770077070777070000700007700077000777000
+77777770707070707077707077000770700070000077700007777700077777007770777007777700777777707700077077777770000700007707077007777700
+77777770070707007077707077707770007000700777700007777700007770000770770000777000070707007770077070000070077700007700077000777000
+77777770707070700777770007777700700070000000700000777000000700000077700000707000070777000777770077777770077700000777770000070000
+00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
+00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
+00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
+00000000077777000007000007777700077777000000000000000000077777007777777070707070077700007000000000777000000700000777007007000700
+00000000770077700077700000777000777077707070000070007000770707700000000070707070007000007000700000000000077770000070000077777070
+70707070770007707777777000070000770007700700707007070700777077707777777070707070077770007000070007777700000700000777770007007000
+00000000770077700777770000777000770007700000070000700070770707700000000070707070707707007070070000000700007007007070007007007000
+00000000077777000700070007777700077777000000000000000000077777007777777070707070077007000700000000077000070770000770070007070000
+00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
+00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
+00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
+00777000000077000700070007770000077777000700000000070000070070000077770000700000007000000077770007777700000700000700077007077770
+07777700007700000707777000007000000700000700000007777700077777000000700007770000777777007700007000007000000777007777000007000070
+00777000070000000700070000000000077700000700000000070000070070000777777000707700007770000000007000070000007000000700070007000000
+07000000007700000700070007000000700000000700070000770000070000000007000007000000000077000000070000070000070000007007770007070000
+00777000000077000700700000777700077770000077700000070000007770000000777007007770077770000007700000007000007777000007707007007770
+00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
+00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
+00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
+70070000070077000077770007007000770007000077000000000000707777000077700007700000007007000707000007777000007007000707770000070000
+07777700770700700707007007077700070007700000000000770000700070000777770000700700077700700077770000700000077777700770707000077700
+77070070077000707007007007007000070007000007000007007000707777000007000007777770007000000707707007777000007007700700707000070000
+70770770770007707007007007077700070007000707070070000700700770000777700007700700077000700770007000700070000700000000770007777000
+07700770070007700770070007077070007770007077007000000070707707700077070000007000007777000000770000077700000700000007000007700700
+00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
+00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
+00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
+00070000070000000077770000700000007777000700770007770000070000000000000000000000000000000000000007777700000077000007000000777000
+07000000070007000000700007707700000070007707007000700770077700000000000007070000007000000700000000000700077700000777770000070000
+07777700070007000077777000770700007777700770007000777000070070000777000077777000777700000777000000707000000700000000070000070000
+00000700007007000700777007700700070000707700070000070700700070700000700007077000707070000700000000700000000700000000700000070000
+00777000000070000000770000700770000077000700700000077770700077000007000000700000707700007077700007000000000700000077000007777700
+00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
+00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
+00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
+00007000007000000070000000700000007000000777770000700700000700000777770000700000070007000077777000777000070700700077700000700000
+07777770077777000777700000777700007777700000070007777770070070000000070007777770007007000070007000070000070700700000000000700000
+00077000007007000007000007000700070070000000070000700700007000000000700000700700000007000700707007777700000007000777770000777000
+07707000070007000777770000007000000070000000070000000700000007700007700000700000000070000000077000070000000070000007000000700700
+00077000070077000007000000070000000700000777770000007000007770000770070000077700000700000000700000700000007700000070000000700000
+00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
+00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
+00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
+00070000000000000777770000070000000007000000700007000000077777000077000000070000077777000077770000070000000000700777770000707770
+07777700007770000000070007777700000007000070070007007700000007000700700007777700000007000000000000700000000707000007000007770070
+00070000000000000007070000000700000070000070070007770000000007007000070000070000007070000777770000700700000070000777777000700700
+00070000000000000000770077777070000700000700007007000000000070000000007007070700000700000000000007000770000707700007000000070000
+00700000077777000077000000070000077000000700007000777700007700000000000070770070000070000777700007777070077000000000777000070000
+00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
+00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
+00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
+00077770077770000077700000700700007070000700000007777770077777000777770070000000000000000000000000000000000000000007000000070000
+00000070000070000000000000700700007070000700000007000070070007000000070007000000707070000700000000000000077700000070000000007000
+00000700077777000777770000700700007070000700000007000070000007000777770000007000000070007777700007770000077770007700077077000770
+00000700000070000000070000000700007070700700770007000070000070000000070000070000000700000700700000070000000700000000700000700000
+00777770077770000007700000077000070077000777000007777770000700000007700077700000077000000070000007777000077700000007000000070000
+00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
+00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
+00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
+00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
+00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
+00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
+00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000)";
+
+std::string get_font_data() {
+    return font_ss_str;
+}
\ No newline at end of file
diff --git a/source/fontdata.h b/source/fontdata.h
index ba483a6..ae6f424 100644
--- a/source/fontdata.h
+++ b/source/fontdata.h
@@ -1,126 +1,3 @@
+#include <string>

-//taken from tac08: https://github.com/0xcafed00d/tac08
-static const char FONT_SS_STR[] = "(77700000000000000000000000000000000000000000000000700000700000007770000000000000707000000000000000000000000000007070000007000000\
-77700000777000007770000070700000707000007070000007700000770000007000000000700000777000000000000000000000000000007070000070700000\
-77700000777000007070000007000000000000007070000077700000777000007000000000700000070000000700000000000000000000000000000007000000\
-77700000777000007770000070700000707000007070000007700000770000007000000000700000777000000000000070000000770000000000000000000000\
-77700000000000000000000000000000000000000000000000700000700000000000000077700000070000000000000007000000770000000000000000000000\
-00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
-00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
-00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
-00000000070000007070000070700000777000007070000077000000070000000700000007000000707000000000000000000000000000000000000000700000\
-00000000070000007070000077700000770000000070000077000000700000007000000000700000070000000700000000000000000000000000000007000000\
-00000000070000000000000070700000077000000700000077000000000000007000000000700000777000007770000000000000777000000000000007000000\
-00000000000000000000000077700000777000007000000070700000000000007000000000700000070000000700000007000000000000000000000007000000\
-00000000070000000000000070700000070000007070000077700000000000000700000007000000707000000000000070000000000000000700000070000000\
-00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
-00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
-00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
-77700000770000007770000077700000707000007770000070000000777000007770000077700000000000000000000000700000000000007000000077700000\
-70700000070000000070000000700000707000007000000070000000007000007070000070700000070000000700000007000000777000000700000000700000\
-70700000070000007770000007700000777000007770000077700000007000007770000077700000000000000000000070000000000000000070000007700000\
-70700000070000007000000000700000007000000070000070700000007000007070000000700000070000000700000007000000777000000700000000000000\
-77700000777000007770000077700000007000007770000077700000007000007770000000700000000000007000000000700000000000007000000007000000\
-00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
-00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
-00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
-07000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
-70700000777000007700000077700000770000007770000077700000777000007070000077700000777000007070000070000000777000007700000007700000\
-70700000707000007700000070000000707000007700000077000000700000007070000007000000070000007700000070000000777000007070000070700000\
-70000000777000007070000070000000707000007000000070000000707000007770000007000000070000007070000070000000707000007070000070700000\
-07700000707000007770000077700000770000007770000070000000777000007070000077700000770000007070000077700000707000007070000077000000\
-00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
-00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
-00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
-00000000000000000000000000000000000000000000000000000000000000000000000000000000000000007700000070000000077000000700000000000000\
-77700000070000007770000007700000777000007070000070700000707000007070000070700000777000007000000007000000007000007070000000000000\
-70700000707000007070000070000000070000007070000070700000707000000700000077700000007000007000000007000000007000000000000000000000\
-77700000770000007700000000700000070000007070000077700000777000007070000000700000700000007000000007000000007000000000000000000000\
-70000000077000007070000077000000070000000770000007000000777000007070000077700000777000007700000000700000077000000000000077700000\
-00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
-00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
-00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
-07000000777000007770000007700000770000007770000077700000077000007070000077700000777000007070000070000000777000007700000007700000\
-00700000707000007070000070000000707000007000000070000000700000007070000007000000070000007070000070000000777000007070000070700000\
-00000000777000007700000070000000707000007700000077000000700000007770000007000000070000007700000070000000707000007070000070700000\
-00000000707000007070000070000000707000007000000070000000707000007070000007000000070000007070000070000000707000007070000070700000\
-00000000707000007770000007700000777000007770000070000000777000007070000077700000770000007070000077700000707000007070000077000000\
-00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
-00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
-00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
-77700000070000007770000007700000777000007070000070700000707000007070000070700000777000000770000007000000770000000000000000000000\
-70700000707000007070000070000000070000007070000070700000707000007070000070700000007000000700000007000000070000000070000007000000\
-77700000707000007700000077700000070000007070000070700000707000000700000077700000070000007700000007000000077000007770000070700000\
-70000000770000007070000000700000070000007070000077700000777000007070000000700000700000000700000007000000070000007000000070700000\
-70000000077000007070000077000000070000000770000007000000777000007070000077700000777000000770000007000000770000000000000077700000\
-00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
-00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
-00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
-77777770707070707000007007777700700070000070000000777000077077000077700000777000007770000777770077777770000777000777770000070000\
-77777770070707007777777077000770007000700077770007770700077777000770770000777000077777007770077070777070000700007700077000777000\
-77777770707070707077707077000770700070000077700007777700077777007770777007777700777777707700077077777770000700007707077007777700\
-77777770070707007077707077707770007000700777700007777700007770000770770000777000070707007770077070000070077700007700077000777000\
-77777770707070700777770007777700700070000000700000777000000700000077700000707000070777000777770077777770077700000777770000070000\
-00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
-00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
-00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
-00000000077777000007000007777700077777000000000000000000077777007777777070707070077700007000000000777000000700000777007007000700\
-00000000770077700077700000777000777077707070000070007000770707700000000070707070007000007000700000000000077770000070000077777070\
-70707070770007707777777000070000770007700700707007070700777077707777777070707070077770007000070007777700000700000777770007007000\
-00000000770077700777770000777000770007700000070000700070770707700000000070707070707707007070070000000700007007007070007007007000\
-00000000077777000700070007777700077777000000000000000000077777007777777070707070077007000700000000077000070770000770070007070000\
-00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
-00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
-00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
-00777000000077000700070007770000077777000700000000070000070070000077770000700000007000000077770007777700000700000700077007077770\
-07777700007700000707777000007000000700000700000007777700077777000000700007770000777777007700007000007000000777007777000007000070\
-00777000070000000700070000000000077700000700000000070000070070000777777000707700007770000000007000070000007000000700070007000000\
-07000000007700000700070007000000700000000700070000770000070000000007000007000000000077000000070000070000070000007007770007070000\
-00777000000077000700700000777700077770000077700000070000007770000000777007007770077770000007700000007000007777000007707007007770\
-00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
-00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
-00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
-70070000070077000077770007007000770007000077000000000000707777000077700007700000007007000707000007777000007007000707770000070000\
-07777700770700700707007007077700070007700000000000770000700070000777770000700700077700700077770000700000077777700770707000077700\
-77070070077000707007007007007000070007000007000007007000707777000007000007777770007000000707707007777000007007700700707000070000\
-70770770770007707007007007077700070007000707070070000700700770000777700007700700077000700770007000700070000700000000770007777000\
-07700770070007700770070007077070007770007077007000000070707707700077070000007000007777000000770000077700000700000007000007700700\
-00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
-00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
-00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
-00070000070000000077770000700000007777000700770007770000070000000000000000000000000000000000000007777700000077000007000000777000\
-07000000070007000000700007707700000070007707007000700770077700000000000007070000007000000700000000000700077700000777770000070000\
-07777700070007000077777000770700007777700770007000777000070070000777000077777000777700000777000000707000000700000000070000070000\
-00000700007007000700777007700700070000707700070000070700700070700000700007077000707070000700000000700000000700000000700000070000\
-00777000000070000000770000700770000077000700700000077770700077000007000000700000707700007077700007000000000700000077000007777700\
-00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
-00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
-00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
-00007000007000000070000000700000007000000777770000700700000700000777770000700000070007000077777000777000070700700077700000700000\
-07777770077777000777700000777700007777700000070007777770070070000000070007777770007007000070007000070000070700700000000000700000\
-00077000007007000007000007000700070070000000070000700700007000000000700000700700000007000700707007777700000007000777770000777000\
-07707000070007000777770000007000000070000000070000000700000007700007700000700000000070000000077000070000000070000007000000700700\
-00077000070077000007000000070000000700000777770000007000007770000770070000077700000700000000700000700000007700000070000000700000\
-00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
-00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
-00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
-00070000000000000777770000070000000007000000700007000000077777000077000000070000077777000077770000070000000000700777770000707770\
-07777700007770000000070007777700000007000070070007007700000007000700700007777700000007000000000000700000000707000007000007770070\
-00070000000000000007070000000700000070000070070007770000000007007000070000070000007070000777770000700700000070000777777000700700\
-00070000000000000000770077777070000700000700007007000000000070000000007007070700000700000000000007000770000707700007000000070000\
-00700000077777000077000000070000077000000700007000777700007700000000000070770070000070000777700007777070077000000000777000070000\
-00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
-00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
-00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
-00077770077770000077700000700700007070000700000007777770077777000777770070000000000000000000000000000000000000000007000000070000\
-00000070000070000000000000700700007070000700000007000070070007000000070007000000707070000700000000000000077700000070000000007000\
-00000700077777000777770000700700007070000700000007000070000007000777770000007000000070007777700007770000077770007700077077000770\
-00000700000070000000070000000700007070700700770007000070000070000000070000070000000700000700700000070000000700000000700000700000\
-00777770077770000007700000077000070077000777000007777770000700000007700077700000077000000070000007777000077700000007000000070000\
-00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
-00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
-00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
-00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
-00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
-00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\
-00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000)";
+std::string get_font_data();
\ No newline at end of file
diff --git a/source/graphics.c b/source/graphics.cpp
similarity index 67%
rename from source/graphics.c
rename to source/graphics.cpp
index 6e4ce1d..9e5637a 100644
--- a/source/graphics.c
+++ b/source/graphics.cpp
@@ -1,25 +1,12 @@
 #include <math.h>
-#include <3ds.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <string>

 #include "graphics.h"
-#include "fontdata.h"


-/*
-typedef struct Point{
-	char X;
-	char Y;
-};
-
-typedef struct Dimensions{
-	char Width;
-	char Height;
-};
-*/
-
 const Color BgGray = BG_GRAY_COLOR;

 const Color PaletteColors[] = {
@@ -44,38 +31,66 @@ const Color PaletteColors[] = {

 uint8_t _pico8_fb[128*128];

-GraphicsState _graphicsState;
+static GraphicsState _graphicsState;

 SpriteSheet _fontSpriteSheet;

-void copy_data_to_sprites(SpriteSheet *sprites, const char* data, size_t datalength, bool bits8) {
+void copy_data_to_sprites(SpriteSheet *sprites, std::string data) {
 	uint16_t i = 0;

-	for (size_t n = 0; n < datalength; n++) {
+	for (size_t n = 0; n < data.length(); n++) {
 		char buf[3] = {0};

 		if (data[n] > ' ') {
 			buf[0] = data[n++];
 			buf[1] = data[n];
 			uint8_t val = (uint8_t)strtol(buf, NULL, 16);
-			if (bits8) {
-				sprites->sprite_data[i++] = val;
-			} else {
-				sprites->sprite_data[i++] = val >> 4;
-				sprites->sprite_data[i++] = val & 0x0f;
-			}
+
+			sprites->sprite_data[i++] = val >> 4;
+			sprites->sprite_data[i++] = val & 0x0f;
 		}
 	}
 }

+
 //call initialize to make sure defaults are correct
-void initPico8Graphics() {
-	_graphicsState.bgColor = 0;
-	_graphicsState.color = 7;
+void initPico8Graphics(std::string fontdata) {

-	copy_data_to_sprites(&_fontSpriteSheet, FONT_SS_STR, sizeof(FONT_SS_STR), false);
+	copy_data_to_sprites(&_fontSpriteSheet, fontdata);
 }

+//based on tac08 implementation of blitter()
+void copySpriteToScreen(
+	uint8_t spritebuffer[],
+	short scr_x,
+	short scr_y,
+	short spr_x,
+	short spr_y,
+	short spr_w,
+	short spr_h,
+	bool flip_x = false,
+	bool flip_y = false)
+{
+
+	//note: no clipping yet
+	short scr_w = spr_w;
+	short scr_h = spr_h;
+
+	short dy = 1;
+
+	for (short y = 0; y < scr_h; y++) {
+		uint8_t* spr = spritebuffer + ((spr_y + y * dy) & 0x7f) * 128;
+
+		for (short x = 0; x < scr_w; x++) {
+			uint8_t c = spr[(spr_x + x) & 0x7f];
+			if (c != 0) { //if not transparent. Come back later to add palt() support by checking tranparency palette
+				pset(scr_x + x, scr_y + y, c); //set color on framebuffer. Come back later and add pal() by translating color
+			}
+		}
+	}
+}
+
+
 //start helper methods
 void swap(short *x, short *y) {
    short temp;
@@ -126,6 +141,7 @@ uint8_t pget(short x, short y){
 	return 0;
 }

+
 void color(uint8_t col){
 	_graphicsState.color = col;
 }
@@ -231,12 +247,34 @@ void rectfill(short x1, short y1, short x2, short y2, uint8_t col) {
 	}
 }

-void print(char* str, size_t strlength, short x, short y, uint8_t col){
+//tac08
+short print(std::string str, short x, short y, uint16_t c) {
+	_graphicsState.text_x = x;
+
+	for (size_t n = 0; n < str.length(); n++) {
+		uint8_t ch = str[n];
+		if (ch >= 0x10 && ch < 0x80) {
+			short index = ch - 0x10;
+			copySpriteToScreen(_fontSpriteSheet.sprite_data, x, y, (index % 16) * 8, (index / 16) * 8, 4, 5);
+			x += 4;
+		} else if (ch >= 0x80) {
+			short index = ch - 0x80;
+			copySpriteToScreen(_fontSpriteSheet.sprite_data, x, y, (index % 16) * 8, (index / 16) * 8 + 56, 8, 5);
+			x += 8;
+		} else if (ch == '\n') {
+			x = _graphicsState.text_x;
+			y += 6;
+		}
+	}

+	_graphicsState.text_x = 0;
+	_graphicsState.text_y = y + 6;
+
+	return x;
 }

-void flipBuffer(u8* fb) {
-	int x, y;
+void flipBuffer(uint8_t* fb) {
+	short x, y;
     for(x = 0; x < 400; x++) {
     	for(y = 0; y < 240; y++) {
 			if (x < 128 && y < 128) {
@@ -251,4 +289,3 @@ void flipBuffer(u8* fb) {
     }
 }

-
diff --git a/source/graphics.h b/source/graphics.h
index 9cd4c80..616c002 100644
--- a/source/graphics.h
+++ b/source/graphics.h
@@ -1,4 +1,5 @@

+#include <string>

 #define COLOR_00 {  0,   0,   0, 255}
 #define COLOR_01 { 29,  43,  83, 255}
@@ -20,24 +21,27 @@
 #define BG_GRAY_COLOR {128, 128, 128, 255}


-typedef struct {
+struct Color {
 	char Red;
 	char Green;
 	char Blue;
 	char Alpha;
-} Color;
+};

-typedef struct {
-    uint8_t color;
-    uint8_t bgColor;
-} GraphicsState;
+struct GraphicsState{
+    uint8_t color = 7;
+    uint8_t bgColor = 0;

-typedef struct {
+    short text_x = 0;
+	short text_y = 0;
+};
+
+struct SpriteSheet{
 	uint8_t sprite_data[128 * 128];
 	uint8_t flags[256];
-} SpriteSheet;
+};

-void initPico8Graphics();
+void initPico8Graphics(std::string fontdata);

 void cls();

@@ -54,4 +58,6 @@ void circfill(short ox, short oy, short r, uint8_t col);
 void rect(short x1, short y1, short x2, short y2, uint8_t col);
 void rectfill(short x1, short y1, short x2, short y2, uint8_t col);

-void flipBuffer(u8* fb);
\ No newline at end of file
+short print(std::string str, short x, short y, uint16_t c);
+
+void flipBuffer(uint8_t* fb);
\ No newline at end of file
diff --git a/source/main.c b/source/main.cpp
similarity index 77%
rename from source/main.c
rename to source/main.cpp
index 372caa2..a6681f5 100644
--- a/source/main.c
+++ b/source/main.cpp
@@ -1,7 +1,3 @@
-/*
-	Hello World example made by Aurelio Mannara for ctrulib
-	This code was modified for the last time on: 12/12/2014 21:00 UTC+1
-*/


 #include <3ds.h>
@@ -11,13 +7,14 @@

 #include "graphics.h"
 #include "fakecart.h"
+#include "picointernals.h"

-int main(int argc, char **argv)
+int main(int argc, char* argv[])
 {
 	int frames = 0;
 	gfxInitDefault();

-	initPico8Graphics();
+	initPicoInternals();

 	consoleInit(GFX_BOTTOM, NULL);

@@ -40,7 +37,7 @@ int main(int argc, char **argv)

 		_update();

-		u8* fb = gfxGetFramebuffer(GFX_TOP, GFX_LEFT, NULL, NULL);
+		uint8_t* fb = gfxGetFramebuffer(GFX_TOP, GFX_LEFT, NULL, NULL);
 		//clear whole framebuffer
 		memset(fb, 192, 240*400*3);

diff --git a/source/picointernals.cpp b/source/picointernals.cpp
new file mode 100644
index 0000000..fad26a8
--- /dev/null
+++ b/source/picointernals.cpp
@@ -0,0 +1,12 @@
+#include <string>
+
+#include "picointernals.h"
+#include "graphics.h"
+#include "fontdata.h"
+
+void initPicoInternals() {
+    auto fontdata = get_font_data();
+
+    initPico8Graphics(fontdata);
+
+}
\ No newline at end of file
diff --git a/source/picointernals.h b/source/picointernals.h
new file mode 100644
index 0000000..26b9aad
--- /dev/null
+++ b/source/picointernals.h
@@ -0,0 +1 @@
+void initPicoInternals();
\ No newline at end of file