Whatevers

This commit is contained in:
2022-01-04 09:09:21 -08:00
commit c882f07089
16 changed files with 635 additions and 0 deletions

79
.gitignore vendored Normal file
View File

@@ -0,0 +1,79 @@
# Prerequisites
*.d
# Object files
*.o
*.ko
build/*.obj
*.elf
# Linker output
*.ilk
*.map
*.exp
# Precompiled Headers
*.gch
*.pch
# Libraries
*.lib
*.a
*.la
*.lo
# Shared objects (inc. Windows DLLs)
*.dll
*.so
*.so.*
*.dylib
# Executables
*.exe
*.out
*.app
*.i*86
*.x86_64
*.hex
# Debug files
*.dSYM/
*.su
*.idb
*.pdb
# Kernel Module Compile Results
*.mod*
*.cmd
.tmp_versions/
modules.order
Module.symvers
Mkfile.old
dkms.conf
# CMake
CMakeLists.txt.user
CMakeCache.txt
CMakeFiles
CMakeScripts
Testing
Makefile
cmake_install.cmake
install_manifest.txt
compile_commands.json
CTestTestfile.cmake
_deps
# Custom
build
.vscode
assets/testworld/tileset.png
oldsrc
node_modules
yarn.lock
*.log
obj
res

BIN
Font.aseprite Normal file

Binary file not shown.

BIN
data.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 142 B

BIN
font.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 595 B

72
out.c Normal file
View File

@@ -0,0 +1,72 @@
#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 Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

11
package.json Normal file
View File

@@ -0,0 +1,11 @@
{
"name": "Dawn-GB",
"version": "1.0.0",
"main": "index.js",
"repository": "https://github.com/YourWishes/Dawn-GB.git",
"author": "Dominic Masters <dominic@domsplace.com>",
"license": "MIT",
"dependencies": {
"pngjs": "^6.0.0"
}
}

104
scripts/gb2png/index.js Normal file
View File

@@ -0,0 +1,104 @@
// let DATA = [
// 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
// ];
const TILEMAP = [
];
const TILEMAP_WIDTH = 8;
const convertData = (DATA, fileOut) => {
// Begin
const PNG = require('pngjs').PNG;
const fs = require('fs');
const PIXELS = DATA.length / 2 * 8;
const TILE_WIDTH = 8;
const TILE_HEIGHT = 8;
const DATA_WIDTH = TILE_WIDTH;
const DATA_HEIGHT = PIXELS / DATA_WIDTH;
const TILEMAP_HEIGHT = TILEMAP.length / TILEMAP_WIDTH;
const TILEMAP_PIXEL_WIDTH = TILEMAP_WIDTH * TILE_WIDTH;
const TILEMAP_PIXEL_HEIGHT = TILEMAP_HEIGHT * TILE_HEIGHT;
const colorPixel = (id) => {
if(id === undefined) id = 3;
if(id === 3) return { r: 8, g: 24, b: 32 };
if(id === 2) return { r: 52, g: 104, b: 86 };
if(id === 1) return { r: 136, g: 192, b: 112 };
if(id === 0) return { r: 224, g: 248, b: 208 };
throw new Error();
}
// Create output image
const imageData = new PNG({
width: DATA_WIDTH,
height: DATA_HEIGHT
});
const tileData = new PNG({
width: TILEMAP_PIXEL_WIDTH,
height: TILEMAP_PIXEL_HEIGHT
});
// Convert data into pixels
const pixelsOut = [];
for(let i = 0; i < DATA.length; i += 2) {
const low = DATA[i];
const high = DATA[i+1];
for(let j = 0; j < 8; j++) {
const mask = 0x80 >> j;
const pixel = (low & mask ? 1 : 0) + (high & mask ? 2 : 0);
pixelsOut.push(pixel);
}
}
// Buffer data output
for(let y = 0; y < DATA_HEIGHT; y++) {
for(let x = 0; x < DATA_WIDTH; x++) {
const id = (DATA_WIDTH * y + x);
const color = colorPixel(pixelsOut[id]);
const idx = id << 2;
imageData.data[idx] = color.r;
imageData.data[idx+1] = color.g;
imageData.data[idx+2] = color.b;
imageData.data[idx+3] = 0xFF;
}
}
const buffer = PNG.sync.write(imageData, { });
fs.writeFileSync(fileOut, buffer);
}
// Now work out tile data
if(TILEMAP.length) {
for(let i = 0; i < TILEMAP.length; i++) {
const tileX = i % TILEMAP_WIDTH;
const tileY = Math.floor(i / TILEMAP_WIDTH);
const tile = TILEMAP[i];
for(let j = 0; j < TILE_WIDTH*TILE_HEIGHT; j++) {
const outI = (
(tileX * TILE_WIDTH) + (tileY * TILE_HEIGHT * TILEMAP_PIXEL_WIDTH) +
((j % TILE_WIDTH) + (Math.floor(j / TILE_WIDTH) * TILEMAP_PIXEL_WIDTH))
);
const idx = outI << 2;
const pixelI = (tile * TILE_WIDTH * TILE_HEIGHT) + j;
const color = colorPixel(pixelsOut[pixelI]);
tileData.data[idx] = color.r;
tileData.data[idx+1] = color.g;
tileData.data[idx+2] = color.b;
tileData.data[idx+3] = 0xFF;
}
}
const buffer2 = PNG.sync.write(tileData, { });
fs.writeFileSync('out.png', buffer2);
}
module.exports = convertData;

89
scripts/png2gb/index.js Normal file
View File

@@ -0,0 +1,89 @@
const PNG = require('pngjs').PNG;
const fs = require('fs');
const convert = (fileIn, fileOut) => {
const TILE_WIDTH = 8;
const TILE_HEIGHT = 8;
const data = fs.readFileSync(fileIn);
const png = PNG.sync.read(data);
const getPixelValue = (pixel) => {
if(pixel.r === 15) return 3;
if(pixel.r === 48) return 2;
if(pixel.r === 0) return 1;
if(pixel.r === 155) return 0;
throw new Error();
}
// Convert PNG pixels into 0x00-0x03
const pixels = [];
for(let x = 0; x < png.width; x++) {
for(let y = 0; y < png.height; y++) {
const id = x + (y * png.width);
const idx = id << 2;
const r = png.data[idx];
const g = png.data[idx+1];
const b = png.data[idx+2];
const value = getPixelValue({ r, g, b });
pixels.push(value);
}
}
// Now take these raw pixels and extract the tiles themselves
let rearranged = [];
const columns = (png.width / TILE_WIDTH);
const rows = (png.height / TILE_HEIGHT);
let n = 0;
for(let i = 0; i < columns * rows; i++) {
const tileX = i % columns;
const tileY = Math.floor(i / columns) % rows;
for(let x = 0; x < TILE_WIDTH; x++) {
for(let y = 0; y < TILE_HEIGHT; y++) {
const px = (tileY * TILE_WIDTH) + x;// NO idea why I need to flipX/Y.
const py = (tileX * TILE_HEIGHT) + y;// and too lazy to figure out why.
const pi = px + (py * png.width);
rearranged[n++] = pixels[pi];
}
}
}
// Now turn into a tileset
const bits = [];
for(let i = 0; i < rearranged.length; i += TILE_WIDTH) {
let lowBits = 0x00;
let highBits = 0x00;
for(let j = 0; j < TILE_WIDTH; j++) {
const pixel = rearranged[i + j];
lowBits = lowBits | ((pixel & 0x01) << (7-j));
highBits = highBits | ((pixel & 0x02) >> 1 << (7-j));
}
bits.push(lowBits, highBits);
}
const b = bits.map(n => {
return '0x' + (n.toString(16).padStart(2, '0').toUpperCase());
});
let str = '';
for(let i = 0; i < b.length; i += 16) {
str += ' ';
for(let x = i; x < Math.min(i+16, b.length); x++) {
str += b[x];
str += ',';
}
str += '\n';
}
let out = '';
out += `#include "../libs.h"\n\n`
out += `#define IMAGE_WIDTH ${png.width}\n`;
out += `#define IMAGE_HEIGHT ${png.height}\n`;
out += `#define IMAGE_TILES ${columns * rows}\n`;
out += `\nconst uint8_t IMAGE[] = {\n${str}};`;
fs.writeFileSync(fileOut, out);
require('./../gb2png/')(bits, `${fileOut}.png`);
}
convert('font.png', 'out.c');

75
src/images/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,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,
};

14
src/images/font.h Normal file
View File

@@ -0,0 +1,14 @@
/**
* Copyright (c) 2022 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#include "../libs.h"
#define IMAGE_WIDTH 64
#define IMAGE_HEIGHT 64
#define IMAGE_TILES 64
extern const uint8_t FONT_DATA[];

18
src/libs.h Normal file
View File

@@ -0,0 +1,18 @@
/**
* Copyright (c) 2021 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#pragma once
#ifndef _LIBS_H
#define _LIBS_H
#include <gb/gb.h>
#include <stdint.h>
#include <stdio.h>
#include <stdbool.h>
#endif

82
src/main.c Normal file
View File

@@ -0,0 +1,82 @@
/**
* Copyright (c) 2021 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#include "libs.h"
#include "text.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;
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;
set_bkg_data(0x00, 0x04, std_data);
set_bkg_data(0x04, FONT_TILE_COUNT, FONT);
// Fill screen white
uint8_t filled[0x20*0x20];
for(j = 0; j < 0x20*0x20; j++) {
filled[j] = 0x00;
}
set_bkg_tiles(0x00, 0x00, 0x20, 0x20, filled);
SCX_REG = 0x00;
SCY_REG = 0x00;
DISPLAY_ON;
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);
while(1) {
/* Skip four VBLs (slow down animation) */
for(i = 0; i < 4; i++) {
wait_vbl_done();
}
time++;
}
}

75
src/text.c Normal file
View File

@@ -0,0 +1,75 @@
/**
* 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
};

16
src/text.h Normal file
View File

@@ -0,0 +1,16 @@
/**
* 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

BIN
test.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 205 B