{$CLEO}
jump @start
0662: NOP "Opcode ID: 003E"
0662: NOP "Version: 1.0"
0662: NOP "Compatible with:"
0662: NOP "GTA San Andreas v1.0 [US] HOODLUM No-CD  Fixed EXE"
0662: NOP "GTA: San Andreas v1.01 [EURO] No-CD/Fixed EXE" 
0000: NOP
0662: NOP "opcodes.txt:    003E: overwrite_camera_movement_state 2"
0662: NOP "SASCM.INI:      003E=1,overwrite_camera_movement_state %1d%"
0000: NOP
0662: NOP "Author: fastman92"
0662: NOP "Visit my site: fastman92.tk"
:start
{$INCLUDE functions/Detect_EXE_version.txt}
{
Opcode 003D
opcodes.txt:    003E: overwrite_camera_movement_state 2 
SASCM.INI:      003E=1,overwrite_camera_movement_state %1d%
}    

CONST
GAME_VERSION = 0@
SCRIPT_POINTER = 1@
end

:opcode_003E_initialize
0AB1: call_scm_func @Get_EXE_version_ID 0 get_version_number_to 0@
0A9F: 1@ = current_thread_pointer
1@ += 0x10
0A8D: 1@ = read_memory 1@ size 4 virtual_protect 0      // Script content


// CCam__ProcessRotationOnFootMouseMode_Horizontally
0AB1: call_scm_func @ArrayGetValueByIndex num_params 7 index GAME_VERSION total_values 2 default_value 0 index1 VERSION_1_0_US_CRACKED value1 0x00523F4B index2 VERSION_1_01_EURO_CRACKED value2 0x005243EB store_value_to 5@
0AB1: call_scm_func @asm_PutOnAddressJmpFarToLabel 4 script_content SCRIPT_POINTER source_address 5@ source_virtual_protect true destination @CCam__ProcessRotationOnFootMouseMode_Horizontally_part

0AB1: call_scm_func @asm_PutOnLabelAbsoluteAddressToLabel 3 script_content SCRIPT_POINTER source_label @CCam__ProcessRotationOnFootMouseMode_Horizontally_mov_al_TimecycCameraStateAddress destination @OverwrittenCameraState

0AB1: call_scm_func @asm_PutOnLabelRelativeAddressToLabel 4 script_content SCRIPT_POINTER source_label @CCam__ProcessRotationOnFootMouseMode_Horizontally_jne_tryState1Address source_size 1 destination @CCam__ProcessRotationOnFootMouseMode_Horizontally_tryState1

5@ += 0xA
0AB1: call_scm_func @asm_PutOnLabelRelativeAddressToAddress 4 script_content SCRIPT_POINTER source_label @CCam__ProcessRotationOnFootMouseMode_Horizontally_je_doMovementAccordingToMouseAddress source_size 4 destination 5@

0AB1: call_scm_func @ArrayGetValueByIndex num_params 7 index GAME_VERSION total_values 2 default_value 0 index1 VERSION_1_0_US_CRACKED value1 0x00523F85 index2 VERSION_1_01_EURO_CRACKED value2 0x00524425 store_value_to 6@
0AB1: call_scm_func @asm_PutOnLabelRelativeAddressToAddress 4 script_content SCRIPT_POINTER source_label @CCam__ProcessRotationOnFootMouseMode_Vertically_jmp_stabiliteHorizontalAngleAddress source_size 4 destination 6@

0AB1: call_scm_func @asm_PutOnLabelRelativeAddressToAddress 4 script_content SCRIPT_POINTER source_label @CCam__ProcessRotationOnFootMouseMode_Horizontally_jne_tryState2Address source_size 4 destination 5@

0AB1: call_scm_func @asm_PutOnLabelAbsoluteAddressToLabel 3 script_content SCRIPT_POINTER source_label @CCam__ProcessRotationOnFootMouseMode_Horizontally_fld_ZeroAddress destination @FloatZero
5@ += 0x6

0AB1: call_scm_func @asm_PutOnLabelRelativeAddressToAddress 4 script_content SCRIPT_POINTER source_label @CCam__ProcessRotationOnFootMouseMode_Horizontally_jmp_ProcessZeroCameraMovement source_size 4 destination 5@

// CCam__ProcessRotationOnFootMouseMode_Vertically    
0AB1: call_scm_func @ArrayGetValueByIndex num_params 7 index GAME_VERSION total_values 2 default_value 0 index1 VERSION_1_0_US_CRACKED value1 0x00524032 index2 VERSION_1_01_EURO_CRACKED value2 0x005244D2 store_value_to 5@
0AB1: call_scm_func @asm_PutOnAddressJmpFarToLabel 4 script_content SCRIPT_POINTER source_address 5@ source_virtual_protect true destination @CCam__ProcessRotationOnFootMouseMode_Vertically_part

0AB1: call_scm_func @asm_PutOnLabelAbsoluteAddressToLabel 3 script_content SCRIPT_POINTER source_label @CCam__ProcessRotationOnFootMouseMode_Vertically_mov_al_TimecycCameraStateAddress destination @OverwrittenCameraState

0AB1: call_scm_func @asm_PutOnLabelRelativeAddressToLabel 4 script_content SCRIPT_POINTER source_label @CCam__ProcessRotationOnFootMouseMode_Vertically_jne_tryState1Address source_size 1 destination @CCam__ProcessRotationOnFootMouseMode_Vertically_tryState1

5@ += 0xE
0AB1: call_scm_func @asm_PutOnLabelRelativeAddressToAddress 4 script_content SCRIPT_POINTER source_label @CCam__ProcessRotationOnFootMouseMode_Vertically_je_doMovementAccordingToMouseAddress source_size 4 destination 5@
0AB1: call_scm_func @asm_PutOnLabelRelativeAddressToAddress 4 script_content SCRIPT_POINTER source_label @CCam__ProcessRotationOnFootMouseMode_Vertically_jne_tryState2Address source_size 4 destination 5@

0AB1: call_scm_func @ArrayGetValueByIndex num_params 7 index GAME_VERSION total_values 2 default_value 0 index1 VERSION_1_0_US_CRACKED value1 0x00524147 index2 VERSION_1_01_EURO_CRACKED value2 0x005245E7 store_value_to 6@
0AB1: call_scm_func @asm_PutOnLabelRelativeAddressToAddress 4 script_content SCRIPT_POINTER source_label @CCam__ProcessRotationOnFootMouseMode_Vertically_jmp_stabiliteVerticalAngleAddress source_size 4 destination 6@

0AB1: call_scm_func @asm_PutOnLabelAbsoluteAddressToLabel 3 script_content SCRIPT_POINTER source_label @CCam__ProcessRotationOnFootMouseMode_Vertically_fld_ZeroAddress destination @FloatZero
5@ += 0x6
0AB1: call_scm_func @asm_PutOnLabelRelativeAddressToAddress 4 script_content SCRIPT_POINTER source_label @CCam__ProcessRotationOnFootMouseMode_Vertically_jmp_ProcessZeroCameraMovement source_size 4 destination 5@

// CCam__ProcessRotationInVehicle    
0AB1: call_scm_func @ArrayGetValueByIndex num_params 7 index GAME_VERSION total_values 2 default_value 0 index1 VERSION_1_0_US_CRACKED value1 0x00525626 index2 VERSION_1_01_EURO_CRACKED value2 0x00525AC6 store_value_to 5@
0AB1: call_scm_func @asm_PutOnAddressJmpFarToLabel 4 script_content SCRIPT_POINTER source_address 5@ source_virtual_protect true destination @CCam__ProcessRotationInVehicle_part

0AB1: call_scm_func @asm_PutOnLabelAbsoluteAddressToLabel 3 script_content SCRIPT_POINTER source_label @CCam__ProcessRotationInVehicle_mov_al_TimecycCameraStateAddress destination @OverwrittenCameraState

0AB1: call_scm_func @asm_PutOnLabelRelativeAddressToLabel 4 script_content SCRIPT_POINTER source_label @CCam__ProcessRotationInVehicle_jne_tryState1Address source_size 1 destination @CCam__ProcessRotationInVehicle_tryState1

5@ += 0xD
0AB1: call_scm_func @asm_PutOnLabelRelativeAddressToAddress 4 script_content SCRIPT_POINTER source_label @CCam__ProcessRotationInVehicle_je_doMovementAccordingToMouseAddress source_size 4 destination 5@
0AB1: call_scm_func @asm_PutOnLabelRelativeAddressToAddress 4 script_content SCRIPT_POINTER source_label @CCam__ProcessRotationInVehicle_jne_tryState2Address source_size 4 destination 5@

