Author Topic: Uncle Remus Tales  (Read 22706 times)

Mikl__

  • Member
  • ****
  • Posts: 763
Re: Uncle Remus Tales
« Reply #105 on: January 31, 2019, 12:39:11 AM »
a continuation

jj2007

  • Member
  • *****
  • Posts: 9697
  • Assembler is fun ;-)
    • MasmBasic
Re: Uncle Remus Tales
« Reply #106 on: January 31, 2019, 01:13:49 AM »
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:
Code: [Select]
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.

AW

  • Member
  • *****
  • Posts: 2341
  • Let's Make ASM Great Again!
Re: Uncle Remus Tales
« Reply #107 on: January 31, 2019, 01:50:23 AM »
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....

AW

  • Member
  • *****
  • Posts: 2341
  • Let's Make ASM Great Again!
Re: Uncle Remus Tales
« Reply #108 on: January 31, 2019, 02:25:05 AM »
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.

AW

  • Member
  • *****
  • Posts: 2341
  • Let's Make ASM Great Again!
Re: Uncle Remus Tales
« Reply #109 on: February 03, 2019, 09:17:58 PM »
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__

  • Member
  • ****
  • Posts: 763
Re: Uncle Remus Tales
« Reply #110 on: February 03, 2019, 11:19:34 PM »
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.
Quote
This 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

  • Member
  • *****
  • Posts: 9697
  • Assembler is fun ;-)
    • MasmBasic
Re: Uncle Remus Tales
« Reply #111 on: February 04, 2019, 12:51:02 AM »
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)

AW

  • Member
  • *****
  • Posts: 2341
  • Let's Make ASM Great Again!
Re: Uncle Remus Tales
« Reply #112 on: February 04, 2019, 02:04:52 AM »
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

  • Member
  • *****
  • Posts: 9697
  • Assembler is fun ;-)
    • MasmBasic
Re: Uncle Remus Tales
« Reply #113 on: February 04, 2019, 04:20:30 AM »
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.

AW

  • Member
  • *****
  • Posts: 2341
  • Let's Make ASM Great Again!
Re: Uncle Remus Tales
« Reply #114 on: February 04, 2019, 07:21:40 PM »
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__

  • Member
  • ****
  • Posts: 763
Re: Uncle Remus Tales
« Reply #115 on: August 18, 2019, 08:19:48 PM »
There is GDI+ in the console program
asm-file
Code: [Select]
;; 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

  • Member
  • *****
  • Posts: 9697
  • Assembler is fun ;-)
    • MasmBasic
Re: Uncle Remus Tales
« Reply #116 on: August 19, 2019, 04:11:49 AM »
Cute idea, Mikl!

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 6679
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: Uncle Remus Tales
« Reply #117 on: August 19, 2019, 02:40:23 PM »
 :biggrin:

Nice image of Ethiopia, I wonder where that came from ?  :tongue:
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :skrewy:

Mikl__

  • Member
  • ****
  • Posts: 763
Re: Uncle Remus Tales
« Reply #118 on: August 19, 2019, 03:48:35 PM »
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...
« Last Edit: August 19, 2019, 08:28:56 PM by Mikl__ »

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 6679
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: Uncle Remus Tales
« Reply #119 on: August 20, 2019, 12:36:08 AM »
 :biggrin:

Nothing to apologise for, I will give you a bigger version of it if you like.
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :skrewy: