1<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2<html xml:lang="en-US" lang="en-US" xmlns="http://www.w3.org/1999/xhtml">
3<head>
4<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5<meta http-equiv="Content-Style-Type" content="text/css" />
6<title>ctr_GxCommandAnalyzer</title>
7<style type="text/css">
8<!--
9body {
10/*
11    font-size       : 10pt;
12*/
13    font-weight     : normal;
14    color           : #000000;
15    margin          : 8px;
16}
17
18div {
19    width           : 98%;
20    white-space     : nowrap;
21}
22
23div.title {
24    text-align      : left;
25    font-weight     : bold;
26/*
27    font-size       : 16pt;
28*/
29    font-size       : 150%;
30    color           : #202020;
31    border-style    : double;
32    border-width    : 8px;
33    /* タイトルを囲む枠線の色を指定 */
34    border-color    : #CD202C;
35
36    /* RVLプラットフォーム系列 */
37/*
38    border-color    : #34beed;
39*/
40
41    /* TWLプラットフォーム系列 */
42/*
43    border-color    : #ff458f;
44*/
45
46    margin          : 4px;
47    padding         : 4px;
48}
49H1 {
50  font-size		: 150%;
51  font-family		: Arial;
52  border-bottom-width	: 5px;
53  border-bottom-style	: solid;
54  border-bottom-color	: #CD202C;
55  padding-bottom		: 1px;
56  margin-bottom		: 20px;
57  letter-spacing		: normal;
58  font-weight		: bold;
59}
60
61h2 {
62    font-weight     : bold;
63/*
64    font-size       : 16pt;
65*/
66    font-size       : 150%;
67    border-style    : none none solid double;
68    border-width    : 0px 0px 2px 8px;
69    /* 見出しの線の色を指定 */
70    border-color    : #CD202C;
71
72    /* RVLプラットフォーム系列 */
73/*
74    border-color    : #34beed;
75*/
76
77    /* TWLプラットフォーム系列 */
78/*
79    border-color    : #ff458f;
80*/
81
82    margin-left     : 2px;
83    padding-left    : 4px;
84}
85CODE {
86  font-family		: "Courier New", monospace;
87  position		: normal;
88  left			: 12px;
89  font-size		: 10pt;
90}
91table {
92  margin-top        : 2pt;
93  margin-bottom     : 2pt;
94  margin-left       : 0pt;
95  margin-right      : 0pt;
96  padding-left      : 0pt;
97  padding-right     : 0pt;
98  position          : relative;
99  left              : 12px;
100  font-family       : Arial;
101  font-size         : 10pt;
102  border-style      : none none none none;
103}
104td,th {
105  padding           : 2pt;
106  border-width      : 2pt;
107  border-style      : none none none none;
108  font-style        : normal;
109  text-align        : left;
110}
111td {
112  background        : #e8f4f4;
113  font-weight       : normal;
114}
115th {
116  background        : #c0d8d8;
117  font-weight       : bold;
118}
119
120p {
121    margin-left     : 4px;
122}
123p.code {
124  font-family		: "Courier New", monospace;
125  position		: normal;
126  left			: 12px;
127  font-size		: 10pt;
128  background            : #e8f4f4;
129}
130
131PRE
132{
133    padding             : 10px;
134
135    background          : #f0f0f0;
136    border              : 1px solid #ccc;
137}
138
139CODE
140{
141/*    padding             : 0;
142    display             : block;*/
143
144/* SampleDemos Only */
145
146    display          : block;
147
148    border           : solid gray 1px;
149    padding          : 2px;
150    background-color : #f0f0f0;
151}
152
153-->
154</style>
155</head>
156  <body>
157    <h1><CODE>ctr_GxCommandAnalyzer</CODE></h1>
158    <h2>Description</h2>
159      <p>
160The <CODE>ctr_GxCommandAnalyzer</CODE> command line tool is for parsing 3D commands output from the debugger and elsewhere, and converting them into a format that is easier to view.<br>You can also use this as a GUI tool by double-clicking to open the executable file.<br /><B>Note</B>: If you directly drag-and-drop to the binary icon, the tool operates as the command line version.
161      </p>
162
163<h2>How to Use (command line version)</h2>
164<h3>Format</h3>
165    <pre> $ ctr_GxCommandAnalyzer32.exe [options...] [CommandFile]</pre>
166    <h3>Options</h3>
167    <div class="section">
168      <p>
169        <table class="table"><tbody>
170          <tr><th>Options</th> <th>Description</th></tr>
171          <tr>
172<td><CODE>-h</CODE></td>
173<td>Displays help.</td>
174          </tr>
175          <tr>
176<td><CODE>-nd</CODE></td>
177<td>Converts a physical address to a virtual address, and halts functionality that performs additional output.</td>
178          </tr>
179          <tr>
180<td><CODE>-ni</CODE></td>
181<td>Halts functionality that outputs an overview of the registers.</td>
182          </tr>
183          <tr>
184<td><CODE>-sb</CODE></td>
185<td>Displays data that was output in burst mode in simple format.</td>
186          </tr>
187        </tbody></table>
188      </p>
189
190      <p>
191After parsing, a file is saved in the format [file name]_Analyze.txt in the location of the file that was used for input.
192      </p>
193    </div>
194
195<h2>How to Use (GUI version)</h2>
196    <p>
197Open data from the <B>File</B> menu or drag to the List View area to parse commands.<br />
198    </p>
199    <p>
200<img alt="<CODE>banner</CODE>" src="image/gxCommandAnalyzerGui.png" style="width: 768px; height: 576px" /></p>
201    <div class="section">
202      <p>
203        <table class="table"><tbody>
204<tr><th>Number</th> <th>Description</th></tr>
205          <tr>
206             <td>1</td>
207<td>Displays the command parsing data. This data is nearly the same as the data output by the console version.<br />
208The columns have the following meanings:<br /><br />
209Far left - Indicates whether burst transfer.<br />
210Line - The order in which commands are stacked.<br />
211Reg - The register number.<br />
212Data - The data entered in this register.<br />
213BE - The byte enable.<br />
214Value - Displays the virtual address when the data is an address.<br />
215Summary - Displays a summary of that register.<br /><br /><br />
216Click the columns to sort them.<br /><br />
217Right-click a column to open a menu and choose whether to show or hide the column.<br /><br />
218Click an item to display details in the left panel.<br /><br />
219Here are the meanings of the various colors for items:<br /><br /> <br />
220Blue - Burst transfer; single register access.</br>
221Red -  Burst transfer; consecutive register access.</br>
222Gray - Dummy command (BE is 0x0).</br></br>
223Folding is the default loading mode for burst transfer.<br />
224If the &quot; + &quot; symbol displays in the far left column, you can double-click it to expand the view. <br />
225Once expanded, the &quot; - &quot; symbol displays. Double-click it to collapse the view.<br />
226The <B>View</B> menu has a feature for expanding and collapsing all.<br />
227             </td>
228          </tr>
229          <tr>
230            <td>2</td>
231<td>A summary of the selected register. This is the same as what is displayed in List View.</td>
232          </tr>
233          <tr>
234            <td>3</td>
235<td>Simple command editing can be performed here. Data can be edited in hexadecimal, decimal, and binary.<br />Enter data and then apply the edited changes to the command by pressing the ENTER key (except when entering binary), or by clicking the <B>Update</B> button.<br />Click the <B>Default</B> button to restore the command to its original state when loaded.<br />For binary, click on each digit to swap out 0/1s. Bits shown in black have not been specified for byte enable.<br />
236            </td>
237          </tr>
238          <tr>
239            <td>4</td>
240<td>The entire range of bits that can be set for this register, displayed as buttons.<br /> Place the pointer above a button to show the bits that are binary data in red (or purple if not specified by BE), and to display detailed data about that range in the lower part of the panel (explained in detail below).<br /><b> Note that if a command has been edited but the edits have not been applied (by clicking the <B>Update</B> button or otherwise), this detailed data is also not updated.</b>
241            </td>
242          </tr>
243          <tr>
244            <td>5</td>
245            <td>
246Shows the corresponding OpenGL API function.<br />
247            </td>
248          </tr>
249          <tr>
250            <td>6</td>
251            <td>
252Displays detailed data. The contents are nearly the same as the specification.<br />
253            </td>
254          </tr>
255          <tr>
256            <td>7</td>
257            <td>
258Displays the range of data specified by <B>Range Button</B> in hexadecimal, decimal, and binary.<br />If the register takes data such as floating-point values or addresses, that value is displayed in the <B>LocalData(Converted)</B> field.<br />
259            </td>
260          </tr>
261          <tr>
262            <td>8</td>
263            <td>
264Use this to search for registers.<br />Enter a register number and press the ENTER key to select the relevant item in the List View.<br /> After moving the focus to List View, press F3 to search for the next item in that same register. <br /><b> You cannot use the Search Register feature with any sort order except the default (which is to sort by ascending Line). </b>
265            </td>
266          </tr>
267        </tbody></table>
268      </p>
269    </div>
270<p>Here is a description of the menu items.</p>
271    <div class="section">
272      <p>
273        <table class="table"><tbody>
274<tr><th>Category</th><th>Name</th><th>Description</th></tr>
275          <tr>
276<td>File</td>
277<td>Open</td>
278<td>Opens a file.</td>
279          </tr>
280          <tr>
281             <td></td>
282<td>Save</td>
283<td>Saves the parsing results.</td>
284          </tr>
285          <tr>
286             <td></td>
287<td>Save As Command</td>
288<td>Saves the file as command data.</td>
289          </tr>
290          <tr>
291             <td></td>
292<td>Exit</td>
293<td>Exits the program.</td>
294          </tr>
295          <tr>
296<td>View</td>
297<td>Show All</td>
298             <td>
299Displays all data that was omitted for burst access.<br />If the command data is large in size this could take some time.
300             </td>
301          </tr>
302          <tr>
303             <td></td>
304<td>Hide All</td>
305             <td>
306Omits all data written by burst access.<br />If the command data is large in size this could take some time.
307             </td>
308          </tr>
309          <tr>
310<td>Help</td>
311<td>Version</td>
312<td>Shows the version of the DMPGL specification on which the command detailed data is based.</td>
313          </tr>
314        </tbody></table>
315      </p>
316    </div>
317<h3>Notes</h3>
318If the command file is too big, it can take an extremely long time to close and open burst transfers and apply command edits.<br />The specifications for your PC also matter, but in general, Nintendo recommends keeping the size of your command files to 50 KB or less.<br />
319<h2>Command Data Format</h2>
320      <p>
321Enter command data in the format of a 64-bit collection of commands, comprising a 32-bit header and 32 bits of data.<br /><br /> To output the command data when you are using PARTNER-CTR, open the <B>File</B> menu and select <B>Save binary</B> or <B>Save binary [Size]</B>. Use binary data that are output this way as the input file for this tool.<br /><br />Use the <CODE>nngxGetCmdlistParameteri</CODE> function to get the command buffer address needed when saving the binary.<br />Get the starting address of the command buffer by specifying <CODE>NN_GX_CMDLIST_TOP_BUFADDR</CODE> for the first argument of the function.<br />Get the current address of the command buffer by specifying <CODE>NN_GX_CMDLIST_CURRENT_BUFADDR</CODE> for the argument.<br />Get the accumulated size of the command buffer by specifying <CODE>NN_GX_CMDLIST_USED_BUFSIZE</CODE> for the argument.<br />Here is an example of pseudo-code for getting the starting address of the command buffer and the post-rendering size of the command buffer:
322
323        <pre class="code">
324void Initialize()
325{
326    nngxInitialize(allocator, deallocator);
327
328    nngxGenCmdlists(1, &cmdList);
329    nngxBindCmdlist(cmdList);
330    nngxCmdlistStorage(0x400000, 128);
331
332    // Get starting address
333    nngxGetCmdListParameteri(NN_GX_CMDLIST_TOP_BUFADDR, &addr);
334
335    /* Initialization process */
336}
337
338void DrawFrame()
339{
340    /* Various processes */
341
342    // Rendering functions
343    Draw();
344
345    // Get size
346    nngxGetCmdListParameteri(NN_GX_CMDLIST_USED_BUFSIZE, &size);
347
348    // When getting current address
349    //nngxGetCmdListParameteri(NN_GX_CMDLIST_CURRENT_BUFADDR, &addr);
350}
351        </pre>
352Pass the address and size obtained with this code to the parameters for <B>Save binary [Size]</B> and output to get command data in a format that can be used by this tool. <br />If you use <B>Save binary...</B> to output the command data, get the current address for the command buffer by specifying <CODE>NN_GX_CMDLIST_CURRENT_BUFADDR</CODE> for the first argument of the <CODE>nngxGetCmdListParameteri</CODE> function.
353      </p>
354<h3>Notes</h3>
355・ Note that writing to the command buffer generally takes place when render functions are executing.<br />・ If you are using a command-jump subroutine, write the jump-destination commands separately. (The parsing itself is done separately.) <br />・ If you are duplicating command lists, confirm that the buffer you want to output is storing the bound command list.<br />・If you are using burst access, write out all the necessary data. If there is not enough data, you will not be able to load it.
356<h2>Example Output</h2>
357    <pre class="code">
3580x041 : 0x0045E000 (BE: 0x7)	viewport settings (width)
3590x042 : 0x38111112 (BE: 0xF)	viewport settings (width)
3600x043 : 0x00469000 (BE: 0x7)	viewport settings (height)
3610x044 : 0x3747AE14 (BE: 0xF)	viewport settings (height)
3620x068 : 0x00000000 (BE: 0xF)	viewport settings register (x/y)
363BurstSequence	  3 times (BE: 0xF)
364	0x065 : 0x00000003				scissoring settings (false/true)
365	0x066 : 0x00000000				scissoring settings (x/y)
366	0x067 : 0x018F00EF				scissoring settings (width/height)
3670x111 : 0x00000001 (BE: 0xF)	framebuffer cache flush
3680x110 : 0x00000001 (BE: 0xF)	framebuffer cache tag clearing
369BurstSequence	  4 times (BE: 0xF)
370	0x200 : 0x0402C048 [0x14160240]	Shared base address for array of all vertices
371	0x201 :0x0000000B				Internal vertex attribute type (Attributes 0 - 7)
372	0x202 :0x00000000				Internal vertex attribute type (Attributes 8 - 11, mask, number of attributes)
373	0x203 :0x00000004 [0x00000004]	Address offset for load array 0</pre>
374
375<p>0x200 :0x0402C048 [0x14160240]	Shared base address for array of all vertices</p>
376<p>In this example, <B>0x200</B> is the register number, <B>0x0402C048</B> is the data content, <B>[0x14160240]</B> is the value of the data content converted to a virtual address, and <B>Shared base address for array of all vertices</B> is the description for that register.</p>
377
378    <h2>Location</h2>
379    <pre> $CTRSDK_ROOT/tools/ComandlineTools/ctr_GxCommandAnalyzer/ctr_GxCommandAnalyzer32.exe </pre>
380    <h2>Revision History</h2>
381    <div class="section">
382      <dl class="history">
383        <dt>2011/2/13</dt>
384<dd>Added description of the GUI version.<br />
385        </dd>
386        <dt>2011/12/29</dt>
387<dd>Added description of the command data format.<br />
388        </dd>
389        <dt>2011/12/08</dt>
390<dd>Initial version.<br />
391        </dd>
392      </dl>
393    </div>
394  <hr><p>CONFIDENTIAL</p></body>
395</html>