Posts: 8
Threads: 2
Joined: Aug 2019
Reputation:
0
Hey all. Been playing more with programming for the NGPC, and it really is a fun system to work with.
One thing I've been wanting to try next is changing the scroll position at time of HBlank to create raster effects (like stretching vertically, or raster 'haze' effects). I'm having a bit of trouble understanding the timing and requirements to executing code during the h-interrupt, however.
I'm using the C framework. I tried creating a new HBlankInterrupt routine and installing it to HBL_INT (0x6FD4), but it doesn't seem to execute the code inside. I'm thinking maybe I have to change the interrupt priority setting? But I'm not exactly sure how that works.
If anybody has any tips/sample code to help execute commands during HBlank, that would be a great help.
Posts: 1,610
Threads: 19
Joined: Feb 2012
Reputation:
29
I wonder if we can get Thor to come offer any expertise. Maybe he'd know. I'll try to contact him.
Posts: 1,610
Threads: 19
Joined: Feb 2012
Reputation:
29
I might, then, suggest sending them a private message with a link to this thread to see if they'd like to chime in.
Posts: 8
Threads: 2
Joined: Aug 2019
Reputation:
0
03-27-2020, 04:00 PM
(This post was last modified: 03-27-2020, 07:29 PM by Nnnn.)
Amazing, thank you thor!!
But I don't think the file is attached!
EDIT: Sent my email address just in case.
Posts: 91
Threads: 6
Joined: Apr 2012
Reputation:
2
file sent, tell me if it's ok
Posts: 8
Threads: 2
Joined: Aug 2019
Reputation:
0
Wonderful! Thank you, Flavor and sodthor. This is more than I could have hoped for.
Posts: 85
Threads: 16
Joined: Apr 2020
Reputation:
7
I am finding when working with hblank to do gradients, or even simpler solid segments, by setting the bg color that I get great behavior on an emulator, but something much different and less desirable happens on real hardware.
In general, the emulator (vdmgr in this case) seems to run much faster than real hardware, so I'm guessing that's a factor in the change in behavior.
In my case I have the scroll plane 2 segmented into 4 sections, where I control X separately for 3 of them. For each segment, I was applying a different bg color.
On real hardware, the transitions from one segment to the next looked like they were competing for a pixel row, as if the bg color was changing in the middle of the line being drawn. In that line there are a lot of jittery artifacts.
I got to thinking that setting bg color and moving the plane within the same hblank might be too much, so I attempted doing them separately and it didn't improve things much.
I am working in C and have to imagine that most of what I'm doing is not efficient, but I'm not sure what to make of this issue. A lot of it was pulled from sodthor's code linked above, and I have observed his intro working fine on real hardware. Perhaps it's an issue of choosing between either gradient backgrounds or segmented horizontal movement, but not both?
It's a little disappointing, because as I was looking up hblank effects and examples, I saw mention of Castlevania: Rondo of Blood. Knowing what I know now about these effects, I reviewed some videos of Rondo of Blood and was thinking the NGPC could pull of a lot of the same effects, which seem to mostly be gradients and segmented scrolling at the same time.
In addition to the less than ideal effect I'm getting on real hardware, it seems that applying bg colors in hblanks is pretty taxing. The difference between having the bg color changed only 4 times within a vblank, and not doing any bg changes at all, is the difference between a game that's maybe a little too fast (may need to slow it down with timer variables) or one that's too slow (not much I can do to speed it up).
By comparison, before I started working with hblank interrupts, my main loop that controls the character and level drawing/movement was waiting for 150 intervals of a timer variable (just adding to a variable every loop with no artificial waiting). After adding hblank effects, I essentially had to eliminate the timer and do main operations every loop. It makes sense, since adding hblank effects means you're running whatever is in the interrupt 152 times per frame, even if it's just checking that it doesn't have to do anything.
I will have to see if I can replicate my issue in a less complicated program and come up with a simple demo and source code, but I'm curious if anyone else has experience with making use of these effects.