0AB1: call_scm_func @ArrayGetValueByIndex num_params 7 index GAME_VERSION total_values 2 default_value 0 index1 VERSION_1_0_US_CRACKED value1 0x00525749 index2 VERSION_1_01_EURO_CRACKED value2 0x00525BE9 store_value_to 6@
0AB1: call_scm_func @asm_PutOnLabelRelativeAddressToAddress 4 script_content SCRIPT_POINTER source_label @CCam__ProcessRotationInVehicle_jmp_stabiliteAngleAddress source_size 4 destination 6@

5@ += 0x25
0AB1: call_scm_func @asm_PutOnLabelRelativeAddressToAddress 4 script_content SCRIPT_POINTER source_label @CCam__ProcessRotationInVehicle_jmp_ProcessZeroCameraMovementAddress source_size 4 destination 5@


// OPCODE itself
0AB1: call_scm_func @ArrayGetValueByIndex num_params 7 index 0@ total_values 2 default_value 0 _opcode_table_0.opcode_003D index1 VERSION_1_0_US_CRACKED value1 0x466D48 index2 VERSION_1_01_EURO_CRACKED value 0x466DC8 store_value_to 3@
0AB1: call_scm_func @asm_PutOnAddressAbsoluteAddressToLabel 4 script_content 1@ source_address 3@ source_virtual_protect true destination @opcode_003E     

0AB1: call_scm_func @GetAddress_CScriptThread_getNumberParams_Address 0 store_address_to 3@
0AB1: call_scm_func @asm_PutOnLabelRelativeAddressToAddress 4 script_content 1@ source_label @opcode_003E_call_CScriptThread__getNumberParams_address source_size 4 destination 3@

0AB1: call_scm_func @GetAddress_GetOpcodeParameters 0 store_address_to 3@
0AB1: call_scm_func @asm_PutOnLabelAbsoluteAddressToAddress 4 script_content 1@ source_label @opcode_003E_mov_ecx_opcodeParameters_address source_size 4 destination 3@


0AB1: call_scm_func @asm_PutOnLabelAbsoluteAddressToLabel 3 script_content 1@ source_label @opcode_003E_mov_OverwrittenCameraState_clAddress destination @OverwrittenCameraState

end_custom_thread

:opcode_003E
hex
6A 01                   // push     1
8B CE                   // mov      ecx, esi

E8                      // call     CScriptThread__getNumberParams
end

:opcode_003E_call_CScriptThread__getNumberParams_address
hex
00 00 00 00

8B 0D                   // mov      ecx, _opcodeParameters[0]               
end

:opcode_003E_mov_ecx_opcodeParameters_address
hex
00 00 00 00

88 0D                   // mov      [OverwrittenCameraState],cl
end

:opcode_003E_mov_OverwrittenCameraState_clAddress
hex
00 00 00 00

// ending here
5F                      // pop      edi
32 C0                   // xor      al, al
5E                      // pop      esi
8B 4C 24 14             // mov      ecx,[esp+14]
64 89 0D 00 00 00 00    // mov      fs:[00000000],ecx
83 C4 20                // add      esp,20h
C2 04 00                // retn     0004
end
:opcode_003E_end

:OverwrittenCameraState
{
0 - standard, project is inactive, camera should be statibilised when player can`t move
1 - project is active, camera can`t move, but not stabilised
2 - project is active, camera can move, not stabilised 
}
hex
00 
end

// --------------- :CCam__ProcessRotationOnFootMouseMode_Horizontally
:CCam__ProcessRotationOnFootMouseMode_Horizontally_part
hex
8A 05   // mov      al, [TimecycCameraState]

end
:CCam__ProcessRotationOnFootMouseMode_Horizontally_mov_al_TimecycCameraStateAddress
hex
00 00 00 00     

3C 00   // cmp      al, 0

75      // jne      @@tryState1
end

:CCam__ProcessRotationOnFootMouseMode_Horizontally_jne_tryState1Address
hex
00

66 83 BA 0E010000 00    // cmp     [edx+CPad.DisablePlayerControls], 0

0F 84                   // je       @@doMovementAccordingToMouse
end
:CCam__ProcessRotationOnFootMouseMode_Horizontally_je_doMovementAccordingToMouseAddress
hex
00 00 00 00     

