gbasys

annotate src/gfx.h @ 3:06726f0b8cd3

foo
author John Tsiombikas <nuclear@member.fsf.org>
date Thu, 08 Mar 2012 14:37:17 +0200
parents e3dc7705ad9c
children f77381b12726
rev   line source
nuclear@0 1 /*
nuclear@0 2 This file is part of libgba, a library for GameBoy Advance development.
nuclear@0 3 Copyright (C) 2004, 2005 John Tsiombikas <nuclear@siggraph.org>
nuclear@0 4
nuclear@0 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@0 7 the Free Software Foundation; either version 2 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@0 16 along with this program; if not, write to the Free Software
nuclear@0 17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
nuclear@0 18 */
nuclear@0 19
nuclear@0 20 #ifndef _GFX_H_
nuclear@0 21 #define _GFX_H_
nuclear@0 22
nuclear@0 23 struct pixel_buffer {
nuclear@0 24 int x, y, bpp;
nuclear@0 25 void *pixels;
nuclear@2 26 };
nuclear@0 27
nuclear@0 28 enum {
nuclear@0 29 VMODE_LFB_240x160_16 = 3,
nuclear@0 30 VMODE_LFB_240x160_8 = 4,
nuclear@0 31 VMODE_LFB_160x128_16 = 5
nuclear@0 32 };
nuclear@0 33
nuclear@0 34 extern struct pixel_buffer *back_buffer, *front_buffer;
nuclear@0 35
nuclear@0 36 #define RGB(r, g, b)\
nuclear@0 37 ((((b) >> 3) & 0x1f) << 10) |\
nuclear@0 38 ((((g) >> 3) & 0x1f) << 5) |\
nuclear@0 39 (((r) >> 3) & 0x1f)
nuclear@0 40
nuclear@0 41 #define GET_R(c) ((((c) >> 10) & 0x1f) << 3)
nuclear@0 42 #define GET_G(c) ((((c) >> 5) & 0x1f) << 3)
nuclear@0 43 #define GET_B(c) (((c) & 0x1f) << 3)
nuclear@0 44
nuclear@0 45 int set_video_mode(int mode, int back_buffering);
nuclear@0 46 void flip(void);
nuclear@0 47
nuclear@0 48 struct pixel_buffer *create_pixel_buffer(int x, int y, int bpp);
nuclear@0 49 void destroy_pixel_buffer(struct pixel_buffer *pbuf);
nuclear@0 50
nuclear@0 51 void clear_buffer(struct pixel_buffer *pbuf, unsigned short color);
nuclear@0 52
nuclear@0 53 void copy_buffer(const struct pixel_buffer *src, struct pixel_buffer *dst);
nuclear@3 54 void blit(struct pixel_buffer *src, int src_x, int src_y, int src_w, int src_h,
nuclear@3 55 struct pixel_buffer *dst, int dest_x, int dest_y);
nuclear@0 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_ */