Overworld housekeeping continued

This commit is contained in:
Justin Scofield
2022-07-19 19:44:43 +00:00
parent d28420450d
commit 099a209739
4 changed files with 27 additions and 32 deletions

View File

@@ -218,8 +218,8 @@ void Overworld::FetchLargeMaps() {
} }
void Overworld::LoadOverworldMap() { void Overworld::LoadOverworldMap() {
overworldMapBitmap.Create(128, 128, 8, 0x40000); overworld_map_bmp_.Create(128, 128, 8, 0x40000);
auto ptr = overworldMapBitmap.GetData(); auto ptr = overworld_map_bmp_.GetData();
int pos = 0; int pos = 0;
for (int sy = 0; sy < 16; sy++) { for (int sy = 0; sy < 16; sy++) {
@@ -235,7 +235,7 @@ void Overworld::LoadOverworldMap() {
} }
auto renderer = rom_.Renderer(); auto renderer = rom_.Renderer();
overworldMapBitmap.CreateTexture(renderer); overworld_map_bmp_.CreateTexture(renderer);
} }
} // namespace zelda3 } // namespace zelda3

View File

@@ -51,9 +51,9 @@ class Overworld {
ROM rom_; ROM rom_;
OWMapTiles map_tiles_; OWMapTiles map_tiles_;
gfx::Bitmap mapblockset16; gfx::Bitmap tile16_blockset_bmp_;
gfx::Bitmap currentOWgfx16; gfx::Bitmap current_gfx_bmp_;
gfx::Bitmap overworldMapBitmap; gfx::Bitmap overworld_map_bmp_;
std::vector<gfx::Tile16> tiles16; std::vector<gfx::Tile16> tiles16;
std::vector<gfx::Tile32> tiles32; std::vector<gfx::Tile32> tiles32;

View File

@@ -144,8 +144,7 @@ void OverworldMap::BuildMap(int count, int game_state, uchar* map_parent,
for (int y = 0; y < 32; y++) { for (int y = 0; y < 32; y++) {
for (int x = 0; x < 32; x++) { for (int x = 0; x < 32; x++) {
CopyTile8bpp16((x * 16), (y * 16), CopyTile8bpp16((x * 16), (y * 16),
tiles_used_[x + (superX * 32)][y + (superY * 32)], gfxPtr, tiles_used_[x + (superX * 32)][y + (superY * 32)], gfxPtr);
mapblockset16_);
} }
} }
} }
@@ -206,9 +205,7 @@ void OverworldMap::BuildTileset(int gameState) {
static_graphics_[7] = 91; static_graphics_[7] = 91;
} }
// TODO: PSEUDO VRAM DATA HERE uchar* current_map_gfx_tile8_data = rom_.GetVRAM().GetGraphicsData();
uchar* currentmapgfx8Data = rom_.GetVRAM().GetGraphicsData();
// TODO: PUT GRAPHICS DATA HERE
uchar const* all_gfx_data = rom_.GetMasterGraphicsBin(); uchar const* all_gfx_data = rom_.GetMasterGraphicsBin();
for (int i = 0; i < 16; i++) { for (int i = 0; i < 16; i++) {
@@ -222,15 +219,15 @@ void OverworldMap::BuildTileset(int gameState) {
mapByte += 0x88; mapByte += 0x88;
break; break;
} }
// Upload used gfx data
currentmapgfx8Data[(i * 2048) + j] = mapByte; // Upload used gfx data current_map_gfx_tile8_data[(i * 2048) + j] = mapByte;
} }
} }
} }
void OverworldMap::BuildTiles16Gfx(int count) { void OverworldMap::BuildTiles16Gfx(int count) {
auto gfx16Data = mapblockset16_; auto gfx_tile16_data = tile16_blockset_bmp_.GetData();
auto gfx8Data = rom_.GetVRAM().GetGraphicsData(); auto gfx_tile8_data = rom_.GetVRAM().GetGraphicsData();
int offsets[] = {0, 8, 1024, 1032}; int offsets[] = {0, 8, 1024, 1032};
auto yy = 0; auto yy = 0;
@@ -248,7 +245,7 @@ void OverworldMap::BuildTiles16Gfx(int count) {
for (auto y = 0; y < 8; y++) { for (auto y = 0; y < 8; y++) {
for (auto x = 0; x < 4; x++) { for (auto x = 0; x < 4; x++) {
CopyTile(x, y, xx, yy, offset, info, gfx16Data, gfx8Data); CopyTile(x, y, xx, yy, offset, info, gfx_tile16_data, gfx_tile8_data);
} }
} }
} }
@@ -311,28 +308,26 @@ 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::CopyTile8bpp16(int x, int y, int tile, uchar* destbmpPtr, void OverworldMap::CopyTile8bpp16(int x, int y, int tile, uchar* destbmpPtr) {
uchar* sourcebmpPtr) {
int source_ptr_pos = ((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 source_ptr = sourcebmpPtr; auto source_ptr = tile16_blockset_bmp_.GetData();
int destPtrPos = (x + (y * 512)); int dest_ptr_pos = (x + (y * 512));
auto destPtr = destbmpPtr; auto dest_ptr = 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)] = dest_ptr[dest_ptr_pos + xstrip + (ystrip * 512)] =
source_ptr[source_ptr_pos + xstrip + (ystrip * 128)]; source_ptr[source_ptr_pos + xstrip + (ystrip * 128)];
} }
} }
} }
void OverworldMap::CopyTile8bpp16From8(int xP, int yP, int tileID, void OverworldMap::CopyTile8bpp16From8(int xP, int yP, int tileID,
uchar* destbmpPtr, uchar* sourcebmpPtr) { uchar* destbmpPtr) {
auto gfx16Data = destbmpPtr; auto gfx_tile16_data = destbmpPtr;
// TODO: PSEUDO VRAM auto gfx_tile8_data = rom_.GetVRAM().GetGraphicsData();
auto gfx8Data = rom_.GetVRAM().GetGraphicsData();
int offsets[] = {0, 8, 4096, 4104}; int offsets[] = {0, 8, 4096, 4104};
@@ -344,7 +339,8 @@ void OverworldMap::CopyTile8bpp16From8(int xP, int yP, int tileID,
for (auto y = 0; y < 8; y++) { for (auto y = 0; y < 8; y++) {
for (auto x = 0; x < 4; x++) { for (auto x = 0; x < 4; x++) {
CopyTileToMap(x, y, xP, yP, offset, info, gfx16Data, gfx8Data); CopyTileToMap(x, y, xP, yP, offset, info, gfx_tile16_data,
gfx_tile8_data);
} }
} }
} }

View File

@@ -32,8 +32,7 @@ class OverworldMap {
void CopyTileToMap(int x, int y, int xx, int yy, int offset, void CopyTileToMap(int x, int y, int xx, int yy, int offset,
gfx::TileInfo tile, uchar* gfx16Pointer, gfx::TileInfo tile, uchar* gfx16Pointer,
uchar* gfx8Pointer); uchar* gfx8Pointer);
void CopyTile8bpp16(int x, int y, int tile, uchar* destbmpPtr, void CopyTile8bpp16(int x, int y, int tile, uchar* destbmpPtr);
uchar* sourcebmpPtr);
void CopyTile8bpp16From8(int xP, int yP, int tileID, uchar* destbmpPtr, void CopyTile8bpp16From8(int xP, int yP, int tileID, uchar* destbmpPtr,
uchar* sourcebmpPtr); uchar* sourcebmpPtr);
@@ -47,16 +46,16 @@ class OverworldMap {
uchar sprite_palette_[3]; uchar sprite_palette_[3];
uchar area_music_[4]; uchar area_music_[4];
uchar static_graphics_[16]; uchar static_graphics_[16];
uchar* gfxPtr = new uchar[512 * 512]; uchar* gfxPtr = new uchar[512 * 512];
uchar* mapblockset16_ = nullptr;
bool initialized_ = false; bool initialized_ = false;
bool large_map_ = false; bool large_map_ = false;
ROM rom_;
std::vector<gfx::Tile16> tiles16_; std::vector<gfx::Tile16> tiles16_;
std::vector<std::vector<ushort>> tiles_used_; std::vector<std::vector<ushort>> tiles_used_;
ROM rom_;
gfx::Bitmap tile16_blockset_bmp_; // psuedo vram?
}; };
} // namespace zelda3 } // namespace zelda3