Jump to content

Photo

Calculating time


26 replies to this topic

#1 JPC531 OFFLINE  

JPC531

    Combat Commando

  • 3 posts

Posted Mon Mar 18, 2019 11:07 AM

I just started playing around with Extended Basic to see what the TI-99/4A can do.

I made a simple program where I want to see how many words can be entered in one minute, but I do not see any Basic commands for time.

On the TI-99 do you just have to estimate based on how long each instruction takes to run?  Not sure how I would do that since the number of words would be different every time it is run.

How do you handle a time count down?



#2 Vorticon OFFLINE  

Vorticon

    River Patroller

  • 3,726 posts
  • Location:Eagan, MN, USA

Posted Mon Mar 18, 2019 11:25 AM

This will be near-impossible to do without assembly language support to access the 9901 timer. 

To clarify, will you be timing at rest or in motion? There might be some complicating factors at play here  ;)



#3 HOME AUTOMATION OFFLINE  

HOME AUTOMATION

    Moonsweeper

  • 428 posts
  • Location:"trapped in interspace"

Posted Mon Mar 18, 2019 11:40 AM

TI-99-4A-CLOCK-Capability-v1.10.pdf

 

I remember a program called 4aclock... I think it was in TI BASIC... can't locate.


Edited by HOME AUTOMATION, Mon Mar 18, 2019 11:59 AM.


#4 Asmusr ONLINE  

Asmusr

    River Patroller

  • 3,110 posts
  • Location:Denmark

Posted Mon Mar 18, 2019 12:52 PM

Isn't there a VDP interrupt counter that you can peek (>83d6)?



#5 Vorticon OFFLINE  

Vorticon

    River Patroller

  • 3,726 posts
  • Location:Eagan, MN, USA

Posted Mon Mar 18, 2019 1:26 PM

Yes, the screen time-out counter. How long would it take for it to go from 0 to >FFFF? That would be the maximum time interval that could be counted. Problem is there is no POKE function in XB, so one would not be able to reset the timer before starting the word count.



#6 sometimes99er OFFLINE  

sometimes99er

    River Patroller

  • 4,225 posts
  • Location:Denmark

Posted Mon Mar 18, 2019 1:38 PM

You can set a sprite in motion and then read its position to get time.



#7 Vorticon OFFLINE  

Vorticon

    River Patroller

  • 3,726 posts
  • Location:Eagan, MN, USA

Posted Mon Mar 18, 2019 3:54 PM

You can set a sprite in motion and then read its position to get time.

 

Great idea! Didn't think of that.



#8 Lee Stewart ONLINE  

Lee Stewart

    River Patroller

  • 3,966 posts
  • Location:Silver Run, Maryland

Posted Mon Mar 18, 2019 4:07 PM

Yes, the screen time-out counter. How long would it take for it to go from 0 to >FFFF? That would be the maximum time interval that could be counted. Problem is there is no POKE function in XB, so one would not be able to reset the timer before starting the word count.

 

The screen timeout counter steps by 2 at each interrupt, so 32768/3600 = 9.1 minutes.

 

In XB, you use CALL LOAD() to poke byte values into RAM.

 

...lee



#9 JPC531 OFFLINE  

JPC531

    Combat Commando

  • Topic Starter
  • 3 posts

Posted Mon Mar 18, 2019 5:53 PM

This will be near-impossible to do without assembly language support to access the 9901 timer. 

To clarify, will you be timing at rest or in motion? There might be some complicating factors at play here  ;)

 

 

 

The screen timeout counter steps by 2 at each interrupt, so 32768/3600 = 9.1 minutes.

 

In XB, you use CALL LOAD() to poke byte values into RAM.

 

...lee

 

Timing would be in motion. I do want to try assembly, but I wanted to see what is possible in Basic first.  I think I can handle a peek and poke though.

At least I know that I didn't miss anything easy :)



#10 JPC531 OFFLINE  

JPC531

    Combat Commando

  • Topic Starter
  • 3 posts

Posted Mon Mar 18, 2019 5:55 PM

You can set a sprite in motion and then read its position to get time.

 

Using sprite motion is a great idea.  I could not think of anything that was consistent over time.  I'll try that.  Thanks



#11 RXB OFFLINE  

RXB

    River Patroller

  • 3,583 posts
  • Location:Vancouver, Washington, USA

Posted Mon Mar 18, 2019 7:27 PM

Yes, the screen time-out counter. How long would it take for it to go from 0 to >FFFF? That would be the maximum time interval that could be counted. Problem is there is no POKE function in XB, so one would not be able to reset the timer before starting the word count.

