Refactor MessageEditor: improve code readability and maintainability by adjusting formatting, updating variable names, and reorganizing includes
This commit is contained in:
@@ -301,8 +301,8 @@ void MessageEditor::ReadAllTextDataV2() {
|
|||||||
|
|
||||||
uint32_t address = Get24LocalFromPC(
|
uint32_t address = Get24LocalFromPC(
|
||||||
rom()->mutable_data(), kPointersDictionaries + (dictionary * 2));
|
rom()->mutable_data(), kPointersDictionaries + (dictionary * 2));
|
||||||
uint32_t address_end = Get24LocalFromPC(
|
uint32_t address_end =
|
||||||
rom()->mutable_data(),
|
Get24LocalFromPC(rom()->mutable_data(),
|
||||||
kPointersDictionaries + ((dictionary + 1) * 2));
|
kPointersDictionaries + ((dictionary + 1) * 2));
|
||||||
|
|
||||||
for (uint32_t i = address; i < address_end; i++) {
|
for (uint32_t i = address; i < address_end; i++) {
|
||||||
@@ -399,8 +399,8 @@ void MessageEditor::ReadAllTextData() {
|
|||||||
|
|
||||||
uint32_t address = Get24LocalFromPC(
|
uint32_t address = Get24LocalFromPC(
|
||||||
rom()->mutable_data(), kPointersDictionaries + (dictionary * 2));
|
rom()->mutable_data(), kPointersDictionaries + (dictionary * 2));
|
||||||
uint32_t address_end = Get24LocalFromPC(
|
uint32_t address_end =
|
||||||
rom()->mutable_data(),
|
Get24LocalFromPC(rom()->mutable_data(),
|
||||||
kPointersDictionaries + ((dictionary + 1) * 2));
|
kPointersDictionaries + ((dictionary + 1) * 2));
|
||||||
|
|
||||||
for (uint32_t i = address; i < address_end; i++) {
|
for (uint32_t i = address; i < address_end; i++) {
|
||||||
@@ -538,7 +538,7 @@ void MessageEditor::DrawCharacterToPreview(const std::vector<uint8_t> &text) {
|
|||||||
void MessageEditor::DrawMessagePreview() {
|
void MessageEditor::DrawMessagePreview() {
|
||||||
// From Parsing.
|
// From Parsing.
|
||||||
text_line_ = 0;
|
text_line_ = 0;
|
||||||
for (int i = 0; i < (172 * 4096); i++) {
|
for (int i = 0; i < kFontGfx16Size; i++) {
|
||||||
current_font_gfx16_data_[i] = 0;
|
current_font_gfx16_data_[i] = 0;
|
||||||
}
|
}
|
||||||
text_position_ = 0;
|
text_position_ = 0;
|
||||||
@@ -614,18 +614,17 @@ absl::Status MessageEditor::Save() {
|
|||||||
pos++;
|
pos++;
|
||||||
}
|
}
|
||||||
|
|
||||||
RETURN_IF_ERROR(rom()->WriteByte(
|
RETURN_IF_ERROR(rom()->WriteByte(pos++, kMessageTerminator));
|
||||||
pos++, kMessageTerminator)); // , true, "Terminator text"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Verify that we didn't go over the space available for the second block.
|
// Verify that we didn't go over the space available for the second block.
|
||||||
// 0x14BF available.
|
// 0x14BF available.
|
||||||
if ((in_second_bank & pos) > kTextData2End) {
|
if ((in_second_bank & pos) > kTextData2End) {
|
||||||
// rom()->data() = backup;
|
// TODO: Restore the backup.
|
||||||
return absl::InternalError(DisplayTextOverflowError(pos, false));
|
return absl::InternalError(DisplayTextOverflowError(pos, false));
|
||||||
}
|
}
|
||||||
|
|
||||||
RETURN_IF_ERROR(rom()->WriteByte(pos, 0xFF)); // , true, "End of text"
|
RETURN_IF_ERROR(rom()->WriteByte(pos, 0xFF));
|
||||||
|
|
||||||
return absl::OkStatus();
|
return absl::OkStatus();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,8 +6,8 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "absl/status/status.h"
|
#include "absl/status/status.h"
|
||||||
#include "app/editor/message/message_data.h"
|
|
||||||
#include "app/editor/editor.h"
|
#include "app/editor/editor.h"
|
||||||
|
#include "app/editor/message/message_data.h"
|
||||||
#include "app/gfx/bitmap.h"
|
#include "app/gfx/bitmap.h"
|
||||||
#include "app/gui/canvas.h"
|
#include "app/gui/canvas.h"
|
||||||
#include "app/rom.h"
|
#include "app/rom.h"
|
||||||
@@ -24,6 +24,7 @@ constexpr int kCurrentMessageWidth = 172;
|
|||||||
constexpr int kCurrentMessageHeight = 4096;
|
constexpr int kCurrentMessageHeight = 4096;
|
||||||
constexpr int kFontGfxMessageSize = 128;
|
constexpr int kFontGfxMessageSize = 128;
|
||||||
constexpr int kFontGfxMessageDepth = 8;
|
constexpr int kFontGfxMessageDepth = 8;
|
||||||
|
constexpr int kFontGfx16Size = 172 * 4096;
|
||||||
|
|
||||||
constexpr uint8_t kWidthArraySize = 100;
|
constexpr uint8_t kWidthArraySize = 100;
|
||||||
constexpr uint8_t kBlockTerminator = 0x80;
|
constexpr uint8_t kBlockTerminator = 0x80;
|
||||||
|
|||||||
Reference in New Issue
Block a user