Difference between revisions of "057F"

From GTAMods Wiki
Jump to navigation Jump to search
(trying out disassembly)
Line 1: Line 1:
{{Icon|VC}} '''GET_BUS_FARES_COLLECTED_BY_PLAYER'''
+
{{OpCode
<hr />
+
| games      = {{Icon|VC}}
'''Description'''
+
| command    = GET_BUS_FARES_COLLECTED_BY_PLAYER
: Gets the bus fares collected by the player
+
| description = Gets the bus fares collected by the player
'''Syntax'''
+
| syntax1    = 057F: get_player [''player handle''] store_coach_passengers_dropped_off_to [''var'']
: 057F: get_player [''player handle''] store_coach_passengers_dropped_off_to [''var'']
+
| p1t        = [''player handle'']
'''Parameter'''
+
| p1d        = The [[0053|handle of the player]]
: [''player handle'']
+
| p2t        = [''var'']
:: The handle of the [[0053|player]]
+
| p2d        = Variable to store the integer value
: [''var'']
+
}}
:: Variable to store the integer value
 
  
This opcode gets the bus fares collected by the player so far. Bus fares can only be collected when you are stopped in a Coach at a bus stop. Each fare costs $5 so the value it can return will be in multiples of 5. Once this opcode is called, the bus fares collected ''will reset to 0 afterwards'' so you must store the value to another variable if you want to keep track of the total bus fares collected. You do not need to be in a Coach to use this opcode. The original script called this opcode only in the 'BUS' thread.
+
This opcode gets the bus fares collected by the player so far. Bus fares can only be collected when you are stopped in a Coach at a bus stop. Each fare costs $5 so the value it can return will be in multiples of 5. Once this opcode is called, the bus fares collected ''will reset to 0 afterwards'' so you must store the value to another variable if you want to keep track of the total bus fares collected. You do not need to be in a Coach to use this opcode. The original script called this opcode only in the 'BUS' script.
  
 
== Disassembled code ==
 
== Disassembled code ==
This is disassembled code for this opcode from v1.0 US.
+
This is disassembled code for this opcode from PC v1.0 US.
<syntaxhighlight lang="asm">
+
<syntaxhighlight lang="nasm" style="overflow-x: auto;">
; call subroutine to collect values from input parameters
+
loc_637836:
.text:00637836                lea    eax, [ebx+10h]
+
    lea    eax, [ebx+10h]                   ; get address of script's current instruction pointer
.text:00637839                mov    ecx, ebx
+
    mov    ecx, ebx                         ; get CRunningScript pointer for thiscall
.text:0063783B                push    1 ; one parameter to collect
+
    push    1                                 ; push 1 for one parameter to collect
.text:0063783D                push    eax
+
    push    eax                               ; push address of script's current instruction pointer
.text:0063783E                call    CRunningScript__CollectParameters
+
    call    CRunningScript::CollectParameters ; call CRunningScript::CollectParameters
; read collected content
+
    mov    edi, ds:ScriptParams[0]          ; get value of first parameter, the player handle
.text:00637843                mov    edi, ds:_opcodeParameter1
+
    imul    edi, 170h
.text:00637849                imul    edi, 170h
+
    push    1                                 ; push 1 for one parameter to store
.text:0063784F                push    1
+
    add    edi, offset CWorld::Players
.text:00637851                add    edi, offset _playerInfo  ; pointer to the player
+
    mov    ecx, [edi]                       ; get address of player ped at CWorld::Players + player handle * 0x170
.text:00637857                mov    ecx, [edi]
+
    mov    eax, [ecx+6D4h]                   ; offset player ped address by 0x6D4 to get bus fares collected
.text:00637859                mov    eax, [ecx+6D4h] ; offset 0x6D4 to get bus fares collected
+
    mov    ecx, ebx                         ; get CRunningScript pointer for thiscall
.text:0063785F                mov    ecx, ebx
+
    mov    ds:ScriptParams[0], eax           ; store bus fares collected
