Skip to content

Commit

Permalink
Update tutorial
Browse files Browse the repository at this point in the history
Two main changes:
 - "Seek nearby targets" is no longer enabled by default.
 - The application asks the user to save new projects immediately.

Various minor edits were also made.

A couple of the images are slightly stale, showing ".org" rather than
".addrs", but they're in the advanced section and the difference
isn't notable.
  • Loading branch information
fadden committed Aug 19, 2024
1 parent 5544014 commit eef1710
Show file tree
Hide file tree
Showing 14 changed files with 106 additions and 87 deletions.
1 change: 0 additions & 1 deletion SourceGen/DisasmProject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2111,7 +2111,6 @@ public ChangeSet PopUndoSet() {
/// <summary>
/// Returns the next redo operation, and moves the pointer to the next item.
/// </summary>
/// <returns></returns>
public ChangeSet PopRedoSet() {
if (!CanRedo) {
throw new Exception("Can't redo");
Expand Down
4 changes: 2 additions & 2 deletions docs/sgtutorial/about-disasm.html
Original file line number Diff line number Diff line change
Expand Up @@ -152,13 +152,13 @@ <h2>About Disassembly</h2>

<p>The process can be improved by keeping track of the flags in the
6502 status register. For example, in the code fragment shown
earlier, <code>BMI</code> conditional branch instruction is used.
earlier, the <code>BMI</code> conditional branch instruction is used.
A simple tracing algorithm would both follow the branch and fall
through to the following instruction. However, the code that precedes
the <code>BMI</code> ensures that the branch is always taken, so a
clever disassembler would only trace that path.</p>

<p>(The situation is worse on the 65816, because the length of
<p>(This is even more important on the 65816, because the length of
certain instructions is determined by the values of the processor
status flags.)</p>

Expand Down
7 changes: 4 additions & 3 deletions docs/sgtutorial/address-tables.html
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ <h2>Address Tables</h2>
<samp>Select File</samp> and navigate to the 6502bench Examples directory.
In the "A2-Amper-fdraw" directory, select the file "AMPERFDRAW#061d60"
(just ignore the existing .dis65 file).
Click <samp>OK</samp> to create the project.</p>
Click <samp>OK</samp> to create the project. Click <samp>Cancel</samp>
to skip saving the project file.</p>
</div>
</div>

Expand Down Expand Up @@ -145,7 +146,7 @@ <h2>Address Tables</h2>
<div class="grid-item-text">
<p>As it happens, the start address of the code
is $1D60 -- the last four digits of the filename -- so let's make that
change. Double-click the initial <code>.ORG</code> statement,
change. Double-click the initial <code>.ADDRS</code> statement,
and change it from $2000 to $1D60. We can now see that $1D70 starts
right after this initial chunk of code.</p>
</div>
Expand Down Expand Up @@ -212,7 +213,7 @@ <h2>Address Tables</h2>
<code>&lt;FUNC-152</code>, you forgot to select the high part.)</p>

<p>We've now changed the first entry in the address table to a
symbolic reference, which is helps someone reading the code to
symbolic reference, which will help someone reading the code to
understand what is being referenced. You could repeat these
steps (tag as code, set label, change address bytes to symbols)
for the remaining items, but there's an easier way.</p>
Expand Down
7 changes: 4 additions & 3 deletions docs/sgtutorial/digging-deeper.html
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,10 @@ <h2>Digging Deeper</h2>

<div class="grid-container">
<div class="grid-item-text">
<p>This tutorial will walk you through some of the fancier things SourceGen
can do. We assume you've already finished the basic features tutorial,
and know how to create projects and move around in them.</p>
<p>This part of the tutorial will walk you through some of the
fancier things SourceGen can do. We assume you've already finished
the basic features tutorial, and know how to create projects and move
around in them.</p>
<p>Start a new project. Select <samp>Generic 6502</samp>. For the
data file, navigate to the Examples directory, then from the Tutorial
directory select "Tutorial2".</p>
Expand Down
9 changes: 5 additions & 4 deletions docs/sgtutorial/editing-data.html
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,11 @@ <h2>Editing Data</h2>
<img src="images/t1-data-editdlg-1.png" alt="t1-data-editdlg-1"/>
</div>
<div class="grid-item-text">
<p>Select the last line in the file, then <samp>Actions &gt; Edit Operand</samp>.
You'll notice that this dialog is much different from the one you got when editing
the operand of an instruction. At the top it will say "<samp>65 bytes
selected</samp>". You can format this as a single 65-byte string, as 65 individual
<p>Select the last line of data in the file ($2030), then
<samp>Actions &gt; Edit Operand</samp>. You'll notice that this dialog
is much different from the one you got when editing the operand of an
instruction. At the top it will say "<samp>65 bytes selected</samp>".
You can format this as a single 65-byte string, as 65 individual
items, or various things in between. For now, select <samp>Single bytes</samp>,
and then on the right, select <samp>ASCII (low or high) character</samp>.
Click <samp>OK</samp>.</p>
Expand Down
43 changes: 24 additions & 19 deletions docs/sgtutorial/extension-scripts.html
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,9 @@ <h2>Extension Scripts</h2>
<p>An earlier tutorial demonstrated how to manually mark bytes as
inline data. We're going to do it a faster way. For this tutorial,
start a new project with the <samp>Generic 6502</samp> profile, and
in the SourceGen Examples/Tutorial directory select "Tutorial4".</p>
in the SourceGen Examples/Tutorial directory select "Tutorial4" as
the data file.
You can choose to save the project file or not.</p>
<!--<p>We'll need to load scripts from the project directory, so we have to
save the project. <samp>File &gt; Save</samp>,
use the default name ("Tutorial4.dis65").</p>-->
Expand Down Expand Up @@ -125,9 +127,10 @@ <h2>Extension Scripts</h2>
</div>
<div class="grid-item-text">
<p>Nothing happened. If you look at the script with an editor (and you
know some C#), you'll see that it's looking for a <code>JSR</code> to a
function that begins with certain prefixes. For ASCII length-delimited
strings, the prefix is <code>InA1_</code>. So let's set a label.</p>
know some C#), you'll see that it's looking for <code>JSR</code>
instructions that call functions whose names begin with certain strings.
For ASCII strings prefixed with a 1-byte length, the appropriate
function name prefix is <code>InA1_</code>. So let's set a label.</p>
</div>
</div>

Expand All @@ -149,9 +152,9 @@ <h2>Extension Scripts</h2>
<div class="grid-item-text">
<p>This time, double-click the <code>JSR</code> <i>operand</i>
("<samp>L1036</samp>") to edit the operand.
Click <samp>Create Label</samp>, and enter <kbd>InA1_PrintString</kbd>.
Remember that labels are case-sensitive;
you must enter it exactly as shown. Hit <samp>OK</samp> to accept the label,
Click <samp>Create Label</samp>, and enter "<kbd>InA1_PrintString</kbd>".
Remember that labels are case-sensitive; you must enter it exactly
as shown (note the lower-case 'n'). Hit <samp>OK</samp> to accept the label,
and <samp>OK</samp> to close the operand editor.</p>
</div>
</div>
Expand All @@ -177,9 +180,9 @@ <h2>Extension Scripts</h2>
<p>Double-click the operand on line $100D ("<code>L1037</code>"),
click <samp>Create Label</samp>,
and set the label to "<kbd>InAZ_PrintString1</kbd>".
Hit <samp>OK</samp> twice. That formatted the first one and got us
to the next <code>JSR</code>, at $1019. Repeat the process on line $1019
("<code>L1038</code>"), setting the label to
Hit <samp>OK</samp> twice. That formatted the string that followed,
and got us to the next <code>JSR</code>, at $1019. Repeat the
process on line $1019 ("<code>L1038</code>"), setting the label to
"<kbd>InAZ_PrintString2</kbd>".</p>
</div>
</div>
Expand All @@ -192,22 +195,24 @@ <h2>Extension Scripts</h2>
<p>The last <code>JSR</code>, at $1025, is followed by a 16-bit
pointer. Edit the operand, and use <samp>Create Label</samp> to
set the label at the target address to "<kbd>InWA_StringPtr</kbd>".
Because the bytes were formatted as an address and not a just a
16-bit value, a label was generated automatically.</p>

<p>What we'd really like to do in this case is to have it format the
16-bit address as a pointer, and format the data it points to as
a null-terminated string. The StdInline script doesn't know how to
do that though, so you'd need to write a custom script. (Scripts
can format multiple data items, add symbolic references to labels
This causes the two bytes to be formatted as a 16-bit address,
rather than just a 16-bit value, so a label was generated
automatically at the target address ("<code>L102B</code>").</p>

<p>It would be even more helpful if it formatted the data at $102B
as a null-terminated string. The basic StdInline script doesn't
happen to do that, but it's possible to do it with a custom script.
(Scripts can format multiple data items, add symbolic references to labels
and constants, and chase pointers around.)</p>

<p>The entire project is now nicely formatted. In a real project the
"Print Inline" locations would be actual print functions, not just <code>RTS</code>
instructions. There would likely be multiple <code>JSR</code>s to the print function,
so labeling a single function entry point could format dozens of inline
strings and clean up the disassembly automatically. The reason for
allowing wildcard names is that some functions may have multiple
using name prefixes like <code>InAZ_</code>, rather than full function
names, is that there may be more than one function with the same stack
mechanics. Also, some functions may have multiple
entry points or chain through different locations.</p>
</div>
</div>
Expand Down
8 changes: 4 additions & 4 deletions docs/sgtutorial/labels-symbols.html
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,13 @@ <h2>Labels &amp; Symbols</h2>
can greatly improve the readability of the code: something like
<code>JSR DrawSprite</code> is far more helpful for human readers.
Further, once the code has been disassembled to source code, using symbols
instead of fixed addresses makes it easier to alter the program or re-use
the code.</p>
instead of fixed addresses makes it easier to alter the program or reuse
the code in another project.</p>

<p>When the target address of instructions like <code>JSR</code> and
<code>LDA</code> falls within the scope of the data file, SourceGen classifies
the reference as <i>internal</i>, and automatically adds a generic
symbolic label (e.g. <code>L1000</code>). This can be edited if desired.</p>
symbolic label (e.g. <code>L1000</code>). The label can be edited if desired.</p>
</div>
</div>

Expand Down Expand Up @@ -367,7 +367,7 @@ <h4>Non-Unique Labels</h4>
button is selected automatically if you start a label with '@' (or
whatever character you have configured). Click <samp>OK</samp>.</p>
<p>You now have two lines with the same label. In some cases the
assembly source generator need to may "promote" them to globals, or
assembly source generator may need to "promote" them to globals, or
rename them to make them unique, depending on what your preferred assembler
allows.</p>
</div>
Expand Down
12 changes: 7 additions & 5 deletions docs/sgtutorial/local-variables.html
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ <h2>Local Variables</h2>
</div>
<div class="grid-item-text">
<p>Let's move on to the code at $203D. It starts by storing a couple of
values into direct page address $02/03. This appears to be setting up a
values into zero page addresses $02/03. This appears to be setting up a
pointer to $2063, which is a data area inside the file. So let's make it
official.</p>
</div>
Expand Down Expand Up @@ -158,8 +158,8 @@ <h2>Local Variables</h2>
<img src="images/t2-20a7.png" alt="t2-20a7"/>
</div>
<div class="grid-item-text">
<p>Double-click on the <code>JSR</code> opcode on line $2045 to jump to
<samp>L20A7</samp>.
<p>Double-click on the <code>JSR</code> opcode on line $2045 to jump
way down to <samp>L20A7</samp>.
The code here just loads a value from $3000 into the accumulator
and returns, so not much to see here. Hit the back-arrow in the
toolbar to jump back to the <code>JSR</code>.</p>
Expand Down Expand Up @@ -256,7 +256,8 @@ <h4>Showing Cycle Counts</h4>
<samp>Edit &gt; Settings</samp> to open the app settings panel.
In the <samp>Miscellaneous</samp> group on the right side, click the
<samp>Show cycle counts for instructions</samp> checkbox, then click
<samp>OK</samp>. (There's also a toolbar button for this.)</p>
<samp>OK</samp>. (There's also a toolbar button that toggles it
on and off.)</p>
</div>
</div>

Expand Down Expand Up @@ -287,7 +288,8 @@ <h4>Showing Cycle Counts</h4>
The following instruction, <code>ORA #$80</code>, cleared the 'Z' flag and
set the 'N' flag, so a <code>BMI</code> would also be an always-taken branch.)</p>

<p>The cycle-count comments can be added to generated source code as well.</p>
<p>The cycle-count comments can be added to generated source code as well,
with an application setting in the <code>Asm Config</code> tab.</p>
<p>If you add an end-of-line comment, it appears after the cycle count.
(Try it.)</p>
</div>
Expand Down
2 changes: 1 addition & 1 deletion docs/sgtutorial/making-edits.html
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ <h2>Making Edits</h2>
window on the bottom left. Notes are like long comments, with three key
differences:</p>
<ol>
<li>You can't pick their line width, but you can pick their color.</li>
<li>You can't really format the text, but you can pick their color.</li>
<li>They don't appear in generated assembly sources, making them
useful for leaving notes to yourself as you work.</li>
<li>They're listed in the Notes window. Double-clicking them jumps
Expand Down
14 changes: 8 additions & 6 deletions docs/sgtutorial/moving-around.html
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ <h2>Moving Around</h2>
<li>Symbols. All known symbols. The buttons at the top allow you
to filter out symbol types that you're not interested in.</li>
<li>Info. Information about the selected line. For code, this
will have a summary of the instruction.</li>
will include a summary of the instruction's behavior.</li>
</ol>
</div>
</div>
Expand Down Expand Up @@ -151,8 +151,9 @@ <h2>Moving Around</h2>
<li>Address 1017 and label L1017 were highlighted. When you select
a line with an operand that targets an in-file address, the target
address is highlighted.</li>
<li>An entry appeared in the References window. This tells you that the
only reference to L1002 is a branch from address $100B.</li>
<li>An entry appeared in the References window. This tells you
that the only reference to L1002 is a branch from address $1009. The
branch operand on line $1009 was also highlighted.</li>
<li>The Info window filled with a bunch of text that describes the
line format and some details about the LDA instruction.</li>
</ul>
Expand Down Expand Up @@ -224,9 +225,10 @@ <h2>Moving Around</h2>
on opcodes or lines in the side windows, the locations are added to a
navigation history. The arrows let you move forward and backward
through it.</p>
<p>The "Nav Backward" feature is bound to the 4th button found on some
mice (usually found on the side, activated with the thumb). This can
be used to navigate quickly through a project using only the mouse.</p>
<p>The "Nav Backward" feature is usually bound to the 4th button found
on some mice (generally found on the side, activated with the thumb).
This can be used to navigate quickly through a project using only the
mouse.</p>
</div>
</div>

Expand Down
Loading

0 comments on commit eef1710

Please sign in to comment.