;vector_handler_66
;-----------------
;Returns the RO3.1 address for DA2
;Returns a valid length in R2 on RISC OS 3.8/4.x/6.x

; R11 - pointer to VARS
; R12 - address for state

.vector_handler_66
 LDRB    R14, [R11, #is_screen_remapped - VARS]
 TEQ     R14, #0			;is screen memory remapped?
 BEQ     vector_handler_forward		;NO, pass call onto OS

 TEQ     R0, #2				;Return info?
 TEQEQ   R1, #2				;YES, Screen memory?
 BLEQ    check_taskID			;YES, is the task supported?
 BLEQ    check_SWI_in_appspace_or_JIT	;YES, is it within appspace?
 BNE     vector_handler_forward		;NO, pass call onto OS

 BL      pre_SWI_veneer			;call SWI that follows
 SWI     XOS_DynamicArea		;PRM5a-53

 MOV     R3, #&2000000			;RO3.1 DA2 end
 LDR     R2, DA2_size			;DA2 size
 #if compile_RO == 400
   LDRB    R14, [R11, #riscos6 - VARS]
   TEQ     R14, #0
   LDREQ   R14, [R11, #DA2_delta - VARS]	;fix RO4/6 SA
   ADDEQ   R2, R2, R14
 #endif
 SUB     R3, R3, R2			;RO3.1 DA2 start
 MOV     R5, #480 * 1024		;max DA2 size on RO3.1
B       exit_SWI_veneer			;return to original caller