Light init?

SGDK only sub forum

Moderator: Stef

Post Reply
mikejmoffitt
Very interested
Posts: 86
Joined: Fri Sep 25, 2015 4:16 pm

Light init?

Post by mikejmoffitt » Mon Oct 05, 2015 8:55 pm

I like using SGDK for ease of some hardware functions but there is a lot going on I'd like the ability to disable. Is there an easy way to disable the following without modifying SGDK?

-Transfer of font into VRAM; subsequent linking of font into ROM (little bit of space saving)
-Ext, V, or H interrupt code which runs before or after my routine (I want JUST mine for timing reasons)
-Sprite cache init / memory allocation (I wrote my own already which has DMA and don't need this taking up memory)

Stef
Very interested
Posts: 3072
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Re: Light init?

Post by Stef » Tue Oct 06, 2015 9:09 am

mikejmoffitt wrote:I like using SGDK for ease of some hardware functions but there is a lot going on I'd like the ability to disable. Is there an easy way to disable the following without modifying SGDK?

-Transfer of font into VRAM; subsequent linking of font into ROM (little bit of space saving)
-Ext, V, or H interrupt code which runs before or after my routine (I want JUST mine for timing reasons)
-Sprite cache init / memory allocation (I wrote my own already which has DMA and don't need this taking up memory)
Currently there is no support for that kind of "light init" but that should be "doable" to some extends...
For the font, no problem... i can easily disable it (i will add a define for that), you can do it in the library source by yourself in the meantime.
For the V/H interrupt code that might be a bit more complex as some internals methods rely on it (vint is used to maintain an internal counter, also i need to know when i'm in a interrupt callback to avoid possible dead lock...). The next SGDK version will add a new handler for vint so your callback can be called almost right at the beginning of the vint and you can exploit it almost at maximum (very minor overhead).
For the Hint, here you really need to bypass the SGDK default callback to preserve your cycles, it's why when you are using the default SGDK makefile you always have the sega.s and romhead.c files included in your project. You can customize the boot process and modify interrupt code as you want.
Sprite cache is not initialized by default as far i remember :)

mikejmoffitt
Very interested
Posts: 86
Joined: Fri Sep 25, 2015 4:16 pm

Re: Light init?

Post by mikejmoffitt » Tue Oct 06, 2015 11:03 pm

I see; I'll look into modifying it myself then.

As for internal functions which rely on it, I'm really only using SGDK for these things:

-Init the VDP
-Set up some VDP registers for configuration (Plane / sprite table locations, display width/height, etc)
-Perform a DMA

Everything else I am doing manually - tilemap placement, palettes, animations, etc - so if those do not rely on the v/h int functions then reassigning them to my own would work best for me. Maybe I'll play with forcing that on my own.

Stef
Very interested
Posts: 3072
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Re: Light init?

Post by Stef » Wed Oct 07, 2015 8:15 am

Then you can probably hook the vint / hint directly to your methods but honestly the vint overhead should not be too high anyway by default. Only the hint can be a problem as we use it almost for raster effect which require very tight timings.
Note that next SGDK version will have DMA queue support (already available in the github repository), i guess you want to use it instead of the classic DMA methods.

mikejmoffitt
Very interested
Posts: 86
Joined: Fri Sep 25, 2015 4:16 pm

Re: Light init?

Post by mikejmoffitt » Wed Oct 07, 2015 4:20 pm

Stef wrote:Then you can probably hook the vint / hint directly to your methods but honestly the vint overhead should not be too high anyway by default. Only the hint can be a problem as we use it almost for raster effect which require very tight timings.
Note that next SGDK version will have DMA queue support (already available in the github repository), i guess you want to use it instead of the classic DMA methods.
Well coincidentally I've wanted to use Hint for raster effects of my own :P

As for the DMA queue, that is good to know. I have implemented my own queueing system so I just use the DMA functions to proceed to empty my queue at the start of Vint. If that is a built-in feature that sounds great, though I would want the ability to enable and disable an automatic queue flush.

I noticed Vint is a little bit late. I was able to steal a little bit of extra vblank time by triggering Hint at the last visible line, and allowing my end-of-frame processing to begin immediately.

Stef
Very interested
Posts: 3072
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Re: Light init?

Post by Stef » Wed Oct 07, 2015 4:48 pm

mikejmoffitt wrote: Well coincidentally I've wanted to use Hint for raster effects of my own :P
Well not really surprised, that is actually a very good reason to light up SGDK ;)
As for the DMA queue, that is good to know. I have implemented my own queueing system so I just use the DMA functions to proceed to empty my queue at the start of Vint. If that is a built-in feature that sounds great, though I would want the ability to enable and disable an automatic queue flush.
The way the DMA queue is implemented in SGDK make it quite fast (the queue is flushed with minimal overhead between DMA call).
You can see the DMA queue methods here :
https://github.com/Stephane-D/SGDK/blob ... /inc/dma.h

Note that automatic / manual flushing is a feature already implemented :

Code: Select all

DMA_setAutoFlush(u16 value);
I noticed Vint is a little bit late. I was able to steal a little bit of extra vblank time by triggering Hint at the last visible line, and allowing my end-of-frame processing to begin immediately.
True, you usually receive vint not exactly at beginning of VBlank period and SGDK callback make it even worse, again the next version add a new callback arriving sooner and probably enough for many cases ;)

Post Reply