3 Extension to the Quick and Dirty Game Development Framework (QDGDF)
5 Copyright (C) 2001 Daniel Compton <C_Anon01@yahoo.com>
7 This program is free software; you can redistribute it and/or
8 modify it under the terms of the GNU General Public License
9 as published by the Free Software Foundation; either version 2
10 of the License, or (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
25 #include "qdgdf_video_ext.h"
27 void qdgdfv_display_pcx(unsigned char *pcx
, unsigned int w
, unsigned int h
, unsigned int x
,
30 unsigned int sw
= _qdgdfv_screen_x_size
; /* max screen width is sw */
31 unsigned char *vscreen
= _qdgdfv_virtual_screen
+ y
* sw
;
34 for (i
= 0; i
< h
; i
++) {
35 memcpy(vscreen
+ x
, pcx
, w
);
41 int qdgdfv_display_pcx_safe(unsigned char *pcx
, unsigned int w
, unsigned int h
, unsigned int x
,
44 unsigned int sw
= _qdgdfv_screen_x_size
; /* max screen width is sw */
45 unsigned int sh
= _qdgdfv_screen_y_size
; /* max screen heigh is sh */
46 unsigned char *vscreen
= _qdgdfv_virtual_screen
;
49 if (x
>= sw
|| y
>= sh
)
58 for (i
= 0; i
< h
; i
++) {
59 memcpy(vscreen
+ x
, pcx
, w
);
67 int qdgdfv_display_pcx_full(unsigned char *pcx
, unsigned int w
, unsigned int h
, unsigned int x
,
70 unsigned int sw
= _qdgdfv_screen_x_size
; /* max screen width is sw */
71 unsigned int sh
= _qdgdfv_screen_y_size
; /* max screen heigh is sh */
72 unsigned char *vscreen
= _qdgdfv_virtual_screen
;
86 for (i
= 0; i
< h
; i
++) {
87 memcpy(vscreen
+ x
, pcx
, w
);
95 unsigned char qdgdfv_find_color(unsigned int r
, unsigned int g
, unsigned int b
)
97 unsigned int *table
= _qdgdfv_palette
;
98 unsigned long lastcolor
= abs(r
- table
[0]) + abs(g
- table
[1]) + abs(b
- table
[2]);
100 unsigned int pos
= 0;
102 for (; i
< 256 * 3; i
+= 3) {
103 unsigned long curcolor
=
104 abs(r
- table
[i
]) + abs(g
- table
[i
+ 1]) + abs(b
- table
[i
+ 2]);
105 if (curcolor
< lastcolor
) {
106 lastcolor
= curcolor
;
113 int qdgdfv_plot_pixel_color(unsigned int x
, unsigned int y
, unsigned char color
)
115 if (x
< _qdgdfv_screen_x_size
&& y
< _qdgdfv_screen_y_size
) {
116 _qdgdfv_virtual_screen
[y
* _qdgdfv_screen_x_size
+ x
] = color
;
122 int qdgdfv_plot_pixel_rgb(unsigned int x
, unsigned int y
, unsigned long RGB
)
124 if (x
< _qdgdfv_screen_x_size
&& y
< _qdgdfv_screen_y_size
) {
125 _qdgdfv_virtual_screen
[y
* _qdgdfv_screen_x_size
+ x
] =
126 qdgdfv_find_color(GetRValue(RGB
), GetGValue(RGB
), GetBValue(RGB
));
132 int qdgdfv_draw_rect_fill(unsigned int x
, unsigned int y
, unsigned int w
, unsigned int h
,
135 unsigned int sw
= _qdgdfv_screen_x_size
; /* max screen width is sw */
136 unsigned int sh
= _qdgdfv_screen_y_size
; /* max screen heigh is sh */
137 unsigned long totsw
= x
+ w
;
138 unsigned long totsh
= y
+ h
;
139 if ((totsw
<= sw
) && (totsh
<= sh
)) { /* if memset cant be sent a 0 length, then add (w != 0) */
140 unsigned char *vscreen
= _qdgdfv_virtual_screen
+ y
* sw
;
143 memset(vscreen
+ x
, color
, w
);
151 /* wallw is number of pixels for size of the wall */
152 int qdgdfv_draw_rect(unsigned int x
, unsigned int y
, unsigned int w
, unsigned int h
,
153 unsigned int wallw
, unsigned char color
)
156 result
= qdgdfv_draw_hline(x
, y
, w
, wallw
, color
);
159 result
= qdgdfv_draw_vline(x
, y
, h
, wallw
, color
);
162 result
= qdgdfv_draw_hline(x
, y
+ h
- wallw
, w
, wallw
, color
);
165 result
= qdgdfv_draw_vline(x
+ w
- wallw
, y
, h
, wallw
, color
);