Gamestudio Links
Zorro Links
Newest Posts
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
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (AndrewAMD, Ayumi), 853 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
lorikob361, LucasJoshua, Baklazhan, Hanky27, firatv
19054 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Regarding Lite-C and API-Calls #252425
02/18/09 07:55
02/18/09 07:55
Joined: Feb 2009
Posts: 33
Germany, Hamburg
V
Vorick Offline OP
Newbie
Vorick  Offline OP
Newbie
V

Joined: Feb 2009
Posts: 33
Germany, Hamburg
Hi there,

I just returned to 3DGS after a couple of years and Lite-C is quite new to me. The best way for me to learn a new programming language is to solve simple tasks, but the one I gave myself now is not quite that simple to me, so I'm asking for help.

I'm trying to use an API-Call to read the first available screen resolution using "EnumDisplaySettings". After a little research I found out that I have to define a structure to contain the returned values of this call. Trouble is, that I don't know how to access the returned values, so I'd appreciate any help.

This is my code so far:

Code:
#include <acknex.h>  // Pure-Mode
#include <default.c> // Standard-Keys
#include <windows.h> // Windows-API-Calls

typedef struct _devicemode {
  DWORD dmBitsPerPel;
  DWORD dmPelsWidth;
  DWORD dmPelsHeight;
  DWORD dmDisplayFlags;
  DWORD dmDisplayFrequency;
} SCRMODE;

STRING* rvalue = "Test";

TEXT* doutput =
{
	pos_x = 50;
	pos_y = 50;
	layer = 1;
	string (rvalue);
	flags = VISIBLE;
}

void main() 
{
	var rvalue;

	d3d_antialias = 1;
	video_mode = 8;
	video_screen = 2;
	wait(1);
	level_load(_str("title.wmb"));
	SCRMODE* resolution;
	rvalue = EnumDisplaySettings(NULL, 0, resolution);	
}


So far I don't get any errors, but I don't really know how to put the return value "rvalue" or the members of "resolution" to use. What I like to do is to display rvalue in doutput.string and after a couple of frames to display the given resolution in the same panel in the format "width x height" (e.g. 800x600).

How could I accomplish this. I hope my problem is understandable.

Thanks in advance,

Patrick

PS: I know that EnumDisplaySettings uses a structure with more values of the DEVMODE-Type, but only the five given values are used by EnumDisplaySettings, so I figured that defining only those five needed members should be enough.

Last edited by Vorick; 02/18/09 10:35.

A8.10 Commercial
Re: Regarding Lite-C and API-Calls [Re: Vorick] #252448
02/18/09 10:43
02/18/09 10:43
Joined: Jul 2002
Posts: 4,436
Germany, Luebeck
Xarthor Offline
Expert
Xarthor  Offline
Expert

Joined: Jul 2002
Posts: 4,436
Germany, Luebeck
Don't wanna cut your efforts down but there might be a more simple solution:
Use sys_metrics :: http://www.conitec.net/beta/asys_metrics.htm
and the modi 0 and 1.
I hope this is what you are looking for, if not: sorry!

Re: Regarding Lite-C and API-Calls [Re: Xarthor] #252456
02/18/09 11:29
02/18/09 11:29
Joined: Feb 2009
Posts: 33
Germany, Hamburg
V
Vorick Offline OP
Newbie
Vorick  Offline OP
Newbie
V

Joined: Feb 2009
Posts: 33
Germany, Hamburg
Definitely a nice-to-know function, but sadly not what I'm looking for.

What I intend to do in the end is to get a list of viable resolutions according to the users system and then do a matchup between supported resolutions by my "game". Not that there is any game as of yet, but atm I'm messing around with panels and stuff and trying to create a main menu-settings-screen to get the hang of the Lite-C and 3DGS-workflow.

That's exactly what EnumDisplaySettings does. The parameter "0" gives you the first available resolution. By iterating this parameter until rvalue is false, you can get a list of all resolutions. This is what I'd like to do in the end.


A8.10 Commercial
Re: Regarding Lite-C and API-Calls [Re: Vorick] #252550
02/18/09 21:21
02/18/09 21:21
Joined: Feb 2009
Posts: 33
Germany, Hamburg
V
Vorick Offline OP
Newbie
Vorick  Offline OP
Newbie
V

Joined: Feb 2009
Posts: 33
Germany, Hamburg
Who would have thought that even simple things could be so hard with 3DGS. After two hours of basic trial and error i came up with this:

Code:
#include <acknex.h>  // Pure-Mode
#include <default.c> // Standard-Keys
#include <windows.h> // Windows-API-Calls

typedef struct _devicemode {
  DWORD dmBitsPerPel;
  DWORD dmPelsWidth;
  DWORD dmPelsHeight;
  DWORD dmDisplayFlags;
  DWORD dmDisplayFrequency;
} SCRMODE;

var rvalue = 0;
var xvalue = 0;

PANEL* pan_results = 
{
	pos_x = 0;
	pos_y = 0;
	layer = 1;
	flags = OVERLAY | VISIBLE;
	digits(0, 40, 4, *, 1, rvalue);
	digits(0, 60, 4, *, 1, xvalue);
}

