I cobbled all of the ramfont bits including the data from the font included in laser2 into a fully stripped down c file for IKD but unfortunately I was still unable to print anything to the screen, which shows I still don't have a hang of some of the very basics of UB graphics (or anything) yet.
Code: Select all
#include <avr/interrupt.h>
#include <avr/io.h>
#include <avr/pgmspace.h>
#include <math.h>
#include <stdbool.h>
#include <stdlib.h>
#include <uzebox.h>
const uint8_t myramfont[] PROGMEM = {
0x1c, 0x36, 0x63, 0x63, 0x7f, 0x63, 0x63, 0x00,
0x3f, 0x63, 0x63, 0x3f, 0x63, 0x63, 0x3f, 0x00,
0x3c, 0x66, 0x03, 0x03, 0x03, 0x66, 0x3c, 0x00,
0x1f, 0x33, 0x63, 0x63, 0x63, 0x33, 0x1f, 0x00,
0x7f, 0x03, 0x03, 0x3f, 0x03, 0x03, 0x7f, 0x00,
0x7f, 0x03, 0x03, 0x3f, 0x03, 0x03, 0x03, 0x00,
0x7c, 0x06, 0x03, 0x73, 0x63, 0x66, 0x7c, 0x00,
0x63, 0x63, 0x63, 0x7f, 0x63, 0x63, 0x63, 0x00,
0x7e, 0x18, 0x18, 0x18, 0x18, 0x18, 0x7e, 0x00,
0x78, 0x30, 0x30, 0x30, 0x30, 0x31, 0x1e, 0x00,
0x63, 0x33, 0x1b, 0x0f, 0x1f, 0x3b, 0x73, 0x00,
0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x7e, 0x00,
0x63, 0x77, 0x7f, 0x7f, 0x6b, 0x63, 0x63, 0x00,
0x63, 0x67, 0x6f, 0x7f, 0x7b, 0x73, 0x63, 0x00,
0x3e, 0x63, 0x63, 0x63, 0x63, 0x63, 0x3e, 0x00,
0x3f, 0x63, 0x63, 0x63, 0x3f, 0x03, 0x03, 0x00,
0x3e, 0x63, 0x63, 0x63, 0x7b, 0x33, 0x5e, 0x00,
0x3f, 0x63, 0x63, 0x73, 0x1f, 0x3b, 0x73, 0x00,
0x1e, 0x33, 0x03, 0x3e, 0x60, 0x63, 0x3e, 0x00,
0x7e, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00,
0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x3e, 0x00,
0x63, 0x63, 0x63, 0x77, 0x3e, 0x1c, 0x08, 0x00,
0x63, 0x63, 0x6b, 0x7f, 0x7f, 0x77, 0x63, 0x00,
0x63, 0x77, 0x3e, 0x1c, 0x3e, 0x77, 0x63, 0x00,
0x66, 0x66, 0x66, 0x3c, 0x18, 0x18, 0x18, 0x00,
0x7f, 0x70, 0x38, 0x1c, 0x0e, 0x07, 0x7f, 0x00,
0x00, 0x00, 0x00, 0x00, 0x0c, 0x0c, 0x06, 0x00,
0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x00,
};
void RamFont_Load(const uint8_t* ramfont, uint8_t len, uint8_t fg_color, uint8_t bg_color)
{
SetUserRamTilesCount(len);
for (uint8_t tile = 0; tile < len; ++tile) {
uint8_t* ramTile = GetUserRamTile(tile);
for (uint8_t row = 0; row < 8; ++row) {
uint8_t data = (uint8_t)pgm_read_byte(&ramfont[tile * 8 + row]);
for (uint8_t bit = 0; bit < 8; ++bit)
if (data & (1 << bit))
ramTile[row * 8 + bit] = fg_color;
else
ramTile[row * 8 + bit] = bg_color;
}
}
}
void RamFont_Print(uint8_t x, uint8_t y, const char *message, uint8_t len)
{
for (uint8_t i = 0; i < len; ++i) {
int8_t tileno = (int8_t)pgm_read_byte(&message[i]) - 'A';
if (tileno >= 0)
SetRamTile(x + i, y, tileno);
}
}
const char pgm_press_a[] PROGMEM = "PRESS A TO CONTINUE";
int main() {
ClearVram();
// Calls to DrawMap, or SetTile go here
RamFont_Load(myramfont, sizeof(myramfont) / 8, 0x00, 0xad);
//WaitVsync(1);
// Wait for button presses, etc...
// Optionally call RamFont_Load() again here to change the FG and BG color of text
RamFont_Print(5, 5, pgm_press_a, sizeof(pgm_press_a));
}
I have tried putting RamFont_Print() in a while loop, using different foreground colours and a few other things with no sign of text yet.
Can I not use these (1 BPP) ramfonts on the same screen as some 8 BPP tiles or sprites?