gbasys

changeset 6:f77381b12726

palette
author John Tsiombikas <nuclear@member.fsf.org>
date Tue, 04 Sep 2012 05:05:50 +0300
parents 1807781b4503
children 72c6429ae953 047c61960005
files src/gfx.c src/gfx.h
diffstat 2 files changed, 8 insertions(+), 0 deletions(-) [+]
line diff
     1.1 --- a/src/gfx.c	Fri Jul 20 22:47:39 2012 +0300
     1.2 +++ b/src/gfx.c	Tue Sep 04 05:05:50 2012 +0300
     1.3 @@ -38,6 +38,8 @@
     1.4  static volatile unsigned short *reg_disp_ctl = (void*)0x4000000;
     1.5  static volatile unsigned short *reg_vcount = (void*)0x4000006;
     1.6  
     1.7 +static unsigned short *paladdr = (void*)0x5000000;
     1.8 +
     1.9  static int xres, yres;
    1.10  static int sizeof_pixel;
    1.11  static int page_flipping;
    1.12 @@ -171,6 +173,10 @@
    1.13  	}
    1.14  }
    1.15  
    1.16 +void set_palette(int idx, int r, int g, int b)
    1.17 +{
    1.18 +	paladdr[idx] = RGB(r, g, b);
    1.19 +}
    1.20  
    1.21  void draw_line(int x1, int y1, int x2, int y2, unsigned short col, struct pixel_buffer *pbuf) {
    1.22  	int dx, dy, dx2, dy2;
     2.1 --- a/src/gfx.h	Fri Jul 20 22:47:39 2012 +0300
     2.2 +++ b/src/gfx.h	Tue Sep 04 05:05:50 2012 +0300
     2.3 @@ -54,6 +54,8 @@
     2.4  void blit(struct pixel_buffer *src, int src_x, int src_y, int src_w, int src_h,
     2.5  		struct pixel_buffer *dst, int dest_x, int dest_y);
     2.6  
     2.7 +void set_palette(int idx, int r, int g, int b);
     2.8 +
     2.9  #define wait_vsync()	while(*((volatile unsigned short*)0x4000006) < front_buffer->y)
    2.10  
    2.11  #define put_pixel(px, py, col, pbuf)	((unsigned short*)(pbuf)->pixels)[(py) * (pbuf)->x + (px)] = col