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 »

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 »

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 »

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 »

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 »

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 »

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 »

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 »

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 »

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 »

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 »

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 »

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 »

Post Reply