Explorar o código

Merge branch 'develop'

Wilfried Klaas %!s(int64=6) %!d(string=hai) anos
pai
achega
37d3ab2fe3
Modificáronse 13 ficheiros con 572 adicións e 145 borrados
  1. 3 3
      Beispiele/SimpleServo.tps
  2. 9 0
      Beispiele/simple_blink.tps
  3. 149 1
      README.md
  4. 4 4
      SPS_EMU.000
  5. 8 3
      SPS_EMU.001
  6. 8 3
      SPS_EMU.044
  7. 9 2
      SPS_EMU.049
  8. 3 2
      SPS_Emu.lpi
  9. BIN=BIN
      SPS_Emu.lsu
  10. 0 1
      SPS_Emu.xml
  11. 109 63
      ugui.lfm
  12. 182 53
      ugui.pas
  13. 88 10
      usps.pas

+ 3 - 3
Beispiele/SimpleServo.tps

@@ -1,12 +1,12 @@
 #TPS:Willies SPS Arduino
 0x00,4,4,""
-0x01,5,1,""
+0x01,5,2,""
 0x02,4,F,""
 0x03,7,C,""
 0x04,F,8,""
 0x05,4,0,""
 0x06,F,8,""
 0x07,2,0,""
-0x08,3,6,""
+0x08,A,2,""
 0x09,F,F,""
-0x0A,0,,""
+0x0A,0,0,""

+ 9 - 0
Beispiele/simple_blink.tps

@@ -0,0 +1,9 @@
+#TPS:Willies SPS Arduino
+0x00,4,0,""
+0x01,1,5,""
+0x02,2,8,""
+0x03,1,A,""
+0x04,2,8,""
+0x05,3,4,""
+0x06,0,0,""
+0x07,0,0,""

+ 149 - 1
README.md

@@ -1 +1,149 @@
-SPS_Emulator
+# **SPS_Emulator Version History**
+
+**18.11.2018 Version 0.2.1.52**
+  * FEATURE: deactivating right panel if not in emulator mode
+  * FEATURE: new internal "Jump to" will show the absolute memory address, if a skip or jump command will be executed
+
+**17.11.2018 Version 0.2.1.51**
+  * BUG: clicking "new row" with active row at the end of the table, two rows will be added
+  * BUG: The last empty row will only show command 0. Data is not be set. 
+  * BUG: on Export the field names are no correctly padded
+  * BUG: on "new file" changes of the actual file will not be saved
+  * FEATURE: loading and saving of input presets, adding PRG and SEL Buttons to preset
+  * BUG: Holtec -> Holtek
+	
+**10.11.2018 Version 0.2.1.50**
+
+  * adding visual tone control for SPS Version 0.8
+
+**10.11.2018 Version 0.2.1.48**
+
+  * adding new internals: page and delay
+  * Bug: Servo indicator shown in Holtec mode.
+
+**08.11.2018 Version 0.2.1.47**
+
+  * neue Webseitenadresse eingebaut
+  * Icon und Text start/stoppen geändert
+  * aktuelle Lazarus Version
+  * bei der Auswahl von COM Port und Arduino Pfad wird dieser aus der Registry vorbesetzt
+  * zus. Servoanzeige mit Strich
+
+**05.12.2013 Version 0.2.1.45**
+
+  * Feature: Internationalisierung. Das Programm steht nun in deutsch und englisch zur Verfügung. Es schaltet sich je nach Sprachversion des Betriebssystems automatisch um.
+
+**05.12.2013 Version 0.2.1.44**
+
+Herzlich Dank an Herrn Oehme, durch den ich folgende Bug beseitigen konnte .
+
+  * Die Internet-Verbindung im Eröffnungsbildschirm klappt nicht – Anzeige “keine Verb.”
+
+Lösung: Die WebAdresse hat sich geändert.
+
+  * Im “Skip if”-Befehl fehlen S_SEL=0/S_PRG=0/S_SEL=1/S_PRG=1 (betrifft nur TPS Holtec).
+
+Lösung: Befehle nachgetragen.
+
+  * Der “Return”-Befehl für TPS Holtec und TPS ATMega8 funktioniert nicht – RAdr lautet immer 0
+
+Lösung: Bug gefixed.
+
+**09.03.2013 Version 0.2.1.43**
+
+Durch die tatenreiche Mithilfe von Herrn Chvatal (Amateurtfunk-Rufzeichen: OE1GCA) habe ich folgende Bug beseitigen können. Hiermit möchte ich allen, die mir bisher eine Rückmeldung gegeben haben vielen Dank sagen.
+
+  * Die beiden Taster SEL und PRG waren vertauscht.
+  * In der Holtek und ATMEga 8 Version gibt es nur ein Ebene für den Subroutinen Call. Bei meinen beiden Versionen (ATTiny84 und Arduino gibt es davon 8, d.h. ich kann 8 Aufrufebenen verwenden.) Das berücksichtigt jetzt auch der Emulator.
+  * Das A-Register ist in der Holtect und der ATMega8 Version immer nur 4 Bit breit. ATTiny84 und Arduino-Version verarbeiten aber 8-Bit. Auch das berücksichtigt nun der Emulator.
+
+**05.03.2013 Version 0.2.1.41**
+
+  * Der Call Befehl springt jetzt auch dahin, wo er hin soll.
+
+**03.10.2012 Version 0.2.1.38**
+
+  * Emulator kann nun auch direkt eine HEX Datei zum Upload erzeugen. Diese liegt im gleichen Verzeichniss wie das TPS Programm und hat die den gleichen Namen, aber die Endung .hex
+
+**25.9.2012 Version 0.2.1.36**
+
+  * Bug beim Push und Pop im Emulator. (Nur ArduinoSPS)
+  * Stackanzeige für Push/Pop A.
+
+**25.9.2012 Version 0.2.1.35**
+
+  * Anzeige der Rücksprungadresse bei Call/Sub.
+  * Automatischer Updatecheck.
+  * Shortcuts für die Buttons. (z.B. fürs Debuggen F8, F9, F5)
+
+**24.9.2012 Version 0.2.1.29**
+
+  * Bug beim Zuweisen der Servos im Bytemodus behoben. (Nur ArduinoSPS)
+  * Wertebereich der Servos im Bytemodus angepasst. 0= 0° und 255= 180°.
+
+**22.9.2012 Version 0.2.1.28**
+
+  * Beim Laden einer neuen Datei wird nun auch der alte Quelltext gelöscht.
+  * Bei Änderungen an der aktuellen Datei und Aufruf des Ladens wird nun gefragt, ob man die Änerungen speichern möchte. (Leider erst nach der Auswahl der zu ladenden Datei…)
+
+**21.9.2012 Version 0.2.1.26**
+
+  * Reset der Eingabewerte (R Button).
+  * Nullwert von RC.# auf 8 geändert.
+
+**20.9.2012 Version 0.2.1.23**
+
+  * Die Taster PRG und SEL fehlten in der Eingabemaske.
+  * Speichern von definierten Eingabewerten möglich. (Einfach rechte Maustaste auf den jeweiligen Button und schon wird das gesamte Eingabeset auf diesen Button gespeichert.)
+
+**20.9.2012 Version 0.2.1.22**
+
+  * Neue Befehle der ArduinoSPS implementiert.
+  * Textfenster nun mit Copyfunktion. (STRG-C)
+  * Kleinere Fixes im Bereich der erweiterten Befehle der ArduinoSPS
+  * Bei der Programmausführung kann nun auch die Aktualisierung des Quelltextfensters abgeschaltet werden. Dadurch wird eine deutlich höhere Ausführungsgeschwindigkeit erreicht.
+
+**20.9.2012 Version 0.2.1.20**
+
+  * Neue Spalte mit der Befehlsbeschreibung. Gespeicherte Programm sind davon unberührt.
+  * Neben der Position wird nun auch die Größe des Programmfensters gespeichert. Ebenso wie die Spaltenbreiten.
+  * Uploadfenster wird jetzt zentriert über dem Programmfenster.
+  * Kleinere Fixes.
+
+**18.9.2012 Version 0.2.1.19**
+
+  * Namensgebung der TPS angepasst. Ausgänge 1..4 und Eingänge 1..4 (statt 0..3) Gespeicherte Programm sind davon völlig unberührt.
+
+**18.9.2012 Version 0.2.1.18**
+
+  * kleinere Bugs behoben.
+  * Wertebereich der ADC und RC Felder erweitert. (Den DIV 16 hab ich da jetzt mal durch einen AND $0F ersetzt, somit werden nun bei den Befehlen 69 Und 6A nur das untere Nibble berücksichtigt.)
+  * HOLTEC Version mit 2. ADC
+
+Vielen Dank an Herrn R.Beesner für das Melden der Bugs.
+
+**18.9.2012 Version 0.2.1.16**
+
+  * kleinere Bugs behoben.
+  * Abfrage beim Verlassen bei geänderter Datei.
+  * Speichknopf speichert bei geladener Datei automatisch.
+  * InfoScreen eingebaut.
+
+**17.9.2012 Version 0.1.1.11**
+
+  * kleinere Bugs behoben.
+  * Upload auf den Arduino eingebaut. (Verwendet die in der Arduino Installation vorhandene AVRDude Versionen)
+
+**14.9.2012 Version 0.1.1.7**
+
+  * kleinere Bugs behoben.
+  * Zeilen löschen und einfügen.
+  * speichert auch die Version des Controllers mit in die Datei.
+  * Implementierung weiterer Funktionen.
+
+**14.9.2012 Version 0.1.1.6**
+
+  * Drag und Drop für Dateien eingeführt. Man kann jetzt aus dem Explorer einfach die zu editierende Datei auf das Programm droppen.
+  * Start mit Datei. Man kann das Programm direkt mit einer Datei starten. Somit ist es jetzt auch möglich, die SPS als Editor für tps-Dateien im Windows Explorer zu setzen.
+  * Button „Neu“ erzeugt eine neue leere Session.
+

