![]() ![]() |
![]() Post #1 | |
![]() The Assistant Posts: 84 From: Matera, IT Joined: 16-June 11 ![]() | Hello, this is my first significant post I make in this forum! As the title says, I'm unable to get drawing functions working while I call them by SCM or CLEO scripts. This occurs for every kind of functions which draw 2D or 3D primitives, so I'd point you to the CTexture__drawTexturedRect (0x728350) function as a reference. ![]() I'd like someone who explain the reasons and (possibly) give me any solution. |
![]() |
![]() Post #2 | |
![]() Coding like a Rockstar! ![]() Posts: 1,468 From: ??? Joined: 28-May 09 ![]() | Not sure I fully understand your problem. A view of your current script may help. I've used that particular function in ASI but it doesn't sound like that exact function is what you are trying to call. This should be the way to call that function. SANNY 0AA6: call_method 0x728350 struct {*RwTexture} num_params 2 pop 0 {*dwRGBA} {*[X,Y,Width,Height]} If not, then the parameter order needs reversing. -------------------- | CLEO 4.3.22 | A?i?a?o?3D | UI SDK | Black Market Mod 1.0.1 | GInput 0.3 | Cheat Keyboard | Tactile Cheat Activation | Stream Ini Extender 0.7 | SuperVars | ScrDebug | Vigilante Justice: San Andreas | |
![]() Post #3 | |
![]() The Assistant Posts: 84 From: Matera, IT Joined: 16-June 11 ![]() | Basically, I want to load a TXD dictionary differently from the "Script" one which is used by SCM. I've already made functions which enables me doing that but I cannot succeed on drawing those loaded textures. This is an example script: SANNY {$CLEO} 0000: NOP while true wait 0 0A8D: 0@ = read_memory 0xC403F4 size 4 virtual_protect 0 // _texShadExp 0AB1: call_scm_func @drawTexture 9 texture 0@ cornerA_XY 160.0 120.0 cornerB_XY 480.0 1080.0 RGBA 128 128 128 255 end :drawTexture { Parameters: Passed: 0@ - texture (offset) 1@ - rect ul 2@ - rect ll 3@ - rect ur 4@ - rect lr 5@ - red 6@ - green 7@ - blue 8@ - alpha Result: none Example: 0AB1: call_scm_func @drawTexture 9 texture 0x0 cornerA_XY 0.0 0.0 cornerB_XY 0.0 0.0 RGBA 128 128 128 255 } 0A9F: 11@ = current_thread_pointer 0AB1: call_scm_func @getLocalVarOffset 2 thread 11@ var 1 store_to 9@ 0AB1: call_scm_func @getRGBAValue 4 RGBA 5@ 6@ 7@ 8@ store_to 10@ 0AA6: call_method 0x728350 struct 0@ num_params 2 pop 0 dwColor 10@ pRect 9@ // CTexture__drawTexturedRect 0AB2: ret 0 :getRGBAValue { Parameters: Passed: 0@ - red 1@ - green 2@ - blue 3@ - alpha Result: 4@ - color (offset) Example: 0AB1: call_scm_func @getRGBAValue 4 RGBA 128 128 128 255 store_to 1@ } 0AA7: call_function 0x7170C0 num_params 4 pop 0 bAlpha 3@ bBlue 2@ bGreen 1@ bRed 0@ bResult 4@ // _RGBA__set 0AB2: ret 1 4@ :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@ } if 0@ <> 0 then 1@ *= 0x4 0A8E: 2@ = 0@ + 0xDC // mission flag if 2@ == 1 then 1@ += 0xA48960 // mission locals else 005A: 1@ += 0@ 1@ += 0x3C end else 1@ = 0 end 0AB2: ret 1 1@ I don't know why the game doesn't show anything onscreen even if everything looks correct apparently. |
![]() Post #4 | |
![]() Coding like a Rockstar! ![]() Posts: 1,468 From: ??? Joined: 28-May 09 ![]() | Mmm.. That script crashes for me. This is doesn't crash but doesn't display the texture either: SANNY 0@ = 0xFFFFFFFF 0AC7: 1@ = var 0@ offset 5@ = 10.0 6@ = 10.0 7@ = 40.0 8@ = 40.0 0AC7: 9@ = var 5@ offset 0AA6: call_method 0x728350 struct 0xBAB208 num_params 2 pop 0 dwColor 1@ pRect 9@ It works fine for me in an ASI, so it should be convertable... CODE RwRGBA colour = {0xFFu,0xFFu,0xFFu,0xB2u}; RwRect2D texturePos; texturePos.x2 = _x(2.0); texturePos.y2 = _y(346.0); texturePos.x1 = _x(2.0 - 16.0); texturePos.y1 = _y(346.0 + 24.0); DrawTexturedRect(&HudTextures[0], &texturePos, &colour); -------------------- | CLEO 4.3.22 | A?i?a?o?3D | UI SDK | Black Market Mod 1.0.1 | GInput 0.3 | Cheat Keyboard | Tactile Cheat Activation | Stream Ini Extender 0.7 | SuperVars | ScrDebug | Vigilante Justice: San Andreas | |
![]() Post #5 | |
![]() The Assistant Posts: 84 From: Matera, IT Joined: 16-June 11 ![]() | Ok, thanks. So mine is more than just a suggestion. Every drawing function doesn't work in SCM/CLEO. I may try to use ASM code to call those functions instead of using the calling-function opcodes, otherwise I have to find a way to inject them by scripts. ![]() I believe, I got the answer. Thanks again! ![]() |
![]() Post #6 | |
![]() The master of cut retort ![]() Posts: 239 From: Warsaw, PL Joined: 21-July 10 ![]() | Yeah, ASM call should be a good way to do it, if CLEO call does not work ![]() |
![]() Post #7 | |
![]() Member Posts: 197 From: Liberty City, Shoreside Joined: 15-July 10 ![]() | You guys made very big work on this! I would wanna to know: 1) How to load txd using .asi (.dll) which made in cpp? 2) How to define textures (load_texture "" as) 3) Do I need to use smth like "enable_text_draw 1" And I believe I could made it in __ASM in C++, but have just few questions: 1) How do you "attach" procedure in C++ to procedure in .exe? 2) How did you defined "HudTextures"? Is it an array of textures which must be loaded from models/txd? If yes, how did you "attached" it to array in .exe? I really can't understand how these "pointers" work in C++... |
![]() Post #8 | |
![]() The Assistant Posts: 84 From: Matera, IT Joined: 16-June 11 ![]() | I'm sorry DK22, but we're talking about making texture showing by CLEO. You should open another topic to ask for ASI functions implementation. Back on topic, I noticed game won't render anything in CGame__process() (0x53BEE0), but in CGame__Idle() (0x53E920) works! I injected an ASM function by overwriting a call to a NOP function: CODE {$CLEO} 0000: NOP 0AB1: call_scm_func @getLabelOffset 1 label @drawBarChart store_to 0@ 0@ -= 0x53EBE9 0A8C: write_memory 0x53EBE4 size 1 value 0xE9 virtual_protect 1 0A8C: write_memory 0x53EBE5 size 4 value 0@ virtual_protect 1 0A93: end_custom_thread :drawBarChart hex 68 00000000 // push 00000000h dwRightBorderColor 68 FF0000FF // push FF0000FFh dwForeColor 6A 01 // push 1 bBorder 6A 00 // push 0 bPercentage 68 00000000 // push 0 dwRightBorderWidth 68 00004842 // push 50.0 fPercentage 68 64000000 // push 100 dwHeight 68 C8000000 // push 200 dwWidth 68 00007043 // push 240.0 fPosY 68 0000A043 // push 320.0 fPosX B8 40867200 // mov eax, 728640h DrawBarChart FFD0 // call eax 83C4 28 // add esp, 28h B8 E9EB5300 // mov eax, 53EBE9h FFE0 // jmp eax end Coordinates depend on the current screen resolution, so guess it is a test. This post has been edited by Wesser: Jul 11 2011, 07:59 AM |
![]() Post #9 | |
![]() The master of cut retort ![]() Posts: 239 From: Warsaw, PL Joined: 21-July 10 ![]() | Windshield GUI 2.0 made via ASM? ![]() |
![]() Post #10 | |
![]() The Assistant Posts: 84 From: Matera, IT Joined: 16-June 11 ![]() | I hope so. ![]() By the way, I made a better function than R*'s one, but I had some problems with screen scales. I may use the original routine which is hardly ever the worse choise. ![]() OFFTOPIC: why the topic date says I've posted this message today (Today, 12:22 AM)? It's correct to say "Today, 0:22 AM". Is it a known bug? This post has been edited by Wesser: Jul 11 2011, 09:41 AM |
![]() Post #11 | |
![]() The master of cut retort ![]() Posts: 239 From: Warsaw, PL Joined: 21-July 10 ![]() | DST confusion. You have to scale your position and scale to SA resolution scale. CODE v4 = (long double)RsGlobal.MaximumHeight * 0.002232142956927419 * 22.0; v5 = (long double)RsGlobal.MaximumWidth - 0.001562500023283064 * (long double)RsGlobal.MaximumWidth * 32.0; _drawText(v5, v4, str); IDA pseudocode helps a lot. |
![]() Post #12 | |
![]() Coding like a Rockstar! ![]() Posts: 1,468 From: ??? Joined: 28-May 09 ![]() | CGame::Process should run, assuming the function you're overwriting is not jumped past after a check. However, "_Render" does not run and it appears to be an unused function with debugging capabilities. But that's a different matter, I guess ![]() -------------------- | CLEO 4.3.22 | A?i?a?o?3D | UI SDK | Black Market Mod 1.0.1 | GInput 0.3 | Cheat Keyboard | Tactile Cheat Activation | Stream Ini Extender 0.7 | SuperVars | ScrDebug | Vigilante Justice: San Andreas | |
![]() ![]() |