From fe35493773448e78a3859a27cb08b209e8d46581 Mon Sep 17 00:00:00 2001
From: Robert Sprowson <rsprowson@gitlab.riscosopen.org>
Date: Sun, 1 Jul 2012 21:26:41 +0000
Subject: [PATCH] Sort out SetBorder

NewReset.s:
The one remaining use of SetBorder was to denote the user asked for and got a CMOS reset, which in the HAL case emitted a warning because setting the border is potentially complicated/slow.
To solve this, the reset is noted and replaces the normal RISC OS banner with a warning message. The behaviour and text for this comes from the BBC Master, though the escape key is used in place of break since a reset isn't actually needed.
Moved the unused cputable inside its corresponding switch.
Two occurrences of WriteS_Translated would have executed the message in the V=1 case.
KernelWS/Resources:
Flag added to workspace, translation added to messages files.
Heapman.s:
Commented out use of SetBorder removed.
Kernel.s:
SetBorder macro removed.
Middle.s:
Switched out use of SetBorder removed.
Super1.s:
Conditional WriteS_Translated would try to execute the message in the opposite condition case.


Version 5.35, 4.79.2.157. Tagged as 'Kernel-5_35-4_79_2_157'
---
 Resources/UK/Messages         |  3 +-
 Resources/UK/Morris4/Messages |  3 +-
 Resources/UK/Omega/Messages   |  3 +-
 Resources/UK/Ursula/Messages  |  3 +-
 VersionASM                    | 10 ++--
 VersionNum                    | 14 ++---
 hdr/KernelWS                  |  3 +-
 s/HeapMan                     |  8 ---
 s/Kernel                      | 19 -------
 s/Middle                      | 15 ------
 s/NewReset                    | 96 +++++++++++++++++++----------------
 s/Super1                      |  4 +-
 12 files changed, 77 insertions(+), 104 deletions(-)

diff --git a/Resources/UK/Messages b/Resources/UK/Messages
index 10c6f6b..2d204f6 100644
--- a/Resources/UK/Messages
+++ b/Resources/UK/Messages
@@ -151,7 +151,8 @@ BadMSFlags:Illegal flags in mode selector
 CDATStackOverflow:System stack overflow
 NoSuchSWI:SWI not known
 BadSav:Incorrect number of parameters for *Save
-MonType:Monitor type reconfigured.
+CmosRst:CMOS RAM reset, press ESCAPE to continue
+MonType:Monitor type reconfigured
 NoKbd:No keyboard present - autobooting
 BreakPt:Stopped at break point at &%0
 STail:|J|MUse *Configure to set the options.|J|M
diff --git a/Resources/UK/Morris4/Messages b/Resources/UK/Morris4/Messages
index e9f7233..b9001a9 100644
--- a/Resources/UK/Morris4/Messages
+++ b/Resources/UK/Morris4/Messages
@@ -151,7 +151,8 @@ BadMSFlags:Illegal flags in mode selector
 CDATStackOverflow:System stack overflow
 NoSuchSWI:SWI not known
 BadSav:Incorrect number of parameters for *Save
-MonType:Monitor type reconfigured.
+CmosRst:CMOS RAM reset, press ESCAPE to continue
+MonType:Monitor type reconfigured
 NoKbd:No keyboard present - autobooting
 BreakPt:Stopped at break point at &%0
 STail:|J|MUse *Configure to set the options.|J|M
diff --git a/Resources/UK/Omega/Messages b/Resources/UK/Omega/Messages
index 376f459..aa8a311 100644
--- a/Resources/UK/Omega/Messages
+++ b/Resources/UK/Omega/Messages
@@ -151,7 +151,8 @@ BadMSFlags:Illegal flags in mode selector
 CDATStackOverflow:System stack overflow
 NoSuchSWI:SWI not known
 BadSav:Incorrect number of parameters for *Save
