2 * Copyright (C) <2003> iOS-Software
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
19 #include "drawmethods.h"
21 #define DRAWMETHOD_PLUS(_out,_backbuf,_col) \
24 unsigned char *bra = (unsigned char*)&(_backbuf);\
25 unsigned char *dra = (unsigned char*)&(_out);\
26 unsigned char *cra = (unsigned char*)&(_col);\
30 if (tra>255) tra=255;\
36 #define DRAWMETHOD DRAWMETHOD_PLUS(*p,*p,col)
39 draw_line (Pixel * data, int x1, int y1, int x2, int y2, int col, int screenx,
42 int x, y, dx, dy, yy, xx;
45 if ((y1 < 0) || (y2 < 0) || (x1 < 0) || (x2 < 0) || (y1 >= screeny)
46 || (y2 >= screeny) || (x1 >= screenx) || (x2 >= screenx))
50 if ((y1 < 0) && (y2 < 0))
54 x1 += (y1 * (x1 - x2)) / (y2 - y1);
58 x2 += (y2 * (x1 - x2)) / (y2 - y1);
63 if ((y1 >= screeny) && (y2 >= screeny))
66 x1 -= ((screeny - y1) * (x1 - x2)) / (y2 - y1);
70 x2 -= ((screeny - y2) * (x1 - x2)) / (y2 - y1);
74 if ((x1 < 0) && (x2 < 0))
77 y1 += (x1 * (y1 - y2)) / (x2 - x1);
81 y2 += (x2 * (y1 - y2)) / (x2 - x1);
85 if ((x1 >= screenx) && (x2 >= screenx))
88 y1 -= ((screenx - x1) * (y1 - y2)) / (x2 - x1);
92 y2 -= ((screenx - x2) * (y1 - y2)) / (x2 - x1);
115 p = &(data[(screenx * y1) + x1]);
116 for (y = y1; y <= y2; y++) {
121 p = &(data[(screenx * y2) + x1]);
122 for (y = y2; y <= y1; y++) {
129 /* horizontal line */
132 p = &(data[(screenx * y1) + x1]);
133 for (x = x1; x <= x2; x++) {
139 p = &(data[(screenx * y1) + x2]);
140 for (x = x2; x <= x1; x++) {
154 dx = ((dx << 16) / dy);
156 for (y = y1; y <= y2; y++) {
158 p = &(data[(screenx * y) + xx]);
160 if (xx < (screenx - 1)) {
170 dy = ((dy << 16) / dx);
172 for (x = x1; x <= x2; x++) {
174 p = &(data[(screenx * yy) + x]);
176 if (yy < (screeny - 1)) {
191 dx = ((dx << 16) / -dy);
193 for (y = y1; y >= y2; y--) {
195 p = &(data[(screenx * y) + xx]);
197 if (xx < (screenx - 1)) {
207 dy = ((dy << 16) / dx);
209 for (x = x1; x <= x2; x++) {
211 p = &(data[(screenx * yy) + x]);
213 if (yy < (screeny - 1)) {