;*ADFFlush
;---------
;Save changes to the currently loaded ADF file
;Entry:
; R0 = pointer to command tail
; R1 = no. of parameters
; R12 = pointer to module private word

.Entry_ADFFlush
 STMFD   R13!, {R1-R12, R14}
 LDR     R12, [R12, #0]

 LDR     R1, [R12, #ADF_Mounted - VARS]	;check an ADF is mounted
 TEQ     R1, #0
 MOVEQ   R0, #&80000000			;set V
 ADDEQS  R0, R0, R0			;  |
 ADRVS   R0, Error_Disc_Empty		;  |
 LDMVSFD R13!, {R1-R12, PC}		;  + report an error

 TEQ     R1, #1				;check it's not at APD or JFD
 MOVNE   R0, #&80000000			;set V
 ADDNES  R0, R0, R0			;  |
 ADRVS   R0, Error_Disc_SaveAPD		;  |
 LDMVSFD R13!, {R1-R12, PC}		;  + report an error

 ADR     R1, Current_File_Mounted	;filename
 LDRB    R0, [R1]			;get first byte of filename
 TEQ     R0, #0				;check we actually have a filename
 MOVEQ   R0, #&80000000			;set V
 ADDEQS  R0, R0, R0			;  |
 ADRVS   R0, Error_Disc_Empty		;  |
 LDMVSFD R13!, {R1-R12, PC}		;  + report an error

B       ADFSave_Flush_Entry