Commit bcc668c7 authored by Jeffrey Lee's avatar Jeffrey Lee

Evict ECFIndex and PalIndex from VDU workspace

Detail:
  ECFIndex and PalIndex claim to be mode variables, but it's impossible for extension modes to specify their values.
  Since they're easy to calculate from the ModeFlags and Log2BPP values, drop them from the mode workspace (+ table of builtin modes) and calculate them on the fly instead.
  File changes:
  - hdr/KernelWS - Drop ECFIndex & PalIndex from workspace
  - s/vdu/vdumodes - Adjust workspace definition, drop ECFIndex & PalIndex values from VWSTAB
  - s/vdu/vdudriver - Remove now-redundant copy loop from ModeChangeSub. Remove code from GenerateModeSelectorVars that sets up the ECFIndex & PalIndex values on the stack
  - s/vdu/vdugrafl - Adjust copy loop in SwitchOutputToSprite/Mask
  - s/vdu/vdupalette, s/vdu/vdupalxx - Add GetPalIndex routine to generate PalIndex on the fly. Drop the obsolete 16bpp palette/gamma table and shuffle the other entries to simplify GetPalIndex a bit.
  - s/vdu/vduplot - Add GetECFIndex routine to generate ECFIndex on the fly. Also, fix things so that mode 0 isn't the only rectangular-pixel mode which uses the special rectangular-pixel ECF patterns (index 0 vs. index 4). Fiddle with ExportedHLine a bit to avoid an out-of-range ADR.
  - s/NewReset - Fix UAL warning for MOV R0, AppSpaceStart. Adjust memset to not assume 512KB is the correct amount
Admin:
  Tested on Raspberry Pi 3


