Login
Back to forumReply to this topicGo to last reply

Posted By

Haegar
on 2023-10-14
11:45:55
 program a timer

Hello,

Maybe someone can help me. I want to program a timer (in assembler), but I have no idea how to start.

Posted By

Ati
on 2023-10-14
11:56:00
 Re: program a timer

Hello Haegar!
If you count frames, you can take one sec.

Posted By

gerliczer
on 2023-10-14
13:10:14
 Re: program a timer

It is not too complicated. Set the timer you want as an interrupt source in the Interrupt Control Register ($FF09) and set the timer value in the corresponding Timer Register ($FF00/$FF01|$FF02/$FF03|$FF04/$FF05). I'm not sure which is the correct write sequence high-low or low-high, that you should find in some documentation. The first timer is repeating, the other two are on shot types and they will continue with a full cycle after finishing. There is a simple description of TED Registers in the Plus/4 Encyclopedia under the Programming/Assembly section. Csabo has an example for one in Defiance's music routine.

Posted By

Haegar
on 2023-10-14
14:28:04
 Re: program a timer

Hi Gerliczer,
There should be no timer interrupt, more a countdown. As an example, count back from 1 minute to zero. There is already a timer that you can query in Basic with TI$ or TI. Does anyone know where you can query it?

Posted By

gerliczer
on 2023-10-14
14:31:14
 Re: program a timer

Ah! That is quite a different thing. You should check out SVS' excellent Ultimate Map. It has a detailed description of BASIC system variables.

Posted By

SVS
on 2023-10-15
04:08:18
 Re: program a timer

You can consider the use of $A3...$A5 memory cells. They are updated every 1/60th of second (even if system is a PAL), and are automatically reset after 24 hours.

Posted By

gerliczer
on 2023-10-15
04:45:32
 Re: program a timer

Well, the BASIC timer actually is not running at 60Hz in PAL systems but its counter is increased by two at every fifth time, IIRC. Furthermore, the timer is not exactly accurate as PAL machines run at about 49.86 Fps and NTSC ones at approximately 59.92 Fps. Also, there are the Drean machines, rare as they are, at who knows what frame rate.

Posted By

Haegar
on 2023-10-15
06:54:25
 Re: program a timer

Thanks, that seems to be exactly what I need. I will try it out.

Posted By

SVS
on 2023-10-16
04:36:18
 Re: program a timer

@gerliczer: are you sure? I remember, when I wrote that section of Ultimate Map, that I'd discovered a special routine that adds +10 to the counter in case of PAL-system, so that in any way it achieves 60.

Posted By

gerliczer
on 2023-10-16
06:39:28
 Re: program a timer

I was not, that is why I added IIRC which means If I Remember Correctly. But now I checked it in a ROM disassembly book. It should work as I wrote. Check the routine at $CFD1.

Posted By

SVS
on 2023-10-16
09:06:09
 Re: program a timer

@gerliczer: What I understand from the code, is that the counter is added by +1 every 5 PAL tics. In this way after 50 tics the counter is 60. Then summarizing: There are 50 updates per second, but the counter is increased of +60 per second. Am I right?

Posted By

gerliczer
on 2023-10-16
09:35:24
 Re: program a timer

Yes, that is the mechanism in PAL machines, just as I wrote in my post yesterday. The one second is a question though as refresh rate is not exactly 50 Fps.



Back to topReply to this topic


Copyright © Plus/4 World Team, 2001-2024. Support Plus/4 World on Patreon