0 Members and 1 Guest are viewing this topic.
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?
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 } }}