I'm writing a console app and looking for the best way to clear the screen (like the 16b INT 0x10 w/ AX=0x0700) and how to INKEY (like the 16b INT 0x16 w/ AH=0)

Any suggestions / code snippet will be much appreicated.

Thanks
Posted on 2001-10-21 17:18:50 by eet_1024
masm32.lib has a function in for clearing the screen, look up that.
As for character inputs, i have never been able to get that to work, so i cant help you sorry.
Posted on 2001-10-21 22:26:01 by huh
huh,
do you have the source of that proc? I've looked up and down the web for anything about console apps and have found very little.

Thanks
Posted on 2001-10-22 00:46:26 by eet_1024
It works like reading and writing to a file. You grab the handle to standard input/output/error and then you do reading and writing. Not sure about a clear screen because the size of the screen buffer can be changed - maybe there is a clear screen character? I haven't seen any console apps that clear screen?
Hutch's STDIN:
StdIn proc lpszBuffer:DWORD,bLen:DWORD


LOCAL hInput :DWORD
LOCAL bRead :DWORD

invoke GetStdHandle,STD_INPUT_HANDLE
mov hInput, eax

invoke SetConsoleMode,hInput,ENABLE_LINE_INPUT or \
ENABLE_ECHO_INPUT or \
ENABLE_PROCESSED_INPUT

invoke ReadFile,hInput,lpszBuffer,bLen,ADDR bRead,NULL

mov eax, bRead

ret

StdIn endp
Posted on 2001-10-22 01:01:30 by bitRAKE
From \masm32\m32lib\clearscr.asm



; #########################################################################

.386
.model flat, stdcall
option casemap :none ; case sensitive

include \masm32\include\windows.inc

include \masm32\include\user32.inc
include \masm32\include\kernel32.inc
include \masm32\include\masm32.inc

.code

; #########################################################################

ClearScreen proc

; -----------------------------------------------------------
; This procedure reads the column and row count, multiplies
; them together to get the number of characters that will fit
; onto the screen, writes that number of blank spaces to the
; screen and reposition the prompt at position 0,0.
; -----------------------------------------------------------

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

invoke GetStdHandle,STD_OUTPUT_HANDLE
mov hOutPut, eax

invoke GetConsoleScreenBufferInfo,hOutPut,ADDR sbi

mov eax, sbi.dwSize ; 2 word values returned for screen size

; -----------------------------------------------
; extract the 2 values and multiply them together
; -----------------------------------------------
push ax
rol eax, 16
mov cx, ax
pop ax
mul cx
cwde
mov cnt, eax

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

invoke locate,0,0

ret

ClearScreen endp

; #########################################################################

end
Posted on 2001-10-22 02:57:41 by huh
Thanks huh for the help. Since my screen size will be 25x80, I'll continue using:
    stdcall [FillAttr], [StdOut], 0x0F, 2000, 0, Bytes.Tx

stdcall [FillChar], [StdOut], 0x00, 2000, 0, Bytes.Tx
stdcall [Locate], [StdOut], 0


bitRAKE,
I know how to read a line in, but I want to pull a single character in; like the Q/GWBASIC $INKEY function. How does the C(++) getchar work?

p.s. My console apps with a UI CLS.
Posted on 2001-10-22 22:45:28 by eet_1024
eet_1024,
use ReadConsoleInput or PeekConsoleInput to read 1 character from console.

japheth
Posted on 2001-10-23 03:14:20 by japheth
I was hoping not too, but it looks like the only way. Should I define 32 dwords to cover the unions?
Posted on 2001-10-23 23:16:12 by eet_1024