How to change a character's text and background color in video unit? lazarus / 21-General ---------------------------------------------------------------------- temp765485 · 2021-02-06 23:21 So I recently discovered and have been using the video standard unit because of its system independency. So far I have learnt how to display a single character using the VideoBuf array: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i uses video; begin InitVideo; VideoBuf^[0]:=Ord('D'); UpdateScreen(False); readln;  DoneVideo;end.The question is, how to display the character but with different text and background colors? I have seen the unit reference, but I think I need a more closely explanation of it. Any help will be very appreciated. ---------------------------------------------------------------------- Kays · 2021-02-07 00:25 Quote from: temp765485 on February 07, 2021, 12:21:54 am[…] I have seen the unit reference, […]You know, reading it helps. It’s everything there. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i videoBuf^[0] := ord('D') + (yellow + blue shl 4) shl 8;The background will be blue, the letter (i.e. “foreground” color) yellow. Please take note of getCapabilities, i. e. you wanna first check colors are actually supported. If you’re related to the anonymous user throwaway34865, I’ll tell you right away you won’t be able to display non-ASCII characters using the video unit. ---------------------------------------------------------------------- temp765485 · 2021-02-07 00:57 Ohh I get it now. Thank you for the help. But can you at least tell me why do we need to shift 8 bits to the left at the end? I will look more into it later. And yes, the other account is me lol, so thanks again ---------------------------------------------------------------------- lucamar · 2021-02-07 04:02 Quote from: temp765485 on February 07, 2021, 01:57:00 am[...] can you at least tell me why do we need to shift 8 bits to the left at the end? I will look more into it later. Looking at it before might help you better The video buffer (of type TVideoBuf) is a TVideoCell (a Word) array, with each "cell" organized like the text screen, i.e. two bytes corresponding to the attribute (the color) and the character code, so to build it you need to get the attribute in the high byte and the char in the lower. The attribute byte itself is organized as two nibbles: the background and the foreground "colors", with the background including the "blink" bit ($80). In short, each word is: Code: [Select]x bbb ffff - cccccccc |  |    |       | |  |    |       \-- character code |  |    \-- foreground color/attribute |  \-- background color \-- blink bitso you build the "color" byte by shifting the back color left 4 bits and adding the fore color, then shift that byte left 8 bits to put it in the high byte and add the character code. Easy peasy ---------------------------------------------------------------------- Kays · 2021-02-07 13:34 Quote from: temp765485 on February 07, 2021, 01:57:00 am[…] shift 8 bits to the left at the end […]I’ve quickly drawn up a unit taking care of all those shl and placed it under https://wiki.freepascal.org/video_unit [To be precise, examining the generated code you’ll see there will be no shl anymore.]