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

SGDK only sub forum

Moderator: Stef

Post Reply
Moon-Watcher
Very interested
Posts: 117
Joined: Sun Jan 02, 2011 9:14 pm
Contact:

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

Post by Moon-Watcher » Thu Oct 03, 2013 11:36 am

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?

Moon-Watcher
Very interested
Posts: 117
Joined: Sun Jan 02, 2011 9:14 pm
Contact:

Post by Moon-Watcher » Tue Oct 08, 2013 9:02 am

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

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

Post by Stef » Tue Oct 08, 2013 12:52 pm

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 !

Moon-Watcher
Very interested
Posts: 117
Joined: Sun Jan 02, 2011 9:14 pm
Contact:

Post by Moon-Watcher » Wed Oct 09, 2013 8:41 am

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.

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

Post by Stef » Wed Oct 09, 2013 9:48 am

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 ?

Moon-Watcher
Very interested
Posts: 117
Joined: Sun Jan 02, 2011 9:14 pm
Contact:

Post by Moon-Watcher » Wed Oct 09, 2013 10:15 am

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

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

Post by Stef » Wed Oct 09, 2013 4:02 pm

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.

Moon-Watcher
Very interested
Posts: 117
Joined: Sun Jan 02, 2011 9:14 pm
Contact:

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

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?

Moon-Watcher
Very interested
Posts: 117
Joined: Sun Jan 02, 2011 9:14 pm
Contact:

Post by Moon-Watcher » Fri Oct 11, 2013 8:32 am

Checked. Haven't found any strange issue using 68K driver without align parameter.

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

Post by Stef » Fri Oct 11, 2013 12:02 pm

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 !

Moon-Watcher
Very interested
Posts: 117
Joined: Sun Jan 02, 2011 9:14 pm
Contact:

Post by Moon-Watcher » Fri Oct 11, 2013 12:50 pm

Thanks, really glad to hear that

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

Post by Stef » Fri Oct 11, 2013 1:01 pm

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) ;)

Moon-Watcher
Very interested
Posts: 117
Joined: Sun Jan 02, 2011 9:14 pm
Contact:

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


Post Reply