One small step forward, but far from finished and needs some checking of what is going on because it is not what it should be

Trace data displaying for the long time base settings (100mS/div and up) is implemented. Was quite the struggle to grasp the meaning of a part of the code. It turns out to be some signal rise speed detection.
void display_channel1_long_timebase_trace(void)
{
undefined2 *puVar1;
undefined *puVar2;
int iVar3;
uint uVar4;
uint ystart;
uint uVar5;
uint yend;
bool bVar6;
bool bVar7;
set_display_fg_color(DAT_80006890);
puVar2 = PTR_DAT_80006894;
uVar4 = (uint)*(ushort *)PTR_DAT_80006894;
if (uVar4 == 0)
{
puVar1 = (undefined2 *)(PTR_DAT_80006894 + 0x16);
*(undefined2 *)(PTR_DAT_80006894 + 2) = *puVar1;
*(undefined2 *)(puVar2 + 6) = *puVar1;
}
yend = (uint)*(ushort *)(puVar2 + 0x16);
ystart = (uint)*(ushort *)(puVar2 + 2);
uVar5 = yend + 0xf;
bVar7 = ystart <= uVar5;
bVar6 = uVar5 == ystart;
if (bVar7 && !bVar6)
{
uVar5 = ystart + 0xf;
}
if (bVar7 && !bVar6)
{
bVar7 = yend <= uVar5;
bVar6 = uVar5 == yend;
}
if (!bVar7 || bVar6)
{
uVar5 = ystart + 0x14;
bVar7 = uVar5 <= yend;
bVar6 = yend == uVar5;
if (!bVar7 || bVar6)
{
uVar5 = yend + 0x14;
}
if (!bVar7 || bVar6)
{
bVar7 = uVar5 <= ystart;
bVar6 = ystart == uVar5;
}
if (bVar7 && !bVar6)
{
display_draw_line(uVar4 + 3,ystart,uVar4 + 3,yend);
display_draw_line(*(ushort *)puVar2 + 3,*(ushort *)(puVar2 + 2) + 1,*(ushort *)puVar2 + 3,*(ushort *)(puVar2 + 0x16) + 1);
goto LAB_80006828;
}
}
else
{
yend = yend + ystart >> 1;
*(short *)(puVar2 + 0x16) = (short)yend;
}
display_draw_line(uVar4 + 3,ystart,uVar4 + 4,yend);
display_draw_line(*(ushort *)puVar2 + 3,*(ushort *)(puVar2 + 2) + 1,*(ushort *)puVar2 + 4,*(ushort *)(puVar2 + 0x16) + 1);
LAB_80006828:
iVar3 = DAT_80006898;
*(undefined2 *)(puVar2 + 6) = *(undefined2 *)(puVar2 + 2);
*(undefined2 *)(puVar2 + 2) = *(undefined2 *)(puVar2 + 0x16);
*(undefined2 *)(iVar3 + (uint)*(ushort *)puVar2 * 2) = *(undefined2 *)(puVar2 + 0x16);
return;
}
At first I had to identify the functions called as being display_draw_line. Then it took a while to notice that the first two calls use the same x point. One reads what one wants to read

Also the bit with all the compares if one of the points plus 15 is less then the other and then the points plus 20, so I made test code of it and ran it through with a debugger.
Turns out that on the absolute difference a check is done to see if the delta is less then 15. If so take the average between the two points, if less then or equal to 20 use the points and draw them on consecutive x positions. Is it more then 20 draw the points on a single x position.
This is what I made of it.
//Check on rise speed of the signal
if(disp_ch1_y < disp_ch1_prev_y)
{
//previous bigger then current so subtract from it to get positive delta
dy = disp_ch1_prev_y - disp_ch1_y;
}
else
{
//current bigger then previous so subtract from it to get positive delta
dy = disp_ch1_y - disp_ch1_prev_y;
}
//Take action based on the delta
if(dy < 15)
{
//Less then 15 apart slow the trace by stopping on the average of the two points
disp_ch1_y = (disp_ch1_y + disp_ch1_prev_y) >> 1;
}
else if(dy > 20)
{
//Else if delta bigger then 20 draw on a single x position
xpos2--;
}
//Draw the lines. When on a single x point it is a bit inefficient. Would be better to only draw one line and make it one longer for the double width
display_draw_line(xpos1, disp_ch1_prev_y, xpos2, disp_ch1_y);
display_draw_line(xpos1, disp_ch1_prev_y + 1, xpos2, disp_ch1_y + 1);
And the photo shows what the scope makes of it
