Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to optimize C code for NGPC?
Quote:In attempting to change TREG0 to some other interval, I discovered I need it set to 1 for udmadac, which uses timer 0 and timer 2.

You have to set it to 4 only for the hblank interrupt of course, not for others (or did I misunderstand? maybe it's not treg0 in your code)

And sometimes, changing the condition order can help if it reduces the number of tests/memory load/...

    else if(y==60) {if (screenSplit)  SCR2_X=split1; }
    else if(y==100) { if (screenSplit)  SCR2_X=split2; }

here, screenSplit value is only tested for y = 60 and 100 (y is already loaded from mem), in your previous code it's always loaded and tested
tried on different emus and TREG0 values with udmadac code, and the hbl seems to run differently each time...
(02-15-2022, 04:17 AM)sodthor Wrote: tried on different emus and TREG0 values with udmadac code, and the hbl seems to run differently each time...

I will experiment. The udmadac code I have does some of its own initialization, which I had running after hbl setup, and it was overwriting TREG0 to 1. I was thinking it requires 1 because of that, but I can try without. I was worried it would affect playback speed, but might be wrong.

For the record, I can get different hblank behavior by changing TREG0.
I succeeded in getting my game to run too fast on real hardware, which is great!  Big Grin  I can always make it run slower.

I kept playing around with TREG0 intervals of 2, 4 and 8 and mostly ended up with broken behavior in my hbl.

The main event I needed to have happen was when RAS_Y is 8.  Some very important stuff happens then because vbl is responsible for displaying the row of HUD tiles by moving scroll plane 1 down and moving the sprite offset down.  At RAS_Y==8, scroll plane 1 and sprite offset go back to what they should be.  As far as I was seeing, it was never getting to RAS_Y==8.

Well, I attempted an interval value of 3 and my HUD started behaving again, so it then occurred to me that RAS_Y starts at 0 and I was off by 1, so when it got through 3 intervals, it was at RAS_Y==8.

So I set the TREG0 interval to 9 and have events at RAS_Y of 8, 62 and 98.

udmadac does not seem to be negatively affected by the change to TREG0, at least I don't think it has been. Sounds still play at what sounds like a normal speed to me.
Good news!
and maybe 9 will also fit with values 8/62/98...

Forum Jump:

Users browsing this thread: 1 Guest(s)