From 4cdf43341d72dcf16c63a44e9eb7a6761797a046 Mon Sep 17 00:00:00 2001 From: Luc van den Brand <10974297+LucvandenBrand@users.noreply.github.com> Date: Wed, 12 Sep 2018 18:55:58 +0200 Subject: [PATCH 01/25] Created debug map for objects. --- .../assets/size16-terrain-objects/map.tmx | 32 ++++++++++++++++++ .../size16-terrain-objects/tileset.aseprite | Bin 0 -> 732 bytes .../assets/size16-terrain-objects/tileset.png | Bin 0 -> 802 bytes .../size16-terrain-objects/untitled.tsx | 11 ++++++ 4 files changed, 43 insertions(+) create mode 100644 examples/assets/size16-terrain-objects/map.tmx create mode 100644 examples/assets/size16-terrain-objects/tileset.aseprite create mode 100644 examples/assets/size16-terrain-objects/tileset.png create mode 100644 examples/assets/size16-terrain-objects/untitled.tsx diff --git a/examples/assets/size16-terrain-objects/map.tmx b/examples/assets/size16-terrain-objects/map.tmx new file mode 100644 index 0000000..09666f1 --- /dev/null +++ b/examples/assets/size16-terrain-objects/map.tmx @@ -0,0 +1,32 @@ + + + + + +1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, +1,3,3,3,3,3,3,3,3,3,3,3,3,3,3,1, +1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1, +1,2,2,4,2,1,2,2,2,2,2,2,2,2,2,1, +1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,1, +1,3,3,3,3,3,2,2,2,1,1,2,2,2,2,1, +1,2,2,2,2,2,2,2,2,1,1,2,2,2,2,1, +3,2,2,2,2,2,2,2,2,3,3,2,2,2,2,3, +2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, +2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, +2,2,2,2,2,2,2,2,2,1,2,2,2,2,2,2, +1,2,2,2,2,2,2,2,1,1,1,2,2,2,2,1, +1,1,1,1,2,2,2,2,3,1,3,2,2,2,2,1, +1,3,3,3,2,2,2,2,2,3,2,2,2,2,2,1, +1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1, +1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 + + + + + + + + + + + diff --git a/examples/assets/size16-terrain-objects/tileset.aseprite b/examples/assets/size16-terrain-objects/tileset.aseprite new file mode 100644 index 0000000000000000000000000000000000000000..fce3ce0e6de54b41fd4aa5dc121fc10d8289c82f GIT binary patch literal 732 zcmcJNZ%7ky9EX2vN-s=$(+eeJzfE&NFPtkKBiV@{{+VI_(7l;KOrtloA*nAyFsDH+4UtHeibdP}`MFGk-uFH3fxClyp6_uV4iNHb zP(kSLLqQ1PasC}j6!OjgHWv7QeNWi8F2IyZ=^vl!UoRs>Lr;N)$MZm&F&mUBPlF%r znP8~j2Clt+1V-0$!G~YYg2F2uXt>`Dnj5mf3Udai&ohD?*9z+DZhFxC`Be35r{gZp$kzcLXOKBmV%`A5YW{Z!uHi{ABQ+=8%5rhxVjTH!Zr{nZ8Kfn95TV z@wd>Jw04n?-nJ)=-w?W3{$jZ|qCK+W%8AcvVkKvo`|Z){XU^(n)>-Uy`D3Yfwhr_0 zM$<7#^D;QugSVzP_9?1TY@FX(WRAWISRK4wSdeBMj?d41eHQj)=tNW7z|_(PXAGB@ zUFaXt@|@|~xmnS&oe>a)r%qvB8W~jw#7jSwciEM+?KeTC_nT@sqMb|IT<6q=+dvflP8M~B7z=kPwp_cWG+U=a2a{}R3#E8*LYEFPO)=T}2TWTi^e32P z?3Q>)po1Yp4Nj+S84RJtQjjg0p~j(;i|y+mq)4((zLWYUo$lU!-+OoOeMi1lS7|Yy z1|Wzwl^<+s0S`6G8{WQ4bM2AD+mD_!%F~w1OV!L1$v{&?cCXEpzv{H z0o>k{=iBy?>c{#KzZc~TWb>5Rf2>>oVCZFZ(Bzo z0`4Z^PkMh$Q9YUBdgA@x)+pNA4Cy4$s>moQB)kztvHqB1^KcQ|ZPycE^Kgp(nEqb^ zv$+*HuT@W`n9b=80sB&knA@j2prMfmWuiNv-VBJ4@UK0(ms{~ zS{2!8$x>WBcjQ?iINg>*Gm%aLr`z6EEW6KC + + + + + + + + + + From 16e19830071e0c1bba084efc65dad57dffcf678c Mon Sep 17 00:00:00 2001 From: Luc van den Brand <10974297+LucvandenBrand@users.noreply.github.com> Date: Sun, 23 Sep 2018 10:52:56 +0200 Subject: [PATCH 02/25] Beginning of object converter. --- .../objectLayerConverter.cpp | 32 +++++++++++++++++++ .../objectLayerConverter.hpp | 26 +++++++++++++++ .../stringConverter/stringConverter.cpp | 29 +++++++++++++++++ .../stringConverter/stringConverter.hpp | 25 +++++++++++++++ 4 files changed, 112 insertions(+) create mode 100644 src/mapConverter/objectLayerConverter/objectLayerConverter.cpp create mode 100644 src/mapConverter/objectLayerConverter/objectLayerConverter.hpp create mode 100644 src/mapConverter/stringConverter/stringConverter.cpp create mode 100644 src/mapConverter/stringConverter/stringConverter.hpp diff --git a/src/mapConverter/objectLayerConverter/objectLayerConverter.cpp b/src/mapConverter/objectLayerConverter/objectLayerConverter.cpp new file mode 100644 index 0000000..2074bee --- /dev/null +++ b/src/mapConverter/objectLayerConverter/objectLayerConverter.cpp @@ -0,0 +1,32 @@ +#include "objectLayerConverter.hpp" +#include "../stringConverter/stringConverter.hpp" + +vector ObjectLayerConverter::convert(const tmx::ObjectGroup *objectGroup) { + return convert(objectGroup->getObjects()); +} + +vector ObjectLayerConverter::convert(const vector &objects) { + vector bytes; + for (const tmx::Object &object : objects) { + auto objectBytes = convert(object); + bytes.insert(bytes.end(), objectBytes.begin(), objectBytes.end()); + } + + return bytes; +} + +vector ObjectLayerConverter::convert(const tmx::Object &object) { + vector bytes; + + auto id = (uint16_t) object.getUID(); + bytes.push_back(id); + + StringConverter stringConverter; + vector nameBytes = stringConverter.convert(object.getName()); + bytes.insert(bytes.end(), nameBytes.begin(), nameBytes.end()); + + vector typeBytes = stringConverter.convert(object.getType()); + bytes.insert(bytes.end(), typeBytes.begin(), typeBytes.end()); + + return bytes; +} \ No newline at end of file diff --git a/src/mapConverter/objectLayerConverter/objectLayerConverter.hpp b/src/mapConverter/objectLayerConverter/objectLayerConverter.hpp new file mode 100644 index 0000000..fe58674 --- /dev/null +++ b/src/mapConverter/objectLayerConverter/objectLayerConverter.hpp @@ -0,0 +1,26 @@ +#ifndef OBJECT_LAYER_CONVERTER_H +#define OBJECT_LAYER_CONVERTER_H + +#include +#include "../../lib/tmxlite/ObjectGroup.hpp" + +using namespace std; + +/** + * Converts an Object Layer to binary data describing the objects. + */ +class ObjectLayerConverter { +public: + /** + * Convert an Object Layer. + * @param objectGroup The list of objects in the layer. + */ + vector convert(const tmx::ObjectGroup *objectGroup); + +private: + vector convert(const vector &objects); + vector convert(const tmx::Object &object); + +}; + +#endif // OBJECT_LAYER_CONVERTER_H \ No newline at end of file diff --git a/src/mapConverter/stringConverter/stringConverter.cpp b/src/mapConverter/stringConverter/stringConverter.cpp new file mode 100644 index 0000000..7b7a156 --- /dev/null +++ b/src/mapConverter/stringConverter/stringConverter.cpp @@ -0,0 +1,29 @@ +#include +#include "stringConverter.hpp" + +vector StringConverter::convert(const string &text) { + vector bytes; + + string paddedText = paddString(text); + auto numStringBytes = paddedText.length() + 1; + + char characters[numStringBytes]; + strcpy(characters, paddedText.c_str()); + + for (unsigned index = 0; index < numStringBytes; index += 2) { + auto mergedChar = (uint16_t) characters[index]; + mergedChar |= (uint16_t) characters[index+1] << 8; + bytes.push_back(mergedChar); + } + + return bytes; +} + +string StringConverter::paddString(string text) { + auto numStringBytes = text.length() + 1; + auto remainingBytes = 4 - numStringBytes % 4; + string appendedText = text; + appendedText.append(remainingBytes, ' '); + + return appendedText; +} \ No newline at end of file diff --git a/src/mapConverter/stringConverter/stringConverter.hpp b/src/mapConverter/stringConverter/stringConverter.hpp new file mode 100644 index 0000000..a9e7220 --- /dev/null +++ b/src/mapConverter/stringConverter/stringConverter.hpp @@ -0,0 +1,25 @@ +#ifndef STRING_CONVERTER_H +#define STRING_CONVERTER_H + +#include +#include + +using namespace std; + +/** + * Converts strings into binary data readable by the GBA. + */ +class StringConverter { +public: + /** + * Convert a string into a vector of 2-byte values. + * @param text The text to convert. + * @return A vector of 2-byte values. + */ + vector convert(const string &text); + +private: + string paddString(string text); +}; + +#endif \ No newline at end of file From 3b6d05453d741a1ad5d445cb499c3e3092dfa1b3 Mon Sep 17 00:00:00 2001 From: Luc van den Brand <10974297+LucvandenBrand@users.noreply.github.com> Date: Sun, 23 Sep 2018 11:18:43 +0200 Subject: [PATCH 03/25] Refactor to ease layer parsing. --- src/mapConverter/mapConverter.cpp | 39 ++++++++++++++++++++++++------- src/mapConverter/mapConverter.hpp | 5 ++++ 2 files changed, 36 insertions(+), 8 deletions(-) diff --git a/src/mapConverter/mapConverter.cpp b/src/mapConverter/mapConverter.cpp index e4448a8..54b746a 100644 --- a/src/mapConverter/mapConverter.cpp +++ b/src/mapConverter/mapConverter.cpp @@ -69,22 +69,45 @@ GBAMap MapConverter::convert(const string &name, const tmx::Map &tmxMap) { gbaMap.setTerrainMap(terrainMap); const auto& layers = tmxMap.getLayers(); - if (layers.size() > GBA_LAYERS) { - log(WARN, "This map has " + to_string(layers.size()) - + " layers, which is " + to_string(layers.size() - GBA_LAYERS) + const auto tileLayers = getTileLayers(layers); + if (tileLayers.size() > GBA_LAYERS) { + log(WARN, "This map has " + to_string(tileLayers.size()) + + "tile layers, which is " + to_string(tileLayers.size() - GBA_LAYERS) + " more than than the GBA has natively."); } auto *tileLayerConverter = new TileLayerConverter(tileSet.getFirstGID()); + for (const auto& tileLayer : tileLayers) { + log(INFO, "Converting layer '" + tileLayer->getName() + "'."); + auto tileLayerBytes = tileLayerConverter->convert(tileLayer, mapSize.x, mapSize.y, tileSize.x); + gbaMap.addTileLayer(tileLayerBytes); + } + + return gbaMap; +} + +vector MapConverter::getTileLayers(const vector &layers) { + vector tileLayers; + for (const auto& layer : layers) { if (layer->getType() != tmx::Layer::Type::Tile) continue; - - log(INFO, "Converting layer '" + layer->getName() + "'."); const auto tileLayer = dynamic_cast(layer.get()); - auto tileLayerBytes = tileLayerConverter->convert(tileLayer, mapSize.x, mapSize.y, tileSize.x); - gbaMap.addTileLayer(tileLayerBytes); + tileLayers.push_back(tileLayer); } - return gbaMap; + return tileLayers; +} + +vector MapConverter::getObjectLayers(const vector &layers) { + vector objectLayers; + + for (const auto& layer : layers) { + if (layer->getType() != tmx::Layer::Type::Object) + continue; + const auto tileLayer = dynamic_cast(layer.get()); + objectLayers.push_back(tileLayer); + } + + return objectLayers; } \ No newline at end of file diff --git a/src/mapConverter/mapConverter.hpp b/src/mapConverter/mapConverter.hpp index b9b146b..7145c53 100644 --- a/src/mapConverter/mapConverter.hpp +++ b/src/mapConverter/mapConverter.hpp @@ -3,6 +3,7 @@ #include "../lib/tmxlite/Map.hpp" #include "../gba/gbaMap/gbaMap.hpp" +#include "../lib/tmxlite/TileLayer.hpp" using namespace std; @@ -17,6 +18,10 @@ class MapConverter { * @return The GBA Map. */ GBAMap convert(const string &name, const tmx::Map &tmxMap); + +private: + vector getTileLayers(const vector &layers); + vector getObjectLayers(const vector &layers); }; #endif // MAP_CONVERTER_H \ No newline at end of file From d82babe7b1615aeb2bf82312e2f1b9e4fd98c561 Mon Sep 17 00:00:00 2001 From: Luc van den Brand <10974297+LucvandenBrand@users.noreply.github.com> Date: Sun, 30 Sep 2018 17:01:20 +0200 Subject: [PATCH 04/25] Improved string conversion for objects. --- examples/mapViewer/source/asset/map.c | 200 ++++++++++-------- examples/mapViewer/source/asset/map.h | 7 +- src/gba/gbaMap/gbaMap.cpp | 7 + src/gba/gbaMap/gbaMap.hpp | 9 +- src/mapConverter/mapConverter.cpp | 15 +- .../stringConverter/stringConverter.cpp | 40 ++-- .../stringConverter/stringConverter.hpp | 5 +- 7 files changed, 172 insertions(+), 111 deletions(-) diff --git a/examples/mapViewer/source/asset/map.c b/examples/mapViewer/source/asset/map.c index 9a99fce..1d90455 100644 --- a/examples/mapViewer/source/asset/map.c +++ b/examples/mapViewer/source/asset/map.c @@ -1,6 +1,6 @@ const unsigned short mapPalette[256] = { - 0x7c1f, 0x18e6, 0x3626, 0x6f0b, 0x3d65, 0x38e7, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x7c1f, 0x0557, 0x11bb, 0x47bf, 0x1bbe, 0x235a, 0x22da, 0x2276, 0x5c28, 0x6c8c, 0x0831, 0x1474, 0x019a, 0x0113, 0x0088, + 0x0001, 0x0156, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, @@ -19,103 +19,125 @@ const unsigned short mapPalette[256] = { 0x0000 }; -const unsigned short mapTileSet[288] = { - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, 0x0101, 0x0101, 0x0101, 0x0101, 0x0101, 0x0101, 0x0101, 0x0101, 0x0101, 0x0102, 0x0101, 0x0102, 0x0201, - 0x0201, 0x0201, 0x0201, 0x0202, 0x0202, 0x0202, 0x0202, 0x0102, 0x0202, 0x0202, 0x0202, 0x0202, 0x0202, 0x0201, 0x0102, - 0x0201, 0x0202, 0x0202, 0x0202, 0x0101, 0x0101, 0x0101, 0x0101, 0x0101, 0x0101, 0x0101, 0x0101, 0x0101, 0x0102, 0x0101, - 0x0102, 0x0201, 0x0201, 0x0201, 0x0201, 0x0202, 0x0202, 0x0202, 0x0202, 0x0202, 0x0202, 0x0102, 0x0202, 0x0202, 0x0201, - 0x0202, 0x0202, 0x0202, 0x0202, 0x0202, 0x0202, 0x0303, 0x0303, 0x0303, 0x0303, 0x0303, 0x0303, 0x0303, 0x0303, 0x0303, - 0x0303, 0x0303, 0x0303, 0x0303, 0x0303, 0x0303, 0x0303, 0x0303, 0x0303, 0x0303, 0x0303, 0x0303, 0x0303, 0x0303, 0x0303, - 0x0303, 0x0303, 0x0303, 0x0303, 0x0303, 0x0303, 0x0303, 0x0303, 0x0303, 0x0303, 0x0303, 0x0303, 0x0303, 0x0303, 0x0303, - 0x0303, 0x0303, 0x0303, 0x0303, 0x0303, 0x0303, 0x0303, 0x0303, 0x0303, 0x0303, 0x0303, 0x0303, 0x0303, 0x0303, 0x0303, - 0x0303, 0x0303, 0x0303, 0x0303, 0x0303, 0x0303, 0x0303, 0x0303, 0x0303, 0x0303, 0x0202, 0x0202, 0x0202, 0x0202, 0x0202, - 0x0102, 0x0202, 0x0202, 0x0202, 0x0202, 0x0202, 0x0202, 0x0202, 0x0202, 0x0202, 0x0202, 0x0202, 0x0202, 0x0202, 0x0202, - 0x0202, 0x0202, 0x0202, 0x0202, 0x0202, 0x0202, 0x0202, 0x0202, 0x0202, 0x0202, 0x0202, 0x0202, 0x0102, 0x0202, 0x0102, - 0x0202, 0x0202, 0x0202, 0x0202, 0x0202, 0x0202, 0x0202, 0x0202, 0x0102, 0x0202, 0x0202, 0x0202, 0x0202, 0x0202, 0x0202, - 0x0202, 0x0202, 0x0202, 0x0202, 0x0202, 0x0202, 0x0202, 0x0202, 0x0202, 0x0202, 0x0202, 0x0202, 0x0202, 0x0202, 0x0303, - 0x0303, 0x0303, 0x0303, 0x0303, 0x0303, 0x0303, 0x0303, 0x0303, 0x0303, 0x0303, 0x0303, 0x0303, 0x0303, 0x0303, 0x0303, - 0x0304, 0x0304, 0x0304, 0x0304, 0x0503, 0x0503, 0x0503, 0x0503, 0x0305, 0x0505, 0x0305, 0x0505, 0x0505, 0x0505, 0x0505, - 0x0505, 0x0303, 0x0303, 0x0303, 0x0303, 0x0303, 0x0303, 0x0303, 0x0303, 0x0303, 0x0303, 0x0303, 0x0303, 0x0303, 0x0303, - 0x0303, 0x0303, 0x0304, 0x0304, 0x0304, 0x0304, 0x0503, 0x0503, 0x0503, 0x0503, 0x0305, 0x0505, 0x0305, 0x0505, 0x0505, - 0x0505, 0x0505, 0x0505 +const unsigned short mapTileSet[544] = { + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0201, 0x0202, 0x0202, 0x0202, 0x0202, 0x0303, 0x0303, 0x0303, 0x0402, 0x0302, 0x0303, 0x0303, 0x0402, + 0x0204, 0x0303, 0x0303, 0x0402, 0x0404, 0x0302, 0x0303, 0x0402, 0x0404, 0x0204, 0x0303, 0x0402, 0x0404, 0x0404, 0x0302, + 0x0402, 0x0404, 0x0404, 0x0204, 0x0201, 0x0202, 0x0202, 0x0202, 0x0303, 0x0303, 0x0303, 0x0101, 0x0303, 0x0303, 0x0103, + 0x0105, 0x0303, 0x0303, 0x0501, 0x0105, 0x0303, 0x0103, 0x0505, 0x0105, 0x0303, 0x0501, 0x0505, 0x0105, 0x0103, 0x0505, + 0x0505, 0x0105, 0x0501, 0x0505, 0x0505, 0x0105, 0x0401, 0x0404, 0x0404, 0x0104, 0x0402, 0x0404, 0x0404, 0x0601, 0x0402, + 0x0404, 0x0104, 0x0606, 0x0402, 0x0404, 0x0601, 0x0606, 0x0402, 0x0104, 0x0606, 0x0606, 0x0402, 0x0701, 0x0606, 0x0606, + 0x0102, 0x0707, 0x0707, 0x0707, 0x0202, 0x0202, 0x0202, 0x0202, 0x0502, 0x0505, 0x0505, 0x0205, 0x0206, 0x0505, 0x0505, + 0x0105, 0x0606, 0x0502, 0x0505, 0x0105, 0x0606, 0x0206, 0x0505, 0x0105, 0x0606, 0x0606, 0x0502, 0x0105, 0x0606, 0x0606, + 0x0207, 0x0105, 0x0707, 0x0707, 0x0707, 0x0102, 0x0202, 0x0202, 0x0202, 0x0102, 0x0808, 0x0808, 0x0808, 0x0808, 0x0808, + 0x0909, 0x0909, 0x0909, 0x0908, 0x0809, 0x0909, 0x0908, 0x0908, 0x0909, 0x0909, 0x0909, 0x0908, 0x0908, 0x0809, 0x0909, + 0x0908, 0x0909, 0x0909, 0x0909, 0x0908, 0x0809, 0x0909, 0x0908, 0x0908, 0x0909, 0x0909, 0x0909, 0x0808, 0x0808, 0x0808, + 0x0808, 0x0909, 0x0909, 0x0909, 0x0808, 0x0809, 0x0909, 0x0908, 0x0809, 0x0909, 0x0909, 0x0909, 0x0809, 0x0908, 0x0809, + 0x0809, 0x0809, 0x0909, 0x0909, 0x0909, 0x0809, 0x0809, 0x0909, 0x0908, 0x0809, 0x0909, 0x0909, 0x0909, 0x0809, 0x0908, + 0x0908, 0x0908, 0x0909, 0x0908, 0x0909, 0x0909, 0x0908, 0x0908, 0x0809, 0x0909, 0x0909, 0x0908, 0x0909, 0x0809, 0x0909, + 0x0908, 0x0909, 0x0909, 0x0909, 0x0908, 0x0809, 0x0909, 0x0908, 0x0808, 0x0909, 0x0909, 0x0909, 0x0808, 0x0808, 0x0808, + 0x0808, 0x0908, 0x0909, 0x0908, 0x0809, 0x0909, 0x0908, 0x0909, 0x0809, 0x0909, 0x0909, 0x0809, 0x0809, 0x0908, 0x0809, + 0x0909, 0x0809, 0x0909, 0x0909, 0x0909, 0x0809, 0x0809, 0x0909, 0x0908, 0x0809, 0x0909, 0x0909, 0x0909, 0x0808, 0x0808, + 0x0808, 0x0808, 0x0808, 0x0701, 0x0607, 0x0606, 0x0606, 0x0702, 0x0606, 0x0606, 0x0606, 0x0602, 0x0606, 0x0606, 0x0606, + 0x0602, 0x0606, 0x0606, 0x0606, 0x0602, 0x0606, 0x0606, 0x0606, 0x0702, 0x0606, 0x0606, 0x0606, 0x0702, 0x0607, 0x0606, + 0x0606, 0x0208, 0x0202, 0x0202, 0x0202, 0x0606, 0x0606, 0x0706, 0x0207, 0x0606, 0x0606, 0x0606, 0x0107, 0x0606, 0x0606, + 0x0606, 0x0106, 0x0606, 0x0606, 0x0606, 0x0106, 0x0606, 0x0606, 0x0606, 0x0106, 0x0606, 0x0606, 0x0606, 0x0107, 0x0606, + 0x0606, 0x0706, 0x0107, 0x0202, 0x0202, 0x0202, 0x0802, 0x0808, 0x0808, 0x0808, 0x0808, 0x0808, 0x0909, 0x0909, 0x0908, + 0x0908, 0x0809, 0x0909, 0x0909, 0x0908, 0x0909, 0x0809, 0x0909, 0x0908, 0x0909, 0x0909, 0x0909, 0x0908, 0x0809, 0x0909, + 0x0908, 0x0808, 0x0909, 0x0909, 0x0909, 0x0808, 0x0808, 0x0808, 0x0808, 0x0808, 0x0808, 0x0808, 0x0808, 0x0909, 0x0908, + 0x0909, 0x0808, 0x0909, 0x0909, 0x0809, 0x0809, 0x0908, 0x0809, 0x0909, 0x0809, 0x0909, 0x0909, 0x0909, 0x0809, 0x0809, + 0x0909, 0x0908, 0x0809, 0x0909, 0x0909, 0x0909, 0x0808, 0x0808, 0x0808, 0x0808, 0x0808, 0x0b0a, 0x0b0b, 0x0b0b, 0x0b0b, + 0x0c0b, 0x0c0c, 0x0d0c, 0x0f0e, 0x0c0b, 0x100c, 0x110f, 0x1111, 0x0c0b, 0x1110, 0x1111, 0x1111, 0x0c0b, 0x110f, 0x1111, + 0x1111, 0x0d0b, 0x1111, 0x1111, 0x1111, 0x0e0b, 0x1111, 0x1111, 0x1111, 0x0f0b, 0x1111, 0x1111, 0x1111, 0x0b0a, 0x0b0b, + 0x0b0b, 0x0b0b, 0x0e0f, 0x0c0d, 0x0c0c, 0x0a0c, 0x1111, 0x0f11, 0x0c10, 0x0a0c, 0x1111, 0x1111, 0x1011, 0x0a0c, 0x1111, + 0x1111, 0x0f11, 0x0a0c, 0x1111, 0x1111, 0x1111, 0x0a0d, 0x1111, 0x1111, 0x1111, 0x0a0e, 0x1111, 0x1111, 0x1111, 0x0a0f, + 0x0f0a, 0x1111, 0x1111, 0x1111, 0x0e0b, 0x1111, 0x1111, 0x1111, 0x0d0b, 0x1111, 0x1111, 0x1111, 0x0c0b, 0x110f, 0x1111, + 0x1111, 0x0c0b, 0x1110, 0x1111, 0x1111, 0x0c0b, 0x100c, 0x110f, 0x1111, 0x0c0b, 0x0c0c, 0x0d0c, 0x0f0e, 0x0a0b, 0x0a0a, + 0x0a0a, 0x0a0a, 0x1111, 0x1111, 0x1111, 0x0b0f, 0x1111, 0x1111, 0x1111, 0x0a0e, 0x1111, 0x1111, 0x1111, 0x0a0d, 0x1111, + 0x1111, 0x0f11, 0x0a0c, 0x1111, 0x1111, 0x1011, 0x0a0c, 0x1111, 0x0f11, 0x0c10, 0x0a0c, 0x0e0f, 0x0c0d, 0x0c0c, 0x0a0c, + 0x0a0b, 0x0a0a, 0x0a0a, 0x0a0a }; const unsigned short mapTerrainMap[16] = { - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0001, 0x0001, 0x0001, 0x0001, 0xffff, 0xffff, 0xffff, 0xffff, 0x0001, 0x0001, 0xffff, 0xffff, 0x0000, 0x0000, 0x0000, 0x0000 }; +const unsigned short mapObjects[20] = { + 0x0004, 0x4261, 0x6c6c, 0x2053, 0x7061, 0x776e, 0x0000, 0x5265, 0x6400, 0x0005, 0x426c, 0x6f63, 0x6b4f, 0x626a, 0x6563, + 0x7400, 0x466c, 0x6f61, 0x7479, 0x0000 +}; + const unsigned short mapTileMap0[1024] = { - 0x0003, 0x0004, 0x0003, 0x0004, 0x0003, 0x0004, 0x0003, 0x0004, 0x0003, 0x0004, 0x0004, 0x0003, 0x0003, 0x0003, 0x0003, - 0x0003, 0x0003, 0x0004, 0x0004, 0x0004, 0x0004, 0x0004, 0x0004, 0x0004, 0x0004, 0x0003, 0x0003, 0x0007, 0x0008, 0x0004, - 0x0004, 0x0003, 0x0003, 0x0003, 0x0007, 0x0008, 0x0007, 0x0008, 0x0007, 0x0008, 0x0003, 0x0004, 0x0003, 0x0003, 0x0003, - 0x0003, 0x0004, 0x0004, 0x0004, 0x0003, 0x0003, 0x0004, 0x0003, 0x0004, 0x0004, 0x0004, 0x0003, 0x0003, 0x0004, 0x0001, - 0x0002, 0x0003, 0x0003, 0x0004, 0x0003, 0x0003, 0x0001, 0x0002, 0x0001, 0x0002, 0x0001, 0x0002, 0x0004, 0x0003, 0x0003, - 0x0003, 0x0003, 0x0007, 0x0008, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0004, 0x0004, 0x0004, 0x0004, - 0x0003, 0x0005, 0x0006, 0x0004, 0x0003, 0x0004, 0x0004, 0x0003, 0x0005, 0x0006, 0x0005, 0x0006, 0x0005, 0x0006, 0x0003, - 0x0004, 0x0004, 0x0004, 0x0004, 0x0001, 0x0002, 0x0003, 0x0003, 0x0004, 0x0003, 0x0003, 0x0003, 0x0003, 0x0004, 0x0004, - 0x0003, 0x0004, 0x0004, 0x0003, 0x0003, 0x0003, 0x0004, 0x0003, 0x0003, 0x0003, 0x0004, 0x0003, 0x0003, 0x0004, 0x0003, - 0x0004, 0x0004, 0x0003, 0x0004, 0x0003, 0x0004, 0x0005, 0x0006, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0004, 0x0003, - 0x0004, 0x0003, 0x0003, 0x0003, 0x0003, 0x0004, 0x0003, 0x0004, 0x0004, 0x0003, 0x0003, 0x0004, 0x0003, 0x0004, 0x0003, - 0x0004, 0x0004, 0x0003, 0x0004, 0x0003, 0x0004, 0x0003, 0x0004, 0x0004, 0x0003, 0x0004, 0x0003, 0x0004, 0x0003, 0x0004, - 0x0003, 0x0004, 0x0003, 0x0004, 0x0003, 0x0003, 0x0007, 0x0008, 0x0003, 0x0004, 0x0003, 0x0003, 0x0003, 0x0003, 0x0004, - 0x0003, 0x0007, 0x0008, 0x0008, 0x0007, 0x0008, 0x0007, 0x0008, 0x0007, 0x0008, 0x0008, 0x0007, 0x0008, 0x0007, 0x0008, - 0x0007, 0x0008, 0x0007, 0x0008, 0x0003, 0x0004, 0x0003, 0x0004, 0x0001, 0x0002, 0x0004, 0x0004, 0x0003, 0x0004, 0x0004, - 0x0003, 0x0004, 0x0004, 0x0001, 0x0002, 0x0001, 0x0002, 0x0001, 0x0002, 0x0001, 0x0002, 0x0001, 0x0002, 0x0001, 0x0002, - 0x0001, 0x0002, 0x0001, 0x0002, 0x0001, 0x0002, 0x0003, 0x0004, 0x0003, 0x0004, 0x0005, 0x0006, 0x0004, 0x0004, 0x0003, - 0x0004, 0x0003, 0x0004, 0x0004, 0x0003, 0x0005, 0x0006, 0x0005, 0x0006, 0x0005, 0x0006, 0x0005, 0x0006, 0x0005, 0x0006, - 0x0005, 0x0006, 0x0005, 0x0006, 0x0005, 0x0006, 0x0005, 0x0006, 0x0003, 0x0004, 0x0004, 0x0004, 0x0004, 0x0004, 0x0004, - 0x0003, 0x0003, 0x0004, 0x0003, 0x0004, 0x0003, 0x0003, 0x0003, 0x0004, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, - 0x0004, 0x0004, 0x0004, 0x0004, 0x0003, 0x0003, 0x0004, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0004, 0x0003, 0x0004, - 0x0004, 0x0003, 0x0003, 0x0004, 0x0004, 0x0004, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0004, 0x0004, 0x0003, - 0x0003, 0x0003, 0x0004, 0x0004, 0x0003, 0x0004, 0x0004, 0x0007, 0x0008, 0x0004, 0x0003, 0x0004, 0x0003, 0x0003, 0x0004, - 0x0004, 0x0003, 0x0004, 0x0003, 0x0004, 0x0003, 0x0004, 0x0003, 0x0003, 0x0004, 0x0004, 0x0004, 0x0003, 0x0003, 0x0003, - 0x0004, 0x0004, 0x0003, 0x0004, 0x0004, 0x0004, 0x0003, 0x0004, 0x0003, 0x0001, 0x0002, 0x0004, 0x0003, 0x0004, 0x0003, - 0x0003, 0x0004, 0x0004, 0x0003, 0x0004, 0x0003, 0x0004, 0x0003, 0x0004, 0x0004, 0x0004, 0x0004, 0x0004, 0x0003, 0x0003, - 0x0004, 0x0007, 0x0008, 0x0004, 0x0004, 0x0004, 0x0003, 0x0004, 0x0003, 0x0004, 0x0003, 0x0005, 0x0006, 0x0004, 0x0003, - 0x0004, 0x0003, 0x0003, 0x0004, 0x0004, 0x0003, 0x0004, 0x0003, 0x0004, 0x0003, 0x0004, 0x0004, 0x0003, 0x0003, 0x0003, - 0x0004, 0x0004, 0x0003, 0x0001, 0x0002, 0x0004, 0x0003, 0x0004, 0x0003, 0x0004, 0x0003, 0x0004, 0x0003, 0x0004, 0x0003, - 0x0004, 0x0003, 0x0004, 0x0003, 0x0004, 0x0003, 0x0004, 0x0003, 0x0004, 0x0003, 0x0004, 0x0003, 0x0004, 0x0003, 0x0004, - 0x0004, 0x0004, 0x0003, 0x0004, 0x0003, 0x0005, 0x0006, 0x0004, 0x0003, 0x0004, 0x0003, 0x0004, 0x0003, 0x0004, 0x0003, - 0x0004, 0x0003, 0x0004, 0x0003, 0x0004, 0x0003, 0x0004, 0x0003, 0x0004, 0x0003, 0x0004, 0x0003, 0x0004, 0x0003, 0x0004, - 0x0003, 0x0004, 0x0004, 0x0004, 0x0003, 0x0004, 0x0003, 0x0004, 0x0003, 0x0004, 0x0003, 0x0004, 0x0003, 0x0004, 0x0003, - 0x0004, 0x0003, 0x0004, 0x0003, 0x0004, 0x0003, 0x0004, 0x0003, 0x0004, 0x0003, 0x0004, 0x0003, 0x0004, 0x0003, 0x0004, - 0x0003, 0x0004, 0x0004, 0x0004, 0x0003, 0x0004, 0x0003, 0x0004, 0x0004, 0x0004, 0x0003, 0x0004, 0x0003, 0x0004, 0x0003, - 0x0004, 0x0003, 0x0004, 0x0003, 0x0004, 0x0003, 0x0004, 0x0003, 0x0004, 0x0003, 0x0004, 0x0003, 0x0004, 0x0003, 0x0004, - 0x0003, 0x0004, 0x0003, 0x0004, 0x0003, 0x0004, 0x0003, 0x0004, 0x0004, 0x0004, 0x0003, 0x0004, 0x0004, 0x0004, 0x0004, - 0x0003, 0x0004, 0x0004, 0x0004, 0x0004, 0x0004, 0x0004, 0x0004, 0x0003, 0x0004, 0x0003, 0x0004, 0x0003, 0x0004, 0x0003, - 0x0004, 0x0003, 0x0004, 0x0004, 0x0003, 0x0004, 0x0004, 0x0003, 0x0004, 0x0004, 0x0003, 0x0003, 0x0004, 0x0003, 0x0004, - 0x0003, 0x0004, 0x0004, 0x0003, 0x0004, 0x0003, 0x0003, 0x0003, 0x0004, 0x0003, 0x0007, 0x0008, 0x0007, 0x0008, 0x0007, - 0x0008, 0x0007, 0x0008, 0x0004, 0x0003, 0x0004, 0x0003, 0x0004, 0x0004, 0x0004, 0x0003, 0x0004, 0x0003, 0x0004, 0x0003, - 0x0004, 0x0003, 0x0004, 0x0003, 0x0004, 0x0003, 0x0003, 0x0004, 0x0003, 0x0004, 0x0004, 0x0004, 0x0001, 0x0002, 0x0001, - 0x0002, 0x0001, 0x0002, 0x0001, 0x0002, 0x0004, 0x0003, 0x0004, 0x0003, 0x0004, 0x0003, 0x0004, 0x0003, 0x0004, 0x0003, - 0x0004, 0x0003, 0x0004, 0x0003, 0x0004, 0x0003, 0x0003, 0x0003, 0x0004, 0x0004, 0x0004, 0x0003, 0x0004, 0x0003, 0x0005, - 0x0006, 0x0005, 0x0006, 0x0005, 0x0006, 0x0005, 0x0006, 0x0004, 0x0003, 0x0004, 0x0003, 0x0004, 0x0003, 0x0004, 0x0003, - 0x0004, 0x0003, 0x0004, 0x0003, 0x0004, 0x0003, 0x0004, 0x0003, 0x0004, 0x0003, 0x0004, 0x0003, 0x0004, 0x0003, 0x0004, - 0x0003, 0x0003, 0x0003, 0x0004, 0x0003, 0x0003, 0x0004, 0x0004, 0x0003, 0x0004, 0x0003, 0x0004, 0x0003, 0x0004, 0x0003, - 0x0004, 0x0003, 0x0004, 0x0003, 0x0004, 0x0003, 0x0004, 0x0003, 0x0004, 0x0003, 0x0004, 0x0003, 0x0004, 0x0003, 0x0004, - 0x0003, 0x0003, 0x0003, 0x0003, 0x0004, 0x0004, 0x0003, 0x0003, 0x0004, 0x0004, 0x0003, 0x0004, 0x0003, 0x0004, 0x0003, + 0x0001, 0x0002, 0x0001, 0x0002, 0x0001, 0x0002, 0x0001, 0x0002, 0x0001, 0x0002, 0x0001, 0x0002, 0x0001, 0x0002, 0x0001, + 0x0002, 0x0001, 0x0002, 0x0001, 0x0002, 0x0001, 0x0002, 0x0001, 0x0002, 0x0001, 0x0002, 0x0001, 0x0002, 0x0001, 0x0002, + 0x0001, 0x0002, 0x0003, 0x0004, 0x0003, 0x0004, 0x0003, 0x0004, 0x0003, 0x0004, 0x0003, 0x0004, 0x0003, 0x0004, 0x0003, 0x0004, 0x0003, 0x0004, 0x0003, 0x0004, 0x0003, 0x0004, 0x0003, 0x0004, 0x0003, 0x0004, 0x0003, 0x0004, 0x0003, 0x0004, - 0x0003, 0x0004, 0x0003, 0x0004, 0x0003, 0x0003, 0x0004, 0x0004, 0x0003, 0x0004, 0x0003, 0x0004, 0x0003, 0x0004, 0x0003, - 0x0004, 0x0003, 0x0004, 0x0004, 0x0003, 0x0004, 0x0003, 0x0003, 0x0004, 0x0003, 0x0003, 0x0003, 0x0004, 0x0003, 0x0004, - 0x0003, 0x0004, 0x0003, 0x0003, 0x0004, 0x0003, 0x0003, 0x0004, 0x0004, 0x0004, 0x0003, 0x0004, 0x0003, 0x0004, 0x0004, - 0x0004, 0x0003, 0x0004, 0x0003, 0x0004, 0x0004, 0x0004, 0x0003, 0x0003, 0x0004, 0x0004, 0x0003, 0x0003, 0x0004, 0x0004, - 0x0003, 0x0004, 0x0003, 0x0003, 0x0003, 0x0004, 0x0003, 0x0004, 0x0003, 0x0004, 0x0004, 0x0003, 0x0004, 0x0004, 0x0003, - 0x0004, 0x0003, 0x0004, 0x0003, 0x0004, 0x0003, 0x0004, 0x0004, 0x0003, 0x0004, 0x0003, 0x0004, 0x0003, 0x0003, 0x0004, - 0x0003, 0x0004, 0x0003, 0x0004, 0x0003, 0x0003, 0x0004, 0x0004, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0004, 0x0004, - 0x0004, 0x0004, 0x0004, 0x0003, 0x0004, 0x0003, 0x0004, 0x0003, 0x0004, 0x0004, 0x0003, 0x0003, 0x0004, 0x0003, 0x0003, - 0x0004, 0x0004, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0004, 0x0003, 0x0004, 0x0003, 0x0003, 0x0004, 0x0004, 0x0003, - 0x0004, 0x0004, 0x0003, 0x0004, 0x0004, 0x0003, 0x0004, 0x0003, 0x0004, 0x0003, 0x0004, 0x0003, 0x0004, 0x0003, 0x0004, - 0x0003, 0x0004, 0x0003, 0x0004, 0x0003, 0x0004, 0x0003, 0x0004, 0x0003, 0x0004, 0x0003, 0x0004, 0x0003, 0x0004, 0x0003, - 0x0004, 0x0003, 0x0004, 0x0004, 0x0003, 0x0004, 0x0003, 0x0004, 0x0003, 0x0004, 0x0003, 0x0004, 0x0003, 0x0007, 0x0008, + 0x0003, 0x0004, 0x0003, 0x0004, 0x0001, 0x0002, 0x0009, 0x000a, 0x0009, 0x000a, 0x0009, 0x000a, 0x0009, 0x000a, 0x0009, + 0x000a, 0x0009, 0x000a, 0x0009, 0x000a, 0x0009, 0x000a, 0x0009, 0x000a, 0x0009, 0x000a, 0x0009, 0x000a, 0x0009, 0x000a, + 0x0009, 0x000a, 0x0009, 0x000a, 0x0001, 0x0002, 0x0003, 0x0004, 0x000b, 0x000c, 0x000b, 0x000c, 0x000b, 0x000c, 0x000b, + 0x000c, 0x000b, 0x000c, 0x000b, 0x000c, 0x000b, 0x000c, 0x000b, 0x000c, 0x000b, 0x000c, 0x000b, 0x000c, 0x000b, 0x000c, + 0x000b, 0x000c, 0x000b, 0x000c, 0x000b, 0x000c, 0x0003, 0x0004, 0x0001, 0x0002, 0x0005, 0x0006, 0x0005, 0x0006, 0x0005, + 0x0006, 0x0005, 0x0006, 0x0005, 0x0006, 0x0005, 0x0006, 0x0005, 0x0006, 0x0005, 0x0006, 0x0005, 0x0006, 0x0005, 0x0006, + 0x0005, 0x0006, 0x0005, 0x0006, 0x0005, 0x0006, 0x0005, 0x0006, 0x0001, 0x0002, 0x0003, 0x0004, 0x0007, 0x0008, 0x0007, + 0x0008, 0x0007, 0x0008, 0x0007, 0x0008, 0x0007, 0x0008, 0x0007, 0x0008, 0x0007, 0x0008, 0x0007, 0x0008, 0x0007, 0x0008, + 0x0007, 0x0008, 0x0007, 0x0008, 0x0007, 0x0008, 0x0007, 0x0008, 0x0007, 0x0008, 0x0003, 0x0004, 0x0001, 0x0002, 0x0005, + 0x0006, 0x0005, 0x0006, 0x000d, 0x000e, 0x0005, 0x0006, 0x0001, 0x0002, 0x0005, 0x0006, 0x0005, 0x0006, 0x0005, 0x0006, + 0x0005, 0x0006, 0x0005, 0x0006, 0x0005, 0x0006, 0x0005, 0x0006, 0x0005, 0x0006, 0x0005, 0x0006, 0x0001, 0x0002, 0x0003, + 0x0004, 0x0007, 0x0008, 0x0007, 0x0008, 0x000f, 0x0010, 0x0007, 0x0008, 0x0003, 0x0004, 0x0007, 0x0008, 0x0007, 0x0008, + 0x0007, 0x0008, 0x0007, 0x0008, 0x0007, 0x0008, 0x0007, 0x0008, 0x0007, 0x0008, 0x0007, 0x0008, 0x0007, 0x0008, 0x0003, + 0x0004, 0x0001, 0x0002, 0x0001, 0x0002, 0x0001, 0x0002, 0x0001, 0x0002, 0x0001, 0x0002, 0x0001, 0x0002, 0x0005, 0x0006, + 0x0005, 0x0006, 0x0005, 0x0006, 0x0005, 0x0006, 0x0005, 0x0006, 0x0005, 0x0006, 0x0005, 0x0006, 0x0005, 0x0006, 0x0005, + 0x0006, 0x0001, 0x0002, 0x0003, 0x0004, 0x0003, 0x0004, 0x0003, 0x0004, 0x0003, 0x0004, 0x0003, 0x0004, 0x0003, 0x0004, 0x0007, 0x0008, 0x0007, 0x0008, 0x0007, 0x0008, 0x0007, 0x0008, 0x0007, 0x0008, 0x0007, 0x0008, 0x0007, 0x0008, 0x0007, - 0x0008, 0x0007, 0x0008, 0x0007, 0x0008, 0x0008, 0x0007, 0x0008, 0x0007, 0x0008, 0x0007, 0x0008, 0x0007, 0x0008, 0x0007, + 0x0008, 0x0007, 0x0008, 0x0003, 0x0004, 0x0001, 0x0002, 0x0009, 0x000a, 0x0009, 0x000a, 0x0009, 0x000a, 0x0009, 0x000a, + 0x0009, 0x000a, 0x0005, 0x0006, 0x0005, 0x0006, 0x0005, 0x0006, 0x0001, 0x0002, 0x0001, 0x0002, 0x0005, 0x0006, 0x0005, + 0x0006, 0x0005, 0x0006, 0x0005, 0x0006, 0x0001, 0x0002, 0x0003, 0x0004, 0x000b, 0x000c, 0x000b, 0x000c, 0x000b, 0x000c, + 0x000b, 0x000c, 0x000b, 0x000c, 0x0007, 0x0008, 0x0007, 0x0008, 0x0007, 0x0008, 0x0003, 0x0004, 0x0003, 0x0004, 0x0007, + 0x0008, 0x0007, 0x0008, 0x0007, 0x0008, 0x0007, 0x0008, 0x0003, 0x0004, 0x0001, 0x0002, 0x0005, 0x0006, 0x0005, 0x0006, + 0x0005, 0x0006, 0x0005, 0x0006, 0x0005, 0x0006, 0x0005, 0x0006, 0x0005, 0x0006, 0x0005, 0x0006, 0x0001, 0x0002, 0x0001, + 0x0002, 0x0005, 0x0006, 0x0005, 0x0006, 0x0005, 0x0006, 0x0005, 0x0006, 0x0001, 0x0002, 0x0003, 0x0004, 0x0007, 0x0008, + 0x0007, 0x0008, 0x0007, 0x0008, 0x0007, 0x0008, 0x0007, 0x0008, 0x0007, 0x0008, 0x0007, 0x0008, 0x0007, 0x0008, 0x0003, + 0x0004, 0x0003, 0x0004, 0x0007, 0x0008, 0x0007, 0x0008, 0x0007, 0x0008, 0x0007, 0x0008, 0x0003, 0x0004, 0x0009, 0x000a, + 0x0005, 0x0006, 0x0005, 0x0006, 0x0005, 0x0006, 0x0005, 0x0006, 0x0005, 0x0006, 0x0005, 0x0006, 0x0005, 0x0006, 0x0005, + 0x0006, 0x0009, 0x000a, 0x0009, 0x000a, 0x0005, 0x0006, 0x0005, 0x0006, 0x0005, 0x0006, 0x0005, 0x0006, 0x0009, 0x000a, + 0x000b, 0x000c, 0x0007, 0x0008, 0x0007, 0x0008, 0x0007, 0x0008, 0x0007, 0x0008, 0x0007, 0x0008, 0x0007, 0x0008, 0x0007, + 0x0008, 0x0007, 0x0008, 0x000b, 0x000c, 0x000b, 0x000c, 0x0007, 0x0008, 0x0007, 0x0008, 0x0007, 0x0008, 0x0007, 0x0008, + 0x000b, 0x000c, 0x0005, 0x0006, 0x0005, 0x0006, 0x0005, 0x0006, 0x0005, 0x0006, 0x0005, 0x0006, 0x0005, 0x0006, 0x0005, + 0x0006, 0x0005, 0x0006, 0x0005, 0x0006, 0x0005, 0x0006, 0x0005, 0x0006, 0x0005, 0x0006, 0x0005, 0x0006, 0x0005, 0x0006, + 0x0005, 0x0006, 0x0005, 0x0006, 0x0007, 0x0008, 0x0007, 0x0008, 0x0007, 0x0008, 0x0007, 0x0008, 0x0007, 0x0008, 0x0007, + 0x0008, 0x0007, 0x0008, 0x0007, 0x0008, 0x0007, 0x0008, 0x0007, 0x0008, 0x0007, 0x0008, 0x0007, 0x0008, 0x0007, 0x0008, + 0x0007, 0x0008, 0x0007, 0x0008, 0x0007, 0x0008, 0x0005, 0x0006, 0x0005, 0x0006, 0x0005, 0x0006, 0x0005, 0x0006, 0x0005, + 0x0006, 0x0005, 0x0006, 0x0005, 0x0006, 0x0005, 0x0006, 0x0005, 0x0006, 0x0005, 0x0006, 0x0005, 0x0006, 0x0005, 0x0006, + 0x0005, 0x0006, 0x0005, 0x0006, 0x0005, 0x0006, 0x0005, 0x0006, 0x0007, 0x0008, 0x0007, 0x0008, 0x0007, 0x0008, 0x0007, + 0x0008, 0x0007, 0x0008, 0x0007, 0x0008, 0x0007, 0x0008, 0x0007, 0x0008, 0x0007, 0x0008, 0x0007, 0x0008, 0x0007, 0x0008, + 0x0007, 0x0008, 0x0007, 0x0008, 0x0007, 0x0008, 0x0007, 0x0008, 0x0007, 0x0008, 0x0005, 0x0006, 0x0005, 0x0006, 0x0005, + 0x0006, 0x0005, 0x0006, 0x0005, 0x0006, 0x0005, 0x0006, 0x0005, 0x0006, 0x0005, 0x0006, 0x0005, 0x0006, 0x0001, 0x0002, + 0x0005, 0x0006, 0x0005, 0x0006, 0x0005, 0x0006, 0x0005, 0x0006, 0x0005, 0x0006, 0x0005, 0x0006, 0x0007, 0x0008, 0x0007, + 0x0008, 0x0007, 0x0008, 0x0007, 0x0008, 0x0007, 0x0008, 0x0007, 0x0008, 0x0007, 0x0008, 0x0007, 0x0008, 0x0007, 0x0008, + 0x0003, 0x0004, 0x0007, 0x0008, 0x0007, 0x0008, 0x0007, 0x0008, 0x0007, 0x0008, 0x0007, 0x0008, 0x0007, 0x0008, 0x0001, + 0x0002, 0x0005, 0x0006, 0x0005, 0x0006, 0x0005, 0x0006, 0x0005, 0x0006, 0x0005, 0x0006, 0x0005, 0x0006, 0x0005, 0x0006, + 0x0001, 0x0002, 0x0001, 0x0002, 0x0001, 0x0002, 0x0005, 0x0006, 0x0005, 0x0006, 0x0005, 0x0006, 0x0005, 0x0006, 0x0001, + 0x0002, 0x0003, 0x0004, 0x0007, 0x0008, 0x0007, 0x0008, 0x0007, 0x0008, 0x0007, 0x0008, 0x0007, 0x0008, 0x0007, 0x0008, + 0x0007, 0x0008, 0x0003, 0x0004, 0x0003, 0x0004, 0x0003, 0x0004, 0x0007, 0x0008, 0x0007, 0x0008, 0x0007, 0x0008, 0x0007, + 0x0008, 0x0003, 0x0004, 0x0001, 0x0002, 0x0001, 0x0002, 0x0001, 0x0002, 0x0001, 0x0002, 0x0005, 0x0006, 0x0005, 0x0006, + 0x0005, 0x0006, 0x0005, 0x0006, 0x0009, 0x000a, 0x0001, 0x0002, 0x0009, 0x000a, 0x0005, 0x0006, 0x0005, 0x0006, 0x0005, + 0x0006, 0x0005, 0x0006, 0x0001, 0x0002, 0x0003, 0x0004, 0x0003, 0x0004, 0x0003, 0x0004, 0x0003, 0x0004, 0x0007, 0x0008, + 0x0007, 0x0008, 0x0007, 0x0008, 0x0007, 0x0008, 0x000b, 0x000c, 0x0003, 0x0004, 0x000b, 0x000c, 0x0007, 0x0008, 0x0007, + 0x0008, 0x0007, 0x0008, 0x0007, 0x0008, 0x0003, 0x0004, 0x0001, 0x0002, 0x0009, 0x000a, 0x0009, 0x000a, 0x0009, 0x000a, + 0x0005, 0x0006, 0x0005, 0x0006, 0x0005, 0x0006, 0x0005, 0x0006, 0x0005, 0x0006, 0x0009, 0x000a, 0x0005, 0x0006, 0x0005, + 0x0006, 0x0005, 0x0006, 0x0005, 0x0006, 0x0005, 0x0006, 0x0001, 0x0002, 0x0003, 0x0004, 0x000b, 0x000c, 0x000b, 0x000c, + 0x000b, 0x000c, 0x0007, 0x0008, 0x0007, 0x0008, 0x0007, 0x0008, 0x0007, 0x0008, 0x0007, 0x0008, 0x000b, 0x000c, 0x0007, + 0x0008, 0x0007, 0x0008, 0x0007, 0x0008, 0x0007, 0x0008, 0x0007, 0x0008, 0x0003, 0x0004, 0x0001, 0x0002, 0x0005, 0x0006, + 0x0005, 0x0006, 0x0005, 0x0006, 0x0005, 0x0006, 0x0005, 0x0006, 0x0005, 0x0006, 0x0005, 0x0006, 0x0005, 0x0006, 0x0005, + 0x0006, 0x0005, 0x0006, 0x0005, 0x0006, 0x0005, 0x0006, 0x0005, 0x0006, 0x0005, 0x0006, 0x0001, 0x0002, 0x0003, 0x0004, + 0x0007, 0x0008, 0x0007, 0x0008, 0x0007, 0x0008, 0x0007, 0x0008, 0x0007, 0x0008, 0x0007, 0x0008, 0x0007, 0x0008, 0x0007, + 0x0008, 0x0007, 0x0008, 0x0007, 0x0008, 0x0007, 0x0008, 0x0007, 0x0008, 0x0007, 0x0008, 0x0007, 0x0008, 0x0003, 0x0004, 0x0001, 0x0002, 0x0001, 0x0002, 0x0001, 0x0002, 0x0001, 0x0002, 0x0001, 0x0002, 0x0001, 0x0002, 0x0001, 0x0002, 0x0001, 0x0002, 0x0001, 0x0002, 0x0001, 0x0002, 0x0001, 0x0002, 0x0001, 0x0002, 0x0001, 0x0002, 0x0001, 0x0002, 0x0001, 0x0002, - 0x0001, 0x0002, 0x0005, 0x0006, 0x0005, 0x0006, 0x0005, 0x0006, 0x0005, 0x0006, 0x0005, 0x0006, 0x0005, 0x0006, 0x0005, - 0x0006, 0x0005, 0x0006, 0x0005, 0x0006, 0x0005, 0x0006, 0x0005, 0x0006, 0x0005, 0x0006, 0x0005, 0x0006, 0x0005, 0x0006, - 0x0005, 0x0006, 0x0005, 0x0006 + 0x0001, 0x0002, 0x0003, 0x0004, 0x0003, 0x0004, 0x0003, 0x0004, 0x0003, 0x0004, 0x0003, 0x0004, 0x0003, 0x0004, 0x0003, + 0x0004, 0x0003, 0x0004, 0x0003, 0x0004, 0x0003, 0x0004, 0x0003, 0x0004, 0x0003, 0x0004, 0x0003, 0x0004, 0x0003, 0x0004, + 0x0003, 0x0004, 0x0003, 0x0004 }; diff --git a/examples/mapViewer/source/asset/map.h b/examples/mapViewer/source/asset/map.h index 14c7f28..2e82013 100644 --- a/examples/mapViewer/source/asset/map.h +++ b/examples/mapViewer/source/asset/map.h @@ -3,12 +3,15 @@ #define mapPaletteLength 256 extern const unsigned short mapPalette[256]; -#define mapTileSetLength 288 -extern const unsigned short mapTileSet[288]; +#define mapTileSetLength 544 +extern const unsigned short mapTileSet[544]; #define mapTerrainMapLength 16 extern const unsigned short mapTerrainMap[16]; +#define mapObjectsLength 20 +extern const unsigned short mapObjects[20]; + #define mapTileMap0Length 1024 extern const unsigned short mapTileMap0[1024]; diff --git a/src/gba/gbaMap/gbaMap.cpp b/src/gba/gbaMap/gbaMap.cpp index 9fb3d60..448cfa3 100644 --- a/src/gba/gbaMap/gbaMap.cpp +++ b/src/gba/gbaMap/gbaMap.cpp @@ -23,6 +23,10 @@ void GBAMap::setTerrainMap(vector &bytes) { d_terrainMap = bytes; } +void GBAMap::addObjects(vector &bytes) { + d_objects = bytes; +} + void GBAMap::setSize(unsigned mapWidth, unsigned mapHeight) { auto widthFlag = (uint16_t) (mapWidth == GBA_MAP_SIZE ? 0 : 1); auto heightFlag = (uint16_t) (mapHeight == GBA_MAP_SIZE ? 0 : 1); @@ -42,6 +46,9 @@ void GBAMap::toCode(ostream &headerFile, ostream &codeFile) { makeArrayDeclaration(headerFile, d_name + TERRAIN_MAP_NAME, d_terrainMap); makeArrayDefinition(codeFile, d_name + TERRAIN_MAP_NAME, d_terrainMap); + makeArrayDeclaration(headerFile, d_name + OBJECTS_NAME, d_objects); + makeArrayDefinition(codeFile, d_name + OBJECTS_NAME, d_objects); + for (int index = 0; index < d_tileLayers.size(); index++) { auto tileLayer = d_tileLayers[index]; makeArrayDeclaration(headerFile, d_name + TILE_MAP_NAME + to_string(index), tileLayer); diff --git a/src/gba/gbaMap/gbaMap.hpp b/src/gba/gbaMap/gbaMap.hpp index 4a826c9..5ff9644 100644 --- a/src/gba/gbaMap/gbaMap.hpp +++ b/src/gba/gbaMap/gbaMap.hpp @@ -51,6 +51,12 @@ class GBAMap { */ void addTileLayer(vector &bytes); + /** + * Add a collection of objects to the map. + * @param bytes The objects in byte data. + */ + void addObjects(vector &bytes); + /** * Convert the map data to C code. * @param headerFile The header file to store declarations in. @@ -83,11 +89,12 @@ class GBAMap { const char *TILE_SET_NAME = "TileSet"; const char *TILE_MAP_NAME = "TileMap"; const char *TERRAIN_MAP_NAME = "TerrainMap"; + const char *OBJECTS_NAME = "Objects"; const uint16_t PADDING_16_BIT = 0x0000; uint16_t d_sizeFlag; - vector d_palette, d_tileSet, d_terrainMap; + vector d_palette, d_tileSet, d_terrainMap, d_objects; vector> d_tileLayers; string d_name; diff --git a/src/mapConverter/mapConverter.cpp b/src/mapConverter/mapConverter.cpp index 54b746a..a1bb384 100644 --- a/src/mapConverter/mapConverter.cpp +++ b/src/mapConverter/mapConverter.cpp @@ -3,6 +3,7 @@ #include "tileLayerConverter/tileLayerConverter.hpp" #include "../log/logger.hpp" #include "../gba/background.h" +#include "objectLayerConverter/objectLayerConverter.hpp" #include GBAMap MapConverter::convert(const string &name, const tmx::Map &tmxMap) { @@ -28,8 +29,8 @@ GBAMap MapConverter::convert(const string &name, const tmx::Map &tmxMap) { unsigned gbaWidth = mapSize.x * tileSize.x / GBA_TILE_SIZE; unsigned gbaHeight = mapSize.y * tileSize.y / GBA_TILE_SIZE; - if (gbaWidth != GBA_MAP_SIZE && gbaWidth != GBA_MAP_SIZE * 2 || - gbaHeight != GBA_MAP_SIZE && gbaHeight != GBA_MAP_SIZE * 2) { + if ((gbaWidth != GBA_MAP_SIZE && gbaWidth != GBA_MAP_SIZE * 2) || + (gbaHeight != GBA_MAP_SIZE && gbaHeight != GBA_MAP_SIZE * 2)) { log(ERROR, "The map width and height must be either " + to_string(GBA_MAP_SIZE) + " or " + to_string(GBA_MAP_SIZE * 2) + " tiles large (when subdivided to GBA-sized tiles of " @@ -78,11 +79,19 @@ GBAMap MapConverter::convert(const string &name, const tmx::Map &tmxMap) { auto *tileLayerConverter = new TileLayerConverter(tileSet.getFirstGID()); for (const auto& tileLayer : tileLayers) { - log(INFO, "Converting layer '" + tileLayer->getName() + "'."); + log(INFO, "Converting tile layer '" + tileLayer->getName() + "'."); auto tileLayerBytes = tileLayerConverter->convert(tileLayer, mapSize.x, mapSize.y, tileSize.x); gbaMap.addTileLayer(tileLayerBytes); } + const auto objectLayers = getObjectLayers(layers); + auto *objectLayerConverter = new ObjectLayerConverter(); + for (const auto& objectLayer : objectLayers) { + log(INFO, "Converting object layer '" + objectLayer->getName() + "'."); + auto objectLayerBytes = objectLayerConverter->convert(objectLayer); + gbaMap.addObjects(objectLayerBytes); + } + return gbaMap; } diff --git a/src/mapConverter/stringConverter/stringConverter.cpp b/src/mapConverter/stringConverter/stringConverter.cpp index 7b7a156..ece0476 100644 --- a/src/mapConverter/stringConverter/stringConverter.cpp +++ b/src/mapConverter/stringConverter/stringConverter.cpp @@ -2,28 +2,38 @@ #include "stringConverter.hpp" vector StringConverter::convert(const string &text) { + const char* byteArray = text.c_str(); + const char* paddedByteArray = createPaddedByteArray(byteArray); + auto numBytes = getByteArraySize(paddedByteArray); vector bytes; - string paddedText = paddString(text); - auto numStringBytes = paddedText.length() + 1; - - char characters[numStringBytes]; - strcpy(characters, paddedText.c_str()); - - for (unsigned index = 0; index < numStringBytes; index += 2) { - auto mergedChar = (uint16_t) characters[index]; - mergedChar |= (uint16_t) characters[index+1] << 8; + for (unsigned index = 0; index < numBytes; index += 2) { + auto mergedChar = (uint16_t) paddedByteArray[index] << 8; + mergedChar |= (uint16_t) paddedByteArray[index+1]; bytes.push_back(mergedChar); } return bytes; } -string StringConverter::paddString(string text) { - auto numStringBytes = text.length() + 1; - auto remainingBytes = 4 - numStringBytes % 4; - string appendedText = text; - appendedText.append(remainingBytes, ' '); +const char* StringConverter::createPaddedByteArray(const char* byteArray) { + auto numBytes = getByteArraySize(byteArray); + unsigned remainingBytes = getAlignmentOffset(numBytes); + unsigned numBytesPadded = numBytes + remainingBytes; + char* paddedByteArray = new char[numBytesPadded]; + + for (unsigned index = 0; index < numBytes; index++) + paddedByteArray[index] = byteArray[index]; + for (unsigned index = numBytes; index < numBytesPadded; index++) + paddedByteArray[index] = '\0'; + + return paddedByteArray; +} + +unsigned StringConverter::getByteArraySize(const char *byteArray) { + return (unsigned) strlen(byteArray) + 1; +} - return appendedText; +unsigned StringConverter::getAlignmentOffset(unsigned size) { + return sizeof(uint32_t) - size % sizeof(uint32_t); } \ No newline at end of file diff --git a/src/mapConverter/stringConverter/stringConverter.hpp b/src/mapConverter/stringConverter/stringConverter.hpp index a9e7220..8c38a04 100644 --- a/src/mapConverter/stringConverter/stringConverter.hpp +++ b/src/mapConverter/stringConverter/stringConverter.hpp @@ -13,13 +13,16 @@ class StringConverter { public: /** * Convert a string into a vector of 2-byte values. + * It adds null characters to the vector in order preserve proper 32-bit alignment. * @param text The text to convert. * @return A vector of 2-byte values. */ vector convert(const string &text); private: - string paddString(string text); + const char* createPaddedByteArray(const char* byteArray); + unsigned getByteArraySize(const char* byteArray); + unsigned getAlignmentOffset(unsigned size); }; #endif \ No newline at end of file From d3f1994c2cdcaa949031c3207ca48e07af36473d Mon Sep 17 00:00:00 2001 From: Luc van den Brand <10974297+LucvandenBrand@users.noreply.github.com> Date: Sun, 30 Sep 2018 17:25:43 +0200 Subject: [PATCH 05/25] Increased object id size, because it plays nicer with alignments. --- examples/mapViewer/source/asset/map.c | 6 +++--- examples/mapViewer/source/asset/map.h | 4 ++-- .../objectLayerConverter/objectLayerConverter.cpp | 7 +++++-- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/examples/mapViewer/source/asset/map.c b/examples/mapViewer/source/asset/map.c index 1d90455..873bef5 100644 --- a/examples/mapViewer/source/asset/map.c +++ b/examples/mapViewer/source/asset/map.c @@ -64,9 +64,9 @@ const unsigned short mapTerrainMap[16] = { 0x0000 }; -const unsigned short mapObjects[20] = { - 0x0004, 0x4261, 0x6c6c, 0x2053, 0x7061, 0x776e, 0x0000, 0x5265, 0x6400, 0x0005, 0x426c, 0x6f63, 0x6b4f, 0x626a, 0x6563, - 0x7400, 0x466c, 0x6f61, 0x7479, 0x0000 +const unsigned short mapObjects[22] = { + 0x0000, 0x0004, 0x4261, 0x6c6c, 0x2053, 0x7061, 0x776e, 0x0000, 0x5265, 0x6400, 0x0000, 0x0005, 0x426c, 0x6f63, 0x6b4f, + 0x626a, 0x6563, 0x7400, 0x466c, 0x6f61, 0x7479, 0x0000 }; const unsigned short mapTileMap0[1024] = { diff --git a/examples/mapViewer/source/asset/map.h b/examples/mapViewer/source/asset/map.h index 2e82013..25775ed 100644 --- a/examples/mapViewer/source/asset/map.h +++ b/examples/mapViewer/source/asset/map.h @@ -9,8 +9,8 @@ extern const unsigned short mapTileSet[544]; #define mapTerrainMapLength 16 extern const unsigned short mapTerrainMap[16]; -#define mapObjectsLength 20 -extern const unsigned short mapObjects[20]; +#define mapObjectsLength 22 +extern const unsigned short mapObjects[22]; #define mapTileMap0Length 1024 extern const unsigned short mapTileMap0[1024]; diff --git a/src/mapConverter/objectLayerConverter/objectLayerConverter.cpp b/src/mapConverter/objectLayerConverter/objectLayerConverter.cpp index 2074bee..5dc04da 100644 --- a/src/mapConverter/objectLayerConverter/objectLayerConverter.cpp +++ b/src/mapConverter/objectLayerConverter/objectLayerConverter.cpp @@ -18,8 +18,11 @@ vector ObjectLayerConverter::convert(const vector &object vector ObjectLayerConverter::convert(const tmx::Object &object) { vector bytes; - auto id = (uint16_t) object.getUID(); - bytes.push_back(id); + uint32_t id = object.getUID(); + auto higherId = (uint16_t) (id << 16); + bytes.push_back(higherId); + auto lowerId = (uint16_t) id; + bytes.push_back(lowerId); StringConverter stringConverter; vector nameBytes = stringConverter.convert(object.getName()); From 54fc2166916ea3c77eb8b05f9f5d50ca12519040 Mon Sep 17 00:00:00 2001 From: Luc van den Brand <10974297+LucvandenBrand@users.noreply.github.com> Date: Sun, 30 Sep 2018 17:57:18 +0200 Subject: [PATCH 06/25] Fixed string padding error and added multiple obj layer support. --- examples/assets/size16-terrain-objects/map.tmx | 7 ++++++- examples/mapViewer/source/asset/map.c | 7 ++++--- examples/mapViewer/source/asset/map.h | 4 ++-- src/gba/gbaMap/gbaMap.cpp | 2 +- src/mapConverter/stringConverter/stringConverter.cpp | 1 + 5 files changed, 14 insertions(+), 7 deletions(-) diff --git a/examples/assets/size16-terrain-objects/map.tmx b/examples/assets/size16-terrain-objects/map.tmx index 09666f1..11d362b 100644 --- a/examples/assets/size16-terrain-objects/map.tmx +++ b/examples/assets/size16-terrain-objects/map.tmx @@ -1,6 +1,11 @@ - + + + + + + 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, diff --git a/examples/mapViewer/source/asset/map.c b/examples/mapViewer/source/asset/map.c index 873bef5..7675d4a 100644 --- a/examples/mapViewer/source/asset/map.c +++ b/examples/mapViewer/source/asset/map.c @@ -64,9 +64,10 @@ const unsigned short mapTerrainMap[16] = { 0x0000 }; -const unsigned short mapObjects[22] = { - 0x0000, 0x0004, 0x4261, 0x6c6c, 0x2053, 0x7061, 0x776e, 0x0000, 0x5265, 0x6400, 0x0000, 0x0005, 0x426c, 0x6f63, 0x6b4f, - 0x626a, 0x6563, 0x7400, 0x466c, 0x6f61, 0x7479, 0x0000 +const unsigned short mapObjects[40] = { + 0x0000, 0x0010, 0x4869, 0x6464, 0x656e, 0x4369, 0x7263, 0x6c65, 0x0000, 0x0000, 0x5365, 0x6372, 0x6574, 0x0000, 0x0000, + 0x0004, 0x4261, 0x6c6c, 0x2053, 0x7061, 0x776e, 0x0000, 0x5265, 0x6400, 0x0000, 0x0000, 0x0000, 0x0005, 0x426c, 0x6f63, + 0x6b4f, 0x626a, 0x6563, 0x7400, 0x0000, 0x0000, 0x466c, 0x6f61, 0x7479, 0x0000 }; const unsigned short mapTileMap0[1024] = { diff --git a/examples/mapViewer/source/asset/map.h b/examples/mapViewer/source/asset/map.h index 25775ed..4294291 100644 --- a/examples/mapViewer/source/asset/map.h +++ b/examples/mapViewer/source/asset/map.h @@ -9,8 +9,8 @@ extern const unsigned short mapTileSet[544]; #define mapTerrainMapLength 16 extern const unsigned short mapTerrainMap[16]; -#define mapObjectsLength 22 -extern const unsigned short mapObjects[22]; +#define mapObjectsLength 40 +extern const unsigned short mapObjects[40]; #define mapTileMap0Length 1024 extern const unsigned short mapTileMap0[1024]; diff --git a/src/gba/gbaMap/gbaMap.cpp b/src/gba/gbaMap/gbaMap.cpp index 448cfa3..5343ff4 100644 --- a/src/gba/gbaMap/gbaMap.cpp +++ b/src/gba/gbaMap/gbaMap.cpp @@ -24,7 +24,7 @@ void GBAMap::setTerrainMap(vector &bytes) { } void GBAMap::addObjects(vector &bytes) { - d_objects = bytes; + d_objects.insert(d_objects.end(), bytes.begin(), bytes.end()); } void GBAMap::setSize(unsigned mapWidth, unsigned mapHeight) { diff --git a/src/mapConverter/stringConverter/stringConverter.cpp b/src/mapConverter/stringConverter/stringConverter.cpp index ece0476..8f6e3e7 100644 --- a/src/mapConverter/stringConverter/stringConverter.cpp +++ b/src/mapConverter/stringConverter/stringConverter.cpp @@ -5,6 +5,7 @@ vector StringConverter::convert(const string &text) { const char* byteArray = text.c_str(); const char* paddedByteArray = createPaddedByteArray(byteArray); auto numBytes = getByteArraySize(paddedByteArray); + numBytes += getAlignmentOffset(numBytes); vector bytes; for (unsigned index = 0; index < numBytes; index += 2) { From 83c1526de4a2af535f33ebb49454dc24f20c69c8 Mon Sep 17 00:00:00 2001 From: Luc van den Brand <10974297+LucvandenBrand@users.noreply.github.com> Date: Sun, 30 Sep 2018 19:26:23 +0200 Subject: [PATCH 07/25] Refactor of code generation. --- src/gba/gbaMap/gbaMap.cpp | 76 +++++++++++++++++++-------------------- src/gba/gbaMap/gbaMap.hpp | 3 +- 2 files changed, 40 insertions(+), 39 deletions(-) diff --git a/src/gba/gbaMap/gbaMap.cpp b/src/gba/gbaMap/gbaMap.cpp index 5343ff4..cd193f0 100644 --- a/src/gba/gbaMap/gbaMap.cpp +++ b/src/gba/gbaMap/gbaMap.cpp @@ -36,49 +36,28 @@ void GBAMap::setSize(unsigned mapWidth, unsigned mapHeight) { void GBAMap::toCode(ostream &headerFile, ostream &codeFile) { makeFlagDefinition(headerFile, d_name + SIZE_FLAG_NAME, d_sizeFlag); - - makeArrayDeclaration(headerFile, d_name + PALETTE_NAME, d_palette); - makeArrayDefinition(codeFile, d_name + PALETTE_NAME, d_palette); - - makeArrayDeclaration(headerFile, d_name + TILE_SET_NAME, d_tileSet); - makeArrayDefinition(codeFile, d_name + TILE_SET_NAME, d_tileSet); - - makeArrayDeclaration(headerFile, d_name + TERRAIN_MAP_NAME, d_terrainMap); - makeArrayDefinition(codeFile, d_name + TERRAIN_MAP_NAME, d_terrainMap); - - makeArrayDeclaration(headerFile, d_name + OBJECTS_NAME, d_objects); - makeArrayDefinition(codeFile, d_name + OBJECTS_NAME, d_objects); - - for (int index = 0; index < d_tileLayers.size(); index++) { - auto tileLayer = d_tileLayers[index]; - makeArrayDeclaration(headerFile, d_name + TILE_MAP_NAME + to_string(index), tileLayer); - makeArrayDefinition(codeFile, d_name + TILE_MAP_NAME + to_string(index), tileLayer); - } + vectorToCode(headerFile, codeFile, PALETTE_NAME, d_palette); + vectorToCode(headerFile, codeFile, TILE_SET_NAME, d_tileSet); + vectorToCode(headerFile, codeFile, TERRAIN_MAP_NAME, d_terrainMap); + vectorToCode(headerFile, codeFile, OBJECTS_NAME, d_objects); + vectorToCode(headerFile, codeFile, TILE_MAP_NAME, d_tileLayers); } -void GBAMap::toBinary(ostream &binFile) { - unsigned byteCount = 0; - writeBinary(binFile, d_sizeFlag, &byteCount); - writeBinary(binFile, (uint16_t) d_palette.size(), &byteCount); - writeBinary(binFile, d_palette, &byteCount); - - writeBinary(binFile, PADDING_16_BIT, &byteCount); - writeBinary(binFile, (uint16_t) d_tileSet.size(), &byteCount); - writeBinary(binFile, d_tileSet, &byteCount); - - writeBinary(binFile, PADDING_16_BIT, &byteCount); - writeBinary(binFile, (uint16_t) d_terrainMap.size(), &byteCount); - writeBinary(binFile, d_terrainMap, &byteCount); +void GBAMap::makeFlagDefinition(ostream &headerStream, const string &name, uint16_t flag) { + headerStream << "#define " << name << " 0x" << setfill('0') << setw(4) << hex << (int) flag << endl << endl; +} - writeBinary(binFile, (uint16_t) d_tileLayers.size(), &byteCount); - if (!d_tileLayers.empty()) { - writeBinary(binFile, (uint16_t) d_tileLayers[0].size(), &byteCount); - writeBinary(binFile, d_tileLayers, &byteCount); - } +void GBAMap::vectorToCode(ostream &headerStream, ostream &codeStream, const string &name, vector byteVector) { + makeArrayDeclaration(headerStream, d_name + name, byteVector); + makeArrayDefinition(codeStream, d_name + name, byteVector); } -void GBAMap::makeFlagDefinition(ostream &headerStream, const string &name, uint16_t flag) { - headerStream << "#define " << name << " 0x" << setfill('0') << setw(4) << hex << (int) flag << endl << endl; +void GBAMap::vectorToCode(ostream &headerStream, ostream &codeStream, const string &name, vector> byteVectors) { + for (int index = 0; index < byteVectors.size(); index++) { + auto byteVectorName = name + to_string(index); + auto byteVector = byteVectors[index]; + vectorToCode(headerStream, codeStream, byteVectorName, byteVector); + } } void GBAMap::makeArrayDeclaration(ostream &headerStream, const string &name, vector &bytes) { @@ -107,6 +86,27 @@ void GBAMap::makeArrayDefinition(ostream &codeStream, const string &name, vector codeStream << endl << "};" << endl << endl; } +void GBAMap::toBinary(ostream &binFile) { + unsigned byteCount = 0; + writeBinary(binFile, d_sizeFlag, &byteCount); + writeBinary(binFile, (uint16_t) d_palette.size(), &byteCount); + writeBinary(binFile, d_palette, &byteCount); + + writeBinary(binFile, PADDING_16_BIT, &byteCount); + writeBinary(binFile, (uint16_t) d_tileSet.size(), &byteCount); + writeBinary(binFile, d_tileSet, &byteCount); + + writeBinary(binFile, PADDING_16_BIT, &byteCount); + writeBinary(binFile, (uint16_t) d_terrainMap.size(), &byteCount); + writeBinary(binFile, d_terrainMap, &byteCount); + + writeBinary(binFile, (uint16_t) d_tileLayers.size(), &byteCount); + if (!d_tileLayers.empty()) { + writeBinary(binFile, (uint16_t) d_tileLayers[0].size(), &byteCount); + writeBinary(binFile, d_tileLayers, &byteCount); + } +} + template ostream& GBAMap::writeBinary(ostream &stream, const T &value, unsigned *byteCount) { *byteCount += sizeof(T); diff --git a/src/gba/gbaMap/gbaMap.hpp b/src/gba/gbaMap/gbaMap.hpp index 5ff9644..a4fa4e2 100644 --- a/src/gba/gbaMap/gbaMap.hpp +++ b/src/gba/gbaMap/gbaMap.hpp @@ -72,7 +72,8 @@ class GBAMap { private: void makeFlagDefinition(ostream &headerStream, const string &name, uint16_t flag); - + void vectorToCode(ostream &headerStream, ostream &codeStream, const string &name, vector byteVector); + void vectorToCode(ostream &headerStream, ostream &codeStream, const string &name, vector> byteVectors); void makeArrayDeclaration(ostream &headerStream, const string &name, vector &bytes); void makeArrayDefinition(ostream &codeStream, const string &name, vector &bytes); From b2cf01bb4f9d639798b92d13b149c126fe5ce3d3 Mon Sep 17 00:00:00 2001 From: Luc van den Brand <10974297+LucvandenBrand@users.noreply.github.com> Date: Sun, 7 Oct 2018 09:09:15 +0200 Subject: [PATCH 08/25] Object loading from rom implemented (untested strings) --- examples/mapViewer/Makefile | 2 +- examples/mapViewer/source/asset/map.c | 8 ++-- examples/mapViewer/source/asset/map.h | 4 +- .../source/mapViewer/map/loadMapFromROM.c | 12 ++++- examples/mapViewer/source/mapViewer/map/map.h | 4 ++ .../source/mapViewer/map/object/loadObject.c | 9 ++++ .../mapViewer/map/object/loadObjectID.c | 7 +++ .../source/mapViewer/map/object/loadString.c | 8 ++++ .../source/mapViewer/map/object/object.h | 18 ++++++++ .../source/mapViewer/map/object/popValue.c | 7 +++ src/gba/gbaMap/gbaMap.cpp | 3 ++ .../stringConverter/stringConverter.cpp | 45 ++++++++----------- .../stringConverter/stringConverter.hpp | 6 +-- 13 files changed, 96 insertions(+), 37 deletions(-) create mode 100644 examples/mapViewer/source/mapViewer/map/object/loadObject.c create mode 100644 examples/mapViewer/source/mapViewer/map/object/loadObjectID.c create mode 100644 examples/mapViewer/source/mapViewer/map/object/loadString.c create mode 100644 examples/mapViewer/source/mapViewer/map/object/object.h create mode 100644 examples/mapViewer/source/mapViewer/map/object/popValue.c diff --git a/examples/mapViewer/Makefile b/examples/mapViewer/Makefile index bbba293..fa3072e 100644 --- a/examples/mapViewer/Makefile +++ b/examples/mapViewer/Makefile @@ -5,7 +5,7 @@ PATH := $(DEVKITARM)/bin:$(PATH) PROJ := mapViewer TITLE := $(PROJ) -GAMEOBJS := main.o map/loadMap.o map/loadMapFromCode.o map/loadMapFromROM.o map/setMapOnScreen.o shiftMap.o shiftMapLayer.o +GAMEOBJS := main.o map/loadMap.o map/loadMapFromCode.o map/loadMapFromROM.o map/setMapOnScreen.o map/object/loadObject.o map/object/loadObjectID.o map/object/loadString.o map/object/popValue.o shiftMap.o shiftMapLayer.o ASSETSOBJS := map.o LIBOBJS := gbfs/libgbfs.o diff --git a/examples/mapViewer/source/asset/map.c b/examples/mapViewer/source/asset/map.c index 7675d4a..caffec5 100644 --- a/examples/mapViewer/source/asset/map.c +++ b/examples/mapViewer/source/asset/map.c @@ -64,10 +64,10 @@ const unsigned short mapTerrainMap[16] = { 0x0000 }; -const unsigned short mapObjects[40] = { - 0x0000, 0x0010, 0x4869, 0x6464, 0x656e, 0x4369, 0x7263, 0x6c65, 0x0000, 0x0000, 0x5365, 0x6372, 0x6574, 0x0000, 0x0000, - 0x0004, 0x4261, 0x6c6c, 0x2053, 0x7061, 0x776e, 0x0000, 0x5265, 0x6400, 0x0000, 0x0000, 0x0000, 0x0005, 0x426c, 0x6f63, - 0x6b4f, 0x626a, 0x6563, 0x7400, 0x0000, 0x0000, 0x466c, 0x6f61, 0x7479, 0x0000 +const unsigned short mapObjects[42] = { + 0x0000, 0x0010, 0x0008, 0x4869, 0x6464, 0x656e, 0x4369, 0x7263, 0x6c65, 0x0000, 0x0000, 0x0004, 0x5365, 0x6372, 0x6574, + 0x0000, 0x0000, 0x0004, 0x0006, 0x4261, 0x6c6c, 0x2053, 0x7061, 0x776e, 0x0000, 0x0002, 0x5265, 0x6400, 0x0000, 0x0005, + 0x0006, 0x426c, 0x6f63, 0x6b4f, 0x626a, 0x6563, 0x7400, 0x0004, 0x466c, 0x6f61, 0x7479, 0x0000 }; const unsigned short mapTileMap0[1024] = { diff --git a/examples/mapViewer/source/asset/map.h b/examples/mapViewer/source/asset/map.h index 4294291..f716708 100644 --- a/examples/mapViewer/source/asset/map.h +++ b/examples/mapViewer/source/asset/map.h @@ -9,8 +9,8 @@ extern const unsigned short mapTileSet[544]; #define mapTerrainMapLength 16 extern const unsigned short mapTerrainMap[16]; -#define mapObjectsLength 40 -extern const unsigned short mapObjects[40]; +#define mapObjectsLength 42 +extern const unsigned short mapObjects[42]; #define mapTileMap0Length 1024 extern const unsigned short mapTileMap0[1024]; diff --git a/examples/mapViewer/source/mapViewer/map/loadMapFromROM.c b/examples/mapViewer/source/mapViewer/map/loadMapFromROM.c index c4d8f87..73abcb0 100644 --- a/examples/mapViewer/source/mapViewer/map/loadMapFromROM.c +++ b/examples/mapViewer/source/mapViewer/map/loadMapFromROM.c @@ -2,7 +2,7 @@ Map loadMapFromROM(const u16 *mapData) { Map map; - u32 index = 0; + u16 index = 0; map.sizeFlag = mapData[index++]; @@ -27,5 +27,15 @@ Map loadMapFromROM(const u16 *mapData) { index += map.tileMapLength; } + u16 lengthObjectData = mapData[index++]; + u32 endObjectData = index + lengthObjectData; + u32 objectCount = 0; + while (index != endObjectData) { + Object object = loadObject(mapData, &index); + map.objects[objectCount] = object; + objectCount++; + } + map.numObjects = objectCount; + return map; } diff --git a/examples/mapViewer/source/mapViewer/map/map.h b/examples/mapViewer/source/mapViewer/map/map.h index aa3770f..105096d 100644 --- a/examples/mapViewer/source/mapViewer/map/map.h +++ b/examples/mapViewer/source/mapViewer/map/map.h @@ -2,12 +2,14 @@ #define MAP_H #include "../../gbaLib/types.h" +#include "object/object.h" typedef struct { u16 sizeFlag, paletteLength, tileSetLength, terrainMapLength, + numObjects, numLayers, tileMapLength; @@ -15,6 +17,8 @@ typedef struct { *tileSet, *terrainMap; + Object objects[256]; + const u16 *tileMapLayers[3]; } Map; diff --git a/examples/mapViewer/source/mapViewer/map/object/loadObject.c b/examples/mapViewer/source/mapViewer/map/object/loadObject.c new file mode 100644 index 0000000..620b702 --- /dev/null +++ b/examples/mapViewer/source/mapViewer/map/object/loadObject.c @@ -0,0 +1,9 @@ +#include "object.h" + +Object loadObject(const u16* objectData, u16* index) { + Object object; + object.id = loadObjectID(objectData, index); + object.name = loadString(objectData, index); + object.type = loadString(objectData, index); + return object; +} \ No newline at end of file diff --git a/examples/mapViewer/source/mapViewer/map/object/loadObjectID.c b/examples/mapViewer/source/mapViewer/map/object/loadObjectID.c new file mode 100644 index 0000000..3e19289 --- /dev/null +++ b/examples/mapViewer/source/mapViewer/map/object/loadObjectID.c @@ -0,0 +1,7 @@ +#include "object.h" + +u32 loadObjectID(const u16* idData, u16* index) { + u32 upperID = popValue(idData, index); + u32 lowerID = popValue(idData, index); + return (upperID << 16) | lowerID; +} \ No newline at end of file diff --git a/examples/mapViewer/source/mapViewer/map/object/loadString.c b/examples/mapViewer/source/mapViewer/map/object/loadString.c new file mode 100644 index 0000000..ec1b574 --- /dev/null +++ b/examples/mapViewer/source/mapViewer/map/object/loadString.c @@ -0,0 +1,8 @@ +#include "object.h" + +u8* loadString(const u16* stringData, u16* index) { + u16 length = popValue(stringData, index); + u8* string = (u8*) &stringData[*index]; + *index += length; + return string; +} \ No newline at end of file diff --git a/examples/mapViewer/source/mapViewer/map/object/object.h b/examples/mapViewer/source/mapViewer/map/object/object.h new file mode 100644 index 0000000..de02623 --- /dev/null +++ b/examples/mapViewer/source/mapViewer/map/object/object.h @@ -0,0 +1,18 @@ +#ifndef OBJECT_H +#define OBJECT_H + +#include "../../../gbaLib/types.h" + +typedef struct +{ + u32 id; + u8 *name; + u8 *type; +} Object; + +Object loadObject(const u16* objectData, u16* index); +u32 loadObjectID(const u16* idData, u16* index); +u8* loadString(const u16* stringData, u16* index); +u16 popValue(const u16* data, u16* index); + +#endif \ No newline at end of file diff --git a/examples/mapViewer/source/mapViewer/map/object/popValue.c b/examples/mapViewer/source/mapViewer/map/object/popValue.c new file mode 100644 index 0000000..06239e2 --- /dev/null +++ b/examples/mapViewer/source/mapViewer/map/object/popValue.c @@ -0,0 +1,7 @@ +#include "object.h" + +u16 popValue(const u16* data, u16* index) { + u16 value = data[*index]; + *index += 1; + return value; +} \ No newline at end of file diff --git a/src/gba/gbaMap/gbaMap.cpp b/src/gba/gbaMap/gbaMap.cpp index cd193f0..f08ea28 100644 --- a/src/gba/gbaMap/gbaMap.cpp +++ b/src/gba/gbaMap/gbaMap.cpp @@ -105,6 +105,9 @@ void GBAMap::toBinary(ostream &binFile) { writeBinary(binFile, (uint16_t) d_tileLayers[0].size(), &byteCount); writeBinary(binFile, d_tileLayers, &byteCount); } + + writeBinary(binFile, (uint16_t) d_objects.size(), &byteCount); + writeBinary(binFile, d_objects, &byteCount); } template diff --git a/src/mapConverter/stringConverter/stringConverter.cpp b/src/mapConverter/stringConverter/stringConverter.cpp index 8f6e3e7..6ecf67c 100644 --- a/src/mapConverter/stringConverter/stringConverter.cpp +++ b/src/mapConverter/stringConverter/stringConverter.cpp @@ -2,39 +2,32 @@ #include "stringConverter.hpp" vector StringConverter::convert(const string &text) { - const char* byteArray = text.c_str(); - const char* paddedByteArray = createPaddedByteArray(byteArray); - auto numBytes = getByteArraySize(paddedByteArray); - numBytes += getAlignmentOffset(numBytes); - vector bytes; - - for (unsigned index = 0; index < numBytes; index += 2) { - auto mergedChar = (uint16_t) paddedByteArray[index] << 8; - mergedChar |= (uint16_t) paddedByteArray[index+1]; - bytes.push_back(mergedChar); + vector stringBytes = stringToByteVector(text); + paddByteVector(stringBytes); + vector mergedStringBytes; + auto numStringBytes = stringBytes.size(); + mergedStringBytes.push_back((uint16_t) (numStringBytes/2)); + + for (unsigned index = 0; index < numStringBytes; index += 2) { + auto firstChar = (uint16_t) (stringBytes[index] << 8 & 0xFF00); + auto secondChar = (uint16_t) (stringBytes[index+1] & 0x00FF); + uint16_t mergedChar = firstChar | secondChar; + mergedStringBytes.push_back(mergedChar); } - return bytes; + return mergedStringBytes; } -const char* StringConverter::createPaddedByteArray(const char* byteArray) { - auto numBytes = getByteArraySize(byteArray); - unsigned remainingBytes = getAlignmentOffset(numBytes); - unsigned numBytesPadded = numBytes + remainingBytes; - char* paddedByteArray = new char[numBytesPadded]; - - for (unsigned index = 0; index < numBytes; index++) - paddedByteArray[index] = byteArray[index]; - for (unsigned index = numBytes; index < numBytesPadded; index++) - paddedByteArray[index] = '\0'; - - return paddedByteArray; +vector StringConverter::stringToByteVector(const string &text) { + return vector(text.begin(), text.end()); } -unsigned StringConverter::getByteArraySize(const char *byteArray) { - return (unsigned) strlen(byteArray) + 1; +void StringConverter::paddByteVector(vector &byteVector) { + unsigned padding = getAlignmentOffset(byteVector.size()); + for (unsigned index = 0; index < padding; index++) + byteVector.push_back(0); } -unsigned StringConverter::getAlignmentOffset(unsigned size) { +unsigned StringConverter::getAlignmentOffset(unsigned long size) { return sizeof(uint32_t) - size % sizeof(uint32_t); } \ No newline at end of file diff --git a/src/mapConverter/stringConverter/stringConverter.hpp b/src/mapConverter/stringConverter/stringConverter.hpp index 8c38a04..495c878 100644 --- a/src/mapConverter/stringConverter/stringConverter.hpp +++ b/src/mapConverter/stringConverter/stringConverter.hpp @@ -20,9 +20,9 @@ class StringConverter { vector convert(const string &text); private: - const char* createPaddedByteArray(const char* byteArray); - unsigned getByteArraySize(const char* byteArray); - unsigned getAlignmentOffset(unsigned size); + vector stringToByteVector(const string &text); + void paddByteVector(vector &byteVector); + unsigned getAlignmentOffset(unsigned long size); }; #endif \ No newline at end of file From 5a4d72a960c1e2a6eea6df5c292e3b25b9aca7b3 Mon Sep 17 00:00:00 2001 From: Luc van den Brand <10974297+LucvandenBrand@users.noreply.github.com> Date: Sun, 7 Oct 2018 10:16:36 +0200 Subject: [PATCH 09/25] Object loading from code implemented (untested strings) --- .../mapViewer/source/mapViewer/map/loadMapFromCode.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/examples/mapViewer/source/mapViewer/map/loadMapFromCode.c b/examples/mapViewer/source/mapViewer/map/loadMapFromCode.c index d9729d0..e5a07a0 100644 --- a/examples/mapViewer/source/mapViewer/map/loadMapFromCode.c +++ b/examples/mapViewer/source/mapViewer/map/loadMapFromCode.c @@ -16,5 +16,14 @@ Map loadMapFromCode() { map.tileMapLength = mapTileMap0Length; map.tileMapLayers[0] = &mapTileMap0[0]; + u16 objectDataindex = 0; + u32 objectCount = 0; + while (objectDataindex != mapObjectsLength) { + Object object = loadObject(mapObjects, &objectDataindex); + map.objects[objectCount] = object; + objectCount++; + } + map.numObjects = objectCount; + return map; } From 08c787afe13ef093f4602a0a7f54dff100ede7cc Mon Sep 17 00:00:00 2001 From: Luc van den Brand <10974297+LucvandenBrand@users.noreply.github.com> Date: Sun, 7 Oct 2018 10:19:14 +0200 Subject: [PATCH 10/25] Updated readme to not mention a specific build target. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9cfc98e..37ac3c7 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ Simple CLI for converting [Tiled](https://www.mapeditor.org) maps to data the ** Special thanks to [Jasper Vijn](https://www.coranac.com) for providing a great tutorial on GBA development! ## Releases -You can download binary releases for Linux [here](https://github.com/LucvandenBrand/Tiled2GBA/releases). +You can download binary releases [here](https://github.com/LucvandenBrand/Tiled2GBA/releases). ## Usage Tiled2GBA can generate both compilable C code and appendable binary data. From 48f154e70e45122d7d4f20bed0d40f3b213feeb9 Mon Sep 17 00:00:00 2001 From: Luc van den Brand <10974297+LucvandenBrand@users.noreply.github.com> Date: Sun, 7 Oct 2018 15:46:27 +0200 Subject: [PATCH 11/25] Tested object string and fixed endian bug. --- examples/mapViewer/source/mapViewer/map/loadMapFromROM.c | 1 + examples/mapViewer/source/mapViewer/map/object/loadString.c | 4 ++-- examples/mapViewer/source/mapViewer/map/object/object.h | 6 +++--- src/mapConverter/stringConverter/stringConverter.cpp | 4 ++-- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/examples/mapViewer/source/mapViewer/map/loadMapFromROM.c b/examples/mapViewer/source/mapViewer/map/loadMapFromROM.c index 73abcb0..bb1590b 100644 --- a/examples/mapViewer/source/mapViewer/map/loadMapFromROM.c +++ b/examples/mapViewer/source/mapViewer/map/loadMapFromROM.c @@ -1,4 +1,5 @@ #include "map.h" +#include Map loadMapFromROM(const u16 *mapData) { Map map; diff --git a/examples/mapViewer/source/mapViewer/map/object/loadString.c b/examples/mapViewer/source/mapViewer/map/object/loadString.c index ec1b574..aeb8d50 100644 --- a/examples/mapViewer/source/mapViewer/map/object/loadString.c +++ b/examples/mapViewer/source/mapViewer/map/object/loadString.c @@ -1,8 +1,8 @@ #include "object.h" -u8* loadString(const u16* stringData, u16* index) { +const char* loadString(const u16* stringData, u16* index) { u16 length = popValue(stringData, index); - u8* string = (u8*) &stringData[*index]; + const char* string = (const char*) &stringData[*index]; *index += length; return string; } \ No newline at end of file diff --git a/examples/mapViewer/source/mapViewer/map/object/object.h b/examples/mapViewer/source/mapViewer/map/object/object.h index de02623..fbef46e 100644 --- a/examples/mapViewer/source/mapViewer/map/object/object.h +++ b/examples/mapViewer/source/mapViewer/map/object/object.h @@ -6,13 +6,13 @@ typedef struct { u32 id; - u8 *name; - u8 *type; + const char* name; + const char* type; } Object; Object loadObject(const u16* objectData, u16* index); u32 loadObjectID(const u16* idData, u16* index); -u8* loadString(const u16* stringData, u16* index); +const char* loadString(const u16* stringData, u16* index); u16 popValue(const u16* data, u16* index); #endif \ No newline at end of file diff --git a/src/mapConverter/stringConverter/stringConverter.cpp b/src/mapConverter/stringConverter/stringConverter.cpp index 6ecf67c..9dbfdb5 100644 --- a/src/mapConverter/stringConverter/stringConverter.cpp +++ b/src/mapConverter/stringConverter/stringConverter.cpp @@ -9,8 +9,8 @@ vector StringConverter::convert(const string &text) { mergedStringBytes.push_back((uint16_t) (numStringBytes/2)); for (unsigned index = 0; index < numStringBytes; index += 2) { - auto firstChar = (uint16_t) (stringBytes[index] << 8 & 0xFF00); - auto secondChar = (uint16_t) (stringBytes[index+1] & 0x00FF); + auto firstChar = (uint16_t) (stringBytes[index+1] << 8 & 0xFF00); + auto secondChar = (uint16_t) (stringBytes[index] & 0x00FF); uint16_t mergedChar = firstChar | secondChar; mergedStringBytes.push_back(mergedChar); } From aa25e1c68a425bb4f3958ae7d54cce255ba992af Mon Sep 17 00:00:00 2001 From: Luc van den Brand <10974297+LucvandenBrand@users.noreply.github.com> Date: Sun, 7 Oct 2018 15:48:03 +0200 Subject: [PATCH 12/25] Fixed broken name style. --- examples/mapViewer/source/mapViewer/map/loadMapFromCode.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/mapViewer/source/mapViewer/map/loadMapFromCode.c b/examples/mapViewer/source/mapViewer/map/loadMapFromCode.c index e5a07a0..0465a8f 100644 --- a/examples/mapViewer/source/mapViewer/map/loadMapFromCode.c +++ b/examples/mapViewer/source/mapViewer/map/loadMapFromCode.c @@ -16,10 +16,10 @@ Map loadMapFromCode() { map.tileMapLength = mapTileMap0Length; map.tileMapLayers[0] = &mapTileMap0[0]; - u16 objectDataindex = 0; + u16 objectDataIndex = 0; u32 objectCount = 0; - while (objectDataindex != mapObjectsLength) { - Object object = loadObject(mapObjects, &objectDataindex); + while (objectDataIndex != mapObjectsLength) { + Object object = loadObject(mapObjects, &objectDataIndex); map.objects[objectCount] = object; objectCount++; } From d76aec135f4880884f0c20a55aabd76ea5a1b6e2 Mon Sep 17 00:00:00 2001 From: Luc van den Brand <10974297+LucvandenBrand@users.noreply.github.com> Date: Sun, 7 Oct 2018 18:09:07 +0200 Subject: [PATCH 13/25] Made the gba makefile automatically find source files. --- examples/mapViewer/Makefile | 59 ++++++------------- .../mapViewer/source/gbaLib/input/input.c | 3 - 2 files changed, 18 insertions(+), 44 deletions(-) delete mode 100644 examples/mapViewer/source/gbaLib/input/input.c diff --git a/examples/mapViewer/Makefile b/examples/mapViewer/Makefile index fa3072e..d978564 100644 --- a/examples/mapViewer/Makefile +++ b/examples/mapViewer/Makefile @@ -1,37 +1,14 @@ PATH := $(DEVKITARM)/bin:$(PATH) -# --- Project details ------------------------------------------------- +# Project settings -PROJ := mapViewer -TITLE := $(PROJ) +NAME := mapViewer +SOURCE_DIR := source/ +SPECS := -specs=gba.specs -GAMEOBJS := main.o map/loadMap.o map/loadMapFromCode.o map/loadMapFromROM.o map/setMapOnScreen.o map/object/loadObject.o map/object/loadObjectID.o map/object/loadString.o map/object/popValue.o shiftMap.o shiftMapLayer.o -ASSETSOBJS := map.o -LIBOBJS := gbfs/libgbfs.o +MAP := map -GAMEOBJS := $(addprefix source/mapViewer/,$(GAMEOBJS)) -ASSETSOBJS := $(addprefix source/asset/,$(ASSETSOBJS)) -LIBOBJS := $(addprefix source/gbaLib/,$(LIBOBJS)) - -OBJS := $(GAMEOBJS) $(ASSETSOBJS) $(LIBOBJS) - -# --- boot type (MB=0 : normal. MB=1 : multiboot) --- - -MB = 0 - -ifeq ($(MB),1) - -TARGET := $(PROJ).mb -SPECS := -specs=gba_mb.specs - -else - -TARGET := $(PROJ) -SPECS := -specs=gba.specs - -endif - -# --- Compiling ------------------------------------------------------- +# Compilation settings CROSS ?= arm-none-eabi- AS := $(CROSS)as @@ -47,29 +24,29 @@ LDFLAGS := $(ARCH) $(SPECS) .PHONY : build clean -# --- Build ----------------------------------------------------------- +# Build commands -build : $(TARGET).gba +SOURCES := $(shell find $(SOURCE_DIR) -name '*.c') +OBJECTS := $(SOURCES:%.c=%.o) -play: build - vba $(TARGET).gba +build : $(NAME).gba -append: $(TARGET).gba - ./gbfs/gbfs map.gbfs map.bin +append: $(NAME).gba + ./gbfs/gbfs $(MAP).gbfs $(MAP).bin ./gbfs/padbin 256 $< - cat $< map.gbfs > $(TARGET)_append.gba + cat $< $(MAP).gbfs > $(NAME)_append.gba -$(TARGET).gba : $(TARGET).elf +$(NAME).gba : $(NAME).elf $(OBJCOPY) -v -O binary $< $@ - -@gbafix $@ -t$(TITLE) + -@gbafix $@ -t$(NAME) -$(TARGET).elf : $(OBJS) +$(NAME).elf : $(OBJECTS) $(LD) $^ $(LDFLAGS) -o $@ -$(OBJS) : %.o : %.c +$(OBJECTS) : %.o : %.c $(CC) $(CFLAGS) -c $< -o $@ -# --- Clean ----------------------------------------------------------- +# Cleanup settings clean : @rm -fv *.gba diff --git a/examples/mapViewer/source/gbaLib/input/input.c b/examples/mapViewer/source/gbaLib/input/input.c deleted file mode 100644 index 27f8359..0000000 --- a/examples/mapViewer/source/gbaLib/input/input.c +++ /dev/null @@ -1,3 +0,0 @@ -u32 getButton(u32 button) { - -}; From 47444ca9db296e1911508b767ff35c0e51165ecf Mon Sep 17 00:00:00 2001 From: Luc van den Brand <10974297+LucvandenBrand@users.noreply.github.com> Date: Mon, 8 Oct 2018 15:46:56 +0200 Subject: [PATCH 14/25] Fixed clean error in gba makefile. --- examples/mapViewer/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/mapViewer/Makefile b/examples/mapViewer/Makefile index d978564..d0c97e1 100644 --- a/examples/mapViewer/Makefile +++ b/examples/mapViewer/Makefile @@ -52,6 +52,6 @@ clean : @rm -fv *.gba @rm -fv *.elf @rm -fv *.gbfs - @rm -rf $(OBJS) + @rm -rf $(OBJECTS) #EOF From 4126240a62f9fd2b0d6445f510017b3017b3a48e Mon Sep 17 00:00:00 2001 From: Luc van den Brand <10974297+LucvandenBrand@users.noreply.github.com> Date: Mon, 8 Oct 2018 15:56:11 +0200 Subject: [PATCH 15/25] Restructuring of mapviewer project. --- examples/mapViewer/source/gbaLib/input/input.h | 2 ++ examples/mapViewer/source/mapViewer/main.c | 3 +-- examples/mapViewer/source/mapViewer/map/map.h | 3 +++ .../mapViewer/source/mapViewer/map/setMapOnScreen.c | 1 - .../mapViewer/source/mapViewer/{ => map}/shiftMap.c | 2 +- .../source/mapViewer/{ => map}/shiftMapLayer.c | 2 +- examples/mapViewer/source/mapViewer/mapViewer.h | 10 ---------- 7 files changed, 8 insertions(+), 15 deletions(-) rename examples/mapViewer/source/mapViewer/{ => map}/shiftMap.c (85%) rename examples/mapViewer/source/mapViewer/{ => map}/shiftMapLayer.c (71%) delete mode 100644 examples/mapViewer/source/mapViewer/mapViewer.h diff --git a/examples/mapViewer/source/gbaLib/input/input.h b/examples/mapViewer/source/gbaLib/input/input.h index a6f281f..a316ccb 100644 --- a/examples/mapViewer/source/gbaLib/input/input.h +++ b/examples/mapViewer/source/gbaLib/input/input.h @@ -1,6 +1,8 @@ #ifndef INPUT_H #define INPUT_H +#include "../memoryMap.h" + /** * Defines user input access. **/ diff --git a/examples/mapViewer/source/mapViewer/main.c b/examples/mapViewer/source/mapViewer/main.c index abfeb13..b5e6715 100644 --- a/examples/mapViewer/source/mapViewer/main.c +++ b/examples/mapViewer/source/mapViewer/main.c @@ -1,7 +1,6 @@ #include "../gbaLib/types.h" -#include "mapViewer.h" -#include "map/map.h" #include "../gbaLib/input/input.h" +#include "map/map.h" int main() { diff --git a/examples/mapViewer/source/mapViewer/map/map.h b/examples/mapViewer/source/mapViewer/map/map.h index 105096d..f567ee2 100644 --- a/examples/mapViewer/source/mapViewer/map/map.h +++ b/examples/mapViewer/source/mapViewer/map/map.h @@ -2,6 +2,7 @@ #define MAP_H #include "../../gbaLib/types.h" +#include "../../gbaLib/video/background.h" #include "object/object.h" typedef struct { @@ -32,5 +33,7 @@ Map loadMapFromROM(const u16 *mapData); Map loadMapFromCode(); void setMapOnScreen(Map map); +void shiftMap(Map map, BGPoint offset); +void shiftMapLayer(u16 layer, BGPoint offset); #endif diff --git a/examples/mapViewer/source/mapViewer/map/setMapOnScreen.c b/examples/mapViewer/source/mapViewer/map/setMapOnScreen.c index 3884edb..459f0be 100644 --- a/examples/mapViewer/source/mapViewer/map/setMapOnScreen.c +++ b/examples/mapViewer/source/mapViewer/map/setMapOnScreen.c @@ -1,6 +1,5 @@ #include "map.h" #include -#include "../../gbaLib/video/background.h" void setMapOnScreen(Map map) { memcpy(MEMORY_BACKGROUND_PALETTE, map.palette, map.paletteLength * 2); diff --git a/examples/mapViewer/source/mapViewer/shiftMap.c b/examples/mapViewer/source/mapViewer/map/shiftMap.c similarity index 85% rename from examples/mapViewer/source/mapViewer/shiftMap.c rename to examples/mapViewer/source/mapViewer/map/shiftMap.c index 38cae16..52247c6 100644 --- a/examples/mapViewer/source/mapViewer/shiftMap.c +++ b/examples/mapViewer/source/mapViewer/map/shiftMap.c @@ -1,4 +1,4 @@ -#include "mapViewer.h" +#include "map.h" void shiftMap(Map map, BGPoint offset) { diff --git a/examples/mapViewer/source/mapViewer/shiftMapLayer.c b/examples/mapViewer/source/mapViewer/map/shiftMapLayer.c similarity index 71% rename from examples/mapViewer/source/mapViewer/shiftMapLayer.c rename to examples/mapViewer/source/mapViewer/map/shiftMapLayer.c index 8d2dc2c..9e460ae 100644 --- a/examples/mapViewer/source/mapViewer/shiftMapLayer.c +++ b/examples/mapViewer/source/mapViewer/map/shiftMapLayer.c @@ -1,4 +1,4 @@ -#include "../gbaLib/video/background.h" +#include "map.h" void shiftMapLayer(u16 layer, BGPoint offset) { diff --git a/examples/mapViewer/source/mapViewer/mapViewer.h b/examples/mapViewer/source/mapViewer/mapViewer.h deleted file mode 100644 index c5391ab..0000000 --- a/examples/mapViewer/source/mapViewer/mapViewer.h +++ /dev/null @@ -1,10 +0,0 @@ -#ifndef MAP_VIEWER_H -#define MAP_VIEWER_H - -#include "../gbaLib/video/background.h" -#include "map/map.h" - -void shiftMap(Map map, BGPoint offset); -void shiftMapLayer(u16 layer, BGPoint offset); - -#endif // MAP_VIEWER_H From 8093895f4b0988a6d4830f623aba8e349ede0dd6 Mon Sep 17 00:00:00 2001 From: Luc van den Brand <10974297+LucvandenBrand@users.noreply.github.com> Date: Mon, 8 Oct 2018 16:12:59 +0200 Subject: [PATCH 16/25] Added position support. --- examples/mapViewer/source/asset/map.c | 9 +++++---- examples/mapViewer/source/asset/map.h | 4 ++-- .../mapViewer/source/mapViewer/map/object/loadObject.c | 2 ++ examples/mapViewer/source/mapViewer/map/object/object.h | 5 +++++ .../objectLayerConverter/objectLayerConverter.cpp | 5 +++++ 5 files changed, 19 insertions(+), 6 deletions(-) diff --git a/examples/mapViewer/source/asset/map.c b/examples/mapViewer/source/asset/map.c index caffec5..dbe99f2 100644 --- a/examples/mapViewer/source/asset/map.c +++ b/examples/mapViewer/source/asset/map.c @@ -64,10 +64,11 @@ const unsigned short mapTerrainMap[16] = { 0x0000 }; -const unsigned short mapObjects[42] = { - 0x0000, 0x0010, 0x0008, 0x4869, 0x6464, 0x656e, 0x4369, 0x7263, 0x6c65, 0x0000, 0x0000, 0x0004, 0x5365, 0x6372, 0x6574, - 0x0000, 0x0000, 0x0004, 0x0006, 0x4261, 0x6c6c, 0x2053, 0x7061, 0x776e, 0x0000, 0x0002, 0x5265, 0x6400, 0x0000, 0x0005, - 0x0006, 0x426c, 0x6f63, 0x6b4f, 0x626a, 0x6563, 0x7400, 0x0004, 0x466c, 0x6f61, 0x7479, 0x0000 +const unsigned short mapObjects[48] = { + 0x0000, 0x0010, 0x0060, 0x0034, 0x0008, 0x6948, 0x6464, 0x6e65, 0x6943, 0x6372, 0x656c, 0x0000, 0x0000, 0x0004, 0x6553, + 0x7263, 0x7465, 0x0000, 0x0000, 0x0004, 0x0038, 0x0089, 0x0006, 0x6142, 0x6c6c, 0x5320, 0x6170, 0x6e77, 0x0000, 0x0002, + 0x6552, 0x0064, 0x0000, 0x0005, 0x007d, 0x0090, 0x0006, 0x6c42, 0x636f, 0x4f6b, 0x6a62, 0x6365, 0x0074, 0x0004, 0x6c46, + 0x616f, 0x7974, 0x0000 }; const unsigned short mapTileMap0[1024] = { diff --git a/examples/mapViewer/source/asset/map.h b/examples/mapViewer/source/asset/map.h index f716708..120222a 100644 --- a/examples/mapViewer/source/asset/map.h +++ b/examples/mapViewer/source/asset/map.h @@ -9,8 +9,8 @@ extern const unsigned short mapTileSet[544]; #define mapTerrainMapLength 16 extern const unsigned short mapTerrainMap[16]; -#define mapObjectsLength 42 -extern const unsigned short mapObjects[42]; +#define mapObjectsLength 48 +extern const unsigned short mapObjects[48]; #define mapTileMap0Length 1024 extern const unsigned short mapTileMap0[1024]; diff --git a/examples/mapViewer/source/mapViewer/map/object/loadObject.c b/examples/mapViewer/source/mapViewer/map/object/loadObject.c index 620b702..0327ccd 100644 --- a/examples/mapViewer/source/mapViewer/map/object/loadObject.c +++ b/examples/mapViewer/source/mapViewer/map/object/loadObject.c @@ -3,6 +3,8 @@ Object loadObject(const u16* objectData, u16* index) { Object object; object.id = loadObjectID(objectData, index); + object.position.x = popValue(objectData, index); + object.position.y = popValue(objectData, index); object.name = loadString(objectData, index); object.type = loadString(objectData, index); return object; diff --git a/examples/mapViewer/source/mapViewer/map/object/object.h b/examples/mapViewer/source/mapViewer/map/object/object.h index fbef46e..8bfa624 100644 --- a/examples/mapViewer/source/mapViewer/map/object/object.h +++ b/examples/mapViewer/source/mapViewer/map/object/object.h @@ -3,9 +3,14 @@ #include "../../../gbaLib/types.h" +typedef struct { + u16 x, y; +} ALIGN(4) ObjectPoint; + typedef struct { u32 id; + ObjectPoint position; const char* name; const char* type; } Object; diff --git a/src/mapConverter/objectLayerConverter/objectLayerConverter.cpp b/src/mapConverter/objectLayerConverter/objectLayerConverter.cpp index 5dc04da..fa79e7a 100644 --- a/src/mapConverter/objectLayerConverter/objectLayerConverter.cpp +++ b/src/mapConverter/objectLayerConverter/objectLayerConverter.cpp @@ -24,6 +24,11 @@ vector ObjectLayerConverter::convert(const tmx::Object &object) { auto lowerId = (uint16_t) id; bytes.push_back(lowerId); + auto xPosition = (uint16_t) object.getPosition().x; + bytes.push_back(xPosition); + auto yPosition = (uint16_t) object.getPosition().y; + bytes.push_back(yPosition); + StringConverter stringConverter; vector nameBytes = stringConverter.convert(object.getName()); bytes.insert(bytes.end(), nameBytes.begin(), nameBytes.end()); From 3863b9cc48c3cc3c00209e08dd467839019eeb90 Mon Sep 17 00:00:00 2001 From: Luc van den Brand <10974297+LucvandenBrand@users.noreply.github.com> Date: Mon, 8 Oct 2018 16:47:50 +0200 Subject: [PATCH 17/25] Refactor of position loading. --- .../mapViewer/source/mapViewer/map/object/loadObject.c | 3 +-- .../mapViewer/source/mapViewer/map/object/loadPosition.c | 8 ++++++++ examples/mapViewer/source/mapViewer/map/object/object.h | 1 + 3 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 examples/mapViewer/source/mapViewer/map/object/loadPosition.c diff --git a/examples/mapViewer/source/mapViewer/map/object/loadObject.c b/examples/mapViewer/source/mapViewer/map/object/loadObject.c index 0327ccd..70cc75c 100644 --- a/examples/mapViewer/source/mapViewer/map/object/loadObject.c +++ b/examples/mapViewer/source/mapViewer/map/object/loadObject.c @@ -3,8 +3,7 @@ Object loadObject(const u16* objectData, u16* index) { Object object; object.id = loadObjectID(objectData, index); - object.position.x = popValue(objectData, index); - object.position.y = popValue(objectData, index); + object.position = loadPosition(objectData, index); object.name = loadString(objectData, index); object.type = loadString(objectData, index); return object; diff --git a/examples/mapViewer/source/mapViewer/map/object/loadPosition.c b/examples/mapViewer/source/mapViewer/map/object/loadPosition.c new file mode 100644 index 0000000..ffadf89 --- /dev/null +++ b/examples/mapViewer/source/mapViewer/map/object/loadPosition.c @@ -0,0 +1,8 @@ +#include "object.h" + +ObjectPoint loadPosition(const u16* positionData, u16* index) { + ObjectPoint position; + position.x = popValue(positionData, index); + position.y = popValue(positionData, index); + return position; +} \ No newline at end of file diff --git a/examples/mapViewer/source/mapViewer/map/object/object.h b/examples/mapViewer/source/mapViewer/map/object/object.h index 8bfa624..78dcf7a 100644 --- a/examples/mapViewer/source/mapViewer/map/object/object.h +++ b/examples/mapViewer/source/mapViewer/map/object/object.h @@ -17,6 +17,7 @@ typedef struct Object loadObject(const u16* objectData, u16* index); u32 loadObjectID(const u16* idData, u16* index); +ObjectPoint loadPosition(const u16* positionData, u16* index); const char* loadString(const u16* stringData, u16* index); u16 popValue(const u16* data, u16* index); From 3630388026e6bbc648037237c853bd113094eae9 Mon Sep 17 00:00:00 2001 From: Luc van den Brand <10974297+LucvandenBrand@users.noreply.github.com> Date: Mon, 8 Oct 2018 16:52:56 +0200 Subject: [PATCH 18/25] Increased minor version to 4. --- src/main.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main.hpp b/src/main.hpp index 2a7e881..aa41725 100644 --- a/src/main.hpp +++ b/src/main.hpp @@ -4,8 +4,8 @@ const char *PROGRAM_NAME = "Tiled2GBA"; const char *AUTHOR = "Luc van den Brand"; const int VERSION_MAJOR = 0; -const int VERSION_MINOR = 3; -const int VERSION_PATCH = 5; +const int VERSION_MINOR = 4; +const int VERSION_PATCH = 0; using namespace std; From 150a1878c6c628544b1c604595c66aa0f770198d Mon Sep 17 00:00:00 2001 From: Luc van den Brand <10974297+LucvandenBrand@users.noreply.github.com> Date: Sat, 13 Oct 2018 10:49:09 +0200 Subject: [PATCH 19/25] Messy buggy object visualization. --- examples/mapViewer/source/asset/sprite.c | 60 +++++++++++++++++++ examples/mapViewer/source/asset/sprite.h | 7 +++ examples/mapViewer/source/gbaLib/bitField.h | 8 +++ examples/mapViewer/source/gbaLib/memoryMap.h | 7 ++- .../source/gbaLib/video/background.h | 4 +- .../mapViewer/source/gbaLib/video/object.h | 34 +++++++++++ examples/mapViewer/source/mapViewer/main.c | 17 ++++++ .../source/mapViewer/map/object/object.h | 2 + .../mapViewer/map/object/shiftMapObjects.c | 10 ++++ .../sprite/copySpriteObjectsToMemory.c | 12 ++++ .../mapViewer/sprite/hideSpriteObjects.c | 11 ++++ .../sprite/initializeSpriteObjectMemory.c | 7 +++ .../source/mapViewer/sprite/loadSpriteSheet.c | 9 +++ .../sprite/mapObjectsToSpriteObjects.c | 18 ++++++ .../sprite/setSpriteObjectAttributes.c | 8 +++ .../sprite/setSpriteObjectPosition.c | 8 +++ .../mapViewer/sprite/setSpritesOnScreen.c | 6 ++ .../source/mapViewer/sprite/sprite.h | 16 +++++ 18 files changed, 240 insertions(+), 4 deletions(-) create mode 100644 examples/mapViewer/source/asset/sprite.c create mode 100644 examples/mapViewer/source/asset/sprite.h create mode 100644 examples/mapViewer/source/gbaLib/bitField.h create mode 100644 examples/mapViewer/source/gbaLib/video/object.h create mode 100644 examples/mapViewer/source/mapViewer/map/object/shiftMapObjects.c create mode 100644 examples/mapViewer/source/mapViewer/sprite/copySpriteObjectsToMemory.c create mode 100644 examples/mapViewer/source/mapViewer/sprite/hideSpriteObjects.c create mode 100644 examples/mapViewer/source/mapViewer/sprite/initializeSpriteObjectMemory.c create mode 100644 examples/mapViewer/source/mapViewer/sprite/loadSpriteSheet.c create mode 100644 examples/mapViewer/source/mapViewer/sprite/mapObjectsToSpriteObjects.c create mode 100644 examples/mapViewer/source/mapViewer/sprite/setSpriteObjectAttributes.c create mode 100644 examples/mapViewer/source/mapViewer/sprite/setSpriteObjectPosition.c create mode 100644 examples/mapViewer/source/mapViewer/sprite/setSpritesOnScreen.c create mode 100644 examples/mapViewer/source/mapViewer/sprite/sprite.h diff --git a/examples/mapViewer/source/asset/sprite.c b/examples/mapViewer/source/asset/sprite.c new file mode 100644 index 0000000..f32541b --- /dev/null +++ b/examples/mapViewer/source/asset/sprite.c @@ -0,0 +1,60 @@ +const unsigned short spritePalette[256] = { + 0x7c1f, 0x0557, 0x11bb, 0x47bf, 0x1bbe, 0x235a, 0x22da, 0x2276, 0x5c28, 0x6c8c, 0x0831, 0x1474, 0x019a, 0x0113, 0x0088, + 0x0001, 0x0156, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000 +}; + +const unsigned short spriteTileSet[544] = { + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0201, 0x0202, 0x0202, 0x0202, 0x0202, 0x0303, 0x0303, 0x0303, 0x0402, 0x0302, 0x0303, 0x0303, 0x0402, + 0x0204, 0x0303, 0x0303, 0x0402, 0x0404, 0x0302, 0x0303, 0x0402, 0x0404, 0x0204, 0x0303, 0x0402, 0x0404, 0x0404, 0x0302, + 0x0402, 0x0404, 0x0404, 0x0204, 0x0201, 0x0202, 0x0202, 0x0202, 0x0303, 0x0303, 0x0303, 0x0101, 0x0303, 0x0303, 0x0103, + 0x0105, 0x0303, 0x0303, 0x0501, 0x0105, 0x0303, 0x0103, 0x0505, 0x0105, 0x0303, 0x0501, 0x0505, 0x0105, 0x0103, 0x0505, + 0x0505, 0x0105, 0x0501, 0x0505, 0x0505, 0x0105, 0x0401, 0x0404, 0x0404, 0x0104, 0x0402, 0x0404, 0x0404, 0x0601, 0x0402, + 0x0404, 0x0104, 0x0606, 0x0402, 0x0404, 0x0601, 0x0606, 0x0402, 0x0104, 0x0606, 0x0606, 0x0402, 0x0701, 0x0606, 0x0606, + 0x0102, 0x0707, 0x0707, 0x0707, 0x0202, 0x0202, 0x0202, 0x0202, 0x0502, 0x0505, 0x0505, 0x0205, 0x0206, 0x0505, 0x0505, + 0x0105, 0x0606, 0x0502, 0x0505, 0x0105, 0x0606, 0x0206, 0x0505, 0x0105, 0x0606, 0x0606, 0x0502, 0x0105, 0x0606, 0x0606, + 0x0207, 0x0105, 0x0707, 0x0707, 0x0707, 0x0102, 0x0202, 0x0202, 0x0202, 0x0102, 0x0808, 0x0808, 0x0808, 0x0808, 0x0808, + 0x0909, 0x0909, 0x0909, 0x0908, 0x0809, 0x0909, 0x0908, 0x0908, 0x0909, 0x0909, 0x0909, 0x0908, 0x0908, 0x0809, 0x0909, + 0x0908, 0x0909, 0x0909, 0x0909, 0x0908, 0x0809, 0x0909, 0x0908, 0x0908, 0x0909, 0x0909, 0x0909, 0x0808, 0x0808, 0x0808, + 0x0808, 0x0909, 0x0909, 0x0909, 0x0808, 0x0809, 0x0909, 0x0908, 0x0809, 0x0909, 0x0909, 0x0909, 0x0809, 0x0908, 0x0809, + 0x0809, 0x0809, 0x0909, 0x0909, 0x0909, 0x0809, 0x0809, 0x0909, 0x0908, 0x0809, 0x0909, 0x0909, 0x0909, 0x0809, 0x0908, + 0x0908, 0x0908, 0x0909, 0x0908, 0x0909, 0x0909, 0x0908, 0x0908, 0x0809, 0x0909, 0x0909, 0x0908, 0x0909, 0x0809, 0x0909, + 0x0908, 0x0909, 0x0909, 0x0909, 0x0908, 0x0809, 0x0909, 0x0908, 0x0808, 0x0909, 0x0909, 0x0909, 0x0808, 0x0808, 0x0808, + 0x0808, 0x0908, 0x0909, 0x0908, 0x0809, 0x0909, 0x0908, 0x0909, 0x0809, 0x0909, 0x0909, 0x0809, 0x0809, 0x0908, 0x0809, + 0x0909, 0x0809, 0x0909, 0x0909, 0x0909, 0x0809, 0x0809, 0x0909, 0x0908, 0x0809, 0x0909, 0x0909, 0x0909, 0x0808, 0x0808, + 0x0808, 0x0808, 0x0808, 0x0701, 0x0607, 0x0606, 0x0606, 0x0702, 0x0606, 0x0606, 0x0606, 0x0602, 0x0606, 0x0606, 0x0606, + 0x0602, 0x0606, 0x0606, 0x0606, 0x0602, 0x0606, 0x0606, 0x0606, 0x0702, 0x0606, 0x0606, 0x0606, 0x0702, 0x0607, 0x0606, + 0x0606, 0x0208, 0x0202, 0x0202, 0x0202, 0x0606, 0x0606, 0x0706, 0x0207, 0x0606, 0x0606, 0x0606, 0x0107, 0x0606, 0x0606, + 0x0606, 0x0106, 0x0606, 0x0606, 0x0606, 0x0106, 0x0606, 0x0606, 0x0606, 0x0106, 0x0606, 0x0606, 0x0606, 0x0107, 0x0606, + 0x0606, 0x0706, 0x0107, 0x0202, 0x0202, 0x0202, 0x0802, 0x0808, 0x0808, 0x0808, 0x0808, 0x0808, 0x0909, 0x0909, 0x0908, + 0x0908, 0x0809, 0x0909, 0x0909, 0x0908, 0x0909, 0x0809, 0x0909, 0x0908, 0x0909, 0x0909, 0x0909, 0x0908, 0x0809, 0x0909, + 0x0908, 0x0808, 0x0909, 0x0909, 0x0909, 0x0808, 0x0808, 0x0808, 0x0808, 0x0808, 0x0808, 0x0808, 0x0808, 0x0909, 0x0908, + 0x0909, 0x0808, 0x0909, 0x0909, 0x0809, 0x0809, 0x0908, 0x0809, 0x0909, 0x0809, 0x0909, 0x0909, 0x0909, 0x0809, 0x0809, + 0x0909, 0x0908, 0x0809, 0x0909, 0x0909, 0x0909, 0x0808, 0x0808, 0x0808, 0x0808, 0x0808, 0x0b0a, 0x0b0b, 0x0b0b, 0x0b0b, + 0x0c0b, 0x0c0c, 0x0d0c, 0x0f0e, 0x0c0b, 0x100c, 0x110f, 0x1111, 0x0c0b, 0x1110, 0x1111, 0x1111, 0x0c0b, 0x110f, 0x1111, + 0x1111, 0x0d0b, 0x1111, 0x1111, 0x1111, 0x0e0b, 0x1111, 0x1111, 0x1111, 0x0f0b, 0x1111, 0x1111, 0x1111, 0x0b0a, 0x0b0b, + 0x0b0b, 0x0b0b, 0x0e0f, 0x0c0d, 0x0c0c, 0x0a0c, 0x1111, 0x0f11, 0x0c10, 0x0a0c, 0x1111, 0x1111, 0x1011, 0x0a0c, 0x1111, + 0x1111, 0x0f11, 0x0a0c, 0x1111, 0x1111, 0x1111, 0x0a0d, 0x1111, 0x1111, 0x1111, 0x0a0e, 0x1111, 0x1111, 0x1111, 0x0a0f, + 0x0f0a, 0x1111, 0x1111, 0x1111, 0x0e0b, 0x1111, 0x1111, 0x1111, 0x0d0b, 0x1111, 0x1111, 0x1111, 0x0c0b, 0x110f, 0x1111, + 0x1111, 0x0c0b, 0x1110, 0x1111, 0x1111, 0x0c0b, 0x100c, 0x110f, 0x1111, 0x0c0b, 0x0c0c, 0x0d0c, 0x0f0e, 0x0a0b, 0x0a0a, + 0x0a0a, 0x0a0a, 0x1111, 0x1111, 0x1111, 0x0b0f, 0x1111, 0x1111, 0x1111, 0x0a0e, 0x1111, 0x1111, 0x1111, 0x0a0d, 0x1111, + 0x1111, 0x0f11, 0x0a0c, 0x1111, 0x1111, 0x1011, 0x0a0c, 0x1111, 0x0f11, 0x0c10, 0x0a0c, 0x0e0f, 0x0c0d, 0x0c0c, 0x0a0c, + 0x0a0b, 0x0a0a, 0x0a0a, 0x0a0a +}; diff --git a/examples/mapViewer/source/asset/sprite.h b/examples/mapViewer/source/asset/sprite.h new file mode 100644 index 0000000..3173fe7 --- /dev/null +++ b/examples/mapViewer/source/asset/sprite.h @@ -0,0 +1,7 @@ +#define mapSizeFlag 0x0000 + +#define spritePaletteLength 256 +extern const unsigned short spritePalette[256]; + +#define spriteTileSetLength 544 +extern const unsigned short spriteTileSet[544]; diff --git a/examples/mapViewer/source/gbaLib/bitField.h b/examples/mapViewer/source/gbaLib/bitField.h new file mode 100644 index 0000000..d3e4ef4 --- /dev/null +++ b/examples/mapViewer/source/gbaLib/bitField.h @@ -0,0 +1,8 @@ +#ifndef BIT_FIELD_H +#define BIT_FIELD_H + +#define BIT_FIELD_PREP(x, name) ( ((x)<>name##_SHIFT ) +#define BIT_FIELD_SET(y, x, name) (y = ((y)&~name##_MASK) | BIT_FIELD_PREP(x,name) ) + +#endif \ No newline at end of file diff --git a/examples/mapViewer/source/gbaLib/memoryMap.h b/examples/mapViewer/source/gbaLib/memoryMap.h index 9e2007d..11e1bef 100644 --- a/examples/mapViewer/source/gbaLib/memoryMap.h +++ b/examples/mapViewer/source/gbaLib/memoryMap.h @@ -7,9 +7,10 @@ * Defines the general memory locations. */ -#define MEMORY_IO 0x04000000 -#define MEMORY_PALETTE 0x05000000 -#define MEMORY_VIDEORAM 0x06000000 +#define MEMORY_IO 0x04000000 +#define MEMORY_PALETTE 0x05000000 +#define MEMORY_VIDEORAM 0x06000000 +#define MEMORY_OBJECT_ATTRIBUTES 0x07000000 #define REGISTER_BASE MEMORY_IO diff --git a/examples/mapViewer/source/gbaLib/video/background.h b/examples/mapViewer/source/gbaLib/video/background.h index e541fed..c471b9b 100644 --- a/examples/mapViewer/source/gbaLib/video/background.h +++ b/examples/mapViewer/source/gbaLib/video/background.h @@ -4,7 +4,7 @@ #include "video.h" /** - * Defines the background control. + * Defines the background control. */ typedef u16 ScreenEntry; @@ -21,6 +21,8 @@ typedef ScreenEntry ScreenBlock[1024]; typedef Tile CharBlock[512]; #define MEMORY_BACKGROUND_PALETTE ((Color*)MEMORY_PALETTE) +#define MEMORY_BACKGROUND_PALETTE_SIZE 0x00200 + #define MEMORY_SCREEN_BLOCK ((ScreenBlock*)MEMORY_VIDEORAM) #define MEMORY_CHAR_BLOCK ((CharBlock*)MEMORY_VIDEORAM) diff --git a/examples/mapViewer/source/gbaLib/video/object.h b/examples/mapViewer/source/gbaLib/video/object.h new file mode 100644 index 0000000..a1643be --- /dev/null +++ b/examples/mapViewer/source/gbaLib/video/object.h @@ -0,0 +1,34 @@ +#include "background.h" + +/** + * Defines the sprite object control + */ + +typedef struct +{ + u16 attribute0; + u16 attribute1; + u16 attribute2; + s16 fill; +} ALIGN(4) SpriteObject; + +#define MEMORY_OBJECT_PALETTE ((Color*)(MEMORY_PALETTE + MEMORY_BACKGROUND_PALETTE_SIZE)) +#define MEMORY_SPRITE_OBJECTS ((SpriteObject*)MEMORY_OBJECT_ATTRIBUTES) + +#define ATTRIBUTE0_HIDE 0x0200 +#define ATTRIBUTE0_SQUARE 0 +#define ATTRIBUTE0_Y_MASK 0x00FF +#define ATTRIBUTE0_Y_SHIFT 0 +#define ATTRIBUTE0_Y(n) ((n)< + +void loadSpriteSheet() +{ + memcpy(MEMORY_OBJECT_PALETTE, spritePalette, spritePaletteLength * 2); + memcpy(&MEMORY_CHAR_BLOCK[4][0], spriteTileSet, spriteTileSetLength * 2); +}; \ No newline at end of file diff --git a/examples/mapViewer/source/mapViewer/sprite/mapObjectsToSpriteObjects.c b/examples/mapViewer/source/mapViewer/sprite/mapObjectsToSpriteObjects.c new file mode 100644 index 0000000..92830ab --- /dev/null +++ b/examples/mapViewer/source/mapViewer/sprite/mapObjectsToSpriteObjects.c @@ -0,0 +1,18 @@ +#include "sprite.h" + +void mapObjectsToSpriteObjects(Object* mapObjects, SpriteObject* spriteObjects, u32 count) +{ + for (u32 index = 0; index < count; index++) + { + u32 tileID = 0; + u32 paletteBank = 0; + SpriteObject *spriteObject= &spriteObjects[index]; + setSpriteObjectAttributes(spriteObject, + ATTRIBUTE0_SQUARE, + ATTRIBUTE1_SIZE_64, + ATTRIBUTE2_PALETTE_BANK(paletteBank) | tileID); + + ObjectPoint position = mapObjects[index].position; + setSpriteObjectPosition(spriteObject, position); + } +} \ No newline at end of file diff --git a/examples/mapViewer/source/mapViewer/sprite/setSpriteObjectAttributes.c b/examples/mapViewer/source/mapViewer/sprite/setSpriteObjectAttributes.c new file mode 100644 index 0000000..195bd92 --- /dev/null +++ b/examples/mapViewer/source/mapViewer/sprite/setSpriteObjectAttributes.c @@ -0,0 +1,8 @@ +#include "sprite.h" + +void setSpriteObjectAttributes(SpriteObject* spriteObject, u16 attribute0, u16 attribute1, u16 attribute2) +{ + spriteObject->attribute0 = attribute0; + spriteObject->attribute1 = attribute1; + spriteObject->attribute2 = attribute2; +} \ No newline at end of file diff --git a/examples/mapViewer/source/mapViewer/sprite/setSpriteObjectPosition.c b/examples/mapViewer/source/mapViewer/sprite/setSpriteObjectPosition.c new file mode 100644 index 0000000..61c6f22 --- /dev/null +++ b/examples/mapViewer/source/mapViewer/sprite/setSpriteObjectPosition.c @@ -0,0 +1,8 @@ +#include "sprite.h" +#include "../../gbaLib/bitField.h" + +void setSpriteObjectPosition(SpriteObject* spriteObject, ObjectPoint position) +{ + BIT_FIELD_SET(spriteObject->attribute0, position.y, ATTRIBUTE0_Y); + BIT_FIELD_SET(spriteObject->attribute1, position.x, ATTRIBUTE1_X); +} \ No newline at end of file diff --git a/examples/mapViewer/source/mapViewer/sprite/setSpritesOnScreen.c b/examples/mapViewer/source/mapViewer/sprite/setSpritesOnScreen.c new file mode 100644 index 0000000..768e554 --- /dev/null +++ b/examples/mapViewer/source/mapViewer/sprite/setSpritesOnScreen.c @@ -0,0 +1,6 @@ +#include "sprite.h" + +void setSpritesOnScreen() +{ + REGISTER_DISPLAY_CONTROL |= FLAG_SPRITE_OBJECTS | FLAG_1D_SPRITE_SHEET; +} \ No newline at end of file diff --git a/examples/mapViewer/source/mapViewer/sprite/sprite.h b/examples/mapViewer/source/mapViewer/sprite/sprite.h new file mode 100644 index 0000000..e7684f6 --- /dev/null +++ b/examples/mapViewer/source/mapViewer/sprite/sprite.h @@ -0,0 +1,16 @@ +#ifndef SPRITE_H +#define SPRITE_H + +#include "../../gbaLib/video/object.h" +#include "../map/object/object.h" + +void loadSpriteSheet(); +void initializeSpriteObjectMemory(SpriteObject *spriteObjects, u32 count); +void hideSpriteObjects(SpriteObject *spriteObjects, u32 count); +void copySpriteObjectsToMemory(const SpriteObject *spriteObjects, u32 count); +void setSpritesOnScreen(); +void mapObjectsToSpriteObjects(Object* mapObjects, SpriteObject* spriteObjects, u32 count); +void setSpriteObjectAttributes(SpriteObject* spriteObject, u16 attribute0, u16 attribute1, u16 attribute2); +void setSpriteObjectPosition(SpriteObject* spriteObject, ObjectPoint position); + +#endif \ No newline at end of file From 6cce71338105e4101aef377257f635199d4506c9 Mon Sep 17 00:00:00 2001 From: Luc van den Brand <10974297+LucvandenBrand@users.noreply.github.com> Date: Sat, 13 Oct 2018 18:54:02 +0200 Subject: [PATCH 20/25] Made object sprites render properly.: --- examples/mapViewer/source/asset/sprite.c | 79 ++++++------------- examples/mapViewer/source/asset/sprite.h | 4 +- .../mapViewer/source/gbaLib/video/object.h | 4 + .../sprite/mapObjectsToSpriteObjects.c | 2 +- 4 files changed, 30 insertions(+), 59 deletions(-) diff --git a/examples/mapViewer/source/asset/sprite.c b/examples/mapViewer/source/asset/sprite.c index f32541b..310567d 100644 --- a/examples/mapViewer/source/asset/sprite.c +++ b/examples/mapViewer/source/asset/sprite.c @@ -1,60 +1,27 @@ const unsigned short spritePalette[256] = { - 0x7c1f, 0x0557, 0x11bb, 0x47bf, 0x1bbe, 0x235a, 0x22da, 0x2276, 0x5c28, 0x6c8c, 0x0831, 0x1474, 0x019a, 0x0113, 0x0088, - 0x0001, 0x0156, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000 + 0x0000, 0x1884, 0x1CA8, 0x18EC, 0x1D51, 0x11DB, 0x329B, 0x4F1D, 0x1BDF, 0x2B93, 0x1AED, 0x3646, 0x15A9, 0x112A, 0x1CE6, + 0x38E7, 0x4186, 0x71AB, 0x7E6C, 0x732B, 0x7F79, 0x7FFF, 0x5AB3, 0x41F0, 0x35AD, 0x294B, 0x450E, 0x18D5, 0x315B, 0x5DFA, + 0x2651, 0x19B1, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000 }; -const unsigned short spriteTileSet[544] = { - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, 0x0201, 0x0202, 0x0202, 0x0202, 0x0202, 0x0303, 0x0303, 0x0303, 0x0402, 0x0302, 0x0303, 0x0303, 0x0402, - 0x0204, 0x0303, 0x0303, 0x0402, 0x0404, 0x0302, 0x0303, 0x0402, 0x0404, 0x0204, 0x0303, 0x0402, 0x0404, 0x0404, 0x0302, - 0x0402, 0x0404, 0x0404, 0x0204, 0x0201, 0x0202, 0x0202, 0x0202, 0x0303, 0x0303, 0x0303, 0x0101, 0x0303, 0x0303, 0x0103, - 0x0105, 0x0303, 0x0303, 0x0501, 0x0105, 0x0303, 0x0103, 0x0505, 0x0105, 0x0303, 0x0501, 0x0505, 0x0105, 0x0103, 0x0505, - 0x0505, 0x0105, 0x0501, 0x0505, 0x0505, 0x0105, 0x0401, 0x0404, 0x0404, 0x0104, 0x0402, 0x0404, 0x0404, 0x0601, 0x0402, - 0x0404, 0x0104, 0x0606, 0x0402, 0x0404, 0x0601, 0x0606, 0x0402, 0x0104, 0x0606, 0x0606, 0x0402, 0x0701, 0x0606, 0x0606, - 0x0102, 0x0707, 0x0707, 0x0707, 0x0202, 0x0202, 0x0202, 0x0202, 0x0502, 0x0505, 0x0505, 0x0205, 0x0206, 0x0505, 0x0505, - 0x0105, 0x0606, 0x0502, 0x0505, 0x0105, 0x0606, 0x0206, 0x0505, 0x0105, 0x0606, 0x0606, 0x0502, 0x0105, 0x0606, 0x0606, - 0x0207, 0x0105, 0x0707, 0x0707, 0x0707, 0x0102, 0x0202, 0x0202, 0x0202, 0x0102, 0x0808, 0x0808, 0x0808, 0x0808, 0x0808, - 0x0909, 0x0909, 0x0909, 0x0908, 0x0809, 0x0909, 0x0908, 0x0908, 0x0909, 0x0909, 0x0909, 0x0908, 0x0908, 0x0809, 0x0909, - 0x0908, 0x0909, 0x0909, 0x0909, 0x0908, 0x0809, 0x0909, 0x0908, 0x0908, 0x0909, 0x0909, 0x0909, 0x0808, 0x0808, 0x0808, - 0x0808, 0x0909, 0x0909, 0x0909, 0x0808, 0x0809, 0x0909, 0x0908, 0x0809, 0x0909, 0x0909, 0x0909, 0x0809, 0x0908, 0x0809, - 0x0809, 0x0809, 0x0909, 0x0909, 0x0909, 0x0809, 0x0809, 0x0909, 0x0908, 0x0809, 0x0909, 0x0909, 0x0909, 0x0809, 0x0908, - 0x0908, 0x0908, 0x0909, 0x0908, 0x0909, 0x0909, 0x0908, 0x0908, 0x0809, 0x0909, 0x0909, 0x0908, 0x0909, 0x0809, 0x0909, - 0x0908, 0x0909, 0x0909, 0x0909, 0x0908, 0x0809, 0x0909, 0x0908, 0x0808, 0x0909, 0x0909, 0x0909, 0x0808, 0x0808, 0x0808, - 0x0808, 0x0908, 0x0909, 0x0908, 0x0809, 0x0909, 0x0908, 0x0909, 0x0809, 0x0909, 0x0909, 0x0809, 0x0809, 0x0908, 0x0809, - 0x0909, 0x0809, 0x0909, 0x0909, 0x0909, 0x0809, 0x0809, 0x0909, 0x0908, 0x0809, 0x0909, 0x0909, 0x0909, 0x0808, 0x0808, - 0x0808, 0x0808, 0x0808, 0x0701, 0x0607, 0x0606, 0x0606, 0x0702, 0x0606, 0x0606, 0x0606, 0x0602, 0x0606, 0x0606, 0x0606, - 0x0602, 0x0606, 0x0606, 0x0606, 0x0602, 0x0606, 0x0606, 0x0606, 0x0702, 0x0606, 0x0606, 0x0606, 0x0702, 0x0607, 0x0606, - 0x0606, 0x0208, 0x0202, 0x0202, 0x0202, 0x0606, 0x0606, 0x0706, 0x0207, 0x0606, 0x0606, 0x0606, 0x0107, 0x0606, 0x0606, - 0x0606, 0x0106, 0x0606, 0x0606, 0x0606, 0x0106, 0x0606, 0x0606, 0x0606, 0x0106, 0x0606, 0x0606, 0x0606, 0x0107, 0x0606, - 0x0606, 0x0706, 0x0107, 0x0202, 0x0202, 0x0202, 0x0802, 0x0808, 0x0808, 0x0808, 0x0808, 0x0808, 0x0909, 0x0909, 0x0908, - 0x0908, 0x0809, 0x0909, 0x0909, 0x0908, 0x0909, 0x0809, 0x0909, 0x0908, 0x0909, 0x0909, 0x0909, 0x0908, 0x0809, 0x0909, - 0x0908, 0x0808, 0x0909, 0x0909, 0x0909, 0x0808, 0x0808, 0x0808, 0x0808, 0x0808, 0x0808, 0x0808, 0x0808, 0x0909, 0x0908, - 0x0909, 0x0808, 0x0909, 0x0909, 0x0809, 0x0809, 0x0908, 0x0809, 0x0909, 0x0809, 0x0909, 0x0909, 0x0909, 0x0809, 0x0809, - 0x0909, 0x0908, 0x0809, 0x0909, 0x0909, 0x0909, 0x0808, 0x0808, 0x0808, 0x0808, 0x0808, 0x0b0a, 0x0b0b, 0x0b0b, 0x0b0b, - 0x0c0b, 0x0c0c, 0x0d0c, 0x0f0e, 0x0c0b, 0x100c, 0x110f, 0x1111, 0x0c0b, 0x1110, 0x1111, 0x1111, 0x0c0b, 0x110f, 0x1111, - 0x1111, 0x0d0b, 0x1111, 0x1111, 0x1111, 0x0e0b, 0x1111, 0x1111, 0x1111, 0x0f0b, 0x1111, 0x1111, 0x1111, 0x0b0a, 0x0b0b, - 0x0b0b, 0x0b0b, 0x0e0f, 0x0c0d, 0x0c0c, 0x0a0c, 0x1111, 0x0f11, 0x0c10, 0x0a0c, 0x1111, 0x1111, 0x1011, 0x0a0c, 0x1111, - 0x1111, 0x0f11, 0x0a0c, 0x1111, 0x1111, 0x1111, 0x0a0d, 0x1111, 0x1111, 0x1111, 0x0a0e, 0x1111, 0x1111, 0x1111, 0x0a0f, - 0x0f0a, 0x1111, 0x1111, 0x1111, 0x0e0b, 0x1111, 0x1111, 0x1111, 0x0d0b, 0x1111, 0x1111, 0x1111, 0x0c0b, 0x110f, 0x1111, - 0x1111, 0x0c0b, 0x1110, 0x1111, 0x1111, 0x0c0b, 0x100c, 0x110f, 0x1111, 0x0c0b, 0x0c0c, 0x0d0c, 0x0f0e, 0x0a0b, 0x0a0a, - 0x0a0a, 0x0a0a, 0x1111, 0x1111, 0x1111, 0x0b0f, 0x1111, 0x1111, 0x1111, 0x0a0e, 0x1111, 0x1111, 0x1111, 0x0a0d, 0x1111, - 0x1111, 0x0f11, 0x0a0c, 0x1111, 0x1111, 0x1011, 0x0a0c, 0x1111, 0x0f11, 0x0c10, 0x0a0c, 0x0e0f, 0x0c0d, 0x0c0c, 0x0a0c, - 0x0a0b, 0x0a0a, 0x0a0a, 0x0a0a +const unsigned int spriteTileSet[32] = { + 0x00000000,0x58888550,0x88888350,0x33888880,0x83888880,0x83888880,0x33888880,0x88888850, + 0x00000000,0x05588885,0x05388888,0x08888833,0x08888838,0x08888838,0x08888833,0x05888888, + 0x33888850,0x83888880,0x33888880,0x83888880,0x33888880,0x88888350,0x58888550,0x00000000, + 0x05888833,0x08888838,0x08888883,0x08888838,0x08888833,0x05388888,0x05588885,0x00000000 }; diff --git a/examples/mapViewer/source/asset/sprite.h b/examples/mapViewer/source/asset/sprite.h index 3173fe7..6d416ab 100644 --- a/examples/mapViewer/source/asset/sprite.h +++ b/examples/mapViewer/source/asset/sprite.h @@ -3,5 +3,5 @@ #define spritePaletteLength 256 extern const unsigned short spritePalette[256]; -#define spriteTileSetLength 544 -extern const unsigned short spriteTileSet[544]; +#define spriteTileSetLength 64 +extern const unsigned int spriteTileSet[32]; \ No newline at end of file diff --git a/examples/mapViewer/source/gbaLib/video/object.h b/examples/mapViewer/source/gbaLib/video/object.h index a1643be..2112432 100644 --- a/examples/mapViewer/source/gbaLib/video/object.h +++ b/examples/mapViewer/source/gbaLib/video/object.h @@ -21,6 +21,10 @@ typedef struct #define ATTRIBUTE0_Y_SHIFT 0 #define ATTRIBUTE0_Y(n) ((n)< Date: Sat, 13 Oct 2018 21:42:08 +0200 Subject: [PATCH 21/25] Refactor of object rendering. --- .../source/gbaLib/video/background.h | 4 +-- .../gbaLib/video/{object.h => spriteObject.h} | 3 +- examples/mapViewer/source/mapViewer/main.c | 28 +++++++------------ examples/mapViewer/source/mapViewer/main.h | 11 ++++++++ .../source/mapViewer/map/loadMapFromCode.c | 2 +- .../source/mapViewer/map/loadMapFromROM.c | 2 +- examples/mapViewer/source/mapViewer/map/map.h | 8 +++--- .../map/{object => mapObject}/loadObject.c | 6 ++-- .../map/{object => mapObject}/loadObjectID.c | 2 +- .../map/{object => mapObject}/loadPosition.c | 2 +- .../map/{object => mapObject}/loadString.c | 2 +- .../object.h => mapObject/mapObject.h} | 10 +++---- .../map/{object => mapObject}/popValue.c | 2 +- .../{object => mapObject}/shiftMapObjects.c | 4 +-- .../mapViewer/source/mapViewer/map/shiftMap.c | 2 +- .../source/mapViewer/map/shiftMapLayer.c | 2 +- .../source/mapViewer/showMapObjects.c | 6 ++++ .../source/mapViewer/sprite/loadSpriteSheet.c | 2 +- .../sprite/mapObjectsToSpriteObjects.c | 2 +- .../source/mapViewer/sprite/sprite.h | 6 ++-- 20 files changed, 57 insertions(+), 49 deletions(-) rename examples/mapViewer/source/gbaLib/video/{object.h => spriteObject.h} (87%) create mode 100644 examples/mapViewer/source/mapViewer/main.h rename examples/mapViewer/source/mapViewer/map/{object => mapObject}/loadObject.c (68%) rename examples/mapViewer/source/mapViewer/map/{object => mapObject}/loadObjectID.c (87%) rename examples/mapViewer/source/mapViewer/map/{object => mapObject}/loadPosition.c (89%) rename examples/mapViewer/source/mapViewer/map/{object => mapObject}/loadString.c (89%) rename examples/mapViewer/source/mapViewer/map/{object/object.h => mapObject/mapObject.h} (68%) rename examples/mapViewer/source/mapViewer/map/{object => mapObject}/popValue.c (82%) rename examples/mapViewer/source/mapViewer/map/{object => mapObject}/shiftMapObjects.c (62%) create mode 100644 examples/mapViewer/source/mapViewer/showMapObjects.c diff --git a/examples/mapViewer/source/gbaLib/video/background.h b/examples/mapViewer/source/gbaLib/video/background.h index c471b9b..80c0fa7 100644 --- a/examples/mapViewer/source/gbaLib/video/background.h +++ b/examples/mapViewer/source/gbaLib/video/background.h @@ -15,7 +15,7 @@ typedef struct { typedef struct { s16 x, y; -} ALIGN(4) BGPoint; +} ALIGN(4) BackgroundPoint; typedef ScreenEntry ScreenBlock[1024]; typedef Tile CharBlock[512]; @@ -27,7 +27,7 @@ typedef Tile CharBlock[512]; #define MEMORY_CHAR_BLOCK ((CharBlock*)MEMORY_VIDEORAM) #define REGISTER_BACKGROUND_CONTROL ((vu16*)(REGISTER_BASE+0x0008)) -#define REGISTER_BACKGROUND_OFFSET ((BGPoint*)(REGISTER_BASE+0x0010)) +#define REGISTER_BACKGROUND_OFFSET ((BackgroundPoint*)(REGISTER_BASE+0x0010)) #define FLAG_BACKGROUND_4BPP 0 #define FLAG_BACKGROUND_8BPP 0x0080 diff --git a/examples/mapViewer/source/gbaLib/video/object.h b/examples/mapViewer/source/gbaLib/video/spriteObject.h similarity index 87% rename from examples/mapViewer/source/gbaLib/video/object.h rename to examples/mapViewer/source/gbaLib/video/spriteObject.h index 2112432..b2a9a24 100644 --- a/examples/mapViewer/source/gbaLib/video/object.h +++ b/examples/mapViewer/source/gbaLib/video/spriteObject.h @@ -12,7 +12,7 @@ typedef struct s16 fill; } ALIGN(4) SpriteObject; -#define MEMORY_OBJECT_PALETTE ((Color*)(MEMORY_PALETTE + MEMORY_BACKGROUND_PALETTE_SIZE)) +#define MEMORY_SPRITE_OBJECT_PALETTE ((Color*)(MEMORY_PALETTE + MEMORY_BACKGROUND_PALETTE_SIZE)) #define MEMORY_SPRITE_OBJECTS ((SpriteObject*)MEMORY_OBJECT_ATTRIBUTES) #define ATTRIBUTE0_HIDE 0x0200 @@ -21,7 +21,6 @@ typedef struct #define ATTRIBUTE0_Y_SHIFT 0 #define ATTRIBUTE0_Y(n) ((n)<objects, spriteObjects, map->numObjects); + copySpriteObjectsToMemory(spriteObjects, map->numObjects); +} \ No newline at end of file diff --git a/examples/mapViewer/source/mapViewer/sprite/loadSpriteSheet.c b/examples/mapViewer/source/mapViewer/sprite/loadSpriteSheet.c index 3827ba3..0da2a29 100644 --- a/examples/mapViewer/source/mapViewer/sprite/loadSpriteSheet.c +++ b/examples/mapViewer/source/mapViewer/sprite/loadSpriteSheet.c @@ -4,6 +4,6 @@ void loadSpriteSheet() { - memcpy(MEMORY_OBJECT_PALETTE, spritePalette, spritePaletteLength * 2); + memcpy(MEMORY_SPRITE_OBJECT_PALETTE, spritePalette, spritePaletteLength * 2); memcpy(&MEMORY_CHAR_BLOCK[4][0], spriteTileSet, spriteTileSetLength * 2); }; \ No newline at end of file diff --git a/examples/mapViewer/source/mapViewer/sprite/mapObjectsToSpriteObjects.c b/examples/mapViewer/source/mapViewer/sprite/mapObjectsToSpriteObjects.c index 3b4fdc0..5e83067 100644 --- a/examples/mapViewer/source/mapViewer/sprite/mapObjectsToSpriteObjects.c +++ b/examples/mapViewer/source/mapViewer/sprite/mapObjectsToSpriteObjects.c @@ -1,6 +1,6 @@ #include "sprite.h" -void mapObjectsToSpriteObjects(Object* mapObjects, SpriteObject* spriteObjects, u32 count) +void mapObjectsToSpriteObjects(MapObject* mapObjects, SpriteObject* spriteObjects, u32 count) { for (u32 index = 0; index < count; index++) { diff --git a/examples/mapViewer/source/mapViewer/sprite/sprite.h b/examples/mapViewer/source/mapViewer/sprite/sprite.h index e7684f6..21f1ccb 100644 --- a/examples/mapViewer/source/mapViewer/sprite/sprite.h +++ b/examples/mapViewer/source/mapViewer/sprite/sprite.h @@ -1,15 +1,15 @@ #ifndef SPRITE_H #define SPRITE_H -#include "../../gbaLib/video/object.h" -#include "../map/object/object.h" +#include "../../gbaLib/video/spriteObject.h" +#include "../map/mapObject/mapObject.h" void loadSpriteSheet(); void initializeSpriteObjectMemory(SpriteObject *spriteObjects, u32 count); void hideSpriteObjects(SpriteObject *spriteObjects, u32 count); void copySpriteObjectsToMemory(const SpriteObject *spriteObjects, u32 count); void setSpritesOnScreen(); -void mapObjectsToSpriteObjects(Object* mapObjects, SpriteObject* spriteObjects, u32 count); +void mapObjectsToSpriteObjects(MapObject* mapObjects, SpriteObject* spriteObjects, u32 count); void setSpriteObjectAttributes(SpriteObject* spriteObject, u16 attribute0, u16 attribute1, u16 attribute2); void setSpriteObjectPosition(SpriteObject* spriteObject, ObjectPoint position); From 23498cac70c27e2a9558dad0f5ad2fc423f7c400 Mon Sep 17 00:00:00 2001 From: Luc van den Brand <10974297+LucvandenBrand@users.noreply.github.com> Date: Sat, 13 Oct 2018 22:30:20 +0200 Subject: [PATCH 22/25] Tweaks and fixes for precision. --- examples/assets/size16-terrain-objects/map.tmx | 2 +- .../source/mapViewer/map/mapObject/shiftMapObjects.c | 4 ++-- .../source/mapViewer/sprite/setSpriteObjectPosition.c | 4 ++-- .../objectLayerConverter/objectLayerConverter.cpp | 9 +++++++-- 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/examples/assets/size16-terrain-objects/map.tmx b/examples/assets/size16-terrain-objects/map.tmx index 11d362b..1a641cf 100644 --- a/examples/assets/size16-terrain-objects/map.tmx +++ b/examples/assets/size16-terrain-objects/map.tmx @@ -32,6 +32,6 @@ - + diff --git a/examples/mapViewer/source/mapViewer/map/mapObject/shiftMapObjects.c b/examples/mapViewer/source/mapViewer/map/mapObject/shiftMapObjects.c index 7d1c816..22a79bb 100644 --- a/examples/mapViewer/source/mapViewer/map/mapObject/shiftMapObjects.c +++ b/examples/mapViewer/source/mapViewer/map/mapObject/shiftMapObjects.c @@ -4,7 +4,7 @@ void shiftMapObjects(MapObject* objects, ObjectPoint shift, u32 count) { for (u32 index = 0; index < count; index++) { - objects[index].position.x += shift.x; - objects[index].position.y += shift.y; + objects[index].position.x -= shift.x; + objects[index].position.y -= shift.y; } } \ No newline at end of file diff --git a/examples/mapViewer/source/mapViewer/sprite/setSpriteObjectPosition.c b/examples/mapViewer/source/mapViewer/sprite/setSpriteObjectPosition.c index 61c6f22..022e31f 100644 --- a/examples/mapViewer/source/mapViewer/sprite/setSpriteObjectPosition.c +++ b/examples/mapViewer/source/mapViewer/sprite/setSpriteObjectPosition.c @@ -3,6 +3,6 @@ void setSpriteObjectPosition(SpriteObject* spriteObject, ObjectPoint position) { - BIT_FIELD_SET(spriteObject->attribute0, position.y, ATTRIBUTE0_Y); - BIT_FIELD_SET(spriteObject->attribute1, position.x, ATTRIBUTE1_X); + BIT_FIELD_SET(spriteObject->attribute0, position.y - 8, ATTRIBUTE0_Y); + BIT_FIELD_SET(spriteObject->attribute1, position.x - 8, ATTRIBUTE1_X); } \ No newline at end of file diff --git a/src/mapConverter/objectLayerConverter/objectLayerConverter.cpp b/src/mapConverter/objectLayerConverter/objectLayerConverter.cpp index fa79e7a..1fe2ecd 100644 --- a/src/mapConverter/objectLayerConverter/objectLayerConverter.cpp +++ b/src/mapConverter/objectLayerConverter/objectLayerConverter.cpp @@ -24,9 +24,14 @@ vector ObjectLayerConverter::convert(const tmx::Object &object) { auto lowerId = (uint16_t) id; bytes.push_back(lowerId); - auto xPosition = (uint16_t) object.getPosition().x; + auto halfWidth = (int16_t) (object.getAABB().width / 2); + auto halfHeight = (int16_t) (object.getAABB().height / 2); + if (object.getTileID() > 0) + halfHeight *= -1; + + auto xPosition = (uint16_t) object.getPosition().x + halfWidth; bytes.push_back(xPosition); - auto yPosition = (uint16_t) object.getPosition().y; + auto yPosition = (uint16_t) object.getPosition().y + halfHeight; bytes.push_back(yPosition); StringConverter stringConverter; From 26b4b32dc0441e72822f6c63b28259a6e6813651 Mon Sep 17 00:00:00 2001 From: Luc van den Brand <10974297+LucvandenBrand@users.noreply.github.com> Date: Sun, 14 Oct 2018 17:46:45 +0200 Subject: [PATCH 23/25] Made gbfs and padbin be compile in the main cmake file. --- CMakeLists.txt | 16 ++++++++++++---- examples/mapViewer/gbfs/Makefile | 15 --------------- .../{assets => }/size16-terrain-objects/map.tmx | 0 .../size16-terrain-objects/tileset.aseprite | Bin .../size16-terrain-objects/tileset.png | Bin .../size16-terrain-objects/untitled.tsx | 0 examples/{assets => }/size16-terrain/map.tmx | 0 .../size16-terrain/tileset.aseprite | Bin .../{assets => }/size16-terrain/tileset.png | Bin .../{assets => }/size16-terrain/untitled.tsx | 0 examples/{assets => }/size16-town/map.tmx | 0 examples/{assets => }/size16-town/tileset.png | Bin examples/{assets => }/size16-town/tileset.tsx | 0 examples/{assets => }/size16/map.tmx | 0 examples/{assets => }/size16/tileset.aseprite | Bin examples/{assets => }/size16/tileset.png | Bin examples/{assets => }/size16/untitled.tsx | 0 .../{assets => }/size32-large-layered/map.tmx | 0 .../size32-large-layered/tileset.png | Bin .../size32-large-layered/tileset.tsx | 0 examples/{assets => }/size32-large/map.tmx | 0 examples/{assets => }/size32-large/tileset.png | Bin examples/{assets => }/size32-large/tileset.tsx | 0 examples/{assets => }/size32-long/map.tmx | 0 examples/{assets => }/size32-long/tileset.png | Bin examples/{assets => }/size32-long/tileset.tsx | 0 .../{assets => }/size32-wide-wrong-size/map.tmx | 0 .../size32-wide-wrong-size/tileset.png | Bin .../size32-wide-wrong-size/tileset.tsx | 0 examples/{assets => }/size32-wide/map.tmx | 0 examples/{assets => }/size32-wide/tileset.png | Bin examples/{assets => }/size32-wide/tileset.tsx | 0 examples/{assets => }/size8-2/map.tmx | 0 examples/{assets => }/size8-2/tileset.aseprite | Bin examples/{assets => }/size8-2/tileset.png | Bin examples/{assets => }/size8-2/untitled.tsx | 0 examples/{assets => }/size8-3/map.tmx | 0 examples/{assets => }/size8-3/tileset.aseprite | Bin examples/{assets => }/size8-3/tileset.png | Bin examples/{assets => }/size8-3/untitled.tsx | 0 examples/{assets => }/size8-4/map.tmx | 0 examples/{assets => }/size8-4/tileset.aseprite | Bin examples/{assets => }/size8-4/tileset.png | Bin examples/{assets => }/size8-4/untitled.tsx | 0 examples/{assets => }/size8/grass.aseprite | Bin examples/{assets => }/size8/map.tmx | 0 examples/{assets => }/size8/sky.aseprite | Bin examples/{assets => }/size8/tileset.tsx | 0 examples/{assets => }/size8/tilesheet.png | Bin {examples/mapViewer => tools}/gbfs/gbfs.c | 0 {examples/mapViewer => tools}/gbfs/gbfs.h | 0 {examples => tools}/mapViewer/.gitignore | 2 -- {examples => tools}/mapViewer/Makefile | 4 ++-- {examples => tools}/mapViewer/README.md | 0 .../mapViewer/source/asset/map.c | 0 .../mapViewer/source/asset/map.h | 0 .../mapViewer/source/asset/sprite.c | 0 .../mapViewer/source/asset/sprite.h | 0 .../mapViewer/source/gbaLib/bitField.h | 0 .../mapViewer/source/gbaLib/gbfs/gbfs.h | 0 .../mapViewer/source/gbaLib/gbfs/libgbfs.c | 0 .../mapViewer/source/gbaLib/input/input.h | 0 .../mapViewer/source/gbaLib/memoryMap.h | 0 .../mapViewer/source/gbaLib/types.h | 0 .../mapViewer/source/gbaLib/video/background.h | 0 .../source/gbaLib/video/spriteObject.h | 0 .../mapViewer/source/gbaLib/video/video.h | 0 .../mapViewer/source/mapViewer/main.c | 0 .../mapViewer/source/mapViewer/main.h | 0 .../mapViewer/source/mapViewer/map/loadMap.c | 0 .../source/mapViewer/map/loadMapFromCode.c | 0 .../source/mapViewer/map/loadMapFromROM.c | 0 .../mapViewer/source/mapViewer/map/map.h | 0 .../source/mapViewer/map/mapObject/loadObject.c | 0 .../mapViewer/map/mapObject/loadObjectID.c | 0 .../mapViewer/map/mapObject/loadPosition.c | 0 .../source/mapViewer/map/mapObject/loadString.c | 0 .../source/mapViewer/map/mapObject/mapObject.h | 0 .../source/mapViewer/map/mapObject/popValue.c | 0 .../mapViewer/map/mapObject/shiftMapObjects.c | 0 .../source/mapViewer/map/setMapOnScreen.c | 0 .../mapViewer/source/mapViewer/map/shiftMap.c | 0 .../source/mapViewer/map/shiftMapLayer.c | 0 .../mapViewer/source/mapViewer/showMapObjects.c | 0 .../sprite/copySpriteObjectsToMemory.c | 0 .../source/mapViewer/sprite/hideSpriteObjects.c | 0 .../sprite/initializeSpriteObjectMemory.c | 0 .../source/mapViewer/sprite/loadSpriteSheet.c | 0 .../sprite/mapObjectsToSpriteObjects.c | 0 .../sprite/setSpriteObjectAttributes.c | 0 .../mapViewer/sprite/setSpriteObjectPosition.c | 0 .../mapViewer/sprite/setSpritesOnScreen.c | 0 .../mapViewer/source/mapViewer/sprite/sprite.h | 0 .../mapViewer/gbfs => tools/padbin}/padbin.c | 0 94 files changed, 14 insertions(+), 23 deletions(-) delete mode 100644 examples/mapViewer/gbfs/Makefile rename examples/{assets => }/size16-terrain-objects/map.tmx (100%) rename examples/{assets => }/size16-terrain-objects/tileset.aseprite (100%) rename examples/{assets => }/size16-terrain-objects/tileset.png (100%) rename examples/{assets => }/size16-terrain-objects/untitled.tsx (100%) rename examples/{assets => }/size16-terrain/map.tmx (100%) rename examples/{assets => }/size16-terrain/tileset.aseprite (100%) rename examples/{assets => }/size16-terrain/tileset.png (100%) rename examples/{assets => }/size16-terrain/untitled.tsx (100%) rename examples/{assets => }/size16-town/map.tmx (100%) rename examples/{assets => }/size16-town/tileset.png (100%) rename examples/{assets => }/size16-town/tileset.tsx (100%) rename examples/{assets => }/size16/map.tmx (100%) rename examples/{assets => }/size16/tileset.aseprite (100%) rename examples/{assets => }/size16/tileset.png (100%) rename examples/{assets => }/size16/untitled.tsx (100%) rename examples/{assets => }/size32-large-layered/map.tmx (100%) rename examples/{assets => }/size32-large-layered/tileset.png (100%) rename examples/{assets => }/size32-large-layered/tileset.tsx (100%) rename examples/{assets => }/size32-large/map.tmx (100%) rename examples/{assets => }/size32-large/tileset.png (100%) rename examples/{assets => }/size32-large/tileset.tsx (100%) rename examples/{assets => }/size32-long/map.tmx (100%) rename examples/{assets => }/size32-long/tileset.png (100%) rename examples/{assets => }/size32-long/tileset.tsx (100%) rename examples/{assets => }/size32-wide-wrong-size/map.tmx (100%) rename examples/{assets => }/size32-wide-wrong-size/tileset.png (100%) rename examples/{assets => }/size32-wide-wrong-size/tileset.tsx (100%) rename examples/{assets => }/size32-wide/map.tmx (100%) rename examples/{assets => }/size32-wide/tileset.png (100%) rename examples/{assets => }/size32-wide/tileset.tsx (100%) rename examples/{assets => }/size8-2/map.tmx (100%) rename examples/{assets => }/size8-2/tileset.aseprite (100%) rename examples/{assets => }/size8-2/tileset.png (100%) rename examples/{assets => }/size8-2/untitled.tsx (100%) rename examples/{assets => }/size8-3/map.tmx (100%) rename examples/{assets => }/size8-3/tileset.aseprite (100%) rename examples/{assets => }/size8-3/tileset.png (100%) rename examples/{assets => }/size8-3/untitled.tsx (100%) rename examples/{assets => }/size8-4/map.tmx (100%) rename examples/{assets => }/size8-4/tileset.aseprite (100%) rename examples/{assets => }/size8-4/tileset.png (100%) rename examples/{assets => }/size8-4/untitled.tsx (100%) rename examples/{assets => }/size8/grass.aseprite (100%) rename examples/{assets => }/size8/map.tmx (100%) rename examples/{assets => }/size8/sky.aseprite (100%) rename examples/{assets => }/size8/tileset.tsx (100%) rename examples/{assets => }/size8/tilesheet.png (100%) rename {examples/mapViewer => tools}/gbfs/gbfs.c (100%) rename {examples/mapViewer => tools}/gbfs/gbfs.h (100%) rename {examples => tools}/mapViewer/.gitignore (71%) rename {examples => tools}/mapViewer/Makefile (93%) rename {examples => tools}/mapViewer/README.md (100%) rename {examples => tools}/mapViewer/source/asset/map.c (100%) rename {examples => tools}/mapViewer/source/asset/map.h (100%) rename {examples => tools}/mapViewer/source/asset/sprite.c (100%) rename {examples => tools}/mapViewer/source/asset/sprite.h (100%) rename {examples => tools}/mapViewer/source/gbaLib/bitField.h (100%) rename {examples => tools}/mapViewer/source/gbaLib/gbfs/gbfs.h (100%) rename {examples => tools}/mapViewer/source/gbaLib/gbfs/libgbfs.c (100%) rename {examples => tools}/mapViewer/source/gbaLib/input/input.h (100%) rename {examples => tools}/mapViewer/source/gbaLib/memoryMap.h (100%) rename {examples => tools}/mapViewer/source/gbaLib/types.h (100%) rename {examples => tools}/mapViewer/source/gbaLib/video/background.h (100%) rename {examples => tools}/mapViewer/source/gbaLib/video/spriteObject.h (100%) rename {examples => tools}/mapViewer/source/gbaLib/video/video.h (100%) rename {examples => tools}/mapViewer/source/mapViewer/main.c (100%) rename {examples => tools}/mapViewer/source/mapViewer/main.h (100%) rename {examples => tools}/mapViewer/source/mapViewer/map/loadMap.c (100%) rename {examples => tools}/mapViewer/source/mapViewer/map/loadMapFromCode.c (100%) rename {examples => tools}/mapViewer/source/mapViewer/map/loadMapFromROM.c (100%) rename {examples => tools}/mapViewer/source/mapViewer/map/map.h (100%) rename {examples => tools}/mapViewer/source/mapViewer/map/mapObject/loadObject.c (100%) rename {examples => tools}/mapViewer/source/mapViewer/map/mapObject/loadObjectID.c (100%) rename {examples => tools}/mapViewer/source/mapViewer/map/mapObject/loadPosition.c (100%) rename {examples => tools}/mapViewer/source/mapViewer/map/mapObject/loadString.c (100%) rename {examples => tools}/mapViewer/source/mapViewer/map/mapObject/mapObject.h (100%) rename {examples => tools}/mapViewer/source/mapViewer/map/mapObject/popValue.c (100%) rename {examples => tools}/mapViewer/source/mapViewer/map/mapObject/shiftMapObjects.c (100%) rename {examples => tools}/mapViewer/source/mapViewer/map/setMapOnScreen.c (100%) rename {examples => tools}/mapViewer/source/mapViewer/map/shiftMap.c (100%) rename {examples => tools}/mapViewer/source/mapViewer/map/shiftMapLayer.c (100%) rename {examples => tools}/mapViewer/source/mapViewer/showMapObjects.c (100%) rename {examples => tools}/mapViewer/source/mapViewer/sprite/copySpriteObjectsToMemory.c (100%) rename {examples => tools}/mapViewer/source/mapViewer/sprite/hideSpriteObjects.c (100%) rename {examples => tools}/mapViewer/source/mapViewer/sprite/initializeSpriteObjectMemory.c (100%) rename {examples => tools}/mapViewer/source/mapViewer/sprite/loadSpriteSheet.c (100%) rename {examples => tools}/mapViewer/source/mapViewer/sprite/mapObjectsToSpriteObjects.c (100%) rename {examples => tools}/mapViewer/source/mapViewer/sprite/setSpriteObjectAttributes.c (100%) rename {examples => tools}/mapViewer/source/mapViewer/sprite/setSpriteObjectPosition.c (100%) rename {examples => tools}/mapViewer/source/mapViewer/sprite/setSpritesOnScreen.c (100%) rename {examples => tools}/mapViewer/source/mapViewer/sprite/sprite.h (100%) rename {examples/mapViewer/gbfs => tools/padbin}/padbin.c (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index efb2845..a30257e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,9 +1,17 @@ cmake_minimum_required(VERSION 3.9) project(Tiled2GBA) -# Source location. -file(GLOB_RECURSE SOURCES src/*.c src/*.cpp src/*.h src/*.hpp src/*.inl) - # Compilation settings. set(CMAKE_CXX_STANDARD 17) -add_executable(${PROJECT_NAME} ${SOURCES}) + +# Build Tiled2GBA +file(GLOB_RECURSE PROJECT_SOURCES src/*.c src/*.cpp src/*.h src/*.hpp src/*.inl) +add_executable(${PROJECT_NAME} ${PROJECT_SOURCES}) +add_dependencies(${PROJECT_NAME} gbfs padbin) + +# Build additional tools. +file(GLOB_RECURSE GBFS_SOURCES tools/gbfs/*.c tools/gbfs/*.h) +add_executable(gbfs ${GBFS_SOURCES}) + +file(GLOB_RECURSE PADBIN_SOURCES tools/padbin/*.c tools/padbin/*.h) +add_executable(padbin ${PADBIN_SOURCES}) \ No newline at end of file diff --git a/examples/mapViewer/gbfs/Makefile b/examples/mapViewer/gbfs/Makefile deleted file mode 100644 index acef061..0000000 --- a/examples/mapViewer/gbfs/Makefile +++ /dev/null @@ -1,15 +0,0 @@ -# Builds the required gbfs tools - -build : gbfs padbin - -gbfs : gbfs.h gbfs.c - gcc -Wall -O2 gbfs.c -o gbfs - -padbin : padbin.c - gcc -Wall -O2 padbin.c -o padbin - -clean : - @rm -fv gbfs - @rm -fv padbin - -#EOF diff --git a/examples/assets/size16-terrain-objects/map.tmx b/examples/size16-terrain-objects/map.tmx similarity index 100% rename from examples/assets/size16-terrain-objects/map.tmx rename to examples/size16-terrain-objects/map.tmx diff --git a/examples/assets/size16-terrain-objects/tileset.aseprite b/examples/size16-terrain-objects/tileset.aseprite similarity index 100% rename from examples/assets/size16-terrain-objects/tileset.aseprite rename to examples/size16-terrain-objects/tileset.aseprite diff --git a/examples/assets/size16-terrain-objects/tileset.png b/examples/size16-terrain-objects/tileset.png similarity index 100% rename from examples/assets/size16-terrain-objects/tileset.png rename to examples/size16-terrain-objects/tileset.png diff --git a/examples/assets/size16-terrain-objects/untitled.tsx b/examples/size16-terrain-objects/untitled.tsx similarity index 100% rename from examples/assets/size16-terrain-objects/untitled.tsx rename to examples/size16-terrain-objects/untitled.tsx diff --git a/examples/assets/size16-terrain/map.tmx b/examples/size16-terrain/map.tmx similarity index 100% rename from examples/assets/size16-terrain/map.tmx rename to examples/size16-terrain/map.tmx diff --git a/examples/assets/size16-terrain/tileset.aseprite b/examples/size16-terrain/tileset.aseprite similarity index 100% rename from examples/assets/size16-terrain/tileset.aseprite rename to examples/size16-terrain/tileset.aseprite diff --git a/examples/assets/size16-terrain/tileset.png b/examples/size16-terrain/tileset.png similarity index 100% rename from examples/assets/size16-terrain/tileset.png rename to examples/size16-terrain/tileset.png diff --git a/examples/assets/size16-terrain/untitled.tsx b/examples/size16-terrain/untitled.tsx similarity index 100% rename from examples/assets/size16-terrain/untitled.tsx rename to examples/size16-terrain/untitled.tsx diff --git a/examples/assets/size16-town/map.tmx b/examples/size16-town/map.tmx similarity index 100% rename from examples/assets/size16-town/map.tmx rename to examples/size16-town/map.tmx diff --git a/examples/assets/size16-town/tileset.png b/examples/size16-town/tileset.png similarity index 100% rename from examples/assets/size16-town/tileset.png rename to examples/size16-town/tileset.png diff --git a/examples/assets/size16-town/tileset.tsx b/examples/size16-town/tileset.tsx similarity index 100% rename from examples/assets/size16-town/tileset.tsx rename to examples/size16-town/tileset.tsx diff --git a/examples/assets/size16/map.tmx b/examples/size16/map.tmx similarity index 100% rename from examples/assets/size16/map.tmx rename to examples/size16/map.tmx diff --git a/examples/assets/size16/tileset.aseprite b/examples/size16/tileset.aseprite similarity index 100% rename from examples/assets/size16/tileset.aseprite rename to examples/size16/tileset.aseprite diff --git a/examples/assets/size16/tileset.png b/examples/size16/tileset.png similarity index 100% rename from examples/assets/size16/tileset.png rename to examples/size16/tileset.png diff --git a/examples/assets/size16/untitled.tsx b/examples/size16/untitled.tsx similarity index 100% rename from examples/assets/size16/untitled.tsx rename to examples/size16/untitled.tsx diff --git a/examples/assets/size32-large-layered/map.tmx b/examples/size32-large-layered/map.tmx similarity index 100% rename from examples/assets/size32-large-layered/map.tmx rename to examples/size32-large-layered/map.tmx diff --git a/examples/assets/size32-large-layered/tileset.png b/examples/size32-large-layered/tileset.png similarity index 100% rename from examples/assets/size32-large-layered/tileset.png rename to examples/size32-large-layered/tileset.png diff --git a/examples/assets/size32-large-layered/tileset.tsx b/examples/size32-large-layered/tileset.tsx similarity index 100% rename from examples/assets/size32-large-layered/tileset.tsx rename to examples/size32-large-layered/tileset.tsx diff --git a/examples/assets/size32-large/map.tmx b/examples/size32-large/map.tmx similarity index 100% rename from examples/assets/size32-large/map.tmx rename to examples/size32-large/map.tmx diff --git a/examples/assets/size32-large/tileset.png b/examples/size32-large/tileset.png similarity index 100% rename from examples/assets/size32-large/tileset.png rename to examples/size32-large/tileset.png diff --git a/examples/assets/size32-large/tileset.tsx b/examples/size32-large/tileset.tsx similarity index 100% rename from examples/assets/size32-large/tileset.tsx rename to examples/size32-large/tileset.tsx diff --git a/examples/assets/size32-long/map.tmx b/examples/size32-long/map.tmx similarity index 100% rename from examples/assets/size32-long/map.tmx rename to examples/size32-long/map.tmx diff --git a/examples/assets/size32-long/tileset.png b/examples/size32-long/tileset.png similarity index 100% rename from examples/assets/size32-long/tileset.png rename to examples/size32-long/tileset.png diff --git a/examples/assets/size32-long/tileset.tsx b/examples/size32-long/tileset.tsx similarity index 100% rename from examples/assets/size32-long/tileset.tsx rename to examples/size32-long/tileset.tsx diff --git a/examples/assets/size32-wide-wrong-size/map.tmx b/examples/size32-wide-wrong-size/map.tmx similarity index 100% rename from examples/assets/size32-wide-wrong-size/map.tmx rename to examples/size32-wide-wrong-size/map.tmx diff --git a/examples/assets/size32-wide-wrong-size/tileset.png b/examples/size32-wide-wrong-size/tileset.png similarity index 100% rename from examples/assets/size32-wide-wrong-size/tileset.png rename to examples/size32-wide-wrong-size/tileset.png diff --git a/examples/assets/size32-wide-wrong-size/tileset.tsx b/examples/size32-wide-wrong-size/tileset.tsx similarity index 100% rename from examples/assets/size32-wide-wrong-size/tileset.tsx rename to examples/size32-wide-wrong-size/tileset.tsx diff --git a/examples/assets/size32-wide/map.tmx b/examples/size32-wide/map.tmx similarity index 100% rename from examples/assets/size32-wide/map.tmx rename to examples/size32-wide/map.tmx diff --git a/examples/assets/size32-wide/tileset.png b/examples/size32-wide/tileset.png similarity index 100% rename from examples/assets/size32-wide/tileset.png rename to examples/size32-wide/tileset.png diff --git a/examples/assets/size32-wide/tileset.tsx b/examples/size32-wide/tileset.tsx similarity index 100% rename from examples/assets/size32-wide/tileset.tsx rename to examples/size32-wide/tileset.tsx diff --git a/examples/assets/size8-2/map.tmx b/examples/size8-2/map.tmx similarity index 100% rename from examples/assets/size8-2/map.tmx rename to examples/size8-2/map.tmx diff --git a/examples/assets/size8-2/tileset.aseprite b/examples/size8-2/tileset.aseprite similarity index 100% rename from examples/assets/size8-2/tileset.aseprite rename to examples/size8-2/tileset.aseprite diff --git a/examples/assets/size8-2/tileset.png b/examples/size8-2/tileset.png similarity index 100% rename from examples/assets/size8-2/tileset.png rename to examples/size8-2/tileset.png diff --git a/examples/assets/size8-2/untitled.tsx b/examples/size8-2/untitled.tsx similarity index 100% rename from examples/assets/size8-2/untitled.tsx rename to examples/size8-2/untitled.tsx diff --git a/examples/assets/size8-3/map.tmx b/examples/size8-3/map.tmx similarity index 100% rename from examples/assets/size8-3/map.tmx rename to examples/size8-3/map.tmx diff --git a/examples/assets/size8-3/tileset.aseprite b/examples/size8-3/tileset.aseprite similarity index 100% rename from examples/assets/size8-3/tileset.aseprite rename to examples/size8-3/tileset.aseprite diff --git a/examples/assets/size8-3/tileset.png b/examples/size8-3/tileset.png similarity index 100% rename from examples/assets/size8-3/tileset.png rename to examples/size8-3/tileset.png diff --git a/examples/assets/size8-3/untitled.tsx b/examples/size8-3/untitled.tsx similarity index 100% rename from examples/assets/size8-3/untitled.tsx rename to examples/size8-3/untitled.tsx diff --git a/examples/assets/size8-4/map.tmx b/examples/size8-4/map.tmx similarity index 100% rename from examples/assets/size8-4/map.tmx rename to examples/size8-4/map.tmx diff --git a/examples/assets/size8-4/tileset.aseprite b/examples/size8-4/tileset.aseprite similarity index 100% rename from examples/assets/size8-4/tileset.aseprite rename to examples/size8-4/tileset.aseprite diff --git a/examples/assets/size8-4/tileset.png b/examples/size8-4/tileset.png similarity index 100% rename from examples/assets/size8-4/tileset.png rename to examples/size8-4/tileset.png diff --git a/examples/assets/size8-4/untitled.tsx b/examples/size8-4/untitled.tsx similarity index 100% rename from examples/assets/size8-4/untitled.tsx rename to examples/size8-4/untitled.tsx diff --git a/examples/assets/size8/grass.aseprite b/examples/size8/grass.aseprite similarity index 100% rename from examples/assets/size8/grass.aseprite rename to examples/size8/grass.aseprite diff --git a/examples/assets/size8/map.tmx b/examples/size8/map.tmx similarity index 100% rename from examples/assets/size8/map.tmx rename to examples/size8/map.tmx diff --git a/examples/assets/size8/sky.aseprite b/examples/size8/sky.aseprite similarity index 100% rename from examples/assets/size8/sky.aseprite rename to examples/size8/sky.aseprite diff --git a/examples/assets/size8/tileset.tsx b/examples/size8/tileset.tsx similarity index 100% rename from examples/assets/size8/tileset.tsx rename to examples/size8/tileset.tsx diff --git a/examples/assets/size8/tilesheet.png b/examples/size8/tilesheet.png similarity index 100% rename from examples/assets/size8/tilesheet.png rename to examples/size8/tilesheet.png diff --git a/examples/mapViewer/gbfs/gbfs.c b/tools/gbfs/gbfs.c similarity index 100% rename from examples/mapViewer/gbfs/gbfs.c rename to tools/gbfs/gbfs.c diff --git a/examples/mapViewer/gbfs/gbfs.h b/tools/gbfs/gbfs.h similarity index 100% rename from examples/mapViewer/gbfs/gbfs.h rename to tools/gbfs/gbfs.h diff --git a/examples/mapViewer/.gitignore b/tools/mapViewer/.gitignore similarity index 71% rename from examples/mapViewer/.gitignore rename to tools/mapViewer/.gitignore index d66963b..9a74d5f 100644 --- a/examples/mapViewer/.gitignore +++ b/tools/mapViewer/.gitignore @@ -5,5 +5,3 @@ *.sav *.bin *.gbfs -gbfs/gbfs -gbfs/padbin diff --git a/examples/mapViewer/Makefile b/tools/mapViewer/Makefile similarity index 93% rename from examples/mapViewer/Makefile rename to tools/mapViewer/Makefile index d0c97e1..00b8785 100644 --- a/examples/mapViewer/Makefile +++ b/tools/mapViewer/Makefile @@ -32,8 +32,8 @@ OBJECTS := $(SOURCES:%.c=%.o) build : $(NAME).gba append: $(NAME).gba - ./gbfs/gbfs $(MAP).gbfs $(MAP).bin - ./gbfs/padbin 256 $< + ../gbfs $(MAP).gbfs $(MAP).bin + ../padbin 256 $< cat $< $(MAP).gbfs > $(NAME)_append.gba $(NAME).gba : $(NAME).elf diff --git a/examples/mapViewer/README.md b/tools/mapViewer/README.md similarity index 100% rename from examples/mapViewer/README.md rename to tools/mapViewer/README.md diff --git a/examples/mapViewer/source/asset/map.c b/tools/mapViewer/source/asset/map.c similarity index 100% rename from examples/mapViewer/source/asset/map.c rename to tools/mapViewer/source/asset/map.c diff --git a/examples/mapViewer/source/asset/map.h b/tools/mapViewer/source/asset/map.h similarity index 100% rename from examples/mapViewer/source/asset/map.h rename to tools/mapViewer/source/asset/map.h diff --git a/examples/mapViewer/source/asset/sprite.c b/tools/mapViewer/source/asset/sprite.c similarity index 100% rename from examples/mapViewer/source/asset/sprite.c rename to tools/mapViewer/source/asset/sprite.c diff --git a/examples/mapViewer/source/asset/sprite.h b/tools/mapViewer/source/asset/sprite.h similarity index 100% rename from examples/mapViewer/source/asset/sprite.h rename to tools/mapViewer/source/asset/sprite.h diff --git a/examples/mapViewer/source/gbaLib/bitField.h b/tools/mapViewer/source/gbaLib/bitField.h similarity index 100% rename from examples/mapViewer/source/gbaLib/bitField.h rename to tools/mapViewer/source/gbaLib/bitField.h diff --git a/examples/mapViewer/source/gbaLib/gbfs/gbfs.h b/tools/mapViewer/source/gbaLib/gbfs/gbfs.h similarity index 100% rename from examples/mapViewer/source/gbaLib/gbfs/gbfs.h rename to tools/mapViewer/source/gbaLib/gbfs/gbfs.h diff --git a/examples/mapViewer/source/gbaLib/gbfs/libgbfs.c b/tools/mapViewer/source/gbaLib/gbfs/libgbfs.c similarity index 100% rename from examples/mapViewer/source/gbaLib/gbfs/libgbfs.c rename to tools/mapViewer/source/gbaLib/gbfs/libgbfs.c diff --git a/examples/mapViewer/source/gbaLib/input/input.h b/tools/mapViewer/source/gbaLib/input/input.h similarity index 100% rename from examples/mapViewer/source/gbaLib/input/input.h rename to tools/mapViewer/source/gbaLib/input/input.h diff --git a/examples/mapViewer/source/gbaLib/memoryMap.h b/tools/mapViewer/source/gbaLib/memoryMap.h similarity index 100% rename from examples/mapViewer/source/gbaLib/memoryMap.h rename to tools/mapViewer/source/gbaLib/memoryMap.h diff --git a/examples/mapViewer/source/gbaLib/types.h b/tools/mapViewer/source/gbaLib/types.h similarity index 100% rename from examples/mapViewer/source/gbaLib/types.h rename to tools/mapViewer/source/gbaLib/types.h diff --git a/examples/mapViewer/source/gbaLib/video/background.h b/tools/mapViewer/source/gbaLib/video/background.h similarity index 100% rename from examples/mapViewer/source/gbaLib/video/background.h rename to tools/mapViewer/source/gbaLib/video/background.h diff --git a/examples/mapViewer/source/gbaLib/video/spriteObject.h b/tools/mapViewer/source/gbaLib/video/spriteObject.h similarity index 100% rename from examples/mapViewer/source/gbaLib/video/spriteObject.h rename to tools/mapViewer/source/gbaLib/video/spriteObject.h diff --git a/examples/mapViewer/source/gbaLib/video/video.h b/tools/mapViewer/source/gbaLib/video/video.h similarity index 100% rename from examples/mapViewer/source/gbaLib/video/video.h rename to tools/mapViewer/source/gbaLib/video/video.h diff --git a/examples/mapViewer/source/mapViewer/main.c b/tools/mapViewer/source/mapViewer/main.c similarity index 100% rename from examples/mapViewer/source/mapViewer/main.c rename to tools/mapViewer/source/mapViewer/main.c diff --git a/examples/mapViewer/source/mapViewer/main.h b/tools/mapViewer/source/mapViewer/main.h similarity index 100% rename from examples/mapViewer/source/mapViewer/main.h rename to tools/mapViewer/source/mapViewer/main.h diff --git a/examples/mapViewer/source/mapViewer/map/loadMap.c b/tools/mapViewer/source/mapViewer/map/loadMap.c similarity index 100% rename from examples/mapViewer/source/mapViewer/map/loadMap.c rename to tools/mapViewer/source/mapViewer/map/loadMap.c diff --git a/examples/mapViewer/source/mapViewer/map/loadMapFromCode.c b/tools/mapViewer/source/mapViewer/map/loadMapFromCode.c similarity index 100% rename from examples/mapViewer/source/mapViewer/map/loadMapFromCode.c rename to tools/mapViewer/source/mapViewer/map/loadMapFromCode.c diff --git a/examples/mapViewer/source/mapViewer/map/loadMapFromROM.c b/tools/mapViewer/source/mapViewer/map/loadMapFromROM.c similarity index 100% rename from examples/mapViewer/source/mapViewer/map/loadMapFromROM.c rename to tools/mapViewer/source/mapViewer/map/loadMapFromROM.c diff --git a/examples/mapViewer/source/mapViewer/map/map.h b/tools/mapViewer/source/mapViewer/map/map.h similarity index 100% rename from examples/mapViewer/source/mapViewer/map/map.h rename to tools/mapViewer/source/mapViewer/map/map.h diff --git a/examples/mapViewer/source/mapViewer/map/mapObject/loadObject.c b/tools/mapViewer/source/mapViewer/map/mapObject/loadObject.c similarity index 100% rename from examples/mapViewer/source/mapViewer/map/mapObject/loadObject.c rename to tools/mapViewer/source/mapViewer/map/mapObject/loadObject.c diff --git a/examples/mapViewer/source/mapViewer/map/mapObject/loadObjectID.c b/tools/mapViewer/source/mapViewer/map/mapObject/loadObjectID.c similarity index 100% rename from examples/mapViewer/source/mapViewer/map/mapObject/loadObjectID.c rename to tools/mapViewer/source/mapViewer/map/mapObject/loadObjectID.c diff --git a/examples/mapViewer/source/mapViewer/map/mapObject/loadPosition.c b/tools/mapViewer/source/mapViewer/map/mapObject/loadPosition.c similarity index 100% rename from examples/mapViewer/source/mapViewer/map/mapObject/loadPosition.c rename to tools/mapViewer/source/mapViewer/map/mapObject/loadPosition.c diff --git a/examples/mapViewer/source/mapViewer/map/mapObject/loadString.c b/tools/mapViewer/source/mapViewer/map/mapObject/loadString.c similarity index 100% rename from examples/mapViewer/source/mapViewer/map/mapObject/loadString.c rename to tools/mapViewer/source/mapViewer/map/mapObject/loadString.c diff --git a/examples/mapViewer/source/mapViewer/map/mapObject/mapObject.h b/tools/mapViewer/source/mapViewer/map/mapObject/mapObject.h similarity index 100% rename from examples/mapViewer/source/mapViewer/map/mapObject/mapObject.h rename to tools/mapViewer/source/mapViewer/map/mapObject/mapObject.h diff --git a/examples/mapViewer/source/mapViewer/map/mapObject/popValue.c b/tools/mapViewer/source/mapViewer/map/mapObject/popValue.c similarity index 100% rename from examples/mapViewer/source/mapViewer/map/mapObject/popValue.c rename to tools/mapViewer/source/mapViewer/map/mapObject/popValue.c diff --git a/examples/mapViewer/source/mapViewer/map/mapObject/shiftMapObjects.c b/tools/mapViewer/source/mapViewer/map/mapObject/shiftMapObjects.c similarity index 100% rename from examples/mapViewer/source/mapViewer/map/mapObject/shiftMapObjects.c rename to tools/mapViewer/source/mapViewer/map/mapObject/shiftMapObjects.c diff --git a/examples/mapViewer/source/mapViewer/map/setMapOnScreen.c b/tools/mapViewer/source/mapViewer/map/setMapOnScreen.c similarity index 100% rename from examples/mapViewer/source/mapViewer/map/setMapOnScreen.c rename to tools/mapViewer/source/mapViewer/map/setMapOnScreen.c diff --git a/examples/mapViewer/source/mapViewer/map/shiftMap.c b/tools/mapViewer/source/mapViewer/map/shiftMap.c similarity index 100% rename from examples/mapViewer/source/mapViewer/map/shiftMap.c rename to tools/mapViewer/source/mapViewer/map/shiftMap.c diff --git a/examples/mapViewer/source/mapViewer/map/shiftMapLayer.c b/tools/mapViewer/source/mapViewer/map/shiftMapLayer.c similarity index 100% rename from examples/mapViewer/source/mapViewer/map/shiftMapLayer.c rename to tools/mapViewer/source/mapViewer/map/shiftMapLayer.c diff --git a/examples/mapViewer/source/mapViewer/showMapObjects.c b/tools/mapViewer/source/mapViewer/showMapObjects.c similarity index 100% rename from examples/mapViewer/source/mapViewer/showMapObjects.c rename to tools/mapViewer/source/mapViewer/showMapObjects.c diff --git a/examples/mapViewer/source/mapViewer/sprite/copySpriteObjectsToMemory.c b/tools/mapViewer/source/mapViewer/sprite/copySpriteObjectsToMemory.c similarity index 100% rename from examples/mapViewer/source/mapViewer/sprite/copySpriteObjectsToMemory.c rename to tools/mapViewer/source/mapViewer/sprite/copySpriteObjectsToMemory.c diff --git a/examples/mapViewer/source/mapViewer/sprite/hideSpriteObjects.c b/tools/mapViewer/source/mapViewer/sprite/hideSpriteObjects.c similarity index 100% rename from examples/mapViewer/source/mapViewer/sprite/hideSpriteObjects.c rename to tools/mapViewer/source/mapViewer/sprite/hideSpriteObjects.c diff --git a/examples/mapViewer/source/mapViewer/sprite/initializeSpriteObjectMemory.c b/tools/mapViewer/source/mapViewer/sprite/initializeSpriteObjectMemory.c similarity index 100% rename from examples/mapViewer/source/mapViewer/sprite/initializeSpriteObjectMemory.c rename to tools/mapViewer/source/mapViewer/sprite/initializeSpriteObjectMemory.c diff --git a/examples/mapViewer/source/mapViewer/sprite/loadSpriteSheet.c b/tools/mapViewer/source/mapViewer/sprite/loadSpriteSheet.c similarity index 100% rename from examples/mapViewer/source/mapViewer/sprite/loadSpriteSheet.c rename to tools/mapViewer/source/mapViewer/sprite/loadSpriteSheet.c diff --git a/examples/mapViewer/source/mapViewer/sprite/mapObjectsToSpriteObjects.c b/tools/mapViewer/source/mapViewer/sprite/mapObjectsToSpriteObjects.c similarity index 100% rename from examples/mapViewer/source/mapViewer/sprite/mapObjectsToSpriteObjects.c rename to tools/mapViewer/source/mapViewer/sprite/mapObjectsToSpriteObjects.c diff --git a/examples/mapViewer/source/mapViewer/sprite/setSpriteObjectAttributes.c b/tools/mapViewer/source/mapViewer/sprite/setSpriteObjectAttributes.c similarity index 100% rename from examples/mapViewer/source/mapViewer/sprite/setSpriteObjectAttributes.c rename to tools/mapViewer/source/mapViewer/sprite/setSpriteObjectAttributes.c diff --git a/examples/mapViewer/source/mapViewer/sprite/setSpriteObjectPosition.c b/tools/mapViewer/source/mapViewer/sprite/setSpriteObjectPosition.c similarity index 100% rename from examples/mapViewer/source/mapViewer/sprite/setSpriteObjectPosition.c rename to tools/mapViewer/source/mapViewer/sprite/setSpriteObjectPosition.c diff --git a/examples/mapViewer/source/mapViewer/sprite/setSpritesOnScreen.c b/tools/mapViewer/source/mapViewer/sprite/setSpritesOnScreen.c similarity index 100% rename from examples/mapViewer/source/mapViewer/sprite/setSpritesOnScreen.c rename to tools/mapViewer/source/mapViewer/sprite/setSpritesOnScreen.c diff --git a/examples/mapViewer/source/mapViewer/sprite/sprite.h b/tools/mapViewer/source/mapViewer/sprite/sprite.h similarity index 100% rename from examples/mapViewer/source/mapViewer/sprite/sprite.h rename to tools/mapViewer/source/mapViewer/sprite/sprite.h diff --git a/examples/mapViewer/gbfs/padbin.c b/tools/padbin/padbin.c similarity index 100% rename from examples/mapViewer/gbfs/padbin.c rename to tools/padbin/padbin.c From aefca3f0843b1b2cbc72ba31b4fdcfe3b8f187f1 Mon Sep 17 00:00:00 2001 From: Luc van den Brand <10974297+LucvandenBrand@users.noreply.github.com> Date: Sun, 14 Oct 2018 18:20:19 +0200 Subject: [PATCH 24/25] Made mapViewer be build if devkitpro is installed (in linux at least). --- CMakeLists.txt | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a30257e..323f34a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,4 +14,19 @@ file(GLOB_RECURSE GBFS_SOURCES tools/gbfs/*.c tools/gbfs/*.h) add_executable(gbfs ${GBFS_SOURCES}) file(GLOB_RECURSE PADBIN_SOURCES tools/padbin/*.c tools/padbin/*.h) -add_executable(padbin ${PADBIN_SOURCES}) \ No newline at end of file +add_executable(padbin ${PADBIN_SOURCES}) + +set(DEVKITARM /opt/devkitpro/devkitARM) +if(EXISTS ${DEVKITARM}) + set(MAPVIEWER_DIR ${CMAKE_CURRENT_SOURCE_DIR}/tools/mapViewer) + set(MAPVIEWER mapViewer.gba) + add_custom_target( + ${MAPVIEWER} + COMMAND make + WORKING_DIRECTORY ${MAPVIEWER_DIR} + ) + add_dependencies(${PROJECT_NAME} ${MAPVIEWER}) + configure_file(${MAPVIEWER_DIR}/${MAPVIEWER} ${MAPVIEWER} COPYONLY) +else() + message(STATUS "No DevkitARM found in ${DEVKITARM}, skipping mapViewer build") +endif() \ No newline at end of file From 2f3a1d6e792bc485e0827cee6193f47a1088eb86 Mon Sep 17 00:00:00 2001 From: Luc van den Brand <10974297+LucvandenBrand@users.noreply.github.com> Date: Tue, 16 Oct 2018 10:24:28 +0200 Subject: [PATCH 25/25] Large restructure of the project. --- CMakeLists.txt | 21 +- README.md | 22 +- tools/gbfs/LICENSE | 292 ++++++++++++++++++ tools/gbfs/Makefile | 32 ++ tools/gbfs/README.md | 17 + tools/gbfs/{ => src}/gbfs.c | 0 tools/gbfs/{ => src}/gbfs.h | 0 tools/mapViewer/Makefile | 9 +- tools/mapViewer/README.md | 9 +- tools/mapViewer/{source => src}/asset/map.c | 0 tools/mapViewer/{source => src}/asset/map.h | 0 .../mapViewer/{source => src}/asset/sprite.c | 0 .../mapViewer/{source => src}/asset/sprite.h | 0 .../{source => src}/gbaLib/bitField.h | 0 .../{source => src}/gbaLib/gbfs/gbfs.h | 0 .../{source => src}/gbaLib/gbfs/libgbfs.c | 0 .../{source => src}/gbaLib/input/input.h | 0 .../{source => src}/gbaLib/memoryMap.h | 0 .../mapViewer/{source => src}/gbaLib/types.h | 0 .../{source => src}/gbaLib/video/background.h | 0 .../gbaLib/video/spriteObject.h | 0 .../{source => src}/gbaLib/video/video.h | 0 .../{source => src}/mapViewer/main.c | 0 .../{source => src}/mapViewer/main.h | 0 .../{source => src}/mapViewer/map/loadMap.c | 0 .../mapViewer/map/loadMapFromCode.c | 0 .../mapViewer/map/loadMapFromROM.c | 0 .../{source => src}/mapViewer/map/map.h | 0 .../mapViewer/map/mapObject/loadObject.c | 0 .../mapViewer/map/mapObject/loadObjectID.c | 0 .../mapViewer/map/mapObject/loadPosition.c | 0 .../mapViewer/map/mapObject/loadString.c | 0 .../mapViewer/map/mapObject/mapObject.h | 0 .../mapViewer/map/mapObject/popValue.c | 0 .../mapViewer/map/mapObject/shiftMapObjects.c | 0 .../mapViewer/map/setMapOnScreen.c | 0 .../{source => src}/mapViewer/map/shiftMap.c | 0 .../mapViewer/map/shiftMapLayer.c | 0 .../mapViewer/showMapObjects.c | 0 .../sprite/copySpriteObjectsToMemory.c | 0 .../mapViewer/sprite/hideSpriteObjects.c | 0 .../sprite/initializeSpriteObjectMemory.c | 0 .../mapViewer/sprite/loadSpriteSheet.c | 0 .../sprite/mapObjectsToSpriteObjects.c | 0 .../sprite/setSpriteObjectAttributes.c | 0 .../sprite/setSpriteObjectPosition.c | 0 .../mapViewer/sprite/setSpritesOnScreen.c | 0 .../{source => src}/mapViewer/sprite/sprite.h | 0 tools/padbin/LICENSE | 292 ++++++++++++++++++ tools/padbin/Makefile | 32 ++ tools/padbin/README.md | 19 ++ tools/padbin/{ => src}/padbin.c | 0 52 files changed, 709 insertions(+), 36 deletions(-) create mode 100644 tools/gbfs/LICENSE create mode 100644 tools/gbfs/Makefile create mode 100644 tools/gbfs/README.md rename tools/gbfs/{ => src}/gbfs.c (100%) rename tools/gbfs/{ => src}/gbfs.h (100%) rename tools/mapViewer/{source => src}/asset/map.c (100%) rename tools/mapViewer/{source => src}/asset/map.h (100%) rename tools/mapViewer/{source => src}/asset/sprite.c (100%) rename tools/mapViewer/{source => src}/asset/sprite.h (100%) rename tools/mapViewer/{source => src}/gbaLib/bitField.h (100%) rename tools/mapViewer/{source => src}/gbaLib/gbfs/gbfs.h (100%) rename tools/mapViewer/{source => src}/gbaLib/gbfs/libgbfs.c (100%) rename tools/mapViewer/{source => src}/gbaLib/input/input.h (100%) rename tools/mapViewer/{source => src}/gbaLib/memoryMap.h (100%) rename tools/mapViewer/{source => src}/gbaLib/types.h (100%) rename tools/mapViewer/{source => src}/gbaLib/video/background.h (100%) rename tools/mapViewer/{source => src}/gbaLib/video/spriteObject.h (100%) rename tools/mapViewer/{source => src}/gbaLib/video/video.h (100%) rename tools/mapViewer/{source => src}/mapViewer/main.c (100%) rename tools/mapViewer/{source => src}/mapViewer/main.h (100%) rename tools/mapViewer/{source => src}/mapViewer/map/loadMap.c (100%) rename tools/mapViewer/{source => src}/mapViewer/map/loadMapFromCode.c (100%) rename tools/mapViewer/{source => src}/mapViewer/map/loadMapFromROM.c (100%) rename tools/mapViewer/{source => src}/mapViewer/map/map.h (100%) rename tools/mapViewer/{source => src}/mapViewer/map/mapObject/loadObject.c (100%) rename tools/mapViewer/{source => src}/mapViewer/map/mapObject/loadObjectID.c (100%) rename tools/mapViewer/{source => src}/mapViewer/map/mapObject/loadPosition.c (100%) rename tools/mapViewer/{source => src}/mapViewer/map/mapObject/loadString.c (100%) rename tools/mapViewer/{source => src}/mapViewer/map/mapObject/mapObject.h (100%) rename tools/mapViewer/{source => src}/mapViewer/map/mapObject/popValue.c (100%) rename tools/mapViewer/{source => src}/mapViewer/map/mapObject/shiftMapObjects.c (100%) rename tools/mapViewer/{source => src}/mapViewer/map/setMapOnScreen.c (100%) rename tools/mapViewer/{source => src}/mapViewer/map/shiftMap.c (100%) rename tools/mapViewer/{source => src}/mapViewer/map/shiftMapLayer.c (100%) rename tools/mapViewer/{source => src}/mapViewer/showMapObjects.c (100%) rename tools/mapViewer/{source => src}/mapViewer/sprite/copySpriteObjectsToMemory.c (100%) rename tools/mapViewer/{source => src}/mapViewer/sprite/hideSpriteObjects.c (100%) rename tools/mapViewer/{source => src}/mapViewer/sprite/initializeSpriteObjectMemory.c (100%) rename tools/mapViewer/{source => src}/mapViewer/sprite/loadSpriteSheet.c (100%) rename tools/mapViewer/{source => src}/mapViewer/sprite/mapObjectsToSpriteObjects.c (100%) rename tools/mapViewer/{source => src}/mapViewer/sprite/setSpriteObjectAttributes.c (100%) rename tools/mapViewer/{source => src}/mapViewer/sprite/setSpriteObjectPosition.c (100%) rename tools/mapViewer/{source => src}/mapViewer/sprite/setSpritesOnScreen.c (100%) rename tools/mapViewer/{source => src}/mapViewer/sprite/sprite.h (100%) create mode 100644 tools/padbin/LICENSE create mode 100644 tools/padbin/Makefile create mode 100644 tools/padbin/README.md rename tools/padbin/{ => src}/padbin.c (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 323f34a..3e811d2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,26 +7,11 @@ set(CMAKE_CXX_STANDARD 17) # Build Tiled2GBA file(GLOB_RECURSE PROJECT_SOURCES src/*.c src/*.cpp src/*.h src/*.hpp src/*.inl) add_executable(${PROJECT_NAME} ${PROJECT_SOURCES}) -add_dependencies(${PROJECT_NAME} gbfs padbin) -# Build additional tools. +# Build GBFS file(GLOB_RECURSE GBFS_SOURCES tools/gbfs/*.c tools/gbfs/*.h) add_executable(gbfs ${GBFS_SOURCES}) +# Build PADBIN file(GLOB_RECURSE PADBIN_SOURCES tools/padbin/*.c tools/padbin/*.h) -add_executable(padbin ${PADBIN_SOURCES}) - -set(DEVKITARM /opt/devkitpro/devkitARM) -if(EXISTS ${DEVKITARM}) - set(MAPVIEWER_DIR ${CMAKE_CURRENT_SOURCE_DIR}/tools/mapViewer) - set(MAPVIEWER mapViewer.gba) - add_custom_target( - ${MAPVIEWER} - COMMAND make - WORKING_DIRECTORY ${MAPVIEWER_DIR} - ) - add_dependencies(${PROJECT_NAME} ${MAPVIEWER}) - configure_file(${MAPVIEWER_DIR}/${MAPVIEWER} ${MAPVIEWER} COPYONLY) -else() - message(STATUS "No DevkitARM found in ${DEVKITARM}, skipping mapViewer build") -endif() \ No newline at end of file +add_executable(padbin ${PADBIN_SOURCES}) \ No newline at end of file diff --git a/README.md b/README.md index 37ac3c7..e5799bf 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ You can download binary releases [here](https://github.com/LucvandenBrand/Tiled2 ## Usage Tiled2GBA can generate both compilable C code and appendable binary data. The latter is recommended (no need to recompile your project for changes in assets), -and can be used with [GBFS](http://www.pineight.com/gba/#gbfs) in order to access it (see the example). +and can be used with [GBFS](http://www.pineight.com/gba/#gbfs) in order to access it (see the `tools` folder). ### Generating C code Simply call `Tiled2GBA` from your command prompt, and provide a `map.tmx` and `map.c map.h` as @@ -18,15 +18,23 @@ For example, `Tiled2GBA assets/map.tmx src/map.c src/map.h` would output compila into the `src` folder. ### Generating binary data -Simply call `Tiled2GBA` from your command prompt, and provide a `map.tmx` and `map.bin` as +Call `Tiled2GBA` from your command prompt with the `--binary` option, and provide a `map.tmx` and `map.bin` as input and output parameters respectively. -For example, `Tiled2GBA assets/map.tmx assets/map.bin` would output appendable binary data +For example, `Tiled2GBA assets/map.tmx assets/map.bin --binary` would output appendable binary data into the `assets` folder. You can use the `--help` command for more information. ## Development -This project is written in C++ and contains a very simple Makefile to help you compile it. +This project is written in C++ and contains a very simple [CMake](https://cmake.org/) file to help you compile it. +Without an IDE like CLion (greatly recommended!) you can build this project by calling: + +1. `mkdir build` +2. `cd build` +3. `cmake ..` +4. `make` + +This should result in a cute little `Tiled2GBA` binary. ### Contributing Contributions are always welcome! You can make a contribution by: @@ -39,6 +47,6 @@ The **develop** branch is meant for in-development unstable releases, whilst the **master** branch is meant for stable production-ready releases. ### Licence -All source files are protected under the MIT Licence, except for the included libraries in `lib`. -The used libraries are open-source, but please read their included licenses for their specific -terms and conditions. \ No newline at end of file +All source files are protected under the MIT Licence, except for the included libraries in `src/lib`, +`tools/gbfs` and `tools/padbin`. The used libraries are open-source, but please read their included licenses for +their specific terms and conditions. \ No newline at end of file diff --git a/tools/gbfs/LICENSE b/tools/gbfs/LICENSE new file mode 100644 index 0000000..25aa290 --- /dev/null +++ b/tools/gbfs/LICENSE @@ -0,0 +1,292 @@ +### GNU GENERAL PUBLIC LICENSE + +Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + +### Preamble + +The licenses for most software are designed to take away your freedom +to share and change it. By contrast, the GNU General Public License is +intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Lesser General Public License instead.) You can apply it to +your programs, too. + +When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + +To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if +you distribute copies of the software, or if you modify it. + +For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + +We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + +Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, +we want its recipients to know that what they have is not the +original, so that any problems introduced by others will not reflect +on the original authors' reputations. + +Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at +all. + +The precise terms and conditions for copying, distribution and +modification follow. + +### TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + +**0.** This License applies to any program or other work which +contains a notice placed by the copyright holder saying it may be +distributed under the terms of this General Public License. The +"Program", below, refers to any such program or work, and a "work +based on the Program" means either the Program or any derivative work +under copyright law: that is to say, a work containing the Program or +a portion of it, either verbatim or with modifications and/or +translated into another language. (Hereinafter, translation is +included without limitation in the term "modification".) Each licensee +is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the Program +(independent of having been made by running the Program). Whether that +is true depends on what the Program does. + +**1.** You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a +fee. + +**2.** You may modify your copy or copies of the Program or any +portion of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + +**a)** You must cause the modified files to carry prominent notices +stating that you changed the files and the date of any change. + + +**b)** You must cause any work that you distribute or publish, that in +whole or in part contains or is derived from the Program or any part +thereof, to be licensed as a whole at no charge to all third parties +under the terms of this License. + + +**c)** If the modified program normally reads commands interactively +when run, you must cause it, when started running for such interactive +use in the most ordinary way, to print or display an announcement +including an appropriate copyright notice and a notice that there is +no warranty (or else, saying that you provide a warranty) and that +users may redistribute the program under these conditions, and telling +the user how to view a copy of this License. (Exception: if the +Program itself is interactive but does not normally print such an +announcement, your work based on the Program is not required to print +an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote +it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + +**3.** You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + +**a)** Accompany it with the complete corresponding machine-readable +source code, which must be distributed under the terms of Sections 1 +and 2 above on a medium customarily used for software interchange; or, + + +**b)** Accompany it with a written offer, valid for at least three +years, to give any third party, for a charge no more than your cost of +physically performing source distribution, a complete machine-readable +copy of the corresponding source code, to be distributed under the +terms of Sections 1 and 2 above on a medium customarily used for +software interchange; or, + + +**c)** Accompany it with the information you received as to the offer +to distribute corresponding source code. (This alternative is allowed +only for noncommercial distribution and only if you received the +program in object code or executable form with such an offer, in +accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + +**4.** You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt otherwise +to copy, modify, sublicense or distribute the Program is void, and +will automatically terminate your rights under this License. However, +parties who have received copies, or rights, from you under this +License will not have their licenses terminated so long as such +parties remain in full compliance. + +**5.** You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + +**6.** Each time you redistribute the Program (or any work based on +the Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + +**7.** If, as a consequence of a court judgment or allegation of +patent infringement or for any other reason (not limited to patent +issues), conditions are imposed on you (whether by court order, +agreement or otherwise) that contradict the conditions of this +License, they do not excuse you from the conditions of this License. +If you cannot distribute so as to satisfy simultaneously your +obligations under this License and any other pertinent obligations, +then as a consequence you may not distribute the Program at all. For +example, if a patent license would not permit royalty-free +redistribution of the Program by all those who receive copies directly +or indirectly through you, then the only way you could satisfy both it +and this License would be to refrain entirely from distribution of the +Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + +**8.** If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + +**9.** The Free Software Foundation may publish revised and/or new +versions of the General Public License from time to time. Such new +versions will be similar in spirit to the present version, but may +differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and +"any later version", you have the option of following the terms and +conditions either of that version or of any later version published by +the Free Software Foundation. If the Program does not specify a +version number of this License, you may choose any version ever +published by the Free Software Foundation. + +**10.** If you wish to incorporate parts of the Program into other +free programs whose distribution conditions are different, write to +the author to ask for permission. For software which is copyrighted by +the Free Software Foundation, write to the Free Software Foundation; +we sometimes make exceptions for this. Our decision will be guided by +the two goals of preserving the free status of all derivatives of our +free software and of promoting the sharing and reuse of software +generally. + +**NO WARRANTY** + +**11.** BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO +WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. +EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR +OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY +KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE +PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME +THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + +**12.** IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN +WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY +AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU +FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR +CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE +PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING +RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A +FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF +SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH +DAMAGES. \ No newline at end of file diff --git a/tools/gbfs/Makefile b/tools/gbfs/Makefile new file mode 100644 index 0000000..4d6778d --- /dev/null +++ b/tools/gbfs/Makefile @@ -0,0 +1,32 @@ +# Project settings + +NAME := gbfs +SOURCE_DIR := src/ + +# Compilation settings + +CC := gcc +LD := gcc + +.PHONY : build clean + +# Build commands + +SOURCES := $(shell find $(SOURCE_DIR) -name '*.c') +OBJECTS := $(SOURCES:%.c=%.o) + +build : $(NAME) + +$(NAME) : $(OBJECTS) + $(LD) $^ -o $@ + +$(OBJECTS) : %.o : %.c + $(CC) -c $< -o $@ + +# Cleanup settings + +clean : + @rm -fv $(NAME) + @rm -rf $(OBJECTS) + +#EOF diff --git a/tools/gbfs/README.md b/tools/gbfs/README.md new file mode 100644 index 0000000..7dd5cf3 --- /dev/null +++ b/tools/gbfs/README.md @@ -0,0 +1,17 @@ +# GBFS +Takes an input file and packages it as a GBFS archive. +A GBFS archive can be appended to a (padded) `.gba` binary, such that it +can easily find your archived content and use it. + +## Usage +Simply call `gbfs` from your command prompt with the archive and input file(s) +respectively. For example, archiving two Tiled2GBA generated maps would require the call: +`gbfs mapdata.gbfs map1.bin map2.bin` + +## Development +The code for this project is very simple, and can be easily build by passing +the sources to your average C(++) compiler. For your convenience, a Makefile +has been included. Simply call `make` and you should have your `gbfs` binary. + +## Author +This tool is made by [Damian Yerrick](https://github.com/pinobatch). \ No newline at end of file diff --git a/tools/gbfs/gbfs.c b/tools/gbfs/src/gbfs.c similarity index 100% rename from tools/gbfs/gbfs.c rename to tools/gbfs/src/gbfs.c diff --git a/tools/gbfs/gbfs.h b/tools/gbfs/src/gbfs.h similarity index 100% rename from tools/gbfs/gbfs.h rename to tools/gbfs/src/gbfs.h diff --git a/tools/mapViewer/Makefile b/tools/mapViewer/Makefile index 00b8785..0599830 100644 --- a/tools/mapViewer/Makefile +++ b/tools/mapViewer/Makefile @@ -3,11 +3,9 @@ PATH := $(DEVKITARM)/bin:$(PATH) # Project settings NAME := mapViewer -SOURCE_DIR := source/ +SOURCE_DIR := src/ SPECS := -specs=gba.specs -MAP := map - # Compilation settings CROSS ?= arm-none-eabi- @@ -31,11 +29,6 @@ OBJECTS := $(SOURCES:%.c=%.o) build : $(NAME).gba -append: $(NAME).gba - ../gbfs $(MAP).gbfs $(MAP).bin - ../padbin 256 $< - cat $< $(MAP).gbfs > $(NAME)_append.gba - $(NAME).gba : $(NAME).elf $(OBJCOPY) -v -O binary $< $@ -@gbafix $@ -t$(NAME) diff --git a/tools/mapViewer/README.md b/tools/mapViewer/README.md index 35ee204..b6bb813 100644 --- a/tools/mapViewer/README.md +++ b/tools/mapViewer/README.md @@ -8,9 +8,12 @@ Once compiled, simply open the GBA binary using the emulator of your choosing. The directional pad of the GBA allows you to scroll through the map. ## Development +The code for this project **requires DevkitARM to be installed**, and a global `DEVKITARM` +environment variable to be defined describing its directory. This project includes a Makefile, which allows you to build the required binaries. -There are a few build options: +The `make` command will build a `mapViewer.gba`, which uses generated code stored in `src\asset` +as map data. -- `make` will build a `mapViewer.gba`, which uses the generated code for the Tiled map. -- `make append` will build `mapViewer_append.gba`, which will append a `map.bin` (if generated by Tiled2GBA). \ No newline at end of file +Alternatively, you can use `padbin` and `gbfs` to append binary map data to the compiled `gba` binary. +In this case it will display the appended map instead. \ No newline at end of file diff --git a/tools/mapViewer/source/asset/map.c b/tools/mapViewer/src/asset/map.c similarity index 100% rename from tools/mapViewer/source/asset/map.c rename to tools/mapViewer/src/asset/map.c diff --git a/tools/mapViewer/source/asset/map.h b/tools/mapViewer/src/asset/map.h similarity index 100% rename from tools/mapViewer/source/asset/map.h rename to tools/mapViewer/src/asset/map.h diff --git a/tools/mapViewer/source/asset/sprite.c b/tools/mapViewer/src/asset/sprite.c similarity index 100% rename from tools/mapViewer/source/asset/sprite.c rename to tools/mapViewer/src/asset/sprite.c diff --git a/tools/mapViewer/source/asset/sprite.h b/tools/mapViewer/src/asset/sprite.h similarity index 100% rename from tools/mapViewer/source/asset/sprite.h rename to tools/mapViewer/src/asset/sprite.h diff --git a/tools/mapViewer/source/gbaLib/bitField.h b/tools/mapViewer/src/gbaLib/bitField.h similarity index 100% rename from tools/mapViewer/source/gbaLib/bitField.h rename to tools/mapViewer/src/gbaLib/bitField.h diff --git a/tools/mapViewer/source/gbaLib/gbfs/gbfs.h b/tools/mapViewer/src/gbaLib/gbfs/gbfs.h similarity index 100% rename from tools/mapViewer/source/gbaLib/gbfs/gbfs.h rename to tools/mapViewer/src/gbaLib/gbfs/gbfs.h diff --git a/tools/mapViewer/source/gbaLib/gbfs/libgbfs.c b/tools/mapViewer/src/gbaLib/gbfs/libgbfs.c similarity index 100% rename from tools/mapViewer/source/gbaLib/gbfs/libgbfs.c rename to tools/mapViewer/src/gbaLib/gbfs/libgbfs.c diff --git a/tools/mapViewer/source/gbaLib/input/input.h b/tools/mapViewer/src/gbaLib/input/input.h similarity index 100% rename from tools/mapViewer/source/gbaLib/input/input.h rename to tools/mapViewer/src/gbaLib/input/input.h diff --git a/tools/mapViewer/source/gbaLib/memoryMap.h b/tools/mapViewer/src/gbaLib/memoryMap.h similarity index 100% rename from tools/mapViewer/source/gbaLib/memoryMap.h rename to tools/mapViewer/src/gbaLib/memoryMap.h diff --git a/tools/mapViewer/source/gbaLib/types.h b/tools/mapViewer/src/gbaLib/types.h similarity index 100% rename from tools/mapViewer/source/gbaLib/types.h rename to tools/mapViewer/src/gbaLib/types.h diff --git a/tools/mapViewer/source/gbaLib/video/background.h b/tools/mapViewer/src/gbaLib/video/background.h similarity index 100% rename from tools/mapViewer/source/gbaLib/video/background.h rename to tools/mapViewer/src/gbaLib/video/background.h diff --git a/tools/mapViewer/source/gbaLib/video/spriteObject.h b/tools/mapViewer/src/gbaLib/video/spriteObject.h similarity index 100% rename from tools/mapViewer/source/gbaLib/video/spriteObject.h rename to tools/mapViewer/src/gbaLib/video/spriteObject.h diff --git a/tools/mapViewer/source/gbaLib/video/video.h b/tools/mapViewer/src/gbaLib/video/video.h similarity index 100% rename from tools/mapViewer/source/gbaLib/video/video.h rename to tools/mapViewer/src/gbaLib/video/video.h diff --git a/tools/mapViewer/source/mapViewer/main.c b/tools/mapViewer/src/mapViewer/main.c similarity index 100% rename from tools/mapViewer/source/mapViewer/main.c rename to tools/mapViewer/src/mapViewer/main.c diff --git a/tools/mapViewer/source/mapViewer/main.h b/tools/mapViewer/src/mapViewer/main.h similarity index 100% rename from tools/mapViewer/source/mapViewer/main.h rename to tools/mapViewer/src/mapViewer/main.h diff --git a/tools/mapViewer/source/mapViewer/map/loadMap.c b/tools/mapViewer/src/mapViewer/map/loadMap.c similarity index 100% rename from tools/mapViewer/source/mapViewer/map/loadMap.c rename to tools/mapViewer/src/mapViewer/map/loadMap.c diff --git a/tools/mapViewer/source/mapViewer/map/loadMapFromCode.c b/tools/mapViewer/src/mapViewer/map/loadMapFromCode.c similarity index 100% rename from tools/mapViewer/source/mapViewer/map/loadMapFromCode.c rename to tools/mapViewer/src/mapViewer/map/loadMapFromCode.c diff --git a/tools/mapViewer/source/mapViewer/map/loadMapFromROM.c b/tools/mapViewer/src/mapViewer/map/loadMapFromROM.c similarity index 100% rename from tools/mapViewer/source/mapViewer/map/loadMapFromROM.c rename to tools/mapViewer/src/mapViewer/map/loadMapFromROM.c diff --git a/tools/mapViewer/source/mapViewer/map/map.h b/tools/mapViewer/src/mapViewer/map/map.h similarity index 100% rename from tools/mapViewer/source/mapViewer/map/map.h rename to tools/mapViewer/src/mapViewer/map/map.h diff --git a/tools/mapViewer/source/mapViewer/map/mapObject/loadObject.c b/tools/mapViewer/src/mapViewer/map/mapObject/loadObject.c similarity index 100% rename from tools/mapViewer/source/mapViewer/map/mapObject/loadObject.c rename to tools/mapViewer/src/mapViewer/map/mapObject/loadObject.c diff --git a/tools/mapViewer/source/mapViewer/map/mapObject/loadObjectID.c b/tools/mapViewer/src/mapViewer/map/mapObject/loadObjectID.c similarity index 100% rename from tools/mapViewer/source/mapViewer/map/mapObject/loadObjectID.c rename to tools/mapViewer/src/mapViewer/map/mapObject/loadObjectID.c diff --git a/tools/mapViewer/source/mapViewer/map/mapObject/loadPosition.c b/tools/mapViewer/src/mapViewer/map/mapObject/loadPosition.c similarity index 100% rename from tools/mapViewer/source/mapViewer/map/mapObject/loadPosition.c rename to tools/mapViewer/src/mapViewer/map/mapObject/loadPosition.c diff --git a/tools/mapViewer/source/mapViewer/map/mapObject/loadString.c b/tools/mapViewer/src/mapViewer/map/mapObject/loadString.c similarity index 100% rename from tools/mapViewer/source/mapViewer/map/mapObject/loadString.c rename to tools/mapViewer/src/mapViewer/map/mapObject/loadString.c diff --git a/tools/mapViewer/source/mapViewer/map/mapObject/mapObject.h b/tools/mapViewer/src/mapViewer/map/mapObject/mapObject.h similarity index 100% rename from tools/mapViewer/source/mapViewer/map/mapObject/mapObject.h rename to tools/mapViewer/src/mapViewer/map/mapObject/mapObject.h diff --git a/tools/mapViewer/source/mapViewer/map/mapObject/popValue.c b/tools/mapViewer/src/mapViewer/map/mapObject/popValue.c similarity index 100% rename from tools/mapViewer/source/mapViewer/map/mapObject/popValue.c rename to tools/mapViewer/src/mapViewer/map/mapObject/popValue.c diff --git a/tools/mapViewer/source/mapViewer/map/mapObject/shiftMapObjects.c b/tools/mapViewer/src/mapViewer/map/mapObject/shiftMapObjects.c similarity index 100% rename from tools/mapViewer/source/mapViewer/map/mapObject/shiftMapObjects.c rename to tools/mapViewer/src/mapViewer/map/mapObject/shiftMapObjects.c diff --git a/tools/mapViewer/source/mapViewer/map/setMapOnScreen.c b/tools/mapViewer/src/mapViewer/map/setMapOnScreen.c similarity index 100% rename from tools/mapViewer/source/mapViewer/map/setMapOnScreen.c rename to tools/mapViewer/src/mapViewer/map/setMapOnScreen.c diff --git a/tools/mapViewer/source/mapViewer/map/shiftMap.c b/tools/mapViewer/src/mapViewer/map/shiftMap.c similarity index 100% rename from tools/mapViewer/source/mapViewer/map/shiftMap.c rename to tools/mapViewer/src/mapViewer/map/shiftMap.c diff --git a/tools/mapViewer/source/mapViewer/map/shiftMapLayer.c b/tools/mapViewer/src/mapViewer/map/shiftMapLayer.c similarity index 100% rename from tools/mapViewer/source/mapViewer/map/shiftMapLayer.c rename to tools/mapViewer/src/mapViewer/map/shiftMapLayer.c diff --git a/tools/mapViewer/source/mapViewer/showMapObjects.c b/tools/mapViewer/src/mapViewer/showMapObjects.c similarity index 100% rename from tools/mapViewer/source/mapViewer/showMapObjects.c rename to tools/mapViewer/src/mapViewer/showMapObjects.c diff --git a/tools/mapViewer/source/mapViewer/sprite/copySpriteObjectsToMemory.c b/tools/mapViewer/src/mapViewer/sprite/copySpriteObjectsToMemory.c similarity index 100% rename from tools/mapViewer/source/mapViewer/sprite/copySpriteObjectsToMemory.c rename to tools/mapViewer/src/mapViewer/sprite/copySpriteObjectsToMemory.c diff --git a/tools/mapViewer/source/mapViewer/sprite/hideSpriteObjects.c b/tools/mapViewer/src/mapViewer/sprite/hideSpriteObjects.c similarity index 100% rename from tools/mapViewer/source/mapViewer/sprite/hideSpriteObjects.c rename to tools/mapViewer/src/mapViewer/sprite/hideSpriteObjects.c diff --git a/tools/mapViewer/source/mapViewer/sprite/initializeSpriteObjectMemory.c b/tools/mapViewer/src/mapViewer/sprite/initializeSpriteObjectMemory.c similarity index 100% rename from tools/mapViewer/source/mapViewer/sprite/initializeSpriteObjectMemory.c rename to tools/mapViewer/src/mapViewer/sprite/initializeSpriteObjectMemory.c diff --git a/tools/mapViewer/source/mapViewer/sprite/loadSpriteSheet.c b/tools/mapViewer/src/mapViewer/sprite/loadSpriteSheet.c similarity index 100% rename from tools/mapViewer/source/mapViewer/sprite/loadSpriteSheet.c rename to tools/mapViewer/src/mapViewer/sprite/loadSpriteSheet.c diff --git a/tools/mapViewer/source/mapViewer/sprite/mapObjectsToSpriteObjects.c b/tools/mapViewer/src/mapViewer/sprite/mapObjectsToSpriteObjects.c similarity index 100% rename from tools/mapViewer/source/mapViewer/sprite/mapObjectsToSpriteObjects.c rename to tools/mapViewer/src/mapViewer/sprite/mapObjectsToSpriteObjects.c diff --git a/tools/mapViewer/source/mapViewer/sprite/setSpriteObjectAttributes.c b/tools/mapViewer/src/mapViewer/sprite/setSpriteObjectAttributes.c similarity index 100% rename from tools/mapViewer/source/mapViewer/sprite/setSpriteObjectAttributes.c rename to tools/mapViewer/src/mapViewer/sprite/setSpriteObjectAttributes.c diff --git a/tools/mapViewer/source/mapViewer/sprite/setSpriteObjectPosition.c b/tools/mapViewer/src/mapViewer/sprite/setSpriteObjectPosition.c similarity index 100% rename from tools/mapViewer/source/mapViewer/sprite/setSpriteObjectPosition.c rename to tools/mapViewer/src/mapViewer/sprite/setSpriteObjectPosition.c diff --git a/tools/mapViewer/source/mapViewer/sprite/setSpritesOnScreen.c b/tools/mapViewer/src/mapViewer/sprite/setSpritesOnScreen.c similarity index 100% rename from tools/mapViewer/source/mapViewer/sprite/setSpritesOnScreen.c rename to tools/mapViewer/src/mapViewer/sprite/setSpritesOnScreen.c diff --git a/tools/mapViewer/source/mapViewer/sprite/sprite.h b/tools/mapViewer/src/mapViewer/sprite/sprite.h similarity index 100% rename from tools/mapViewer/source/mapViewer/sprite/sprite.h rename to tools/mapViewer/src/mapViewer/sprite/sprite.h diff --git a/tools/padbin/LICENSE b/tools/padbin/LICENSE new file mode 100644 index 0000000..25aa290 --- /dev/null +++ b/tools/padbin/LICENSE @@ -0,0 +1,292 @@ +### GNU GENERAL PUBLIC LICENSE + +Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + +### Preamble + +The licenses for most software are designed to take away your freedom +to share and change it. By contrast, the GNU General Public License is +intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Lesser General Public License instead.) You can apply it to +your programs, too. + +When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + +To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if +you distribute copies of the software, or if you modify it. + +For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + +We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + +Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, +we want its recipients to know that what they have is not the +original, so that any problems introduced by others will not reflect +on the original authors' reputations. + +Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at +all. + +The precise terms and conditions for copying, distribution and +modification follow. + +### TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + +**0.** This License applies to any program or other work which +contains a notice placed by the copyright holder saying it may be +distributed under the terms of this General Public License. The +"Program", below, refers to any such program or work, and a "work +based on the Program" means either the Program or any derivative work +under copyright law: that is to say, a work containing the Program or +a portion of it, either verbatim or with modifications and/or +translated into another language. (Hereinafter, translation is +included without limitation in the term "modification".) Each licensee +is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the Program +(independent of having been made by running the Program). Whether that +is true depends on what the Program does. + +**1.** You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a +fee. + +**2.** You may modify your copy or copies of the Program or any +portion of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + +**a)** You must cause the modified files to carry prominent notices +stating that you changed the files and the date of any change. + + +**b)** You must cause any work that you distribute or publish, that in +whole or in part contains or is derived from the Program or any part +thereof, to be licensed as a whole at no charge to all third parties +under the terms of this License. + + +**c)** If the modified program normally reads commands interactively +when run, you must cause it, when started running for such interactive +use in the most ordinary way, to print or display an announcement +including an appropriate copyright notice and a notice that there is +no warranty (or else, saying that you provide a warranty) and that +users may redistribute the program under these conditions, and telling +the user how to view a copy of this License. (Exception: if the +Program itself is interactive but does not normally print such an +announcement, your work based on the Program is not required to print +an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote +it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + +**3.** You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + +**a)** Accompany it with the complete corresponding machine-readable +source code, which must be distributed under the terms of Sections 1 +and 2 above on a medium customarily used for software interchange; or, + + +**b)** Accompany it with a written offer, valid for at least three +years, to give any third party, for a charge no more than your cost of +physically performing source distribution, a complete machine-readable +copy of the corresponding source code, to be distributed under the +terms of Sections 1 and 2 above on a medium customarily used for +software interchange; or, + + +**c)** Accompany it with the information you received as to the offer +to distribute corresponding source code. (This alternative is allowed +only for noncommercial distribution and only if you received the +program in object code or executable form with such an offer, in +accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + +**4.** You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt otherwise +to copy, modify, sublicense or distribute the Program is void, and +will automatically terminate your rights under this License. However, +parties who have received copies, or rights, from you under this +License will not have their licenses terminated so long as such +parties remain in full compliance. + +**5.** You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + +**6.** Each time you redistribute the Program (or any work based on +the Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + +**7.** If, as a consequence of a court judgment or allegation of +patent infringement or for any other reason (not limited to patent +issues), conditions are imposed on you (whether by court order, +agreement or otherwise) that contradict the conditions of this +License, they do not excuse you from the conditions of this License. +If you cannot distribute so as to satisfy simultaneously your +obligations under this License and any other pertinent obligations, +then as a consequence you may not distribute the Program at all. For +example, if a patent license would not permit royalty-free +redistribution of the Program by all those who receive copies directly +or indirectly through you, then the only way you could satisfy both it +and this License would be to refrain entirely from distribution of the +Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + +**8.** If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + +**9.** The Free Software Foundation may publish revised and/or new +versions of the General Public License from time to time. Such new +versions will be similar in spirit to the present version, but may +differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and +"any later version", you have the option of following the terms and +conditions either of that version or of any later version published by +the Free Software Foundation. If the Program does not specify a +version number of this License, you may choose any version ever +published by the Free Software Foundation. + +**10.** If you wish to incorporate parts of the Program into other +free programs whose distribution conditions are different, write to +the author to ask for permission. For software which is copyrighted by +the Free Software Foundation, write to the Free Software Foundation; +we sometimes make exceptions for this. Our decision will be guided by +the two goals of preserving the free status of all derivatives of our +free software and of promoting the sharing and reuse of software +generally. + +**NO WARRANTY** + +**11.** BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO +WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. +EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR +OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY +KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE +PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME +THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + +**12.** IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN +WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY +AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU +FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR +CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE +PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING +RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A +FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF +SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH +DAMAGES. \ No newline at end of file diff --git a/tools/padbin/Makefile b/tools/padbin/Makefile new file mode 100644 index 0000000..d10e7a3 --- /dev/null +++ b/tools/padbin/Makefile @@ -0,0 +1,32 @@ +# Project settings + +NAME := padbin +SOURCE_DIR := src/ + +# Compilation settings + +CC := gcc +LD := gcc + +.PHONY : build clean + +# Build commands + +SOURCES := $(shell find $(SOURCE_DIR) -name '*.c') +OBJECTS := $(SOURCES:%.c=%.o) + +build : $(NAME) + +$(NAME) : $(OBJECTS) + $(LD) $^ -o $@ + +$(OBJECTS) : %.o : %.c + $(CC) -c $< -o $@ + +# Cleanup settings + +clean : + @rm -fv $(NAME) + @rm -rf $(OBJECTS) + +#EOF diff --git a/tools/padbin/README.md b/tools/padbin/README.md new file mode 100644 index 0000000..7daeba9 --- /dev/null +++ b/tools/padbin/README.md @@ -0,0 +1,19 @@ +# PadBin +Takes an input file and padds it to an integer multiple of a given number of bytes. +This can be used to prepare a `.gba` binary for appending GBFS data (due to +the way GBFS is capable of finding its archives). + +## Usage +Simply call `padbin` from your command prompt with the byte number and the +file to pad respectively. +For example, padding `mapViewer.gba` to 256 bytes (as is required for GBFS) +would require the call: +`padbin 256 mapViewer.gba` + +## Development +The code for this project is very simple, and can be easily build by passing +the sources to your average C(++) compiler. For your convenience, a Makefile +has been included. Simply call `make` and you should have your `padbin` binary. + +## Author +This tool is made by [Damian Yerrick](https://github.com/pinobatch). \ No newline at end of file diff --git a/tools/padbin/padbin.c b/tools/padbin/src/padbin.c similarity index 100% rename from tools/padbin/padbin.c rename to tools/padbin/src/padbin.c