Commit 7fbbad3d authored by Jeffrey Lee's avatar Jeffrey Lee
Browse files

ModeFlag_GreyscalePalette handling improvements. Issue service calls on...

ModeFlag_GreyscalePalette handling improvements. Issue service calls on certain GraphicsV events. Sprite tweaks and fixes.

Detail:
  hdr/VduExt - Add reason codes used by Service_DisplayChanged & Service_DisplayStatus
  s/vdu/vdugrafg - Remove dependency on SpriteReason_BadReasonCode; just use the size of our lookup table instead. Alter SpriteOp lookup table so that unimplemented ops return an error instead of doing nothing. Fix PutSprite incorrectly using the slow GCOL action plotter if a request was made to plot a sprite using its mask but the sprite has none.
  s/vdu/vdugrafl - Update screen redirection handling to set ModeFlag_GreyscalePalette if switching output to a sprite with a greyscale palette or a RISC OS Select alpha mask. Restore the flag to its correct value when restoring screen output.
  s/vdu/vdupalxx - Update ModeFlag_GreyscalePalette in realtime as the palette is changed
  s/vdu/vduswis - Issue Service_DisplayChanged during OS_ScreenMode 11. Issue Service_DisplayStatus during OS_ScreenMode 65 & 66.
Admin:
  Tested on Iyonix, BB-xM


