News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Uncle Remus Tales

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

Previous topic - Next topic

Mikl__

Uncle Remus Tales
Consider this cycle a parody that Joel Chandler Harris wrote on the "Iczelion Lessons" rewritten under Win x64
Drawings from the movie "Song of the South" (1946) are kindly provided
Uncle Remus tales:#37i gif-animation
; GUI #
include win64a.inc
include gdiplus.inc
includelib gdiplus.lib

PropertyTagFrameDelay  equ 5100h
cdXPos          equ 127
cdYPos          equ 127
cdXSize         equ 200
cdYSize         equ 100
cdVBarTipo      equ 0
cdMainIcon      equ 100
cdIdTimer       equ 1
.code
WinMain proc
local msg:MSG
local ptDiff:POINT
local rctWnd:RECT
local rctClient:RECT
local nSize:qword
local pDimensionIDs:qword
local count:qword

;инициализация библиотеки GDIPLUS
mov ecx,offset gdiplusToken
mov edx,offset gsi
invoke GdiplusStartup,,,0

xor ebx,ebx
mov edi,offset ClassName
mov ecx,offset FileName
invoke LoadCursorFromFile

push rax ;hIconSm
push rdi ;lpszClassName
push rbx ;lpszMenuName
push COLOR_WINDOWTEXT ;hbrBackground
push 10003h ;hCursor
push rax ;hIcon
push IMAGE_BASE ;hInstance
push rbx ;cbClsExtra & cbWndExtra
pushaddr WndProc  ;lpfnWndProc
push sizeof WNDCLASSEX;cbSize & style
invoke RegisterClassEx,esp ;addr WNDCLASSEX

        mov ecx,offset szfilename
mov edx,offset g_image
invoke GdipLoadImageFromFile
;TestForAnimatedGIF-------------------------------
lea edx,count
mov [rdx],ebx;count=0
mov ecx,g_image
invoke GdipImageGetFrameDimensionsCount
mov ecx,dword ptr count
test ecx,ecx
jz @f
shl ecx,4
invoke GdipAlloc

mov dword ptr pDimensionIDs,eax
mov ecx,g_image
invoke GdipImageGetFrameDimensionsList,,eax,count
or eax,eax
jnz @f
mov r8d,offset nFrameCount
mov ecx,g_image
invoke GdipImageGetFrameCount,,pDimensionIDs
or eax,eax
jnz @f
lea r8d,nSize
mov ecx,g_image
invoke GdipGetPropertyItemSize,,PropertyTagFrameDelay
or eax,eax
jnz @f
mov ecx,dword ptr nSize
shl ecx,2
invoke GdipAlloc
mov pPropertyItem,eax
mov ecx,g_image
invoke GdipGetPropertyItem,,PropertyTagFrameDelay,nSize,eax
or eax,eax
jnz @f
mov ecx,dword ptr pDimensionIDs
        invoke GdipFree
@@:;------------------------------------
mov edx,offset nWidth
mov ecx,g_image
call GdipGetImageWidth
mov edx,offset nHeight
mov ecx,g_image
call GdipGetImageHeight

push rbx
push IMAGE_BASE
push rbx
push rbx
push cdYSize ; nHeight
push cdXSize ; nWidth
push cdYPos ; Y
push cdXPos ; X
sub esp,20h
    invoke CreateWindowEx,0,edi,edi,WS_OVERLAPPEDWINDOW or WS_VISIBLE
        mov hMainWnd,eax
        lea edx,rctClient ;lpRect
invoke GetClientRect,eax
lea edx,rctWnd ;lpRect
mov ecx,hMainWnd
invoke GetWindowRect
mov eax,rctWnd.right
sub eax,rctWnd.left
sub eax,rctClient.right
mov ptDiff.x,eax
mov eax,rctWnd.bottom
sub eax,rctWnd.top
sub eax,rctClient.bottom
mov ptDiff.y,eax
mov qword ptr [rsp+28h],TRUE ; bRepaint
        mov ecx,nHeight
