diff --git a/.gitignore b/.gitignore
index 90f23a4..7da0a8b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -5,3 +5,6 @@
# Building sources
build-fx/
build-cg/
+
+# Python files
+assets-cg/__pycache__/
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 01b4f52..bf4ec54 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -11,6 +11,7 @@ find_package(Gint 2.1 REQUIRED)
set(SOURCES
src/main.c
+ src/game_engine.c
# ...
)
# Shared assets, fx-9860G-only assets and fx-CG-50-only assets
@@ -20,9 +21,13 @@ set(ASSETS
set(ASSETS_fx
)
set(ASSETS_cg
+ assets-cg/tileset.png
+ assets-cg/maps/world.json
+
)
fxconv_declare_assets(${ASSETS} ${ASSETS_fx} ${ASSETS_cg} WITH_METADATA)
+fxconv_declare_converters(assets-cg/converters.py)
add_executable(myaddin ${SOURCES} ${ASSETS} ${ASSETS_${FXSDK_PLATFORM}})
target_compile_options(myaddin PRIVATE -Wall -Wextra -Os)
diff --git a/assets-cg/Tiled/carte.tmx b/assets-cg/Tiled/carte.tmx
new file mode 100644
index 0000000..921e918
--- /dev/null
+++ b/assets-cg/Tiled/carte.tmx
@@ -0,0 +1,65 @@
+
+
diff --git a/assets-cg/Tiled/tileset.json b/assets-cg/Tiled/tileset.json
new file mode 100644
index 0000000..636fa4e
--- /dev/null
+++ b/assets-cg/Tiled/tileset.json
@@ -0,0 +1,14 @@
+{ "columns":49,
+ "image":"..\/tileset.png",
+ "imageheight":373,
+ "imagewidth":832,
+ "margin":0,
+ "name":"tileset",
+ "spacing":1,
+ "tilecount":1078,
+ "tiledversion":"1.7.1",
+ "tileheight":16,
+ "tilewidth":16,
+ "type":"tileset",
+ "version":"1.6"
+}
\ No newline at end of file
diff --git a/assets-cg/converters.py b/assets-cg/converters.py
new file mode 100644
index 0000000..50509c2
--- /dev/null
+++ b/assets-cg/converters.py
@@ -0,0 +1,33 @@
+import fxconv
+import json
+
+
+def convert(input_name, output, params, target):
+ if params["custom-type"] == "map":
+ convert_map(input_name, output, params, target)
+ return 0
+ else:
+ return 1
+
+
+def convert_map(input_name, output, params, target):
+ with open(input_name, "r") as file:
+ json_data = json.load(file)
+
+ data = fxconv.ObjectData()
+ data += fxconv.u32(json_data["width"]) + fxconv.u32(json_data["height"]) + fxconv.u32(len(json_data["layers"]))
+
+
+ for layer in json_data["layers"]:
+ layer_data = bytes()
+
+ for tile in layer["data"]:
+ layer_data += fxconv.u16(tile)
+
+ data += fxconv.ref(layer_data)
+
+ fxconv.elf(data, output, "_" + params["name"], **target)
+
+
+
+
diff --git a/assets-cg/fxconv-metadata.txt b/assets-cg/fxconv-metadata.txt
index 018d3a3..b4e6115 100644
--- a/assets-cg/fxconv-metadata.txt
+++ b/assets-cg/fxconv-metadata.txt
@@ -1,4 +1,4 @@
*.png:
type: bopti-image
profile: p8
- name_regex: (*)\.png img_\1
+ name_regex: (.*)\.png img_\1
diff --git a/assets-cg/maps/fxconv-metadata.txt b/assets-cg/maps/fxconv-metadata.txt
new file mode 100644
index 0000000..6e290ce
--- /dev/null
+++ b/assets-cg/maps/fxconv-metadata.txt
@@ -0,0 +1,3 @@
+*.json:
+ custom-type: map
+ name_regex: (.*)\.json map_\1
\ No newline at end of file
diff --git a/assets-cg/maps/world.json b/assets-cg/maps/world.json
new file mode 100644
index 0000000..e10770d
--- /dev/null
+++ b/assets-cg/maps/world.json
@@ -0,0 +1,44 @@
+{ "compressionlevel":-1,
+ "height":25,
+ "infinite":false,
+ "layers":[
+ {
+ "data":[55, 55, 55, 6, 55, 55, 6, 6, 55, 6, 59, 6, 55, 6, 6, 55, 55, 6, 55, 6, 55, 55, 6, 55, 6, 55, 6, 55, 55, 6, 55, 6, 59, 59, 55, 55, 6, 6, 6, 6, 6, 55, 55, 55, 6, 6, 55, 6, 6, 6, 6, 6, 6, 55, 6, 6, 55, 55, 6, 6, 55, 55, 59, 55, 6, 55, 6, 55, 6, 6, 6, 59, 6, 55, 6, 55, 6, 6, 6, 59, 55, 6, 3, 4, 4, 4, 5, 55, 55, 59, 55, 55, 59, 55, 6, 6, 6, 55, 55, 6, 55, 55, 6, 6, 55, 3, 4, 100, 1076, 53, 53, 54, 55, 6, 55, 6, 55, 55, 6, 55, 55, 55, 6, 6, 6, 6, 55, 6, 59, 6, 52, 53, 53, 53, 53, 53, 99, 5, 6, 6, 55, 55, 55, 55, 55, 55, 55, 6, 55, 6, 55, 6, 6, 6, 6, 101, 51, 53, 53, 53, 53, 53, 54, 55, 55, 55, 55, 55, 6, 6, 59, 55, 6, 6, 55, 6, 55, 6, 55, 55, 55, 52, 53, 53, 1078, 50, 102, 103, 55, 55, 55, 59, 6, 6, 55, 6, 55, 55, 6, 6, 55, 55, 59, 6, 55, 55, 101, 102, 102, 102, 103, 55, 6, 6, 55, 6, 6, 55, 6, 6, 55, 55, 6, 55, 6, 55, 55, 55, 55, 59, 55, 55, 55, 55, 6, 6, 6, 6, 55, 59, 6, 55, 6, 6, 6, 55, 55, 6, 6, 55, 55, 6, 55, 6, 6, 6, 6, 6, 6, 55, 6, 6, 6, 6, 55, 6, 55, 6, 6, 55, 6, 6, 55, 55, 55, 55, 6, 59, 55, 55, 55, 6, 55, 6, 6, 6, 55, 6, 55, 6, 55, 6, 55, 55, 55, 6, 6, 55, 55, 55, 55, 55, 55, 55, 59, 6, 6, 55, 55, 55, 55, 55, 55, 55, 6, 6, 6, 59, 55, 6, 55, 6, 55, 55, 6, 6, 55, 55, 55, 55, 6, 6, 6, 6, 55, 55, 59, 6, 55, 55, 55, 55, 6, 55, 55, 59, 6, 6, 55, 55, 55, 55, 59, 55, 55, 6, 55, 59, 6, 6, 6, 6, 6, 55, 6, 55, 6, 6, 6, 6, 6, 6, 55, 55, 55, 6, 55, 55, 55, 6, 55, 55, 6, 55, 55, 6, 55, 55, 6, 6, 6, 55, 55, 55, 6, 6, 55, 6, 6, 6, 55, 6, 55, 55, 59, 6, 6, 55, 59, 6, 6, 6, 6, 55, 59, 55, 6, 55, 6, 55, 55, 6, 55, 55, 6, 6, 55, 55, 6, 6, 6, 6, 55, 55, 6, 6, 55, 55, 6, 55, 6, 6, 6, 6, 55, 55, 6, 55, 6, 55, 6, 6, 55, 6, 6, 6, 6, 6, 6, 55, 59, 55, 55, 6, 6, 55, 55, 6, 55, 55, 6, 6, 55, 6, 55, 6, 55, 6, 6, 6, 55, 55, 6, 55, 55, 55, 6, 6, 55, 913, 914, 914, 915, 55, 6, 55, 55, 6, 6, 55, 55, 55, 6, 55, 55, 59, 6, 55, 55, 6, 55, 6, 6, 6, 962, 963, 963, 964, 55, 6, 55, 55, 6, 6, 55, 6, 55, 6, 6, 6, 6, 55, 6, 55, 55, 55, 55, 6, 6, 1011, 1012, 1012, 1013, 55, 55, 55, 55, 6, 55, 6, 55, 6, 55, 55, 6, 55, 6, 55, 6, 55, 6, 6, 6, 6, 55, 6, 55, 55, 55, 6, 55, 55, 6, 6, 55, 6, 55, 6, 55, 6, 55, 55, 55, 55, 6, 55, 6, 6, 6, 6, 55, 55, 6, 55, 6, 6, 6, 55, 55, 55, 55, 55, 6, 55, 55, 55, 55, 6, 6, 55, 6, 55, 55, 55, 55, 55, 55, 6, 6, 55, 55, 55, 55, 55, 55],
+ "height":25,
+ "id":1,
+ "name":"Calque de Tuiles 1",
+ "opacity":1,
+ "type":"tilelayer",
+ "visible":true,
+ "width":25,
+ "x":0,
+ "y":0
+ },
+ {
+ "data":[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 514, 738, 739, 739, 739, 739, 739, 739, 739, 739, 739, 739, 740, 514, 0, 289, 0, 0, 0, 0, 0, 0, 0, 0, 0, 563, 787, 736, 837, 837, 837, 837, 837, 837, 837, 837, 737, 789, 563, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 787, 789, 0, 0, 0, 0, 0, 0, 0, 0, 787, 789, 0, 0, 0, 0, 0, 289, 0, 0, 0, 0, 0, 0, 514, 787, 789, 0, 0, 0, 0, 0, 0, 0, 0, 787, 789, 514, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 563, 787, 789, 0, 0, 0, 0, 0, 0, 0, 0, 787, 789, 563, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 787, 789, 0, 0, 0, 0, 0, 0, 0, 0, 787, 789, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 514, 787, 789, 0, 0, 0, 0, 0, 0, 0, 0, 787, 789, 514, 0, 0, 0, 291, 292, 532, 0, 0, 0, 0, 0, 563, 787, 789, 0, 0, 0, 0, 0, 0, 0, 0, 787, 789, 563, 0, 514, 0, 340, 341, 532, 532, 0, 0, 0, 0, 0, 787, 785, 739, 739, 739, 739, 739, 739, 739, 739, 786, 789, 0, 0, 563, 313, 0, 0, 0, 0, 0, 0, 0, 0, 514, 836, 837, 837, 837, 837, 837, 837, 837, 837, 837, 837, 838, 514, 0, 0, 0, 406, 0, 359, 359, 0, 0, 0, 0, 563, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 563, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 514, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 563, 0, 0, 0, 514, 0, 0, 0, 0, 0, 514, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 563, 0, 0, 0, 0, 0, 563, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 514, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 909, 761, 761, 910, 0, 0, 0, 0, 0, 0, 0, 0, 0, 563, 0, 0, 0, 0, 0, 0, 0, 1023, 1020, 1020, 1020, 958, 761, 761, 959, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1023, 1024, 0, 0, 1007, 960, 960, 1008, 0, 0, 0, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1023, 1024, 0, 0, 0, 383, 0, 0, 0, 60, 60, 109, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1023, 1019, 1020, 1020, 0, 33, 0, 383, 20, 256, 256, 305, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 934, 936, 0, 0, 0, 0, 0, 0, 0, 0, 0, 885, 886, 886, 886, 886, 886, 886, 886, 886, 886, 886, 886, 886, 886, 933, 936, 0, 0, 0, 0, 0, 0, 0, 0, 0, 983, 984, 984, 984, 984, 984, 984, 984, 984, 984, 984, 984, 984, 984, 984, 985, 0, 0, 0, 0, 0, 0, 0, 0],
+ "height":25,
+ "id":2,
+ "name":"Calque de Tuiles 2",
+ "opacity":1,
+ "type":"tilelayer",
+ "visible":true,
+ "width":25,
+ "x":0,
+ "y":0
+ }],
+ "nextlayerid":3,
+ "nextobjectid":1,
+ "orientation":"orthogonal",
+ "renderorder":"right-down",
+ "tiledversion":"1.7.2",
+ "tileheight":16,
+ "tilesets":[
+ {
+ "firstgid":1,
+ "source":"..\/Tiled\/tileset.json"
+ }],
+ "tilewidth":16,
+ "type":"map",
+ "version":"1.6",
+ "width":25
+}
\ No newline at end of file
diff --git a/src/display_engine.c b/src/display_engine.c
new file mode 100644
index 0000000..aa0cf66
--- /dev/null
+++ b/src/display_engine.c
@@ -0,0 +1 @@
+#include "display_engine.h"
\ No newline at end of file
diff --git a/src/display_engine.h b/src/display_engine.h
new file mode 100644
index 0000000..21255d2
--- /dev/null
+++ b/src/display_engine.h
@@ -0,0 +1,5 @@
+#ifndef _DISPLAY_ENGINE_H
+#define _DISPLAY_ENGINE_H
+
+
+#endif /* _DISPLAY_ENGINE_H */
\ No newline at end of file
diff --git a/src/game_engine.c b/src/game_engine.c
new file mode 100644
index 0000000..c0940b1
--- /dev/null
+++ b/src/game_engine.c
@@ -0,0 +1,3 @@
+#include "game_engine.h"
+
+
diff --git a/src/game_engine.h b/src/game_engine.h
new file mode 100644
index 0000000..5ca0a85
--- /dev/null
+++ b/src/game_engine.h
@@ -0,0 +1,14 @@
+#ifndef _GAME_ENGINE_H
+#define _GAME_ENGINE_H
+
+#include
+
+struct map
+{
+ int width, height, nb_layers;
+
+ // to get a cell : layers[layer_number][y*width+x]
+ uint16_t *layers[];
+};
+
+#endif /* _GAME_ENGINE_H */
\ No newline at end of file
diff --git a/src/main.c b/src/main.c
index 1a9e9b4..dd5d89c 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1,12 +1,50 @@
-#include
+/*
+ Name : Odyssée Game Engine
+ Version : dev
+
+ code provided with licence :
+ GNU General Public Licence v3.0
+*/
+
#include
+#include
+#include "game_engine.h"
+
+#define TILE_SIZE 16
+#define TILESET_WIDTH 49
+
+#define SCREEN_WIDTH 24
+#define SCREEN_HEIGHT 14
int main(void)
{
- dclear(C_WHITE);
- dtext(1, 1, C_BLACK, "Sample fxSDK add-in.");
- dupdate();
+ extern const struct map map_world;
+ extern const bopti_image_t img_tileset;
- getkey();
- return 1;
-}
+ dclear(C_WHITE);
+
+ for (int layer = 0 ; layer < map_world.nb_layers; layer++)
+ {
+ for (int y = 0 ; y <= SCREEN_HEIGHT; y ++)
+ {
+ for (int x = 0 ; x <= SCREEN_WIDTH; x ++)
+ {
+ unsigned int tile_id = map_world.layers[layer][y * map_world.width + x];
+ if (tile_id != 0)
+ {
+ tile_id --;
+ unsigned int tile_x = (TILE_SIZE + 1) * (tile_id % TILESET_WIDTH);
+ unsigned int tile_y = (TILE_SIZE + 1) * (tile_id / TILESET_WIDTH);
+
+ dsubimage(x * TILE_SIZE, y * TILE_SIZE, &img_tileset, tile_x, tile_y, TILE_SIZE, TILE_SIZE, DIMAGE_NONE);
+ }
+ }
+ }
+ }
+
+ // dprint(2, 2, C_BLACK, "%d", map_world.layers[0][0]);
+ dupdate();
+ getkey();
+
+ return 0;
+}
\ No newline at end of file