Refactor NACT::message() to take first command byte

This commit is contained in:
kichikuou
2024-12-20 14:16:55 +09:00
parent 24c6041915
commit b1c917b89a
3 changed files with 16 additions and 18 deletions
+15 -14
View File
@@ -249,8 +249,7 @@ void NACT::execute()
break;
default:
if (is_message(cmd)) {
sco.ungetd();
message(0);
message(cmd);
} else {
sco.unknown_command(cmd);
}
@@ -290,21 +289,23 @@ void NACT::cmd_page_call()
output_console("\n%%%d:", next_page);
}
void NACT::message(uint8 terminator)
void NACT::message(uint8_t first_byte)
{
char buf[200];
if (terminator) { // SysEng
sco.get_syseng_string(buf, sizeof(buf), encoding.get(), terminator);
if (first_byte == '\'' || first_byte == '"') { // SysEng
sco.get_syseng_string(buf, sizeof(buf), encoding.get(), first_byte);
} else {
const uint8* begin = sco.ptr();
const uint8* p = begin;
while (is_message(*p))
p += encoding->mblen(*p);
int len = p - begin;
sco.skip(len);
strncpy(buf, reinterpret_cast<const char*>(begin), len);
buf[len] = '\0';
int i = 0;
uint8_t c = first_byte;
while (is_message(c)) {
int len = encoding->mblen(c);
buf[i++] = c;
for (int j = 1; j < len; ++j)
buf[i++] = sco.getd();
c = sco.getd();
}
sco.ungetd();
buf[i] = '\0';
}
ags->draw_text(buf, text_wait_enb);
+1 -1
View File
@@ -117,7 +117,7 @@ protected:
int tvar_index = 0;
int tvar_maxlen;
void message(uint8 terminator);
void message(uint8_t first_byte);
// Commands
virtual void cmd_calc() = 0;
-3
View File
@@ -16,9 +16,6 @@ public:
page_ = page;
cmd_addr_ = addr_ = addr;
}
size_t size() const { return data_.size(); }
uint8_t& operator[](int i) { return data_[i]; }
const uint8_t* ptr() const { return &data_[addr_]; }
int default_addr() { return data_[0] | data_[1] << 8; }
int page() const { return page_; }