B %10draw__renderObject ;Options are not renderable
B draw__renderTransformedText ;Render rotated text
B draw__renderTransformedSprite ;Render rotated sprite
+ B %10draw__renderObject ;Type 14 is not defined
+ B %10draw__renderObject ;Type 15 is not defined
+ B draw__renderJPEG ;Render a JPEG
10 B draw__next ;Ignore unknown objects
; --- Make sure the text isn't invisible ---
- ADD R6,R7,#24 ;Point to the object data
- LDR R0,[R6,#0] ;Load the foreground colour
+ LDR R0,[R7,#24] ;Load the foreground colour
CMP R0,#-1 ;Is it transparent?
MOVEQS PC,R14 ;Yes -- do nothing then
+ ADD R6,R7,#24 ;Point to the object data
; --- Find the font name ---
STMFD R13!,{R14} ;Save the link again
ADD R2,R6,#12 ;Point to the text sizes
- LDMIA R2,{R2,R3} ;Load x and y sizes
LDR R4,[R10,#0] ;Load the scale factor
+ LDMIA R2,{R2,R3} ;Load x and y sizes
MOV R4,R4,LSR #8 ;Scale it down a little
MUL R2,R4,R2 ;Scale up the x size
MUL R3,R4,R3 ;And scale up the y size
; --- Work out where to paint the text ---
ADD R3,R6,#20 ;Point to the coordinates
- LDMIA R3,{R3,R4} ;Load the coordinates out
LDR R5,[R10,#0] ;Load the scale factor out
+ LDMIA R3,{R3,R4} ;Load the coordinates out
MOV R5,R5,LSR #8 ;Scale it down a little
MUL R3,R5,R3 ;Multiply up the x position
MUL R4,R5,R4 ;Multiply up the y position
BL screen_getInfo ;Get things about the screen
LDMIA R0,{R2,R3} ;Load the eigen factors
ADD R14,R6,#12 ;Point to the size arguments
- LDMIA R14,{R0,R1} ;Load the text sizes out
LDR R4,[R10,#0] ;Load the scale factor
+ LDMIA R14,{R0,R1} ;Load the text sizes out
MOV R4,R4,LSR #8 ;Shift it down a little
MUL R0,R4,R0 ;Multiply x size up
MUL R1,R4,R1 ;Multiply y size up too
; --- Work out the correct scaling ---
- MOV R0,#40 ;Read sprite info
- ADD R0,R0,#512 ;Sprite is pointed at
+ MOV R0,#40+512 ;Read sprite info
+ ;Sprite is pointed at
MOV R1,#&1000 ;Don't care about sprite area
ADD R2,R7,#24 ;Point to sprite block
SWI OS_SpriteOp ;Read the sprite info
LDMIA R0,{R0-R3} ;Load the values out
SUB R2,R2,R0 ;Get sprite width in R2
SUB R3,R3,R1 ;Get sprite height in R3
+ LDR R14,[R10,#0] ;Load the scale factor
MOV R2,R2,LSR #8 ;Scale the dimensions down
MOV R3,R3,LSR #8 ;In both directions
- LDR R14,[R10,#0] ;Load the scale factor
MUL R2,R14,R2 ;Scale the x size
MUL R3,R14,R3 ;And the y size
MOV R2,R2,LSR #16 ;And scale the value down
MOV R3,R3,LSR #16 ;Both directions again
- STMFD R13!,{R2-R5} ;Save the resulting zoom blk
+ STMFD R13!,{R2-R5,R7} ;Save the resulting zoom blk
+ ;Save R7 -- we need to use it
MOV R14,R14,LSR #8 ;Shift scale factor down
MUL R3,R14,R0 ;Scale the x position
; --- Now plot the sprite in the right place ---
- STMFD R13!,{R7} ;Save R7 -- we need to use it
- MOV R0,#52 ;Plot sprite scaled, please
- ADD R0,R0,#512 ;Tell it I have a sprite ptr
+ MOV R0,#52+512 ;Plot sprite scaled, please
MOV R1,#&1000 ;A dummy sprite area
ADD R2,R7,#24 ;Point to the sprite def
MOV R5,#8 ;Plot with mask, please
- ADD R6,R13,#4 ;Point to my zoom block
+ MOV R6,R13 ;Point to my zoom block
MOV R7,R11 ;Point to my translate table
SWI OS_SpriteOp ;Plot the sprite
- LDMFD R13!,{R7} ;Unstack R7 again
ADD R13,R13,#16 ;Recover the zoom block
- LDMFD R13!,{R14} ;Unstack the link register
+ LDMFD R13!,{R7, R14} ;Unstack R7 and link register
B draw__next ;And render the next object
LTORG
BCC draw__next ;No -- then return
STMFD R13!,{R7,R8} ;Save the object pointer
+ ;SA optimised, looks crazy:
+ LDR R8,[R7,#32] ;Get the object size
ADD R7,R7,#28 ;Point to the enclosed object
- LDR R8,[R7,#4] ;Get the object size
ADD R8,R7,R8 ;Point past the object
BL draw__doRender ;Render the object
LDMFD R13!,{R7,R8,R14} ;Restore registers
; --- Make sure the text isn't invisible ---
- ADD R6,R7,#24 ;Point to the object data
- LDR R0,[R6,#0] ;Load the foreground colour
+ LDR R0,[R7,#24] ;Load the foreground colour
CMP R0,#-1 ;Is it transparent?
MOVEQS PC,R14 ;Yes -- do nothing then
+ ADD R6,R7,#24 ;Point to the object data
; --- Find the font name ---
STMFD R13!,{R14} ;Save the link again
ADD R2,R6,#40 ;Point to the text sizes
- LDMIA R2,{R2,R3} ;Load x and y sizes
LDR R4,[R10,#0] ;Load the scale factor
+ LDMIA R2,{R2,R3} ;Load x and y sizes
MOV R4,R4,LSR #8 ;Scale it down a little
MUL R2,R4,R2 ;Scale up the x size
MUL R3,R4,R3 ;And scale up the y size
; --- Work out where to paint the text ---
ADD R3,R6,#48 ;Point to the coordinates
- LDMIA R3,{R3,R4} ;Load the coordinates out
LDR R5,[R10,#0] ;Load the scale factor out
+ LDMIA R3,{R3,R4} ;Load the coordinates out
MOV R5,R5,LSR #8 ;Scale it down a little
MUL R3,R5,R3 ;Multiply up the x position
MUL R4,R5,R4 ;Multiply up the y position
; --- Paint the actual text then ---
- ADD R1,R6,#56 ;Point to the text string
LDR R2,[R6,#24] ;Load the special magic flags
+ ADD R1,R6,#56 ;Point to the text string
MOV R2,R2,LSL #9 ;Shift flags into position
ORR R2,R2,#&40 ;Specify transform matrix
STMFD R13!,{R0} ;Save the font handle
; --- Build the transformation matrix ---
ADD R14,R7,#24 ;Find the transform matrix
- LDMIA R14,{R0-R5} ;Load all the bits I need
LDR R6,[R10,#0] ;Load the scale factor
+ LDMIA R14,{R0-R5} ;Load all the bits I need
MOV R6,R6,LSR #8 ;Shift scale factor down
MOV R0,R0,ASR #8 ;Also shift down sprite scale
MOV R1,R1,ASR #8 ;Also shift down sprite scale
MUL R1,R6,R1 ;Apply scale to sprite matrix
MUL R2,R6,R2 ;Apply scale to sprite matrix
MUL R3,R6,R3 ;Apply scale to sprite matrix
+ STMFD R13!,{R7} ;Save R7 -- we need to use it
SUB R13,R13,#24 ;Make space for matrix
STMIA R13,{R0-R3} ;Save transform on stack
ADD R14,R10,#16 ;Point to my offsets
; --- Now plot the sprite in the right place ---
- STMFD R13!,{R7} ;Save R7 -- we need to use it
- MOV R0,#56 ;Plot sprite scaled, please
- ADD R0,R0,#512 ;Tell it I have a sprite ptr
+ MOV R0,#512+56 ;Plot sprite scaled, please
+ ;Tell it I have a sprite ptr
MOV R1,#&1000 ;A dummy sprite area
ADD R2,R7,#48 ;Point to the sprite def
MOV R3,#0 ;R6 points to a matrix
MOV R4,#0 ;No source rectangle thing
MOV R5,#8 ;Plot with mask, please
- ADD R6,R13,#4 ;Point to my matrix
+ MOV R6,R13 ;Point to my matrix
MOV R7,R11 ;Point to my translate table
SWI OS_SpriteOp ;Plot the sprite
- LDMFD R13!,{R7} ;Unstack R7 again
+ ADD R13,R13,#24 ;Recover the matrix block
+ LDMFD R13!,{R7,R14} ;Unstack R7 and link register
+ B draw__next ;And render the next object
+
+; --- draw__renderJPEG ----
+
+draw__renderJPEG ROUT
+
+ ; --- Make sure I have to render it ---
+
+ STMFD R13!,{R14} ;Save the link temporarily
+ BL draw__clip ;Do we have to render it?
+ BLCS rov_version ;Get the current OS version
+ CMPCS R0,#360 ;Is it RISC OS 3.60 yet?
+ LDMCCFD R13!,{R14} ;Restore the link again
+ BCC draw__next ;No -- then return
+
+ ; --- Build the transformation matrix ---
+
+ ADD R14,R7,#40 ;Find the transform matrix
+ LDR R6,[R10,#0] ;Load the scale factor
+ LDMIA R14,{R0-R5} ;Load all the bits I need
+ MOV R6,R6,LSR #8 ;Shift scale factor down
+ MOV R0,R0,ASR #8 ;Also shift down JPEG scale
+ MOV R1,R1,ASR #8 ;Also shift down JPEG scale
+ MOV R2,R2,ASR #8 ;Also shift down JPEG scale
+ MOV R3,R3,ASR #8 ;Also shift down JPEG scale
+ MUL R0,R6,R0 ;Apply scale to JPEG matrix
+ MUL R1,R6,R1 ;Apply scale to JPEG matrix
+ MUL R2,R6,R2 ;Apply scale to JPEG matrix
+ MUL R3,R6,R3 ;Apply scale to JPEG matrix
+ SUB R13,R13,#24 ;Make space for matrix
+ STMIA R13,{R0-R3} ;Save transform on stack
+ ADD R14,R10,#16 ;Point to my offsets
+ LDMIA R14,{R0,R1} ;Load the offsets out
+ MUL R4,R6,R4 ;Scale the JPEG x offset
+ MUL R5,R6,R5 ;Scale the JPEG y offset
+ ADD R4,R0,R4,ASR #8 ;Add on to original offset
+ ADD R5,R1,R5,ASR #8 ;Add on to original offset
+ ADD R14,R13,#16 ;Point to bit of matrix
+ STMIA R14,{R4,R5} ;Save these in the matrix
+
+ ; --- Now plot the JPEG in the right place ---
+
+ ADD R0,R7,#68 ;Point to the JPEG def
+ MOV R1,#2 ;R2 points to a matrix, dither
+ MOV R2,R13 ;Point to my matrix
+ LDR R3,[R0,#-4] ;Load length of JPEG
+ SWI JPEG_PlotTransformed ;Plot the JPEG
ADD R13,R13,#24 ;Recover the matrix block
LDMFD R13!,{R14} ;Unstack the link register
B draw__next ;And render the next object