function getscreenres()
{
	SCRMODE* resolution;	
	rvalue = EnumDisplaySettings(NULL, 1, resolution);
}

void main() 
{
	video_mode = 8;
	video_screen = 2;
	level_load("title.wmb");
	wait(1);
	getscreenres();	
}


At this point I had encountered about three to four dozen SED-Crashes while trying to use printf for small debug outputs.

As far as my code goes right now it seems to work. rvalue returns 1 or 0, depending on how high i set the second parameter of EnumDisplaySettings. Now i wanted to use xvalue to fetch the width of the returned resolution inside my resolution pointer.

This is what I tried:

Version 1:
Code:
function getscreenres()
{
	SCRMODE* resolution;	
	rvalue = EnumDisplaySettings(NULL, 1, resolution);
	xvalue = resolution->dmPelsWidth;
}


Version 2:
Code:
function getscreenres()
{
	SCRMODE* resolution;	
	rvalue = EnumDisplaySettings(NULL, 1, resolution);
	xvalue = resolution.dmPelsWidth;
}


Both ended up in Error E1513 "Crash in getscreenres". Any ideas how that could be fixed? I think I'm referencing wrong, but according to the manual it should work.

Again, any help is appreciated.

Patrick


A8.10 Commercial
Re: Regarding Lite-C and API-Calls [Re: Vorick] #252613
02/19/09 08:17
02/19/09 08:17
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
You're accessing an empty pointer here, which consequently causes a crash. Probably you meant to do this:

Code:
function getscreenres()
{
	SCRMODE resolution;	
	rvalue = EnumDisplaySettings(NULL, 1, &resolution); // mind the '&'
	xvalue = resolution.dmPelsWidth;
}


Re: Regarding Lite-C and API-Calls [Re: jcl] #252615
02/19/09 09:03
02/19/09 09:03
Joined: Feb 2009
Posts: 33
Germany, Hamburg
V
Vorick Offline OP
Newbie
Vorick  Offline OP
Newbie
V

Joined: Feb 2009
Posts: 33
Germany, Hamburg
I'll try it first thing this evening as I get home. Thank you very much.


A8.10 Commercial
Re: Regarding Lite-C and API-Calls [Re: Vorick] #252701
02/19/09 20:02
02/19/09 20:02
Joined: Feb 2009
Posts: 33
Germany, Hamburg
V
Vorick Offline OP
Newbie
Vorick  Offline OP
Newbie
V

Joined: Feb 2009
Posts: 33
Germany, Hamburg
Okay, I tried it with your version of the function getscreenres and ended up without SED-Crashes but still with Error E1513 "Crash in getscreenres". Also xvalue seems to behave eradically. Each test run it changes displaying negative and positive values in the thousands.

I also tried the following code without success:

Code:
function getscreenres()
{
	SCRMODE resolution;	
	rvalue = EnumDisplaySettings(NULL, 1, &resolution); // mind the '&'
	xvalue = &resolution.dmPelsWidth; // another '&'
}


I must be getting something very basic very wrong.


A8.10 Commercial
Re: Regarding Lite-C and API-Calls [Re: Vorick] #252790
02/20/09 07:57
02/20/09 07:57
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
Yes, your "SCRMODE" definition is also wrong and causes a crash.

I don't know where you got it from, but if you need a struct, you can just copy it from the Windows header definitions. The only thing to have to do is resolving the "unions".

Code:
typedef struct _devicemode { 
  char  dmDeviceName[32]; 
  WORD   dmSpecVersion; 
  WORD   dmDriverVersion; 
  WORD   dmSize; 
  WORD   dmDriverExtra; 
  DWORD  dmFields; 
      short dmOrientation;
      short dmPaperSize;
      short dmPaperLength;
      short dmPaperWidth;
      short dmScale; 
      short dmCopies; 
      short dmDefaultSource; 
      short dmPrintQuality; 

  short  dmColor; 
  short  dmDuplex; 
  short  dmYResolution; 
  short  dmTTOption; 
  short  dmCollate; 
  BYTE  dmFormName[32]; 
  WORD  dmLogPixels; 
  DWORD  dmBitsPerPel; 
  DWORD  dmPelsWidth; 
  DWORD  dmPelsHeight; 
    DWORD  dmDisplayFlags; 
  DWORD  dmDisplayFrequency; 
  DWORD  dmICMMethod;
  DWORD  dmICMIntent;
  DWORD  dmMediaType;
  DWORD  dmDitherType;
  DWORD  dmReserved1;
  DWORD  dmReserved2;
  DWORD  dmPanningWidth;
  DWORD  dmPanningHeight;
} SCRMODE; 



Re: Regarding Lite-C and API-Calls [Re: jcl] #252834
02/20/09 18:49
02/20/09 18:49
Joined: Feb 2009
Posts: 33
Germany, Hamburg
V
Vorick Offline OP
Newbie
Vorick  Offline OP
Newbie
V

Joined: Feb 2009
Posts: 33
Germany, Hamburg
Working like a breeze, thank you so much.

Regarding the struct I just did a bit of googeling it up. Seems like I got the wrong sources. But now I'm ready to let things roll.


A8.10 Commercial

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