News:

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

Calling API WriteConsoleOutput

Started by frktons, August 02, 2010, 10:31:27 PM

Previous topic - Next topic

frktons

Quote from: dedndave on August 17, 2010, 12:34:48 AM
you are using ANSI chars, so each cell should look like this...
character  db 'A',0         ;the 0 is a filler - if it were unicode, it would contain data
attributes dw Attrib        ;refer to the link below


http://msdn.microsoft.com/en-us/library/ms682013%28VS.85%29.aspx

i am trying to write some code   :P
if you make a new DAT file.....

So far this kind of file has worked with PBCC and C with WriteConsoleOutput.
I guess it can work with MASM as well. I think the second byte for char and attrib
is just ignored, if it contains zero or space it should not change.
Anyway if you want to try with a file with zero after each meaningful byte here
you are, attached  :P
Mind is like a parachute. You know what to do in order to use it :-)

dedndave

ok - well - one of them should fly   :U

frktons

Quote from: dedndave on August 17, 2010, 01:00:49 AM
ok - well - one of them should fly   :U

From my point of view the one with zeros will not fly  :P
Mind is like a parachute. You know what to do in order to use it :-)

dedndave

well - it has some goofy attribute values
here is my code, so far
it does the same thing as yours - lol
let me play some more.....

removed attachment - see later post for working version

dedndave

oops one mistake already...
ByteCount dd 4*BufLen                                   ;Bytes to read from input file

frktons

I think this code:

ByteCount dd 2*BufLen 


should be:

ByteCount dd 4*BufLen


each character on the screen (25*80) takes 4 bytes in the screen buffer
to display (2 for the char and 2 for the attribute). 
Mind is like a parachute. You know what to do in order to use it :-)

dedndave

lol - i think you're right, Frank   :bg

sinsi

2 changes:

        mov windowSize.Left, 0
        mov windowSize.Right, 79
        mov windowSize.Top, 0
        mov windowSize.Bottom, 24

left <> right


    invoke WriteConsoleOutput, wHnd, offset charArray, DWORD PTR bufferSize, DWORD PTR startPoint, offset windowSize

the COORD parameters are the actual values, not the address
Light travels faster than sound, that's why some people seem bright until you hear them.

frktons

Quote from: sinsi on August 17, 2010, 01:44:54 AM
2 changes:

        mov windowSize.Left, 0
        mov windowSize.Right, 79
        mov windowSize.Top, 0
        mov windowSize.Bottom, 24

left <> right


    invoke WriteConsoleOutput, wHnd, offset charArray, DWORD PTR bufferSize, DWORD PTR startPoint, offset windowSize

the COORD parameters are the actual values, not the address


Very well done, sinsi. Eventually I got my screen displayed.
Thanks a lot for your help.  :U

@dedndave:

could you explain to me how did you get an executable that is 1/3 of mine?
You declared the structure CHAR_INFO in the .data? section, this is one,
and what else?
Mind is like a parachute. You know what to do in order to use it :-)

dedndave

lol
i got it working, as well
i wrote a loop to fill the CharBuf with green "A"s, rather than reading the file
;        mov     hFile,fopen("myfiles.txt")
;        mov     ebx,fread(hFile,offset CharBuf,ByteCount)
;        fclose  hFile

mov ecx,2000
mov edi,offset CharBuf
test00:
mov dword ptr [edi],0A0041h
add edi,4
dec ecx
jnz test00


as for the size, i put the CharBuf buffer in the uninitialized data segment   :bg

QuoteVery well done, sinsi. Eventually I got my screen displayed.

what am i ? - chopped liver - lol

frktons

Thanks dave, sinsi.  :U
Going to sleep. I'll have to work on this brick and ReadConsoleInput
to build a working console menu old styled.  :P
Holydays permitting, see you soon.

Frank

Quotewhat am i ? - chopped liver - lol
slurp! that's a good italian dish "fegato alla veneziana" with onions and herbs.  :lol
Mind is like a parachute. You know what to do in order to use it :-)

dedndave

it's all good, Frank   :bg

here is my finished one
interesting to note that it works with either data file

Twister

frktons,


What exactly are you trying to do? Are you trying to print on the whole surface on the prompt?

dedndave

yes - you can run it and see   :P

Twister

Works very nice dave, good job.

I added this in at the end of PInit though:
        mov     cci.dwSize,sizeof cci
        mov     cci.bVisible,FALSE
        INVOKE  SetConsoleCursorInfo,hStdOut,addr cci


:P