Make the build system create a sysfont.h which includes font information for the system font. Available #defines are: SYSFONT_NAME, SYSFONT_FACENAME, SYSFONT_WIDTH, SYSFONT_HEIGHT, SYSFONT_SIZE, SYSFONT_ASCENT, SYSFONT_DESCENT, SYSFONT_FIRST_CHAR, SYSFONT_LAST_CHAR, SYSFONT_DEFAULT_CHAR, SYSFONT_PROPORTIONAL, SYSFONT_COPYRIGHT, SYSFONT_BITS_SIZE.

Also fix a small bug in the iPod bootloader printf() code and use printf() for PortalPlayer bootloaders too.


git-svn-id: svn://svn.rockbox.org/rockbox/trunk@12041 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Barry Wardell 2007-01-17 12:20:38 +00:00
parent b0d1bb891e
commit f4709d0c7c
5 changed files with 114 additions and 40 deletions

View file

@ -178,7 +178,7 @@ void printf(const char *format, ...)
lcd_puts(0, line++, ptr);
lcd_update();
if(line >= 30)
if(line >= (LCD_HEIGHT/SYSFONT_HEIGHT))
line = 0;
}

View file

@ -24,6 +24,7 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <stdarg.h>
#include "cpu.h"
#include "system.h"
#include "lcd.h"
@ -51,6 +52,31 @@ char version[] = APPSVERSION;
#define DRAM_START 0x10000000
int line=0;
char printfbuf[256];
void reset_screen(void)
{
lcd_clear_display();
line = 0;
}
void printf(const char *format, ...)
{
int len;
unsigned char *ptr;
va_list ap;
va_start(ap, format);
ptr = printfbuf;
len = vsnprintf(ptr, sizeof(printfbuf), format, ap);
va_end(ap);
lcd_puts(0, line++, ptr);
lcd_update();
if(line >= (LCD_HEIGHT/SYSFONT_HEIGHT))
line = 0;
}
/* Load original mi4 firmware. This function expects a file called
"/System/OF.bin" on the player. It should be a mi4 firmware decrypted
@ -100,9 +126,7 @@ int load_rockbox(unsigned char* buf)
len = filesize(fd) - 8;
snprintf(str, sizeof(str), "Length: %x", len);
lcd_puts(0, line++ ,str);
lcd_update();
printf("Length: %x", len);
if (len > MAX_LOADSIZE)
return -6;
@ -114,9 +138,7 @@ int load_rockbox(unsigned char* buf)
if(rc < 4)
return -2;
snprintf(str, sizeof(str), "Checksum: %x", chksum);
lcd_puts(0, line++ ,str);
lcd_update();
printf("Checksum: %x", chksum);
rc = read(fd, model, 4);
if(rc < 4)
@ -124,9 +146,7 @@ int load_rockbox(unsigned char* buf)
model[4] = 0;
snprintf(str, sizeof(str), "Model name: %s", model);
lcd_puts(0, line++ ,str);
lcd_update();
printf("Model name: %s", model);
lseek(fd, FIRMWARE_OFFSET_FILE_DATA, SEEK_SET);
@ -142,9 +162,7 @@ int load_rockbox(unsigned char* buf)
sum += buf[i];
}
snprintf(str, sizeof(str), "Sum: %x", sum);
lcd_puts(0, line++ ,str);
lcd_update();
printf("Sum: %x", sum);
if(sum != chksum)
return -5;
@ -170,12 +188,9 @@ void* main(void)
lcd_setfont(FONT_SYSFIXED);
lcd_puts(0, line++, "Rockbox boot loader");
snprintf(buf, sizeof(buf), "Version: 20%s", version);
lcd_puts(0, line++, buf);
snprintf(buf, sizeof(buf), MODEL_NAME);
lcd_puts(0, line++, buf);
lcd_update();
printf("Rockbox boot loader");
printf("Version: 20%s", version);
printf(MODEL_NAME);
i=ata_init();
if (i==0) {
@ -188,44 +203,33 @@ void* main(void)
for (i=39; i && buf[i]==' '; i--) {
buf[i]=0;
}
lcd_puts(0, line++, buf);
lcd_update();
printf(buf);
} else {
snprintf(buf, sizeof(buf), "ATA: %d", i);
lcd_puts(0, line++, buf);
lcd_update();
printf("ATA: %d", i);
}
disk_init();
rc = disk_mount_all();
if (rc<=0)
{
lcd_puts(0, line++, "No partition found");
lcd_update();
printf("No partition found");
}
pinfo = disk_partinfo(0);
snprintf(buf, sizeof(buf), "Partition 0: 0x%02x %ld MB",
pinfo->type, pinfo->size / 2048);
lcd_puts(0, line++, buf);
lcd_update();
printf("Partition 0: 0x%02x %ld MB", pinfo->type, pinfo->size / 2048);
i=button_read_device();
if(i==BUTTON_LEFT)
{
lcd_puts(0, line++, "Loading original firmware...");
lcd_update();
printf("Loading original firmware...");
rc=load_original_firmware(loadbuffer);
} else {
lcd_puts(0, line++, "Loading Rockbox...");
lcd_update();
printf("Loading Rockbox...");
rc=load_rockbox(loadbuffer);
}
if (rc < 0) {
snprintf(buf, sizeof(buf), "Rockbox error: %d",rc);
lcd_puts(0, line++, buf);
lcd_update();
printf("Rockbox error: %d",rc);
while(1) {}
}

View file

@ -40,6 +40,9 @@ clean:
$(OBJDIR)/thread.o: thread.c export/thread.h
$(call PRINTS,CC thread.c)$(CC) -c -O -fomit-frame-pointer $(CFLAGS) $< -o $@
sysfont.h: ../fonts/rockbox_default.bdf
$(call PRINTS,Create sysfont.h)$(TOOLSDIR)/convbdf -h -o $(BUILDDIR)/sysfont.h $<
$(OBJDIR)/sysfont.o: ../fonts/rockbox_default.bdf
$(call PRINTS,CONVBDF)$(TOOLSDIR)/convbdf -c -o $(OBJDIR)/sysfont.c $<
$(call PRINTS,CC sysfont.c)$(CC) $(CFLAGS) -c $(OBJDIR)/sysfont.c -o $@

View file

@ -23,6 +23,7 @@
* Incore font and image definitions
*/
#include "config.h"
#include "sysfont.h"
#if defined(HAVE_LCD_BITMAP) || defined(SIMULATOR)

