The following warnings occurred:
Warning [2] Undefined property: MyLanguage::$archive_pages - Line: 2 - File: printthread.php(287) : eval()'d code PHP 8.1.34 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/printthread.php(287) : eval()'d code 2 errorHandler->error_callback
/printthread.php 287 eval
/printthread.php 117 printthread_multipage



Freeplaytech Forum
How to optimize C code for NGPC? - Printable Version

+- Freeplaytech Forum (https://forum.freeplaytech.com)
+-- Forum: Neo Geo Pocket (https://forum.freeplaytech.com/forumdisplay.php?fid=1)
+--- Forum: Software Development (https://forum.freeplaytech.com/forumdisplay.php?fid=4)
+--- Thread: How to optimize C code for NGPC? (/showthread.php?tid=5302)

Pages: 1 2


RE: How to optimize C code for NGPC? - sodthor - 02-15-2022

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/...

Code:
    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


RE: How to optimize C code for NGPC? - sodthor - 02-15-2022

tried on different emus and TREG0 values with udmadac code, and the hbl seems to run differently each time...


RE: How to optimize C code for NGPC? - winteriscoming - 02-15-2022

(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.


RE: How to optimize C code for NGPC? - winteriscoming - 02-16-2022

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.


RE: How to optimize C code for NGPC? - sodthor - 02-16-2022

Good news!
and maybe 9 will also fit with values 8/62/98...