-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
output: move texture pages and palettes to TRX #2415
Conversation
This adds common texture page storage in TRX.
This removes the global texture pages in TR1 and uses the common storage in TRX instead.
This removes the global texture pages in TR2 and uses the common storage in TRX instead.
Download the built assets for this pull request: |
src/libtrx/game/output/textures.c
Outdated
} | ||
|
||
int16_t Output_FindColor8( | ||
const int32_t red, const int32_t green, const int32_t blue) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we could pass RGB_888
here?
{ | ||
int32_t best_idx = 0; | ||
int32_t best_diff = INT32_MAX; | ||
for (int32_t i = 0; i < m_PaletteSize; i++) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can start at index 1, since we assume best_idx
to be 0.
Do we care to return -1
if there is no palette?
src/tr1/game/level.c
Outdated
output->g = 0; | ||
output->b = 0; | ||
output->a = 0; | ||
} else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this check necessary considering we hardcode the index 0 to hold zeroes in M_LoadPalette
?
src/tr2/game/level.c
Outdated
for (int32_t i = 0; i < palette_size; i++) { | ||
m_LevelInfo.palette.data_32[i].r = palette_16[i].r; | ||
m_LevelInfo.palette.data_32[i].g = palette_16[i].g; | ||
m_LevelInfo.palette.data_32[i].b = palette_16[i].b; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I might be mistaken but I think we already have most of this functionality in TRX.
src/tr2/game/level.c
Outdated
VFile_Read(file, input, texture_size_16_bit); | ||
RGBA_8888 *output = m_LevelInfo.textures.pages_32; | ||
for (int32_t i = 0; i < num_pages * TEXTURE_PAGE_SIZE; i++) { | ||
*output++ = Render_ARGB1555To8888(*input++); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe this part could be put into TRX too already at this stage?
This delays reading and preparing the texture pages in TR1 until the palette is loaded to avoid disjointed setup of LEVEL_INFO, and to bring the logic more close to TR2.
This adds common palette storage in TRX.
This migrates TR1 to use the TRX palette API.
This migrates TR2 to use the TRX palette API.
bf1a398
to
f750ff9
Compare
@rr- all addressed, thank you. I had somehow overlooked shifting the actual palette/texture reading to TRX; there is a temporary workaround of passing the injection texture page count here for TR1, but that will be eliminated further down the line with the injection refactor. |
@lahm86 I found a small issue with the draw distance fog colour. |
This moves the named colors array into TR2's output module, the only place it is referenced. Perhaps this can be further refactored at a later date to pass RGB values rather than palette indices.
This moves the final texture and palette setup after level/injection loading to TRX.
This makes the palette and texture page readers for both games common in TRX.
1081b2c
to
4b3e698
Compare
Thanks, fixed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apologies for recommending a faulty optimization for the palettes. LGTM.
Not a problem, it seemed logical to me too. |
Checklist
Description
This moves texture pages and palettes fully to TRX, and gets TR1 and TR2 both loading and handling the data in similar ways. Globals are removed and common accessors are available accordingly instead.
I've adjusted TR1 to initially skip textures pages when reading the level, delaying it until after the palette has been read; this means we can create the 32-bit pages on read rather than having the logic fragmented between the original read and later just before moving on to injections. TR2 is similar here, we interpret the ARGB1555 on read into 32-bit. So overall, TR2 is in a place ready to support texture injections, and the reading logic/flow is very similar for both.
I also moved
g_NamedColors
into TR2's output module as it's only referenced there. I'm wondering if we can eventually replace this with direct RGB values, but that's a separate task I'd say.