|
|
@ -597,69 +597,69 @@ merge_color_table(qstate* qs, uint32_t* colors, uint32_t colorregs){
|
|
|
|
++cidx;
|
|
|
|
++cidx;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
free(qactive);
|
|
|
|
free(qactive);
|
|
|
|
// tend to those which couldn't get a color table entry. we start with two
|
|
|
|
if(*colors > colorregs){
|
|
|
|
// values, lo and hi, initialized to -1. we iterate over the *static* qnodes,
|
|
|
|
// tend to those which couldn't get a color table entry. we start with two
|
|
|
|
// descending into onodes to check their qnodes. we thus iterate over all
|
|
|
|
// values, lo and hi, initialized to -1. we iterate over the *static* qnodes,
|
|
|
|
// used qnodes, in order (and also unused static qnodes). if the node is
|
|
|
|
// descending into onodes to check their qnodes. we thus iterate over all
|
|
|
|
// empty, continue. if it is chosen, replace lo. otherwise, if hi is less
|
|
|
|
// used qnodes, in order (and also unused static qnodes). if the node is
|
|
|
|
// than z, we need find the next lowest chosen one. if there is no next
|
|
|
|
// empty, continue. if it is chosen, replace lo. otherwise, if hi is less
|
|
|
|
// lowest, hi is reset to -1. otherwise, set hi. once we have the new hi > z,
|
|
|
|
// than z, we need find the next lowest chosen one. if there is no next
|
|
|
|
// determine which of hi and lo are closer to z, discounting -1 values, and
|
|
|
|
// lowest, hi is reset to -1. otherwise, set hi. once we have the new hi > z,
|
|
|
|
// link te closer one to z. a toplevel node is worth 8 in terms of distance;
|
|
|
|
// determine which of hi and lo are closer to z, discounting -1 values, and
|
|
|
|
// and lowlevel node is worth 1.
|
|
|
|
// link te closer one to z. a toplevel node is worth 8 in terms of distance;
|
|
|
|
int lo = -1;
|
|
|
|
// and lowlevel node is worth 1.
|
|
|
|
int hi = -1;
|
|
|
|
int lo = -1;
|
|
|
|
const qnode* lq = NULL;
|
|
|
|
int hi = -1;
|
|
|
|
const qnode* hq = NULL;
|
|
|
|
const qnode* lq = NULL;
|
|
|
|
for(int z = 0 ; z < QNODECOUNT ; ++z){
|
|
|
|
const qnode* hq = NULL;
|
|
|
|
if(qs->qnodes[z].q.pop == 0){
|
|
|
|
for(int z = 0 ; z < QNODECOUNT ; ++z){
|
|
|
|
if(qs->qnodes[z].qlink == 0){
|
|
|
|
if(qs->qnodes[z].q.pop == 0){
|
|
|
|
continue; // unused
|
|
|
|
if(qs->qnodes[z].qlink == 0){
|
|
|
|
}
|
|
|
|
continue; // unused
|
|
|
|
// process the onode
|
|
|
|
}
|
|
|
|
const onode* o = &qs->onodes[qs->qnodes[z].qlink - 1];
|
|
|
|
// process the onode
|
|
|
|
for(int i = 0 ; i < 8 ; ++i){
|
|
|
|
const onode* o = &qs->onodes[qs->qnodes[z].qlink - 1];
|
|
|
|
if(o->q[i]){
|
|
|
|
for(int i = 0 ; i < 8 ; ++i){
|
|
|
|
if(!chosen_p(o->q[i])){
|
|
|
|
if(o->q[i]){
|
|
|
|
|
|
|
|
if(!chosen_p(o->q[i])){
|
|
|
|
//fprintf(stderr, "NOT CHOSEN: %u %u %u %u\n", z, o->q[i]->qlink, o->q[i]->q.pop, o->q[i]->cidx);
|
|
|
|
//fprintf(stderr, "NOT CHOSEN: %u %u %u %u\n", z, o->q[i]->qlink, o->q[i]->q.pop, o->q[i]->cidx);
|
|
|
|
if(z * 8 + i > hi){
|
|
|
|
if(z * 8 + i > hi){
|
|
|
|
hi = find_next_lowest_chosen(qs, z, i, &hq);
|
|
|
|
hi = find_next_lowest_chosen(qs, z, i, &hq);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
int cur = z * 8 + 4;
|
|
|
|
int cur = z * 8 + 4;
|
|
|
|
if(lo == -1){
|
|
|
|
if(lo == -1){
|
|
|
|
o->q[i]->cidx = qidx(hq);
|
|
|
|
o->q[i]->cidx = qidx(hq);
|
|
|
|
}else if(hi == -1 || cur - lo < hi - cur){
|
|
|
|
}else if(hi == -1 || cur - lo < hi - cur){
|
|
|
|
o->q[i]->cidx = qidx(lq);
|
|
|
|
o->q[i]->cidx = qidx(lq);
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
|
|
|
o->q[i]->cidx = qidx(hq);
|
|
|
|
|
|
|
|
}
|
|
|
|
}else{
|
|
|
|
}else{
|
|
|
|
o->q[i]->cidx = qidx(hq);
|
|
|
|
lq = o->q[i];
|
|
|
|
|
|
|
|
lo = z * 8 + i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}else{
|
|
|
|
|
|
|
|
lq = o->q[i];
|
|
|
|
|
|
|
|
lo = z * 8 + i;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}else{
|
|
|
|
}else{
|
|
|
|
if(!chosen_p(&qs->qnodes[z])){
|
|
|
|
if(!chosen_p(&qs->qnodes[z])){
|
|
|
|
|
|
|
|
//fprintf(stderr, "NOT CHOSEN: %u %u %u %u\n", z, qs->qnodes[z].qlink, qs->qnodes[z].q.pop, qs->qnodes[z].cidx);
|
|
|
|
//fprintf(stderr, "NOT CHOSEN: %u %u %u %u\n", z, qs->qnodes[z].qlink, qs->qnodes[z].q.pop, qs->qnodes[z].cidx);
|
|
|
|
if(z * 8 > hi){
|
|
|
|
if(z * 8 > hi){
|
|
|
|
hi = find_next_lowest_chosen(qs, z, -1, &hq);
|
|
|
|
hi = find_next_lowest_chosen(qs, z, -1, &hq);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
int cur = z * 8 + 4;
|
|
|
|
int cur = z * 8 + 4;
|
|
|
|
if(lo == -1){
|
|
|
|
if(lo == -1){
|
|
|
|
qs->qnodes[z].cidx = qidx(hq);
|
|
|
|
qs->qnodes[z].cidx = qidx(hq);
|
|
|
|
}else if(hi == -1 || cur - lo < hi - cur){
|
|
|
|
}else if(hi == -1 || cur - lo < hi - cur){
|
|
|
|
qs->qnodes[z].cidx = qidx(lq);
|
|
|
|
qs->qnodes[z].cidx = qidx(lq);
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
|
|
|
qs->qnodes[z].cidx = qidx(hq);
|
|
|
|
|
|
|
|
}
|
|
|
|
}else{
|
|
|
|
}else{
|
|
|
|
qs->qnodes[z].cidx = qidx(hq);
|
|
|
|
lq = &qs->qnodes[z];
|
|
|
|
|
|
|
|
lo = z * 8;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}else{
|
|
|
|
|
|
|
|
lq = &qs->qnodes[z];
|
|
|
|
|
|
|
|
lo = z * 8;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(*colors > colorregs){
|
|
|
|
|
|
|
|
*colors = colorregs;
|
|
|
|
*colors = colorregs;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
return 0;
|
|
|
|