refactor overworld data
This commit is contained in:
@@ -10,28 +10,13 @@ namespace zelda3 {
|
||||
using namespace core;
|
||||
using namespace gfx;
|
||||
|
||||
Overworld::~Overworld() {
|
||||
if (isLoaded) {
|
||||
for (int i = 0; i < (int)tiles32.size(); i++) {
|
||||
free(allmapsTilesLW[i]);
|
||||
free(allmapsTilesDW[i]);
|
||||
free(allmapsTilesSP[i]);
|
||||
}
|
||||
free(allmapsTilesLW);
|
||||
free(allmapsTilesDW);
|
||||
free(allmapsTilesSP);
|
||||
|
||||
delete[] overworldMapPointer;
|
||||
}
|
||||
}
|
||||
|
||||
static TileInfo GetTilesInfo(ushort tile) {
|
||||
// vhopppcc cccccccc
|
||||
ushort o = 0;
|
||||
ushort v = 0;
|
||||
ushort h = 0;
|
||||
ushort tid = (ushort)(tile & 0x3FF);
|
||||
uchar p = (uchar)((tile >> 10) & 0x07);
|
||||
auto tid = (ushort)(tile & 0x3FF);
|
||||
auto p = (uchar)((tile >> 10) & 0x07);
|
||||
|
||||
o = (ushort)((tile & 0x2000) >> 13);
|
||||
h = (ushort)((tile & 0x4000) >> 14);
|
||||
@@ -43,12 +28,6 @@ static TileInfo GetTilesInfo(ushort tile) {
|
||||
void Overworld::Load(app::rom::ROM& rom, uchar* allGfxPtr) {
|
||||
rom_ = rom;
|
||||
allGfx16Ptr = allGfxPtr;
|
||||
for (int i = 0; i < 0x2B; i++) {
|
||||
tileLeftEntrance.push_back(constants::overworldEntranceAllowedTilesLeft +
|
||||
(i * 2));
|
||||
tileRightEntrance.push_back(constants::overworldEntranceAllowedTilesRight +
|
||||
(i * 2));
|
||||
}
|
||||
|
||||
AssembleMap32Tiles();
|
||||
AssembleMap16Tiles();
|
||||
@@ -56,7 +35,7 @@ void Overworld::Load(app::rom::ROM& rom, uchar* allGfxPtr) {
|
||||
|
||||
// Map Initialization
|
||||
for (int i = 0; i < constants::NumberOfOWMaps; i++) {
|
||||
overworld_maps_.push_back(OverworldMap(rom_, tiles16, i));
|
||||
overworld_maps_.emplace_back(rom_, tiles16, i);
|
||||
}
|
||||
FetchLargeMaps();
|
||||
LoadOverworldMap();
|
||||
@@ -65,16 +44,17 @@ void Overworld::Load(app::rom::ROM& rom, uchar* allGfxPtr) {
|
||||
for (int i = 0; i < 160; i++) {
|
||||
overworld_maps_[i].BuildMap(mapParent, size, gameState, allmapsTilesLW,
|
||||
allmapsTilesDW, allmapsTilesSP,
|
||||
currentOWgfx16Ptr, allGfx16Ptr, mapblockset16);
|
||||
currentOWgfx16Ptr.get(), allGfx16Ptr,
|
||||
mapblockset16.get());
|
||||
}
|
||||
|
||||
isLoaded = true;
|
||||
}
|
||||
|
||||
ushort Overworld::GenerateTile32(int i, int k, int dimension) {
|
||||
return (ushort)(rom_.GetRawData()[map32address[dimension] + k + (i)] +
|
||||
(((rom_.GetRawData()[map32address[dimension] + (i) +
|
||||
(k <= 1 ? 4 : 5)] >>
|
||||
return (ushort)(rom_.data()[map32address[dimension] + k + (i)] +
|
||||
(((rom_.data()[map32address[dimension] + (i) +
|
||||
(k <= 1 ? 4 : 5)] >>
|
||||
(k % 2 == 0 ? 4 : 0)) &
|
||||
0x0F) *
|
||||
256));
|
||||
@@ -92,22 +72,19 @@ void Overworld::AssembleMap32Tiles() {
|
||||
}
|
||||
}
|
||||
|
||||
allmapsTilesLW = (ushort**)malloc(tiles32.size() * sizeof(ushort*));
|
||||
for (int i = 0; i < tiles32.size(); i++)
|
||||
allmapsTilesLW[i] = (ushort*)malloc(tiles32.size() * sizeof(ushort));
|
||||
|
||||
allmapsTilesDW = (ushort**)malloc(tiles32.size() * sizeof(ushort*));
|
||||
for (int i = 0; i < tiles32.size(); i++)
|
||||
allmapsTilesDW[i] = (ushort*)malloc(tiles32.size() * sizeof(ushort));
|
||||
|
||||
allmapsTilesSP = (ushort**)malloc(tiles32.size() * sizeof(ushort*));
|
||||
for (int i = 0; i < tiles32.size(); i++)
|
||||
allmapsTilesSP[i] = (ushort*)malloc(tiles32.size() * sizeof(ushort));
|
||||
allmapsTilesLW.resize(tiles32.size());
|
||||
allmapsTilesDW.resize(tiles32.size());
|
||||
allmapsTilesSP.resize(tiles32.size());
|
||||
for (int i = 0; i < tiles32.size(); i++) {
|
||||
allmapsTilesLW[i].resize(tiles32.size());
|
||||
allmapsTilesDW[i].resize(tiles32.size());
|
||||
allmapsTilesSP[i].resize(tiles32.size());
|
||||
}
|
||||
}
|
||||
|
||||
void Overworld::AssembleMap16Tiles() {
|
||||
int tpos = core::constants::map16Tiles;
|
||||
auto rom_data = rom_.GetRawData();
|
||||
auto rom_data = rom_.data();
|
||||
for (int i = 0; i < 4096; i += 1) // 3760
|
||||
{
|
||||
TileInfo t0 = GetTilesInfo((uintptr_t)(rom_data + tpos));
|
||||
@@ -118,7 +95,7 @@ void Overworld::AssembleMap16Tiles() {
|
||||
tpos += 2;
|
||||
TileInfo t3 = GetTilesInfo((uintptr_t)(rom_data + tpos));
|
||||
tpos += 2;
|
||||
tiles16.push_back(Tile16(t0, t1, t2, t3));
|
||||
tiles16.emplace_back(t0, t1, t2, t3);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -129,26 +106,22 @@ void Overworld::DecompressAllMapTiles() {
|
||||
int sy = 0;
|
||||
int c = 0;
|
||||
for (int i = 0; i < 160; i++) {
|
||||
int p1 = (rom_.GetRawData()[(constants::compressedAllMap32PointersHigh) +
|
||||
2 + (int)(3 * i)]
|
||||
<< 16) +
|
||||
(rom_.GetRawData()[(constants::compressedAllMap32PointersHigh) +
|
||||
1 + (int)(3 * i)]
|
||||
<< 8) +
|
||||
(rom_.GetRawData()[(constants::compressedAllMap32PointersHigh +
|
||||
(int)(3 * i))]);
|
||||
int p1 =
|
||||
(rom_.data()[(constants::compressedAllMap32PointersHigh) + 2 + (3 * i)]
|
||||
<< 16) +
|
||||
(rom_.data()[(constants::compressedAllMap32PointersHigh) + 1 + (3 * i)]
|
||||
<< 8) +
|
||||
(rom_.data()[(constants::compressedAllMap32PointersHigh + (3 * i))]);
|
||||
|
||||
char* tmp = new char[256];
|
||||
auto* tmp = new char[256];
|
||||
p1 = lorom_snes_to_pc(p1, &tmp);
|
||||
std::cout << tmp << std::endl;
|
||||
int p2 = (rom_.GetRawData()[(constants::compressedAllMap32PointersLow) + 2 +
|
||||
(int)(3 * i)]
|
||||
<< 16) +
|
||||
(rom_.GetRawData()[(constants::compressedAllMap32PointersLow) + 1 +
|
||||
(int)(3 * i)]
|
||||
<< 8) +
|
||||
(rom_.GetRawData()[(constants::compressedAllMap32PointersLow +
|
||||
(int)(3 * i))]);
|
||||
int p2 =
|
||||
(rom_.data()[(constants::compressedAllMap32PointersLow) + 2 + (3 * i)]
|
||||
<< 16) +
|
||||
(rom_.data()[(constants::compressedAllMap32PointersLow) + 1 + (3 * i)]
|
||||
<< 8) +
|
||||
(rom_.data()[(constants::compressedAllMap32PointersLow + (3 * i))]);
|
||||
p2 = lorom_snes_to_pc(p2, &tmp);
|
||||
std::cout << tmp << std::endl;
|
||||
delete[] tmp;
|
||||
@@ -166,23 +139,17 @@ void Overworld::DecompressAllMapTiles() {
|
||||
highest = p2;
|
||||
}
|
||||
|
||||
if (p1 <= lowest) {
|
||||
if (p1 > 0x0F8000) {
|
||||
lowest = p1;
|
||||
}
|
||||
if (p1 <= lowest && p1 > 0x0F8000) {
|
||||
lowest = p1;
|
||||
}
|
||||
if (p2 <= lowest) {
|
||||
if (p2 > 0x0F8000) {
|
||||
lowest = p2;
|
||||
}
|
||||
if (p2 <= lowest && p2 > 0x0F8000) {
|
||||
lowest = p2;
|
||||
}
|
||||
|
||||
auto bytes =
|
||||
alttp_decompress_overworld((char*)rom_.GetRawData(), p2, 1000,
|
||||
&compressedSize1, &compressedLength1);
|
||||
auto bytes2 =
|
||||
alttp_decompress_overworld((char*)rom_.GetRawData(), p1, 1000,
|
||||
&compressedSize2, &compressedLength2);
|
||||
auto bytes = alttp_decompress_overworld(
|
||||
(char*)rom_.data(), p2, 1000, &compressedSize1, &compressedLength1);
|
||||
auto bytes2 = alttp_decompress_overworld(
|
||||
(char*)rom_.data(), p1, 1000, &compressedSize2, &compressedLength2);
|
||||
|
||||
for (int y = 0; y < 16; y++) {
|
||||
for (int x = 0; x < 16; x++) {
|
||||
@@ -256,8 +223,8 @@ void Overworld::FetchLargeMaps() {
|
||||
overworld_maps_[136].large_map_ = false;
|
||||
|
||||
bool mapChecked[64];
|
||||
for (int i = 0; i < 64; i++) {
|
||||
mapChecked[i] = false;
|
||||
for (auto& each : mapChecked) {
|
||||
each = false;
|
||||
}
|
||||
int xx = 0;
|
||||
int yy = 0;
|
||||
@@ -300,7 +267,7 @@ void Overworld::FetchLargeMaps() {
|
||||
}
|
||||
|
||||
void Overworld::LoadOverworldMap() {
|
||||
overworldMapBitmap.Create(128, 128, 8, overworldMapPointer);
|
||||
overworldMapBitmap.Create(128, 128, 8, overworldMapPointer.get());
|
||||
|
||||
auto ptr = overworldMapPointer;
|
||||
|
||||
@@ -310,7 +277,7 @@ void Overworld::LoadOverworldMap() {
|
||||
for (int y = 0; y < 8; y++) {
|
||||
for (int x = 0; x < 8; x++) {
|
||||
ptr[x + (sx * 8) + (y * 128) + (sy * 1024)] =
|
||||
rom_.GetRawData()[0x0C4000 + pos];
|
||||
rom_.data()[0x0C4000 + pos];
|
||||
pos++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,15 +19,12 @@ namespace zelda3 {
|
||||
|
||||
class Overworld {
|
||||
public:
|
||||
Overworld() = default;
|
||||
~Overworld();
|
||||
|
||||
void Load(app::rom::ROM& rom, uchar* allGfxPtr);
|
||||
inline auto GetTiles16() const { return tiles16; }
|
||||
inline auto GetCurrentGfxSetPtr() { return currentOWgfx16Ptr; }
|
||||
inline auto GetMapBlockset16Ptr() { return mapblockset16; }
|
||||
|
||||
uchar* overworldMapPointer = new uchar[0x40000];
|
||||
std::shared_ptr<uchar[]> overworldMapPointer = std::make_shared<uchar>(0x40000);
|
||||
gfx::Bitmap overworldMapBitmap;
|
||||
|
||||
private:
|
||||
@@ -43,17 +40,14 @@ class Overworld {
|
||||
bool isLoaded = false;
|
||||
uchar mapParent[160];
|
||||
|
||||
ushort** allmapsTilesLW; // 64 maps * (32*32 tiles)
|
||||
ushort** allmapsTilesDW; // 64 maps * (32*32 tiles)
|
||||
ushort** allmapsTilesSP; // 32 maps * (32*32 tiles)
|
||||
|
||||
std::vector<ushort> tileLeftEntrance;
|
||||
std::vector<ushort> tileRightEntrance;
|
||||
std::vector<std::vector<ushort>> allmapsTilesLW; // 64 maps * (32*32 tiles)
|
||||
std::vector<std::vector<ushort>> allmapsTilesDW; // 64 maps * (32*32 tiles)
|
||||
std::vector<std::vector<ushort>> allmapsTilesSP; // 32 maps * (32*32 tiles)
|
||||
|
||||
uchar* allGfx16Ptr = nullptr;
|
||||
uchar* mapblockset16 = new uchar[1048576];
|
||||
uchar* currentOWgfx16Ptr = new uchar[(128 * 512) / 2];
|
||||
SDL_Texture* overworld_map_texture;
|
||||
std::shared_ptr<uchar[]> mapblockset16 = std::make_shared<uchar>(1048576);
|
||||
std::shared_ptr<uchar[]> currentOWgfx16Ptr =
|
||||
std::make_shared<uchar>((128 * 512) / 2);
|
||||
|
||||
std::vector<gfx::Tile16> tiles16;
|
||||
std::vector<gfx::Tile32> tiles32;
|
||||
|
||||
@@ -15,54 +15,48 @@ using namespace core;
|
||||
using namespace gfx;
|
||||
|
||||
OverworldMap::OverworldMap(app::rom::ROM& rom,
|
||||
const std::vector<gfx::Tile16> tiles16, int index_)
|
||||
: rom_(rom), index_(index_), tiles16_(tiles16), parent_(index_) {
|
||||
if (index_ != 0x80) {
|
||||
if (index_ <= 150) {
|
||||
if (rom_.GetRawData()[constants::overworldMapSize + (index_ & 0x3F)] !=
|
||||
0) {
|
||||
large_map_ = true;
|
||||
}
|
||||
}
|
||||
const std::vector<gfx::Tile16>& tiles16, int index_)
|
||||
: parent_(index_), index_(index_), rom_(rom), tiles16_(tiles16) {
|
||||
if (index_ != 0x80 && index_ <= 150 &&
|
||||
rom_.data()[constants::overworldMapSize + (index_ & 0x3F)] != 0) {
|
||||
large_map_ = true;
|
||||
}
|
||||
|
||||
if (index_ < 64) {
|
||||
sprite_graphics_[0] =
|
||||
rom_.GetRawData()[constants::overworldSpriteset + parent_];
|
||||
sprite_graphics_[0] = rom_.data()[constants::overworldSpriteset + parent_];
|
||||
sprite_graphics_[1] =
|
||||
rom_.GetRawData()[constants::overworldSpriteset + parent_ + 64];
|
||||
rom_.data()[constants::overworldSpriteset + parent_ + 64];
|
||||
sprite_graphics_[2] =
|
||||
rom_.GetRawData()[constants::overworldSpriteset + parent_ + 128];
|
||||
gfx_ = rom_.GetRawData()[constants::mapGfx + parent_];
|
||||
palette_ = rom_.GetRawData()[constants::overworldMapPalette + parent_];
|
||||
rom_.data()[constants::overworldSpriteset + parent_ + 128];
|
||||
gfx_ = rom_.data()[constants::mapGfx + parent_];
|
||||
palette_ = rom_.data()[constants::overworldMapPalette + parent_];
|
||||
sprite_palette_[0] =
|
||||
rom_.GetRawData()[constants::overworldSpritePalette + parent_];
|
||||
rom_.data()[constants::overworldSpritePalette + parent_];
|
||||
sprite_palette_[1] =
|
||||
rom_.GetRawData()[constants::overworldSpritePalette + parent_ + 64];
|
||||
rom_.data()[constants::overworldSpritePalette + parent_ + 64];
|
||||
sprite_palette_[2] =
|
||||
rom_.GetRawData()[constants::overworldSpritePalette + parent_ + 128];
|
||||
musics[0] = rom_.GetRawData()[constants::overworldMusicBegining + parent_];
|
||||
musics[1] = rom_.GetRawData()[constants::overworldMusicZelda + parent_];
|
||||
musics[2] =
|
||||
rom_.GetRawData()[constants::overworldMusicMasterSword + parent_];
|
||||
musics[3] = rom_.GetRawData()[constants::overworldMusicAgahim + parent_];
|
||||
rom_.data()[constants::overworldSpritePalette + parent_ + 128];
|
||||
musics[0] = rom_.data()[constants::overworldMusicBegining + parent_];
|
||||
musics[1] = rom_.data()[constants::overworldMusicZelda + parent_];
|
||||
musics[2] = rom_.data()[constants::overworldMusicMasterSword + parent_];
|
||||
musics[3] = rom_.data()[constants::overworldMusicAgahim + parent_];
|
||||
} else if (index_ < 128) {
|
||||
sprite_graphics_[0] =
|
||||
rom_.GetRawData()[constants::overworldSpriteset + parent_ + 128];
|
||||
rom_.data()[constants::overworldSpriteset + parent_ + 128];
|
||||
sprite_graphics_[1] =
|
||||
rom_.GetRawData()[constants::overworldSpriteset + parent_ + 128];
|
||||
rom_.data()[constants::overworldSpriteset + parent_ + 128];
|
||||
sprite_graphics_[2] =
|
||||
rom_.GetRawData()[constants::overworldSpriteset + parent_ + 128];
|
||||
gfx_ = rom_.GetRawData()[constants::mapGfx + parent_];
|
||||
palette_ = rom_.GetRawData()[constants::overworldMapPalette + parent_];
|
||||
rom_.data()[constants::overworldSpriteset + parent_ + 128];
|
||||
gfx_ = rom_.data()[constants::mapGfx + parent_];
|
||||
palette_ = rom_.data()[constants::overworldMapPalette + parent_];
|
||||
sprite_palette_[0] =
|
||||
rom_.GetRawData()[constants::overworldSpritePalette + parent_ + 128];
|
||||
rom_.data()[constants::overworldSpritePalette + parent_ + 128];
|
||||
sprite_palette_[1] =
|
||||
rom_.GetRawData()[constants::overworldSpritePalette + parent_ + 128];
|
||||
rom_.data()[constants::overworldSpritePalette + parent_ + 128];
|
||||
sprite_palette_[2] =
|
||||
rom_.GetRawData()[constants::overworldSpritePalette + parent_ + 128];
|
||||
rom_.data()[constants::overworldSpritePalette + parent_ + 128];
|
||||
|
||||
musics[0] = rom_.GetRawData()[constants::overworldMusicDW + (parent_ - 64)];
|
||||
musics[0] = rom_.data()[constants::overworldMusicDW + (parent_ - 64)];
|
||||
} else {
|
||||
if (index_ == 0x94) {
|
||||
parent_ = 128;
|
||||
@@ -86,69 +80,63 @@ OverworldMap::OverworldMap(app::rom::ROM& rom,
|
||||
parent_ = 136;
|
||||
}
|
||||
|
||||
message_id_ = rom_.GetRawData()[constants::overworldMessages + parent_];
|
||||
message_id_ = rom_.data()[constants::overworldMessages + parent_];
|
||||
|
||||
sprite_graphics_[0] =
|
||||
rom_.GetRawData()[constants::overworldSpriteset + parent_ + 128];
|
||||
rom_.data()[constants::overworldSpriteset + parent_ + 128];
|
||||
sprite_graphics_[1] =
|
||||
rom_.GetRawData()[constants::overworldSpriteset + parent_ + 128];
|
||||
rom_.data()[constants::overworldSpriteset + parent_ + 128];
|
||||
sprite_graphics_[2] =
|
||||
rom_.GetRawData()[constants::overworldSpriteset + parent_ + 128];
|
||||
rom_.data()[constants::overworldSpriteset + parent_ + 128];
|
||||
sprite_palette_[0] =
|
||||
rom_.GetRawData()[constants::overworldSpritePalette + parent_ + 128];
|
||||
rom_.data()[constants::overworldSpritePalette + parent_ + 128];
|
||||
sprite_palette_[1] =
|
||||
rom_.GetRawData()[constants::overworldSpritePalette + parent_ + 128];
|
||||
rom_.data()[constants::overworldSpritePalette + parent_ + 128];
|
||||
sprite_palette_[2] =
|
||||
rom_.GetRawData()[constants::overworldSpritePalette + parent_ + 128];
|
||||
rom_.data()[constants::overworldSpritePalette + parent_ + 128];
|
||||
|
||||
palette_ =
|
||||
rom_.GetRawData()[constants::overworldSpecialPALGroup + parent_ - 128];
|
||||
palette_ = rom_.data()[constants::overworldSpecialPALGroup + parent_ - 128];
|
||||
if (index_ >= 0x80 && index_ <= 0x8A && index_ != 0x88) {
|
||||
gfx_ = rom_.GetRawData()[constants::overworldSpecialGFXGroup +
|
||||
(parent_ - 128)];
|
||||
palette_ = rom_.GetRawData()[constants::overworldSpecialPALGroup + 1];
|
||||
gfx_ = rom_.data()[constants::overworldSpecialGFXGroup + (parent_ - 128)];
|
||||
palette_ = rom_.data()[constants::overworldSpecialPALGroup + 1];
|
||||
} else if (index_ == 0x88) {
|
||||
gfx_ = 81;
|
||||
palette_ = 0;
|
||||
} else // pyramid bg use 0x5B map
|
||||
{
|
||||
gfx_ = rom_.GetRawData()[constants::mapGfx + parent_];
|
||||
palette_ = rom_.GetRawData()[constants::overworldMapPalette + parent_];
|
||||
gfx_ = rom_.data()[constants::mapGfx + parent_];
|
||||
palette_ = rom_.data()[constants::overworldMapPalette + parent_];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void OverworldMap::BuildMap(uchar* mapparent_, int count, int gameState,
|
||||
ushort** allmapsTilesLW, ushort** allmapsTilesDW,
|
||||
ushort** allmapsTilesSP, uchar* currentOWgfx16Ptr,
|
||||
uchar* allGfxPtr, uchar* mapblockset16) {
|
||||
tilesUsed = new ushort*[32];
|
||||
std::vector<std::vector<ushort>>& allmapsTilesLW,
|
||||
std::vector<std::vector<ushort>>& allmapsTilesDW,
|
||||
std::vector<std::vector<ushort>>& allmapsTilesSP,
|
||||
uchar* currentOWgfx16Ptr, uchar* allGfxPtr,
|
||||
uchar* mapblockset16) {
|
||||
currentOWgfx16Ptr_ = currentOWgfx16Ptr;
|
||||
allGfx16Ptr_ = allGfxPtr;
|
||||
mapblockset16_ = mapblockset16;
|
||||
for (int i = 0; i < 32; i++) tilesUsed[i] = new ushort;
|
||||
|
||||
if (large_map_) {
|
||||
this->parent_ = mapparent_[index_];
|
||||
|
||||
if (parent_ != index_) {
|
||||
if (!initialized_) {
|
||||
if (index_ >= 0x80 && index_ <= 0x8A && index_ != 0x88) {
|
||||
gfx_ = rom_.GetRawData()[core::constants::overworldSpecialGFXGroup +
|
||||
(parent_ - 128)];
|
||||
palette_ =
|
||||
rom_.GetRawData()[core::constants::overworldSpecialPALGroup + 1];
|
||||
} else if (index_ == 0x88) {
|
||||
gfx_ = 81;
|
||||
palette_ = 0;
|
||||
} else {
|
||||
gfx_ = rom_.GetRawData()[core::constants::mapGfx + parent_];
|
||||
palette_ =
|
||||
rom_.GetRawData()[core::constants::overworldMapPalette + parent_];
|
||||
}
|
||||
|
||||
initialized_ = true;
|
||||
if (parent_ != index_ && !initialized_) {
|
||||
if (index_ >= 0x80 && index_ <= 0x8A && index_ != 0x88) {
|
||||
gfx_ = rom_.data()[core::constants::overworldSpecialGFXGroup +
|
||||
(parent_ - 128)];
|
||||
palette_ = rom_.data()[core::constants::overworldSpecialPALGroup + 1];
|
||||
} else if (index_ == 0x88) {
|
||||
gfx_ = 81;
|
||||
palette_ = 0;
|
||||
} else {
|
||||
gfx_ = rom_.data()[core::constants::mapGfx + parent_];
|
||||
palette_ = rom_.data()[core::constants::overworldMapPalette + parent_];
|
||||
}
|
||||
|
||||
initialized_ = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -158,12 +146,12 @@ void OverworldMap::BuildMap(uchar* mapparent_, int count, int gameState,
|
||||
int world = 0;
|
||||
|
||||
if (index_ < 64) {
|
||||
tilesUsed = allmapsTilesLW;
|
||||
tiles_used_ = allmapsTilesLW;
|
||||
} else if (index_ < 128 && index_ >= 64) {
|
||||
tilesUsed = allmapsTilesDW;
|
||||
tiles_used_ = allmapsTilesDW;
|
||||
world = 1;
|
||||
} else {
|
||||
tilesUsed = allmapsTilesSP;
|
||||
tiles_used_ = allmapsTilesSP;
|
||||
world = 2;
|
||||
}
|
||||
|
||||
@@ -173,7 +161,7 @@ void OverworldMap::BuildMap(uchar* mapparent_, int count, int gameState,
|
||||
for (int y = 0; y < 32; y++) {
|
||||
for (int x = 0; x < 32; x++) {
|
||||
CopyTile8bpp16((x * 16), (y * 16),
|
||||
tilesUsed[x + (superX * 32)][y + (superY * 32)], gfxPtr,
|
||||
tiles_used_[x + (superX * 32)][y + (superY * 32)], gfxPtr,
|
||||
mapblockset16);
|
||||
}
|
||||
}
|
||||
@@ -181,10 +169,8 @@ void OverworldMap::BuildMap(uchar* mapparent_, int count, int gameState,
|
||||
|
||||
void OverworldMap::CopyTile8bpp16(int x, int y, int tile, uchar* destbmpPtr,
|
||||
uchar* sourcebmpPtr) {
|
||||
int sourceY = (tile / 8);
|
||||
int sourceX = (tile) - ((sourceY)*8);
|
||||
int sourcePtrPos = ((tile - ((tile / 8) * 8)) * 16) +
|
||||
((tile / 8) * 2048); //(sourceX * 16) + (sourceY * 128);
|
||||
((tile / 8) * 2048); // (sourceX * 16) + (sourceY * 128)
|
||||
auto sourcePtr = sourcebmpPtr;
|
||||
|
||||
int destPtrPos = (x + (y * 512));
|
||||
@@ -252,10 +238,10 @@ void OverworldMap::BuildTiles16Gfx(int count) {
|
||||
}
|
||||
}
|
||||
|
||||
// map,current
|
||||
void OverworldMap::CopyTile(int x, int y, int xx, int yy, int offset,
|
||||
TileInfo tile, uchar* gfx16Pointer,
|
||||
uchar* gfx8Pointer) // map,current
|
||||
{
|
||||
uchar* gfx8Pointer) {
|
||||
int mx = x;
|
||||
int my = y;
|
||||
uchar r = 0;
|
||||
@@ -270,18 +256,17 @@ void OverworldMap::CopyTile(int x, int y, int xx, int yy, int offset,
|
||||
}
|
||||
|
||||
int tx = ((tile.id_ / 16) * 512) + ((tile.id_ - ((tile.id_ / 16) * 16)) * 4);
|
||||
auto index_ = xx + yy + offset + (mx * 2) + (my * 128);
|
||||
auto index = xx + yy + offset + (mx * 2) + (my * 128);
|
||||
auto pixel = gfx8Pointer[tx + (y * 64) + x];
|
||||
|
||||
gfx16Pointer[index_ + r ^ 1] = (uchar)((pixel & 0x0F) + tile.palette_ * 16);
|
||||
gfx16Pointer[index_ + r] =
|
||||
(uchar)(((pixel >> 4) & 0x0F) + tile.palette_ * 16);
|
||||
gfx16Pointer[index + r ^ 1] = (uchar)((pixel & 0x0F) + tile.palette_ * 16);
|
||||
gfx16Pointer[index + r] = (uchar)(((pixel >> 4) & 0x0F) + tile.palette_ * 16);
|
||||
}
|
||||
|
||||
// map,current
|
||||
void OverworldMap::CopyTileToMap(int x, int y, int xx, int yy, int offset,
|
||||
TileInfo tile, uchar* gfx16Pointer,
|
||||
uchar* gfx8Pointer) // map,current
|
||||
{
|
||||
uchar* gfx8Pointer) {
|
||||
int mx = x;
|
||||
int my = y;
|
||||
uchar r = 0;
|
||||
@@ -320,32 +305,28 @@ void OverworldMap::BuildTileset(int gameState) {
|
||||
staticgfx[11] = 115 + 7;
|
||||
for (int i = 0; i < 4; i++) {
|
||||
staticgfx[12 + i] =
|
||||
(uchar)(rom_.GetRawData()[constants::sprite_blockset_pointer +
|
||||
(sprite_graphics_[gameState] * 4) + i] +
|
||||
(uchar)(rom_.data()[constants::sprite_blockset_pointer +
|
||||
(sprite_graphics_[gameState] * 4) + i] +
|
||||
115);
|
||||
}
|
||||
|
||||
// Main Blocksets
|
||||
for (int i = 0; i < 8; i++) {
|
||||
staticgfx[i] = rom_.GetRawData()[constants::overworldgfxGroups2 +
|
||||
(indexWorld * 8) + i];
|
||||
staticgfx[i] =
|
||||
rom_.data()[constants::overworldgfxGroups2 + (indexWorld * 8) + i];
|
||||
}
|
||||
|
||||
if (rom_.GetRawData()[constants::overworldgfxGroups + (gfx_ * 4)] != 0) {
|
||||
staticgfx[3] =
|
||||
rom_.GetRawData()[constants::overworldgfxGroups + (gfx_ * 4)];
|
||||
if (rom_.data()[constants::overworldgfxGroups + (gfx_ * 4)] != 0) {
|
||||
staticgfx[3] = rom_.data()[constants::overworldgfxGroups + (gfx_ * 4)];
|
||||
}
|
||||
if (rom_.GetRawData()[constants::overworldgfxGroups + (gfx_ * 4) + 1] != 0) {
|
||||
staticgfx[4] =
|
||||
rom_.GetRawData()[constants::overworldgfxGroups + (gfx_ * 4) + 1];
|
||||
if (rom_.data()[constants::overworldgfxGroups + (gfx_ * 4) + 1] != 0) {
|
||||
staticgfx[4] = rom_.data()[constants::overworldgfxGroups + (gfx_ * 4) + 1];
|
||||
}
|
||||
if (rom_.GetRawData()[constants::overworldgfxGroups + (gfx_ * 4) + 2] != 0) {
|
||||
staticgfx[5] =
|
||||
rom_.GetRawData()[constants::overworldgfxGroups + (gfx_ * 4) + 2];
|
||||
if (rom_.data()[constants::overworldgfxGroups + (gfx_ * 4) + 2] != 0) {
|
||||
staticgfx[5] = rom_.data()[constants::overworldgfxGroups + (gfx_ * 4) + 2];
|
||||
}
|
||||
if (rom_.GetRawData()[constants::overworldgfxGroups + (gfx_ * 4) + 3] != 0) {
|
||||
staticgfx[6] =
|
||||
rom_.GetRawData()[constants::overworldgfxGroups + (gfx_ * 4) + 3];
|
||||
if (rom_.data()[constants::overworldgfxGroups + (gfx_ * 4) + 3] != 0) {
|
||||
staticgfx[6] = rom_.data()[constants::overworldgfxGroups + (gfx_ * 4) + 3];
|
||||
}
|
||||
|
||||
// Hardcoded overworld GFX Values, for death mountain
|
||||
@@ -360,7 +341,7 @@ void OverworldMap::BuildTileset(int gameState) {
|
||||
}
|
||||
|
||||
uchar* currentmapgfx8Data = currentOWgfx16Ptr_;
|
||||
uchar* allgfxData = allGfx16Ptr_;
|
||||
uchar const* allgfxData = allGfx16Ptr_;
|
||||
|
||||
for (int i = 0; i < 16; i++) {
|
||||
for (int j = 0; j < 2048; j++) {
|
||||
|
||||
@@ -35,14 +35,16 @@ class OverworldMap {
|
||||
std::vector<gfx::Tile16> tiles16_;
|
||||
|
||||
uchar* staticgfx = new uchar[16];
|
||||
ushort** tilesUsed;
|
||||
std::vector<std::vector<ushort>> tiles_used_;
|
||||
|
||||
OverworldMap(app::rom::ROM& rom, const std::vector<gfx::Tile16> tiles16,
|
||||
OverworldMap(app::rom::ROM& rom, const std::vector<gfx::Tile16>& tiles16,
|
||||
int index);
|
||||
void BuildMap(uchar* mapParent, int count, int gameState,
|
||||
ushort** allmapsTilesLW, ushort** allmapsTilesDW,
|
||||
ushort** allmapsTilesSP, uchar* currentOWgfx16Ptr,
|
||||
uchar* allGfxPtr, uchar* mapblockset16);
|
||||
std::vector<std::vector<ushort>>& allmapsTilesLW,
|
||||
std::vector<std::vector<ushort>>& allmapsTilesDW,
|
||||
std::vector<std::vector<ushort>>& allmapsTilesSP,
|
||||
uchar* currentOWgfx16Ptr, uchar* allGfxPtr,
|
||||
uchar* mapblockset16);
|
||||
void CopyTile8bpp16(int x, int y, int tile, uchar* destbmpPtr,
|
||||
uchar* sourcebmpPtr);
|
||||
void CopyTile8bpp16From8(int xP, int yP, int tileID, uchar* destbmpPtr,
|
||||
|
||||
Reference in New Issue
Block a user