;References:
;swi - vector_handler_forward

;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    R12, [R0, #3]			;get the file system number
 TEQ     R12, #8			;is it ADFS?
 BNE     vector_handler_forward		;NO, forward to OS

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

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

 ANDS    R12, 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

 ADR     R12, _SPSR
 BL      pre_SWI_veneer			;call SWI that follows
 SWI     XFileCore_Create
 BL      post_SWI_veneer

 STR     R0, ADFS_FileCore_Private	;store the FileCore details returned
 STR     R1, FileCore_Notify_Background
 STR     R3, FileCore_Release_FIQ
 LOCK    R14

B       exit_SWI_veneer

 ._SPSR     DBD 4
