Overworld housekeeping
This commit is contained in:
@@ -24,10 +24,10 @@ void Overworld::Load(ROM &rom) {
|
|||||||
|
|
||||||
auto size = tiles16.size();
|
auto size = tiles16.size();
|
||||||
for (int i = 0; i < core::NumberOfOWMaps; i++) {
|
for (int i = 0; i < core::NumberOfOWMaps; i++) {
|
||||||
overworld_maps_[i].BuildMap(size, gameState, mapParent, map_tiles_);
|
overworld_maps_[i].BuildMap(size, game_state_, map_parent_, map_tiles_);
|
||||||
}
|
}
|
||||||
|
|
||||||
isLoaded = true;
|
is_loaded_ = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
ushort Overworld::GenerateTile32(int i, int k, int dimension) {
|
ushort Overworld::GenerateTile32(int i, int k, int dimension) {
|
||||||
@@ -162,15 +162,15 @@ void Overworld::DecompressAllMapTiles() {
|
|||||||
|
|
||||||
void Overworld::FetchLargeMaps() {
|
void Overworld::FetchLargeMaps() {
|
||||||
for (int i = 128; i < 145; i++) {
|
for (int i = 128; i < 145; i++) {
|
||||||
mapParent[i] = 0;
|
map_parent_[i] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
mapParent[128] = 128;
|
map_parent_[128] = 128;
|
||||||
mapParent[129] = 129;
|
map_parent_[129] = 129;
|
||||||
mapParent[130] = 129;
|
map_parent_[130] = 129;
|
||||||
mapParent[137] = 129;
|
map_parent_[137] = 129;
|
||||||
mapParent[138] = 129;
|
map_parent_[138] = 129;
|
||||||
mapParent[136] = 136;
|
map_parent_[136] = 136;
|
||||||
overworld_maps_[136].SetLargeMap(false);
|
overworld_maps_[136].SetLargeMap(false);
|
||||||
|
|
||||||
bool mapChecked[64];
|
bool mapChecked[64];
|
||||||
@@ -184,24 +184,24 @@ void Overworld::FetchLargeMaps() {
|
|||||||
if (mapChecked[i] == false) {
|
if (mapChecked[i] == false) {
|
||||||
if (overworld_maps_[i].IsLargeMap() == true) {
|
if (overworld_maps_[i].IsLargeMap() == true) {
|
||||||
mapChecked[i] = true;
|
mapChecked[i] = true;
|
||||||
mapParent[i] = (uchar)i;
|
map_parent_[i] = (uchar)i;
|
||||||
mapParent[i + 64] = (uchar)(i + 64);
|
map_parent_[i + 64] = (uchar)(i + 64);
|
||||||
|
|
||||||
mapChecked[i + 1] = true;
|
mapChecked[i + 1] = true;
|
||||||
mapParent[i + 1] = (uchar)i;
|
map_parent_[i + 1] = (uchar)i;
|
||||||
mapParent[i + 65] = (uchar)(i + 64);
|
map_parent_[i + 65] = (uchar)(i + 64);
|
||||||
|
|
||||||
mapChecked[i + 8] = true;
|
mapChecked[i + 8] = true;
|
||||||
mapParent[i + 8] = (uchar)i;
|
map_parent_[i + 8] = (uchar)i;
|
||||||
mapParent[i + 72] = (uchar)(i + 64);
|
map_parent_[i + 72] = (uchar)(i + 64);
|
||||||
|
|
||||||
mapChecked[i + 9] = true;
|
mapChecked[i + 9] = true;
|
||||||
mapParent[i + 9] = (uchar)i;
|
map_parent_[i + 9] = (uchar)i;
|
||||||
mapParent[i + 73] = (uchar)(i + 64);
|
map_parent_[i + 73] = (uchar)(i + 64);
|
||||||
xx++;
|
xx++;
|
||||||
} else {
|
} else {
|
||||||
mapParent[i] = (uchar)i;
|
map_parent_[i] = (uchar)i;
|
||||||
mapParent[i + 64] = (uchar)(i + 64);
|
map_parent_[i + 64] = (uchar)(i + 64);
|
||||||
mapChecked[i] = true;
|
mapChecked[i] = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,9 +44,9 @@ class Overworld {
|
|||||||
void FetchLargeMaps();
|
void FetchLargeMaps();
|
||||||
void LoadOverworldMap();
|
void LoadOverworldMap();
|
||||||
|
|
||||||
int gameState = 1;
|
int game_state_ = 1;
|
||||||
bool isLoaded = false;
|
uchar map_parent_[160];
|
||||||
uchar mapParent[160];
|
bool is_loaded_ = false;
|
||||||
|
|
||||||
ROM rom_;
|
ROM rom_;
|
||||||
OWMapTiles map_tiles_;
|
OWMapTiles map_tiles_;
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ void Overworld::LoadAreaInfo() {
|
|||||||
sprite_graphics_[0] = z3data[core::overworldSpriteset + parent_ + 128];
|
sprite_graphics_[0] = z3data[core::overworldSpriteset + parent_ + 128];
|
||||||
sprite_graphics_[1] = z3data[core::overworldSpriteset + parent_ + 128];
|
sprite_graphics_[1] = z3data[core::overworldSpriteset + parent_ + 128];
|
||||||
sprite_graphics_[2] = z3data[core::overworldSpriteset + parent_ + 128];
|
sprite_graphics_[2] = z3data[core::overworldSpriteset + parent_ + 128];
|
||||||
|
|
||||||
sprite_palette_[0] = z3data[core::overworldSpritePalette + parent_ + 128];
|
sprite_palette_[0] = z3data[core::overworldSpritePalette + parent_ + 128];
|
||||||
sprite_palette_[1] = z3data[core::overworldSpritePalette + parent_ + 128];
|
sprite_palette_[1] = z3data[core::overworldSpritePalette + parent_ + 128];
|
||||||
sprite_palette_[2] = z3data[core::overworldSpritePalette + parent_ + 128];
|
sprite_palette_[2] = z3data[core::overworldSpritePalette + parent_ + 128];
|
||||||
@@ -106,7 +106,7 @@ void Overworld::LoadAreaInfo() {
|
|||||||
void OverworldMap::BuildMap(int count, int game_state, uchar* map_parent,
|
void OverworldMap::BuildMap(int count, int game_state, uchar* map_parent,
|
||||||
OWMapTiles& map_tiles) {
|
OWMapTiles& map_tiles) {
|
||||||
if (large_map_) {
|
if (large_map_) {
|
||||||
this->parent_ = map_parent[index_];
|
parent_ = map_parent[index_];
|
||||||
|
|
||||||
if (parent_ != index_ && !initialized_) {
|
if (parent_ != index_ && !initialized_) {
|
||||||
if (index_ >= 0x80 && index_ <= 0x8A && index_ != 0x88) {
|
if (index_ >= 0x80 && index_ <= 0x8A && index_ != 0x88) {
|
||||||
@@ -151,22 +151,22 @@ void OverworldMap::BuildMap(int count, int game_state, uchar* map_parent,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void OverworldMap::BuildTileset(int gameState) {
|
void OverworldMap::BuildTileset(int gameState) {
|
||||||
int indexWorld = 0x20;
|
int index_world = 0x20;
|
||||||
if (parent_ < 0x40) {
|
if (parent_ < 0x40) {
|
||||||
indexWorld = 0x20;
|
index_world = 0x20;
|
||||||
} else if (parent_ >= 0x40 && parent_ < 0x80) {
|
} else if (parent_ >= 0x40 && parent_ < 0x80) {
|
||||||
indexWorld = 0x21;
|
index_world = 0x21;
|
||||||
} else if (parent_ == 0x88) {
|
} else if (parent_ == 0x88) {
|
||||||
indexWorld = 36;
|
index_world = 36;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sprites Blocksets
|
// Sprites Blocksets
|
||||||
staticgfx[8] = 115 + 0;
|
static_graphics_[8] = 115 + 0;
|
||||||
staticgfx[9] = 115 + 1;
|
static_graphics_[9] = 115 + 1;
|
||||||
staticgfx[10] = 115 + 6;
|
static_graphics_[10] = 115 + 6;
|
||||||
staticgfx[11] = 115 + 7;
|
static_graphics_[11] = 115 + 7;
|
||||||
for (int i = 0; i < 4; i++) {
|
for (int i = 0; i < 4; i++) {
|
||||||
staticgfx[12 + i] =
|
static_graphics_[12 + i] =
|
||||||
(uchar)(rom_.data()[core::sprite_blockset_pointer +
|
(uchar)(rom_.data()[core::sprite_blockset_pointer +
|
||||||
(sprite_graphics_[gameState] * 4) + i] +
|
(sprite_graphics_[gameState] * 4) + i] +
|
||||||
115);
|
115);
|
||||||
@@ -174,45 +174,46 @@ void OverworldMap::BuildTileset(int gameState) {
|
|||||||
|
|
||||||
// Main Blocksets
|
// Main Blocksets
|
||||||
for (int i = 0; i < 8; i++) {
|
for (int i = 0; i < 8; i++) {
|
||||||
staticgfx[i] =
|
static_graphics_[i] =
|
||||||
rom_.data()[core::overworldgfxGroups2 + (indexWorld * 8) + i];
|
rom_.data()[core::overworldgfxGroups2 + (index_world * 8) + i];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rom_.data()[core::overworldgfxGroups + (area_graphics_ * 4)] != 0) {
|
if (rom_.data()[core::overworldgfxGroups + (area_graphics_ * 4)] != 0) {
|
||||||
staticgfx[3] = rom_.data()[core::overworldgfxGroups + (area_graphics_ * 4)];
|
static_graphics_[3] =
|
||||||
|
rom_.data()[core::overworldgfxGroups + (area_graphics_ * 4)];
|
||||||
}
|
}
|
||||||
if (rom_.data()[core::overworldgfxGroups + (area_graphics_ * 4) + 1] != 0) {
|
if (rom_.data()[core::overworldgfxGroups + (area_graphics_ * 4) + 1] != 0) {
|
||||||
staticgfx[4] =
|
static_graphics_[4] =
|
||||||
rom_.data()[core::overworldgfxGroups + (area_graphics_ * 4) + 1];
|
rom_.data()[core::overworldgfxGroups + (area_graphics_ * 4) + 1];
|
||||||
}
|
}
|
||||||
if (rom_.data()[core::overworldgfxGroups + (area_graphics_ * 4) + 2] != 0) {
|
if (rom_.data()[core::overworldgfxGroups + (area_graphics_ * 4) + 2] != 0) {
|
||||||
staticgfx[5] =
|
static_graphics_[5] =
|
||||||
rom_.data()[core::overworldgfxGroups + (area_graphics_ * 4) + 2];
|
rom_.data()[core::overworldgfxGroups + (area_graphics_ * 4) + 2];
|
||||||
}
|
}
|
||||||
if (rom_.data()[core::overworldgfxGroups + (area_graphics_ * 4) + 3] != 0) {
|
if (rom_.data()[core::overworldgfxGroups + (area_graphics_ * 4) + 3] != 0) {
|
||||||
staticgfx[6] =
|
static_graphics_[6] =
|
||||||
rom_.data()[core::overworldgfxGroups + (area_graphics_ * 4) + 3];
|
rom_.data()[core::overworldgfxGroups + (area_graphics_ * 4) + 3];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Hardcoded overworld GFX Values, for death mountain
|
// Hardcoded overworld GFX Values, for death mountain
|
||||||
if ((parent_ >= 0x03 && parent_ <= 0x07) ||
|
if ((parent_ >= 0x03 && parent_ <= 0x07) ||
|
||||||
(parent_ >= 0x0B && parent_ <= 0x0E)) {
|
(parent_ >= 0x0B && parent_ <= 0x0E)) {
|
||||||
staticgfx[7] = 89;
|
static_graphics_[7] = 89;
|
||||||
} else if ((parent_ >= 0x43 && parent_ <= 0x47) ||
|
} else if ((parent_ >= 0x43 && parent_ <= 0x47) ||
|
||||||
(parent_ >= 0x4B && parent_ <= 0x4E)) {
|
(parent_ >= 0x4B && parent_ <= 0x4E)) {
|
||||||
staticgfx[7] = 89;
|
static_graphics_[7] = 89;
|
||||||
} else {
|
} else {
|
||||||
staticgfx[7] = 91;
|
static_graphics_[7] = 91;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: PSEUDO VRAM DATA HERE
|
// TODO: PSEUDO VRAM DATA HERE
|
||||||
uchar* currentmapgfx8Data = rom_.GetVRAM().GetGraphicsData();
|
uchar* currentmapgfx8Data = rom_.GetVRAM().GetGraphicsData();
|
||||||
// TODO: PUT GRAPHICS DATA HERE
|
// TODO: PUT GRAPHICS DATA HERE
|
||||||
uchar const* allgfxData = rom_.GetMasterGraphicsBin();
|
uchar const* all_gfx_data = rom_.GetMasterGraphicsBin();
|
||||||
|
|
||||||
for (int i = 0; i < 16; i++) {
|
for (int i = 0; i < 16; i++) {
|
||||||
for (int j = 0; j < 2048; j++) {
|
for (int j = 0; j < 2048; j++) {
|
||||||
uchar mapByte = allgfxData[j + (staticgfx[i] * 2048)];
|
uchar mapByte = all_gfx_data[j + (static_graphics_[i] * 2048)];
|
||||||
switch (i) {
|
switch (i) {
|
||||||
case 0:
|
case 0:
|
||||||
case 3:
|
case 3:
|
||||||
@@ -235,8 +236,8 @@ void OverworldMap::BuildTiles16Gfx(int count) {
|
|||||||
auto yy = 0;
|
auto yy = 0;
|
||||||
auto xx = 0;
|
auto xx = 0;
|
||||||
|
|
||||||
for (auto i = 0; i < count; i++) // number of tiles16 3748?
|
// number of tiles16 3748?
|
||||||
{
|
for (auto i = 0; i < count; i++) {
|
||||||
// 8x8 tile draw
|
// 8x8 tile draw
|
||||||
// gfx8 = 4bpp so everyting is /2F
|
// gfx8 = 4bpp so everyting is /2F
|
||||||
auto tiles = tiles16_[i];
|
auto tiles = tiles16_[i];
|
||||||
@@ -259,6 +260,7 @@ 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,
|
||||||
@@ -311,9 +313,9 @@ void OverworldMap::CopyTileToMap(int x, int y, int xx, int yy, int offset,
|
|||||||
|
|
||||||
void OverworldMap::CopyTile8bpp16(int x, int y, int tile, uchar* destbmpPtr,
|
void OverworldMap::CopyTile8bpp16(int x, int y, int tile, uchar* destbmpPtr,
|
||||||
uchar* sourcebmpPtr) {
|
uchar* sourcebmpPtr) {
|
||||||
int sourcePtrPos = ((tile - ((tile / 8) * 8)) * 16) +
|
int source_ptr_pos = ((tile - ((tile / 8) * 8)) * 16) +
|
||||||
((tile / 8) * 2048); // (sourceX * 16) + (sourceY * 128)
|
((tile / 8) * 2048); // (sourceX * 16) + (sourceY * 128)
|
||||||
auto sourcePtr = sourcebmpPtr;
|
auto source_ptr = sourcebmpPtr;
|
||||||
|
|
||||||
int destPtrPos = (x + (y * 512));
|
int destPtrPos = (x + (y * 512));
|
||||||
auto destPtr = destbmpPtr;
|
auto destPtr = destbmpPtr;
|
||||||
@@ -321,7 +323,7 @@ void OverworldMap::CopyTile8bpp16(int x, int y, int tile, uchar* destbmpPtr,
|
|||||||
for (int ystrip = 0; ystrip < 16; ystrip++) {
|
for (int ystrip = 0; ystrip < 16; ystrip++) {
|
||||||
for (int xstrip = 0; xstrip < 16; xstrip++) {
|
for (int xstrip = 0; xstrip < 16; xstrip++) {
|
||||||
destPtr[destPtrPos + xstrip + (ystrip * 512)] =
|
destPtr[destPtrPos + xstrip + (ystrip * 512)] =
|
||||||
sourcePtr[sourcePtrPos + xstrip + (ystrip * 128)];
|
source_ptr[source_ptr_pos + xstrip + (ystrip * 128)];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,27 +37,26 @@ class OverworldMap {
|
|||||||
void CopyTile8bpp16From8(int xP, int yP, int tileID, uchar* destbmpPtr,
|
void CopyTile8bpp16From8(int xP, int yP, int tileID, uchar* destbmpPtr,
|
||||||
uchar* sourcebmpPtr);
|
uchar* sourcebmpPtr);
|
||||||
|
|
||||||
ROM rom_;
|
|
||||||
gfx::Bitmap gfxBitmap;
|
|
||||||
std::vector<gfx::Tile16> tiles16_;
|
|
||||||
|
|
||||||
uchar* staticgfx = new uchar[16];
|
|
||||||
std::vector<std::vector<ushort>> tiles_used_;
|
|
||||||
|
|
||||||
int parent_ = 0;
|
int parent_ = 0;
|
||||||
int index_ = 0;
|
int index_ = 0;
|
||||||
int message_id_ = 0;
|
int message_id_ = 0;
|
||||||
int area_graphics_ = 0;
|
int area_graphics_ = 0;
|
||||||
int area_palette_ = 0;
|
int area_palette_ = 0;
|
||||||
bool initialized_ = false;
|
|
||||||
bool large_map_ = false;
|
|
||||||
uchar sprite_graphics_[3];
|
uchar sprite_graphics_[3];
|
||||||
uchar sprite_palette_[3];
|
uchar sprite_palette_[3];
|
||||||
uchar area_music_[4];
|
uchar area_music_[4];
|
||||||
|
uchar static_graphics_[16];
|
||||||
|
|
||||||
uchar* gfxPtr = new uchar[512 * 512];
|
uchar* gfxPtr = new uchar[512 * 512];
|
||||||
uchar* mapblockset16_ = nullptr;
|
uchar* mapblockset16_ = nullptr;
|
||||||
uchar* currentOWgfx16Ptr_ = nullptr;
|
|
||||||
uchar* allGfx16Ptr_ = nullptr;
|
bool initialized_ = false;
|
||||||
|
bool large_map_ = false;
|
||||||
|
|
||||||
|
ROM rom_;
|
||||||
|
std::vector<gfx::Tile16> tiles16_;
|
||||||
|
std::vector<std::vector<ushort>> tiles_used_;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace zelda3
|
} // namespace zelda3
|
||||||
|
|||||||
Reference in New Issue
Block a user