Import backup from 2004-04-03

This commit is contained in:
josh committed 2017-07-25 22:23:46 -04:00
1 parent 7110307896
commit 6236c341dd
21 files changed
+1778 -82

No files matched your search

+72 -11
View File
@@ -68,13 +68,13 @@ void video_horiz(int y, int x1, int x2, dword color)
}
if (x2 < 0)
return;
if (x1 > video_mode.XResolution)
if (x1 >= video_mode.XResolution)
return;
if (x1 < 0)
x1 = 0;
if (x2 > video_mode.XResolution)
x2 = video_mode.XResolution;
int pixel = y*video_mode.XResolution+x1;
if (x2 >= video_mode.XResolution)
x2 = video_mode.XResolution - 1;
int pixel = y * video_mode.XResolution + x1;
for (; x1 <= x2; x1++)
{
video_psetp(pixel++, color);
@@ -84,12 +84,13 @@ void video_horiz(int y, int x1, int x2, dword color)
//Draws a single pixel
void video_pset(int x, int y, dword color)
{
if ((x < 0) || (x > video_mode.XResolution) || (y < 0) || (y > video_mode.YResolution))
if ((x < 0) || (x >= video_mode.XResolution) || (y < 0) || (y >= video_mode.YResolution))
return;
video_psetp(y*video_mode.XResolution+x, color);
video_psetp(y * video_mode.XResolution + x, color);
}
//Draws a pixel at the specified pixel position
//This function is needed because external modules do not have access to the function pointer video_psetp
void video_pseti(int pixel, dword color)
{
video_psetp(pixel, color);
@@ -106,17 +107,17 @@ void video_vert(int x, int y1, int y2, dword color)
}
if (y2 < 0)
return;
if (y1 > video_mode.YResolution)
if (y1 >= video_mode.YResolution)
return;
if (y1 < 0)
y1 = 0;
if (y2 > video_mode.YResolution)
y2 = video_mode.YResolution;
int pixel = y1*video_mode.XResolution+x;
if (y2 >= video_mode.YResolution)
y2 = video_mode.YResolution - 1;
int pixel = y1 * video_mode.XResolution + x;
for (; y1 <= y2; y1++)
{
video_psetp(pixel, color);
pixel+=video_mode.XResolution;
pixel += video_mode.XResolution;
}
}
@@ -191,3 +192,63 @@ dword video_Mode()
return videoMode;
}
void video_line(int x0, int y0, int x1, int y1, dword color)
{
int dy = y1 - y0;
int dx = x1 - x0;
int stepx, stepy;
if (dy < 0)
{
dy = -dy;
stepy = -1;
}
else
{
stepy = 1;
}
if (dx < 0)
{
dx = -dx;
stepx = -1;
}
else
{
stepx = 1;
}
dy <<= 1; // dy is now 2*dy
dx <<= 1; // dx is now 2*dx
video_pset(x0, y0, color);
if (dx > dy)
{
int fraction = dy - (dx >> 1); // same as 2*dy - dx
while (x0 != x1)
{
if (fraction >= 0)
{
y0 += stepy;
fraction -= dx; // same as fraction -= 2*dx
}
x0 += stepx;
fraction += dy; // same as fraction -= 2*dy
video_pset(x0, y0, color);
}
}
else
{
int fraction = dx - (dy >> 1);
while (y0 != y1)
{
if (fraction >= 0)
{
x0 += stepx;
fraction -= dy;
}
y0 += stepy;
fraction += dx;
video_pset(x0, y0, color);
}
}
}
+1
View File
@@ -24,6 +24,7 @@ int video_getHeight();
byte video_getBitsPerPixel();
dword video_getPhysBasePtr();
dword video_Mode();
void video_line(int x0, int y0, int x1, int y1, dword color);
typedef struct{