GKXB,  Super XB have a CALL LOAD or CALL PEEK,

 

Problem is both require CALL INIT to access.

 

RXB does not require a CALL INIT to use CALL LOAD or CALL PEEK this really speeds up access and ez to use.



#12 Vorticon OFFLINE  

Vorticon

    River Patroller

  • 3,726 posts
  • Location:Eagan, MN, USA

Posted Mon Mar 18, 2019 10:28 PM

Can you LOAD into CPU RAM? I thought you could only use CALL LOAD for the expansion RAM to directly load a value.

 

EDIT: Never mind. You can



#13 Vorticon OFFLINE  

Vorticon

    River Patroller

  • 3,726 posts
  • Location:Eagan, MN, USA

Posted Mon Mar 18, 2019 10:51 PM

 

The screen timeout counter steps by 2 at each interrupt, so 32768/3600 = 9.1 minutes.

 

In XB, you use CALL LOAD() to poke byte values into RAM.

 

...lee

 

Actually using the timeout counter won't work because it keeps getting reset while a program is running and only starts counting when the computer is idle. A quick test in Classic99 and its debugger confirmed that.



#14 Vorticon OFFLINE  

Vorticon

    River Patroller

  • 3,726 posts
  • Location:Eagan, MN, USA

Posted Mon Mar 18, 2019 10:53 PM

 

 

 

Timing would be in motion. I do want to try assembly, but I wanted to see what is possible in Basic first.  I think I can handle a peek and poke though.

At least I know that I didn't miss anything easy :)

 

I was being obnoxious here. I was referring to time dilatation with motion  :grin:



#15 Lee Stewart ONLINE  

Lee Stewart

    River Patroller

  • 3,966 posts
  • Location:Silver Run, Maryland

Posted Tue Mar 19, 2019 6:38 AM

Actually using the timeout counter won't work because it keeps getting reset while a program is running and only starts counting when the computer is idle. A quick test in Classic99 and its debugger confirmed that.

 

I actually was not suggesting using the timeout counter—just answering the question.  The timeout counter is incremented by 2 at every VDP interrupt.  It is reset only when a keystroke is detected by KSCAN, the console’s keyboard routine.

 

...lee



#16 Vorticon OFFLINE  

Vorticon

    River Patroller

  • 3,726 posts
  • Location:Eagan, MN, USA

Posted Tue Mar 19, 2019 6:59 AM

In my test, the timer kept getting reset while a short program was running even without any key presses...

#17 Asmusr ONLINE  

Asmusr

    River Patroller

  • 3,110 posts
  • Location:Denmark

Posted Tue Mar 19, 2019 10:04 AM

In my test, the timer kept getting reset while a short program was running even without any key presses...

 

Yes that's also what I found.

 

I then tried for fun to see if I could add my own ISR hook and counter using pokes only. It seems to be working but for some reason it's counting too slowly.

XAS99 CROSS-ASSEMBLER   VERSION 1.7.2
**** **** ****     > isr.a99
0001               	aorg >83b8
0002 83B8 05A0  34 	inc @cnt
     83BA 83BE 
0003 83BC 045B  20 	rt
0004 83BE 0000     cnt data 0
0005               

10 CALL INIT
15 REM CREATE THE ROUTINE
20 CALL LOAD(-31816,5,160,131,190,4,91)
25 REM HOOK INTO ISR
30 CALL LOAD(-31804,131,184)
35 REM READ COUNTER
40 CALL PEEK(-31810,MSB,LSB)
50 TIME=(MSB*256+LSB)/60
60 PRINT INT(TIME)
70 GOTO 40



#18 Lee Stewart ONLINE  

Lee Stewart

    River Patroller

  • 3,966 posts
  • Location:Silver Run, Maryland

Posted Tue Mar 19, 2019 11:49 AM

In my test, the timer kept getting reset while a short program was running even without any key presses...

 

Yes that's also what I found.

...

 

My bad.  :P   I just checked the console code and, indeed, the VDP screen timeout timer, >83D6, is reset for each and every Basic statement executed.  Sorry about that.

 

However, what I said about KSCAN still obtains for any ALC (and TI Forth, fbForth and, I believe, TurboForth and Camel99 Forth) program that does not explicitly change >83D6, i.e., >83D6 will not be reset until a new keystroke is detected by KSCAN.

 

...lee



#19 Tursi OFFLINE  

Tursi

    Quadrunner

  • 5,638 posts
  • HarmlessLion
  • Location:BUR

Posted Tue Mar 19, 2019 5:11 PM

 

 

Yes that's also what I found.

 

I then tried for fun to see if I could add my own ISR hook and counter using pokes only. It seems to be working but for some reason it's counting too slowly.

