Skip to content
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

Add support for HD cams. #1344

Open
wants to merge 39 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
8485d30
Added type variable to Renderer + Added hd cam support for opengl.
mlgthatsme Aug 24, 2021
e4b25af
Merge remote-tracking branch 'origin/master'
mlgthatsme Aug 24, 2021
1d98b56
fix compile poop
mlgthatsme Aug 24, 2021
763bf8c
Change LoadCustomCAM to LoadExternalCam - Add warning logs
mlgthatsme Sep 1, 2021
3e68c03
imgui demo code included in cmake
mlgthatsme Dec 2, 2021
83a4a57
finally fixed issue where certain sprites rendered incorrectly.
mlgthatsme Dec 2, 2021
6c8e7d4
removed redundant rendererType variable
mlgthatsme Dec 2, 2021
a046cb0
fixed issue where background wasn't loading properly.
mlgthatsme Dec 3, 2021
10e40d7
add checks for opengl calls + gpu info window
mlgthatsme Dec 4, 2021
3a1c94a
Call end frame.
mlgthatsme Dec 9, 2021
24eb07f
Merge remote-tracking branch 'origin/master' into opengl
mlgthatsme Dec 29, 2021
7ed4239
Merge remote-tracking branch 'origin/master' into opengl
mlgthatsme Jan 8, 2022
5444a82
Merge remote-tracking branch 'origin/master' into opengl
mlgthatsme Jan 8, 2022
30f4f4c
add imgui stdlib for std::string helper functions
mlgthatsme Feb 20, 2022
80ee9f3
asset tool + extra masher funcs
mlgthatsme Feb 20, 2022
b5778ad
add variable to know if game is ae or ae
mlgthatsme Feb 20, 2022
1c10b53
add present to renderer functions + hd asset loading wip
mlgthatsme Feb 20, 2022
ab43d65
Merge branch 'AliveTeam:master' into opengl
mlgthatsme Feb 20, 2022
042a375
fix some warnings
mlgthatsme Feb 20, 2022
143cf86
check if folder name is valid for loading external assets. skip on fail
mlgthatsme Feb 20, 2022
71146ae
Change how we apply hd textures, use global table instead
mlgthatsme Feb 20, 2022
62fa3a0
Make slig render in shadows properly
mlgthatsme Feb 20, 2022
6609f97
make it so emissive textures only render if object is dark
mlgthatsme Feb 20, 2022
e3062e3
fix signed char causing overflow issues with rgb color
mlgthatsme Feb 23, 2022
37d1a6f
fix incorrect resource files for abe falling and die
mlgthatsme Feb 23, 2022
f9ea48c
new and improved
mlgthatsme Feb 23, 2022
9416fb0
add support for flipped textures and flipped emissive textures
mlgthatsme Feb 23, 2022
64bf2e9
fix a bunch of anims not exporting due to wrong anim info
mouzedrift Oct 18, 2022
cfc605f
AO hd cam support + meta json error handling
mouzedrift Oct 21, 2022
6523a83
fix wrong paramite animation names
mouzedrift Apr 21, 2023
8c0ab04
enable RENDERER_OPENGL by default
mouzedrift Apr 21, 2023
89ab3b9
fix warnings
mouzedrift Apr 22, 2023
fc127a4
normalize flying slig anim id names
mouzedrift Apr 30, 2023
8e63510
make loading hd sprites a bit faster
mouzedrift Apr 19, 2024
72eb641
don't try to play movies
mouzedrift May 24, 2024
b1eddbf
don't load broken fg1 in AO
mouzedrift May 24, 2024
b34d8b0
show progress while loading external animations
mouzedrift May 24, 2024
7fea3cb
add ability to toggle the debug window and external assets using F1 a…
mouzedrift May 25, 2024
e6593da
add original data to meta.json files
mouzedrift Jun 19, 2024
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
2 changes: 2 additions & 0 deletions 3rdParty/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,10 @@ add_library(imgui
imgui/imgui_draw.cpp
imgui/imgui_tables.cpp
imgui/imgui_widgets.cpp
imgui/imgui_demo.cpp
imgui/backends/imgui_impl_sdl.cpp
imgui/backends/imgui_impl_opengl3.cpp
imgui/misc/cpp/imgui_stdlib.cpp
)

target_link_libraries(imgui
Expand Down
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/Source/AliveLibAO)
add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/Source/AliveLibAE)
add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/Source/relive)
add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/Source/Tools/vab_tool)
add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/Source/Tools/asset_tool)
add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/Source/Tools/relive_api)
add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/Source/Tools/relive_api_integration_test)
add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/Source/Tools/relive_api_unit_test)
Expand Down
19 changes: 19 additions & 0 deletions Source/AliveLibAE/Animation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "Sys_common.hpp"
#include "Renderer/IRenderer.hpp"
#include <gmock/gmock.h>
#include "ExternalAssets.hpp"

// Frame call backs ??
EXPORT s32 CC Animation_OnFrame_Common_Null_455F40(void*, s16*)
Expand Down Expand Up @@ -602,6 +603,24 @@ void Animation::vRender_40B820(s32 xpos, s32 ypos, PrimHeader** ppOt, s16 width,
SetPrimExtraPointerHack(pPoly, nullptr);
}

//////////////
// HD HAX
//////////////

CustomRenderSpriteFormat sprite;
sprite.x = PsxToPCX(xpos);
sprite.y = ypos;
sprite.frame = (this->field_92_current_frame == -1) ? 0 : this->field_92_current_frame;
sprite.frametable_offset = field_18_frame_table_offset;
sprite.resource_id = pResourceManager_5C1BB0->Get_Header_49C410(field_20_ppBlock)->field_C_id;
sprite.r = pPoly->mBase.header.rgb_code.r;
sprite.g = pPoly->mBase.header.rgb_code.g;
sprite.b = pPoly->mBase.header.rgb_code.b;
sprite.scale = (float)FP_GetDouble(this->field_14_scale);
sprite.flip = this->field_4_flags.Get(AnimFlags::eBit5_FlipX);

CustomRender_AddCommand(pPoly, sprite);

OrderingTable_Add_4F8AA0(OtLayer(ppOt, field_C_render_layer), &pPoly->mBase.header);
}

Expand Down
4 changes: 2 additions & 2 deletions Source/AliveLibAE/BaseBomb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ BaseBomb* BaseBomb::ctor_423E70(FP x, FP y, s32 /*unused*/, FP scale)
SetVTable(this, 0x544C54);
SetType(AETypes::eBaseBomb_46);

const AnimRecord& rec = AnimRec(AnimId::Explosion_Mine);
const AnimRecord& rec = AnimRec(AnimId::GroundExplosion);
Animation_Init_424E10(rec.mFrameTableOffset, rec.mMaxW, rec.mMaxH, BaseGameObject::Add_Resource_4DC130(ResourceManager::Resource_Animation, rec.mResourceId), 1, 1);

field_20_animation.field_4_flags.Clear(AnimFlags::eBit18_IsLastFrame); // Double Check
Expand Down Expand Up @@ -192,7 +192,7 @@ void BaseBomb::vUpdate_424180()

