Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
.DS_Store
**/__pycache__/
*.pyc

/cmake-build-*
/.idea/
CMakeUserPresets.json
Expand Down
7 changes: 6 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ endif()
# Performance options
option(LBA2_NATIVE_ARCH "Use -march=native for host-optimized build (not portable)" OFF)

# Optional: embed community 640x480 LIM+PAL from assets/embedded/ for startup logos (see assets/embedded/README.txt)
option(LBA2_EMBEDDED_COMMUNITY_STARTUP "Embed community startup LIM/PAL from assets/embedded (no HQR replacement)" OFF)
# CD audio check UI is obsolete for this port; default ON skips insert-disc screen and uses InitCD(\"\").
option(LBA2_SKIP_CDROM_CHECK "Skip CD-ROM insert-disc loop; call InitCD(\"\") instead" ON)

if(CMAKE_BUILD_TYPE STREQUAL "Release")
include(CheckIPOSupported)
check_ipo_supported(RESULT ipo_supported OUTPUT ipo_error)
Expand Down Expand Up @@ -82,7 +87,7 @@ include(${CMAKE_SOURCE_DIR}/cmake/git_version.cmake)

# Build info header (timestamp from compile, flags from configure,
# version macro from the include of VERSION_GENERATED.h inside BUILD_INFO.h.in).
set(BUILD_FLAGS_STR "SOUND_BACKEND=${SOUND_BACKEND} MVIDEO_BACKEND=${MVIDEO_BACKEND} ENABLE_ASM=${ENABLE_ASM}")
set(BUILD_FLAGS_STR "SOUND_BACKEND=${SOUND_BACKEND} MVIDEO_BACKEND=${MVIDEO_BACKEND} ENABLE_ASM=${ENABLE_ASM} LBA2_SKIP_CDROM_CHECK=${LBA2_SKIP_CDROM_CHECK} LBA2_EMBEDDED_COMMUNITY_STARTUP=${LBA2_EMBEDDED_COMMUNITY_STARTUP}")
configure_file(${CMAKE_SOURCE_DIR}/SOURCES/BUILD_INFO.h.in ${CMAKE_BINARY_DIR}/BUILD_INFO.h)

# Process the targets
Expand Down
33 changes: 33 additions & 0 deletions SOURCES/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,39 @@ set(SOURCES_FILES_ASM_DOS DEC_XCF.ASM HERCUL_A.ASM KEYB.ASM)

list(APPEND SOURCES_FILES CONSOLE/CONSOLE_CMD.CPP)
add_executable(lba2 ${SOURCES_FILES} ${SOURCES_FILES_ASM} ${SOURCES_FILES_WIN} ${EMBEDDED_LBA2_CFG_CPP})

if(LBA2_SKIP_CDROM_CHECK)
target_compile_definitions(lba2 PRIVATE LBA2_SKIP_CDROM_CHECK=1)
endif()
if(LBA2_EMBEDDED_COMMUNITY_STARTUP)
find_package(Python3 3.8 REQUIRED COMPONENTS Interpreter)
set(LBA2_EMBED_DIR "${CMAKE_SOURCE_DIR}/assets/embedded")
set(LBA2_EMBED_SPLASH_LIM "${LBA2_EMBED_DIR}/community_splash_640x480.lim")
set(LBA2_EMBED_SPLASH_PAL "${LBA2_EMBED_DIR}/community_splash_640x480.pal")
foreach(_f IN ITEMS
"${LBA2_EMBED_SPLASH_LIM}"
"${LBA2_EMBED_SPLASH_PAL}")
if(NOT EXISTS "${_f}")
message(FATAL_ERROR "LBA2_EMBEDDED_COMMUNITY_STARTUP is ON but missing required file: ${_f}\nSee assets/embedded/README.txt")
endif()
endforeach()
set(LBA2_COMMUNITY_EMBED_C "${CMAKE_CURRENT_BINARY_DIR}/community_embedded_data.c")
add_custom_command(
OUTPUT "${LBA2_COMMUNITY_EMBED_C}"
COMMAND "${Python3_EXECUTABLE}" "${CMAKE_SOURCE_DIR}/tools/bin2c.py"
-o "${LBA2_COMMUNITY_EMBED_C}"
"g_Lba2EmbedCommunitySplashLim:${LBA2_EMBED_SPLASH_LIM}"
"g_Lba2EmbedCommunitySplashPal:${LBA2_EMBED_SPLASH_PAL}"
DEPENDS
"${LBA2_EMBED_SPLASH_LIM}"
"${LBA2_EMBED_SPLASH_PAL}"
"${CMAKE_SOURCE_DIR}/tools/bin2c.py"
COMMENT "Generating community_embedded_data.c from assets/embedded"
VERBATIM
)
target_sources(lba2 PRIVATE "${LBA2_COMMUNITY_EMBED_C}")
target_compile_definitions(lba2 PRIVATE LBA2_EMBEDDED_COMMUNITY_STARTUP=1)
endif()
# GCC LTO mis-infers T_PLASMA::data_start size when ptrc writes into Malloc tail (see ANIMTEX.CPP plasma case).
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
set_source_files_properties(ANIMTEX.CPP PROPERTIES COMPILE_OPTIONS "-Wno-stringop-overflow")
Expand Down
63 changes: 62 additions & 1 deletion SOURCES/GAMEMENU.CPP
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "GAMEMENU_MOUSE.H"

