Quantcast

Jump to content

» «
Photo

[Question] Offset of AdditionalVariables?

11 replies to this topic
MasterHK
  • MasterHK

    کیان حامی‏

  • Members
  • Joined: 20 Mar 2013
  • Iran

#1

Posted 15 January 2014 - 03:39 PM

there are several ways for making new local variables but base of all of them is arrays (or

at least like arrays)

so, how can i determine offset of their additional variables?

 

thanks in advance. : )


fastman92
  • fastman92

    фастман92 | ف

  • Members
  • Joined: 28 Jul 2009
  • None

#2

Posted 15 January 2014 - 10:41 PM


Man, this is easy!
In case of int var determine memory ofsset of base.
Then let x = array index read from second var * 4
Add this value to memory address.
  • MasterHK likes this

MasterHK
  • MasterHK

    کیان حامی‏

  • Members
  • Joined: 20 Mar 2013
  • Iran

#3

Posted 16 January 2014 - 02:47 AM

Thank You : )


MasterHK
  • MasterHK

    کیان حامی‏

  • Members
  • Joined: 20 Mar 2013
  • Iran

#4

Posted 16 January 2014 - 03:03 AM

But I don't understand... :catspider:

Could you write an example, plz?


Wesser
  • Wesser

    The complexity simplifier, the efficiency optimizer.

  • Feroci Racing
  • Joined: 19 Aug 2006
  • Unknown

#5

Posted 16 January 2014 - 10:41 AM

He mean something like this:
0A90: 1@ = LVAR_INDEX * 0x04 // Var offset.
0A8E: 2@ = 0@ + 1@ // Var pointer.
  • MasterHK likes this

MasterHK
  • MasterHK

    کیان حامی‏

  • Members
  • Joined: 20 Mar 2013
  • Iran

#6

Posted 16 January 2014 - 02:53 PM

Tnx...

 

LVAR_INDEX is the array index as 31@ in 0@(31@,1i) ?


fastman92
  • fastman92

    фастман92 | ف

  • Members
  • Joined: 28 Jul 2009
  • None

#7

Posted 16 January 2014 - 06:25 PM Edited by fastman92, 16 January 2014 - 06:27 PM.

Tnx...
 
LVAR_INDEX is the array index as 31@ in 0@(31@,1i) ?

Value from 31@

Perhaps this opcode works with arrays:
0AC7: 5@ = var 0@(31@,1i) offset
But I never tested.
  • MasterHK likes this

MasterHK
  • MasterHK

    کیان حامی‏

  • Members
  • Joined: 20 Mar 2013
  • Iran

#8

Posted 16 January 2014 - 07:22 PM

OK.

in fact i want to load values from another thread; the thread that load textures from an external dic using DK's opcodes.

i want handle(?) of those textures; currently i made several threads but if this way work it will be easier.


fastman92
  • fastman92

    фастман92 | ف

  • Members
  • Joined: 28 Jul 2009
  • None

#9

Posted 16 January 2014 - 08:30 PM

0AAA: 0@ = thread 'OTB' pointer


This opcode returns a pointer to CRunningScript object of script identified by a name.
Name must be altered by an opcode 03A4 previously.

03A4: name_thread 'MAIN'
:getLocalVarOffset
{
 Parameters:
   Passed:
     0@ - thread pointer
     1@ - var number
   Result:
     1@ - var value

 Example:
   0AB1: call_scm_func @getLocalVarOffset 2 thread 0@ var 0 store_to 1@ 
}
1@ *= 4
1@ += 60
005A: 0@ += 1@  // (int)
0AB2: ret 1 0@
When you have variable number and script pointer, you can use this function.

As you know in case of arrays, the variable ID is base variable ID + index read from secondary variable.
  • MasterHK likes this

MasterHK
  • MasterHK

    کیان حامی‏

  • Members
  • Joined: 20 Mar 2013
  • Iran

#10

Posted 17 January 2014 - 03:50 AM

oh, i had seen that func some time ago but i need a func to get offset of variables that this func have made them:

 

:MakeMoreVariables
2@ = Thread.Pointer()
2@ += 60
{3@ = Thread.Pointer()
3@ += 16
3@ = Memory.Read(3@, 4, 0)
0062: 3@ -= 0@ // (int)}
0AC6: 3@ = label 0@ offset
0062: 3@ -= 2@ // (int)
3@ /= 16
3@ += 1
3@ *= 16
0072: 3@ /= 1@ // (int)
ret 1 3@
 

 

Currently i'm using a funny function for that intent;

like this:

 

0@ = Actor.CurrentWeapon($3)
call_scm_func @draw 1 0@
...
:draw
if
    0@ < 32
then
    1@ = Thread.PointerByName('HUDPIC2')
    0@ -= 32        
else
    1@ = Thread.PointerByName('HUDPIC1')
end
2@ = Thread.GetLocalVar(1@, 0@)
if
    2@ <> 0
then
DRAW IT

and content of HUDPIC1/2:

 

Thread.SetName('HUDPIC1')
0@ = Texture.LoadByTXDName("Fist", "MYTXD")
...
31@ = Texture.LoadByTXDName("M4", "MYTXD")

 

Thread.SetName('HUDPIC2')
0@ = Texture.LoadByTXDName("TEC9", "MYTXD")
...

 

works correctly but in this case i need at least 3 threads and it's Not So Good.

 

hopefully anyone can, help me... : (


madleg
  • madleg

    Player Hater

  • Members
  • Joined: 01 Jan 2014
  • Russia

#11

Posted 17 January 2014 - 11:40 AM Edited by madleg, 17 January 2014 - 11:54 AM.

lol, you just need to create hex...end construction with empty bites and mark his start with a label. all other things will be like with your threads, just in the beginning you need to save your vars in it. an example:

//i have to load 4 textures, so i need (4handlers)*(4bites.each.var)=(16bites.free.space)
0@ = label @some_memory offset
1@=load texture 'blabla1'
write memory 0@ value 1@
0@ += 4
1@=load texture 'blabla2'
write memory 0@ value 1@
0@ += 4
...etc

// btw, i hardly recommend to rename textures with repeating name+index string 
// and replace this shi with some for..end with editing of this dynamic string in it

while true
   wait 0
   0@ = label @some_memory offset
   1@ = actor weapone 
// ill skip checks here
   1@ *= 4
   0@ += 1@
   1@ = read mem 0@
   draw texture 1@
end

:some_memory
hex
00 00 00 00
00 00 00 00
00 00 00 00
00 00 00 00
end
  • MasterHK likes this

MasterHK
  • MasterHK

    کیان حامی‏

  • Members
  • Joined: 20 Mar 2013
  • Iran

#12

Posted 17 January 2014 - 12:11 PM

Yes, an good replace for my purpose.

But i'm still searching for get offset of them,

... however thank you so much for lost your time in writing answer. :)





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users