Removed DOS task fields from the NE_MODULE structure.
[wine/gsoc_dplay.git] / msdos / int2f.c
blobff620506faa8109dcdb6da574fc4827afbd63246
1 /* -*- tab-width: 8; c-basic-offset: 4 -*- */
2 /*
3 * DOS interrupt 2fh handler
5 * Cdrom - device driver emulation - Audio features.
6 * (c) 1998 Petr Tomasek <tomasek@etf.cuni.cz>
7 * (c) 1999 Eric Pouech
8 */
10 #include "config.h"
12 #include "wine/winbase16.h"
13 #include "dosexe.h"
14 #include "drive.h"
15 #include "miscemu.h"
16 #include "module.h"
17 #include "task.h"
18 /* #define DEBUG_INT */
19 #include "debugtools.h"
20 #include "cdrom.h"
22 DEFAULT_DEBUG_CHANNEL(int);
24 /* base WPROCS.DLL ordinal number for VxDs */
25 #define VXD_BASE 400
27 static void do_int2f_16( CONTEXT86 *context );
28 static void MSCDEX_Handler( CONTEXT86 *context );
30 /**********************************************************************
31 * INT_Int2fHandler
33 * Handler for int 2fh (multiplex).
35 void WINAPI INT_Int2fHandler( CONTEXT86 *context )
37 TRACE("Subfunction 0x%X\n", AX_reg(context));
39 switch(AH_reg(context))
41 case 0x10:
42 AL_reg(context) = 0xff; /* share is installed */
43 break;
45 case 0x11: /* Network Redirector / IFSFUNC */
46 switch (AL_reg(context))
48 case 0x00: /* Install check */
49 /* not installed */
50 break;
51 case 0x80: /* Enhanced services - Install check */
52 /* not installed */
53 break;
54 default:
55 INT_BARF( context, 0x2f );
56 break;
58 break;
60 case 0x12:
61 switch (AL_reg(context))
63 case 0x2e: /* get or set DOS error table address */
64 switch (DL_reg(context))
66 /* Four tables: even commands are 'get', odd are 'set' */
67 /* DOS 5.0+ ignores "set" commands */
68 case 0x01:
69 case 0x03:
70 case 0x05:
71 case 0x07:
72 case 0x09:
73 break;
74 /* Instead of having a message table in DOS-space, */
75 /* we can use a special case for MS-DOS to force */
76 /* the secondary interface. */
77 case 0x00:
78 case 0x02:
79 case 0x04:
80 case 0x06:
81 ES_reg(context) = 0x0001;
82 DI_reg(context) = 0x0000;
83 break;
84 case 0x08:
85 FIXME("No real-mode handler for errors yet! (bye!)");
86 break;
87 default:
88 INT_BARF(context, 0x2f);
90 break;
91 default:
92 INT_BARF(context, 0x2f);
94 break;
96 case 0x15: /* mscdex */
97 MSCDEX_Handler(context);
98 break;
100 case 0x16:
101 do_int2f_16( context );
102 break;
104 case 0x1a: /* ANSI.SYS / AVATAR.SYS Install Check */
105 /* Not supported yet, do nothing */
106 break;
108 case 0x43:
109 #if 1
110 switch (AL_reg(context))
112 case 0x00: /* XMS v2+ installation check */
113 WARN("XMS is not fully implemented\n");
114 AL_reg(context) = 0x80;
115 break;
116 case 0x10: /* XMS v2+ get driver address */
118 LPDOSTASK lpDosTask = MZ_Current();
120 ES_reg(context) = lpDosTask ? lpDosTask->xms_seg : 0;
121 BX_reg(context) = 0;
122 break;
124 default:
125 INT_BARF( context, 0x2f );
127 #else
128 FIXME("check for XMS (not supported)\n");
129 AL_reg(context) = 0x42; /* != 0x80 */
130 #endif
131 break;
133 case 0x45:
134 switch (AL_reg(context))
136 case 0x00:
137 case 0x01:
138 case 0x02:
139 case 0x03:
140 case 0x04:
141 case 0x05:
142 case 0x06:
143 case 0x07:
144 case 0x08:
145 /* Microsoft Profiler - not installed */
146 break;
147 default:
148 INT_BARF( context, 0x2f );
150 break;
152 case 0x4a:
153 switch(AL_reg(context))
155 case 0x10: /* smartdrv */
156 break; /* not installed */
157 case 0x11: /* dblspace */
158 break; /* not installed */
159 case 0x12: /* realtime compression interface */
160 break; /* not installed */
161 case 0x32: /* patch IO.SYS (???) */
162 break; /* we have no IO.SYS, so we can't patch it :-/ */
163 default:
164 INT_BARF( context, 0x2f );
166 break;
167 case 0x4b:
168 switch(AL_reg(context))
170 case 0x01:
171 case 0x02:
172 case 0x03:
173 case 0x04:
174 case 0x05:
175 FIXME("Task Switcher - not implemented\n");
176 break;
177 default:
178 INT_BARF( context, 0x2f );
180 break;
181 case 0x56: /* INTERLNK */
182 switch(AL_reg(context))
184 case 0x01: /* check if redirected drive */
185 AL_reg(context) = 0; /* not redirected */
186 break;
187 default:
188 INT_BARF( context, 0x2f );
190 break;
191 case 0x7a: /* NOVELL NetWare */
192 switch (AL_reg(context))
194 case 0x0: /* Low-level Netware installation check AL=0 not installed.*/
195 AL_reg(context) = 0;
196 break;
197 case 0x20: /* Get VLM Call Address */
198 /* return nothing -> NetWare not installed */
199 break;
200 default:
201 INT_BARF( context, 0x2f );
202 break;
204 break;
205 case 0xb7: /* append */
206 AL_reg(context) = 0; /* not installed */
207 break;
208 case 0xb8: /* network */
209 switch (AL_reg(context))
211 case 0x00: /* Install check */
212 /* not installed */
213 break;
214 default:
215 INT_BARF( context, 0x2f );
216 break;
218 break;
219 case 0xbd: /* some Novell network install check ??? */
220 AX_reg(context) = 0xa5a5; /* pretend to have Novell IPX installed */
221 break;
222 case 0xbf: /* REDIRIFS.EXE */
223 switch (AL_reg(context))
225 case 0x00: /* Install check */
226 /* not installed */
227 break;
228 default:
229 INT_BARF( context, 0x2f );
230 break;
232 break;
233 case 0xd2:
234 switch(AL_reg(context))
236 case 0x01: /* Quarterdeck RPCI - QEMM/QRAM - PCL-838.EXE functions */
237 if(BX_reg(context) == 0x5145 && CX_reg(context) == 0x4D4D
238 && DX_reg(context) == 0x3432)
239 TRACE("Check for QEMM v5.0+ (not installed)\n");
240 break;
241 default:
242 INT_BARF( context, 0x2f );
243 break;
245 break;
246 case 0xd7: /* Banyan Vines */
247 switch (AL_reg(context))
249 case 0x01: /* Install check - Get Int Number */
250 /* not installed */
251 break;
252 default:
253 INT_BARF( context, 0x2f );
254 break;
256 break;
257 case 0xde:
258 switch(AL_reg(context))
260 case 0x01: /* Quarterdeck QDPMI.SYS - DESQview */
261 if(BX_reg(context) == 0x4450 && CX_reg(context) == 0x4d49
262 && DX_reg(context) == 0x8f4f)
263 TRACE("Check for QDPMI.SYS (not installed)\n");
264 break;
265 default:
266 INT_BARF( context, 0x2f );
267 break;
269 break;
270 case 0xfa: /* Watcom debugger check, returns 0x666 if installed */
271 break;
272 default:
273 INT_BARF( context, 0x2f );
274 break;
279 /**********************************************************************
280 * do_int2f_16
282 static void do_int2f_16( CONTEXT86 *context )
284 DWORD addr;
286 switch(AL_reg(context))
288 case 0x00: /* Windows enhanced mode installation check */
289 AX_reg(context) = (GetWinFlags16() & WF_ENHANCED) ?
290 LOWORD(GetVersion16()) : 0;
291 break;
293 case 0x0a: /* Get Windows version and type */
294 AX_reg(context) = 0;
295 BX_reg(context) = (LOWORD(GetVersion16()) << 8) |
296 (LOWORD(GetVersion16()) >> 8);
297 CX_reg(context) = (GetWinFlags16() & WF_ENHANCED) ? 3 : 2;
298 break;
300 case 0x0b: /* Identify Windows-aware TSRs */
301 /* we don't have any pre-Windows TSRs */
302 break;
304 case 0x11: /* Get Shell Parameters - (SHELL= in CONFIG.SYS) */
305 /* We can mock this up. But not today... */
306 FIXME("Get Shell Parameters\n");
307 break;
309 case 0x80: /* Release time-slice */
310 AL_reg(context) = 0;
311 break;
313 case 0x81: /* Begin critical section. */
314 /* FIXME? */
315 break;
317 case 0x82: /* End critical section. */
318 /* FIXME? */
319 break;
321 case 0x83: /* Return Current Virtual Machine ID */
322 /* Virtual Machines are usually created/destroyed when Windows runs
323 * DOS programs. Since we never do, we are always in the System VM.
324 * According to Ralf Brown's Interrupt List, never return 0. But it
325 * seems to work okay (returning 0), just to be sure we return 1.
327 BX_reg(context) = 1; /* VM 1 is probably the System VM */
328 break;
330 case 0x84: /* Get device API entry point */
331 addr = (DWORD)NE_GetEntryPoint( GetModuleHandle16("WPROCS"),
332 VXD_BASE + BX_reg(context) );
333 if (!addr) /* not supported */
335 ERR("Accessing unknown VxD %04x - Expect a failure now.\n",
336 BX_reg(context) );
338 ES_reg(context) = SELECTOROF(addr);
339 DI_reg(context) = OFFSETOF(addr);
340 break;
342 case 0x86: /* DPMI detect mode */
343 AX_reg(context) = 0; /* Running under DPMI */
344 break;
346 case 0x87: /* DPMI installation check */
347 #if 1 /* DPMI still breaks pkunzip */
348 if (ISV86(context)) break; /* so bail out for now if in v86 mode */
349 #endif
351 SYSTEM_INFO si;
352 LPDOSTASK lpDosTask = MZ_Current();
354 GetSystemInfo(&si);
355 AX_reg(context) = 0x0000; /* DPMI Installed */
356 BX_reg(context) = 0x0001; /* 32bits available */
357 CL_reg(context) = si.wProcessorLevel;
358 DX_reg(context) = 0x005a; /* DPMI major/minor 0.90 */
359 SI_reg(context) = 0; /* # of para. of DOS extended private data */
360 ES_reg(context) = lpDosTask ? lpDosTask->dpmi_seg : 0;
361 DI_reg(context) = 0; /* ES:DI is DPMI switch entry point */
362 break;
364 case 0x8a: /* DPMI get vendor-specific API entry point. */
365 /* The 1.0 specs say this should work with all 0.9 hosts. */
366 break;
368 default:
369 INT_BARF( context, 0x2f );
373 /* FIXME: this macro may have to be changed on architectures where <size> reads/writes
374 * must be <size> aligned
375 * <size> could be WORD, DWORD...
376 * in this case, we would need two macros, one for read, the other one for write
377 * Note: PTR_AT can be used as an l-value
379 #define PTR_AT(_ptr, _ofs, _typ) (*((_typ*)(((char*)_ptr)+(_ofs))))
381 /* Use #if 1 if you want full int 2f debug... normal users can leave it at 0 */
382 #if 0
383 /**********************************************************************
384 * MSCDEX_Dump [internal]
386 * Dumps mscdex requests to int debug channel.
388 static void MSCDEX_Dump(char* pfx, BYTE* req, int dorealmode)
390 int i;
391 BYTE buf[2048];
392 BYTE* ptr;
393 BYTE* ios;
395 ptr = buf;
396 ptr += sprintf(ptr, "%s\tCommand => ", pfx);
397 for (i = 0; i < req[0]; i++) {
398 ptr += sprintf(ptr, "%02x ", req[i]);
401 switch (req[2]) {
402 case 3:
403 case 12:
404 ptr += sprintf(ptr, "\n\t\t\t\tIO_struct => ");
405 ios = (dorealmode) ?
406 DOSMEM_MapRealToLinear(MAKELONG(PTR_AT(req, 14, WORD), PTR_AT(req, 16, WORD))) :
407 PTR_SEG_OFF_TO_LIN(PTR_AT(req, 16, WORD), PTR_AT(req, 14, WORD));
409 for (i = 0; i < PTR_AT(req, 18, WORD); i++) {
410 ptr += sprintf(ptr, "%02x ", ios[i]);
411 if ((i & 0x1F) == 0x1F) {
412 *ptr++ = '\n';
413 *ptr = 0;
416 break;
418 TRACE("%s\n", buf);
420 #else
421 #define MSCDEX_Dump(pfx, req, drm)
422 #endif
424 static void MSCDEX_StoreMSF(DWORD frame, BYTE* val)
426 val[3] = 0; /* zero */
427 val[2] = frame / CDFRAMES_PERMIN; /* minutes */
428 val[1] = (frame - CDFRAMES_PERMIN * val[2]) / CDFRAMES_PERSEC; /* seconds */
429 val[0] = frame - CDFRAMES_PERMIN * val[2] - CDFRAMES_PERSEC * val[1]; /* frames */
432 static void MSCDEX_Handler(CONTEXT86* context)
434 int drive, count;
435 char* p;
437 switch(AL_reg(context)) {
438 case 0x00: /* Installation check */
439 /* Count the number of contiguous CDROM drives
441 for (drive = count = 0; drive < MAX_DOS_DRIVES; drive++) {
442 if (DRIVE_GetType(drive) == TYPE_CDROM) {
443 while (DRIVE_GetType(drive + count) == TYPE_CDROM) count++;
444 break;
447 TRACE("Installation check: %d cdroms, starting at %d\n", count, drive);
448 BX_reg(context) = count;
449 CX_reg(context) = (drive < MAX_DOS_DRIVES) ? drive : 0;
450 break;
452 case 0x0B: /* drive check */
453 AX_reg(context) = (DRIVE_GetType(CX_reg(context)) == TYPE_CDROM);
454 BX_reg(context) = 0xADAD;
455 break;
457 case 0x0C: /* get version */
458 BX_reg(context) = 0x020a;
459 TRACE("Version number => %04x\n", BX_reg(context));
460 break;
462 case 0x0D: /* get drive letters */
463 p = CTX_SEG_OFF_TO_LIN(context, ES_reg(context), EBX_reg(context));
464 memset(p, 0, MAX_DOS_DRIVES);
465 for (drive = 0; drive < MAX_DOS_DRIVES; drive++) {
466 if (DRIVE_GetType(drive) == TYPE_CDROM) *p++ = drive;
468 TRACE("Get drive letters\n");
469 break;
471 case 0x10: /* direct driver access */
473 static WINE_CDAUDIO wcda;
474 BYTE* driver_request;
475 BYTE* io_stru;
476 BYTE Error = 255; /* No Error */
477 int dorealmode = ISV86(context);
479 driver_request = (dorealmode) ?
480 DOSMEM_MapRealToLinear(MAKELONG(BX_reg(context), ES_reg(context))) :
481 PTR_SEG_OFF_TO_LIN(ES_reg(context), BX_reg(context));
483 if (!driver_request) {
484 /* FIXME - to be deleted ?? */
485 ERR("ES:BX==0 ! SEGFAULT ?\n");
486 ERR("-->BX=0x%04x, ES=0x%04lx, DS=0x%04lx, CX=0x%04x\n",
487 BX_reg(context), ES_reg(context), DS_reg(context), CX_reg(context));
488 driver_request[4] |= 0x80;
489 driver_request[3] = 5; /* bad request length */
490 return;
492 /* FIXME - would be better to open the device at the beginning of the wine session...
493 * - the device is also never closed...
494 * - the current implementation only supports a single CD ROM
496 if (wcda.unixdev <= 0)
497 CDROM_Open(&wcda, -1);
498 TRACE("CDROM device driver -> command <%d>\n", (unsigned char)driver_request[2]);
500 for (drive = 0;
501 drive < MAX_DOS_DRIVES && DRIVE_GetType(drive) != TYPE_CDROM;
502 drive++);
503 /* drive contains the first CD ROM */
504 if (CX_reg(context) != drive) {
505 WARN("Request made doesn't match a CD ROM drive (%d/%d)\n", CX_reg(context), drive);
506 driver_request[4] |= 0x80;
507 driver_request[3] = 1; /* unknown unit */
508 return;
511 MSCDEX_Dump("Beg", driver_request, dorealmode);
513 /* set status to 0 */
514 PTR_AT(driver_request, 3, WORD) = 0;
515 CDROM_Audio_GetCDStatus(&wcda);
517 switch (driver_request[2]) {
518 case 3:
519 io_stru = (dorealmode) ?
520 DOSMEM_MapRealToLinear(MAKELONG(PTR_AT(driver_request, 14, WORD), PTR_AT(driver_request, 16, WORD))) :
521 PTR_SEG_OFF_TO_LIN(PTR_AT(driver_request, 16, WORD), PTR_AT(driver_request, 14, WORD));
523 TRACE(" --> IOCTL INPUT <%d>\n", io_stru[0]);
524 switch (io_stru[0]) {
525 #if 0
526 case 0: /* Get device Header */
528 static LPSTR ptr = 0;
529 if (ptr == 0) {
530 ptr = SEGPTR_ALLOC(22);
531 PTR_AT(ptr, 0, DWORD) = ~1; /* Next Device Driver */
532 PTR_AT(ptr, 4, WORD) = 0xC800; /* Device attributes */
533 PTR_AT(ptr, 6, WORD) = 0x1234; /* Pointer to device strategy routine: FIXME */
534 PTR_AT(ptr, 8, WORD) = 0x3142; /* Pointer to device interrupt routine: FIXME */
535 PTR_AT(ptr, 10, char) = 'W'; /* 8-byte character device name field */
536 PTR_AT(ptr, 11, char) = 'I';
537 PTR_AT(ptr, 12, char) = 'N';
538 PTR_AT(ptr, 13, char) = 'E';
539 PTR_AT(ptr, 14, char) = '_';
540 PTR_AT(ptr, 15, char) = 'C';
541 PTR_AT(ptr, 16, char) = 'D';
542 PTR_AT(ptr, 17, char) = '_';
543 PTR_AT(ptr, 18, WORD) = 0; /* Reserved (must be zero) */
544 PTR_AT(ptr, 20, BYTE) = 0; /* Drive letter (must be zero) */
545 PTR_AT(ptr, 21, BYTE) = 1; /* Number of units supported (one or more) FIXME*/
547 PTR_AT(io_stru, DWORD, 0) = SEGPTR_GET(ptr);
549 break;
550 #endif
552 case 1: /* location of head */
553 switch (io_stru[1]) {
554 case 0:
555 PTR_AT(io_stru, 2, DWORD) = wcda.dwCurFrame;
556 break;
557 case 1:
558 MSCDEX_StoreMSF(wcda.dwCurFrame, io_stru + 2);
559 break;
560 default:
561 ERR("CD-ROM driver: unsupported addressing mode !!\n");
562 Error = 0x0c;
564 TRACE(" ----> HEAD LOCATION <%ld>\n", PTR_AT(io_stru, 2, DWORD));
565 break;
567 case 4: /* Audio channel info */
568 io_stru[1] = 0;
569 io_stru[2] = 0xff;
570 io_stru[3] = 1;
571 io_stru[4] = 0xff;
572 io_stru[5] = 2;
573 io_stru[6] = 0;
574 io_stru[7] = 3;
575 io_stru[8] = 0;
576 TRACE(" ----> AUDIO CHANNEL INFO\n");
577 break;
579 case 6: /* device status */
580 PTR_AT(io_stru, 1, DWORD) = 0x00000290;
581 /* 290 =>
582 * 1 Supports HSG and Red Book addressing modes
583 * 0 Supports audio channel manipulation
585 * 1 Supports prefetching requests
586 * 0 Reserved
587 * 0 No interleaving
588 * 1 Data read and plays audio/video tracks
590 * 0 Read only
591 * 0 Supports only cooked reading
592 * 0 Door locked
593 * 0 see below (Door closed/opened)
595 if (wcda.cdaMode == WINE_CDA_OPEN)
596 io_stru[1] |= 1;
597 TRACE(" ----> DEVICE STATUS <0x%08lx>\n", PTR_AT(io_stru, 1, DWORD));
598 break;
600 case 8: /* Volume size */
601 PTR_AT(io_stru, 1, DWORD) = wcda.dwLastFrame;
602 TRACE(" ----> VOLUME SIZE <%ld>\n", PTR_AT(io_stru, 1, DWORD));
603 break;
605 case 9: /* media changed ? */
606 /* answers don't know... -1/1 for yes/no would be better */
607 io_stru[1] = 0; /* FIXME? 1? */
608 TRACE(" ----> MEDIA CHANGED <%d>\n", io_stru[1]);
609 break;
611 case 10: /* audio disk info */
612 io_stru[1] = wcda.nFirstTrack; /* starting track of the disc */
613 io_stru[2] = wcda.nLastTrack; /* ending track */
614 MSCDEX_StoreMSF(wcda.dwLastFrame, io_stru + 3);
616 TRACE(" ----> AUDIO DISK INFO <%d-%d/%08lx>\n",
617 io_stru[1], io_stru[2], PTR_AT(io_stru, 3, DWORD));
618 break;
620 case 11: /* audio track info */
621 if (io_stru[1] >= wcda.nFirstTrack && io_stru[1] <= wcda.nLastTrack) {
622 int nt = io_stru[1] - wcda.nFirstTrack;
623 MSCDEX_StoreMSF(wcda.lpdwTrackPos[nt], io_stru + 2);
624 /* starting point if the track */
625 io_stru[6] = (wcda.lpbTrackFlags[nt] & 0xF0) >> 4;
626 } else {
627 PTR_AT(io_stru, 2, DWORD) = 0;
628 io_stru[6] = 0;
630 TRACE(" ----> AUDIO TRACK INFO[%d] = [%08lx:%d]\n",
631 io_stru[1], PTR_AT(io_stru, 2, DWORD), io_stru[6]);
632 break;
634 case 12: /* get Q-Channel info */
635 io_stru[1] = wcda.lpbTrackFlags[wcda.nCurTrack - 1];
636 io_stru[2] = wcda.nCurTrack;
637 io_stru[3] = 0; /* FIXME ?? */
639 /* why the heck did MS use another format for 0MSF information... sigh */
641 BYTE bTmp[4];
643 MSCDEX_StoreMSF(wcda.dwCurFrame - wcda.lpdwTrackPos[wcda.nCurTrack - 1], bTmp);
644 io_stru[ 4] = bTmp[2];
645 io_stru[ 5] = bTmp[1];
646 io_stru[ 6] = bTmp[0];
647 io_stru[ 7] = 0;
649 MSCDEX_StoreMSF(wcda.dwCurFrame, bTmp);
650 io_stru[ 8] = bTmp[2];
651 io_stru[ 9] = bTmp[1];
652 io_stru[10] = bTmp[0];
653 io_stru[11] = 0;
655 TRACE("Q-Channel info: Ctrl/adr=%02x TNO=%02x X=%02x rtt=%02x:%02x:%02x rtd=%02x:%02x:%02x (cf=%08lx, tp=%08lx)\n",
656 io_stru[ 1], io_stru[ 2], io_stru[ 3],
657 io_stru[ 4], io_stru[ 5], io_stru[ 6],
658 io_stru[ 8], io_stru[ 9], io_stru[10],
659 wcda.dwCurFrame, wcda.lpdwTrackPos[wcda.nCurTrack - 1]);
660 break;
662 case 15: /* Audio status info */
663 /* !!!! FIXME FIXME FIXME !! */
664 PTR_AT(io_stru, 1, WORD) = 2 | ((wcda.cdaMode == WINE_CDA_PAUSE) ? 1 : 0);
665 if (wcda.cdaMode == WINE_CDA_OPEN) {
666 PTR_AT(io_stru, 3, DWORD) = 0;
667 PTR_AT(io_stru, 7, DWORD) = 0;
668 } else {
669 PTR_AT(io_stru, 3, DWORD) = wcda.lpdwTrackPos[0];
670 PTR_AT(io_stru, 7, DWORD) = wcda.lpdwTrackPos[wcda.nTracks - 1];
672 TRACE("Audio status info: status=%04x startLoc=%ld endLoc=%ld\n",
673 PTR_AT(io_stru, 1, WORD), PTR_AT(io_stru, 3, DWORD), PTR_AT(io_stru, 7, DWORD));
674 break;
676 default:
677 FIXME("IOCTL INPUT: Unimplemented <%d>!!\n", io_stru[0]);
678 Error = 0x0c;
679 break;
681 break;
683 case 12:
684 io_stru = (dorealmode) ?
685 DOSMEM_MapRealToLinear(MAKELONG(PTR_AT(driver_request, 14, WORD), PTR_AT(driver_request, 16, WORD))) :
686 PTR_SEG_OFF_TO_LIN(PTR_AT(driver_request, 16, WORD), PTR_AT(driver_request, 14, WORD));
688 TRACE(" --> IOCTL OUTPUT <%d>\n", io_stru[0]);
689 switch (io_stru[0]) {
690 case 0: /* eject */
691 CDROM_SetDoor(&wcda, 1);
692 TRACE(" ----> EJECT\n");
693 break;
694 case 2: /* reset drive */
695 CDROM_Reset(&wcda);
696 TRACE(" ----> RESET\n");
697 break;
698 case 3: /* Audio Channel Control */
699 FIXME(" ----> AUDIO CHANNEL CONTROL (NIY)\n");
700 break;
701 case 5: /* close tray */
702 CDROM_SetDoor(&wcda, 0);
703 TRACE(" ----> CLOSE TRAY\n");
704 break;
705 default:
706 FIXME(" IOCTL OUTPUT: Unimplemented <%d>!!\n", io_stru[0]);
707 Error = 0x0c;
708 break;
710 break;
712 case 131: /* seek */
714 DWORD at;
716 at = PTR_AT(driver_request, 20, DWORD);
718 TRACE(" --> SEEK AUDIO mode :<0x%02X>, [%ld]\n",
719 (BYTE)driver_request[13], at);
721 switch (driver_request[13]) {
722 case 1: /* Red book addressing mode = 0:m:s:f */
723 /* FIXME : frame <=> msf conversion routines could be shared
724 * between mscdex and mcicda
726 at = LOBYTE(HIWORD(at)) * CDFRAMES_PERMIN +
727 HIBYTE(LOWORD(at)) * CDFRAMES_PERSEC +
728 LOBYTE(LOWORD(at));
729 /* fall thru */
730 case 0: /* HSG addressing mode */
731 CDROM_Audio_Seek(&wcda, at);
732 break;
733 default:
734 ERR("Unsupported address mode !!\n");
735 Error = 0x0c;
736 break;
739 break;
741 case 132: /* play */
743 DWORD beg, end;
745 beg = end = PTR_AT(driver_request, 14, DWORD);
746 end += PTR_AT(driver_request, 18, DWORD);
748 TRACE(" --> PLAY AUDIO mode :<0x%02X>, [%ld-%ld]\n",
749 (BYTE)driver_request[13], beg, end);
751 switch (driver_request[13]) {
752 case 1: /* Red book addressing mode = 0:m:s:f */
753 /* FIXME : frame <=> msf conversion routines could be shared
754 * between mscdex and mcicda
756 beg = LOBYTE(HIWORD(beg)) * CDFRAMES_PERMIN +
757 HIBYTE(LOWORD(beg)) * CDFRAMES_PERSEC +
758 LOBYTE(LOWORD(beg));
759 end = LOBYTE(HIWORD(end)) * CDFRAMES_PERMIN +
760 HIBYTE(LOWORD(end)) * CDFRAMES_PERSEC +
761 LOBYTE(LOWORD(end));
762 /* fall thru */
763 case 0: /* HSG addressing mode */
764 CDROM_Audio_Play(&wcda, beg, end);
765 break;
766 default:
767 ERR("Unsupported address mode !!\n");
768 Error = 0x0c;
769 break;
772 break;
774 case 133:
775 if (wcda.cdaMode == WINE_CDA_PLAY) {
776 CDROM_Audio_Pause(&wcda, 1);
777 TRACE(" --> STOP AUDIO (Paused)\n");
778 } else {
779 CDROM_Audio_Stop(&wcda);
780 TRACE(" --> STOP AUDIO (Stopped)\n");
782 break;
784 case 136:
785 TRACE(" --> RESUME AUDIO\n");
786 CDROM_Audio_Pause(&wcda, 0);
787 break;
789 default:
790 FIXME(" ioctl uninplemented <%d>\n", driver_request[2]);
791 Error = 0x0c;
794 /* setting error codes if any */
795 if (Error < 255) {
796 driver_request[4] |= 0x80;
797 driver_request[3] = Error;
800 /* setting status bits
801 * 3 == playing && done
802 * 1 == done
804 driver_request[4] |= (wcda.cdaMode == WINE_CDA_PLAY) ? 3 : 1;
806 MSCDEX_Dump("End", driver_request, dorealmode);
808 break;
809 default:
810 FIXME("Unimplemented MSCDEX function 0x%02X.\n", AL_reg(context));
811 break;