XAS99 CROSS-ASSEMBLER   VERSION 1.7.2
**** **** ****     > isr.a99
0001               	aorg >83b8
0002 83B8 05A0  34 	inc @cnt
     83BA 83BE 
0003 83BC 045B  20 	rt
0004 83BE 0000     cnt data 0
0005               

10 CALL INIT
15 REM CREATE THE ROUTINE
20 CALL LOAD(-31816,5,160,131,190,4,91)
25 REM HOOK INTO ISR
30 CALL LOAD(-31804,131,184)
35 REM READ COUNTER
40 CALL PEEK(-31810,MSB,LSB)
50 TIME=(MSB*256+LSB)/60
60 PRINT INT(TIME)
70 GOTO 40

 

Print scrolls the screen, and scrolling the screen takes more than one frame in BASIC/XB. During the screen scroll, interrupts are blocked. You can see it happen with a moving sprite, too.



#20 Vorticon OFFLINE  

Vorticon

    River Patroller

  • 3,726 posts
  • Location:Eagan, MN, USA

Posted Tue Mar 19, 2019 6:03 PM

Learn something everyday :)



#21 RXB OFFLINE  

RXB

    River Patroller

  • 3,583 posts
  • Location:Vancouver, Washington, USA

Posted Tue Mar 19, 2019 6:05 PM

 

Print scrolls the screen, and scrolling the screen takes more than one frame in BASIC/XB. During the screen scroll, interrupts are blocked. You can see it happen with a moving sprite, too.

Try RXB:

10 CALL INIT
15 REM CREATE THE ROUTINE
20 CALL LOAD(-31816,5,160,131,190,4,91)
25 REM HOOK INTO ISR
30 CALL LOAD(-31804,131,184)
35 REM READ COUNTER
40 CALL PEEK(-31810,MSB,LSB)
50 CALL HPUT(INT((MSB*256+LSB)/60)
60 GOTO 40



#22 1980gamer OFFLINE  

1980gamer

    Dragonstomper

  • 986 posts
  • Location:Charlton, MA

Posted Tue Mar 19, 2019 8:01 PM

 

Print scrolls the screen, and scrolling the screen takes more than one frame in BASIC/XB. During the screen scroll, interrupts are blocked. You can see it happen with a moving sprite, too.

Are you talking about the screen FREEZE for a split second?

Or the output issues?

25

25

25

25

21

25

25

25

26

26


Edited by 1980gamer, Wed Mar 20, 2019 3:29 AM.


#23 LASooner OFFLINE  

LASooner

    Moonsweeper

  • 401 posts

Posted Tue Mar 19, 2019 8:44 PM

 

 

Yes that's also what I found.

 

I then tried for fun to see if I could add my own ISR hook and counter using pokes only. It seems to be working but for some reason it's counting too slowly.

XAS99 CROSS-ASSEMBLER   VERSION 1.7.2
**** **** ****     > isr.a99
0001               	aorg >83b8
0002 83B8 05A0  34 	inc @cnt
     83BA 83BE 
0003 83BC 045B  20 	rt
0004 83BE 0000     cnt data 0
0005               

10 CALL INIT
15 REM CREATE THE ROUTINE
20 CALL LOAD(-31816,5,160,131,190,4,91)
25 REM HOOK INTO ISR
30 CALL LOAD(-31804,131,184)
35 REM READ COUNTER
40 CALL PEEK(-31810,MSB,LSB)
50 TIME=(MSB*256+LSB)/60
60 PRINT INT(TIME)
70 GOTO 40

 

 

This works in Classic99, but JS99er.net doesn't like it



#24 Tursi OFFLINE  

Tursi

    Quadrunner

  • 5,638 posts
  • HarmlessLion
  • Location:BUR

Posted Wed Mar 20, 2019 3:04 AM

Learn something everyday :)

 

I do too, that's why it's so much fun to come here ;)



#25 Tursi OFFLINE  

Tursi

    Quadrunner

  • 5,638 posts
  • HarmlessLion
  • Location:BUR

Posted Wed Mar 20, 2019 3:16 AM

Are you talking about the screen FREEZE for a split second?

 

I didn't run the code, so I guess the freeze. ;) If you're running interrupts in XB and you scroll the screen, it will miss a few frames. ;)

 

I find it easiest to see with a sprite - you can visibly see the motion stutter:

 

10 CALL SPRITE(#1,65,3,100,100,0,50)
20 INPUT A$
30 PRINT : : : : : : : : : :
40 GOTO 20





0 user(s) are browsing this forum

0 members, 0 guests, 0 anonymous users