add ecx,ptDiff.y
mov [rsp+20h],rcx ;nHeight
mov eax,nWidth
add eax,ptDiff.x
mov ecx,hMainWnd
invoke MoveWindow,,cdXPos,cdYPos,rax
lea edi,msg
@@: invoke GetMessage,edi,NULL,0,0
cmp msg.wParam,VK_ESCAPE;user press 'Esc'?
je wmDESTROY
invoke DispatchMessage,edi
jmp @b
WinMain endp
WndProc proc hWnd:qword,umsg:qword,wParam:qword,lParam:qword
local ps:PAINTSTRUCT
local graphics:qword

mov hWnd,rcx
mov wParam,r8
mov lParam,r9

cmp edx,WM_DESTROY
je wmDESTROY
cmp edx,WM_CREATE
je wmCREATE
cmp edx,WM_SIZE
je wmSIZE
cmp edx,WM_PAINT
je wmPAINT
cmp edx,WM_TIMER
je wmTIMER
leave
        jmp DefWindowProc
wmDESTROY::invoke KillTimer,,cdIdTimer
cmp g_image,0
jz @f
mov ecx,g_image
invoke GdipDisposeImage
@@: cmp pPropertyItem,0
jz @f
mov ecx,pPropertyItem
invoke GdipFree
@@: invoke ExitProcess,NULL
wmPAINT:lea edx,ps
invoke BeginPaint
;DrawFrameGIF---------------------
mov edx,offset nWidth
mov ecx,g_image
invoke GdipGetImageWidth
or eax,eax
jnz @f
mov edx,offset nHeight
mov ecx,g_image
invoke GdipGetImageHeight
or eax,eax
jnz @f
lea edx,graphics
invoke GdipCreateFromHDC,ps.hdc
mov eax,dword ptr vdyClient
mov [rsp+28h],rax
mov eax,dword ptr vdxClient
mov [rsp+20h],rax
mov edx,g_image
invoke GdipDrawImageRectI,graphics,,0,0
invoke GdipDeleteGraphics,graphics
mov r8d,nFramePosition
inc nFramePosition
mov edx,offset pageGuid
mov ecx,g_image
invoke GdipImageSelectActiveFrame
mov eax,nFramePosition
sub eax,nFrameCount
jnz @f
mov nFramePosition,eax
;-------------------------------
@@: lea edx,ps
invoke EndPaint,hWnd
jmp wmBYE
wmTIMER:invoke InvalidateRect,,0,0
jmp wmBYE
wmCREATE:invoke SetTimer,,cdIdTimer,100,0
jmp wmBYE
wmSIZE: mov rax,r9;lParam
mov vdxClient,ax
shr eax,10h
mov vdyClient,ax
jmp wmBYE
wmBYE: leave
retn
WndProc endp
;-----------------------------------
ClassName db "Uncle Remus tales:#37i gif animation",0
FileName db "br_Rabbit3.cur",0
gsi GdiplusStartupInput <1,0,0,0,0>
pageGuid GUID <6AEDBD6Dh,3FB5h,418Ah,<83h,0A6h,7Fh,45h,22h,9Dh,0C8h,72h>>
szfilename: du <movie.gif>
gdiplusToken dd ?
nWidth dd ?
nHeight dd ?
vdxClient dw 0,0
vdyClient dw 0,0
nFrameCount dd ?
nFramePosition dd 0
pPropertyItem dd ?
g_image dd ?
hMainWnd dd ?
end

Mikl__

rename files movie.01.zip, movie.02.zip, movie.03.zip, movie.04.zip to movie.zip.001, movie.zip.002, movie.zip.003, movie.zip.004 and unzip they
to be continued

Mikl__


Mikl__


Mikl__


Siekmanski

I renamed the files, but couldn't unzip the movie. (unknown format or corrupt file)
Creative coders use backward thinking techniques as a strategy.

Mikl__

#6
Hi, Siekmanski!
I used 7-zip (www.7-zip.org) compression level=Maximum, compression method=default, dictionary size=32 KB, word size=64
Result is "movie.zip" folder with "movie.gif" file, size is 1730254 bytes. I just checked. File movie.gif downloaded and unpacked without errors

Mikl__

#7
Uncle Remus tales:#37j simple animation
; GUI #
include win64a.inc
include gdiplus.inc
includelib gdiplus.lib
ILD_NORMAL equ 0
.code
WinMain proc
local msg:MSG
local hwnd:qword

