Compare commits
3 Commits
a6bacb6e8c
...
0605d4dbc3
Author | SHA1 | Date |
---|---|---|
|
0605d4dbc3 | |
|
cbe4595fb8 | |
|
4c680feb5e |
|
@ -1,4 +1,4 @@
|
||||||
build
|
build
|
||||||
2D_Engine_Casio_Tool
|
2D_Engine_Casio_Tool
|
||||||
GameData.bin
|
GameData.bin
|
||||||
assets/maps/__pycache__
|
assets/__pycache__
|
||||||
|
|
|
@ -1,21 +0,0 @@
|
||||||
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.
|
|
File diff suppressed because it is too large
Load Diff
4
Makefile
4
Makefile
|
@ -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_CONVERTERS = assets/maps/map_converter.py
|
FXCONV_CONVERTER = assets/converters.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_CONVERTERS) $< -o $@
|
$(Q)fxconv $(FXCONV_FLAGS) --converter=$(FXCONV_CONVERTER) $< -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
|
||||||
|
|
11
README.md
11
README.md
|
@ -12,10 +12,9 @@ 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)
|
||||||
|
|
||||||
- Folder [src/nlohmann/json](src/nlohmann/json) contains code under **MIT license** :
|
- Tileset and props are taken from the free pack offered by [Anokolisa](https://anokolisa.itch.io/).
|
||||||
Copyright (c) 2013-2025 Niels Lohmann.
|
See [Terms.pdf](assets/tileset/Terms.pdf)
|
||||||
See [LICENSE.MIT](src/nlohmann/json/LICENSE.MIT).
|
There is no saxophone solo in this project, but I had to cite his/her beautifull work !
|
||||||
[GitHub](https://github.com/nlohmann/json)
|
|
||||||
|
|
||||||
- Assets are taken from the free pack offered by [Anokolisa](https://anokolisa.itch.io/).
|
- Player sheets are a separation of the original sheet designed and distributed by [PenzillaDesign](https://penzilladesign.itch.io/).
|
||||||
See [Terms.pdf]()
|
See [PenzillaDesign_StandardLicense.pdf](assets/player-sheets/PenzillaDesign_StandardLicense.pdf)
|
|
@ -0,0 +1,75 @@
|
||||||
|
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)
|
|
@ -47,7 +47,7 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ID": 2034,
|
"ID": 345,
|
||||||
"Components": [
|
"Components": [
|
||||||
{
|
{
|
||||||
"Type": "TransformComponent",
|
"Type": "TransformComponent",
|
||||||
|
|
|
@ -1,79 +0,0 @@
|
||||||
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)
|
|
|
@ -4,13 +4,13 @@
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
typedef struct animation_system_data_t {
|
typedef struct animation_system_data_t {
|
||||||
bool play :1;
|
|
||||||
bool loop :1;
|
|
||||||
bool reverse :1;
|
|
||||||
|
|
||||||
float frame_delay_ms;
|
|
||||||
uint32_t actual_frame_nb;
|
|
||||||
uint32_t nb_frames;
|
uint32_t nb_frames;
|
||||||
} animation_system_data_t;
|
uint32_t actual_frame_nb;
|
||||||
|
uint32_t frame_delay_ms;
|
||||||
|
|
||||||
|
bool play;
|
||||||
|
bool loop;
|
||||||
|
bool reverse;
|
||||||
|
} __attribute__((packed, aligned(4))) animation_system_data_t;
|
||||||
|
|
||||||
#endif // SPRITE_COMPONENT_H
|
#endif // SPRITE_COMPONENT_H
|
|
@ -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;
|
||||||
} component_t;
|
} __attribute__((packed, aligned(4))) 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;
|
||||||
} entity_t;
|
} __attribute__((packed, aligned(4))) entity_t;
|
||||||
|
|
||||||
#endif // ECS_H
|
#endif // ECS_H
|
|
@ -3,6 +3,6 @@
|
||||||
|
|
||||||
typedef struct sprite_component_data_t {
|
typedef struct sprite_component_data_t {
|
||||||
const char *texture_name;
|
const char *texture_name;
|
||||||
} sprite_component_data_t;
|
} __attribute__((packed, aligned(4))) sprite_component_data_t;
|
||||||
|
|
||||||
#endif // SPRITE_COMPONENT_H
|
#endif // SPRITE_COMPONENT_H
|
|
@ -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;
|
||||||
float speed;
|
uint32_t speed;
|
||||||
} transform_component_data_t;
|
} __attribute__((packed, aligned(4))) transform_component_data_t;
|
||||||
|
|
||||||
#endif // TRANSFORM_COMPONENT_H
|
#endif // TRANSFORM_COMPONENT_H
|
|
@ -69,6 +69,7 @@ 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;
|
||||||
|
@ -105,12 +106,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::cout << " - NbFrames : " << system_data->nb_frames << std::endl;
|
||||||
std::cout << " - FrameNb : " << system_data->actual_frame_nb;
|
std::cout << " - FrameNb : " << system_data->actual_frame_nb << std::endl;
|
||||||
std::cout << " - FrameDelay : " << system_data->frame_delay_ms;
|
std::cout << " - FrameDelay : " << system_data->frame_delay_ms << std::endl;
|
||||||
std::cout << " - Play : " << system_data->play;
|
std::cout << " - Play : " << system_data->play << std::endl;
|
||||||
std::cout << " - Loop : " << system_data->loop;
|
std::cout << " - Loop : " << system_data->loop << std::endl;
|
||||||
std::cout << " - Reverse : " << system_data->reverse;
|
std::cout << " - Reverse : " << system_data->reverse << std::endl;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue