1. background colors
- Posted by "Cuny, David" <ATB.DCUNY at HW1.CAHWNET.GOV> Mar 14, 1997
- 1343 views
I'm trying to get the Text-GUI to support VGA mode, and am having a *lot* of trouble working out how to get the background color to work. When I do a call to bk_color(), it changes the text background color of *all* the text that has been displayed. This obviously will not work for me, since I need a lot of different background colors on the screen at the same time. For example, something like the following: -- CODE BEGINS HERE ------------------------------------------------------ -- VGA mode integer result result = graphics_mode(18) -- red text on white background bk_color( WHITE ) text_color( RED ) puts( 1, "This is line 1\n" ) -- white text on red background bk_color( RED ) text_color( WHITE ) puts( 1, "This is line 2\n" ) --- CODE ENDS HERE -------------------------------------------------------- will *not* work. I think this is because screen writes use the attributes {text_color, bk_color}, and the redefinition of bk_color just changes the pallette of the background color. What I *really* want to do is write a different background attribute number to the screen, not attribute zero. That way, I can hopefully get around the problem of bk_color() redefining BLACK's pallette. Is there a simple way that I can display text on the screen in graphics mode 18 that either (1) allows me to use multiple background colors, or (2) uses the color that is already displayed in the background? I've finally resorted to an interrupt, but the routine has problems: -- CODE BEGINS HERE ------------------------------------------------------ procedure display( integer row, integer col, integer color, sequence char ) object lowMem sequence inReg, outReg, cursor lowMem = allocate_low( length( char ) ) -- get memory poke( lowMem, char ) -- move description to memory inReg = repeat( 0, 10 ) -- initialize register list inReg[REG_AX] = #1301 -- tty string write inReg[REG_BX] = #F0 + color -- video page/color inReg[REG_CX] = length(char) -- number of characters to print inReg[REG_DX] = row*#100+col -- position of cursor inReg[REG_ES] = floor(lowMem / 16) -- segment of low_mem (low memory) inReg[REG_BP] = remainder(lowMem, 16) -- offset of low_mem outReg = dos_interrupt( #10, inReg ) -- bios call free_low( lowMem ) -- free the memory end procedure -- CODE ENDS HERE ------------------------------------------------------- Note that I set a bit high in high byte of BL (I forgot which one, so I set them all). If the bit is set to 0, the program will use the BLACK color (#0). By setting the bit, it ORs the colors with the background. Using this hack, I can display text that uses the underlying background color - but I have to specify the *inverse* of the color, relative to the background. This is a pain. I *think* I can re-write the code by setting AL to 3 or 4, and poking the string into memory as a { char, attribute } pair. Needless to say, I'm hoping that there is a much simpler way of going about this business. -- David Cuny