Housekeeping

This commit is contained in:
scawful
2023-11-30 02:13:31 -05:00
parent 53873614ae
commit b4820d1d32
6 changed files with 34 additions and 101 deletions

View File

@@ -31,7 +31,7 @@ For developers to reference.
- [Constants](../src/app/core/constants.h)
- [Controller](../src/app/core/controller.h)
- [Editor](../src/app/core/editor.h)
- [Pipeline](../src/app/core/pipeline.h)
- [Pipeline](../src/app/gui/pipeline.h)
- **Editor Namespace**:
- Editors are responsible for representing the GUI view and handling user input.
- These classes are all controlled by [MasterEditor](../src/app/editor/master_editor.h)

View File

@@ -8,6 +8,7 @@ add_executable(
app/emu/audio/dsp.cc
app/emu/video/ppu.cc
app/emu/memory/dma.cc
app/emu/memory/memory.cc
app/emu/cpu.cc
app/emu/snes.cc
${YAZE_APP_CORE_SRC}

View File

@@ -203,7 +203,7 @@ absl::StatusOr<Bytes> ROM::Load2BppGraphics() {
}
absl::Status ROM::LoadLinkGraphics() {
const auto link_gfx_offset = 81920; // $10:8000
const auto link_gfx_offset = 81920; // $10:8000
const auto link_gfx_length = 0x800;
// Load Links graphics from the ROM
@@ -248,6 +248,8 @@ absl::Status ROM::LoadAllGraphicsData() {
graphics_manager_.LoadBitmap(i, converted_sheet, core::kTilesheetWidth,
core::kTilesheetHeight,
core::kTilesheetDepth);
graphics_manager_[i]->ApplyPaletteWithTransparent(
palette_groups_["dungeon_main"][0], 0);
graphics_manager_[i]->CreateTexture(renderer_);
}
graphics_bin_[i] =

View File

@@ -18,66 +18,6 @@ namespace app {
namespace zelda3 {
namespace dungeon {
void DrawDungeonRoomBG1(std::vector<uint8_t>& tiles_bg1_buffer,
std::vector<uint8_t>& current_gfx16,
std::vector<uint8_t>& room_bg1_data) {
for (int yy = 0; yy < 64; ++yy) {
for (int xx = 0; xx < 64; ++xx) {
if (tiles_bg1_buffer[xx + (yy * 64)] != 0xFFFF) {
auto t = gfx::GetTilesInfo(tiles_bg1_buffer[xx + (yy * 64)]);
for (int yl = 0; yl < 8; ++yl) {
for (int xl = 0; xl < 4; ++xl) {
int mx = xl * (1 - t.horizontal_mirror_) +
(3 - xl) * t.horizontal_mirror_;
int my =
yl * (1 - t.vertical_mirror_) + (7 - yl) * t.vertical_mirror_;
int ty = (t.id_ / 16) * 512;
int tx = (t.id_ % 16) * 4;
uint8_t pixel = current_gfx16[(tx + ty) + (yl * 64) + xl];
int index = (xx * 8) + (yy * 4096) + ((mx * 2) + (my * 512));
room_bg1_data[index + t.horizontal_mirror_ ^ 1] =
static_cast<uint8_t>((pixel & 0x0F) + t.palette_ * 16);
room_bg1_data[index + t.horizontal_mirror_] =
static_cast<uint8_t>(((pixel >> 4) & 0x0F) + t.palette_ * 16);
}
}
}
}
}
}
void DrawDungeonRoomBG2(std::vector<uint8_t>& tiles_bg2_buffer,
std::vector<uint8_t>& current_gfx16,
std::vector<uint8_t>& room_bg2_data) {
for (int yy = 0; yy < 64; ++yy) {
for (int xx = 0; xx < 64; ++xx) {
if (tiles_bg2_buffer[xx + (yy * 64)] != 0xFFFF) {
auto t = gfx::GetTilesInfo(tiles_bg2_buffer[xx + (yy * 64)]);
for (int yl = 0; yl < 8; ++yl) {
for (int xl = 0; xl < 4; ++xl) {
int mx = xl * (1 - t.horizontal_mirror_) +
(3 - xl) * t.horizontal_mirror_;
int my =
yl * (1 - t.vertical_mirror_) + (7 - yl) * t.vertical_mirror_;
int ty = (t.id_ / 16) * 512;
int tx = (t.id_ % 16) * 4;
uint8_t pixel = current_gfx16[(tx + ty) + (yl * 64) + xl];
int index = (xx * 8) + (yy * 4096) + ((mx * 2) + (my * 512));
room_bg2_data[index + t.horizontal_mirror_ ^ 1] =
static_cast<uint8_t>((pixel & 0x0F) + t.palette_ * 16);
room_bg2_data[index + t.horizontal_mirror_] =
static_cast<uint8_t>(((pixel >> 4) & 0x0F) + t.palette_ * 16);
}
}
}
}
}
}
void Room::LoadHeader() {
// Address of the room header
int header_pointer = (rom()->data()[kRoomHeaderPointer + 2] << 16) +
@@ -106,30 +46,12 @@ void Room::LoadHeader() {
// tag1 = (TagKey)((rom()->data()[header_location + 5]));
// tag2 = (TagKey)((rom()->data()[header_location + 6]));
// holewarpPlane = ((rom()->data()[header_location + 7]) & 0x03);
staircase_plane[0] = ((rom()->data()[header_location + 7] >> 2) & 0x03);
staircase_plane[1] = ((rom()->data()[header_location + 7] >> 4) & 0x03);
staircase_plane[2] = ((rom()->data()[header_location + 7] >> 6) & 0x03);
staircase_plane[3] = ((rom()->data()[header_location + 8]) & 0x03);
// if (holewarpPlane == 2) {
// Console::WriteLine("Room Index Plane 1 : Used in room id = " +
// index.ToString("X2"));
// } else if (staircasePlane[0] == 2) {
// Console::WriteLine("Room Index Plane 1 : Used in room id = " +
// index.ToString("X2"));
// } else if (staircasePlane[1] == 2) {
// Console::WriteLine("Room Index Plane 1 : Used in room id = " +
// index.ToString("X2"));
// } else if (staircasePlane[2] == 2) {
// Console::WriteLine("Room Index Plane 1 : Used in room id = " +
// index.ToString("X2"));
// } else if (staircasePlane[3] == 2) {
// Console::WriteLine("Room Index Plane 1 : Used in room id = " +
// index.ToString("X2"));
// }
// holewarp = (rom()->data()[header_location + 9]);
holewarp = (rom()->data()[header_location + 9]);
staircase_rooms[0] = (rom()->data()[header_location + 10]);
staircase_rooms[1] = (rom()->data()[header_location + 11]);
staircase_rooms[2] = (rom()->data()[header_location + 12]);
@@ -495,4 +417,4 @@ void Room::LoadRoomFromROM() {
} // namespace dungeon
} // namespace zelda3
} // namespace app
} // namespace yaze
} // namespace yaze

View File

@@ -20,6 +20,26 @@ namespace app {
namespace zelda3 {
namespace dungeon {
// public static int room_object_layout_pointer = 0x882D;
// public static int room_object_pointer = 0x874C; // Long pointer
// oh eh
// in bank 01 ? lol
// those are pointer of pointers
// 0x882D -> readlong() -> 2FEF04 (04EF2F -> toPC->026F2F) ->
// that's all the layout "room" pointers
// 47EF04 ; layout00 ptr
// AFEF04 ; layout01 ptr
// F0EF04 ; layout02 ptr
// 4CF004 ; layout03 ptr
// A8F004 ; layout04 ptr
// ECF004 ; layout05 ptr
// 48F104 ; layout06 ptr
// A4F104 ; layout07 ptr
// also they are not exactly the same as rooms
// the object array is terminated by a 0xFFFF there's no layers
// in normal room when you encounter a 0xFFFF it goes to the next layer
constexpr int entrance_gfx_group = 0x5D97;
constexpr int dungeons_main_bg_palette_pointers = 0xDEC4B; // JP Same
constexpr int dungeons_palettes = 0xDD734;
@@ -45,7 +65,6 @@ constexpr int torches_length_pointer = 0x88C1;
constexpr int sprite_blockset_pointer = 0x5B57;
constexpr int sprites_data = 0x4D8B0;
constexpr int sprites_data_empty_room = 0x4D8AE;
constexpr int sprites_end_data = 0x4EC9E;
constexpr int pit_pointer = 0x394AB;
@@ -67,14 +86,6 @@ constexpr int dungeon_spr_ptrs = 0x090000;
constexpr ushort stairsObjects[] = {0x139, 0x138, 0x13B, 0x12E, 0x12D};
void DrawDungeonRoomBG1(std::vector<uint8_t>& tiles_bg1_buffer,
std::vector<uint8_t>& current_gfx16,
std::vector<uint8_t>& room_bg1_ptr);
void DrawDungeonRoomBG2(std::vector<uint8_t>& tiles_bg2_buffer,
std::vector<uint8_t>& current_gfx16,
std::vector<uint8_t>& room_bg2_ptr);
class DungeonDestination {
public:
DungeonDestination() = default;
@@ -139,6 +150,7 @@ class Room : public SharedROM {
uint8_t spriteset = 0;
uint8_t palette = 0;
uint8_t layout = 0;
uint8_t holewarp = 0;
uint16_t message_id_ = 0;
@@ -170,6 +182,7 @@ class Room : public SharedROM {
std::array<uint8_t, 16> blocks_;
std::array<uchar, 16> ChestList;
std::array<gfx::Bitmap, 3> background_bmps_;
std::vector<zelda3::Sprite> sprites_;
std::vector<StaircaseRooms> staircaseRooms;

View File

@@ -47,6 +47,8 @@ class DungeonObjectRenderer : public SharedROM {
}
gfx::Bitmap* bitmap() { return &bitmap_; }
auto memory() { return memory_; }
auto mutable_memory() { return memory_.data(); }
private:
struct SubtypeInfo {
@@ -67,11 +69,7 @@ class DungeonObjectRenderer : public SharedROM {
info.subtypePtr = core::subtype1_tiles + (objectId & 0xFF) * 2;
info.routinePtr = core::subtype1_tiles + 0x200 + (objectId & 0xFF) * 2;
std::cout << "Subtype 1 " << std::hex << info.subtypePtr << std::endl;
info.routinePtr =
memory_.ReadWord(core::MapBankToWordAddress(0x01, info.routinePtr));
std::cout << "Subtype 1 " << std::hex << info.routinePtr << std::endl;
std::cout << "Subtype 1 " << std::hex << core::SnesToPc(info.routinePtr)
<< std::endl;
break;
case 2: // Subtype 2
info.subtypePtr = core::subtype2_tiles + (objectId & 0x7F) * 2;
@@ -97,6 +95,8 @@ class DungeonObjectRenderer : public SharedROM {
void ConfigureObject(const SubtypeInfo& info) {
cpu.A = 0x00;
cpu.X = 0x00;
cpu.SetAccumulatorSize(false);
cpu.SetIndexSize(false);
// Might need to set the height and width manually?
}
@@ -142,8 +142,8 @@ class DungeonObjectRenderer : public SharedROM {
*/
void RenderObject(const SubtypeInfo& info) {
cpu.PC = info.routinePtr;
cpu.PB = 0x01;
cpu.PC = cpu.ReadWord(0x01 << 16 | info.routinePtr);
int i = 0;
while (true) {
@@ -151,11 +151,6 @@ class DungeonObjectRenderer : public SharedROM {
cpu.ExecuteInstruction(opcode);
cpu.HandleInterrupts();
// Check if the end of the routine is reached
if (opcode == 0x60) { // RTS opcode
break;
}
if (i > 50) {
break;
}