News:

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

cls bug

Started by oex, August 07, 2010, 08:56:00 AM

Previous topic - Next topic

oex

If I'm not mistaken there is a bug with cls (console clearscreen proc) indicated below....

    invoke GetConsoleScreenBufferInfo,hOutPut,ADDR sbi
    mov eax, sbi.dwSize     ; 2 word values returned for screen size

    push ax
    rol eax, 16
    mov cx, ax
    pop ax
    mul cx
    cwde                <---- It's not enough to change the resolution after the multiply
    mov cnt, eax

    invoke FillConsoleOutputCharacter,hOutPut,32,cnt,NULL,ADDR noc

maybe something like:

movzx eax, sbi.dwSize.x
movzx ecx, sbi.dwSize.y
imul ecx
mov cnt, eax

Consider the case 150 x 5000 = 750,000
We are all of us insane, just to varying degrees and intelligently balanced through networking

http://www.hereford.tv

Neil

Here is the slightly modified proc I've used for the past couple of years :-

SetScreenColor proc fore:DWORD,back:DWORD

    LOCAL noc    :DWORD
    LOCAL cnt    :DWORD
    LOCAL sbi    :CONSOLE_SCREEN_BUFFER_INFO

    invoke GetConsoleScreenBufferInfo,hConsoleOutput,ADDR sbi
    mov eax,sbi.dwSize
    push ax
    rol eax,16
    mov cx,ax
    pop ax
    mul cx
    cwde
    mov cnt,eax
    mov edx,back
    shl edx,4
    or  edx,fore
    invoke FillConsoleOutputAttribute,hConsoleOutput,edx,cnt,NULL,ADDR noc
    ret

SetScreenColor endp

you are probably right about the bug, but only if the console is of a huge maybe impracticable size.

oex

Quote from: Neil on August 07, 2010, 04:28:12 PM
you are probably right about the bug, but only if the console is of a huge maybe impracticable size.

Yeah I guess it just depends on how you use it.... I do most of my testing in console and a big area is better than hitting lots of keys to continue :lol
We are all of us insane, just to varying degrees and intelligently balanced through networking

http://www.hereford.tv