Add Object selector to DungeonEditor
Loads current room gfx from ROM gfx buffer
This commit is contained in:
@@ -12,6 +12,68 @@ namespace app {
|
||||
namespace zelda3 {
|
||||
namespace dungeon {
|
||||
|
||||
void Room::LoadGfxGroups() {
|
||||
int gfxPointer =
|
||||
(rom_[gfx_groups_pointer + 1] << 8) + rom_[gfx_groups_pointer];
|
||||
gfxPointer = core::SnesToPc(gfxPointer);
|
||||
|
||||
for (int i = 0; i < 37; i++) {
|
||||
for (int j = 0; j < 8; j++) {
|
||||
mainGfx[i][j] = rom_[gfxPointer + (i * 8) + j];
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < 82; i++) {
|
||||
for (int j = 0; j < 4; j++) {
|
||||
roomGfx[i][j] = rom_[entrance_gfx_group + (i * 4) + j];
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < 144; i++) {
|
||||
for (int j = 0; j < 4; j++) {
|
||||
spriteGfx[i][j] = rom_[sprite_blockset_pointer + (i * 4) + j];
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < 72; i++) {
|
||||
for (int j = 0; j < 4; j++) {
|
||||
paletteGfx[i][j] = rom_[dungeons_palettes_groups + (i * 4) + j];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool Room::SaveGroupsToROM() {
|
||||
int gfxPointer =
|
||||
(rom_[gfx_groups_pointer + 1] << 8) + rom_[gfx_groups_pointer];
|
||||
gfxPointer = core::SnesToPc(gfxPointer);
|
||||
|
||||
for (int i = 0; i < 37; i++) {
|
||||
for (int j = 0; j < 8; j++) {
|
||||
rom_.Write(gfxPointer + (i * 8) + j, mainGfx[i][j]);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < 82; i++) {
|
||||
for (int j = 0; j < 4; j++) {
|
||||
rom_.Write(entrance_gfx_group + (i * 4) + j, roomGfx[i][j]);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < 144; i++) {
|
||||
for (int j = 0; j < 4; j++) {
|
||||
rom_.Write(sprite_blockset_pointer + (i * 4) + j, spriteGfx[i][j]);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < 72; i++) {
|
||||
for (int j = 0; j < 4; j++) {
|
||||
rom_.Write(dungeons_palettes_groups + (i * 4) + j, paletteGfx[i][j]);
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void Room::LoadChests() {}
|
||||
|
||||
void Room::LoadBlocks() {}
|
||||
@@ -20,12 +82,82 @@ void Room::LoadTorches() {}
|
||||
|
||||
void Room::LoadSecrets() {}
|
||||
|
||||
void Room::Resync() {}
|
||||
void Room::Resync() {}
|
||||
|
||||
void Room::LoadObjectsFromArray(int loc) {}
|
||||
|
||||
void Room::LoadSpritesFromArray(int loc) {}
|
||||
|
||||
void Room::LoadRoomGraphics(uchar entrance_blockset) {
|
||||
for (int i = 0; i < 8; i++) {
|
||||
blocks[i] = mainGfx[BackgroundTileset][i];
|
||||
if (i >= 6 && i <= 6) {
|
||||
// 3-6
|
||||
if (entrance_blockset != 0xFF) {
|
||||
// 6 is wrong for the entrance? -NOP need to fix that
|
||||
// TODO: Find why this is wrong - Thats because of the stairs need to
|
||||
// find a workaround
|
||||
if (roomGfx[entrance_blockset][i - 3] != 0) {
|
||||
blocks[i] = roomGfx[entrance_blockset][i - 3];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
blocks[8] = 115 + 0; // Static Sprites Blocksets (fairy,pot,ect...)
|
||||
blocks[9] = 115 + 10;
|
||||
blocks[10] = 115 + 6;
|
||||
blocks[11] = 115 + 7;
|
||||
for (int i = 0; i < 4; i++) {
|
||||
blocks[12 + i] = (uchar)(spriteGfx[SpriteTileset + 64][i] + 115);
|
||||
} // 12-16 sprites
|
||||
|
||||
auto newPdata = rom_.GetGraphicsBuffer();
|
||||
|
||||
uchar* sheetsData = current_graphics_.GetData();
|
||||
// Into "room gfx16" 16 of them
|
||||
|
||||
int sheetPos = 0;
|
||||
for (int i = 0; i < 16; i++) {
|
||||
int d = 0;
|
||||
int ioff = blocks[i] * 2048;
|
||||
while (d < 2048) {
|
||||
// NOTE LOAD BLOCKSETS SOMEWHERE FIRST
|
||||
uchar mapByte = newPdata[d + ioff];
|
||||
if (i < 4) // removed switch
|
||||
{
|
||||
mapByte += 0x88;
|
||||
} // Last line of 6, first line of 7 ?
|
||||
|
||||
sheetsData[d + sheetPos] = mapByte;
|
||||
d++;
|
||||
}
|
||||
|
||||
sheetPos += 2048;
|
||||
}
|
||||
|
||||
LoadAnimatedGraphics();
|
||||
}
|
||||
|
||||
void Room::LoadAnimatedGraphics() {
|
||||
int gfxanimatedPointer = core::SnesToPc(gfx_animated_pointer);
|
||||
|
||||
auto newPdata = rom_.GetGraphicsBuffer();
|
||||
|
||||
uchar* sheetsData = current_graphics_.GetData();
|
||||
int data = 0;
|
||||
while (data < 512) {
|
||||
uchar mapByte = newPdata[data + (92 * 2048) + (512 * animated_frame)];
|
||||
sheetsData[data + (7 * 2048)] = mapByte;
|
||||
|
||||
mapByte =
|
||||
newPdata[data + (rom_[gfxanimatedPointer + BackgroundTileset] * 2048) +
|
||||
(512 * animated_frame)];
|
||||
sheetsData[data + (7 * 2048) - 512] = mapByte;
|
||||
data++;
|
||||
}
|
||||
}
|
||||
|
||||
void Room::LoadRoomFromROM() {
|
||||
// Load dungeon header
|
||||
int headerPointer = core::SnesToPc(room_header_pointer);
|
||||
|
||||
@@ -13,6 +13,9 @@ namespace app {
|
||||
namespace zelda3 {
|
||||
namespace dungeon {
|
||||
|
||||
constexpr int entrance_gfx_group = 0x5D97;
|
||||
constexpr int gfx_animated_pointer = 0x10275; // JP 0x10624 //long pointer
|
||||
|
||||
class DungeonDestination {
|
||||
public:
|
||||
DungeonDestination(uint8_t i) : Index(i) {}
|
||||
@@ -85,6 +88,8 @@ class Room {
|
||||
Room() = default;
|
||||
|
||||
private:
|
||||
void LoadGfxGroups();
|
||||
bool SaveGroupsToROM();
|
||||
void LoadChests();
|
||||
void LoadBlocks();
|
||||
void LoadTorches();
|
||||
@@ -94,6 +99,9 @@ class Room {
|
||||
void LoadObjectsFromArray(int loc);
|
||||
void LoadSpritesFromArray(int loc);
|
||||
|
||||
void LoadRoomGraphics(uchar entrance_blockset = 0xFF);
|
||||
void LoadAnimatedGraphics();
|
||||
|
||||
void LoadRoomFromROM();
|
||||
|
||||
DungeonDestination Pits;
|
||||
@@ -102,6 +110,8 @@ class Room {
|
||||
DungeonDestination Stair3;
|
||||
DungeonDestination Stair4;
|
||||
|
||||
int animated_frame = 0;
|
||||
|
||||
int RoomID = 0;
|
||||
ushort MessageID = 0;
|
||||
uchar BackgroundTileset;
|
||||
@@ -111,6 +121,12 @@ class Room {
|
||||
uchar Floor1Graphics;
|
||||
uchar Floor2Graphics;
|
||||
uchar Layer2Mode;
|
||||
std::array<uchar, 16> blocks;
|
||||
|
||||
uint8_t mainGfx[37][8];
|
||||
uint8_t roomGfx[82][4];
|
||||
uint8_t spriteGfx[144][4];
|
||||
uint8_t paletteGfx[72][4];
|
||||
|
||||
// LayerMergeType LayerMerging;
|
||||
uchar Tag1;
|
||||
@@ -118,6 +134,8 @@ class Room {
|
||||
bool IsDark;
|
||||
|
||||
ROM rom_;
|
||||
|
||||
gfx::Bitmap current_graphics_;
|
||||
};
|
||||
|
||||
} // namespace dungeon
|
||||
|
||||
Reference in New Issue
Block a user