diff --git a/src/app/editor/message/message_editor.cc b/src/app/editor/message/message_editor.cc index ff022558..ee39d0b6 100644 --- a/src/app/editor/message/message_editor.cc +++ b/src/app/editor/message/message_editor.cc @@ -611,6 +611,36 @@ string MessageEditor::ParseTextDataByte(uint8_t value) { return ""; } +void MessageEditor::DrawTileToPreview(int x, int y, int srcx, int srcy, int pal, + bool mirror_x, bool mirror_y, int sizex, + int sizey) { + int drawid = srcx + (srcy * 32); + for (int yl = 0; yl < sizey * 8; yl++) { + for (int xl = 0; xl < 4; xl++) { + int mx = xl; + int my = yl; + + // Formula information to get tile index position in the array. + // ((ID / nbrofXtiles) * (imgwidth/2) + (ID - ((ID/16)*16) )) + int tx = ((drawid / 16) * 512) + ((drawid - ((drawid / 16) * 16)) * 4); + uint8_t pixel = font_gfx16_data[tx + (yl * 64) + xl]; + + // nx,ny = object position, xx,yy = tile position, xl,yl = pixel + // position + int index = x + (y * 172) + (mx * 2) + (my * 172); + if ((pixel & 0x0F) != 0) { + current_font_gfx16_data_[index + 1] = + (uint8_t)((pixel & 0x0F) + (0 * 4)); + } + + if (((pixel >> 4) & 0x0F) != 0) { + current_font_gfx16_data_[index + 0] = + (uint8_t)(((pixel >> 4) & 0x0F) + (0 * 4)); + } + } + } +} + void MessageEditor::DrawStringToPreview(string str) { for (const auto c : str) { DrawCharacterToPreview(c); @@ -690,36 +720,6 @@ void MessageEditor::DrawMessagePreview() // From Parsing. shown_lines = 0; } -void MessageEditor::DrawTileToPreview(int x, int y, int srcx, int srcy, int pal, - bool mirror_x, bool mirror_y, int sizex, - int sizey) { - int drawid = srcx + (srcy * 32); - for (int yl = 0; yl < sizey * 8; yl++) { - for (int xl = 0; xl < 4; xl++) { - int mx = xl; - int my = yl; - - // Formula information to get tile index position in the array. - // ((ID / nbrofXtiles) * (imgwidth/2) + (ID - ((ID/16)*16) )) - int tx = ((drawid / 16) * 512) + ((drawid - ((drawid / 16) * 16)) * 4); - uint8_t pixel = font_gfx16_data[tx + (yl * 64) + xl]; - - // nx,ny = object position, xx,yy = tile position, xl,yl = pixel - // position - int index = x + (y * 172) + (mx * 2) + (my * 172); - if ((pixel & 0x0F) != 0) { - current_font_gfx16_data_[index + 1] = - (uint8_t)((pixel & 0x0F) + (0 * 4)); - } - - if (((pixel >> 4) & 0x0F) != 0) { - current_font_gfx16_data_[index + 0] = - (uint8_t)(((pixel >> 4) & 0x0F) + (0 * 4)); - } - } - } -} - std::string MessageEditor::DisplayTextOverflowError(int pos, bool bank) { int space = bank ? kTextDataEnd - kTextData : kTextData2End - kTextData2; string bankSTR = bank ? "1st" : "2nd"; diff --git a/src/app/editor/overworld/refresh.cc b/src/app/editor/overworld/refresh.cc index 0241bd79..bdfaa566 100644 --- a/src/app/editor/overworld/refresh.cc +++ b/src/app/editor/overworld/refresh.cc @@ -11,15 +11,8 @@ void OverworldEditor::RefreshChildMap(int map_index) { status_ = overworld_.mutable_overworld_map(map_index)->BuildTiles16Gfx( overworld_.tiles16().size()); PRINT_IF_ERROR(status_); - OWBlockset blockset; - if (current_world_ == 0) { - blockset = overworld_.map_tiles().light_world; - } else if (current_world_ == 1) { - blockset = overworld_.map_tiles().dark_world; - } else { - blockset = overworld_.map_tiles().special_world; - } - status_ = overworld_.mutable_overworld_map(map_index)->BuildBitmap(blockset); + status_ = overworld_.mutable_overworld_map(map_index)->BuildBitmap( + overworld_.GetMapTiles(current_world_)); maps_bmp_[map_index].set_data( overworld_.mutable_overworld_map(map_index)->bitmap_data()); maps_bmp_[map_index].set_modified(true); @@ -64,8 +57,7 @@ void OverworldEditor::RefreshOverworldMap() { absl::Status OverworldEditor::RefreshMapPalette() { RETURN_IF_ERROR( overworld_.mutable_overworld_map(current_map_)->LoadPalette()); - const auto current_map_palette = - overworld_.overworld_map(current_map_)->current_palette(); + const auto current_map_palette = overworld_.AreaPalette(); if (overworld_.overworld_map(current_map_)->is_large_map()) { // We need to update the map and its siblings if it's a large map