瀏覽代碼

TermBox: Frame skip fixes

Arthur Yefimov 3 年之前
父節點
當前提交
865029a05e
共有 2 個文件被更改,包括 16 次插入8 次删除
  1. 1 1
      src/FreeOberon.Mod
  2. 15 7
      src/TermBox.Mod

+ 1 - 1
src/FreeOberon.Mod

@@ -1150,7 +1150,7 @@ BEGIN
   curX := 0; curY := 0;
   success := FALSE;
   ParseArgs(fs, sw, w, h, fnames);
-  T.Settings(0, 0, {T.resizable});
+  T.Settings(0, 0, {T.resizable, T.window, T.center});
   T.Init;
   IF T.Done THEN
     InitIDE;

+ 15 - 7
src/TermBox.Mod

@@ -6,7 +6,7 @@ CONST
   partH = 256;
   emptyCh = ' ';
   nofcolors = 16;
-  cursorTickSpeed = 1.0;
+  cursorTickSpeed = 4.0;
   stdW = 80;
   stdH = 25;
 
@@ -287,7 +287,7 @@ VAR
   cursorTimer: G.Timer; (* Text cursor tick timer *)
   userTimer: G.Timer; (* User timer set by StartTimer *)
 
-  needFlip: BOOLEAN;
+  needFlip: INTEGER;
   screen: G.Window;
   font: G.MonoFont;
   colors: ARRAY nofcolors OF G.Color;
@@ -403,9 +403,11 @@ END UpdateCell;
 
 PROCEDURE Flip(forse: BOOLEAN);
 BEGIN
-  IF ~G.HasEvents() OR forse THEN
-    G.Flip; needFlip := FALSE
-  ELSE needFlip := TRUE
+  IF ~G.HasEvents() OR forse OR (needFlip > 4) THEN
+    G.Flip; needFlip := 0
+    ;Out.String('ОБНОВЛЕНИЕ');Out.Ln
+  ELSE INC(needFlip)
+    ;Out.String(' отложено');Out.Ln
   END
 END Flip;
 
@@ -535,7 +537,9 @@ BEGIN
         UpdateCell(curX, curY);
         Flush
       END;
-      IF needFlip THEN G.Flip; needFlip := FALSE END
+      IF needFlip # 0 THEN G.Flip; needFlip := 0
+        ;Out.String('    По таймеру');Out.Ln
+      END
     ELSE
       event.type := timer
     END
@@ -569,6 +573,10 @@ END ParseEvent;
 PROCEDURE WaitAndParseEvent(VAR event: Event);
 VAR E: G.Event;
 BEGIN
+  IF (needFlip # 0) & ~G.PeekEvent(E) THEN
+    G.Flip; needFlip := 0
+    ;Out.String('    По ожиданию');Out.Ln
+  END;
   G.WaitEvent(E);
   ParseEvent(E, event)
 END WaitAndParseEvent;
@@ -814,7 +822,7 @@ BEGIN Done := FALSE;
     InitBuffer;
     InitTimer;
     mouseDown := FALSE;
-    needFlip := FALSE;
+    needFlip := 0;
     processingEvent := FALSE;
     Done := TRUE
   END