BBS: Inland Empire Archive Date: 04-19-92 (00:12) Number: 189 From: DANIEL CORBIER Refer#: NONE To: MIKE MELAMED Recvd: NO Subj: Backround Conf: (2) Quik_Bas
MM>How do you get background of a certain spot 1,1 for MM>example? I know that to get forground, you should do this: MM>A=SCREEN(1,1,1):A=A AND 15 A AND 15 will not yield correct results for forground colors > 15. Use the following: Attribute = SCREEN(1,1,1) ----------------------------------------------------------- Forground = (Attribute AND 15) + (Attribute AND 128) \ 8 Background = (Attribute AND 112) \ 16 ----------------------------------------------------------- The '\' instead of '/' is for integer division. Let me try to elucidate what is going on. The color attribute is stored in an 8-bit pattern as follows: (each X is 0 or 1) 7 6 5 4 3 2 1 0 X X X X X X X X _ ___________________ _ ___________________ | | | | Blinking | Intensity | | | | | Background Forground With that in mind, to get the BACKGROUND we do: X X X X X X X X 'Attribute AND 0 1 1 1 0 0 0 0 'background mask (binary for 112) ------------------------- 0 X X X 0 0 0 0 Div by 2^4 'Moves result over 4 columns ========================= 0 0 0 0 0 X X X 'Background color For the FORGROUND: X X X X X X X X 'Attribute AND 0 0 0 0 1 1 1 1 'Forground & intensity mask (15) ------------------------- 0 0 0 0 X X X X 'Part one Add to that: X X X X X X X X 'Attribute AND 1 0 0 0 0 0 0 0 'blinking mask (&b10000000 = 128) ------------------------- X 0 0 0 0 0 0 0 Div by 2^3 'Move it over 3 columns ------------------------- 0 0 0 X 0 0 0 0 'Part two Which gives us the final forground operation: 0 0 0 0 X X X X 'Part one Add 0 0 0 X 0 0 0 0 'Part two ======================== 0 0 0 X X X X X 'Forground color --- Maximus 2.00 * Origin: Telcom Central (1:135/23)
Books at Amazon:
Back to BASIC: The History, Corruption, and Future of the Language
Hackers: Heroes of the Computer Revolution (including Tiny BASIC)
Go to: The Story of the Math Majors, Bridge Players, Engineers, Chess Wizards, Scientists and Iconoclasts who were the Hero Programmers of the Software Revolution
The Advent of the Algorithm: The Idea that Rules the World
Moths in the Machine: The Power and Perils of Programming
Mastering Visual Basic .NET