Horizontal Interrupts & Rasters
Moderators: BigEvilCorporation, Mask of Destiny
Horizontal Interrupts & Rasters
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!
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!
-
- Very interested
- Posts: 292
- Joined: Sat Apr 21, 2007 1:14 am
Re: Horizontal Interrupts & Rasters
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.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?).
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.
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.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?
There aren't any tutorials about this subject though.
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 :/
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 :/
-
- Very interested
- Posts: 292
- Joined: Sat Apr 21, 2007 1:14 am
The part where the head rotates left and right during combat or the part at the end where it falls over?The effect I'm interested in the most from Batman and Robin is the effect on the Cheshire Cat's face.
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).
All pre-rendered. Generally raster effects won't be involved for anything that involves rotation or small objects.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?
The part during combat.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).
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
-
- Very interested
- Posts: 292
- Joined: Sat Apr 21, 2007 1:14 am
In VDP register $0B, bit 2 enables vertical column scrolling when set, and bits 1,0 enable line scrolling when both are set:I guess I'm not sure how to use the scroll modes aside from the over all vert and horizontal modes.
Code: Select all
move.w #$8B07, $C00004 ; Enable column and line scroll
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.
Okay, I understand the theory behind that, I think
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?
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?
-
- Very interested
- Posts: 292
- Joined: Sat Apr 21, 2007 1:14 am
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.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?
Yep, that's all it is.Also, to add a sine wave, it's just a matter of setting the scroll values right?