Finished textbox, learned that windows aren't transparent

This commit is contained in:
2022-04-20 23:38:14 -07:00
parent 1fa9cf453e
commit 45228018f2
5 changed files with 27 additions and 22 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 737 B

After

Width:  |  Height:  |  Size: 725 B

View File

@@ -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);
@@ -41,9 +41,8 @@ inline void conversationTextboxInit() {
TEXTBOX_TILES[TEXTBOX_WIDTH_IN_TILES * (i+1) - 1] = BORDER_TILE_CENTER_RIGHT;
}
// Setup tiles.
set_win_tiles(
0, 0,
0x00, 0x00,
TEXTBOX_WIDTH_IN_TILES, TEXTBOX_HEIGHT_IN_TILES,
TEXTBOX_TILES
);
@@ -53,7 +52,10 @@ void conversationTextboxSetText(char *text) {
uint8_t i, j, k, rowStart, stateFlags;
char c, c2;
// Begin by filling the textbox text chars with whitespace to begin.
// TODO: I'm pretty sure I can move this lower and optimize.
for(i = 0; i < TEXTBOX_SCROLL_ROWS_MAX * TEXTBOX_CHARS_PER_ROW; i++) {
break;
TEXTBOX_TEXTS[i] = ' ';
}
@@ -66,9 +68,9 @@ void conversationTextboxSetText(char *text) {
// Copy source text to buffer, also determine wordwrapping here.
i = 0, j = 0, rowStart = 0, stateFlags = 0;
while((c = text[i]) != '\0') {
while((c = text[i]) != '\0') {// "For each char in string"
if(c == ' ') {
// Scan ahead and look at how many chars remain to the next space
// Scan ahead and look at how many chars remain to the next space.
k = i + 1;
while(
(c2 = text[k]) != '\0' &&
@@ -86,16 +88,18 @@ void conversationTextboxSetText(char *text) {
stateFlags |= 1 << 0;
}
// Do we need to newline?
// Do we need to insert newline where we are currently?
if((stateFlags & (1 << 0)) != 0) {
stateFlags &= ~(1 << 0);
rowStart = i;
j = ((j / TEXTBOX_CHARS_PER_ROW) + 1) * TEXTBOX_CHARS_PER_ROW;
stateFlags &= ~(1 << 0);// Remove newline flag
i++;
rowStart = i;// Update the row start (Should this be i+1?)
//TODO: can I optimize the next line by using rowStart somehow?
j = ((j / TEXTBOX_CHARS_PER_ROW) + 1) * TEXTBOX_CHARS_PER_ROW;// Update destination character position.
TEXTBOX_ROW_COUNT++;
continue;
}
// Insert the character
TEXTBOX_TEXTS[j] = c;
i++;
j++;
@@ -162,8 +166,8 @@ inline void conversationTextboxUpdate() {
} else {
tiles[0] = c - 33 + FONT_DATA_POSITION;
set_win_tiles(
1 + (TEXTBOX_SCROLL % TEXTBOX_CHARS_PER_ROW),
1 + (TEXTBOX_SCROLL / TEXTBOX_CHARS_PER_ROW),
0x01 + (TEXTBOX_SCROLL % TEXTBOX_CHARS_PER_ROW),
0x01 + (TEXTBOX_SCROLL / TEXTBOX_CHARS_PER_ROW),
1, 1,
tiles
);

View File

@@ -41,7 +41,7 @@
#define TEXTBOX_TILES_ROWS 3
#define TEXTBOX_TILE_BLANK COMMON_TILE_3
#define TEXTBOX_SCROLL_ROWS_MAX 9
#define TEXTBOX_SCROLL_ROWS_MAX 14
// STR_ ## name ## _DATA, STR_ ## name ## _LENGTH
#define conversationTextboxString(name) conversationTextboxSetText(\

View File

@@ -137,8 +137,9 @@ void main() {
// Set up the GAMEBOY's registers.
disable_interrupts();
DISPLAY_OFF;
LCDC_REG = LCDCF_OFF | LCDCF_WIN9C00 | LCDCF_BG8800 | LCDCF_BG9800 | LCDCF_BGON;
BGP_REG = 0xE4U;
LCDC_REG = LCDCF_OFF | LCDCF_WIN9C00 | LCDCF_WINON | LCDCF_BG8800 | LCDCF_BG9800 | LCDCF_BGON;
// Set the background color palette register
BGP_REG = OBP0_REG = OBP1_REG = 0xE4U;
// Init the random seed
initarand(DIV_REG);
@@ -154,23 +155,21 @@ void main() {
// pokerInit();
// Fill screen white
for(j = 0; j < 0x20*0x20; j++) filled[j] = COMMON_TILE_3;
for(j = 0; j < GB_BACKGROUND_COLUMNS * GB_BACKGROUND_ROWS; j++) filled[j] = COMMON_TILE_3;
set_bkg_tiles(0x00, 0x00, GB_BACKGROUND_COLUMNS, GB_BACKGROUND_ROWS, filled);
SCX_REG = 0x00;
SCY_REG = 0x00;
// Alright begin the game logic here.
// conversationQueueNext();
char DEBUG_TEXT[] = "Hello World\nThe quick brown fox jumps over the lazy dog. How now brown cow? The fitness gram pacer test";
conversationTextboxSetText(DEBUG_TEXT);
// Now turn the screen on
DISPLAY_ON;
enable_interrupts();
wait_vbl_done();
// Alright begin the game logic here.
// conversationQueueNext();
char DEBUG_TEXT[] = "Hello World\nThe quick brown fox jumps over the lazy dog. How now brown cow? The fitness gram pacer test is a";
// uint8_t DEBUG_TEXT_LENGTH = strlen(DEBUG_TEXT);
// for(j = 0; j < DEBUG_TEXT_LENGTH; j++) DEBUG_TEXT[j] = DEBUG_TEXT[j] - 33 + 4;
conversationTextboxSetText(DEBUG_TEXT);
// Begin the loop
while(1) {
// Wait for VSYNC

View File

@@ -10,6 +10,8 @@
#include "libs.h"
#include "time.h"
#include "SM.h"
#include "display/common.h"
#include "display/tilemap.h"
#include "poker/poker.h"