Calculator Community > Calculator C

Tigcc delay

(1/1)

Jonson26:
So i've got a little issue: How do i work delay into my program? I don't want it to run too fast, so that the user can see something. Is there lik a library, or do i need a workaround?

Ranman:

--- Quote from: Jonson26 on November 18, 2017, 09:21:42 am ---So i've got a little issue: How do i work delay into my program? I don't want it to run too fast, so that the user can see something. Is there lik a library, or do i need a workaround?

--- End quote ---

If you have the Jumpman 89 v1.01 source code... look in the utilities folder for some files called TimeUtils.h and TimeUtils.c. There is a Sleep function in there.


--- Code: ---void Sleep(uint4 milliseconds)
{
  static int2 firstTime = 1;
  static int2 vti = 0;

  uint4 loops;
  uint4 i;

  if (firstTime)
  {
    firstTime = 0;
    vti = IsVTI();
  }

  if (vti)
  {
    // this is Virtual TI emulator
    loops = milliseconds * 430; // 430 was found by testing

    for (i = 0; i < loops; i++)
    {
      asm ("NOP");
      asm ("NOP");
      asm ("NOP");
      asm ("NOP");
      asm ("NOP");
      asm ("NOP");
      asm ("NOP");
      asm ("NOP");
      asm ("NOP");
      asm ("NOP");
    }
  }
  else
  {
    // this is a real calculator
    loops = milliseconds * 2; // 2 was found by testing

    for (i = 0; i < loops; i++)
    {
      // poke this reg to put CPU to sleep
      pokeIO(0x600005,0b10101); // allow interrupts 1,3,5 to wake us up
    }
  }
}

--- End code ---

Now... go check your email account.   ;)

Jonson26:
Thanks. That will surely help!  ;D

Navigation

[0] Message Index

Go to full version