Skip to content
This repository has been archived by the owner on Dec 25, 2023. It is now read-only.

Commit

Permalink
DLL Projects:
Browse files Browse the repository at this point in the history
- TIMER.DLL:
    - Fixed reset timer function.
    - Separated resume logic from pause function. Create resume_timer().
- Removed old DLLTEST.PRG and oldest non-DLL test PRGs.
- Created separated test PRGs programs for each DLL.
  • Loading branch information
José Miguel Sánchez Fernández committed May 30, 2020
1 parent f6d9cec commit af41ee9
Show file tree
Hide file tree
Showing 10 changed files with 303 additions and 550 deletions.
Binary file modified DLL/TIMER.DLL
Binary file not shown.
32 changes: 27 additions & 5 deletions DLL/TIMER/TIMER.CPP
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ void frameTimers()
retval(RESULT_OK);
}

/** Pause or resume active timer.
/** Pause active timer.
*
* @param {int} index - Timer index.
*
Expand All @@ -136,14 +136,35 @@ void pause()
if (isIndexValid(index))
{
struct TimerData* t = &timers[index];
if (t->paused)
if (!t->paused)
{
t->pauseDelta = clock();
t->paused = 1;
}
else

retval(RESULT_OK);
return;
}

retval(RESULT_ERROR);
}

/** Resume active and paused timer.
*
* @param {int} index - Timer index.
*
* @return {int} - Returns RESULT_ERROR if the timer index is not valid or timer is not active.
*/
void resume()
{
int index = getparm();

if (isIndexValid(index))
{
struct TimerData* t = &timers[index];
if (t->paused)
{
t->startTime = clock() - t->pauseDelta;
t->startTime += clock() - t->pauseDelta;
t->paused = 0;
}

Expand Down Expand Up @@ -181,14 +202,14 @@ void isPaused()
*/
void reset()
{
int paused = getparm();
int index = getparm();

if (isIndexValid(index))
{
struct TimerData* t = &timers[index];
t->startTime = clock();
t->pauseDelta = 0;
t->paused = 0;

retval(RESULT_OK);
return;
Expand All @@ -207,6 +228,7 @@ void __export divlibrary(LIBRARY_PARAMS)
COM_export("get_time", getTime, 1);
COM_export("frame_timers", frameTimers, 0);
COM_export("pause_timer", pause, 1);
COM_export("resume_timer", resume, 1);
COM_export("is_timer_paused", isPaused, 1);
COM_export("reset_timer", reset, 1);
}
Expand Down
1 change: 1 addition & 0 deletions DLL/TIMER/TIMER.H
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,6 @@ void freeAll();
void getTime();
void frameTimers();
void pause();
void resume();
void isPaused();
void reset();
79 changes: 0 additions & 79 deletions PRG/TESTS/ADVTIMER.PRG

This file was deleted.

Loading

0 comments on commit af41ee9

Please sign in to comment.