rev |
line source |
nuclear@0
|
1 /*
|
nuclear@7
|
2 gbasys - a gameboy advance hardware abstraction library
|
nuclear@7
|
3 Copyright (C) 2004-2014 John Tsiombikas <nuclear@member.fsf.org>
|
nuclear@0
|
4
|
nuclear@7
|
5 This program is free software: you can redistribute it and/or modify
|
nuclear@0
|
6 it under the terms of the GNU General Public License as published by
|
nuclear@7
|
7 the Free Software Foundation, either version 3 of the License, or
|
nuclear@0
|
8 (at your option) any later version.
|
nuclear@0
|
9
|
nuclear@0
|
10 This program is distributed in the hope that it will be useful,
|
nuclear@0
|
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
|
nuclear@0
|
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
nuclear@0
|
13 GNU General Public License for more details.
|
nuclear@0
|
14
|
nuclear@0
|
15 You should have received a copy of the GNU General Public License
|
nuclear@7
|
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
|
nuclear@0
|
17 */
|
nuclear@0
|
18 #ifndef _GFX_H_
|
nuclear@0
|
19 #define _GFX_H_
|
nuclear@0
|
20
|
nuclear@0
|
21 struct pixel_buffer {
|
nuclear@0
|
22 int x, y, bpp;
|
nuclear@0
|
23 void *pixels;
|
nuclear@2
|
24 };
|
nuclear@0
|
25
|
nuclear@0
|
26 enum {
|
nuclear@0
|
27 VMODE_LFB_240x160_16 = 3,
|
nuclear@0
|
28 VMODE_LFB_240x160_8 = 4,
|
nuclear@0
|
29 VMODE_LFB_160x128_16 = 5
|
nuclear@0
|
30 };
|
nuclear@0
|
31
|
nuclear@0
|
32 extern struct pixel_buffer *back_buffer, *front_buffer;
|
nuclear@0
|
33
|
nuclear@0
|
34 #define RGB(r, g, b)\
|
nuclear@0
|
35 ((((b) >> 3) & 0x1f) << 10) |\
|
nuclear@0
|
36 ((((g) >> 3) & 0x1f) << 5) |\
|
nuclear@0
|
37 (((r) >> 3) & 0x1f)
|
nuclear@0
|
38
|
nuclear@0
|
39 #define GET_R(c) ((((c) >> 10) & 0x1f) << 3)
|
nuclear@0
|
40 #define GET_G(c) ((((c) >> 5) & 0x1f) << 3)
|
nuclear@0
|
41 #define GET_B(c) (((c) & 0x1f) << 3)
|
nuclear@0
|
42
|
nuclear@0
|
43 int set_video_mode(int mode, int back_buffering);
|
nuclear@0
|
44 void flip(void);
|
nuclear@0
|
45
|
nuclear@0
|
46 struct pixel_buffer *create_pixel_buffer(int x, int y, int bpp);
|
nuclear@0
|
47 void destroy_pixel_buffer(struct pixel_buffer *pbuf);
|
nuclear@0
|
48
|
nuclear@0
|
49 void clear_buffer(struct pixel_buffer *pbuf, unsigned short color);
|
nuclear@0
|
50
|
nuclear@0
|
51 void copy_buffer(const struct pixel_buffer *src, struct pixel_buffer *dst);
|
nuclear@3
|
52 void blit(struct pixel_buffer *src, int src_x, int src_y, int src_w, int src_h,
|
nuclear@3
|
53 struct pixel_buffer *dst, int dest_x, int dest_y);
|
nuclear@0
|
54
|
nuclear@6
|
55 void set_palette(int idx, int r, int g, int b);
|
nuclear@6
|
56
|
nuclear@2
|
57 #define wait_vsync() while(*((volatile unsigned short*)0x4000006) < front_buffer->y)
|
nuclear@0
|
58
|
nuclear@0
|
59 #define put_pixel(px, py, col, pbuf) ((unsigned short*)(pbuf)->pixels)[(py) * (pbuf)->x + (px)] = col
|
nuclear@0
|
60 void draw_line(int x1, int y1, int x2, int y2, unsigned short col, struct pixel_buffer *pbuf);
|
nuclear@0
|
61
|
nuclear@0
|
62 #endif /* _GFX_H_ */
|