-MonType:Monitor type reconfigured.
+CmosRst:CMOS RAM reset, press ESCAPE to continue
+MonType:Monitor type reconfigured
 NoKbd:No keyboard present - autobooting
 BreakPt:Stopped at break point at &%0
 STail:|J|MUse *Configure to set the options.|J|M
diff --git a/Resources/UK/Ursula/Messages b/Resources/UK/Ursula/Messages
index e9f7233..b9001a9 100644
--- a/Resources/UK/Ursula/Messages
+++ b/Resources/UK/Ursula/Messages
@@ -151,7 +151,8 @@ BadMSFlags:Illegal flags in mode selector
 CDATStackOverflow:System stack overflow
 NoSuchSWI:SWI not known
 BadSav:Incorrect number of parameters for *Save
-MonType:Monitor type reconfigured.
+CmosRst:CMOS RAM reset, press ESCAPE to continue
+MonType:Monitor type reconfigured
 NoKbd:No keyboard present - autobooting
 BreakPt:Stopped at break point at &%0
 STail:|J|MUse *Configure to set the options.|J|M
diff --git a/VersionASM b/VersionASM
index 611b120..5d4c72e 100644
--- a/VersionASM
+++ b/VersionASM
@@ -13,11 +13,11 @@
                         GBLS    Module_ComponentPath
 Module_MajorVersion     SETS    "5.35"
 Module_Version          SETA    535
-Module_MinorVersion     SETS    "4.79.2.156"
-Module_Date             SETS    "27 Jun 2012"
-Module_ApplicationDate  SETS    "27-Jun-12"
+Module_MinorVersion     SETS    "4.79.2.157"
+Module_Date             SETS    "01 Jul 2012"
+Module_ApplicationDate  SETS    "01-Jul-12"
 Module_ComponentName    SETS    "Kernel"
 Module_ComponentPath    SETS    "castle/RiscOS/Sources/Kernel"
-Module_FullVersion      SETS    "5.35 (4.79.2.156)"
-Module_HelpVersion      SETS    "5.35 (27 Jun 2012) 4.79.2.156"
+Module_FullVersion      SETS    "5.35 (4.79.2.157)"
+Module_HelpVersion      SETS    "5.35 (01 Jul 2012) 4.79.2.157"
                         END
diff --git a/VersionNum b/VersionNum
index ccefc03..6f3ae26 100644
--- a/VersionNum
+++ b/VersionNum
@@ -5,19 +5,19 @@
  *
  */
 #define Module_MajorVersion_CMHG        5.35
-#define Module_MinorVersion_CMHG        4.79.2.156
-#define Module_Date_CMHG                27 Jun 2012
+#define Module_MinorVersion_CMHG        4.79.2.157
+#define Module_Date_CMHG                01 Jul 2012
 
 #define Module_MajorVersion             "5.35"
 #define Module_Version                  535
-#define Module_MinorVersion             "4.79.2.156"
-#define Module_Date                     "27 Jun 2012"
+#define Module_MinorVersion             "4.79.2.157"
+#define Module_Date                     "01 Jul 2012"
 
-#define Module_ApplicationDate          "27-Jun-12"
+#define Module_ApplicationDate          "01-Jul-12"
 
 #define Module_ComponentName            "Kernel"
 #define Module_ComponentPath            "castle/RiscOS/Sources/Kernel"
 
-#define Module_FullVersion              "5.35 (4.79.2.156)"
-#define Module_HelpVersion              "5.35 (27 Jun 2012) 4.79.2.156"
+#define Module_FullVersion              "5.35 (4.79.2.157)"
+#define Module_HelpVersion              "5.35 (01 Jul 2012) 4.79.2.157"
 #define Module_LibraryVersionInfo       "5:35"