Version 5.35, 4.79.2.210. Tagged as 'Kernel-5_35-4_79_2_210'
parent f6c764dd
......@@ -13,11 +13,11 @@
GBLS Module_ComponentPath
Module_MajorVersion SETS "5.35"
Module_Version SETA 535
Module_MinorVersion SETS "4.79.2.209"
Module_Date SETS "26 Jan 2014"
Module_ApplicationDate SETS "26-Jan-14"
Module_MinorVersion SETS "4.79.2.210"
Module_Date SETS "09 Mar 2014"
Module_ApplicationDate SETS "09-Mar-14"
Module_ComponentName SETS "Kernel"
Module_ComponentPath SETS "castle/RiscOS/Sources/Kernel"
Module_FullVersion SETS "5.35 (4.79.2.209)"
Module_HelpVersion SETS "5.35 (26 Jan 2014) 4.79.2.209"
Module_FullVersion SETS "5.35 (4.79.2.210)"
Module_HelpVersion SETS "5.35 (09 Mar 2014) 4.79.2.210"
END
......@@ -5,19 +5,19 @@
*
*/
#define Module_MajorVersion_CMHG 5.35
#define Module_MinorVersion_CMHG 4.79.2.209
#define Module_Date_CMHG 26 Jan 2014
#define Module_MinorVersion_CMHG 4.79.2.210
#define Module_Date_CMHG 09 Mar 2014
#define Module_MajorVersion "5.35"
#define Module_Version 535
#define Module_MinorVersion "4.79.2.209"
#define Module_Date "26 Jan 2014"
#define Module_MinorVersion "4.79.2.210"
#define Module_Date "09 Mar 2014"
#define Module_ApplicationDate "26-Jan-14"
#define Module_ApplicationDate "09-Mar-14"
#define Module_ComponentName "Kernel"
#define Module_ComponentPath "castle/RiscOS/Sources/Kernel"
#define Module_FullVersion "5.35 (4.79.2.209)"
#define Module_HelpVersion "5.35 (26 Jan 2014) 4.79.2.209"
#define Module_FullVersion "5.35 (4.79.2.210)"
#define Module_HelpVersion "5.35 (09 Mar 2014) 4.79.2.210"
#define Module_LibraryVersionInfo "5:35"
......@@ -119,7 +119,7 @@ ModeFlag_HardScrollDisabled * 1:SHL:6 ; set when outputting to a sprite, or dri
ModeFlag_FullPalette * 1:SHL:7 ; set when palette is not brain damaged
ModeFlag_64k * ModeFlag_FullPalette ; Used with log2bpp==4 to indicate 565 RGB/BGR mode
ModeFlag_InterlacedMode * 1:SHL:8 ; set when interlaced mode with hardware using two seperate framebuffers
ModeFlag_GreyscalePalette * 1:SHL:9 ; palette is gradient from black to white
ModeFlag_GreyscalePalette * 1:SHL:9 ; all entries greyscale, but no defined order
ModeFlag_ChromaSubsampleMode * ModeFlag_GreyscalePalette ; Used with log2bpp==7 to indicate chroma mode
; bits 10-11 reserved
ModeFlag_DataFormat_Mask * &F:SHL:12
......@@ -189,6 +189,14 @@ ModeSelector_MaxSize * ModeSelector_ModeVars+(NumModeVars * 8)+4
; maximum size of a mode selector, with each mode variable overridden
; plus terminator on end
; Service_DisplayChanged reason codes (R0)
DisplayChanged_Changing * 0
DisplayChanged_Changed * 1
; Service_DisplayStatus reason codes (R0)
DisplayStatus_Deregistered * 0
DisplayStatus_Registered * 1
OPT OldOpt
END
......@@ -341,7 +341,7 @@ SpriteVecHandler
LDRCC R1, [WsPtr, #SpAreaStart] ; then point at MOS sprite area
AND R0, R0, #&FF ; Kill the range bits
CMP R0, #SpriteReason_BadReasonCode
CMP R0, #(SwiSpriteOpCallTb_End-SwiSpriteOpCallTb)/4
BCS BadReasonCode
ADR R10, SwiSpriteOpCallTb
......@@ -516,20 +516,20 @@ Group4 * Group3 + SSO_NeedsSpriteModeData
Group5 * SSO_NeedsSomething + SSO_NeedsSprite
SwiSpriteOpCallTb
SpriteOpEntry DoesNowt, Group1
SpriteOpEntry BadReasonCode, Group1
[ AssemblingArthur :LOR: Module
SpriteOpEntry DoesNowt, Group1
SpriteOpEntry BadReasonCode, Group1
|
SpriteOpEntry ClaimSpace, Group1 ; *SSpace <size>
]
SpriteOpEntry ScreenSave, Group1
SpriteOpEntry ScreenLoad, Group1
SpriteOpEntry DoesNowt, Group1
SpriteOpEntry DoesNowt, Group1
SpriteOpEntry DoesNowt, Group1
SpriteOpEntry DoesNowt, Group1
SpriteOpEntry BadReasonCode, Group1 ; 4
SpriteOpEntry BadReasonCode, Group1 ; 5
SpriteOpEntry BadReasonCode, Group1 ; 6
SpriteOpEntry BadReasonCode, Group1 ; 7
; The following need valid workspace
......@@ -544,13 +544,13 @@ SwiSpriteOpCallTb
SpriteOpEntry GetSprite, Group2 ; *SGet <name>
SpriteOpEntry CreateSprite, Group2
SpriteOpEntry GetSpriteUserCoords, Group2
SpriteOpEntry DoesNowt, Group2
SpriteOpEntry DoesNowt, Group2
SpriteOpEntry DoesNowt, Group2
SpriteOpEntry DoesNowt, Group2
SpriteOpEntry DoesNowt, Group2
SpriteOpEntry DoesNowt, Group2
SpriteOpEntry DoesNowt, Group2
SpriteOpEntry BadReasonCode, Group2 ; 17 CheckSpriteArea
SpriteOpEntry BadReasonCode, Group2 ; 18
SpriteOpEntry BadReasonCode, Group2 ; 19
SpriteOpEntry BadReasonCode, Group2 ; 20
SpriteOpEntry BadReasonCode, Group2 ; 21
SpriteOpEntry BadReasonCode, Group2 ; 22
SpriteOpEntry BadReasonCode, Group2 ; 23
; The following need a sprite
......@@ -565,11 +565,11 @@ SwiSpriteOpCallTb
SpriteOpEntry DeleteRow, Group3 + SSO_DangerOp
SpriteOpEntry FlipAboutXAxis, Group3
SpriteOpEntry PutSpriteUserCoords, Group3
SpriteOpEntry DoesNowt, Group3
SpriteOpEntry DoesNowt, Group3
SpriteOpEntry DoesNowt, Group3
SpriteOpEntry DoesNowt, Group3
SpriteOpEntry DoesNowt, Group3
SpriteOpEntry BadReasonCode, Group3 ; 35 AppendSprite
SpriteOpEntry BadReasonCode, Group3 ; 36 SetPointerShape
SpriteOpEntry BadReasonCode, Group3 ; 37 CreateRemovePalette
SpriteOpEntry BadReasonCode, Group3 ; 38 CreateRemoveAlpha
SpriteOpEntry BadReasonCode, Group3 ; 39
; The following need sprite mode data
......@@ -583,16 +583,16 @@ SwiSpriteOpCallTb
SpriteOpEntry FlipAboutYAxis, Group4 + SSO_DangerOp
SpriteOpEntry PlotMask, Group4
SpriteOpEntry PlotMaskUserCoords, Group4
SpriteOpEntry DoesNowt, Group4 ; 50 ; PlotMaskScaled
SpriteOpEntry DoesNowt, Group4 ; 51 ; PaintCharScaled
SpriteOpEntry DoesNowt, Group4 ; 52 ; PutSpriteScaled
SpriteOpEntry DoesNowt, Group4 ; 53 ; PutSpriteGreyScaled
SpriteOpEntry BadReasonCode, Group4 ; 50 PlotMaskScaled
SpriteOpEntry BadReasonCode, Group4 ; 51 PaintCharScaled
SpriteOpEntry BadReasonCode, Group4 ; 52 PutSpriteScaled
SpriteOpEntry BadReasonCode, Group4 ; 53 PutSpriteGreyScaled
SpriteOpEntry RemoveLeftHandWastage, Group4
SpriteOpEntry DoesNowt, Group4 ; 55 PlotMaskTransformed
SpriteOpEntry DoesNowt, Group4 ; 56 PutSpriteTransformed
SpriteOpEntry DoesNowt, Group4 ; 57 InsertDeleteRows
SpriteOpEntry DoesNowt, Group4 ; 58 InsertDeleteColumns
SpriteOpEntry DoesNowt, Group4 ; 59 pseudo reason used by Wimp
SpriteOpEntry BadReasonCode, Group4 ; 55 PlotMaskTransformed
SpriteOpEntry BadReasonCode, Group4 ; 56 PutSpriteTransformed
SpriteOpEntry BadReasonCode, Group4 ; 57 InsertDeleteRows
SpriteOpEntry BadReasonCode, Group4 ; 58 InsertDeleteColumns
SpriteOpEntry BadReasonCode, Group4 ; 59 pseudo reason used by Wimp
; The following need (sprite area + sprite) or (anything + 0), meaning screen
......@@ -600,6 +600,9 @@ SwiSpriteOpCallTb
SpriteOpEntry SwitchOutputToMask, Group5 ; 61
SpriteOpEntry ReadSaveAreaSize, Group5 ; 62
SwiSpriteOpCallTb_End
; *****************************************************************************
;
; SetupSprModeData - Set up registers and variables from the sprite mode
......@@ -701,7 +704,7 @@ SpriteErr_NotGraphics MakeErrorBlock Sprite_NotGraphics
SpriteErr_NotEnoughRoom MakeErrorBlock Sprite_NotEnoughRoom
SpriteErr_BadSpriteFile MakeErrorBlock Sprite_BadSpriteFile
SpriteErr_NoRoomToMerge MakeErrorBlock Sprite_NoRoomToMerge
SpriteErr_Bad2ndPtr MakeErrorBlock Sprite_Bad2ndPtr
SpriteErr_Bad2ndPtr MakeErrorBlock Sprite_Bad2ndPtr
SpriteErr_InvalidRowOrCol MakeErrorBlock Sprite_InvalidRowOrCol
SpriteErr_InvalidHeight MakeErrorBlock Sprite_InvalidHeight
SpriteErr_InvalidWidth MakeErrorBlock Sprite_InvalidWidth
......@@ -1251,7 +1254,7 @@ PutSpri20
ADD WsPtr, WsPtr, #SPltScrAdr ; repoint WsPtr at SPltScrAdr
LDMIA WsPtr, {R0-R1,R5-R7}
TEQ R2, #0
TST R2, #7
BNE SolPl10 ; not store, do it slowly
; SimpleCase
......
......@@ -213,7 +213,7 @@ SwitchOutputToMask ROUT
LDR R5, [WsPtr, #XEigFactor]
LDR R6, [WsPtr, #ModeFlags]
TEQ R2, #0
ORRNE R6, R6, #ModeFlag_HardScrollDisabled ; if sprite then disable hard
ORRNE R6, R6, #ModeFlag_HardScrollDisabled ; if sprite then disable hard scroll
STR R6, [WsPtr, #ModeFlags]
;if switching to a sprite, check for full palette 8bpp, and set modeflags and
......@@ -222,22 +222,51 @@ SwitchOutputToMask ROUT
TEQ R2, #0
BEQ %FT65 ; switching to a sprite ?
CMP R0, #3
BNE %FT65 ; which is 8bpp ?
ADD R7, R2, #spImage ; point R7 at the image/mask start pair
LDMIA R7, {R7, LR} ; fetch them
CMP R7, LR ; which is lower
MOVGT R7, LR ; use the lowest
SUB R7, R7, #spPalette ; get the size of the palette
CMP R0, #3
BNE %FT51 ; which is 8bpp ?
CMP R7, #&800 ; full 8bpp palette ?
BNE %FT65
BNE %FT51
ORR R6, R6, #ModeFlag_FullPalette
STR R6, [WsPtr, #ModeFlags] ; set the full palette flag
MOV R7, #255
STR R7, [WsPtr, #NColour] ; and set the number of colours
MOV LR, #255
STR LR, [WsPtr, #NColour] ; and set the number of colours
51
LDRB LR, [WsPtr, #SpriteMaskSelect]
TEQ LR, #SpriteReason_SwitchOutputToSprite
BEQ %FT52
LDR LR, [R2, #spMode]
TST LR, #&80000000
ORRNE R6, R6, #ModeFlag_GreyscalePalette+ModeFlag_FullPalette ; alpha masks are 256 greyscale
STRNE R6, [WsPtr, #ModeFlags]
MOVNE LR, #255
STRNE LR, [WsPtr, #NColour]
B %FT65
52
; Redirecting to sprite image, check for greyscale palette
CMP R0, #3
BHI %FT65
TSTEQ R6, #ModeFlag_FullPalette ; 63 colour can't be greyscale
TEQNE R7, #0 ; If no palette then (probably) also not greyscale
BEQ %FT65
ADD R8, R2, #spPalette
53
LDR LR, [R8], #4
EOR LR, LR, LR, LSL #8
CMP LR, #&10000
BHS %FT65
SUBS R7, R7, #4
BGT %BT53
ORR R6, R6, #ModeFlag_GreyscalePalette
STR R6, [WsPtr, #ModeFlags]
65
TST R6, #ModeFlag_DoubleVertical
......@@ -385,6 +414,11 @@ SwitchOutputToMask ROUT
BL DefaultWindows
BL Home
90
; If we've just switched back to the screen, make sure the greyscale palette flag is accurate. Easiest way is to copy DisplayModeFlags into ModeFlags.
LDR R2, [WsPtr, #VduSprite]
TEQ R2, #0
LDREQ R2, [WsPtr, #DisplayModeFlags]
STREQ R2, [WsPtr, #ModeFlags]
[ STB ; Change made by TMD 29-May-96, to stop cursor flashing before interlace module has
; fixed up LineLength on Service_SwitchingOutputToSprite
MOV R1, #Service_SwitchingOutputToSprite ; issue the service *first*
......
......@@ -425,7 +425,7 @@ PV_BulkWrite ROUT
TEQNE R7,#17
MOVEQ R0,R11
MOVEQ R1,#1
MOVEQ R1,#1+4
LDREQ R2,[R9],#4
BLEQ UpdateNormalColour
......@@ -433,7 +433,7 @@ PV_BulkWrite ROUT
TEQNE R7,#18
MOVEQ R0,R11
MOVEQ R1,#2
MOVEQ R1,#2+4
LDREQ R2,[R9],#4
BLEQ UpdateNormalColour
......@@ -453,6 +453,38 @@ PV_BulkWrite ROUT
CMP R10,R8
BCC %BT10
; Update greyscale palette mode flag as appropriate
LDR r2, [WsPtr, #DisplayNColour]
CMP r7, #19
CMP r2, #256
BHS %FT90
PHPSEI
LDR r7, [WsPtr, #DisplayModeFlags]
CMP r2, #63
LDR r5, [WsPtr, #FirPalAddr]
MOVEQ r2, #255
LDR r6, [WsPtr, #SecPalAddr]
BIC r7, r7, #ModeFlag_GreyscalePalette
30
LDR r8, [r5], #4
LDR r9, [r6], #4
EOR r8, r8, r8, LSL #8
EOR r9, r9, r9, LSL #8
CMP r8, #&10000
CMPLO r9, #&10000
BHS %FT40
SUBS r2, r2, #1
BGE %BT30
ORR r7, r7, #ModeFlag_GreyscalePalette
40
STR r7, [WsPtr, #DisplayModeFlags]
; Update live ModeFlags if not redirected to sprite
LDR r8, [WsPtr, #VduSprite]
TEQ r8, #0
STREQ r7, [WsPtr, #ModeFlags]
PLP
90
MOV R4,#0
Pull "R0-R3,R5-R11,PC"
......@@ -581,6 +613,7 @@ PointerColour ROUT
;
; in: r0 = index (0..255 for normal, 256 for border, 257..259 for pointer)
; r1 = bit mask of which flash states to update (bit 0 set => 1st, bit 1 set => 2nd)
; bit 2 set to suppress greyscale palette check
; r3 = SBGR
; r4 = SBGR to EOR with to go from 1st to 2nd flash state
......@@ -618,6 +651,7 @@ UpdateSettingStraightRGB EntryS "r2,r5,r6,r7"
;
; in: r0 = index (0..255 for normal, 256 for border, 257..259 for pointer)
; r1 = bit mask of which flash states to update (bit 0 set => 1st, bit 1 set => 2nd)
; bit 2 set to suppress greyscale palette check
; r2 = BBGGRRSS
;
; out: r0, r1, r2 preserved
......@@ -635,6 +669,7 @@ UpdateSettingAndVIDC ALTENTRY
;
; in: r0 = index (0..255 for normal, 256 for border, 257..259 for pointer)
; r1 = bit mask of which flash states to update (bit 0 set => 1st, bit 1 set => 2nd)
; bit 2 set to suppress greyscale palette check
; r3 = BBGGRRSS
; r4 = BBGGRRSS to EOR with to go from 1st to 2nd flash state
; r2, r5, r6, r7, lr stacked
......@@ -734,6 +769,51 @@ UpdateSettingCommon ROUT
Pull "r0-r2,r4,lr"
20
; Update greyscale palette mode flag as appropriate
; NOTE - relies on r3 being 2nd flash state
LDR r2, [WsPtr, #DisplayNColour]
CMP r0, #256
CMPLO r2, #256
CMPLO r1, #4
BHS %FT90
EOR r4, r3, r4 ; r4 = 1st flash state, r3 = 2nd
EOR r8, r3, r3, LSL #8
EOR r9, r4, r4, LSL #8
TST r1, #1
MOVEQ r9, #0 ; treat unmodified flash states as greyscale - the full check below will sort things out properly if required
TST r2, #1
MOVEQ r8, #0
CMP r8, #&10000
CMPLO r9, #&10000
; LO -> palette potentially greyscale, HS -> definitely not greyscale
LDR r7, [WsPtr, #DisplayModeFlags]
BICHS r7, r7, #ModeFlag_GreyscalePalette
BHS %FT40
TST r7, #ModeFlag_GreyscalePalette
BNE %FT90
; Check the full palette for greyscaleness
CMP r2, #63
LDR r5, [WsPtr, #FirPalAddr]
MOVEQ r2, #255
LDR r6, [WsPtr, #SecPalAddr]
30
LDR r8, [r5], #4
LDR r9, [r6], #4
EOR r8, r8, r8, LSL #8
EOR r9, r9, r9, LSL #8
CMP r8, #&10000
CMPLO r9, #&10000
BHS %FT90
SUBS r2, r2, #1
BGE %BT30
ORR r7, r7, #ModeFlag_GreyscalePalette
40
STR r7, [WsPtr, #DisplayModeFlags]
; Update live ModeFlags if not redirected to sprite
LDR r8, [WsPtr, #VduSprite]
TEQ r8, #0
STREQ r7, [WsPtr, #ModeFlags]
90
PLP
Pull "r8, r9"
EXITS ; restore registers, claim vector
......
......@@ -2261,19 +2261,36 @@ ScreenMode_SelectDevice ROUT
BEQ %FT10
! 0, "GVTODO - API to disable a driver"
10
CMP r1, #GraphicsVInvalid
STR r1, [WsPtr, #CurrentGraphicsVDriver]
; Issue service call to indicate change is coming
MOV r0, #DisplayChanged_Changing
MOV r2, r1
MOV r1, #Service_DisplayChanged
MOV r3, #0
IssueService
; Call InitialiseMode to select a mode to use for this new driver
CMP r2, #GraphicsVInvalid
BLNE InitialiseMode
BVS %FT15
; Success!
MOV r0, #DisplayChanged_Changed
IssueService
MOV r1, r5
EXIT VC
EXIT
15
; Something went wrong trying to activate the new driver
; Try and restore the old one
STR r0, [sp] ; Return the error to the caller
STR r1, [WsPtr, #CurrentGraphicsVDriver]
CMP r1, #GraphicsVInvalid
STR r5, [WsPtr, #CurrentGraphicsVDriver]
MOV r0, #DisplayChanged_Changing
MOV r2, r5
IssueService
CMP r5, #GraphicsVInvalid
BLNE InitialiseMode
; TODO - Try harder if this 2nd call fails (e.g. try all drivers in turn)
MOV r0, #DisplayChanged_Changed
IssueService
MOV r1, r5
SETV
EXIT
20
......@@ -2960,7 +2977,7 @@ ScreenMode_RegisterDriver ROUT
;
ScreenMode_StartDriver ROUT
Entry "r0-r1"
Entry "r0-r3"
VDWS WsPtr
; Validate driver number
CMP r1, #MaxGraphicsVDrivers
......@@ -2974,11 +2991,19 @@ ScreenMode_StartDriver ROUT
BEQ %FT10
; Mark as started
STR r0, [r11, #GVDriver_StateFlags]
! 0, "GVTODO - Issue service call" ; Service_DisplayStatus doesn't make much sense here, since we aren't using ROL's format of display descriptor
; Issue a service call to indicate new driver is ready to go
; For simplicity ROL's Service_DisplayStatus is used. However the
; display descriptor is empty as we don't (currently) use them.
MOV r0, #DisplayStatus_Registered
MOV r2, r1
MOV r1, #Service_DisplayStatus
ADR r3, dummy_display_descriptor
IssueService
; If we don't have a driver yet, use this one
LDR r0, [WsPtr, #CurrentGraphicsVDriver]
CMP r0, #GraphicsVInvalid
MOVEQ r0, #ScreenModeReason_SelectDevice
MOVEQ r1, r2
SWIEQ XOS_ScreenMode
; Swallow any error - just because the driver can't be used as the default driver it doesn't mean that it failed to start
CLRV
......@@ -2988,6 +3013,9 @@ ScreenMode_StartDriver ROUT
ADRL r0, ErrorBlock_BadGDriver
B ScreenMode_TranslateAndReturnError
dummy_display_descriptor
DCD 0
;**************************************************************************
;
......@@ -3003,7 +3031,7 @@ ScreenMode_StartDriver ROUT
;
ScreenMode_StopDriver ROUT
Entry "r0-r1"
Entry "r0-r3"
VDWS WsPtr
; Validate driver number
CMP r1, #MaxGraphicsVDrivers
......@@ -3023,7 +3051,12 @@ ScreenMode_StopDriver ROUT
; Give up if the driver failed to stop (shouldn't really happen, as it'll be the driver making the call to StopDriver)
STRVS r0, [sp]
EXIT VS
! 0, "GVTODO - Issue service call" ; Service_DisplayStatus doesn't make much sense here, since we aren't using ROL's format of display descriptor
; Issue Service_DisplayStatus to indicate driver stopping
MOV r0, #DisplayStatus_Deregistered
MOV r2, r1
MOV r1, #Service_DisplayStatus
MOV r3, #0
IssueService
; Mark as stopped
LDR r0, [r11, #GVDriver_StateFlags]
BIC r0, r0, #GVDriverState_Started
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment