Compiling for 32 bit arch because of compatibility with SH4 arch

This commit is contained in:
Ulysse Cura 2025-08-24 12:54:23 +02:00
parent 8c14e56846
commit a6bacb6e8c
9 changed files with 94 additions and 41 deletions

View File

@ -25,12 +25,12 @@ OUTPUT := 2D_Engine_Casio_Tool
# Compiler and flags # Compiler and flags
CXX = ccache g++ CXX = ccache g++
CXXFLAGS = -Wall -Wextra -std=c++17 -O2 -no-pie CXXFLAGS = -m32 -Wall -Wextra -std=c++17 -g -no-pie
INCLUDE_DIRS = 3rd_party INCLUDE_DIRS = 3rd_party
LDFLAGS = -no-pie LDFLAGS = -m32 -no-pie
# Converter flags # Converter flags
FXCONV_FLAGS = --cg --toolchain= --arch=x86-64 --outputtarget=elf64-x86-64 FXCONV_FLAGS = --cg --toolchain= --arch=i386 --outputtarget=elf32-x86-64
FXCONV_CONVERTERS = assets/maps/map_converter.py FXCONV_CONVERTERS = assets/maps/map_converter.py
# Change output location # Change output location

View File

@ -1,5 +1,5 @@
{ {
"MapWidth": 3, "MapWidth": 2,
"MapHeight": 2, "MapHeight": 2,
"BackgroundLayer1": [ "BackgroundLayer1": [

View File

@ -1,5 +1,5 @@
import fxconv import fxconv
from fxconv import u16, u32, ref, string from fxconv import u16, u32, ref, chars, string
import json import json
def convert(input, output, params, target): def convert(input, output, params, target):
@ -17,6 +17,11 @@ def convert_map(input, output, params, target):
SPRITE_COMPONENT = 1 SPRITE_COMPONENT = 1
ANIMATION_SYSTEM = 2 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() entities = fxconv.Structure()
for entity in map["Entities"]: for entity in map["Entities"]:
@ -24,6 +29,8 @@ def convert_map(input, output, params, target):
e += u16(entity["ID"]) e += u16(entity["ID"])
e += u32(len(entity["Components"])) e += u32(len(entity["Components"]))
components = fxconv.Structure()
for component in entity["Components"]: for component in entity["Components"]:
c = fxconv.Structure() c = fxconv.Structure()
c_data = fxconv.Structure() c_data = fxconv.Structure()
@ -54,17 +61,18 @@ def convert_map(input, output, params, target):
raise fxconv.FxconvError(f"unknown component type {component['Type']}") raise fxconv.FxconvError(f"unknown component type {component['Type']}")
c += ref(c_data) c += ref(c_data)
e += ref(c) components += c
e += ref(components)
entities += e entities += e
o = fxconv.ObjectData() o = fxconv.ObjectData()
o += string(params["name"]) o += string(params["name"])
o += u32(map["MapWidth"]) + u32(map["MapHeight"]) o += u32(map["MapWidth"]) + u32(map["MapHeight"])
o += bytes(map["BackgroundLayer1"]) o += ref(background_layer1)
o += bytes(map["BackgroundLayer2"]) o += ref(background_layer2)
o += bytes(map["BackgroundLayer3"]) o += ref(background_layer3)
o += bytes(map["Foreground"]) o += ref(foreground)
o += u32(len(map["Entities"])) o += u32(len(map["Entities"]))
o += ref(entities) o += ref(entities)

View File

@ -23,8 +23,7 @@ typedef struct component_t {
typedef struct entity_t { typedef struct entity_t {
uint16_t id; uint16_t id;
uint32_t nb_component;
unsigned long nb_component;
component_t *components; component_t *components;
} entity_t; } entity_t;

View File

@ -8,10 +8,10 @@
typedef struct game_data_t { typedef struct game_data_t {
const uint32_t nb_textures = NB_TEXTURES; const uint32_t nb_textures = NB_TEXTURES;
const texture_t *textures = textures; const texture_t *textures = TEXTURES;
const uint32_t nb_maps = NB_MAPS; const uint32_t nb_maps = NB_MAPS;
const map_t **maps = maps; const map_t **maps = MAPS;
} game_data_t; } game_data_t;
void write_game_data_as_bin_into_file(void); void write_game_data_as_bin_into_file(void);

View File

@ -2,46 +2,82 @@
#include "maps.hpp" #include "maps.hpp"
static inline void verify_layers_integrity(void)
{
for(uint32_t map_index = 0; map_index < NB_MAPS; map_index++)
{
std::cout << "Map " << map_index + 1 << std::endl;
}
}
static inline void verify_entities_integrity(void)
{
}
void verify_maps_integrity(void) void verify_maps_integrity(void)
{ {
std::cout << "Nb Maps : " << NB_MAPS << std::endl; std::cout << "Nb Maps : " << NB_MAPS << std::endl;
for(uint32_t map_index = 0; map_index < NB_MAPS; map_index++) for(uint32_t map_index = 0; map_index < NB_MAPS; map_index++)
{ {
const uint32_t NB_ENTITIES = maps[map_index]->nb_entities; const uint32_t NB_ENTITIES = MAPS[map_index]->nb_entities;
const entity_t *ENTITIES = maps[map_index]->entities; const entity_t *ENTITIES = MAPS[map_index]->entities;
std::cout << "Map " << map_index + 1 << std::endl; std::cout << "Map " << map_index + 1 << std::endl;
std::cout << " - MapName : " << maps[map_index]->map_name << std::endl; std::cout << " - MapName : " << MAPS[map_index]->map_name << std::endl;
std::cout << " - MapWidth : " << maps[map_index]->map_width << std::endl; std::cout << " - MapWidth : " << MAPS[map_index]->map_width << std::endl;
std::cout << " - MapHeight : " << maps[map_index]->map_width << std::endl; std::cout << " - MapHeight : " << MAPS[map_index]->map_height << std::endl;
std::cout << " - Nb Entities : " << NB_ENTITIES << std::endl; std::cout << " BackgroundLayer1 :";
for(uint32_t tile_index_x = 0; tile_index_x < MAPS[map_index]->map_width; tile_index_x++)
{
std::cout << "\n ";
for(uint32_t tile_index_y = 0; tile_index_y < MAPS[map_index]->map_height; tile_index_y++)
{
std::cout << MAPS[map_index]->map_background_layer1[tile_index_x * MAPS[map_index]->map_width + tile_index_y] << ",";
}
}
std::cout << "\n BackgroundLayer2 :";
for(uint32_t tile_index_x = 0; tile_index_x < MAPS[map_index]->map_width; tile_index_x++)
{
std::cout << "\n ";
for(uint32_t tile_index_y = 0; tile_index_y < MAPS[map_index]->map_height; tile_index_y++)
{
std::cout << MAPS[map_index]->map_background_layer2[tile_index_x * MAPS[map_index]->map_width + tile_index_y] << ",";
}
}
std::cout << "\n BackgroundLayer3 :";
for(uint32_t tile_index_x = 0; tile_index_x < MAPS[map_index]->map_width; tile_index_x++)
{
std::cout << "\n ";
for(uint32_t tile_index_y = 0; tile_index_y < MAPS[map_index]->map_height; tile_index_y++)
{
std::cout << MAPS[map_index]->map_background_layer3[tile_index_x * MAPS[map_index]->map_width + tile_index_y] << ",";
}
}
std::cout << "\n Foreground :";
for(uint32_t tile_index_x = 0; tile_index_x < MAPS[map_index]->map_width; tile_index_x++)
{
std::cout << "\n ";
for(uint32_t tile_index_y = 0; tile_index_y < MAPS[map_index]->map_height; tile_index_y++)
{
std::cout << MAPS[map_index]->map_foreground[tile_index_x * MAPS[map_index]->map_width + tile_index_y] << ",";
}
}
std::cout << "\n - Nb Entities : " << NB_ENTITIES << std::endl;
for(uint32_t entity_index = 0; entity_index < NB_ENTITIES; entity_index++) for(uint32_t entity_index = 0; entity_index < NB_ENTITIES; entity_index++)
{ {
const uint32_t NB_COMPONENTS = ENTITIES->nb_component; const uint32_t NB_COMPONENTS = ENTITIES[entity_index].nb_component;
const component_t *COMPONENTS = ENTITIES->components; const component_t *COMPONENTS = ENTITIES[entity_index].components;
std::cout << " Entity " << entity_index + 1 << std::endl;
std::cout << " - Nb Components : " << NB_COMPONENTS << std::endl; std::cout << " - ID : " << ENTITIES[entity_index].id << std::endl;
std::cout << " - Nb Components : " << NB_COMPONENTS << std::endl;
for(uint32_t component_index = 0; component_index < NB_COMPONENTS; component_index++) for(uint32_t component_index = 0; component_index < NB_COMPONENTS; component_index++)
{ {
const component_t *COMPONENT = &COMPONENTS[component_index]; const component_t *COMPONENT = &COMPONENTS[component_index];
std::cout << " Component " << component_index << std::endl; std::cout << " Component " << component_index + 1 << std::endl;
switch(COMPONENT->component_type) switch(COMPONENT->component_type)
{ {

View File

@ -20,7 +20,7 @@ typedef struct map_t {
extern map_t map_example; extern map_t map_example;
static map_t *maps[] = { static const map_t *MAPS[] = {
&map_example &map_example
}; };

View File

@ -1,6 +1,16 @@
#include <iostream>
#include "textures.hpp" #include "textures.hpp"
void verify_textures_integrity(void) void verify_textures_integrity(void)
{ {
return; std::cout << "NbTexture : " << NB_TEXTURES << std::endl;
for(uint32_t texture_index = 0; texture_index < NB_TEXTURES; texture_index++)
{
const texture_t *TEXTURE = &TEXTURES[texture_index];
std::cout << "Texture \"" << TEXTURE->name << "\" :" << std::endl;
std::cout << " - Width : " << TEXTURE->image->width << std::endl;
std::cout << " - Height : " << TEXTURE->image->height << std::endl;
}
} }

View File

@ -17,7 +17,7 @@ extern bopti_image_t img_lever_sheet;
extern bopti_image_t img_small_chest_sheet; extern bopti_image_t img_small_chest_sheet;
extern bopti_image_t img_big_chest_sheet; extern bopti_image_t img_big_chest_sheet;
static texture_t textures[] = { static const texture_t TEXTURES[] = {
{"tileset", &img_tileset}, {"tileset", &img_tileset},
{"player_idle_sheet", &img_player_idle_sheet}, {"player_idle_sheet", &img_player_idle_sheet},
{"player_walk_sheet", &img_player_walk_sheet}, {"player_walk_sheet", &img_player_walk_sheet},