May 21, 2024, 03:17:35 PM

News:

IonicWind Snippit Manager 2.xx Released!  Install it on a memory stick and take it with you!  With or without IWBasic!


Sleep DLL

Started by GWS, February 22, 2008, 12:23:00 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

GWS

February 22, 2008, 12:23:00 PM Last Edit: February 22, 2008, 12:25:27 PM by GWS
Here's another little routine which just encapsulates the GetTickCount() stuff to wait for 'n' millisecs.

The dll is sleep.dll, the test program is 'sleeptest.cba' and the code from the EBasic routine is sleepdll.txt, all zipped.

At some point, if they work OK, these little routines could be packaged in one DLL to give a few more useful functions in CBasic.

best wishes,  :)

Graham
Tomorrow may be too late ..

Ionic Wind Support Team

CBasic can use API imports so why the encapsulation of GetTickCount?
Ionic Wind Support Team

GWS

It's nothing amazing I agree, it just does the timing comparison in one statement to save typing the routine  each time you need a pause.

Sleep(1000)

is just neater ..  :)

Graham
Tomorrow may be too late ..

Mike Stefanik

There's Sleep and SleepEx functions that are part of the base operating system, exported from Kernel32.dll. Looping around calling GetTickCount is just going to burn CPU cycles; calling Sleep actually allows the scheduler to put the thread to sleep for that period of time.
Mike Stefanik
www.catalyst.com
Catalyst Development Corporation

GWS

February 26, 2008, 01:51:54 AM #4 Last Edit: February 26, 2008, 02:02:49 AM by GWS
Yep .. OK thanks Mike.  No point in thrashing the CPU just to pause for a second or two ..  :)

I have seen the looping method used for game timing though - no harm done if the machine is being paused anyway.

What's missing there is a 'Check(1000)' function that can be put in a game loop IF statement, that only executes an IF block if Check() returns a 1.  Trouble is, that needs the Check() routine to remember when it was first called, and I haven't thought of a way of doing that yet.

I've changed to using the Sleep API in the attached zip ..

best wishes, :)

Graham
Tomorrow may be too late ..