diff --git a/.gitignore b/.gitignore index 19e09ab..3e36b5b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,6 @@ -syntax: glob - aee .DS_Store trick.ini -.vscode/* +.vscode/ data.jrf -build/* +build/ diff --git a/CLAUDE.md b/CLAUDE.md new file mode 100644 index 0000000..f442da5 --- /dev/null +++ b/CLAUDE.md @@ -0,0 +1,60 @@ +# CLAUDE.md + +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. + +## Project Overview + +**Aventures En Egipte (AEE)** — a retro-style 2D game written in C++ using SDL3. The game uses a software-rendered 8-bit paletted graphics engine (320x200, 256 colors) with an OpenGL CRT shader pass, custom audio (JailAudio replacing SDL_Mixer), and GIF-based assets. The codebase and commit messages are in Valencian/Catalan. + +## Build + +```bash +# Linux +cmake -B build +cmake --build build + +# Windows (MinGW) +cmake -B build -G "MinGW Makefiles" +cmake --build build +``` + +Dependencies: SDL3, OpenGL. Uses CMake (minimum 3.10) with C++20. + +The executable is output to the project root. The `data/` folder contains runtime assets (GIF images, OGG music, GLSL shader) and must be in the working directory at runtime. + +## Architecture + +### Custom "Jail" Engine Libraries (prefix: J) + +All engine modules are flat C-style APIs (no classes), prefixed by subsystem: + +- **JG** (`source/jgame`) — Game loop timing: init/finalize, fixed-timestep update via `JG_ShouldUpdate()` +- **JD8** (`source/jdraw8`) — 8-bit paletted software renderer. 320x200 screen buffer (`JD8_Surface` = `Uint8*`), palette-indexed blitting with color-key transparency, fade effects. `JD8_Flip()` converts the indexed buffer to ARGB, uploads to SDL texture, and renders through the CRT shader +- **JA** (`source/jail_audio`) — Custom audio mixing using SDL3 audio streams directly (OGG via stb_vorbis, WAV). Manages music and sound channels independently +- **JI** (`source/jinput`) — Input: keyboard state polling, key debouncing, cheat code detection +- **JF** (`source/jfile`) — File I/O: supports loading from filesystem folder or a packed resource file (`.jrf`). Currently uses folder mode (`data/`) +- **shader** (`source/jshader`) — OpenGL post-processing shader (CRT effect) applied to the back buffer + +### Game Modules + +- **ModuleSequence** (`modulesequence.cpp/h`) — Non-gameplay screens: intro, menu, slides, banners, credits, death screen. State machine entry point (state=1) +- **ModuleGame** (`modulegame.cpp/h`) — Core gameplay loop. Owns and orchestrates all game objects. State=0 +- **Sprite** (`sprite.cpp/h`) — Base class for animated entities (frame/animation data via `Entitat`) +- **Prota** (`prota.cpp/h`) — Player character ("Sam"), extends Sprite +- **Mapa** (`mapa.cpp/h`) — Level map with tomb grid (16 tombs), items (treasure, keys, pharaoh, mummy, scroll, diamond), door logic +- **Momia** (`momia.cpp/h`) — Enemy: mummies +- **Bola** (`bola.cpp/h`) — Enemy: projectile ball +- **Marcador** (`marcador.cpp/h`) — HUD/scoreboard +- **info** (`info.cpp/h`) — Global game state namespace (room number, pyramid, money, diamonds, lives, etc.) + +### Main Loop (`main.cpp`) + +A state machine alternates between `ModuleSequence` (state 1) and `ModuleGame` (state 0). Each module's `Go()` returns the next state (-1 to quit). Modules are allocated/freed each transition. + +### Key Conventions + +- All surfaces are 320x200 = 64000 bytes. Pixel coordinates assume this fixed resolution +- Graphics loaded from GIF files, palettes extracted from GIF headers +- Music files are numbered OGG files (`00000001.ogg` etc.) +- `trick.ini` presence enables the secret character +- The `gif.h` is a header-only GIF decoder; `stb_vorbis.h` is the stb single-header OGG decoder diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..d88ff1f --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,62 @@ +# CMakeLists.txt + +cmake_minimum_required(VERSION 3.10) +project(aee VERSION 1.00) + +# Estándar de C++ +set(CMAKE_CXX_STANDARD 20) +set(CMAKE_CXX_STANDARD_REQUIRED True) + +# Exportar comandos de compilación para herramientas de análisis +set(CMAKE_EXPORT_COMPILE_COMMANDS ON) + +# --- LISTA EXPLÍCITA DE FUENTES --- +set(APP_SOURCES + source/main.cpp + source/bola.cpp + source/engendro.cpp + source/info.cpp + source/jail_audio.cpp + source/jdraw8.cpp + source/jfile.cpp + source/jgame.cpp + source/jinput.cpp + source/jshader.cpp + source/mapa.cpp + source/marcador.cpp + source/modulegame.cpp + source/modulesequence.cpp + source/momia.cpp + source/prota.cpp + source/sprite.cpp +) + +# Configuración de SDL3 +find_package(SDL3 REQUIRED CONFIG REQUIRED COMPONENTS SDL3) +message(STATUS "SDL3 encontrado: ${SDL3_INCLUDE_DIRS}") + +# --- EJECUTABLE --- +add_executable(${PROJECT_NAME} ${APP_SOURCES}) + +# --- DIRECTORIOS DE INCLUSIÓN --- +target_include_directories(${PROJECT_NAME} PUBLIC + "${CMAKE_SOURCE_DIR}/source" +) + +# Enlazar SDL3 +target_link_libraries(${PROJECT_NAME} PRIVATE SDL3::SDL3) + +# --- FLAGS DE COMPILACIÓN --- +target_compile_options(${PROJECT_NAME} PRIVATE -Wall) +target_compile_options(${PROJECT_NAME} PRIVATE $<$:-Os -ffunction-sections -fdata-sections>) + +# --- CONFIGURACIÓN POR PLATAFORMA --- +if(WIN32) + target_link_libraries(${PROJECT_NAME} PRIVATE mingw32 opengl32) +elseif(UNIX AND NOT APPLE) + find_package(OpenGL REQUIRED) + target_link_libraries(${PROJECT_NAME} PRIVATE OpenGL::GL) +endif() + +# Ejecutable en la raíz del proyecto +set_target_properties(${PROJECT_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}) diff --git a/gcwmake b/gcwmake deleted file mode 100644 index 90f7342..0000000 --- a/gcwmake +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash - -/opt/gcw0-toolchain/usr/bin/mipsel-linux-gcc -D GCWZERO -O2 -I/opt/gcw0-toolchain/usr/mipsel-gcw0-linux-uclibc/sysroot/usr/include/SDL2 -D_GNU_SOURCE=1 -D_REENTRANT -lSDL2 -lSDL2_mixer -lstdc++ *.cpp -o aee - -/opt/gcw0-toolchain/usr/bin/mksquashfs ./default.gcw0.desktop ./icon.png ./aee ./data.jrf aee.opk -all-root -noappend -no-exports -no-xattrs - -ftp -n -v 10.1.1.2 << EOT -ascii -user root ezahfm -pass -cd apps -put ./aee.opk -bye -EOT diff --git a/lagueirtofile b/lagueirtofile deleted file mode 100644 index 7540ddd..0000000 --- a/lagueirtofile +++ /dev/null @@ -1,5 +0,0 @@ -libs = -lSDL3 -lGL -cppflags = -D DEBUG -D VERBOSE -g -Wall -executable = aee -sourcepath = . -buildpath = build diff --git a/makefile b/makefile deleted file mode 100644 index 0e99dab..0000000 --- a/makefile +++ /dev/null @@ -1,10 +0,0 @@ -TARGET=aee -linux: - g++ *.cpp -lSDL3 -lGL -o $(TARGET) - -windows: - g++ *.cpp -lmingw32 -lSDL3 -lopengl32 -mwindows -o $(TARGET) - -clean: - rm -rf ./$(TARGET) - diff --git a/icon.png b/release/icon.png similarity index 100% rename from icon.png rename to release/icon.png diff --git a/bola.cpp b/source/bola.cpp similarity index 100% rename from bola.cpp rename to source/bola.cpp diff --git a/bola.h b/source/bola.h similarity index 100% rename from bola.h rename to source/bola.h diff --git a/engendro.cpp b/source/engendro.cpp similarity index 100% rename from engendro.cpp rename to source/engendro.cpp diff --git a/engendro.h b/source/engendro.h similarity index 100% rename from engendro.h rename to source/engendro.h diff --git a/gif.h b/source/gif.h similarity index 100% rename from gif.h rename to source/gif.h diff --git a/info.cpp b/source/info.cpp similarity index 100% rename from info.cpp rename to source/info.cpp diff --git a/info.h b/source/info.h similarity index 100% rename from info.h rename to source/info.h diff --git a/jail_audio.cpp b/source/jail_audio.cpp similarity index 100% rename from jail_audio.cpp rename to source/jail_audio.cpp diff --git a/jail_audio.h b/source/jail_audio.h similarity index 100% rename from jail_audio.h rename to source/jail_audio.h diff --git a/jdraw8.cpp b/source/jdraw8.cpp similarity index 100% rename from jdraw8.cpp rename to source/jdraw8.cpp diff --git a/jdraw8.h b/source/jdraw8.h similarity index 100% rename from jdraw8.h rename to source/jdraw8.h diff --git a/jfile.cpp b/source/jfile.cpp similarity index 99% rename from jfile.cpp rename to source/jfile.cpp index e075fe6..24e936f 100644 --- a/jfile.cpp +++ b/source/jfile.cpp @@ -69,7 +69,7 @@ bool file_getdictionary() { fi.read((char*)&toc_offset, 4); fi.seekg(toc_offset); - for (int i=0; i