Change Colors

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
User avatar
Nathan
Member
Member
Posts: 201
Joined: Sun Jul 19, 2009 1:48 pm
Location: Brazil
Contact:

Change Colors

Post by Nathan »

Hello,
How i can change the colors of the text and background, because i can't see this in any tutorial, then i need to ask here, if it's needed, here is my code:

Code: Select all

[BITS 16]	     ; 16 bit code generation
[ORG 0x7C00]	 ; ORGin location is 7C00

JMP short main   ; Jump past disk description section
NOP              ; Pad out before disk description


; ------------------------------------------------------------------
; Disk description table, to make it a valid floppy
; Note: some of these values are hard-coded in the source!
; Values are those used by IBM for 1.44 MB, 3.5" diskette

OEMLabel            db "BERL OS"    ; Disk label - 8 chars
BytesPerSector      dw 512          ; Bytes per sector
SectorsPerCluster   db 1            ; Sectors per cluster
ReservedForBoot     dw 1            ; Reserved sectors for boot record
NumberOfFats        db 2            ; Number of copies of the FAT
RootDirEntries      dw 224          ; Number of entries in root dir
LogicalSectors      dw 2880         ; Number of logical sectors
MediumByte          db 0F0h         ; Medium descriptor byte
SectorsPerFat       dw 9            ; Sectors per FAT
SectorsPerTrack     dw 18           ; Sectors per track (36/cylinder)
Sides               dw 2            ; Number of sides/heads
HiddenSectors       dd 0            ; Number of hidden sectors
LargeSectors        dd 0            ; Number of LBA sectors
DriveNo             dw 0            ; Drive No: 0
Signature           db 41           ; Drive signature: 41 for floppy
VolumeID            dd 00000000h    ; Volume ID: any number
VolumeLabel         db "BERL OS"    ; Volume Label: any 11 chars
FileSystem          db "FAT12"      ; File system type: don't change!

main:
MOV BH, 00h
MOV BL, 07h
MOV AL, 1
MOV BH, 0
MOV BL, 0011_1011b
MOV CX, osmsgend - os_msg           ; calculate message size. 
MOV DL, 30
MOV DH, 0
PUSH CS
POP ES
MOV BP, os_msg
MOV AH, 13h
INT 10h
JMP wel

wel:
MOV BH, 00h
MOV BL, 07h
MOV AL, 1
MOV BH, 0
MOV BL, 0011_1011b 
MOV CX, welcome_end - welcome       ; calculate message size. 
MOV DL, 32
MOV DH, 2
PUSH CS
POP ES
MOV BP, welcome
MOV AH, 13h
INT 10h
JMP osmsgend
                         
welcome DB "Welcome !"
welcome_end:
                         
os_msg DB "BerlOS v0.0.1"
osmsgend:
JMP $

; Boot things
TIMES 510-($-$$) DB 0	            ; Fill the rest of the sector with zeros
DW 0xAA55		                    ; Boot signature
Thanks,
Nathan Paulino Campos
User avatar
gravaera
Member
Member
Posts: 737
Joined: Tue Jun 02, 2009 4:35 pm
Location: Supporting the cause: Use \tabs to indent code. NOT \x20 spaces.

Re: Change Colors

Post by gravaera »

17:56 < sortie> Paging is called paging because you need to draw it on pages in your notebook to succeed at it.
User avatar
neon
Member
Member
Posts: 1567
Joined: Sun Feb 18, 2007 7:28 pm
Contact:

Re: Change Colors

Post by neon »

Hello,

Int 0x10 function 9

Keep in mind that this will not update the cursor position, nor handle the newline/carriage return characters as expected. Because of this, you need to handle them yourself.

Setting cursor position
Getting cursor position

I can provide example code from my system, but its in C. In any case, it shouldn't be that hard to do in assembly.

(Also, alot of your posts are not OS development related. This might be better posted in the General Programming board..)
OS Development Series | Wiki | os | ncc
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}
User avatar
Nathan
Member
Member
Posts: 201
Joined: Sun Jul 19, 2009 1:48 pm
Location: Brazil
Contact:

Re: Change Colors

Post by Nathan »

Thanks for the resources neon!
Only one more thing. Before i start learning Assembly, i read your tutorial of Bootloaders, because of this i start learning Assembly!

Thanks!
User avatar
Nathan
Member
Member
Posts: 201
Joined: Sun Jul 19, 2009 1:48 pm
Location: Brazil
Contact:

Re: Change Colors

Post by Nathan »

The line that i have to change is:

Code: Select all

MOV BL, color here
Now it is working, thanks because of the resources!
Post Reply