Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void kvideo_putline(uint16 x1, uint16 y1, uint16 x2, uint16 y2, char c, uint8 col)
- {
- if (c == '\0') return;
- uint16 *vptr = (uint16*)VGA_TEXTCOLOR;
- unsigned short lc = (col << 8) | c;
- unsigned int i = 0, j = 0;
- if (y1 == y2) //horizontal
- {
- if (x1 > x2) {
- for (i = x2; i < x1; i++)
- *(vptr + i + (y1 * KVIDEO_W)) = lc;
- } else if (x2 > x1) {
- for (i = x1; i < x2; i++)
- *(vptr + i + (y1 * KVIDEO_W)) = lc;
- } else if (x1 == x2) {
- *(vptr + x1 + (y1 * KVIDEO_W)) = lc;
- }
- }
- else if (x1 == x2) //vertical
- {
- if (y1 > y2) {
- for (i = y2; i < y1; i++)
- *(vptr + x1 + (i * KVIDEO_W)) = lc;
- } else if (y2 > y1) {
- for (i = y1; i < y2; i++)
- *(vptr + x1 + (i * KVIDEO_W)) = lc;
- } else if (y1 == y2) {
- *(vptr + x1 + (y1 * KVIDEO_W)) = lc;
- }
- }
- else //cant get off that easy...
- {
- short deltax = x2 - x1;
- short deltay = y2 - y1;
- short deltaxabs = abs_16(deltax);
- short deltayabs = abs_16(deltay);
- short sgndeltax = sgn_16(deltax);
- short sgndeltay = sgn_16(deltay);
- short x = deltayabs >> 1;
- short y = deltaxabs >> 1;
- short drawx = x1, drawy = y1;
- *(vptr + drawx + (drawy * KVIDEO_W)) = lc;
- int n = 0;
- if (deltaxabs >= deltayabs) {
- for (n = 0; n < deltaxabs; n++) {
- y += deltayabs;
- if (y >= deltaxabs) {
- y -= deltaxabs;
- drawy += sgndeltay;
- }
- drawx += sgndeltax;
- *(vptr + drawx + (drawy * KVIDEO_W)) = lc;
- }
- } else {
- for (n = 0; n < deltayabs; n++) {
- x += deltaxabs;
- if (x >= deltayabs) {
- x -= deltayabs;
- drawx += sgndeltax;
- }
- drawy += sgndeltay;
- *(vptr + drawx + (drawy * KVIDEO_W)) = lc;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement