mirror of
https://github.com/zeldaret/oot
synced 2026-08-29 01:01:57 -04:00
ba0c6965ca
* remove zap * git subrepo clone https://github.com/zeldaret/ZAPD.git tools/ZAPD subrepo: subdir: "tools/ZAPD" merged: "cd4a8760b" upstream: origin: "https://github.com/zeldaret/ZAPD.git" branch: "master" commit: "cd4a8760b" git-subrepo: version: "0.4.3" origin: "https://github.com/ingydotnet/git-subrepo.git" commit: "2f68596" * remove thanks.md * zap2 -> zapd and spec changes * remove submodule init
101 lines
2.9 KiB
C++
101 lines
2.9 KiB
C++
#include "SetRoomList.h"
|
|
#include "../ZRoom.h"
|
|
#include "../../ZFile.h"
|
|
#include "../../Globals.h"
|
|
#include "../../BitConverter.h"
|
|
#include "../../StringHelper.h"
|
|
|
|
using namespace std;
|
|
|
|
SetRoomList::SetRoomList(ZRoom* nZRoom, std::vector<uint8_t> rawData, int rawDataIndex) : ZRoomCommand(nZRoom, rawData, rawDataIndex)
|
|
{
|
|
int numRooms = rawData[rawDataIndex + 1];
|
|
segmentOffset = BitConverter::ToInt32BE(rawData, rawDataIndex + 4) & 0x00FFFFFF;
|
|
|
|
rooms = vector<RoomEntry*>();
|
|
|
|
int32_t currentPtr = segmentOffset;
|
|
|
|
for (int i = 0; i < numRooms; i++)
|
|
{
|
|
RoomEntry* entry = new RoomEntry(rawData, currentPtr);
|
|
rooms.push_back(entry);
|
|
|
|
currentPtr += 8;
|
|
}
|
|
|
|
//string declaration = "";
|
|
|
|
/*for (int i = 0; i < rooms.size(); i++)
|
|
{
|
|
RoomEntry* entry = rooms[i];
|
|
|
|
string roomName = StringHelper::Sprintf("%sRoom%i", StringHelper::Split(zRoom->GetName(), "_scene")[0].c_str(), i);
|
|
declaration += StringHelper::Sprintf("\t{ (u32)%sSegmentRomStart, (u32)%sSegmentRomEnd },\n", roomName.c_str(), roomName.c_str());
|
|
}*/
|
|
|
|
//zRoom->parent->declarations[segmentOffset] = new Declaration(DeclarationAlignment::None, rooms.size() * 8,
|
|
//"RomFile", StringHelper::Sprintf("%sRoomList0x%06X", zRoom->GetName().c_str(), segmentOffset), true, declaration);
|
|
}
|
|
|
|
string SetRoomList::GenerateSourceCodePass1(string roomName, int baseAddress)
|
|
{
|
|
return StringHelper::Sprintf("%s 0x%02X, (u32)&%sRoomList0x%06X", ZRoomCommand::GenerateSourceCodePass1(roomName, baseAddress).c_str(), rooms.size(), zRoom->GetName().c_str(), segmentOffset);
|
|
}
|
|
|
|
string SetRoomList::GenerateSourceCodePass2(string roomName, int baseAddress)
|
|
{
|
|
return "";
|
|
}
|
|
|
|
string SetRoomList::GenerateExterns()
|
|
{
|
|
return StringHelper::Sprintf("extern RomFile %sRoomList0x%06X[];\n", zRoom->GetName().c_str(), segmentOffset);
|
|
}
|
|
|
|
string SetRoomList::GetCommandCName()
|
|
{
|
|
return "SCmdRoomList";
|
|
}
|
|
|
|
RoomCommand SetRoomList::GetRoomCommand()
|
|
{
|
|
return RoomCommand::SetRoomList;
|
|
}
|
|
|
|
std::string SetRoomList::PreGenSourceFiles()
|
|
{
|
|
string declaration = "";
|
|
|
|
for (ZFile* file : Globals::Instance->files)
|
|
{
|
|
for (ZResource* res : file->resources)
|
|
{
|
|
if (res->GetResourceType() == ZResourceType::Room && res != zRoom)
|
|
{
|
|
string roomName = res->GetName();
|
|
declaration += StringHelper::Sprintf("\t{ (u32)_%sSegmentRomStart, (u32)_%sSegmentRomEnd },\n", roomName.c_str(), roomName.c_str());
|
|
}
|
|
}
|
|
}
|
|
|
|
zRoom->parent->declarations[segmentOffset] = new Declaration(DeclarationAlignment::None, rooms.size() * 8,
|
|
"RomFile", StringHelper::Sprintf("%sRoomList0x%06X", zRoom->GetName().c_str(), segmentOffset), true, declaration);
|
|
|
|
return std::string();
|
|
}
|
|
|
|
std::string SetRoomList::Save()
|
|
{
|
|
return std::string();
|
|
}
|
|
|
|
RoomEntry::RoomEntry(int32_t nVAS, int32_t nVAE)
|
|
{
|
|
virtualAddressStart = nVAS;
|
|
virtualAddressEnd = nVAE;
|
|
}
|
|
|
|
RoomEntry::RoomEntry(std::vector<uint8_t> rawData, int rawDataIndex) : RoomEntry(BitConverter::ToInt32BE(rawData, rawDataIndex + 0), BitConverter::ToInt32BE(rawData, rawDataIndex + 4))
|
|
{
|
|
} |