diff options
Diffstat (limited to 'firmware/ajf.c')
-rw-r--r-- | firmware/ajf.c | 100 |
1 files changed, 0 insertions, 100 deletions
diff --git a/firmware/ajf.c b/firmware/ajf.c deleted file mode 100644 index 82ba0b7939..0000000000 --- a/firmware/ajf.c +++ /dev/null | |||
@@ -1,100 +0,0 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2002 by Alex Gitelman | ||
11 | * | ||
12 | * All files in this archive are subject to the GNU General Public License. | ||
13 | * See the file COPYING in the source tree root for full license agreement. | ||
14 | * | ||
15 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
16 | * KIND, either express or implied. | ||
17 | * | ||
18 | ****************************************************************************/ | ||
19 | #ifdef SIMULATOR | ||
20 | #include <fcntl.h> | ||
21 | #endif | ||
22 | #include <file.h> | ||
23 | #include "ajf.h" | ||
24 | #include <string.h> | ||
25 | #include <errno.h> | ||
26 | #include <stdbool.h> | ||
27 | #include "debug.h" | ||
28 | |||
29 | static unsigned char font_buf[MAX_FONT_BUFLEN]; | ||
30 | |||
31 | unsigned char* ajf_read_font(char* fname) | ||
32 | { | ||
33 | int count; | ||
34 | #ifdef WIN32 | ||
35 | int fd = open(fname, O_RDONLY|O_BINARY); | ||
36 | #else | ||
37 | int fd = open(fname, O_RDONLY); | ||
38 | #endif | ||
39 | if (fd<0) | ||
40 | { | ||
41 | #ifdef SIMULATOR | ||
42 | #ifdef WIN32 | ||
43 | DEBUGF("Failed opening font file: %d %s. ", _errno(), fname); | ||
44 | #else | ||
45 | DEBUGF("Failed opening font file: %d %s. ", errno, fname); | ||
46 | #endif | ||
47 | #endif | ||
48 | return NULL; | ||
49 | } | ||
50 | |||
51 | count = read(fd, font_buf, MAX_FONT_BUFLEN); | ||
52 | if (count==MAX_FONT_BUFLEN) { | ||
53 | DEBUGF("Font is larger than allocated %d bytes!\n",MAX_FONT_BUFLEN); | ||
54 | return NULL; | ||
55 | } | ||
56 | close(fd); | ||
57 | |||
58 | if (font_buf[0]!=MAGIC1 || font_buf[1]!=MAGIC2) { | ||
59 | DEBUGF("Bad magic word in font"); | ||
60 | return NULL; | ||
61 | } | ||
62 | return font_buf; | ||
63 | } | ||
64 | |||
65 | |||
66 | unsigned char* ajf_get_charbuf(unsigned char c, unsigned char* font, | ||
67 | int *w, int *h) | ||
68 | { | ||
69 | int height = READ_SHORT(&font[HEIGHT_OFFSET]); | ||
70 | int size = READ_SHORT(&font[SIZE_OFFSET]); | ||
71 | int chars_offset = LOOKUP_MAP_OFFSET + size*3; | ||
72 | int rows = (height-1)/8 + 1; | ||
73 | int first_char = READ_SHORT(&font[FIRST_CHAR_OFFSET]); | ||
74 | int map_idx = LOOKUP_MAP_OFFSET + (c-first_char)*3; | ||
75 | int byte_count = font[map_idx]; | ||
76 | int char_idx; | ||
77 | |||
78 | *h = height; | ||
79 | *w = byte_count/rows; | ||
80 | |||
81 | map_idx++; | ||
82 | char_idx = READ_SHORT(&font[map_idx]); | ||
83 | return &font[chars_offset + char_idx]; | ||
84 | } | ||
85 | |||
86 | void ajf_get_charsize(unsigned char c, unsigned char* font, | ||
87 | int *width, int *height) | ||
88 | { | ||
89 | int first_char = READ_SHORT(&font[FIRST_CHAR_OFFSET]); | ||
90 | int map_idx = LOOKUP_MAP_OFFSET + (c-first_char)*3; | ||
91 | int rows = 1; | ||
92 | *height = READ_SHORT(&font[HEIGHT_OFFSET]); | ||
93 | rows = (*height-1)/8 + 1; | ||
94 | *width = font[map_idx]/rows; | ||
95 | } | ||
96 | |||
97 | int ajf_get_fontheight(unsigned char* font) | ||
98 | { | ||
99 | return READ_SHORT(&font[HEIGHT_OFFSET]); | ||
100 | } | ||