Finished textbox, learned that windows aren't transparent
This commit is contained in:
Binary file not shown.
Before Width: | Height: | Size: 737 B After Width: | Height: | Size: 725 B |
@@ -21,7 +21,7 @@ inline void conversationTextboxInit() {
|
|||||||
TEXTBOX_STATE = 0;
|
TEXTBOX_STATE = 0;
|
||||||
|
|
||||||
// Setup window data
|
// 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(FONT_DATA_POSITION, FONT_IMAGE_TILES, FONT_IMAGE);
|
||||||
set_win_data(BORDER_DATA_POSITION, BORDER_IMAGE_TILES, BORDER_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;
|
TEXTBOX_TILES[TEXTBOX_WIDTH_IN_TILES * (i+1) - 1] = BORDER_TILE_CENTER_RIGHT;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Setup tiles.
|
|
||||||
set_win_tiles(
|
set_win_tiles(
|
||||||
0, 0,
|
0x00, 0x00,
|
||||||
TEXTBOX_WIDTH_IN_TILES, TEXTBOX_HEIGHT_IN_TILES,
|
TEXTBOX_WIDTH_IN_TILES, TEXTBOX_HEIGHT_IN_TILES,
|
||||||
TEXTBOX_TILES
|
TEXTBOX_TILES
|
||||||
);
|
);
|
||||||
@@ -53,7 +52,10 @@ void conversationTextboxSetText(char *text) {
|
|||||||
uint8_t i, j, k, rowStart, stateFlags;
|
uint8_t i, j, k, rowStart, stateFlags;
|
||||||
char c, c2;
|
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++) {
|
for(i = 0; i < TEXTBOX_SCROLL_ROWS_MAX * TEXTBOX_CHARS_PER_ROW; i++) {
|
||||||
|
break;
|
||||||
TEXTBOX_TEXTS[i] = ' ';
|
TEXTBOX_TEXTS[i] = ' ';
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -66,9 +68,9 @@ void conversationTextboxSetText(char *text) {
|
|||||||
|
|
||||||
// Copy source text to buffer, also determine wordwrapping here.
|
// Copy source text to buffer, also determine wordwrapping here.
|
||||||
i = 0, j = 0, rowStart = 0, stateFlags = 0;
|
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 == ' ') {
|
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;
|
k = i + 1;
|
||||||
while(
|
while(
|
||||||
(c2 = text[k]) != '\0' &&
|
(c2 = text[k]) != '\0' &&
|
||||||
@@ -86,16 +88,18 @@ void conversationTextboxSetText(char *text) {
|
|||||||
stateFlags |= 1 << 0;
|
stateFlags |= 1 << 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Do we need to newline?
|
// Do we need to insert newline where we are currently?
|
||||||
if((stateFlags & (1 << 0)) != 0) {
|
if((stateFlags & (1 << 0)) != 0) {
|
||||||
stateFlags &= ~(1 << 0);
|
stateFlags &= ~(1 << 0);// Remove newline flag
|
||||||
rowStart = i;
|
|
||||||
j = ((j / TEXTBOX_CHARS_PER_ROW) + 1) * TEXTBOX_CHARS_PER_ROW;
|
|
||||||
i++;
|
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++;
|
TEXTBOX_ROW_COUNT++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Insert the character
|
||||||
TEXTBOX_TEXTS[j] = c;
|
TEXTBOX_TEXTS[j] = c;
|
||||||
i++;
|
i++;
|
||||||
j++;
|
j++;
|
||||||
@@ -162,8 +166,8 @@ inline void conversationTextboxUpdate() {
|
|||||||
} else {
|
} else {
|
||||||
tiles[0] = c - 33 + FONT_DATA_POSITION;
|
tiles[0] = c - 33 + FONT_DATA_POSITION;
|
||||||
set_win_tiles(
|
set_win_tiles(
|
||||||
1 + (TEXTBOX_SCROLL % TEXTBOX_CHARS_PER_ROW),
|
0x01 + (TEXTBOX_SCROLL % TEXTBOX_CHARS_PER_ROW),
|
||||||
1 + (TEXTBOX_SCROLL / TEXTBOX_CHARS_PER_ROW),
|
0x01 + (TEXTBOX_SCROLL / TEXTBOX_CHARS_PER_ROW),
|
||||||
1, 1,
|
1, 1,
|
||||||
tiles
|
tiles
|
||||||
);
|
);
|
||||||
|
@@ -41,7 +41,7 @@
|
|||||||
#define TEXTBOX_TILES_ROWS 3
|
#define TEXTBOX_TILES_ROWS 3
|
||||||
#define TEXTBOX_TILE_BLANK COMMON_TILE_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
|
// STR_ ## name ## _DATA, STR_ ## name ## _LENGTH
|
||||||
#define conversationTextboxString(name) conversationTextboxSetText(\
|
#define conversationTextboxString(name) conversationTextboxSetText(\
|
||||||
|
19
src/main.c
19
src/main.c
@@ -137,8 +137,9 @@ void main() {
|
|||||||
// Set up the GAMEBOY's registers.
|
// Set up the GAMEBOY's registers.
|
||||||
disable_interrupts();
|
disable_interrupts();
|
||||||
DISPLAY_OFF;
|
DISPLAY_OFF;
|
||||||
LCDC_REG = LCDCF_OFF | LCDCF_WIN9C00 | LCDCF_BG8800 | LCDCF_BG9800 | LCDCF_BGON;
|
LCDC_REG = LCDCF_OFF | LCDCF_WIN9C00 | LCDCF_WINON | LCDCF_BG8800 | LCDCF_BG9800 | LCDCF_BGON;
|
||||||
BGP_REG = 0xE4U;
|
// Set the background color palette register
|
||||||
|
BGP_REG = OBP0_REG = OBP1_REG = 0xE4U;
|
||||||
|
|
||||||
// Init the random seed
|
// Init the random seed
|
||||||
initarand(DIV_REG);
|
initarand(DIV_REG);
|
||||||
@@ -154,23 +155,21 @@ void main() {
|
|||||||
// pokerInit();
|
// pokerInit();
|
||||||
|
|
||||||
// Fill screen white
|
// 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);
|
set_bkg_tiles(0x00, 0x00, GB_BACKGROUND_COLUMNS, GB_BACKGROUND_ROWS, filled);
|
||||||
SCX_REG = 0x00;
|
SCX_REG = 0x00;
|
||||||
SCY_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
|
// Now turn the screen on
|
||||||
DISPLAY_ON;
|
DISPLAY_ON;
|
||||||
enable_interrupts();
|
enable_interrupts();
|
||||||
wait_vbl_done();
|
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
|
// Begin the loop
|
||||||
while(1) {
|
while(1) {
|
||||||
// Wait for VSYNC
|
// Wait for VSYNC
|
||||||
|
@@ -10,6 +10,8 @@
|
|||||||
#include "libs.h"
|
#include "libs.h"
|
||||||
#include "time.h"
|
#include "time.h"
|
||||||
|
|
||||||
|
#include "SM.h"
|
||||||
|
|
||||||
#include "display/common.h"
|
#include "display/common.h"
|
||||||
#include "display/tilemap.h"
|
#include "display/tilemap.h"
|
||||||
#include "poker/poker.h"
|
#include "poker/poker.h"
|
||||||
|
Reference in New Issue
Block a user