Fixed flashing text issue, moved textbox to window layer.
This commit is contained in:
@@ -187,7 +187,7 @@ void main() {
|
||||
|
||||
// Fill screen white
|
||||
for(j = 0; j < GB_BACKGROUND_COLUMNS * GB_BACKGROUND_ROWS; j++) filled[j] = SPRITE_TILESET_BLACK_LOW;
|
||||
spriteBufferBackgroundLow(0x00, 0x00, GB_BACKGROUND_COLUMNS, GB_BACKGROUND_ROWS, filled);
|
||||
spriteBufferBackground(0x00, 0x00, GB_BACKGROUND_COLUMNS, GB_BACKGROUND_ROWS, filled);
|
||||
SCX_REG = 0x00;
|
||||
SCY_REG = 0x00;
|
||||
|
||||
|
@@ -44,7 +44,7 @@ void questionBoxSetOptions(char *title, char **options, uint8_t count) {
|
||||
|
||||
// Repurpose old array and draw arrow
|
||||
spaces[0] = spriteFontTileFromChar(QUESTION_BOX_CURSOR);
|
||||
spriteBufferBackgroundHigh(0x01, TEXTBOX_WIN_Y + 0x02, 1, 1, spaces);
|
||||
spriteBufferWindow(0x01, TEXTBOX_Y + 0x02, 1, 1, spaces);
|
||||
}
|
||||
|
||||
inline void questionBoxUpdate() {
|
||||
@@ -76,9 +76,9 @@ inline void questionBoxUpdate() {
|
||||
} else {
|
||||
tiles[0] = spriteFontTileFromChar(' ');
|
||||
}
|
||||
spriteBufferBackgroundHigh(
|
||||
spriteBufferWindow(
|
||||
0x01 + ((i % 0x02) * QUESTION_BOX_QUESTION_SPACES),
|
||||
TEXTBOX_WIN_Y + 0x02 + (i / 0x02),
|
||||
TEXTBOX_Y + 0x02 + (i / 0x02),
|
||||
1, 1,
|
||||
tiles
|
||||
);
|
||||
|
@@ -77,6 +77,8 @@ void conversationTextboxSetText(char *text) {
|
||||
// Now we have organized the string nicely we can prep for rendering. Fill the
|
||||
// tiles with blank chars.
|
||||
textboxFillBlank();
|
||||
WY_REG = TEXTBOX_WINDOW_Y * TILE_HEIGHT;
|
||||
SHOW_WIN;
|
||||
}
|
||||
|
||||
inline void textboxFillBlank() {
|
||||
@@ -86,8 +88,8 @@ inline void textboxFillBlank() {
|
||||
tiles, TEXTBOX_WIDTH_IN_TILES, TEXTBOX_HEIGHT_IN_TILES, SPRITE_TILESET_WHITE_HIGH
|
||||
);
|
||||
|
||||
spriteBufferBackgroundHigh(
|
||||
0x00, TEXTBOX_WIN_Y,
|
||||
spriteBufferWindow(
|
||||
0x00, TEXTBOX_Y,
|
||||
TEXTBOX_WIDTH_IN_TILES, TEXTBOX_HEIGHT_IN_TILES,
|
||||
tiles
|
||||
);
|
||||
@@ -108,6 +110,7 @@ inline void conversationTextboxUpdate() {
|
||||
if((TEXTBOX_ROW_COUNT - TEXTBOX_ROW_CURRENT) < TEXTBOX_TILES_ROWS) {
|
||||
TEXTBOX_STATE &= ~TEXTBOX_STATE_VISIBLE;
|
||||
HIDE_WIN;
|
||||
LCDC_REG |= LCDCF_BG8000;
|
||||
conversationQueueNext();
|
||||
return;
|
||||
}
|
||||
@@ -129,9 +132,9 @@ inline void conversationTextboxUpdate() {
|
||||
} else {
|
||||
tile = spriteFontTileFromChar(c);
|
||||
|
||||
spriteBufferBackgroundHigh(
|
||||
spriteBufferWindow(
|
||||
0x01 + (TEXTBOX_SCROLL % TEXTBOX_CHARS_PER_ROW),
|
||||
TEXTBOX_WIN_Y + 0x01 + (TEXTBOX_SCROLL / TEXTBOX_CHARS_PER_ROW),
|
||||
TEXTBOX_Y + 0x01 + (TEXTBOX_SCROLL / TEXTBOX_CHARS_PER_ROW),
|
||||
1, 1,
|
||||
&tile
|
||||
);
|
||||
|
@@ -32,7 +32,9 @@
|
||||
|
||||
#define TEXTBOX_SCROLL_ROWS_MAX 14
|
||||
|
||||
#define TEXTBOX_WIN_Y (18 - TEXTBOX_HEIGHT_IN_TILES)
|
||||
#define TEXTBOX_Y 0x00
|
||||
#define TEXTBOX_WINDOW_Y (18 - TEXTBOX_HEIGHT_IN_TILES)
|
||||
#define TEXTBOX_SCREEN_Y (TEXTBOX_WINDOW_Y + TEXTBOX_Y)
|
||||
|
||||
extern char TEXTBOX_TEXTS[TEXTBOX_SCROLL_ROWS_MAX * TEXTBOX_CHARS_PER_ROW];
|
||||
extern uint8_t TEXTBOX_ROW_COUNT;
|
||||
|
@@ -9,6 +9,6 @@
|
||||
#include "libs.h"
|
||||
#include "conversation/textbox.h"
|
||||
|
||||
#define INTERRUPT_TEXTBOX_VRAM ((TEXTBOX_WIN_Y * TILE_HEIGHT) - 1)
|
||||
#define INTERRUPT_TEXTBOX_VRAM ((TEXTBOX_SCREEN_Y * TILE_HEIGHT) - 1)
|
||||
|
||||
void interruptOnScanline();
|
@@ -15,4 +15,4 @@
|
||||
#include <string.h>
|
||||
|
||||
#define TILE_WIDTH 8
|
||||
#define TILE_HEIGHT 8
|
||||
#define TILE_HEIGHT TILE_WIDTH
|
16
src/main.c
16
src/main.c
@@ -18,11 +18,21 @@ void main() {
|
||||
// Create a critical section for some video stuff
|
||||
CRITICAL {
|
||||
DISPLAY_OFF;
|
||||
LCDC_REG = LCDCF_OFF | LCDCF_BG8000 | LCDCF_BG9800 | LCDCF_BGON;
|
||||
LCDC_REG = LCDCF_OFF | LCDCF_WIN9C00 | LCDCF_BG8000 | LCDCF_BG9800 | LCDCF_BGON;
|
||||
/*
|
||||
* LCD = Off
|
||||
* WindowBank = 0x9C00
|
||||
* BG Chr = 0x8800
|
||||
* BG Bank = 0x9800
|
||||
* BG = On
|
||||
*/
|
||||
|
||||
STAT_REG |= STATF_LYC;
|
||||
LYC_REG = 0x00;
|
||||
SCX_REG = 0x00;
|
||||
SCY_REG = 0x00;
|
||||
WX_REG = TILE_WIDTH;
|
||||
// WY_REG = 0x00;
|
||||
add_LCD(interruptOnScanline);
|
||||
}
|
||||
set_interrupts(VBL_IFLAG | LCD_IFLAG);
|
||||
@@ -47,12 +57,12 @@ void main() {
|
||||
for(j = 0; j < GB_BACKGROUND_COLUMNS * GB_BACKGROUND_ROWS; j++) {
|
||||
filled[j] = SPRITE_TILESET_WHITE_LOW;
|
||||
}
|
||||
spriteBufferBackgroundLow(0x00, 0x00, GB_BACKGROUND_COLUMNS, GB_BACKGROUND_ROWS, filled);
|
||||
spriteBufferBackground(0x00, 0x00, GB_BACKGROUND_COLUMNS, GB_BACKGROUND_ROWS, filled);
|
||||
|
||||
// Card Test
|
||||
uint8_t cardTiles[SPRITE_CARD_TILE_COUNT];
|
||||
spriteCardBufferTiles(cardTiles, CARD_SPADES_QUEEN);
|
||||
spriteBufferBackgroundLow(0x00, 0x00, SPRITE_CARD_WIDTH, SPRITE_CARD_HEIGHT, cardTiles);
|
||||
spriteBufferBackground(0x00, 0x00, SPRITE_CARD_WIDTH, SPRITE_CARD_HEIGHT, cardTiles);
|
||||
|
||||
// Now turn the screen on
|
||||
DISPLAY_ON;
|
||||
|
@@ -20,7 +20,7 @@ inline void spriteBufferHigh(uint8_t position, uint8_t length, uint8_t *tiles) {
|
||||
vmemcpy(vramPosition, tiles, SPRITE_VRAM_SIZE_PER_TILE * length);
|
||||
}
|
||||
|
||||
inline void spriteBufferBackgroundLow(
|
||||
inline void spriteBufferBackground(
|
||||
uint8_t x, uint8_t y,
|
||||
uint8_t width, uint8_t height,
|
||||
uint8_t *tiles
|
||||
@@ -28,12 +28,11 @@ inline void spriteBufferBackgroundLow(
|
||||
set_tiles(
|
||||
x, y,
|
||||
height, width,// Bug?
|
||||
SPRITE_VRAM_TILEMAP_LOW,
|
||||
SPRITE_VRAM_TILEMAP_BACKGROUND_LOW,
|
||||
tiles
|
||||
);
|
||||
}
|
||||
|
||||
inline void spriteBufferBackgroundHigh(
|
||||
inline void spriteBufferWindow(
|
||||
uint8_t x, uint8_t y,
|
||||
uint8_t width, uint8_t height,
|
||||
uint8_t *tiles
|
||||
@@ -41,7 +40,7 @@ inline void spriteBufferBackgroundHigh(
|
||||
set_tiles(
|
||||
x, y,
|
||||
height, width,// Bug?
|
||||
SPRITE_VRAM_TILEMAP_LOW,
|
||||
SPRITE_VRAM_TILEMAP_WINDOW_LOW,
|
||||
tiles
|
||||
);
|
||||
}
|
@@ -12,7 +12,8 @@
|
||||
#define SPRITE_VRAM_HIGH 0x8800
|
||||
#define SPRITE_VRAM_DISTANCE_BETWEEN_LOW_AND_HIGH 0x0800
|
||||
#define SPRITE_VRAM_SIZE_PER_TILE 0x10
|
||||
#define SPRITE_VRAM_TILEMAP_LOW 0x9800
|
||||
#define SPRITE_VRAM_TILEMAP_BACKGROUND_LOW 0x9800
|
||||
#define SPRITE_VRAM_TILEMAP_WINDOW_LOW 0x9C00
|
||||
|
||||
/**
|
||||
* Buffer tiles data into VRAM in the HIGH space (The upper bounds of VRAM)
|
||||
@@ -32,13 +33,13 @@ inline void spriteBufferHigh(uint8_t position, uint8_t length, uint8_t *tiles);
|
||||
*/
|
||||
inline void spriteBufferLow(uint8_t position, uint8_t length, uint8_t *tiles);
|
||||
|
||||
inline void spriteBufferBackgroundLow(
|
||||
inline void spriteBufferBackground(
|
||||
uint8_t x, uint8_t y,
|
||||
uint8_t width, uint8_t height,
|
||||
uint8_t *tiles
|
||||
);
|
||||
|
||||
inline void spriteBufferBackgroundHigh(
|
||||
inline void spriteBufferWindow(
|
||||
uint8_t x, uint8_t y,
|
||||
uint8_t width, uint8_t height,
|
||||
uint8_t *tiles
|
||||
|
Reference in New Issue
Block a user