Search code examples
assemblyscreenmasmirvine32

Clears the screen faster in assemly


I have problem with clearing the screen.

I was using call Clrscr but its slow. It is not fast enough, so i have screen, black, with no figure, because of waiting on function Clrscr to finish.

    call Clrscr

  ; Write a string to the console:
    INVOKE WriteConsole,
        consoleHandle,              ;console output handle
        ADDR HANGMAN_GOODGAME_00,               ; string pointer
        messageSizeGoodGame,                ; string length
        ADDR bytesWritten,          ; returns num bytes written
        0                           ; not used

    mov eax, drowDelay
    call Delay
    call Clrscr

  ; Write a string to the console:
    INVOKE WriteConsole,
        consoleHandle,              ;console output handle
        ADDR HANGMAN_GOODGAME_01,               ; string pointer
        messageSizeGoodGame,                ; string length
        ADDR bytesWritten,          ; returns num bytes written
        0                           ; not used

    mov eax, drowDelay
    call Delay
    call Clrscr

  ........

This is photo. How Its look without slearing. I am trying to make animation..:)

enter image description here


Solution

  • You can just set cursor position.
    Just use setcursorpos from winapi:

    push 0
    push 0
    call [SetCursorPos]
    

    Its in the user32.dll

    Edit: the way it wokrs is simple, you set the cursor position to the top left corner making the feel of movement