Author Topic: Tigcc delay  (Read 1644 times)

0 Members and 1 Guest are viewing this topic.

Offline Jonson26

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 117
  • Rating: +1/-0
  • Follow cat! Do what cat! Into tree! Now!
    • View Profile
Tigcc delay
« 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?

Offline Ranman

  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1354
  • Rating: +83/-0
    • View Profile
Re: Tigcc delay
« Reply #1 on: November 18, 2017, 10:19:35 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?

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: [Select]
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
    }
  }
}

Now... go check your email account.   ;)
« Last Edit: November 18, 2017, 10:28:57 am by Ranman »
Ranman
Bringing Randy Glover's Jumpman to the TI-89 calculator. Download available at Ticalc.

Offline Jonson26

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 117
  • Rating: +1/-0
  • Follow cat! Do what cat! Into tree! Now!
    • View Profile
Re: Tigcc delay
« Reply #2 on: November 18, 2017, 11:22:08 am »
Thanks. That will surely help!  ;D