Browse Source

+ added unit zxbasic, containing ZX Spectrum constants for the ZX BASIC keywords
* use these constants to construct the BASIC program loader (so it's now less cryptic what we're writing there)

git-svn-id: branches/z80@44590 -

nickysn 5 years ago
parent
commit
ac1d4ad499
4 changed files with 139 additions and 4 deletions
  1. 1 0
      .gitattributes
  2. 5 1
      utils/ihx2tzx/ihx2tzx.lpi
  3. 3 3
      utils/ihx2tzx/ihx2tzx.lpr
  4. 130 0
      utils/ihx2tzx/zxbasic.pas

+ 1 - 0
.gitattributes

@@ -19056,6 +19056,7 @@ utils/ihx2tzx/ihx2tzx.lpi svneol=native#text/plain
 utils/ihx2tzx/ihx2tzx.lpr svneol=native#text/plain
 utils/ihx2tzx/ihxreader.pas svneol=native#text/plain
 utils/ihx2tzx/tzxwriter.pas svneol=native#text/plain
+utils/ihx2tzx/zxbasic.pas svneol=native#text/plain
 utils/importtl/Makefile svneol=native#text/plain
 utils/importtl/Makefile.fpc svneol=native#text/plain
 utils/importtl/Makefile.fpc.fpcmake svneol=native#text/plain

+ 5 - 1
utils/ihx2tzx/ihx2tzx.lpi

@@ -24,7 +24,7 @@
       <FormatVersion Value="2"/>
       <Modes Count="0"/>
     </RunParams>
-    <Units Count="3">
+    <Units Count="4">
       <Unit0>
         <Filename Value="ihx2tzx.lpr"/>
         <IsPartOfProject Value="True"/>
@@ -37,6 +37,10 @@
         <Filename Value="tzxwriter.pas"/>
         <IsPartOfProject Value="True"/>
       </Unit2>
+      <Unit3>
+        <Filename Value="zxbasic.pas"/>
+        <IsPartOfProject Value="True"/>
+      </Unit3>
     </Units>
   </ProjectOptions>
   <CompilerOptions>

+ 3 - 3
utils/ihx2tzx/ihx2tzx.lpr

@@ -25,7 +25,7 @@ program ihx2tzx;
 {$mode objfpc}{$H+}
 
 uses
-  Classes, SysUtils, CustApp, ihxreader, tzxwriter
+  Classes, SysUtils, CustApp, ihxreader, tzxwriter, zxbasic
   { you can add units after this };
 
 const
@@ -99,8 +99,8 @@ begin
   FOutputFile := TFileStream.Create(FOutputFileName, fmCreate);
   FTapeWriter := TTZXWriter.Create(FOutputFile);
 
-  BasicLine1 := ' '#$EF'"" '#$AF#13;
-  BasicLine2 := ' '#$F5#$C0+IntToStr(FInputImage.Origin)+#14#0#0+Chr(Byte(FInputImage.Origin))+Chr(Byte(FInputImage.Origin shr 8))+#0#13;
+  BasicLine1 := ' '+BC_LOAD+'"" '+BC_CODE+#13;
+  BasicLine2 := ' '+BC_PRINT+BC_USR+IntToStr(FInputImage.Origin)+#14#0#0+Chr(Byte(FInputImage.Origin))+Chr(Byte(FInputImage.Origin shr 8))+#0#13;
   BasicProgram := #0#10+Chr(Byte(Length(BasicLine1)))+Chr(Byte(Length(BasicLine1) shr 8))+BasicLine1+
                   #0#20+Chr(Byte(Length(BasicLine2)))+Chr(Byte(Length(BasicLine2) shr 8))+BasicLine2;
 

+ 130 - 0
utils/ihx2tzx/zxbasic.pas

