Make terminal ui binaries work well everywhere

Here's some screenshots of an emulator tui program that was compiled on
Linux, then scp'd it to Windows, Mac, and FreeBSD.

https://justine.storage.googleapis.com/blinkenlights-cmdexe.png
https://justine.storage.googleapis.com/blinkenlights-imac.png
https://justine.storage.googleapis.com/blinkenlights-freebsd.png
https://justine.storage.googleapis.com/blinkenlights-lisp.png

How is this even possible that we have a nontrivial ui binary that just
works on Mac, Windows, Linux, and BSD? Surely a first ever achievement.

Fixed many bugs. Bootstrapped John McCarthy's metacircular evaluator on
bare metal in half the size of Altair BASIC (about 2.5kb) and ran it in
emulator for fun and profit.
This commit is contained in:
Justine Tunney 2020-10-10 21:18:53 -07:00
parent 680daf1210
commit 9e3e985ae5
276 changed files with 7026 additions and 3790 deletions

View file

@ -26,7 +26,7 @@
/* this is a reduced-precision calculation of YCbCr-to-RGB introduced
to make sure the code produces the same results in both SIMD and scalar */
#define FLOAT2FIXED(x) (((int)((x)*4096.0f + 0.5f)) << 8)
#define FLOAT2FIXED(x) (((int)((x)*4096.0f + .5f)) << 8)
void stbi__YCbCr_to_RGB_row(unsigned char *out, const unsigned char *y,
const unsigned char *pcb, const unsigned char *pcr,
@ -45,9 +45,9 @@ void stbi__YCbCr_to_RGB_row(unsigned char *out, const unsigned char *y,
g = y_fixed + (cr * -FLOAT2FIXED(0.71414f)) +
((cb * -FLOAT2FIXED(0.34414f)) & 0xffff0000);
b = y_fixed + cb * FLOAT2FIXED(1.77200f);
r /= 1048576;
g /= 1048576;
b /= 1048576;
r >>= 20;
g >>= 20;
b >>= 20;
b4[0] = MIN(255, MAX(0, r));
b4[1] = MIN(255, MAX(0, g));
b4[2] = MIN(255, MAX(0, b));