Browse Source

+ added keyboard input functions (ReadKey and KeyPressed) to the ZX Spectrum. Now you can start having fun! :)

git-svn-id: branches/z80@44902 -
nickysn 5 years ago
parent
commit
6f874eefa6
1 changed files with 16 additions and 0 deletions
  1. 16 0
      rtl/zxspectrum/system.pp

+ 16 - 0
rtl/zxspectrum/system.pp

@@ -66,11 +66,27 @@ procedure PrintHexWord(const w: word);
 procedure Ink(colour: Byte);
 procedure Ink(colour: Byte);
 procedure Paper(colour: Byte);
 procedure Paper(colour: Byte);
 procedure GotoXY(X, Y: Byte);
 procedure GotoXY(X, Y: Byte);
+function ReadKey: Char;
+function KeyPressed: Boolean;
 
 
 implementation
 implementation
 
 
 var
 var
   save_iy: Word; public name 'FPC_SAVE_IY';
   save_iy: Word; public name 'FPC_SAVE_IY';
+  LastKey: Char absolute 23560;
+
+function ReadKey: Char;
+begin
+  repeat
+    ReadKey:=LastKey;
+  until ReadKey<>#0;
+  LastKey:=#0;
+end;
+
+function KeyPressed: Boolean;
+begin
+  KeyPressed:=LastKey<>#0;
+end;
 
 
 procedure fpc_InitializeUnits;[public,alias:'FPC_INITIALIZEUNITS']; compilerproc;
 procedure fpc_InitializeUnits;[public,alias:'FPC_INITIALIZEUNITS']; compilerproc;
 begin
 begin