diff options
author | Kartik Agaram <vc@akkartik.com> | 2021-01-12 21:51:46 -0800 |
---|---|---|
committer | Kartik Agaram <vc@akkartik.com> | 2021-01-12 21:51:46 -0800 |
commit | c5e617f5cc769c96fbb30083c4280e9acc22e5b3 (patch) | |
tree | 838aefe4ed787945910688bb6ab34de1956bd703 /baremetal | |
parent | e59086e65a204740da5ba1cf6a70c262bfc03b69 (diff) | |
download | mu-c5e617f5cc769c96fbb30083c4280e9acc22e5b3.tar.gz |
7504
Diffstat (limited to 'baremetal')
-rw-r--r-- | baremetal/vga_palette.c | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/baremetal/vga_palette.c b/baremetal/vga_palette.c index 11a440ce..9f4161ce 100644 --- a/baremetal/vga_palette.c +++ b/baremetal/vga_palette.c @@ -7,20 +7,31 @@ #include <assert.h> char* bar(int n) { - char* result = calloc(65, 1); + char* result = calloc(1024, 32); int i; + strcat(result, "<div style='float:left; width:40em'>"); for (i = 0; i < n; ++i) - result[i] = '.'; - for (; i < 64; ++i) - result[i] = ' '; - result[64] = '\0'; +//? result[i] = '.'; + strcat(result, "■"); /* black square */ +//? for (; i < 64; ++i) +//? result[i] = ' '; +//? result[64] = '\0'; + strcat(result, " </div>"); /* make sure the div occupies space */ return result; } +/* convert 6-bit color to 8-bit color */ +int levelUp(int n) { + assert(n < 64); + /* duplicate two most significant bits in two least significant bits */ + return (n<<2) | (n>>4); +} + void addColor(int r, int g, int b) { static int i = 0; //? printf("%02x %02x %02x\n", r, g, b); - printf("%3d: %2d %2d %2d %s %s %s\n", i, r, g, b, bar(r), bar(g), bar(b)); +//? printf("%3d: %2d %2d %2d %s %s %s\n", i, r, g, b, bar(r), bar(g), bar(b)); + printf("<div style='clear:both; white-space:pre; color:#%02x%02x%02x'><div style='float:left; margin-right:1em'>%03d: %02d %02d %02d</div> %s %s %s</div>\n", levelUp(r), levelUp(g), levelUp(b), i, r, g, b, bar(r), bar(g), bar(b)); ++i; } |