diff --git a/hdr/KernelWS b/hdr/KernelWS
index a16022f..51232ee 100644
--- a/hdr/KernelWS
+++ b/hdr/KernelWS
@@ -1478,7 +1478,8 @@ MOShasFIQ          #    1
 FIQclaim_interlock #    1
 CallBack_Flag      #    1
 IRQ_CallBack_Flag * CallBack_Flag
-MonitorLeadType #       1       ; some function of the monitor lead inputs, as yet undetermined
+MonitorLeadType    #    1       ; some function of the monitor lead inputs, as yet undetermined
+MentionCMOSReset   #    1       ; non zero reports CMOS resets prior to the start banner
 
                 AlignSpace
 
diff --git a/s/HeapMan b/s/HeapMan
index e8fc100..0833f92 100644
--- a/s/HeapMan
+++ b/s/HeapMan
@@ -401,14 +401,6 @@ GoodHeapExit                            ; V cleared on entry to SWI dispatch
         ExitSWIHandler                  ; Like all good SWI handlers
       ]
 
-;HeapInUse
-;     $HeapBadAsModuleBRA
-;       SetBorder R10, R11, 15, 0, 0
-;     $HeapBadAsModuleKET
-
-;        ADR     R0, ErrorBlock_HeapFail_HeapLocked
-;        B       NaffHeapExit
-
 ; Errors
        MakeErrorBlock  HeapBadReason
        MakeErrorBlock  HeapFail_Init
diff --git a/s/Kernel b/s/Kernel
index 5a8c559..44a34f4 100644
--- a/s/Kernel
+++ b/s/Kernel
@@ -84,25 +84,6 @@ $label  LDR     $reg, =ZeroPage+VduDriverWorkSpace
                 GBLA    Module_BaseAddr
 Module_BaseAddr SETA    0
 
-;        Command $cmd, $max, $min   - declared in hdr.macros.
-
-; debug macro: set the border colour
-
-        MACRO
-$l      SetBorder  $reg1, $reg2, $red, $green, $blue, $delay
-        ! 0, "Setborder used"
-$l      LDR     $reg1, =VIDC
-; Note $reg, $green and $blue are 4 bit values
-        LDR     $reg2, =&40000000+(($red)*&11)+(($green)*&1100)+(($blue)*&110000)
-        STR     $reg2, [$reg1]
- [ "$delay"<>""
-        MOV     $reg1, #$delay
-10
-        SUBS    $reg1, $reg1, #1
-        BNE     %BT10
- ]
-        MEND
-
 ; Fake a 26-bit pc, given a PSR currently in lr (or reg), and the 32-bit address on
 ; the stack. The stacked address is pulled, and the result is left in lr.
 
diff --git a/s/Middle b/s/Middle
index 2087924..9996afc 100644
--- a/s/Middle
+++ b/s/Middle
@@ -1129,21 +1129,6 @@ exit_AOS
  ]
         MakeErrorBlock BadEnvNumber
 
