#23184 - Vince - Tue Jul 06, 2004 7:38 pm
Hiya to you all,
Since I am not so experienced in GBA devel, I post here despite the fact that my request does not directly address GBA programming but managing ROMS instead.
I want to write utilities to be able to manage ROMs under Linux/free OSes. One of them is a ROM trimmer. I use Perl as a language.
Basically, what I wanted to do is the following :
1. Use the seek() function to go to the end of the ROM file.
2. Iterate on bytes reading backwards with read() as long as the byte read is a 00 or an FF. Stop when different. I would get a certain location (let's name it $offset) from the end of the ROM
3. Now go to the beginning of the ROM
4. Copy ROM contents from start to (size-$offset) into new file : ROM_trimmed.gba
However, I have problems with read() which, along reading a byte, advances the "seek cursor" position by one byte. Instead of having to, before doing a new read, going backwards two bytes, I wanted to know if there is a possibility to read backwards in an easier manner.
Thank you for your attention, I hope I was clear enough
Vince
Since I am not so experienced in GBA devel, I post here despite the fact that my request does not directly address GBA programming but managing ROMS instead.
I want to write utilities to be able to manage ROMs under Linux/free OSes. One of them is a ROM trimmer. I use Perl as a language.
Basically, what I wanted to do is the following :
1. Use the seek() function to go to the end of the ROM file.
2. Iterate on bytes reading backwards with read() as long as the byte read is a 00 or an FF. Stop when different. I would get a certain location (let's name it $offset) from the end of the ROM
3. Now go to the beginning of the ROM
4. Copy ROM contents from start to (size-$offset) into new file : ROM_trimmed.gba
However, I have problems with read() which, along reading a byte, advances the "seek cursor" position by one byte. Instead of having to, before doing a new read, going backwards two bytes, I wanted to know if there is a possibility to read backwards in an easier manner.
Thank you for your attention, I hope I was clear enough
Vince