From c882f07089b2ba38c41b1a9726db3d952200cf40 Mon Sep 17 00:00:00 2001 From: Dominic Masters Date: Tue, 4 Jan 2022 09:09:21 -0800 Subject: [PATCH] Whatevers --- .gitignore | 79 ++++++++++++++++++++++++++++++ Font.aseprite | Bin 0 -> 789 bytes data.png | Bin 0 -> 142 bytes font.png | Bin 0 -> 595 bytes out.c | 72 ++++++++++++++++++++++++++++ out.c.png | Bin 0 -> 2547 bytes package.json | 11 +++++ scripts/gb2png/index.js | 104 ++++++++++++++++++++++++++++++++++++++++ scripts/png2gb/index.js | 89 ++++++++++++++++++++++++++++++++++ src/images/font.c | 75 +++++++++++++++++++++++++++++ src/images/font.h | 14 ++++++ src/libs.h | 18 +++++++ src/main.c | 82 +++++++++++++++++++++++++++++++ src/text.c | 75 +++++++++++++++++++++++++++++ src/text.h | 16 +++++++ test.png | Bin 0 -> 205 bytes 16 files changed, 635 insertions(+) create mode 100644 .gitignore create mode 100644 Font.aseprite create mode 100644 data.png create mode 100644 font.png create mode 100644 out.c create mode 100644 out.c.png create mode 100644 package.json create mode 100644 scripts/gb2png/index.js create mode 100644 scripts/png2gb/index.js create mode 100644 src/images/font.c create mode 100644 src/images/font.h create mode 100644 src/libs.h create mode 100644 src/main.c create mode 100644 src/text.c create mode 100644 src/text.h create mode 100644 test.png diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..8aeb3ee --- /dev/null +++ b/.gitignore @@ -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 \ No newline at end of file diff --git a/Font.aseprite b/Font.aseprite new file mode 100644 index 0000000000000000000000000000000000000000..5926422bdc74c0a798f01c1fd055ca102a849673 GIT binary patch literal 789 zcmWe-W?*=*l##&!2ss!S85kH+fEWQ-7#Klkf*RS$FS@7*RuU*i0 z3%-Y)9QXaYw%16Cwrhqz{=O%^_Ne^jgzo&?*ZZEo^NoBg==k~iKEJ;o4tz9}t6A^Nz3F_e9$wE+c%c@KWyQ z@;S8}2c9p?y>n!L`L=gW-+yO)xc^@A+3B0kvdr;wx0tj=pYu(v{&aD{$L+7c`fn{{1j#;jTxUyZ+b9J$ACr{5*5>iTk>LtLkc>&6#g{ z|Mee7`=b*N1?V4ZfA9WpLG`;5m#_YR*|y%fnq4vLY5sk-c(dDI=L$T({rd5q)87TN zuD>d;ee@&rAGbX}->U2v7IRP9X?#8M)^4ZZld%0xZ1s<_QlXwMjv*C{tp^Q7n*#(G4yNAM zpD@8_(uK)dLK7St*WKXY%S+$(_v=672?~x)ESy3rYu=X{OoXw2|1w0d|G>pmdKI;Vst03OpUBme*a literal 0 HcmV?d00001 diff --git a/font.png b/font.png new file mode 100644 index 0000000000000000000000000000000000000000..c90012765cd7203f3c2cc45103cabcaad45205d0 GIT binary patch literal 595 zcmV-Z0<8UsP)Px#3{Xr|MVq`2i>wbYVlWRl5BN)mg8%>l^+`lQR9JWZO4;aB{8zd=L-=xL|+ff4Y>eMUYN&Papvt zm0OH3JQ#zzF{k}l5=LGJJBWZrd$Xc?P^36nIl}+~dRstUXu7KDktm}BoW{G|!_5FI zdT;;x$GYzUev>W0b;QxWHU^N+z(=R~(&7MS3|&jW=p?irT=Js>bcbU|ukL}~cSp+i zL~tm|=IIJ;r4ipim|wbT0R97juHmy_i5d8!#jfZ*n4d(j@;gA;3p?$v0C#B|ARg>S z9)%BL5xM|4mlJI^nyUi@j`Df<1Rz`QSMyQm&pp6#1k@N%RW>nj^D^I}JgG$%}sK`3Nl##Er5(l$_2Lugz8?6K=nL`23%7+{`HTPn002ovPDHLkV1hbJ1PTBE literal 0 HcmV?d00001 diff --git a/out.c b/out.c new file mode 100644 index 0000000..db51898 --- /dev/null +++ b/out.c @@ -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, +} \ No newline at end of file diff --git a/out.c.png b/out.c.png new file mode 100644 index 0000000000000000000000000000000000000000..d7186c6e45c85473bf8ac4c3daa91dd43ecee25c GIT binary patch literal 2547 zcmZuzZA_C_6z(8UC&-7Lg-jfbIo~A%49UVrO8^yhgz&=nkhwZxjHt;-Ej0y}sSFw? zm8e@9A88m7t1rI`+PqKZ94Pj?~SiT)nwiHWXU@_Vx5J~Ft+m($uD`_f~xg```Bsr~V@Gl!e%9yQGF?`oPkLa&^e%ITSo%9+O_{sS3L zeYcCAbPi5D9NPZV-kHk}W|mhD?%tM}vFGXJxAD`4_`OdIcV<1a{e~fN>+atjSLyuu z!#QVLuSMqg9m=NZiLTk{8zZw*75+bG{~D{@dxu^{{uqjwm@+uFb2p;(R%ZY6h5uq9 zDp2V>@+8lweB9mQt%;7Y3P<#%I_<77i}AZ*TZqfaZ^6cB{(vC2g|ub#W95uua|G`) zFdU?u^_ZfcRue;|Jzht$t(;4rC^n4)my^6jX056VljA!@(rPTcyM^v6<2)s%B$pF! z)d^`Xr|}tNQfn2Lre32vCkw8tLke7KR0o1KE)70w#{ZhcjA|(^7m6O#g{i9(&?N8Z zs?h4&h^tJEilIB}#S8da79%({3eR$@kRKkwtL?ufe`qn@5z0(S;#G*<>BtR#_H1zn zS%rJTD8lu&mg*)CQFd`h-7OUsBd`&_&-d7<@*T=3=Ze(!#H||SyguBaR~4Jwj*CE` z-b2+ERVVPcYVwlZjFjsE7P2TYm2qvVzCa**kKcb^Z&dZ2;^lQ_UhQ%g0(g;LM=eJ0 z=rXDy0}W7GtIWK^toYo5liIL$?+L|bcguQI=5i{fC~}i23Aeh@K%BOEYZ`n4zRBt= zd?&I)9o-5uFSk}j>%~sDqwhP#=2BMU4xzMZcFOKd9xmtFY-OCw3BXWI<5ECtMoFV` z^zND+D+&~@v9KEm@FW|o1@a%{G?u$AZt~F27OT53&S0Pun!DNQ#Y&n zWO{v}ZgM5DjYOZpDo*&HEk-Ivf$CCImZ7;(6IL%$RAe@q3`@Z&(7F*ssZJ0<+-l~< zPI8c>`kghr*#pQh069R#5 z4jf(wVUd{;!yytiQ}0cv*8m{dI!Qg;(G8Y%MnITE-XTU>H3VO5Y6a>@e*s&rZB;^Kz6mK8NU`F@XYgHDU;(B7NGR`FrplTJ{+SYh_liK|l| zn6gL|I8AsH=h|XHQ*;EtXfc~ewcZ+zxwxCmm(7k^(KSdM7oZIkfnN$>ho=nlk20V{ z0Xl(=F?9?!>~0~Gb~#T&aq`r!K`}6c#-s@!lLCl>(=y-$x*-@eE8Hb_r%?n?d`{pC zMh-{@84x*on2RKlx4YpTn5|;b69T*>;FTQF+;<=r0{6V&Gr0pazT22X(7", + "license": "MIT", + "dependencies": { + "pngjs": "^6.0.0" + } +} diff --git a/scripts/gb2png/index.js b/scripts/gb2png/index.js new file mode 100644 index 0000000..1ffd1d6 --- /dev/null +++ b/scripts/gb2png/index.js @@ -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; \ No newline at end of file diff --git a/scripts/png2gb/index.js b/scripts/png2gb/index.js new file mode 100644 index 0000000..a3a4139 --- /dev/null +++ b/scripts/png2gb/index.js @@ -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'); \ No newline at end of file diff --git a/src/images/font.c b/src/images/font.c new file mode 100644 index 0000000..424922b --- /dev/null +++ b/src/images/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,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/images/font.h b/src/images/font.h new file mode 100644 index 0000000..96049e7 --- /dev/null +++ b/src/images/font.h @@ -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[]; \ No newline at end of file diff --git a/src/libs.h b/src/libs.h new file mode 100644 index 0000000..8fc79a2 --- /dev/null +++ b/src/libs.h @@ -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 +#include +#include +#include + +#endif \ No newline at end of file diff --git a/src/main.c b/src/main.c new file mode 100644 index 0000000..67a7d7e --- /dev/null +++ b/src/main.c @@ -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++; + } +} diff --git a/src/text.c b/src/text.c new file mode 100644 index 0000000..ca95525 --- /dev/null +++ b/src/text.c @@ -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 +}; \ No newline at end of file diff --git a/src/text.h b/src/text.h new file mode 100644 index 0000000..29ff45f --- /dev/null +++ b/src/text.h @@ -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 \ No newline at end of file diff --git a/test.png b/test.png new file mode 100644 index 0000000000000000000000000000000000000000..5144522540a421521d0ddccb01b2c3c49de7c678 GIT binary patch literal 205 zcmeAS@N?(olHy`uVBq!ia0vp^0zk~c!3HEhl+{lMQY^(zo*^7SP{WbZ0pz!Mx;Tbt zOiZr$@c2+YA1AAY*-4J(&DMM(f7DgZFIgyXpy2UAHnx%r8AD^{wpv9a;E z8hA<^P(PnBN${Jz+Qu{|(ZgNB+yN%9S!NhMn4G?I(?gLto0XCnom*U)4$o>xFEDia z#B+j?iCf`I!(sLFF01BWd>VN{^`hv)-;%L%3|v{Q{o0@3T?D#^!PC{xWt~$(69CL; BMAQHP literal 0 HcmV?d00001