Gamestudio Links
Zorro Links
Newest Posts
New FXCM FIX Plugin
by flink. 06/04/24 07:30
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (AndrewAMD), 1,507 guests, and 12 spiders.
Key: Admin, Global Mod, Mod
Newest Members
AemStones, LucasJoshua, Baklazhan, Hanky27, firatv
19058 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 2 of 2 1 2
Re: New, delete, and windows.h [Re: the_mehmaster] #350291
12/15/10 09:00
12/15/10 09:00
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
Dude!

What does this demo do when you run it, and what are you running it with?

Im using A7.86.0 Comm and the mouse performs the little squares, but it also wanders off to the top-left of the screen...

Did it do that for you?!?


[EDIT] PS: I will be getting to your PM later tonite...

[EDIT 2] For what it is worth, here is a savagely cut down version of meh_masters code....
windows.h no longer requires, ans structs over-simplified...
(still has the drift problem on my machine...)
Click to reveal..
Code:
#include <acknex.h>
#include <default.c>


long __stdcall SendInput(long cInputs,long pInputs,long cbSize);
API(SendInput,user32)


typedef struct MOUSEINPUT
{
    long	type;				//unused : always ZERO for mouse
    long	dx, dy;			//move mouse by dx, dy pixels
    long	unused_0;		//unused
    long	dwFlags;			//static : always 0x1 for mouse-input 
    long unused_1[2];	//unused
} MOUSEINPUT;



void mouseMove(int dx, int dy)
{
   static MOUSEINPUT* input = NULL;	
   if(!input)	{ 	input = sys_malloc(sizeof(MOUSEINPUT));	
   					memset(input, 0, sizeof(MOUSEINPUT));
   					input.dwFlags = 0x1;							}
	//-----------------------------------------------------
   input.dx = dx;
   input.dy = dy;
   SendInput(0x1, input, sizeof(MOUSEINPUT));
}




void main()
{
	level_load("");
	while(1)
	{
		mouseMove(40,0);
		wait(1);
		mouseMove(0,40);
		wait(1);
		mouseMove(-40,0);
		wait(1);
		mouseMove(0,-40);
		wait(1);
	}
}




Last edited by EvilSOB; 12/15/10 09:35. Reason: code added

"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Re: New, delete, and windows.h [Re: EvilSOB] #350301
12/15/10 10:22
12/15/10 10:22
Joined: Dec 2008
Posts: 528
Wagga, Australia
the_mehmaster Offline OP
User
the_mehmaster  Offline OP
User

Joined: Dec 2008
Posts: 528
Wagga, Australia
Yeah the code does exactly the same thing for me smile

But that doesn't really matter as that's all it was supposed to do anyway.. I have already integrated it with the IMU code that we had earlier, and it works perfectly.. Using the IMU to control crysis is pretty cool wink

EDIT: I integrated your code.. looks a lot more efficient, and everything still works fine. Thanks! smile

Last edited by the_mehmaster; 12/15/10 10:29.
Re: New, delete, and windows.h [Re: the_mehmaster] #350308
12/15/10 11:20
12/15/10 11:20
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
excellent!


"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Re: New, delete, and windows.h [Re: EvilSOB] #350317
12/15/10 12:20
12/15/10 12:20
Joined: Apr 2007
Posts: 3,751
Canada
WretchedSid Offline
Expert
WretchedSid  Offline
Expert

Joined: Apr 2007
Posts: 3,751
Canada
Question: Why malloc at all? Thats a serious performance penalty when you call this multiple times as its dispatched in many other functions including a context switch to the kernel and memory mapping.
The code from EvilSOB is better, but leaks the memory. In the end it could be done perfectly on the stack.


Shitlord by trade and passion. Graphics programmer at Laminar Research.
I write blog posts at feresignum.com
Re: New, delete, and windows.h [Re: WretchedSid] #350405
12/15/10 20:53
12/15/10 20:53
Joined: Dec 2008
Posts: 528
Wagga, Australia
the_mehmaster Offline OP
User
the_mehmaster  Offline OP
User

Joined: Dec 2008
Posts: 528
Wagga, Australia
The site (listed in the first post) that I got most of the original code from only used the stack.. But for some reason that method would not compile.. so I just used malloc grin

But for the purposes I am using it for.. Performance is pretty much irrelevant unless the program is REALLY slow (I'm talking ~ 5fps) It currently runs at and around 400(with a level and entities+such).

As for evilSOB's code... I think I'll leave that to him to explain grin

Page 2 of 2 1 2

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1