Subj : Color parsing
To : echicken
From : Kirkman
Date : Sun Dec 03 2017 02:36 pm
Re: Color parsing
By: echicken to Kirkman on Sun Dec 03 2017 03:28 pm
ec> The foreground colour is in the lower three bits of the byte.
ec> var fg = attr&7; // 7 is essentially (1<<0)|(1<<1)|(1<<2)
Wow, that was fast! Thanks, echicken.
I was looking around online and experimenting with a bitwise calculator, and I
ended up doing something like this:
// Use bitwise AND with a mask to get the four rightmost bits.
// dec 15 | bin 00001111 | hex 0xf
var fg = theAttr & 15;
// Use bitwise AND with a mask to get the four leftmost bits.
// dec 240 | bin 11110000 | hex 0xf0
var bg = theAttr & 240;
I think it's working, but I have other issues in my code to sort out before I
can say 100%.
Then I'm doing fg = fg & 7 to change high colors into low equivalents.
--Josh
////--------------------------------------------------
BiC -=-
http://breakintochat.com -=- bbs wiki and blog
---
� Synchronet