flat assembler
Message board for the users of flat assembler.
 Home   FAQ   Search   Register 
 Profile   Log in to check your private messages   Log in 
flat assembler > Windows > Graphics in console mode - demo

Author
Thread Post new topic Reply to topic
bazizmix



Joined: 15 Jan 2016
Posts: 25
Graphics in console mode - demo
Will be usefull for start screen in console applications


Description:
Download
Filename: Gfx_console.zip
Filesize: 169.61 KB
Downloaded: 139 Time(s)

Post 20 Feb 2016, 12:38
View user's profile Send private message Reply with quote
Trinitek



Joined: 06 Nov 2011
Posts: 257
Using ConEmu instead of the default terminal, the graphic flashes for a fraction of a second, and then says "Check graphics in console window".
Post 21 Feb 2016, 07:17
View user's profile Send private message Reply with quote
bazizmix



Joined: 15 Jan 2016
Posts: 25
Use the normal terminal and all will be ok
Post 21 Feb 2016, 09:44
View user's profile Send private message Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3439
Location: Bulgaria
It does not work in wine terminal as well.
Post 21 Feb 2016, 12:14
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
bazizmix



Joined: 15 Jan 2016
Posts: 25
So, this demo was written exclusively for windows console. Without any clones...
Post 21 Feb 2016, 14:32
View user's profile Send private message Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3439
Location: Bulgaria
Hm, I am almost sure, that it should work in WINE. I didn't analyze the source in deep, but Isn't it possible to has some bug inside?
Post 21 Feb 2016, 17:01
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
bazizmix



Joined: 15 Jan 2016
Posts: 25
No bugs. Work fine in Win7-32bit and Win10-64bit
Post 21 Feb 2016, 20:14
View user's profile Send private message Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3439
Location: Bulgaria
I mean bug, that reveals itself only in WINE.
Post 21 Feb 2016, 21:46
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 15168
Location: GW170817

JohnFound wrote:
I mean bug, that reveals itself only in WINE.

If so then that would be WINE's bug.
Post 21 Feb 2016, 23:22
View user's profile Send private message Visit poster's website Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3439
Location: Bulgaria

revolution wrote:

JohnFound wrote:
I mean bug, that reveals itself only in WINE.

If so then that would be WINE's bug.



Well, not always. WINE follows WinApi specification, but in some corner/edge cases, that are not explicitly specified, they can differs. But if some program uses the API this way, it is definitely problem in the program, not in the API itself.

The current case is exactly like this. Using the window DC of the console window to draw graphics on it is not documented in any way and is simply side effect, only because the console is a window and has device context.

_________________
Tox ID: 48C0321ADDB2FE5F644BB5E3D58B0D58C35E5BCBC81D7CD333633FEDF1047914A534256478D9
Post 22 Feb 2016, 00:37
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
Mikl___



Joined: 30 Dec 2014
Posts: 55
bazizmix,
threre are many console examples in Examples for Win64 Iczelion tutorial
Post 22 Feb 2016, 02:32
View user's profile Send private message Reply with quote
TmX



Joined: 02 Mar 2006
Posts: 790
Location: Jakarta, Indonesia
The executable ran fine on Windows built-in terminal app: there was a dragon displayed.
I'm running 32-bit Windows 10, BTW.

ConEmu (the latest nightly build) failed to run it properly, though...
Post 22 Feb 2016, 06:10
View user's profile Send private message Reply with quote
bazizmix



Joined: 15 Jan 2016
Posts: 25
Mikl___ nice examples Smile
Masm was my favorite, until I found out fasm
Post 22 Feb 2016, 11:48
View user's profile Send private message Reply with quote
Mikl___



Joined: 30 Dec 2014
Posts: 55
bazizmix,
at all respect, but your program has three shortcomings:
  1. you release the existing console and you don't create the new console
  2. when overlapping a window of your program other windows the drawing brought to the console collapses
  3. from your program the exit isn't provided when pressing any key or the "Esc" key
Post 24 Feb 2016, 02:09
View user's profile Send private message Reply with quote
bazizmix



Joined: 15 Jan 2016
Posts: 25
you're right, but I did not set out those goals. This is just an example, and anyone can improve it as part of their requirements
Here screenshort


Description:
Filesize: 132.39 KB
Viewed: 1824 Time(s)

Gfx_cons.jpg


Post 24 Feb 2016, 10:45
View user's profile Send private message Reply with quote
Mikl___



Joined: 30 Dec 2014
Posts: 55
Hi, bazizmix!

Code:
;============ Check graphics in console window
format PE console 4.0
entry start

include 'win32a.inc'
struct CONSOLE_CURSOR_INFO
  dwSize    dd      ?
  bVisible  dd      ?
ends
struct SMALL_RECT
  Left      dw      ?
  Top       dw      ?
  Right     dw      ?
  Bottom    dw      ?
ends
section '.data' data readable writeable 

