5 ReadAsync( _REG( a0
) AsyncFile
*file
, _REG( a1
) APTR buffer
, _REG( d0
) LONG numBytes
)
7 #ifdef ASIO_NOEXTERNALS
8 struct ExecBase
*SysBase
= file
->af_SysBase
;
13 /* if we need more bytes than there are in the current buffer, enter the
17 while( numBytes
> file
->af_BytesLeft
)
20 CopyMem( file
->af_Offset
, buffer
, file
->af_BytesLeft
);
22 numBytes
-= file
->af_BytesLeft
;
23 buffer
= ( APTR
) ( ( ULONG
) buffer
+ file
->af_BytesLeft
);
24 totalBytes
+= file
->af_BytesLeft
;
25 file
->af_BytesLeft
= 0;
27 bytesArrived
= AS_WaitPacket( file
);
29 if( bytesArrived
<= 0 )
31 if( bytesArrived
== 0 )
39 /* ask that the buffer be filled */
40 AS_SendPacket( file
, file
->af_Buffers
[ 1 - file
->af_CurrentBuf
] );
42 /* in case we tried to seek past EOF */
43 if( file
->af_SeekOffset
> bytesArrived
)
45 file
->af_SeekOffset
= bytesArrived
;
48 file
->af_Offset
= file
->af_Buffers
[ file
->af_CurrentBuf
] + file
->af_SeekOffset
;
49 file
->af_CurrentBuf
= 1 - file
->af_CurrentBuf
;
50 file
->af_BytesLeft
= bytesArrived
- file
->af_SeekOffset
;
51 file
->af_SeekOffset
= 0;
54 CopyMem( file
->af_Offset
, buffer
, numBytes
);
55 file
->af_BytesLeft
-= numBytes
;
56 file
->af_Offset
+= numBytes
;
58 return( totalBytes
+ numBytes
);