Răsfoiți Sursa

Bug: Jump to illegal address will lead into deactivating the stop button, if the emulator is running. Now the emulator will stop and show a error message.

Wilfried Klaas 3 ani în urmă
părinte
comite
b94b7d5e45
6 a modificat fișierele cu 124 adăugiri și 58 ștergeri
  1. 9 1
      README.md
  2. 2 2
      SPS_EMU.000
  3. 1 1
      SPS_Emu.lpi
  4. BIN
      SPS_Emu.lsu
  5. 100 53
      ugui.pas
  6. 12 1
      usps.pas

+ 9 - 1
README.md

@@ -1,4 +1,13 @@
 # **SPS_Emulator Version History**
+**15.05.2021 Version 0.2.1.88**
+
+  * Bug: BBC micro:bit V2 wrong images will be displayed on image > 1 (only a little offset of 1)
+  * Bug: Jump to illegal address will lead into deactivating the stop button, if the emulator is running. Now the emulator will stop and show a error message. 
+
+**09.05.2021 Version 0.2.1.85**
+
+  * Feature: automatic upload for BBC micro:bit V2 via serial connection. Now you don't have to put the mb into programming mode anymore. Simply click on the upload button.
+
 **08.04.2021 Version 0.2.1.80**
 
   * Feature: upload activating for BBC micro:bit V2 via serial connection. 
@@ -58,7 +67,6 @@
   * 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**
 

+ 2 - 2
SPS_EMU.000

@@ -2,8 +2,8 @@
 LSUTextFile=1
 Copyrigth=MCS Media Computer Software
 [LSUInfo]
-CompileDate=14.05.2021
-CompileTime=13:13:11
+CompileDate=15.05.2021
+CompileTime=10:36:14
 Name=Wilfried Klaas
 LSUBinFile=C:\e-platte\daten\git-sourcen\SPS_Emulator\SPS_Emu.lsu
 LSUTextFile=C:\e-platte\daten\git-sourcen\SPS_Emulator\SPS_Emu.

+ 1 - 1
SPS_Emu.lpi

@@ -22,7 +22,7 @@
       <AutoIncrementBuild Value="True"/>
       <MinorVersionNr Value="2"/>
       <RevisionNr Value="1"/>
-      <BuildNr Value="87"/>
+      <BuildNr Value="88"/>
       <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>

BIN
SPS_Emu.lsu


+ 100 - 53
ugui.pas

@@ -178,7 +178,8 @@ 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 tbPrgChange(Sender: TObject);
     procedure tbResetClick(Sender: TObject);
     procedure tbSelChange(Sender: TObject);
@@ -193,6 +194,7 @@ type
     dirty: boolean;
     lastNote: byte;
     Examples: TStringList;
+    procedure doStopExecute();
     procedure initMidi;
     procedure playNote(note: byte);
     procedure loadFromList(Lines: TStringList; filename: string);
@@ -202,7 +204,7 @@ type
 
     procedure loadFile(filename: string);
     procedure programSps;
-    procedure nextStep;
+    procedure nextStep(singleStep: boolean);
     procedure renumberGrid;
     procedure saveFile(filename: string);
     procedure selectAddress(addr: byte);
@@ -619,8 +621,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;
@@ -655,12 +657,20 @@ begin
     Statusbar1.SimpleText := MCSLSU.GetLSUText('statusbar', 'ID_SPS_RUNNING', lsuCode);
     while (not stopit) do
     begin
-      nextStep();
+      nextStep(False);
+      if not sps.isActive() then
+      begin
+        stopit := True;
+        doStopExecute(); // error in sps
+      end;
       if (cbAdrActual.Checked) then
         selectAddress(sps.getAddress());
       Application.ProcessMessages;
     end;
-    Statusbar1.SimpleText := MCSLSU.GetLSUText('statusbar', 'ID_SPS_STOPPED', lsuCode);
+    if sps.getLastError() <> '' then
+      MyMsgBox(sps.getLastError(), 'Error', MB_OK + MB_ICONERROR)
+    else
+      Statusbar1.SimpleText := MCSLSU.GetLSUText('statusbar', 'ID_SPS_STOPPED', lsuCode);
     cbAdrActual.Enabled := False;
     acNextStep.Enabled := True;
     sps.doReset();
@@ -767,7 +777,7 @@ end;
 
 procedure TForm1.acNextStepExecute(Sender: TObject);
 begin
-  nextStep();
+  nextStep(True);
   selectAddress(sps.getAddress());
 end;
 
@@ -787,7 +797,7 @@ begin
   savePreset(filename);
 end;
 
-procedure TForm1.nextStep;
+procedure TForm1.nextStep(singleStep: boolean);
 begin
   if (not sps.isActive()) then
   begin
@@ -800,14 +810,14 @@ begin
   else
   begin
     acNextStep.Enabled := False;
-    acStop.Enabled := False;
+    acStop.Enabled := not singleStep;
     inputMicrobit();
     inputSps();
     sps.nextStep();
     outputSps();
     outputMicrobit();