@@ -0,0 +1,130 @@
+{ IHX (Intel Hex format) to TZX (ZX Spectrum tape file format) convertor tool
+
+  This file contains various definitions, constants and utility functions for
+  dealing with BASIC programs on the ZX Spectrum.
+
+  Copyright (C) 2020 Nikolay Nikolov <[email protected]>
+
+  This source is free software; you can redistribute it and/or modify it under
+  the terms of the GNU General Public License as published by the Free
+  Software Foundation; either version 2 of the License, or (at your option)
+  any later version.
+
+  This code is distributed in the hope that it will be useful, but WITHOUT ANY
+  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+  details.
+
+  A copy of the GNU General Public License is available on the World Wide Web
+  at <http://www.gnu.org/copyleft/gpl.html>. You can also obtain it by writing
+  to the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor,
+  Boston, MA 02110-1335, USA.
+}
+
+unit zxbasic;
+
+{$mode objfpc}{$H+}
+
+interface
+
+uses
+  Classes, SysUtils;
+
+const
+  { the ZX BASIC special keyword character set }
+  BC_RND       = #165;  { RND       }
+  BC_INKEYS    = #166;  { INKEY$    }
+  BC_PI        = #167;  { PI        }
+  BC_FN        = #168;  { FN        }
+  BC_POINT     = #169;  { POINT     }
+  BC_SCREENS   = #170;  { SCREEN$   }
+  BC_ATTR      = #171;  { ATTR      }
+  BC_AT        = #172;  { AT        }
+  BC_TAB       = #173;  { TAB       }
+  BC_VALS      = #174;  { VAL$      }
+  BC_CODE      = #175;  { CODE      }
+  BC_VAL       = #176;  { VAL       }
+  BC_LEN       = #177;  { LEN       }
+  BC_SIN       = #178;  { SIN       }
+  BC_COS       = #179;  { COS       }
+  BC_TAN       = #180;  { TAN       }
+  BC_ASN       = #181;  { ASN       }
+  BC_ACS       = #182;  { ACS       }
+  BC_ATN       = #183;  { ATN       }
+  BC_LN        = #184;  { LN        }
+  BC_EXP       = #185;  { EXP       }
+  BC_INT       = #186;  { INT       }
+  BC_SOR       = #187;  { SOR       }
+  BC_SGN       = #188;  { SGN       }
+  BC_ABS       = #189;  { ABS       }
+  BC_PEEK      = #190;  { PEEK      }
+  BC_IN        = #191;  { IN        }
+  BC_USR       = #192;  { USR       }
+  BC_STRS      = #193;  { STR$      }
+  BC_CHRS      = #194;  { CHR$      }
+  BC_NOT       = #195;  { NOT       }
+  BC_BIN       = #196;  { BIN       }
+  BC_OR        = #197;  { OR        }
+  BC_AND       = #198;  { AND       }
+  BC_LE        = #199;  { <=        }
+  BC_GE        = #200;  { >=        }
+  BC_NEQ       = #201;  { <>        }
+  BC_LINE      = #202;  { LINE      }
+  BC_THEN      = #203;  { THEN      }
+  BC_TO        = #204;  { TO        }
+  BC_STEP      = #205;  { STEP      }
+  BC_DEF_FN    = #206;  { DEF FN    }
+  BC_CAT       = #207;  { CAT       }
+  BC_FORMAT    = #208;  { FORMAT    }
+  BC_MOVE      = #209;  { MOVE      }
+  BC_ERASE     = #210;  { ERASE     }
+  BC_OPEN      = #211;  { OPEN      }
+  BC_CLOSE     = #212;  { CLOSE     }
+  BC_MERGE     = #213;  { MERGE     }
+  BC_VERIFY    = #214;  { VERIFY    }
+  BC_BEEP      = #215;  { BEEP      }
+  BC_CIRCLE    = #216;  { CIRCLE    }
+  BC_INK       = #217;  { INK       }
+  BC_PAPER     = #218;  { PAPER     }
+  BC_FLASH     = #219;  { FLASH     }
+  BC_BRIGHT    = #220;  { BRIGHT    }
+  BC_INVERSE   = #221;  { INVERSE   }
+  BC_OVER      = #222;  { OVER      }
+  BC_OUT       = #223;  { OUT       }
+  BC_LPRINT    = #224;  { LPRINT    }
+  BC_LLIST     = #225;  { LLIST     }
+  BC_STOP      = #226;  { STOP      }
+  BC_READ      = #227;  { READ      }
+  BC_DATA      = #228;  { DATA      }
+  BC_RESTORE   = #229;  { RESTORE   }
+  BC_NEW       = #230;  { NEW       }
+  BC_BORDER    = #231;  { BORDER    }
+  BC_CONTINUE  = #232;  { CONTINUE  }
+  BC_DIM       = #233;  { DIM       }
+  BC_REM       = #234;  { REM       }
+  BC_FOR       = #235;  { FOR       }
+  BC_GO_TO     = #236;  { GO TO     }
+  BC_GO_SUB    = #237;  { GO SUB    }
+  BC_INPUT     = #238;  { INPUT     }
+  BC_LOAD      = #239;  { LOAD      }
+  BC_LIST      = #240;  { LIST      }
+  BC_LET       = #241;  { LET       }
+  BC_PAUSE     = #242;  { PAUSE     }
+  BC_NEXT      = #243;  { NEXT      }
+  BC_POKE      = #244;  { POKE      }
+  BC_PRINT     = #245;  { PRINT     }
+  BC_PLOT      = #246;  { PLOT      }
+  BC_RUN       = #247;  { RUN       }
+  BC_SAVE      = #248;  { SAVE      }
+  BC_RANDOMIZE = #249;  { RANDOMIZE }
+  BC_IF        = #250;  { IF        }
+  BC_CLS       = #251;  { CLS       }
+  BC_DRAW      = #252;  { DRAW      }
+  BC_CLEAR     = #253;  { CLEAR     }
+  BC_RETURN    = #254;  { RETURN    }
+  BC_COPY      = #255;  { COPY      }
+
+implementation
+
+end.
+