;inizialisation GDIPLUS
mov ecx,offset gdiplusToken
mov edx,offset gsi
invoke GdiplusStartup,,,0

xor ebx,ebx
mov esi,IMAGE_BASE
mov edi,offset ClassName
mov ecx,offset FileName
invoke LoadCursorFromFile
push rax ;hIconSm
push rdi ;lpszClassName
push rbx ;lpszMenuName
push COLOR_WINDOWTEXT;hbrBackground
push 10003h ;hCursor
push rax    ;hIcon
push rsi ;hInstance
push rbx    ;cbClsExtra & cbWndExtra
pushaddr WndProc  ;lpfnWndProc
push sizeof WNDCLASSEX;cbSize & style
invoke RegisterClassEx,esp ;addr WNDCLASSEX

push rbx
push rsi ;rsi=400000h
shl esi,9 ;rsi=CW_USEDEFAULT
push rbx
push rbx
push 180;rsi
push 170;
push rsi
push rsi
sub esp,20h
    invoke CreateWindowEx,0,edi,edi,WS_OVERLAPPEDWINDOW or WS_VISIBLE
    mov hwnd,rax
        and  qword ptr [rsp+20h],0
invoke ImageList_Create,153,147,ILC_COLOR24,1
mov hList,eax

        mov ecx,offset FilenameW
mov edx,offset pImage
invoke GdipCreateBitmapFromFile
mov edx,offset hBmp
invoke  GdipCreateHBITMAPFromBitmap,pImage,,0
invoke  GdipDisposeImage,pImage

mov edx,hBmp
mov ecx,hList
invoke ImageList_Add,,,0
mov ecx,hBmp
invoke DeleteObject
        invoke GetDC,hwnd
        mov hDC,eax
        mov r9d,offset Draw
        invoke SetTimer,hwnd,1,40;1000/25=40
lea edi,msg
@@: invoke GetMessage,edi,NULL,0,0
invoke DispatchMessage,edi
jmp @b
WinMain endp
WndProc:
cmp edx,WM_DESTROY
je wmDESTROY
        jmp DefWindowProc
wmDESTROY:invoke ExitProcess,NULL
;-------------------------------------
Draw proc
        enter 30h,0
and qword ptr [rbp-8],ILD_NORMAL; drawing style
and qword ptr [rbp-10h],0;y-coordinate to draw at
mov edx,count
mov r8d,hDC
mov ecx,hList
invoke ImageList_Draw,,,,0
inc count
cmp count,210
jb @f
and count,0
@@: leave
ret
Draw endp
;-----------------------------------
align 2
FilenameW: du <all3.jpg>
ClassName db "Uncle Remus tales:#37j Simple animation",0
gsi GdiplusStartupInput <1,0,0,0,0>
FileName db "br_Rabbit3.cur",0
gdiplusToken dd ?
hBmp dd ?
count dd ?
hList dd ?
hDC dd ?
pImage dq ?
end

Mikl__

rename files 37j.001.zip, 37j.002.zip, 37j.003.zip, 37j.004.zip to 37j.zip.001, 37j.zip.002, 37j.zip.003, 37j.zip.004 and unzip they
to be continued

Mikl__


Mikl__


Mikl__

Uncle Remus tales:#37a Animation
We are writing a player based on the SysAnimate32 class. We create a window, on this window we upload a child window with the class SysAnimate32 indicating the file that we want to play.
Create a child window using the CreateWindowEx function. We do not need to register the window class, since it was already registered by Windows. When creating the screen, specify "SysAnimate32" as the class name for CreateWindowsEx. Other parameters that we must specify are the handle of the parent window and the ID of the control. The control ID should be unique if we used several controls to distinguish this control from others. But since the control we have is the only one set ID = 0. We also need to specify the screen sizes and the coordinates of its upper left corner. Normally, the child window is created during the processing of the WM_CREATE message of the main window. We will create a child window before processing the message loop. After creating the animation management tool, we send the ACM_OPEN message via the SendMessage function to open the AVI clip and load it into memory. The message specifies the path to the AVI file.LRESULT WINAPI SendMessage(
  _In_ HWND   hWndControl, //A handle to the window whose window procedure will receive the message
  _In_ UINT ACM_OPEN, //The message to be sent
  _In_ WPARAM hinst, //Additional message-specific information
  _In_ LPARAM lpszName      //Additional message-specific information
);
Parameters

  • Hinst - The descriptor of the module instance from which the resource should be loaded. Set this value to the HINSTANCE module that created the window. Note - if the window is created using a DLL, then hinst is the HINSTANCE DLL value, and not the application that accesses the DLL.
  • LpszName - A pointer to a buffer that contains the path to the AVI file or the name of the AVI resource. Alternatively, this parameter can consist of the AVI resource identifier in the low word and the zero in the high word. To create this value, use the MAKEINTRESOURCE macro. The control loads the AVI resource from the module specified by the hinst parameter. The AVI resource must be of type "AVI". If this parameter is zero, the system will close the AVI file, which was previously opened in the animator, if it existed. The AVI file or resource specified with lpszName should not contain audio data. It should be without sound.
