Forums

Sega Master System / Mark III / Game Gear
SG-1000 / SC-3000 / SF-7000 / OMV
Home - Forums - Games - Scans - Maps - Cheats - Credits
Music - Videos - Development - Hacks - Translations - Homebrew

View topic - Periodic interrupts every 1/10th of a frame.

Reply to topic
Author Message
  • Joined: 24 Sep 2013
  • Posts: 141
Reply with quote
Periodic interrupts every 1/10th of a frame.
Post Posted: Tue Jun 25, 2019 12:35 pm
I want to get some precise timing using the VDP but reading the docs I don't know how scanline interrupts work.

If I wanted to have an interrupt every tenth of a frame, even during active/blanking, will it work by just setting the counter register to 312/10 (31)?
  View user's profile Send private message Visit poster's website
  • Joined: 05 Sep 2013
  • Posts: 3757
  • Location: Stockholm, Sweden
Reply with quote
Post Posted: Tue Jun 25, 2019 1:00 pm
you won't have any line interrupt during v-blank, unfortunately - you'll have to find some other way to handle the timing right in that phase.
  View user's profile Send private message Visit poster's website
  • Joined: 24 Sep 2013
  • Posts: 141
Reply with quote
Post Posted: Tue Jun 25, 2019 1:21 pm
The shortest period then it would be at a minimum the duration of VBlank, setting the line register to VBlank length and on the last line setting it to Zero as to get a line interrupt as soon as the active area starts again.

I'll need to crunch the numbers if it is feasible ...
  View user's profile Send private message Visit poster's website
  • Joined: 05 Sep 2013
  • Posts: 3757
  • Location: Stockholm, Sweden
Reply with quote
Post Posted: Tue Jun 25, 2019 1:48 pm
but vblank is quite long, at least on a PAL machine: 313-192 lines...
  View user's profile Send private message Visit poster's website
  • Joined: 24 Sep 2013
  • Posts: 141
Reply with quote
Post Posted: Tue Jun 25, 2019 6:50 pm
sverx wrote
but vblank is quite long, at least on a PAL machine: 313-192 lines...


So not only I'm out of interrupts on VBlank but also on the inactive areas. :/

Maybe I can get something workable with TMS modes, actually I don't really need Mode 4 for this. And I really don't want to fake it and add an external timer circuit.
  View user's profile Send private message Visit poster's website
  • Joined: 05 Sep 2013
  • Posts: 3757
  • Location: Stockholm, Sweden
Reply with quote
Post Posted: Wed Jun 26, 2019 5:55 am
if you need precise timing (for music?) and you don't need to do something else (on screen?) at the same time, you could just have a big delay inside your loop. Timing would be very precise, as Maxim's pcmenc demonstrates well.
  View user's profile Send private message Visit poster's website
  • Site Admin
  • Joined: 19 Oct 1999
  • Posts: 14682
  • Location: London
Reply with quote
Post Posted: Wed Jun 26, 2019 6:59 am
But as soon as your periodic code has any branches, you start to have difficulty cycle counting...
  View user's profile Send private message Visit poster's website
  • Joined: 24 Sep 2013
  • Posts: 141
Reply with quote
Post Posted: Wed Jun 26, 2019 7:35 pm
I want to move away from cycle counting and start using strictly interrupt based code. I'll give it a try this weekend.
  View user's profile Send private message Visit poster's website
  • Joined: 01 Jan 2014
  • Posts: 331
Reply with quote
Post Posted: Thu Jun 27, 2019 1:26 am
Polling v counter is probably your best bet. http://www.smspower.org/Development/ScanlineCounter

Calindro and I used the the technique a while back to play a high frequency chip tune, works well.
  View user's profile Send private message
Reply to topic



Back to the top of this page

Back to SMS Power!