diff --git a/build_rom.sh b/build_rom.sh new file mode 100755 index 00000000..867ee362 --- /dev/null +++ b/build_rom.sh @@ -0,0 +1,10 @@ +#! /usr/bin/env bash + +set -e + +padbin 32 build/gba-release/src/player/nostalgia.bin +echo NOSTALGIA_MEDIA_HEADER_________ > media_header.txt +oxfs format 32 1m nostalgia_media.oxfs +./build/current/src/tools/nost-pack -fs nostalgia_media.oxfs -img charset.png -inode 1 -c +cat build/gba-release/src/player/nostalgia.bin media_header.txt nostalgia_media.oxfs > nostalgia.gba +gbafix nostalgia.gba diff --git a/charset.png b/charset.png new file mode 100644 index 00000000..20bae7eb Binary files /dev/null and b/charset.png differ diff --git a/media_header.txt b/media_header.txt new file mode 100644 index 00000000..a7049b62 --- /dev/null +++ b/media_header.txt @@ -0,0 +1 @@ +NOSTALGIA_MEDIA_HEADER_________ diff --git a/src/core/gba/gfx.cpp b/src/core/gba/gfx.cpp index c42daa7b..c256a394 100644 --- a/src/core/gba/gfx.cpp +++ b/src/core/gba/gfx.cpp @@ -11,6 +11,7 @@ #include "addresses.hpp" #include "media.hpp" #include "gba.hpp" +#include "../gfx.hpp" namespace nostalgia { namespace core { @@ -20,6 +21,101 @@ using namespace ox::fs; #define TILE_ADDR ((CharBlock*) 0x06000000) #define TILE8_ADDR ((CharBlock8*) 0x06000000) +// map ASCII values to the nostalgia charset +static char charMap[128] = { + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 38, // ! + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 37, // , + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 1, // A + 2, // B + 3, // C + 4, // D + 5, // E + 6, // F + 7, // G + 8, // H + 9, // I + 10, // J + 11, // K + 12, // L + 13, // M + 14, // N + 15, // O + 16, // P + 17, // Q + 18, // R + 19, // S + 20, // T + 21, // U + 22, // V + 23, // W + 24, // X + 25, // Y + 26, // Z +}; + ox::Error initGfx() { /* Sprite Mode ----\ */ /* ---\| */ @@ -28,19 +124,24 @@ ox::Error initGfx() { /* |||| */ REG_DISPCNT = 0x1100; + return 0; +} + +void initConsole() { auto fs = (FileStore32*) findMedia(); REG_BG0CNT = (28 << 8) | 1; REG_BG0CNT |= (1 << 7); // set to use 8 bits per pixel if (fs) { FileStore32::FsSize_t readSize = 0; - fs->read(1, 511, 8 * 64 * 36, &TILE8_ADDR[0][1], nullptr); + fs->read(1, 512, 8 * 64 * 36, &TILE8_ADDR[0][1], nullptr); fs->read(1, 0, 512, &MEM_PALLETE_BG[0], &readSize); } +} - MEM_BG_MAP[28][106] = 1; - MEM_BG_MAP[28][107] = 1; - - return 0; +void puts(int loc, const char *str) { + for (int i = 0; str[i]; i++) { + MEM_BG_MAP[28][loc + i] = charMap[(int) str[i]]; + } } } diff --git a/src/core/gfx.hpp b/src/core/gfx.hpp index d6d6af48..98037475 100644 --- a/src/core/gfx.hpp +++ b/src/core/gfx.hpp @@ -14,5 +14,9 @@ namespace core { ox::Error initGfx(); +void initConsole(); + +void puts(int loc, const char *str); + } } diff --git a/src/core/qt/gfx.cpp b/src/core/qt/gfx.cpp index 8b7c08d0..21b92fe7 100644 --- a/src/core/qt/gfx.cpp +++ b/src/core/qt/gfx.cpp @@ -15,5 +15,11 @@ ox::Error initGfx() { return 0; } +void initConsole() { +} + +void puts(int loc, const char *str) { +} + } } diff --git a/src/player/main.cpp b/src/player/main.cpp index a63a883e..90229b2c 100644 --- a/src/player/main.cpp +++ b/src/player/main.cpp @@ -12,6 +12,8 @@ using namespace nostalgia; int main() { core::init(); + core::initConsole(); + core::puts(296, "HELLO, WORLD!"); while (1); return 0; }