worked on adding tile16 for overworld support

This commit is contained in:
Justin Scofield
2022-06-20 19:21:41 -04:00
parent f11e8f2aac
commit 367fe3552f
10 changed files with 276 additions and 232 deletions

View File

@@ -53,18 +53,19 @@ void Overworld::Load(app::rom::ROM& rom) {
AssembleMap16Tiles();
DecompressAllMapTiles();
// Map Initialization :
// for (int i = 0; i < 160; i++) {
// allmaps.push_back(OverworldMap(rom_, tiles16, (uchar)i));
// }
// FetchLargeMaps();
// LoadOverworldMap();
// Map Initialization
for (int i = 0; i < 160; i++) {
overworld_maps_.push_back(OverworldMap(rom_, tiles16, (uchar)i));
}
FetchLargeMaps();
LoadOverworldMap();
// auto size = tiles16.size();
// for (int i = 0; i < 160; i++) {
// allmaps[i].BuildMap(mapParent, size, gameState, allmapsTilesLW,
// allmapsTilesDW, allmapsTilesSP);
// }
auto size = tiles16.size();
for (int i = 0; i < 160; i++) {
overworld_maps_[i].BuildMap(mapParent, size, gameState, allmapsTilesLW,
allmapsTilesDW, allmapsTilesSP,
currentOWgfx16Ptr);
}
isLoaded = true;
}
@@ -250,7 +251,7 @@ void Overworld::FetchLargeMaps() {
mapParent[137] = 129;
mapParent[138] = 129;
mapParent[136] = 136;
allmaps[136].largeMap = false;
overworld_maps_[136].largeMap = false;
bool mapChecked[64];
for (int i = 0; i < 64; i++) {
@@ -261,7 +262,7 @@ void Overworld::FetchLargeMaps() {
while (true) {
int i = xx + (yy * 8);
if (mapChecked[i] == false) {
if (allmaps[i].largeMap == true) {
if (overworld_maps_[i].largeMap == true) {
mapChecked[i] = true;
mapParent[i] = (uchar)i;
mapParent[i + 64] = (uchar)(i + 64);
@@ -314,7 +315,7 @@ void Overworld::LoadOverworldMap() {
}
}
overworld_map_texture = overworldMapBitmap->CreateTexture(rom_.Renderer());
// overworld_map_texture = overworldMapBitmap->CreateTexture(rom_.Renderer());
}
} // namespace zelda3

View File

@@ -23,11 +23,21 @@ class Overworld {
~Overworld();
void Load(app::rom::ROM& rom);
inline auto GetTiles16() const { return tiles16; }
inline auto GetCurrentGfxSetPtr() { return currentOWgfx16Ptr; }
inline auto GetMapBlockset16Ptr() { return mapblockset16; }
char* overworldMapPointer = new char[0x40000];
gfx::Bitmap* overworldMapBitmap;
private:
ushort GenerateTile32(int i, int k, int dimension);
void AssembleMap32Tiles();
void AssembleMap16Tiles();
void DecompressAllMapTiles();
void FetchLargeMaps();
void LoadOverworldMap();
app::rom::ROM rom_;
int gameState = 1;
bool isLoaded = false;
@@ -37,23 +47,19 @@ class Overworld {
ushort** allmapsTilesDW; // 64 maps * (32*32 tiles)
ushort** allmapsTilesSP; // 32 maps * (32*32 tiles)
std::vector<gfx::Tile16> tiles16;
std::vector<gfx::Tile32> tiles32;
std::vector<gfx::Tile32> map16tiles;
std::vector<OverworldMap> allmaps;
std::vector<ushort> tileLeftEntrance;
std::vector<ushort> tileRightEntrance;
std::shared_ptr<uchar> mapblockset16;
std::shared_ptr<uchar> currentOWgfx16Ptr;
gfx::Bitmap mapblockset16Bitmap;
uchar* mapblockset16 = new uchar[1048576];
uchar* currentOWgfx16Ptr = new uchar[(128 * 512) / 2];
SDL_Texture* overworld_map_texture;
int map32address[4] = {
std::vector<gfx::Tile16> tiles16;
std::vector<gfx::Tile32> tiles32;
std::vector<gfx::Tile32> map16tiles;
std::vector<OverworldMap> overworld_maps_;
const int map32address[4] = {
core::constants::map32TilesTL, core::constants::map32TilesTR,
core::constants::map32TilesBL, core::constants::map32TilesBR};
@@ -63,13 +69,6 @@ class Overworld {
map32TilesBL = 2,
map32TilesBR = 3
};
ushort GenerateTile32(int i, int k, int dimension);
void AssembleMap32Tiles();
void AssembleMap16Tiles();
void DecompressAllMapTiles();
void FetchLargeMaps();
void LoadOverworldMap();
};
} // namespace zelda3

View File

@@ -14,8 +14,8 @@ namespace zelda3 {
using namespace core;
using namespace gfx;
OverworldMap::OverworldMap(app::rom::ROM& rom, const std::vector<gfx::Tile16> tiles16,
uchar index)
OverworldMap::OverworldMap(app::rom::ROM& rom,
const std::vector<gfx::Tile16> tiles16, uchar index)
: rom_(rom), index(index), tiles16_(tiles16), parent(index) {
if (index != 0x80) {
if (index <= 150) {
@@ -111,8 +111,9 @@ OverworldMap::OverworldMap(app::rom::ROM& rom, const std::vector<gfx::Tile16> ti
void OverworldMap::BuildMap(uchar* mapParent, int count, int gameState,
ushort** allmapsTilesLW, ushort** allmapsTilesDW,
ushort** allmapsTilesSP) {
ushort** allmapsTilesSP, uchar* currentOWgfx16Ptr) {
tilesUsed = new ushort*[32];
currentOWgfx16Ptr_ = currentOWgfx16Ptr;
for (int i = 0; i < 32; i++) tilesUsed[i] = new ushort;
if (largeMap) {
@@ -333,7 +334,7 @@ void OverworldMap::BuildTileset(int gameState) {
staticgfx[7] = 91;
}
uchar* currentmapgfx8Data = new uchar[(128 * 512) / 2];
uchar* currentmapgfx8Data = currentOWgfx16Ptr_;
// (uchar*)GFX.currentOWgfx16Ptr.ToPointer(); // loaded gfx for the current
// // map (empty at this point)
uchar* allgfxData = new uchar[(128 * 7136) / 2];

View File

@@ -29,7 +29,7 @@ class OverworldMap {
int* gfxPtr = new int[512 * 512];
int* mapblockset16 = new int[1048576];
gfx::Bitmap mapblockset16Bitmap;
uchar* currentOWgfx16Ptr_ = nullptr;
gfx::Bitmap gfxBitmap;
uchar* staticgfx =
@@ -42,10 +42,11 @@ class OverworldMap {
uchar* currentOWgfx16Ptr = new uchar[(128 * 512) / 2];
std::vector<gfx::Tile16> tiles16_;
OverworldMap(app::rom::ROM& rom, const std::vector<gfx::Tile16> tiles16, uchar index);
OverworldMap(app::rom::ROM& rom, const std::vector<gfx::Tile16> tiles16,
uchar index);
void BuildMap(uchar* mapParent, int count, int gameState,
ushort** allmapsTilesLW, ushort** allmapsTilesDW,
ushort** allmapsTilesSP);
ushort** allmapsTilesSP, uchar* currentOWgfx16Ptr);
void CopyTile8bpp16(int x, int y, int tile, int* destbmpPtr,
int* sourcebmpPtr);
void CopyTile8bpp16From8(int xP, int yP, int tileID, int* destbmpPtr,