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

5
.gitignore vendored
View File

@@ -76,4 +76,7 @@ yarn.lock
*.log
obj
res
res
./out.c
./out.c.png

Binary file not shown.

BIN
data.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 142 B

BIN
font.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 595 B

BIN
images/Font.aseprite Normal file

Binary file not shown.

BIN
images/font.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 564 B

72
out.c
View File

@@ -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,
}

BIN
out.c.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.5 KiB

View File

@@ -86,4 +86,4 @@ const convert = (fileIn, fileOut) => {
require('./../gb2png/')(bits, `${fileOut}.png`);
}
convert('font.png', 'out.c');
convert('images/font.png', 'out.c');

15
src/common_tiles.c Normal file
View File

@@ -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
};

18
src/common_tiles.h Normal file
View File

@@ -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[];

75
src/font.c Normal file
View File

@@ -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,
};

View File

@@ -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[];

View File

@@ -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,
};

View File

@@ -6,13 +6,7 @@
*/
#pragma once
#ifndef _LIBS_H
#define _LIBS_H
#include <gb/gb.h>
#include <stdint.h>
#include <stdio.h>
#include <stdbool.h>
#endif
#include <stdbool.h>

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++;
}
}

View File

@@ -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
};

View File

@@ -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

85
src/textbox.c Normal file
View File

@@ -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;
}
}

34
src/textbox.h Normal file
View File

@@ -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();

9
src/tiles.h Normal file
View File

@@ -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"

10
src/time.c Normal file
View File

@@ -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;

11
src/time.h Normal file
View File

@@ -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;

12
src/util.h Normal file
View File

@@ -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

BIN
test.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 205 B