NameConsole db "For exit press 'Esc'",0
bmp_path  db 'dragon.bmp',0
hOut      dd ?
hWnd      dd ?
hDC       dd ?
hbitmap   dd ?
memDC     dd ?
ScreenX   dd ?
ScreenY   dd ?
bi        BITMAP
cci       CONSOLE_CURSOR_INFO
ConsoleWindow   SMALL_RECT
;---------------------------------------------
section '.code' code readable executable
  start:
        xor     ebx,ebx
        invoke  FreeConsole
        invoke  AllocConsole
        invoke  SetConsoleTitle,NameConsole
        invoke  GetStdHandle,STD_OUTPUT_HANDLE
        mov     [hOut],eax
        invoke  LoadImage,400000h,bmp_path,ebx,ebx,ebx,LR_LOADFROMFILE
        mov     [hbitmap],eax
        lea     edi,[bi]
        invoke  GetObject,eax,sizeof.BITMAP,edi
        movzx   eax,[bi.bmBitsPixel]
        shr     eax,3                   ; eax=bmBitsPixel/8
        mul     [bi.bmWidth]
        mul     [bi.bmHeight]
        push    eax     ;eax=bmpBitsPixel*bmpWidth*bmBitsPixel/8
        invoke  GetProcessHeap
        invoke  HeapAlloc,eax,HEAP_NO_SERIALIZE
        mov     eax,[bi.bmWidth]
        shr     eax,3
        mov     [ScreenX],eax             ; eax=bmWidth/8
        mov     edx,357913941           ; edx=(2^32)/12
        mov     eax,[bi.bmHeight]
        mul     edx
        mov     [ScreenY],edx             ; edx=bmHeight/12
        invoke  GetLargestConsoleWindowSize,[hOut]
        lea     edi,[ConsoleWindow]
        mov     [edi],ebx
        sub     eax, [ScreenX]
        sbb     edxedx
        and     axdx
        dec     eax
        add     eax, [ScreenX]
        mov     [edi+SMALL_RECT.Right],ax
        shr     eax16
        sub     eax,[ScreenY]
        sbb     edxedx
        and     eaxedx
        dec     eax
        add     eax, [ScreenY]
        mov     [edi+SMALL_RECT.Bottom],ax
        invoke  SetConsoleWindowInfo,[hOut],TRUE,edi
        mov     eax,[ScreenY]
        shl     eax,16                  ; Coord.y=ScreenY
        add     eax,[ScreenX]             ; Coord.x=ScreenX
        invoke  SetConsoleScreenBufferSize,[hOut],eax
        lea     edi,[cci]
        invoke  GetConsoleCursorInfo,[hOut],edi
        mov     [edi+CONSOLE_CURSOR_INFO.bVisible],ebx      ; FALSE
        invoke  SetConsoleCursorInfo,[hOut],edi
        invoke  CloseHandle,[hOut]
        invoke GetConsoleWindow
        mov     [hWnd],eax
        invoke GetDC,eax
        mov     [hDC],eax
        invoke  CreateCompatibleDC,eax
        mov     [memDC],eax
        invoke  SelectObject,eax,[hbitmap]
@@:     invoke  Sleep,150
        invoke  BitBlt,[hDC],ebx,ebx,[bi.bmWidth],[bi.bmHeight],\
                      [memDC],ebx,ebx,SRCCOPY
        invoke  GetAsyncKeyState,VK_ESCAPE
; Determine whether a key is up or down
        test    eax8000h
        jz      @b
exit:   invoke  DeleteObject,[hbitmap]
        invoke  ReleaseDC,[hDC],[hWnd]
        invoke  DeleteDC,[memDC]
        invoke  FreeConsole
        invoke  ExitProcess,ebx

;---------------------------------------------
section '.idata' import data readable writeable
  library kernel32,'kernel32.dll',\
          user32,'user32.dll',\
          gdi32'gdi32.dll'
  include 'include\api\kernel32.inc'
  include 'include\api\user32.inc'
  include 'include\api\gdi32.inc'



Description:
Filesize: 187.22 KB
Viewed: 1785 Time(s)

1.png


Post 14 Mar 2016, 07:48
View user's profile Send private message Reply with quote
bazizmix



Joined: 15 Jan 2016
Posts: 25
Mikl___, well done Exclamation
Post 15 Mar 2016, 13:20
View user's profile Send private message Reply with quote
Picnic



Joined: 05 May 2007
Posts: 1203
Location: Athens, Greece
Nice demo. I think i will include this feature in my Basic. It's kinda cool. I have posted a simillar example some moment in the past.

Parameters are wrong here

Code:

invoke  ReleaseDC,[hDC],[hWnd



Should be

Code:

invoke  ReleaseDC,[hWnd],[hDC]




Last edited by Picnic on 24 May 2017, 19:43; edited 1 time in total
Post 24 Apr 2016, 13:05
View user's profile Send private message Reply with quote
catafest



Joined: 05 Aug 2010
Posts: 81
AV told me is infected with TR/Dropper.
I think is section '.data' data problem.
@Mikl___ this remember by MIRC with effect of chat window.
Maybe this is offtopic but http://cmder.net has a great window ...
Post 24 Apr 2016, 19:41
View user's profile Send private message Visit poster's website Yahoo Messenger Reply with quote
Picnic



Joined: 05 May 2007
Posts: 1203
Location: Athens, Greece
Motivated by bazizmix topic, i added a bitmap command to Hobby Basic in the form bitmap x,y,path

About the overlapping issue -which i did not realize, thanks Mikl___- what i do is repaint the bitmap each time the console window regains focus.
Post 10 Jun 2017, 12:34
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >

Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2005 phpBB Group.

Main index   Download   Documentation   Examples   Message board
Copyright © 2004-2016, Tomasz Grysztar.