Go Back   BWHacks > Development > Reverse Engineering > Code Snippets and Tutorials

Code Snippets and Tutorials The place for open source releases, great information, and tutorials written by other members.

Reply
 
LinkBack Thread Tools

Old 05-22-2007, 04:54 AM   #1 (permalink)
Perma
rol 3905h, 8
Senior Member
Administrator

Saint
 
Perma's Avatar
 
Join Date: Jul 2004
Location: Canada
Posts: 5,414
Perma has disabled reputation
Default [StarCraft] Transparent Pane Drawing (v1.15.2)

Here are a few functions I wrote up for drawing transparent window panes in Starcraft. The first function is used to draw a box based on the parameters you pass to it. The box is quite solid, like the original Starspeak interface.

Drawing Solid Boxes
Code:
.data

BWFXN_DrawBox           dd 004E18E0h

.code

DrawBox proc x:DWORD,y:DWORD,w:DWORD,h:DWORD,clr:BYTE

        mov cl,clr
        mov byte ptr ds:[006CF494h], cl
        push h 
        push w 
        push y
        push x
        call dword ptr [BWFXN_DrawBox] 
        ret

DrawBox endp
Code:
invoke DrawBox, xcoordinate, ycoordinate, width, height, color
Many users felt that a transparent box would be much more useful and visually appealing that a solid one. Unfortunately, I wasn't able to uncover a native function that Starcraft used to adjust the alpha on drawn objects. So instead, I created a function that would mathematically draw a series of lines to give the illusion of transparency.

In addition to drawing lines spaced one pixel apart, the function also draws a border around the object. You can adjust the inner and border colors to your liking.

Drawing a Transparent Box
Code:
DrawTransparentBox proc         x:DWORD,y:DWORD,w:DWORD,h:DWORD,clr:BYTE,midclr:BYTE

        pushad
        mov edx, y
        mov eax, h
        add eax, edx
        mov ebx, eax
        .while edx < ebx
               pushad
               invoke DrawBox, x, edx, w, 1, midclr
               popad
               add edx, 02h
        .endw
        invoke DrawBox, x, y, w, 2, clr
        invoke DrawBox, x, ebx, w, 2, clr
        invoke DrawBox, x, y, 1, h, clr
        mov eax, x
        mov ebx, w
        add ebx, eax
        invoke DrawBox, ebx, y, 1, h, clr
        popad
        ret

DrawTransparentBox endp
Code:
invoke DrawTransparentBox, xcoordinate, ycoordinate, width, height, bordercolor, innercolor

Last edited by Perma : 05-20-2008 at 01:44 AM.
Perma 15 0FF11|\|3   Reply With Quote
Advertisement
 
Advertisement
Advertisement Sponsored links


Old 05-22-2007, 05:47 AM   #2 (permalink)
Jiggie=#1

Advocate
 
Jiggie=#1's Avatar
 
Join Date: Jul 2006
Location: Cream
Posts: 304
Jiggie=#1 is on a distinguished road
OOOO this will be very useful, thx a lot!
Any chance on telling me how you got the address used to draw the box?
I doubt I would figure it out and I like to convert the hacks I code just in case of a new patch
Jiggie=#1 15 0FF11|\|3   Reply With Quote

Old 05-22-2007, 12:36 PM   #3 (permalink)
Perma
rol 3905h, 8
Senior Member
Administrator

Saint
 
Perma's Avatar
 
Join Date: Jul 2004
Location: Canada
Posts: 5,414
Perma has disabled reputation
Default

Quote:
Originally Posted by Jiggie=#1 View Post
Any chance on telling me how you got the address used to draw the box?
Actually I think it was Kc who originally found that function a few patches ago. If you're simply converting it, there's no need to reinvent the wheel. You can just create a disassembly of both versions and cross reference them.
Perma 15 0FF11|\|3   Reply With Quote

Old 05-22-2007, 06:33 PM   #4 (permalink)
Arcanite
Gold Member

Deviant
 
Join Date: May 2007
Location: Behind You!
Posts: 138
Arcanite is on a distinguished road
Default

Woah looks nice. Great job Perma =)
Arcanite 15 0FF11|\|3   Reply With Quote

