Update BuildMap with OWMapTiles structure
This commit is contained in:
@@ -8,12 +8,10 @@ namespace app {
|
||||
namespace zelda3 {
|
||||
|
||||
using namespace core;
|
||||
using namespace gfx;
|
||||
|
||||
void Overworld::Load(ROM& rom) {
|
||||
rom_ = rom;
|
||||
mapblockset16.Create(128, 8192, 8, 1048576);
|
||||
currentOWgfx16.Create(128, 512, 4, (128 * 512) / 2);
|
||||
|
||||
AssembleMap32Tiles();
|
||||
AssembleMap16Tiles();
|
||||
@@ -28,7 +26,7 @@ void Overworld::Load(ROM& rom) {
|
||||
|
||||
auto size = tiles16.size();
|
||||
for (int i = 0; i < constants::NumberOfOWMaps; i++) {
|
||||
overworld_maps_[i].BuildMap(mapParent, size, gameState, map_tiles_);
|
||||
overworld_maps_[i].BuildMap(size, gameState, mapParent, map_tiles_);
|
||||
}
|
||||
|
||||
isLoaded = true;
|
||||
@@ -51,7 +49,7 @@ void Overworld::AssembleMap32Tiles() {
|
||||
tr = GenerateTile32(i, k, (int)Dimension::map32TilesTR);
|
||||
bl = GenerateTile32(i, k, (int)Dimension::map32TilesBL);
|
||||
br = GenerateTile32(i, k, (int)Dimension::map32TilesBR);
|
||||
tiles32.push_back(Tile32(tl, tr, bl, br));
|
||||
tiles32.push_back(gfx::Tile32(tl, tr, bl, br));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,13 +68,13 @@ void Overworld::AssembleMap16Tiles() {
|
||||
auto rom_data = rom_.data();
|
||||
for (int i = 0; i < 4096; i += 1) // 3760
|
||||
{
|
||||
TileInfo t0 = GetTilesInfo((uintptr_t)(rom_data + tpos));
|
||||
gfx::TileInfo t0 = gfx::GetTilesInfo((uintptr_t)(rom_data + tpos));
|
||||
tpos += 2;
|
||||
TileInfo t1 = GetTilesInfo((uintptr_t)(rom_data + tpos));
|
||||
gfx::TileInfo t1 = gfx::GetTilesInfo((uintptr_t)(rom_data + tpos));
|
||||
tpos += 2;
|
||||
TileInfo t2 = GetTilesInfo((uintptr_t)(rom_data + tpos));
|
||||
gfx::TileInfo t2 = gfx::GetTilesInfo((uintptr_t)(rom_data + tpos));
|
||||
tpos += 2;
|
||||
TileInfo t3 = GetTilesInfo((uintptr_t)(rom_data + tpos));
|
||||
gfx::TileInfo t3 = gfx::GetTilesInfo((uintptr_t)(rom_data + tpos));
|
||||
tpos += 2;
|
||||
tiles16.emplace_back(t0, t1, t2, t3);
|
||||
}
|
||||
@@ -89,21 +87,16 @@ void Overworld::DecompressAllMapTiles() {
|
||||
int sy = 0;
|
||||
int c = 0;
|
||||
for (int i = 0; i < 160; 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))]);
|
||||
|
||||
int map_high_ptr = constants::compressedAllMap32PointersHigh;
|
||||
int p1 = (rom_.data()[(map_high_ptr) + 2 + (3 * i)] << 16) +
|
||||
(rom_.data()[(map_high_ptr) + 1 + (3 * i)] << 8) +
|
||||
(rom_.data()[(map_high_ptr + (3 * i))]);
|
||||
p1 = SnesToPc(p1);
|
||||
int p2 =
|
||||
(rom_.data()[(constants::compressedAllMap32PointersLow) + 2 + (3 * i)]
|
||||
<< 16) +
|
||||
(rom_.data()[(constants::compressedAllMap32PointersLow) + 1 + (3 * i)]
|
||||
<< 8) +
|
||||
(rom_.data()[(constants::compressedAllMap32PointersLow + (3 * i))]);
|
||||
|
||||
int map_low_ptr = constants::compressedAllMap32PointersLow;
|
||||
int p2 = (rom_.data()[(map_low_ptr) + 2 + (3 * i)] << 16) +
|
||||
(rom_.data()[(map_low_ptr) + 1 + (3 * i)] << 8) +
|
||||
(rom_.data()[(map_low_ptr + (3 * i))]);
|
||||
p2 = SnesToPc(p2);
|
||||
|
||||
int ttpos = 0;
|
||||
@@ -258,8 +251,8 @@ void Overworld::LoadOverworldMap() {
|
||||
for (int sx = 0; sx < 16; sx++) {
|
||||
for (int y = 0; y < 8; y++) {
|
||||
for (int x = 0; x < 8; x++) {
|
||||
ptr[x + (sx * 8) + (y * 128) + (sy * 1024)] =
|
||||
rom_.data()[0x0C4000 + pos];
|
||||
auto position = x + (sx * 8) + (y * 128) + (sy * 1024);
|
||||
ptr[position] = rom_.data()[0x0C4000 + pos];
|
||||
pos++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,12 +18,6 @@ namespace yaze {
|
||||
namespace app {
|
||||
namespace zelda3 {
|
||||
|
||||
struct OWMapTiles {
|
||||
std::vector<std::vector<ushort>> light_world; // 64 maps * (32*32 tiles)
|
||||
std::vector<std::vector<ushort>> dark_world; // 64 maps * (32*32 tiles)
|
||||
std::vector<std::vector<ushort>> special_world; // 32 maps * (32*32 tiles)
|
||||
}
|
||||
|
||||
class Overworld {
|
||||
public:
|
||||
void Load(ROM& rom);
|
||||
@@ -39,15 +33,11 @@ class Overworld {
|
||||
void FetchLargeMaps();
|
||||
void LoadOverworldMap();
|
||||
|
||||
ROM rom_;
|
||||
int gameState = 1;
|
||||
bool isLoaded = false;
|
||||
uchar mapParent[160];
|
||||
|
||||
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)
|
||||
|
||||
ROM rom_;
|
||||
OWMapTiles map_tiles_;
|
||||
|
||||
gfx::Bitmap mapblockset16;
|
||||
|
||||
@@ -3,7 +3,9 @@
|
||||
#include <imgui/imgui.h>
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include "app/core/common.h"
|
||||
#include "app/gfx/bitmap.h"
|
||||
@@ -15,7 +17,6 @@ namespace app {
|
||||
namespace zelda3 {
|
||||
|
||||
using namespace core;
|
||||
using namespace gfx;
|
||||
|
||||
OverworldMap::OverworldMap(ROM& rom, const std::vector<gfx::Tile16>& tiles16,
|
||||
int index_)
|
||||
@@ -113,16 +114,10 @@ OverworldMap::OverworldMap(ROM& rom, const std::vector<gfx::Tile16>& tiles16,
|
||||
}
|
||||
}
|
||||
|
||||
void OverworldMap::BuildMap(uchar* mapparent_, int count, int gameState,
|
||||
std::vector<std::vector<ushort>>& allmapsTilesLW,
|
||||
std::vector<std::vector<ushort>>& allmapsTilesDW,
|
||||
std::vector<std::vector<ushort>>& allmapsTilesSP,
|
||||
uchar* currentOWgfx16Ptr, uchar* mapblockset16) {
|
||||
currentOWgfx16Ptr_ = currentOWgfx16Ptr;
|
||||
mapblockset16_ = mapblockset16;
|
||||
|
||||
void OverworldMap::BuildMap(int count, int game_state, uchar* map_parent,
|
||||
OWMapTiles& map_tiles) {
|
||||
if (large_map_) {
|
||||
this->parent_ = mapparent_[index_];
|
||||
this->parent_ = map_parent[index_];
|
||||
|
||||
if (parent_ != index_ && !initialized_) {
|
||||
if (index_ >= 0x80 && index_ <= 0x8A && index_ != 0x88) {
|
||||
@@ -141,29 +136,27 @@ void OverworldMap::BuildMap(uchar* mapparent_, int count, int gameState,
|
||||
}
|
||||
}
|
||||
|
||||
BuildTileset(gameState);
|
||||
BuildTileset(game_state);
|
||||
BuildTiles16Gfx(count); // build on GFX.mapgfx16Ptr
|
||||
|
||||
int world = 0;
|
||||
|
||||
if (index_ < 64) {
|
||||
tiles_used_ = allmapsTilesLW;
|
||||
tiles_used_ = map_tiles.light_world;
|
||||
} else if (index_ < 128 && index_ >= 64) {
|
||||
tiles_used_ = allmapsTilesDW;
|
||||
tiles_used_ = map_tiles.dark_world;
|
||||
world = 1;
|
||||
} else {
|
||||
tiles_used_ = allmapsTilesSP;
|
||||
tiles_used_ = map_tiles.special_world;
|
||||
world = 2;
|
||||
}
|
||||
|
||||
int superY = ((index_ - (world * 64)) / 8);
|
||||
int superX = index_ - (world * 64) - (superY * 8);
|
||||
|
||||
for (int y = 0; y < 32; y++) {
|
||||
for (int x = 0; x < 32; x++) {
|
||||
CopyTile8bpp16((x * 16), (y * 16),
|
||||
tiles_used_[x + (superX * 32)][y + (superY * 32)], gfxPtr,
|
||||
mapblockset16);
|
||||
mapblockset16_);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -189,14 +182,14 @@ void OverworldMap::CopyTile8bpp16From8(int xP, int yP, int tileID,
|
||||
uchar* destbmpPtr, uchar* sourcebmpPtr) {
|
||||
auto gfx16Data = destbmpPtr;
|
||||
// TODO: PSEUDO VRAM
|
||||
auto gfx8Data = currentOWgfx16Ptr_;
|
||||
auto gfx8Data = rom_.GetVRAM().GetGraphicsData();
|
||||
|
||||
int offsets[] = {0, 8, 4096, 4104};
|
||||
|
||||
auto tiles = tiles16_[tileID];
|
||||
|
||||
for (auto tile = 0; tile < 4; tile++) {
|
||||
TileInfo info = tiles.tiles_info[tile];
|
||||
gfx::TileInfo info = tiles.tiles_info[tile];
|
||||
int offset = offsets[tile];
|
||||
|
||||
for (auto y = 0; y < 8; y++) {
|
||||
@@ -209,7 +202,7 @@ void OverworldMap::CopyTile8bpp16From8(int xP, int yP, int tileID,
|
||||
|
||||
void OverworldMap::BuildTiles16Gfx(int count) {
|
||||
auto gfx16Data = mapblockset16_;
|
||||
auto gfx8Data = currentOWgfx16Ptr_;
|
||||
auto gfx8Data = rom_.GetVRAM().GetGraphicsData();
|
||||
|
||||
int offsets[] = {0, 8, 1024, 1032};
|
||||
auto yy = 0;
|
||||
@@ -222,7 +215,7 @@ void OverworldMap::BuildTiles16Gfx(int count) {
|
||||
auto tiles = tiles16_[i];
|
||||
|
||||
for (auto tile = 0; tile < 4; tile++) {
|
||||
TileInfo info = tiles16_[i].tiles_info[tile];
|
||||
gfx::TileInfo info = tiles16_[i].tiles_info[tile];
|
||||
int offset = offsets[tile];
|
||||
|
||||
for (auto y = 0; y < 8; y++) {
|
||||
@@ -242,7 +235,7 @@ void OverworldMap::BuildTiles16Gfx(int count) {
|
||||
|
||||
// map,current
|
||||
void OverworldMap::CopyTile(int x, int y, int xx, int yy, int offset,
|
||||
TileInfo tile, uchar* gfx16Pointer,
|
||||
gfx::TileInfo tile, uchar* gfx16Pointer,
|
||||
uchar* gfx8Pointer) {
|
||||
int mx = x;
|
||||
int my = y;
|
||||
@@ -267,7 +260,7 @@ void OverworldMap::CopyTile(int x, int y, int xx, int yy, int offset,
|
||||
|
||||
// map,current
|
||||
void OverworldMap::CopyTileToMap(int x, int y, int xx, int yy, int offset,
|
||||
TileInfo tile, uchar* gfx16Pointer,
|
||||
gfx::TileInfo tile, uchar* gfx16Pointer,
|
||||
uchar* gfx8Pointer) {
|
||||
int mx = x;
|
||||
int my = y;
|
||||
@@ -343,9 +336,9 @@ void OverworldMap::BuildTileset(int gameState) {
|
||||
}
|
||||
|
||||
// TODO: PSEUDO VRAM DATA HERE
|
||||
uchar* currentmapgfx8Data = currentOWgfx16Ptr_;
|
||||
uchar* currentmapgfx8Data = rom_.GetVRAM().GetGraphicsData();
|
||||
// TODO: PUT GRAPHICS DATA HERE
|
||||
uchar const* allgfxData = allGfx16Ptr_;
|
||||
uchar const* allgfxData = rom_.GetMasterGraphicsBin();
|
||||
|
||||
for (int i = 0; i < 16; i++) {
|
||||
for (int j = 0; j < 2048; j++) {
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
#include <imgui/imgui.h>
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include "app/core/common.h"
|
||||
#include "app/gfx/bitmap.h"
|
||||
@@ -12,8 +14,6 @@ namespace yaze {
|
||||
namespace app {
|
||||
namespace zelda3 {
|
||||
|
||||
using ushort = unsigned short;
|
||||
|
||||
class OverworldMap {
|
||||
public:
|
||||
int parent_ = 0;
|
||||
@@ -39,12 +39,8 @@ class OverworldMap {
|
||||
std::vector<std::vector<ushort>> tiles_used_;
|
||||
|
||||
OverworldMap(ROM& rom, const std::vector<gfx::Tile16>& tiles16, int index);
|
||||
void BuildMap(uchar* mapParent, int count, int gameState,
|
||||
std::vector<std::vector<ushort>>& allmapsTilesLW,
|
||||
std::vector<std::vector<ushort>>& allmapsTilesDW,
|
||||
std::vector<std::vector<ushort>>& allmapsTilesSP,
|
||||
uchar* currentOWgfx16Ptr, uchar* mapblockset16);
|
||||
void BuildMap(uchar* mapParent, int count, int gameState, OWMapTiles& map_tiles);
|
||||
void BuildMap(int count, int game_state, uchar* map_parent,
|
||||
OWMapTiles& map_tiles);
|
||||
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