Commit 907aab31 authored by Neil Turton's avatar Neil Turton
Browse files

NCOS 1.06 Imported from Zip drive

parent d5db212e
......@@ -4,10 +4,10 @@
GBLS CurrentDate
GBLS CurrentTime
CurrentDate SETS "13 Apr 1995"
CurrentDate SETS "28 Sep 1995"
CurrentTime SETS "14:00:00"
GBLA VersionNumber
VersionNumber SETA 435
VersionNumber SETA 439
END
......@@ -302,6 +302,9 @@ intcolour_selecttable
intcolour_selecttable_doneflags
Debug mjs,"select_table stored effective R5 = ",R5
STR R5, ctrans_selgentab_R5 ;store the R5 flags value (zapped to 0 as appropriate)
[ Medusa
BL intcolour_16or32 ;Is source mode 16 or 32bpp?
STRVS R0,[sp,#CallerR0] ;Poke error return address onto the stack
......@@ -324,6 +327,8 @@ intcolour_generatetable
Push "R0-R9,LR" ;Preserve the registers, return address already pushed
STR R5, ctrans_selgentab_R5 ;store the entry R5 flags value
[ Medusa
BL intcolour_16or32 ;Is source mode 16 or 32bpp?
STRVS R0,[sp,#CallerR0] ;Poke error return address onto the stack
......@@ -378,8 +383,8 @@ intcolour_not_jpeg
SWIVC XColourTrans_GenerateTable
BVS intcolour_table_errored
LDR R5, [sp, #24] ; get caller R5 back (interested in bit4 'wide')
Debug mjs,"mjs: generate table, caller R5 = ",R5
LDR R5,ctrans_selgentab_R5 ; get effective caller R5 back (interested in bit4 'wide')
Debug mjs,"mjs: generate/select table effective R5 = ",R5
; R8 -> buffer to be filled with pixtrans values
; R9 => start of the table to be processed
......
......@@ -196,6 +196,7 @@ FontHandleEnsure SETL {TRUE} ;Apply the bug fix
; Setting the 'debug' variable to FALSE will turn off all NDR debugging
debug SETL {FALSE} :LAND: BeingDeveloped
;debug SETL {TRUE}
hostvdu SETL {TRUE}
debug_flush SETL {FALSE} :LAND: (:LNOT: hostvdu)
......
......@@ -141,6 +141,8 @@ fontpaint_spacecount # 4 ;Number of spaces within the line
fontpaint_initmatrix # 4*6 ;Matrix to use at start of day
fontpaint_matrix # 4*6
ctrans_selgentab_R5 # 4 ;R5 for _SelectTable or _GenerateTable
jpeg_ctransflag # 4 ;limits scope of ColourTrans intercept for JPEG's
jpeg_maxmemory # 4 ;max memory SpriteExtend requires for any JPEG's
......@@ -148,6 +150,9 @@ counting_pass # 4 ;flag - true if asking for rectangles only to
; count such things as JPEG memory requirements
counting_nextrect # 4 ;next user rectangle in counting pass
; mjs fudge
PDriverDPMaxMemBuff # 32
; Any extra chunk of RMA that is temporarily claimed during a call should
; have its address placed here, so that it can be released on a soft break.
......
......@@ -246,7 +246,7 @@ image_scaling
STR R4,job_spritescale+28 ; (Y3)
STR R4,job_spritescale+20 ; (Y2)
ADR R6,job_spritescale ; R6 -> SpriteOp 56 style destination block
ADRL R6,job_spritescale ; R6 -> SpriteOp 56 style destination block
Pull "R0-R4,R8,PC"
......
......@@ -57,7 +57,7 @@ job_htonealign # 1 ; current alignment within the halftone
job_sarea_change # 4 ; amount we have changed system sprite area by
job_spritearea # 4 ; which sprite area we are using
job_linebuffer # 12 * (max_passes+1)
job_linebuffer # 12 * (max_passes+2)
; name(s) of/pointer to our sprite for buffering lines
job_currentbuffer # 4 ; pointer to (name of) sprite we are currently
; redirecting output to
......
......@@ -24,7 +24,7 @@ Font SETD false
FontSlaving SETD false
ManageJob SETD false
PageBox SETD false
PageBoxMem SETD true
PageBoxMem SETD false
Plot SETD false
Private SETD false
Privatemjs SETD true
......@@ -34,8 +34,8 @@ Info SETD false
TransSprite SETD false
xx SETD false
CallPDumper SETD false
Dump SETD true
JPEG SETD true
Dump SETD false
JPEG SETD false
mjs SETD false
GBLL DescribeWS
......
......@@ -349,7 +349,10 @@ managejob_abortalt ROUT
[ MultiplePasses
ADR r0, job_linebuffer+12
LDRB r2, job_strip_type
CMP r2, #3 ;multiple pass 16m colours
LDRB r2, job_no_passes
ADDEQ r2,r2,#1
00
BL losebuffersprite
ADD r0, r0, #12
......
......@@ -338,8 +338,10 @@ pagebox_memory_setup ROUT
MUL r0, r2, r0
BL Divide
[ Libra1
ADD R0, R0, #3
BIC R0, R0, #3
;make width a multiple of 8 (may be assumed by newer, faster
;code in PDumperSpt and dumper modules)
ADD R0, R0, #7
BIC R0, R0, #7
]
STR r0, job_linelength
......@@ -459,11 +461,11 @@ no_allocate1
ADD R3, R0, #2
LDRB R0, job_strip_type
CMP R0, #1
MOVEQ R3, R3, LSL #2
MOVEQ R3, R3, LSL #2 ;for grey strip type - 4 bytes per pixel
BEQ skip_past
CMP R0, #0
BEQ skip_past
MOV R3, R3, LSL #4
MOV R3, R3, LSL #4 ;for colour strip types - 16 bytes per pixel (4 per component)
skip_past
LDR R0, job_halftoneX
AND LR, R0, #255
......@@ -485,9 +487,14 @@ halftoned
Pull "R0,R3"
]
; r3 pulled, now = memory required for dump depth * required row width
; Account for multiple passes. These are the output dumps.
[ MultiplePasses
LDRB lr, job_no_passes
LDRB lr, job_strip_type
CMP lr, #3 ;multiple pass 16m colour
LDRB lr, job_no_passes ;no_passes 8-bit buffers
ADDEQ lr,lr,#4 ;strip type 3: + one '32-bit' buffer (4x sized buffer)
MUL r3, lr, r3
]
......@@ -518,10 +525,10 @@ halftoned
; r7 := absolute maximum size of sprite area
[ MultiplePasses
LDR lr, job_sprheadsize
MOV r7, #max_passes+1
MOV r7, #max_passes+2
MLA r7, lr, r7, r0
ADD r7, r7, #SpriteAreaCBsize
;<< ADD r7, r0, #SpriteCBsize*(max_passes+1) + SpriteAreaCBsize
;<< ADD r7, r0, #SpriteCBsize*(max_passes+2) + SpriteAreaCBsize
|
LDR lr, job_sprheadsize
ADD lr, r0, lr, LSL #1
......@@ -546,7 +553,10 @@ halftoned
ADD r1, r3, #SpriteAreaCBsize
LDR r5, job_sprheadsize
;<< MOV r5, #SpriteCBsize
LDRB lr, job_strip_type
CMP lr,#3 ;multiple-pass 16m colour
LDRB lr, job_no_passes
ADDEQ lr,lr,#1 ;plus 1 for 32bpp buffer
MLA r1, lr, r5, r1
|
LDR lr, job_sprblocksize
......@@ -564,6 +574,39 @@ halftoned
MOV r5, r1 ;; keep for later
; mjs fudge - respond to system variable 'PDriverDP$MaxMem' - assumed
; to be maximum grabbable in Kbytes
Debug PageBoxMem,"before PDriverDP$MaxMem, min max = ",R5,R7
Push "R0-R4"
ADRL R0, PDriverDPMaxMemName
ADRL R1, PDriverDPMaxMemBuff
MOV R2,#31
MOV R3,#0
MOV R4,#0
SWI XOS_ReadVarVal
BVS no_dpmaxmem
CMP R4,#0 ;must be string
BNE no_dpmaxmem
CMP R2,#0
BLE no_dpmaxmem
CMP R2,#31
BGE no_dpmaxmem
MOV R4,#0
STRB R4,[R1,R2] ;terminate it
MOV R0,#10
SWI XOS_ReadUnsigned
BVS no_dpmaxmem
MOV R4,R2 ;value
Debug PageBoxMem,"PDriverDP$MaxMem (kbytes) = ",R4
MOV R4,R4,LSL #10 ;it's in kbytes
CMP R4,R5
MOVLT R4,R5 ;can't use less than minimum
CMP R7,R4
MOVGT R7,R4 ;ok, so set max useful to read value
Debug PageBoxMem,"after PDriverDP$MaxMem, min max = ",R5,R7
no_dpmaxmem
Pull "R0-R4" ;ignore errors - treat as variable not there
Debug PageBoxMem,"try Wimp_ClaimFreeMemory, bytes = ",R1
SWI XWimp_ClaimFreeMemory
[ {FALSE} ; Libra1 - don't want to check v bit
......@@ -647,7 +690,10 @@ is_a_Medusa
SUB r6, r6, #SpriteAreaCBsize
LDR r0, job_sprheadsize
;<< MOV r0, #SpriteCBsize
LDRB lr, job_strip_type
CMP lr, #3
LDRB lr, job_no_passes
ADDEQ lr, lr,#1
MUL r0, lr, r0
SUB r6, r6, r0
|
......@@ -717,7 +763,10 @@ no_wimp_slot
SUB r2, r2, #SpriteAreaCBsize ;Grab enough space for both control block
LDR r6, job_sprheadsize
;<< MOV r6, #SpriteCBsize
LDRB lr, job_strip_type
CMP lr, #3
LDRB lr, job_no_passes ;Get size of the control block and the number of passes
ADDEQ lr,lr,#1
MUL r6, lr, r6 ;Yeilds: Control block size*number of passes
SUBS r2, r2, r6 ;Remove from the remaining space
|
......@@ -746,7 +795,10 @@ retry_buffer_claim
ADD r3, r3, #SpriteAreaCBsize
LDR r0, job_sprheadsize
;<< MOV r0, #SpriteCBsize
LDRB lr, job_strip_type
CMP lr, #3
LDRB lr, job_no_passes
ADDEQ lr,lr,#1
MUL r0, lr, r0
ADD r3, r3, r0
|
......@@ -817,14 +869,30 @@ buffer_area_set
MultiplyByDumpDepth r5, r6
[ MultiplePasses
; Create no_passes sprites
; Create no_passes(+1) sprites; the extra one (strip type 3 only) is 4x sized, used to
; create 32bpp format for new 16m colour code in PDumperSpt
LDRB r8, job_strip_type
CMP r8, #3 ;multiple pass 16m colour mode
LDRB r8, job_no_passes
ADDEQ r8,r8,#1
ADD r2, r2, #12
01
Push "r8"
LDRB r8, job_strip_type
CMP r8, #3
Pull "r8"
CMPEQ r8,#0
MOVEQ r4,r4,LSL #2 ; 4x size for last one, strip type 3
]
BLVC create_buffer_sprite
BVS %FT99
[ MultiplePasses
Push "r8"
LDRB r8, job_strip_type
CMP r8, #3
Pull "r8"
CMPEQ r8,#0
MOVEQ r4,r4,LSR #2 ;undo 4x for last one, strip type 3
ADD r2, r2, #12
SUBS r8, r8, #1
BGT %BT01
......@@ -937,6 +1005,48 @@ set_sprite_background ROUT
Pull "R0-R2,PC"
]
;
;uses fast code if possible
;
do_copysprite_withrotate
Push "LR"
LDRB R14,job_strip_type
CMP R14,#1 ;8bpp
CMPNE R14,#3 ;24bpp multipass (3x8bpp)
BEQ do_cswr_8bpp
CMP R14,#5
BNE do_cswr_slow
LDRB R14,job_rotation_id
AND R14,R14,#7
CMP R14,#1
BEQ do_cswr_fast_90
CMP R14,#7
BEQ do_cswr_fast_270
do_cswr_slow
BL copysprite_withrotate
Pull "PC"
do_cswr_fast_90
BL copysprite_withrotate_32bpp90
Pull "PC"
do_cswr_fast_270
BL copysprite_withrotate_32bpp270
Pull "PC"
do_cswr_8bpp
LDRB R14,job_rotation_id
AND R14,R14,#7
CMP R14,#1
BEQ do_cswr_fast8_90
CMP R14,#7
BEQ do_cswr_fast8_270
B do_cswr_slow
do_cswr_fast8_90
BL copysprite_withrotate_8bpp90
Pull "PC"
do_cswr_fast8_270
BL copysprite_withrotate_8bpp270
Pull "PC"
; entered with R0 = number of pages
; returns with R0 modified to contain the real number of copies.
start_page
......@@ -963,8 +1073,24 @@ pagebox_real_nextbox ROUT
; see &.Text.RectMaths for an explanation of this code.
; first flip the buffer so that it is correctly aligned for output
;skip flips if simple rotation in 8bpp grey or 24bpp multipass or 32bpp mode (flips
;will be accounted for in fast rotate code)
LDRB R7,job_strip_type
CMP R7,#1 ;8bpp
CMPNE R7,#3 ;24bpp multipass (3x8bpp)
CMPNE R7,#5 ;32bpp
BNE %FT50
LDRB R7,job_rotation_id
AND R7,R7,#7
CMP R7,#1
CMPNE R7,#7
BEQ %FT51
50
Debug PageBoxMem,"pagebox_real_nextbox calling flip_buffer"
BL flip_buffer
BVS %FT99
51
LDR r7, job_currentbuffer
ADR r2, job_linebuffer
CMP r7, r2 ; test for rotated output
......@@ -983,7 +1109,7 @@ pagebox_real_nextbox ROUT
STR r1, job_clipwidth
MOV r0, r7
MOV r1, r2
BL copysprite_withrotate
BL do_copysprite_withrotate
Pull "r0, r1"
01 MOV r3, #0
......@@ -1774,5 +1900,8 @@ calculate_pixel_memory ROUT
]
Pull "pc",,^
PDriverDPMaxMemName
DCB "PDriverDP$MaxMem",0
ALIGN
END
......@@ -15,6 +15,62 @@
; > Sources.PDriverDP.Private
;aims to dump chunk of about 32 rows, subject to remaining height
;and chunk being multiple of dump depth (except last chunk)
;
;entry: R0-R3,R5-R8 set up for CallPDumperForJob
; R4=height remaining for output
;exit R4 updated, R0 updated as necessary
;
dump_one_chunk
Push "R5-R9,LR"
LDRB R9,job_dump_depth
Debug Privatemjs,"dump_one_chunk, dump_depth = ",R9
00 CMP R9,#32
MOVLT R9,R9,LSL #1
BLT %BT00
Debug Privatemjs," chunk_depth,remaining_height = ",R9,R4
Push "R4,R9"
CMP R4,R9
MOVGE R4,R9
Debug Privatemjs," chosen depth for dumper = ",R4
MOV R9,#PDumperReason_OutputDump
BL CallPDumperForJob
Pull "R4,R9"
BVS %FT03
CMP R4,R9
MOVLT R4,R9
SUBS R4,R4,R9 ;new remaining height
BEQ %FT03
[ Libra1
;convert R5 from pixels to bytes
LDRB R8,job_strip_type
CMP R8,#4
MOVEQ R5,R5,LSL #1
CMP R8,#5
MOVEQ R5,R5,LSL #2
]
MUL R8,R9,R5 ;bytes in one dump_depth
LDRB R6,job_no_passes
CMP R6,#1
BLE %FT02
Push "R0"
01
LDR R7,[R0]
ADD R7,R7,R8 ;adjust each pass pixel pointer
STR R7,[R0],#4
SUBS R6,R6,#1
BGT %BT01
LDR R7,[R0]
ADD R7,R7,R8,LSL #2 ;adjust 32bpp buffer pixel pointer
STR R7,[R0]
Pull "R0"
B %FT03
02
ADD R0,R0,R8 ;adjust strip pixel pointer
03
Pull "R5-R9,PC"
; +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
; the main dump routine!
......@@ -31,8 +87,11 @@ dump_current_buffer ROUT
BVS %FT99
LDRB r4, job_no_passes
Debug Privatemjs,"dump_current_buffer, passes=",r4
CMP r4, #1
BLE %FT00
ADD r4,r4,#1 ;one extra for 32bpp buffer
;use job_DrawMatrix as buffer to place pointers to multiple pass sprites
ADR r0, job_DrawMatrix
ADR r3, job_linebuffer+12
01
......@@ -46,6 +105,9 @@ dump_current_buffer ROUT
ADD r3, r3, #12
SUBS r4, r4, #1
BGT %BT01
SUB r3,r3,#12 ;step back from 32bpp buffer
MOV r2, r3
BL get_sprite_address
ADR r0, job_DrawMatrix
B %FT02
......@@ -70,7 +132,6 @@ dump_current_buffer ROUT
LDR r5, [r2, #spWidth] ; r5 = sprite width in words
ADD r5, r5, #1
Push "r9"
; r0 -> sprite pixel data for a single pass plot
LDR r1, jobhandle ; r1 = file handle for job
[ Libra1
......@@ -91,14 +152,41 @@ dump_current_buffer ROUT
LDR r6, job_halftoneX ; r6 = halftone width in byte 0, halftone height in byte 1
ADR r7, job_dump_depth ; r7 -> job workspace
ADR r8, job_pdumper_word ; r8 = pdumper private word
MOV r9, #PDumperReason_OutputDump
BL CallPDumperForJob
Pull "r9" ; preserving r9
BLVC redirect_output
03
; Debug Privatemjs,"dump_one_chunk ptr step w h +",r0,r2,r3,r4,r5
BL dump_one_chunk
BVS %FT99
;check escape state - drop into user mode so that callbacks get a chance to go off
STMFD SP,{LR}^ ;preserve user LR
SUB SP,SP,#4 ;couldn't use write back in banked STMFD
TEQP PC,#0 ;user mode
MOV R0,R0 ;NOP
SWI XOS_ReadEscapeState
BCS %FT98
SWI XOS_EnterOS ;svc mode
LDMFD SP,{LR}^ ;restore user LR
MOV R0,R0 ;NOP
ADD SP,SP,#4
CMP R4,#0
BNE %BT03
BL redirect_output
99 STRVS r0, [stack]
Pull "r0-r8, pc"
98
SWI XOS_EnterOS ;svc mode
LDMFD SP,{LR}^ ;restore user LR
MOV R0,R0 ;NOP
ADD SP,SP,#4
SETV
Pull "r0-r8, pc"
; **********************************************************
; now get all the common subroutines
......
......@@ -595,6 +595,7 @@ divide_and_scale
flip_buffer ROUT
Push "r0-r3, lr"
LDRB lr, job_buffer_marked
CMP lr, #0
......@@ -818,43 +819,42 @@ main_loopy16
]
[ Libra1
Handle_32bpp_rotation
LDR R4, [r1, #spHeight]
ADD r4, r4, #1
MOV R6, R4
LDR R5, [r1, #spWidth]
ADD R5, R5, #1
MOV R7, R5
; now set initial pixel pointers
LDR r7, [r0, #spImage]
ADD r0, r0, r7
; destination copy starts at the first pixel on the last row
LDR r7, [r1, #spImage]
ADD r1, r1, r7 ; point at first byte after sprite
MOV R7, R5
MOV R3, R4, LSL #2
ADD R0, R0, R3
MOV R2, R0
Start_loop32
SUB R2, R2, #4
MOV R0, R2
main_loopy32
LDR LR, [R0], R3
STR LR, [R1], #4
SUBS R5, R5, #1
BGT main_loopy32
MOV R5, R7
SUBS R4, R4, #1
BGT Start_loop32
Push "R8-R11"
LDR R2, [R1, #spHeight]
ADD R2,R2,#1 ;dest height, or source width
LDR R3, [R1, #spWidth]
ADD R3,R3,#1 ;dest width, or source height
; Debug PageBoxMem,"32bpp rotate: source width height = ",R2,R3
LDR R4, [R0, #spImage]
ADD R0,R0,R4 ;R0 -> 1st source pixel
LDR R4, [R1, #spImage]
ADD R1,R1,R4 ;R1 -> 1st dest pixel
MUL R5,R2,R3 ;R5 = (dest height).(dest width)
ADD R1,R1,R5,LSL #2
SUB R1,R1,R3,LSL #2 ;R1 -> 1st dest pixel of last row
MOV R7,R3 ;source row counter
; Debug PageBoxMem,"32bpp rotate:R0 R1 start = ",R0,R1
01
MOV R6,R2 ;source column counter
02
LDR R8,[R0],R2,LSL #2 ;load next 4 pixels...
LDR R9,[R0],R2,LSL #2
LDR R10,[R0],R2,LSL #2
LDR R11,[R0],R2,LSL #2 ;...columnwise from source
STMIA R1,{R8-R11} ;store them rowwise in dest.
SUB R0,R0,R2,LSL #4 ;reset R0
ADD R0,R0,#4 ;move to next source column
SUB R1,R1,R3,LSL #2 ;move to next dest row up
SUBS R6,R6,#1
BNE %BT02 ;till columns done
ADD R0,R0,R2,LSL #3
ADD R0,R0,R2,LSL #2 ;move R0 to next set of 4 source rows
ADD R1,R1,R5,LSL #2
ADD R1,R1,#16 ;move R1 to next set of 4 pixels, bottom row
SUBS R7,R7,#4 ;4 more source rows done
; Debug PageBoxMem,"32bpp rotate:R0 R1 next = ",R0,R1
BNE %BT01
Pull "R8-R11"
Pull "r0-r7, pc",,^
]
......@@ -1169,6 +1169,201 @@ spin8x8_in_words ROUT
MOVS pc, lr ; preserve flags
]
;
;fast copysprite_withrotate, 32 bpp case, 90 degrees
;
copysprite_withrotate_32bpp90 ROUT
Push "R0-R11,LR"
Debug PageBoxMem,"copysprite_withrotate_32bpp90"
MOV R2,R0
BL get_sprite_address
MOV R0,R2
MOV R2,R1
BL get_sprite_address
MOV R1,R2
LDR R2, [R1, #spHeight]
ADD R2,R2,#1 ;dest height, or source width
LDR R3, [R1, #spWidth]
ADD R3,R3,#1 ;dest width, or source height
LDR R4, [R0, #spImage]