Version 6.11. Tagged as 'Kernel-6_11'
parent c5569c81
......@@ -11,13 +11,13 @@
GBLS Module_HelpVersion
GBLS Module_ComponentName
GBLS Module_ComponentPath
Module_MajorVersion SETS "6.10"
Module_Version SETA 610
Module_MajorVersion SETS "6.11"
Module_Version SETA 611
Module_MinorVersion SETS ""
Module_Date SETS "08 Jul 2018"
Module_ApplicationDate SETS "08-Jul-18"
Module_Date SETS "14 Jul 2018"
Module_ApplicationDate SETS "14-Jul-18"
Module_ComponentName SETS "Kernel"
Module_ComponentPath SETS "castle/RiscOS/Sources/Kernel"
Module_FullVersion SETS "6.10"
Module_HelpVersion SETS "6.10 (08 Jul 2018)"
Module_FullVersion SETS "6.11"
Module_HelpVersion SETS "6.11 (14 Jul 2018)"
END
/* (6.10)
/* (6.11)
*
* This file is automatically maintained by srccommit, do not edit manually.
* Last processed by srccommit version: 1.1.
*
*/
#define Module_MajorVersion_CMHG 6.10
#define Module_MajorVersion_CMHG 6.11
#define Module_MinorVersion_CMHG
#define Module_Date_CMHG 08 Jul 2018
#define Module_Date_CMHG 14 Jul 2018
#define Module_MajorVersion "6.10"
#define Module_Version 610
#define Module_MajorVersion "6.11"
#define Module_Version 611
#define Module_MinorVersion ""
#define Module_Date "08 Jul 2018"
#define Module_Date "14 Jul 2018"
#define Module_ApplicationDate "08-Jul-18"
#define Module_ApplicationDate "14-Jul-18"
#define Module_ComponentName "Kernel"
#define Module_ComponentPath "castle/RiscOS/Sources/Kernel"
#define Module_FullVersion "6.10"
#define Module_HelpVersion "6.10 (08 Jul 2018)"
#define Module_LibraryVersionInfo "6:10"
#define Module_FullVersion "6.11"
#define Module_HelpVersion "6.11 (14 Jul 2018)"
#define Module_LibraryVersionInfo "6:11"
......@@ -542,8 +542,6 @@ LineLength # 4 ; Length of one pixel row in bytes
NColour # 4 ; Number of colours minus 1
; End of word mode variables
YShftFactor # 4 ; Number of places to shift YCoord in address generation after
; multiplying by 5, holds
; 7,6,5 or 4 for 8,4,2 or 1 bits per pixel (640x256 mode) or
......@@ -563,15 +561,13 @@ Log2BPC # 4 ; Log to base 2 of BytesPerChar ie (0,1,2,3,4)
Log2BPP # 4 ; Log to base 2 of BitsPerPix ie (0,1,2,3)
ECFIndex # 4 ; Index into default ECF tables
ScrRCol # 4 ; Maximum column number in this screen mode
ScrBRow # 4 ; Maximum row number in this screen mode
PalIndex # 4 ; Index into palette tables (0,1,2,3)
; End of table-initialised workspace
# 8 ; SPARE
; Next 3 must be together in this order !
XShftFactor # 4 ; Number of places to shift XCoord in address generation,
......
......@@ -276,12 +276,12 @@ conversionSWIfill
RSB R1, R1, #0 ; should make it easier to debug any ROM init failures.
SWI XOS_ChangeDynamicArea
LDR R1, =ZeroPage
LDR R0, [R1, #AplWorkSize]
STR R0, [R1, #MemLimit]
LDR R2, [R1, #AplWorkSize]
STR R2, [R1, #MemLimit]
MOV R0, AppSpaceStart
MOV R0, #AppSpaceStart
MOV R1, #0
MOV R2, #512*1024
SUB R2, R2, R0
BL memset ; Clear AplSpace
DebugTX "InitVectors"
......
......@@ -962,16 +962,6 @@ mchsub_3
LDR R6, [R13, #wkModeFlags]
STR R6, [WsPtr, #DisplayModeFlags]
MOV R2, #wkend-wkdispstart ; number of bytes to do
ADD R1, R13, #wkdispstart
ADD R4, WsPtr, #PalIndex ; first display mode variable
15
LDR R3, [R1], #4 ; copy variables
STR R3, [R4], #4
SUBS R2, R2, #4 ; loop until all done
BNE %BT15
; initialise any values which SwitchOutput refers to
LDR R4, [R13, #wkLineLength]
......@@ -980,7 +970,8 @@ mchsub_3
; now set up other mode variables by calling SwitchOutput
ADD R3, WsPtr, #VduSaveArea+InitFlag
STR R2, [R3] ; indicate uninitialised (R2=0)
MOV R2, #0
STR R2, [R3] ; indicate uninitialised
TST R6, #ModeFlag_Teletext
MOVNE R3, #0 ; if teletext, then no save area
MOVEQ R3, #1 ; else MOS's save area
......@@ -1459,12 +1450,6 @@ GenerateModeSelectorVars Entry "r0,r1,r3-r8,r10-r12"
ADR lr, NColourTable
LDR lr, [lr, r6, LSL #2] ; load NColour value
STR lr, [r9, #wkNColour]
ADR lr, PalIndexTable
LDRB lr, [lr, r6]
STR lr, [r9, #wkPalIndex]
ADR lr, ECFIndexTable
LDRB lr, [lr, r6]
STR lr, [r9, #wkECFIndex]
MOV lr, #0
STR lr, [r9, #wkYShftFactor] ; yshftfactor = 0 (obsolete)
......@@ -1523,10 +1508,6 @@ GenerateModeSelectorVars Entry "r0,r1,r3-r8,r10-r12"
ADRNEL r0, ErrorBlock_BadPixelDepth
BNE %FT90
]
; Fixup PalIndex
CMP r0, #255
MOVLS r0, #4
STRLS r0, [r9, #wkPalIndex]
; Massage ScreenSize, needs to be large enough for two screen banks
LDR r0, [r9, #wkScreenSize]
MOV r0, r0, LSL #1
......@@ -1641,14 +1622,6 @@ GenerateModeSelectorVars Entry "r0,r1,r3-r8,r10-r12"
STR r0, [r9, #wkLog2BPC]
STR r0, [r9, #wkLog2BPP]
ADR r1, PalIndexTable
LDRB r1, [r1, r0]
STR r1, [r9, #wkPalIndex]
ADR r1, ECFIndexTable
LDRB r1, [r1, r0]
STR r1, [r9, #wkECFIndex]
CLRV
EXIT
......@@ -1725,10 +1698,6 @@ NColourTable & NColour_0, NColour_1, NColour_2
& 4095 ; 4K sprite
& NColour_5, NColour_5 ; YCbCr 422 & 420 (not supported)
ASSERT . - NColourTable = (SpriteType_RO5MAX-1)*4
PalIndexTable = 0, 1, 2, 3, 7, 7 ; TODO get rid of palette 6 if VIDC mangling is gone for good
ALIGN ; makes ECFIndexTable more accessible
ECFIndexTable = 4, 2, 3, 5, 5, 5
ALIGN
MakeErrorBlock BadPixelDepth
MakeErrorBlock Sprite_BadDPI
......
......@@ -204,12 +204,10 @@ SwitchOutputToMask ROUT
STR R8, [WsPtr, #ScrRCol]
STR R10, [WsPtr, #ScrBRow]
LDR R0,[R11, #wkNColour]
STR R0,[WsPtr, #NColour] ; copy number of colours -1
ADD R11, R11, #wkmiddle
MOV R0, #wkmidend-wkmiddle ; number of bytes to do
ADD R1, WsPtr, #YShftFactor ; first mode variable that we do
ASSERT :INDEX: wkmiddle == :INDEX: wkNColour
ADD R1, WsPtr, #NColour ; first mode variable that we do
40
LDR R5, [R11], #4 ; copy byte from mode table
......
......@@ -1024,28 +1024,27 @@ Vwstab
^ 0
wkstart # 0
; values which are calculated from sprite header when switching to sprite
wkScreenSize # 4
wkXWindLimit # 4
wkYWindLimit # 4
wkLineLength # 4
wkNColour # 4 ; DDV; defined to be a word (17-Sep-92)
wkmiddle # 0
; values which are taken from pushed mode info (from wkmiddle ... wkmidend)
wkNColour # 4
wkYShftFactor # 4
wkModeFlags # 4
wkXEigFactor # 4
wkYEigFactor # 4
wkLog2BPC # 4
wkLog2BPP # 4
wkECFIndex # 4
wkmidend # 0
; these are also taken from sprite header
wkScrRCol # 4
wkScrBRow # 4
wkdispstart # 0
wkPalIndex # 4
wkend # 0
wksize * wkend-wkstart
wkwordsize * (wksize + 3) :AND: :NOT: 3
wklim * wksize-(wkmiddle-wkstart)
;VIDC list type 3 size (hardware independent video controller list)
;
......@@ -1065,7 +1064,7 @@ M47S * 360*480/8
M50S * 320*240/8
MACRO
$label VWSTAB $BaseMode, $ScreenSize,$LineLength,$XWindLimit,$YWindLimit,$YShftFactor, $XEigFactor,$YEigFactor,$NColour,$ScrRCol,$ScrBRow,$Log2BPC,$Log2BPP,$PalIndex, $ECFIndex,$ModeFlags
$label VWSTAB $BaseMode, $ScreenSize,$LineLength,$XWindLimit,$YWindLimit,$YShftFactor, $XEigFactor,$YEigFactor,$NColour,$ScrRCol,$ScrBRow,$Log2BPC,$Log2BPP,$ModeFlags
$label
LCLS ScrSize
LCLA xres
......@@ -1082,86 +1081,86 @@ scrsz SETA $ScreenSize
& scrsz
& $XWindLimit, $YWindLimit, $LineLength, $NColour
& $YShftFactor, $ModeFlags, $XEigFactor, $YEigFactor
& $Log2BPC, $Log2BPP, $ECFIndex
& $ScrRCol, $ScrBRow, $PalIndex
& $Log2BPC, $Log2BPP
& $ScrRCol, $ScrBRow
ALIGN
MEND
VW_0 VWSTAB 0, 20K, 80, 639,255,4,1,2, 1, 79, 31,0,0,0,1,0 ; MODE 0
VW_1 VWSTAB 1, 20K, 80, 319,255,4,2,2, 3, 39, 31,1,1,1,2,0 ; MODE 1
VW_2 VWSTAB 2, 40K,160, 159,255,5,3,2,15, 19, 31,3,2,2,3,0 ; MODE 2
VW_3 VWSTAB 3, 40K,160, 639,249,5,1,2, 1, 79, 24,1,1,0,0,ModeFlag_NonGraphic+ModeFlag_GapMode+ModeFlag_BBCGapMode ; MODE 3
VW_4 VWSTAB 4, 20K, 80, 319,255,4,2,2, 1, 39, 31,1,0,0,4,0 ; MODE 4
VW_5 VWSTAB 5, 20K, 80, 159,255,4,3,2, 3, 19, 31,2,1,1,2,0 ; MODE 5
VW_6 VWSTAB 6, 20K, 80, 319,249,4,2,2, 1, 39, 24,1,1,0,0,ModeFlag_NonGraphic+ModeFlag_GapMode+ModeFlag_BBCGapMode ; MODE 6
VW_0 VWSTAB 0, 20K, 80, 639,255,4,1,2, 1, 79, 31,0,0,0 ; MODE 0
VW_1 VWSTAB 1, 20K, 80, 319,255,4,2,2, 3, 39, 31,1,1,0 ; MODE 1
VW_2 VWSTAB 2, 40K,160, 159,255,5,3,2,15, 19, 31,3,2,0 ; MODE 2
VW_3 VWSTAB 3, 40K,160, 639,249,5,1,2, 1, 79, 24,1,1,ModeFlag_NonGraphic+ModeFlag_GapMode+ModeFlag_BBCGapMode ; MODE 3
VW_4 VWSTAB 4, 20K, 80, 319,255,4,2,2, 1, 39, 31,1,0,0 ; MODE 4
VW_5 VWSTAB 5, 20K, 80, 159,255,4,3,2, 3, 19, 31,2,1,0 ; MODE 5
VW_6 VWSTAB 6, 20K, 80, 319,249,4,2,2, 1, 39, 24,1,1,ModeFlag_NonGraphic+ModeFlag_GapMode+ModeFlag_BBCGapMode ; MODE 6
[ TTX256
ASSERT HiResTTX
VW_7 VWSTAB 7,640K,640, 639,499,5,1,1,255,39, 24,3,3,4,0,ModeFlag_NonGraphic+ModeFlag_GapMode+ModeFlag_Teletext+ModeFlag_DoubleVertical+ModeFlag_FullPalette ; MODE 7
VW_7 VWSTAB 7,640K,640, 639,499,5,1,1,255,39, 24,3,3,ModeFlag_NonGraphic+ModeFlag_GapMode+ModeFlag_Teletext+ModeFlag_DoubleVertical+ModeFlag_FullPalette ; MODE 7
|
[ HiResTTX
VW_7 VWSTAB 7,320K,320, 639,499,5,1,1,15, 39, 24,2,2,4,0,ModeFlag_NonGraphic+ModeFlag_GapMode+ModeFlag_Teletext+ModeFlag_DoubleVertical ; MODE 7
VW_7 VWSTAB 7,320K,320, 639,499,5,1,1,15, 39, 24,2,2,ModeFlag_NonGraphic+ModeFlag_GapMode+ModeFlag_Teletext+ModeFlag_DoubleVertical ; MODE 7
|
VW_7 VWSTAB 7, 80K,160, 319,249,5,2,2,15, 39, 24,2,2,4,0,ModeFlag_NonGraphic+ModeFlag_GapMode+ModeFlag_Teletext ; MODE 7
VW_7 VWSTAB 7, 80K,160, 319,249,5,2,2,15, 39, 24,2,2,ModeFlag_NonGraphic+ModeFlag_GapMode+ModeFlag_Teletext ; MODE 7
]
]
VW_8 VWSTAB 8, 40K,160, 639,255,5,1,2, 3, 79, 31,1,1,1,2,0 ; MODE 8
VW_9 VWSTAB 9, 40K,160, 319,255,5,2,2,15, 39, 31,2,2,2,3,0 ; MODE 9
VW_10 VWSTAB 10, 80K,320, 159,255,6,3,2,63, 19, 31,4,3,3,5,0 ; MODE 10
VW_11 VWSTAB 11, 40K,160, 639,249,5,1,2, 3, 79, 24,1,1,1,2,ModeFlag_GapMode ; MODE 11
VW_12 VWSTAB 12, 80K,320, 639,255,6,1,2,15, 79, 31,2,2,2,3,0 ; MODE 12
VW_13 VWSTAB 13, 80K,320, 319,255,6,2,2,63, 39, 31,3,3,3,5,0 ; MODE 13
VW_14 VWSTAB 14, 80K,320, 639,249,6,1,2,15, 79, 24,2,2,2,3,ModeFlag_GapMode ; MODE 14
VW_15 VWSTAB 15,160K,640, 639,255,7,1,2,63, 79, 31,3,3,3,5,0 ; MODE 15
VW_16 VWSTAB 16,132K,528,1055,255,0,1,2,15,131, 31,2,2,2,3,0 ; MODE 16
VW_17 VWSTAB 17,132K,528,1055,249,0,1,2,15,131, 24,2,2,2,3,ModeFlag_GapMode ; MODE 17
VW_18 VWSTAB 18, 40K, 80, 639,511,4,1,1, 1, 79, 63,0,0,0,4,0 ; MODE 18
VW_19 VWSTAB 19, 80K,160, 639,511,5,1,1, 3, 79, 63,1,1,1,2,0 ; MODE 19
VW_20 VWSTAB 20,160K,320, 639,511,6,1,1,15, 79, 63,2,2,2,3,0 ; MODE 20
VW_21 VWSTAB 21,320K,640, 639,511,7,1,1,63, 79, 63,3,3,3,5,0 ; MODE 21
VW_22 VWSTAB 22,108K,384, 767,287,0,0,1,15, 95, 35,2,2,2,3,0 ; MODE 22
VW_23 VWSTAB 23,M23S,144,1151,895,0,1,1, 1,143, 55,0,0,5,4,ModeFlag_HiResMono+ModeFlag_DoubleVertical ; MODE 23
VW_24 VWSTAB 24,264K,1056,1055,255,0,1,2,63,131,31,3,3,3,5,0 ; MODE 24
VW_25 VWSTAB 25,M25S , 80, 639,479,4,1,1, 1, 79, 59,0,0,0,4,0 ; MODE 25
VW_26 VWSTAB 26,M25S*2,160, 639,479,5,1,1, 3, 79, 59,1,1,1,2,0 ; MODE 26
VW_27 VWSTAB 27,M25S*4,320, 639,479,6,1,1,15, 79, 59,2,2,2,3,0 ; MODE 27
VW_28 VWSTAB 28,M25S*8,640, 639,479,7,1,1,63, 79, 59,3,3,3,5,0 ; MODE 28
VW_29 VWSTAB 29,M31S ,100, 799,599,0,1,1, 1, 99, 74,0,0,0,4,0 ; MODE 29
VW_30 VWSTAB 30,M31S*2,200, 799,599,0,1,1, 3, 99, 74,1,1,1,2,0 ; MODE 30
VW_31 VWSTAB 31,M31S*4,400, 799,599,0,1,1,15, 99, 74,2,2,2,3,0 ; MODE 31
VW_32 VWSTAB 32,M31S*8,800, 799,599,0,1,1,63, 99, 74,3,3,3,5,0 ; MODE 32
VW_33 VWSTAB 33, 27K, 96, 767,287,0,1,2, 1, 95, 35,0,0,0,4,0 ; MODE 33
VW_34 VWSTAB 34, 54K,192, 767,287,0,1,2, 3, 95, 35,1,1,1,2,0 ; MODE 34
VW_35 VWSTAB 35,108K,384, 767,287,0,1,2,15, 95, 35,2,2,2,3,0 ; MODE 35
VW_36 VWSTAB 36,216K,768, 767,287,0,1,2,63, 95, 35,3,3,3,5,0 ; MODE 36
VW_37 VWSTAB 37,M37S ,112, 895,351,0,1,2, 1,111, 43,0,0,0,4,0 ; MODE 37
VW_38 VWSTAB 38,M37S*2,224, 895,351,0,1,2, 3,111, 43,1,1,1,2,0 ; MODE 38
VW_39 VWSTAB 39,M37S*4,448, 895,351,0,1,2,15,111, 43,2,2,2,3,0 ; MODE 39
VW_40 VWSTAB 40,M37S*8,896, 895,351,0,1,2,63,111, 43,3,3,3,5,0 ; MODE 40
VW_41 VWSTAB 41,M41S , 80, 639,351,0,1,2, 1, 79, 43,0,0,0,4,0 ; EGA 1,2,4bpp
VW_42 VWSTAB 42,M41S*2,160, 639,351,0,1,2, 3, 79, 43,1,1,1,2,0 ;
VW_43 VWSTAB 43,M41S*4,320, 639,351,0,1,2,15, 79, 43,2,2,2,3,0 ; 640x352
VW_44 VWSTAB 44,M44S , 80, 639,199,0,1,2, 1, 79, 24,0,0,0,4,0 ; CGA 1,2,4bpp
VW_45 VWSTAB 45,M44S*2,160, 639,199,0,1,2, 3, 79, 24,1,1,1,2,0 ;
VW_46 VWSTAB 46,M44S*4,320, 639,199,0,1,2,15, 79, 24,2,2,2,3,0 ; 640x200
VW_47 VWSTAB 47,M47S*8,360, 359,479,0,2,2,63, 44, 59,3,3,3,5,0 ; PCSoft 360 x 480 x 8bpp
VW_48 VWSTAB 48, 75K,160, 319,479,0,2,1,15, 39, 59,2,2,2,3,0 ; Games 320 x 480 x 4bpp
VW_49 VWSTAB 49, 150K,320, 319,479,0,2,1,63, 39, 59,3,3,3,5,0 ; Games 320 x 480 x 8bpp
VW_50 VWSTAB 50,M50S , 40, 319,239,0,2,2, 1, 39, 29,0,0,0,4,0
VW_51 VWSTAB 51,M50S*2, 80, 319,239,0,2,2, 3, 39, 29,1,1,1,2,0
VW_52 VWSTAB 52,M50S*4,160, 319,239,0,2,2,15, 39, 29,2,2,2,3,0
VW_53 VWSTAB 53,M50S*8,320, 319,239,0,2,2,63, 39, 29,3,3,3,5,0
; $BaseMode $YShftFactor $ScrBRow $ModeFlags
; $ScreenSize $XEigFactor $Log2BPC
; $LineLength $YEigFactor $Log2BPP
; $XWindLimit $NColour $PalIndex
; $YWindLimit $ScrRCol $ECFIndex
VW_8 VWSTAB 8, 40K,160, 639,255,5,1,2, 3, 79, 31,1,1,0 ; MODE 8
VW_9 VWSTAB 9, 40K,160, 319,255,5,2,2,15, 39, 31,2,2,0 ; MODE 9
VW_10 VWSTAB 10, 80K,320, 159,255,6,3,2,63, 19, 31,4,3,0 ; MODE 10
VW_11 VWSTAB 11, 40K,160, 639,249,5,1,2, 3, 79, 24,1,1,ModeFlag_GapMode ; MODE 11
VW_12 VWSTAB 12, 80K,320, 639,255,6,1,2,15, 79, 31,2,2,0 ; MODE 12
VW_13 VWSTAB 13, 80K,320, 319,255,6,2,2,63, 39, 31,3,3,0 ; MODE 13
VW_14 VWSTAB 14, 80K,320, 639,249,6,1,2,15, 79, 24,2,2,ModeFlag_GapMode ; MODE 14
VW_15 VWSTAB 15,160K,640, 639,255,7,1,2,63, 79, 31,3,3,0 ; MODE 15
VW_16 VWSTAB 16,132K,528,1055,255,0,1,2,15,131, 31,2,2,0 ; MODE 16
VW_17 VWSTAB 17,132K,528,1055,249,0,1,2,15,131, 24,2,2,ModeFlag_GapMode ; MODE 17
VW_18 VWSTAB 18, 40K, 80, 639,511,4,1,1, 1, 79, 63,0,0,0 ; MODE 18
VW_19 VWSTAB 19, 80K,160, 639,511,5,1,1, 3, 79, 63,1,1,0 ; MODE 19
VW_20 VWSTAB 20,160K,320, 639,511,6,1,1,15, 79, 63,2,2,0 ; MODE 20
VW_21 VWSTAB 21,320K,640, 639,511,7,1,1,63, 79, 63,3,3,0 ; MODE 21
VW_22 VWSTAB 22,108K,384, 767,287,0,0,1,15, 95, 35,2,2,0 ; MODE 22
VW_23 VWSTAB 23,M23S,144,1151,895,0,1,1, 1,143, 55,0,0,ModeFlag_HiResMono+ModeFlag_DoubleVertical ; MODE 23
VW_24 VWSTAB 24,264K,1056,1055,255,0,1,2,63,131,31,3,3,0 ; MODE 24
VW_25 VWSTAB 25,M25S , 80, 639,479,4,1,1, 1, 79, 59,0,0,0 ; MODE 25
VW_26 VWSTAB 26,M25S*2,160, 639,479,5,1,1, 3, 79, 59,1,1,0 ; MODE 26
VW_27 VWSTAB 27,M25S*4,320, 639,479,6,1,1,15, 79, 59,2,2,0 ; MODE 27
VW_28 VWSTAB 28,M25S*8,640, 639,479,7,1,1,63, 79, 59,3,3,0 ; MODE 28
VW_29 VWSTAB 29,M31S ,100, 799,599,0,1,1, 1, 99, 74,0,0,0 ; MODE 29
VW_30 VWSTAB 30,M31S*2,200, 799,599,0,1,1, 3, 99, 74,1,1,0 ; MODE 30
VW_31 VWSTAB 31,M31S*4,400, 799,599,0,1,1,15, 99, 74,2,2,0 ; MODE 31
VW_32 VWSTAB 32,M31S*8,800, 799,599,0,1,1,63, 99, 74,3,3,0 ; MODE 32
VW_33 VWSTAB 33, 27K, 96, 767,287,0,1,2, 1, 95, 35,0,0,0 ; MODE 33
VW_34 VWSTAB 34, 54K,192, 767,287,0,1,2, 3, 95, 35,1,1,0 ; MODE 34
VW_35 VWSTAB 35,108K,384, 767,287,0,1,2,15, 95, 35,2,2,0 ; MODE 35
VW_36 VWSTAB 36,216K,768, 767,287,0,1,2,63, 95, 35,3,3,0 ; MODE 36
VW_37 VWSTAB 37,M37S ,112, 895,351,0,1,2, 1,111, 43,0,0,0 ; MODE 37
VW_38 VWSTAB 38,M37S*2,224, 895,351,0,1,2, 3,111, 43,1,1,0 ; MODE 38
VW_39 VWSTAB 39,M37S*4,448, 895,351,0,1,2,15,111, 43,2,2,0 ; MODE 39
VW_40 VWSTAB 40,M37S*8,896, 895,351,0,1,2,63,111, 43,3,3,0 ; MODE 40
VW_41 VWSTAB 41,M41S , 80, 639,351,0,1,2, 1, 79, 43,0,0,0 ; EGA 1,2,4bpp
VW_42 VWSTAB 42,M41S*2,160, 639,351,0,1,2, 3, 79, 43,1,1,0 ;
VW_43 VWSTAB 43,M41S*4,320, 639,351,0,1,2,15, 79, 43,2,2,0 ; 640x352
VW_44 VWSTAB 44,M44S , 80, 639,199,0,1,2, 1, 79, 24,0,0,0 ; CGA 1,2,4bpp
VW_45 VWSTAB 45,M44S*2,160, 639,199,0,1,2, 3, 79, 24,1,1,0 ;
VW_46 VWSTAB 46,M44S*4,320, 639,199,0,1,2,15, 79, 24,2,2,0 ; 640x200
VW_47 VWSTAB 47,M47S*8,360, 359,479,0,2,2,63, 44, 59,3,3,0 ; PCSoft 360 x 480 x 8bpp
VW_48 VWSTAB 48, 75K,160, 319,479,0,2,1,15, 39, 59,2,2,0 ; Games 320 x 480 x 4bpp
VW_49 VWSTAB 49, 150K,320, 319,479,0,2,1,63, 39, 59,3,3,0 ; Games 320 x 480 x 8bpp
VW_50 VWSTAB 50,M50S , 40, 319,239,0,2,2, 1, 39, 29,0,0,0
VW_51 VWSTAB 51,M50S*2, 80, 319,239,0,2,2, 3, 39, 29,1,1,0
VW_52 VWSTAB 52,M50S*4,160, 319,239,0,2,2,15, 39, 29,2,2,0
VW_53 VWSTAB 53,M50S*8,320, 319,239,0,2,2,63, 39, 29,3,3,0
; $BaseMode $YShftFactor $ScrBRow
; $ScreenSize $XEigFactor $Log2BPC
; $LineLength $YEigFactor $Log2BPP
; $XWindLimit $NColour $ModeFlags
; $YWindLimit $ScrRCol
END
......@@ -100,8 +100,8 @@ SetPal EntryS
TST r1, #4 ; bit 2 set => blue full on
ORRNE r2, r2, #&FF000000
LDRB lr, [WsPtr, #PalIndex]
CMP lr, #3 ; only flash colours if PalIndex = 0, 1 or 2
BL GetPalIndex
CMP r6, #3 ; only flash colours if PalIndex = 0, 1 or 2
BICCS r1, r1, #8
TST r1, #8
......@@ -141,6 +141,34 @@ CallPaletteV
SWI XOS_CallAVector
EXITS
; *****************************************************************************
;
; GetPalIndex - return index of default palette, for VDU hardware
;
;
; out: R6 = palette index
; R3 corrupt
;
GetPalIndex ROUT
; Normally maps to log2bpp
LDRB R6, [WsPtr, #DisplayLog2BPP]
CMP R6, #4
MOVHI R6, #4
MOVHS PC, LR
; BBC gap modes run at lower logical BPP than physical BPP, so palette index needs adjusting too
LDR R3, [WsPtr, #DisplayModeFlags]
TEQ R6, #0
TSTNE R3, #ModeFlag_BBCGapMode
SUBNE R6, R6, #1
; Hi-res mono & (<=8bpp) teletext have special ones too
TST R3, #ModeFlag_Teletext
MOVNE R6, #5
TST R3, #ModeFlag_HiResMono
MOVNE R6, #6
MOV PC, LR
; *****************************************************************************
;
; SWIReadPalette - SWI ReadPalette handler
......
......@@ -97,11 +97,11 @@ PV_SetDefaultPalette ROUT
TST r0, #ModeFlag_GreyscalePalette
BNE %FT30
05
LDR r0, [WsPtr, #PalIndex] ; the new index 0-7
BL GetPalIndex ; the new index 0-6
ADR r1, paldptab
LDR r2, [r1, r0, LSL #2] ; offset from r1 to start of table
ADD r0, r0, #1 ; point to next item
LDR r5, [r1, r0, LSL #2] ; offset from r1 to end of table +1
LDR r2, [r1, r6, LSL #2] ; offset from r1 to start of table
ADD r6, r6, #1 ; point to next item
LDR r5, [r1, r6, LSL #2] ; offset from r1 to end of table +1
TST r2, #&80000000 ; if bit 31 set, it's a routine
BIC r2, r2, #&80000000 ; clear that flag
ADD r2, r2, r1 ; r2 -> start of table
......@@ -195,10 +195,9 @@ paldptab
& paldat2-paldptab ; 4
& paldat4-paldptab ; 16
& (paldat8-paldptab) :OR: &80000000 ; 256 (VIDC10 compatible) - use routine
& (paldatLin-paldptab) :OR: &80000000 ; 16bpp, 32bpp, 256 greys - use routine
& paldatT-paldptab ; teletext mode
& paldatHR-paldptab ; Hi-res mono mode
& (paldat16-paldptab) :OR: &80000000 ; 16 bpp - use routine
& (paldat32-paldptab) :OR: &80000000 ; 32 bpp (or 256 greys - they're identical!) - use routine
& paldatend-paldptab ; end of table marker
paldat1 ; Data for 1 bit modes - only necessary to program registers 0 and 1
......@@ -269,6 +268,48 @@ paldat8 ROUT
BNE %BT10
B FinishDefault
; Linear / greyscale palette or gamma table
paldatLin ROUT
ADR r5, paldatLintab
palmetatab
MOV r1, #3 ; set both halves of palette
MOV r0, #0 ; starting index
10
MOV r8, r5
MOV r2, #0
MOV r6, r0
20
LDR r7, [r8], #4
MOVS r6, r6, LSR #1
ORRCS r2, r2, r7
BNE %BT20
BL UpdateSettingAndVIDC
ADD r0, r0, #1
TEQ r0, #&100
BNE %BT10
B FinishDefault
paldatLintab
[ DefaultSupremacy
& &01010101 ; palette bit 0
& &02020202 ; 1
& &04040404 ; 2
& &08080808 ; 3
& &10101010 ; 4
& &20202020 ; 5
& &40404040 ; 6
& &80808080 ; 7
|
& &01010100 ; palette bit 0
& &02020200 ; 1
& &04040400 ; 2
& &08080800 ; 3
& &10101000 ; 4
& &20202000 ; 5
& &40404000 ; 6
& &80808000 ; 7
]
paldatT ; Data for teletext mode
DCW &0000 ; 0 Black
......@@ -314,71 +355,6 @@ paldatHR ; data for Hi-res mono mode
DCW &0020
DCW &0030
paldat16 ROUT
ADR r5, paldat16tab
palmetatab
MOV r1, #3 ; set both halves of palette
MOV r0, #0 ; starting index
10
MOV r8, r5
MOV r2, #0
MOV r6, r0
20
LDR r7, [r8], #4
MOVS r6, r6, LSR #1
ORRCS r2, r2, r7
BNE %BT20
BL UpdateSettingAndVIDC
ADD r0, r0, #1
TEQ r0, #&100
BNE %BT10
B FinishDefault
paldat16tab
[ DefaultSupremacy
& &00000800 ; palette bit 0
& &00081000 ; 1
& &08102100 ; 2
& &102142FF ; 3
& &21428400 ; 4
& &42840000 ; 5
& &84000000 ; 6
& &00000000 ; 7
|
& &00000800 ; palette bit 0
& &00081000 ; 1
& &08102100 ; 2
& &10214200 ; 3
& &21428400 ; 4
& &42840000 ; 5
& &84000000 ; 6
& &00000000 ; 7
]
paldat32 ROUT
ADR r5, paldat32tab
B palmetatab
paldat32tab
[ DefaultSupremacy
& &01010101 ; palette bit 0
& &02020202 ; 1
& &04040404 ; 2
& &08080808 ; 3
& &10101010 ; 4
& &20202020 ; 5
& &40404040 ; 6
& &80808080 ; 7
|
& &01010100 ; palette bit 0
& &02020200 ; 1
& &04040400 ; 2
& &08080800 ; 3
& &10101000 ; 4
& &20202000 ; 5
& &40404000 ; 6
& &80808000 ; 7
]
paldatend
......
......@@ -681,6 +681,34 @@ SetPatLength ROUT
MSR CPSR_f, R3
MOV PC, R14
; *****************************************************************************
;
; GetECFIndex - Return index of default ECF patterns for mode
;
; Out:
; R0 = table index
; R2 corrupt
;
GetECFIndex ROUT
; Non-graphic modes always get index 0 (empty patterns)
LDR R0, [WsPtr, #ModeFlags]
TST R0, #ModeFlag_NonGraphic
MOVNE R0, #0
MOVNE PC, LR
; Other modes are dependent on BPP
LDR R0, [WsPtr, #Log2BPP]
; Extra hassle for 1bpp, we want two different patterns depending on pixel aspect ratio
CMP R0, #0
LDREQ R2, [WsPtr, #AspectRatio]
CMPEQ R2, #2
MOVEQ R0, #1
LDRNEB R0, [PC, R0] ; 1 or 4 for 1bpp
MOV PC, LR
DCB 4, 2, 3, 5, 5, 5 ; 1bpp-32bpp
ALIGN
; *****************************************************************************
;
; DefaultEcfPattern - Setup all 4 ecf patterns for this mode
......@@ -694,7 +722,9 @@ DefaultEcfPattern ROUT
MOV R0, #0
STR R0, [WsPtr, #BBCcompatibleECFs] ;Select BBC compatible ECF mode
LDR R0, [WsPtr, #ECFIndex]
Push "lr"
BL GetECFIndex
Pull "lr"
ADR R1, DefEcfTb
ADD R0, R1, R0, LSL #4 ; 16 bytes per entry
ADD R1, WsPtr, #Ecf1
......@@ -705,39 +735,39 @@ DefaultEcfPattern ROUT
B SetColour ; update FgEcf & BgEcf in case they are Ecfs
DefEcfTb ; Table of default ECFs, indexed by ECFIndex (a mode variable)
DefEcfTb ; Table of default ECFs, indexed by ECFIndex
; Modes 3,6,7
; Modes 3,6,7 (i.e. non-graphic modes)
& 0
& 0
& 0
& 0
; Mode 0
; Mode 0 (i.e. 1:2 eigen 1bpp modes)
& &00330033 ;Dark grey (3 black, 1 white)
& &CC33CC33 ;Grey (2 black, 2 white)
& &CCFFCCFF ;Light grey (1 black, 3 white)
& &030C30C0 ;Hatching
; Modes 1,5,8,11,19
; Modes 1,5,8,11,19 (i.e. 2bpp modes)
& &55665566 ;Red orange (3 red, 1 yellow)
& &99669966 ;Orange (2 red, 2 yellow)
& &99AA99AA ;Yellow orange (1 red, 3 yellow)
& &BBEEBBEE ;Cream (2 white, 2 yellow)
; Modes 2,9,12,14,16,17,20(,21)
; Modes 2,9,12,14,16,17,20(,21) (i.e. 4bpp modes)
& &31133113 ;Orange (2 red, 2 yellow)
& &51155115 ;Pink (2 red, 2 magenta)
& &32233223 ;Yellow green (2 green, 2 yellow)
& &37733773 ;Cream (2 white, 2 yellow)
; Modes 4,18,22,23
; Modes 4,18,22,23 (i.e. square pixel 1bpp modes)