-    acNextStep.Enabled := True;
-    acStop.Enabled := True;
+    acNextStep.Enabled := singleStep;
+    acStop.Enabled := not singleStep;
   end;
 end;
 
@@ -890,7 +900,8 @@ 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;
@@ -901,24 +912,28 @@ end;
 
 procedure TForm1.acStopExecute(Sender: TObject);
 begin
-
   if (sps.isActive()) then
   begin
     stopit := True;
     sps.break();
-    acDebug.ImageIndex := 40;
-    //   repeat
-    //     Application.ProcessMessages;
-    //   until (not sps.isDelayActive());
-    sps.doReset();
-    acStop.Enabled := False;
-    acDebug.Enabled := True;
-    outputSps();
-    selectAddress(0);
-    activateSps(False);
+    doStopExecute();
   end;
 end;
 
+procedure TForm1.doStopExecute();
+begin
+  acDebug.ImageIndex := 40;
+  //   repeat
+  //     Application.ProcessMessages;
+  //   until (not sps.isDelayActive());
+  sps.doReset();
+  acStop.Enabled := False;
+  acDebug.Enabled := True;
+  outputSps();
+  selectAddress(0);
+  activateSps(False);
+end;
+
 procedure TForm1.acThisStepExecute(Sender: TObject);
 var
   Data, com: byte;
@@ -1023,12 +1038,12 @@ begin
       if (return = mrOk) then
       begin
         hexFile := serialUpload;
-        SdpoSerial1.BaudRate:= br__9600;
+        SdpoSerial1.BaudRate := br__9600;
 
         if cbTPSVersion.ItemIndex = 5 then
         begin
           // Micro:bit V2 auto programm
-          SdpoSerial1.BaudRate:= br115200;
+          SdpoSerial1.BaudRate := br115200;
         end;
 
         SdpoSerial1.Device := comService;
@@ -1124,7 +1139,8 @@ 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);
@@ -1254,7 +1270,8 @@ begin
   end
   else
   begin
-    Caption := MCSLSU.GetLSUText('form1Captions', 'ID_CAPTION', lsuCode) + ':' + ExtractFileName(activeFile);
+    Caption := MCSLSU.GetLSUText('form1Captions', 'ID_CAPTION', lsuCode) +
+      ':' + ExtractFileName(activeFile);
   end;
 
 end;
@@ -1269,7 +1286,8 @@ 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;
 
@@ -1462,6 +1480,14 @@ end;
 procedure TForm1.FormCloseQuery(Sender: TObject; var CanClose: boolean);
 begin
   canClose := checkDirty();
+  if canClose then
+  begin
+    if (sps.isActive()) then
+    begin
+      acStopExecute(Sender);
+    end;
+
+  end;
 end;
 
 procedure TForm1.StringGrid1EditingDone(Sender: TObject);
@@ -1486,7 +1512,8 @@ 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;
@@ -1593,10 +1620,13 @@ begin
   WriteIniInteger(key, 'accx', XMLPropStorage1.ReadInteger(key + '.accx', 0), filename);
   WriteIniInteger(key, 'accy', XMLPropStorage1.ReadInteger(key + '.accy', 0), filename);
   WriteIniInteger(key, 'accz', XMLPropStorage1.ReadInteger(key + '.accz', 0), filename);
-  WriteIniInteger(key, 'sound', XMLPropStorage1.ReadInteger(key + '.sound', 0), filename);
-  WriteIniInteger(key, 'light', XMLPropStorage1.ReadInteger(key + '.light', 0), filename);
+  WriteIniInteger(key, 'sound', XMLPropStorage1.ReadInteger(key + '.sound', 0),
+    filename);
+  WriteIniInteger(key, 'light', XMLPropStorage1.ReadInteger(key + '.light', 0),
+    filename);
   WriteIniInteger(key, 'comp', XMLPropStorage1.ReadInteger(key + '.comp', 0), filename);
-  WriteIniInteger(key, 'gesture', XMLPropStorage1.ReadInteger(key + '.gesture', 0), filename);
+  WriteIniInteger(key, 'gesture', XMLPropStorage1.ReadInteger(key +
+    '.gesture', 0), filename);
 end;
 
 procedure TForm1.loadSection(filename: string; key: string);
@@ -1604,10 +1634,14 @@ 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.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));
@@ -1617,10 +1651,13 @@ begin
   XMLPropStorage1.WriteInteger(key + '.accx', ReadIniInteger(key, 'accx', 0, filename));
   XMLPropStorage1.WriteInteger(key + '.accy', ReadIniInteger(key, 'accy', 0, filename));
   XMLPropStorage1.WriteInteger(key + '.accz', ReadIniInteger(key, 'accz', 0, filename));
-  XMLPropStorage1.WriteInteger(key + '.sound', ReadIniInteger(key, 'sound', 0, filename));
-  XMLPropStorage1.WriteInteger(key + '.light', ReadIniInteger(key, 'light', 0, filename));
+  XMLPropStorage1.WriteInteger(key + '.sound', ReadIniInteger(key,
+    'sound', 0, filename));
+  XMLPropStorage1.WriteInteger(key + '.light', ReadIniInteger(key,
+    'light', 0, filename));
   XMLPropStorage1.WriteInteger(key + '.comp', ReadIniInteger(key, 'comp', 0, filename));
-  XMLPropStorage1.WriteInteger(key + '.gesture', ReadIniInteger(key, 'gesture', 0, filename));
+  XMLPropStorage1.WriteInteger(key + '.gesture', ReadIniInteger(key,
+    'gesture', 0, filename));
 end;
 
 procedure TForm1.tbPreset1Click(Sender: TObject);
@@ -1661,17 +1698,26 @@ begin
   ADC2.Value := XMLPropStorage1.ReadInteger(key + '.adc2', ADC2.Value);
   RC1.Value := XMLPropStorage1.ReadInteger(key + '.rc1', RC1.Value);
   RC2.Value := XMLPropStorage1.ReadInteger(key + '.rc2', RC2.Value);
-  fMicrobit.tbLogo.Checked := XMLPropStorage1.ReadBoolean(key + '.logo', fMicrobit.tbLogo.Checked);
-  fMicrobit.accx.Value := XMLPropStorage1.ReadInteger(key + '.accx', fMicrobit.accx.Value);
-  fMicrobit.accy.Value := XMLPropStorage1.ReadInteger(key + '.accy', fMicrobit.accy.Value);
-  fMicrobit.accz.Value := XMLPropStorage1.ReadInteger(key + '.accz', fMicrobit.accz.Value);
-  fMicrobit.snd.Value := XMLPropStorage1.ReadInteger(key + '.sound', fMicrobit.snd.Value);
-  fMicrobit.light.Value := XMLPropStorage1.ReadInteger(key + '.light', fMicrobit.light.Value);
-  fMicrobit.compass.Value := XMLPropStorage1.ReadInteger(key + '.comp', fMicrobit.compass.Value);
-  fMicrobit.cbGesture.ItemIndex := XMLPropStorage1.ReadInteger(key + '.gesture', fMicrobit.cbGesture.ItemIndex);
-end;
-
-procedure TForm1.tbPreset1ContextPopup(Sender: TObject; MousePos: TPoint; var Handled: boolean);
+  fMicrobit.tbLogo.Checked := XMLPropStorage1.ReadBoolean(key + '.logo',
+    fMicrobit.tbLogo.Checked);
+  fMicrobit.accx.Value := XMLPropStorage1.ReadInteger(key + '.accx',
+    fMicrobit.accx.Value);
+  fMicrobit.accy.Value := XMLPropStorage1.ReadInteger(key + '.accy',
+    fMicrobit.accy.Value);
+  fMicrobit.accz.Value := XMLPropStorage1.ReadInteger(key + '.accz',
+    fMicrobit.accz.Value);
+  fMicrobit.snd.Value := XMLPropStorage1.ReadInteger(key + '.sound',
+    fMicrobit.snd.Value);
+  fMicrobit.light.Value := XMLPropStorage1.ReadInteger(key + '.light',
+    fMicrobit.light.Value);
+  fMicrobit.compass.Value := XMLPropStorage1.ReadInteger(key + '.comp',
+    fMicrobit.compass.Value);
+  fMicrobit.cbGesture.ItemIndex :=
+    XMLPropStorage1.ReadInteger(key + '.gesture', fMicrobit.cbGesture.ItemIndex);
+end;
+
+procedure TForm1.tbPreset1ContextPopup(Sender: TObject; MousePos: TPoint;
+  var Handled: boolean);
 var
   key: string;
 begin
@@ -1775,8 +1821,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;
@@ -1820,7 +1866,8 @@ begin
     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;
 

+ 12 - 1
usps.pas

@@ -207,6 +207,8 @@ type
     soundLevel: byte;
     lightLevel: byte;
 
+    errorMessage: string;
+
     procedure doNull(Data: byte);
     procedure doPort(Data: byte);
     procedure doDelay(Data: byte);
@@ -270,6 +272,7 @@ type
     procedure break();
     procedure doSingleCommand(command: byte);
     procedure preFetch();
+    function getLastError():string;
 
     procedure writeEEProm(adr: byte; Data: byte);
 
@@ -432,14 +435,17 @@ end;
 procedure TSPS.nextStep();
 var
   Value: byte;
+  oldAddr : word;
 begin
+  errorMessage := '';
   Value := eeprom[addr];
+  oldAddr := addr;
   addr := addr + 1;
-
   doSingleCommand(Value);
 
   if (addr > e2e) then
   begin
+    errorMessage := 'Address out of range after address: 0x' + IntToHex(oldAddr, 2);
     doReset();
   end;
   preFetch();
@@ -621,6 +627,11 @@ begin
   end;
 end;
 
+function TSPS.getLastError(): string;
+begin
+  result := errorMessage;
+end;
+
 procedure TSPS.writeEEProm(adr: byte; Data: byte);
 begin
   eeprom[adr] := Data;