Author Topic: [TIGCC] Key Testing Too Fast?  (Read 6724 times)

0 Members and 1 Guest are viewing this topic.

Offline bfr

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 819
  • Rating: +4/-0
    • View Profile
    • bfr's website
[TIGCC] Key Testing Too Fast?
« 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.

Liazon

  • Guest
[TIGCC] Key Testing Too Fast?
« Reply #1 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.

MathStuf

  • Guest
[TIGCC] Key Testing Too Fast?
« Reply #2 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.

Liazon

  • Guest
[TIGCC] Key Testing Too Fast?
« Reply #3 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.

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
[TIGCC] Key Testing Too Fast?
« Reply #4 on: July 31, 2006, 11:46:00 am »
is that the new version of tigcc?

Offline bfr

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 819
  • Rating: +4/-0
    • View Profile
    • bfr's website
[TIGCC] Key Testing Too Fast?
« Reply #5 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.

MathStuf

  • Guest
[TIGCC] Key Testing Too Fast?
« Reply #6 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.

Offline bfr

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 819
  • Rating: +4/-0
    • View Profile
    • bfr's website
[TIGCC] Key Testing Too Fast?
« Reply #7 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...

Offline bfr

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 819
  • Rating: +4/-0
    • View Profile
    • bfr's website
[TIGCC] Key Testing Too Fast?
« Reply #8 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

Liazon

  • Guest
[TIGCC] Key Testing Too Fast?
« Reply #9 on: August 13, 2006, 01:00:00 am »
no problem

Offline Ranman

  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1354
  • Rating: +83/-0
    • View Profile
[TIGCC] Key Testing Too Fast?
« Reply #10 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:
 
Ranman
Bringing Randy Glover's Jumpman to the TI-89 calculator. Download available at Ticalc.

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
[TIGCC] Key Testing Too Fast?
« Reply #11 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

Offline Ranman

  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1354
  • Rating: +83/-0
    • View Profile
[TIGCC] Key Testing Too Fast?
« Reply #12 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
Ranman
Bringing Randy Glover's Jumpman to the TI-89 calculator. Download available at Ticalc.

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
[TIGCC] Key Testing Too Fast?
« Reply #13 on: August 15, 2006, 09:37:00 am »
I am wondering if there is that kind of stuff on the z80 models