瀏覽代碼

+ 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 年之前
父節點
當前提交
6f874eefa6
共有 1 個文件被更改,包括 16 次插入0 次删除
  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 Paper(colour: Byte);
 procedure GotoXY(X, Y: Byte);
+function ReadKey: Char;
+function KeyPressed: Boolean;
 
 implementation
 
 var
   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;
 begin