Bad idea: build a captcha library that embeds DOSBox so it can make you beat levels/puzzles from DOS games to continue.
-
@enno mean
but yeah, clearly. -
oh sweet laser jesus I found the upload palette function and THEY UNROLLED IT
-
why do:
for(int i=0;i<256;i++){
upload_color(i,palette[i]);
}when you can do
upload_color(0,palette[0]);
upload_color(1,palette[1]);
upload_color(2,palette[2]);
upload_color(3,palette[3]);
upload_color(4,palette[4]);
upload_color(5,palette[5]);and just repeat 251 more times
-
the worst part is that this was done with a compiler from 1991 so there's no way it unrolled the loop itself. they did this manually
-
@foone Any idea why? I have extremely little experience with programming in that era, but I remember that code size was always a serious concern ... so unrolling it sounds like a bad idea, unless they really needed it for performance.
-
@saua it runs slightly faster. like a couple cycles per "iteration".
This is aiming at CPUs so slow that that might matter
-
No compiler flags that would do this? ️
-
oh that's cute. their set_palette function takes two arguments: a pointer to the palette, and a number of extra palettes to apply.
so they could set up an array of palettes in decreasing brightness, and just do set_palette(&fade_pallets[0], 64) to go through them.
but the same function is a regular one-time set_palette if you just pass 1 for the second argument.
-
@simonzerafa in 1991? I don't think so. Not a for loop this big.
-
"hey ghidra what calls set_palette?"
"I don't know! you're in 16bit segmented mode! pointers are MEANINGLESS
-
ahh, nope! I misidentified it.
the second parameter on set_palette is how many frames to set it for.
The same palette gets set.it vsyncs every time so this is a set_palette that's also a timing function
-
@foone the only thing better than __FILE__ is __func__
-
or maybe not? it's too 2am to tell.
ANYWAY I'm currently debugging through a function that's 256 palette entry uploads and my debugger has no "run until return" function so I have to manually hit next instruction SO MANY TIMES
-
(approximately 1536 times)
-
this set_palette code got loaded into the segment 0BBC, one of the only 16-bit DOS segments marked red in shinigami eyes
-
@[email protected] maybe they wanted to experience the joys of funroll-loops all by themselves
not much else going on in 91 -
Foone🏳️⚧️replied to Foone🏳️⚧️ last edited by [email protected]
interesting: the same function is called to fade a palette TO black and to fade a palette FROM black
I wonder if it's specialized to just be palette to black and vice versa, or if it does arbitrary fades between two palettes?
-
@aud good point, it was a famously uneventful year
-
I'm staring at this code going "if it was less 2am, I could understand this math"
-
this math:
local_8 = (int)(0x3f / (long)param_1) + 1;
iVar6 = 0;
do {
uVar7 = (undefined2)((ulong)param_2 >> 0x10);
uVar8 = (undefined2)((ulong)param_4 >> 0x10);
iVar4 = (int)param_4;
uVar1 = (int)*(char *)(iVar4 + iVar6) - (int)*(char *)((int)param_2 + iVar6);
uVar2 = (int)uVar1 >> 0xf;
local_608[iVar6] = (char)((int)((uVar1 ^ uVar2) - uVar2) / local_8) + '\x01';
iVar6 = iVar6 + 1;
} while (iVar6 < 0x300);