diff --git a/.gitignore b/.gitignore index 8aeb3ee..2babf3f 100644 --- a/.gitignore +++ b/.gitignore @@ -76,4 +76,7 @@ yarn.lock *.log obj -res \ No newline at end of file +res + +./out.c +./out.c.png \ No newline at end of file diff --git a/Font.aseprite b/Font.aseprite deleted file mode 100644 index 5926422..0000000 Binary files a/Font.aseprite and /dev/null differ diff --git a/data.png b/data.png deleted file mode 100644 index a77562e..0000000 Binary files a/data.png and /dev/null differ diff --git a/font.png b/font.png deleted file mode 100644 index c900127..0000000 Binary files a/font.png and /dev/null differ diff --git a/images/Font.aseprite b/images/Font.aseprite new file mode 100644 index 0000000..e93a76e Binary files /dev/null and b/images/Font.aseprite differ diff --git a/images/font.png b/images/font.png new file mode 100644 index 0000000..7d2999e Binary files /dev/null and b/images/font.png differ diff --git a/out.c b/out.c deleted file mode 100644 index db51898..0000000 --- a/out.c +++ /dev/null @@ -1,72 +0,0 @@ -#include "../libs.h" - -#define IMAGE_WIDTH 64 -#define IMAGE_HEIGHT 64 -#define IMAGE_TILES 64 - -const uint8_t IMAGE[] = { - 0x06,0x06,0x0E,0x0E,0x1E,0x1E,0x1C,0x1C,0x38,0x38,0x30,0x30,0x00,0x00,0x40,0x40, - 0x48,0x48,0x48,0x48,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x24,0x24,0x00,0x3E,0x24,0x64,0x00,0x3C,0x24,0x26,0x24,0x66,0x00,0x3C,0x24,0x24, - 0x02,0x02,0x44,0x44,0x64,0x64,0x08,0x08,0x10,0x10,0x20,0x20,0x26,0x26,0x44,0x44, - 0x38,0x38,0x44,0x44,0x44,0x44,0x38,0x38,0x30,0x30,0x4A,0x4A,0x44,0x44,0x3A,0x3A, - 0x10,0x10,0x10,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x08,0x08,0x10,0x10,0x10,0x10,0x20,0x20,0x20,0x20,0x10,0x10,0x10,0x10,0x08,0x08, - 0x10,0x10,0x08,0x08,0x08,0x08,0x04,0x04,0x04,0x04,0x08,0x08,0x08,0x08,0x10,0x10, - 0x10,0x10,0x38,0x38,0x10,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x10,0x10,0x10,0x10,0x7C,0x7C,0x10,0x10,0x10,0x10,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x40,0x40, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7E,0x7E,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x40, - 0x02,0x02,0x04,0x04,0x04,0x04,0x08,0x08,0x10,0x10,0x20,0x20,0x20,0x20,0x40,0x40, - 0x3C,0x3C,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x3C,0x3C, - 0x18,0x18,0x38,0x38,0x78,0x78,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x7E,0x7E, - 0x3C,0x3C,0x66,0x66,0x66,0x66,0x06,0x06,0x1C,0x1C,0x38,0x38,0x70,0x70,0x7E,0x7E, - 0x3C,0x3C,0x66,0x66,0x66,0x66,0x0C,0x0C,0x0E,0x0E,0x66,0x66,0x66,0x66,0x3C,0x3C, - 0x0E,0x0E,0x1E,0x1E,0x36,0x36,0x66,0x66,0x7E,0x7E,0x06,0x06,0x06,0x06,0x06,0x06, - 0x7E,0x7E,0x60,0x60,0x60,0x60,0x7C,0x7C,0x06,0x06,0x66,0x66,0x66,0x66,0x3C,0x3C, - 0x3C,0x3C,0x66,0x66,0x60,0x60,0x7C,0x7C,0x66,0x66,0x66,0x66,0x66,0x66,0x3C,0x3C, - 0x7E,0x7E,0x06,0x06,0x06,0x06,0x0C,0x0C,0x0C,0x0C,0x18,0x18,0x38,0x38,0x30,0x30, - 0x3C,0x3C,0x66,0x66,0x66,0x66,0x3C,0x3C,0x66,0x66,0x66,0x66,0x66,0x66,0x3C,0x3C, - 0x3E,0x3E,0x66,0x66,0x66,0x66,0x66,0x66,0x3E,0x3E,0x06,0x06,0x06,0x06,0x06,0x06, - 0x00,0x00,0x18,0x18,0x18,0x18,0x00,0x00,0x00,0x00,0x18,0x18,0x18,0x18,0x00,0x00, - 0x00,0x00,0x18,0x18,0x18,0x18,0x00,0x00,0x00,0x00,0x18,0x18,0x08,0x08,0x10,0x10, - 0x00,0x00,0x00,0x00,0x08,0x08,0x10,0x10,0x20,0x20,0x10,0x10,0x08,0x08,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x7E,0x7E,0x00,0x00,0x7E,0x7E,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x10,0x10,0x08,0x08,0x04,0x04,0x08,0x08,0x10,0x10,0x00,0x00, - 0x1C,0x1C,0x22,0x22,0x22,0x22,0x02,0x02,0x04,0x04,0x08,0x08,0x00,0x00,0x08,0x08, - 0x3C,0x3C,0x42,0x42,0x5A,0x5A,0x6A,0x6A,0x6A,0x6A,0x5A,0x5A,0x44,0x44,0x3A,0x3A, - 0x18,0x18,0x24,0x24,0x24,0x24,0x24,0x24,0x42,0x42,0x7E,0x7E,0x42,0x42,0x42,0x42, - 0x7C,0x7C,0x42,0x42,0x42,0x42,0x7C,0x7C,0x42,0x42,0x42,0x42,0x42,0x42,0x7C,0x7C, - 0x3C,0x3C,0x42,0x42,0x42,0x42,0x40,0x40,0x40,0x40,0x40,0x40,0x42,0x42,0x3C,0x3C, - 0x7C,0x7C,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x7C,0x7C, - 0x7E,0x7E,0x40,0x40,0x40,0x40,0x78,0x78,0x40,0x40,0x40,0x40,0x40,0x40,0x7E,0x7E, - 0x7E,0x7E,0x40,0x40,0x40,0x40,0x7C,0x7C,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40, - 0x3C,0x3C,0x42,0x42,0x42,0x42,0x40,0x40,0x4E,0x4E,0x42,0x42,0x42,0x42,0x3C,0x3C, - 0x42,0x42,0x42,0x42,0x42,0x42,0x7E,0x7E,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42, - 0x38,0x38,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x38,0x38, - 0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x42,0x42,0x42,0x42,0x3C,0x3C, - 0x42,0x42,0x44,0x44,0x48,0x48,0x70,0x70,0x48,0x48,0x44,0x44,0x42,0x42,0x42,0x42, - 0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x7C,0x7C, - 0x42,0x42,0x42,0x42,0x66,0x66,0x5A,0x5A,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42, - 0x42,0x42,0x42,0x42,0x62,0x62,0x52,0x52,0x4A,0x4A,0x46,0x46,0x42,0x42,0x42,0x42, - 0x3C,0x3C,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x3C,0x3C, - 0x7C,0x7C,0x42,0x42,0x42,0x42,0x42,0x42,0x7C,0x7C,0x40,0x40,0x40,0x40,0x40,0x40, - 0x3C,0x3C,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x4A,0x4A,0x44,0x44,0x38,0x38, - 0x7C,0x7C,0x42,0x42,0x42,0x42,0x42,0x42,0x7C,0x7C,0x48,0x48,0x44,0x44,0x42,0x42, - 0x3C,0x3C,0x42,0x42,0x40,0x40,0x3C,0x3C,0x02,0x02,0x02,0x02,0x42,0x42,0x3C,0x3C, - 0xFE,0xFE,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10, - 0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x3C,0x3C, - 0x82,0x82,0x82,0x82,0x82,0x82,0x44,0x44,0x44,0x44,0x28,0x28,0x28,0x28,0x10,0x10, - 0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x5A,0x5A,0x66,0x66,0x42,0x42, - 0x42,0x42,0x42,0x42,0x24,0x24,0x18,0x18,0x18,0x18,0x24,0x24,0x42,0x42,0x42,0x42, - 0x82,0x82,0x82,0x82,0x44,0x44,0x44,0x44,0x38,0x38,0x10,0x10,0x10,0x10,0x10,0x10, - 0x7E,0x7E,0x02,0x02,0x04,0x04,0x08,0x08,0x10,0x10,0x20,0x20,0x40,0x40,0x7E,0x7E, - 0x18,0x18,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x18,0x18, - 0x40,0x40,0x20,0x20,0x20,0x20,0x10,0x10,0x08,0x08,0x04,0x04,0x04,0x04,0x02,0x02, - 0x18,0x18,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x18,0x18, - 0x10,0x10,0x28,0x28,0x44,0x44,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7E,0x7E, - 0x10,0x10,0x08,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -} \ No newline at end of file diff --git a/out.c.png b/out.c.png deleted file mode 100644 index d7186c6..0000000 Binary files a/out.c.png and /dev/null differ diff --git a/scripts/png2gb/index.js b/scripts/png2gb/index.js index a3a4139..14bf749 100644 --- a/scripts/png2gb/index.js +++ b/scripts/png2gb/index.js @@ -86,4 +86,4 @@ const convert = (fileIn, fileOut) => { require('./../gb2png/')(bits, `${fileOut}.png`); } -convert('font.png', 'out.c'); \ No newline at end of file +convert('images/font.png', 'out.c'); \ No newline at end of file diff --git a/src/common_tiles.c b/src/common_tiles.c new file mode 100644 index 0000000..453dc9e --- /dev/null +++ b/src/common_tiles.c @@ -0,0 +1,15 @@ +/** + * Copyright (c) 2022 Dominic Masters + * + * This software is released under the MIT License. + * https://opensource.org/licenses/MIT + */ + +#include "common_tiles.h" + +const uint8_t COMMON_TILES[] = { + 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 +}; \ No newline at end of file diff --git a/src/common_tiles.h b/src/common_tiles.h new file mode 100644 index 0000000..f6c3d16 --- /dev/null +++ b/src/common_tiles.h @@ -0,0 +1,18 @@ +/** + * Copyright (c) 2022 Dominic Masters + * + * This software is released under the MIT License. + * https://opensource.org/licenses/MIT + */ + +#pragma once +#include "libs.h" + +#define COMMON_TILE_COUNT 0x04 + +#define COMMON_TILE_0 0x00 +#define COMMON_TILE_1 0x01 +#define COMMON_TILE_2 0x02 +#define COMMON_TILE_3 0x03 + +extern const uint8_t COMMON_TILES[]; \ No newline at end of file diff --git a/src/font.c b/src/font.c new file mode 100644 index 0000000..7d676af --- /dev/null +++ b/src/font.c @@ -0,0 +1,75 @@ +/** + * Copyright (c) 2022 Dominic Masters + * + * This software is released under the MIT License. + * https://opensource.org/licenses/MIT + */ + +#include "font.h" + +const uint8_t FONT_DATA[] = { + 0x06,0x06,0x0E,0x0E,0x1C,0x1C,0x38,0x38,0x70,0x70,0x20,0x20,0x80,0x80,0x00,0x00, + 0x48,0x48,0x48,0x48,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x24,0x24,0x7E,0x7E,0x24,0x24,0x24,0x24,0x7E,0x7E,0x24,0x24,0x00,0x00,0x00,0x00, + 0x08,0x08,0x3E,0x3E,0x28,0x28,0x3E,0x3E,0x0A,0x0A,0x3E,0x3E,0x08,0x08,0x00,0x00, + 0x02,0x02,0x64,0x64,0x48,0x48,0x08,0x08,0x10,0x10,0x22,0x22,0x46,0x46,0x00,0x00, + 0x38,0x38,0x44,0x44,0x4C,0x4C,0x38,0x38,0x44,0x44,0x44,0x44,0x3A,0x3A,0x00,0x00, + 0x10,0x10,0x10,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x04,0x04,0x08,0x08,0x10,0x10,0x10,0x10,0x10,0x10,0x08,0x08,0x04,0x04,0x00,0x00, + 0x40,0x40,0x20,0x20,0x10,0x10,0x10,0x10,0x10,0x10,0x20,0x20,0x40,0x40,0x00,0x00, + 0xA0,0xA0,0x40,0x40,0xA0,0xA0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x10,0x10,0x10,0x10,0x7C,0x7C,0x10,0x10,0x10,0x10,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x10,0x20,0x20,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7C,0x7C,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x04,0x04,0x08,0x08,0x08,0x08,0x10,0x10,0x20,0x20,0x20,0x20,0x40,0x40,0x00,0x00, + 0x7C,0x7C,0xCE,0xCE,0xD6,0xD6,0xD6,0xD6,0xD6,0xD6,0xE6,0xE6,0x7C,0x7C,0x00,0x00, + 0x18,0x18,0x38,0x38,0x78,0x78,0x18,0x18,0x18,0x18,0x18,0x18,0x7E,0x7E,0x00,0x00, + 0x3C,0x3C,0x66,0x66,0x66,0x66,0x06,0x06,0x1C,0x1C,0x38,0x38,0x7E,0x7E,0x00,0x00, + 0x3C,0x3C,0x66,0x66,0x66,0x66,0x0C,0x0C,0x66,0x66,0x66,0x66,0x3C,0x3C,0x00,0x00, + 0x3C,0x3C,0x6C,0x6C,0xCC,0xCC,0xCC,0xCC,0xFE,0xFE,0x0C,0x0C,0x0C,0x0C,0x00,0x00, + 0x7E,0x7E,0x60,0x60,0x60,0x60,0x7C,0x7C,0x06,0x06,0x66,0x66,0x7C,0x7C,0x00,0x00, + 0x7C,0x7C,0xE6,0xE6,0xE0,0xE0,0xFC,0xFC,0xE6,0xE6,0xE6,0xE6,0x7C,0x7C,0x00,0x00, + 0x7E,0x7E,0x06,0x06,0x06,0x06,0x0C,0x0C,0x38,0x38,0x30,0x30,0x30,0x30,0x00,0x00, + 0x3C,0x3C,0x66,0x66,0x66,0x66,0x3C,0x3C,0x66,0x66,0x66,0x66,0x3C,0x3C,0x00,0x00, + 0x3C,0x3C,0x66,0x66,0x66,0x66,0x3E,0x3E,0x06,0x06,0x06,0x06,0x3C,0x3C,0x00,0x00, + 0x00,0x00,0x60,0x60,0x60,0x60,0x00,0x00,0x00,0x00,0x60,0x60,0x60,0x60,0x00,0x00, + 0x00,0x00,0x60,0x60,0x60,0x60,0x00,0x00,0x00,0x00,0x60,0x60,0x20,0x20,0x00,0x00, + 0x00,0x00,0x00,0x00,0x04,0x04,0x08,0x08,0x10,0x10,0x08,0x08,0x04,0x04,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x7C,0x7C,0x00,0x00,0x7C,0x7C,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x40,0x40,0x20,0x20,0x10,0x10,0x20,0x20,0x40,0x40,0x00,0x00, + 0x1C,0x1C,0x22,0x22,0x02,0x02,0x04,0x04,0x08,0x08,0x00,0x00,0x08,0x08,0x00,0x00, + 0x3C,0x3C,0x42,0x42,0x5A,0x5A,0x6A,0x6A,0x7A,0x7A,0x46,0x46,0x3C,0x3C,0x00,0x00, + 0x18,0x18,0x24,0x24,0x24,0x24,0x24,0x24,0x42,0x42,0x7E,0x7E,0x42,0x42,0x00,0x00, + 0x7C,0x7C,0x42,0x42,0x42,0x42,0x7C,0x7C,0x42,0x42,0x42,0x42,0x7C,0x7C,0x00,0x00, + 0x3C,0x3C,0x42,0x42,0x42,0x42,0x40,0x40,0x42,0x42,0x42,0x42,0x3C,0x3C,0x00,0x00, + 0x7C,0x7C,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x7C,0x7C,0x00,0x00, + 0x7E,0x7E,0x40,0x40,0x40,0x40,0x78,0x78,0x40,0x40,0x40,0x40,0x7E,0x7E,0x00,0x00, + 0x7E,0x7E,0x40,0x40,0x40,0x40,0x7C,0x7C,0x40,0x40,0x40,0x40,0x40,0x40,0x00,0x00, + 0x3C,0x3C,0x42,0x42,0x40,0x40,0x40,0x40,0x4E,0x4E,0x42,0x42,0x3C,0x3C,0x00,0x00, + 0x42,0x42,0x42,0x42,0x42,0x42,0x7E,0x7E,0x42,0x42,0x42,0x42,0x42,0x42,0x00,0x00, + 0x7C,0x7C,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x7C,0x7C,0x00,0x00, + 0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x42,0x42,0x42,0x42,0x3C,0x3C,0x00,0x00, + 0x42,0x42,0x44,0x44,0x48,0x48,0x70,0x70,0x48,0x48,0x44,0x44,0x42,0x42,0x00,0x00, + 0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x7C,0x7C,0x00,0x00, + 0x42,0x42,0x42,0x42,0x66,0x66,0x5A,0x5A,0x42,0x42,0x42,0x42,0x42,0x42,0x00,0x00, + 0x42,0x42,0x42,0x42,0x62,0x62,0x52,0x52,0x4A,0x4A,0x46,0x46,0x42,0x42,0x00,0x00, + 0x3C,0x3C,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x3C,0x3C,0x00,0x00, + 0x7C,0x7C,0x42,0x42,0x42,0x42,0x7C,0x7C,0x40,0x40,0x40,0x40,0x40,0x40,0x00,0x00, + 0x3C,0x3C,0x42,0x42,0x42,0x42,0x42,0x42,0x4A,0x4A,0x44,0x44,0x3A,0x3A,0x00,0x00, + 0x7C,0x7C,0x42,0x42,0x42,0x42,0x7C,0x7C,0x50,0x50,0x48,0x48,0x44,0x44,0x00,0x00, + 0x3C,0x3C,0x42,0x42,0x40,0x40,0x3C,0x3C,0x02,0x02,0x42,0x42,0x3C,0x3C,0x00,0x00, + 0x7C,0x7C,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x00,0x00, + 0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x3C,0x3C,0x00,0x00, + 0x82,0x82,0x82,0x82,0x82,0x82,0x44,0x44,0x44,0x44,0x28,0x28,0x10,0x10,0x00,0x00, + 0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x5A,0x5A,0x66,0x66,0x42,0x42,0x00,0x00, + 0x42,0x42,0x42,0x42,0x24,0x24,0x18,0x18,0x24,0x24,0x42,0x42,0x42,0x42,0x00,0x00, + 0x82,0x82,0x82,0x82,0x44,0x44,0x28,0x28,0x10,0x10,0x10,0x10,0x10,0x10,0x00,0x00, + 0x7E,0x7E,0x04,0x04,0x08,0x08,0x10,0x10,0x20,0x20,0x40,0x40,0x7E,0x7E,0x00,0x00, + 0x0C,0x0C,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x0C,0x0C,0x00,0x00, + 0x40,0x40,0x20,0x20,0x20,0x20,0x10,0x10,0x08,0x08,0x08,0x08,0x04,0x04,0x00,0x00, + 0x60,0x60,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x60,0x60,0x00,0x00, + 0x10,0x10,0x28,0x28,0x44,0x44,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7C,0x7C,0x00,0x00, + 0x10,0x10,0x08,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +}; \ No newline at end of file diff --git a/src/images/font.h b/src/font.h similarity index 60% rename from src/images/font.h rename to src/font.h index 96049e7..c9a4903 100644 --- a/src/images/font.h +++ b/src/font.h @@ -5,10 +5,11 @@ * https://opensource.org/licenses/MIT */ -#include "../libs.h" +#pragma once +#include "libs.h" -#define IMAGE_WIDTH 64 -#define IMAGE_HEIGHT 64 -#define IMAGE_TILES 64 +#define FONT_IMAGE_WIDTH 64 +#define FONT_IMAGE_HEIGHT 64 +#define FONT_TILE_COUNT 64 extern const uint8_t FONT_DATA[]; \ No newline at end of file diff --git a/src/images/font.c b/src/images/font.c deleted file mode 100644 index 424922b..0000000 --- a/src/images/font.c +++ /dev/null @@ -1,75 +0,0 @@ -/** - * Copyright (c) 2022 Dominic Masters - * - * This software is released under the MIT License. - * https://opensource.org/licenses/MIT - */ - -#include "font.h" - -const uint8_t FONT_DATA[] = { - 0x06,0x06,0x0E,0x0E,0x1E,0x1E,0x1C,0x1C,0x38,0x38,0x30,0x30,0x00,0x00,0x40,0x40, - 0x48,0x48,0x48,0x48,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x24,0x24,0x00,0x3E,0x24,0x64,0x00,0x3C,0x24,0x26,0x24,0x66,0x00,0x3C,0x24,0x24, - 0x02,0x02,0x44,0x44,0x64,0x64,0x08,0x08,0x10,0x10,0x20,0x20,0x26,0x26,0x44,0x44, - 0x38,0x38,0x44,0x44,0x44,0x44,0x38,0x38,0x30,0x30,0x4A,0x4A,0x44,0x44,0x3A,0x3A, - 0x10,0x10,0x10,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x08,0x08,0x10,0x10,0x10,0x10,0x20,0x20,0x20,0x20,0x10,0x10,0x10,0x10,0x08,0x08, - 0x10,0x10,0x08,0x08,0x08,0x08,0x04,0x04,0x04,0x04,0x08,0x08,0x08,0x08,0x10,0x10, - 0x10,0x10,0x38,0x38,0x10,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x10,0x10,0x10,0x10,0x7C,0x7C,0x10,0x10,0x10,0x10,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x40,0x40, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7E,0x7E,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x40, - 0x02,0x02,0x04,0x04,0x04,0x04,0x08,0x08,0x10,0x10,0x20,0x20,0x20,0x20,0x40,0x40, - 0x3C,0x3C,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x3C,0x3C, - 0x18,0x18,0x38,0x38,0x78,0x78,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x7E,0x7E, - 0x3C,0x3C,0x66,0x66,0x66,0x66,0x06,0x06,0x1C,0x1C,0x38,0x38,0x70,0x70,0x7E,0x7E, - 0x3C,0x3C,0x66,0x66,0x66,0x66,0x0C,0x0C,0x0E,0x0E,0x66,0x66,0x66,0x66,0x3C,0x3C, - 0x0E,0x0E,0x1E,0x1E,0x36,0x36,0x66,0x66,0x7E,0x7E,0x06,0x06,0x06,0x06,0x06,0x06, - 0x7E,0x7E,0x60,0x60,0x60,0x60,0x7C,0x7C,0x06,0x06,0x66,0x66,0x66,0x66,0x3C,0x3C, - 0x3C,0x3C,0x66,0x66,0x60,0x60,0x7C,0x7C,0x66,0x66,0x66,0x66,0x66,0x66,0x3C,0x3C, - 0x7E,0x7E,0x06,0x06,0x06,0x06,0x0C,0x0C,0x0C,0x0C,0x18,0x18,0x38,0x38,0x30,0x30, - 0x3C,0x3C,0x66,0x66,0x66,0x66,0x3C,0x3C,0x66,0x66,0x66,0x66,0x66,0x66,0x3C,0x3C, - 0x3E,0x3E,0x66,0x66,0x66,0x66,0x66,0x66,0x3E,0x3E,0x06,0x06,0x06,0x06,0x06,0x06, - 0x00,0x00,0x18,0x18,0x18,0x18,0x00,0x00,0x00,0x00,0x18,0x18,0x18,0x18,0x00,0x00, - 0x00,0x00,0x18,0x18,0x18,0x18,0x00,0x00,0x00,0x00,0x18,0x18,0x08,0x08,0x10,0x10, - 0x00,0x00,0x00,0x00,0x08,0x08,0x10,0x10,0x20,0x20,0x10,0x10,0x08,0x08,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x7E,0x7E,0x00,0x00,0x7E,0x7E,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x10,0x10,0x08,0x08,0x04,0x04,0x08,0x08,0x10,0x10,0x00,0x00, - 0x1C,0x1C,0x22,0x22,0x22,0x22,0x02,0x02,0x04,0x04,0x08,0x08,0x00,0x00,0x08,0x08, - 0x3C,0x3C,0x42,0x42,0x5A,0x5A,0x6A,0x6A,0x6A,0x6A,0x5A,0x5A,0x44,0x44,0x3A,0x3A, - 0x18,0x18,0x24,0x24,0x24,0x24,0x24,0x24,0x42,0x42,0x7E,0x7E,0x42,0x42,0x42,0x42, - 0x7C,0x7C,0x42,0x42,0x42,0x42,0x7C,0x7C,0x42,0x42,0x42,0x42,0x42,0x42,0x7C,0x7C, - 0x3C,0x3C,0x42,0x42,0x42,0x42,0x40,0x40,0x40,0x40,0x40,0x40,0x42,0x42,0x3C,0x3C, - 0x7C,0x7C,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x7C,0x7C, - 0x7E,0x7E,0x40,0x40,0x40,0x40,0x78,0x78,0x40,0x40,0x40,0x40,0x40,0x40,0x7E,0x7E, - 0x7E,0x7E,0x40,0x40,0x40,0x40,0x7C,0x7C,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40, - 0x3C,0x3C,0x42,0x42,0x42,0x42,0x40,0x40,0x4E,0x4E,0x42,0x42,0x42,0x42,0x3C,0x3C, - 0x42,0x42,0x42,0x42,0x42,0x42,0x7E,0x7E,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42, - 0x38,0x38,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x38,0x38, - 0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x42,0x42,0x42,0x42,0x3C,0x3C, - 0x42,0x42,0x44,0x44,0x48,0x48,0x70,0x70,0x48,0x48,0x44,0x44,0x42,0x42,0x42,0x42, - 0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x7C,0x7C, - 0x42,0x42,0x42,0x42,0x66,0x66,0x5A,0x5A,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42, - 0x42,0x42,0x42,0x42,0x62,0x62,0x52,0x52,0x4A,0x4A,0x46,0x46,0x42,0x42,0x42,0x42, - 0x3C,0x3C,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x3C,0x3C, - 0x7C,0x7C,0x42,0x42,0x42,0x42,0x42,0x42,0x7C,0x7C,0x40,0x40,0x40,0x40,0x40,0x40, - 0x3C,0x3C,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x4A,0x4A,0x44,0x44,0x38,0x38, - 0x7C,0x7C,0x42,0x42,0x42,0x42,0x42,0x42,0x7C,0x7C,0x48,0x48,0x44,0x44,0x42,0x42, - 0x3C,0x3C,0x42,0x42,0x40,0x40,0x3C,0x3C,0x02,0x02,0x02,0x02,0x42,0x42,0x3C,0x3C, - 0xFE,0xFE,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10, - 0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x3C,0x3C, - 0x82,0x82,0x82,0x82,0x82,0x82,0x44,0x44,0x44,0x44,0x28,0x28,0x28,0x28,0x10,0x10, - 0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x5A,0x5A,0x66,0x66,0x42,0x42, - 0x42,0x42,0x42,0x42,0x24,0x24,0x18,0x18,0x18,0x18,0x24,0x24,0x42,0x42,0x42,0x42, - 0x82,0x82,0x82,0x82,0x44,0x44,0x44,0x44,0x38,0x38,0x10,0x10,0x10,0x10,0x10,0x10, - 0x7E,0x7E,0x02,0x02,0x04,0x04,0x08,0x08,0x10,0x10,0x20,0x20,0x40,0x40,0x7E,0x7E, - 0x18,0x18,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x18,0x18, - 0x40,0x40,0x20,0x20,0x20,0x20,0x10,0x10,0x08,0x08,0x04,0x04,0x04,0x04,0x02,0x02, - 0x18,0x18,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x18,0x18, - 0x10,0x10,0x28,0x28,0x44,0x44,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7E,0x7E, - 0x10,0x10,0x08,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -}; \ No newline at end of file diff --git a/src/libs.h b/src/libs.h index 8fc79a2..22bfa03 100644 --- a/src/libs.h +++ b/src/libs.h @@ -6,13 +6,7 @@ */ #pragma once - -#ifndef _LIBS_H -#define _LIBS_H - #include #include #include -#include - -#endif \ No newline at end of file +#include \ No newline at end of file diff --git a/src/main.c b/src/main.c index 67a7d7e..cff209b 100644 --- a/src/main.c +++ b/src/main.c @@ -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++; } } diff --git a/src/text.c b/src/text.c deleted file mode 100644 index ca95525..0000000 --- a/src/text.c +++ /dev/null @@ -1,75 +0,0 @@ -/** - * Copyright (c) 2021 Dominic Masters - * - * This software is released under the MIT License. - * https://opensource.org/licenses/MIT - */ - -#include "text.h" - -const uint8_t FONT[] = { - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0xC0, - 0x01,0x01,0x00,0x00,0x21,0x21,0x70,0x70,0x0F,0x0F,0x00,0x00,0x7E,0x7E,0x30,0x30, - 0x0C,0x0C,0x00,0x00,0x61,0x61,0xF8,0xF8,0x74,0x74,0x81,0x81,0x81,0x81,0x08,0x08, - 0x3C,0x3C,0x81,0x81,0xFF,0xFF,0x88,0x88,0x84,0x84,0xFF,0xFF,0x81,0x81,0x0F,0x0F, - 0x78,0x78,0x66,0x66,0xFF,0xFF,0x88,0x88,0x84,0x84,0x81,0x81,0x85,0x85,0x08,0x08, - 0xF0,0xF0,0x18,0x18,0x01,0x01,0xFF,0xFF,0x74,0x74,0x00,0x00,0x82,0x82,0x30,0x30, - 0xE0,0xE0,0x00,0x00,0x01,0x01,0xFF,0xFF,0x0F,0x0F,0x00,0x00,0x7C,0x7C,0xC0,0xC0, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0xC0,0xC0,0x00,0x00,0x63,0x63,0x00,0x00,0xFF,0xFF,0x06,0x06,0xFF,0xFF,0x83,0x83, - 0x00,0x00,0x40,0x40,0xE7,0xE7,0x00,0x00,0x91,0x91,0x01,0x01,0x88,0x88,0x85,0x85, - 0x00,0x00,0xE0,0xE0,0x8F,0x8F,0x66,0x66,0x91,0x91,0x01,0x01,0x88,0x88,0x89,0x89, - 0xC0,0xC0,0x40,0x40,0x8D,0x8D,0x66,0x66,0x91,0x91,0x01,0x01,0x8C,0x8C,0x91,0x91, - 0x00,0x00,0x00,0x00,0xF9,0xF9,0x00,0x00,0x91,0x91,0x01,0x01,0x8A,0x8A,0xA1,0xA1, - 0x00,0x00,0x00,0x00,0x71,0x71,0x00,0x00,0x6E,0x6E,0xFE,0xFE,0x71,0x71,0xC1,0xC1, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x10,0x10,0x66,0x66,0x00,0x00,0x7E,0x7E,0xFF,0xFF,0x62,0x62,0x00,0x00, - 0x00,0x00,0x10,0x10,0xE7,0xE7,0x00,0x00,0x81,0x81,0x10,0x10,0x91,0x91,0x00,0x00, - 0x00,0x00,0x7C,0x7C,0x81,0x81,0x65,0x65,0x81,0x81,0x10,0x10,0x91,0x91,0xFF,0xFF, - 0x00,0x00,0x10,0x10,0x99,0x99,0x66,0x66,0x81,0x81,0x28,0x28,0x91,0x91,0x81,0x81, - 0x00,0x00,0x10,0x10,0xFF,0xFF,0x00,0x00,0x81,0x81,0x44,0x44,0x91,0x91,0x00,0x00, - 0x00,0x00,0x00,0x00,0x6E,0x6E,0x00,0x00,0x62,0x62,0x83,0x83,0x4E,0x4E,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x80,0x00,0x00, - 0x00,0x24,0x01,0x01,0x18,0x18,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0x80,0x80,0x80,0x80, - 0xAD,0xFF,0x02,0x02,0x38,0x38,0x08,0x08,0x81,0x81,0x01,0x01,0x80,0x80,0x60,0x60, - 0x00,0x52,0x02,0x02,0x68,0x68,0x14,0x14,0x81,0x81,0x01,0x01,0xFF,0xFF,0x10,0x10, - 0x00,0x52,0x00,0x00,0xC8,0xC8,0x22,0x22,0x81,0x81,0x01,0x01,0x80,0x80,0x08,0x08, - 0xAD,0xFF,0x00,0x00,0xFF,0xFF,0x00,0x00,0x81,0x81,0x01,0x01,0x80,0x80,0x06,0x06, - 0x00,0x4C,0x00,0x00,0xFF,0xFF,0x00,0x00,0x7E,0x7E,0x00,0x00,0x80,0x80,0x01,0x01, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x61,0x61,0x08,0x08,0xF6,0xF6,0x14,0x14,0xFF,0xFF,0xFF,0xFF,0xFE,0xFE,0x00,0x00, - 0x26,0x26,0x08,0x08,0xF7,0xF7,0x14,0x14,0x91,0x91,0x20,0x20,0x01,0x01,0x00,0x00, - 0x08,0x08,0x08,0x08,0x91,0x91,0x14,0x14,0x91,0x91,0x10,0x10,0x01,0x01,0x81,0x81, - 0x10,0x10,0x08,0x08,0x91,0x91,0x14,0x14,0x91,0x91,0x10,0x10,0x01,0x01,0xFF,0xFF, - 0x63,0x63,0x08,0x08,0x9F,0x9F,0x14,0x14,0x81,0x81,0x20,0x20,0x01,0x01,0x00,0x00, - 0x82,0x82,0x08,0x08,0x8E,0x8E,0x14,0x14,0x81,0x81,0xFF,0xFF,0xFE,0xFE,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xE0,0xE0,0x00,0x00, - 0x66,0x66,0x01,0x01,0x7E,0x7E,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0x18,0x18,0x20,0x20, - 0x99,0x99,0x00,0x00,0xFF,0xFF,0x00,0x00,0x90,0x90,0x20,0x20,0x06,0x06,0x40,0x40, - 0x99,0x99,0x00,0x00,0x91,0x91,0x22,0x22,0x90,0x90,0x10,0x10,0x01,0x01,0x80,0x80, - 0x95,0x95,0x00,0x00,0x91,0x91,0x14,0x14,0x90,0x90,0x08,0x08,0x06,0x06,0x40,0x40, - 0x62,0x62,0x00,0x00,0xDF,0xDF,0x08,0x08,0x90,0x90,0x04,0x04,0x18,0x18,0x20,0x20, - 0x05,0x05,0x00,0x00,0x4E,0x4E,0x00,0x00,0x80,0x80,0xFF,0xFF,0xE0,0xE0,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x01,0x01,0x80,0x80,0x00,0x00,0x7E,0x7E,0x7E,0x7E,0xFF,0xFF,0x01,0x01, - 0x00,0x00,0x06,0x06,0x83,0x83,0x60,0x60,0x81,0x81,0x81,0x81,0x02,0x02,0x01,0x01, - 0xC0,0xC0,0x08,0x08,0x87,0x87,0x80,0x80,0x81,0x81,0x81,0x81,0x04,0x04,0x01,0x01, - 0x00,0x00,0x10,0x10,0x9E,0x9E,0x85,0x85,0x89,0x89,0x81,0x81,0x04,0x04,0x01,0x01, - 0x00,0x00,0x60,0x60,0xF8,0xF8,0x88,0x88,0x89,0x89,0x81,0x81,0x02,0x02,0x01,0x01, - 0x00,0x00,0x80,0x80,0xE0,0xE0,0x70,0x70,0x6E,0x6E,0x7E,0x7E,0xFF,0xFF,0x01,0x01, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x7E,0x7E,0x6E,0x6E,0x7E,0x7E,0xFF,0xFF,0xFF,0xFF,0xC3,0xC3,0x00,0x00, - 0x18,0x18,0xFF,0xFF,0xFF,0xFF,0x99,0x99,0x10,0x10,0x88,0x88,0x24,0x24,0x00,0x00, - 0x66,0x66,0x81,0x81,0x91,0x91,0xA5,0xA5,0x10,0x10,0x88,0x88,0x18,0x18,0x80,0x80, - 0x81,0x81,0x81,0x81,0x91,0x91,0xBD,0xBD,0x10,0x10,0x88,0x88,0x18,0x18,0x40,0x40, - 0x00,0x00,0xFF,0xFF,0xFF,0xFF,0x82,0x82,0x10,0x10,0x88,0x88,0x24,0x24,0x00,0x00, - 0x00,0x00,0x7E,0x7E,0x6E,0x6E,0x7D,0x7D,0xFF,0xFF,0x70,0x70,0xC3,0xC3,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 -}; \ No newline at end of file diff --git a/src/text.h b/src/text.h deleted file mode 100644 index 29ff45f..0000000 --- a/src/text.h +++ /dev/null @@ -1,16 +0,0 @@ -/** - * Copyright (c) 2021 Dominic Masters - * - * This software is released under the MIT License. - * https://opensource.org/licenses/MIT - */ - -#ifndef _TEXT_H -#define _TEXT_H -#include "libs.h" - -#define FONT_TILE_COUNT 64 - -extern const uint8_t FONT[]; - -#endif \ No newline at end of file diff --git a/src/textbox.c b/src/textbox.c new file mode 100644 index 0000000..e2f19db --- /dev/null +++ b/src/textbox.c @@ -0,0 +1,85 @@ +/** + * Copyright (c) 2022 Dominic Masters + * + * This software is released under the MIT License. + * https://opensource.org/licenses/MIT + */ + +#include "textbox.h" + +char *TEXTBOX_TEXT; +uint8_t TEXTBOX_TEXT_LENGTH; +uint8_t TEXTBOX_STATE; +uint8_t TEXTBOX_SCROLL; + + +void textboxInit() { + TEXTBOX_TEXT = NULL; + TEXTBOX_STATE = 0; + TEXTBOX_TEXT_LENGTH = 0; + TEXTBOX_SCROLL = 0; + move_win(7, SCREENHEIGHT - (TEXTBOX_TILES_ROWS * 8)); + + set_win_data(TEXTBOX_TILES_DATA_POSITION, FONT_TILE_COUNT, FONT_DATA); +} + +void textboxSetText(char *text, uint8_t length) { + uint8_t tiles[TEXTBOX_TILES_MAX]; + uint8_t i; + + TEXTBOX_TEXT = text; + TEXTBOX_TEXT_LENGTH = length; + TEXTBOX_STATE = TEXTBOX_STATE_VISIBLE; + TEXTBOX_SCROLL = 0; + + for(i = 0; i < TEXTBOX_TILES_MAX; i++) tiles[i] = TEXTBOX_TILE_BLANK; + + set_win_tiles(0, 0, TEXTBOX_TILES_PER_ROW, TEXTBOX_TILES_ROWS, tiles); + SHOW_WIN; +} + +void textboxClose() { + TEXTBOX_STATE &= ~TEXTBOX_STATE_VISIBLE; + HIDE_WIN; +} + +void textboxUpdate() { + uint8_t tiles[TEXTBOX_TILES_MAX]; + uint8_t i, j; + + if(!(TEXTBOX_STATE & TEXTBOX_STATE_VISIBLE)) return; + if(TEXTBOX_STATE & TEXTBOX_STATE_SCROLLED) { + return; + } + + TEXTBOX_SCROLL++; + j = 0; + for(i = 0; i < TEXTBOX_SCROLL; i++) { + if(TEXTBOX_TEXT[i] == ' ') { + j++; + continue; + } + if(TEXTBOX_TEXT[i] == '\n') { + j = TEXTBOX_TILES_PER_ROW; + continue; + } + tiles[j] = TILE_FROM_CHAR(TEXTBOX_TEXT[i]); + j++; + } + + + for(i = j; i < TEXTBOX_TILES_MAX; i++) { + tiles[i] = TEXTBOX_TILE_BLANK; + } + + set_win_tiles( + 0, 0, + TEXTBOX_TILES_PER_ROW, + TEXTBOX_TILES_ROWS, + tiles + ); + + if(TEXTBOX_SCROLL == TEXTBOX_TEXT_LENGTH) { + TEXTBOX_STATE |= TEXTBOX_STATE_SCROLLED; + } +} \ No newline at end of file diff --git a/src/textbox.h b/src/textbox.h new file mode 100644 index 0000000..9c118de --- /dev/null +++ b/src/textbox.h @@ -0,0 +1,34 @@ +/** + * Copyright (c) 2022 Dominic Masters + * + * This software is released under the MIT License. + * https://opensource.org/licenses/MIT + */ + +#pragma once +#include "libs.h" +#include "font.h" +#include "util.h" +#include "common_tiles.h" + +#define TEXTBOX_STATE_VISIBLE 1 << 0 +#define TEXTBOX_STATE_SCROLLED 1 << 1 + +#define TEXTBOX_TILES_PER_ROW 20 +#define TEXTBOX_TILES_ROWS 2 +#define TEXTBOX_TILES_MAX TEXTBOX_TILES_PER_ROW * TEXTBOX_TILES_ROWS +#define TEXTBOX_CHARACTER_FIRST 33 +#define TEXTBOX_TILE_BLANK COMMON_TILE_3 + +#define TEXTBOX_TILES_DATA_POSITION 0x04 + +#define TILE_FROM_CHAR(c) c-TEXTBOX_CHARACTER_FIRST+TEXTBOX_TILES_DATA_POSITION + +extern char *TEXTBOX_TEXT; +extern uint8_t TEXTBOX_TEXT_LENGTH; +extern uint8_t TEXTBOX_STATE; +extern uint8_t TEXTBOX_SCROLL; + +void textboxInit(); +void textboxSetText(char *text, uint8_t length); +void textboxUpdate(); \ No newline at end of file diff --git a/src/tiles.h b/src/tiles.h new file mode 100644 index 0000000..e5affd8 --- /dev/null +++ b/src/tiles.h @@ -0,0 +1,9 @@ +/** + * Copyright (c) 2022 Dominic Masters + * + * This software is released under the MIT License. + * https://opensource.org/licenses/MIT + */ + +#pragma once +#include "libs.h" \ No newline at end of file diff --git a/src/time.c b/src/time.c new file mode 100644 index 0000000..dde632a --- /dev/null +++ b/src/time.c @@ -0,0 +1,10 @@ +/** + * Copyright (c) 2022 Dominic Masters + * + * This software is released under the MIT License. + * https://opensource.org/licenses/MIT + */ + +#include "time.h" + +uint8_t time = 0; \ No newline at end of file diff --git a/src/time.h b/src/time.h new file mode 100644 index 0000000..9a2e498 --- /dev/null +++ b/src/time.h @@ -0,0 +1,11 @@ +/** + * Copyright (c) 2022 Dominic Masters + * + * This software is released under the MIT License. + * https://opensource.org/licenses/MIT + */ + +#pragma once +#include "libs.h" + +extern uint8_t time; \ No newline at end of file diff --git a/src/util.h b/src/util.h new file mode 100644 index 0000000..7f205f3 --- /dev/null +++ b/src/util.h @@ -0,0 +1,12 @@ +/** + * Copyright (c) 2022 Dominic Masters + * + * This software is released under the MIT License. + * https://opensource.org/licenses/MIT + */ + +#pragma once +#include "libs.h" + +#define MATH_MIN(a, b) a > b ? b : a +#define MATH_MAX(a, b) a < b ? b : a \ No newline at end of file diff --git a/test.png b/test.png deleted file mode 100644 index 5144522..0000000 Binary files a/test.png and /dev/null differ