Move Overworld constants to Overworld
This commit is contained in:
@@ -142,14 +142,8 @@ constexpr int Uncompressed3BPPSize = 0x0600;
|
|||||||
constexpr int UncompressedSheetSize = 0x0800;
|
constexpr int UncompressedSheetSize = 0x0800;
|
||||||
|
|
||||||
constexpr int NumberOfSheets = 223;
|
constexpr int NumberOfSheets = 223;
|
||||||
constexpr int LimitOfMap32 = 8864;
|
|
||||||
constexpr int NumberOfRooms = 296;
|
constexpr int NumberOfRooms = 296;
|
||||||
|
|
||||||
constexpr int kNumOverworldMaps = 160;
|
|
||||||
constexpr int Map32PerScreen = 256;
|
|
||||||
constexpr int NumberOfMap16 = 3752; // 4096
|
|
||||||
constexpr int NumberOfMap32 = Map32PerScreen * kNumOverworldMaps;
|
|
||||||
constexpr int NumberOfOWSprites = 352;
|
|
||||||
constexpr int NumberOfColors = 3143;
|
constexpr int NumberOfColors = 3143;
|
||||||
|
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
@@ -162,7 +156,6 @@ constexpr int subtype1_tiles = 0x8000; // JP = Same
|
|||||||
constexpr int subtype2_tiles = 0x83F0; // JP = Same
|
constexpr int subtype2_tiles = 0x83F0; // JP = Same
|
||||||
constexpr int subtype3_tiles = 0x84F0; // JP = Same
|
constexpr int subtype3_tiles = 0x84F0; // JP = Same
|
||||||
constexpr int gfx_animated_pointer = 0x10275; // JP 0x10624 //long pointer
|
constexpr int gfx_animated_pointer = 0x10275; // JP 0x10624 //long pointer
|
||||||
constexpr int overworldgfxGroups2 = 0x6073; // 0x60B3
|
|
||||||
|
|
||||||
constexpr int hud_palettes = 0xDD660;
|
constexpr int hud_palettes = 0xDD660;
|
||||||
constexpr int maxGfx = 0xC3FB5;
|
constexpr int maxGfx = 0xC3FB5;
|
||||||
@@ -171,129 +164,6 @@ constexpr int kTilesheetWidth = 128;
|
|||||||
constexpr int kTilesheetHeight = 32;
|
constexpr int kTilesheetHeight = 32;
|
||||||
constexpr int kTilesheetDepth = 8;
|
constexpr int kTilesheetDepth = 8;
|
||||||
|
|
||||||
// ============================================================================
|
|
||||||
// Overworld Related Variables
|
|
||||||
// ============================================================================
|
|
||||||
|
|
||||||
constexpr int compressedAllMap32PointersHigh = 0x1794D;
|
|
||||||
constexpr int compressedAllMap32PointersLow = 0x17B2D;
|
|
||||||
constexpr int overworldgfxGroups = 0x05D97;
|
|
||||||
constexpr int map16Tiles = 0x78000;
|
|
||||||
constexpr int map32TilesTL = 0x18000;
|
|
||||||
constexpr int map32TilesTR = 0x1B400;
|
|
||||||
constexpr int map32TilesBL = 0x20000;
|
|
||||||
constexpr int map32TilesBR = 0x23400;
|
|
||||||
constexpr int overworldPalGroup1 = 0xDE6C8;
|
|
||||||
constexpr int overworldPalGroup2 = 0xDE86C;
|
|
||||||
constexpr int overworldPalGroup3 = 0xDE604;
|
|
||||||
constexpr int overworldMapPalette = 0x7D1C;
|
|
||||||
constexpr int overworldSpritePalette = 0x7B41;
|
|
||||||
constexpr int overworldMapPaletteGroup = 0x75504;
|
|
||||||
constexpr int overworldSpritePaletteGroup = 0x75580;
|
|
||||||
constexpr int overworldSpriteset = 0x7A41;
|
|
||||||
constexpr int overworldSpecialGFXGroup = 0x16821;
|
|
||||||
constexpr int overworldSpecialPALGroup = 0x16831;
|
|
||||||
|
|
||||||
constexpr int overworldSpritesBegining = 0x4C881;
|
|
||||||
constexpr int overworldSpritesAgahnim = 0x4CA21;
|
|
||||||
constexpr int overworldSpritesZelda = 0x4C901;
|
|
||||||
|
|
||||||
constexpr int overworldItemsPointers = 0xDC2F9;
|
|
||||||
constexpr int overworldItemsAddress = 0xDC8B9; // 1BC2F9
|
|
||||||
constexpr int overworldItemsBank = 0xDC8BF;
|
|
||||||
constexpr int overworldItemsEndData = 0xDC89C; // 0DC89E
|
|
||||||
|
|
||||||
constexpr int mapGfx = 0x7C9C;
|
|
||||||
constexpr int overlayPointers = 0x77664;
|
|
||||||
constexpr int overlayPointersBank = 0x0E;
|
|
||||||
|
|
||||||
constexpr int overworldTilesType = 0x71459;
|
|
||||||
constexpr int overworldMessages = 0x3F51D;
|
|
||||||
|
|
||||||
constexpr int overworldMusicBegining = 0x14303;
|
|
||||||
constexpr int overworldMusicZelda = 0x14303 + 0x40;
|
|
||||||
constexpr int overworldMusicMasterSword = 0x14303 + 0x80;
|
|
||||||
constexpr int overworldMusicAgahim = 0x14303 + 0xC0;
|
|
||||||
constexpr int overworldMusicDW = 0x14403;
|
|
||||||
|
|
||||||
constexpr int overworldEntranceAllowedTilesLeft = 0xDB8C1;
|
|
||||||
constexpr int overworldEntranceAllowedTilesRight = 0xDB917;
|
|
||||||
|
|
||||||
// 0x00 = small maps, 0x20 = large maps
|
|
||||||
constexpr int overworldMapSize = 0x12844;
|
|
||||||
|
|
||||||
// 0x01 = small maps, 0x03 = large maps
|
|
||||||
constexpr int overworldMapSizeHighByte = 0x12884;
|
|
||||||
|
|
||||||
// relative to the WORLD + 0x200 per map
|
|
||||||
// large map that are not == parent id = same position as their parent!
|
|
||||||
// eg for X position small maps :
|
|
||||||
// 0000, 0200, 0400, 0600, 0800, 0A00, 0C00, 0E00
|
|
||||||
// all Large map would be :
|
|
||||||
// 0000, 0000, 0400, 0400, 0800, 0800, 0C00, 0C00
|
|
||||||
|
|
||||||
constexpr int overworldMapParentId = 0x125EC;
|
|
||||||
|
|
||||||
constexpr int overworldTransitionPositionY = 0x128C4;
|
|
||||||
|
|
||||||
constexpr int overworldTransitionPositionX = 0x12944;
|
|
||||||
|
|
||||||
constexpr int overworldScreenSize = 0x1788D;
|
|
||||||
|
|
||||||
constexpr int OverworldScreenSizeForLoading = 0x4C635;
|
|
||||||
|
|
||||||
constexpr int OverworldScreenTileMapChangeByScreen = 0x12634;
|
|
||||||
|
|
||||||
constexpr int transition_target_north = 0x13ee2;
|
|
||||||
|
|
||||||
constexpr int transition_target_west = 0x13f62;
|
|
||||||
|
|
||||||
constexpr int overworldCustomMosaicASM = 0x1301D0;
|
|
||||||
|
|
||||||
constexpr int overworldCustomMosaicArray = 0x1301F0;
|
|
||||||
|
|
||||||
// ============================================================================
|
|
||||||
// Overworld Exits/Entrances Variables
|
|
||||||
// ============================================================================
|
|
||||||
constexpr int OWExitRoomId = 0x15D8A; // 0x15E07 Credits sequences
|
|
||||||
// 105C2 Ending maps
|
|
||||||
// 105E2 Sprite Group Table for Ending
|
|
||||||
constexpr int OWExitMapId = 0x15E28;
|
|
||||||
constexpr int OWExitVram = 0x15E77;
|
|
||||||
constexpr int OWExitYScroll = 0x15F15;
|
|
||||||
constexpr int OWExitXScroll = 0x15FB3;
|
|
||||||
constexpr int OWExitYPlayer = 0x16051;
|
|
||||||
constexpr int OWExitXPlayer = 0x160EF;
|
|
||||||
constexpr int OWExitYCamera = 0x1618D;
|
|
||||||
constexpr int OWExitXCamera = 0x1622B;
|
|
||||||
constexpr int OWExitDoorPosition = 0x15724;
|
|
||||||
constexpr int OWExitUnk1 = 0x162C9;
|
|
||||||
constexpr int OWExitUnk2 = 0x16318;
|
|
||||||
constexpr int OWExitDoorType1 = 0x16367;
|
|
||||||
constexpr int OWExitDoorType2 = 0x16405;
|
|
||||||
constexpr int OWEntranceMap = 0xDB96F;
|
|
||||||
constexpr int OWEntrancePos = 0xDBA71;
|
|
||||||
constexpr int OWEntranceEntranceId = 0xDBB73;
|
|
||||||
constexpr int OWHolePos = 0xDB800; //(0x13 entries, 2 bytes each) modified(less
|
|
||||||
// 0x400) map16 coordinates for each hole
|
|
||||||
constexpr int OWHoleArea =
|
|
||||||
0xDB826; //(0x13 entries, 2 bytes each) corresponding
|
|
||||||
// area numbers for each hole
|
|
||||||
constexpr int OWHoleEntrance =
|
|
||||||
0xDB84C; //(0x13 entries, 1 byte each) corresponding entrance numbers
|
|
||||||
|
|
||||||
constexpr int OWExitMapIdWhirlpool = 0x16AE5; // JP = ;016849
|
|
||||||
constexpr int OWExitVramWhirlpool = 0x16B07; // JP = ;01686B
|
|
||||||
constexpr int OWExitYScrollWhirlpool = 0x16B29; // JP = ;01688D
|
|
||||||
constexpr int OWExitXScrollWhirlpool = 0x16B4B; // JP = ;016DE7
|
|
||||||
constexpr int OWExitYPlayerWhirlpool = 0x16B6D; // JP = ;016E09
|
|
||||||
constexpr int OWExitXPlayerWhirlpool = 0x16B8F; // JP = ;016E2B
|
|
||||||
constexpr int OWExitYCameraWhirlpool = 0x16BB1; // JP = ;016E4D
|
|
||||||
constexpr int OWExitXCameraWhirlpool = 0x16BD3; // JP = ;016E6F
|
|
||||||
constexpr int OWExitUnk1Whirlpool = 0x16BF5; // JP = ;016E91
|
|
||||||
constexpr int OWExitUnk2Whirlpool = 0x16C17; // JP = ;016EB3
|
|
||||||
constexpr int OWWhirlpoolPosition = 0x16CF8; // JP = ;016F94
|
|
||||||
|
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
// Dungeon Related Variables
|
// Dungeon Related Variables
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
|
|||||||
@@ -347,7 +347,7 @@ absl::Status OverworldEditor::LoadGraphics() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Render the overworld maps loaded from the ROM.
|
// Render the overworld maps loaded from the ROM.
|
||||||
for (int i = 0; i < core::kNumOverworldMaps; ++i) {
|
for (int i = 0; i < zelda3::kNumOverworldMaps; ++i) {
|
||||||
overworld_.SetCurrentMap(i);
|
overworld_.SetCurrentMap(i);
|
||||||
auto palette = overworld_.AreaPalette();
|
auto palette = overworld_.AreaPalette();
|
||||||
core::BuildAndRenderBitmapPipeline(0x200, 0x200, 0x200,
|
core::BuildAndRenderBitmapPipeline(0x200, 0x200, 0x200,
|
||||||
|
|||||||
@@ -32,33 +32,9 @@ void ScreenEditor::Update() {
|
|||||||
DrawNamingScreenEditor();
|
DrawNamingScreenEditor();
|
||||||
DrawOverworldMapEditor();
|
DrawOverworldMapEditor();
|
||||||
DrawDungeonMapsEditor();
|
DrawDungeonMapsEditor();
|
||||||
DrawMosaicEditor();
|
|
||||||
END_TAB_BAR()
|
END_TAB_BAR()
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScreenEditor::DrawWorldGrid(int world, int h, int w) {
|
|
||||||
const float time = (float)ImGui::GetTime();
|
|
||||||
|
|
||||||
int i = 0;
|
|
||||||
if (world == 1) {
|
|
||||||
i = 64;
|
|
||||||
} else if (world == 2) {
|
|
||||||
i = 128;
|
|
||||||
}
|
|
||||||
for (int y = 0; y < h; y++)
|
|
||||||
for (int x = 0; x < w; x++) {
|
|
||||||
if (x > 0) ImGui::SameLine();
|
|
||||||
ImGui::PushID(y * 4 + x);
|
|
||||||
std::string label = absl::StrCat(" #", absl::StrFormat("%x", i));
|
|
||||||
if (ImGui::Selectable(label.c_str(), mosaic_tiles_[i] != 0, 0,
|
|
||||||
ImVec2(35, 25))) {
|
|
||||||
mosaic_tiles_[i] ^= 1;
|
|
||||||
}
|
|
||||||
ImGui::PopID();
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ScreenEditor::DrawInventoryMenuEditor() {
|
void ScreenEditor::DrawInventoryMenuEditor() {
|
||||||
TAB_ITEM("Inventory Menu")
|
TAB_ITEM("Inventory Menu")
|
||||||
|
|
||||||
@@ -117,30 +93,6 @@ void ScreenEditor::DrawDungeonMapsEditor() {
|
|||||||
END_TAB_ITEM()
|
END_TAB_ITEM()
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScreenEditor::DrawMosaicEditor() {
|
|
||||||
TAB_ITEM("Mosaic Transitions")
|
|
||||||
|
|
||||||
if (ImGui::BeginTable("Worlds", 3, ImGuiTableFlags_Borders)) {
|
|
||||||
ImGui::TableSetupColumn("Light World");
|
|
||||||
ImGui::TableSetupColumn("Dark World");
|
|
||||||
ImGui::TableSetupColumn("Special World");
|
|
||||||
ImGui::TableHeadersRow();
|
|
||||||
|
|
||||||
ImGui::TableNextColumn();
|
|
||||||
DrawWorldGrid(0);
|
|
||||||
|
|
||||||
ImGui::TableNextColumn();
|
|
||||||
DrawWorldGrid(1);
|
|
||||||
|
|
||||||
ImGui::TableNextColumn();
|
|
||||||
DrawWorldGrid(2, 4);
|
|
||||||
|
|
||||||
ImGui::EndTable();
|
|
||||||
}
|
|
||||||
|
|
||||||
END_TAB_ITEM()
|
|
||||||
}
|
|
||||||
|
|
||||||
void ScreenEditor::DrawToolset() {
|
void ScreenEditor::DrawToolset() {
|
||||||
static bool show_bg1 = true;
|
static bool show_bg1 = true;
|
||||||
static bool show_bg2 = true;
|
static bool show_bg2 = true;
|
||||||
|
|||||||
@@ -19,15 +19,12 @@ namespace yaze {
|
|||||||
namespace app {
|
namespace app {
|
||||||
namespace editor {
|
namespace editor {
|
||||||
|
|
||||||
using MosaicArray = std::array<int, core::kNumOverworldMaps>;
|
|
||||||
|
|
||||||
class ScreenEditor : public SharedROM {
|
class ScreenEditor : public SharedROM {
|
||||||
public:
|
public:
|
||||||
ScreenEditor();
|
ScreenEditor();
|
||||||
void Update();
|
void Update();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void DrawMosaicEditor();
|
|
||||||
void DrawTitleScreenEditor();
|
void DrawTitleScreenEditor();
|
||||||
void DrawNamingScreenEditor();
|
void DrawNamingScreenEditor();
|
||||||
void DrawOverworldMapEditor();
|
void DrawOverworldMapEditor();
|
||||||
@@ -36,9 +33,6 @@ class ScreenEditor : public SharedROM {
|
|||||||
|
|
||||||
void DrawToolset();
|
void DrawToolset();
|
||||||
void DrawInventoryToolset();
|
void DrawInventoryToolset();
|
||||||
void DrawWorldGrid(int world, int h = 8, int w = 8);
|
|
||||||
|
|
||||||
char mosaic_tiles_[core::kNumOverworldMaps];
|
|
||||||
|
|
||||||
Bytes all_gfx_;
|
Bytes all_gfx_;
|
||||||
zelda3::Inventory inventory_;
|
zelda3::Inventory inventory_;
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ absl::Status Overworld::Load(ROM &rom) {
|
|||||||
AssembleMap16Tiles();
|
AssembleMap16Tiles();
|
||||||
RETURN_IF_ERROR(DecompressAllMapTiles())
|
RETURN_IF_ERROR(DecompressAllMapTiles())
|
||||||
|
|
||||||
for (int map_index = 0; map_index < core::kNumOverworldMaps; ++map_index)
|
for (int map_index = 0; map_index < kNumOverworldMaps; ++map_index)
|
||||||
overworld_maps_.emplace_back(map_index, rom_, tiles16);
|
overworld_maps_.emplace_back(map_index, rom_, tiles16);
|
||||||
|
|
||||||
FetchLargeMaps();
|
FetchLargeMaps();
|
||||||
@@ -52,7 +52,7 @@ absl::Status Overworld::Load(ROM &rom) {
|
|||||||
|
|
||||||
auto size = tiles16.size();
|
auto size = tiles16.size();
|
||||||
std::vector<std::future<absl::Status>> futures;
|
std::vector<std::future<absl::Status>> futures;
|
||||||
for (int i = 0; i < core::kNumOverworldMaps; ++i) {
|
for (int i = 0; i < kNumOverworldMaps; ++i) {
|
||||||
futures.push_back(std::async(std::launch::async, [this, i, size]() {
|
futures.push_back(std::async(std::launch::async, [this, i, size]() {
|
||||||
if (i < 64) {
|
if (i < 64) {
|
||||||
return overworld_maps_[i].BuildMap(size, game_state_, 0, map_parent_,
|
return overworld_maps_[i].BuildMap(size, game_state_, 0, map_parent_,
|
||||||
@@ -91,157 +91,145 @@ absl::Status Overworld::SaveOverworldMaps() {
|
|||||||
int parentxPos = overworld_maps_[i].Parent() % 8;
|
int parentxPos = overworld_maps_[i].Parent() % 8;
|
||||||
|
|
||||||
// Always write the map parent since it should not matter
|
// Always write the map parent since it should not matter
|
||||||
rom_.Write(core::overworldMapParentId + i, overworld_maps_[i].Parent());
|
rom_.Write(overworldMapParentId + i, overworld_maps_[i].Parent());
|
||||||
|
|
||||||
// If it's large then save parent pos *
|
// If it's large then save parent pos *
|
||||||
// 0x200 otherwise pos * 0x200
|
// 0x200 otherwise pos * 0x200
|
||||||
if (overworld_maps_[i].IsLargeMap()) {
|
if (overworld_maps_[i].IsLargeMap()) {
|
||||||
// Check 1
|
// Check 1
|
||||||
rom_.Write(core::overworldMapSize + i, 0x20);
|
rom_.Write(overworldMapSize + i, 0x20);
|
||||||
rom_.Write(core::overworldMapSize + i + 1, 0x20);
|
rom_.Write(overworldMapSize + i + 1, 0x20);
|
||||||
rom_.Write(core::overworldMapSize + i + 8, 0x20);
|
rom_.Write(overworldMapSize + i + 8, 0x20);
|
||||||
rom_.Write(core::overworldMapSize + i + 9, 0x20);
|
rom_.Write(overworldMapSize + i + 9, 0x20);
|
||||||
|
|
||||||
// Check 2
|
// Check 2
|
||||||
rom_.Write(core::overworldMapSizeHighByte + i, 0x03);
|
rom_.Write(overworldMapSizeHighByte + i, 0x03);
|
||||||
rom_.Write(core::overworldMapSizeHighByte + i + 1, 0x03);
|
rom_.Write(overworldMapSizeHighByte + i + 1, 0x03);
|
||||||
rom_.Write(core::overworldMapSizeHighByte + i + 8, 0x03);
|
rom_.Write(overworldMapSizeHighByte + i + 8, 0x03);
|
||||||
rom_.Write(core::overworldMapSizeHighByte + i + 9, 0x03);
|
rom_.Write(overworldMapSizeHighByte + i + 9, 0x03);
|
||||||
|
|
||||||
// Check 3
|
// Check 3
|
||||||
rom_.Write(core::overworldScreenSize + i, 0x00);
|
rom_.Write(overworldScreenSize + i, 0x00);
|
||||||
rom_.Write(core::overworldScreenSize + i + 64, 0x00);
|
rom_.Write(overworldScreenSize + i + 64, 0x00);
|
||||||
|
|
||||||
rom_.Write(core::overworldScreenSize + i + 1, 0x00);
|
rom_.Write(overworldScreenSize + i + 1, 0x00);
|
||||||
rom_.Write(core::overworldScreenSize + i + 1 + 64, 0x00);
|
rom_.Write(overworldScreenSize + i + 1 + 64, 0x00);
|
||||||
|
|
||||||
rom_.Write(core::overworldScreenSize + i + 8, 0x00);
|
rom_.Write(overworldScreenSize + i + 8, 0x00);
|
||||||
rom_.Write(core::overworldScreenSize + i + 8 + 64, 0x00);
|
rom_.Write(overworldScreenSize + i + 8 + 64, 0x00);
|
||||||
|
|
||||||
rom_.Write(core::overworldScreenSize + i + 9, 0x00);
|
rom_.Write(overworldScreenSize + i + 9, 0x00);
|
||||||
rom_.Write(core::overworldScreenSize + i + 9 + 64, 0x00);
|
rom_.Write(overworldScreenSize + i + 9 + 64, 0x00);
|
||||||
|
|
||||||
// Check 4
|
// Check 4
|
||||||
rom_.Write(core::OverworldScreenSizeForLoading + i, 0x04);
|
rom_.Write(OverworldScreenSizeForLoading + i, 0x04);
|
||||||
rom_.Write(core::OverworldScreenSizeForLoading + i + 64, 0x04);
|
rom_.Write(OverworldScreenSizeForLoading + i + 64, 0x04);
|
||||||
rom_.Write(core::OverworldScreenSizeForLoading + i + 128, 0x04);
|
rom_.Write(OverworldScreenSizeForLoading + i + 128, 0x04);
|
||||||
|
|
||||||
rom_.Write(core::OverworldScreenSizeForLoading + i + 1, 0x04);
|
rom_.Write(OverworldScreenSizeForLoading + i + 1, 0x04);
|
||||||
rom_.Write(core::OverworldScreenSizeForLoading + i + 1 + 64, 0x04);
|
rom_.Write(OverworldScreenSizeForLoading + i + 1 + 64, 0x04);
|
||||||
rom_.Write(core::OverworldScreenSizeForLoading + i + 1 + 128, 0x04);
|
rom_.Write(OverworldScreenSizeForLoading + i + 1 + 128, 0x04);
|
||||||
|
|
||||||
rom_.Write(core::OverworldScreenSizeForLoading + i + 8, 0x04);
|
rom_.Write(OverworldScreenSizeForLoading + i + 8, 0x04);
|
||||||
rom_.Write(core::OverworldScreenSizeForLoading + i + 8 + 64, 0x04);
|
rom_.Write(OverworldScreenSizeForLoading + i + 8 + 64, 0x04);
|
||||||
rom_.Write(core::OverworldScreenSizeForLoading + i + 8 + 128, 0x04);
|
rom_.Write(OverworldScreenSizeForLoading + i + 8 + 128, 0x04);
|
||||||
|
|
||||||
rom_.Write(core::OverworldScreenSizeForLoading + i + 9, 0x04);
|
rom_.Write(OverworldScreenSizeForLoading + i + 9, 0x04);
|
||||||
rom_.Write(core::OverworldScreenSizeForLoading + i + 9 + 64, 0x04);
|
rom_.Write(OverworldScreenSizeForLoading + i + 9 + 64, 0x04);
|
||||||
rom_.Write(core::OverworldScreenSizeForLoading + i + 9 + 128, 0x04);
|
rom_.Write(OverworldScreenSizeForLoading + i + 9 + 128, 0x04);
|
||||||
|
|
||||||
// Check 5 and 6
|
// Check 5 and 6
|
||||||
rom_.WriteShort(
|
rom_.WriteShort(
|
||||||
core::transition_target_north + (i * 2) + 2,
|
transition_target_north + (i * 2) + 2,
|
||||||
(short)((parentyPos * 0x200) -
|
(short)((parentyPos * 0x200) -
|
||||||
0xE0)); // (short) is placed to reduce the int to 2 bytes.
|
0xE0)); // (short) is placed to reduce the int to 2 bytes.
|
||||||
rom_.WriteShort(core::transition_target_west + (i * 2) + 2,
|
rom_.WriteShort(transition_target_west + (i * 2) + 2,
|
||||||
(short)((parentxPos * 0x200) - 0x100));
|
(short)((parentxPos * 0x200) - 0x100));
|
||||||
|
|
||||||
rom_.WriteShort(
|
rom_.WriteShort(
|
||||||
core::transition_target_north + (i * 2) + 16,
|
transition_target_north + (i * 2) + 16,
|
||||||
(short)((parentyPos * 0x200) -
|
(short)((parentyPos * 0x200) -
|
||||||
0xE0)); // (short) is placed to reduce the int to 2 bytes.
|
0xE0)); // (short) is placed to reduce the int to 2 bytes.
|
||||||
rom_.WriteShort(core::transition_target_west + (i * 2) + 16,
|
rom_.WriteShort(transition_target_west + (i * 2) + 16,
|
||||||
(short)((parentxPos * 0x200) - 0x100));
|
(short)((parentxPos * 0x200) - 0x100));
|
||||||
|
|
||||||
rom_.WriteShort(
|
rom_.WriteShort(
|
||||||
core::transition_target_north + (i * 2) + 18,
|
transition_target_north + (i * 2) + 18,
|
||||||
(short)((parentyPos * 0x200) -
|
(short)((parentyPos * 0x200) -
|
||||||
0xE0)); // (short) is placed to reduce the int to 2 bytes.
|
0xE0)); // (short) is placed to reduce the int to 2 bytes.
|
||||||
rom_.WriteShort(core::transition_target_west + (i * 2) + 18,
|
rom_.WriteShort(transition_target_west + (i * 2) + 18,
|
||||||
(short)((parentxPos * 0x200) - 0x100));
|
(short)((parentxPos * 0x200) - 0x100));
|
||||||
|
|
||||||
// Check 7 and 8
|
// Check 7 and 8
|
||||||
rom_.WriteShort(core::overworldTransitionPositionX + (i * 2),
|
rom_.WriteShort(overworldTransitionPositionX + (i * 2),
|
||||||
(parentxPos * 0x200));
|
(parentxPos * 0x200));
|
||||||
rom_.WriteShort(core::overworldTransitionPositionY + (i * 2),
|
rom_.WriteShort(overworldTransitionPositionY + (i * 2),
|
||||||
(parentyPos * 0x200));
|
(parentyPos * 0x200));
|
||||||
|
|
||||||
rom_.WriteShort(core::overworldTransitionPositionX + (i * 2) + 2,
|
rom_.WriteShort(overworldTransitionPositionX + (i * 2) + 2,
|
||||||
(parentxPos * 0x200));
|
(parentxPos * 0x200));
|
||||||
rom_.WriteShort(core::overworldTransitionPositionY + (i * 2) + 2,
|
rom_.WriteShort(overworldTransitionPositionY + (i * 2) + 2,
|
||||||
(parentyPos * 0x200));
|
(parentyPos * 0x200));
|
||||||
|
|
||||||
rom_.WriteShort(core::overworldTransitionPositionX + (i * 2) + 16,
|
rom_.WriteShort(overworldTransitionPositionX + (i * 2) + 16,
|
||||||
(parentxPos * 0x200));
|
(parentxPos * 0x200));
|
||||||
rom_.WriteShort(core::overworldTransitionPositionY + (i * 2) + 16,
|
rom_.WriteShort(overworldTransitionPositionY + (i * 2) + 16,
|
||||||
(parentyPos * 0x200));
|
(parentyPos * 0x200));
|
||||||
|
|
||||||
rom_.WriteShort(core::overworldTransitionPositionX + (i * 2) + 18,
|
rom_.WriteShort(overworldTransitionPositionX + (i * 2) + 18,
|
||||||
(parentxPos * 0x200));
|
(parentxPos * 0x200));
|
||||||
rom_.WriteShort(core::overworldTransitionPositionY + (i * 2) + 18,
|
rom_.WriteShort(overworldTransitionPositionY + (i * 2) + 18,
|
||||||
(parentyPos * 0x200));
|
(parentyPos * 0x200));
|
||||||
|
|
||||||
// Check 9
|
// Check 9
|
||||||
rom_.WriteShort(core::OverworldScreenTileMapChangeByScreen + (i * 2),
|
rom_.WriteShort(OverworldScreenTileMapChangeByScreen + (i * 2),
|
||||||
0x0060); // Always 0x0060
|
0x0060); // Always 0x0060
|
||||||
rom_.WriteShort(core::OverworldScreenTileMapChangeByScreen + (i * 2) + 2,
|
rom_.WriteShort(OverworldScreenTileMapChangeByScreen + (i * 2) + 2,
|
||||||
0x0060); // Always 0x0060
|
0x0060); // Always 0x0060
|
||||||
|
|
||||||
// If parentX == 0 then lower submaps == 0x0060 too
|
// If parentX == 0 then lower submaps == 0x0060 too
|
||||||
if (parentxPos == 0) {
|
if (parentxPos == 0) {
|
||||||
rom_.WriteShort(
|
rom_.WriteShort(OverworldScreenTileMapChangeByScreen + (i * 2) + 16,
|
||||||
core::OverworldScreenTileMapChangeByScreen + (i * 2) + 16, 0x0060);
|
0x0060);
|
||||||
rom_.WriteShort(
|
rom_.WriteShort(OverworldScreenTileMapChangeByScreen + (i * 2) + 18,
|
||||||
core::OverworldScreenTileMapChangeByScreen + (i * 2) + 18, 0x0060);
|
0x0060);
|
||||||
} else {
|
} else {
|
||||||
// Otherwise lower submaps == 0x1060
|
// Otherwise lower submaps == 0x1060
|
||||||
rom_.WriteShort(
|
rom_.WriteShort(OverworldScreenTileMapChangeByScreen + (i * 2) + 16,
|
||||||
core::OverworldScreenTileMapChangeByScreen + (i * 2) + 16, 0x1060);
|
0x1060);
|
||||||
rom_.WriteShort(
|
rom_.WriteShort(OverworldScreenTileMapChangeByScreen + (i * 2) + 18,
|
||||||
core::OverworldScreenTileMapChangeByScreen + (i * 2) + 18, 0x1060);
|
0x1060);
|
||||||
}
|
}
|
||||||
|
|
||||||
rom_.WriteShort(
|
rom_.WriteShort(OverworldScreenTileMapChangeByScreen + (i * 2) + 128,
|
||||||
core::OverworldScreenTileMapChangeByScreen + (i * 2) + 128,
|
0x0080); // Always 0x0080
|
||||||
0x0080); // Always 0x0080
|
rom_.WriteShort(OverworldScreenTileMapChangeByScreen + (i * 2) + 2 + 128,
|
||||||
rom_.WriteShort(
|
0x0080); // Always 0x0080
|
||||||
core::OverworldScreenTileMapChangeByScreen + (i * 2) + 2 + 128,
|
// Lower are always 8010
|
||||||
0x0080); // Always 0x0080
|
rom_.WriteShort(OverworldScreenTileMapChangeByScreen + (i * 2) + 16 + 128,
|
||||||
// Lower are always 8010
|
0x1080); // Always 0x1080
|
||||||
rom_.WriteShort(
|
rom_.WriteShort(OverworldScreenTileMapChangeByScreen + (i * 2) + 18 + 128,
|
||||||
core::OverworldScreenTileMapChangeByScreen + (i * 2) + 16 + 128,
|
0x1080); // Always 0x1080
|
||||||
0x1080); // Always 0x1080
|
|
||||||
rom_.WriteShort(
|
|
||||||
core::OverworldScreenTileMapChangeByScreen + (i * 2) + 18 + 128,
|
|
||||||
0x1080); // Always 0x1080
|
|
||||||
|
|
||||||
rom_.WriteShort(
|
rom_.WriteShort(OverworldScreenTileMapChangeByScreen + (i * 2) + 256,
|
||||||
core::OverworldScreenTileMapChangeByScreen + (i * 2) + 256,
|
0x1800); // Always 0x1800
|
||||||
0x1800); // Always 0x1800
|
rom_.WriteShort(OverworldScreenTileMapChangeByScreen + (i * 2) + 16 + 256,
|
||||||
rom_.WriteShort(
|
0x1800); // Always 0x1800
|
||||||
core::OverworldScreenTileMapChangeByScreen + (i * 2) + 16 + 256,
|
// Right side is always 1840
|
||||||
0x1800); // Always 0x1800
|
rom_.WriteShort(OverworldScreenTileMapChangeByScreen + (i * 2) + 2 + 256,
|
||||||
// Right side is always 1840
|
0x1840); // Always 0x1840
|
||||||
rom_.WriteShort(
|
rom_.WriteShort(OverworldScreenTileMapChangeByScreen + (i * 2) + 18 + 256,
|
||||||
core::OverworldScreenTileMapChangeByScreen + (i * 2) + 2 + 256,
|
0x1840); // Always 0x1840
|
||||||
0x1840); // Always 0x1840
|
|
||||||
rom_.WriteShort(
|
|
||||||
core::OverworldScreenTileMapChangeByScreen + (i * 2) + 18 + 256,
|
|
||||||
0x1840); // Always 0x1840
|
|
||||||
|
|
||||||
rom_.WriteShort(
|
rom_.WriteShort(OverworldScreenTileMapChangeByScreen + (i * 2) + 384,
|
||||||
core::OverworldScreenTileMapChangeByScreen + (i * 2) + 384,
|
0x2000); // Always 0x2000
|
||||||
0x2000); // Always 0x2000
|
rom_.WriteShort(OverworldScreenTileMapChangeByScreen + (i * 2) + 16 + 384,
|
||||||
rom_.WriteShort(
|
0x2000); // Always 0x2000
|
||||||
core::OverworldScreenTileMapChangeByScreen + (i * 2) + 16 + 384,
|
// Right side is always 0x2040
|
||||||
0x2000); // Always 0x2000
|
rom_.WriteShort(OverworldScreenTileMapChangeByScreen + (i * 2) + 2 + 384,
|
||||||
// Right side is always 0x2040
|
0x2040); // Always 0x2000
|
||||||
rom_.WriteShort(
|
rom_.WriteShort(OverworldScreenTileMapChangeByScreen + (i * 2) + 18 + 384,
|
||||||
core::OverworldScreenTileMapChangeByScreen + (i * 2) + 2 + 384,
|
0x2040); // Always 0x2000
|
||||||
0x2040); // Always 0x2000
|
|
||||||
rom_.WriteShort(
|
|
||||||
core::OverworldScreenTileMapChangeByScreen + (i * 2) + 18 + 384,
|
|
||||||
0x2040); // Always 0x2000
|
|
||||||
|
|
||||||
// checkedMap.Add((uchar)i);
|
// checkedMap.Add((uchar)i);
|
||||||
// checkedMap.Add((uchar)(i + 1));
|
// checkedMap.Add((uchar)(i + 1));
|
||||||
@@ -249,34 +237,31 @@ absl::Status Overworld::SaveOverworldMaps() {
|
|||||||
// checkedMap.Add((uchar)(i + 9));
|
// checkedMap.Add((uchar)(i + 9));
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
rom_.Write(core::overworldMapSize + i, 0x00);
|
rom_.Write(overworldMapSize + i, 0x00);
|
||||||
rom_.Write(core::overworldMapSizeHighByte + i, 0x01);
|
rom_.Write(overworldMapSizeHighByte + i, 0x01);
|
||||||
|
|
||||||
rom_.Write(core::overworldScreenSize + i, 0x01);
|
rom_.Write(overworldScreenSize + i, 0x01);
|
||||||
rom_.Write(core::overworldScreenSize + i + 64, 0x01);
|
rom_.Write(overworldScreenSize + i + 64, 0x01);
|
||||||
|
|
||||||
rom_.Write(core::OverworldScreenSizeForLoading + i, 0x02);
|
rom_.Write(OverworldScreenSizeForLoading + i, 0x02);
|
||||||
rom_.Write(core::OverworldScreenSizeForLoading + i + 64, 0x02);
|
rom_.Write(OverworldScreenSizeForLoading + i + 64, 0x02);
|
||||||
rom_.Write(core::OverworldScreenSizeForLoading + i + 128, 0x02);
|
rom_.Write(OverworldScreenSizeForLoading + i + 128, 0x02);
|
||||||
|
|
||||||
rom_.WriteShort(core::OverworldScreenTileMapChangeByScreen + (i * 2),
|
rom_.WriteShort(OverworldScreenTileMapChangeByScreen + (i * 2), 0x0060);
|
||||||
0x0060);
|
rom_.WriteShort(OverworldScreenTileMapChangeByScreen + (i * 2) + 128,
|
||||||
rom_.WriteShort(
|
0x0040);
|
||||||
core::OverworldScreenTileMapChangeByScreen + (i * 2) + 128, 0x0040);
|
rom_.WriteShort(OverworldScreenTileMapChangeByScreen + (i * 2) + 256,
|
||||||
rom_.WriteShort(
|
0x1800);
|
||||||
core::OverworldScreenTileMapChangeByScreen + (i * 2) + 256, 0x1800);
|
rom_.WriteShort(OverworldScreenTileMapChangeByScreen + (i * 2) + 384,
|
||||||
rom_.WriteShort(
|
0x1000);
|
||||||
core::OverworldScreenTileMapChangeByScreen + (i * 2) + 384, 0x1000);
|
|
||||||
|
|
||||||
rom_.WriteShort(core::transition_target_north + (i * 2),
|
rom_.WriteShort(transition_target_north + (i * 2),
|
||||||
(short)((yPos * 0x200) - 0xE0));
|
(short)((yPos * 0x200) - 0xE0));
|
||||||
rom_.WriteShort(core::transition_target_west + (i * 2),
|
rom_.WriteShort(transition_target_west + (i * 2),
|
||||||
(short)((xPos * 0x200) - 0x100));
|
(short)((xPos * 0x200) - 0x100));
|
||||||
|
|
||||||
rom_.WriteShort(core::overworldTransitionPositionX + (i * 2),
|
rom_.WriteShort(overworldTransitionPositionX + (i * 2), (xPos * 0x200));
|
||||||
(xPos * 0x200));
|
rom_.WriteShort(overworldTransitionPositionY + (i * 2), (yPos * 0x200));
|
||||||
rom_.WriteShort(core::overworldTransitionPositionY + (i * 2),
|
|
||||||
(yPos * 0x200));
|
|
||||||
|
|
||||||
// checkedMap.Add((uchar)i);
|
// checkedMap.Add((uchar)i);
|
||||||
}
|
}
|
||||||
@@ -287,9 +272,9 @@ absl::Status Overworld::SaveOverworldMaps() {
|
|||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
void Overworld::SaveMap16Tiles() {
|
void Overworld::SaveMap16Tiles() {
|
||||||
int tpos = core::map16Tiles;
|
int tpos = kMap16Tiles;
|
||||||
// 3760
|
// 3760
|
||||||
for (int i = 0; i < core::NumberOfMap16; i += 1) {
|
for (int i = 0; i < NumberOfMap16; i += 1) {
|
||||||
rom_.WriteShort(tpos, TileInfoToShort(tiles16[i].tile0_));
|
rom_.WriteShort(tpos, TileInfoToShort(tiles16[i].tile0_));
|
||||||
tpos += 2;
|
tpos += 2;
|
||||||
rom_.WriteShort(tpos, TileInfoToShort(tiles16[i].tile1_));
|
rom_.WriteShort(tpos, TileInfoToShort(tiles16[i].tile1_));
|
||||||
@@ -373,7 +358,7 @@ void Overworld::AssembleMap32Tiles() {
|
|||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
void Overworld::AssembleMap16Tiles() {
|
void Overworld::AssembleMap16Tiles() {
|
||||||
int tpos = core::map16Tiles;
|
int tpos = kMap16Tiles;
|
||||||
for (int i = 0; i < 4096; i += 1) {
|
for (int i = 0; i < 4096; i += 1) {
|
||||||
auto t0 = gfx::GetTilesInfo(rom_.toint16(tpos));
|
auto t0 = gfx::GetTilesInfo(rom_.toint16(tpos));
|
||||||
tpos += 2;
|
tpos += 2;
|
||||||
@@ -541,9 +526,9 @@ void Overworld::FetchLargeMaps() {
|
|||||||
|
|
||||||
void Overworld::LoadEntrances() {
|
void Overworld::LoadEntrances() {
|
||||||
for (int i = 0; i < 129; i++) {
|
for (int i = 0; i < 129; i++) {
|
||||||
short mapId = rom_.toint16(core::OWEntranceMap + (i * 2));
|
short mapId = rom_.toint16(OWEntranceMap + (i * 2));
|
||||||
ushort mapPos = rom_.toint16(core::OWEntrancePos + (i * 2));
|
ushort mapPos = rom_.toint16(OWEntrancePos + (i * 2));
|
||||||
uchar entranceId = (rom_[core::OWEntranceEntranceId + i]);
|
uchar entranceId = (rom_[OWEntranceEntranceId + i]);
|
||||||
int p = mapPos >> 1;
|
int p = mapPos >> 1;
|
||||||
int x = (p % 64);
|
int x = (p % 64);
|
||||||
int y = (p >> 6);
|
int y = (p >> 6);
|
||||||
@@ -558,11 +543,11 @@ void Overworld::LoadEntrances() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < 0x13; i++) {
|
for (int i = 0; i < 0x13; i++) {
|
||||||
auto mapId = (short)((rom_[core::OWHoleArea + (i * 2) + 1] << 8) +
|
auto mapId = (short)((rom_[OWHoleArea + (i * 2) + 1] << 8) +
|
||||||
(rom_[core::OWHoleArea + (i * 2)]));
|
(rom_[OWHoleArea + (i * 2)]));
|
||||||
auto mapPos = (short)((rom_[core::OWHolePos + (i * 2) + 1] << 8) +
|
auto mapPos = (short)((rom_[OWHolePos + (i * 2) + 1] << 8) +
|
||||||
(rom_[core::OWHolePos + (i * 2)]));
|
(rom_[OWHolePos + (i * 2)]));
|
||||||
uchar entranceId = (rom_[core::OWHoleEntrance + i]);
|
uchar entranceId = (rom_[OWHoleEntrance + i]);
|
||||||
int p = (mapPos + 0x400) >> 1;
|
int p = (mapPos + 0x400) >> 1;
|
||||||
int x = (p % 64);
|
int x = (p % 64);
|
||||||
int y = (p >> 6);
|
int y = (p >> 6);
|
||||||
@@ -592,9 +577,9 @@ void Overworld::LoadSprites() {
|
|||||||
all_sprites_[2].emplace_back();
|
all_sprites_[2].emplace_back();
|
||||||
}
|
}
|
||||||
|
|
||||||
LoadSpritesFromMap(core::overworldSpritesBegining, 64, 0);
|
LoadSpritesFromMap(overworldSpritesBegining, 64, 0);
|
||||||
LoadSpritesFromMap(core::overworldSpritesZelda, 144, 1);
|
LoadSpritesFromMap(overworldSpritesZelda, 144, 1);
|
||||||
LoadSpritesFromMap(core::overworldSpritesAgahnim, 144, 2);
|
LoadSpritesFromMap(overworldSpritesAgahnim, 144, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
@@ -642,7 +627,7 @@ absl::Status Overworld::LoadPrototype(ROM &rom, std::vector<uint8_t> &tilemap,
|
|||||||
AssembleMap16Tiles();
|
AssembleMap16Tiles();
|
||||||
RETURN_IF_ERROR(DecompressAllMapTiles())
|
RETURN_IF_ERROR(DecompressAllMapTiles())
|
||||||
|
|
||||||
for (int map_index = 0; map_index < core::kNumOverworldMaps; ++map_index)
|
for (int map_index = 0; map_index < kNumOverworldMaps; ++map_index)
|
||||||
overworld_maps_.emplace_back(map_index, rom_, tiles16);
|
overworld_maps_.emplace_back(map_index, rom_, tiles16);
|
||||||
|
|
||||||
FetchLargeMaps();
|
FetchLargeMaps();
|
||||||
@@ -650,7 +635,7 @@ absl::Status Overworld::LoadPrototype(ROM &rom, std::vector<uint8_t> &tilemap,
|
|||||||
|
|
||||||
auto size = tiles16.size();
|
auto size = tiles16.size();
|
||||||
std::vector<std::future<absl::Status>> futures;
|
std::vector<std::future<absl::Status>> futures;
|
||||||
for (int i = 0; i < core::kNumOverworldMaps; ++i) {
|
for (int i = 0; i < kNumOverworldMaps; ++i) {
|
||||||
futures.push_back(std::async(std::launch::async, [this, i, size]() {
|
futures.push_back(std::async(std::launch::async, [this, i, size]() {
|
||||||
if (i < 64) {
|
if (i < 64) {
|
||||||
return overworld_maps_[i].BuildMap(size, game_state_, 0, map_parent_,
|
return overworld_maps_[i].BuildMap(size, game_state_, 0, map_parent_,
|
||||||
|
|||||||
@@ -19,6 +19,45 @@ namespace yaze {
|
|||||||
namespace app {
|
namespace app {
|
||||||
namespace zelda3 {
|
namespace zelda3 {
|
||||||
|
|
||||||
|
constexpr int OWExitRoomId = 0x15D8A; // 0x15E07 Credits sequences
|
||||||
|
// 105C2 Ending maps
|
||||||
|
// 105E2 Sprite Group Table for Ending
|
||||||
|
constexpr int OWExitMapId = 0x15E28;
|
||||||
|
constexpr int OWExitVram = 0x15E77;
|
||||||
|
constexpr int OWExitYScroll = 0x15F15;
|
||||||
|
constexpr int OWExitXScroll = 0x15FB3;
|
||||||
|
constexpr int OWExitYPlayer = 0x16051;
|
||||||
|
constexpr int OWExitXPlayer = 0x160EF;
|
||||||
|
constexpr int OWExitYCamera = 0x1618D;
|
||||||
|
constexpr int OWExitXCamera = 0x1622B;
|
||||||
|
constexpr int OWExitDoorPosition = 0x15724;
|
||||||
|
constexpr int OWExitUnk1 = 0x162C9;
|
||||||
|
constexpr int OWExitUnk2 = 0x16318;
|
||||||
|
constexpr int OWExitDoorType1 = 0x16367;
|
||||||
|
constexpr int OWExitDoorType2 = 0x16405;
|
||||||
|
constexpr int OWEntranceMap = 0xDB96F;
|
||||||
|
constexpr int OWEntrancePos = 0xDBA71;
|
||||||
|
constexpr int OWEntranceEntranceId = 0xDBB73;
|
||||||
|
constexpr int OWHolePos = 0xDB800; //(0x13 entries, 2 bytes each) modified(less
|
||||||
|
// 0x400) map16 coordinates for each hole
|
||||||
|
constexpr int OWHoleArea =
|
||||||
|
0xDB826; //(0x13 entries, 2 bytes each) corresponding
|
||||||
|
// area numbers for each hole
|
||||||
|
constexpr int OWHoleEntrance =
|
||||||
|
0xDB84C; //(0x13 entries, 1 byte each) corresponding entrance numbers
|
||||||
|
|
||||||
|
constexpr int OWExitMapIdWhirlpool = 0x16AE5; // JP = ;016849
|
||||||
|
constexpr int OWExitVramWhirlpool = 0x16B07; // JP = ;01686B
|
||||||
|
constexpr int OWExitYScrollWhirlpool = 0x16B29; // JP = ;01688D
|
||||||
|
constexpr int OWExitXScrollWhirlpool = 0x16B4B; // JP = ;016DE7
|
||||||
|
constexpr int OWExitYPlayerWhirlpool = 0x16B6D; // JP = ;016E09
|
||||||
|
constexpr int OWExitXPlayerWhirlpool = 0x16B8F; // JP = ;016E2B
|
||||||
|
constexpr int OWExitYCameraWhirlpool = 0x16BB1; // JP = ;016E4D
|
||||||
|
constexpr int OWExitXCameraWhirlpool = 0x16BD3; // JP = ;016E6F
|
||||||
|
constexpr int OWExitUnk1Whirlpool = 0x16BF5; // JP = ;016E91
|
||||||
|
constexpr int OWExitUnk2Whirlpool = 0x16C17; // JP = ;016EB3
|
||||||
|
constexpr int OWWhirlpoolPosition = 0x16CF8; // JP = ;016F94
|
||||||
|
|
||||||
class OverworldEntrance {
|
class OverworldEntrance {
|
||||||
public:
|
public:
|
||||||
int x_;
|
int x_;
|
||||||
@@ -68,6 +107,70 @@ class OverworldEntrance {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
constexpr int compressedAllMap32PointersHigh = 0x1794D;
|
||||||
|
constexpr int compressedAllMap32PointersLow = 0x17B2D;
|
||||||
|
constexpr int overworldgfxGroups = 0x05D97;
|
||||||
|
constexpr int overworldPalGroup1 = 0xDE6C8;
|
||||||
|
constexpr int overworldPalGroup2 = 0xDE86C;
|
||||||
|
constexpr int overworldPalGroup3 = 0xDE604;
|
||||||
|
constexpr int overworldMapPalette = 0x7D1C;
|
||||||
|
constexpr int overworldSpritePalette = 0x7B41;
|
||||||
|
constexpr int overworldMapPaletteGroup = 0x75504;
|
||||||
|
constexpr int overworldSpritePaletteGroup = 0x75580;
|
||||||
|
constexpr int overworldSpriteset = 0x7A41;
|
||||||
|
constexpr int overworldSpecialGFXGroup = 0x16821;
|
||||||
|
constexpr int overworldSpecialPALGroup = 0x16831;
|
||||||
|
constexpr int overworldSpritesBegining = 0x4C881;
|
||||||
|
constexpr int overworldSpritesAgahnim = 0x4CA21;
|
||||||
|
constexpr int overworldSpritesZelda = 0x4C901;
|
||||||
|
constexpr int overworldItemsPointers = 0xDC2F9;
|
||||||
|
constexpr int overworldItemsAddress = 0xDC8B9; // 1BC2F9
|
||||||
|
constexpr int overworldItemsBank = 0xDC8BF;
|
||||||
|
constexpr int overworldItemsEndData = 0xDC89C; // 0DC89E
|
||||||
|
constexpr int mapGfx = 0x7C9C;
|
||||||
|
constexpr int overlayPointers = 0x77664;
|
||||||
|
constexpr int overlayPointersBank = 0x0E;
|
||||||
|
constexpr int overworldTilesType = 0x71459;
|
||||||
|
constexpr int overworldMessages = 0x3F51D;
|
||||||
|
constexpr int overworldMusicBegining = 0x14303;
|
||||||
|
constexpr int overworldMusicZelda = 0x14303 + 0x40;
|
||||||
|
constexpr int overworldMusicMasterSword = 0x14303 + 0x80;
|
||||||
|
constexpr int overworldMusicAgahim = 0x14303 + 0xC0;
|
||||||
|
constexpr int overworldMusicDW = 0x14403;
|
||||||
|
constexpr int overworldEntranceAllowedTilesLeft = 0xDB8C1;
|
||||||
|
constexpr int overworldEntranceAllowedTilesRight = 0xDB917;
|
||||||
|
|
||||||
|
// 0x00 = small maps, 0x20 = large maps
|
||||||
|
constexpr int overworldMapSize = 0x12844;
|
||||||
|
|
||||||
|
// 0x01 = small maps, 0x03 = large maps
|
||||||
|
constexpr int overworldMapSizeHighByte = 0x12884;
|
||||||
|
|
||||||
|
// relative to the WORLD + 0x200 per map
|
||||||
|
// large map that are not == parent id = same position as their parent!
|
||||||
|
// eg for X position small maps :
|
||||||
|
// 0000, 0200, 0400, 0600, 0800, 0A00, 0C00, 0E00
|
||||||
|
// all Large map would be :
|
||||||
|
// 0000, 0000, 0400, 0400, 0800, 0800, 0C00, 0C00
|
||||||
|
constexpr int overworldMapParentId = 0x125EC;
|
||||||
|
constexpr int overworldTransitionPositionY = 0x128C4;
|
||||||
|
constexpr int overworldTransitionPositionX = 0x12944;
|
||||||
|
constexpr int overworldScreenSize = 0x1788D;
|
||||||
|
constexpr int OverworldScreenSizeForLoading = 0x4C635;
|
||||||
|
constexpr int OverworldScreenTileMapChangeByScreen = 0x12634;
|
||||||
|
constexpr int transition_target_north = 0x13ee2;
|
||||||
|
constexpr int transition_target_west = 0x13f62;
|
||||||
|
constexpr int overworldCustomMosaicASM = 0x1301D0;
|
||||||
|
constexpr int overworldCustomMosaicArray = 0x1301F0;
|
||||||
|
|
||||||
|
constexpr int kMap16Tiles = 0x78000;
|
||||||
|
constexpr int kNumOverworldMaps = 160;
|
||||||
|
constexpr int Map32PerScreen = 256;
|
||||||
|
constexpr int NumberOfMap16 = 3752; // 4096
|
||||||
|
constexpr int LimitOfMap32 = 8864;
|
||||||
|
constexpr int NumberOfOWSprites = 352;
|
||||||
|
constexpr int NumberOfMap32 = Map32PerScreen * kNumOverworldMaps;
|
||||||
|
|
||||||
class Overworld {
|
class Overworld {
|
||||||
public:
|
public:
|
||||||
absl::Status Load(ROM &rom);
|
absl::Status Load(ROM &rom);
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
#include "app/gfx/bitmap.h"
|
#include "app/gfx/bitmap.h"
|
||||||
#include "app/gfx/snes_tile.h"
|
#include "app/gfx/snes_tile.h"
|
||||||
#include "app/rom.h"
|
#include "app/rom.h"
|
||||||
|
#include "app/zelda3/overworld.h"
|
||||||
|
|
||||||
namespace yaze {
|
namespace yaze {
|
||||||
namespace app {
|
namespace app {
|
||||||
@@ -164,15 +165,14 @@ absl::Status OverworldMap::BuildMap(int count, int game_state, int world,
|
|||||||
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) {
|
||||||
area_graphics_ =
|
area_graphics_ = rom_[overworldSpecialGFXGroup + (parent_ - 0x80)];
|
||||||
rom_[core::overworldSpecialGFXGroup + (parent_ - 0x80)];
|
area_palette_ = rom_[overworldSpecialPALGroup + 1];
|
||||||
area_palette_ = rom_[core::overworldSpecialPALGroup + 1];
|
|
||||||
} else if (index_ == 0x88) {
|
} else if (index_ == 0x88) {
|
||||||
area_graphics_ = 0x51;
|
area_graphics_ = 0x51;
|
||||||
area_palette_ = 0x00;
|
area_palette_ = 0x00;
|
||||||
} else {
|
} else {
|
||||||
area_graphics_ = rom_[core::mapGfx + parent_];
|
area_graphics_ = rom_[mapGfx + parent_];
|
||||||
area_palette_ = rom_[core::overworldMapPalette + parent_];
|
area_palette_ = rom_[overworldMapPalette + parent_];
|
||||||
}
|
}
|
||||||
|
|
||||||
initialized_ = true;
|
initialized_ = true;
|
||||||
@@ -190,37 +190,37 @@ absl::Status OverworldMap::BuildMap(int count, int game_state, int world,
|
|||||||
|
|
||||||
void OverworldMap::LoadAreaInfo() {
|
void OverworldMap::LoadAreaInfo() {
|
||||||
if (index_ != 0x80 && index_ <= 150 &&
|
if (index_ != 0x80 && index_ <= 150 &&
|
||||||
rom_[core::overworldMapSize + (index_ & 0x3F)] != 0) {
|
rom_[overworldMapSize + (index_ & 0x3F)] != 0) {
|
||||||
large_map_ = true;
|
large_map_ = true;
|
||||||
}
|
}
|
||||||
if (index_ < 64) {
|
if (index_ < 64) {
|
||||||
area_graphics_ = rom_[core::mapGfx + parent_];
|
area_graphics_ = rom_[mapGfx + parent_];
|
||||||
area_palette_ = rom_[core::overworldMapPalette + parent_];
|
area_palette_ = rom_[overworldMapPalette + parent_];
|
||||||
|
|
||||||
area_music_[0] = rom_[core::overworldMusicBegining + parent_];
|
area_music_[0] = rom_[overworldMusicBegining + parent_];
|
||||||
area_music_[1] = rom_[core::overworldMusicZelda + parent_];
|
area_music_[1] = rom_[overworldMusicZelda + parent_];
|
||||||
area_music_[2] = rom_[core::overworldMusicMasterSword + parent_];
|
area_music_[2] = rom_[overworldMusicMasterSword + parent_];
|
||||||
area_music_[3] = rom_[core::overworldMusicAgahim + parent_];
|
area_music_[3] = rom_[overworldMusicAgahim + parent_];
|
||||||
|
|
||||||
sprite_graphics_[0] = rom_[core::overworldSpriteset + parent_];
|
sprite_graphics_[0] = rom_[overworldSpriteset + parent_];
|
||||||
sprite_graphics_[1] = rom_[core::overworldSpriteset + parent_ + 0x40];
|
sprite_graphics_[1] = rom_[overworldSpriteset + parent_ + 0x40];
|
||||||
sprite_graphics_[2] = rom_[core::overworldSpriteset + parent_ + 0x80];
|
sprite_graphics_[2] = rom_[overworldSpriteset + parent_ + 0x80];
|
||||||
|
|
||||||
sprite_palette_[0] = rom_[core::overworldSpritePalette + parent_];
|
sprite_palette_[0] = rom_[overworldSpritePalette + parent_];
|
||||||
sprite_palette_[1] = rom_[core::overworldSpritePalette + parent_ + 0x40];
|
sprite_palette_[1] = rom_[overworldSpritePalette + parent_ + 0x40];
|
||||||
sprite_palette_[2] = rom_[core::overworldSpritePalette + parent_ + 0x80];
|
sprite_palette_[2] = rom_[overworldSpritePalette + parent_ + 0x80];
|
||||||
} else if (index_ < 0x80) {
|
} else if (index_ < 0x80) {
|
||||||
area_graphics_ = rom_[core::mapGfx + parent_];
|
area_graphics_ = rom_[mapGfx + parent_];
|
||||||
area_palette_ = rom_[core::overworldMapPalette + parent_];
|
area_palette_ = rom_[overworldMapPalette + parent_];
|
||||||
area_music_[0] = rom_[core::overworldMusicDW + (parent_ - 64)];
|
area_music_[0] = rom_[overworldMusicDW + (parent_ - 64)];
|
||||||
|
|
||||||
sprite_graphics_[0] = rom_[core::overworldSpriteset + parent_ + 0x80];
|
sprite_graphics_[0] = rom_[overworldSpriteset + parent_ + 0x80];
|
||||||
sprite_graphics_[1] = rom_[core::overworldSpriteset + parent_ + 0x80];
|
sprite_graphics_[1] = rom_[overworldSpriteset + parent_ + 0x80];
|
||||||
sprite_graphics_[2] = rom_[core::overworldSpriteset + parent_ + 0x80];
|
sprite_graphics_[2] = rom_[overworldSpriteset + parent_ + 0x80];
|
||||||
|
|
||||||
sprite_palette_[0] = rom_[core::overworldSpritePalette + parent_ + 0x80];
|
sprite_palette_[0] = rom_[overworldSpritePalette + parent_ + 0x80];
|
||||||
sprite_palette_[1] = rom_[core::overworldSpritePalette + parent_ + 0x80];
|
sprite_palette_[1] = rom_[overworldSpritePalette + parent_ + 0x80];
|
||||||
sprite_palette_[2] = rom_[core::overworldSpritePalette + parent_ + 0x80];
|
sprite_palette_[2] = rom_[overworldSpritePalette + parent_ + 0x80];
|
||||||
} else {
|
} else {
|
||||||
if (index_ == 0x94) {
|
if (index_ == 0x94) {
|
||||||
parent_ = 0x80;
|
parent_ = 0x80;
|
||||||
@@ -242,28 +242,28 @@ void OverworldMap::LoadAreaInfo() {
|
|||||||
parent_ = 0x88;
|
parent_ = 0x88;
|
||||||
}
|
}
|
||||||
|
|
||||||
area_palette_ = rom_[core::overworldSpecialPALGroup + parent_ - 0x80];
|
area_palette_ = rom_[overworldSpecialPALGroup + parent_ - 0x80];
|
||||||
if (index_ >= 0x80 && index_ <= 0x8A && index_ != 0x88) {
|
if (index_ >= 0x80 && index_ <= 0x8A && index_ != 0x88) {
|
||||||
area_graphics_ = rom_[core::overworldSpecialGFXGroup + (parent_ - 0x80)];
|
area_graphics_ = rom_[overworldSpecialGFXGroup + (parent_ - 0x80)];
|
||||||
area_palette_ = rom_[core::overworldSpecialPALGroup + 1];
|
area_palette_ = rom_[overworldSpecialPALGroup + 1];
|
||||||
} else if (index_ == 0x88) {
|
} else if (index_ == 0x88) {
|
||||||
area_graphics_ = 0x51;
|
area_graphics_ = 0x51;
|
||||||
area_palette_ = 0x00;
|
area_palette_ = 0x00;
|
||||||
} else {
|
} else {
|
||||||
// pyramid bg use 0x5B map
|
// pyramid bg use 0x5B map
|
||||||
area_graphics_ = rom_[core::mapGfx + parent_];
|
area_graphics_ = rom_[mapGfx + parent_];
|
||||||
area_palette_ = rom_[core::overworldMapPalette + parent_];
|
area_palette_ = rom_[overworldMapPalette + parent_];
|
||||||
}
|
}
|
||||||
|
|
||||||
message_id_ = rom_[core::overworldMessages + parent_];
|
message_id_ = rom_[overworldMessages + parent_];
|
||||||
|
|
||||||
sprite_graphics_[0] = rom_[core::overworldSpriteset + parent_ + 0x80];
|
sprite_graphics_[0] = rom_[overworldSpriteset + parent_ + 0x80];
|
||||||
sprite_graphics_[1] = rom_[core::overworldSpriteset + parent_ + 0x80];
|
sprite_graphics_[1] = rom_[overworldSpriteset + parent_ + 0x80];
|
||||||
sprite_graphics_[2] = rom_[core::overworldSpriteset + parent_ + 0x80];
|
sprite_graphics_[2] = rom_[overworldSpriteset + parent_ + 0x80];
|
||||||
|
|
||||||
sprite_palette_[0] = rom_[core::overworldSpritePalette + parent_ + 0x80];
|
sprite_palette_[0] = rom_[overworldSpritePalette + parent_ + 0x80];
|
||||||
sprite_palette_[1] = rom_[core::overworldSpritePalette + parent_ + 0x80];
|
sprite_palette_[1] = rom_[overworldSpritePalette + parent_ + 0x80];
|
||||||
sprite_palette_[2] = rom_[core::overworldSpritePalette + parent_ + 0x80];
|
sprite_palette_[2] = rom_[overworldSpritePalette + parent_ + 0x80];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -344,10 +344,9 @@ gfx::SNESPalette OverworldMap::GetPalette(const std::string& group, int index,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void OverworldMap::LoadPalette() {
|
void OverworldMap::LoadPalette() {
|
||||||
int previousPalId =
|
int previousPalId = index_ > 0 ? rom_[overworldMapPalette + parent_ - 1] : 0;
|
||||||
index_ > 0 ? rom_[core::overworldMapPalette + parent_ - 1] : 0;
|
|
||||||
int previousSprPalId =
|
int previousSprPalId =
|
||||||
index_ > 0 ? rom_[core::overworldSpritePalette + parent_ - 1] : 0;
|
index_ > 0 ? rom_[overworldSpritePalette + parent_ - 1] : 0;
|
||||||
|
|
||||||
area_palette_ = std::min(area_palette_, 0xA3);
|
area_palette_ = std::min(area_palette_, 0xA3);
|
||||||
|
|
||||||
@@ -358,9 +357,9 @@ void OverworldMap::LoadPalette() {
|
|||||||
(area_palette_ * 4) + 1];
|
(area_palette_ * 4) + 1];
|
||||||
uchar pal3 = rom_[rom_.GetVersionConstants().overworldMapPaletteGroup +
|
uchar pal3 = rom_[rom_.GetVersionConstants().overworldMapPaletteGroup +
|
||||||
(area_palette_ * 4) + 2];
|
(area_palette_ * 4) + 2];
|
||||||
uchar pal4 = rom_[core::overworldSpritePaletteGroup +
|
uchar pal4 =
|
||||||
(sprite_palette_[game_state_] * 2)];
|
rom_[overworldSpritePaletteGroup + (sprite_palette_[game_state_] * 2)];
|
||||||
uchar pal5 = rom_[core::overworldSpritePaletteGroup +
|
uchar pal5 = rom_[overworldSpritePaletteGroup +
|
||||||
(sprite_palette_[game_state_] * 2) + 1];
|
(sprite_palette_[game_state_] * 2) + 1];
|
||||||
|
|
||||||
gfx::SNESColor bgr = rom_.GetPaletteGroup("grass")[0].GetColor(0);
|
gfx::SNESColor bgr = rom_.GetPaletteGroup("grass")[0].GetColor(0);
|
||||||
@@ -379,7 +378,7 @@ void OverworldMap::LoadPalette() {
|
|||||||
} else if (parent_ >= 0x40 && parent_ < 0x80) {
|
} else if (parent_ >= 0x40 && parent_ < 0x80) {
|
||||||
pal0 = parent_ == 0x43 || parent_ == 0x45 || parent_ == 0x47 ? 3 : 1;
|
pal0 = parent_ == 0x43 || parent_ == 0x45 || parent_ == 0x47 ? 3 : 1;
|
||||||
bgr = rom_.GetPaletteGroup("grass")[0].GetColor(1);
|
bgr = rom_.GetPaletteGroup("grass")[0].GetColor(1);
|
||||||
} else if (parent_ >= 128 && parent_ < core::kNumOverworldMaps) {
|
} else if (parent_ >= 128 && parent_ < kNumOverworldMaps) {
|
||||||
pal0 = 0;
|
pal0 = 0;
|
||||||
bgr = rom_.GetPaletteGroup("grass")[0].GetColor(2);
|
bgr = rom_.GetPaletteGroup("grass")[0].GetColor(2);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user