Release 950727
[wine] / miscemu / int25.c
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <string.h>
4 #include "registers.h"
5 #include "msdos.h"
6 #include "ldt.h"
7 #include "wine.h"
8 #include "miscemu.h"
9 #include "dos_fs.h"
10 #include "stddebug.h"
11 /* #define DEBUG_INT */
12 #include "debug.h"
13
14 /**********************************************************************
15  *          INT_Int25Handler
16  *
17  * Handler for int 25h (absolute disk read).
18  */
19 void INT_Int25Handler( struct sigcontext_struct sigcontext )
20 {
21 #define context (&sigcontext)
22         BYTE *dataptr = PTR_SEG_OFF_TO_LIN(DS, BX);
23         DWORD begin, length;
24
25         if(!DOS_ValidDrive(AL))
26         {
27             SetCflag;
28             AX = 0x0101;        /* unknown unit */
29             return;
30         }
31
32         if (CX == 0xffff) {
33                 begin = getdword(dataptr);
34                 length = getword(&dataptr[4]);
35                 dataptr = (BYTE *) PTR_SEG_TO_LIN(getdword(&dataptr[6]));
36                         
37         } else {
38                 begin = DX;
39                 length = CX;
40         }
41         dprintf_int(stdnimp, "int25: abs diskread, drive %d, sector %ld, "
42         "count %ld, buffer %d\n", AL, begin, length, (int) dataptr);
43
44         memset(dataptr, 0, length * 512);
45
46         if (begin == 0 && length > 1) 
47                 *(dataptr + 512) = 0xf8;
48
49         if (begin == 1) 
50                 *dataptr = 0xf8;
51
52         ResetCflag;
53 #undef context
54 }