E9      // jmp      @@stabiliteVerticalAngle
end

:CCam__ProcessRotationOnFootMouseMode_Vertically_jmp_stabiliteHorizontalAngleAddress
hex
00 00 00 00
end

:CCam__ProcessRotationOnFootMouseMode_Horizontally_tryState1
hex
3C 01   // cmp      al, 1

0F 85   // jne       @@doMovementAccordingToMouse       
end
:CCam__ProcessRotationOnFootMouseMode_Horizontally_jne_tryState2Address
hex
00 00 00 00

D9 05   // fld dword ptr [FloatZero]
end

:CCam__ProcessRotationOnFootMouseMode_Horizontally_fld_ZeroAddress
hex
00 00 00 00

E9
end
:CCam__ProcessRotationOnFootMouseMode_Horizontally_jmp_ProcessZeroCameraMovement
hex
00 00 00 00
end

// --------------- :CCam__ProcessRotationOnFootMouseMode_Vertically
:CCam__ProcessRotationOnFootMouseMode_Vertically_part
hex
8A 05   // mov      al, [TimecycCameraState]
end

:CCam__ProcessRotationOnFootMouseMode_Vertically_mov_al_TimecycCameraStateAddress
hex
00 00 00 00

3C 00   // cmp      al, 0

75      // jne      @@tryState1
end

:CCam__ProcessRotationOnFootMouseMode_Vertically_jne_tryState1Address
hex
00

66 83 B9 0E010000 00    // cmp     [ecx+CPad.DisablePlayerControls], 0

0F 84   // je       @@doMovementAccordingToMouse   
end

:CCam__ProcessRotationOnFootMouseMode_Vertically_je_doMovementAccordingToMouseAddress
hex
00 00 00 00

E9      // jmp      @@stabiliteVerticalAngle
end
:CCam__ProcessRotationOnFootMouseMode_Vertically_jmp_stabiliteVerticalAngleAddress
hex
00 00 00 00
end

:CCam__ProcessRotationOnFootMouseMode_Vertically_tryState1
hex
3C 01   // cmp      al, 1

0F 85 
end
:CCam__ProcessRotationOnFootMouseMode_Vertically_jne_tryState2Address
hex
00 00 00 00

D9 05   // fld dword ptr [FloatZero]
end

:CCam__ProcessRotationOnFootMouseMode_Vertically_fld_ZeroAddress
hex
00 00 00 00

E9
end
:CCam__ProcessRotationOnFootMouseMode_Vertically_jmp_ProcessZeroCameraMovement
hex
00 00 00 00
end

// --------------- :CCam__ProcessRotationInVehicle
{
dx is zero here
}
:CCam__ProcessRotationInVehicle_part
hex
8A 05   // mov      al, [TimecycCameraState]
end

:CCam__ProcessRotationInVehicle_mov_al_TimecycCameraStateAddress
hex
00 00 00 00

38 D0   // cmp      al, dl

75      // jne      @@tryState1
end
:CCam__ProcessRotationInVehicle_jne_tryState1Address
hex
00

66 39 95 0E010000   // cmp      [ebp+CPad.DisablePlayerControls], dx

0F 84   // je       @@doMovementAccordingToMouse  
end

:CCam__ProcessRotationInVehicle_je_doMovementAccordingToMouseAddress
hex
00 00 00 00

E9      // jmp      @@stabiliteAngle
end
:CCam__ProcessRotationInVehicle_jmp_stabiliteAngleAddress
hex
00 00 00 00
end

:CCam__ProcessRotationInVehicle_tryState1
hex
3C 01   // cmp      al, 1

0F 85   // jne       @@doMovementAccordingToMouse
end
:CCam__ProcessRotationInVehicle_jne_tryState2Address
hex
00 00 00 00

8B 87 94050000              // mov      eax,[edi+00000594]

83 F8 04                    // cmp      eax, 04

C7 44 24 3C 00000000        // mov      [esp+3C],0.0

C7 44 24 40 00000000        // mov      [esp+3C],0.0

E9
end
:CCam__ProcessRotationInVehicle_jmp_ProcessZeroCameraMovementAddress
hex
00 00 00 00 
end

:FloatZero
hex
00 00 00 00 
end

{$INCLUDE functions/asm_handling.txt}
{$INCLUDE functions/ArrayGetValueByIndex.txt}
{$INCLUDE general/addresses.txt}