.text:00637861                mov    ds:_opcodeParameter1, eax
+
    mov    eax, [edi]                       ; get address of player ped at CWorld::Players + player handle * 0x170
.text:00637866                mov    eax, [edi]
+
    mov    dword ptr [eax+6D4h], 0           ; offset player ped address by 0x6D4 to set bus fares collected to 0
.text:00637868                mov    dword ptr [eax+6D4h], 0 ; set bus fares collected to 0 after getting it
+
    lea    eax, [ebx+10h]                   ; get address of script's current instruction pointer
; call subroutine to store value from output parameter into variable
+
    push    eax                               ; push address of script's current instruction pointer
.text:00637872                lea    eax, [ebx+10h]
+
    call    CRunningScript::StoreParameters  ; call CRunningScript::StoreParameters
.text:00637875                push    eax
+
    lea    esp, [ebp-0Ch]
.text:00637876                call    CRunningScript__StoreParameters
+
    xor    al, al                           ; return 0
; end
 
.text:0063787B                lea    esp, [ebp-0Ch]
 
.text:0063787E                xor    al, al
 
.text:00637880                pop    edi
 
.text:00637881                pop    esi
 
.text:00637882                pop    ebx
 
.text:00637883                pop    ebp
 
.text:00637884                retn    4
 
 
</syntaxhighlight>
 
</syntaxhighlight>
  
 
== Keywords ==
 
== Keywords ==
 
get, store, bus, coach, collect, collected, dropped, off, passenger
 
get, store, bus, coach, collect, collected, dropped, off, passenger
 
[[Category:OpCodes]]
 

Revision as of 01:42, 23 November 2016

Vice City GET_BUS_FARES_COLLECTED_BY_PLAYER


Description
Gets the bus fares collected by the player
Syntax
057F: get_player [player handle] store_coach_passengers_dropped_off_to [var]
Parameter
[player handle]
The handle of the player
[var]
Variable to store the integer value

This opcode gets the bus fares collected by the player so far. Bus fares can only be collected when you are stopped in a Coach at a bus stop. Each fare costs $5 so the value it can return will be in multiples of 5. Once this opcode is called, the bus fares collected will reset to 0 afterwards so you must store the value to another variable if you want to keep track of the total bus fares collected. You do not need to be in a Coach to use this opcode. The original script called this opcode only in the 'BUS' script.

Disassembled code

This is disassembled code for this opcode from PC v1.0 US.

loc_637836:
    lea     eax, [ebx+10h]                    ; get address of script's current instruction pointer
    mov     ecx, ebx                          ; get CRunningScript pointer for thiscall
    push    1                                 ; push 1 for one parameter to collect
    push    eax                               ; push address of script's current instruction pointer
    call    CRunningScript::CollectParameters ; call CRunningScript::CollectParameters
    mov     edi, ds:ScriptParams[0]           ; get value of first parameter, the player handle
    imul    edi, 170h
    push    1                                 ; push 1 for one parameter to store
    add     edi, offset CWorld::Players
    mov     ecx, [edi]                        ; get address of player ped at CWorld::Players + player handle * 0x170
    mov     eax, [ecx+6D4h]                   ; offset player ped address by 0x6D4 to get bus fares collected
    mov     ecx, ebx                          ; get CRunningScript pointer for thiscall
    mov     ds:ScriptParams[0], eax           ; store bus fares collected
    mov     eax, [edi]                        ; get address of player ped at CWorld::Players + player handle * 0x170
    mov     dword ptr [eax+6D4h], 0           ; offset player ped address by 0x6D4 to set bus fares collected to 0
    lea     eax, [ebx+10h]                    ; get address of script's current instruction pointer
    push    eax                               ; push address of script's current instruction pointer
    call    CRunningScript::StoreParameters   ; call CRunningScript::StoreParameters
    lea     esp, [ebp-0Ch]
    xor     al, al                            ; return 0

Keywords

get, store, bus, coach, collect, collected, dropped, off, passenger