; GUI #
include win64a.inc
ACM_OPEN = WM_USER + 100
ACS_AUTOPLAY = 4
ID_ANIMATE = 101
.code
WinMain proc
local msg:MSG
local hwnd:QWORD

xor ebx,ebx
mov esi,IMAGE_BASE
mov ecx,offset FileNameCur
invoke LoadCursorFromFile
mov edi,offset ClassName
push rax ;hIconSm
push rdi ;lpszClassName
push rbx ;lpszMenuName
push COLOR_WINDOW;hbrBackground
push 10005h ;hCursor
push rax        ;hIcon
push rsi ;hInstance
push rbx        ;cbClsExtra & cbWndExtra
pushaddr WndProc      ;lpfnWndProc
push sizeof WNDCLASSEX;cbSize & style
    invoke RegisterClassEx,esp ;addr WNDCLASSEX

push rbx
push rsi ;rsi=400000h
push rbx
push rbx
push 440
push 510
push 10
push 10
sub esp,20h
    invoke CreateWindowEx,0,edi,edi,WS_CAPTION or WS_SYSMENU or WS_VISIBLE
mov hwnd,rax

push rbx
push rsi;IMAGE_BASE
push ID_ANIMATE
push rax;hwnd
push rbx;The width and height of the frame will be adjusted automatically
push rbx
push 20
push 20
sub esp,20h
mov r8d,offset NoText
mov edx,offset Animate32
invoke CreateWindowEx,WS_EX_STATICEDGE+WS_EX_CLIENTEDGE,,,WS_CHILD+WS_VISIBLE+WS_TABSTOP+ACS_AUTOPLAY

movr qword ptr [rsp+20h],AviFile
    invoke SendDlgItemMessage,hwnd,ID_ANIMATE,ACM_OPEN,IMAGE_BASE

    lea edi,msg
@@:     invoke GetMessage,edi,0,0,0
        invoke DispatchMessage,edi
        jmp @b
WinMain endp
WndProc: cmp edx,WM_DESTROY
je wmDESTROY
        jmp DefWindowProc
wmDESTROY:invoke ExitProcess,0
;---------------------------------------
ClassName db 'Uncle Remus tales:#37a Animation',0
FileNameCur db "br_Rabbit3.cur",0
AviFile db 'output.avi',0
Animate32 db "SysAnimate32"
NoText db 0
end
There is link for output.avi file. To play via "SysAnimate32", the avi-file should not be compressed (therefore it has such a large size) and can not contain audio data

Mikl__

Read 129 times, downloaded 1 times
Is my english so terrible? Or the topic is completely uninteresting?

jj2007

No, your English is good, your code is excellent, as usual :t

I even quoted you here ;-)

push rbx ; ширина и высота кадра настроятся автоматически
push rbx ; The width and height of the frame will be adjusted automatically


But I had to write a little converter to see your cyrillic comments:

include \masm32\MasmBasic\MasmBasic.inc      ; download
  Init
  Let esi=Cat$(Utf8Bom+ConvertCp$(FileRead$("tut_37a.asm"), 1251, CP_UTF8))
  FileWrite "tut_37aUtf8.asc", esi
  ShEx "tut_37aUtf8.asc"
EndOfCode

nidud

#14
deleted