if (field_20_animation.field_92_current_frame == 3)
{
const AnimRecord& rec = AnimRec(AnimId::Explosion_Mine);
const AnimRecord& rec = AnimRec(AnimId::GroundExplosion);
u8** ppRes = Add_Resource_4DC130(ResourceManager::Resource_Animation, rec.mResourceId);
if (ppRes)
{
Expand Down
1 change: 1 addition & 0 deletions Source/AliveLibAE/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,7 @@ endif()

target_link_libraries(AliveLibAE
AliveLibCommon
jsonxx_reliveapi
EasyLogging++
googletest
Cinder
Expand Down
2 changes: 1 addition & 1 deletion Source/AliveLibAE/DoorFlame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ class FlameSparks final : public ::BaseAnimatedWithPhysicsGameObject
SetVTable(this, 0x545974);
SetType(AETypes::eNone_0);

const AnimRecord& rec = AnimRec(AnimId::Zap_Sparks);
const AnimRecord& rec = AnimRec(AnimId::ChantOrb_Particle_Small);
u8** ppRes = Add_Resource_4DC130(ResourceManager::Resource_Animation, rec.mResourceId);
Animation_Init_424E10(rec.mFrameTableOffset, rec.mMaxW, rec.mMaxH, ppRes, 1, 1);

Expand Down
6 changes: 3 additions & 3 deletions Source/AliveLibAE/Explosion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ Explosion* Explosion::ctor_4A1200(FP xpos, FP ypos, FP scale, s16 bSmall)
field_F4_bSmall = bSmall;
if (field_F4_bSmall)
{
const AnimRecord& rec = AnimRec(AnimId::Explosion_Small);
const AnimRecord& rec = AnimRec(AnimId::AirExplosion_Small);
u8** ppRes = Add_Resource_4DC130(ResourceManager::Resource_Animation, rec.mResourceId);
Animation_Init_424E10(rec.mFrameTableOffset, rec.mMaxW, rec.mMaxH, ppRes, 1, 1);
}
else
{
const AnimRecord& rec = AnimRec(AnimId::Explosion);
const AnimRecord& rec = AnimRec(AnimId::AirExplosion);
u8** ppRes = Add_Resource_4DC130(ResourceManager::Resource_Animation, rec.mResourceId);
Animation_Init_424E10(rec.mFrameTableOffset, rec.mMaxW, rec.mMaxH, ppRes, 1, 1);
}
Expand Down Expand Up @@ -179,7 +179,7 @@ void Explosion::vUpdate_4A1510()
auto pParticle = ae_new<Particle>();
if (pParticle)
{
const AnimRecord& rec = field_F4_bSmall ? AnimRec(AnimId::Explosion_Small) : AnimRec(AnimId::Explosion);
const AnimRecord& rec = field_F4_bSmall ? AnimRec(AnimId::AirExplosion_Small) : AnimRec(AnimId::AirExplosion);
pParticle->ctor_4CC4C0(field_B8_xpos, field_BC_ypos, rec.mFrameTableOffset,
202, // Same size for both explosions for some reason
91, // ^^^
Expand Down
2 changes: 1 addition & 1 deletion Source/AliveLibAE/FallingItem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ EXPORT void FallingItem::vUpdate_427780()
auto pParticle = ae_new<Particle>();
if (pParticle)
{
const AnimRecord& rec = AnimRec(AnimId::Explosion);
const AnimRecord& rec = AnimRec(AnimId::AirExplosion);
u8** ppRes = ResourceManager::GetLoadedResource_49C2A0(ResourceManager::Resource_Animation, rec.mResourceId, 0, 0);
pParticle->ctor_4CC4C0(
field_B8_xpos,
Expand Down
36 changes: 18 additions & 18 deletions Source/AliveLibAE/FlyingSlig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ FlyingSlig* FlyingSlig::ctor_4342B0(Path_FlyingSlig* pTlv, s32 tlvInfo)
field_10_resources_array.SetAt(7, ResourceManager::GetLoadedResource_49C2A0(ResourceManager::Resource_Animation, AEResourceID::kVaporResID, TRUE, FALSE));
field_10_resources_array.SetAt(8, ResourceManager::GetLoadedResource_49C2A0(ResourceManager::Resource_Animation, AEResourceID::kSlogBlowResID, TRUE, FALSE));

const AnimRecord& rec = AnimRec(AnimId::Flying_Slig_Idle);
const AnimRecord& rec = AnimRec(AnimId::FlyingSlig_Idle);
u8** ppRes = Add_Resource_4DC130(ResourceManager::Resource_Animation, rec.mResourceId);
Animation_Init_424E10(rec.mFrameTableOffset, rec.mMaxW, rec.mMaxH, ppRes, 1, 1);
//Animation_Init_424E10(116888, 107, 48u, field_10_resources_array.ItemAt(0), 1, 1u);
Expand Down Expand Up @@ -261,23 +261,23 @@ FlyingSlig* FlyingSlig::ctor_4342B0(Path_FlyingSlig* pTlv, s32 tlvInfo)
}

const AnimId sFlyingSligFrameTables_552408[28] = {
AnimId::Flying_Slig_Idle,
AnimId::Flying_Slig_Move_Horizontal,
AnimId::Flying_Slig_Idle_Turn_Around,
AnimId::Flying_Slig_Move_Down,
AnimId::Flying_Slig_Move_Down_Turn_Around,
AnimId::Flying_Slig_Move_Up,
AnimId::Flying_Slig_Move_Up_Turn_Around,
AnimId::Flying_Slig_Pull_Lever,
AnimId::Flying_Slig_Speak,
AnimId::Flying_Slig_Possession,
AnimId::Flying_Slig_Move_Horizontal_End,
AnimId::Flying_Slig_Move_Up_Start,
AnimId::Flying_Slig_Move_Horizontal_To_Down,
AnimId::Flying_Slig_Move_Up_To_Horizontal,
AnimId::Flying_Slig_Move_Down_To_Horizontal,
AnimId::Flying_Slig_Turn_Quick,
AnimId::Flying_Slig_Idle_To_Horizontal,
AnimId::FlyingSlig_Idle,
AnimId::FlyingSlig_MoveHorizontal,
AnimId::FlyingSlig_IdleTurnAround,
AnimId::FlyingSlig_MoveDown,
AnimId::FlyingSlig_MoveDownTurnAround,
AnimId::FlyingSlig_MoveUp,
AnimId::FlyingSlig_MoveUpTurnAround,
AnimId::FlyingSlig_PullLever,
AnimId::FlyingSlig_Speak,
AnimId::FlyingSlig_Possession,
AnimId::FlyingSlig_MoveHorizontalEnd,
AnimId::FlyingSlig_MoveUpStart,
AnimId::FlyingSlig_MoveHorizontalToDown,
AnimId::FlyingSlig_MoveUpToHorizontal,
AnimId::FlyingSlig_MoveDownToHorizontal,
AnimId::FlyingSlig_TurnQuick,
AnimId::FlyingSlig_IdleToHorizontal,
AnimId::FlyingSlig_BeginDownMovement,
AnimId::FlyingSlig_EndDownMovement,
AnimId::FlyingSlig_DownKnockback,
Expand Down
2 changes: 1 addition & 1 deletion Source/AliveLibAE/Game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ EXPORT void CC DrawFps_4952F0(Bitmap* pBmp, s32 x, s32 y, f32 fps)

EXPORT void CC sub_4FBA20()
{
NOT_IMPLEMENTED();
//NOT_IMPLEMENTED();
}

EXPORT void CC CheckShiftCapslock_4953B0()
Expand Down
6 changes: 5 additions & 1 deletion Source/AliveLibAE/Movie.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -673,14 +673,18 @@ void Movie::Init_4DFF60(s32 id, CdlLOC* pCdPos, s16 bUnknown, s16 flags, s16 vol
ResourceManager::Reclaim_Memory_49C470(0);
}

Movie* Movie::ctor_4DFDE0(s32 id, u32 pos, s16 bUnknown, s16 flags, s16 volume)
Movie* Movie::ctor_4DFDE0(s32 /*id*/, u32 /*pos*/, s16 /*bUnknown*/, s16 /*flags*/, s16 /*volume*/)
{
/*
BaseGameObject_ctor_4DBFA0(TRUE, 0);
SetVTable(this, 0x547EF4); // vTbl_Movie_547EF4

CdlLOC cdLoc = {};
PSX_Pos_To_CdLoc_4FADD0(pos, &cdLoc);
Init_4DFF60(id, &cdLoc, bUnknown, flags, volume);
*/

field_6_flags.Set(BaseGameObject::Options::eDead_Bit3);
return this;
}

Expand Down
2 changes: 1 addition & 1 deletion Source/AliveLibAE/Paramite.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ const AnimId sParamiteAnimIdTable_55D660[44] = {
AnimId::Paramite_WebLeaveUp,
AnimId::Paramite_Eating,
AnimId::Paramite_Death,
AnimId::Paramite_Squawk,
AnimId::Paramite_Struggle,
AnimId::Paramite_Attack};

s32 CC Paramite::CreateFromSaveState_4855A0(const u8* pBuffer)
Expand Down
2 changes: 2 additions & 0 deletions Source/AliveLibAE/PsxRender.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3432,6 +3432,8 @@ static bool DrawOTagImpl(PrimHeader** ppOt, s16 drawEnv_of0, s16 drawEnv_of1)
pOtItem = any.mPrimHeader->tag; // offset 0
}

renderer.EndFrame();

return false;
}

Expand Down
9 changes: 9 additions & 0 deletions Source/AliveLibAE/Renderer/DirectX9Renderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ void DirectX9Renderer::StartFrame(s32 /*xOff*/, s32 /*yOff*/)
}

void DirectX9Renderer::EndFrame()
{
}

void DirectX9Renderer::Present()
{
SDL_RenderPresent(mRenderer);
}
Expand Down Expand Up @@ -180,4 +184,9 @@ void DirectX9Renderer::Upload(BitDepth /*bitDepth*/, const PSX_RECT& /*rect*/, c
{
}

void DirectX9Renderer::LoadExternalCam(const char* /*path*/, const unsigned char* /*key*/, int /*keyLength*/)
{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should prob log it isn't implemented with LOG_WARNING

LOG_WARNING("LoadExternalCam not implemented for DirectX9 - external cam not loaded.");
}

#endif
3 changes: 3 additions & 0 deletions Source/AliveLibAE/Renderer/DirectX9Renderer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class DirectX9Renderer final : public IRenderer
void Clear(u8 r, u8 g, u8 b) override;
void StartFrame(s32 xOff, s32 yOff) override;
void EndFrame() override;
void Present() override;
void BltBackBuffer(const SDL_Rect* pCopyRect, const SDL_Rect* pDst) override;
void OutputSize(s32* w, s32* h) override;
bool UpdateBackBuffer(const void* pPixels, s32 pitch) override;
Expand All @@ -36,6 +37,8 @@ class DirectX9Renderer final : public IRenderer

void Upload(BitDepth bitDepth, const PSX_RECT& rect, const u8* pPixels) override;

void LoadExternalCam(const char* path, const unsigned char* key, int keyLength) override;

private:
SDL_Renderer* mRenderer = nullptr;
IDirect3DDevice9* mDevice = nullptr;
Expand Down
4 changes: 2 additions & 2 deletions Source/AliveLibAE/Renderer/IRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
#include "SoftwareRenderer.hpp"
#include "DirectX9Renderer.hpp"

static IRenderer* gRenderer = nullptr;

#if RENDERER_OPENGL
#include "OpenGLRenderer.hpp"
#endif

static IRenderer* gRenderer = nullptr;

IRenderer* IRenderer::GetRenderer()
{
return gRenderer;
Expand Down
4 changes: 4 additions & 0 deletions Source/AliveLibAE/Renderer/IRenderer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class IRenderer
public:
enum class Renderers
{
None = 0,
Software,
DirectX9,
OpenGL,
Expand Down Expand Up @@ -43,6 +44,7 @@ class IRenderer
virtual void Clear(u8 r, u8 g, u8 b) = 0;
virtual void StartFrame(s32 xOff, s32 yOff) = 0;
virtual void EndFrame() = 0;
virtual void Present() = 0;
virtual void BltBackBuffer(const SDL_Rect* pCopyRect, const SDL_Rect* pDst) = 0;
virtual void OutputSize(s32* w, s32* h) = 0;
virtual bool UpdateBackBuffer(const void* pPixels, s32 pitch) = 0;
Expand All @@ -59,6 +61,8 @@ class IRenderer

virtual void Upload(BitDepth bitDepth, const PSX_RECT& rect, const u8* pPixels) = 0;

virtual void LoadExternalCam(const char* path, const unsigned char* key, int keyLength) = 0;

// FG1/zaplines/blood/hintfly
virtual void Draw(Prim_Sprt& sprt) = 0;
virtual void Draw(Prim_GasEffect& gasEffect) = 0;
Expand Down
Loading