gbasys

view src/gfx.h @ 7:72c6429ae953

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