#set DA2_magic_number = &F0000002

;vector_handler_5C
;-----------------
;Returns the RO3.1 address for DA2

;Entry:
; R0 - Area
;       bit 7 set if we need to return the max size
; R11 - pointer to VARS
; R12 - address for state

.vector_handler_5C
 BIC     R14, R0, #1 << 7
 TEQ     R14, #DA2_magic_number		;are we calling for the OS DA2 info?
 ANDEQ   R0, R0, #&FF			;YES
 LDRNEB  R14, [R11, #is_screen_remapped - VARS]	;emulating RO3.11?
 TEQNE   R14, #0			;is screen memory remapped?
 BEQ     vector_handler_forward		;NO, pass call onto OS

 TEQ     R0, #2				;screen DA?
 TEQNE   R0, #2 + (1<<7)
 BLEQ    check_taskID			;YES, is the task supported?
 BLEQ    check_SWI_in_appspace_or_JIT	;YES, is it within appspace?
 BNE     vector_handler_forward		;pass call onto OS

 TST     R0, #1 << 7			;do we need to return the max size?
 MOVNE   R2, #480 * 1024		;max DA2 size on RO3.1

 MOV     R0, #&2000000			;RO3.1 DA2 end
 LDR     R1, [R11, #DA2_size - VARS]	;DA2 size
 #if compile_RO == 400
   LDR     R14, [R11, #DA2_delta - VARS]	;fix RO4/6 SA
   ADD     R1, R1, R14
 #endif
 SUB     R0, R0, R1			;RO3.1 DA2 start
EXITSWI ""				;return to original caller