Release 980201
[wine/multimedia.git] / msdos / int25.c
blob2fd6d737c3e2430be4374ea61ef5f749431995b3
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 "stddebug.h"
15 /* #define DEBUG_INT */
16 #include "debug.h"
18 /**********************************************************************
19 * INT_Int25Handler
21 * Handler for int 25h (absolute disk read).
23 void WINAPI INT_Int25Handler( CONTEXT *context )
25 BYTE *dataptr = PTR_SEG_OFF_TO_LIN( DS_reg(context), BX_reg(context) );
26 DWORD begin, length;
27 int fd;
29 if (!DRIVE_IsValid(AL_reg(context)))
31 SET_CFLAG(context);
32 AX_reg(context) = 0x0101; /* unknown unit */
33 return;
36 if (CX_reg(context) == 0xffff)
38 begin = *(DWORD *)dataptr;
39 length = *(WORD *)(dataptr + 4);
40 dataptr = (BYTE *)PTR_SEG_TO_LIN( *(SEGPTR *)(dataptr + 6) );
42 else
44 begin = DX_reg(context);
45 length = CX_reg(context);
47 dprintf_int( stdnimp, "int25: abs diskread, drive %d, sector %ld, "
48 "count %ld, buffer %d\n",
49 AL_reg(context), begin, length, (int) dataptr);
51 if ((fd = DRIVE_OpenDevice( AL_reg(context), O_RDONLY )) != -1)
53 lseek( fd, begin * 512, SEEK_SET );
54 /* FIXME: check errors */
55 read( fd, dataptr, length * 512 );
56 close( fd );
58 else
60 memset(dataptr, 0, length * 512);
61 if (begin == 0 && length > 1) *(dataptr + 512) = 0xf8;
62 if (begin == 1) *dataptr = 0xf8;
64 RESET_CFLAG(context);