From 1896d2764023c164d4479a3fdb6bcf33f70ce8d4 Mon Sep 17 00:00:00 2001
From: Ben Avison <bavison@gitlab.riscosopen.org>
Date: Wed, 10 May 2000 15:35:25 +0000
Subject: [PATCH] Callbacks can now go off when the text window scrolls
 (newline or line wrap).

  In particular, they can go off when Scroll Lock etc have frozen the text
  output.
Detail:
  The callback chain is examined at least once per line scroll. Additionally,
  it is examined repeatedly while Scroll Lock or Ctrl-Shift are acting, while
  idling between lines if Ctrl is held down, and while waiting for the Shift
  key to be pressed at the bottom of a screen when in page mode.
  The opportunity is also taken to call Portable_Idle after each time that the
  callback chain has been examined.
Admin:
  Not tested.

Version 5.27. Tagged as 'Kernel-5_27'
---
 VersionASM    |  6 +++---
 VersionNum    | 10 +++++-----
 s/vdu/vduwrch | 20 ++++++++++++++++++++
 3 files changed, 28 insertions(+), 8 deletions(-)

diff --git a/VersionASM b/VersionASM
index 27db1339..d67f3942 100644
--- a/VersionASM
+++ b/VersionASM
@@ -6,9 +6,9 @@
                         GBLS    Module_MinorVersion
                         GBLS    Module_Date
                         GBLS    Module_FullVersion
-Module_MajorVersion     SETS    "5.26"
-Module_Version          SETA    526
+Module_MajorVersion     SETS    "5.27"
+Module_Version          SETA    527
 Module_MinorVersion     SETS    ""
 Module_Date             SETS    "10 May 2000"
-Module_FullVersion      SETS    "5.26"
+Module_FullVersion      SETS    "5.27"
                         END
diff --git a/VersionNum b/VersionNum
index f9e3cf36..6eb31113 100644
--- a/VersionNum
+++ b/VersionNum
@@ -1,15 +1,15 @@
-/* (5.26)
+/* (5.27)
  *
  * This file is automatically maintained by srccommit, do not edit manually.
  *
  */
-#define Module_MajorVersion_CMHG        5.26
+#define Module_MajorVersion_CMHG        5.27
 #define Module_MinorVersion_CMHG        
 #define Module_Date_CMHG                10 May 2000
 
-#define Module_MajorVersion             "5.26"
-#define Module_Version                  526
+#define Module_MajorVersion             "5.27"
+#define Module_Version                  527
 #define Module_MinorVersion             ""
 #define Module_Date                     "10 May 2000"
 
-#define Module_FullVersion              "5.26"
+#define Module_FullVersion              "5.27"
diff --git a/s/vdu/vduwrch b/s/vdu/vduwrch
index 784f2e5a..02ada601 100644
--- a/s/vdu/vduwrch
+++ b/s/vdu/vduwrch
@@ -2709,6 +2709,8 @@ DoOSBYTE87
 PageTest
         Push    R14
 
+        BL      Page_ProcessCallbacks   ; give callbacks at least one chance per line
+
         CLC                             ; don't set leds first time
         BL      CtrlShiftTest           ; on exit, C=CTRL, N=SHIFT
         BCC     Page20                  ; CTRL up, then branch
@@ -2722,6 +2724,7 @@ CSWaitLoop
         SEC                             ; set leds
         BL      CtrlShiftTest
         BCC     Page18
+        BLMI    Page_ProcessCallbacks
         BMI     CSWaitLoop              ; and wait for change (NB C=1 now)
 Page18
         BL      PreWrchCursor           ; get rid of cursor again
@@ -2745,6 +2748,7 @@ Page30
         BCC     Page35                  ; CTRL no longer down
         LDROSB  R1, CentiCounter
         CMP     R1, #1
+        BLCS    Page_ProcessCallbacks
         BCS     Page30                  ; loop with carry set
 Page35
         BL      PreWrchCursor           ; remove cursor again
@@ -2783,6 +2787,7 @@ Page50                                  ; NB C=0 on entry from above
 PageWaitLoop
         SEC
         BL      CtrlShiftTest
+        BLPL    Page_ProcessCallbacks
         BPL     PageWaitLoop
         BL      PreWrchCursor
 
@@ -2832,6 +2837,21 @@ CtrlShiftTest ROUT
         MOVS    R0, R0, LSL #(32-6)     ; C=CTRL, N=SHIFT
         MOV     PC, R14
 
+Page_ProcessCallbacks
+        EntryS                          ; routine must preserve flags
+        ; See if there are any pending callbacks
+        MOV     R0, #0
+        LDRB    R14, [R0, #CallBack_Flag]
+        TST     R14, #CBack_VectorReq
+        BLNE    process_callback_chain
+        ; Now they're dealt with, we have nothing else to do, so call Idle
+      [ StorkPowerSave
+        LDR     R14, [r0, #PortableFlags]
+        TST     R14, #PortableFeature_Idle
+        SWINE   XPortable_Idle
+      ]
+        EXITS
+
 ; *****************************************************************************
 ;
 ;       SO - Page mode on
-- 
GitLab