flat assembler
Message board for the users of flat assembler.

Index > OS Construction > most efficient way of change background color in textmode?

Author
Thread Post new topic Reply to topic
MAD_DËMON



Joined: 03 Mar 2006
Posts: 23
MAD_DËMON 14 Mar 2006, 19:40
if it is the way of change the background color int text mode that I have found

INT 10 - VIDEO - SET BACKGROUND/BORDER COLOR
AH = 0Bh
BH = 00h
BL = background/border color (border only in text modes)
Return: nothing
SeeAlso: AH=0Bh/BH=01h

then i tried to do this in debug to see how it works

Code:
mov ah,0xb
mov bh,0
mov bl,0x70
int 0x10    


but it doesn't change the bg color, the docs that i have doesn't specify the format of the value that is passed to BL

_________________
Tah rah rah boom de ay, I blew some guy away, his brains turned into spray, I was paid well that day
Post 14 Mar 2006, 19:40
View user's profile Send private message Visit poster's website Reply with quote
doubletoker



Joined: 15 Mar 2005
Posts: 4
doubletoker 15 Mar 2006, 15:47
I signed up for this board a long time never came back till now, anyway, that's besides the point, I don't know if there is a better way, but for text color mode, the address in memory for the video buffer is at B8000h and the buffer is an array of words, the high byte being the backcolor and forecolor and the low byte being the character for the screen. The high nibble of the high byte is the backcolor and the low nibble is the forecolor. since you got 80x25 I'm guessing, it would be comprised of 2000 words aka 4000 bytes. the colors for the nibbles are gonna be below in the code I'm gonna post. basicly you would have to know where the last word is (2000 * 2) - 2 and either count up or down and change the back color, a good AND will null the backcolor and OR will write the back color anyway here's the code

Code:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Input: SI = Color        ;;
;; Colors:                  ;;
;;         0 black          ;;
;;         1 blue           ;;
;;         2 green          ;;
;;         3 cyan           ;;
;;         4 red            ;;
;;         5 magenta        ;;
;;         6 brown          ;;
;;         7 light gray     ;;
;;         8 dark gray      ;;
;;         9 light blue     ;;
;;         10 light green   ;;
;;         11 light cyan    ;;
;;         12 light red     ;;
;;         13 light magenta ;;
;;         14 light brown   ;;
;;         15 white         ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
ChangeBackground:
  ;; save data segment
  push ds
  ;; save the regs not sure if you need them
  pushaw
  ;; setup the segment
  mov ax, 0B800h
  mov ds, ax
  ;; last byte of video buffer for 80x25
  mov di, 3998
  ;; shift color to backcolor in high nibble of the high byte
  shl si, 12
 @@:
  ;; null the backcolor, high nibble of high byte
  and word [di], 0FFFh
  ;; set the backcolor
  or word [ds:di], si
  ;; decrease di by 2, point to next word in array
  sub di, 2
  ;; jump if not signed, greater then or equal to zero to @@
  jns @r
  ;; restore previous register values
  popaw
  ;; restore data segment
  pop ds
  ret    


as for the int, I think the way it's read as you can only change the border color in text mode, which I think would be the low nibble of bl, I'm not sure how to use it, as I write my own graphic functions but might try it later, I did test this code and it works on 80x25 color text mode.

-pz
Post 15 Mar 2006, 15:47
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.