Timer interrupts

SGDK only sub forum

Moderator: Stef

Post Reply
Boyfinn
Very interested
Posts: 57
Joined: Sat Aug 08, 2015 12:12 pm
Location: Lapland, Finland

Timer interrupts

Post by Boyfinn » Tue Apr 02, 2019 11:57 am

Does the megadrive have any timer interrupts? or does it just have the blanking interrupts?
Either way, Would anyone here have any example of an interrupt function that may repeat at a set amount of time?

Stef
Very interested
Posts: 3131
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Re: Timer interrupts

Post by Stef » Tue Apr 02, 2019 5:10 pm

There is no timer interrupt, just VInt (and HInt). What we do usually is just counting a number of frame (using the vint) then when counter elapsed we process the event (then we reload the counter / timer for the next event).

Chilly Willy
Very interested
Posts: 2984
Joined: Fri Aug 17, 2007 9:33 pm

Re: Timer interrupts

Post by Chilly Willy » Tue Apr 02, 2019 5:19 pm

There ARE timers on the YM2612, but in their infinite wisdom, SEGA didn't connect the INT line from the 2612 to the Z80. People still use the 2612 timers in some cases, but it won't interrupt the Z80 or 68000, so you have to poll it periodically. Given most games don't need that kind of timing, nearly everyone just uses the vblank int to count frames, as Stef mentioned.

Boyfinn
Very interested
Posts: 57
Joined: Sat Aug 08, 2015 12:12 pm
Location: Lapland, Finland

Re: Timer interrupts

Post by Boyfinn » Wed Apr 03, 2019 10:40 am

Chilly Willy wrote:
Tue Apr 02, 2019 5:19 pm
There ARE timers on the YM2612, but in their infinite wisdom, SEGA didn't connect the INT line from the 2612 to the Z80. People still use the 2612 timers in some cases, but it won't interrupt the Z80 or 68000, so you have to poll it periodically. Given most games don't need that kind of timing, nearly everyone just uses the vblank int to count frames, as Stef mentioned.
Oh, thats BS. Timer interrupts are such a basic feature it should've been implemented.
Well, there's no way around polling and software timers then, eh?

It just feels so wrong to poll for anything because i've been taught to avoid that.

Miquel
Very interested
Posts: 514
Joined: Sat Jul 30, 2016 12:33 am

Re: Timer interrupts

Post by Miquel » Wed Apr 03, 2019 11:56 am

Since you update the game on a frame basis doesn't make sense to have more accurate timing than that.
The exceptions could be sound/music and sintetic tests.
HELP. Spanish TVs are brain washing people to be hostile to me.

Miquel
Very interested
Posts: 514
Joined: Sat Jul 30, 2016 12:33 am

Re: Timer interrupts

Post by Miquel » Wed Apr 03, 2019 3:25 pm

Possibly, if you are thinking on a game, the hidden discussion we are having here is how to structure the engine, in particular, how to make easy developing the IA.

A bit of addendum:

This cool way of managing concealed ideas remains me on how calm you have to be while endorsing diplomacy whit other people. Let me put two examples.

We were just asking representatives of well stablished religions about how the predictable imminent future will impact on them, and, after asking just that to an Indian, he told me:

“You idiot, westerns believe they are the center of the world!, the basis of our religion is precisely the existence of extraterrestrials!”

As said, on diplomacy you should always answer with a full smile and wait your turn. While the conversation was developing become very obvious that while he believed on the existence of other people he also trust they to be very far, like on other system or galaxy. That was my turn, I put him on perplexity when I told him they were right on his belly.

The second tale developed right when we were talking with southern Rarutziiby for second time, and I just learn they have streets on their cities. That didn’t make sense to me, because, why they need them? they just can “fly” on water, right? So I just ask them, and answer was:

“To carry things”, and undoubtedly thought: “how brilliant are those humans”

A year later we accomplish to visualize another one of their cities, enrolling their help, this time a norther one, and we were shock to observe a well known disposition, their city was built around two big streets perpendicular one to the other, while main/governmental buildings are situated on the junction. If this rings a bell, be warn, a lots of bells are coming.
HELP. Spanish TVs are brain washing people to be hostile to me.

Boyfinn
Very interested
Posts: 57
Joined: Sat Aug 08, 2015 12:12 pm
Location: Lapland, Finland

Re: Timer interrupts

Post by Boyfinn » Thu Apr 04, 2019 2:54 pm

Miquel wrote:
Wed Apr 03, 2019 3:25 pm
-cut-
I didnt mean for my message to come across in any way that might offend people.
I was merely expressing my frustration with the hardware.
As much as i love the sega megadrive, timer interrupts could've greatly improved the amount of logic and code to achieve certain timed events for both low-level assembly and C.

Also, I've been strictly taught not to poll on any hardware and rely on interrupts instead. That's the only thing that makes sense for me and that i can wrap my head around.

So once again, I'm really sorry if my message came across as arrogant or asshole-ish.
After all, im having a hard enough time wrapping my head around C again after doing assembly for so long.

Stef
Very interested
Posts: 3131
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Re: Timer interrupts

Post by Stef » Thu Apr 04, 2019 4:46 pm

I was eventually thinking of adding "timer event" to SGDK but internally they would use the V-Int for that (and so could be inaccurate if some V-Int were missed or if they are disabled).

Boyfinn
Very interested
Posts: 57
Joined: Sat Aug 08, 2015 12:12 pm
Location: Lapland, Finland

Re: Timer interrupts

Post by Boyfinn » Thu Apr 04, 2019 4:51 pm

Stef wrote:
Thu Apr 04, 2019 4:46 pm
(and so could be inaccurate if some V-Int were miss or if they are disabled).
That's a good example of what I mean.
It didnt really come across my mind at the time of writing my post.

Sik
Very interested
Posts: 939
Joined: Thu Apr 10, 2008 3:03 pm
Contact:

Re: Timer interrupts

Post by Sik » Fri Apr 05, 2019 9:26 pm

Yeah, games treat vblank as their main timer. There's no point processing game logic more often than the hardware will ever draw on screen, so it's normally seen as good enough (and consider that early computers in several cases had it even worse than consoles of the time).

The YM2612 timer interrupts not being connected is bullshit, yeah, but if you ever use them, expect them to more likely see use in the context of audio (e.g. Echo uses timer A to handle PCM output and timer B as its "tempo" timer).
Sik is pronounced as "seek", not as "sick".

Miquel
Very interested
Posts: 514
Joined: Sat Jul 30, 2016 12:33 am

Re: Timer interrupts

Post by Miquel » Sun Apr 07, 2019 7:26 pm

Boyfinn wrote:
Thu Apr 04, 2019 2:54 pm
I didnt mean for my message to come across in any way that might offend people.
You haven't offend anyone. :)
Boyfinn wrote:
Thu Apr 04, 2019 2:54 pm
I was merely expressing my frustration with the hardware.
As much as i love the sega megadrive, timer interrupts could've greatly improved the amount of logic and code to achieve certain timed events for both low-level assembly and C.
If you are developing a videogame I very much doubt REALLY need more timing hardware. You need better organization on a engine level to write easy IA routines. That's what my experience says.

Perhaps you are used to write programs for OS', then guess what, at a hardware level x86 has very few user friendly timers (like 1 or 2), the rest is accomplished by software.
HELP. Spanish TVs are brain washing people to be hostile to me.

Post Reply