namespace housekeeping continued x3

This commit is contained in:
Justin Scofield
2022-06-20 14:07:35 -04:00
parent f9e0ed17bf
commit 350d5526de
9 changed files with 78 additions and 78 deletions

View File

@@ -23,7 +23,7 @@ using uchar = unsigned char;
namespace yaze { namespace yaze {
namespace app { namespace app {
namespace core { namespace core {
namespace Constants { namespace constants {
//=========================================================================================== //===========================================================================================
// 65816 LanguageDefinition // 65816 LanguageDefinition
@@ -1224,7 +1224,7 @@ static const std::string TileTypeNames[] = {
"$FE Door X top? (unused?)", "$FE Door X top? (unused?)",
"$FF Door X top? (unused?)"}; "$FF Door X top? (unused?)"};
} // namespace Constants } // namespace constants
} // namespace Core } // namespace Core
} // namespace app } // namespace app
} // namespace yaze } // namespace yaze

View File

@@ -11,16 +11,16 @@ namespace gfx {
int GetPCGfxAddress(char *romData, char id) { int GetPCGfxAddress(char *romData, char id) {
char **info1 = new char *[255]; char **info1 = new char *[255];
int gfxPointer1 = int gfxPointer1 =
lorom_snes_to_pc((romData[core::Constants::gfx_1_pointer + 1] << 8) + lorom_snes_to_pc((romData[core::constants::gfx_1_pointer + 1] << 8) +
(romData[core::Constants::gfx_1_pointer]), (romData[core::constants::gfx_1_pointer]),
info1); info1);
int gfxPointer2 = int gfxPointer2 =
lorom_snes_to_pc((romData[core::Constants::gfx_2_pointer + 1] << 8) + lorom_snes_to_pc((romData[core::constants::gfx_2_pointer + 1] << 8) +
(romData[core::Constants::gfx_2_pointer]), (romData[core::constants::gfx_2_pointer]),
info1); info1);
int gfxPointer3 = int gfxPointer3 =
lorom_snes_to_pc((romData[core::Constants::gfx_3_pointer + 1] << 8) + lorom_snes_to_pc((romData[core::constants::gfx_3_pointer + 1] << 8) +
(romData[core::Constants::gfx_3_pointer]), (romData[core::constants::gfx_3_pointer]),
info1); info1);
char gfxGamePointer1 = romData[gfxPointer1 + id]; char gfxGamePointer1 = romData[gfxPointer1 + id];
@@ -45,7 +45,7 @@ char *CreateAllGfxDataRaw(char *romData) {
unsigned int uncompressedSize = 0; unsigned int uncompressedSize = 0;
unsigned int compressedSize = 0; unsigned int compressedSize = 0;
for (int i = 0; i < core::Constants::NumberOfSheets; i++) { for (int i = 0; i < core::constants::NumberOfSheets; i++) {
isbpp3[i] = ((i >= 0 && i <= 112) || // Compressed 3bpp bg isbpp3[i] = ((i >= 0 && i <= 112) || // Compressed 3bpp bg
(i >= 115 && i <= 126) || // Uncompressed 3bpp sprites (i >= 115 && i <= 126) || // Uncompressed 3bpp sprites
(i >= 127 && i <= 217) // Compressed 3bpp sprites (i >= 127 && i <= 217) // Compressed 3bpp sprites
@@ -53,15 +53,15 @@ char *CreateAllGfxDataRaw(char *romData) {
// uncompressed sheets // uncompressed sheets
if (i >= 115 && i <= 126) { if (i >= 115 && i <= 126) {
data = new char[core::Constants::Uncompressed3BPPSize]; data = new char[core::constants::Uncompressed3BPPSize];
int startAddress = GetPCGfxAddress(romData, (char)i); int startAddress = GetPCGfxAddress(romData, (char)i);
for (int j = 0; j < core::Constants::Uncompressed3BPPSize; j++) { for (int j = 0; j < core::constants::Uncompressed3BPPSize; j++) {
data[j] = romData[j + startAddress]; data[j] = romData[j + startAddress];
} }
} else { } else {
data = alttp_decompress_gfx((char *)romData, data = alttp_decompress_gfx((char *)romData,
GetPCGfxAddress(romData, (char)i), GetPCGfxAddress(romData, (char)i),
core::Constants::UncompressedSheetSize, core::constants::UncompressedSheetSize,
&uncompressedSize, &compressedSize); &uncompressedSize, &compressedSize);
} }
@@ -82,7 +82,7 @@ void CreateAllGfxData(char *romData, char *allgfx16Ptr) {
int sheetPosition = 0; int sheetPosition = 0;
// 8x8 tile // 8x8 tile
for (int s = 0; s < core::Constants::NumberOfSheets; s++) // Per Sheet for (int s = 0; s < core::constants::NumberOfSheets; s++) // Per Sheet
{ {
for (int j = 0; j < 4; j++) // Per Tile Line Y for (int j = 0; j < 4; j++) // Per Tile Line Y
{ {
@@ -160,9 +160,9 @@ void CreateAllGfxData(char *romData, char *allgfx16Ptr) {
} }
if (isbpp3[s]) { if (isbpp3[s]) {
sheetPosition += core::Constants::Uncompressed3BPPSize; sheetPosition += core::constants::Uncompressed3BPPSize;
} else { } else {
sheetPosition += core::Constants::UncompressedSheetSize; sheetPosition += core::constants::UncompressedSheetSize;
} }
} }

View File

@@ -24,7 +24,7 @@ class Bitmap {
char *pixel_data_; char *pixel_data_;
}; };
static bool isbpp3[core::Constants::NumberOfSheets]; static bool isbpp3[core::constants::NumberOfSheets];
int GetPCGfxAddress(char *romData, char id); int GetPCGfxAddress(char *romData, char id);
char *CreateAllGfxDataRaw(char *romData); char *CreateAllGfxDataRaw(char *romData);

View File

@@ -44,9 +44,9 @@ static TileInfo GetTilesInfo(ushort tile) {
void Overworld::Load(Data::ROM& rom) { void Overworld::Load(Data::ROM& rom) {
rom_ = rom; rom_ = rom;
for (int i = 0; i < 0x2B; i++) { for (int i = 0; i < 0x2B; i++) {
tileLeftEntrance.push_back(Constants::overworldEntranceAllowedTilesLeft + tileLeftEntrance.push_back(constants::overworldEntranceAllowedTilesLeft +
(i * 2)); (i * 2));
tileRightEntrance.push_back(Constants::overworldEntranceAllowedTilesRight + tileRightEntrance.push_back(constants::overworldEntranceAllowedTilesRight +
(i * 2)); (i * 2));
} }
@@ -105,7 +105,7 @@ void Overworld::AssembleMap32Tiles() {
} }
void Overworld::AssembleMap16Tiles() { void Overworld::AssembleMap16Tiles() {
int tpos = core::Constants::map16Tiles; int tpos = core::constants::map16Tiles;
for (int i = 0; i < 4096; i += 1) // 3760 for (int i = 0; i < 4096; i += 1) // 3760
{ {
TileInfo t0 = GetTilesInfo((uintptr_t)rom_.GetRawData() + tpos); TileInfo t0 = GetTilesInfo((uintptr_t)rom_.GetRawData() + tpos);
@@ -127,25 +127,25 @@ void Overworld::DecompressAllMapTiles() {
int sy = 0; int sy = 0;
int c = 0; int c = 0;
for (int i = 0; i < 160; i++) { for (int i = 0; i < 160; i++) {
int p1 = (rom_.GetRawData()[(Constants::compressedAllMap32PointersHigh) + int p1 = (rom_.GetRawData()[(constants::compressedAllMap32PointersHigh) +
2 + (int)(3 * i)] 2 + (int)(3 * i)]
<< 16) + << 16) +
(rom_.GetRawData()[(Constants::compressedAllMap32PointersHigh) + (rom_.GetRawData()[(constants::compressedAllMap32PointersHigh) +
1 + (int)(3 * i)] 1 + (int)(3 * i)]
<< 8) + << 8) +
(rom_.GetRawData()[(Constants::compressedAllMap32PointersHigh + (rom_.GetRawData()[(constants::compressedAllMap32PointersHigh +
(int)(3 * i))]); (int)(3 * i))]);
char* tmp = new char[256]; char* tmp = new char[256];
p1 = lorom_snes_to_pc(p1, &tmp); p1 = lorom_snes_to_pc(p1, &tmp);
std::cout << tmp << std::endl; std::cout << tmp << std::endl;
int p2 = (rom_.GetRawData()[(Constants::compressedAllMap32PointersLow) + 2 + int p2 = (rom_.GetRawData()[(constants::compressedAllMap32PointersLow) + 2 +
(int)(3 * i)] (int)(3 * i)]
<< 16) + << 16) +
(rom_.GetRawData()[(Constants::compressedAllMap32PointersLow) + 1 + (rom_.GetRawData()[(constants::compressedAllMap32PointersLow) + 1 +
(int)(3 * i)] (int)(3 * i)]
<< 8) + << 8) +
(rom_.GetRawData()[(Constants::compressedAllMap32PointersLow + (rom_.GetRawData()[(constants::compressedAllMap32PointersLow +
(int)(3 * i))]); (int)(3 * i))]);
p2 = lorom_snes_to_pc(p2, &tmp); p2 = lorom_snes_to_pc(p2, &tmp);
std::cout << tmp << std::endl; std::cout << tmp << std::endl;

View File

@@ -49,8 +49,8 @@ class Overworld {
std::vector<ushort> tileRightEntrance; std::vector<ushort> tileRightEntrance;
int map32address[4] = { int map32address[4] = {
core::Constants::map32TilesTL, core::Constants::map32TilesTR, core::constants::map32TilesTL, core::constants::map32TilesTR,
core::Constants::map32TilesBL, core::Constants::map32TilesBR}; core::constants::map32TilesBL, core::constants::map32TilesBR};
enum Dimension { enum Dimension {
map32TilesTL = 0, map32TilesTL = 0,

View File

@@ -16,7 +16,7 @@ OverworldMap::OverworldMap(Data::ROM & rom,
: rom_(rom), index(index), tiles16_(tiles16), parent(index) { : rom_(rom), index(index), tiles16_(tiles16), parent(index) {
if (index != 0x80) { if (index != 0x80) {
if (index <= 150) { if (index <= 150) {
if (rom_.GetRawData()[Constants::overworldMapSize + (index & 0x3F)] != if (rom_.GetRawData()[constants::overworldMapSize + (index & 0x3F)] !=
0) { 0) {
largeMap = true; largeMap = true;
} }
@@ -24,36 +24,36 @@ OverworldMap::OverworldMap(Data::ROM & rom,
} }
if (index < 64) { if (index < 64) {
sprgfx[0] = rom_.GetRawData()[Constants::overworldSpriteset + parent]; sprgfx[0] = rom_.GetRawData()[constants::overworldSpriteset + parent];
sprgfx[1] = rom_.GetRawData()[Constants::overworldSpriteset + parent + 64]; sprgfx[1] = rom_.GetRawData()[constants::overworldSpriteset + parent + 64];
sprgfx[2] = rom_.GetRawData()[Constants::overworldSpriteset + parent + 128]; sprgfx[2] = rom_.GetRawData()[constants::overworldSpriteset + parent + 128];
gfx = rom_.GetRawData()[Constants::mapGfx + parent]; gfx = rom_.GetRawData()[constants::mapGfx + parent];
palette = rom_.GetRawData()[Constants::overworldMapPalette + parent]; palette = rom_.GetRawData()[constants::overworldMapPalette + parent];
sprpalette[0] = sprpalette[0] =
rom_.GetRawData()[Constants::overworldSpritePalette + parent]; rom_.GetRawData()[constants::overworldSpritePalette + parent];
sprpalette[1] = sprpalette[1] =
rom_.GetRawData()[Constants::overworldSpritePalette + parent + 64]; rom_.GetRawData()[constants::overworldSpritePalette + parent + 64];
sprpalette[2] = sprpalette[2] =
rom_.GetRawData()[Constants::overworldSpritePalette + parent + 128]; rom_.GetRawData()[constants::overworldSpritePalette + parent + 128];
musics[0] = rom_.GetRawData()[Constants::overworldMusicBegining + parent]; musics[0] = rom_.GetRawData()[constants::overworldMusicBegining + parent];
musics[1] = rom_.GetRawData()[Constants::overworldMusicZelda + parent]; musics[1] = rom_.GetRawData()[constants::overworldMusicZelda + parent];
musics[2] = musics[2] =
rom_.GetRawData()[Constants::overworldMusicMasterSword + parent]; rom_.GetRawData()[constants::overworldMusicMasterSword + parent];
musics[3] = rom_.GetRawData()[Constants::overworldMusicAgahim + parent]; musics[3] = rom_.GetRawData()[constants::overworldMusicAgahim + parent];
} else if (index < 128) { } else if (index < 128) {
sprgfx[0] = rom_.GetRawData()[Constants::overworldSpriteset + parent + 128]; sprgfx[0] = rom_.GetRawData()[constants::overworldSpriteset + parent + 128];
sprgfx[1] = rom_.GetRawData()[Constants::overworldSpriteset + parent + 128]; sprgfx[1] = rom_.GetRawData()[constants::overworldSpriteset + parent + 128];
sprgfx[2] = rom_.GetRawData()[Constants::overworldSpriteset + parent + 128]; sprgfx[2] = rom_.GetRawData()[constants::overworldSpriteset + parent + 128];
gfx = rom_.GetRawData()[Constants::mapGfx + parent]; gfx = rom_.GetRawData()[constants::mapGfx + parent];
palette = rom_.GetRawData()[Constants::overworldMapPalette + parent]; palette = rom_.GetRawData()[constants::overworldMapPalette + parent];
sprpalette[0] = sprpalette[0] =
rom_.GetRawData()[Constants::overworldSpritePalette + parent + 128]; rom_.GetRawData()[constants::overworldSpritePalette + parent + 128];
sprpalette[1] = sprpalette[1] =
rom_.GetRawData()[Constants::overworldSpritePalette + parent + 128]; rom_.GetRawData()[constants::overworldSpritePalette + parent + 128];
sprpalette[2] = sprpalette[2] =
rom_.GetRawData()[Constants::overworldSpritePalette + parent + 128]; rom_.GetRawData()[constants::overworldSpritePalette + parent + 128];
musics[0] = rom_.GetRawData()[Constants::overworldMusicDW + (parent - 64)]; musics[0] = rom_.GetRawData()[constants::overworldMusicDW + (parent - 64)];
} else { } else {
if (index == 0x94) { if (index == 0x94) {
parent = 128; parent = 128;
@@ -77,31 +77,31 @@ OverworldMap::OverworldMap(Data::ROM & rom,
parent = 136; parent = 136;
} }
messageID = rom_.GetRawData()[Constants::overworldMessages + parent]; messageID = rom_.GetRawData()[constants::overworldMessages + parent];
sprgfx[0] = rom_.GetRawData()[Constants::overworldSpriteset + parent + 128]; sprgfx[0] = rom_.GetRawData()[constants::overworldSpriteset + parent + 128];
sprgfx[1] = rom_.GetRawData()[Constants::overworldSpriteset + parent + 128]; sprgfx[1] = rom_.GetRawData()[constants::overworldSpriteset + parent + 128];
sprgfx[2] = rom_.GetRawData()[Constants::overworldSpriteset + parent + 128]; sprgfx[2] = rom_.GetRawData()[constants::overworldSpriteset + parent + 128];
sprpalette[0] = sprpalette[0] =
rom_.GetRawData()[Constants::overworldSpritePalette + parent + 128]; rom_.GetRawData()[constants::overworldSpritePalette + parent + 128];
sprpalette[1] = sprpalette[1] =
rom_.GetRawData()[Constants::overworldSpritePalette + parent + 128]; rom_.GetRawData()[constants::overworldSpritePalette + parent + 128];
sprpalette[2] = sprpalette[2] =
rom_.GetRawData()[Constants::overworldSpritePalette + parent + 128]; rom_.GetRawData()[constants::overworldSpritePalette + parent + 128];
palette = palette =
rom_.GetRawData()[Constants::overworldSpecialPALGroup + parent - 128]; rom_.GetRawData()[constants::overworldSpecialPALGroup + parent - 128];
if (index >= 0x80 && index <= 0x8A && index != 0x88) { if (index >= 0x80 && index <= 0x8A && index != 0x88) {
gfx = rom_.GetRawData()[Constants::overworldSpecialGFXGroup + gfx = rom_.GetRawData()[constants::overworldSpecialGFXGroup +
(parent - 128)]; (parent - 128)];
palette = rom_.GetRawData()[Constants::overworldSpecialPALGroup + 1]; palette = rom_.GetRawData()[constants::overworldSpecialPALGroup + 1];
} else if (index == 0x88) { } else if (index == 0x88) {
gfx = 81; gfx = 81;
palette = 0; palette = 0;
} else // pyramid bg use 0x5B map } else // pyramid bg use 0x5B map
{ {
gfx = rom_.GetRawData()[Constants::mapGfx + parent]; gfx = rom_.GetRawData()[constants::mapGfx + parent];
palette = rom_.GetRawData()[Constants::overworldMapPalette + parent]; palette = rom_.GetRawData()[constants::overworldMapPalette + parent];
} }
} }
} }
@@ -117,8 +117,8 @@ void OverworldMap::BuildMap(uchar* mapParent, int count, int gameState,
if (parent != index) { if (parent != index) {
if (!firstLoad) { if (!firstLoad) {
gfx = rom_.GetRawData()[Constants::mapGfx + parent]; gfx = rom_.GetRawData()[constants::mapGfx + parent];
palette = rom_.GetRawData()[Constants::overworldMapPalette + parent]; palette = rom_.GetRawData()[constants::overworldMapPalette + parent];
firstLoad = true; firstLoad = true;
} }
} }
@@ -292,31 +292,31 @@ void OverworldMap::BuildTileset(int gameState) {
staticgfx[11] = 115 + 7; staticgfx[11] = 115 + 7;
for (int i = 0; i < 4; i++) { for (int i = 0; i < 4; i++) {
staticgfx[12 + i] = staticgfx[12 + i] =
(uchar)(rom_.GetRawData()[Constants::sprite_blockset_pointer + (uchar)(rom_.GetRawData()[constants::sprite_blockset_pointer +
(sprgfx[gameState] * 4) + i] + (sprgfx[gameState] * 4) + i] +
115); 115);
} }
// Main Blocksets // Main Blocksets
for (int i = 0; i < 8; i++) { for (int i = 0; i < 8; i++) {
staticgfx[i] = rom_.GetRawData()[Constants::overworldgfxGroups2 + staticgfx[i] = rom_.GetRawData()[constants::overworldgfxGroups2 +
(indexWorld * 8) + i]; (indexWorld * 8) + i];
} }
if (rom_.GetRawData()[Constants::overworldgfxGroups + (gfx * 4)] != 0) { if (rom_.GetRawData()[constants::overworldgfxGroups + (gfx * 4)] != 0) {
staticgfx[3] = rom_.GetRawData()[Constants::overworldgfxGroups + (gfx * 4)]; staticgfx[3] = rom_.GetRawData()[constants::overworldgfxGroups + (gfx * 4)];
} }
if (rom_.GetRawData()[Constants::overworldgfxGroups + (gfx * 4) + 1] != 0) { if (rom_.GetRawData()[constants::overworldgfxGroups + (gfx * 4) + 1] != 0) {
staticgfx[4] = staticgfx[4] =
rom_.GetRawData()[Constants::overworldgfxGroups + (gfx * 4) + 1]; rom_.GetRawData()[constants::overworldgfxGroups + (gfx * 4) + 1];
} }
if (rom_.GetRawData()[Constants::overworldgfxGroups + (gfx * 4) + 2] != 0) { if (rom_.GetRawData()[constants::overworldgfxGroups + (gfx * 4) + 2] != 0) {
staticgfx[5] = staticgfx[5] =
rom_.GetRawData()[Constants::overworldgfxGroups + (gfx * 4) + 2]; rom_.GetRawData()[constants::overworldgfxGroups + (gfx * 4) + 2];
} }
if (rom_.GetRawData()[Constants::overworldgfxGroups + (gfx * 4) + 3] != 0) { if (rom_.GetRawData()[constants::overworldgfxGroups + (gfx * 4) + 3] != 0) {
staticgfx[6] = staticgfx[6] =
rom_.GetRawData()[Constants::overworldgfxGroups + (gfx * 4) + 3]; rom_.GetRawData()[constants::overworldgfxGroups + (gfx * 4) + 3];
} }
// Hardcoded overworld GFX Values, for death mountain // Hardcoded overworld GFX Values, for death mountain

View File

@@ -21,10 +21,10 @@ namespace Editor {
using namespace core; using namespace core;
Editor::Editor() { Editor::Editor() {
for (auto &k : core::Constants::kKeywords) for (auto &k : core::constants::kKeywords)
language_65816_.mKeywords.emplace(k); language_65816_.mKeywords.emplace(k);
for (auto &k : core::Constants::kIdentifiers) { for (auto &k : core::constants::kIdentifiers) {
TextEditor::Identifier id; TextEditor::Identifier id;
id.mDeclaration = "Built-in function"; id.mDeclaration = "Built-in function";
language_65816_.mIdentifiers.insert(std::make_pair(std::string(k), id)); language_65816_.mIdentifiers.insert(std::make_pair(std::string(k), id));
@@ -497,7 +497,7 @@ void Editor::DrawDungeonEditor() {
} }
void Editor::DrawgfxEditor() { void Editor::DrawgfxEditor() {
if (ImGui::BeginTabItem("gfx")) { if (ImGui::BeginTabItem("Graphics")) {
ImGui::EndTabItem(); ImGui::EndTabItem();
} }
} }

View File

@@ -301,7 +301,7 @@ void OverworldEditor::DrawTileSelector() {
void OverworldEditor::DrawTile8Selector() { void OverworldEditor::DrawTile8Selector() {
static ImVec2 scrolling(0.0f, 0.0f); static ImVec2 scrolling(0.0f, 0.0f);
ImVec2 canvas_p0 = ImGui::GetCursorScreenPos(); ImVec2 canvas_p0 = ImGui::GetCursorScreenPos();
ImVec2 canvas_sz = ImVec2(256 + 1, kNumSheetsToLoad * 64); ImVec2 canvas_sz = ImVec2(256 + 1, kNumSheetsToLoad * 64 + 1);
ImVec2 canvas_p1 = ImVec2 canvas_p1 =
ImVec2(canvas_p0.x + canvas_sz.x, canvas_p0.y + canvas_sz.y); ImVec2(canvas_p0.x + canvas_sz.x, canvas_p0.y + canvas_sz.y);

View File

@@ -63,7 +63,7 @@ class OverworldEditor {
constexpr static int kByteSize = 3; constexpr static int kByteSize = 3;
constexpr static int kMessageIdSize = 5; constexpr static int kMessageIdSize = 5;
constexpr static float kInputFieldSize = 30.f; constexpr static float kInputFieldSize = 30.f;
constexpr static int kNumSheetsToLoad = 50; constexpr static int kNumSheetsToLoad = 100;
constexpr static int kTile8DisplayHeight = 64; constexpr static int kTile8DisplayHeight = 64;
ImGuiTableFlags toolset_table_flags = ImGuiTableFlags_SizingFixedFit; ImGuiTableFlags toolset_table_flags = ImGuiTableFlags_SizingFixedFit;