Committing progres

This commit is contained in:
2022-01-06 09:22:49 -08:00
parent f339ce0713
commit 4ad29e981e
15 changed files with 74 additions and 320 deletions

Binary file not shown.

View File

@@ -1,5 +1,5 @@
const GAME_STRINGS = {
'HELLO': 'Hello World!\nHow are you today?'
'HELLO': 'Hello World!\nHow are you today?\nThank god!'
};
module.exports = { GAME_STRINGS };

View File

@@ -11,6 +11,9 @@ const DIR_GENERATED = path.resolve(DIR_BUILD, 'generated');
const DIR_OBJ = path.resolve(DIR_BUILD, 'obj');
const DIR_SRC = path.resolve('src');
const DIR_GBDK = path.resolve(process.env['GBDKDIR']);
const DIR_ASSETS = path.resolve('assets');
const DIR_IMAGES = path.resolve(DIR_ASSETS, 'images');
const FILE_OUT = path.resolve(DIR_BUILD, 'Penny.gb');
const FILE_LINKFILE = path.join(DIR_BUILD, `linkflile.lk`);
@@ -85,15 +88,21 @@ Object.entries(GAME_STRINGS).forEach(entry => {
compileC(fileC);
})
// Gen imagery
fs.readdirSync(DIR_IMAGES).forEach(img => {
const { fileC, fileH } = png2gb(
path.join(DIR_IMAGES, img), DIR_GENERATED,
path.basename(img, '.png').toUpperCase()
);
compileC(fileC);
})
// Get a list of sources and build each of them prior to linking.
const allSources = buildSourceFiles(DIR_SRC);
for(let i = 0; i < allSources.length; i++) {
compileC(allSources[i]);
}
// Gen imagery
// Generate a linkfile.
fs.writeFileSync(FILE_LINKFILE, compiledSources.map(cs=>{
return path.join(DIR_OBJ, cs);

View File

@@ -1,4 +1,5 @@
const PNG = require('pngjs').PNG;
const path = require('path');
const fs = require('fs');
const { arrayToString } = require('./util');
const {
@@ -15,8 +16,7 @@ const getPixelValue = (pixel) => {
throw new Error();
}
const png2gb = (fileIn, fileOut, name) => {
const png2gb = (fileIn, dirOut, name) => {
const data = fs.readFileSync(fileIn);
const png = PNG.sync.read(data);
@@ -66,16 +66,24 @@ const png2gb = (fileIn, fileOut, name) => {
bits.push(lowBits, highBits);
}
let out = '';
out += `#include "libs.h"\n\n`
out += `#define ${name}_IMAGE_WIDTH ${png.width}\n`;
out += `#define ${name}_IMAGE_HEIGHT ${png.height}\n`;
out += `#define ${name}_IMAGE_COLUMNS ${png.width / TILE_WIDTH}\n`;
out += `#define ${name}_IMAGE_ROWS ${png.height / TILE_HEIGHT}\n`;
out += `#define ${name}_IMAGE_TILES ${columns * rows}\n`;
out += `\nconst uint8_t ${name}_IMAGE[] = {\n${arrayToSTring(bits)}};`;
let outH = '';
outH += `#include "libs.h"\n\n`
outH += `#define ${name}_IMAGE_WIDTH ${png.width}\n`;
outH += `#define ${name}_IMAGE_HEIGHT ${png.height}\n`;
outH += `#define ${name}_IMAGE_COLUMNS ${png.width / TILE_WIDTH}\n`;
outH += `#define ${name}_IMAGE_ROWS ${png.height / TILE_HEIGHT}\n`;
outH += `#define ${name}_IMAGE_TILES ${columns * rows}\n`;
outH += `extern const uint8_t ${name}_IMAGE[];`;
fs.writeFileSync(fileOut, out);
let outC = `#include "${name}.h"\n`;
outC += `\nconst uint8_t ${name}_IMAGE[] = {\n${arrayToString(bits)}};`;
const fileH = path.join(dirOut, name + '.h');
const fileC = path.join(dirOut, name + '.c');
fs.writeFileSync(fileH, outH);
fs.writeFileSync(fileC, outC);
return { fileH, fileC };
}
module.exports = {

View File

@@ -16,4 +16,4 @@ const uint8_t COMMON_TILES[] = {
void commonTilesInit() {
set_bkg_data(0x00, COMMON_TILE_COUNT, COMMON_TILES);
}${}
}

View File

@@ -1,107 +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,0x1C,0x1C,0x18,0x18,0x30,0x30,0x00,0x00,0x40,0x40,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,
0x00,0x00,0x00,0x00,0x78,0x78,0x04,0x04,0x3C,0x3C,0x44,0x44,0x3A,0x3A,0x00,0x00,
0x20,0x20,0x20,0x20,0x20,0x20,0x3C,0x3C,0x22,0x22,0x22,0x22,0x3C,0x3C,0x00,0x00,
0x00,0x00,0x00,0x00,0x1C,0x1C,0x22,0x22,0x20,0x20,0x22,0x22,0x1C,0x1C,0x00,0x00,
0x02,0x02,0x02,0x02,0x02,0x02,0x1E,0x1E,0x22,0x22,0x22,0x22,0x1E,0x1E,0x00,0x00,
0x00,0x00,0x00,0x00,0x1C,0x1C,0x22,0x22,0x3E,0x3E,0x20,0x20,0x1E,0x1E,0x00,0x00,
0x06,0x06,0x08,0x08,0x08,0x08,0x3E,0x3E,0x08,0x08,0x08,0x08,0x08,0x08,0x00,0x00,
0x00,0x00,0x1C,0x1C,0x22,0x22,0x22,0x22,0x1E,0x1E,0x02,0x02,0x3C,0x3C,0x00,0x00,
0x20,0x20,0x20,0x20,0x20,0x20,0x3C,0x3C,0x22,0x22,0x22,0x22,0x22,0x22,0x00,0x00,
0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x00,0x00,
0x00,0x00,0x02,0x02,0x00,0x00,0x02,0x02,0x02,0x02,0x12,0x12,0x0C,0x0C,0x00,0x00,
0x10,0x10,0x10,0x10,0x12,0x12,0x14,0x14,0x18,0x18,0x14,0x14,0x12,0x12,0x00,0x00,
0x0C,0x0C,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x0E,0x0E,0x00,0x00,
0x00,0x00,0x00,0x00,0x34,0x34,0x2A,0x2A,0x2A,0x2A,0x22,0x22,0x22,0x22,0x00,0x00,
0x00,0x00,0x00,0x00,0x3C,0x3C,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x00,0x00,
0x00,0x00,0x00,0x00,0x1C,0x1C,0x22,0x22,0x22,0x22,0x22,0x22,0x1C,0x1C,0x00,0x00,
0x00,0x00,0x00,0x00,0x3C,0x3C,0x22,0x22,0x22,0x22,0x3C,0x3C,0x20,0x20,0x00,0x00,
0x00,0x00,0x00,0x00,0x1E,0x1E,0x22,0x22,0x22,0x22,0x1E,0x1E,0x02,0x02,0x00,0x00,
0x00,0x00,0x00,0x00,0x2C,0x2C,0x32,0x32,0x20,0x20,0x20,0x20,0x20,0x20,0x00,0x00,
0x00,0x00,0x00,0x00,0x1E,0x1E,0x20,0x20,0x1C,0x1C,0x02,0x02,0x3C,0x3C,0x00,0x00,
0x10,0x10,0x10,0x10,0x3C,0x3C,0x10,0x10,0x10,0x10,0x12,0x12,0x0C,0x0C,0x00,0x00,
0x00,0x00,0x00,0x00,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x1E,0x1E,0x00,0x00,
0x00,0x00,0x00,0x00,0x22,0x22,0x22,0x22,0x22,0x22,0x14,0x14,0x08,0x08,0x00,0x00,
0x00,0x00,0x00,0x00,0x82,0x82,0x82,0x82,0x44,0x44,0x54,0x54,0x28,0x28,0x00,0x00,
0x00,0x00,0x00,0x00,0x42,0x42,0x24,0x24,0x18,0x18,0x24,0x24,0x42,0x42,0x00,0x00,
0x00,0x00,0x00,0x00,0x42,0x42,0x24,0x24,0x18,0x18,0x10,0x10,0x60,0x60,0x00,0x00,
0x00,0x00,0x00,0x00,0x3E,0x3E,0x04,0x04,0x08,0x08,0x10,0x10,0x3E,0x3E,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
};

View File

@@ -1,18 +0,0 @@
/**
* Copyright (c) 2022 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#pragma once
#include "libs.h"
#include "common_tiles.h"
#define FONT_IMAGE_WIDTH 64
#define FONT_IMAGE_HEIGHT 96
#define FONT_TILE_COUNT 96
#define FONT_DATA_POSITION COMMON_TILE_COUNT
extern const uint8_t FONT_DATA[];

View File

@@ -1,20 +0,0 @@
/**
* Copyright (c) 2022 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#include "frame.h"
const uint8_t FRAME_DATA[] = {
0x00,0x00,0x00,0x00,0x3F,0x3F,0x29,0x29,0x3D,0x3D,0x2F,0x2F,0x24,0x24,0x3C,0x3C,
0x00,0x00,0x00,0x00,0xFF,0xFF,0x99,0x99,0x33,0x33,0xFF,0xFF,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0xFC,0xFC,0x94,0x94,0xBC,0xBC,0xF4,0xF4,0x24,0x24,0x3C,0x3C,
0x2C,0x2C,0x24,0x24,0x34,0x34,0x3C,0x3C,0x2C,0x2C,0x24,0x24,0x34,0x34,0x3C,0x3C,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x2C,0x2C,0x24,0x24,0x34,0x34,0x3C,0x3C,0x2C,0x2C,0x24,0x24,0x34,0x34,0x3C,0x3C,
0x3C,0x3C,0x24,0x24,0x2F,0x2F,0x3D,0x3D,0x29,0x29,0x3F,0x3F,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0xFF,0xFF,0x99,0x99,0x33,0x33,0xFF,0xFF,0x00,0x00,0x00,0x00,
0x3C,0x3C,0x24,0x24,0xF4,0xF4,0xBC,0xBC,0x94,0x94,0xFC,0xFC,0x00,0x00,0x00,0x00,
};

View File

@@ -1,29 +0,0 @@
/**
* 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"
#define FRAME_IMAGE_WIDTH 24
#define FRAME_IMAGE_HEIGHT 24
#define FRAME_TILE_COUNT 9
#define FRAME_DATA_POSITION FONT_DATA_POSITION+FONT_TILE_COUNT
#define FRAME_TILE_TOP_LEFT FRAME_DATA_POSITION
#define FRAME_TILE_TOP_CENTER FRAME_TILE_TOP_LEFT + 1
#define FRAME_TILE_TOP_RIGHT FRAME_TILE_TOP_CENTER + 1
#define FRAME_TILE_CENTER_LEFT FRAME_TILE_TOP_RIGHT + 1
#define FRAME_TILE_CENTER FRAME_TILE_CENTER_LEFT + 1
#define FRAME_TILE_CENTER_RIGHT FRAME_TILE_CENTER + 1
#define FRAME_TILE_BOTTOM_LEFT FRAME_TILE_CENTER_RIGHT + 1
#define FRAME_TILE_BOTTOM_CENTER FRAME_TILE_BOTTOM_LEFT + 1
#define FRAME_TILE_BOTTOM_RIGHT FRAME_TILE_BOTTOM_CENTER + 1
extern const uint8_t FRAME_DATA[];

View File

@@ -9,7 +9,7 @@
#include "textbox.h"
#include "time.h"
#include "common_tiles.h"
#include "penny.h"
#include "memory.h"
#include "HELLO.h"
void main() {
@@ -24,15 +24,15 @@ void main() {
// Prepare tiles.
commonTilesInit();
textboxInit();
set_bkg_data(PENNY_DATA_POSITION, PENNY_IMAGE_TILES, PENNY_IMAGE);
set_bkg_data(SM_DATA_POSITION, SM_IMAGE_TILES, SM_IMAGE);
// Fill screen white
for(j = 0; j < 0x20*0x20; j++) filled[j] = COMMON_TILE_3;
set_bkg_tiles(0x00, 0x00, 0x20, 0x20, filled);
uint8_t penny[PENNY_IMAGE_TILES];
for(j = 0; j < PENNY_IMAGE_TILES; j++) penny[j] = j + PENNY_DATA_POSITION;
set_bkg_tiles(0x00, 0x00, PENNY_IMAGE_COLUMNS, PENNY_IMAGE_ROWS, penny);
uint8_t sm[SM_IMAGE_TILES];
for(j = 0; j < SM_IMAGE_TILES; j++) sm[j] = j + SM_DATA_POSITION;
set_bkg_tiles(0x00, 0x00, SM_IMAGE_COLUMNS, SM_IMAGE_ROWS, sm);
SCX_REG = 0x00;
SCY_REG = 0x00;

15
src/memory.h 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
*/
#pragma once
#include "FONT.h"
#include "BORDER.h"
#include "SM.h"
#define FONT_DATA_POSITION 0x04
#define BORDER_DATA_POSITION FONT_DATA_POSITION+FONT_IMAGE_TILES
#define SM_DATA_POSITION BORDER_DATA_POSITION+BORDER_IMAGE_TILES

View File

@@ -1,91 +0,0 @@
/**
* Copyright (c) 2022 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#include "penny.h"
const uint8_t PENNY_IMAGE[] = {
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x02,0x02,0x05,0x04,0x00,0x04,0x04,0x0B,
0x00,0x00,0x00,0x00,0x78,0x78,0x84,0x86,0xCC,0x01,0x02,0x30,0x01,0x08,0x0B,0x85,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3E,0xBF,0xFF,0xC0,0xFF,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0x1F,0xFF,0xE0,0xFF,0x00,
0x00,0x00,0x00,0x00,0x03,0x03,0x0F,0x0C,0x1C,0x10,0x30,0x23,0xE0,0xE4,0xF0,0x35,
0x00,0x00,0x00,0x00,0xC0,0xC0,0xF0,0x30,0x38,0xC8,0x0C,0x04,0x04,0x74,0x0C,0x82,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x08,0x08,0x08,0x0B,0x08,0x0C,0x04,0x04,0x06,0x04,0x03,0x0E,0x01,0x11,0x02,0x24,
0x05,0x62,0x1B,0x8C,0x1F,0x70,0x3C,0x20,0x71,0x28,0xB2,0x48,0x38,0xC4,0x76,0xC0,
0xE3,0x00,0x00,0xC0,0x40,0x20,0x20,0x00,0x83,0x00,0x00,0x00,0x00,0x00,0x07,0x00,
0x98,0x60,0xE0,0x00,0x00,0x00,0x00,0x00,0x04,0x88,0x80,0x50,0x20,0x00,0x0C,0x00,
0xF8,0x0A,0x3B,0x04,0x1C,0x03,0x0E,0x01,0x0F,0x00,0x05,0x02,0x06,0x00,0x04,0x00,
0x06,0x02,0x06,0xF2,0x84,0x0E,0xB8,0x04,0x60,0x98,0x18,0xFC,0x74,0xE4,0xBE,0x42,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x01,0x03,0x02,0x03,0x02,0x06,0x04,
0x65,0x41,0xCF,0x82,0xCF,0x84,0x8E,0x04,0x8F,0x05,0x0F,0x05,0x1B,0x02,0x1B,0x0A,
0xE0,0x00,0x80,0x00,0x60,0x40,0xC0,0x80,0xC0,0x00,0x80,0x00,0x81,0x01,0x8A,0x02,
0x00,0x00,0x08,0x00,0x08,0x11,0x10,0x22,0x12,0x22,0x7A,0x7A,0x05,0x91,0x0B,0x41,
0x10,0x00,0x00,0x4C,0x8A,0xB6,0x57,0x4D,0x32,0x32,0x00,0x00,0x00,0x01,0x01,0x82,
0x00,0x20,0x20,0x00,0x20,0x10,0x10,0x08,0x95,0x88,0xF9,0xF8,0xBD,0x94,0x68,0x32,
0x06,0x1A,0x0B,0x05,0x1B,0x15,0x07,0x08,0x0B,0x04,0x05,0x02,0x25,0x02,0x33,0x02,
0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x80,0x80,0x80,0x80,0x80,0x40,0x40,0x40,0x40,
0x06,0x04,0x06,0x04,0x02,0x04,0x00,0x04,0x0C,0x08,0x04,0x08,0x04,0x08,0x04,0x08,
0x3B,0x0A,0x39,0x09,0x31,0x13,0x33,0x12,0x31,0x11,0x71,0x11,0x70,0x10,0x60,0x20,
0xEC,0x00,0x6C,0x00,0x36,0x01,0xB0,0x02,0x9F,0x02,0xDC,0x04,0xFC,0x88,0x7E,0x54,
0x74,0x00,0xC0,0x00,0x3C,0x9C,0x62,0x22,0x5D,0x59,0xBD,0xBD,0xA4,0xA4,0x86,0xA6,
0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x00,0x00,0x01,0x01,0x01,0x01,0x01,0x01,
0x7C,0x82,0x04,0x02,0xE7,0xE0,0x12,0x11,0xEA,0xC9,0xFF,0xE4,0x24,0x35,0x23,0x30,
0x63,0x0A,0xE7,0x04,0x93,0x04,0x07,0x90,0x0B,0x24,0x17,0xC8,0x3F,0x18,0xEF,0x68,
0xC0,0x40,0xC0,0x40,0xA0,0x20,0xA0,0x20,0xA0,0x20,0xA0,0x20,0xA0,0x20,0x90,0x10,
0x1C,0x10,0x14,0x10,0x14,0x10,0x14,0x10,0x10,0x14,0x10,0x12,0x10,0x12,0x10,0x12,
0x60,0x20,0x60,0x20,0x60,0x20,0x60,0x20,0xE0,0x20,0xE0,0x20,0xE0,0x20,0xE0,0x20,
0x7E,0x64,0x36,0x2C,0x2D,0x2A,0x17,0x32,0x13,0x12,0x0C,0x0F,0x01,0x01,0x00,0x00,
0x3C,0x3E,0x14,0x36,0x10,0x1C,0x00,0x00,0x00,0x00,0x80,0x28,0x80,0x00,0xC0,0x80,
0x00,0x01,0x00,0x01,0x01,0x10,0x00,0x10,0x00,0x08,0x00,0x00,0x60,0xFC,0x78,0x84,
0xE7,0xF2,0x67,0x73,0x47,0xA2,0x02,0x04,0x02,0x04,0x0D,0x57,0x0C,0x04,0x08,0x08,
0xCF,0x48,0xCF,0x48,0x47,0x44,0x07,0x44,0x87,0x84,0x07,0x04,0x03,0x02,0x03,0x02,
0x90,0x10,0x90,0x10,0xD0,0x10,0xD0,0x10,0xC8,0x08,0xC8,0x08,0xC8,0x08,0x48,0x88,
0x10,0x12,0x10,0x12,0x30,0x21,0x30,0x21,0x30,0x21,0x31,0x20,0x30,0x20,0x30,0x20,
0x70,0x10,0x70,0x10,0x30,0x10,0x30,0x10,0x30,0x10,0x30,0x10,0xB0,0x10,0xB0,0x10,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x60,0x40,0x20,0x20,0x10,0x10,0x0C,0x08,0x08,0x0A,0x0D,0x09,0x0C,0x08,0x0C,0x08,
0x30,0x48,0x00,0x30,0x00,0x00,0x00,0x00,0x01,0x00,0xC3,0x83,0xE4,0x6A,0x04,0x12,
0x18,0x08,0x30,0x10,0x60,0x20,0xC0,0x40,0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x00,
0x03,0x02,0x03,0x02,0x03,0x02,0x03,0x02,0x03,0x02,0x03,0x02,0x07,0x04,0x07,0x04,
0x08,0x88,0x04,0x84,0x84,0x44,0x84,0x44,0xC4,0x04,0xC4,0x24,0xC4,0x24,0xC4,0x24,
0x30,0x20,0x38,0x20,0x38,0x20,0x38,0x20,0x38,0x20,0x38,0x20,0x38,0x20,0x18,0x10,
0x70,0x10,0x70,0x10,0x18,0x28,0x18,0x28,0x28,0x18,0x28,0x18,0x3C,0x08,0x39,0x09,
0x00,0x00,0x00,0x00,0x01,0x01,0x06,0x07,0x18,0x1F,0x60,0x7F,0x84,0xE7,0xB8,0xB9,
0x08,0x08,0x68,0x78,0x38,0xF8,0x1C,0xF0,0x0C,0xF8,0x04,0xFC,0x03,0xFE,0x01,0xFF,
0x06,0x02,0x07,0x03,0x03,0x03,0x03,0x02,0x03,0x00,0x00,0x00,0x01,0x82,0x00,0x44,
0x00,0x00,0x80,0x80,0x60,0xE0,0x9C,0xFC,0x82,0xFE,0x81,0xFF,0x80,0xFF,0x80,0xFE,
0x07,0x04,0x07,0x04,0x07,0x04,0x07,0x04,0x0F,0x08,0x8F,0xC8,0x7F,0x70,0xDF,0xDC,
0x84,0x24,0xA4,0x04,0x24,0x04,0x24,0x04,0x14,0x04,0x14,0x04,0x14,0x04,0x14,0x04,
0x1C,0x10,0x1C,0x10,0x1C,0x10,0x1C,0x10,0x1C,0x10,0x1C,0x10,0x0C,0x08,0x0D,0x08,
0x3F,0x07,0x38,0x08,0x70,0x10,0x60,0x20,0xC2,0x40,0x81,0x81,0x80,0x80,0x81,0x80,
0xE6,0xE6,0x39,0x39,0x04,0x06,0x01,0x01,0x00,0x00,0x80,0x00,0xC0,0x80,0xC1,0x40,
0x01,0x7F,0x80,0xBF,0x40,0x5F,0x80,0xAF,0x80,0xD7,0x20,0x2B,0x10,0x14,0x88,0x0B,
0x01,0x00,0x81,0x80,0xC1,0x80,0x61,0xC1,0x63,0xC1,0x23,0xE1,0x33,0xE1,0x32,0x63,
0x80,0xFE,0x81,0xFD,0x82,0xFA,0x02,0xFA,0x05,0xF5,0x03,0xEB,0x06,0xD6,0x2C,0xAC,
0x33,0xB2,0x71,0x61,0xE0,0xC1,0x80,0x80,0x80,0x80,0x00,0x00,0x03,0x00,0x07,0x00,
0x14,0x04,0x84,0x14,0xC0,0x08,0x48,0x88,0xC8,0x88,0xE8,0x48,0x68,0x48,0x68,0x48,
0x0F,0x08,0x0F,0x08,0x0F,0x08,0x0F,0x08,0x07,0x04,0x07,0x04,0x07,0x04,0x07,0x04,
0x81,0x80,0x81,0x80,0x80,0x80,0xC0,0x40,0xC0,0x40,0xC0,0x40,0x80,0x80,0x80,0x80,
0xE9,0x41,0xD6,0x27,0xD8,0x2F,0x78,0x0F,0x78,0x0F,0x78,0x0F,0x78,0x0F,0xF8,0x0F,
0xF4,0xC4,0x3E,0xFF,0x03,0xFF,0x00,0xFF,0x08,0xF7,0x06,0xF9,0x02,0xFD,0x04,0xFB,
0x12,0xB3,0x1E,0x52,0x3F,0xBF,0x70,0xE1,0xE0,0xCC,0xC0,0x92,0xA0,0xBD,0xA1,0xBD,
0x1F,0x5F,0x38,0xBF,0x60,0x7F,0x80,0xFF,0x98,0xE7,0x50,0x6F,0x50,0x6F,0x48,0x77,
0xC7,0xC0,0x27,0xE0,0x17,0xF0,0x97,0x70,0x56,0xB0,0x52,0xB0,0x52,0xB0,0x52,0xB0,
0x68,0x48,0x68,0x48,0x70,0x50,0x70,0x50,0x70,0x50,0x70,0x50,0x70,0x50,0x38,0x28,
0x07,0x04,0x07,0x04,0x03,0x02,0x03,0x02,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
0x80,0x80,0xC0,0x80,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x00,0x01,0x00,0x07,0x02,
0xF8,0x0F,0x7C,0x27,0x7C,0x07,0xFC,0x2F,0xFC,0x2F,0xDC,0x2F,0xFB,0x2F,0xF0,0x6F,
0x08,0xF7,0x00,0xFF,0x03,0xFF,0x0C,0xFF,0x30,0xFF,0xC1,0xFF,0x83,0xFE,0x06,0xFC,
0x52,0x9E,0xED,0xCC,0x33,0xE1,0x7D,0xDE,0xFF,0x80,0xFF,0x00,0xE0,0x00,0x00,0x00,
0xC4,0x7B,0x80,0xFF,0x60,0xFF,0x90,0xFF,0xC8,0x7F,0xE4,0x3F,0x73,0x1F,0x38,0x0F,
0x1C,0xFC,0x14,0xFC,0x14,0xFC,0x10,0xFC,0x10,0xFC,0x16,0xFC,0x26,0xFC,0xC4,0xFC,
0x38,0x28,0x38,0x28,0x38,0x28,0x38,0x28,0x38,0x28,0x38,0x10,0x18,0x10,0x10,0x10,
};

View File

@@ -1,20 +0,0 @@
/**
* Copyright (c) 2022 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#pragma once
#include "libs.h"
#include "frame.h"
#define PENNY_IMAGE_WIDTH 64
#define PENNY_IMAGE_HEIGHT 80
#define PENNY_IMAGE_COLUMNS 8
#define PENNY_IMAGE_ROWS 10
#define PENNY_IMAGE_TILES 80
#define PENNY_DATA_POSITION FRAME_DATA_POSITION+FRAME_TILE_COUNT
extern const uint8_t PENNY_IMAGE[];

View File

@@ -13,7 +13,6 @@ uint8_t TEXTBOX_STATE;
uint8_t TEXTBOX_SCROLL;
uint8_t TEXTBOX_TILES[TEXTBOX_TILES_MAX];
void textboxInit() {
uint8_t i;
@@ -25,23 +24,23 @@ void textboxInit() {
// Setup window data
move_win(7, SCREENHEIGHT - (TEXTBOX_HEIGHT_IN_TILES * 8));
set_win_data(FONT_DATA_POSITION, FONT_TILE_COUNT, FONT_DATA);
set_win_data(FRAME_DATA_POSITION, FRAME_TILE_COUNT, FRAME_DATA);
set_win_data(FONT_DATA_POSITION, FONT_IMAGE_TILES, FONT_IMAGE);
set_win_data(BORDER_DATA_POSITION, BORDER_IMAGE_TILES, BORDER_IMAGE);
// Corners
TEXTBOX_TILES[0] = FRAME_TILE_TOP_LEFT;
TEXTBOX_TILES[TEXTBOX_WIDTH_IN_TILES-1] = FRAME_TILE_TOP_RIGHT;
TEXTBOX_TILES[TEXTBOX_TILES_MAX-1] = FRAME_TILE_BOTTOM_RIGHT;
TEXTBOX_TILES[TEXTBOX_TILES_MAX-TEXTBOX_WIDTH_IN_TILES] = FRAME_TILE_BOTTOM_LEFT;
TEXTBOX_TILES[0] = BORDER_TILE_TOP_LEFT;
TEXTBOX_TILES[TEXTBOX_WIDTH_IN_TILES-1] = BORDER_TILE_TOP_RIGHT;
TEXTBOX_TILES[TEXTBOX_TILES_MAX-1] = BORDER_TILE_BOTTOM_RIGHT;
TEXTBOX_TILES[TEXTBOX_TILES_MAX-TEXTBOX_WIDTH_IN_TILES] = BORDER_TILE_BOTTOM_LEFT;
// Edges
for(i = 1; i < TEXTBOX_WIDTH_IN_TILES - 1; i++) {
TEXTBOX_TILES[i] = FRAME_TILE_TOP_CENTER;
TEXTBOX_TILES[TEXTBOX_TILES_MAX - 1 - i] = FRAME_TILE_BOTTOM_CENTER;
TEXTBOX_TILES[i] = BORDER_TILE_TOP_CENTER;
TEXTBOX_TILES[TEXTBOX_TILES_MAX - 1 - i] = BORDER_TILE_BOTTOM_CENTER;
}
for(i = 1; i < TEXTBOX_HEIGHT_IN_TILES - 1; i++) {
TEXTBOX_TILES[TEXTBOX_WIDTH_IN_TILES * i] = FRAME_TILE_CENTER_LEFT;
TEXTBOX_TILES[TEXTBOX_WIDTH_IN_TILES * (i+1) - 1] = FRAME_TILE_CENTER_RIGHT;
TEXTBOX_TILES[TEXTBOX_WIDTH_IN_TILES * i] = BORDER_TILE_CENTER_LEFT;
TEXTBOX_TILES[TEXTBOX_WIDTH_IN_TILES * (i+1) - 1] = BORDER_TILE_CENTER_RIGHT;
}
}

View File

@@ -7,10 +7,19 @@
#pragma once
#include "libs.h"
#include "font.h"
#include "frame.h"
#include "util.h"
#include "common_tiles.h"
#include "memory.h"
#define BORDER_TILE_TOP_LEFT BORDER_DATA_POSITION
#define BORDER_TILE_TOP_CENTER BORDER_TILE_TOP_LEFT + 1
#define BORDER_TILE_TOP_RIGHT BORDER_TILE_TOP_CENTER + 1
#define BORDER_TILE_CENTER_LEFT BORDER_TILE_TOP_RIGHT + 1
#define BORDER_TILE_CENTER BORDER_TILE_CENTER_LEFT + 1
#define BORDER_TILE_CENTER_RIGHT BORDER_TILE_CENTER + 1
#define BORDER_TILE_BOTTOM_LEFT BORDER_TILE_CENTER_RIGHT + 1
#define BORDER_TILE_BOTTOM_CENTER BORDER_TILE_BOTTOM_LEFT + 1
#define BORDER_TILE_BOTTOM_RIGHT BORDER_TILE_BOTTOM_CENTER + 1
#define TEXTBOX_STATE_VISIBLE 1 << 0
#define TEXTBOX_STATE_SCROLLED 1 << 1
@@ -26,7 +35,6 @@
#define TEXTBOX_TILES_ROWS 3
#define TEXTBOX_TILE_BLANK COMMON_TILE_3
extern char *TEXTBOX_TEXT;
extern uint8_t TEXTBOX_TEXT_LENGTH;
extern uint8_t TEXTBOX_STATE;