+ 4 - 4
SPS_EMU.000

@@ -2,9 +2,9 @@
 LSUTextFile=1
 Copyrigth=MCS Media Computer Software
 [LSUInfo]
-CompileDate=10.11.2018
-CompileTime=23:51:02
+CompileDate=18.11.2018
+CompileTime=10:31:39
 Name=Wilfried Klaas
-LSUBinFile=E:\daten\sourcen\pascal\SPS_TPS_Emulator\SPS_Emu.lsu
-LSUTextFile=E:\daten\sourcen\pascal\SPS_TPS_Emulator\SPS_Emu.
+LSUBinFile=E:\daten\git-sourcen\SPS_Emulator\SPS_Emu.lsu
+LSUTextFile=E:\daten\git-sourcen\SPS_Emulator\SPS_Emu.
 RegString=

+ 8 - 3
SPS_EMU.001

@@ -1,4 +1,3 @@
-
 [LSUOptions]
 LSUTextFile=1
 
@@ -17,6 +16,9 @@ ID_EXEC_NEXT=Next step
 ID_EXEC_STOP=Stop execution
 ID_EXEC_DEBUG=Debug program
 ID_ABOUT=&About
+ID_RESETPRESETS=R
+ID_SAVEPRESETS=S
+ID_LOADPRESETS=L
 
 [form1ButtonHints]
 ID_EXIT=Exit the program
@@ -33,6 +35,9 @@ ID_EXEC_NEXT=Execute the next step
 ID_EXEC_STOP=Stop the debug program execution
 ID_EXEC_DEBUG=Start/stop the program
 ID_ABOUT=About this program
+ID_RESETPRESETS=reset all presets
+ID_SAVEPRESETS=save presets to file
+ID_LOADPRESETS=load presets from file
 
 [infobox]
 ID_APPTITLE=TPS/PLC Emulator
@@ -150,7 +155,7 @@ ID_SPS_STOPPED=PLC stopped
 ID_SPS_PROGRAMMING=programming PLC
 
 [hexfile]
-ID_START_LINE=Addr   BD   Instruction   Data      Comment  
+ID_START_LINE=Addr   BD   Inst.    Data      Comment  
 
 [MessagesMSG]
 ID_MB_WARNINGT=Warning
@@ -165,4 +170,4 @@ ID_COMMENT=Please select the port of the arduino and the path to the arduino ins
 [frmSelectComHints]
 ID_COMPORT=Com Port
 ID_ARDUINO_INST=Arduino installtion
-ID_COMMENT=Comment
+ID_COMMENT=Comment

+ 8 - 3
SPS_EMU.044

@@ -1,4 +1,3 @@
-
 [LSUOptions]
 LSUTextFile=1
 
@@ -17,6 +16,9 @@ ID_EXEC_NEXT=Next step
 ID_EXEC_STOP=Stop debug execution
 ID_EXEC_DEBUG=Start/stop the program
 ID_ABOUT=&About
+ID_RESETPRESETS=R
+ID_SAVEPRESETS=S
+ID_LOADPRESETS=L
 
 [form1ButtonHints]
 ID_EXIT=Exit the program
@@ -33,6 +35,9 @@ ID_EXEC_NEXT=Execute the next step
 ID_EXEC_STOP=Stop the debug program execution
 ID_EXEC_DEBUG=Start/stop the program
 ID_ABOUT=About this program
+ID_RESETPRESETS=reset all presets
+ID_SAVEPRESETS=save presets to file
+ID_LOADPRESETS=load presets from file
 
 [infobox]
 ID_APPTITLE=TPS/PLC Emulator
@@ -150,7 +155,7 @@ ID_SPS_STOPPED=PLC stopped
 ID_SPS_PROGRAMMING=programming PLC
 
 [hexfile]
-ID_START_LINE=Addr   BD   Instruction   Data      Comment  
+ID_START_LINE=Addr   BD   Inst.    Data      Comment  
 
 [MessagesMSG]
 ID_MB_WARNINGT=Warning
@@ -165,4 +170,4 @@ ID_COMMENT=Please select the port of the arduino and the path to the arduino ins
 [frmSelectComHints]
 ID_COMPORT=Com Port
 ID_ARDUINO_INST=Arduino installtion
-ID_COMMENT=Comment
+ID_COMMENT=Comment

+ 9 - 2
SPS_EMU.049

@@ -1,5 +1,4 @@
-
-[LSUOptions]
+[LSUOptions]
 LSUTextFile=1
 
 [form1Buttons]
@@ -17,6 +16,9 @@ ID_EXEC_NEXT=Nächster Schritt
 ID_EXEC_STOP=Debuggen stoppen
 ID_EXEC_DEBUG=Programm starten/stoppen
 ID_ABOUT=&Über
