First of all, there is no foreground black, aka color 0. You can use LORD code `^, which sets the foreground color to 16, which will technically be black, but this is not correct. It will be black, sure, but it will also enable blinking text. So if you have a background other than black, you'll see the characters on it, and they will in fact be blinking.
In the Turbo Pascal TextColor function, anything over color 15 will set the blinking bit. 15 or less (aka the standard 16 DOS colors) resets the bit to 0. I'm not exactly sure why Borland chose to do it this way, since the blinking bit is actually at the end of the background color nibble of the text attribute byte in video memory. The bits are broken up as: bBBBFFFF, where b is blink, BBB is background, and FFFF is foreground. The TextBackground function only seems to accept 0..7 according to the help, though, so I'm doubting that blink can be enabled from it. It would make more sense from a technical standpoint to let you set the flashing bit that way, by setting the background color higher than 7 as you would directly into memory. Maybe they thought it would be confusing to people, since the foreground characters are what blink when it's enabled, so they figured all foreground-related stuff should be together? Something I wonder about though is whether Turbo Pascal can actually accept higher than 8 colors for the background, because EGA and up lets you disable blinking in the hardware in order to use the last bit to enable a full 16 colors for the background like the foreground can do. If TextBackground limits the value, you'd have to use a roundabout method of setting the extended background color when in that mode.
Anyway, the second LORD thing is regarding color 12. In this local printing function, for some reason the `@ LORD code translates to color 9, which `9 also does. Maybe since this local print function isn't used for a whole lot of stuff other than during startup, he just never noticed.
Next is something the background colors. For that you use `rX, where X is the background color. This time we do have a 0 for black. But we also have an 8. As mentioned above, though, this might not be possible and simply display black like with 0. Then again, maybe it displays black and enables blinking? No way to find out unless I wrote a test program in Pascal itself.
Next is something the background colors. For that you use `rX, where X is the background color. This time we do have a 0 for black. But we also have an 8. As mentioned above, though, this might not be possible and simply display black like with 0. Then again, maybe it displays black and enables blinking? No way to find out unless I wrote a test program in Pascal itself.
Related to the above is an oddity. Apparently Seth tried to implement setting the background color twice, probably as an oversight. The first time uses a bunch of comparison checks for each ASCII number value. The second one though works differently; it actually makes a short string of the value, and uses the Turbo Pascal "Val" function to convert it into a number, and then sets the background color. This would let you set 0..9, even.
But here's the thing: that second iteration will never get called normally. Because of the way the comparison checks work, after the first test for `r, the string position variable is incremented in order to get the background digit. By the time it reaches the other comparison check for `r, the current character won't be `r anymore, it'll be the position of the digit, so the comparison never matches. BUT, it can happen, I suppose, if you use an invalid LORD code. For example, `rr4 would trigger it. This can't be tested in the game itself, though, because all of the editable content (LORDTXT.DAT etc) go through a different color code parsing function.
You can look at the source code to Barak's House to find its local color-setting function which has this exactly same "bug."
On a side note, looking through Barak's House is actually fun, because I can see the original (and sometimes much more simple) Pascal code of some of the same functions I spent the time disassembling and figuring out in LORD.
I guess that's it. A lot of rambling about some simple color stuff!
No comments:
Post a Comment