#include <dirent.h>
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
Expand Down Expand Up @@ -3981,6 +3982,59 @@ void SlideDemo(int argc, char *argv[]) {
BumperLogo();
}

#ifdef LBA2_EMBEDDED_COMMUNITY_STARTUP

extern const unsigned char g_Lba2EmbedCommunitySplashLim[];
extern const unsigned int g_Lba2EmbedCommunitySplashLimSize;
extern const unsigned char g_Lba2EmbedCommunitySplashPal[];
extern const unsigned int g_Lba2EmbedCommunitySplashPalSize;

#define LBA2_FULLSCREEN_BYTES (640 * 480)

static S32 Lba2CopyFullscreenLimPal(const unsigned char *lim, unsigned int limSize,
const unsigned char *pal, unsigned int palSize) {
if (limSize < (unsigned)LBA2_FULLSCREEN_BYTES || palSize < 768u)
return FALSE;
memcpy(Log, lim, (size_t)LBA2_FULLSCREEN_BYTES);
memcpy(PalettePcx, pal, 768u);
PtrPal = PalettePcx;
Palette(PalettePcx);
return TRUE;
}

static S32 Lba2ShowEmbeddedFullscreenSeconds(const unsigned char *lim, unsigned int limSize,
const unsigned char *pal, unsigned int palSize, S32 nsec) {
U32 endtimer;
S32 ret = TRUE;

if (!Lba2CopyFullscreenLimPal(lim, limSize, pal, palSize))
return FALSE;

WaitNoInput();

PtrPal = PalettePcx;

BoxStaticFullflip();
FadeToPal(PalettePcx);

ManageTime();
endtimer = TimerRefHR + nsec * 1000;

while (TimerRefHR <= endtimer AND !MyKey) {
ManageTime();
MyGetInput();
}

if (MyKey == K_ESC OR(Input & I_MENUS))
ret = FALSE;

FadeToBlack(PalettePcx);

return ret;
}

#endif // LBA2_EMBEDDED_COMMUNITY_STARTUP

/*──────────────────────────────────────────────────────────────────────────*/

