gbasys

diff src/gfx.h @ 0:875ef6085efc

gbasys mercurial repository
author John Tsiombikas <nuclear@member.fsf.org>
date Sun, 04 Mar 2012 04:04:25 +0200
parents
children e3dc7705ad9c
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/gfx.h	Sun Mar 04 04:04:25 2012 +0200
     1.3 @@ -0,0 +1,60 @@
     1.4 +/*
     1.5 +This file is part of libgba, a library for GameBoy Advance development.
     1.6 +Copyright (C) 2004, 2005 John Tsiombikas <nuclear@siggraph.org>
     1.7 +
     1.8 +This program is free software; you can redistribute it and/or modify
     1.9 +it under the terms of the GNU General Public License as published by
    1.10 +the Free Software Foundation; either version 2 of the License, or
    1.11 +(at your option) any later version.
    1.12 +
    1.13 +This program is distributed in the hope that it will be useful,
    1.14 +but WITHOUT ANY WARRANTY; without even the implied warranty of
    1.15 +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    1.16 +GNU General Public License for more details.
    1.17 +
    1.18 +You should have received a copy of the GNU General Public License
    1.19 +along with this program; if not, write to the Free Software
    1.20 +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    1.21 +*/
    1.22 +
    1.23 +#ifndef _GFX_H_
    1.24 +#define _GFX_H_
    1.25 +
    1.26 +struct pixel_buffer {
    1.27 +	int x, y, bpp;
    1.28 +	void *pixels;
    1.29 +};	
    1.30 +
    1.31 +enum {
    1.32 +	VMODE_LFB_240x160_16	= 3,
    1.33 +	VMODE_LFB_240x160_8		= 4,
    1.34 +	VMODE_LFB_160x128_16	= 5
    1.35 +};
    1.36 +
    1.37 +extern struct pixel_buffer *back_buffer, *front_buffer;
    1.38 +
    1.39 +#define RGB(r, g, b)\
    1.40 +	((((b) >> 3) & 0x1f) << 10) |\
    1.41 +	((((g) >> 3) & 0x1f) << 5) |\
    1.42 +	(((r) >> 3) & 0x1f)
    1.43 +
    1.44 +#define GET_R(c)	((((c) >> 10) & 0x1f) << 3)
    1.45 +#define GET_G(c)	((((c) >> 5) & 0x1f) << 3)
    1.46 +#define GET_B(c)	(((c) & 0x1f) << 3)
    1.47 +
    1.48 +int set_video_mode(int mode, int back_buffering);
    1.49 +void flip(void);
    1.50 +
    1.51 +struct pixel_buffer *create_pixel_buffer(int x, int y, int bpp);
    1.52 +void destroy_pixel_buffer(struct pixel_buffer *pbuf);
    1.53 +
    1.54 +void clear_buffer(struct pixel_buffer *pbuf, unsigned short color);
    1.55 +
    1.56 +void copy_buffer(const struct pixel_buffer *src, struct pixel_buffer *dst);
    1.57 +
    1.58 +#define wait_vsync()	while(*reg_vcount < front_buffer->yres)
    1.59 +
    1.60 +#define put_pixel(px, py, col, pbuf)	((unsigned short*)(pbuf)->pixels)[(py) * (pbuf)->x + (px)] = col
    1.61 +void draw_line(int x1, int y1, int x2, int y2, unsigned short col, struct pixel_buffer *pbuf);
    1.62 +
    1.63 +#endif	/* _GFX_H_ */