summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bootloader/ipod.c2
-rw-r--r--bootloader/main-pp.c78
-rw-r--r--firmware/Makefile3
-rw-r--r--firmware/export/font.h1
-rw-r--r--tools/convbdf.c70
5 files changed, 114 insertions, 40 deletions
diff --git a/bootloader/ipod.c b/bootloader/ipod.c
index 5f7060a526..8b99fbd1ad 100644
--- a/bootloader/ipod.c
+++ b/bootloader/ipod.c
@@ -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;
}
diff --git a/bootloader/main-pp.c b/bootloader/main-pp.c
index a533cc7044..ee2af38731 100644
--- a/bootloader/main-pp.c
+++ b/bootloader/main-pp.c
@@ -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,10 +162,8 @@ 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) {}
}
diff --git a/firmware/Makefile b/firmware/Makefile
index dea4c81b33..55c8269b24 100644
--- a/firmware/Makefile
+++ b/firmware/Makefile
@@ -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 $@
diff --git a/firmware/export/font.h b/firmware/export/font.h
index ccdb30ff00..3cf60aeac3 100644
--- a/firmware/export/font.h
+++ b/firmware/export/font.h
@@ -23,6 +23,7 @@
* Incore font and image definitions
*/
#include "config.h"
+#include "sysfont.h"
#if defined(HAVE_LCD_BITMAP) || defined(SIMULATOR)
diff --git a/tools/convbdf.c b/tools/convbdf.c
index 6dcd2d8394..c75b5fb444 100644
--- a/tools/convbdf.c
+++ b/tools/convbdf.c
@@ -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;
@@ -214,6 +220,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) {
@@ -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;