Release 980315
[wine/gsoc_dplay.git] / msdos / int25.c
blob6f16d8880c92bd93c7d85853e4e6e529f4584478
1 /*
2 * DOS interrupt 25h handler
3 */
5 #include <stdio.h>
6 #include <stdlib.h>
7 #include <string.h>
8 #include <fcntl.h>
9 #include <unistd.h>
10 #include "msdos.h"
11 #include "ldt.h"
12 #include "miscemu.h"
13 #include "drive.h"
14 #include "debug.h"
16 /**********************************************************************
17 * INT_Int25Handler
19 * Handler for int 25h (absolute disk read).
21 void WINAPI INT_Int25Handler( CONTEXT *context )
23 BYTE *dataptr = PTR_SEG_OFF_TO_LIN( DS_reg(context), BX_reg(context) );
24 DWORD begin, length;
25 int fd;
27 if (!DRIVE_IsValid(AL_reg(context)))
29 SET_CFLAG(context);
30 AX_reg(context) = 0x0101; /* unknown unit */
31 return;
34 if (CX_reg(context) == 0xffff)
36 begin = *(DWORD *)dataptr;
37 length = *(WORD *)(dataptr + 4);
38 dataptr = (BYTE *)PTR_SEG_TO_LIN( *(SEGPTR *)(dataptr + 6) );
40 else
42 begin = DX_reg(context);
43 length = CX_reg(context);
45 TRACE(int, "int25: abs diskread, drive %d, sector %ld, "
46 "count %ld, buffer %d\n",
47 AL_reg(context), begin, length, (int) dataptr);
49 if ((fd = DRIVE_OpenDevice( AL_reg(context), O_RDONLY )) != -1)
51 lseek( fd, begin * 512, SEEK_SET );
52 /* FIXME: check errors */
53 read( fd, dataptr, length * 512 );
54 close( fd );
56 else
58 memset(dataptr, 0, length * 512);
59 if (begin == 0 && length > 1) *(dataptr + 512) = 0xf8;
60 if (begin == 1) *dataptr = 0xf8;
62 RESET_CFLAG(context);