Author Topic: Scanline timer or equivalent in PCE hardware  (Read 975 times)

touko

  • Hero Member
  • *****
  • Posts: 953
Re: Scanline timer or equivalent in PCE hardware
« Reply #15 on: April 13, 2012, 12:47:28 AM »
thanks, this is very useful, and why reinvent the wheel !!!

for your custom hsync lib, is not very important for me because i have now the skills for writing my own .
But surely it would have been interesting for people who want to understand how to do their,as i did with your first one .  :wink:
« Last Edit: April 13, 2012, 01:00:30 AM by touko »

Bonknuts

  • Hero Member
  • *****
  • Posts: 3292
Re: Scanline timer or equivalent in PCE hardware
« Reply #16 on: April 15, 2012, 06:36:06 PM »
I'd love to dig through your old HuC stuff, Bonknuts. It sounds like you wrote some really useful stuff.

HuC can do horizontal split-screen so easily, but I wish the screen could split into more than 4 segments... ie control individual scanlines--for making wavy raster effects


 Like this? http://www.pcedev.net/HuC/Chsync_ver_1_1/chsync_ver1_1.zip

 Like I mentioned before, you need ASM to support it. It's not JUST array (more specifically pointer) being slow, although it is, it's everything included and needed to modify 224 scanlines of data. That demo for HuC, 224 scanlines (doh! I clipped the display to 216 scanlines.. so I wasted some cpu cycles making scanline data that will never get used) are used for three effects: BG color #0, X, and Y regs. I didn't animate BG color #0, so it requires no maintenance in vblank. Only X and Y scroll reg arrays. And at that, I only did the LSB of the scroll regs (usually don't need more than that for wavy effects or line scrolls). The loop takes 11,200 cycles. Vblank (216 scanlines) is 20,000 cycles. So half of vblank is needed. Though if you double buffer or 'chase' the beam, you can update during active display without artifacts and give more time back to vblank sensitive code.

 Equivalent C code would be:
Code: [Select]
sin1_idx=old_idx1++;
sin2_idx=old_idx2++;
for(j=1;j<224;j++)
{  hs_x_l[j]=sin1[sin1_idx++]; hs_y_l[j]=sin1[sin2_idx++]+j; }
J is a char, although that won't matter much here if it was an int. It takes the above C code 217,729 cpu cycles to complete that loop! 11,200cycles VS 217,729cycles. Hell, a single 1/60 frame is only ~119,436cycles.

 Edit: Opps, sorry. I had the 'master' cycle count in there instead of cpu cycle count for C code. Fixed. Also fixed link.
« Last Edit: April 15, 2012, 09:41:36 PM by Bonknuts »

ooPo

  • Jr. Member
  • **
  • Posts: 62
Re: Scanline timer or equivalent in PCE hardware
« Reply #17 on: April 18, 2012, 04:39:03 AM »
Neutopia 2 does the wavy screen effect during the first minute of the game.
Racing games like Victory Run use the same kind of effect to draw the track.

You can set the RCR register to fire an interrupt on any scanline you like, as many times as you want.

Bonknuts

  • Hero Member
  • *****
  • Posts: 3292
Re: Scanline timer or equivalent in PCE hardware
« Reply #18 on: April 18, 2012, 02:13:20 PM »
Bomberman '93 does a vertical one for the underwater stages. I always thought those looked nice.

spenoza

  • Hero Member
  • *****
  • Posts: 2751
Re: Scanline timer or equivalent in PCE hardware
« Reply #19 on: April 18, 2012, 06:06:14 PM »
Doesn't Neutopia II do this for the underwater areas over the entire screen?
<a href="http://www.pcedaisakusen.net/2/34/103/show-collection.htm" class="bbc_link" target="_blank">My meager PC Engine Collection so far.</a><br><a href="https://www.pcenginefx.com/forums/" class="bbc_link" target="_blank">PC Engine Software Bible</a><br><a href="http://www.racketboy.com/forum/" c