From e898ef9568bdce551b8ce0da7a428bc645c2f3f8 Mon Sep 17 00:00:00 2001 From: Andy McFadden Date: Fri, 27 Sep 2019 13:43:58 -0700 Subject: [PATCH] Minor fixes Change + save + undo + change was being treated as non-dirty. Added link to "export" feature to documentation TOC. Added keyboard shortcut for high part in data operand editor. Corrected various things in the tutorial. --- SourceGen/DisasmProject.cs | 8 +++ SourceGen/RuntimeData/Help/index.html | 3 +- SourceGen/RuntimeData/Help/tutorials.html | 76 ++++++++++++++--------- SourceGen/WpfGui/EditDataOperand.xaml | 2 +- 4 files changed, 57 insertions(+), 32 deletions(-) diff --git a/SourceGen/DisasmProject.cs b/SourceGen/DisasmProject.cs index 8944df2..8cfe7a8 100644 --- a/SourceGen/DisasmProject.cs +++ b/SourceGen/DisasmProject.cs @@ -1657,6 +1657,14 @@ namespace SourceGen { mUndoList.Add(changeSet); mUndoTop = mUndoList.Count; + + // If the user makes a change, saves the file, hits undo, then makes another change, + // the "undo top" and "save index" will be equal, which will make us think the + // file doesn't need to be saved. In reality there is no longer any undo index that + // matches the saved file state. + if (mUndoSaveIndex >= mUndoTop) { + mUndoSaveIndex = -1; + } } public string DebugGetUndoRedoHistory() { diff --git a/SourceGen/RuntimeData/Help/index.html b/SourceGen/RuntimeData/Help/index.html index 2fccfa1..d97aaa1 100644 --- a/SourceGen/RuntimeData/Help/index.html +++ b/SourceGen/RuntimeData/Help/index.html @@ -103,6 +103,7 @@ and 65816 code. The official web site is
  • cc65
  • Merlin 32
  • +
  • Exporting Source Code
  • Properties & Settings @@ -171,7 +172,7 @@ and 65816 code. The official web site is diff --git a/SourceGen/RuntimeData/Help/tutorials.html b/SourceGen/RuntimeData/Help/tutorials.html index 0ce0926..52d246a 100644 --- a/SourceGen/RuntimeData/Help/tutorials.html +++ b/SourceGen/RuntimeData/Help/tutorials.html @@ -28,7 +28,7 @@ manual is recommended.

    Start by launching SourceGen. The initial screen has a large center area with some buttons, and some mostly-empty windows on the sides. -The buttons are shortcuts for menu items in the File menu.

    +The buttons are shortcuts for items in the File menu.

    Create the project

    @@ -63,7 +63,7 @@ or data. This is a standard Windows "list view", so you can select a row by left-clicking anywhere in it. Use Ctrl+Click to toggle the selection on individual lines, and Shift+Click to select a range of lines. You can move the selection around with the up/down arrow keys and PgUp/PgDn. Scroll -the window with the mouse wheel or by grabbing the scroll bar.

    +the window with the mouse wheel or by dragging the scroll bar.

    Each row is divided into nine columns. You can adjust the column widths by clicking and dragging the column dividers in the header. The @@ -97,7 +97,7 @@ highlights and contents of other windows change.

    selection jumps to L1017. When an operand references an in-file address, double-clicking on the opcode will take you to it. (Double-clicking on the operand itself opens a format editor; more on that later.)

    -

    With L1017 highlighted, double-click on the line that appears in the +

    With line L1017 selected, double-click on the line that appears in the References window. Note the selection jumps to L1002. You can immediately jump to any reference.

    At the top of the Symbols window on the right side of the screen is a @@ -229,7 +229,9 @@ as a hexadecimal value.

    Actions > Edit Label. Enter "IS_OK", and hit Enter. (NOTE: labels are case-sensitive, so it needs to match the operand at $2005 exactly.) You'll see the new label appear, and the operand at line $2005 will use it.

    -

    There's an easier way. Double-click on the "BCC" opcode at address +

    There's an easier way. Select Edit > Undo twice, to get back to the +state where line $2005 says "BCC L2009", and line $2009 has the label +L2009. Now double-click on the "BCC" opcode (not operand) at address $2005. This moves the selection to $2009. Double-click on the label field, and enter "IS_OK". Hit "OK".

    You should now see that both the operand at $2005 and the label at @@ -237,9 +239,19 @@ $2009 have changed to IS_OK, accomplishing what we wanted to do in a single step. The key difference is that we haven't explicitly set a format for the BCC operand -- we just defined a label, and SourceGen used it automatically.

    -

    We could do the exact same thing by using Edit Operand on -the BCC line, clicking the "Create Label" button, and typing "IS_OK". -Sometimes one approach is more convenient than the other.

    +

    There's another way to do the same thing that is sometimes +more convenient. Double-click the "IS_OK" label on line $2009, hit +the Delete key to erase it, and click "OK". This removes the label, +so SourceGen generates L2009 again. Double-click on the operand on +line $2005 ("L2009") to open the operand editor, then in the bottom left +panel click "Create Label". Type "IS_OK", then click "OK". Make sure the +radio buttons are still set to Default format, and click "OK".

    +

    You should again have the IS_OK label at line $2009, just like it did +when you created the label on line $2009, because you did exactly the +same thing. You just opened the label editor from the Edit Operand dialog +instead of the code list. In many cases, particularly when operand's +target address is far off screen, it's more convenient to work through the +operand editor.

    Editing Data Operands

    @@ -344,13 +356,14 @@ a bit more meaningful by loading an additional platform symbol file. Select Edit > Project Properties, then the Symbol Files tab. Click Add Symbol Files. The file browser starts in the RuntimeData directory. In the Apple folder, select Applesoft.sym65, and -click Open. Click "OK" to close the project properties window.

    -

    The STA instructions now reference AMPERV, which is noted -as a call vector. We can see the code setting up a jump (opcode $4c) to -$1d70. 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 .ORG statement, and change it from $2000 to $1d60. We can now -see that $1d70 starts right after this initial chunk of code.

    +click "Open". Click "OK" to close the project properties window.

    +

    The STA instructions now reference BAS_AMPERV, +which is noted as a code vector. We can see the code setting up a jump +(opcode $4c) to $1d70. 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 .ORG statement, and change it from +$2000 to $1d60. We can now see that $1d70 starts right after this +initial chunk of code.

    Select the line with address $1d70, then Actions > Hint As Code Entry Point. @@ -359,9 +372,9 @@ of the file is still data. The code at $1d70 searches through a table at $1d88 for a match with the contents of the accumulator. If it finds a match, it loads bytes from tables at $1da6 and $1d97, pushes them on the stack, and the JMPs away. This code is pushing a return address onto the stack. -When the code at CHRGET returns, it'll return to that address. Because of -a quirk of the 6502 architecture, the address pushed must be the target -address minus one.

    +When the code at BAS_CHRGET returns, it'll return to that +address. Because of a quirk of the 6502 architecture, the address pushed +must be the desired address minus one.

    The first byte in the first address table at $1d97 (which has the auto-label L1D97) is $b4. The first byte in the second table is $1d. So the first address we want is $1db4 + 1 = $1db5.

    @@ -408,7 +421,7 @@ SourceGen asks for confirmation, click Discard & Continue.

    Going Deeper

    Start a new project. Select "Generic 6502". For the data file, navigate -to the Examples directory, then from the Tutorials directory +to the Examples directory, then from the Tutorial directory select "Tutorial2".

    The first thing you'll notice is that we immediately ran into a BRK, which is a pretty reliable sign that we're not in a code section. The @@ -470,7 +483,7 @@ as the dialog opens; you don't need to click around first.) If all went well, the operands should now read LDA #<XDATA and LDA #>XDATA.

    Let's give the pointer a name. Select line $203d, and use -Actions > Edit Local Variable Table to create an empty table. +Actions > Create Local Variable Table to create an empty table. Click "New Symbol" on the right side. Set the Label field to "PTR1", the Value field to $02, and the width to 2 (it's a 2-byte pointer). Leave the Address button selected. Click "OK" to create the entry, and then @@ -556,23 +569,26 @@ than the "nearby" logic.

    avoid explicitly labeling every part of a multi-byte data item. For now, use Edit > Undo to switch it back on.

    -

    The code at $2085 looks a bit strange. LDX, then a BIT with a weird -symbol, then another LDX. If you look at the "bytes" column, you'll notice -that the three-byte BIT instruction has only one byte on its line. The -trick here is that the LDX #$01 is embedded inside the BIT -instruction. When the code runs through here, X is set to $00, then -the BIT instruction sets some flags, then the STA runs. Several lines -down there's a BNE to $2088, which is in the middle of the BIT instruction. -It loads X with $01, then also continues to the STA.

    -

    Embedded instructions are unusual but not unheard-of. When you see the +

    The code at $2085 looks a bit strange. LDX, then a +BIT with a weird symbol, then another LDX. If +you look at the "bytes" column, you'll notice that the three-byte +BIT instruction has only one byte on its line. The +trick here is that the LDX #$01 is embedded inside the +BIT instruction. When the code runs through here, X is set +to $00, then the BIT instruction sets some flags, then the +STA runs. Several lines down there's a BNE +to $2088, which is in the middle of the BIT instruction. +It loads X with $01, then also continues to the STA.

    +

    Embedded instructions are unusual but not unheard-of. (This trick is +used extensively in Microsoft BASICs, such as Applesoft.) When you see the extra symbol in the opcode field, you need to look closely at what's going on.

    Go Forth

    -

    That's it for the tutorials. There's significantly more detail on -all aspects of SourceGen in the manual.

    +

    That's it for the tutorials. Significantly more detail on +all aspects of SourceGen can be found in the manual.

    While you can do some fancy things, nothing you do will alter the data file. The assembled output will always match the original. So don't be afraid to play around.

    diff --git a/SourceGen/WpfGui/EditDataOperand.xaml b/SourceGen/WpfGui/EditDataOperand.xaml index cd1d6ba..93c4943 100644 --- a/SourceGen/WpfGui/EditDataOperand.xaml +++ b/SourceGen/WpfGui/EditDataOperand.xaml @@ -113,7 +113,7 @@ limitations under the License. - +