From f615b604bfa1250265f4e4bc343137eab1d7580f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Deuc=D0=B5?= <shurd@sasktel.net>
Date: Mon, 3 May 2021 11:24:30 -0400
Subject: [PATCH] Vectorize beziers

---
 src/conio/ciolib.c    |  6 +++---
 src/conio/ciolib.h    |  4 ++--
 src/syncterm/ripper.c | 25 +++++++++++++++++--------
 3 files changed, 22 insertions(+), 13 deletions(-)

diff --git a/src/conio/ciolib.c b/src/conio/ciolib.c
index 280c435b1f..665d2ed315 100644
--- a/src/conio/ciolib.c
+++ b/src/conio/ciolib.c
@@ -100,7 +100,7 @@ CIOLIBEXPORT void ciolib_wscroll(void);
 CIOLIBEXPORT void ciolib_gotoxy(int x, int y);
 CIOLIBEXPORT void ciolib_clreol(void);
 CIOLIBEXPORT void ciolib_clrscr(void);
-CIOLIBEXPORT int ciolib_cputs(char *str);
+CIOLIBEXPORT int ciolib_cputs(const char *str);
 CIOLIBEXPORT int	ciolib_cprintf(const char *fmat, ...);
 CIOLIBEXPORT void ciolib_textbackground(int colour);
 CIOLIBEXPORT void ciolib_textcolor(int colour);
@@ -700,7 +700,7 @@ CIOLIBEXPORT char * ciolib_getpass(const char *prompt)
 	if(cio_api.getpass)
 		return(cio_api.getpass(prompt));
 
-	ciolib_cputs((char *)prompt);
+	ciolib_cputs(prompt);
 	while((ch=ciolib_getch())!='\n') {
 		switch(ch) {
 			case 0:		/* Skip extended keys */
@@ -1052,7 +1052,7 @@ CIOLIBEXPORT int ciolib_cprintf(const char *fmat, ...)
 /* The Borland version does not translate \n into \r\n... this does.
  * Returns last character printed (!)
  */
-CIOLIBEXPORT int ciolib_cputs(char *str)
+CIOLIBEXPORT int ciolib_cputs(const char *str)
 {
 	int		pos;
 	int		ret=0;
diff --git a/src/conio/ciolib.h b/src/conio/ciolib.h
index 8efd529177..706e1ef292 100644
--- a/src/conio/ciolib.h
+++ b/src/conio/ciolib.h
@@ -337,7 +337,7 @@ typedef struct {
 	void	(*delline)		(void);
 	void	(*insline)		(void);
 	int		(*cprintf)		(const char *,...);
-	int		(*cputs)		(char *);
+	int		(*cputs)		(const char *);
 	void	(*textbackground)	(int);
 	void	(*textcolor)	(int);
 	int		(*getmouse)		(struct mouse_event *mevent);
@@ -409,7 +409,7 @@ CIOLIBEXPORT void ciolib_wscroll(void);
 CIOLIBEXPORT void ciolib_gotoxy(int x, int y);
 CIOLIBEXPORT void ciolib_clreol(void);
 CIOLIBEXPORT void ciolib_clrscr(void);
-CIOLIBEXPORT int ciolib_cputs(char *str);
+CIOLIBEXPORT int ciolib_cputs(const char *str);
 CIOLIBEXPORT int ciolib_cprintf(const char *fmat, ...);
 CIOLIBEXPORT void ciolib_textbackground(int colour);
 CIOLIBEXPORT void ciolib_textcolor(int colour);
diff --git a/src/syncterm/ripper.c b/src/syncterm/ripper.c
index 37b0327e0e..0484f7e0eb 100644
--- a/src/syncterm/ripper.c
+++ b/src/syncterm/ripper.c
@@ -7691,7 +7691,6 @@ static uint32_t
 map_rip_color(int color)
 {
 	uint32_t col = 0;
-	struct dac_colors *dac = NULL;
 
 	if (color < 16)
 		col = ega_colours[color];
@@ -7703,9 +7702,6 @@ map_rip_color(int color)
 	}
 	else
 		fprintf(stderr, "Unable to map %d\n", color);
-	if (dac) {
-		col = 0x80000000 | (dac->red << 16) | (dac->green << 8) | (dac->blue);
-	}
 	return col;
 }
 
@@ -9872,6 +9868,7 @@ do_rip_command(int level, int sublevel, int cmd, const char *rawargs)
 	int x, y;
 	char cache_path[MAX_PATH + 1];
 	FILE *icn;
+	int *targets;
 
 	args = parse_string(rawargs);
 
@@ -10512,7 +10509,12 @@ do_rip_command(int level, int sublevel, int cmd, const char *rawargs)
 							arg1 = parse_mega(&args[16], 2);
 							x2 = xp[0];
 							y2 = yp[0];
+							targets = malloc((arg1 + 2) * 2 * sizeof(*targets));
+							i = 0;
+							targets[i++] = x2;
+							targets[i++] = y2;
 							// TODO: We should be able to parallelize this...
+							#pragma clang loop vectorize(enable)
 							for (arg2 = 1; arg2 < arg1; arg2++) {
 								double tf = ((double)arg2) / arg1;
 								double tr = ((double)(arg1 - arg2)) / arg1;
@@ -10526,11 +10528,18 @@ do_rip_command(int level, int sublevel, int cmd, const char *rawargs)
 								y1 = trc * yp[0] + 3 * tftrs * yp[1] + 3 * tfstr * yp[2] + tfc * yp[3];
 								//x1 = tr * tr * tr * xp[0] + 3 * tf * tr * tr * xp[1] + 3 * tf * tf * tr * xp[2] + tf * tf * tf * xp[3];
 								//y1 = tr * tr * tr * yp[0] + 3 * tf * tr * tr * yp[1] + 3 * tf * tf * tr * yp[2] + tf * tf * tf * yp[3];
-								draw_line(x2, y2, x1, y1);
-								x2 = x1;
-								y2 = y1;
+								targets[i++] = x1;
+								targets[i++] = y1;
+								//draw_line(x2, y2, x1, y1);
+								//x2 = x1;
+								//y2 = y1;
+							}
+							targets[i++] = xp[3];
+							targets[i++] = yp[3];
+							for (j = 2; j < i; j += 2) {
+								draw_line(targets[j - 2], targets[j - 1], targets[j], targets[j + 1]);
 							}
-							draw_line(x1, y1, xp[3], yp[3]);
+							//draw_line(x1, y1, xp[3], yp[3]);
 							break;
 						case 'a':	// RIP_ONE_PALETTE !|a <color> <value>
 							/* This command changes one color in the 16-color palette.  The color
-- 
GitLab