Rev 1090 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1091 | pj | 1 | /* |
2 | * Project: S.Ha.R.K. |
||
3 | * |
||
4 | * Coordinators: |
||
5 | * Giorgio Buttazzo <giorgio@sssup.it> |
||
6 | * Paolo Gai <pj@gandalf.sssup.it> |
||
7 | * |
||
8 | * Authors : |
||
9 | * Paolo Gai <pj@gandalf.sssup.it> |
||
10 | * Massimiliano Giorgi <massy@gandalf.sssup.it> |
||
11 | * Luca Abeni <luca@gandalf.sssup.it> |
||
12 | * (see the web pages for full authors list) |
||
13 | * |
||
14 | * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
||
15 | * |
||
16 | * http://www.sssup.it |
||
17 | * http://retis.sssup.it |
||
18 | * http://shark.sssup.it |
||
19 | */ |
||
20 | |||
21 | /* CVS : $Id: fab_grx.h,v 1.2 2002-10-01 10:33:52 pj Exp $ */ |
||
22 | |||
23 | /* |
||
24 | * Copyright (C) 2000 Fabio Calabrese <fabiocalabrese77@yahoo.it> |
||
25 | * |
||
26 | * This program is free software; you can redistribute it and/or modify |
||
27 | * it under the terms of the GNU General Public License as published by |
||
28 | * the Free Software Foundation; either version 2 of the License, or |
||
29 | * (at your option) any later version. |
||
30 | * |
||
31 | * This program is distributed in the hope that it will be useful, |
||
32 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
33 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
34 | * GNU General Public License for more details. |
||
35 | * |
||
36 | * You should have received a copy of the GNU General Public License |
||
37 | * along with this program; if not, write to the Free Software |
||
38 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
||
39 | * |
||
40 | */ |
||
41 | |||
42 | /**************************************************** |
||
43 | * * |
||
44 | * file: FAB_grx.h * |
||
45 | * libreria: FAB_LIB * |
||
46 | * version: 1.0 25/08/2002 * |
||
47 | * creato da: Fabio CALABRESE * |
||
48 | * * |
||
49 | **************************************************** |
||
50 | * * |
||
51 | * descrizione: libreria di funzioni grafiche: * |
||
52 | * permette di gestire con facilita' * |
||
53 | * immagini, cornici, e veri e propri * |
||
54 | * pannelli colorati. * |
||
55 | * Il contesto di grafica va avviato * |
||
56 | * con FAB_grx_open() e alla fine * |
||
57 | * chiuso correttamente con la funz. * |
||
58 | * FAB_grx_close(). L'ambiente di * |
||
59 | * grafica e'impostato a 16bit per * |
||
60 | * default, comunque e' sempre * |
||
61 | * possibile scegliere la profondita' * |
||
62 | * di colori preferita tra 15/16/24/32* |
||
63 | * definendo semplicemente solo una * |
||
64 | * delle seguenti costanti all'inizio * |
||
65 | * del proprio programma che include * |
||
66 | * questa libreria grafica: * |
||
67 | * FAB_GRX_15 * |
||
68 | * FAB_GRX_16 (default) * |
||
69 | * FAB_GRX_24 * |
||
70 | * FAB_GRX_32 * |
||
71 | * * |
||
72 | ****************************************************/ |
||
73 | |||
74 | #ifndef __FAB_LIB_fab_grx_h__ |
||
75 | #define __FAB_LIB_fab_grx_h__ |
||
76 | //-------------------BEGIN--------------------------- |
||
77 | |||
78 | // *** Librerie di S.Ha.R.K. *** |
||
79 | #include<kernel/kern.h> |
||
80 | #include<drivers/gd.h> |
||
81 | #include<ll/sys/types.h> |
||
82 | // *** Librerie Standard C *** |
||
83 | // *** Librerie FAB *** |
||
84 | #include"fab_grx.sys" |
||
85 | |||
86 | //#define FAB_GRX_15 |
||
87 | //#define FAB_GRX_16 |
||
88 | //#define FAB_GRX_24 |
||
89 | //#define FAB_GRX_32 |
||
90 | |||
91 | typedef __FAB_COLOR COLOR; |
||
92 | |||
93 | typedef struct { |
||
94 | WORD lx,ly; |
||
95 | COLOR * buf; |
||
96 | int trasparent; |
||
97 | COLOR trasparent_col; |
||
98 | } FAB_IMAGE; |
||
99 | |||
100 | typedef struct { |
||
101 | WORD dim; |
||
102 | COLOR * buf; |
||
103 | } FAB_BORDER; |
||
104 | |||
105 | typedef struct { |
||
106 | FAB_BORDER * border; //default = NULL |
||
107 | WORD border_dim; //default = 0 |
||
108 | COLOR border_col; |
||
109 | |||
110 | BYTE trasparent; //default = 0 |
||
111 | FAB_IMAGE * image; //default = NULL |
||
112 | COLOR color; |
||
113 | |||
114 | WORD x0,y0,x1,y1; //spigoli pannello interno |
||
115 | //cornice esclusa: vengono settati |
||
116 | //automaticamente con FAB_frame_put(). |
||
117 | } FAB_FRAME; |
||
118 | typedef struct { |
||
119 | FAB_BORDER * border; //default = NULL |
||
120 | WORD border_dim; //default = 0 |
||
121 | COLOR border_col; |
||
122 | |||
123 | BYTE trasparent; //default = 0 |
||
124 | COLOR color; |
||
125 | |||
126 | WORD cx,cy,r; //centro e raggio del pannello |
||
127 | //circolare: vengono settati |
||
128 | //automaticamente con FAB_ballframe_put(). |
||
129 | } FAB_BALLFRAME; |
||
130 | |||
131 | // ----------- |
||
132 | // Definizioni |
||
133 | //---------------------- |
||
134 | #define FAB_BPP __FAB_BPP |
||
135 | #define FAB_rgb(R24,G24,B24) __FAB_rgb((R24),(G24),(B24)) |
||
136 | |||
137 | // Colori base |
||
138 | #define FAB_white FAB_rgb(255,255,255) |
||
139 | #define FAB_black FAB_rgb( 0, 0, 0) |
||
140 | #define FAB_red FAB_rgb(255, 0, 0) |
||
141 | #define FAB_green FAB_rgb( 0,255, 0) |
||
142 | #define FAB_blue FAB_rgb( 0, 0,255) |
||
143 | #define FAB_yellow FAB_rgb(255,255, 0) |
||
144 | #define FAB_gray FAB_rgb(100,100,100) |
||
145 | |||
146 | //---------------------- |
||
147 | |||
148 | // ---------------- |
||
149 | // Funzioni & Macro |
||
150 | //-------------------------------------------------- |
||
151 | int FAB_grx_open(WORD lx, WORD ly); |
||
152 | void FAB_grx_close(); |
||
153 | |||
154 | FAB_IMAGE* FAB_image_alloc(WORD lx, WORD ly); //richiede DISABLED INTERRUPTS |
||
155 | void FAB_image_free(FAB_IMAGE* image); //richiede DISABLED INTERRUPTS |
||
156 | FAB_BORDER* FAB_border_alloc(WORD dim); //richiede DISABLED INTERRUPTS |
||
157 | void FAB_border_free(FAB_BORDER * border);//richiede DISABLED INTERRUPTS |
||
158 | FAB_FRAME* FAB_frame_alloc(); //richiede DISABLED INTERRUPTS |
||
159 | void FAB_frame_free(FAB_FRAME * frame); //richiede DISABLED INTERRUPTS |
||
160 | FAB_BALLFRAME* FAB_ballframe_alloc(); //richiede DISABLED INTERRUPTS |
||
161 | void FAB_ballframe_free(FAB_BALLFRAME * frame);//richiede DISABLED INTERRUPTS |
||
162 | |||
163 | // Permette di riempire lo spazio allocato ad un FAB_IMAGE |
||
164 | // leggendo le sequenze rgb a 24bit da un file immagine binario. |
||
165 | // Un formato perfettamente compatibile Š quello |
||
166 | // "RAW"(con header=0 e sequenza ad ordinamento RGB-RGB-RGB...): |
||
167 | int FAB_image_load(FAB_IMAGE* image, char* file_name); // solo in __kernel_register_levels__() |
||
168 | // Per default un FAB_IMAGE non ha il colore di trasparenza: |
||
169 | #define FAB_image_no_trasparent_set(IMAGE) (IMAGE)->trasparent=0 |
||
170 | #define FAB_image_trasparent_set(IMAGE,TRASPARENT_COL) (IMAGE)->trasparent=1;(IMAGE)->trasparent_col=(TRASPARENT_COL) |
||
171 | |||
172 | // Settaggio FAB_BORDER deve essere fatto manualmente! |
||
173 | // esempio: |
||
174 | // mio_border->buf[i] = FAB_rgb(0,100,0); |
||
175 | // ... |
||
176 | // mio_border->buf[N] = FAB_rgb(0,100,255); |
||
177 | // (non esiste una funzione FAB_border_set) |
||
178 | |||
179 | #define FAB_frame_border_set(FRAME,BORDER,BORDER_DIM,BORDER_COL) (FRAME)->border=(BORDER);(FRAME)->border_dim=(BORDER_DIM);(FRAME)->border_col=(BORDER_COL); |
||
180 | #define FAB_frame_color_set(FRAME,TRASPARENT_FLAG,IMAGE,COLOR) (FRAME)->trasparent=(TRASPARENT_FLAG);(FRAME)->image=(IMAGE);(FRAME)->color=(COLOR); |
||
181 | #define FAB_ballframe_border_set(FRAME,BORDER,BORDER_DIM,BORDER_COL) (FRAME)->border=(BORDER);(FRAME)->border_dim=(BORDER_DIM);(FRAME)->border_col=(BORDER_COL); |
||
182 | #define FAB_ballframe_color_set(FRAME,TRASPARENT_FLAG,COLOR) (FRAME)->trasparent=(TRASPARENT_FLAG);(FRAME)->color=(COLOR); |
||
183 | |||
184 | void FAB_ball_put(WORD cx, WORD cy, WORD r, COLOR c); |
||
185 | void FAB_image_get(FAB_IMAGE* image, WORD x, WORD y, WORD lx, WORD ly); |
||
186 | void FAB_image_put(FAB_IMAGE* image, WORD x, WORD y); |
||
187 | void FAB_image_put_within(FAB_IMAGE* image, WORD x0, WORD y0, |
||
188 | WORD xx0, WORD yy0, WORD xx1, WORD yy1); |
||
189 | void FAB_image_copy(FAB_IMAGE* orig_image, FAB_IMAGE* dest_image); |
||
190 | void FAB_image_color_change(FAB_IMAGE* image, COLOR old_col, COLOR new_col); |
||
191 | void FAB_image_fill(FAB_IMAGE* image, WORD x0, WORD y0, WORD lx, WORD ly); |
||
192 | void FAB_border_put(FAB_BORDER* border, WORD x0, WORD y0, WORD x1, WORD y1); |
||
193 | void FAB_ballborder_put(FAB_BORDER* border, WORD cx, WORD cy, WORD r_int); |
||
194 | void FAB_frame_put(FAB_FRAME* frame, WORD x0, WORD y0, WORD lx, WORD ly); |
||
195 | void FAB_ballframe_put(FAB_BALLFRAME* frame, WORD cx, WORD cy, WORD r); |
||
196 | //-------------------------------------------------- |
||
197 | |||
198 | // Altro... |
||
199 | |||
200 | //---------------------END--------------------------- |
||
201 | #endif |