# Calculating time

## Recommended Posts

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?

##### Share on other sites

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

##### Share on other sites

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

##### Share on other sites

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

##### Share on other sites

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.

##### Share on other sites

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

##### Share on other sites

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

Great idea! Didn't think of that.

##### Share on other sites

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

##### Share on other sites

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

##### Share on other sites

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

##### Share on other sites

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.

##### Share on other sites

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

##### Share on other sites

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.

##### Share on other sites

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

##### Share on other sites

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

##### Share on other sites

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

##### Share on other sites

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
25 REM HOOK INTO ISR
40 CALL PEEK(-31810,MSB,LSB)
50 TIME=(MSB*256+LSB)/60
60 PRINT INT(TIME)
70 GOTO 40

```

##### Share on other sites

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. 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

##### Share on other sites

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
25 REM HOOK INTO ISR
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.

##### Share on other sites

Learn something everyday

##### Share on other sites

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
25 REM HOOK INTO ISR
40 CALL PEEK(-31810,MSB,LSB)
50 CALL HPUT(INT((MSB*256+LSB)/60)
60 GOTO 40

```

##### Share on other sites

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

##### Share on other sites

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
25 REM HOOK INTO ISR
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

##### Share on other sites

Learn something everyday

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

##### Share on other sites

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
```

## Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

×   Pasted as rich text.   Paste as plain text instead

Only 75 emoji are allowed.

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.