Old 05-22-2007, 08:17 PM   #5 (permalink)
saren

Crusader
 
saren's Avatar
 
Join Date: Feb 2005
Location: Tucson, AZ
Posts: 3,327
saren has much to be proud ofsaren has much to be proud ofsaren has much to be proud ofsaren has much to be proud ofsaren has much to be proud ofsaren has much to be proud of
Default

To the best of my ability to find it, SC lacks a native ability to adjust alpha levels on anything drawn in game. Sprites are given a visible and not-visible flags though, that dictate if they appear or not to whomever.
__________________


Burn, baby, burn.
saren 15 0FF11|\|3   Reply With Quote

Old 05-22-2007, 10:03 PM   #6 (permalink)
Perma
rol 3905h, 8
Senior Member
Administrator

Saint
 
Perma's Avatar
 
Join Date: Jul 2004
Location: Canada
Posts: 5,414
Perma has disabled reputation
Default

Quote:
Originally Posted by saren View Post
To the best of my ability to find it, SC lacks a native ability to adjust alpha levels on anything drawn in game. Sprites are given a visible and not-visible flags though, that dictate if they appear or not to whomever.
Guess it wasn't just me then.
Perma 15 0FF11|\|3   Reply With Quote

Old 05-23-2007, 01:09 AM   #7 (permalink)
p00onu
C2 100E
Senior Member
Retired Staff Member

High Priest
 
p00onu's Avatar
 
Join Date: Mar 2005
Location: Reno, NV
Posts: 1,934
p00onu has much to be proud ofp00onu has much to be proud ofp00onu has much to be proud ofp00onu has much to be proud ofp00onu has much to be proud ofp00onu has much to be proud of
Send a message via AIM to p00onu Send a message via MSN to p00onu Send a message via Skype™ to p00onu
Default

There is a linked list in the game that contains the sprites to be drawn vs the sprites not to be drawn.
__________________

I get laid.
Quote:
Originally Posted by Disco
i poo you poo we all poo for poo on you
p00onu 15 0FF11|\|3   Reply With Quote

Old 05-23-2007, 05:28 AM   #8 (permalink)
K? Pŕo?ćtiόnŹ
=)
Senior Member
Retired Staff Member

Messiah
 
K? Pŕo?ćtiόnŹ's Avatar
 
Join Date: Oct 2004
Location: Okinawa
Posts: 9,347
K? Pŕo?ćtiόnŹ has a reputation beyond reputeK? Pŕo?ćtiόnŹ has a reputation beyond reputeK? Pŕo?ćtiόnŹ has a reputation beyond reputeK? Pŕo?ćtiόnŹ has a reputation beyond reputeK? Pŕo?ćtiόnŹ has a reputation beyond reputeK? Pŕo?ćtiόnŹ has a reputation beyond reputeK? Pŕo?ćtiόnŹ has a reputation beyond reputeK? Pŕo?ćtiόnŹ has a reputation beyond reputeK? Pŕo?ćtiόnŹ has a reputation beyond reputeK? Pŕo?ćtiόnŹ has a reputation beyond repute
Send a message via AIM to K? Pŕo?ćtiόnŹ
Default

How did I find the DrawBox fxn? When starcraft is drawing the minimap and it is drawing the tiny little blocks to represent units it calls that drawbox fxn, and when I was working on my maphack I stumbled on it and bam, there it is.
__________________
K? Pŕo?ćtiόnŹ 15 0FF11|\|3   Reply With Quote

Old 06-11-2007, 03:26 PM   #9 (permalink)
blaze420

Deviant
 
blaze420's Avatar
 
Join Date: Apr 2007
Location: Australia
Posts: 88
blaze420 is on a distinguished road
Send a message via AIM to blaze420 Send a message via MSN to blaze420 Send a message via Yahoo to blaze420
Default

this help me alot ty
blaze420 15 0FF11|\|3   Reply With Quote

Old 06-15-2007, 05:19 PM   #10 (permalink)
Arcanite
Gold Member

Deviant
 
Join Date: May 2007
Location: Behind You!
Posts: 138
Arcanite is on a distinguished road
Default

I fail to understand where you got this from:

