News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

colored ASCII

Started by sydetys, October 05, 2008, 09:14:53 PM

Previous topic - Next topic

sydetys

Hi!

I have searched from everywhere and I don´t find any tutorials how to make colored ASCII text in Vista console window.

print chr$() can´t handle that, and I found one example for MS DOS, but program crashes everytime I at the line where reads

     int 10

and that means code won´t work.
at MSDN I found example ONLY for windows GUI

are these valid 16bit colors?:

0000b = black
0001b = blue
0010b = green
0011b = cyan
0100b = red
0101b = magenta
0110b = brown
0111b = grey
1000b = dark grey
1001b = light blue
1010b = light green
1011b = light cyan
1100b = light red
1101b = light magneta
1110b = light brown (looks yellow-ish)
1111b = white

any links where would be more recent info about colors?

GregL

See this post HOW to set background and text colour using masm32?ANY suggestion?

From about a month ago.

BTW: You can't use DOS interrupts in 32/64-bit Windows programs.


sydetys

ooh, thanks, it was too easy...to figure out things from MSDN library has been made too hard...or it´s because I´m finnish, or I´m just getting desperate with this obviously easy thing.

...BTW about interrupts, can you give a link to site which holds latest 32 and 64bit interrupts?


thank you

BlackVortex

Quote from: sydetys on October 05, 2008, 10:18:50 PM
ooh, thanks, it was too easy...to figure out things from MSDN library has been made too hard...or it´s because I´m finnish, or I´m just getting desperate with this obviously easy thing.

...BTW about interrupts, can you give a link to site which holds latest 32 and 64bit interrupts?


thank you
Windows programming is based on APIs and libraries, not interrupts. Search for tutorials !

herge


Hi sydetys:

Try this:


; TEXTCOL.ASM 9:12:44 PM Saturday, September 13, 2008
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
    include \masm32\include\masm32rt.inc
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
    .data
    first dd 0
    num   dd 0
    public sZNum
    sZNum db 20 dup(?),0
    db 0
    CRLF    db 13,10
    db 0
    .code
start proc
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««


; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««


    mov     eax, 255
    mov     ebx, 1
    mov     ecx, 254
StartA:
    push    eax
    push    ebx
    push    ecx
    mov     first, eax    
    invoke SetTextColor, eax, ebx
    print "XXXXXXX "
    .if first == 8
    invoke SetTextColor, 15, 1
    .endif
    invoke crt__ultoa, first, addr sZNum, 10
    invoke StdOut, addr sZNum
    print " "
    invoke crt__ultoa, ebx, addr sZNum, 10
    invoke StdOut, addr sZNum
    invoke SetTextColor, 7, 0
    invoke StdOut, addr CRLF
    inc     num
    cmp     num, 16
    jnz     @F
    mov     num,0
    invoke crt__ultoa, ebx, addr sZNum, 10
    invoke SetTextColor, 15, 1
    inkey
@@:
    pop     ecx
    pop     ebx
    pop     eax
    dec     eax
    inc     ebx
    dec     ecx
    jnz     StartA
    invoke SetTextColor, 7, 0
    inkey
    exit
start endp

; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
SetTextColor proc fore:DWORD,back:DWORD

    LOCAL hStdOut:DWORD
    invoke GetStdHandle,STD_OUTPUT_HANDLE
    mov   hStdOut,eax
    mov   eax,back
    shl   eax,4
    or    eax,fore
    invoke SetConsoleTextAttribute,hStdOut,eax
    ret
SetTextColor endp

; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
end start



regards herge
// Herge born  Brussels, Belgium May 22, 1907
// Died March 3, 1983
// Cartoonist of Tintin and Snowy