How/where to find EXTRN variables?

Bare metal programming in PureBasic, for experienced users
citystate
Enthusiast
Enthusiast
Posts: 638
Joined: Sun Feb 12, 2006 10:06 pm

How/where to find EXTRN variables?

Post by citystate »

Hi guys,

I've been trying some of Freak's old, old code to determine the current DrawingMode in a Start/Stop drawing block, but I can't figure out where to find the EXTRN variables; so get back a fatal POLINK error: unresolved external(s). This is the code I'm using:

Code: Select all

Procedure GetDrawingMode()
  !EXTRN  _PB_2DDrawing_CurrentMode
  !MOV EAX, [_PB_2DDrawing_CurrentMode]
  ProcedureReturn
EndProcedure
I can only guess that the internals have changed significantly since 2004 (see other thread )

any help would be appreciated

thanks
there is no sig, only zuul (and the following disclaimer)

WARNING: may be talking out of his hat
User avatar
Shield
Addict
Addict
Posts: 1021
Joined: Fri Jan 21, 2011 8:25 am
Location: 'stralia!
Contact:

Re: How/where to find EXTRN variables?

Post by Shield »

There is no documentation on them because it is generally a very bad idea
to rely on them in the first place.

You might be able to find them when you analyze the libraries.
For this example, it might be worth it to wait for an answer from freak. :)
Image
Blog: Why Does It Suck? (http://whydoesitsuck.com/)
"You can disagree with me as much as you want, but during this talk, by definition, anybody who disagrees is stupid and ugly."
- Linus Torvalds
User avatar
luis
Addict
Addict
Posts: 3876
Joined: Wed Aug 31, 2005 11:09 pm
Location: Italy

Re: How/where to find EXTRN variables?

Post by luis »

Don't you set by YOURSELF in YOUR code the drawing mode ?
If the answer is yes, you can simply save it and query it when needed later.
You can use a couple of macros to override the PB commands and a global var for example, this way work with code made by other people too, as long it is in source format.
"Have you tried turning it off and on again ?"
A little PureBasic review
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Re: How/where to find EXTRN variables?

Post by ts-soft »

PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
citystate
Enthusiast
Enthusiast
Posts: 638
Joined: Sun Feb 12, 2006 10:06 pm

Re: How/where to find EXTRN variables?

Post by citystate »

luis wrote:Don't you set by YOURSELF in YOUR code the drawing mode ?
If the answer is yes, you can simply save it and query it when needed later.
You can use a couple of macros to override the PB commands and a global var for example, this way work with code made by other people too, as long it is in source format.
usually, yes - I'm looking to create some additions in the drawing library, it would be useful to know what the current drawing mode is, to change the fill property of custom shapes (for example)

yes, I could just create a macro, but the idea is to include these in a library - that won't work (afaik)
Shield wrote:You might be able to find them when you analyze the libraries.
For this example, it might be worth it to wait for an answer from freak.
I'm somewhat new to ASM, and I'm not 100% sure how to analyse the libraries (I'll have to check out ts-soft's link) - considering this is just a case of not knowing the correct EXTRN variable, I'd tend to agree with you; waiting for freak seems like the best option - fortunately I'm not in any hurry :)



in any case, thanks for your input guys
there is no sig, only zuul (and the following disclaimer)

WARNING: may be talking out of his hat
User avatar
luis
Addict
Addict
Posts: 3876
Joined: Wed Aug 31, 2005 11:09 pm
Location: Italy

Re: How/where to find EXTRN variables?

Post by luis »

citystate wrote: yes, I could just create a macro, but the idea is to include these in a library - that won't work (afaik)
If you mean a "binary" library (tailbite ?) yes, it will not work. If you just mean something included in source form, written by you or someone else, it should.

Code: Select all

Define CurrDrawingMode = #PB_2DDrawing_Default 

Procedure MyDrawingMode (mode) 
 Shared CurrDrawingMode 
 DrawingMode(mode)
 CurrDrawingMode = mode
EndProcedure

Macro DrawingMode (mode)
 MyDrawingMode (mode) 
EndMacro

Procedure.i GetDrawingMode()
 Shared CurrDrawingMode 
 ProcedureReturn CurrDrawingMode 
EndProcedure


CreateImage(1, 320, 200, 32)

StartDrawing(ImageOutput(1))   
  Debug #PB_2DDrawing_Default 
  Debug GetDrawingMode()
  
  DrawingMode(#PB_2DDrawing_AllChannels)
  Debug #PB_2DDrawing_AllChannels
  Debug GetDrawingMode()
  
  DrawingMode(#PB_2DDrawing_AlphaBlend)
  Debug #PB_2DDrawing_AlphaBlend
  Debug GetDrawingMode()  
StopDrawing()
"Have you tried turning it off and on again ?"
A little PureBasic review
citystate
Enthusiast
Enthusiast
Posts: 638
Joined: Sun Feb 12, 2006 10:06 pm

Re: How/where to find EXTRN variables?

Post by citystate »

ts-soft wrote:http://www.realsource.de/downloads/doc_ ... or-pb-libs :wink:
PBLIBTool should show all infos.
thanks ts-soft, this brought me closest to solving the problem - but it seems like the symbol no longer exists (and nothing appears to have replaced it)... unless an asm guru steps up with a magic fix, I'll either simulate it with parameters, or use macros in a pbi - really wanted a self contained lib, though - oh well.
there is no sig, only zuul (and the following disclaimer)

WARNING: may be talking out of his hat
Post Reply