BWFXN_DrawBox dd 004E18C0h

What function does this address need to be and how would you go about finding it?

Besides that I pretty much understand all of the concept of this, so go me.
Arcanite 15 0FF11|\|3   Reply With Quote

Old 06-15-2007, 06:44 PM   #11 (permalink)
Perma
rol 3905h, 8
Senior Member
Administrator

Saint
 
Perma's Avatar
 
Join Date: Jul 2004
Location: Canada
Posts: 5,414
Perma has disabled reputation
Default

Kc explained how he found the box drawing function.

Quote:
Originally Posted by K? Pŕo?ćtiόnŹ View Post
How did I find the DrawBox fxn? When starcraft is drawing the minimap and it is drawing the tiny little blocks to represent units it calls that drawbox fxn, and when I was working on my maphack I stumbled on it and bam, there it is.
Perma 15 0FF11|\|3   Reply With Quote

Old 06-15-2007, 07:54 PM   #12 (permalink)
dt
Administrator

Inquisitor
 
dt's Avatar
 
Join Date: Jul 2004
Location: Germany
Posts: 4,545
dt has a reputation beyond reputedt has a reputation beyond reputedt has a reputation beyond reputedt has a reputation beyond reputedt has a reputation beyond reputedt has a reputation beyond reputedt has a reputation beyond reputedt has a reputation beyond reputedt has a reputation beyond repute
Default

Quote:
Originally Posted by Perma View Post
Actually I think it was Kc who originally found that function a few patches ago. If you're simply converting it, there's no need to reinvent the wheel. You can just create a disassembly of both versions and cross reference them.
http://www.bwhacks.com/forums/showthread.php?t=826

That's when I found the drawing functions. 08-23-2004.
dt 15 0FF11|\|3   Reply With Quote

Old 06-15-2007, 08:18 PM   #13 (permalink)
Perma
rol 3905h, 8
Senior Member
Administrator

Saint
 
Perma's Avatar
 
Join Date: Jul 2004
Location: Canada
Posts: 5,414
Perma has disabled reputation
Default

Quote:
Originally Posted by dt View Post
http://www.bwhacks.com/forums/showthread.php?t=826

That's when I found the drawing functions. 08-23-2004.
I mean in our uh.. era. You hush, old timer.
Perma 15 0FF11|\|3   Reply With Quote

Old 06-18-2007, 05:28 AM   #14 (permalink)
p00onu
C2 100E
Senior Member
Retired Staff Member

High Priest
 
p00onu's Avatar
 
Join Date: Mar 2005
Location: Reno, NV
Posts: 1,934
p00onu has much to be proud ofp00onu has much to be proud ofp00onu has much to be proud ofp00onu has much to be proud ofp00onu has much to be proud ofp00onu has much to be proud of
Send a message via AIM to p00onu Send a message via MSN to p00onu Send a message via Skype™ to p00onu
Default

Quote:
Originally Posted by dt View Post
http://www.bwhacks.com/forums/showthread.php?t=826

That's when I found the drawing functions. 08-23-2004.
You wouldn't happen to still have the pic would you?
__________________

I get laid.
Quote:
Originally Posted by Disco
i poo you poo we all poo for poo on you
p00onu 15 0FF11|\|3   Reply With Quote

Old 06-18-2007, 05:30 AM   #15 (permalink)
dt
Administrator

Inquisitor
 
dt's Avatar
 
Join Date: Jul 2004
Location: Germany
Posts: 4,545
dt has a reputation beyond reputedt has a reputation beyond reputedt has a reputation beyond reputedt has a reputation beyond reputedt has a reputation beyond reputedt has a reputation beyond reputedt has a reputation beyond reputedt has a reputation beyond reputedt has a reputation beyond repute
Default

Why, you don't believe me?
dt 15 0FF11|\|3   Reply With Quote

Old 06-18-2007, 03:58 PM   #16 (permalink)
Arcanite
Gold Member

Deviant
 
Join Date: May 2007
Location: Behind You!
Posts: 138
Arcanite is on a distinguished road
Default

Thanks for the link, interesting stuff =)
Arcanite 15 0FF11|\|3   Reply With Quote