;vector_handler_40541
;---------------------
;Hijacks SWI FileCore_Create if it's ADFS calling

 .ADFS_boot     DCB "Acorn "
 .ADFS_Module   DCB "ADFS", 0
                ALIGN

.vector_handler_40541			;SWI FileCore_Create (&40541)
 LDRB    R14, [R0, #3]			;get the file system number
 TEQ     R14, #8			;is it ADFS?
 BNE     vector_handler_forward		;NO, forward to OS

 LDR     R14, [R0]			;1st word of ADFS' FileCore block
;@@@ following lines are for debugging purposes only
;BIC R14, R14, #ADFS_Sector_Aligned	;switch to byte mode
;BIC R14, R14, #%10			;turn off floppy FIQ's
;MOV R5, #0				;turn off background transfers
 TEMP    R11
 STR     R14, ADFS_FS_Create_Block	;our FileCore create block

 LDR     R14, [R0, #12]			;load ADFS' DiscOp relative address
 ADD     R14, R14, R1			;ADFS' DiscOp physical address
 STR     R14, ADFS_DiscOp
 LDR     R14, [R0, #16]			;load ADFS' MiscOp relative address
 ADD     R14, R14, R1			;ADFS' MiscOp physical address
 STR     R14, ADFS_MiscOp

 TST     R3, #&FF			;no. of floppies
 ORREQ   R3, R3, #1			;ensure it's at least one

 ADR     R0, ADFS_FS_Create_Block	;redirect FileCore to our FS block
 ADR     R1, 0				;redirect FileCore to our module

 BL      pre_SWI_veneer			;call SWI that follows
 SWI     XFileCore_Create
 BL      post_SWI_veneer
 BVS     exit_SWI_veneer		;exit on error

 STR     R0, ADFS_FileCore_Private	;store the FileCore details returned
 STR     R1, FileCore_Notify_Background
 STR     R3, FileCore_Release_FIQ
 LOCK    R11
 BL      Check_FDC_Type			;need to return the correct errors
B       exit_SWI_veneer
