background colours in dos progs 
Author Message
 background colours in dos progs

Quote:
> I am writing hardware test progs for dos (Early stages) and I can't find
> any info on reliably setting the background and text colours in dos using
> assembler. Anybody able to help? (Interrupt service/regs to set/values to
> use etc.)

text or graphics mode?

fg



Thu, 10 Jan 2002 03:00:00 GMT  
 background colours in dos progs
I am writing hardware test progs for dos (Early stages) and I can't find
any info on reliably setting the background and text colours in dos using
assembler. Anybody able to help? (Interrupt service/regs to set/values to
use etc.)

Scott Phillips.



Thu, 10 Jan 2002 03:00:00 GMT  
 background colours in dos progs
Not sure, probably text, I want to have a similar interface to
Norton's DOS stuff, rather than my present black screen gear.



Quote:
>> I am writing hardware test progs for dos (Early stages) and I can't find
>> any info on reliably setting the background and text colours in dos using
>> assembler. Anybody able to help? (Interrupt service/regs to set/values to
>> use etc.)

>text or graphics mode?

>fg



Thu, 10 Jan 2002 03:00:00 GMT  
 background colours in dos progs


   >I am writing hardware test progs for dos (Early stages) and I can't
   >find any info on reliably setting the background and text colours
   >in dos using assembler. Anybody able to help? (Interrupt
   >service/regs to set/values to use etc.)
   >Scott Phillips.

Consider using ANSI sequences.  It's a quick and relatively easy
way to set the colors, and -- unlike some other color-setting
methods -- the colors "stick."  Almost every DOS-based computer
will have an ANSI driver loaded...but for those few that don't,
your program could first check for the presence of an ANSI driver.

Here's some code for a stand-alone DOS-executable ANSI checker,
written for the A86 compiler.  You can extract whatever snippets
you might need.

;
; CHK4ANSI.ASM
; Determine If An ANSI Driver Is Present
; Freeware from Kirk Lawrence
;
code    segment                 ;start of code segment
        org     100h            ;leave room for base page
        jmp     start           ;go get to the good stuff
;
save    dw      0               ;storage variable for cursor position
ansi    db      27,'[25;80H$'   ;ANSI sequence to set cursor position
back    db      13,'         $' ;screen erase sequence
yes     db      13,10,' An ANSI-compatible driver is installed.',13,10,'$'
no      db      13,10,' An ANSI-compatible driver is NOT installed.',13,10,'$'
;
start:
        mov     ah,3            ;function 3 - get cursor position
        mov     bh,0            ;assume page 0
        int     10h             ;call BIOS video services
        mov     save,dx         ;store result in variable
        mov     dx,offset ansi  ;point to ANSI test string
        mov     ah,9            ;function 9 - print string
        int     21h             ;call DOS services
        mov     ah,3            ;read cursor position again
        mov     bh,0            ;page 0
        int     10h             ;call BIOS video services
        cmp     dx,184Fh        ;is cursor at row 25, column 80?
        jnz     nope            ;no, go say 'no ANSI'
        call    restore         ;go restore former cursor position
        mov     dx,offset yes   ;point to 'yes' message
        jmp     exit            ;go exit
nope:
        mov     ah,9            ;function 9 - print string
        mov     dx,offset back  ;point DX to screen erase sequence
        int     21h             ;call DOS services
        mov     dx,offset no    ;point to 'no' message
        jmp     exit            ;go exit
restore:
        mov     dx,save         ;restore original position from variable
        mov     ah,2            ;function 2 - restore cursor position
        mov     bh,0            ;page 0
        int     10h             ;call BIOS video services
        ret                     ;return
exit:
        mov     ah,9            ;function 9 - print string
        int     21h             ;call DOS services
        int     20h             ;exit to DOS
end

.....................................................................
Return address is mangled to foil spambots. Remove all "g"s to e-mail.

Net-Tamer V 1.08X - Test Drive



Thu, 10 Jan 2002 03:00:00 GMT  
 background colours in dos progs
You know I would suggest accessing video memory directly...
I think that's what norton does(not sure)
B8000
has a fomat of 1 byte char 1 byte color...
hope this helps.

Quote:


>   >I am writing hardware test progs for dos (Early stages) and I can't
>   >find any info on reliably setting the background and text colours
>   >in dos using assembler. Anybody able to help? (Interrupt
>   >service/regs to set/values to use etc.)
>   >Scott Phillips.

>Consider using ANSI sequences.  It's a quick and relatively easy
>way to set the colors, and -- unlike some other color-setting
>methods -- the colors "stick."  Almost every DOS-based computer
>will have an ANSI driver loaded...but for those few that don't,
>your program could first check for the presence of an ANSI driver.

