yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
overworld_item.h
Go to the documentation of this file.
1#ifndef YAZE_APP_ZELDA3_OVERWORLD_ITEM_H_
2#define YAZE_APP_ZELDA3_OVERWORLD_ITEM_H_
3
4#include <algorithm>
5#include <cstdint>
6#include <iomanip>
7#include <iostream>
8#include <string>
9#include <vector>
10
11#include "app/zelda3/common.h"
12
13namespace yaze {
14namespace zelda3 {
15
16constexpr int kNumOverworldMapItemPointers = 0x80;
17constexpr int kOverworldItemsPointers = 0xDC2F9;
18constexpr int kOverworldItemsAddress = 0xDC8B9; // 1BC2F9
19constexpr int kOverworldItemsBank = 0xDC8BF;
20constexpr int kOverworldItemsEndData = 0xDC89C; // 0DC89E
21
22constexpr int kOverworldBombDoorItemLocationsNew = 0x012644;
23constexpr int kOverworldItemsPointersNew = 0x012784;
24constexpr int kOverworldItemsStartDataNew = 0x0DC2F9;
25
26class OverworldItem : public GameEntity {
27 public:
28 OverworldItem() = default;
29 OverworldItem(uint8_t id, uint16_t room_map_id, int x, int y, bool bg2)
30 : bg2_(bg2), id_(id), room_map_id_(room_map_id) {
31 x_ = x;
32 y_ = y;
33 map_id_ = room_map_id;
34 entity_id_ = id;
36
37 int map_x = room_map_id - ((room_map_id / 8) * 8);
38 int map_y = room_map_id / 8;
39
40 game_x_ = static_cast<uint8_t>(std::abs(x - (map_x * 512)) / 16);
41 game_y_ = static_cast<uint8_t>(std::abs(y - (map_y * 512)) / 16);
42 }
43
44 void UpdateMapProperties(uint16_t room_map_id) override {
45 room_map_id_ = room_map_id;
46
47 if (room_map_id_ >= 64) {
48 room_map_id_ -= 64;
49 }
50
51 int map_x = room_map_id_ - ((room_map_id_ / 8) * 8);
52 int map_y = room_map_id_ / 8;
53
54 game_x_ = static_cast<uint8_t>(std::abs(x_ - (map_x * 512)) / 16);
55 game_y_ = static_cast<uint8_t>(std::abs(y_ - (map_y * 512)) / 16);
56 }
57
58 bool bg2_ = false;
59 uint8_t id_;
60 uint8_t game_x_;
61 uint8_t game_y_;
62 uint16_t room_map_id_;
63 int unique_id = 0;
64 bool deleted = false;
65};
66
67inline bool CompareOverworldItems(const std::vector<OverworldItem>& items1,
68 const std::vector<OverworldItem>& items2) {
69 if (items1.size() != items2.size()) {
70 return false;
71 }
72
73 const auto is_same_item = [](const OverworldItem& a, const OverworldItem& b) {
74 return a.x_ == b.x_ && a.y_ == b.y_ && a.id_ == b.id_;
75 };
76
77 return std::all_of(items1.begin(), items1.end(),
78 [&](const OverworldItem& it) {
79 return std::any_of(items2.begin(), items2.end(),
80 [&](const OverworldItem& other) {
81 return is_same_item(it, other);
82 });
83 });
84}
85
86const std::vector<std::string> kSecretItemNames = {
87 "Nothing", // 0
88 "Green Rupee", // 1
89 "Rock hoarder", // 2
90 "Bee", // 3
91 "Health pack", // 4
92 "Bomb", // 5
93 "Heart ", // 6
94 "Blue Rupee", // 7
95 "Key", // 8
96 "Arrow", // 9
97 "Bomb", // 10
98 "Heart", // 11
99 "Magic", // 12
100 "Full Magic", // 13
101 "Cucco", // 14
102 "Green Soldier", // 15
103 "Bush Stal", // 16
104 "Blue Soldier", // 17
105 "Landmine", // 18
106 "Heart", // 19
107 "Fairy", // 20
108 "Heart", // 21
109 "Nothing ", // 22
110 "Hole", // 23
111 "Warp", // 24
112 "Staircase", // 25
113 "Bombable", // 26
114 "Switch" // 27
115};
116
117} // namespace zelda3
118} // namespace yaze
119
120#endif // YAZE_APP_ZELDA3_OVERWORLD_ITEM_H_
Base class for all overworld and dungeon entities.
Definition common.h:19
enum yaze::zelda3::GameEntity::EntityType entity_type_
void UpdateMapProperties(uint16_t room_map_id) override
OverworldItem(uint8_t id, uint16_t room_map_id, int x, int y, bool bg2)
constexpr int kOverworldItemsBank
bool CompareOverworldItems(const std::vector< OverworldItem > &items1, const std::vector< OverworldItem > &items2)
constexpr int kNumOverworldMapItemPointers
constexpr int kOverworldItemsAddress
constexpr int kOverworldItemsEndData
const std::vector< std::string > kSecretItemNames
constexpr int kOverworldItemsStartDataNew
constexpr int kOverworldItemsPointers
constexpr int kOverworldBombDoorItemLocationsNew
constexpr int kOverworldItemsPointersNew
Main namespace for the application.