View file

@ -64,6 +64,7 @@ struct font {
#define EXTRA 300 /* # bytes extra allocation for buggy .bdf files*/
int gen_c = 0;
int gen_h = 0;
int gen_fnt = 0;
int gen_map = 1;
int start_char = 0;
@ -83,6 +84,7 @@ char * bdf_getline(FILE *fp, char *buf, int len);
bitmap_t bdf_hexval(unsigned char *buf, int ndx1, int ndx2);
int gen_c_source(struct font* pf, char *path);
int gen_h_header(struct font* pf, char *path);
int gen_fnt_file(struct font* pf, char *path);
void
@ -93,6 +95,7 @@ usage(void)
" convbdf [options] [-o output-file] [single-input-file]\n"
"Options:\n"
" -c Convert .bdf to .c source file\n"
" -h Convert .bdf to .h header file (to create sysfont.h)\n"
" -f Convert .bdf to .fnt font file\n"
" -s N Start output at character encodings >= N\n"
" -l N Limit output to character encodings <= N\n"
@ -124,6 +127,9 @@ void getopts(int *pac, char ***pav)
case 'c': /* generate .c output*/
gen_c = 1;
break;
case 'h': /* generate .h output*/
gen_h = 1;
break;
case 'f': /* generate .fnt output*/
gen_fnt = 1;
break;
@ -215,6 +221,14 @@ int convbdf(char *path)
ret |= gen_c_source(pf, outfile);
}
if (gen_h) {
if (!oflag) {
strcpy(outfile, basename(path));
strcat(outfile, ".h");
}
ret |= gen_h_header(pf, outfile);
}
if (gen_fnt) {
if (!oflag) {
strcpy(outfile, basename(path));
@ -234,12 +248,12 @@ int main(int ac, char **av)
++av; --ac; /* skip av[0]*/
getopts(&ac, &av); /* read command line options*/
if (ac < 1 || (!gen_c && !gen_fnt)) {
if (ac < 1 || (!gen_c && !gen_h && !gen_fnt)) {
usage();
exit(1);
}
if (oflag) {
if (ac > 1 || (gen_c && gen_fnt)) {
if (ac > 1 || (gen_c && gen_fnt) || (gen_c && gen_h) || (gen_h && gen_fnt)) {
usage();
exit(1);
}
@ -965,6 +979,58 @@ int gen_c_source(struct font* pf, char *path)
return 0;
}
/* generate C header from in-core font*/
int gen_h_header(struct font* pf, char *path)
{
FILE *ofp;
time_t t = time(0);
char buf[256];
char hdr1[] = {
"/* Generated by convbdf on %s. */\n"
"#ifdef HAVE_LCD_BITMAP\n"
"\n"
"/* Font information*/\n"
"#define SYSFONT_NAME %s\n"
"#define SYSFONT_FACENAME %s\n"
"#define SYSFONT_WIDTH %d\n"
"#define SYSFONT_HEIGHT %d\n"
"#define SYSFONT_SIZE %d\n"
"#define SYSFONT_ASCENT %d\n"
"#define SYSFONT_DESCENT %d\n"
"#define SYSFONT_FIRST_CHAR %d\n"
"#define SYSFONT_LAST_CHAR %d\n"
"#define SYSFONT_DEFAULT_CHAR %d\n"
"#define SYSFONT_PROPORTIONAL %s\n"
"#define SYSFONT_COPYRIGHT %s\n"
"#define SYSFONT_BITS_SIZE %d\n"
"\n"
"#endif\n"
};
ofp = fopen(path, "w");
if (!ofp) {
fprintf(stderr, "Can't create %s\n", path);
return 1;
}
strcpy(buf, ctime(&t));
buf[strlen(buf)-1] = 0;
fprintf(ofp, hdr1, buf,
pf->name,
pf->facename? pf->facename: "",
pf->maxwidth, pf->height,
pf->size,
pf->ascent, pf->descent,
pf->firstchar,
pf->firstchar+pf->size-1,
pf->defaultchar,
pf->width? 1: 0,
pf->copyright? pf->copyright: "");
return 0;
}
static int writebyte(FILE *fp, unsigned char c)
{
return putc(c, fp) != EOF;