about summary refs log tree commit diff
path: root/generator/pamtris
diff options
context:
space:
mode:
authorgiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2018-08-14 21:46:25 +0000
committergiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2018-08-14 21:46:25 +0000
commitf6515fd12bc9ccbea0347fd68a8422a9223f3099 (patch)
treecccb6606a102267aad29205d7d140c86804a5912 /generator/pamtris
parentd3cea986a286392f9e52464f7aec932fc9921417 (diff)
downloadnetpbm-mirror-f6515fd12bc9ccbea0347fd68a8422a9223f3099.tar.gz
netpbm-mirror-f6515fd12bc9ccbea0347fd68a8422a9223f3099.tar.xz
netpbm-mirror-f6515fd12bc9ccbea0347fd68a8422a9223f3099.zip
Declare function formal parameters constant
git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@3301 9d0c8265-081b-0410-96cb-a4ca84ce46f8
Diffstat (limited to 'generator/pamtris')
-rw-r--r--generator/pamtris/boundaries.c52
-rw-r--r--generator/pamtris/boundaries.h4
-rw-r--r--generator/pamtris/framebuffer.c36
-rw-r--r--generator/pamtris/framebuffer.h4
-rw-r--r--generator/pamtris/input.c97
-rw-r--r--generator/pamtris/pamtris.c19
-rw-r--r--generator/pamtris/triangle.c99
-rw-r--r--generator/pamtris/triangle.h16
-rw-r--r--generator/pamtris/utils.c48
9 files changed, 191 insertions, 184 deletions
diff --git a/generator/pamtris/boundaries.c b/generator/pamtris/boundaries.c
index e11ea894..9bd9928c 100644
--- a/generator/pamtris/boundaries.c
+++ b/generator/pamtris/boundaries.c
@@ -55,7 +55,7 @@ free_boundary_buffer(boundary_info * bi) {
 
 
 bool
-gen_triangle_boundaries(int32_t         xy[3][2],
+gen_triangle_boundaries(Xy              xy,
                         boundary_info * bi,
                         int16_t         width,
                         int16_t         height) {
@@ -71,8 +71,8 @@ gen_triangle_boundaries(int32_t         xy[3][2],
   The return value indicates whether the middle vertex is to the left of the
   line connecting the top vertex to the bottom vertex or not.
 -----------------------------------------------------------------------------*/
-    int16_t leftmost_x = xy[0][0];
-    int16_t rightmost_x = xy[0][0];
+    int16_t leftmost_x = xy._[0][0];
+    int16_t rightmost_x = xy._[0][0];
     int mid_is_to_the_left;
     fract left_x;
     fract right_x;
@@ -104,7 +104,7 @@ gen_triangle_boundaries(int32_t         xy[3][2],
     bi->num_upper_rows = 0;
     bi->num_lower_rows = 0;
 
-    if (xy[2][1] < 0 || xy[0][1] >= height) {
+    if (xy._[2][1] < 0 || xy._[0][1] >= height) {
         /* Triangle is either completely above the topmost scanline or
            completely below the bottom scanline.
         */
@@ -116,12 +116,12 @@ gen_triangle_boundaries(int32_t         xy[3][2],
         unsigned int i;
 
         for (i = 1; i < 3; i++) {
-            if (xy[i][0] < leftmost_x) {
-                leftmost_x = xy[i][0];
+            if (xy._[i][0] < leftmost_x) {
+                leftmost_x = xy._[i][0];
             }
 
-            if (xy[i][0] > rightmost_x) {
-                rightmost_x = xy[i][0];
+            if (xy._[i][0] > rightmost_x) {
+                rightmost_x = xy._[i][0];
             }
         }
     }
@@ -133,28 +133,28 @@ gen_triangle_boundaries(int32_t         xy[3][2],
         return false; /* Actual value doesn't matter. */
     }
 
-    if (xy[0][1] == xy[1][1] && xy[1][1] == xy[2][1]) {
+    if (xy._[0][1] == xy._[1][1] && xy._[1][1] == xy._[2][1]) {
         /* Triangle is degenarate: its visual representation consists only of
            a horizontal straight line.
         */
 
-        bi->start_scanline = xy[0][1];
+        bi->start_scanline = xy._[0][1];
 
         return false; /* Actual value doesn't matter. */
     }
 
     mid_is_to_the_left = 2;
 
-    left_x  = make_pos_fract(xy[0][0], 0);
-    right_x = make_pos_fract(xy[0][0], 0);
+    left_x  = make_pos_fract(xy._[0][0], 0);
+    right_x = make_pos_fract(xy._[0][0], 0);
 
-    if (xy[0][1] == xy[1][1]) {
+    if (xy._[0][1] == xy._[1][1]) {
         /* Triangle has only a lower part. */
 
         mid_is_to_the_left = 0;
 
-        right_x.q = xy[1][0];
-    } else if (xy[1][1] == xy[2][1]) {
+        right_x.q = xy._[1][0];
+    } else if (xy._[1][1] == xy._[2][1]) {
         /* Triangle has only an upper part (plus the row of the middle
            vertex).
         */
@@ -162,15 +162,15 @@ gen_triangle_boundaries(int32_t         xy[3][2],
         mid_is_to_the_left = 1;
     }
 
-    no_upper_part = (xy[1][1] == xy[0][1]);
+    no_upper_part = (xy._[1][1] == xy._[0][1]);
 
-    top2mid_delta = xy[1][1] - xy[0][1] + !no_upper_part;
-    top2bot_delta = xy[2][1] - xy[0][1] + 1;
-    mid2bot_delta = xy[2][1] - xy[1][1] + no_upper_part;
+    top2mid_delta = xy._[1][1] - xy._[0][1] + !no_upper_part;
+    top2bot_delta = xy._[2][1] - xy._[0][1] + 1;
+    mid2bot_delta = xy._[2][1] - xy._[1][1] + no_upper_part;
 
-    gen_steps(&xy[0][0], &xy[1][0], &top2mid_step, 1, top2mid_delta);
-    gen_steps(&xy[0][0], &xy[2][0], &top2bot_step, 1, top2bot_delta);
-    gen_steps(&xy[1][0], &xy[2][0], &mid2bot_step, 1, mid2bot_delta);
+    gen_steps(&xy._[0][0], &xy._[1][0], &top2mid_step, 1, top2mid_delta);
+    gen_steps(&xy._[0][0], &xy._[2][0], &top2bot_step, 1, top2bot_delta);
+    gen_steps(&xy._[1][0], &xy._[2][0], &mid2bot_step, 1, mid2bot_delta);
 
     if (mid_is_to_the_left == 2) {
         if (top2bot_step.negative_flag == true) {
@@ -232,7 +232,7 @@ gen_triangle_boundaries(int32_t         xy[3][2],
     num_rows_ptr[0] = &bi->num_upper_rows;
     num_rows_ptr[1] = &bi->num_lower_rows;
 
-    y = xy[0][1];
+    y = xy._[0][1];
 
     i = 0;
     k = 0;
@@ -240,14 +240,14 @@ gen_triangle_boundaries(int32_t         xy[3][2],
     if (no_upper_part == true) {
         k = 1;
 
-        right_x.q = xy[1][0];
+        right_x.q = xy._[1][0];
     }
 
     step_up(&left_x, left_step[k], 1, left_delta[k]);
     step_up(&right_x, right_step[k], 1, right_delta[k]);
 
     while (k < 2) {
-        int32_t end = xy[k + 1][1] + k;
+        int32_t end = xy._[k + 1][1] + k;
 
         if (y < 0) {
             int32_t delta;
@@ -255,7 +255,7 @@ gen_triangle_boundaries(int32_t         xy[3][2],
             if (end > 0) {
                 delta = -y;
             } else {
-                delta = xy[k + 1][1] - y;
+                delta = xy._[k + 1][1] - y;
             }
 
             y += delta;
diff --git a/generator/pamtris/boundaries.h b/generator/pamtris/boundaries.h
index 639a3d3e..f5306057 100644
--- a/generator/pamtris/boundaries.h
+++ b/generator/pamtris/boundaries.h
@@ -3,6 +3,8 @@
 
 #include <stdint.h>
 
+#include "triangle.h"
+
 typedef struct boundary_info {
 /*----------------------------------------------------------------------------
   Information about visible triangle rows' boundaries. Also see the
@@ -55,7 +57,7 @@ void
 free_boundary_buffer(boundary_info *);
 
 bool
-gen_triangle_boundaries(int32_t         xy[3][2],
+gen_triangle_boundaries(Xy              xy,
                         boundary_info *,
                         int16_t         width,
                         int16_t         height);
diff --git a/generator/pamtris/framebuffer.c b/generator/pamtris/framebuffer.c
index 01a66bea..81195779 100644
--- a/generator/pamtris/framebuffer.c
+++ b/generator/pamtris/framebuffer.c
@@ -47,8 +47,8 @@
 
 
 int
-set_tupletype(const char * str,
-              char         tupletype[256]) {
+set_tupletype(const char * const str,
+              char *       const tupletype) {
 /*----------------------------------------------------------------------------
   Set the tuple type for the output PAM images given a string ("str") of 255
   characters or less. If the string has more than 255 characters, the function
@@ -86,7 +86,7 @@ set_tupletype(const char * str,
 
 
 int
-init_framebuffer(framebuffer_info * fbi) {
+init_framebuffer(framebuffer_info * const fbi) {
 
     uint8_t num_planes = fbi->num_attribs + 1;
 
@@ -136,7 +136,7 @@ init_framebuffer(framebuffer_info * fbi) {
 
 
 void
-free_framebuffer(framebuffer_info * fbi) {
+free_framebuffer(framebuffer_info * const fbi) {
 
     free(fbi->img.buffer);
     free(fbi->z.buffer);
@@ -147,9 +147,9 @@ free_framebuffer(framebuffer_info * fbi) {
 
 
 int
-realloc_image_buffer(int32_t            new_maxval,
-                     int32_t            new_num_attribs,
-                     framebuffer_info * fbi) {
+realloc_image_buffer(int32_t            const new_maxval,
+                     int32_t            const new_num_attribs,
+                     framebuffer_info * const fbi) {
 /*----------------------------------------------------------------------------
   Reallocate the image buffer with a new maxval and depth, given the struct
   with information about the framebuffer. The fields variables "maxval" and
@@ -227,7 +227,7 @@ realloc_image_buffer(int32_t            new_maxval,
 
 
 void
-print_framebuffer(framebuffer_info * fbi) {
+print_framebuffer(framebuffer_info * const fbi) {
 
     uint8_t num_planes = fbi->num_attribs + 1;
     uint32_t i = 0;
@@ -256,9 +256,9 @@ print_framebuffer(framebuffer_info * fbi) {
 
 
 void
-clear_framebuffer(bool              clear_image_buffer,
-                  bool              clear_z_buffer,
-                  framebuffer_info* fbi) {
+clear_framebuffer(bool               const clear_image_buffer,
+                  bool               const clear_z_buffer,
+                  framebuffer_info * const fbi) {
 
     if (clear_image_buffer) {
         memset(fbi->img.buffer, 0, fbi->img.bytes);
@@ -272,12 +272,12 @@ clear_framebuffer(bool              clear_image_buffer,
 
 
 void
-draw_span(uint32_t           base,
-          uint16_t           length,
-          fract *            attribs_start,
-          const fract *      attribs_steps,
-          int32_t            div,
-          framebuffer_info * fbi) {
+draw_span(uint32_t           const base,
+          uint16_t           const length,
+          fract *            const attribs_start,
+          const fract *      const attribs_steps,
+          int32_t            const div,
+          framebuffer_info * const fbi) {
 /*----------------------------------------------------------------------------
   Draw a horizontal span of "length" pixels into the frame buffer, performing
   the appropriate depth tests. "base" must equal the row of the frame buffer
@@ -326,3 +326,5 @@ draw_span(uint32_t           base,
 }
 
 
+
+
diff --git a/generator/pamtris/framebuffer.h b/generator/pamtris/framebuffer.h
index 9b3d4dcf..442520ce 100644
--- a/generator/pamtris/framebuffer.h
+++ b/generator/pamtris/framebuffer.h
@@ -42,8 +42,8 @@ typedef struct framebuffer_info {
 
 
 int
-set_tupletype(const char * str,
-              char         tupletype[256]);
+set_tupletype(const char * const str,
+              char *       const tupletype);
 
 int
 init_framebuffer(framebuffer_info *);
diff --git a/generator/pamtris/input.c b/generator/pamtris/input.c
index 3529c16d..f447bb03 100644
--- a/generator/pamtris/input.c
+++ b/generator/pamtris/input.c
@@ -42,12 +42,12 @@
 #define SYNTAX_ERROR        "syntax error: line %lu."
 
 typedef struct {
-    int32_t v_xy[3][2];
+    Xy v_xy;
         /* X- and Y-coordinates of the vertices for the current triangle.
            int32_t v_attribs[3][MAX_NUM_ATTRIBS + 1]; // Vertex attributes for
            the current triangle. Includes the Z-coordinates.
         */
-	int32_t v_attribs[3][MAX_NUM_ATTRIBS + 1];
+	Attribs v_attribs;
         /* Vertex attributes for the current triangle. Includes the
            Z-coordinates.
         */
@@ -69,9 +69,9 @@ typedef struct {
 
 
 static void
-clear_attribs(state_info * si,
-              int32_t      maxval,
-              int16_t      num_attribs) {
+clear_attribs(state_info * const si,
+              int32_t      const maxval,
+              int16_t      const num_attribs) {
 
     unsigned int i;
 
@@ -83,7 +83,7 @@ clear_attribs(state_info * si,
 
 
 void
-init_input_processor(input_info * ii) {
+init_input_processor(input_info * const ii) {
 
     MALLOCARRAY_NOFAIL(ii->buffer, 128);
 
@@ -94,7 +94,7 @@ init_input_processor(input_info * ii) {
 
 
 void
-free_input_processor(input_info * ii) {
+free_input_processor(input_info * const ii) {
     free(ii->buffer);
 }
 
@@ -112,22 +112,18 @@ typedef struct {
 
 
 static token
-next_token(char * string_ptr) {
+next_token(char * const startPos) {
 
     token retval;
+    char * p;
 
-    while (*string_ptr != '\0' && isspace(*string_ptr)) {
-        string_ptr++;
-    }
+    for (p = startPos; *p && isspace(*p); ++p);
 
-    retval.begin = string_ptr;
+    retval.begin = p;
 
-    while (*string_ptr != '\0' && !isspace(*string_ptr))
-    {
-        string_ptr++;
-    }
+    for (; *p && !isspace(*p); ++p)
 
-    retval.end = string_ptr;
+    retval.end = p;
 
     return retval;
 }
@@ -135,33 +131,29 @@ next_token(char * string_ptr) {
 
 
 static bool
-validate_string(const char * target,
-                const char * src_begin,
-                const char * src_end) {
+validate_string(const char * const target,
+                const char * const srcBegin,
+                const char * const srcEnd) {
 
-    uint8_t chars_matched = 0;
+    unsigned int charsMatched;
+    const char * p;
 
-    while (src_begin != src_end && target[chars_matched] != '\0') {
-        if (*src_begin == target[chars_matched]) {
-            chars_matched++;
-        } else {
-            break;
-        }
+    for (p = srcBegin, charsMatched = 0;
+         p != srcEnd && target[charsMatched] != '\0'; ++p) {
 
-        src_begin++;
-    }
-
-    if (!isspace(*src_begin) && *src_begin != '\0') {
-        return false;
+        if (*p == target[charsMatched])
+            ++charsMatched;
+        else
+            break;
     }
 
-    return true;
+    return (*p == '\0' || isspace(*p));
 }
 
 
 
 static void
-init_state(state_info * si) {
+init_state(state_info * const si) {
 
     si->next = 0;
     si->draw = false;
@@ -171,37 +163,36 @@ init_state(state_info * si) {
 
 
 static void
-make_lowercase(token t) {
+make_lowercase(token const t) {
 
-    while (t.begin != t.end) {
-        *t.begin = tolower(*t.begin);
+    char * p;
 
-        t.begin++;
-    }
+    for (p = t.begin; t.begin != t.end; ++p)
+        *p = tolower(*p);
 }
 
 
 
 static void
-remove_comments(char * str) {
+remove_comments(char * const str) {
 
-    while (*str != '\0') {
-        if (*str == '#') {
-            *str = '\0';
+    char * p;
 
-            return;
-        }
+    for (p = &str[0]; *p; ++p) {
+        if (*p == '#') {
+            *p = '\0';
 
-        str++;
+            break;
+        }
     }
 }
 
 
 
 int
-process_next_command(input_info           * line,
-                     struct boundary_info * bi,
-                     framebuffer_info     * fbi) {
+process_next_command(input_info           * const line,
+                     struct boundary_info * const bi,
+                     framebuffer_info     * const fbi) {
 /*----------------------------------------------------------------------------
   Doesn't necessarily process a command, just the next line of input, which
   may be empty. Always returns 1, except when it cannot read any more lines of
@@ -415,13 +406,13 @@ process_next_command(input_info           * line,
         }
 
         for (i = 0; i < fbi->num_attribs; i++) {
-            state.v_attribs[state.next][i] = state.curr_attribs[i];
+            state.v_attribs._[state.next][i] = state.curr_attribs[i];
         }
 
-        state.v_attribs[state.next][fbi->num_attribs] = i_args[2];
+        state.v_attribs._[state.next][fbi->num_attribs] = i_args[2];
 
-        state.v_xy[state.next][0] = i_args[0];
-        state.v_xy[state.next][1] = i_args[1];
+        state.v_xy._[state.next][0] = i_args[0];
+        state.v_xy._[state.next][1] = i_args[1];
 
         state.next++;
 
diff --git a/generator/pamtris/pamtris.c b/generator/pamtris/pamtris.c
index 3237b009..5b851c67 100644
--- a/generator/pamtris/pamtris.c
+++ b/generator/pamtris/pamtris.c
@@ -16,15 +16,14 @@
 
 
 static int
-parse_command_line (
- int       argv_idx,
- int *     argc_ptr,
- const char ** argv,
- int32_t * width,
- int32_t * height,
- int32_t * maxval,
- int32_t * num_attribs,
- char      tupletype[256]) {
+parse_command_line(int           const argv_idx,
+                   int *         const argc_ptr,
+                   const char ** const argv,
+                   int32_t *     const width,
+                   int32_t *     const height,
+                   int32_t *     const maxval,
+                   int32_t *     const num_attribs,
+                   char *        const tupletype) {
 
     optEntry * option_def;
     optStruct3 opt;
@@ -72,6 +71,8 @@ parse_command_line (
 
     if (maxval_spec) {
         if (*maxval < 1 || *maxval > PAM_OVERALL_MAXVAL) {
+
+
             pm_errormsg("invalid maxval.");
 
             return 0;
diff --git a/generator/pamtris/triangle.c b/generator/pamtris/triangle.c
index eb6b7a00..cc9cdba2 100644
--- a/generator/pamtris/triangle.c
+++ b/generator/pamtris/triangle.c
@@ -18,15 +18,15 @@
 
 static void
 draw_partial_triangle(
-    const fract *         left_attribs_input,
-    const fract *         left_attribs_steps,
-    const fract *         right_attribs_input,
-    const fract *         right_attribs_steps,
-    int32_t               left_div,
-    int32_t               right_div,
-    bool                  upper_part,
-    const boundary_info * bi,
-    framebuffer_info *    fbi) {
+    const fract *         const left_attribs_input,
+    const fract *         const left_attribs_steps,
+    const fract *         const right_attribs_input,
+    const fract *         const right_attribs_steps,
+    int32_t               const left_div,
+    int32_t               const right_div,
+    bool                  const upper_part,
+    const boundary_info * const bi,
+    framebuffer_info *    const fbi) {
 
     uint8_t num_planes = fbi->num_attribs + 1;
 
@@ -123,16 +123,16 @@ draw_partial_triangle(
 
 
 static void
-draw_degenerate_horizontal(int32_t           xy[3][2],
-                           fract *           attribs_left,
-                           fract *           attribs_mid,
-                           const fract *     top2mid_steps,
-                           const fract *     top2bot_steps,
-                           const fract *     mid2bot_steps,
-                           int32_t           top2mid_delta,
-                           int32_t           top2bot_delta,
-                           int32_t           mid2bot_delta,
-                           framebuffer_info* fbi) {
+draw_degenerate_horizontal(Xy                 const xy,
+                           fract *            const attribs_left,
+                           fract *            const attribs_mid,
+                           const fract *      const top2mid_steps,
+                           const fract *      const top2bot_steps,
+                           const fract *      const mid2bot_steps,
+                           int32_t            const top2mid_delta,
+                           int32_t            const top2bot_delta,
+                           int32_t            const mid2bot_delta,
+                           framebuffer_info * const fbi) {
 
     uint8_t num_planes = fbi->num_attribs + 1;
 
@@ -143,7 +143,7 @@ draw_degenerate_horizontal(int32_t           xy[3][2],
     memcpy(attribs_left_bkup, attribs_left, num_planes * sizeof(fract));
 
     {
-        int16_t y = xy[0][1];
+        int16_t y = xy._[0][1];
 
         int16_t x[3];
         int16_t x_start[3];
@@ -152,9 +152,9 @@ draw_degenerate_horizontal(int32_t           xy[3][2],
         int32_t span_length[3];
         unsigned int i;
 
-        x[0] = xy[0][0];
-        x[1] = xy[1][0];
-        x[2] = xy[2][0];
+        x[0] = xy._[0][0];
+        x[1] = xy._[1][0];
+        x[2] = xy._[2][0];
 
         x_start[0] = x[0];
         x_start[1] = x[0];
@@ -204,14 +204,14 @@ draw_degenerate_horizontal(int32_t           xy[3][2],
 
 
 void
-draw_triangle(int32_t            xy_input[3][2],
-              int32_t            attribs_input[3][MAX_NUM_ATTRIBS + 1],
-              boundary_info *    bi,
-              framebuffer_info * fbi) {
+draw_triangle(Xy                 const xy_input,
+              Attribs            const attribs_input,
+              boundary_info *    const bi,
+              framebuffer_info * const fbi) {
 
     uint8_t num_planes = fbi->num_attribs + 1;
 
-    int32_t xy[3][2];
+    Xy xy;
     int32_t * attribs[3];
     unsigned int i;
     uint8_t index_array[3];
@@ -222,17 +222,17 @@ draw_triangle(int32_t            xy_input[3][2],
     MALLOCARRAY_NOFAIL(attribs[1], num_planes);
     MALLOCARRAY_NOFAIL(attribs[2], num_planes);
 
-    memcpy(xy, xy_input, sizeof(xy));
+    xy = xy_input;
 
     for (i = 0; i < 3; i++) {
-        memcpy(attribs[i], attribs_input[i], num_planes * sizeof(int32_t));
+        memcpy(attribs[i], attribs_input._[i], num_planes * sizeof(int32_t));
     }
 
     /* Argument preparations for sort3: */
 
     index_array[0] = 0; index_array[1] = 1; index_array[2] = 2;
-    y_array[0] = xy[0][1]; y_array[1] = xy[1][1]; y_array[2] = xy[2][1];
-    x_array[0] = xy[0][0]; x_array[1] = xy[1][0]; x_array[2] = xy[2][0];
+    y_array[0] = xy._[0][1]; y_array[1] = xy._[1][1]; y_array[2] = xy._[2][1];
+    x_array[0] = xy._[0][0]; x_array[1] = xy._[1][0]; x_array[2] = xy._[2][0];
 
     sort3(index_array, y_array, x_array);
 
@@ -243,14 +243,14 @@ draw_triangle(int32_t            xy_input[3][2],
 
         bool mid_is_to_the_left;
 
-        int32_t xy_sorted[3][2];
+        Xy xy_sorted;
 
-        xy_sorted[0][0] = xy[top][0];
-        xy_sorted[0][1] = xy[top][1];
-        xy_sorted[1][0] = xy[mid][0];
-        xy_sorted[1][1] = xy[mid][1];
-        xy_sorted[2][0] = xy[bot][0];
-        xy_sorted[2][1] = xy[bot][1];
+        xy_sorted._[0][0] = xy._[top][0];
+        xy_sorted._[0][1] = xy._[top][1];
+        xy_sorted._[1][0] = xy._[mid][0];
+        xy_sorted._[1][1] = xy._[mid][1];
+        xy_sorted._[2][0] = xy._[bot][0];
+        xy_sorted._[2][1] = xy._[bot][1];
 
         mid_is_to_the_left =
             gen_triangle_boundaries(xy_sorted, bi, fbi->width, fbi->height);
@@ -260,16 +260,17 @@ draw_triangle(int32_t            xy_input[3][2],
 
             return;
         } else {
-            bool no_upper_part = (xy_sorted[1][1] == xy_sorted[0][1]);
+            bool no_upper_part = (xy_sorted._[1][1] == xy_sorted._[0][1]);
 
-            bool horizontal = (xy[0][1] == xy[1][1] && xy[1][1] == xy[2][1]);
+            bool horizontal =
+                (xy._[0][1] == xy._[1][1] && xy._[1][1] == xy._[2][1]);
                 /* We are dealing with a degenerate horizontal triangle */
 
             uint8_t t = ~horizontal & 1;
 
-            int32_t top2mid_delta = xy[mid][t] - xy[top][t];
-            int32_t top2bot_delta = xy[bot][t] - xy[top][t];
-            int32_t mid2bot_delta = xy[bot][t] - xy[mid][t];
+            int32_t top2mid_delta = xy._[mid][t] - xy._[top][t];
+            int32_t top2bot_delta = xy._[bot][t] - xy._[top][t];
+            int32_t mid2bot_delta = xy._[bot][t] - xy._[mid][t];
 
             fract * top2mid_steps;
             fract * top2bot_steps;
@@ -361,8 +362,8 @@ draw_triangle(int32_t            xy_input[3][2],
 
                 if (bi->num_upper_rows > 0) {
 
-                    if (bi->start_scanline > xy[top][1]) {
-                        delta = bi->start_scanline - xy[top][1];
+                    if (bi->start_scanline > xy._[top][1]) {
+                        delta = bi->start_scanline - xy._[top][1];
 
                         multi_step_up(left_attribs, upper_left_attribs_steps,
                                       num_planes, delta, upper_left_delta);
@@ -379,7 +380,7 @@ draw_triangle(int32_t            xy_input[3][2],
                         fbi
                         );
 
-                    delta = xy[mid][1] - bi->start_scanline;
+                    delta = xy._[mid][1] - bi->start_scanline;
                 } else {
                     delta = top2mid_delta;
                 }
@@ -390,8 +391,8 @@ draw_triangle(int32_t            xy_input[3][2],
                               num_planes, delta, upper_right_delta);
             }
 
-            if (bi->start_scanline > xy[mid][1]) {
-                int32_t delta = bi->start_scanline - xy[mid][1];
+            if (bi->start_scanline > xy._[mid][1]) {
+                int32_t delta = bi->start_scanline - xy._[mid][1];
 
                 multi_step_up(left_attribs, lower_left_attribs_steps,
                               num_planes, delta, lower_left_delta);
diff --git a/generator/pamtris/triangle.h b/generator/pamtris/triangle.h
index 07e6d065..bceda54f 100644
--- a/generator/pamtris/triangle.h
+++ b/generator/pamtris/triangle.h
@@ -8,10 +8,18 @@
 struct boundary_info;
 struct framebuffer_info;
 
+typedef struct {
+    int32_t _[3][2];
+} Xy;
+
+typedef struct {
+    int32_t _[3][MAX_NUM_ATTRIBS + 1];
+} Attribs;
+
 void
-draw_triangle(int32_t            xy[3][2],
-              int32_t            attribs[3][MAX_NUM_ATTRIBS + 1],
-              struct boundary_info *,
-              struct framebuffer_info *);
+draw_triangle(Xy                        const xy,
+              Attribs                   const attribs,
+              struct boundary_info *    const,
+              struct framebuffer_info * const);
 
 #endif
diff --git a/generator/pamtris/utils.c b/generator/pamtris/utils.c
index 1ef7283c..2ce42576 100644
--- a/generator/pamtris/utils.c
+++ b/generator/pamtris/utils.c
@@ -14,10 +14,10 @@
 
 
 void
-step_up(fract *       vars,
-        const fract * steps,
-        uint8_t       elements,
-        int32_t       div) {
+step_up(fract *       const vars,
+        const fract * const steps,
+        uint8_t       const elements,
+        int32_t       const div) {
 /*----------------------------------------------------------------------------
   Apply interpolation steps (see above) to a collection of fract
   variables (also see above) once. This is done by adding the
@@ -52,11 +52,11 @@ step_up(fract *       vars,
 
 
 void
-multi_step_up(fract *       vars,
-              const fract * steps,
-              uint8_t       elements,
-              int32_t       times,
-              int32_t       div) {
+multi_step_up(fract *       const vars,
+              const fract * const steps,
+              uint8_t       const elements,
+              int32_t       const times,
+              int32_t       const div) {
 /*----------------------------------------------------------------------------
   Similar to step_up, but apply the interpolation step an arbitrary number
   of times, instead of just once.
@@ -85,9 +85,11 @@ multi_step_up(fract *       vars,
 
 
 void
-gen_steps(const int32_t * begin,
-          const int32_t * end,
-          fract         * out, uint8_t elements, int32_t div) {
+gen_steps(const int32_t * const begin,
+          const int32_t * const end,
+          fract         * const out,
+          uint8_t         const elements,
+          int32_t         const div) {
 /*----------------------------------------------------------------------------
   Generate the interpolation steps for a collection of initial and final
   values. "begin" points to an array of initial values, "end" points to the
@@ -133,9 +135,9 @@ gen_steps(const int32_t * begin,
 
 
 void
-fract_to_int32_array(const fract * in,
-                     int32_t *     out,
-                     uint8_t       elements) {
+fract_to_int32_array(const fract * const in,
+                     int32_t *     const out,
+                     uint8_t       const elements) {
 
     unsigned int i;
 
@@ -147,9 +149,9 @@ fract_to_int32_array(const fract * in,
 
 
 void
-int32_to_fract_array(const int32_t * in,
-                     fract *         out,
-                     uint8_t         elements) {
+int32_to_fract_array(const int32_t * const in,
+                     fract *         const out,
+                     uint8_t         const elements) {
 
     unsigned int i;
 
@@ -162,8 +164,8 @@ int32_to_fract_array(const int32_t * in,
 
 
 static void
-swap(uint8_t * a,
-     uint8_t * b) {
+swap(uint8_t * const a,
+     uint8_t * const b) {
 /*----------------------------------------------------------------------------
   Swap the contents pointed to by a and b.
 -----------------------------------------------------------------------------*/
@@ -175,9 +177,9 @@ swap(uint8_t * a,
 
 
 void
-sort3(uint8_t *       index_array,
-      const int32_t * y_array,
-      const int32_t * x_array) {
+sort3(uint8_t *       const index_array,
+      const int32_t * const y_array,
+      const int32_t * const x_array) {
 /*----------------------------------------------------------------------------
   Sort an index array of 3 elements. This function is used to sort vertices
   with regard to relative row from top to bottom, but instead of sorting