Recycle instrument data to keep transplant size down to about half

Zahlman’s Song editor is very useful, but there is a problem with the instrument size to be transplanted.
This tool consumes all the instruments used for each song, so it consumes a lot of size.

I added a new function to reduce the transplant size by using the musical instrument data I already have.
this improvement, the size required for transplantation is reduced to about half.

If sample data of instrument data existed in ROM, I decided(recycle) to use it.

Example.
Convert song fe8 to fe7.

> open fe8
Loaded ROM from disk.

> rip 2
Ripped 8 of 8 tracks.
Song successfully ripped.

> open fe7
Loaded ROM from disk.

> burn 1
track:0 128
track:1 0
recycle 0x18d0 len 16524 → 0x73cd20
track:2 0
track:3 0
track:4 0
recycle 0x512c len 19580 → 0x749ab0
track:5 0
recycle 0x513c len 3696 → 0x805ffc
track:6 0
recycle 0x514c len 33124 → 0x6f8a14
track:7 0
track:8 0
recycle 0x9518 len 20036 → 0x700b88
track:9 0
recycle 0x9528 len 32612 → 0x6ec814
track:10 0
track:11 0
track:12 0
track:13 0
track:14 8
track:15 0
track:16 8
track:17 8
track:18 8
total recycle size: 125572
append data: 160520
Burning successful.

> close fe7
Saved ROM to disk.

In this example, we were able to recycle data of instrument data of tracks 1, 4, 5, 6, 8, 9.

By using the instrument data, I recycled 125572 bytes.
If I did not recycle, I used 160520 bytes + 125572 bytes = 286092 bytes.
About 44% can be saved by using recycle.

Example 2.
Contrary to the previous time, we will bring fe7 song to fe8.

> open fe7
Loaded ROM from disk.

> rip 2
Ripped 7 of 7 tracks.
Song successfully ripped.

> open fe8
Loaded ROM from disk.

> burn 1
track:0 128
track:1 0
recycle 0x1194 len 31620 → 0x24926c
track:2 0
recycle 0x11a4 len 1764 → 0x217638
track:3 8
track:4 8
track:5 8
track:6 0
track:7 1
track:8 8
track:9 1
track:10 1
track:11 8
track:12 8
track:13 0
track:14 0
track:15 0
recycle 0x157c0 len 12616 → 0x223300
track:16 0
track:17 0
recycle 0x19b8c len 9896 → 0x26b880
track:18 0
total recycle size: 55896
append data: 114764
Burning successful.

> close fe8
Saved ROM to disk.

In this example, we were able to recycle data of instrument data of tracks 1,2,15,17.

By using the instrument data, I recycled 55896 bytes.
If I did not recycle, I used 114764 bytes + 55896 bytes = 170660 bytes.
About 33% can be saved by using recycle.

Problems
However, there are some problems.

It takes a long time to search for data already in ROM.
(I do not understand how to search fast Array in python.)

Also, since we are simply comparing binary, the possibility of mistaken hit besides musical instruments is not zero.
In the future, you should try to explore only instruments.

Download
The modified source code is here.
You can download it by clicking the “ダウンロード” button.

There is also a routine for porting songs from different games that you created earlier.
You can port almost all songs of GBA.

Backup
Before using the tool, be sure to back up the ROM before using it!

6 Likes

Nice! I don’t think this is used very much anymore but still useful to have, and one of the big reasons I didn’t like using ZSE.