>Here's some code for a stand-alone DOS-executable ANSI checker,
>written for the A86 compiler.  You can extract whatever snippets
>you might need.

>;
>; CHK4ANSI.ASM
>; Determine If An ANSI Driver Is Present
>; Freeware from Kirk Lawrence
>;
>code    segment                 ;start of code segment
>        org     100h            ;leave room for base page
>        jmp     start           ;go get to the good stuff
>;
>save    dw      0               ;storage variable for cursor position
>ansi    db      27,'[25;80H$'   ;ANSI sequence to set cursor position
>back    db      13,'         $' ;screen erase sequence
>yes     db      13,10,' An ANSI-compatible driver is installed.',13,10,'$'
>no      db      13,10,' An ANSI-compatible driver is NOT

installed.',13,10,'$'

- Show quoted text -

Quote:
>;
>start:
>        mov     ah,3            ;function 3 - get cursor position
>        mov     bh,0            ;assume page 0
>        int     10h             ;call BIOS video services
>        mov     save,dx         ;store result in variable
>        mov     dx,offset ansi  ;point to ANSI test string
>        mov     ah,9            ;function 9 - print string
>        int     21h             ;call DOS services
>        mov     ah,3            ;read cursor position again
>        mov     bh,0            ;page 0
>        int     10h             ;call BIOS video services
>        cmp     dx,184Fh        ;is cursor at row 25, column 80?
>        jnz     nope            ;no, go say 'no ANSI'
>        call    restore         ;go restore former cursor position
>        mov     dx,offset yes   ;point to 'yes' message
>        jmp     exit            ;go exit
>nope:
>        mov     ah,9            ;function 9 - print string
>        mov     dx,offset back  ;point DX to screen erase sequence
>        int     21h             ;call DOS services
>        mov     dx,offset no    ;point to 'no' message
>        jmp     exit            ;go exit
>restore:
>        mov     dx,save         ;restore original position from variable
>        mov     ah,2            ;function 2 - restore cursor position
>        mov     bh,0            ;page 0
>        int     10h             ;call BIOS video services
>        ret                     ;return
>exit:
>        mov     ah,9            ;function 9 - print string
>        int     21h             ;call DOS services
>        int     20h             ;exit to DOS
>end

>.....................................................................
>Return address is mangled to foil spambots. Remove all "g"s to e-mail.

>Net-Tamer V 1.08X - Test Drive



Thu, 10 Jan 2002 03:00:00 GMT  
 background colours in dos progs

Quote:
> Not sure, probably text, I want to have a similar interface to
> Norton's DOS stuff, rather than my present black screen gear.

then you're in text mode, most probably (bios mode 3h, 80x25
characters, 16 colours)

i would suggest you accessing the screen directly without the
BIOS or DOS or anything... this is by no means incompatible, the
way to do this hasn't changed since the CGA, and it's much faster
than other methods ever can be.

the segment in which the screen data is stored (in text mode) is
0b800h. you have to write your values there. the layout is like
the following

  db  char     ; ascii code of character you want to display
  db  color    ; code of the color the character should be displayed with

(and this repeated as often as there are characters on the
screen, i.e. 2000 times for 80x25 screen mode).

  the layout for the color byte (bitwise) is like follows:

bit  7    6    5    4    3    2    1    0
   +----+----+----+----+----+----+----+----+
   | BL | BR | BG | BB | IN | FR | FG | FB |
   +----+----+----+----+----+----+----+----+

with the following meanings:
  FB=Foreground Blue (if set, it means a blue intensity level of 2/3)
  FG=Foreground Green (if set, it means a green intensity level of 2/3)
  FB=Foregorund Red (red intensity level=2/3)
  IN=Intensity Bit, if set, it adds 1/3 to all of the foreground color components
  BB=Background Blue  \
  BG=Background Green  > these have the same meanings as the foreground bits
  BR=Background Red   /
  BL=Blink Bit, if set the Characters blink
  (you can swith the blink bit off, then you get a intensity bit for the
   background, which is also useful).

hope this is enough, if you still have problems, ask me...

Fabian Giesen
ryg/teklords



Fri, 11 Jan 2002 03:00:00 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. getting the forground and background colours of a window (widget)

2. Background Colours

3. Text, Tags and background colours.

4. default background colours (option add?)

5. Help with foreground/background colours

6. Codepage Trouble with clipper-progs that working in a Dos-Box-Window

7. Executing DOS progs under forth

8. Executing DOS progs under forth

9. Executing DOS progs under Forth

10. Executing DOS progs under forth

11. Debugger that can debug P-mode DOS progs

12. Debugger that can debug P-mode DOS progs

 

 
Powered by phpBB® Forum Software