Compare commits

..

No commits in common. "0605d4dbc331e1e12e4665a2ff960c9c4375d927" and "a6bacb6e8cb7cd89b9a179cfaacf30685b5db015" have entirely different histories.

13 changed files with 25805 additions and 103 deletions

2
.gitignore vendored
View File

@ -1,4 +1,4 @@
build build
2D_Engine_Casio_Tool 2D_Engine_Casio_Tool
GameData.bin GameData.bin
assets/__pycache__ assets/maps/__pycache__

21
3rd_party/nlohmann/LICENSE.MIT vendored Normal file
View File

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2013-2025 Niels Lohmann
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

25677
3rd_party/nlohmann/json/json.hpp vendored Normal file

File diff suppressed because it is too large Load Diff

View File

@ -31,7 +31,7 @@ LDFLAGS = -m32 -no-pie
# Converter flags # Converter flags
FXCONV_FLAGS = --cg --toolchain= --arch=i386 --outputtarget=elf32-x86-64 FXCONV_FLAGS = --cg --toolchain= --arch=i386 --outputtarget=elf32-x86-64
FXCONV_CONVERTER = assets/converters.py FXCONV_CONVERTERS = assets/maps/map_converter.py
# Change output location # Change output location
OUTPUT := $(BUILD_DIR)/$(OUTPUT) OUTPUT := $(BUILD_DIR)/$(OUTPUT)
@ -78,7 +78,7 @@ $(BUILD_DIR)/%.o: %
$(eval CURRENT_FILE := $(shell echo $$(($(CURRENT_FILE)+1)))) $(eval CURRENT_FILE := $(shell echo $$(($(CURRENT_FILE)+1))))
$(eval PERCENTAGE := $(shell echo $$(($(CURRENT_FILE)*100/$(TOTAL_FILES))))) $(eval PERCENTAGE := $(shell echo $$(($(CURRENT_FILE)*100/$(TOTAL_FILES)))))
@echo "[$(PERCENTAGE)%] $(GREEN)Building FXCONV object $@$(RESET)" @echo "[$(PERCENTAGE)%] $(GREEN)Building FXCONV object $@$(RESET)"
$(Q)fxconv $(FXCONV_FLAGS) --converter=$(FXCONV_CONVERTER) $< -o $@ $(Q)fxconv $(FXCONV_FLAGS) --converter=$(FXCONV_CONVERTERS) $< -o $@
$(Q)objcopy --add-section .note.GNU-stack=/dev/null $@ $(Q)objcopy --add-section .note.GNU-stack=/dev/null $@
# Source files dependencies # Source files dependencies

View File

