Skip to content

Commit

Permalink
data: fix incorrect Colosseum textures (#733)
Browse files Browse the repository at this point in the history
Resolves #131
  • Loading branch information
lahm86 authored Feb 17, 2023
1 parent 742695c commit 60ffec9
Show file tree
Hide file tree
Showing 11 changed files with 52 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
- fixed Scion 1 respawning on load (#707)
- fixed dead water rats looking alive when a room's water is drained (#687, regression from 0.12.0)
- fixed triggered flip effects not working if there are no sound devices (#583)
- fixed the incorrect ceiling textures in Colosseum (#131)

## [2.12.1](https://github.com/rr-/Tomb1Main/compare/2.12...2.12.1) - 2023-01-16
- fixed crash when using enhanced saves in levels with flame emitters (#693)
Expand Down
12 changes: 8 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ Not all options are turned on by default. Refer to `Tomb1Main_ConfigTool.exe` fo
#### Visuals
- added optional shotgun flash sprites
- added optional rendering of pickups on the ground as 3D meshes
- added braid (currently only works in Lost Valley)
- added Lara's braid to each level
- added support for displaying more than 3 pickup sprites
- added more control over when to show health bar and air bar
- added customizable health bar and air bar
Expand All @@ -324,6 +324,7 @@ Not all options are turned on by default. Refer to `Tomb1Main_ConfigTool.exe` fo
- fixed black screen flashing when navigating the inventory
- fixed detail levels text flashing with any option change
- fixed underwater caustics animating at 2x speed
- fixed incorrect ceiling textures in Colosseum

#### Audio
- added music during the credits
Expand Down Expand Up @@ -383,8 +384,8 @@ Not all options are turned on by default. Refer to `Tomb1Main_ConfigTool.exe` fo

The difficulty here is that these features often require inserting a
completely new animation, a textured mesh or a sound file and pretend
they're always been a part of the original game. So far we haven't found a
good way that'll keep the code maintainable.
they're always been a part of the original game. Work is underway on an
injection framework, and the braid is now supported in each level.

4. **Can I play this on Mac, Linux, Android...?**

Expand All @@ -410,7 +411,10 @@ Note: this section may be subject to change.
- [ ] ...
- [ ] Test for performance and crash resilience
- [ ] 3.0
- [ ] Work on data injection and other features?
- [ ] Work on data injection and other features
- [x] Add Lara's braid to each level
- [ ] Fix texture/face issues
- [ ] ...

## License

Expand Down
3 changes: 3 additions & 0 deletions bin/cfg/Tomb1Main_gameflow.json5
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,9 @@
"file": "data/level5.phd",
"type": "normal",
"music": 59,
"injections": [
"data/colosseum_roof.bin"
],
"sequence": [
{"type": "start_game"},
{"type": "loop_game"},
Expand Down
Binary file modified bin/data/backpack.bin
Binary file not shown.
Binary file modified bin/data/backpack_cut.bin
Binary file not shown.
Binary file modified bin/data/braid.bin
Binary file not shown.
Binary file modified bin/data/braid_cut1.bin
Binary file not shown.
Binary file modified bin/data/braid_cut2_cut4.bin
Binary file not shown.
Binary file added bin/data/colosseum_roof.bin
Binary file not shown.
40 changes: 39 additions & 1 deletion src/game/inject.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@

#include <stddef.h>

#define BIN_VERSION 1
#define BIN_VERSION 2

typedef enum INJECTION_TYPE {
INJ_GENERAL = 0,
INJ_BRAID = 1,
INJ_TEXTURE_FIX = 2,
} INJECTION_TYPE;

typedef struct INJECTION {
Expand Down Expand Up @@ -86,6 +87,8 @@ static void Inject_ApplyFaceEdit(
FACE_EDIT *face_edit, int16_t *data_ptr, int16_t texture);
static void Inject_ApplyMeshEdit(MESH_EDIT *mesh_edit);
static void Inject_MeshEdits(INJECTION *injection);
static void Inject_TextureOverwrites(
INJECTION *injection, LEVEL_INFO *level_info, uint8_t *palette_map);

bool Inject_Init(
int num_injections, char *filenames[], INJECTION_INFO *aggregate)
Expand Down Expand Up @@ -129,6 +132,7 @@ static bool Inject_LoadFromFile(INJECTION *injection, const char *filename)

switch (injection->type) {
case INJ_GENERAL:
case INJ_TEXTURE_FIX:
injection->relevant = true;
break;
case INJ_BRAID:
Expand Down Expand Up @@ -196,6 +200,7 @@ bool Inject_AllInjections(LEVEL_INFO *level_info)
Inject_SFXData(injection, level_info);

Inject_MeshEdits(injection);
Inject_TextureOverwrites(injection, level_info, palette_map);

// Realign base indices for the next injection.
INJECTION_INFO inj_info = injection->info;
Expand Down Expand Up @@ -711,6 +716,39 @@ static int16_t *Inject_GetMeshTexture(FACE_EDIT *face_edit)
return NULL;
}

static void Inject_TextureOverwrites(
INJECTION *injection, LEVEL_INFO *level_info, uint8_t *palette_map)
{
INJECTION_INFO inj_info = injection->info;
MYFILE *fp = injection->fp;

uint16_t target_page, source_width, source_height;
uint8_t target_x, target_y;
for (int i = 0; i < inj_info.texture_overwrite_count; i++) {
File_Read(&target_page, sizeof(uint16_t), 1, fp);
File_Read(&target_x, sizeof(uint8_t), 1, fp);
File_Read(&target_y, sizeof(uint8_t), 1, fp);
File_Read(&source_width, sizeof(uint16_t), 1, fp);
File_Read(&source_height, sizeof(uint16_t), 1, fp);

uint8_t *source_img = Memory_Alloc(source_width * source_height);
File_Read(source_img, source_width * source_height, 1, fp);

// Copy the source image pixels directly into the target page.
uint8_t *page = level_info->texture_page_ptrs + target_page * PAGE_SIZE;
int pal_idx, target_pixel;
for (int y = 0; y < source_height; y++) {
for (int x = 0; x < source_width; x++) {
pal_idx = source_img[y * source_width + x];
target_pixel = (y + target_y) * PAGE_WIDTH + x + target_x;
*(page + target_pixel) = palette_map[pal_idx];
}
}

Memory_FreePointer(&source_img);
}
}

static void Inject_Cleanup(void)
{
for (int i = 0; i < m_NumInjections; i++) {
Expand Down
1 change: 1 addition & 0 deletions src/game/inject.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ typedef struct INJECTION_INFO {
int32_t sfx_data_size;
int32_t sample_count;
int32_t mesh_edit_count;
int32_t texture_overwrite_count;
} INJECTION_INFO;

bool Inject_Init(
Expand Down

0 comments on commit 60ffec9

Please sign in to comment.