<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-GB">
	<id>https://www.grandtheftwiki.com/ADF/history?feed=atom</id>
	<title>ADF - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://www.grandtheftwiki.com/ADF/history?feed=atom"/>
	<link rel="alternate" type="text/html" href="https://www.grandtheftwiki.com/ADF/history"/>
	<updated>2026-06-11T05:12:36Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.44.2</generator>
	<entry>
		<id>https://www.grandtheftwiki.com/index.php?title=ADF&amp;diff=417407&amp;oldid=prev</id>
		<title>Spaceeinstein: contributions from myself, Aschratt, NTAuthority, RedSabre, and Seemann</title>
		<link rel="alternate" type="text/html" href="https://www.grandtheftwiki.com/index.php?title=ADF&amp;diff=417407&amp;oldid=prev"/>
		<updated>2018-08-25T06:53:51Z</updated>

		<summary type="html">&lt;p&gt;contributions from myself, Aschratt, NTAuthority, RedSabre, and Seemann&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;The [[ADF]] file format is used for the [[Radio Stations in GTA Vice City|radio stations]] in [[Grand Theft Auto: Vice City]]. It is equal to a raw MP3 file with no ID3 tag (though a tag will likely be ignored) with a very simple encryption: every byte should be XOR-ed against the value 0x22.&lt;br /&gt;
&lt;br /&gt;
== Example ==&lt;br /&gt;
This is an example of performing a XOR operation on a byte within a file. The first byte in an ADF file is 0xDD. In binary, that would be 0b11011101. Perform a XOR on that against the value 0x22, which is 0b100010 in binary. If the digit in 0xDD corresponds to 0x22&amp;#039;s digit &amp;quot;1&amp;quot;, then switch the digit to its opposite. If the digit in 0xDD corresponds to 0x22&amp;#039;s digit &amp;quot;0&amp;quot;, then leave the digit alone. The result would be 0b11111111, which is 0xFF.&lt;br /&gt;
 0xDD 0b11011101&lt;br /&gt;
 0x22 0b00100010&lt;br /&gt;
      0b11111111 = 0xFF&lt;br /&gt;
&lt;br /&gt;
Another example, performing a XOR on 0x10 against 0x22:&lt;br /&gt;
 0x10 0b00010000&lt;br /&gt;
 0x22 0b00100010&lt;br /&gt;
      0b00110010 = 0x32&lt;br /&gt;
&lt;br /&gt;
When this is done to every byte within the ADF file, the file will result in a file that is listenable in standard audio players.&lt;br /&gt;
&lt;br /&gt;
Below is an example of a simple C++ program:&lt;br /&gt;
{{Pre|1=&lt;br /&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
#include &amp;lt;stdlib.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
int main(int argc, char *argv[])&lt;br /&gt;
{&lt;br /&gt;
	// check command-line arguments&lt;br /&gt;
	if (argc != 3)&lt;br /&gt;
	{&lt;br /&gt;
		printf(&amp;quot;Usage: adftool &amp;lt;inputFile&amp;gt; &amp;lt;outputFile&amp;gt;\n&amp;quot;);&lt;br /&gt;
		return 1;&lt;br /&gt;
	}&lt;br /&gt;
	&lt;br /&gt;
	// open input file&lt;br /&gt;
	FILE *inputFile = fopen(argv[1], &amp;quot;rb&amp;quot;);&lt;br /&gt;
	if (!inputFile)&lt;br /&gt;
	{&lt;br /&gt;
		printf(&amp;quot;Failed to open %s!\n&amp;quot;, argv[1]);&lt;br /&gt;
		return 1;&lt;br /&gt;
	}&lt;br /&gt;
	&lt;br /&gt;
	// open output file&lt;br /&gt;
	FILE *outputFile = fopen(argv[2], &amp;quot;wb&amp;quot;);&lt;br /&gt;
	if (!outputFile)&lt;br /&gt;
	{&lt;br /&gt;
		printf(&amp;quot;Failed to open %s!\n&amp;quot;, argv[2]);&lt;br /&gt;
		fclose(inputFile);&lt;br /&gt;
		return 1;&lt;br /&gt;
	}&lt;br /&gt;
	&lt;br /&gt;
	// allocate buffer (16 MB)&lt;br /&gt;
	const size_t bufferSize = 1024 * 1024 * 16;&lt;br /&gt;
	char *buffer = (char *)malloc(bufferSize);&lt;br /&gt;
	if (!buffer)&lt;br /&gt;
	{&lt;br /&gt;
		printf(&amp;quot;Failed to allocate buffer!\n&amp;quot;);&lt;br /&gt;
		fclose(inputFile);&lt;br /&gt;
		fclose(outputFile);&lt;br /&gt;
		return 1;&lt;br /&gt;
	}&lt;br /&gt;
	&lt;br /&gt;
	// read input file into buffer block by block&lt;br /&gt;
	size_t size;&lt;br /&gt;
	while ((size = fread(buffer, 1, bufferSize, inputFile)) &amp;gt; 0)&lt;br /&gt;
	{&lt;br /&gt;
		// xor buffer against 0x22&lt;br /&gt;
		char *iterator = buffer;&lt;br /&gt;
		for (size_t i = 0; i &amp;lt; size; i++)&lt;br /&gt;
		{&lt;br /&gt;
			*iterator++ ^= 0x22;&lt;br /&gt;
		}&lt;br /&gt;
		&lt;br /&gt;
		// write buffer to output file&lt;br /&gt;
		fwrite(buffer, 1, size, outputFile);&lt;br /&gt;
	}&lt;br /&gt;
	&lt;br /&gt;
	// deallocate buffer and close files&lt;br /&gt;
	free(buffer);&lt;br /&gt;
	fclose(inputFile);&lt;br /&gt;
	fclose(outputFile);&lt;br /&gt;
	&lt;br /&gt;
	return 0;&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== External links ==&lt;br /&gt;
* [[Wikipedia:MP3|MP3 format description at Wikipedia]]&lt;br /&gt;
* [[Wikipedia:Bitwise_operation#XOR|Bitwise exclusive OR at Wikipedia]]&lt;br /&gt;
* [http://www.gtaforums.com/index.php?showtopic=96504 Early topic on decoding ADF]&lt;br /&gt;
&lt;br /&gt;
{{VC-navi}}&lt;br /&gt;
[[Category:Audio Formats]]&lt;/div&gt;</summary>
		<author><name>Spaceeinstein</name></author>
	</entry>
</feed>