Page 1 of 1

Compiled TFM files are too big. How to reduce it?

Posted: Thu Oct 03, 2013 11:36 am
by Moon-Watcher
All .o files compiled from .tfm are about 33-36kB, no matter its original size. Isn't it too much? How can I reduce it?

Posted: Tue Oct 08, 2013 9:02 am
by Moon-Watcher
I shall answer myself.

I managed to shrink the rom from 768KB to 384KB ROM by using bin2h.exe (from Uwol source, thanks, Shiru!) instead of bintos.exe

Looks there's something weird in the SGDK / bintos.exe

Posted: Tue Oct 08, 2013 12:52 pm
by Stef
This is because of the 32 KBytes TFM alignment, i just realized that yesterday... I believe the Z80 TFM driver need the TFM music to be 32 KBytes aligned then a lot of space is wasted when you have severals TFM musics. I need to check this memory alignment is really needed or not !

Posted: Wed Oct 09, 2013 8:41 am
by Moon-Watcher
Did some tests.

I compiled an old SGDK project without the align parameter and it generated a smaller rom. Haven't tested much.

I compiled my current project using the Uwol method. Of course it generated a smaller rom too but some tracks sounds really bad.

Posted: Wed Oct 09, 2013 9:48 am
by Stef
You just need to modify the makefile.gen file :
Replace

Code: Select all

%.s: %.tfc
    $(BINTOS) -align 32768 $<
with

Code: Select all

%.s: %.tfc
    $(BINTOS) $<
and it should reduce dramatically the size of your rom, but it may broke the TFM driver.
Do you use the 68k driver or the Z80 one ?

Posted: Wed Oct 09, 2013 10:15 am
by Moon-Watcher
Stef wrote:You just need to modify the makefile.gen file :
Replace

Code: Select all

%.s: %.tfc
    $(BINTOS) -align 32768 $<
with

Code: Select all

%.s: %.tfc
    $(BINTOS) $<
and it should reduce dramatically the size of your rom, but it may broke the TFM driver.
Yep, it broke the driver.
Stef wrote:Do you use the 68k driver or the Z80 one ?
I dunno :oops: Just use SND_startPlay_TFM()

Posted: Wed Oct 09, 2013 4:02 pm
by Stef
Yep, this is the Z80 driver... i probably removed the 68k one.
Too bad about the needed 32Kb alignment, so much space wasted :-/ I don't know if the driver source is available somewhere, it should be possible to remove this limitation.

Posted: Thu Oct 10, 2013 9:27 am
by Moon-Watcher

Code: Select all

void TFC_init(const u8*);
void TFC_frame(void);
void TFC_play(u16);
Good point. I'll try to avoid this problem using the 68K driver
Stef wrote:I don't know if the driver source is available somewhere
Isn't it z80_tfm.s80 file?

Posted: Fri Oct 11, 2013 8:32 am
by Moon-Watcher
Checked. Haven't found any strange issue using 68K driver without align parameter.

Posted: Fri Oct 11, 2013 12:02 pm
by Stef
Oh so the 68K driver is still there, indeed there is no any reason that the 68000 driver need the 32k alignment unlike the Z80 which access 68000 bus in 32k bank ;) I forgot the TFM Z80 source was available, i will to dig in it and modify it for that purpose !

Posted: Fri Oct 11, 2013 12:50 pm
by Moon-Watcher
Thanks, really glad to hear that

Posted: Fri Oct 11, 2013 1:01 pm
by Stef
Still as always i say that but don't expect it really soon :-/
I have many things to do aside that but that is definitely something i want to improve (i will add an issue for that so i won't forget) ;)

Posted: Wed Oct 16, 2013 9:16 am
by Moon-Watcher