Skip to content

Commit

Permalink
Some more startup files
Browse files Browse the repository at this point in the history
  • Loading branch information
xavieran committed Mar 25, 2024
1 parent d689f40 commit a2efe36
Show file tree
Hide file tree
Showing 7 changed files with 68 additions and 1 deletion.
9 changes: 9 additions & 0 deletions app/display_startup_files.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "bak/startupFiles.hpp"
#include "bak/combat.hpp"

#include "com/logger.hpp"

Expand Down Expand Up @@ -32,5 +33,13 @@ int main(int argc, char** argv)
BAK::LoadZoneMap(BAK::ZoneNumber{i});
}

logger.Info() << "Z00.DAT\n";
for (unsigned i = 1; i < 13; i++)
{
BAK::LoadZoneDat(BAK::ZoneNumber{i});
}

BAK::LoadP1Dat();

return 0;
}
1 change: 1 addition & 0 deletions bak/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ add_library(bak
book.hpp book.cpp
camera.hpp
camp.hpp camp.cpp
combat.hpp combat.cpp
condition.hpp condition.cpp
constants.hpp
cutscenes.hpp cutscenes.cpp
Expand Down
28 changes: 28 additions & 0 deletions bak/combat.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#include "bak/combat.hpp"

#include "bak/fileBufferFactory.hpp"

#include "com/logger.hpp"

#include <sstream>

namespace BAK {

void LoadP1Dat()
{
auto fb = FileBufferFactory::Get().CreateDataBuffer("P1.DAT");

std::stringstream ss{};
for (unsigned j = 0; j < 7; j++)
{
for (unsigned i = 0; i < 16; i++)
{
ss << " " << +fb.GetUint8();
}
Logging::LogDebug(__FUNCTION__) << "Skills? " << ss.str() << "\n";
ss = {};
}
Logging::LogDebug(__FUNCTION__) << "Remaining: " << fb.GetBytesLeft() << "\n";
}

}
7 changes: 7 additions & 0 deletions bak/combat.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#pragma once

namespace BAK {

void LoadP1Dat();

}
7 changes: 7 additions & 0 deletions bak/resourceNames.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,13 @@ class ZoneLabel
ss << GetZoneLabel() << "MAP.DAT";
return ss.str();
};

std::string GetZoneDat() const
{
std::stringstream ss{""};
ss << GetZoneLabel() << ".DAT";
return ss.str();
};
private:
std::string mZoneLabel;
};
Expand Down
15 changes: 15 additions & 0 deletions bak/startupFiles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,4 +162,19 @@ unsigned GetMapDatTileValue(
return mapVal & mask;
}

void LoadZoneDat(ZoneNumber zone)
{
auto zoneLabel = ZoneLabel{zone.mValue};
auto fb = FileBufferFactory::Get().CreateDataBuffer(zoneLabel.GetZoneDat());
Logging::LogDebug(__FUNCTION__) << "Zone: " << zone << "\n";

auto word0 = fb.GetUint16LE();
auto word1 = fb.GetUint16LE();
auto word2 = fb.GetUint16LE();
auto word3 = fb.GetUint16LE();

Logging::LogDebug(__FUNCTION__) << "Data: " << word0 << " " << word1 << " " << word2 << " " << word3 << "\n";
Logging::LogDebug(__FUNCTION__) << "Remaining:" << fb.GetBytesLeft() << "\n";
}

}
2 changes: 1 addition & 1 deletion bak/startupFiles.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace BAK
void LoadChapter(Chapter);
void LoadFilter();
void LoadDetect();
void LoadZoneDat();
void LoadZoneDat(ZoneNumber);
void LoadZoneDefDat(ZoneNumber);

using ZoneMap = std::array<std::uint8_t, 0x190>;
Expand Down

0 comments on commit a2efe36

Please sign in to comment.