First commit

This commit is contained in:
2026-03-15 18:36:05 +01:00
commit 9dfc56eb4a
12 changed files with 624 additions and 0 deletions

39
runtime/Makefile Normal file
View File

@@ -0,0 +1,39 @@
DEVKITPRO := C:/Users/Usuario/Documents/softwares/devkitPro
DEVKITARM := $(DEVKITPRO)/devkitARM
LIBCTRU := $(DEVKITPRO)/libctru
3DSXTOOL := $(DEVKITPRO)/tools/bin/3dsxtool.exe
CXX := $(DEVKITARM)/bin/arm-none-eabi-g++.exe
include $(DEVKITARM)/3ds_rules
TARGET := FennecApp
INCLUDES := -Ilib -Igen -I$(LIBCTRU)/include \
-I$(DEVKITPRO)/libcitro2d/include \
-I$(DEVKITPRO)/libcitro3d/include
ARCH := -march=armv6k -mtune=mpcore -mfloat-abi=hard -mfpu=vfp
CFLAGS := -g -Wall -O2 -mword-relocations $(ARCH)
CXXFLAGS := $(CFLAGS) -fno-exceptions -fno-rtti $(INCLUDES)
LDFLAGS := $(ARCH) -specs=3dsx.specs -g
LIBS := -lcitro2d -lcitro3d -lctru -lm
all: $(TARGET).3dsx
$(TARGET).3dsx: $(TARGET).elf
"$(3DSXTOOL)" $< $@ \
--smdh="../build/metadata.smdh"
@echo "🦊 Fennec : Build terminé avec succès !"
$(TARGET).elf: lib/fennec_core.o gen/out.o
$(CXX) $(LDFLAGS) -o $@ $^ -L$(LIBCTRU)/lib $(LIBS)
lib/fennec_core.o: lib/fennec_core.cpp
$(CXX) $(CXXFLAGS) -c $< -o $@
gen/out.o: gen/out.cpp
$(CXX) $(CXXFLAGS) -c $< -o $@
clean:
rm -f lib/*.o gen/*.o *.elf *.3dsx

29
runtime/gen/out.cpp Normal file
View File

@@ -0,0 +1,29 @@
#include "fennec_core.h"
int main() {
Fennec::init();
u32 white = Fennec::color(255, 255, 255);
u32 red = Fennec::color(255, 0, 0);
u32 blue = Fennec::color(0, 0, 255);
while (aptMainLoop()) {
hidScanInput();
if (hidKeysDown() & KEY_START) break;
Fennec::beginFrame();
Fennec::selectScreen(GFX_TOP);
Fennec::drawRect(10, 10, 380, 220, blue); // Un fond bleu
Fennec::drawText(50, 100, "BIENVENUE SUR FENNEC", white);
Fennec::selectScreen(GFX_BOTTOM);
Fennec::drawRect(50, 50, 100, 100, red);
Fennec::drawText(60, 160, "Carré rouge :)", white);
Fennec::endFrame();
}
Fennec::exit();
return 0;
}

View File

@@ -0,0 +1,64 @@
#include "fennec_core.h"
namespace Fennec {
static C3D_RenderTarget* topTarget;
static C3D_RenderTarget* bottomTarget;
static C3D_RenderTarget* currentTarget;
static C2D_TextBuf staticTextBuf;
void init() {
gfxInitDefault();
C3D_Init(C3D_DEFAULT_CMDBUF_SIZE);
C2D_Init(C2D_DEFAULT_MAX_OBJECTS);
C2D_Prepare();
staticTextBuf = C2D_TextBufNew(4096);
topTarget = C2D_CreateScreenTarget(GFX_TOP, GFX_LEFT);
bottomTarget = C2D_CreateScreenTarget(GFX_BOTTOM, GFX_LEFT);
currentTarget = topTarget;
}
void drawRect(float x, float y, float z, float w, float h, u32 color) {
C2D_DrawRectSolid(x, y, 0.5f, w, h, color);
}
void drawText(float x, float y, std::string content, u32 color) {
if (!staticTextBuf) return;
C2D_Text textObj;
C2D_TextParse(&textObj, staticTextBuf, content.c_str());
C2D_TextOptimize(&textObj);
C2D_DrawText(&textObj, C2D_WithColor, x, y, 0.5f, 0.1f, 0.1f, color);
}
void clearTextBuffer() {
C2D_TextBufClear(staticTextBuf)
}
void exit() {
C2D_TextBufDelete(staticTextBuf);
C2D_Fini();
C3D_Fini();
gfxExit();
}
void beginFrame() {
C3D_FrameBegin(C3D_FRAME_SYNCDRAW);
C2D_TextBufClear(staticTextBuf);
}
void endFrame() {
C3D_FrameEnd(0);
}
void selectScreen(gfxScreen_t screen) {
currentTarget = (screen == GFX_TOP) ? topTarget : bottomTarget;
C2D_SceneBegin(currentTarget);
}
u32 color(u8 r, u8 g, u8 b, u8 a) {
return C2D_Color32(r, g, b, a);
}
}

21
runtime/lib/fennec_core.h Normal file
View File

@@ -0,0 +1,21 @@
#ifndef FENNEC_CORE_H
#define FENNEC_CORE_H
#include <3ds.h>
#include <citro2d.h>
#include <string>
namespace Fennec {
void init();
void exit();
void beginFrame();
void endFrame();
void drawRect(float x, float y, float w, float h, u32 color);
void drawText(float x, float y, std::string content, u32 color);
void selectScreen(gfxScreen_t screen);
u32 color(u8 r, u8 g, u8 b, u8 a = 255);
}
#endif