flat assembler
Message board for the users of flat assembler.

Index > Windows > comcall

Author
Thread Post new topic Reply to topic
asmgges



Joined: 17 Jun 2003
Posts: 86
Location: France
asmgges
Hi ! Very Happy

The first parameter of an appeal " comcall " in a proc generates an error of compilation.
A solution ?

Code:
.....
stdcall WriteSurf,lpDDSFond

proc WriteSurf,Surface
    enter
    .....
    .....                                        ; error message
    comcall [Surface],GetDC,hdc    ; mov eax,[[..arg?00000E33]#.handle]
    .....
    .....
    return
    

Friendly....Gges
Post 18 Jun 2003, 16:40
View user's profile Send private message Visit poster's website Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3502
Location: Bulgaria
JohnFound
Hm, bad written macro, I think. Probably it allows only absolute address (label) as first parameter.
Post 18 Jun 2003, 16:59
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 7802
Location: Kraków, Poland
Tomasz Grysztar
It only allows a COM object structure as first parameter.
Post 18 Jun 2003, 17:53
View user's profile Send private message Visit poster's website Reply with quote
asmgges



Joined: 17 Jun 2003
Posts: 86
Location: France
asmgges
At the moment I made my procedure as this:
Code:
proc WriteSurf, NumSurf
    enter
    ........
    .......
    cmp dword[NumSurf],1
    jne .lab1
    comcall lpDDSBack,GetDC,hdc
    jmp .lab5
.lab1:
    cmp dword[NumSurf],2
    jne .lab2
    comcall lpDDSFond,GetDC,hdc
    jmp .lab5
.lab2:
    etc....

.lab5:
    ....
    return
    

But I am going to have the other surfaces .......

Friendly....Gges
Post 18 Jun 2003, 18:35
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 7802
Location: Kraków, Poland
Tomasz Grysztar
Here's my solution:
Code:
proc WriteSurf,Handle
    enter
    virtual
      Surface DirectDrawSurface
      Surface.handle equ Handle
    end virtual
    ; ...
    ; ...
    comcall Surface,GetDC,hdc
    ; ...
    ; ...
    return    

And this is the way how it should be called:
Code:
stdcall WriteSurf,[lpDDSBack]    
Post 18 Jun 2003, 20:30
View user's profile Send private message Visit poster's website Reply with quote
asmgges



Joined: 17 Jun 2003
Posts: 86
Location: France
asmgges
Hi! Very Happy
Thanks Tomasz
Your solution works but the management of the first parameter of comcall remains very delicate

If I make two procedures , work OK
Code:
stdcall CreateSurfBmp,picture,lpDDSPicture
stdcall CopieBmpSurf,[lpDDSPicture] 

proc CreateSurfBmp,Filename,AdrSurface
    enter

    invoke LoadImage,0,[Filename],IMAGE_BITMAP,0,0,LR_CREATEDIBSECTION + LR_LOADFROMFILE
    mov [hBitmap],eax

    invoke GetObject,[hBitmap],24,bitmap2

    mov [ddsd.dwFlags],DDSD_CAPS+DDSD_WIDTH+DDSD_HEIGHT
    mov [ddsd.ddsCaps.dwCaps],DDSCAPS_OFFSCREENPLAIN

    mov eax ,[bitmap2.bmWidth]
    mov [ddsd.dwWidth],eax
    mov eax,[bitmap2.bmHeight]
    mov [ddsd.dwHeight],eax
    comcall lpDD,CreateSurface,ddsd,[AdrSurface],0     ;

    return

proc CopieBmpSurf,Handle
    enter

    virtual
      Surface DirectDrawSurface
      Surface.handle equ Handle
    end virtual

    invoke CreateCompatibleDC,0
    mov [hdcImage],eax

    invoke SelectObject,[hdcImage],[hBitmap]
    mov [hbmOld],eax

    comcall Surface,GetDC,hdc
    .if eax,e,0
        invoke BitBlt,[hdc],0,0,[bitmap2.bmWidth],[bitmap2.bmHeight],\
                     [hdcImage],0,0,SRCCOPY
        comcall Surface,ReleaseDC,[hdc]
    .endif

    invoke SelectObject,[hdcImage],[hbmOld]
    invoke DeleteObject,[hBitmap]
    invoke DeleteDC,[hdcImage]

    comcall Surface,SetColorKey,DDCKEY_SRCBLT ,ddcolorkey

    return    
    



If I try to merge two procedures , compilation OK but error of execution
Code:
TEWBMP a causé une défaillance de page dans
 le module TEWBMP.EXE a 0157:00401396.
Registres :
EAX=00000000 CS=0157 EIP=00401396 EFLGS=00210246
EBX=00560000 SS=015f ESP=0057fe20 EBP=0057fe28
ECX=c0fb3930 DS=015f ESI=815d55c0 FS=1157
EDX=00000004 ES=015f EDI=00000000 GS=0000
Octets a CS : EIP :
8b 00 ff 50 44 83 f8 00 75 3a 68 20 00 cc 00 6a 
Etat de la pile :
00000000 00404008 0057ff78 0044c1f8 00402072 00404100 
00000000 bff89349 00000000 815d55c0 00560000 74796247 
6d627765 58450070 00000045 00000000

stdcall CreateSurfLoadBmp,picture,lpDDSPicture,[lpDDSPicture]


proc CreateSurfLoadBmp,Filename,AdrSurface,Handle
    enter

    virtual
      Surface2 DirectDrawSurface  ;I changed the name because conflict of name with the other procedures
      Surface2.handle equ Handle
    end virtual

    invoke LoadImage,0,[Filename],IMAGE_BITMAP,0,0,LR_CREATEDIBSECTION + LR_LOADFROMFILE
    mov [hBitmap],eax

    invoke GetObject,[hBitmap],24,bitmap2

    mov [ddsd.dwFlags],DDSD_CAPS+DDSD_WIDTH+DDSD_HEIGHT
    mov [ddsd.ddsCaps.dwCaps],DDSCAPS_OFFSCREENPLAIN

    mov eax ,[bitmap2.bmWidth]
    mov [ddsd.dwWidth],eax
    mov eax,[bitmap2.bmHeight]
    mov [ddsd.dwHeight],eax
    comcall lpDD,CreateSurface,ddsd,[AdrSurface],0     ;

    invoke CreateCompatibleDC,0
    mov [hdcImage],eax

    invoke SelectObject,[hdcImage],[hBitmap]
    mov [hbmOld],eax

    comcall Surface2,GetDC,hdc
    .if eax,e,0
        invoke BitBlt,[hdc],0,0,[bitmap2.bmWidth],[bitmap2.bmHeight],\
                     [hdcImage],0,0,SRCCOPY
        comcall Surface2,ReleaseDC,[hdc]
    .endif

    invoke SelectObject,[hdcImage],[hbmOld]
    invoke DeleteObject,[hBitmap]
    invoke DeleteDC,[hdcImage]

    comcall Surface2,SetColorKey,DDCKEY_SRCBLT ,ddcolorkey

    return          
    


But your solution is very acceptable Very Happy

Friendly...Gges
Post 19 Jun 2003, 08:08
View user's profile Send private message Visit poster's website 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


Copyright © 1999-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.