From 59571f6089de04959f8bdd992c78ae18cec7f9fe Mon Sep 17 00:00:00 2001 From: Dominic Masters Date: Sun, 20 Feb 2022 10:41:00 -0800 Subject: [PATCH] Comitting progress --- src/conversation/textbox.c | 44 ++++++++++---------------------------- 1 file changed, 11 insertions(+), 33 deletions(-) diff --git a/src/conversation/textbox.c b/src/conversation/textbox.c index 6731eab..c9f21d6 100644 --- a/src/conversation/textbox.c +++ b/src/conversation/textbox.c @@ -21,7 +21,7 @@ inline void conversationTextboxInit() { TEXTBOX_STATE = 0; // Setup window data - move_win(7, SCREENHEIGHT - (TEXTBOX_HEIGHT_IN_TILES * 8)); + // move_win(7, SCREENHEIGHT - (TEXTBOX_HEIGHT_IN_TILES * 8)); set_win_data(FONT_DATA_POSITION, FONT_IMAGE_TILES, FONT_IMAGE); set_win_data(BORDER_DATA_POSITION, BORDER_IMAGE_TILES, BORDER_IMAGE); @@ -57,7 +57,7 @@ void conversationTextboxSetText(char *text) { for(i = 0; i < TEXTBOX_SCROLL_ROWS_MAX * TEXTBOX_CHARS_PER_ROW; i++) { TEXTBOX_TEXTS[i] = '4'; } - + // Reset textbox state TEXTBOX_STATE = TEXTBOX_STATE_VISIBLE; TEXTBOX_SCROLL = 0; @@ -68,10 +68,11 @@ void conversationTextboxSetText(char *text) { while((c = text[i]) != '\0') { if(c == ' ') { // Scan ahead and look at how many chars remain to the next space - k = i; - while((c2 = text[++k]) != '\0') { + k = i + 1; + while((c2 = text[k]) != '\0') { if(c2 == '\n' || c2 == ' ') break; if((k - rowStart) >= TEXTBOX_CHARS_PER_ROW) break; + k++; } // IF that number is less than the remaining chars on the current row, @@ -105,7 +106,7 @@ void conversationTextboxSetText(char *text) { } } set_win_tiles( - 1, 1, + 0x01, 0x01, TEXTBOX_WIDTH_IN_TILES - 0x02, TEXTBOX_HEIGHT_IN_TILES - 0x02, TEXTBOX_TILES ); @@ -117,49 +118,26 @@ void conversationTextboxSetText(char *text) { inline void conversationTextboxUpdate() { uint8_t i; char c; + uint8_t tiles[1]; // Is the textbox visible? - if(!(TEXTBOX_STATE & TEXTBOX_STATE_VISIBLE)) return; - - // Has the textbox finished scrolling? - // if(TEXTBOX_STATE & TEXTBOX_STATE_SCROLLED) { - // // Is the player attempting to close the textbox? - // if(INPUT_STATE & J_A) { - // TEXTBOX_STATE &= ~TEXTBOX_STATE_VISIBLE; - // HIDE_WIN; - // conversationQueueNext(); - // } - // return; - // } + if((TEXTBOX_STATE & TEXTBOX_STATE_VISIBLE) == 0) return; // Move to the next character. i = TEXTBOX_ROW_CURRENT * TEXTBOX_CHARS_PER_ROW; c = TEXTBOX_TEXTS[i+TEXTBOX_SCROLL]; - - // while((c = TEXTBOX_TEXTS[i+TEXTBOX_SCROLL]) == ' ') { - // TEXTBOX_SCROLL++; - - // if(TEXTBOX_SCROLL == TEXTBOX_CHARS_MAX) { - // c = '\0'; - // break; - // } - // } if(TEXTBOX_SCROLL == TEXTBOX_CHARS_MAX) { // TEXTBOX_ - } else if(c != '\0') { + } else { + tiles[0] = c - 33 + 4; set_win_tiles( 1 + (TEXTBOX_SCROLL % TEXTBOX_CHARS_PER_ROW), 1 + (TEXTBOX_SCROLL / TEXTBOX_CHARS_PER_ROW), 1, 1, - 0x04 + tiles ); TEXTBOX_SCROLL++; } - // // Update state. TODO: I actually don't really need this state, it's just here - // // incase I want to check if the state has scrolled later on? Doubt it though. - // if(TEXTBOX_SCROLL == TEXTBOX_TEXT_LENGTH) { - // TEXTBOX_STATE |= TEXTBOX_STATE_SCROLLED; - // } } \ No newline at end of file