+ID_RESETPRESETS=R
+ID_SAVEPRESETS=S
+ID_LOADPRESETS=L
 
 [form1ButtonHints]
 ID_EXIT=Beenden
@@ -33,6 +35,9 @@ ID_EXEC_NEXT=Nächsten Schritt ausführen
 ID_EXEC_STOP=Debuggen stoppen
 ID_EXEC_DEBUG=Programm starten/stoppen
 ID_ABOUT=Über dieses Programm
+ID_RESETPRESETS=Einstellungen zurücksetzen
+ID_LOADPRESETS=Presets aus Datei laden
+ID_SAVEPRESETS=Presets in Datei speichern
 
 [infobox]
 ID_APPTITLE=TPS/SPS Emulator
@@ -166,3 +171,5 @@ ID_COMMENT=Bitte wählen Sie die Schnittstelle des Arduino und den Ort der Ardui
 ID_COMPORT=
 ID_ARDUINO_INST=
 ID_COMMENT=
+[LSUOptions]
+LSUTextFile=1

+ 3 - 2
SPS_Emu.lpi

@@ -22,7 +22,7 @@
       <AutoIncrementBuild Value="True"/>
       <MinorVersionNr Value="2"/>
       <RevisionNr Value="1"/>
-      <BuildNr Value="50"/>
+      <BuildNr Value="55"/>
       <Language Value="0407"/>
       <StringTable CompanyName="MCS" FileDescription="TPS/SPS Emulator" InternalName="SPS_EMU" LegalCopyright="MCS (C) Wilfried Klaas" OriginalFilename="SPS_EMU.exe" ProductName="TPS/SPS Emulator" ProductVersion="0.2"/>
     </VersionInfo>
@@ -111,7 +111,8 @@
     </Target>
     <SearchPaths>
       <IncludeFiles Value="$(ProjOutDir)"/>
-      <OtherUnitFiles Value="..\Lazarus_lib"/>
+      <Libraries Value="..\Lazarus_Libraries"/>
+      <OtherUnitFiles Value="..\Lazarus_Libraries"/>
       <UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
     </SearchPaths>
     <CodeGeneration>

BIN=BIN
SPS_Emu.lsu


A diferenza do arquivo foi suprimida porque é demasiado grande
+ 0 - 1
SPS_Emu.xml


+ 109 - 63
ugui.lfm

@@ -1,14 +1,14 @@
 object Form1: TForm1
-  Left = 232
-  Height = 549
-  Top = 109
-  Width = 665
+  Left = 235
+  Height = 582
+  Top = 107
+  Width = 691
   AllowDropFiles = True
   Caption = 'SPS Emulator'
-  ClientHeight = 549
-  ClientWidth = 665
-  Constraints.MinHeight = 472
-  Constraints.MinWidth = 620
+  ClientHeight = 582
+  ClientWidth = 691
+  Constraints.MinHeight = 582
+  Constraints.MinWidth = 684
   OnCloseQuery = FormCloseQuery
   OnCreate = FormCreate
   OnDropFiles = FormDropFiles
@@ -16,22 +16,23 @@ object Form1: TForm1
   ShowHint = True
   LCLVersion = '1.8.4.0'
   object Panel1: TPanel
-    Left = 345
-    Height = 500
+    Left = 367
+    Height = 533
     Top = 26
-    Width = 320
+    Width = 324
     Align = alRight
     BevelOuter = bvNone
-    ClientHeight = 500
+    BorderStyle = bsSingle
+    ClientHeight = 529
     ClientWidth = 320
     TabOrder = 0
-    object GroupBox1: TGroupBox
+    object GBOutput: TGroupBox
       Left = 182
-      Height = 291
+      Height = 294
       Top = 5
       Width = 134
       Caption = 'ID_OUTPUT'
-      ClientHeight = 271
+      ClientHeight = 274
       ClientWidth = 130
       TabOrder = 0
       object PWM1: TLabeledEdit
@@ -208,7 +209,7 @@ object Form1: TForm1
         TabOrder = 4
       end
     end
-    object GroupBox2: TGroupBox
+    object GBInput: TGroupBox
       Left = 4
       Height = 294
       Top = 5
@@ -412,20 +413,32 @@ object Form1: TForm1
         end
         object tbReset: TToolButton
           Left = 3
-          Hint = 'EInstellungen zurücksetzen'
+          Hint = 'ID_RESETPRESETS'
           Top = 186
-          Caption = 'R'
+          Caption = 'ID_RESETPRESETS'
           OnClick = tbResetClick
         end
+        object tbPreLoad: TToolButton
+          Left = 3
+          Top = 209
+          Action = acPresetLoad
+          Caption = 'ID_LOADPRESETS'
+        end
+        object tbPreSave: TToolButton
+          Left = 3
+          Top = 232
+          Action = acPresetSave
+          Caption = 'ID_SAVEPRESETS'
+        end
       end
     end
-    object GroupBox3: TGroupBox
-      Left = 8
-      Height = 134
+    object GBInternal: TGroupBox
+      Left = 4
+      Height = 142
       Top = 304
       Width = 312
       Caption = 'ID_INTERNAL_DATA'
-      ClientHeight = 114
+      ClientHeight = 122
       ClientWidth = 308
       TabOrder = 2
       object EditA: TLabeledEdit
@@ -451,7 +464,7 @@ object Form1: TForm1
       object EditC: TLabeledEdit
         Left = 22
         Height = 23
-        Top = 28
+        Top = 32
         Width = 40
         EditLabel.AnchorSideTop.Control = EditC
         EditLabel.AnchorSideTop.Side = asrCenter
@@ -460,7 +473,7 @@ object Form1: TForm1
         EditLabel.AnchorSideBottom.Side = asrBottom
         EditLabel.Left = 11
         EditLabel.Height = 15
-        EditLabel.Top = 32
+        EditLabel.Top = 36
         EditLabel.Width = 8
         EditLabel.Caption = 'C'
         EditLabel.ParentColor = False
@@ -471,7 +484,7 @@ object Form1: TForm1
       object EditE: TLabeledEdit
         Left = 22
         Height = 23
-        Top = 52
+        Top = 60
         Width = 40
         EditLabel.AnchorSideTop.Control = EditE
         EditLabel.AnchorSideTop.Side = asrCenter
@@ -480,7 +493,7 @@ object Form1: TForm1
         EditLabel.AnchorSideBottom.Side = asrBottom
         EditLabel.Left = 13
         EditLabel.Height = 15
-        EditLabel.Top = 56
+        EditLabel.Top = 64
         EditLabel.Width = 6
         EditLabel.Caption = 'E'
         EditLabel.ParentColor = False
@@ -511,7 +524,7 @@ object Form1: TForm1
       object EditD: TLabeledEdit
         Left = 86
         Height = 23
-        Top = 28
+        Top = 32
         Width = 40
         EditLabel.AnchorSideTop.Control = EditD
         EditLabel.AnchorSideTop.Side = asrCenter
@@ -520,7 +533,7 @@ object Form1: TForm1
         EditLabel.AnchorSideBottom.Side = asrBottom
         EditLabel.Left = 75
         EditLabel.Height = 15
-        EditLabel.Top = 32
+        EditLabel.Top = 36
         EditLabel.Width = 8
         EditLabel.Caption = 'D'
         EditLabel.ParentColor = False
