nuclear@0: /* nuclear@0: This file is part of libgba, a library for GameBoy Advance development. nuclear@0: Copyright (C) 2004, 2005 John Tsiombikas nuclear@0: nuclear@0: This program is free software; you can redistribute it and/or modify nuclear@0: it under the terms of the GNU General Public License as published by nuclear@0: the Free Software Foundation; either version 2 of the License, or nuclear@0: (at your option) any later version. nuclear@0: nuclear@0: This program is distributed in the hope that it will be useful, nuclear@0: but WITHOUT ANY WARRANTY; without even the implied warranty of nuclear@0: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the nuclear@0: GNU General Public License for more details. nuclear@0: nuclear@0: You should have received a copy of the GNU General Public License nuclear@0: along with this program; if not, write to the Free Software nuclear@0: Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA nuclear@0: */ nuclear@0: nuclear@0: #ifndef _GFX_H_ nuclear@0: #define _GFX_H_ nuclear@0: nuclear@0: struct pixel_buffer { nuclear@0: int x, y, bpp; nuclear@0: void *pixels; nuclear@2: }; nuclear@0: nuclear@0: enum { nuclear@0: VMODE_LFB_240x160_16 = 3, nuclear@0: VMODE_LFB_240x160_8 = 4, nuclear@0: VMODE_LFB_160x128_16 = 5 nuclear@0: }; nuclear@0: nuclear@0: extern struct pixel_buffer *back_buffer, *front_buffer; nuclear@0: nuclear@0: #define RGB(r, g, b)\ nuclear@0: ((((b) >> 3) & 0x1f) << 10) |\ nuclear@0: ((((g) >> 3) & 0x1f) << 5) |\ nuclear@0: (((r) >> 3) & 0x1f) nuclear@0: nuclear@0: #define GET_R(c) ((((c) >> 10) & 0x1f) << 3) nuclear@0: #define GET_G(c) ((((c) >> 5) & 0x1f) << 3) nuclear@0: #define GET_B(c) (((c) & 0x1f) << 3) nuclear@0: nuclear@0: int set_video_mode(int mode, int back_buffering); nuclear@0: void flip(void); nuclear@0: nuclear@0: struct pixel_buffer *create_pixel_buffer(int x, int y, int bpp); nuclear@0: void destroy_pixel_buffer(struct pixel_buffer *pbuf); nuclear@0: nuclear@0: void clear_buffer(struct pixel_buffer *pbuf, unsigned short color); nuclear@0: nuclear@0: void copy_buffer(const struct pixel_buffer *src, struct pixel_buffer *dst); nuclear@3: void blit(struct pixel_buffer *src, int src_x, int src_y, int src_w, int src_h, nuclear@3: struct pixel_buffer *dst, int dest_x, int dest_y); nuclear@0: nuclear@6: void set_palette(int idx, int r, int g, int b); nuclear@6: nuclear@2: #define wait_vsync() while(*((volatile unsigned short*)0x4000006) < front_buffer->y) nuclear@0: nuclear@0: #define put_pixel(px, py, col, pbuf) ((unsigned short*)(pbuf)->pixels)[(py) * (pbuf)->x + (px)] = col nuclear@0: void draw_line(int x1, int y1, int x2, int y2, unsigned short col, struct pixel_buffer *pbuf); nuclear@0: nuclear@0: #endif /* _GFX_H_ */