;References:
;swi - vector_handler_forward

;R12, R14 are on the stack


;vector_handler_2A
;-----------------
;Tracks the size of DA2 when running on RO3.5+

.vector_handler_2A
 TEQ     R0, #2				;screen DA?
 BNE     vector_handler_forward		;NO, pass to OS

 LDR     R12, is_screen_remapped
 TEQ     R12, #0			;is screen memory remapped?
 LDREQ   R12, Screen_Cache_Off		;NO, turn the screen cache off?
 TEQEQ   R12, #0
 BEQ     vector_handler_forward		;NO, exit

 #if JIT_WIMP_support == 1
   BL      check_task_ID		;is the task supported?
   BNE     vector_handler_forward	;NO
 #endif

 TEMP    R12
 STR     R1, DA2_delta			;store the delta being requested

 #if JIT_debug == 1 AND compile_IOMD == 1
   STR     R13, dbg_pause		;pause debug whilst we switch mode
 #endif
 #if compile_GPU == 1
   STR     R13, blit_in_progress	;pause the blitter
 #endif
 LOCK    R12

 ADR     R12, _SPSR
 BL      pre_SWI_veneer			;call SWI that follows
 SWI     XADFFS_DoNothing

 LDR     R0, Screen_Cache_Off
 TEQ     R0, #0				;is the screen cache off?
 BLEQ    unmap_screen_memory		;NO, unmap the RO3.1 screen memory
 MOV     R0, #2				;preserve R0
 BL      pass_SWI_on
 SWI     XOS_ChangeDynamicArea		;PRM1-384
 BL      post_SWI_veneer

 BL      get_screen_start		;get DA2 address and size
 BL      get_DA2_size			;work out the DA size
 BL      map_screen_memory		;re-map the RO3.1 screen memory

 TEMP    R14
 #if JIT_debug == 1 AND compile_IOMD == 1
   MOV     R0, #1
   STR     R0, dbg_pause		;unpause debug
 #endif
 #if compile_GPU == 1
   BL      start_fifty_hz_ticker	;reset Vsync counters
   MOV     R0, #0
   STR     R0, blit_in_progress		;unpause the blitter
 #endif
 LOCK    R14

 MOV     R0, #2
B       exit_SWI_veneer

 ._SPSR		DBD 4
