From 4824ad7490e705701105a0670fcaed0c0ced7b13 Mon Sep 17 00:00:00 2001 From: Diegoisawesome Date: Sat, 20 Jan 2018 14:39:32 -0600 Subject: [PATCH] Add special text characters and fix others --- datadump/global.c | 7 +++-- datadump/txtparse.c | 70 ++++++++++++++++++++++++++++++++++++--------- 2 files changed, 61 insertions(+), 16 deletions(-) diff --git a/datadump/global.c b/datadump/global.c index 006a984..8d29b0d 100644 --- a/datadump/global.c +++ b/datadump/global.c @@ -47,8 +47,11 @@ const char * text_table[] = { const unsigned char previewable[] = {0xff, 0xfb, 0xff, 0x7e, 0xff, 0x6f, 0x20, 0, 0, 0, 6, 0x3c, 0, 0x81, 0, 0, 0, 0, 0, 0, 0xfe, 0x7f, 0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x7f, 0x80}; -const char * colors[] = {"TRANSPARENT", "DARK_GREY", "RED", "GREEN", "BLUE", "YELLOW", "CYAN", "MAGENTA", - "LIGHT_GRAY", "BLACK", "BLACK2", "SILVER", "WHITE", "SKY_BLUE", "LIGHT_BLUE", "WHITE2"}; +/*const char * colors[] = {"TRANSPARENT", "DARK_GREY", "RED", "GREEN", "BLUE", "YELLOW", "CYAN", "MAGENTA", + "LIGHT_GRAY", "BLACK", "BLACK2", "SILVER", "WHITE", "SKY_BLUE", "LIGHT_BLUE", "WHITE2"};*/ +const char * colors[] = {"TRANSPARENT", "WHITE", "DARK_GREY", "LIGHT_GREY", "RED", "LIGHT_RED", "GREEN", + "LIGHT_GREEN", "BLUE", "LIGHT_BLUE", "DYNAMIC_COLOR1", "DYNAMIC_COLOR2", + "DYNAMIC_COLOR3", "DYNAMIC_COLOR4", "DYNAMIC_COLOR5", "DYNAMIC_COLOR6"}; const char * buffers[] = {NULL, "PLAYER", "STR_VAR_1", "STR_VAR_2", "STR_VAR_3", NULL, "RIVAL", "VERSION", "EVIL_TEAM", "GOOD_TEAM", "EVIL_LEADER", "GOOD_LEADER", "EVIL_LEGENDARY", "GOOD_LEGENDARY", NULL, NULL}; diff --git a/datadump/txtparse.c b/datadump/txtparse.c index 4799987..5ad0a4a 100644 --- a/datadump/txtparse.c +++ b/datadump/txtparse.c @@ -2,7 +2,7 @@ char * parse_buffer (const unsigned char * buffer, unsigned buffer_length) { unsigned char shift_state = 0; - unsigned char prev_value; + unsigned char prev_value[2]; char * result = malloc(1); *result = 0; unsigned length = 0; @@ -11,10 +11,17 @@ char * parse_buffer (const unsigned char * buffer, unsigned buffer_length) { for (pos = 0; pos < buffer_length; pos ++) switch (shift_state) { case 0: - if ((buffer[pos] & 0xfe) == 0xfc) - shift_state = buffer[pos]; - else - concatenate(&result, &length, text_table[buffer[pos]], NULL); + switch (buffer[pos]) + { + case 0xF9: + case 0xFC: + case 0xFD: + shift_state = buffer[pos]; + break; + default: + concatenate(&result, &length, text_table[buffer[pos]], NULL); + break; + } break; case 1: case 2: @@ -26,12 +33,12 @@ char * parse_buffer (const unsigned char * buffer, unsigned buffer_length) { shift_state = 0; break; case 4: - prev_value = buffer[pos]; - shift_state = 5; + prev_value[0] = buffer[pos]; + shift_state = 22; break; case 5: - concatenate(&result, &length, "{COLOR_HIGHLIGHT_SHADOW ", (prev_value > 15) ? temp : colors[prev_value], " ", - (buffer[pos] > 15) ? temp : colors[buffer[pos]], "}", NULL); + sprintf(temp, "%hhu", buffer[pos]); + concatenate(&result, &length, "{PALETTE ", temp, "}", NULL); shift_state = 0; break; case 6: @@ -43,6 +50,10 @@ char * parse_buffer (const unsigned char * buffer, unsigned buffer_length) { concatenate(&result, &length, "{PAUSE ", temp, "}", NULL); shift_state = 0; break; + case 11: + prev_value[0] = buffer[pos]; + shift_state = 24; + break; case 12: if (buffer[pos] < 250) concatenate(&result, &length, text_table[buffer[pos]], NULL); @@ -58,17 +69,48 @@ char * parse_buffer (const unsigned char * buffer, unsigned buffer_length) { shift_state = 0; break; case 16: - prev_value = buffer[pos]; - shift_state = 17; + prev_value[0] = buffer[pos]; + shift_state = 25; break; case 17: - sprintf(temp, "%02hhX%02hhX", buffer[pos], prev_value); - concatenate(&result, &length, "{PLAY_MUSIC 0x", temp, "}", NULL); + sprintf(temp, "%hhu", buffer[pos]); + concatenate(&result, &length, "{CLEAR ", temp, "}", NULL); + shift_state = 0; + break; + case 19: + sprintf(temp, "%hhu", buffer[pos]); + concatenate(&result, &length, "{CLEAR_TO ", temp, "}", NULL); + shift_state = 0; + break; + case 22: + prev_value[1] = buffer[pos]; + shift_state = 23; + break; + case 23: + concatenate(&result, &length, "{COLOR_HIGHLIGHT_SHADOW ", + (prev_value[0] > 15) ? temp : colors[prev_value[0]], " ", + (prev_value[1] > 15) ? temp : colors[prev_value[1]], " ", + (buffer[pos] > 15) ? temp : colors[buffer[pos]], "}", NULL); + shift_state = 0; + break; + case 24: + sprintf(temp, "%02hhX%02hhX", buffer[pos], prev_value[0]); + concatenate(&result, &length, "{PLAY_BGM 0x", temp, "}", NULL); + shift_state = 0; + break; + case 25: + sprintf(temp, "%02hhX%02hhX", buffer[pos], prev_value[0]); + concatenate(&result, &length, "{PLAY_SE 0x", temp, "}", NULL); + shift_state = 0; + break; + case 0xf9: + sprintf(temp, "%hhu", buffer[pos]); + concatenate(&result, &length, "{UNK_CTRL_F9 ", temp, "}", NULL); shift_state = 0; break; case 0xfc: switch (buffer[pos]) { - case 1: case 2: case 3: case 4: case 6: case 8: case 12: case 13: case 16: + case 1: case 2: case 3: case 4: case 5: case 6: case 8: case 11: case 12: case 13: case 16: case 17: case 19: shift_state = buffer[pos]; break; case 0: