This commit is contained in:
2022-01-04 14:47:34 -08:00
parent c882f07089
commit c9ebb85d13
25 changed files with 297 additions and 302 deletions

View File

@@ -6,58 +6,30 @@
*/
#include "libs.h"
#include "text.h"
#include "textbox.h"
#include "time.h"
#include "common_tiles.h"
const uint8_t std_data[] = {
/* Basic tiles (0xFC to 0xFF) */
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,
0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
};
#define NBDFRAMES 0x18 /* Nb frames for the door */
#define NBSFRAMES 0x07 /* Nb frames for the sprite */
#define WINSZX 0x80 /* Size of the picture in the window */
#define WINSZY 0x50
#define MINWINX (MAXWNDPOSX-WINSZX+1) /* Bounds of the window origin */
#define MINWINY (MAXWNDPOSY-WINSZY+1)
#define MAXWINX MAXWNDPOSX
#define MAXWINY MAXWNDPOSY
#define FADESTEP 0x10 /* Nb steps for the fading effect */
#define STARTFADE (0x06*FADESTEP) /* Initial value for the fading effect */
#define CLOSED 0x00
#define OPENING 0x01
#define OPENED 0x02
#define CLOSING 0x03
static uint8_t time = 0;/* Global "time" value (counter) */
void main() {
uint8_t i;
int16_t j;
uint8_t filled[0x20*0x20];
disable_interrupts();
DISPLAY_OFF;
LCDC_REG = LCDCF_OFF | LCDCF_BG8800 | LCDCF_BG9800 | LCDCF_BGON;
/*
* LCD = Off
* BG Chr = 0x8800
* BG Bank = 0x9800
* BG = On
*/
BGP_REG = 0xE4U;
LCDC_REG = LCDCF_OFF | LCDCF_WIN9C00 | LCDCF_BG8800 | LCDCF_BG9800 | LCDCF_BGON;
BGP_REG = OBP0_REG = OBP1_REG = 0xE4U;
set_bkg_data(0x00, 0x04, std_data);
set_bkg_data(0x04, FONT_TILE_COUNT, FONT);
// Upload the common tiles.
set_bkg_data(0x00, COMMON_TILE_COUNT, COMMON_TILES);
// Init the textbox
textboxInit();
// Fill screen white
uint8_t filled[0x20*0x20];
for(j = 0; j < 0x20*0x20; j++) {
filled[j] = 0x00;
}
for(j = 0; j < 0x20*0x20; j++) filled[j] = COMMON_TILE_0;
set_bkg_tiles(0x00, 0x00, 0x20, 0x20, filled);
SCX_REG = 0x00;
SCY_REG = 0x00;
@@ -65,18 +37,12 @@ void main() {
enable_interrupts();
wait_vbl_done();
// Now set BKG tiles
uint8_t bkg_tiles[FONT_TILE_COUNT];
for(i = 0; i < FONT_TILE_COUNT; i++) {
bkg_tiles[i] = i;
}
set_bkg_tiles(0, 0, 0x08, 0x08, bkg_tiles);
// Testing.
textboxSetText("HELLO WORLD.\nHOW ARE YOU?", 25);
while(1) {
/* Skip four VBLs (slow down animation) */
for(i = 0; i < 4; i++) {
wait_vbl_done();
}
wait_vbl_done();
textboxUpdate();
time++;
}
}