Refactor OverworldMap class
This commit is contained in:
@@ -17,7 +17,7 @@ void Overworld::Load(ROM &rom) {
|
|||||||
|
|
||||||
// Map Initialization
|
// Map Initialization
|
||||||
for (int i = 0; i < core::NumberOfOWMaps; i++) {
|
for (int i = 0; i < core::NumberOfOWMaps; i++) {
|
||||||
overworld_maps_.emplace_back(rom_, tiles16, i);
|
overworld_maps_.emplace_back(i, rom_, tiles16);
|
||||||
}
|
}
|
||||||
FetchLargeMaps();
|
FetchLargeMaps();
|
||||||
LoadOverworldMap();
|
LoadOverworldMap();
|
||||||
|
|||||||
@@ -19,18 +19,27 @@ namespace app {
|
|||||||
namespace zelda3 {
|
namespace zelda3 {
|
||||||
|
|
||||||
class Overworld {
|
class Overworld {
|
||||||
public:
|
public:
|
||||||
void Load(ROM &rom);
|
void Load(ROM &rom);
|
||||||
auto GetTiles16() const { return tiles16; }
|
auto GetTiles16() const { return tiles16; }
|
||||||
auto GetCurrentGfxSetPtr() { return currentOWgfx16.GetData(); }
|
auto GetCurrentGfxSetPtr() { return currentOWgfx16.GetData(); }
|
||||||
auto GetMapBlockset16Ptr() { return mapblockset16.GetData(); }
|
auto GetMapBlockset16Ptr() { return mapblockset16.GetData(); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
const int map32address[4] = {core::map32TilesTL, core::map32TilesTR,
|
||||||
|
core::map32TilesBL, core::map32TilesBR};
|
||||||
|
enum Dimension {
|
||||||
|
map32TilesTL = 0,
|
||||||
|
map32TilesTR = 1,
|
||||||
|
map32TilesBL = 2,
|
||||||
|
map32TilesBR = 3
|
||||||
|
};
|
||||||
|
|
||||||
ushort GenerateTile32(int i, int k, int dimension);
|
ushort GenerateTile32(int i, int k, int dimension);
|
||||||
void AssembleMap32Tiles();
|
void AssembleMap32Tiles();
|
||||||
void AssembleMap16Tiles();
|
void AssembleMap16Tiles();
|
||||||
void AssignWorldTiles(std::vector<std::vector<ushort>> &world, int x,
|
void AssignWorldTiles(std::vector<std::vector<ushort>> &world, int x, int y,
|
||||||
int y, int sx, int sy, int tpos);
|
int sx, int sy, int tpos);
|
||||||
void DecompressAllMapTiles();
|
void DecompressAllMapTiles();
|
||||||
void FetchLargeMaps();
|
void FetchLargeMaps();
|
||||||
void LoadOverworldMap();
|
void LoadOverworldMap();
|
||||||
@@ -50,21 +59,10 @@ private:
|
|||||||
std::vector<gfx::Tile32> tiles32;
|
std::vector<gfx::Tile32> tiles32;
|
||||||
std::vector<gfx::Tile32> map16tiles;
|
std::vector<gfx::Tile32> map16tiles;
|
||||||
std::vector<OverworldMap> overworld_maps_;
|
std::vector<OverworldMap> overworld_maps_;
|
||||||
|
|
||||||
const int map32address[4] = {
|
|
||||||
core::map32TilesTL, core::map32TilesTR,
|
|
||||||
core::map32TilesBL, core::map32TilesBR};
|
|
||||||
|
|
||||||
enum Dimension {
|
|
||||||
map32TilesTL = 0,
|
|
||||||
map32TilesTR = 1,
|
|
||||||
map32TilesBL = 2,
|
|
||||||
map32TilesBR = 3
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace zelda3
|
} // namespace zelda3
|
||||||
} // namespace app
|
} // namespace app
|
||||||
} // namespace yaze
|
} // namespace yaze
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -16,54 +16,56 @@ namespace yaze {
|
|||||||
namespace app {
|
namespace app {
|
||||||
namespace zelda3 {
|
namespace zelda3 {
|
||||||
|
|
||||||
OverworldMap::OverworldMap(ROM& rom, const std::vector<gfx::Tile16>& tiles16,
|
OverworldMap::OverworldMap(int index, ROM& rom,
|
||||||
int index_)
|
const std::vector<gfx::Tile16>& tiles16)
|
||||||
: parent_(index_), index_(index_), rom_(rom), tiles16_(tiles16) {
|
: parent_(index_), index(index_), rom_(rom), tiles16_(tiles16) {
|
||||||
if (index_ != 0x80 && index_ <= 150 &&
|
if (index_ != 0x80 && index_ <= 150 &&
|
||||||
rom_.data()[core::overworldMapSize + (index_ & 0x3F)] != 0) {
|
rom_.data()[core::overworldMapSize + (index_ & 0x3F)] != 0) {
|
||||||
large_map_ = true;
|
large_map_ = true;
|
||||||
}
|
}
|
||||||
|
LoadAreaInfo();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Overworld::LoadAreaInfo() {
|
||||||
|
auto z3data = rom_.data();
|
||||||
|
|
||||||
if (index_ < 64) {
|
if (index_ < 64) {
|
||||||
sprite_graphics_[0] = rom_.data()[core::overworldSpriteset + parent_];
|
sprite_graphics_[0] = z3data[core::overworldSpriteset + parent_];
|
||||||
sprite_graphics_[1] = rom_.data()[core::overworldSpriteset + parent_ + 64];
|
sprite_graphics_[1] = z3data[core::overworldSpriteset + parent_ + 64];
|
||||||
sprite_graphics_[2] = rom_.data()[core::overworldSpriteset + parent_ + 128];
|
sprite_graphics_[2] = z3data[core::overworldSpriteset + parent_ + 128];
|
||||||
gfx_ = rom_.data()[core::mapGfx + parent_];
|
|
||||||
palette_ = rom_.data()[core::overworldMapPalette + parent_];
|
|
||||||
sprite_palette_[0] = rom_.data()[core::overworldSpritePalette + parent_];
|
|
||||||
sprite_palette_[1] =
|
|
||||||
rom_.data()[core::overworldSpritePalette + parent_ + 64];
|
|
||||||
sprite_palette_[2] =
|
|
||||||
rom_.data()[core::overworldSpritePalette + parent_ + 128];
|
|
||||||
musics[0] = rom_.data()[core::overworldMusicBegining + parent_];
|
|
||||||
musics[1] = rom_.data()[core::overworldMusicZelda + parent_];
|
|
||||||
musics[2] = rom_.data()[core::overworldMusicMasterSword + parent_];
|
|
||||||
musics[3] = rom_.data()[core::overworldMusicAgahim + parent_];
|
|
||||||
} else if (index_ < 128) {
|
|
||||||
sprite_graphics_[0] = rom_.data()[core::overworldSpriteset + parent_ + 128];
|
|
||||||
sprite_graphics_[1] = rom_.data()[core::overworldSpriteset + parent_ + 128];
|
|
||||||
sprite_graphics_[2] = rom_.data()[core::overworldSpriteset + parent_ + 128];
|
|
||||||
gfx_ = rom_.data()[core::mapGfx + parent_];
|
|
||||||
palette_ = rom_.data()[core::overworldMapPalette + parent_];
|
|
||||||
sprite_palette_[0] =
|
|
||||||
rom_.data()[core::overworldSpritePalette + parent_ + 128];
|
|
||||||
sprite_palette_[1] =
|
|
||||||
rom_.data()[core::overworldSpritePalette + parent_ + 128];
|
|
||||||
sprite_palette_[2] =
|
|
||||||
rom_.data()[core::overworldSpritePalette + parent_ + 128];
|
|
||||||
|
|
||||||
musics[0] = rom_.data()[core::overworldMusicDW + (parent_ - 64)];
|
sprite_palette_[0] = z3data[core::overworldSpritePalette + parent_];
|
||||||
|
sprite_palette_[1] = z3data[core::overworldSpritePalette + parent_ + 64];
|
||||||
|
sprite_palette_[2] = z3data[core::overworldSpritePalette + parent_ + 128];
|
||||||
|
|
||||||
|
area_graphics_ = z3data[core::mapGfx + parent_];
|
||||||
|
area_palette_ = z3data[core::overworldMapPalette + parent_];
|
||||||
|
|
||||||
|
area_music_[0] = z3data[core::overworldMusicBegining + parent_];
|
||||||
|
area_music_[1] = z3data[core::overworldMusicZelda + parent_];
|
||||||
|
area_music_[2] = z3data[core::overworldMusicMasterSword + parent_];
|
||||||
|
area_music_[3] = z3data[core::overworldMusicAgahim + parent_];
|
||||||
|
} else if (index_ < 128) {
|
||||||
|
sprite_graphics_[0] = z3data[core::overworldSpriteset + parent_ + 128];
|
||||||
|
sprite_graphics_[1] = z3data[core::overworldSpriteset + parent_ + 128];
|
||||||
|
sprite_graphics_[2] = z3data[core::overworldSpriteset + parent_ + 128];
|
||||||
|
|
||||||
|
sprite_palette_[0] = z3data[core::overworldSpritePalette + parent_ + 128];
|
||||||
|
sprite_palette_[1] = z3data[core::overworldSpritePalette + parent_ + 128];
|
||||||
|
sprite_palette_[2] = z3data[core::overworldSpritePalette + parent_ + 128];
|
||||||
|
|
||||||
|
area_graphics_ = z3data[core::mapGfx + parent_];
|
||||||
|
area_palette_ = z3data[core::overworldMapPalette + parent_];
|
||||||
|
area_music_[0] = z3data[core::overworldMusicDW + (parent_ - 64)];
|
||||||
} else {
|
} else {
|
||||||
if (index_ == 0x94) {
|
if (index_ == 0x94) {
|
||||||
parent_ = 128;
|
parent_ = 128;
|
||||||
} else if (index_ == 0x95) {
|
} else if (index_ == 0x95) {
|
||||||
parent_ = 03;
|
parent_ = 03;
|
||||||
} else if (index_ == 0x96) // pyramid bg use 0x5B map
|
} else if (index_ == 0x96) {
|
||||||
{
|
parent_ = 0x5B; // pyramid bg use 0x5B map
|
||||||
parent_ = 0x5B;
|
} else if (index_ == 0x97) {
|
||||||
} else if (index_ == 0x97) // pyramid bg use 0x5B map
|
parent_ = 0x00; // pyramid bg use 0x5B map
|
||||||
{
|
|
||||||
parent_ = 0x00;
|
|
||||||
} else if (index_ == 156) {
|
} else if (index_ == 156) {
|
||||||
parent_ = 67;
|
parent_ = 67;
|
||||||
} else if (index_ == 157) {
|
} else if (index_ == 157) {
|
||||||
@@ -76,29 +78,27 @@ OverworldMap::OverworldMap(ROM& rom, const std::vector<gfx::Tile16>& tiles16,
|
|||||||
parent_ = 136;
|
parent_ = 136;
|
||||||
}
|
}
|
||||||
|
|
||||||
message_id_ = rom_.data()[core::overworldMessages + parent_];
|
message_id_ = z3data[core::overworldMessages + parent_];
|
||||||
|
|
||||||
sprite_graphics_[0] = rom_.data()[core::overworldSpriteset + parent_ + 128];
|
sprite_graphics_[0] = z3data[core::overworldSpriteset + parent_ + 128];
|
||||||
sprite_graphics_[1] = rom_.data()[core::overworldSpriteset + parent_ + 128];
|
sprite_graphics_[1] = z3data[core::overworldSpriteset + parent_ + 128];
|
||||||
sprite_graphics_[2] = rom_.data()[core::overworldSpriteset + parent_ + 128];
|
sprite_graphics_[2] = z3data[core::overworldSpriteset + parent_ + 128];
|
||||||
sprite_palette_[0] =
|
|
||||||
rom_.data()[core::overworldSpritePalette + parent_ + 128];
|
|
||||||
sprite_palette_[1] =
|
|
||||||
rom_.data()[core::overworldSpritePalette + parent_ + 128];
|
|
||||||
sprite_palette_[2] =
|
|
||||||
rom_.data()[core::overworldSpritePalette + parent_ + 128];
|
|
||||||
|
|
||||||
palette_ = rom_.data()[core::overworldSpecialPALGroup + parent_ - 128];
|
sprite_palette_[0] = z3data[core::overworldSpritePalette + parent_ + 128];
|
||||||
|
sprite_palette_[1] = z3data[core::overworldSpritePalette + parent_ + 128];
|
||||||
|
sprite_palette_[2] = z3data[core::overworldSpritePalette + parent_ + 128];
|
||||||
|
|
||||||
|
area_palette_ = z3data[core::overworldSpecialPALGroup + parent_ - 128];
|
||||||
if (index_ >= 0x80 && index_ <= 0x8A && index_ != 0x88) {
|
if (index_ >= 0x80 && index_ <= 0x8A && index_ != 0x88) {
|
||||||
gfx_ = rom_.data()[core::overworldSpecialGFXGroup + (parent_ - 128)];
|
area_graphics_ = z3data[core::overworldSpecialGFXGroup + (parent_ - 128)];
|
||||||
palette_ = rom_.data()[core::overworldSpecialPALGroup + 1];
|
area_palette_ = z3data[core::overworldSpecialPALGroup + 1];
|
||||||
} else if (index_ == 0x88) {
|
} else if (index_ == 0x88) {
|
||||||
gfx_ = 81;
|
area_graphics_ = 81;
|
||||||
palette_ = 0;
|
area_palette_ = 0;
|
||||||
} else // pyramid bg use 0x5B map
|
} else // pyramid bg use 0x5B map
|
||||||
{
|
{
|
||||||
gfx_ = rom_.data()[core::mapGfx + parent_];
|
area_graphics_ = z3data[core::mapGfx + parent_];
|
||||||
palette_ = rom_.data()[core::overworldMapPalette + parent_];
|
area_palette_ = z3data[core::overworldMapPalette + parent_];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -110,14 +110,15 @@ void OverworldMap::BuildMap(int count, int game_state, uchar* map_parent,
|
|||||||
|
|
||||||
if (parent_ != index_ && !initialized_) {
|
if (parent_ != index_ && !initialized_) {
|
||||||
if (index_ >= 0x80 && index_ <= 0x8A && index_ != 0x88) {
|
if (index_ >= 0x80 && index_ <= 0x8A && index_ != 0x88) {
|
||||||
gfx_ = rom_.data()[core::overworldSpecialGFXGroup + (parent_ - 128)];
|
area_graphics_ =
|
||||||
palette_ = rom_.data()[core::overworldSpecialPALGroup + 1];
|
rom_.data()[core::overworldSpecialGFXGroup + (parent_ - 128)];
|
||||||
|
area_palette_ = rom_.data()[core::overworldSpecialPALGroup + 1];
|
||||||
} else if (index_ == 0x88) {
|
} else if (index_ == 0x88) {
|
||||||
gfx_ = 81;
|
area_graphics_ = 81;
|
||||||
palette_ = 0;
|
area_palette_ = 0;
|
||||||
} else {
|
} else {
|
||||||
gfx_ = rom_.data()[core::mapGfx + parent_];
|
area_graphics_ = rom_.data()[core::mapGfx + parent_];
|
||||||
palette_ = rom_.data()[core::overworldMapPalette + parent_];
|
area_palette_ = rom_.data()[core::overworldMapPalette + parent_];
|
||||||
}
|
}
|
||||||
|
|
||||||
initialized_ = true;
|
initialized_ = true;
|
||||||
@@ -149,41 +150,79 @@ void OverworldMap::BuildMap(int count, int game_state, uchar* map_parent,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void OverworldMap::CopyTile8bpp16(int x, int y, int tile, uchar* destbmpPtr,
|
void OverworldMap::BuildTileset(int gameState) {
|
||||||
uchar* sourcebmpPtr) {
|
int indexWorld = 0x20;
|
||||||
int sourcePtrPos = ((tile - ((tile / 8) * 8)) * 16) +
|
if (parent_ < 0x40) {
|
||||||
((tile / 8) * 2048); // (sourceX * 16) + (sourceY * 128)
|
indexWorld = 0x20;
|
||||||
auto sourcePtr = sourcebmpPtr;
|
} else if (parent_ >= 0x40 && parent_ < 0x80) {
|
||||||
|
indexWorld = 0x21;
|
||||||
int destPtrPos = (x + (y * 512));
|
} else if (parent_ == 0x88) {
|
||||||
auto destPtr = destbmpPtr;
|
indexWorld = 36;
|
||||||
|
|
||||||
for (int ystrip = 0; ystrip < 16; ystrip++) {
|
|
||||||
for (int xstrip = 0; xstrip < 16; xstrip++) {
|
|
||||||
destPtr[destPtrPos + xstrip + (ystrip * 512)] =
|
|
||||||
sourcePtr[sourcePtrPos + xstrip + (ystrip * 128)];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void OverworldMap::CopyTile8bpp16From8(int xP, int yP, int tileID,
|
// Sprites Blocksets
|
||||||
uchar* destbmpPtr, uchar* sourcebmpPtr) {
|
staticgfx[8] = 115 + 0;
|
||||||
auto gfx16Data = destbmpPtr;
|
staticgfx[9] = 115 + 1;
|
||||||
// TODO: PSEUDO VRAM
|
staticgfx[10] = 115 + 6;
|
||||||
auto gfx8Data = rom_.GetVRAM().GetGraphicsData();
|
staticgfx[11] = 115 + 7;
|
||||||
|
for (int i = 0; i < 4; i++) {
|
||||||
|
staticgfx[12 + i] =
|
||||||
|
(uchar)(rom_.data()[core::sprite_blockset_pointer +
|
||||||
|
(sprite_graphics_[gameState] * 4) + i] +
|
||||||
|
115);
|
||||||
|
}
|
||||||
|
|
||||||
int offsets[] = {0, 8, 4096, 4104};
|
// Main Blocksets
|
||||||
|
for (int i = 0; i < 8; i++) {
|
||||||
|
staticgfx[i] =
|
||||||
|
rom_.data()[core::overworldgfxGroups2 + (indexWorld * 8) + i];
|
||||||
|
}
|
||||||
|
|
||||||
auto tiles = tiles16_[tileID];
|
if (rom_.data()[core::overworldgfxGroups + (area_graphics_ * 4)] != 0) {
|
||||||
|
staticgfx[3] = rom_.data()[core::overworldgfxGroups + (area_graphics_ * 4)];
|
||||||
|
}
|
||||||
|
if (rom_.data()[core::overworldgfxGroups + (area_graphics_ * 4) + 1] != 0) {
|
||||||
|
staticgfx[4] =
|
||||||
|
rom_.data()[core::overworldgfxGroups + (area_graphics_ * 4) + 1];
|
||||||
|
}
|
||||||
|
if (rom_.data()[core::overworldgfxGroups + (area_graphics_ * 4) + 2] != 0) {
|
||||||
|
staticgfx[5] =
|
||||||
|
rom_.data()[core::overworldgfxGroups + (area_graphics_ * 4) + 2];
|
||||||
|
}
|
||||||
|
if (rom_.data()[core::overworldgfxGroups + (area_graphics_ * 4) + 3] != 0) {
|
||||||
|
staticgfx[6] =
|
||||||
|
rom_.data()[core::overworldgfxGroups + (area_graphics_ * 4) + 3];
|
||||||
|
}
|
||||||
|
|
||||||
for (auto tile = 0; tile < 4; tile++) {
|
// Hardcoded overworld GFX Values, for death mountain
|
||||||
gfx::TileInfo info = tiles.tiles_info[tile];
|
if ((parent_ >= 0x03 && parent_ <= 0x07) ||
|
||||||
int offset = offsets[tile];
|
(parent_ >= 0x0B && parent_ <= 0x0E)) {
|
||||||
|
staticgfx[7] = 89;
|
||||||
|
} else if ((parent_ >= 0x43 && parent_ <= 0x47) ||
|
||||||
|
(parent_ >= 0x4B && parent_ <= 0x4E)) {
|
||||||
|
staticgfx[7] = 89;
|
||||||
|
} else {
|
||||||
|
staticgfx[7] = 91;
|
||||||
|
}
|
||||||
|
|
||||||
for (auto y = 0; y < 8; y++) {
|
// TODO: PSEUDO VRAM DATA HERE
|
||||||
for (auto x = 0; x < 4; x++) {
|
uchar* currentmapgfx8Data = rom_.GetVRAM().GetGraphicsData();
|
||||||
CopyTileToMap(x, y, xP, yP, offset, info, gfx16Data, gfx8Data);
|
// TODO: PUT GRAPHICS DATA HERE
|
||||||
|
uchar const* allgfxData = rom_.GetMasterGraphicsBin();
|
||||||
|
|
||||||
|
for (int i = 0; i < 16; i++) {
|
||||||
|
for (int j = 0; j < 2048; j++) {
|
||||||
|
uchar mapByte = allgfxData[j + (staticgfx[i] * 2048)];
|
||||||
|
switch (i) {
|
||||||
|
case 0:
|
||||||
|
case 3:
|
||||||
|
case 4:
|
||||||
|
case 5:
|
||||||
|
mapByte += 0x88;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
currentmapgfx8Data[(i * 2048) + j] = mapByte; // Upload used gfx data
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -220,7 +259,6 @@ void OverworldMap::BuildTiles16Gfx(int count) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// map,current
|
// map,current
|
||||||
void OverworldMap::CopyTile(int x, int y, int xx, int yy, int offset,
|
void OverworldMap::CopyTile(int x, int y, int xx, int yy, int offset,
|
||||||
gfx::TileInfo tile, uchar* gfx16Pointer,
|
gfx::TileInfo tile, uchar* gfx16Pointer,
|
||||||
@@ -271,76 +309,41 @@ void OverworldMap::CopyTileToMap(int x, int y, int xx, int yy, int offset,
|
|||||||
gfx16Pointer[index + r] = (uchar)(((pixel >> 4) & 0x0F) + tile.palette_ * 16);
|
gfx16Pointer[index + r] = (uchar)(((pixel >> 4) & 0x0F) + tile.palette_ * 16);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OverworldMap::BuildTileset(int gameState) {
|
void OverworldMap::CopyTile8bpp16(int x, int y, int tile, uchar* destbmpPtr,
|
||||||
int indexWorld = 0x20;
|
uchar* sourcebmpPtr) {
|
||||||
if (parent_ < 0x40) {
|
int sourcePtrPos = ((tile - ((tile / 8) * 8)) * 16) +
|
||||||
indexWorld = 0x20;
|
((tile / 8) * 2048); // (sourceX * 16) + (sourceY * 128)
|
||||||
} else if (parent_ >= 0x40 && parent_ < 0x80) {
|
auto sourcePtr = sourcebmpPtr;
|
||||||
indexWorld = 0x21;
|
|
||||||
} else if (parent_ == 0x88) {
|
|
||||||
indexWorld = 36;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Sprites Blocksets
|
int destPtrPos = (x + (y * 512));
|
||||||
staticgfx[8] = 115 + 0;
|
auto destPtr = destbmpPtr;
|
||||||
staticgfx[9] = 115 + 1;
|
|
||||||
staticgfx[10] = 115 + 6;
|
|
||||||
staticgfx[11] = 115 + 7;
|
|
||||||
for (int i = 0; i < 4; i++) {
|
|
||||||
staticgfx[12 + i] =
|
|
||||||
(uchar)(rom_.data()[core::sprite_blockset_pointer +
|
|
||||||
(sprite_graphics_[gameState] * 4) + i] +
|
|
||||||
115);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Main Blocksets
|
for (int ystrip = 0; ystrip < 16; ystrip++) {
|
||||||
for (int i = 0; i < 8; i++) {
|
for (int xstrip = 0; xstrip < 16; xstrip++) {
|
||||||
staticgfx[i] =
|
destPtr[destPtrPos + xstrip + (ystrip * 512)] =
|
||||||
rom_.data()[core::overworldgfxGroups2 + (indexWorld * 8) + i];
|
sourcePtr[sourcePtrPos + xstrip + (ystrip * 128)];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (rom_.data()[core::overworldgfxGroups + (gfx_ * 4)] != 0) {
|
void OverworldMap::CopyTile8bpp16From8(int xP, int yP, int tileID,
|
||||||
staticgfx[3] = rom_.data()[core::overworldgfxGroups + (gfx_ * 4)];
|
uchar* destbmpPtr, uchar* sourcebmpPtr) {
|
||||||
}
|
auto gfx16Data = destbmpPtr;
|
||||||
if (rom_.data()[core::overworldgfxGroups + (gfx_ * 4) + 1] != 0) {
|
// TODO: PSEUDO VRAM
|
||||||
staticgfx[4] = rom_.data()[core::overworldgfxGroups + (gfx_ * 4) + 1];
|
auto gfx8Data = rom_.GetVRAM().GetGraphicsData();
|
||||||
}
|
|
||||||
if (rom_.data()[core::overworldgfxGroups + (gfx_ * 4) + 2] != 0) {
|
|
||||||
staticgfx[5] = rom_.data()[core::overworldgfxGroups + (gfx_ * 4) + 2];
|
|
||||||
}
|
|
||||||
if (rom_.data()[core::overworldgfxGroups + (gfx_ * 4) + 3] != 0) {
|
|
||||||
staticgfx[6] = rom_.data()[core::overworldgfxGroups + (gfx_ * 4) + 3];
|
|
||||||
}
|
|
||||||
|
|
||||||
// Hardcoded overworld GFX Values, for death mountain
|
int offsets[] = {0, 8, 4096, 4104};
|
||||||
if ((parent_ >= 0x03 && parent_ <= 0x07) ||
|
|
||||||
(parent_ >= 0x0B && parent_ <= 0x0E)) {
|
|
||||||
staticgfx[7] = 89;
|
|
||||||
} else if ((parent_ >= 0x43 && parent_ <= 0x47) ||
|
|
||||||
(parent_ >= 0x4B && parent_ <= 0x4E)) {
|
|
||||||
staticgfx[7] = 89;
|
|
||||||
} else {
|
|
||||||
staticgfx[7] = 91;
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: PSEUDO VRAM DATA HERE
|
auto tiles = tiles16_[tileID];
|
||||||
uchar* currentmapgfx8Data = rom_.GetVRAM().GetGraphicsData();
|
|
||||||
// TODO: PUT GRAPHICS DATA HERE
|
|
||||||
uchar const* allgfxData = rom_.GetMasterGraphicsBin();
|
|
||||||
|
|
||||||
for (int i = 0; i < 16; i++) {
|
for (auto tile = 0; tile < 4; tile++) {
|
||||||
for (int j = 0; j < 2048; j++) {
|
gfx::TileInfo info = tiles.tiles_info[tile];
|
||||||
uchar mapByte = allgfxData[j + (staticgfx[i] * 2048)];
|
int offset = offsets[tile];
|
||||||
switch (i) {
|
|
||||||
case 0:
|
for (auto y = 0; y < 8; y++) {
|
||||||
case 3:
|
for (auto x = 0; x < 4; x++) {
|
||||||
case 4:
|
CopyTileToMap(x, y, xP, yP, offset, info, gfx16Data, gfx8Data);
|
||||||
case 5:
|
|
||||||
mapByte += 0x88;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
currentmapgfx8Data[(i * 2048) + j] = mapByte; // Upload used gfx data
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,20 +16,26 @@ namespace zelda3 {
|
|||||||
|
|
||||||
class OverworldMap {
|
class OverworldMap {
|
||||||
public:
|
public:
|
||||||
int parent_ = 0;
|
OverworldMap(int index, ROM& rom, const std::vector<gfx::Tile16>& tiles16);
|
||||||
int index_ = 0;
|
void BuildMap(int count, int game_state, uchar* map_parent,
|
||||||
int message_id_ = 0;
|
OWMapTiles& map_tiles);
|
||||||
int gfx_ = 0;
|
|
||||||
int palette_ = 0;
|
auto SetLargeMap(bool is_set) { large_map_ = is_set; }
|
||||||
bool initialized_ = false;
|
auto IsLargeMap() { return large_map_; }
|
||||||
bool large_map_ = false;
|
|
||||||
uchar sprite_graphics_[3];
|
private:
|
||||||
uchar sprite_palette_[3];
|
void LoadAreaInfo();
|
||||||
uchar musics[4];
|
void BuildTileset(int gameState);
|
||||||
uchar* gfxPtr = new uchar[512 * 512];
|
void BuildTiles16Gfx(int count);
|
||||||
uchar* mapblockset16_ = nullptr;
|
void CopyTile(int x, int y, int xx, int yy, int offset, gfx::TileInfo tile,
|
||||||
uchar* currentOWgfx16Ptr_ = nullptr;
|
uchar* gfx16Pointer, uchar* gfx8Pointer);
|
||||||
uchar* allGfx16Ptr_ = nullptr;
|
void CopyTileToMap(int x, int y, int xx, int yy, int offset,
|
||||||
|
gfx::TileInfo tile, uchar* gfx16Pointer,
|
||||||
|
uchar* gfx8Pointer);
|
||||||
|
void CopyTile8bpp16(int x, int y, int tile, uchar* destbmpPtr,
|
||||||
|
uchar* sourcebmpPtr);
|
||||||
|
void CopyTile8bpp16From8(int xP, int yP, int tileID, uchar* destbmpPtr,
|
||||||
|
uchar* sourcebmpPtr);
|
||||||
|
|
||||||
ROM rom_;
|
ROM rom_;
|
||||||
gfx::Bitmap gfxBitmap;
|
gfx::Bitmap gfxBitmap;
|
||||||
@@ -38,22 +44,20 @@ class OverworldMap {
|
|||||||
uchar* staticgfx = new uchar[16];
|
uchar* staticgfx = new uchar[16];
|
||||||
std::vector<std::vector<ushort>> tiles_used_;
|
std::vector<std::vector<ushort>> tiles_used_;
|
||||||
|
|
||||||
OverworldMap(ROM& rom, const std::vector<gfx::Tile16>& tiles16, int index);
|
int parent_ = 0;
|
||||||
void BuildMap(int count, int game_state, uchar* map_parent,
|
int index_ = 0;
|
||||||
OWMapTiles& map_tiles);
|
int message_id_ = 0;
|
||||||
void CopyTile8bpp16(int x, int y, int tile, uchar* destbmpPtr,
|
int area_graphics_ = 0;
|
||||||
uchar* sourcebmpPtr);
|
int area_palette_ = 0;
|
||||||
void CopyTile8bpp16From8(int xP, int yP, int tileID, uchar* destbmpPtr,
|
bool initialized_ = false;
|
||||||
uchar* sourcebmpPtr);
|
bool large_map_ = false;
|
||||||
|
uchar sprite_graphics_[3];
|
||||||
private:
|
uchar sprite_palette_[3];
|
||||||
void BuildTiles16Gfx(int count);
|
uchar area_music_[4];
|
||||||
void CopyTile(int x, int y, int xx, int yy, int offset, gfx::TileInfo tile,
|
uchar* gfxPtr = new uchar[512 * 512];
|
||||||
uchar* gfx16Pointer, uchar* gfx8Pointer);
|
uchar* mapblockset16_ = nullptr;
|
||||||
void CopyTileToMap(int x, int y, int xx, int yy, int offset,
|
uchar* currentOWgfx16Ptr_ = nullptr;
|
||||||
gfx::TileInfo tile, uchar* gfx16Pointer,
|
uchar* allGfx16Ptr_ = nullptr;
|
||||||
uchar* gfx8Pointer);
|
|
||||||
void BuildTileset(int gameState);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace zelda3
|
} // namespace zelda3
|
||||||
|
|||||||
Reference in New Issue
Block a user