@ -12,9 +12,10 @@ This tool is used to make game data for the 2D_Engine_Casio [Gitea](https://gite
- Files from the gint project are used and modified in directory [gint](gint). - Files from the gint project are used and modified in directory [gint](gint).
[Git](https://git.planet-casio.com/Lephenixnoir/gint) [Git](https://git.planet-casio.com/Lephenixnoir/gint)
- Tileset and props are taken from the free pack offered by [Anokolisa](https://anokolisa.itch.io/). - Folder [src/nlohmann/json](src/nlohmann/json) contains code under **MIT license** :
See [Terms.pdf](assets/tileset/Terms.pdf) Copyright (c) 2013-2025 Niels Lohmann.
There is no saxophone solo in this project, but I had to cite his/her beautifull work ! See [LICENSE.MIT](src/nlohmann/json/LICENSE.MIT).
[GitHub](https://github.com/nlohmann/json)
- Player sheets are a separation of the original sheet designed and distributed by [PenzillaDesign](https://penzilladesign.itch.io/). - Assets are taken from the free pack offered by [Anokolisa](https://anokolisa.itch.io/).
See [PenzillaDesign_StandardLicense.pdf](assets/player-sheets/PenzillaDesign_StandardLicense.pdf) See [Terms.pdf]()

View File

@ -1,75 +0,0 @@
import fxconv
from fxconv import u8, u16, u32, ref, string
import json
def convert(input, output, params, target):
if params["custom-type"] == "map":
convert_map(input, output, params, target)
return 0
else:
return 1
def convert_map(input, output, params, target):
with open(input, "r") as fp:
map = json.load(fp)
TRANSFORM_COMPONENT = 0
SPRITE_COMPONENT = 1
ANIMATION_SYSTEM = 2
background_layer1 = b"".join(u16(tile) for tile in map["BackgroundLayer1"])
background_layer2 = b"".join(u16(tile) for tile in map["BackgroundLayer2"])
background_layer3 = b"".join(u16(tile) for tile in map["BackgroundLayer3"])
foreground = b"".join(u16(tile) for tile in map["Foreground"])
entities = fxconv.Structure()
for e in map["Entities"]:
entities += u16(e["ID"])
entities += u32(len(e["Components"]))
components = fxconv.Structure()
for c in e["Components"]:
component_data = fxconv.Structure()
match c["Type"]:
case "TransformComponent":
components += u32(TRANSFORM_COMPONENT)
component_data += u32(c["x"])
component_data += u32(c["y"])
component_data += u32(c["w"])
component_data += u32(c["h"])
component_data += u32(c["Speed"])
case "SpriteComponent":
components += u32(SPRITE_COMPONENT)
component_data += string(c["TextureName"])
case "AnimationSystem":
components += u32(ANIMATION_SYSTEM)
component_data += u32(c["NbFrames"])
component_data += u32(c["ActualFrame"])
component_data += u32(c["FrameDelayMs"])
component_data += u8(c["Play"])
component_data += u8(c["Loop"])
component_data += u8(c["Reverse"])
case _:
raise fxconv.FxconvError(f"unknown component type {c['Type']}")
components += ref(component_data)
entities += ref(components)
o = fxconv.ObjectData()
o += string(params["name"])
o += u32(map["MapWidth"]) + u32(map["MapHeight"])
o += ref(background_layer1)
o += ref(background_layer2)
o += ref(background_layer3)
o += ref(foreground)
o += u32(len(map["Entities"]))
o += ref(entities)
fxconv.elf(o, output, params["name"], **target)

View File

@ -47,7 +47,7 @@
] ]
}, },
{ {
"ID": 345, "ID": 2034,
"Components": [ "Components": [
{ {
"Type": "TransformComponent", "Type": "TransformComponent",

View File

@ -0,0 +1,79 @@
import fxconv
from fxconv import u16, u32, ref, chars, string
import json
def convert(input, output, params, target):
if params["custom-type"] == "map":
convert_map(input, output, params, target)
return 0
else:
return 1
def convert_map(input, output, params, target):
with open(input, "r") as fp:
map = json.load(fp)
TRANSFORM_COMPONENT = 0
SPRITE_COMPONENT = 1
ANIMATION_SYSTEM = 2
background_layer1 = b''.join(u16(tile) for tile in map["BackgroundLayer1"])
background_layer2 = b''.join(u16(tile) for tile in map["BackgroundLayer2"])
background_layer3 = b''.join(u16(tile) for tile in map["BackgroundLayer3"])
foreground = b''.join(u16(tile) for tile in map["Foreground"])
entities = fxconv.Structure()
for entity in map["Entities"]:
e = fxconv.Structure()
e += u16(entity["ID"])
e += u32(len(entity["Components"]))
components = fxconv.Structure()
for component in entity["Components"]:
c = fxconv.Structure()
c_data = fxconv.Structure()
match component["Type"]:
case "TransformComponent":
c += u32(TRANSFORM_COMPONENT)
c_data += u32(component["x"])
c_data += u32(component["y"])
c_data += u32(component["w"])
c_data += u32(component["h"])
c_data += u32(component["Speed"])
case "SpriteComponent":
c += u32(SPRITE_COMPONENT)
c_data += string(component["TextureName"])
case "AnimationSystem":
c += u32(SPRITE_COMPONENT)
c_data += u32(component["NbFrames"])
c_data += u32(component["ActualFrame"])
c_data += u32(component["FrameDelayMs"])
c_data += u32(component["Play"])
c_data += u32(component["Loop"])
c_data += u32(component["Reverse"])
case _:
raise fxconv.FxconvError(f"unknown component type {component['Type']}")
c += ref(c_data)
components += c
e += ref(components)
entities += e
o = fxconv.ObjectData()
o += string(params["name"])
o += u32(map["MapWidth"]) + u32(map["MapHeight"])
o += ref(background_layer1)
o += ref(background_layer2)
o += ref(background_layer3)
o += ref(foreground)
o += u32(len(map["Entities"]))
o += ref(entities)
fxconv.elf(o, output, params["name"], **target)

View File

@ -4,13 +4,13 @@
#include <stdint.h> #include <stdint.h>
typedef struct animation_system_data_t { typedef struct animation_system_data_t {
uint32_t nb_frames; bool play :1;
uint32_t actual_frame_nb; bool loop :1;
uint32_t frame_delay_ms; bool reverse :1;
bool play; float frame_delay_ms;
bool loop; uint32_t actual_frame_nb;
bool reverse; uint32_t nb_frames;
} __attribute__((packed, aligned(4))) animation_system_data_t; } animation_system_data_t;
#endif // SPRITE_COMPONENT_H #endif // SPRITE_COMPONENT_H

View File

@ -19,12 +19,12 @@ typedef struct component_t {
sprite_component_data_t *sprite_component_data; sprite_component_data_t *sprite_component_data;
animation_system_data_t *animation_system_data; animation_system_data_t *animation_system_data;
} component_data; } component_data;
} __attribute__((packed, aligned(4))) component_t; } component_t;
typedef struct entity_t { typedef struct entity_t {
uint16_t id; uint16_t id;
uint32_t nb_component; uint32_t nb_component;
component_t *components; component_t *components;
} __attribute__((packed, aligned(4))) entity_t; } entity_t;
#endif // ECS_H #endif // ECS_H

View File

@ -3,6 +3,6 @@
typedef struct sprite_component_data_t { typedef struct sprite_component_data_t {
const char *texture_name; const char *texture_name;
} __attribute__((packed, aligned(4))) sprite_component_data_t; } sprite_component_data_t;
#endif // SPRITE_COMPONENT_H #endif // SPRITE_COMPONENT_H

View File

@ -4,7 +4,7 @@
typedef struct transform_component_data_t { typedef struct transform_component_data_t {
uint32_t x, y; uint32_t x, y;
uint32_t w, h; uint32_t w, h;
uint32_t speed; float speed;
} __attribute__((packed, aligned(4))) transform_component_data_t; } transform_component_data_t;
#endif // TRANSFORM_COMPONENT_H #endif // TRANSFORM_COMPONENT_H

View File

@ -69,7 +69,6 @@ void verify_maps_integrity(void)
{ {
const uint32_t NB_COMPONENTS = ENTITIES[entity_index].nb_component; const uint32_t NB_COMPONENTS = ENTITIES[entity_index].nb_component;
const component_t *COMPONENTS = ENTITIES[entity_index].components; const component_t *COMPONENTS = ENTITIES[entity_index].components;
std::cout << " Entity " << entity_index + 1 << std::endl; std::cout << " Entity " << entity_index + 1 << std::endl;
std::cout << " - ID : " << ENTITIES[entity_index].id << std::endl; std::cout << " - ID : " << ENTITIES[entity_index].id << std::endl;
std::cout << " - Nb Components : " << NB_COMPONENTS << std::endl; std::cout << " - Nb Components : " << NB_COMPONENTS << std::endl;
@ -106,12 +105,12 @@ void verify_maps_integrity(void)
{ {
const animation_system_data_t *system_data = COMPONENT->component_data.animation_system_data; const animation_system_data_t *system_data = COMPONENT->component_data.animation_system_data;
std::cout << " - AnimationSystem :" << std::endl; std::cout << " - AnimationSystem :" << std::endl;
std::cout << " - NbFrames : " << system_data->nb_frames << std::endl; std::cout << " - NbFrames : " << system_data->nb_frames;
std::cout << " - FrameNb : " << system_data->actual_frame_nb << std::endl; std::cout << " - FrameNb : " << system_data->actual_frame_nb;
std::cout << " - FrameDelay : " << system_data->frame_delay_ms << std::endl; std::cout << " - FrameDelay : " << system_data->frame_delay_ms;
std::cout << " - Play : " << system_data->play << std::endl; std::cout << " - Play : " << system_data->play;
std::cout << " - Loop : " << system_data->loop << std::endl; std::cout << " - Loop : " << system_data->loop;
std::cout << " - Reverse : " << system_data->reverse << std::endl; std::cout << " - Reverse : " << system_data->reverse;
break; break;
} }
} }