Skip to content
Snippets Groups Projects
Commit 0547b471 authored by deuce's avatar deuce
Browse files

Fix up line-drawing mode... corners work properly now, and direction reversals

no longer extend the line.

Mouse drawing still not functional.
parent 4a612b8b
Branches
Tags
No related merge requests found
...@@ -9,6 +9,14 @@ ...@@ -9,6 +9,14 @@
#include "options.h" #include "options.h"
#include "miscfunctions.h" #include "miscfunctions.h"
enum {
MOVE_NONE
,MOVE_UP
,MOVE_DOWN
,MOVE_RIGHT
,MOVE_LEFT
};
void void
addlinestr(char *bottom, char *top, char *result) addlinestr(char *bottom, char *top, char *result)
{ {
...@@ -226,124 +234,124 @@ line2str(unsigned char ch, char *buffer) ...@@ -226,124 +234,124 @@ line2str(unsigned char ch, char *buffer)
{ {
switch (ch) { switch (ch) {
case 179: case 179:
strncpy(buffer, "SNSN", 5); strcpy(buffer, "SNSN");
break; break;
case 180: case 180:
strncpy(buffer, "SNSS", 5); strcpy(buffer, "SNSS");
break; break;
case 191: case 191:
strncpy(buffer, "NNSS", 5); strcpy(buffer, "NNSS");
break; break;
case 217: case 217:
strncpy(buffer, "SNNS", 5); strcpy(buffer, "SNNS");
break; break;
case 192: case 192:
strncpy(buffer, "SSNN", 5); strcpy(buffer, "SSNN");
break; break;
case 218: case 218:
strncpy(buffer, "NSSN", 5); strcpy(buffer, "NSSN");
break; break;
case 193: case 193:
strncpy(buffer, "SSNS", 5); strcpy(buffer, "SSNS");
break; break;
case 194: case 194:
strncpy(buffer, "NSSS", 5); strcpy(buffer, "NSSS");
break; break;
case 195: case 195:
strncpy(buffer, "SSSN", 5); strcpy(buffer, "SSSN");
break; break;
case 196: case 196:
strncpy(buffer, "NSNS", 5); strcpy(buffer, "NSNS");
break; break;
case 197: case 197:
strncpy(buffer, "SSSS", 5); strcpy(buffer, "SSSS");
break; break;
case 181: case 181:
strncpy(buffer, "SNSD", 5); strcpy(buffer, "SNSD");
break; break;
case 184: case 184:
strncpy(buffer, "NNSD", 5); strcpy(buffer, "NNSD");
break; break;
case 190: case 190:
strncpy(buffer, "SNND", 5); strcpy(buffer, "SNND");
break; break;
case 212: case 212:
strncpy(buffer, "SDNN", 5); strcpy(buffer, "SDNN");
break; break;
case 213: case 213:
strncpy(buffer, "NDSN", 5); strcpy(buffer, "NDSN");
break; break;
case 207: case 207:
strncpy(buffer, "SDND", 5); strcpy(buffer, "SDND");
break; break;
case 209: case 209:
strncpy(buffer, "NDSD", 5); strcpy(buffer, "NDSD");
break; break;
case 198: case 198:
strncpy(buffer, "SDSN", 5); strcpy(buffer, "SDSN");
break; break;
case 216: case 216:
strncpy(buffer, "SDSD", 5); strcpy(buffer, "SDSD");
break; break;
case 182: case 182:
strncpy(buffer, "DNDS", 5); strcpy(buffer, "DNDS");
break; break;
case 183: case 183:
strncpy(buffer, "NNDS", 5); strcpy(buffer, "NNDS");
break; break;
case 189: case 189:
strncpy(buffer, "DNNS", 5); strcpy(buffer, "DNNS");
break; break;
case 211: case 211:
strncpy(buffer, "DSNN", 5); strcpy(buffer, "DSNN");
break; break;
case 214: case 214:
strncpy(buffer, "NSDN", 5); strcpy(buffer, "NSDN");
break; break;
case 208: case 208:
strncpy(buffer, "DSNS", 5); strcpy(buffer, "DSNS");
break; break;
case 210: case 210:
strncpy(buffer, "NSDS", 5); strcpy(buffer, "NSDS");
break; break;
case 199: case 199:
strncpy(buffer, "DSDN", 5); strcpy(buffer, "DSDN");
break; break;
case 215: case 215:
strncpy(buffer, "DSDS", 5); strcpy(buffer, "DSDS");
break; break;
case 185: case 185:
strncpy(buffer, "DNDD", 5); strcpy(buffer, "DNDD");
break; break;
case 186: case 186:
strncpy(buffer, "DNDN", 5); strcpy(buffer, "DNDN");
break; break;
case 187: case 187:
strncpy(buffer, "NNDD", 5); strcpy(buffer, "NNDD");
break; break;
case 188: case 188:
strncpy(buffer, "DNND", 5); strcpy(buffer, "DNND");
break; break;
case 200: case 200:
strncpy(buffer, "DDNN", 5); strcpy(buffer, "DDNN");
break; break;
case 201: case 201:
strncpy(buffer, "NDDN", 5); strcpy(buffer, "NDDN");
break; break;
case 202: case 202:
strncpy(buffer, "DDND", 5); strcpy(buffer, "DDND");
break; break;
case 203: case 203:
strncpy(buffer, "NDDD", 5); strcpy(buffer, "NDDD");
break; break;
case 204: case 204:
strncpy(buffer, "DDDN", 5); strcpy(buffer, "DDDN");
break; break;
case 205: case 205:
strncpy(buffer, "NDND", 5); strcpy(buffer, "NDND");
break; break;
case 206: case 206:
strncpy(buffer, "DDDD", 5); strcpy(buffer, "DDDD");
break; break;
default: default:
buffer[0] = 0; buffer[0] = 0;
...@@ -365,7 +373,7 @@ addtopage(int y, int x, char ch) ...@@ -365,7 +373,7 @@ addtopage(int y, int x, char ch)
void void
drawline(void) drawline(void)
{ {
int a=0, b=0, c=0, d=0, ch, maxy = 22; int mv=MOVE_NONE, lmv=MOVE_NONE, ch, maxy = 22;
struct text_info ti; struct text_info ti;
struct mouse_event me; struct mouse_event me;
...@@ -391,16 +399,16 @@ drawline(void) ...@@ -391,16 +399,16 @@ drawline(void)
getmouse(&me); getmouse(&me);
switch (ch) { switch (ch) {
case CIO_KEY_DOWN: case CIO_KEY_DOWN:
a = 1; mv=MOVE_DOWN;
break; break;
case CIO_KEY_UP: case CIO_KEY_UP:
a = -1; mv=MOVE_UP;
break; break;
case CIO_KEY_LEFT: case CIO_KEY_LEFT:
b = -1; mv=MOVE_LEFT;
break; break;
case CIO_KEY_RIGHT: case CIO_KEY_RIGHT:
b = 1; mv=MOVE_RIGHT;
break; break;
} }
if (CursorY > maxy) { if (CursorY > maxy) {
...@@ -411,67 +419,116 @@ drawline(void) ...@@ -411,67 +419,116 @@ drawline(void)
LastLine = CursorY; LastLine = CursorY;
} }
CursorCheck(); CursorCheck();
switch (a) { switch (mv) {
case 1: case MOVE_UP:
Screen[ActivePage][CursorY + FirstLine - 1][CursorX * 2 + 1] = Attribute; switch(lmv) {
if (d == -1) case MOVE_NONE:
addtopage(CursorY + FirstLine - 1, CursorX * 2, CharSet[ActiveCharset][0]); Screen[ActivePage][CursorY + FirstLine + 1][CursorX * 2 + 1] = Attribute;
/*Screen[ActivePage][CursorY + FirstLine - 1][CursorX * 2] = CharSet[ActiveCharset][0]; */ addtopage(CursorY + FirstLine + 1, CursorX * 2, CharSet[ActiveCharset][5]);
else break;
if (d == 1) case MOVE_UP:
addtopage(CursorY + FirstLine - 1, CursorX * 2, CharSet[ActiveCharset][1]); Screen[ActivePage][CursorY + FirstLine + 1][CursorX * 2 + 1] = Attribute;
/*Screen[ActivePage][CursorY + FirstLine - 1][CursorX * 2] = CharSet[ActiveCharset][1]; */ addtopage(CursorY + FirstLine + 1, CursorX * 2, CharSet[ActiveCharset][5]);
else break;
addtopage(CursorY + FirstLine - 1, CursorX * 2, CharSet[ActiveCharset][5]); case MOVE_DOWN:
/*Screen[ActivePage][CursorY + FirstLine - 1][CursorX * 2] = CharSet[ActiveCharset][5]; */ #if 0
Screen[ActivePage][CursorY + FirstLine + 1][CursorX * 2 + 1] = Attribute;
addtopage(CursorY + FirstLine + 1, CursorX * 2, CharSet[ActiveCharset][5]);
#endif
break; break;
case -1: case MOVE_LEFT:
Screen[ActivePage][CursorY + FirstLine + 1][CursorX * 2 + 1] = Attribute; Screen[ActivePage][CursorY + FirstLine + 1][CursorX * 2 + 1] = Attribute;
if (d == -1)
addtopage(CursorY + FirstLine + 1, CursorX * 2, CharSet[ActiveCharset][2]); addtopage(CursorY + FirstLine + 1, CursorX * 2, CharSet[ActiveCharset][2]);
/*Screen[ActivePage][CursorY + FirstLine + 1][CursorX * 2] = CharSet[ActiveCharset][2]; */ break;
else case MOVE_RIGHT:
if (d == 1) Screen[ActivePage][CursorY + FirstLine + 1][CursorX * 2 + 1] = Attribute;
addtopage(CursorY + FirstLine + 1, CursorX * 2, CharSet[ActiveCharset][3]); addtopage(CursorY + FirstLine + 1, CursorX * 2, CharSet[ActiveCharset][3]);
/*Screen[ActivePage][CursorY + FirstLine + 1][CursorX * 2] = CharSet[ActiveCharset][3]; */
else
addtopage(CursorY + FirstLine + 1, CursorX * 2, CharSet[ActiveCharset][5]);
/*Screen[ActivePage][CursorY + FirstLine + 1][CursorX * 2] = CharSet[ActiveCharset][5]; */
break; break;
} }
switch (b) {
case 1:
Screen[ActivePage][CursorY + FirstLine][CursorX * 2 - 1] = Attribute;
if (c == 1)
addtopage(CursorY + FirstLine, CursorX * 2 - 2, CharSet[ActiveCharset][2]);
/*Screen[ActivePage][CursorY + FirstLine][CursorX * 2 - 2] = CharSet[ActiveCharset][2]; */
else
if (c == -1)
addtopage(CursorY + FirstLine, CursorX * 2 - 2, CharSet[ActiveCharset][0]);
/*Screen[ActivePage][CursorY + FirstLine][CursorX * 2 - 2] = CharSet[ActiveCharset][0]; */
else
addtopage(CursorY + FirstLine, CursorX * 2 - 2, CharSet[ActiveCharset][4]);
/*Screen[ActivePage][CursorY + FirstLine][CursorX * 2 - 2] = CharSet[ActiveCharset][4]; */
break; break;
case MOVE_DOWN:
case -1: switch(lmv) {
Screen[ActivePage][CursorY + FirstLine][CursorX * 2 + 3] = Attribute; case MOVE_NONE:
if (c == 1) Screen[ActivePage][CursorY + FirstLine - 1][CursorX * 2 + 1] = Attribute;
addtopage(CursorY + FirstLine, CursorX * 2 + 2, CharSet[ActiveCharset][3]); addtopage(CursorY + FirstLine - 1, CursorX * 2, CharSet[ActiveCharset][5]);
/*Screen[ActivePage][CursorY + FirstLine][CursorX * 2 + 2] = CharSet[ActiveCharset][3]; */ break;
else case MOVE_UP:
if (c == -1) #if 0
addtopage(CursorY + FirstLine, CursorX * 2 + 2, CharSet[ActiveCharset][1]); Screen[ActivePage][CursorY + FirstLine - 1][CursorX * 2 + 1] = Attribute;
/*Screen[ActivePage][CursorY + FirstLine][CursorX * 2 + 2] = CharSet[ActiveCharset][1]; */ addtopage(CursorY + FirstLine - 1, CursorX * 2, CharSet[ActiveCharset][5]);
else #endif
addtopage(CursorY + FirstLine, CursorX * 2 + 2, CharSet[ActiveCharset][4]); break;
/*Screen[ActivePage][CursorY + FirstLine][CursorX * 2 + 2] = CharSet[ActiveCharset][4]; */ case MOVE_DOWN:
Screen[ActivePage][CursorY + FirstLine - 1][CursorX * 2 + 1] = Attribute;
addtopage(CursorY + FirstLine - 1, CursorX * 2, CharSet[ActiveCharset][5]);
break;
case MOVE_LEFT:
Screen[ActivePage][CursorY + FirstLine - 1][CursorX * 2 + 1] = Attribute;
addtopage(CursorY + FirstLine - 1, CursorX * 2, CharSet[ActiveCharset][0]);
break;
case MOVE_RIGHT:
Screen[ActivePage][CursorY + FirstLine - 1][CursorX * 2 + 1] = Attribute;
addtopage(CursorY + FirstLine - 1, CursorX * 2, CharSet[ActiveCharset][1]);
break;
}
break;
case MOVE_LEFT:
switch(lmv) {
case MOVE_NONE:
Screen[ActivePage][CursorY + FirstLine][(CursorX + 1) * 2 + 1] = Attribute;
addtopage(CursorY + FirstLine, (CursorX + 1) * 2, CharSet[ActiveCharset][4]);
break; break;
case MOVE_UP:
Screen[ActivePage][CursorY + FirstLine][(CursorX + 1) * 2 + 1] = Attribute;
addtopage(CursorY + FirstLine, (CursorX + 1) * 2, CharSet[ActiveCharset][1]);
break;
case MOVE_DOWN:
Screen[ActivePage][CursorY + FirstLine][(CursorX + 1) * 2 + 1] = Attribute;
addtopage(CursorY + FirstLine, (CursorX + 1) * 2, CharSet[ActiveCharset][3]);
break;
case MOVE_LEFT:
Screen[ActivePage][CursorY + FirstLine][(CursorX + 1) * 2 + 1] = Attribute;
addtopage(CursorY + FirstLine, (CursorX + 1) * 2, CharSet[ActiveCharset][4]);
break;
case MOVE_RIGHT:
#if 0
Screen[ActivePage][CursorY + FirstLine][(CursorX + 1) * 2 + 1] = Attribute;
addtopage(CursorY + FirstLine, (CursorX + 1) * 2, CharSet[ActiveCharset][4]);
#endif
break;
}
break;
case MOVE_RIGHT:
switch(lmv) {
case MOVE_NONE:
Screen[ActivePage][CursorY + FirstLine][(CursorX - 1) * 2 + 1] = Attribute;
addtopage(CursorY + FirstLine, (CursorX - 1) * 2, CharSet[ActiveCharset][4]);
break;
case MOVE_UP:
Screen[ActivePage][CursorY + FirstLine][(CursorX - 1) * 2 + 1] = Attribute;
addtopage(CursorY + FirstLine, (CursorX - 1) * 2, CharSet[ActiveCharset][0]);
break;
case MOVE_DOWN:
Screen[ActivePage][CursorY + FirstLine][(CursorX - 1) * 2 + 1] = Attribute;
addtopage(CursorY + FirstLine, (CursorX - 1) * 2, CharSet[ActiveCharset][2]);
break;
case MOVE_LEFT:
#if 0
Screen[ActivePage][CursorY + FirstLine][(CursorX - 1) * 2 + 1] = Attribute;
addtopage(CursorY + FirstLine, (CursorX - 1) * 2, CharSet[ActiveCharset][4]);
#endif
break;
case MOVE_RIGHT:
Screen[ActivePage][CursorY + FirstLine][(CursorX - 1) * 2 + 1] = Attribute;
addtopage(CursorY + FirstLine, (CursorX - 1) * 2, CharSet[ActiveCharset][4]);
break;
}
break;
}
if(mv != MOVE_NONE) {
lmv=mv;
mv=MOVE_NONE;
} }
c = a;
d = b;
a = 0;
b = 0;
Statusline(); Statusline();
ShowScreen(0, 1); ShowScreen(0, 1);
Colors(Attribute); Colors(Attribute);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment