News:

Printed Amstrad Addict magazine announced, check it out here!

Main Menu

2 more new command-line utilities

Started by arnoldemu, 15:48, 11 December 12

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

arnoldemu

http://www.cpctech.org.uk/download/inject.zip

Usage:

inject -o <offset> -s <start> -i <inject file> <input> <output>

This will inject the file named by "<inject file>" into the file named by "<input>" at the offset defined. It doesn't insert the data, it overwrites the existing data at this location.

If -s is present, this is subtracted from <offset> first. Otherwise <offset> is used as it is.

example:

inject -o 0x1000 -s 0x500 -i music.bin game.bin game.bin

music.bin is injected into the file game.bin at offset 0x01000-0x0500. The result is saved to game.bin

another utility:

http://www.cpctech.org.uk/download/getlabel.zip

getlabel <label> <filename.noi>

this will read a noi file (written by sdcc for example) and look for the label named. It will then print it's value to standard output.
e.g.

getlabel _music game.noi

What use are these utilities?

Imagine you created a game, and you had some arkos musics in it. You don't care of their exact location in memory, but the akstobin file requires it.
So on the first run you use akstobin with any value, just so you can get the compiled data size. The game is then compiled, assembled and linked.
At the end you have your binary with the music "generated to the wrong place". i.e. it's pointers are not correct.
You then extract the appropiate labels from the "noi" file which can be generated by sdcc using "getlabel". You then use akstobin with the correct location of the music, and use the "inject" program to re-put it back into the binary file. now it's pointers are in the correct place.

both will need compiling for windows if you want to use them. I built them under linux.
My games. My Games
My website with coding examples: Unofficial Amstrad WWW Resource

Powered by SMFPacks Menu Editor Mod