View Single Post
Old 05 June 2018, 08:18   #4
Asman
68k
 
Asman's Avatar
 
Join Date: Sep 2005
Location: Somewhere
Posts: 829
Try this. I use it and it works like charm.

Code:
;-----------------------------------------------------------------------------
;
;; OsFlush
;
;in	a4 - dt
;out	-
;used	d0/d1/d2/d3/a0/a1/a2/a4
;
	xdef	OsFlush
OsFlush:
		move.l	4.w,a6
		moveq	#72,d0
		moveq	#1,d1
		swap	d1
		jsr	-198(a6)		;exec AllocMem(d0 - size, d1 - attr)
		move.l	d0,d2
		beq.b	.exit
		move.l	d0,a0
		move.l	a0,d1			;device name
		move.l	#'sys:',(a0)

	;get our message port
		move.l	276(a6),a2		;ThisTask
		lea	92(a2),a2		;pr_MsgPort

	;get filesystem message port
		move.l	osDosBase(a4),a6
		jsr	-174(a6)		;dos DeviceProc(d1 - name)
		move.l	d0,d3
		beq.b	.free

	;fill in packet
		move.l	d2,a1
		addq.l	#4,a1		;message
		lea	20(a1),a0	;dos packet
	
		move.l	a0,10(a1)	;message->mn_Node.ln_Name = dospacket
		move.l	a2,14(a1)	;mn_ReplyPort = pr_MsgPort

		move.l	a1,(a0)+	;dp_link = message
		move.l	a2,(a0)+	;dp_Port = pr_MsgPort
		moveq	#27,d0
		move.l	d0,(a0)		;dp_Type = ACTION_FLUSH

	;sends packet 
		move.l	4.w,a6
		move.l	d3,a0
		jsr	-$16e(a6)	;exec PutMsg(a0 - port,a1 - msg)

	;wait for reply
		move.l	a2,a0
		jsr	-$180(a6)	;exec WaitPort(a0 - port)
		move.l	a2,a0
		jsr	-$174(a6)	;exec GetMsg(a0 - port)
.free
		move.l	d2,a1
		moveq	#72,d0
		jsr	-210(a6)	;exec FreeMem(a1 - mem, d0 - size)

.exit		rts

;-----------------------------------------------------------------------------
Asman is offline  
 
Page generated in 0.04417 seconds with 10 queries