summaryrefslogtreecommitdiff
path: root/firmware/include
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/include')
-rw-r--r--firmware/include/font_cache.h48
-rw-r--r--firmware/include/lru.h46
-rw-r--r--firmware/include/rbunicode.h29
3 files changed, 123 insertions, 0 deletions
diff --git a/firmware/include/font_cache.h b/firmware/include/font_cache.h
new file mode 100644
index 0000000000..813cd18987
--- /dev/null
+++ b/firmware/include/font_cache.h
@@ -0,0 +1,48 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 *
9 * Copyright (C) 2003 Tat Tang
10 *
11 * All files in this archive are subject to the GNU General Public License.
12 * See the file COPYING in the source tree root for full license agreement.
13 *
14 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
15 * KIND, either express or implied.
16 *
17 ****************************************************************************/
18
19#include "lru.h"
20
21/*******************************************************************************
22 *
23 ******************************************************************************/
24struct font_cache
25{
26 struct lru _lru;
27 int _size;
28 int _capacity;
29 short *_index; /* index of lru handles in char_code order */
30};
31
32struct font_cache_entry
33{
34 unsigned short _char_code;
35 unsigned char width;
36 unsigned char bitmap[1]; /* place holder */
37};
38
39/* void (*f) (void*, struct font_cache_entry*); */
40/* Create an auto sized font cache from buf */
41void font_cache_create(
42 struct font_cache* fcache, void* buf, int buf_size, int bitmap_bytes_size);
43/* Get font cache entry */
44struct font_cache_entry* font_cache_get(
45 struct font_cache* fcache,
46 unsigned short char_code,
47 void (*callback) (struct font_cache_entry* p, void *callback_data),
48 void *callback_data);
diff --git a/firmware/include/lru.h b/firmware/include/lru.h
new file mode 100644
index 0000000000..8c74aa64ef
--- /dev/null
+++ b/firmware/include/lru.h
@@ -0,0 +1,46 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 *
9 * Copyright (C) 2003 Tat Tang
10 *
11 * All files in this archive are subject to the GNU General Public License.
12 * See the file COPYING in the source tree root for full license agreement.
13 *
14 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
15 * KIND, either express or implied.
16 *
17 ****************************************************************************/
18
19#ifndef LRU_H
20#define LRU_H
21
22/*******************************************************************************
23 * LRU manager
24 ******************************************************************************/
25struct lru
26{
27 short _head;
28 short _tail;
29 short _size;
30 short _slot_size;
31 void *_base;
32};
33
34#define LRU_SLOT_OVERHEAD (2 * sizeof(short))
35
36/* Create LRU list with specified size from buf. */
37void lru_create(struct lru* pl, void *buf, short size, short data_size);
38/* Touch an entry. Moves handle to back of LRU list */
39void lru_touch(struct lru* pl, short handle);
40/* Data */
41void *lru_data(struct lru* pl, short handle);
42/* Traverse lru-wise */
43void lru_traverse(struct lru* pl, void (*callback)(void* data));
44
45#endif /* LRU_H */
46
diff --git a/firmware/include/rbunicode.h b/firmware/include/rbunicode.h
new file mode 100644
index 0000000000..1d4bc43096
--- /dev/null
+++ b/firmware/include/rbunicode.h
@@ -0,0 +1,29 @@
1/* Some conversion functions for handling UTF-8
2 *
3 * copyright Marcoen Hirschberg (2004,2005)
4 *
5 * I got all the info from:
6 * http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
7 * and
8 * http://en.wikipedia.org/wiki/Unicode
9 */
10
11#define CODEPAGE_DIR "/.rockbox/codepages"
12
13#define MAX_CP_TABLE_SIZE 32768
14
15#define MASK 0xC0 /* 11000000 */
16#define COMP 0x80 /* 10x */
17
18extern int codepage;
19
20/* Encode a UCS value as UTF-8 and return a pointer after this UTF-8 char. */
21unsigned char* utf8encode(unsigned long ucs, unsigned char *utf8);
22unsigned char* iso_decode(const unsigned char *latin1, unsigned char *utf8, int cp, int count);
23unsigned char* utf16LEdecode(const unsigned char *utf16, unsigned char *utf8, unsigned int count);
24unsigned char* utf16BEdecode(const unsigned char *utf16, unsigned char *utf8, unsigned int count);
25unsigned char* utf16decode(const unsigned char *utf16, unsigned char *utf8, unsigned int count);
26unsigned long utf8length(const unsigned char *utf8);
27const unsigned char* utf8decode(const unsigned char *utf8, unsigned short *ucs);
28void set_codepage(int cp);
29int utf8seek(const unsigned char* utf8, int offset);