Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Working with h-blank interrupt?
#1
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.
Reply
#2
I wonder if we can get Thor to come offer any expertise. Maybe he'd know. I'll try to contact him.
Card Fighters' Clash 2 English Translation ( http://cfc2english.blogspot.com/ )
Neo Geo Pocket Flash Cart and Linker Project ( http://www.flashmasta.com/ )
Avatar art thanks to Trev-Mun ( http://trevmun.deviantart.com/ )
Reply
#3
Thanks for your reply.

While I don't want to force anybody to reveal their secrets or anything, I believe hitchhikr understands how this works, as they demonstrated similar effects in their excellent NGP monochrome demo.

mic_ also has some super impressive work with sound and music, which I believe utilizes a similar method of interrupts using the uDMAC(?), (in C even!) but I just don't understand how it all works  Big Grin

(speaking of which, I notice that the version of ngpc.h in some of mic_'s work includes some info on interrupts and system variables that isn't in the (also amazing) ngpc framework -- maybe we should all try and make a collaborative most up-to-date library?)
Reply
#4
I might, then, suggest sending them a private message with a link to this thread to see if they'd like to chime in.
Card Fighters' Clash 2 English Translation ( http://cfc2english.blogspot.com/ )
Neo Geo Pocket Flash Cart and Linker Project ( http://www.flashmasta.com/ )
Avatar art thanks to Trev-Mun ( http://trevmun.deviantart.com/ )
Reply
#5
(03-27-2020, 03:07 AM)Flavor Wrote: I might, then, suggest sending them a private message with a link to this thread to see if they'd like to chime in.

I tried to attach the sources of the intro I've done for years ago for 'card fighters clash' . It's in C and display a background gradient using hbl.
Reply
#6
Amazing, thank you thor!!

But I don't think the file is attached!

EDIT: Sent my email address just in case.
Reply
#7
file sent, tell me if it's ok
Reply
#8
Thor shared the file with me, so I'll post it here, too.

.zip   sod_thor_hblank_demo_cfc2_intro.zip (Size: 38.47 KB / Downloads: 12)
Card Fighters' Clash 2 English Translation ( http://cfc2english.blogspot.com/ )
Neo Geo Pocket Flash Cart and Linker Project ( http://www.flashmasta.com/ )
Avatar art thanks to Trev-Mun ( http://trevmun.deviantart.com/ )
Reply
#9
Wonderful! Thank you, Flavor and sodthor. This is more than I could have hoped for.
Reply
#10
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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)