News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests

Main Menu

Uncle Remus Tales

Started by Mikl__, May 26, 2017, 08:43:47 PM

Previous topic - Next topic

Mikl__


jj2007

Hi Mikl,

I can't build it because I don't yet have a consistent Win64 installation, but nonetheless I have a question regarding these lines:
mov r8d,offset expTxt0
mov edx,offset aStatic
sub esp,20h


Now that is obviously 64-bit code. Does the fact that you use edx and esp mean that you assume the addresses are 32-bit? I remember vaguely that years ago a group of programmers tried to promote a system with 64-bit instructions but 32-bit addresses.

aw27

It builds with LARGEADDRESSAWARE:NO (you hate 64-bit!) in link and -Cp in ml64.
However it does not run.
You are using a set of unusual build parameters, so please let us know them. From a previous post I have seen things like /ALIGN:16 /SECTION:.text,W /BASE:0x400000. If I use these it does indeed launch but shows crap.
In short, how do you build this?  :biggrin:
Now all makes sense, including putting the data in the code section....

aw27

All right, it shows crap because I am not using the Windows-1251 character encoding.



I notice that the first tab with caption Static disappeared in my Windows 10.

aw27

BTW, even without Unicode you can display Russian strings to western people.
All you need to do is CreateFont with RUSSIAN_CHARSET (most fonts will do, no need for a Russian font).
Then when is time to render the string you SelectObject with that font before DrawText.

Mikl__

Hi, AW!
I am very sorry that any text except the English text is rubbish ("crap") for you. Of course, in order to display the text in 10 ways, it was necessary to take 10 chapters from "Uncle Remus' Stories" in the Nigger Dixie dialect.
QuoteThis is the Russian translation of "Uncle Remus's Tales". But this is not critical. This is a demonstration of displaying a few dozen lines..

jj2007

Hi, Mikl!

It feels very strange to defend José, but in this particular case when he writes "crap" he means that the control does not display the cyrillian text correctly. Indeed, it shows something else - but that is a minor problem, it's just a codepage issue  8)

aw27

Hi, Mikl!
I can imagine, but I always thought Uncle Remus was Russian.   ::)

Oh JJ,
Thankies. it is indeed a "minor" codepage issue, although very few people know how to solve it. I searched the internet and did not found a single instance of the correct solution. Lots of incorrect suggestions.

jj2007

I can imagine :P

CreateFont with RUSSIAN_CHARSET is indeed an interesting idea, thanks; although in general it is easier to simply use the UTF-16 version of the edit control. You can even mix Russian, Chinese and Arabic then.

aw27

Quote from: jj2007 on February 04, 2019, 04:20:30 AM
CreateFont with RUSSIAN_CHARSET is indeed an interesting idea, thanks; although in general it is easier to simply use the UTF-16 version of the edit control. You can even mix Russian, Chinese and Arabic then.
UTF-16 is better but in some countries is not well accepted. This may not happen in Russia but in Japan they still prefer Shift-JIS. In other words suppose you want to convince Japanese people to use Rich Masm, better you make the menus and everything else in Shift-JIS. This happened to me, my agent said we would sell lots of software in Japan with a Japanese localization but could only be Shift-JIS.  At the time I had a Windows XP Japanese release only for testing. Something crazy to navigate it.

Mikl__

There is GDI+ in the console program
asm-file;; CONSOLE #
include win64a.inc
includelib winmm.lib
include winmm.inc
include gdiplus.inc
includelib gdiplus.lib
MAXSCREENX = 600/8
MAXSCREENY = 315/12
.code
WinMain proc
local result:qword
local hIn:qword
local IDtimer:qword
local ConsoleWindow:SMALL_RECT
local cci:CONSOLE_CURSOR_INFO
local MOUSE_KEY:INPUT_RECORD

        invoke  FreeConsole ;release the existing console
        invoke  AllocConsole    ;create the console
        invoke  GetStdHandle,STD_INPUT_HANDLE
        mov hIn,rax                        ; receive handle for a input
        invoke  GetStdHandle,STD_OUTPUT_HANDLE
        mov hOut,rax                       ; receive handle for a output
    invoke  GetLargestConsoleWindowSize,eax
