flat assembler
Message board for the users of flat assembler.
Index
> OS Construction > most efficient way of change background color in textmode? |
Author |
|
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 |
|||
15 Mar 2006, 15:47 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.