From 7054084a9e1146efadcf982ea47b68b5923e24ea Mon Sep 17 00:00:00 2001 From: Vince Weaver Date: Sun, 1 Oct 2023 01:06:59 -0400 Subject: [PATCH] second: more auto generation --- demos/second/part18_3d/auto/NOTES | 12 +-- demos/second/part18_3d/auto/box_convert.c | 116 +++++++++++++++++++--- 2 files changed, 107 insertions(+), 21 deletions(-) diff --git a/demos/second/part18_3d/auto/NOTES b/demos/second/part18_3d/auto/NOTES index 71dac46a..609e8859 100644 --- a/demos/second/part18_3d/auto/NOTES +++ b/demos/second/part18_3d/auto/NOTES @@ -16,14 +16,14 @@ todo, compressed: 906 bytes: try6: sort by color first 628 bytes: try7: initial use boxes 526 bytes: try8: boxes that optimize to HLIN/VLIN/PLOT + 522 bytes: try9: optimize HLIN to HLIN_ADD variants + 506 bytes: try10: sort types per color + 498 bytes: try11: sort HLIN by Y1 TODO: - If HLIN and previous same x1/x2 do box - If HLIN only one wide, switch to VLIN? - IF HLIN and next line HLIN at +1, use HLIN_ADD - If HLIN and next line HLIN at +1 and R same, HLIN_ADD_RSAME - If HLIN and next line HLIN at +1 and R same, HLIN_ADD_LSAME - + Add don't cares + Try all color combos + Sort the color results to have consecutive HLINs together MOVE PLOTS one line before HLIN Possible size boxes diff --git a/demos/second/part18_3d/auto/box_convert.c b/demos/second/part18_3d/auto/box_convert.c index e522f9c8..77942b14 100644 --- a/demos/second/part18_3d/auto/box_convert.c +++ b/demos/second/part18_3d/auto/box_convert.c @@ -56,7 +56,7 @@ static char action_names[9][16]={ #endif #define MAX_PRIMITIVES 4096 -static struct { +static struct primitive_list_t { int type; int color; int x1,y1,x2,y2; @@ -215,6 +215,29 @@ int create_using_boxes(void) { return current_primitive; } +static int compare_type(const void *p1, const void *p2) { + + struct primitive_list_t *first,*second; + + first=(struct primitive_list_t *)p1; + second=(struct primitive_list_t *)p2; + + return (first->type > second->type); + +} + +static int compare_y1(const void *p1, const void *p2) { + + struct primitive_list_t *first,*second; + + first=(struct primitive_list_t *)p1; + second=(struct primitive_list_t *)p2; + + return (first->y1 > second->y1); + +} + + @@ -308,27 +331,81 @@ int main(int argc, char **argv) { } } + /* Sort each color by BOX/HLIN/ETC */ + int old_color,last_color_start=0; + + old_color=primitive_list[0].color; + for(i=0;i