Work on memory card sys; CMake fixes

This commit is contained in:
Jack Andersen 2016-10-08 21:45:04 -10:00
parent f7f5066038
commit 545fccc4cc
17 changed files with 133 additions and 68 deletions

View File

@ -1,18 +1,19 @@
include_directories(${LIBPNG_INCLUDE_DIR} ${SQUISH_INCLUDE_DIR})
# Assembles a source/header pair list for use in a DNA library
macro(make_dnalist outlist)
macro(make_dnalist outlist subdir)
file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${subdir}")
foreach(type ${ARGN})
get_filename_component(dir ${type} DIRECTORY)
if(dir)
file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${dir}")
file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${subdir}/${dir}")
set(dir "${dir}/")
endif()
get_filename_component(name ${type} NAME)
atdna(${dir}atdna_${name}.cpp ${dir}/${name}.hpp)
atdna("${subdir}/${dir}atdna_${name}.cpp" "${subdir}/${dir}${name}.hpp")
list(APPEND ${outlist}
${dir}atdna_${name}.cpp
${CMAKE_CURRENT_SOURCE_DIR}/${dir}/${name}.hpp)
${subdir}/${dir}atdna_${name}.cpp
${subdir}/${dir}${name}.hpp)
endforeach()
endmacro()
@ -26,16 +27,16 @@ macro(dataspec_add_list rel_path a_list)
list(APPEND tmp_list "${rel_path}/${path}")
endif()
endforeach(path)
set(${a_list} "${tmp_list}" PARENT_SCOPE)
set(${a_list} "${tmp_list}")
endmacro(dataspec_add_list)
include_directories(${ZLIB_INCLUDE_DIR} ${LZO_INCLUDE_DIR})
# Each game's DNA library
add_subdirectory(DNACommon)
add_subdirectory(DNAMP1)
add_subdirectory(DNAMP2)
add_subdirectory(DNAMP3)
include(DNACommon/CMakeLists.txt)
include(DNAMP1/CMakeLists.txt)
include(DNAMP2/CMakeLists.txt)
include(DNAMP3/CMakeLists.txt)
# Embed master shader script
bintoc(RetroMasterShader.c Blender/RetroMasterShader.py RETRO_MASTER_SHADER)
@ -46,6 +47,7 @@ add_library(RetroDataSpec
${DNACOMMON_SOURCES}
SpecMP1.cpp
${DNAMP1_SOURCES}
${ScriptObjectsMP1_SOURCES}
SpecMP2.cpp
${DNAMP2_SOURCES}
SpecMP3.cpp

View File

@ -1,4 +1,4 @@
make_dnalist(liblist
make_dnalist(liblist DNACommon
CMDL
MAPA
EGMC
@ -7,7 +7,6 @@ make_dnalist(liblist
set(DNACOMMON_SOURCES
DNACommon.hpp DNACommon.cpp
${liblist}
PAK.hpp PAK.cpp
GX.hpp
FSM2.hpp FSM2.cpp
@ -44,3 +43,4 @@ set(DNACOMMON_SOURCES
Tweaks/ITweakSlideShow.hpp)
dataspec_add_list(DNACommon DNACOMMON_SOURCES)
list(APPEND DNACOMMON_SOURCES ${liblist})

View File

@ -318,6 +318,7 @@ class WordBitmap
public:
void read(athena::io::IStreamReader& reader, size_t bitCount);
void write(athena::io::IStreamWriter& writer) const;
void reserve(size_t bitCount) { m_words.reserve((bitCount + 31) / 32); }
size_t binarySize(size_t __isz) const;
size_t getBitCount() const {return m_bitCount;}
bool getBit(size_t idx) const
@ -335,6 +336,7 @@ public:
m_words.push_back(0);
size_t wordCur = idx % 32;
m_words[wordIdx] |= (1 << wordCur);
m_bitCount = std::max(m_bitCount, idx + 1);
}
void unsetBit(size_t idx)
{
@ -343,8 +345,9 @@ public:
m_words.push_back(0);
size_t wordCur = idx % 32;
m_words[wordIdx] &= ~(1 << wordCur);
m_bitCount = std::max(m_bitCount, idx + 1);
}
void clear() {m_words.clear();}
void clear() { m_words.clear(); m_bitCount = 0; }
class Iterator : public std::iterator<std::forward_iterator_tag, bool>
{

View File

@ -1,6 +1,6 @@
add_subdirectory(ScriptObjects)
include(DNAMP1/ScriptObjects/CMakeLists.txt)
make_dnalist(liblist
make_dnalist(liblist DNAMP1
PAK
MLVL
AGSC
@ -32,7 +32,6 @@ make_dnalist(liblist
set(DNAMP1_SOURCES
DNAMP1.hpp DNAMP1.cpp
${liblist}
PAK.cpp
MLVL.cpp
STRG.hpp STRG.cpp
@ -49,7 +48,7 @@ set(DNAMP1_SOURCES
SCLY.hpp SCLY.cpp
FRME.cpp
DeafBabe.cpp
Tweaks/CTweakPlayer.cpp
${ScriptObjectsMP1_SOURCES})
Tweaks/CTweakPlayer.cpp)
dataspec_add_list(DNAMP1 DNAMP1_SOURCES)
list(APPEND DNAMP1_SOURCES ${liblist})

View File

@ -1,4 +1,4 @@
make_dnalist(liblist
make_dnalist(liblist DNAMP1/ScriptObjects
IScriptObject
Parameters
Actor
@ -129,9 +129,9 @@ make_dnalist(liblist
WorldTeleporter)
set(ScriptObjectsMP1_SOURCES
${liblist}
ScriptTypes.hpp
IScriptObject.cpp
Parameters.cpp)
dataspec_add_list(ScriptObjects ScriptObjectsMP1_SOURCES)
dataspec_add_list(DNAMP1/ScriptObjects ScriptObjectsMP1_SOURCES)
list(APPEND ScriptObjectsMP1_SOURCES ${liblist})

View File

@ -1,4 +1,4 @@
make_dnalist(liblist
make_dnalist(liblist DNAMP2
MLVL
ANIM
AGSC
@ -12,7 +12,6 @@ make_dnalist(liblist
DeafBabe)
set(DNAMP2_SOURCES
DNAMP2.hpp DNAMP2.cpp
${liblist}
ANIM.cpp
AGSC.cpp
CINF.cpp
@ -24,3 +23,4 @@ set(DNAMP2_SOURCES
STRG.hpp STRG.cpp)
dataspec_add_list(DNAMP2 DNAMP2_SOURCES)
list(APPEND DNAMP2_SOURCES ${liblist})

View File

@ -1,4 +1,4 @@
make_dnalist(liblist
make_dnalist(liblist DNAMP3
PAK
MLVL
ANIM
@ -12,7 +12,6 @@ make_dnalist(liblist
HINT)
set(DNAMP3_SOURCES
DNAMP3.hpp DNAMP3.cpp
${liblist}
PAK.cpp
ANIM.cpp
CINF.cpp
@ -24,3 +23,4 @@ set(DNAMP3_SOURCES
MREA.cpp)
dataspec_add_list(DNAMP3 DNAMP3_SOURCES)
list(APPEND DNAMP3_SOURCES ${liblist})

View File

@ -9,13 +9,48 @@
namespace urde
{
CWorldLayerState::CWorldLayerState(CBitStreamReader& reader, const CSaveWorld& saveWorld)
{
u32 bitCount = reader.ReadEncoded(10);
x10_saveLayers.reserve(bitCount);
for (u32 i=0 ; i<bitCount ; ++i)
{
bool bit = reader.ReadEncoded(1);
if (bit)
x10_saveLayers.setBit(i);
else
x10_saveLayers.unsetBit(i);
}
}
void CWorldLayerState::InitializeWorldLayers(const std::vector<CWorldLayers::Area>& layers)
{
if (x0_areaLayers.size())
return;
x0_areaLayers = layers;
if (x10_saveLayers.getBitCount() == 0)
return;
u32 a = 0;
u32 b = 0;
for (const CWorldLayers::Area& area : x0_areaLayers)
{
for (u32 l=0 ; l<area.m_layerCount ; ++l)
SetLayerActive(a, l, x10_saveLayers.getBit(b++));
++a;
}
x10_saveLayers.clear();
}
CWorldState::CWorldState(ResId id)
: x0_mlvlId(id), x4_areaId(0)
{
x8_relayTracker = std::make_shared<CRelayTracker>();
xc_mapWorldInfo = std::make_shared<CMapWorldInfo>();
x10_ = -1;
x14_ = std::make_shared<CWorldSomethingState>();
x14_layerState = std::make_shared<CWorldLayerState>();
}
CWorldState::CWorldState(CBitStreamReader& reader, ResId mlvlId, const CSaveWorld& saveWorld)
@ -25,7 +60,7 @@ CWorldState::CWorldState(CBitStreamReader& reader, ResId mlvlId, const CSaveWorl
x10_ = reader.ReadEncoded(32);
x8_relayTracker = std::make_shared<CRelayTracker>(reader, saveWorld);
xc_mapWorldInfo = std::make_shared<CMapWorldInfo>(reader, saveWorld, mlvlId);
x14_ = std::make_shared<CWorldSomethingState>(reader, saveWorld);
x14_layerState = std::make_shared<CWorldLayerState>(reader, saveWorld);
}
CGameState::CGameState()

View File

@ -8,35 +8,36 @@
#include "CRelayTracker.hpp"
#include "World/CWorldTransManager.hpp"
#include "AutoMapper/CMapWorldInfo.hpp"
#include "World/CWorld.hpp"
#include "DataSpec/DNACommon/DNACommon.hpp"
namespace urde
{
class CSaveWorldMemory;
/* TODO: Figure out */
class CWorldSomethingState
class CWorldLayerState
{
friend class CSaveWorldIntermediate;
std::vector<u32> x0_;
u32 x10_bitCount = 0;
std::vector<u32> x14_;
std::vector<CWorldLayers::Area> x0_areaLayers;
DataSpec::WordBitmap x10_saveLayers;
public:
CWorldSomethingState() = default;
CWorldSomethingState(CBitStreamReader& reader, const CSaveWorld& saveWorld)
{
u32 bitCount = reader.ReadEncoded(10);
u32 wordCount = (bitCount + 31) / 32;
x14_.resize(wordCount);
CWorldLayerState() = default;
CWorldLayerState(CBitStreamReader& reader, const CSaveWorld& saveWorld);
for (u32 i=0 ; i<bitCount ; ++i)
{
++x10_bitCount;
bool bit = reader.ReadEncoded(1);
if (bit)
x14_[i / 32] |= 1 << (i % 32);
else
x14_[i / 32] &= ~(1 << (i % 32));
}
bool IsLayerActive(int areaIdx, int layerIdx) const
{
return (x0_areaLayers[areaIdx].m_layerBits >> layerIdx) & 1;
}
void SetLayerActive(int areaIdx, int layerIdx, bool active)
{
if (active)
x0_areaLayers[areaIdx].m_layerBits |= 1 << layerIdx;
else
x0_areaLayers[areaIdx].m_layerBits &= ~(1 << layerIdx);
}
void InitializeWorldLayers(const std::vector<CWorldLayers::Area>& layers);
};
class CWorldState
@ -46,7 +47,7 @@ class CWorldState
std::shared_ptr<CRelayTracker> x8_relayTracker;
std::shared_ptr<CMapWorldInfo> xc_mapWorldInfo;
u32 x10_;
std::shared_ptr<CWorldSomethingState> x14_;
std::shared_ptr<CWorldLayerState> x14_layerState;
public:
CWorldState(ResId id);
CWorldState(CBitStreamReader& reader, ResId mlvlId, const CSaveWorld& saveWorld);
@ -55,7 +56,7 @@ public:
TAreaId GetCurrentAreaId() const { return x4_areaId; }
const std::shared_ptr<CRelayTracker>& RelayTracker() const { return x8_relayTracker; }
const std::shared_ptr<CMapWorldInfo>& MapWorldInfo() const { return xc_mapWorldInfo; }
const std::shared_ptr<CWorldSomethingState>& GetSomethingElse() const { return x14_; }
const std::shared_ptr<CWorldLayerState>& GetLayerState() const { return x14_layerState; }
};
class CGameState

View File

@ -36,7 +36,7 @@ bool CSaveWorldIntermediate::InitializePump()
ResId mlvlId = wld.IGetWorldAssetId();
CWorldState& mlvlState = g_GameState->StateForWorld(mlvlId);
x1c_ = mlvlState.GetSomethingElse()->x0_;
x1c_defaultLayerStates = mlvlState.GetLayerState()->x0_areaLayers;
x34_saveWorld = g_SimplePool->GetObj(SObjectTag{FOURCC('SAVW'), x8_savwId});
x2c_dummyWorld.reset();
@ -109,7 +109,7 @@ bool CMemoryCardSys::InitializePump()
wldMemOut.x4_savwId = world.x8_savwId;
wldMemOut.x0_strgId = world.x4_strgId;
wldMemOut.xc_areaIds = world.xc_areaIds;
wldMemOut.x1c_ = world.x1c_;
wldMemOut.x1c_defaultLayerStates = world.x1c_defaultLayerStates;
CSaveWorld& savw = *world.x34_saveWorld;
wldMemOut.x8_areaCount = savw.GetAreaCount();

View File

@ -18,8 +18,8 @@ class CSaveWorldMemory
ResId x0_strgId = -1;
ResId x4_savwId = -1;
u32 x8_areaCount;
std::vector<ResId> xc_areaIds; /* 4 byte element */
std::vector<u32> x1c_; /* 16 byte element */
std::vector<ResId> xc_areaIds;
std::vector<CWorldLayers::Area> x1c_defaultLayerStates;
TLockedToken<CStringTable> x2c_worldName; /* used to be optional */
TLockedToken<CSaveWorld> x3c_saveWorld; /* used to be optional */
@ -38,7 +38,7 @@ class CSaveWorldIntermediate
ResId x4_strgId;
ResId x8_savwId;
std::vector<ResId> xc_areaIds;
std::vector<u32> x1c_;
std::vector<CWorldLayers::Area> x1c_defaultLayerStates;
std::unique_ptr<CDummyWorld> x2c_dummyWorld;
TLockedToken<CSaveWorld> x34_saveWorld; /* Used to be auto_ptr */

View File

@ -28,10 +28,11 @@
namespace urde
{
CStateManager::CStateManager(const std::weak_ptr<CRelayTracker>&,
const std::weak_ptr<CMapWorldInfo>&,
const std::weak_ptr<CPlayerState>&,
const std::weak_ptr<CWorldTransManager>&)
CStateManager::CStateManager(const std::weak_ptr<CRelayTracker>& relayTracker,
const std::weak_ptr<CMapWorldInfo>& mwInfo,
const std::weak_ptr<CPlayerState>& playerState,
const std::weak_ptr<CWorldTransManager>& wtMgr,
const std::weak_ptr<CWorldLayerState>& layerState)
: x80c_allObjs(new CObjectList(EGameObjectList::All)),
x814_actorObjs(new CActorList()),
x81c_physActorObjs(new CPhysicsActorList()),
@ -39,7 +40,12 @@ CStateManager::CStateManager(const std::weak_ptr<CRelayTracker>&,
x82c_lightObjs(new CGameLightList()),
x834_listenAiObjs(new CListeningAiList()),
x83c_aiWaypointObjs(new CAiWaypointList()),
x844_platformAndDoorObjs(new CPlatformAndDoorList())
x844_platformAndDoorObjs(new CPlatformAndDoorList()),
x8b8_playerState(playerState),
x8bc_relayTracker(relayTracker),
x8c0_mapWorldInfo(mwInfo),
x8c4_worldTransManager(wtMgr),
x8c8_worldLayerState(layerState)
{
x86c_stateManagerContainer.reset(new CStateManagerContainer);
x870_cameraManager = &x86c_stateManagerContainer->x0_cameraManager;

View File

@ -42,6 +42,7 @@ class CFinalInput;
class CPlayer;
class CWorld;
class CTexture;
class CWorldLayerState;
struct SScriptObjectStream
{
@ -99,10 +100,10 @@ class CStateManager
std::shared_ptr<CRelayTracker> x8bc_relayTracker;
std::shared_ptr<CMapWorldInfo> x8c0_mapWorldInfo;
std::shared_ptr<CWorldTransManager> x8c4_worldTransManager;
std::shared_ptr<CWorldLayerState> x8c8_worldLayerState;
TAreaId x8c8_currentAreaId;
TAreaId x8cc_nextAreaId;
TAreaId x8d0_prevAreaId;
TAreaId x8cc_nextAreaId = 0;
TAreaId x8d0_prevAreaId = kInvalidAreaId;
//u32 x8d0_extFrameIdx = 0;
//u32 x8d4_updateFrameIdx = 0;
//u32 x8d8_drawFrameIdx = 0;
@ -172,7 +173,8 @@ public:
CStateManager(const std::weak_ptr<CRelayTracker>&,
const std::weak_ptr<CMapWorldInfo>&,
const std::weak_ptr<CPlayerState>&,
const std::weak_ptr<CWorldTransManager>&);
const std::weak_ptr<CWorldTransManager>&,
const std::weak_ptr<CWorldLayerState>&);
bool RenderLast(TUniqueId);
void AddDrawableActor(const CActor& actor, const zeus::CVector3f& vec, const zeus::CAABox& aabb) const;
@ -286,7 +288,8 @@ public:
CRelayTracker* GetRelayTracker() { return x8bc_relayTracker.get(); }
CCameraManager* GetCameraManager() const { return x870_cameraManager; }
std::shared_ptr<CMapWorldInfo> MapWorldInfo() { return x8c0_mapWorldInfo; }
const std::shared_ptr<CMapWorldInfo>& MapWorldInfo() const { return x8c0_mapWorldInfo; }
const std::shared_ptr<CWorldLayerState>& LayerState() const { return x8c8_worldLayerState; }
bool IsLayerActive(TAreaId area, int layerIdx) { return false; }

View File

@ -46,6 +46,11 @@ CMFGameLoader::CMFGameLoader() : CMFGameLoaderBase("CMFGameLoader")
}
}
void CMFGameLoader::MakeLoadDependencyList()
{
}
CIOWin::EMessageReturn CMFGameLoader::OnMessage(const CArchitectureMessage& msg, CArchitectureQueue& queue)
{
std::shared_ptr<CWorldTransManager> wtMgr = g_GameState->GetWorldTransitionManager();
@ -55,6 +60,17 @@ CIOWin::EMessageReturn CMFGameLoader::OnMessage(const CArchitectureMessage& msg,
case EArchMsgType::TimerTick:
{
const CArchMsgParmReal32& tick = MakeMsg::GetParmTimerTick(msg);
float dt = tick.x4_parm;
if (!x2c_24_initialized)
{
if (x1c_.empty())
MakeLoadDependencyList();
wtMgr->StartTransition();
}
else
{
wtMgr->Update(dt);
}
}
default:
break;

View File

@ -45,12 +45,14 @@ class CMFGameLoader : public CMFGameLoaderBase
{
struct
{
bool x2c_24_ : 1;
bool x2c_24_initialized : 1;
bool x2c_25_ : 1;
};
u8 _dummy = 0;
};
void MakeLoadDependencyList();
public:
CMFGameLoader();
EMessageReturn OnMessage(const CArchitectureMessage& msg, CArchitectureQueue& queue);

View File

@ -367,7 +367,6 @@ void CWorldTransManager::EnableTransition(const CAnimRes& samusRes,
else
x1c_bgHeight = 0.f;
StartTransition();
TouchModels();
}
@ -391,7 +390,6 @@ void CWorldTransManager::EnableTransition(ResId fontId, ResId stringId, bool b1,
x8_textData->SetTypeWriteEffectOptions(true, chFadeTime, chFadeRate);
xc_strTable = g_SimplePool->GetObj(SObjectTag{FOURCC('STRG'), stringId});
x8_textData->SetText(L"");
StartTransition();
}
void CWorldTransManager::DisableTransition()

2
amuse

@ -1 +1 @@
Subproject commit 7cb7ed73ea2b91227b55fae206ffbc86a82a4844
Subproject commit 3fd3f3edc51e1d1de74bdb62907cb4ff333995ad