Small trick with ASM

Share your advanced PureBasic knowledge/code with the community.
Progs
User
User
Posts: 21
Joined: Sun Sep 19, 2004 12:42 pm
Location: Russia/Moscow

Small trick with ASM

Post by Progs »

Code: Select all

Procedure mae_setambient( r.f, g.f, b.f )
    Protected *t
    mov *t, esp ;now *t point to 3 floats array :)
    glLightModelfv_( #GL_LIGHT_MODEL_AMBIENT, *t );
EndProcedure
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Re: Small trick with ASM

Post by PB »

What does it do?
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
Dreglor
Enthusiast
Enthusiast
Posts: 759
Joined: Sat Aug 02, 2003 11:22 pm
Location: OR, USA

Post by Dreglor »

somthing with gl and ambient light...?
~Dreglor
PolyVector
Enthusiast
Enthusiast
Posts: 499
Joined: Wed Sep 17, 2003 9:17 pm
Location: Southern California
Contact:

Post by PolyVector »

It appears to set *t to point to the stack of parameters sent to mae-setambient()... I've seen this method used in ASM to call VxDCall
Progs
User
User
Posts: 21
Joined: Sun Sep 19, 2004 12:42 pm
Location: Russia/Moscow

Post by Progs »

Yes. glLightModelfv sets Ambient light level.
Function takes pointer to array of 3 floats
without asm it may looks like

Code: Select all

structure color
r.f, g.f, b.f
end structure

procedure set_ambient( r.f,g.f,b.f )
 c.color
 c\r = r
 c\g = g
 c\b = b
 glLightModelfv_( #GL_LIGHT_MODEL_AMBIENT, @c ); 
endprocedure
but now its only

Code: Select all

!extrn _glLightModelfv@8
Procedure mae_setambient( r.f, g.f, b.f ) 
    !PUSH esp
    !PUSH 0x0B53
    !CALL _glLightModelfv@8
EndProcedure
asm rulez :)
Post Reply