<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>https://gbdev.gg8.se/wiki/index.php?action=history&amp;feed=atom&amp;title=Watermarking</id>
		<title>Watermarking - Revision history</title>
		<link rel="self" type="application/atom+xml" href="https://gbdev.gg8.se/wiki/index.php?action=history&amp;feed=atom&amp;title=Watermarking"/>
		<link rel="alternate" type="text/html" href="https://gbdev.gg8.se/wiki/index.php?title=Watermarking&amp;action=history"/>
		<updated>2026-05-01T12:11:51Z</updated>
		<subtitle>Revision history for this page on the wiki</subtitle>
		<generator>MediaWiki 1.25.1</generator>

	<entry>
		<id>https://gbdev.gg8.se/wiki/index.php?title=Watermarking&amp;diff=800&amp;oldid=prev</id>
		<title>PinoBatch: remove remaining NESisms, reported by NieDzejkob</title>
		<link rel="alternate" type="text/html" href="https://gbdev.gg8.se/wiki/index.php?title=Watermarking&amp;diff=800&amp;oldid=prev"/>
				<updated>2018-09-02T15:31:33Z</updated>
		
		<summary type="html">&lt;p&gt;remove remaining NESisms, reported by NieDzejkob&lt;/p&gt;
&lt;table class='diff diff-contentalign-left'&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;tr style='vertical-align: top;'&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Revision as of 15:31, 2 September 2018&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;L36&quot; &gt;Line 36:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 36:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;A code preprocessor can introduce any of several NOP instructions at random points in a non-time-critical subroutine, such as &amp;lt;code&amp;gt;ld c,c&amp;lt;/code&amp;gt;.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;A code preprocessor can introduce any of several NOP instructions at random points in a non-time-critical subroutine, such as &amp;lt;code&amp;gt;ld c,c&amp;lt;/code&amp;gt;.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;One may also add official do-(near)-nothing instructions such as &amp;lt;code&amp;gt;xor 0&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;or 0&amp;lt;/code&amp;gt; &amp;lt;code&amp;gt;cp a&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;and a&amp;lt;/code&amp;gt;, or a pair of &amp;lt;code&amp;gt;dec e&amp;lt;/code&amp;gt; then &amp;lt;code&amp;gt;inc e&amp;lt;/code&amp;gt;.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;One may also add official do-(near)-nothing instructions such as &amp;lt;code&amp;gt;xor 0&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;or 0&amp;lt;/code&amp;gt; &amp;lt;code&amp;gt;cp a&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;and a&amp;lt;/code&amp;gt;, or a pair of &amp;lt;code&amp;gt;dec e&amp;lt;/code&amp;gt; then &amp;lt;code&amp;gt;inc e&amp;lt;/code&amp;gt;.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Another watermarking padding stratagem would be, before a &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;load &lt;/del&gt;instruction for a register &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;(LDA, LDX, LDY, PLA, TAX, TAY, TSX, TXA, or TYA)&lt;/del&gt;, to introduce instructions affecting that register; the load makes irrelevant all changes to the register's contents. One should, of course, take care to ensure that such new instructions do not have undesired flag changes altering execution flow.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Another watermarking padding stratagem would be, before a &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;code&amp;gt;ld&amp;lt;/code&amp;gt; &lt;/ins&gt;instruction for a register, to introduce instructions affecting that register; the load makes irrelevant all changes to the register's contents. One should, of course, take care to ensure that such new instructions do not have undesired flag changes altering execution flow.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;The addresses of MBCs' writable ports are incompletely decoded because the MBC ignores low address bits.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;The addresses of MBCs' writable ports are incompletely decoded because the MBC ignores low address bits.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;L42&quot; &gt;Line 42:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 42:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;A code preprocessor could randomize these address bits in any instruction that reads or writes MBC ports. &amp;#160;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;A code preprocessor could randomize these address bits in any instruction that reads or writes MBC ports. &amp;#160;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;This would also serve to hinder a cracker's use of an in-emulator debugger that doesn't take mirroring into account.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;This would also serve to hinder a cracker's use of an in-emulator debugger that doesn't take mirroring into account.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;Most of WRAM also appears twice in address space: once at the canonical address ($C000-$DDFF) and once in &amp;quot;echo RAM&amp;quot; ($E000-$FDFF).&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;Though games officially weren't supposed to use echo RAM, nothing ever changed in GB hardware to make it unusable.&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;Thus randomizing addresses loaded into HL and DE between normal RAM and echo RAM could add one bit of entropy per access, though you have to be careful of the last 512 bytes of RAM that do not have an echo RAM counterpart.&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;== Graphics changes ==&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;== Graphics changes ==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Graphics can depend on the build:&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Graphics can depend on the build:&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;*Choose one of several alternatives for [http://www.petesqbsite.com/sections/tutorials/tuts/tsugumo/chapter1.htm grass] and other [http://www.petesqbsite.com/sections/tutorials/tuts/tsugumo/chapter3.htm noisy tiles]&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;*Choose one of several alternatives for [http://www.petesqbsite.com/sections/tutorials/tuts/tsugumo/chapter1.htm grass] and other [http://www.petesqbsite.com/sections/tutorials/tuts/tsugumo/chapter3.htm noisy tiles]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;*Rearrange the order in which sets of tiles appear in the &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;CHR &lt;/del&gt;ROM&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;*Rearrange the order in which sets of tiles appear in the ROM&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;, even within a bank&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;*Tester's name or something derived from tester's name on the title screen. This is easy to remove, but it acts as a deterrent.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;*Tester's name or something derived from tester's name on the title screen. This is easy to remove, but it acts as a deterrent &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;and evidence of intent&lt;/ins&gt;.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;*Tester's name or something derived from tester's name on a sign in a building in the game&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;*Tester's name or something derived from tester's name on a sign in a building in the game&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>PinoBatch</name></author>	</entry>

	<entry>
		<id>https://gbdev.gg8.se/wiki/index.php?title=Watermarking&amp;diff=799&amp;oldid=prev</id>
		<title>PinoBatch: Adapted from own work at https://wiki.nesdev.com/w/index.php/Watermarking</title>
		<link rel="alternate" type="text/html" href="https://gbdev.gg8.se/wiki/index.php?title=Watermarking&amp;diff=799&amp;oldid=prev"/>
				<updated>2018-09-02T04:50:23Z</updated>
		
		<summary type="html">&lt;p&gt;Adapted from own work at https://wiki.nesdev.com/w/index.php/Watermarking&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;'''Watermarking''' is [[wikipedia:Digital watermarking|defined by Wikipedia]] as &amp;quot;the process of embedding information into a digital signal in a way that is difficult to remove.&amp;quot;&lt;br /&gt;
In some cases, the developer of an unreleased Game Boy program wants to distribute copies to beta testers but still [[wikipedia:Traitor tracing|trace]] any [[wikipedia:Internet leak|leaked]] copies of the program to the tester who broke the non-disclosure agreement.&lt;br /&gt;
There are several ways to produce binaries that can be traced back to a particular recipient.&lt;br /&gt;
&lt;br /&gt;
== Shuffling ==&lt;br /&gt;
One way to make each copy unique is to shuffle, or randomly rearrange, pieces of a program at compile time.&lt;br /&gt;
&lt;br /&gt;
A code preprocessor can randomize the order of statically allocated variables in a program.&lt;br /&gt;
This causes the addresses embedded in the code to change every time the program is compiled.&lt;br /&gt;
It has benefits beyond watermarking: as the program is shuffled, a randomly chosen variable acts as a [[wikipedia:Buffer overflow protection|canary]] for the variable before it, and the effects of a [[wikipedia:buffer overflow|buffer overflow]] may become more apparent.&lt;br /&gt;
&lt;br /&gt;
A code preprocessor can shuffle the order of subroutines or lookup tables in a program.&lt;br /&gt;
Watch out: A common technique on the GB is the &amp;quot;[[wikipedia:Inline expansion|inline]] [[wikipedia:tail call|tail call]]&amp;quot;, in which a subroutine doesn't return but instead falls off the end into the following subroutine.&lt;br /&gt;
You'll need to take this into account when adding markup to control the preprocessor.&lt;br /&gt;
&lt;br /&gt;
A code preprocessor can shuffle the order of instructions in a subroutine.&lt;br /&gt;
In a lot of cases, the order of instructions doesn't matter, such as &amp;lt;code&amp;gt;LD&amp;lt;/code&amp;gt; instructions to copy the top and bottom halves of a 16-bit value between registers.&lt;br /&gt;
Writes to some [[Video Display|PPU registers]] act similarly: when setting up SCX, SCY, WX, and WY, it doesn't matter which is written first.&lt;br /&gt;
The markup for such &amp;quot;bundles of instructions&amp;quot; resembles the markup for stop bits in [[wikipedia:explicitly parallel instruction computing|explicitly parallel instruction computing]].&lt;br /&gt;
Adding the required markup also has a benefit beyond watermarking: thinking about what instructions affect others forces a code review, which allows a programmer to refamiliarize himself with a code base and possibly discover defects.&lt;br /&gt;
&lt;br /&gt;
If your game uses an [[MBC1]] or [[MBC5]], you can shuffle the order in which banks appear in the ROM. For example, one copy might put a particular level's tile data in bank 3 and another in bank 5.&lt;br /&gt;
If you shuffle the data in banks 1 through 7, you can make 7! = 5040 different binaries from this alone.&lt;br /&gt;
&lt;br /&gt;
Even in a game with no MBC, shuffling alone allows for more distinct binaries than the number of atoms in the known universe squared.&lt;br /&gt;
With the size of GB games and with modern solid archiving tools such as 7-Zip, you can save each binary that you send out to each tester and still not fill a 4 GB USB flash drive.&lt;br /&gt;
As long as the binary doesn't get leaked to someone with the knowledge to disassemble and reassemble a binary (as in pret's ''Pokémon'' disassemblies), computing the [[wikipedia:Hamming distance|Hamming distance]] between the leaked copy and your saved copies is likely to result in a high-confidence match to the leaker.&lt;br /&gt;
&lt;br /&gt;
== Instruction encoding ==&lt;br /&gt;
A few instructions have multiple encodings that differ only in aspects that are not important in a particular case.&lt;br /&gt;
* &amp;lt;code&amp;gt;add imm&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sub imm&amp;lt;/code&amp;gt; differ in the carry&lt;br /&gt;
* &amp;lt;code&amp;gt;rla&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;adc a&amp;lt;/code&amp;gt; differ in zero&lt;br /&gt;
* &amp;lt;code&amp;gt;xor a&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sub a&amp;lt;/code&amp;gt; are nigh identical&lt;br /&gt;
* &amp;lt;code&amp;gt;or a&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;and a&amp;lt;/code&amp;gt; are nigh identical&lt;br /&gt;
&lt;br /&gt;
A code preprocessor can introduce any of several NOP instructions at random points in a non-time-critical subroutine, such as &amp;lt;code&amp;gt;ld c,c&amp;lt;/code&amp;gt;.&lt;br /&gt;
One may also add official do-(near)-nothing instructions such as &amp;lt;code&amp;gt;xor 0&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;or 0&amp;lt;/code&amp;gt; &amp;lt;code&amp;gt;cp a&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;and a&amp;lt;/code&amp;gt;, or a pair of &amp;lt;code&amp;gt;dec e&amp;lt;/code&amp;gt; then &amp;lt;code&amp;gt;inc e&amp;lt;/code&amp;gt;.&lt;br /&gt;
Another watermarking padding stratagem would be, before a load instruction for a register (LDA, LDX, LDY, PLA, TAX, TAY, TSX, TXA, or TYA), to introduce instructions affecting that register; the load makes irrelevant all changes to the register's contents. One should, of course, take care to ensure that such new instructions do not have undesired flag changes altering execution flow.&lt;br /&gt;
&lt;br /&gt;
The addresses of MBCs' writable ports are incompletely decoded because the MBC ignores low address bits.&lt;br /&gt;
Each MBC1 port, for example, appears 8192 times.&lt;br /&gt;
A code preprocessor could randomize these address bits in any instruction that reads or writes MBC ports. &lt;br /&gt;
This would also serve to hinder a cracker's use of an in-emulator debugger that doesn't take mirroring into account.&lt;br /&gt;
&lt;br /&gt;
== Graphics changes ==&lt;br /&gt;
Graphics can depend on the build:&lt;br /&gt;
*Choose one of several alternatives for [http://www.petesqbsite.com/sections/tutorials/tuts/tsugumo/chapter1.htm grass] and other [http://www.petesqbsite.com/sections/tutorials/tuts/tsugumo/chapter3.htm noisy tiles]&lt;br /&gt;
*Rearrange the order in which sets of tiles appear in the CHR ROM&lt;br /&gt;
*Tester's name or something derived from tester's name on the title screen. This is easy to remove, but it acts as a deterrent.&lt;br /&gt;
*Tester's name or something derived from tester's name on a sign in a building in the game&lt;br /&gt;
&lt;br /&gt;
== Compression ==&lt;br /&gt;
If your program includes compressed data, you can change the interpretation of bits in the data format.&lt;br /&gt;
For example, in RLE tile compression, the sense of bits denoting a run of repeated pixels vs. bits denoting a run of several literal pixels can be inverted.&lt;br /&gt;
&lt;br /&gt;
== External links ==&lt;br /&gt;
*[https://wiki.nesdev.com/w/index.php/Watermarking Watermarking on NESdev Wiki]&lt;br /&gt;
*[https://github.com/pinobatch/croom-nes/blob/master/tools/shuffle.py shuffle.py]: a code preprocessor that shuffles lines of code&lt;/div&gt;</summary>
		<author><name>PinoBatch</name></author>	</entry>

	</feed>