diff --git a/data/ship/cfg/TR1X_gameflow.json5 b/data/ship/cfg/TR1X_gameflow.json5 index 358e25656f..aa6a2d0b06 100644 --- a/data/ship/cfg/TR1X_gameflow.json5 +++ b/data/ship/cfg/TR1X_gameflow.json5 @@ -105,6 +105,7 @@ "type": "normal", "music": 57, "injections": [ + "data/injections/skybox.bin", "data/injections/valley_itemrots.bin", "data/injections/valley_textures.bin", ], @@ -183,6 +184,7 @@ "data/injections/colosseum_fd.bin", "data/injections/colosseum_itemrots.bin", "data/injections/colosseum_textures.bin", + "data/injections/skybox.bin", ], "sequence": [ {"type": "loading_screen", "picture_path": "data/images/greece.webp", "display_time": 5}, diff --git a/data/ship/data/injections/skybox.bin b/data/ship/data/injections/skybox.bin new file mode 100644 index 0000000000..f6df50750c Binary files /dev/null and b/data/ship/data/injections/skybox.bin differ diff --git a/src/game/output.c b/src/game/output.c index b8042bf7ea..8453d97f79 100644 --- a/src/game/output.c +++ b/src/game/output.c @@ -59,6 +59,7 @@ static const int16_t *Output_DrawObjectGT4( const int16_t *obj_ptr, int32_t number); static const int16_t *Output_DrawRoomSprites( const int16_t *obj_ptr, int32_t vertex_count); +static const int16_t *Output_CalculateSkyboxLight(const int16_t *obj_ptr); static const int16_t *Output_CalcObjectVertices(const int16_t *obj_ptr); static const int16_t *Output_CalcVerticeLight(const int16_t *obj_ptr); static const int16_t *Output_CalcRoomVertices(const int16_t *obj_ptr); @@ -236,6 +237,23 @@ static const int16_t *Output_CalcObjectVertices(const int16_t *obj_ptr) return total_clip == 0 ? obj_ptr : NULL; } +static const int16_t *Output_CalculateSkyboxLight(const int16_t *obj_ptr) +{ + int32_t vertex_count = *obj_ptr++; + if (vertex_count > 0) { + obj_ptr += 3 * vertex_count; + } else { + vertex_count = -vertex_count; + obj_ptr += vertex_count; + } + + for (int i = 0; i < vertex_count; i++) { + m_VBuf[i].g = 0xFFF; + } + + return obj_ptr; +} + static const int16_t *Output_CalcVerticeLight(const int16_t *obj_ptr) { int32_t vertex_count = *obj_ptr++; @@ -535,6 +553,27 @@ void Output_CalculateObjectLighting( Output_CalculateLight(offset.x, offset.y, offset.z, item->room_number); } +void Output_DrawSkybox(const int16_t *obj_ptr) +{ + g_PhdLeft = Viewport_GetMinX(); + g_PhdTop = Viewport_GetMinY(); + g_PhdRight = Viewport_GetMaxX(); + g_PhdBottom = Viewport_GetMaxY(); + + obj_ptr = Output_CalcObjectVertices(obj_ptr + 4); + if (obj_ptr) { + S_Output_DisableDepthTest(); + + obj_ptr = Output_CalculateSkyboxLight(obj_ptr); + obj_ptr = Output_DrawObjectGT4(obj_ptr + 1, *obj_ptr); + obj_ptr = Output_DrawObjectGT3(obj_ptr + 1, *obj_ptr); + obj_ptr = Output_DrawObjectG4(obj_ptr + 1, *obj_ptr); + obj_ptr = Output_DrawObjectG3(obj_ptr + 1, *obj_ptr); + + S_Output_EnableDepthTest(); + } +} + void Output_DrawPolygons(const int16_t *obj_ptr, int clip) { obj_ptr += 4; diff --git a/src/game/output.h b/src/game/output.h index ffc1f0c29c..e5aab34df6 100644 --- a/src/game/output.h +++ b/src/game/output.h @@ -44,6 +44,8 @@ void Output_CalculateStaticLight(int16_t adder); void Output_CalculateObjectLighting( const ITEM_INFO *item, const BOUNDS_16 *bounds); +void Output_DrawSkybox(const int16_t *obj_ptr); + void Output_DrawPolygons(const int16_t *obj_ptr, int clip); void Output_DrawPolygons_I(const int16_t *obj_ptr, int32_t clip); diff --git a/src/game/room_draw.c b/src/game/room_draw.c index 8769d844a4..0db168b5b2 100644 --- a/src/game/room_draw.c +++ b/src/game/room_draw.c @@ -204,6 +204,19 @@ void Room_DrawAllRooms(int16_t base_room, int16_t target_room) Room_PrepareToDraw(base_room); Room_PrepareToDraw(target_room); + if (g_Objects[O_SKYBOX].loaded) { + Output_SetupAboveWater(g_Camera.underwater); + Matrix_Push(); + g_MatrixPtr->_03 = g_MatrixPtr->_13 = g_MatrixPtr->_23 = 0; + + FRAME_INFO *frame = g_Anims[g_Objects[O_SKYBOX].anim_index].frame_ptr; + int32_t *packed_rotation = frame->mesh_rots; + Matrix_RotYXZpack(packed_rotation[0]); + Output_DrawSkybox(g_Meshes[g_Objects[O_SKYBOX].mesh_index]); + + Matrix_Pop(); + } + for (int i = 0; i < g_RoomsToDrawCount; i++) { Room_DrawSingleRoom(g_RoomsToDraw[i]); } diff --git a/src/global/types.h b/src/global/types.h index 0661ba6537..1b69a1fdc4 100644 --- a/src/global/types.h +++ b/src/global/types.h @@ -210,7 +210,7 @@ typedef enum GAME_OBJECT_ID { O_BIG_POD = 181, O_BOAT = 182, O_EARTHQUAKE = 183, - O_TEMP5 = 184, + O_SKYBOX = 184, O_TEMP6 = 185, O_TEMP7 = 186, O_TEMP8 = 187,