How h interrupt register works?

For anything related to VDP (plane, color, sprite, tiles)

Moderators: BigEvilCorporation, Mask of Destiny

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

How h interrupt register works?

Post by Miquel » Sat Jun 09, 2018 5:54 pm

How "h interrupt register" reg #10 really works?

I'm trying to modify it's value inside a horizontal exception to fire again in X raster lines more and it seems to completely ignore the value, instead fires again at the previous value, but strangely enough half screen later takes my value into account (?!?).

My first suspicion was that the value that counts is taken at the end of the v-blank, but no, after a while seems to work.

Any crazy idea?

How I'm doing is:
1) In v-blank I set reg10 to a in screen value
2) In a first h-exception I set reg10 to a second in screen value
3) In a second h-exception I set reg10 to 0xFF
HELP. Spanish TVs are brain washing people to be hostile to me.

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

Re: How h interrupt register works?

Post by Sik » Sat Jun 09, 2018 6:00 pm

The counter is reloaded as soon as the interrupt fires, and the register only takes effect when the counter gets reloaded, so yes, it'll only take effect on the interrupt following the next one.

Yes, it's annoying and you have to work around it.
Sik is pronounced as "seek", not as "sick".

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

Re: How h interrupt register works?

Post by Miquel » Sun Jun 10, 2018 9:33 am

Quite bothering indeed.

That's the best explanation I have found so far:

Code: Select all

 The VDP has a counter that is decremented on every line. When the counter
 has expired, and if bit 4 (IE1) of register #0 is set, then a level 4
 interrupt will occur.

 The counter is loaded with the contents of register #10 in the following
 situations:

 - Line zero of the frame.
 - When the counter has expired.
 - Lines 225 through 261. (note that line 224 is not included)

 The counter is *not* loaded when register #10 is written to.
from: https://emudocs.org/Genesis/Graphics/genvdp.txt

I just ended setting reg10 to 0 and use an internal counter, and the result have been a bit better than I thought (check attached rom file).
Alien noise.zip
(8.38 KiB) Downloaded 347 times
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: How h interrupt register works?

Post by Miquel » Tue Jun 12, 2018 11:45 am

I just tried to disconnect display while dma'ing and works MUCH better, on real hardware I only see artefacts with sprites on a very precise line (on the top of the D), and not at all with planes.

Alien Noise (clearer than before).zip
(8.49 KiB) Downloaded 346 times
HELP. Spanish TVs are brain washing people to be hostile to me.

pitcrawler
Newbie
Posts: 6
Joined: Mon Jul 24, 2017 8:24 pm

Re: How h interrupt register works?

Post by pitcrawler » Tue Jun 19, 2018 7:55 pm

I spent a long time trying to get this to work myself. I did manage to eventually get my raster effects working, changing the counter during the hblank. I'm not entirely sure why it works though, it was all trial and error. You kind of have to start changing it 2 steps before you want to see the change.

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

Re: How h interrupt register works?

Post by Miquel » Wed Jun 20, 2018 5:03 pm

The issue is the countdown "internal register" gets update before any horitzontal exception instruction has the change to be executed.

Yes, going two steeps ahead works but involves doing more cases/code, and what I was trying to do is self-changing code to be really fast, an then it must be placed on RAM and be really short. I guess the wining strategy is to do a jump from RAM to ROM like "Sonic 3" does, that allows to change next h-excp routine easily depending on the varying needs.
HELP. Spanish TVs are brain washing people to be hostile to me.

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

Re: How h interrupt register works?

Post by Sik » Wed Jun 20, 2018 10:08 pm

Well, two steps ahead is not that problematic (even if a bit annoying)... the problem is what you do the first time - the first two interrupts have to happen with the same interval, no way to avoid that situation.
Sik is pronounced as "seek", not as "sick".

pitcrawler
Newbie
Posts: 6
Joined: Mon Jul 24, 2017 8:24 pm

Re: How h interrupt register works?

Post by pitcrawler » Tue Jun 26, 2018 10:07 pm

Yeah, with the first couple screen of lines you can't do a thing. In my case I just got lucky because I didn't need to.

Post Reply