summaryrefslogtreecommitdiff
path: root/ZAPD/ZRoom/Commands/SetCsCamera.cpp
diff options
context:
space:
mode:
authorAnghelo Carvajal <angheloalf95@gmail.com>2021-04-15 07:49:28 -0400
committerGitHub <noreply@github.com>2021-04-15 07:49:28 -0400
commit179af7d11fd27b046edfb1bbadade865033583d7 (patch)
tree316a55e5c0857e26184d6758a324483e029e8849 /ZAPD/ZRoom/Commands/SetCsCamera.cpp
parent96ffc1e62720f0f43eb4885e6e7dbaf76a2f6cd2 (diff)
Rename "Prerender" to "Background", properly extract PolygonType1 multi format and change some structs used. (#107)
* Extract BgImage Signed-off-by: angie <angheloalf95@gmail.com> * improve the output a bit Signed-off-by: angie <angheloalf95@gmail.com> * extract backgrounds for multipoly Signed-off-by: angie <angheloalf95@gmail.com> * Extract the dlists of PolygonDlist Signed-off-by: angie <angheloalf95@gmail.com> * commands in the next line Signed-off-by: angie <angheloalf95@gmail.com> * Move a lot of repeated code into a class Signed-off-by: angie <angheloalf95@gmail.com> * Use PolygonDlist instead of MeshEntry0 Signed-off-by: angie <angheloalf95@gmail.com> * Rename prerender to background Signed-off-by: angie <angheloalf95@gmail.com> * format Signed-off-by: angie <angheloalf95@gmail.com> * last cleanup Signed-off-by: angie <angheloalf95@gmail.com> * Handle jpg padding Signed-off-by: angie <angheloalf95@gmail.com> * Add a few checks and warnings for jpeg validity Signed-off-by: Angie <angheloalf95@gmail.com> * typo Signed-off-by: Angie <angheloalf95@gmail.com> * fix merge error Signed-off-by: angie <angheloalf95@gmail.com> * Fix background extraction that somehow was broken Signed-off-by: angie <angheloalf95@gmail.com> * re-add the trailling line feed Signed-off-by: angie <angheloalf95@gmail.com> * add trailing line feed again Signed-off-by: angie <angheloalf95@gmail.com> * fix an already fixed warning Signed-off-by: angie <angheloalf95@gmail.com> * fix crash when no config file is provided * run format
Diffstat (limited to 'ZAPD/ZRoom/Commands/SetCsCamera.cpp')
-rw-r--r--ZAPD/ZRoom/Commands/SetCsCamera.cpp38
1 files changed, 20 insertions, 18 deletions
diff --git a/ZAPD/ZRoom/Commands/SetCsCamera.cpp b/ZAPD/ZRoom/Commands/SetCsCamera.cpp
index 762d01c..582e623 100644
--- a/ZAPD/ZRoom/Commands/SetCsCamera.cpp
+++ b/ZAPD/ZRoom/Commands/SetCsCamera.cpp
@@ -33,12 +33,13 @@ SetCsCamera::SetCsCamera(ZRoom* nZRoom, std::vector<uint8_t> rawData, int rawDat
if (numPoints > 0)
{
uint32_t currentPtr = cameras[0]->segmentOffset;
-
- for (int i = 0; i < numPoints; i++) {
+
+ for (int i = 0; i < numPoints; i++)
+ {
int16_t x = BitConverter::ToInt16BE(rawData, currentPtr + 0);
int16_t y = BitConverter::ToInt16BE(rawData, currentPtr + 2);
int16_t z = BitConverter::ToInt16BE(rawData, currentPtr + 4);
- Vec3s p = { x, y, z };
+ Vec3s p = {x, y, z};
points.push_back(p);
currentPtr += 6;
}
@@ -70,8 +71,8 @@ string SetCsCamera::GenerateSourceCodePass2(string roomName, int baseAddress)
sourceOutput +=
StringHelper::Sprintf("%s %i, (u32)&%sCsCameraList0x%06X };",
- ZRoomCommand::GenerateSourceCodePass1(roomName, baseAddress).c_str(),
- cameras.size(), roomName.c_str(), segmentOffset);
+ ZRoomCommand::GenerateSourceCodePass1(roomName, baseAddress).c_str(),
+ cameras.size(), roomName.c_str(), segmentOffset);
if (points.size() > 0)
{
@@ -80,7 +81,7 @@ string SetCsCamera::GenerateSourceCodePass2(string roomName, int baseAddress)
for (Vec3s point : points)
{
declaration += StringHelper::Sprintf(" { %i, %i, %i }, //0x%06X", point.x, point.y,
- point.z, cameras[0]->segmentOffset + (index * 6));
+ point.z, cameras[0]->segmentOffset + (index * 6));
if (index < points.size() - 1)
declaration += "\n";
@@ -88,11 +89,12 @@ string SetCsCamera::GenerateSourceCodePass2(string roomName, int baseAddress)
index++;
}
- zRoom->parent->AddDeclarationArray(
- cameras[0]->segmentOffset, DeclarationAlignment::None, DeclarationPadding::None,
- points.size() * 6, "Vec3s",
- StringHelper::Sprintf("%sCsCameraPoints0x%06X", roomName.c_str(), cameras[0]->segmentOffset),
- points.size(), declaration);
+ zRoom->parent->AddDeclarationArray(cameras[0]->segmentOffset, DeclarationAlignment::None,
+ DeclarationPadding::None, points.size() * 6, "Vec3s",
+ StringHelper::Sprintf("%sCsCameraPoints0x%06X",
+ roomName.c_str(),
+ cameras[0]->segmentOffset),
+ points.size(), declaration);
}
{
@@ -102,8 +104,9 @@ string SetCsCamera::GenerateSourceCodePass2(string roomName, int baseAddress)
size_t pointsIndex = 0;
for (CsCameraEntry* entry : cameras)
{
- declaration += StringHelper::Sprintf(" %i, %i, (u32)&%sCsCameraPoints0x%06X[%i],", entry->type,
- entry->numPoints, roomName.c_str(), cameras[0]->segmentOffset, pointsIndex);
+ declaration += StringHelper::Sprintf(" %i, %i, (u32)&%sCsCameraPoints0x%06X[%i],",
+ entry->type, entry->numPoints, roomName.c_str(),
+ cameras[0]->segmentOffset, pointsIndex);
if (index < cameras.size() - 1)
declaration += "\n";
@@ -142,10 +145,9 @@ RoomCommand SetCsCamera::GetRoomCommand()
return RoomCommand::SetCsCamera;
}
-CsCameraEntry::CsCameraEntry(std::vector<uint8_t> rawData, int rawDataIndex) :
- baseOffset(rawDataIndex),
- type(BitConverter::ToInt16BE(rawData, rawDataIndex + 0)),
- numPoints(BitConverter::ToInt16BE(rawData, rawDataIndex + 2)),
- segmentOffset(GETSEGOFFSET(BitConverter::ToInt32BE(rawData, rawDataIndex + 4)))
+CsCameraEntry::CsCameraEntry(std::vector<uint8_t> rawData, int rawDataIndex)
+ : baseOffset(rawDataIndex), type(BitConverter::ToInt16BE(rawData, rawDataIndex + 0)),
+ numPoints(BitConverter::ToInt16BE(rawData, rawDataIndex + 2)),
+ segmentOffset(GETSEGOFFSET(BitConverter::ToInt32BE(rawData, rawDataIndex + 4)))
{
}