Omnimaga

Calculator Community => TI Calculators => Calculator C => Topic started by: bfr on July 31, 2006, 05:09:00 am

Title: [TIGCC] Key Testing Too Fast?
Post by: bfr on July 31, 2006, 05:09:00 am
I installed TIGCC .96 Beta 7, and built and ran a program that I had built and ran in TIGCC .96 Beta 6.  But when I tested it out, it seemed that key presses were detected way to quickly, even after putting for(d = 0;d<200000;d++){} at the end of the key test loop to slow it down.  When i built it with TIGCC .96 Beta 6 though, the key presses were detected at the normal speed.  Would anybody know why this is happenning?

I'm using _keytest() to test for key presses, if that helps.
Title: [TIGCC] Key Testing Too Fast?
Post by: Liazon on July 31, 2006, 09:00:00 am
i'll check it out.  Thanks for telling me about a new beta though.

Hopefully this isn't a bug.

edit:

hmm.... well, so far in VTI, my program seems fine.
Title: [TIGCC] Key Testing Too Fast?
Post by: MathStuf on July 31, 2006, 09:18:00 am
Umm...that sounds like something on the calc... I recompiled Cobra Command and it worked fine with _keytest. GCC may optimize empty loops now (unless in another function if it does), but I don't know why it would.
Title: [TIGCC] Key Testing Too Fast?
Post by: Liazon on July 31, 2006, 11:19:00 am
I typically generate random numbers instead of use an empty loop.  It's something I read in a technoplaza tutorial.
Title: [TIGCC] Key Testing Too Fast?
Post by: DJ Omnimaga on July 31, 2006, 11:46:00 am
is that the new version of tigcc?
Title: [TIGCC] Key Testing Too Fast?
Post by: bfr on August 01, 2006, 05:06:00 am
TIGCC .96 Beta 7 is the latest beta version of TIGCC.

Well, I also tried it with a timeout type of thing.  The actions that occurred when keys were press could only happen when the timeout variable had a certain value.  Here is psuedo-code for what I mean:

c1-->
CODE
ec1
timeout = 0;
loop
if(_keytest(RR_UP) && timeout=29){
//do stuff
}
timeout++;
if(timeout==50)timeout=0;
endloop
c2
ec2

But I got the same results as when I did the delay thing.  I guess I'll try the random number thing.
Title: [TIGCC] Key Testing Too Fast?
Post by: MathStuf on August 04, 2006, 08:07:00 am
Try for(d = 0;d<200000;d++);. That's how I make delay loops instead of empty braces. GCC may get rid of empty brace sets now, but not empty statements.
Title: [TIGCC] Key Testing Too Fast?
Post by: bfr on August 04, 2006, 11:34:00 am
OK, thanks.  :)smile.gif  I'll try that when I get on my computer that has TIGCC installed...
Title: [TIGCC] Key Testing Too Fast?
Post by: bfr on August 12, 2006, 06:34:00 am
I finally got it to work.  I put:

b = random(20);

inside the loop.  Thanks, everybody :)smile.gif
Title: [TIGCC] Key Testing Too Fast?
Post by: Liazon on August 13, 2006, 01:00:00 am
no problem
Title: [TIGCC] Key Testing Too Fast?
Post by: Ranman on August 13, 2006, 10:25:00 am
Here is a decent sleep function that is can be used on both real and VTI.

The IsVTI() ASM function was written by Julien Muchembled, I found it on the TIGCC Headquarters message board a while back. The Sleep() function is code that I wrote. It basically puts the calc's CPU into an idle state for the specified number of milliseconds. Hence, it saves battery power -- which is a good thing!

The 68K Assembly code needed...
c1-->
CODE
ec1
|=============================================================================
| VTI detection routine (by Julien Muchembled)
|
| this routine utilizes a bug in VTI: you can set even non-existing flags in
| the status register and query them later!
|=============================================================================

| C prototype:
| short IsVTI(void);

.data
.globl IsVTI
.even

IsVTI:
 
Title: [TIGCC] Key Testing Too Fast?
Post by: DJ Omnimaga on August 13, 2006, 12:12:00 pm
so I assume it should be used for delays instead of like a for/while/repeat loop right? Good stuff to know
Title: [TIGCC] Key Testing Too Fast?
Post by: Ranman on August 14, 2006, 01:08:00 pm
QuoteBegin-xlibman+Aug 13 2006, 06:12 PM-->
QUOTE (xlibman @ Aug 13 2006, 06:12 PM)
so I assume it should be used for delays instead of like a for/while/repeat loop right? Good stuff to know  

 Yes.

A for/while loop used simply for a time delay without idling the CPU is just a waste of battery power. ;)wink.gif
Title: [TIGCC] Key Testing Too Fast?
Post by: DJ Omnimaga on August 15, 2006, 09:37:00 am
I am wondering if there is that kind of stuff on the z80 models