![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Game engine designer
Join Date: May 2005
Location: Sweden
Posts: 318
Rep Power: 4
![]() |
[WIN32] Inline asm call to GetCursorPos
I am trying to call this function using inline assembly:
BOOL GetCursorPos(LPPOINT lpPoint); #include <windows.h>
int main()
{
// C++
while(true)
{
POINT cursorPos;
GetCursorPos(&cursorPos);
}
return 0;
} My thoughts were - "It want an adress to a struct that only contains two int's (actually long's). How do I do this?" I wrote this code...#include <windows.h>
int main()
{
// Assembly
while(true)
{
int cursorPos[2];
cursorPos[0] = cursorPos[1] = 0;
_asm
{
lea eax, cursorPos
push eax
call GetCursorPos
}
}
return 0;
}Where did my thoughts went wrong? Thanks for your help! /Klarre |
|
|
|
|
|
#2 |
|
Programming Guru
![]() Join Date: Jun 2005
Location: elemental plane
Posts: 1,429
Rep Power: 5
![]() |
Uhmm POINT is a structure, which contains an x and a y coordinate. GetCursorPos will give you a structure back. I'm not sure how to do that, but that's what's going wrong if I'm not mistaken.
__________________
"Employ your time in improving yourself by other men's writings, so that you shall gain easily what others have labored hard for." -- Socrates |
|
|
|
|
|
#3 |
|
Expert Programmer
Join Date: Aug 2005
Location: Rotterdam, the Netherlands
Posts: 942
Rep Power: 4
![]() |
I'm definitely not an assembly expert, but can't you do just this:
while(true) {
POINT cursorPos;
_asm {
push cursorPos
call GetCursorPos
}
}@nnxion: Using an array or POINT doesn't really matter i believe, in the end it are just two integers. |
|
|
|
|
|
#4 | |
|
Game engine designer
Join Date: May 2005
Location: Sweden
Posts: 318
Rep Power: 4
![]() |
Quote:
Your proposal do not work. But thanks anyway! ![]() /Klarre |
|
|
|
|
|
|
#5 |
|
Programming Guru
![]() Join Date: Jun 2005
Location: elemental plane
Posts: 1,429
Rep Power: 5
![]() |
You are just coding inline because it is easier to debug? That's the most ridiculous statement I have ever heard about inline assembly.
__________________
"Employ your time in improving yourself by other men's writings, so that you shall gain easily what others have labored hard for." -- Socrates |
|
|
|
|
|
#6 | |
|
Game engine designer
Join Date: May 2005
Location: Sweden
Posts: 318
Rep Power: 4
![]() |
Quote:
I guess I forgot to tell you that I am working on an assembly application. I am just testing my code inline before I implement it in the real app!/Klarre |
|
|
|
|
|
|
#7 |
|
Game engine designer
Join Date: May 2005
Location: Sweden
Posts: 318
Rep Power: 4
![]() |
Problem solved!
Found that it is possible to create structs in asm. That helped alot! /Klarre |
|
|
|
|
|
#8 | |
|
Programming Guru
![]() Join Date: Jun 2005
Location: elemental plane
Posts: 1,429
Rep Power: 5
![]() |
Quote:
__________________
"Employ your time in improving yourself by other men's writings, so that you shall gain easily what others have labored hard for." -- Socrates |
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|