Mercurial > hg > index.fcgi > lj > lj046-2players
comparison src/fontdraw.h @ 2:80a2761bd3a4
change DS keys (add alt. rotate)
author | paulo@localhost |
---|---|
date | Mon, 23 Mar 2009 01:19:12 -0700 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:055ec00c1f30 |
---|---|
1 /* | |
2 Variable width font drawing library for DS (and GBA) | |
3 | |
4 Copyright 2007 Damian Yerrick <pinoandchester@pineight.com> | |
5 | |
6 This work is provided 'as-is', without any express or implied | |
7 warranty. In no event will the authors be held liable for any | |
8 damages arising from the use of this work. | |
9 | |
10 Permission is granted to anyone to use this work for any purpose, | |
11 including commercial applications, and to alter it and redistribute | |
12 it freely, subject to the following restrictions: | |
13 | |
14 1. The origin of this work must not be misrepresented; you must | |
15 not claim that you wrote the original work. If you use | |
16 this work in a product, an acknowledgment in the product | |
17 documentation would be appreciated but is not required. | |
18 2. Altered source versions must be plainly marked as such, and must | |
19 not be misrepresented as being the original work. | |
20 3. This notice may not be removed or altered from any source | |
21 distribution. | |
22 | |
23 "Source" is the preferred form of a work for making changes to it. | |
24 | |
25 */ | |
26 | |
27 #ifndef FONTDRAW_H | |
28 #define FONTDRAW_H | |
29 #include <sys/types.h> | |
30 | |
31 #ifdef ARM9 | |
32 // DS specific macros | |
33 #include <nds.h> | |
34 #ifndef BG_OFFSET_SUB | |
35 #define BG_OFFSET_SUB ((bg_scroll *)(0x04001010)) | |
36 #endif | |
37 | |
38 // macros from libgba that didn't make it to libnds | |
39 #ifndef MAP | |
40 typedef u16 NAMETABLE[32][32]; | |
41 #define MAP ((NAMETABLE *)BG_MAP_RAM(0)) | |
42 #define MAP_SUB ((NAMETABLE *)BG_MAP_RAM_SUB(0)) | |
43 #endif | |
44 | |
45 #else | |
46 // GBA specific macros | |
47 #include <gba_video.h> | |
48 | |
49 #endif | |
50 | |
51 unsigned int fontdraw_charWidth(int glyph); | |
52 unsigned int fontdraw_strWidth(const char *s); | |
53 | |
54 /** | |
55 * Returns the number of characters in s that fit within targetWidth pixels. | |
56 */ | |
57 size_t fontdraw_cutStr(const char *s, int targetWidth); | |
58 | |
59 void fontdraw_setupVRAM(int sub); | |
60 | |
61 // New API | |
62 | |
63 typedef struct VWFWindow { | |
64 u8 left; // in 8 pixel units on nametable | |
65 u8 top; // in 8 pixel units on nametable | |
66 u8 width; // in 8 pixel units on nametable | |
67 u8 height; // in 8 pixel units on nametable | |
68 u32 *chrBase; | |
69 u8 map; // in 2 KiB units on VRAM | |
70 u8 core; // 0: main; 1: sub | |
71 u16 mapTileBase; | |
72 } VWFWindow; | |
73 | |
74 void vwfWinInit(const VWFWindow *vwf); | |
75 void vwfWinClear(const VWFWindow *vwf); | |
76 /** | |
77 * Sets up a portion of a window. | |
78 * @param vwf the window | |
79 * @param l distance in tiles from the left side of the window to the | |
80 * left side of the area to be updated | |
81 * @param t distance in tiles from the top of the window to the | |
82 * top of the area to be updated | |
83 * @param r distance in tiles from the left side of the window to the | |
84 * right side of the area to be updated | |
85 * @param b distance in tiles from the top of the window to the | |
86 * bottom of the area to be updated | |
87 * @param orMask the data to be OR'd with each map space, typically | |
88 * containing a palette number in bits 12 to 15 | |
89 */ | |
90 void vwfPutMap(const VWFWindow *vwf, | |
91 int l, int t, int r, int b, | |
92 unsigned int orMask); | |
93 | |
94 unsigned int vwfPutc(const VWFWindow *w, | |
95 int c, | |
96 int x, int y); | |
97 unsigned int vwfPuts(const VWFWindow *src, | |
98 const char *str, | |
99 int x, int y); | |
100 void vwfRectfill(const VWFWindow *v, | |
101 int l, int t, int r, int b, | |
102 int c); | |
103 void vwfHline(const VWFWindow *v, int l, int t, int r, int c); | |
104 void vwfVline(const VWFWindow *v, int l, int t, int b, int c); | |
105 void vwfRect(const VWFWindow *v, int l, int t, int r, int b, int c); | |
106 | |
107 /** | |
108 * Replaces a rectangle of pixels in dst with pixels from src. | |
109 * @param src the bitmap to copy from | |
110 * @param dst the bitmap to copy to | |
111 * @param srcX the left side of the part of src to copy, | |
112 * in 8-pixel units | |
113 * @param srcY the top of the part of src to copy, | |
114 * in pixels | |
115 * @param dstX the left side of the part of dst to be replaced, | |
116 * in 8-pixel units | |
117 * @param dstY the top of the part of src dst to be replaced, | |
118 * in pixels | |
119 */ | |
120 void vwfBlitAligned(const VWFWindow *src, const VWFWindow *dst, | |
121 int srcX, int srcY, int dstX, int dstY, | |
122 int w, int h); | |
123 | |
124 extern const VWFWindow vwfTop, vwfTouch; | |
125 | |
126 | |
127 #endif |