1 /*
2     sw32_graph.c
3 
4 	(description)
5 
6 	Copyright (C) 1996-1997  Id Software, Inc.
7 
8 	This program is free software; you can redistribute it and/or
9 	modify it under the terms of the GNU General Public License
10 	as published by the Free Software Foundation; either version 2
11 	of the License, or (at your option) any later version.
12 
13 	This program is distributed in the hope that it will be useful,
14 	but WITHOUT ANY WARRANTY; without even the implied warranty of
15 	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16 
17 	See the GNU General Public License for more details.
18 
19 	You should have received a copy of the GNU General Public License
20 	along with this program; if not, write to:
21 
22 		Free Software Foundation, Inc.
23 		59 Temple Place - Suite 330
24 		Boston, MA  02111-1307, USA
25 
26 */
27 #ifdef HAVE_CONFIG_H
28 # include "config.h"
29 #endif
30 
31 #define NH_DEFINE
32 #include "namehack.h"
33 
34 #include "QF/cvar.h"
35 #include "QF/draw.h"
36 #include "QF/render.h"
37 #include "QF/sys.h"
38 
39 #include "r_internal.h"
40 #include "vid_internal.h"
41 
42 /*
43 	R_LineGraph
44 
45 	Called by only R_DisplayTime
46 */
47 void
sw32_R_LineGraph(int x,int y,int * h_vals,int count)48 sw32_R_LineGraph (int x, int y, int *h_vals, int count)
49 {
50 	int         h, i, s, color;
51 
52 	// FIXME: disable on no-buffer adapters, or put in the driver
53 	s = r_graphheight->int_val;
54 
55 	while (count--) {
56 		h = *h_vals++;
57 
58 		if (h == 10000)
59 			color = 0x6f;					// yellow
60 		else if (h == 9999)
61 			color = 0x4f;					// red
62 		else if (h == 9998)
63 			color = 0xd0;					// blue
64 		else
65 			color = 0xff;					// pink
66 
67 		if (h > s)
68 			h = s;
69 
70 		switch(sw32_r_pixbytes) {
71 			case 1:
72 				{
73 					byte *dest = (byte *) vid.buffer + vid.rowbytes * y + x;
74 					for (i = 0; i < h; i++, dest -= vid.rowbytes * 2)
75 						*dest = color;
76 				}
77 				break;
78 			case 2:
79 				{
80 					short *dest = (short *) vid.buffer +
81 								  (vid.rowbytes >> 1) * y + x;
82 					color = sw32_8to16table[color];
83 					for (i = 0; i < h; i++, dest -= vid.rowbytes)
84 						*dest = color;
85 				}
86 				break;
87 			case 4:
88 				{
89 					int *dest = (int *) vid.buffer +
90 								(vid.rowbytes >> 2) * y + x;
91 					color = d_8to24table[color];
92 					for (i = 0; i < h; i++, dest -= (vid.rowbytes >> 1))
93 						*dest = color;
94 				}
95 			break;
96 			default:
97 				Sys_Error("R_LineGraph: unsupported r_pixbytes %i",
98 						  sw32_r_pixbytes);
99 		}
100 	}
101 }
102