Code:
486138 <>VariableOperations 2k3: 4ACB18
486148 xor edx,edx EDX = 0 (check flags for SingleVar/VarRange/VarReference)
48614C call sub_45E524 call GetEvParam
486151 cmp eax,2 Was "Var_ID by the value in Var[....]" checked?
486154 jnz ump if it wasn't
486156 mov edx,1 EDX = 1 (get Var_ID from the first highlighted box)
48615D call sub_45E524 call GetEvParam
486162 mov edx,eax get the VarRef's ID into EDX
48616B call sub_469EE0 call GetVar //get the value of Var[EDX]
486170 mov esi,eax memorize the value of Var[EDX] (will be the new Var_ID)
486172 jmp
486174 mov edx,1 EDX = 1 (get Var_ID from the first highlighted box)
48617B call sub_45E524 call GetEvParam
486180 mov esi,eax memorize Var_ID
486182 xor edx,edx EDX = 0 (check flags for SingleVar/VarRange/VarReference)
486186 call sub_45E524 call GetEvParam
48618B dec eax EAX:0 = SingleVar | EAX:1 = VarRange | EAX:2 = VarRef
48618C jnz jump in case of SingleVar/VarRef
48618E mov edx,2 EDX = 2 (get Var_ID from the second VarRange box)
486195 call sub_45E524 call GetEvParam (Var_ID in EAX)
48619A jmp
48619C mov eax,esi get memorized Var_ID (in case of SingleVar/VarRef)
48619E mov edi,esi get memorized Var_ID
4861A0 mov ebp,eax get Var_ID (2nd box in case of VarRange)
4861A2 sub ebp,edi subtract Var_ID(2nd option) by Var_ID(1st option)
4861A4 jl jump if VarRange: 1st option higher than 2nd option
//This does NOT flip the VarRange around! To support reversed VarRanges:
//4861A4 set [7D 04 89 C7 F7 DD]
4861AA inc ebp VarRangePtr (1 if SingleVar/VarRef/same-same-Range)
4861AB xor esi,esi reset ESI
4861AD mov edx,4 4 = get checked Operand)
4861B4 call sub_45E524 call GetEvParam
4861C2 jmp branch jumps to the selected operand
eax = 0 jmp loc_4861ED -> Number
eax = 1 jmp loc_486200 -> value of Var
eax = 2 jmp loc_486221 -> value in Var_ID
eax = 3 jmp loc_486250 -> Random
eax = 4 jmp loc_4862A8 -> Item
eax = 5 jmp loc_486302 -> Hero
eax = 6 jmp loc_4865A2 -> Event
eax = 7 jmp loc_48664C -> Other
eax = 8 jmp loc_48671B -> Enemy (in battle)
loc_4861ED (number)
4861ED mov edx,5 5 = get the 1st highlighted box in the Operands' section
4861F4 call sub_45E524 call GetEvParam
4861F9 mov esi,eax memorize value
4861FB jmp jump to the calculation
loc_486200 (VarRef)
486200 mov edx,5 5 = get the 1st highlighted box in the Operands' section
486207 call sub_45E524 call GetEvParam
48620C mov edx,eax get the value into EDX
486215 call sub_469EE0 call GetVar //get the value of Var[EDX]
48621A mov esi,eax memorize value
48621C jmp jump to the calculation
loc_486221 (VarRefPtr)
486221 mov edx,5 5 = get the 1st highlighted box in the Operands' section
486228 call sub_45E524 call GetEvParam
48622D mov edx,eax get the value into EDX
486236 call sub_469EE0 call GetVar //get the value of Var[EDX]
48623B mov edx,eax get this VarPointer's value into EDX
486244 call sub_469EE0 call GetVar //gets final value from Var[Var[EDX]]
486249 mov esi,eax memorize value
48624B jmp jump to the calculation
loc_486250 (Random)
486250 mov edx,5 5 = get the 1st highlighted box in the Operands' section
486257 call sub_45E524 call GetEvParam
48625C mov esi,eax get the min.value of the RandomOperand
48625E mov edx,6 6 = get the 2nd highlighted box in the Operands' section
486265 call sub_45E524 call GetEvParam
48626A get the max.value of the RandomOperand
48626E cmp compare min.value with max.value
486272 jle jump if min.value is in fact the minimum (= not above max.)
486274 mov eax,esi get the 1st box's content of the RandomOperand
486276 sub subtract 1st box(bigger value) by 2nd box(smaller value)
48627A inc eax makes the (new) max.value available for rolling, too
48627B call sub_402B40 call RollDice //rolls 0..EAX
486280 add add 2nd box's content to the rolled value
486284 mov esi,eax memorize value (2nd box + random)
486286 jmp jump to the calculation
48628B cmp compare min.value with max.value
48628F jge jump if both are the same value
486295 get the 2nd box's content of the RandomOperand
486299 sub eax,esi subtract 2nd box(max.value) by 1st box(min.value)
48629B inc eax makes the max.value available for rolling, too
48629C call sub_402B40 call RollDice //rolls 0..EAX
4862A1 add esi,eax memorize value (1st box + random)
4862A3 jmp jump to the calculation
loc_4862A8 (Item)
4862A8 mov edx,6 6 = get the 2nd highlighted box in the Operands' section
4862AF call sub_45E524 call GetEvParam (Output EAX: 0=Owned | 1=Equipped)
4862B7 jb jump on OwnedAmount
4862B9 jz jump on EquippedAmount
4862BB jmp jump on invalid options
4862C0 mov edx,5 5 = get the 1st highlighted box in the Operands' section
4862C7 call sub_45E524 call GetEvParam
4862CC mov edx,eax get Item_ID into EDX
4862D5 call sub_47D2A0 call GetItemAmount (of the Item_ID in EDX)
4862DA mov esi,eax memorize value
4862DC jmp jump to the calculation
4862E1 mov edx,5 5 = get the 1st highlighted box in the Operands' section
4862E8 call sub_45E524 call GetEvParam
4862ED mov edx,eax get Item_ID into EDX
4862F6 call sub_47D2CC call GetEquippedAmount (of the Item_ID in EDX)
4862FB mov esi,eax memorize value
4862FD jmp jump to the calculation
loc_486302 (Hero)
486302 mov edx,6 6 = get the 2nd highlighted box in the Operands' section
486309 call sub_45E524 call GetEvParam
486317 jmp branch by selected Hero_Parameter
eax = 0 jmp loc_48635A -> Level
eax = 1 jmp loc_486380 -> Exp
eax = 2 jmp loc_4863A6 -> HP
eax = 3 jmp loc_4863C8 -> MP
eax = 4 jmp loc_4863EA -> max.HP
eax = 5 jmp loc_486410 -> max.MP
eax = 6 jmp loc_486436 -> Str
eax = 7 jmp loc_48645C -> Def
eax = 8 jmp loc_486482 -> Int
eax = 9 jmp loc_4864A8 -> Agi
eax = 10 jmp loc_4864CE -> Item_ID in EquipSlot#1
eax = 11 jmp loc_4864F6 -> Item_ID in EquipSlot#2
eax = 12 jmp loc_486521 -> Item_ID in EquipSlot#3
eax = 13 jmp loc_48654C -> Item_ID in EquipSlot#4
eax = 14 jmp loc_486577 -> Item_ID in EquipSlot#5
loc_48635A
486366 mov edx,eax get Hero_ID
486368 off_49ACE8 = ActorDataPtr
48636F call sub_482A78 get HeroData
486374 call sub_4833D8 get Hero's Level into EAX
486379 mov esi,eax memorize value
loc_486380
48638C mov edx,eax get Hero_ID
48638E off_49ACE8 = ActorDataPtr
486395 call sub_482A78 get HeroData
48639A call sub_48341C get Hero's Exp into EAX
48639F mov esi,eax memorize value
loc_4863A6
4863B2 mov edx,eax get Hero_ID
4863BB call sub_482A78 get HeroData
4863C0 mov esi,[eax+14] memorize Hero's HP
loc_4863C8
4863CD mov edx,eax get Hero_ID
4863DD call sub_482A78 get HeroData
4863E2 mov esi,[eax+18] memorize Hero's MP
loc_4863EA
4863EF mov edx,eax get Hero_ID
4863FF call sub_482A78 get HeroData
486406 call get Hero's max.HP
486409 mov esi,eax memorize value
loc_486410
48641C mov edx,eax get Hero_ID
486425 call sub_482A78 get HeroData
48642C call get Hero's max.MP
48642F mov esi,eax memorize value
loc_486436
486442 mov edx,eax get Hero_ID
48644B call sub_482A78 get HeroData
486450 call sub_481748 get Hero's Str
486455 mov esi,eax memorize value
loc_48645C
486468 mov edx,eax get Hero_ID
486471 call sub_482A78 get HeroData
486476 call sub_4817B8 get Hero's Def
48647B mov esi,eax memorize value
loc_486482
48648E mov edx,eax get Hero_ID
486497 call sub_482A78 get HeroData
48649C call sub_481828 get Hero's Int
4864A1 mov esi,eax memorize value
loc_4864A8
4864B4 mov edx,eax get Hero_ID
4864BD call sub_482A78 get HeroData
4864C2 call sub_481898 get Hero's Agi
4864C7 mov esi,eax emorize value
loc_4864CE
4864DA mov edx,eax get Hero_ID
4864E3 call sub_482A78 get HeroData
4864E8 xor edx,edx 0 = EquipSlot#1
4864EA call sub_483870 call GetEquippedItem (by Hero_ID in EAX and Slot_ID in EDX)
4864EF mov esi,eax memorize value
loc_4864F6
486502 mov edx,eax get Hero_ID
48650B call sub_482A78 get HeroData
486510 mov edx,1 1 = EquipSlot#2
486515 call sub_483870 call GetEquippedItem
48651A mov esi,eax memorize value
loc_486521
48652D mov edx,eax get Hero_ID
486536 call sub_482A78 /get HeroData
48653B mov edx,2 2 = EquipSlot#3
486540 call sub_483870 call GetEquippedItem
486545 mov esi,eax memorize value
loc_48654C
486558 mov edx,eax get Hero_ID
486561 call sub_482A78 get HeroData
486566 mov edx,3 3 = EquipSlot#4
48656B call sub_483870 call GetEquippedItem
486570 mov esi,eax memorize value
loc_486577
486583 mov edx,eax get Hero_ID
48658C call sub_482A78 get HeroData
486591 mov edx,4 4 = EquipSlot#5
486596 call sub_483870 call GetEquippedItem
48659B mov esi,eax memorize value
loc_4865A2 (Event)
4865A2 mov edx,5 5 = get the 1st highlighted box in the Operands' section
4865A9 call sub_45E524 call GetEvParam
4865AE mov edx,eax get Event_ID(?)
4865B0 ??
4865B4 ??
4865B7 call sub_485B4C load current MapData(?) of the Event
4865C0 mov edx,6 6 = get the 2nd highlighted box in the Operands' section
4865C7 call sub_45E524 call GetEvParam
4865D5 jmp branch by selected MapInformation
eax = 0 jmp loc_4865F4 -> Map_ID
eax = 1 jmp loc_486600 -> x-Pos on the grid
eax = 2 jmp loc_48660C -> y-Pos on the grid
eax = 3 jmp loc_486618 -> FacingDirection
eax = 4 jmp loc_48662C -> x-Pos on the Screen
eax = 5 jmp loc_48663C -> y-Pos on the Screen
loc_4865F4
4865F4 get Event's MapData(?)
4865F8 mov esi,[eax+10] memorize Map_ID
4865FB jmp jump to the calculation
loc_486600
486600 get Event's MapData(?)
486604 mov esi,[eax+14] memorize Grid_x-Pos
486607 jmp jump to the calculation
loc_48660C
48660C get Event's MapData(?)
486610 mov esi,[eax+18] memorize Grid_y-Pos
486613 jmp jump to the calculation
loc_486618
486618 get Event's MapData(?)
48661C movsz [eax+1D] get FacingDirection(?)
486620 mov esi,[eax*4] memorize FacingDirection
loc_48662C
48662C get Event's MapData(?)
486630 call sub_490080 get Screen_x-Pos(?)
486635 mov esi,eax memorize value
loc_48663C
48663C get Event's MapData(?)
486640 call sub_49015C get Screen_y-Pos(?)
486645 mov esi,eax memorize value
loc_48664C (Other)
48664C mov edx,5 5 = get the 1st highlighted box in the Operands' section
486653 call sub_45E524 call GetEvParam
486661 jmp branch
eax = 0 jmp loc_48668C -> Money
eax = 1 jmp loc_48669B -> Timer_seconds
eax = 2 jmp loc_4866AE -> PartySize
eax = 3 jmp loc_4866BD -> Saves#
eax = 4 jmp loc_4866CF -> Battles#
eax = 5 jmp loc_4866DE -> Victories#
eax = 6 jmp loc_4866ED -> Defeats#
eax = 7 jmp loc_4866FC -> Escapes#
eax = 8 jmp loc_48670B -> MidTickPos
loc_48668C
48668C off_49AA9C = InventoryDataPtr
486693 mov esi,[eax+1C] memorize Money
486696 jmp jump to the calculation
loc_48669B
48669B off_49AA9C = InventoryDataPtr
4866A2 call sub_47D5BC get Timer_seconds
4866A7 mov esi,eax memorize value
4866A9 jmp jump to the calculation
loc_4866AE
4866AE off_49AA9C = InventoryDataPtr
4866B5 mov esi,[eax+4] memorize PartySize
4866B8 jmp jump to the calculation
loc_4866BD
4866BD off_49ABA4 = MainPtr
4866C4 mov esi,[eax+C0] memorize number of Saves
4866CA jmp jump to the calculation
loc_4866CF
4866CF off_49AA9C = InventoryDataPtr
4866D6 mov esi,[eax+38] memorize Battles#
4866D9 jmp jump to the calculation
loc_4866DE
4866E5 mov esi,[eax+3C] memorize Victories#
4866E8 jmp jump to the calculation
loc_4866ED
4866F4 mov esi,[eax+40] memorize Defeats#
4866F7 jmp jump to the calculation
loc_4866FC
486703 mov esi,[eax+44] memorize Escapes#
486706 jmp jump to the calculation
loc_48670B
48670B off_49AE4C = MusicPtr(?)
486712 call get current PlayPosition in the MIDI
486714 mov esi,eax memorize value
486716 jmp jump to the calculation
loc_48671B (Enemy)
48671B mov edx,6 6 = get the 2nd highlighted box in the Operands' section
486722 call sub_45E524 call GetEvParam
486730 jmp branch
eax = 0 jmp loc_486757 > HP
eax = 1 jmp loc_486779 -> MP
eax = 2 jmp loc_48679B -> max.HP
eax = 3 jmp loc_4867C1 -> max.MP
eax = 4 jmp loc_4867E7 -> Str
eax = 5 jmp loc_48680A -> Def
eax = 6 jmp loc_48682D -> Int
eax = 7 jmp loc_486850 -> Agi
loc_486757
486757 mov edx,5 5 = get the 1st highlighted box
48675E call sub_45E524 call GetEvParam
486763 mov edx,eax get EnemyPartySlot_ID
486765 off_49AD80 = EnemyPartyPtr
48676C call sub_480270 call GetEnemy (by EnemyPartySlot_ID)
486771 mov esi,[eax+14] memorize Enemy_HP
486774 jmp jump to the calculation
loc_486779
...
486793 mov esi,[eax+18] memorize Enemy_MP
486796 jmp jump to the calculation
loc_48679B
...
4867B7 call get Enemy_max.HP
4867BA mov esi,eax memorize value
4867BC jmp jump to the calculation
loc_4867C1
...
4867DD call get Enemy_max.MP
4867E0 mov esi,eax memorize value
4867E2 jmp jump to the calculation
loc_4867E7
...
4867F5 off_49AD80 = EnemyPartyPtr
4867FC call sub_480270 call GetEnemy
486801 call sub_481748 get Enemy_Str
486806 mov esi,eax memorize value
486808 jmp jump to the calculation
loc_48680A
...
486824 call sub_4817B8 get Enemy_Def
486829 mov esi,eax memorize value
48682B jmp jump to the calculation
loc_48682D
...
486847 call sub_481828 get Enemy_Int
48684C mov esi,eax memorize value
48684E jmp jump to the calculation
loc_486850
...
48686A call sub_481898 get Enemy_Agi
48686F mov esi,eax memorize value
486871 off_49ABA4 = MainPtr
486878 mov edx,edi get memorized Var_ID (of the altered Var)
48687A call sub_469EE0 get unaltered value of the Variable
48687F cdq temporarily create 'EAX:EDX' for calculations
486880 memorize old value
486884 ??calculation's remainder(?)
486888 mov edx,3 3 = get checked Operation
48688F call sub_45E524 call GetEvParam
486894 cmp eax,4 Is [div] or [mod] checked?
486897 jl jump on [set],[add],[sub],[mul]
486899 test esi,esi Is ESI = 0?
48689B jnz jump if it isn't
48689D mov esi,1 set Operand's value to 1 //avoids division by zero
4868A2 mov edx,3 3 = get checked Operation
4868A9 call sub_45E524 call GetEvParam
4868B7 jmp branch
eax = 0 jmp loc_4868D6 -> set
eax = 1 jmp loc_4868E6 -> add
eax = 2 jmp loc_4868FB -> sub
eax = 3 jmp loc_48691B -> mul
eax = 4 jmp loc_486937 -> div
eax = 5 jmp loc_486953 -> mod
...
4869C1 off_49ABA4 = MainPtr
4869C8 get new value to put into the Variable
4869CC mov edx,edi get Var_ID to put the new value in
4869CE call sub_469EF8 call SetVar
4869D3 inc edi Var_ID +1
4869D4 dec ebp EBP is bigger than 1 when VarRange was used
4869D5 jnz jump on VarRange until every Variable was changed
4869DB off_49AC98 = EventDataPtr
4869E5 call sub_48C648 update Events