gbasys

view src/gfx.h @ 8:047c61960005

- added bg2 matrix support - changed some stupid const pointers to register addresses to hardcoded compile-time defines
author John Tsiombikas <nuclear@member.fsf.org>
date Sun, 22 Jun 2014 06:26:11 +0300
parents f77381b12726
children 85f219fcdc82
line source
1 /*
2 This file is part of libgba, a library for GameBoy Advance development.
3 Copyright (C) 2004, 2005 John Tsiombikas <nuclear@siggraph.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 2 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, write to the Free Software
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
20 #ifndef _GFX_H_
21 #define _GFX_H_
23 struct pixel_buffer {
24 int x, y, bpp;
25 void *pixels;
26 };
28 enum {
29 VMODE_LFB_240x160_16 = 3,
30 VMODE_LFB_240x160_8 = 4,
31 VMODE_LFB_160x128_16 = 5
32 };
34 extern struct pixel_buffer *back_buffer, *front_buffer;
36 #define RGB(r, g, b)\
37 ((((b) >> 3) & 0x1f) << 10) |\
38 ((((g) >> 3) & 0x1f) << 5) |\
39 (((r) >> 3) & 0x1f)
41 #define GET_R(c) ((((c) >> 10) & 0x1f) << 3)
42 #define GET_G(c) ((((c) >> 5) & 0x1f) << 3)
43 #define GET_B(c) (((c) & 0x1f) << 3)
45 int set_video_mode(int mode, int back_buffering);
46 void flip(void);
48 struct pixel_buffer *create_pixel_buffer(int x, int y, int bpp);
49 void destroy_pixel_buffer(struct pixel_buffer *pbuf);
51 void clear_buffer(struct pixel_buffer *pbuf, unsigned short color);
53 void copy_buffer(const struct pixel_buffer *src, struct pixel_buffer *dst);
54 void blit(struct pixel_buffer *src, int src_x, int src_y, int src_w, int src_h,
55 struct pixel_buffer *dst, int dest_x, int dest_y);
57 void set_palette(int idx, int r, int g, int b);
59 /* accepts 8.8 fixed point values */
60 void set_bg_matrix(int a, int b, int c, int d);
61 void set_bg_scale(int x, int y);
63 #define wait_vsync() while(*((volatile unsigned short*)0x4000006) < front_buffer->y)
65 #define put_pixel(px, py, col, pbuf) ((unsigned short*)(pbuf)->pixels)[(py) * (pbuf)->x + (px)] = col
66 void draw_line(int x1, int y1, int x2, int y2, unsigned short col, struct pixel_buffer *pbuf);
68 #endif /* _GFX_H_ */