-   [ {FALSE}
-
-testcallbackpending
-        CMP     r1, #0                ; OK if only reading
-        CMPEQ   r2, #0
-        CMPEQ   r3, #0
-        LDRNEB  r10, [r0, #CallBack_Flag-CallBackHandler]
-        TSTNE   r10, #CBack_OldStyle
-        MOVEQ   pc, r14
-  SetBorder r0, r14, 15, 0, 0
-        ADR     r0, ErrorBlock_CallbackPending
-        B       exit_AOS
-        MakeErrorBlock CallbackPending
-   ]
-
 AOS_Table
         &  ZeroPage+MemLimit     ;  MemoryLimit
         &  0
diff --git a/s/NewReset b/s/NewReset
index 5fdcf1d..43e9ce2 100644
--- a/s/NewReset
+++ b/s/NewReset
@@ -728,20 +728,6 @@ reset_loop
         TEQ     R1, #SpriteSizeCMOS
         BHI     reset_loop
 
- [ {FALSE}
- ; Oh, just leave it be
-        MOV     R0, #VduCMOS
-        BL      Read
- [ IOMD_C_MonitorType = 0 :LAND: IOMD_C_PALNTSCType = 0
-; Force TV if we don't have a MonitorType auto-detect bit
-        TEQ     R0, #(Sync_Separate :OR: MonitorType0)
- |
-; Force auto-detect of monitor stuff if we have a MonitorType auto-detect bit
-        TEQ     R0, #(Sync_Auto :OR: MonitorTypeAuto)
- ]
-        BNE     cmos_reset
- ]
-
 ; Year should be >=1995, <=2037 (when 32 bit signed Unix time breaks)
         MOV     R0, #YearCMOS+1
         BL      Read
@@ -766,6 +752,7 @@ checkboot
 
 ; IF power-on bit set AND R/T/Del/Copy pressed THEN reset CMOS RAM
 ; note that memory cleared if POR, so key info has had plenty of time!
+
  [ HAL
         LDR     R0, =ZeroPage+HAL_StartFlags
         LDR     R1, [R0]
@@ -816,9 +803,12 @@ checkboot
         LDR     R7, [R0, #KbdFlags]
         TST     R7, #KbdFlag_R:OR:KbdFlag_T:OR:KbdFlag_Delete:OR:KbdFlag_Copy
  |
-        LDR     R7, [R0, #R_Down_Flag]
+        LDR     R7, [R0, #R_Down_Flag]  ; Picks up R/T/Del/Copy flags all in one
         CMP     R7, #0
  ]
+        LDRNE   R3, =ZeroPage
+        MOVNE   R14, #1
+        STRNEB  R14, [R3, #MentionCMOSReset]
         BEQ     no_cmos_reset           ; power on bit checked again there
 
       [ :LNOT: STB
@@ -835,10 +825,8 @@ checkboot
 ; **************************************************************************
 
  [ HAL
-        ! 0, "Sort out SetBorder for CMOS reset"
         TST     R7, #KbdFlag_Copy:OR:KbdFlag_Delete
  |
-        SetBorder  R0, R1, 15, 0, 0     ; flash the border as warning!
         ASSERT  (Del_Down_Flag - R_Down_Flag) = 2
         ASSERT  (Copy_Down_Flag - Del_Down_Flag) = 1
         MOVS    R3, R7, LSR #16         ; full reset or just system?
@@ -2009,22 +1997,44 @@ SkipHardResetPart2                      ; code executed on all types of reset
         STRNEB  r0, [r0, #ErrorSemaphore] ; then allow errors to be translated
       ]
 
-    [ DoInitialiseMode :LOR: :LNOT: Embedded_UI
+      [ DoInitialiseMode :LOR: :LNOT: Embedded_UI
         BL      InitialiseMode
-     [ :LNOT: Embedded_UI
+      ]
+    [ :LNOT: Embedded_UI
+        LDR     R0, =ZeroPage
+        LDRB    R14, [R0, #MentionCMOSReset]
+        TEQ     R14, #0
+        BEQ     %FT12
+      [ International
+        SWI     XOS_WriteI+10
+        BVS     %FT09
+        BL      WriteS_Translated
+        =       "CmosRst:CMOS RAM reset, press ESCAPE to continue",0
+        ALIGN
+09
+      |
+        SWI     XOS_WriteS
+        =       10,"CMOS RAM reset, press ESCAPE to continue",0
+        ALIGN
+      ]
+10
+        SWI     XOS_ReadEscapeState
+        BCC     %BT10
+        MOV     R0, #124
+        SWI     XOS_Byte                ; Clear the condition
+        SWI     XOS_WriteI+12           ; Clear the screen
+12
         SWI     XOS_WriteS
         =       10, "$SystemName ", 0   ; now RISC OS (no +) again
         ALIGN
 
-        LDR     R0, =ZeroPage
-        LDR     R0, [R0, #RAMLIMIT]
-
-        Push    "R0"
         MOV     R0, #8
         ORR     R0, R0, #&500
         SWI     XOS_Memory              ; returns amount of soft ROM (pages) in r1
         MOVVS   R1, #0
-        Pull    "R0"
+
+        LDR     R0, =ZeroPage
+        LDR     R0, [R0, #RAMLIMIT]
         MLA     R0, R1, R2, R0          ; convert pages to bytes and add in
 
         MOV     R0, R0, LSR #20         ; /(1024*1024) down to megabytes
@@ -2035,19 +2045,13 @@ SkipHardResetPart2                      ; code executed on all types of reset
         SWI     XOS_WriteS
         =       "MB", 10,13, 10, 0      ; title complete
         ALIGN
-     ]
-    ]
 
- [ StrongARM
-  [ Embedded_UI
-   ! 0,"Printing of processor type disabled"
-  |
-;        IMPORT  ARM_PrintProcessorType
         BL      ARM_PrintProcessorType
-  ]
- ]
+    |
+        ! 0,    "Banner & printing of processor type disabled"
+    ]
 
-01      MOV     r0, #0                  ; Set DomainId to 0 every reset
+        MOV     r0, #0                  ; Set DomainId to 0 every reset
       [ ZeroPage = 0
         STR     r0, [r0, #DomainId]     ; before calling anyone
       |
@@ -2158,12 +2162,14 @@ HorologicalDelayLoop1
 
       [ International
         SWI     XOS_WriteI+10
-        BLVC    WriteS_Translated
-        =       "MonType:Monitor type reconfigured.",10,13,10,0
+        BVS     %FT65
+        BL      WriteS_Translated
+        =       "MonType:Monitor type reconfigured",10,13,10,0
         ALIGN
+65
       |
         SWI     XOS_WriteS
-        =       10,"Monitor type reconfigured.",10,13,10,0
+        =       10,"Monitor type reconfigured",10,13,10,0
         ALIGN
       ]
     ]
@@ -2191,6 +2197,12 @@ MonitorKeypadTable      ; internal key number, CMOS bits
         =       &FF
         ALIGN 32
 
+      [ International
+MessageFileName DCB     "Resources:$.Resources.Kernel.Messages",0
+        ALIGN
+      ]
+
+ [ StrongARM :LAND: :LNOT: HAL
 cputable
         DCD &6000,0,0
         DCD &6100,1,0
@@ -2202,12 +2214,6 @@ cputable
         DCD &7501,7,0
         DCD -1
 
-      [ International
-MessageFileName DCB     "Resources:$.Resources.Kernel.Messages",0
-        ALIGN
-      ]
-
- [ StrongARM :LAND: :LNOT: HAL
 Processor_Type
         MOV     r0,#IOMD_Base
         LDRB    r1,[r0,#IOMD_ID0]
@@ -2347,9 +2353,11 @@ AutoBootCosNoKbd
     [ :LNOT: Embedded_UI
       [ International
         SWI     XOS_WriteI+7
-        BLVC    WriteS_Translated
+        BVS     %FT81
+        BL      WriteS_Translated
         =       "NoKbd:No keyboard present - autobooting", 10,13,0
         ALIGN
+81
       |
         SWI     XOS_WriteS
         =       7, "No keyboard present - autobooting", 10,13,0
diff --git a/s/Super1 b/s/Super1
index a74fdb4..82f39f2 100644
--- a/s/Super1
+++ b/s/Super1
@@ -87,9 +87,11 @@ ESCAPE  MOV     R0, #&7E
       [ International
         SWI     XOS_EnterOS             ; GO into SVC mode to get some stack
         SWI     OS_NewLine
-        BLVC    WriteS_Translated
+        BVS     %FT01
+        BL      WriteS_Translated
         =       "Escape:Escape",10,13,0
         ALIGN
+01
         WritePSRc 0, R0                 ; Back to user mode.
       |
         SWI     OS_WriteS
-- 
GitLab