TURBO PASCAL |
Новости
|
37: How can I set a hi- intensity color background in the text mode?A: As you should know, the you can test for a blinking text for example as follows. uses Crt; begin TextColor (11 + 128); (* or LightCyan + Blink *) TextBackground (Blue); writeln ('What''s the catch?'); (* An aside, note the '' pair *) end. In the above, bit 7 (the 128) controls the blinking. If you have at least an EGA, you can alter the interpretation of the highest text color bit to denote a hi-intensity background, but then you lose the the blinking. The following piece of code disables blinking, enabling a hi-intensity background. uses Dos; var regs : registers; begin FillChar (regs, SizeOf(regs), 0); (* An initialization precaution *) regs.ah := $10; (* Function $10 *) regs.al := $03; (* Subfunction $03 *) regs.bl := $00; Intr ($10, regs); (* ROM BIOS video driver interrupt *) end. To enable blinking again, set regs.bl := $01; Any high-intensity background you may have currently on the screen, will instantly change into a blinking text a a low-intensity background. A2: The previous answer assumes at least an EGA. Otherwise ports must be accessed. This is both advanced and dangerous programming, because errors in handling posts can do real harm. Besides it is fair to require at least an EGA in writing modern programs, at least for non-laptops, and on the latter the colors don't really matter for CGA and below. Let's take a look, nevertheless, how this is done for a CGA. Note that this won't work an an EGA and beyond, not at least in my tests. For detecting the video adapter you have, see the DetectGraph procedure in you Turbo Pascal manual. First we need some basics from MEMORY.LST in Ralf Brown's ftp://garbo.uwasa.fi/pc/programming/inter46b.zip (or whatever version is current): Format of BIOS Data Segment at segment 40h: 63h WORD Video CRT controller base address: color=03D4h, mono=03B4h 65h BYTE Video current setting of mode select register 03D8h/03B8h From David Jurgens's ftp://garbo.uwasa.fi/pc/programming/helppc21.zip we see 3D0-3DF Color Graphics Monitor Adapter (ports 3D0-3DB are write only, see 6845) 3D8 6845 Mode control register (CGA, EGA, VGA, except PCjr) From Darryl Friesen's (friesend@jester.usask.ca) in the late comp.lang.pascal we have, the following procedure, with my own added comments (* *). procedure SetBlinkState (state : boolean); var ModeRegPort : word; ModeReg : byte; begin Inline($FA); { CLI } (* Interrupts off *) ModeRegPort := MemW[$0040:$0063]+4; (* Typically $03D4+4 = $03D8 *) ModeReg := Mem[$0040:$0065]; (* Typically 1001 *) if state then (* Bit 5 controls blink enable *) ModeReg := ModeReg or $20 (* $20 = 00100000 (base2) *) else ModeReg := ModeReg and $DF; (* $DF = 11011111 disable *) Port[ModeRegPort] := ModeReg; (* Typically $9 = 00001001 *) Mem[$0040:$0065] := ModeReg; (* or $29 = 00101001 *) Inline($FB) { STI } (* Interrupts on *) end; |
(с)Все права защищены По всем интересующим вопросам прошу писать на электронный адрес |