;   eax return in 31-16 bits: dwCoord.y
;                 15-00 bits: dwCoord.x
        lea r8d,ConsoleWindow       ; lpConsoleWindow
    and dword ptr [r8],0
;ConsoleWindow.Left = 0   ConsoleWindow.Top = 0
    sub ax, MAXSCREENX
    sbb edx, edx
    and ax, dx
    add ax, MAXSCREENX-1
    mov [r8+SMALL_RECT.Right],ax
    shr eax, 16
    sub eax, MAXSCREENY
    sbb edx, edx
    and eax, edx
    add eax, MAXSCREENY-1
    mov [r8+SMALL_RECT.Bottom],ax
    invoke  SetConsoleWindowInfo,hOut,TRUE
    invoke  SetConsoleScreenBufferSize,hOut,MAXSCREENY*10000h+MAXSCREENX  ; establish the new size of console window
; initialise GDIPlus
mov ecx,offset graphics
mov edx,offset gdii
invoke GdiplusStartup,,,0

        invoke  SetConsoleTitle,&NameConsole     ;definition of a title bar
        invoke  timeSetEvent,200,0,&TIME,0,TIME_PERIODIC
    mov IDTimer,rax
        invoke  SetConsoleCursorPosition,hOut,0;Y=0 X=0
    invoke  WriteConsole,hOut,&STR1,sizeof STR1,&result,0
invoke  GetConsoleWindow
    mov hWnd,rax
    invoke  GetDC,rax       ;получить DC
    mov hDC,rax
        lea edx,gdiHgraphics
invoke GdipCreateFromHDC,eax; Get graphics "object" from DC handle
        mov ecx,offset FileNameU
        invoke GdipLoadImageFromFile,,ADDR gdiHbitmap   ; Open JPEG file
@@:     invoke  ReadConsoleInput,hIn,&MOUSE_KEY,1,&result
        lea edx,MOUSE_KEY
    cmp [rdx+INPUT_RECORD.EventType],MOUSE_EVENT
    je @b
    cmp     [rdx+INPUT_RECORD.EventType],KEY_EVENT
    jne @b
    cmp [rdx+INPUT_RECORD.KeyEvent.wVirtualKeyCode],VK_ESCAPE
    jne @b
invoke  ReleaseDC,hWnd,hDC       ;free hDC
    invoke  timeKillEvent,IDTimer
    invoke  FreeConsole ;close console
        invoke GdiplusShutdown,graphics        ; cleanup on exit
    invoke RtlExitUserProcess,NULL
WinMain endp
TIME proc
local   dummy:qword

invoke GdipDrawImageI,gdiHgraphics, gdiHbitmap,0,15
    leave
    retn
TIME endp
;----------------------------------------
hDC dq ?
hWnd dq ?
gdiHbitmap dq ?
gdiHgraphics dq ?
gdii GdiplusStartupInput <1,0,0,0>
graphics dq ?
STR1 db 'For exit from program press ESC or CTRL+C or CTRL+Break'
NameConsole db 'JPG Image in Console',0
hOut dq ?
FileNameU: du <background.jpg>
IDTimer dq ?
end
There are asm-/jpg-/exe-files in attachment

jj2007


hutch--

 :biggrin:

Nice image of Ethiopia, I wonder where that came from ?  :tongue:

Mikl__

#118
Hi, jj and hutch--!
That is jpg-file from the new_masm32->examples64->jpg_image lesson. But is it really so important where did I get the jpg-file? I hope that I have not infringed on any copyrights? If it is so, then I am apologizing...

hutch--

 :biggrin:

Nothing to apologise for, I will give you a bigger version of it if you like.