@@ -531,7 +544,7 @@ object Form1: TForm1
       object EditF: TLabeledEdit
         Left = 86
         Height = 23
-        Top = 52
+        Top = 60
         Width = 40
         EditLabel.AnchorSideTop.Control = EditF
         EditLabel.AnchorSideTop.Side = asrCenter
@@ -540,7 +553,7 @@ object Form1: TForm1
         EditLabel.AnchorSideBottom.Side = asrBottom
         EditLabel.Left = 77
         EditLabel.Height = 15
-        EditLabel.Top = 56
+        EditLabel.Top = 64
         EditLabel.Width = 6
         EditLabel.Caption = 'F'
         EditLabel.ParentColor = False
@@ -572,7 +585,7 @@ object Form1: TForm1
         Left = 174
         Height = 23
         Hint = 'Rücksprungadresse'
-        Top = 52
+        Top = 60
         Width = 48
         EditLabel.AnchorSideTop.Control = EditRAdr
         EditLabel.AnchorSideTop.Side = asrCenter
@@ -581,7 +594,7 @@ object Form1: TForm1
         EditLabel.AnchorSideBottom.Side = asrBottom
         EditLabel.Left = 145
         EditLabel.Height = 15
-        EditLabel.Top = 56
+        EditLabel.Top = 64
         EditLabel.Width = 26
         EditLabel.Caption = 'RAdr'
         EditLabel.ParentColor = False
@@ -591,16 +604,16 @@ object Form1: TForm1
       end
       object lbStack: TListBox
         Left = 232
-        Height = 64
-        Top = 10
+        Height = 84
+        Top = 32
         Width = 71
         ItemHeight = 0
         TabOrder = 8
       end
       object Label4: TLabel
-        Left = 235
+        Left = 232
         Height = 15
-        Top = -6
+        Top = 8
         Width = 28
         Caption = 'Stack'
         ParentColor = False
@@ -608,7 +621,7 @@ object Form1: TForm1
       object EditDelay: TLabeledEdit
         Left = 174
         Height = 23
-        Top = 76
+        Top = 88
         Width = 48
         EditLabel.AnchorSideTop.Control = EditDelay
         EditLabel.AnchorSideTop.Side = asrCenter
@@ -617,7 +630,7 @@ object Form1: TForm1
         EditLabel.AnchorSideBottom.Side = asrBottom
         EditLabel.Left = 142
         EditLabel.Height = 15
-        EditLabel.Top = 80
+        EditLabel.Top = 92
         EditLabel.Width = 29
         EditLabel.Caption = 'Delay'
         EditLabel.ParentColor = False
@@ -628,7 +641,7 @@ object Form1: TForm1
       object EditPage: TLabeledEdit
         Left = 174
         Height = 23
-        Top = 28
+        Top = 32
         Width = 48
         EditLabel.AnchorSideTop.Control = EditPage
         EditLabel.AnchorSideTop.Side = asrCenter
@@ -637,7 +650,7 @@ object Form1: TForm1
         EditLabel.AnchorSideBottom.Side = asrBottom
         EditLabel.Left = 145
         EditLabel.Height = 15
-        EditLabel.Top = 32
+        EditLabel.Top = 36
         EditLabel.Width = 26
         EditLabel.Caption = 'Page'
         EditLabel.ParentColor = False
@@ -645,14 +658,34 @@ object Form1: TForm1
         ReadOnly = True
         TabOrder = 10
       end
+      object EditJump: TLabeledEdit
+        Left = 86
+        Height = 23
+        Top = 88
+        Width = 40
+        EditLabel.AnchorSideTop.Control = EditJump
+        EditLabel.AnchorSideTop.Side = asrCenter
+        EditLabel.AnchorSideRight.Control = EditJump
+        EditLabel.AnchorSideBottom.Control = EditJump
+        EditLabel.AnchorSideBottom.Side = asrBottom
+        EditLabel.Left = 40
+        EditLabel.Height = 15
+        EditLabel.Top = 92
+        EditLabel.Width = 43
+        EditLabel.Caption = 'Jump to'
+        EditLabel.ParentColor = False
+        LabelPosition = lpLeft
+        ReadOnly = True
+        TabOrder = 11
+      end
     end
-    object GroupBox4: TGroupBox
-      Left = 8
-      Height = 49
-      Top = 438
+    object GBControl: TGroupBox
+      Left = 4
+      Height = 56
+      Top = 456
       Width = 312
       Caption = 'ID_CONTROL'
-      ClientHeight = 29
+      ClientHeight = 36
       ClientWidth = 308
       TabOrder = 3
       object cbAdrActual: TCheckBox
@@ -669,7 +702,7 @@ object Form1: TForm1
     Left = 0
     Height = 26
     Top = 0
-    Width = 665
+    Width = 691
     ButtonHeight = 22
     ButtonWidth = 22
     Caption = 'ToolBar1'
@@ -727,9 +760,8 @@ object Form1: TForm1
       Top = 2
       Width = 125
       ItemHeight = 15
-      ItemIndex = 0
       Items.Strings = (
-        'TPS Holtec'
+        'TPS Holtek'
         'TPS ATMega8'
         'Willies SPS ATTiny84'
         'Willies SPS Arduino'
@@ -737,7 +769,6 @@ object Form1: TForm1
       OnChange = cbTPSVersionChange
       Style = csDropDownList
       TabOrder = 0
-      Text = 'TPS Holtec'
     end
     object Label3: TLabel
       Left = 345
@@ -838,26 +869,26 @@ object Form1: TForm1
   object StatusBar1: TStatusBar
     Left = 0
     Height = 23
-    Top = 526
-    Width = 665
+    Top = 559
+    Width = 691
     Panels = <>
   end
   object Panel2: TPanel
     Left = 0
-    Height = 500
+    Height = 533
     Top = 26
-    Width = 345
+    Width = 367
     Align = alClient
     BevelOuter = bvNone
     Caption = 'Panel2'
-    ClientHeight = 500
-    ClientWidth = 345
+    ClientHeight = 533
+    ClientWidth = 367
     TabOrder = 3
     object StringGrid1: TStringGrid
       Left = 0
-      Height = 466
+      Height = 499
       Top = 0
-      Width = 345
+      Width = 367
       Align = alClient
       Columns = <      
         item
@@ -896,13 +927,13 @@ object Form1: TForm1
     object Panel3: TPanel
       Left = 0
       Height = 34
-      Top = 466
-      Width = 345
+      Top = 499
+      Width = 367
       Align = alBottom
       BevelInner = bvLowered
       BevelOuter = bvNone
       ClientHeight = 34
-      ClientWidth = 345
+      ClientWidth = 367
       TabOrder = 1
       object cbCommand: TComboBox
         Left = 64
@@ -1096,6 +1127,21 @@ object Form1: TForm1
       ImageIndex = 52
       OnExecute = acHexFileExecute
     end
+    object acPresetLoad: TFileOpen
+      Category = 'File'
+      Caption = 'L'
+      Dialog.DefaultExt = '.ini'
+      Dialog.Filter = 'Ini Files|*.ini|all files|*.*'
+      ShortCut = 16463
+      OnAccept = acPresetLoadAccept
+    end
+    object acPresetSave: TFileSaveAs
+      Category = 'File'
+      Caption = 'S'
+      Dialog.DefaultExt = '.ini'
+      Dialog.Filter = 'ini files|*.ini|all files|*.*'
+      OnAccept = acPresetSaveAccept
+    end
   end
   object ImageList1: TImageList
     Height = 20
@@ -5626,15 +5672,15 @@ object Form1: TForm1
   end
   object SaveHexFile: TSaveDialog
     Title = 'ID_SAVE_HEX'
-    DefaultExt = '.tps'
+    DefaultExt = '.hex'
     left = 584
     top = 496
   end
   object ImageList2: TImageList
     Height = 32
     Width = 32
-    left = 627
-    top = 499
+    left = 616
+    top = 496
     Bitmap = {
       4C6969010000200000002000000080804000808040007C7C3EFF484824FF1A1A
       0DFF040402FF040402FF1A1A0DFF484824FF7C7C3EFF80804000808040008080

+ 182 - 53
ugui.pas

@@ -9,7 +9,7 @@ interface
 uses
   Windows, Classes, SysUtils, FileUtil, SdpoSerial, Forms, Controls, Graphics, Dialogs,
   Grids, ExtCtrls, Menus, ComCtrls, ActnList, StdActns, LCLProc, StdCtrls, Spin,
-  XMLPropStorage, uSPS, LCLType, Buttons, types, MCSWINAPI, Math;
+  XMLPropStorage, uSPS, LCLType, Buttons, types, MCSWINAPI, Math, fpjson, jsonparser;
 
 type
 
@@ -36,9 +36,12 @@ type
     cbTPSVersion: TComboBox;
     cbAdrActual: TCheckBox;
     EditDelay: TLabeledEdit;
+    EditJump: TLabeledEdit;
     EditPage: TLabeledEdit;
     EditRAdr: TLabeledEdit;
-    GroupBox4: TGroupBox;
+    acPresetLoad: TFileOpen;
+    acPresetSave: TFileSaveAs;
+    GBControl: TGroupBox;
     ImageList2: TImageList;
     Label3: TLabel;
     Label4: TLabel;
@@ -53,9 +56,9 @@ type
     Din2: TCheckBox;
     Din3: TCheckBox;
     Din4: TCheckBox;
-    GroupBox1: TGroupBox;
-    GroupBox2: TGroupBox;
-    GroupBox3: TGroupBox;
+    GBOutput: TGroupBox;
+    GBInput: TGroupBox;
+    GBInternal: TGroupBox;
     ImageList1: TImageList;
     Label1: TLabel;
     Label10: TLabel;
@@ -94,6 +97,8 @@ type
     StatusBar1: TStatusBar;
     StringGrid1: TStringGrid;
     tbPrg: TToggleBox;
+    tbPreLoad: TToolButton;
+    tbPreSave: TToolButton;
     tbSel: TToggleBox;
     Timer1: TTimer;
     ToolBar1: TToolBar;
@@ -126,6 +131,8 @@ type
     ToolButton7: TToolButton;
     ToolButton8: TToolButton;
     ToolButton9: TToolButton;
+    TOpenDialogPreset: TOpenDialog;
+    TSaveDialogPreset: TSaveDialog;
     XMLPropStorage1: TXMLPropStorage;
     procedure acDeleteRowExecute(Sender: TObject);
     procedure acExitExecute(Sender: TObject);
@@ -137,6 +144,8 @@ type
     procedure acNewExecute(Sender: TObject);
     procedure acNewRowExecute(Sender: TObject);
     procedure acNextStepExecute(Sender: TObject);
+    procedure acPresetLoadAccept(Sender: TObject);
+    procedure acPresetSaveAccept(Sender: TObject);
     procedure acShowHexFileExecute(Sender: TObject);
     procedure acStopExecute(Sender: TObject);
     procedure acThisStepExecute(Sender: TObject);
@@ -155,8 +164,7 @@ type
     procedure StringGrid1EditingDone(Sender: TObject);
     procedure StringGrid1Selection(Sender: TObject; aCol, aRow: integer);
     procedure tbPreset1Click(Sender: TObject);
-    procedure tbPreset1ContextPopup(Sender: TObject; MousePos: TPoint;
-      var Handled: boolean);
+    procedure tbPreset1ContextPopup(Sender: TObject; MousePos: TPoint; var Handled: boolean);
     procedure tbResetClick(Sender: TObject);
     procedure Timer1Timer(Sender: TObject);
   private
@@ -165,6 +173,9 @@ type
     stopit: boolean;
     activeFile: string;
     dirty: boolean;
+    procedure saveSection(filename: string; key: string);
+    procedure loadSection(filename: string; key: string);
+
     procedure loadFile(filename: string);
     procedure programSps;
     procedure nextStep;
@@ -180,6 +191,9 @@ type
     procedure makeHexFile(fileName: string);
     procedure setCaption;
     procedure addHeaderText;
+    procedure loadPreset(filename: string);
+    procedure savePreset(filename: string);
+    procedure activateSps(enable: boolean);
   public
     { public declarations }
   end;
@@ -190,7 +204,7 @@ var
 implementation
 
 uses MCSAbout, uTextUi, uSelectCom, MCSTools, MCSStrings, synaser,
-  MCSIO, mcsintelhex, fpjson, MCSLSU;
+  MCSIO, mcsintelhex, MCSLSU, MCSIniFiles;
 
 {$R *.lfm}
 
@@ -231,6 +245,7 @@ begin
     line := Application.Params[1];
     loadFile(line);
   end;
+  activateSps(False);
   Timer1.Enabled := True;
   MCSLSU.MakeForm('form1', 'ID_', form1);
 end;
@@ -396,8 +411,8 @@ begin
     begin
       if (StringGrid1.Cells[1, x] <> '') then
       begin
-        line := StringGrid1.Cells[0, x] + ',' + StringGrid1.Cells[1, x] +
-          ',' + StringGrid1.Cells[2, x] + ',"' + StringGrid1.Cells[4, x] + '"';
+        line := StringGrid1.Cells[0, x] + ',' + StringGrid1.Cells[1, x] + ',' +
+          StringGrid1.Cells[2, x] + ',"' + StringGrid1.Cells[4, x] + '"';
         Writeln(f, line);
       end;
     end;
@@ -412,12 +427,11 @@ procedure TForm1.acDebugExecute(Sender: TObject);
 begin
   if (sps.isActive()) then
   begin
-    stopit := True;
-    acDebug.ImageIndex := 18;
-    sps.break();
+    acStopExecute(Sender);
   end
   else
   begin
+    activateSps(True);
     acDebug.Enabled := True;
     acDebug.ImageIndex := 10;
     cbAdrActual.Enabled := True;
@@ -465,33 +479,43 @@ end;
 
 procedure TForm1.acNewExecute(Sender: TObject);
 begin
-  StringGrid1.RowCount := 2;
-  StringGrid1.Clean;
-  addHeaderText();
-  renumberGrid();
-  activeFile := '';
-  setCaption();
-  setDirty(False);
+  if (checkDirty()) then
+  begin
+    StringGrid1.RowCount := 2;
+    StringGrid1.Clean;
+    addHeaderText();
+    renumberGrid();
+    activeFile := '';
+    setCaption();
+    setDirty(False);
+  end;
 end;
 
 procedure TForm1.acNewRowExecute(Sender: TObject);
 var
   myPos: integer;
   i, x: integer;
+  eot: boolean;
 begin
+  eot := False;
   myPos := StringGrid1.Row;
+  if (myPos = StringGrid1.RowCount - 1) then
+    eot := True;
   StringGrid1.RowCount := StringGrid1.RowCount + 1;
-  for i := StringGrid1.RowCount - 2 downto myPos do
+  if (not eot) then
   begin
+    for i := StringGrid1.RowCount - 2 downto myPos do
+    begin
+      for x := 1 to StringGrid1.ColCount - 1 do
+      begin
+        StringGrid1.Cells[x, i + 1] := StringGrid1.Cells[x, i];
+      end;
+    end;
     for x := 1 to StringGrid1.ColCount - 1 do
     begin
-      StringGrid1.Cells[x, i + 1] := StringGrid1.Cells[x, i];
+      StringGrid1.Cells[x, myPos] := '';
     end;
   end;
-  for x := 1 to StringGrid1.ColCount - 1 do
-  begin
-    StringGrid1.Cells[x, myPos] := '';
-  end;
   renumberGrid();
 end;
 
@@ -528,10 +552,27 @@ begin
   selectAddress(sps.getAddress());
 end;
 
+procedure TForm1.acPresetLoadAccept(Sender: TObject);
+var
+  filename: string;
+begin
+  filename := (Sender as TFileOpen).Dialog.FileName;
+  loadPreset(filename);
+end;
+
+procedure TForm1.acPresetSaveAccept(Sender: TObject);
+var
+  filename: string;
+begin
+  filename := (Sender as TFileSaveAs).Dialog.FileName;
+  savePreset(filename);
+end;
+
 procedure TForm1.nextStep;
 begin
   if (not sps.isActive()) then
   begin
+    activateSps(True);
     programSps;
     sps.start();
     acStop.Enabled := True;
@@ -628,8 +669,7 @@ begin
         tmp := tmp + '0';
       line := line + tmp;
 
-      line := line + '      ' + StringGrid1.Cells[3, x] + '   ,"' +
-        StringGrid1.Cells[4, x] + '"';
+      line := line + '      ' + StringGrid1.Cells[3, x] + '   ,"' + StringGrid1.Cells[4, x] + '"';
       list.add(line);
     end;
   end;
@@ -640,10 +680,12 @@ end;
 
 procedure TForm1.acStopExecute(Sender: TObject);
 begin
+
   if (sps.isActive()) then
   begin
     stopit := True;
     sps.break();
+    acDebug.ImageIndex := 18;
     repeat
       Application.ProcessMessages;
     until (not sps.isDelayActive());
@@ -652,6 +694,7 @@ begin
     acDebug.Enabled := True;
     outputSps();
     selectAddress(0);
+    activateSps(False);
   end;
 end;
 
@@ -721,8 +764,7 @@ begin
     begin
       KeyName := 'SOFTWARE\WOW6432Node\Arduino';
       StringValue := 'Install_Dir';
-      Res := RegistryReadString(HKEY_LOCAL_MACHINE, WideString(KeyName),
-        WideString(StringValue));
+      Res := RegistryReadString(HKEY_LOCAL_MACHINE, WideString(KeyName), WideString(StringValue));
       if Res <> '' then
       begin
         line := string(Res);
@@ -808,8 +850,7 @@ var
 begin
   if (dirty) then
   begin
-    i := MCSLSU.LSUAutoMsgBox('Messages', 'SAVE_CHANGES', MB_ICONQUESTION or
-      MB_YESNOCANCEL);
+    i := MCSLSU.LSUAutoMsgBox('Messages', 'SAVE_CHANGES', MB_ICONQUESTION or MB_YESNOCANCEL);
     if (i = mrYes) then
     begin
       saveFile(activeFile);
@@ -834,21 +875,37 @@ end;
 procedure TForm1.checkPresets;
 begin
   if XMLPropStorage1.ReadBoolean('preset_1.set', False) then
-    tbPreset1.Caption := '1*';
+    tbPreset1.Caption := '1*'
+  else
+    tbPreset1.Caption := '1';
   if XMLPropStorage1.ReadBoolean('preset_2.set', False) then
-    tbPreset2.Caption := '2*';
+    tbPreset2.Caption := '2*'
+  else
+    tbPreset2.Caption := '2';
   if XMLPropStorage1.ReadBoolean('preset_3.set', False) then
-    tbPreset3.Caption := '3*';
+    tbPreset3.Caption := '3*'
+  else
+    tbPreset3.Caption := '3';
   if XMLPropStorage1.ReadBoolean('preset_4.set', False) then
-    tbPreset4.Caption := '4*';
+    tbPreset4.Caption := '4*'
+  else
+    tbPreset4.Caption := '4';
   if XMLPropStorage1.ReadBoolean('preset_5.set', False) then
-    tbPreset5.Caption := '5*';
+    tbPreset5.Caption := '5*'
+  else
+    tbPreset5.Caption := '5';
   if XMLPropStorage1.ReadBoolean('preset_6.set', False) then
-    tbPreset6.Caption := '6*';
+    tbPreset6.Caption := '6*'
+  else
+    tbPreset6.Caption := '6';
   if XMLPropStorage1.ReadBoolean('preset_7.set', False) then
-    tbPreset7.Caption := '7*';
+    tbPreset7.Caption := '7*'
+  else
+    tbPreset7.Caption := '7';
   if XMLPropStorage1.ReadBoolean('preset_8.set', False) then
-    tbPreset8.Caption := '8*';
+    tbPreset7.Caption := '8*'
+  else
+    tbPreset7.Caption := '8';
 end;
 
 procedure TForm1.makeHexFile(fileName: string);
@@ -893,8 +950,7 @@ begin
   end
   else
   begin
-    Caption := MCSLSU.GetLSUText('form1Captions', 'ID_CAPTION', lsuCode) +
-      ':' + ExtractFileName(activeFile);
+    Caption := MCSLSU.GetLSUText('form1Captions', 'ID_CAPTION', lsuCode) + ':' + ExtractFileName(activeFile);
   end;
 
 end;
@@ -909,8 +965,7 @@ begin
     StringGrid1.Columns[i].Title.Caption :=
       MCSLSU.GetLSUText('form1Captions', StringGrid1.Columns[i].Title.Caption, lsuCode);
   end;
-  StringGrid1.Cells[0, 0] := MCSLSU.GetLSUText('form1Captions',
-    'ID_GRID_STORAGE', lsuCode);
+  StringGrid1.Cells[0, 0] := MCSLSU.GetLSUText('form1Captions', 'ID_GRID_STORAGE', lsuCode);
   StringGrid1.Repaint;
 end;
 
@@ -944,7 +999,7 @@ begin
   if (cbTPSVersion.ItemIndex = 0) then
   begin
     // HOLTEC
-    sps.setTPSVersion(Holtec);
+    sps.setTPSVersion(Holtek);
 
     Label2.Visible := True;
     ADC2.Visible := True;
@@ -1050,8 +1105,7 @@ begin
   begin
     x := StringGrid1.Row;
     StringGrid1.Cells[3, x] :=
-      sps.getCommandText(HexToInt(StringGrid1.Cells[1, x]),
-      HexToInt(StringGrid1.Cells[2, x]));
+      sps.getCommandText(HexToInt(StringGrid1.Cells[1, x]), HexToInt(StringGrid1.Cells[2, x]));
     setDirty(True);
   end;
 end;
@@ -1066,6 +1120,69 @@ begin
   end;
 end;
 
+procedure TForm1.loadPreset(filename: string);
+var
+  x: integer;
+  key: string;
+begin
+  for x := 1 to 8 do
+  begin
+    key := 'preset_' + IntToStr(x);
+    loadSection(filename, key);
+  end;
+  checkPresets;
+end;
+
+procedure TForm1.savePreset(filename: string);
+var
+  x: integer;
+  key: string;
+begin
+  for x := 1 to 8 do
+  begin
+    key := 'preset_' + IntToStr(x);
+    saveSection(filename, key);
+  end;
+end;
+
+procedure TForm1.activateSps(enable: boolean);
+begin
+  GBControl.Enabled := enable;
+  GBInternal.Enabled := enable;
+  GBOutput.Enabled := enable;
+  ;
+end;
+
+procedure TForm1.saveSection(filename: string; key: string);
+begin
+  WriteIniBool(key, 'set', XMLPropStorage1.ReadBoolean(key + '.set', False), filename);
+  WriteIniBool(key, 'prg', XMLPropStorage1.ReadBoolean(key + '.prg', False), filename);
+  WriteIniBool(key, 'sel', XMLPropStorage1.ReadBoolean(key + '.sel', False), filename);
+  WriteIniBool(key, 'input1', XMLPropStorage1.ReadBoolean(key + '.input1', False), filename);
+  WriteIniBool(key, 'input2', XMLPropStorage1.ReadBoolean(key + '.input2', False), filename);
+  WriteIniBool(key, 'input3', XMLPropStorage1.ReadBoolean(key + '.input3', False), filename);
+  WriteIniBool(key, 'input4', XMLPropStorage1.ReadBoolean(key + '.input4', False), filename);
+  WriteIniInteger(key, 'adc1', XMLPropStorage1.ReadInteger(key + '.adc1', 0), filename);
+  WriteIniInteger(key, 'adc2', XMLPropStorage1.ReadInteger(key + '.adc2', 0), filename);
+  WriteIniInteger(key, 'rc1', XMLPropStorage1.ReadInteger(key + '.rc1', 0), filename);
+  WriteIniInteger(key, 'rc2', XMLPropStorage1.ReadInteger(key + '.rc2', 0), filename);
+end;
+
+procedure TForm1.loadSection(filename: string; key: string);
+begin
+  XMLPropStorage1.WriteBoolean(key + '.set', ReadIniBool(key, 'set', False, filename));
+  XMLPropStorage1.WriteBoolean(key + '.prg', ReadIniBool(key, 'prg', False, filename));
+  XMLPropStorage1.WriteBoolean(key + '.sel', ReadIniBool(key, 'sel', False, filename));
+  XMLPropStorage1.WriteBoolean(key + '.input1', ReadIniBool(key, 'input1', False, filename));
+  XMLPropStorage1.WriteBoolean(key + '.input2', ReadIniBool(key, 'input2', False, filename));
+  XMLPropStorage1.WriteBoolean(key + '.input3', ReadIniBool(key, 'input3', False, filename));
+  XMLPropStorage1.WriteBoolean(key + '.input4', ReadIniBool(key, 'input4', False, filename));
+  XMLPropStorage1.WriteInteger(key + '.adc1', ReadIniInteger(key, 'adc1', 0, filename));
+  XMLPropStorage1.WriteInteger(key + '.adc2', ReadIniInteger(key, 'adc2', 0, filename));
+  XMLPropStorage1.WriteInteger(key + '.rc1', ReadIniInteger(key, 'rc1', 0, filename));
+  XMLPropStorage1.WriteInteger(key + '.rc2', ReadIniInteger(key, 'rc2', 0, filename));
+end;
+
 procedure TForm1.tbPreset1Click(Sender: TObject);
 var
   key: string;
@@ -1094,6 +1211,8 @@ begin
   if Sender = tbPreset8 then
     key := 'preset_8';
 
+  tbSel.Checked := XMLPropStorage1.ReadBoolean(key + '.prg', tbSel.Checked);
+  tbPrg.Checked := XMLPropStorage1.ReadBoolean(key + '.sel', tbPrg.Checked);
   Din1.Checked := XMLPropStorage1.ReadBoolean(key + '.input1', Din1.Checked);
   Din2.Checked := XMLPropStorage1.ReadBoolean(key + '.input2', Din2.Checked);
   Din3.Checked := XMLPropStorage1.ReadBoolean(key + '.input3', Din3.Checked);
@@ -1104,8 +1223,7 @@ begin
   RC2.Value := XMLPropStorage1.ReadInteger(key + '.rc2', RC2.Value);
 end;
 
-procedure TForm1.tbPreset1ContextPopup(Sender: TObject; MousePos: TPoint;
-  var Handled: boolean);
+procedure TForm1.tbPreset1ContextPopup(Sender: TObject; MousePos: TPoint; var Handled: boolean);
 var
   key: string;
 begin
@@ -1134,6 +1252,8 @@ begin
     key := 'preset_8';
 
   XMLPropStorage1.WriteBoolean(key + '.set', True);
+  XMLPropStorage1.WriteBoolean(key + '.prg', tbPrg.Checked);
+  XMLPropStorage1.WriteBoolean(key + '.sel', tbSel.Checked);
   XMLPropStorage1.WriteBoolean(key + '.input1', Din1.Checked);
   XMLPropStorage1.WriteBoolean(key + '.input2', Din2.Checked);
   XMLPropStorage1.WriteBoolean(key + '.input3', Din3.Checked);
@@ -1147,6 +1267,8 @@ end;
 
 procedure TForm1.tbResetClick(Sender: TObject);
 begin
+  tbPrg.Checked := False;
+  tbSel.Checked := False;
   Din1.Checked := False;
   Din2.Checked := False;
   Din3.Checked := False;
@@ -1171,8 +1293,8 @@ begin
   if (InfoBox.newVersion) then
   begin
     MCSLabel.Font.Color := clred;
-    MCSLabel.Hint := InfoBox.versionHint + chr($0a) + chr($0d) +
-      MCSLSU.GetLSUText('form1Captions', 'ID_CLICK_HERE', lsuCode);
+    MCSLabel.Hint := InfoBox.versionHint + chr($0a) + chr($0d) + MCSLSU.GetLSUText(
+      'form1Captions', 'ID_CLICK_HERE', lsuCode);
   end;
   MCSLabel.Caption := InfoBox.versionText;
 end;
@@ -1185,9 +1307,12 @@ begin
   for x := 1 to i - 1 do
   begin
     StringGrid1.Cells[0, x] := '0x' + inttohex(x - 1, 2);
+    if (StringGrid1.Cells[1, x] = '') then
+      StringGrid1.Cells[1, x] := '0';
+    if (StringGrid1.Cells[2, x] = '') then
+      StringGrid1.Cells[2, x] := '0';
     StringGrid1.Cells[3, x] :=
-      sps.getCommandText(HexToInt(StringGrid1.Cells[1, x]),
-      HexToInt(StringGrid1.Cells[2, x]));
+      sps.getCommandText(HexToInt(StringGrid1.Cells[1, x]), HexToInt(StringGrid1.Cells[2, x]));
   end;
 end;
 
@@ -1248,6 +1373,10 @@ begin
   EditAddr.Text := '0x' + IntToHex(sps.getAddress(), 2);
   EditRAdr.Text := '0x' + IntToHex(sps.getRAdr(), 2);
   EditPage.Text := '0x' + IntToHex(sps.getPage(), 2);
+  if (sps.getJump() > 0) then
+    EditJump.Text := '0x' + IntToHex(sps.getJump(), 2)
+  else
+    EditJump.Text := '';
   if (sps.getTone() > 0) then
   begin
     ImageList2.GetBitmap(23, btnTone.Glyph);

+ 88 - 10
usps.pas

@@ -135,7 +135,7 @@ const
 type
   {TPSVersion}
 
-  TTPSVersion = (Holtec, ATMega8, ATTiny84, Arduino);
+  TTPSVersion = (Holtek, ATMega8, ATTiny84, Arduino);
 
   { TServo }
 
@@ -177,6 +177,7 @@ type
     eeprom: array[0..255] of byte;
     adrPage: byte;
     addr: word;
+    jumpAddr: word;
     a, b, c, d, e, f: byte;
 
     servo1, servo2: TServo;
@@ -242,6 +243,7 @@ type
     procedure start();
     procedure break();
     procedure doSingleCommand(command: byte);
+    procedure preFetch();
 
     procedure writeEEProm(adr: byte; Data: byte);
 
@@ -265,6 +267,9 @@ type
     procedure getDatas(cmd: byte; list: TStrings);
 
     function getCommandText(cmd, Data: byte): string;
+
+    function getJump(): byte;
+
   end;
 
 
@@ -411,6 +416,7 @@ begin
   begin
     doReset();
   end;
+  preFetch();
 end;
 
 procedure TSPS.doReset();
@@ -514,6 +520,73 @@ begin
   end;
 end;
 
+procedure TSPS.preFetch();
+var
+  cmd, Data: byte;
+  skip: boolean;
+begin
+  jumpAddr := 0;
+  skip := False;
+  cmd := eeprom[addr];
+  Data := (cmd and $0F);
+  cmd := (cmd and $F0);
+  case cmd of
+    C_COUNT:
+    begin
+      if (c > 0) then
+        jumpAddr := Data + 16 * Page;
+    end;
+    D_COUNT:
+    begin
+      if (d > 0) then
+        jumpAddr := Data + 16 * Page;
+    end;
+    JUMP_BACK: jumpAddr := addr - Data;
+    JUMP: jumpAddr := Data + 16 * Page;
+    SKIP_IF:
+    begin
+      case Data of
+        0: if (a = 0) then
+            case version of
+              ATTiny84, Arduino: skip := True;
+            end;
+        1: if (a > b) then
+            skip := True;
+        2: if (a < b) then
+            skip := True;
+        3: if (a = b) then
+            skip := True;
+        4: if (din1) then
+            skip := True;
+        5: if (din2) then
+            skip := True;
+        6: if (din3) then
+            skip := True;
+        7: if (din4) then
+            skip := True;
+        8: if (not din1) then
+            skip := True;
+        9: if (not din2) then
+            skip := True;
+        10: if (not din3) then
+            skip := True;
+        11: if (not din4) then
+            skip := True;
+        12: if (sw_sel) then
+            skip := True;
+        13: if (sw_prg) then
+            skip := True;
+        14: if (not sw_sel) then
+            skip := True;
+        15: if (not sw_prg) then
+            skip := True;
+      end;
+      if (skip = True) then
+        jumpAddr := addr + 2;
+    end;
+  end;
+end;
+
 procedure TSPS.writeEEProm(adr: byte; Data: byte);
 begin
   eeprom[adr] := Data;
@@ -603,7 +676,7 @@ begin
   if (cmd = 0) then
   begin
     case version of
-      Holtec, ATMega8: MCSStrings.copyArray2List(O_LIST_H, list);
+      Holtek, ATMega8: MCSStrings.copyArray2List(O_LIST_H, list);
       ATTiny84, Arduino: MCSStrings.copyArray2List(O_LIST_AT, list);
     end;
   end;
@@ -620,7 +693,7 @@ begin
   if (cmd = 5) then
   begin
     case version of
-      Holtec: MCSStrings.copyArray2List(IS_A_LIST_H, list);
+      Holtek: MCSStrings.copyArray2List(IS_A_LIST_H, list);
       ATMega8: MCSStrings.copyArray2List(IS_A_LIST_A8, list);
       ATTiny84, Arduino: MCSStrings.copyArray2List(IS_A_LIST_AT, list);
     end;
@@ -628,7 +701,7 @@ begin
   if (cmd = 6) then
   begin
     case version of
-      Holtec: MCSStrings.copyArray2List(A_IS_LIST_H, list);
+      Holtek: MCSStrings.copyArray2List(A_IS_LIST_H, list);
       ATMega8: MCSStrings.copyArray2List(A_IS_LIST_A8, list);
       ATTiny84, Arduino: MCSStrings.copyArray2List(A_IS_LIST_AT, list);
     end;
@@ -636,14 +709,14 @@ begin
   if (cmd = 7) then
   begin
     case version of
-      Holtec, ATMega8: MCSStrings.copyArray2List(A_CALC_LIST_H, list);
+      Holtek, ATMega8: MCSStrings.copyArray2List(A_CALC_LIST_H, list);
       ATTiny84, Arduino: MCSStrings.copyArray2List(A_CALC_LIST_AT, list);
     end;
   end;
   if (cmd = 8) then
   begin
     case version of
-      Holtec, ATMega8: MCSStrings.copyArray2List(PAGE_LIST_H, list);
+      Holtek, ATMega8: MCSStrings.copyArray2List(PAGE_LIST_H, list);
       ATTiny84, Arduino: MCSStrings.copyArray2List(PAGE_LIST_AT, list);
     end;
   end;
@@ -656,7 +729,7 @@ begin
   if (cmd = 12) then
   begin
     case version of
-      Holtec: MCSStrings.copyArray2List(SKIP_LIST_H, list);
+      Holtek: MCSStrings.copyArray2List(SKIP_LIST_H, list);
       ATMega8: MCSStrings.copyArray2List(SKIP_LIST_A8, list);
       ATTiny84, Arduino: MCSStrings.copyArray2List(SKIP_LIST_AT, list);
     end;
@@ -666,14 +739,14 @@ begin
   if (cmd = 14) then
   begin
     case version of
-      Holtec, ATMega8: MCSStrings.copyArray2List(RET_LIST_H, list);
+      Holtek, ATMega8: MCSStrings.copyArray2List(RET_LIST_H, list);
       ATTiny84, Arduino: MCSStrings.copyArray2List(RET_LIST_AT, list);
     end;
   end;
   if (cmd = 15) then
   begin
     case version of
-      Holtec, ATMega8: MCSStrings.copyArray2List(F_LIST_H, list);
+      Holtek, ATMega8: MCSStrings.copyArray2List(F_LIST_H, list);
       ATTiny84, Arduino: MCSStrings.copyArray2List(F_LIST_AT, list);
     end;
   end;
@@ -695,6 +768,11 @@ begin
   Result := line;
 end;
 
+function TSPS.getJump(): byte;
+begin
+  Result := jumpAddr;
+end;
+
 procedure TSPS.doNull(Data: byte);
 begin
   // Do nothing
@@ -868,7 +946,7 @@ begin
       end;
   end;
   case version of
-    Holtec, ATMega8: a := a and 15;
+    Holtek, ATMega8: a := a and 15;
   end;
 end;
 

Algúns arquivos non se mostraron porque demasiados arquivos cambiaron neste cambio