Release 980201
[wine/multimedia.git] / msdos / int26.c
blobc24f1a9e1db9c9da076bf576d7d27d5bfea0c5df
1 /*
2 * DOS interrupt 26h handler
3 */
5 #include <stdio.h>
6 #include <stdlib.h>
7 #include <fcntl.h>
8 #include <unistd.h>
9 #include "msdos.h"
10 #include "ldt.h"
11 #include "miscemu.h"
12 #include "drive.h"
13 #include "stddebug.h"
14 /* #define DEBUG_INT */
15 #include "debug.h"
17 /**********************************************************************
18 * INT_Int26Handler
20 * Handler for int 26h (absolute disk read).
22 void WINAPI INT_Int26Handler( CONTEXT *context )
24 BYTE *dataptr = PTR_SEG_OFF_TO_LIN( DS_reg(context), BX_reg(context) );
25 DWORD begin, length;
26 int fd;
28 if (!DRIVE_IsValid(AL_reg(context)))
30 SET_CFLAG(context);
31 AX_reg(context) = 0x0101; /* unknown unit */
32 return;
35 if (CX_reg(context) == 0xffff)
37 begin = *(DWORD *)dataptr;
38 length = *(WORD *)(dataptr + 4);
39 dataptr = (BYTE *)PTR_SEG_TO_LIN( *(SEGPTR *)(dataptr + 6) );
41 else
43 begin = DX_reg(context);
44 length = CX_reg(context);
47 dprintf_int( stdnimp,"int26: abs diskwrite, 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_WRONLY )) != -1)
53 lseek( fd, begin * 512, SEEK_SET );
54 /* FIXME: check errors */
55 write( fd, dataptr, length * 512 );
56 close( fd );
59 RESET_CFLAG(context);