Horizontal Interrupts & Rasters

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

Moderators: BigEvilCorporation, Mask of Destiny

Post Reply
elusive
Very interested
Posts: 57
Joined: Fri Jan 27, 2012 12:03 am

Horizontal Interrupts & Rasters

Post by elusive » Fri Jan 27, 2012 12:10 am

Hi everyone, I'm somewhat new to programming for the Genesis/Mega Drive (about a year or so with programming for it), and I'm trying to expand my knowledge a bit, and having a hard time finding information and tutorials on a few things.

First, I'm programming in BEX (I know, I know, no flaming please ;) ) and I can understand C/C++ code, and I'm absolutely horrible at learning ASM (at least from reading the few tutorials I've found anyway).

Anywho, onto some questions:

I've been trying to learn how to do some raster effects (like in Rocket Knight Adventures, Batman and Robin, etc), with screen distortions and warping tiles (tilting/rotating), but I honestly have no idea where to start.

I know for the screen distortion in Rocket Knight Adventures (you know, when you're running away from the fire that gets shot out of the right side of the screen), you need to set the HBLANK to 0, and call a routine for the H Interrupt.

Whenever I enable the HBLANK, my controller routines stop (I'm assuming this is because it takes a higher precedence over the VBLANK and that's what controls the controller inputs?).

Does anyone know of any tutorials that will help with rasters (and possibly how to efficiently use the scroll modes) and proper ways to utilize the HBLANK Interrupts?

Thanks!

Charles MacDonald
Very interested
Posts: 292
Joined: Sat Apr 21, 2007 1:14 am

Re: Horizontal Interrupts & Rasters

Post by Charles MacDonald » Fri Jan 27, 2012 3:42 am

Whenever I enable the HBLANK, my controller routines stop (I'm assuming this is because it takes a higher precedence over the VBLANK and that's what controls the controller inputs?).
This shouldn't happen -- vblank has a higher priority (6) than line interrupts (4). It's hard to say what the problem is without looking at your code, however.

In general I would make sure you have the line interrupt vector pointing to a valid function which saves all registers (using movem) and then restores them and finishes with RTE.

If you aren't using assembly you may find it difficult to do raster effects properly as they must run very quickly.
Does anyone know of any tutorials that will help with rasters (and possibly how to efficiently use the scroll modes) and proper ways to utilize the HBLANK Interrupts?
I've spent a lot of time analyzing raster effects in various games, including Batman & Robin so if there is any specific effect in a level you want to know about, just ask and I'll try to help.

There aren't any tutorials about this subject though.

elusive
Very interested
Posts: 57
Joined: Fri Jan 27, 2012 12:03 am

Post by elusive » Fri Jan 27, 2012 3:57 am

You're right, it was my code (too much in the hblank).

The effect I'm interested in the most from Batman and Robin is the effect on the Cheshire Cat's face. Also, when fighting the Mad Hatter, are the sprites already prerendered that spin when he tosses them down, or is that a raster effect as well?

I can insert ASM, though I'm not very familiar with ASM commands :/

Charles MacDonald
Very interested
Posts: 292
Joined: Sat Apr 21, 2007 1:14 am

Post by Charles MacDonald » Fri Jan 27, 2012 4:40 am

The effect I'm interested in the most from Batman and Robin is the effect on the Cheshire Cat's face.
The part where the head rotates left and right during combat or the part at the end where it falls over?

The former is a scrolling effect (using line scrolling and vertical column scrolling at the same time for shearing, which sort of approximates rotation -- notice the head never turns more than 45 degrees) and the latter is a raster effect (adjusting the vertical scroll on every line).
Also, when fighting the Mad Hatter, are the sprites already prerendered that spin when he tosses them down, or is that a raster effect as well?
All pre-rendered. Generally raster effects won't be involved for anything that involves rotation or small objects.

elusive
Very interested
Posts: 57
Joined: Fri Jan 27, 2012 12:03 am

Post by elusive » Fri Jan 27, 2012 4:46 am

Charles MacDonald wrote: The part where the head rotates left and right during combat or the part at the end where it falls over?

The former is a scrolling effect (using line scrolling and vertical column scrolling at the same time for shearing, which sort of approximates rotation -- notice the head never turns more than 45 degrees) and the latter is a raster effect (adjusting the vertical scroll on every line).
The part during combat.

I guess I'm not sure how to use the scroll modes aside from the over all vert and horizontal modes.

And thanks for answering the other question. I thought that's what they were, but wasn't sure :)

Charles MacDonald
Very interested
Posts: 292
Joined: Sat Apr 21, 2007 1:14 am

Post by Charles MacDonald » Fri Jan 27, 2012 5:06 am

I guess I'm not sure how to use the scroll modes aside from the over all vert and horizontal modes.
In VDP register $0B, bit 2 enables vertical column scrolling when set, and bits 1,0 enable line scrolling when both are set:

Code: Select all

move.w #$8B07, $C00004 ; Enable column and line scroll
Since you have done full screen scrolling, you already have a horizontal scroll data table in VRAM where you have been writing scroll values. Remember how the first word was the scroll value of plane A and the second word was the scroll value of plane B? Now these two words are the scroll values of line 0 only. The next two words are the scroll values for line 1, etc. This continues for all 224 lines of the display.

So if you want to scroll lines of plane A only, you'd just update even addresses in that table.

For vertical column scrolling it works the same way. In VSRAM, every even value is the vertical scroll value for columns 0 through 19 of plane A, and every odd value is the vertical scroll value for columns 0 through 19 of plane B.

To calculate the scroll values used for shearing you'll need a bit of fixed point math. Generally you can see that the amount they scroll the cat's head from the top line to the center is applied in the opposite direction from the center to the bottom line, and the same applies for the columns from left to right. This is what gives the appearance of the head rotating.

For the part where the edges of the cat's face wiggles up and down, they are still applying regular shearing but now adding a sine wave to the outer columns and reducing the amplitude for each inner pair of columns. This gives a greater degree of wiggle on the outside and less towards the center.

elusive
Very interested
Posts: 57
Joined: Fri Jan 27, 2012 12:03 am

Post by elusive » Fri Jan 27, 2012 1:00 pm

Okay, I understand the theory behind that, I think :P

In Vertical Column scrolling, doesn't each value move 2 columns together? You mention that even values scroll columns 0 through 19 on A, and odd values on B. If I'm understanding you correctly, if I were to scroll, say, column 2, it would really be columns 2 and 3 on plane A, but if I did 3, it would be 3 and 4 on plane B?

Also, to add a sine wave, it's just a matter of setting the scroll values right?

Charles MacDonald
Very interested
Posts: 292
Joined: Sat Apr 21, 2007 1:14 am

Post by Charles MacDonald » Fri Jan 27, 2012 4:03 pm

In Vertical Column scrolling, doesn't each value move 2 columns together? You mention that even values scroll columns 0 through 19 on A, and odd values on B. If I'm understanding you correctly, if I were to scroll, say, column 2, it would really be columns 2 and 3 on plane A, but if I did 3, it would be 3 and 4 on plane B?
Sorry, I didn't clarify that point -- by column I meant each 16-pixel column. You are right, each column is two vertical strips of tiles.
Also, to add a sine wave, it's just a matter of setting the scroll values right?
Yep, that's all it is.

elusive
Very interested
Posts: 57
Joined: Fri Jan 27, 2012 12:03 am

Post by elusive » Fri Jan 27, 2012 4:15 pm

Thanks for the clarification :)

I'll start messing around with these modes when I get home from work. Thanks Charles!

Post Reply