S32 AdelineLogo(void) {
Expand Down Expand Up @@ -4104,7 +4158,14 @@ S32 ShowLogo(S32 numscr, S32 nsec) {
/*──────────────────────────────────────────────────────────────────────────*/

void DistribLogo(void) {
#ifdef DEMO
#if defined(LBA2_EMBEDDED_COMMUNITY_STARTUP)
// Single community splash (assets/splash.png via prepare_embedded_startup_assets.py)
Lba2ShowEmbeddedFullscreenSeconds(g_Lba2EmbedCommunitySplashLim,
g_Lba2EmbedCommunitySplashLimSize,
g_Lba2EmbedCommunitySplashPal,
g_Lba2EmbedCommunitySplashPalSize,
2);
#elif defined(DEMO)
// Bumper 3 Distributeurs
ShowLogo(3 * 2, 5);
#else
Expand Down
2 changes: 1 addition & 1 deletion SOURCES/PERSO.CPP
Original file line number Diff line number Diff line change
Expand Up @@ -2350,7 +2350,7 @@ int main(int argc, char *argv[]) {
ChoicePalette();

#ifdef CDROM
#if defined(DEBUG_TOOLS) || defined(TEST_TOOLS)
#if defined(DEBUG_TOOLS) || defined(TEST_TOOLS) || defined(LBA2_SKIP_CDROM_CHECK)
InitCD("");
#else
SetBlackPal(); // pour etre sur ...
Expand Down
36 changes: 36 additions & 0 deletions assets/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Source art for optional community branding

This folder holds **authoring** PNGs for features that are **off by default** in CMake so retail behaviour stays easy to compare.

| Path | Role |
|------|------|
| `splash.png` | Full-screen **DistribLogo** image (8-bit indexed at build time). |
| `embedded/` | **Generated** `community_splash_640x480.{lim,pal}` land here after you run the prepare script (see below). Not required unless `LBA2_EMBEDDED_COMMUNITY_STARTUP=ON`. |

## Quick workflow

1. Edit `splash.png` (640×480 target art; script scales/fits — default **contain** keeps the whole picture visible). Use `--content-scale 0.85` (or similar in `(0,1]`) if you want extra letterboxing even when the PNG is already 4:3.
2. From the repo root (Python venv with Pillow if you use one):

```bash
python3 tools/prepare_embedded_startup_assets.py
```

3. Configure with embedding enabled and build:

```bash
cmake -B build -DLBA2_EMBEDDED_COMMUNITY_STARTUP=ON
cmake --build build
```

**CMake options**

- **`LBA2_EMBEDDED_COMMUNITY_STARTUP`** — embed splash into the binary (default **OFF**).
- **`LBA2_SKIP_CDROM_CHECK`** — skip the legacy insert-disc UI and call `InitCD("")` (default **ON** for this port).

## Details

- Full filenames, edge cases, and links to engine behaviour: **[embedded/README.txt](embedded/README.txt)**.
- Implementation: `tools/prepare_embedded_startup_assets.py`, `tools/bin2c.py`, `SOURCES/GAMEMENU.CPP` (`DistribLogo`), `SOURCES/CMakeLists.txt` (embedded blobs).

**Note:** Retail game data (`screen.hqr`, etc.) are not redistributable; keep them out of the repo. Splash conversion is **256-colour**; complex gradients may band — adjust art or `--fit` if needed.
35 changes: 35 additions & 0 deletions assets/embedded/README.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
Community splash (optional build)
---------------------------------

When CMake option LBA2_EMBEDDED_COMMUNITY_STARTUP is ON, DistribLogo shows one
embedded full-screen slide before AdelineLogo:

* community_splash_* — from assets/splash.png (see prepare script)

Required filenames (fixed for CMake / bin2c):

community_splash_640x480.lim
community_splash_640x480.pal

Automated:

python3 tools/prepare_embedded_startup_assets.py

Default mapping uses ``contain`` so the whole image fits on 640x480 (letterbox
if needed). Override: --fit cover|contain|stretch

Optional ``--content-scale S`` (0..1] shrinks the fitted bitmap before
centering (adds margin even for 4:3 sources that would otherwise fill the frame).
Same flag exists on tools/probe_community_assets.py --export.

AdelineLogo still uses retail screen.hqr (PCR_LOGO).

CD-ROM insert-disc screen is not used when LBA2_SKIP_CDROM_CHECK=ON (default).
Turn OFF to restore classic CD check:

cmake -B build -DLBA2_SKIP_CDROM_CHECK=OFF

Configure + build:

cmake -B build -DLBA2_EMBEDDED_COMMUNITY_STARTUP=ON
cmake --build build
433 changes: 433 additions & 0 deletions assets/embedded/community_adeline_640x480.lim

Large diffs are not rendered by default.

Binary file added assets/embedded/community_adeline_640x480.pal
Binary file not shown.
265 changes: 265 additions & 0 deletions assets/embedded/community_cdrom_640x480.lim

Large diffs are not rendered by default.

Binary file added assets/embedded/community_cdrom_640x480.pal
Binary file not shown.
265 changes: 265 additions & 0 deletions assets/embedded/community_distrib1_640x480.lim

Large diffs are not rendered by default.

Binary file added assets/embedded/community_distrib1_640x480.pal
Binary file not shown.
1,270 changes: 1,270 additions & 0 deletions assets/embedded/community_distrib2_640x480.lim

Large diffs are not rendered by default.

34 changes: 34 additions & 0 deletions assets/embedded/community_distrib2_640x480.pal
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
ÂçµµÖ©›Ú‹§Ë›”Ê…„Øs†Ív…Év†Æv‚Ås~Åo–À‰„Àtµƒ„²w~Áp|Ák|¼m|±ngÙ]hÉZuÂhaÂUu½gf½Zt¹hr¹ak¸_Y¸Ns³em³`h²[o¬bf¬Z`±U_­T_©TW¬MG­@€¢uw¡jm¡_]¥S]ŸQU£LM£FRIKœEp”db“TdŠW`ƒTN˜FO“EQ‰EQED >D™?9œ5C”>7”4A<@Œ:8Ž41/@ˆ9;ˆ67‡3=‚5613†0-†+2€.,€*XyNLyA;y2/z+)x'Gj>,k')I(= 8351//,/,+*))('''$$$!$"!  "  #        
    

   

 

   


  
  






  
 









                    
    

   
 
Expand Down
1,270 changes: 1,270 additions & 0 deletions assets/embedded/community_distrib_640x480.lim

Large diffs are not rendered by default.

34 changes: 34 additions & 0 deletions assets/embedded/community_distrib_640x480.pal
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
ÂçµµÖ©›Ú‹§Ë›”Ê…„Øs†Ív…Év†Æv‚Ås~Åo–À‰„Àtµƒ„²w~Áp|Ák|¼m|±ngÙ]hÉZuÂhaÂUu½gf½Zt¹hr¹ak¸_Y¸Ns³em³`h²[o¬bf¬Z`±U_­T_©TW¬MG­@€¢uw¡jm¡_]¥S]ŸQU£LM£FRIKœEp”db“TdŠW`ƒTN˜FO“EQ‰EQED >D™?9œ5C”>7”4A<@Œ:8Ž41/@ˆ9;ˆ67‡3=‚5613†0-†+2€.,€*XyNLyA;y2/z+)x'Gj>,k')I(= 8351//,/,+*))('''$$$!$"!  "  #        
    

   

 

   


  
  






  
 









                    
    

   
 
Expand Down
76 changes: 76 additions & 0 deletions assets/embedded/community_splash_640x480.lim

Large diffs are not rendered by default.

Binary file added assets/embedded/community_splash_640x480.pal
Binary file not shown.
265 changes: 265 additions & 0 deletions assets/generated/distrib1_640x480.lim

Large diffs are not rendered by default.

Binary file added assets/generated/distrib1_640x480.pal
Binary file not shown.
1,270 changes: 1,270 additions & 0 deletions assets/generated/distrib2_640x480.lim

Large diffs are not rendered by default.

34 changes: 34 additions & 0 deletions assets/generated/distrib2_640x480.pal
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
ÂçµµÖ©›Ú‹§Ë›”Ê…„Øs†Ív…Év†Æv‚Ås~Åo–À‰„Àtµƒ„²w~Áp|Ák|¼m|±ngÙ]hÉZuÂhaÂUu½gf½Zt¹hr¹ak¸_Y¸Ns³em³`h²[o¬bf¬Z`±U_­T_©TW¬MG­@€¢uw¡jm¡_]¥S]ŸQU£LM£FRIKœEp”db“TdŠW`ƒTN˜FO“EQ‰EQED >D™?9œ5C”>7”4A<@Œ:8Ž41/@ˆ9;ˆ67‡3=‚5613†0-†+2€.,€*XyNLyA;y2/z+)x'Gj>,k')I(= 8351//,/,+*))('''$$$!$"!  "  #        
    

   

 

   


  
  






  
 









                    
    

   
 
Expand Down
265 changes: 265 additions & 0 deletions assets/generated/loading_640x480.lim

Large diffs are not rendered by default.

Binary file added assets/generated/loading_640x480.pal
Binary file not shown.
1,270 changes: 1,270 additions & 0 deletions assets/generated/logo_640x480.lim

Large diffs are not rendered by default.

34 changes: 34 additions & 0 deletions assets/generated/logo_640x480.pal
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
ÂçµµÖ©›Ú‹§Ë›”Ê…„Øs†Ív…Év†Æv‚Ås~Åo–À‰„Àtµƒ„²w~Áp|Ák|¼m|±ngÙ]hÉZuÂhaÂUu½gf½Zt¹hr¹ak¸_Y¸Ns³em³`h²[o¬bf¬Z`±U_­T_©TW¬MG­@€¢uw¡jm¡_]¥S]ŸQU£LM£FRIKœEp”db“TdŠW`ƒTN˜FO“EQ‰EQED >D™?9œ5C”>7”4A<@Œ:8Ž41/@ˆ9;ˆ67‡3=‚5613†0-†+2€.,€*XyNLyA;y2/z+)x'Gj>,k')I(= 8351//,/,+*))('''$$$!$"!  "  #        
    

   

 

   


  
  






  
 









                    
    

   
 
Expand Down
Binary file added assets/generated/logo_640x480.pcx
Binary file not shown.
76 changes: 76 additions & 0 deletions assets/generated/splash_640x480.lim

Large diffs are not rendered by default.

Binary file added assets/generated/splash_640x480.pal
Binary file not shown.
Binary file added assets/generated/splash_640x480.pcx
Binary file not shown.
Binary file added assets/splash.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Index of documentation in this repository.

| Doc | Description |
|-----|-------------|
| [Community splash assets](../assets/README.md) | Optional embedded DistribLogo splash (`splash.png` → LIM/PAL), CMake flags, prepare script. |
| [WINDOWS.md](WINDOWS.md) | Building on Windows with MSYS2; game files, toolchain. |
| [GAME_DATA.md](GAME_DATA.md) | Retail game files: `LBA2_GAME_DIR`, `--game-dir`, discovery order, dev layouts. |
| [DEBUG.md](DEBUG.md) | Original Adeline debug tools (DEBUG_TOOLS=ON): overlay, F9 screenshot, bug save/load, cheats, scene selection. |
Expand Down
Loading
Loading