Added { } around stuff in ADD_TO_T macros.
[wine/multimedia.git] / msdos / int2f.c
blob757fd1c203420ed1528bf1eec9668823c79e97ad
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 "drive.h"
14 #include "miscemu.h"
15 #include "module.h"
16 #include "task.h"
17 /* #define DEBUG_INT */
18 #include "debugtools.h"
19 #include "cdrom.h"
21 DEFAULT_DEBUG_CHANNEL(int)
23 /* base WPROCS.DLL ordinal number for VxDs */
24 #define VXD_BASE 400
26 static void do_int2f_16( CONTEXT86 *context );
27 static void MSCDEX_Handler( CONTEXT86 *context );
29 /**********************************************************************
30 * INT_Int2fHandler
32 * Handler for int 2fh (multiplex).
34 void WINAPI INT_Int2fHandler( CONTEXT86 *context )
36 TRACE("Subfunction 0x%X\n", AX_reg(context));
38 switch(AH_reg(context))
40 case 0x10:
41 AL_reg(context) = 0xff; /* share is installed */
42 break;
44 case 0x11: /* Network Redirector / IFSFUNC */
45 switch (AL_reg(context))
47 case 0x00: /* Install check */
48 /* not installed */
49 break;
50 case 0x80: /* Enhanced services - Install check */
51 /* not installed */
52 break;
53 default:
54 INT_BARF( context, 0x2f );
55 break;
57 break;
59 case 0x12:
60 switch (AL_reg(context))
62 case 0x2e: /* get or set DOS error table address */
63 switch (DL_reg(context))
65 /* Four tables: even commands are 'get', odd are 'set' */
66 /* DOS 5.0+ ignores "set" commands */
67 case 0x01:
68 case 0x03:
69 case 0x05:
70 case 0x07:
71 case 0x09:
72 break;
73 /* Instead of having a message table in DOS-space, */
74 /* we can use a special case for MS-DOS to force */
75 /* the secondary interface. */
76 case 0x00:
77 case 0x02:
78 case 0x04:
79 case 0x06:
80 ES_reg(context) = 0x0001;
81 DI_reg(context) = 0x0000;
82 break;
83 case 0x08:
84 FIXME("No real-mode handler for errors yet! (bye!)");
85 break;
86 default:
87 INT_BARF(context, 0x2f);
89 break;
90 default:
91 INT_BARF(context, 0x2f);
93 break;
95 case 0x15: /* mscdex */
96 MSCDEX_Handler(context);
97 break;
99 case 0x16:
100 do_int2f_16( context );
101 break;
103 case 0x1a: /* ANSI.SYS / AVATAR.SYS Install Check */
104 /* Not supported yet, do nothing */
105 break;
107 case 0x43:
108 #if 1
109 switch (AL_reg(context))
111 case 0x00: /* XMS v2+ installation check */
112 WARN("XMS is not fully implemented\n");
113 AL_reg(context) = 0x80;
114 break;
115 case 0x10: /* XMS v2+ get driver address */
117 LPDOSTASK lpDosTask = MZ_Current();
119 ES_reg(context) = lpDosTask ? lpDosTask->xms_seg : 0;
120 BX_reg(context) = 0;
121 break;
123 default:
124 INT_BARF( context, 0x2f );
126 #else
127 FIXME("check for XMS (not supported)\n");
128 AL_reg(context) = 0x42; /* != 0x80 */
129 #endif
130 break;
132 case 0x45:
133 switch (AL_reg(context))
135 case 0x00:
136 case 0x01:
137 case 0x02:
138 case 0x03:
139 case 0x04:
140 case 0x05:
141 case 0x06:
142 case 0x07:
143 case 0x08:
144 /* Microsoft Profiler - not installed */
145 break;
146 default:
147 INT_BARF( context, 0x2f );
149 break;
151 case 0x4a:
152 switch(AL_reg(context))
154 case 0x10: /* smartdrv */
155 break; /* not installed */
156 case 0x11: /* dblspace */
157 break; /* not installed */
158 case 0x12: /* realtime compression interface */
159 break; /* not installed */
160 case 0x32: /* patch IO.SYS (???) */
161 break; /* we have no IO.SYS, so we can't patch it :-/ */
162 default:
163 INT_BARF( context, 0x2f );
165 break;
166 case 0x4b:
167 switch(AL_reg(context))
169 case 0x01:
170 case 0x02:
171 case 0x03:
172 case 0x04:
173 case 0x05:
174 FIXME("Task Switcher - not implemented\n");
175 break;
176 default:
177 INT_BARF( context, 0x2f );
179 break;
180 case 0x56: /* INTERLNK */
181 switch(AL_reg(context))
183 case 0x01: /* check if redirected drive */
184 AL_reg(context) = 0; /* not redirected */
185 break;
186 default:
187 INT_BARF( context, 0x2f );
189 break;
190 case 0x7a: /* NOVELL NetWare */
191 switch (AL_reg(context))
193 case 0x0: /* Low-level Netware installation check AL=0 not installed.*/
194 AL_reg(context) = 0;
195 break;
196 case 0x20: /* Get VLM Call Address */
197 /* return nothing -> NetWare not installed */
198 break;
199 default:
200 INT_BARF( context, 0x2f );
201 break;
203 break;
204 case 0xb7: /* append */
205 AL_reg(context) = 0; /* not installed */
206 break;
207 case 0xb8: /* network */
208 switch (AL_reg(context))
210 case 0x00: /* Install check */
211 /* not installed */
212 break;
213 default:
214 INT_BARF( context, 0x2f );
215 break;
217 break;
218 case 0xbd: /* some Novell network install check ??? */
219 AX_reg(context) = 0xa5a5; /* pretend to have Novell IPX installed */
220 break;
221 case 0xbf: /* REDIRIFS.EXE */
222 switch (AL_reg(context))
224 case 0x00: /* Install check */
225 /* not installed */
226 break;
227 default:
228 INT_BARF( context, 0x2f );
229 break;
231 break;
232 case 0xd2:
233 switch(AL_reg(context))
235 case 0x01: /* Quarterdeck RPCI - QEMM/QRAM - PCL-838.EXE functions */
236 if(BX_reg(context) == 0x5145 && CX_reg(context) == 0x4D4D
237 && DX_reg(context) == 0x3432)
238 TRACE("Check for QEMM v5.0+ (not installed)\n");
239 break;
240 default:
241 INT_BARF( context, 0x2f );
242 break;
244 break;
245 case 0xd7: /* Banyan Vines */
246 switch (AL_reg(context))
248 case 0x01: /* Install check - Get Int Number */
249 /* not installed */
250 break;
251 default:
252 INT_BARF( context, 0x2f );
253 break;
255 break;
256 case 0xde:
257 switch(AL_reg(context))
259 case 0x01: /* Quarterdeck QDPMI.SYS - DESQview */
260 if(BX_reg(context) == 0x4450 && CX_reg(context) == 0x4d49
261 && DX_reg(context) == 0x8f4f)
262 TRACE("Check for QDPMI.SYS (not installed)\n");
263 break;
264 default:
265 INT_BARF( context, 0x2f );
266 break;
268 break;
269 case 0xfa: /* Watcom debugger check, returns 0x666 if installed */
270 break;
271 default:
272 INT_BARF( context, 0x2f );
273 break;
278 /**********************************************************************
279 * do_int2f_16
281 static void do_int2f_16( CONTEXT86 *context )
283 DWORD addr;
285 switch(AL_reg(context))
287 case 0x00: /* Windows enhanced mode installation check */
288 AX_reg(context) = (GetWinFlags16() & WF_ENHANCED) ?
289 LOWORD(GetVersion16()) : 0;
290 break;
292 case 0x0a: /* Get Windows version and type */
293 AX_reg(context) = 0;
294 BX_reg(context) = (LOWORD(GetVersion16()) << 8) |
295 (LOWORD(GetVersion16()) >> 8);
296 CX_reg(context) = (GetWinFlags16() & WF_ENHANCED) ? 3 : 2;
297 break;
299 case 0x0b: /* Identify Windows-aware TSRs */
300 /* we don't have any pre-Windows TSRs */
301 break;
303 case 0x11: /* Get Shell Parameters - (SHELL= in CONFIG.SYS) */
304 /* We can mock this up. But not today... */
305 FIXME("Get Shell Parameters\n");
306 break;
308 case 0x80: /* Release time-slice */
309 AL_reg(context) = 0;
310 break;
312 case 0x81: /* Begin critical section. */
313 /* FIXME? */
314 break;
316 case 0x82: /* End critical section. */
317 /* FIXME? */
318 break;
320 case 0x83: /* Return Current Virtual Machine ID */
321 /* Virtual Machines are usually created/destroyed when Windows runs
322 * DOS programs. Since we never do, we are always in the System VM.
323 * According to Ralf Brown's Interrupt List, never return 0. But it
324 * seems to work okay (returning 0), just to be sure we return 1.
326 BX_reg(context) = 1; /* VM 1 is probably the System VM */
327 break;
329 case 0x84: /* Get device API entry point */
330 addr = (DWORD)NE_GetEntryPoint( GetModuleHandle16("WPROCS"),
331 VXD_BASE + BX_reg(context) );
332 if (!addr) /* not supported */
334 ERR("Accessing unknown VxD %04x - Expect a failure now.\n",
335 BX_reg(context) );
337 ES_reg(context) = SELECTOROF(addr);
338 DI_reg(context) = OFFSETOF(addr);
339 break;
341 case 0x86: /* DPMI detect mode */
342 AX_reg(context) = 0; /* Running under DPMI */
343 break;
345 case 0x87: /* DPMI installation check */
346 #if 1 /* DPMI still breaks pkunzip */
347 if (ISV86(context)) break; /* so bail out for now if in v86 mode */
348 #endif
350 SYSTEM_INFO si;
351 LPDOSTASK lpDosTask = MZ_Current();
353 GetSystemInfo(&si);
354 AX_reg(context) = 0x0000; /* DPMI Installed */
355 BX_reg(context) = 0x0001; /* 32bits available */
356 CL_reg(context) = si.wProcessorLevel;
357 DX_reg(context) = 0x005a; /* DPMI major/minor 0.90 */
358 SI_reg(context) = 0; /* # of para. of DOS extended private data */
359 ES_reg(context) = lpDosTask ? lpDosTask->dpmi_seg : 0;
360 DI_reg(context) = 0; /* ES:DI is DPMI switch entry point */
361 break;
363 case 0x8a: /* DPMI get vendor-specific API entry point. */
364 /* The 1.0 specs say this should work with all 0.9 hosts. */
365 break;
367 default:
368 INT_BARF( context, 0x2f );
372 /* FIXME: this macro may have to be changed on architectures where <size> reads/writes
373 * must be <size> aligned
374 * <size> could be WORD, DWORD...
375 * in this case, we would need two macros, one for read, the other one for write
376 * Note: PTR_AT can be used as an l-value
378 #define PTR_AT(_ptr, _ofs, _typ) (*((_typ*)(((char*)_ptr)+(_ofs))))
380 /* Use #if 1 if you want full int 2f debug... normal users can leave it at 0 */
381 #if 0
382 /**********************************************************************
383 * MSCDEX_Dump [internal]
385 * Dumps mscdex requests to int debug channel.
387 static void MSCDEX_Dump(char* pfx, BYTE* req, int dorealmode)
389 int i;
390 BYTE buf[2048];
391 BYTE* ptr;
392 BYTE* ios;
394 ptr = buf;
395 ptr += sprintf(ptr, "%s\tCommand => ", pfx);
396 for (i = 0; i < req[0]; i++) {
397 ptr += sprintf(ptr, "%02x ", req[i]);
400 switch (req[2]) {
401 case 3:
402 case 12:
403 ptr += sprintf(ptr, "\n\t\t\t\tIO_struct => ");
404 ios = (dorealmode) ?
405 DOSMEM_MapRealToLinear(MAKELONG(PTR_AT(req, 14, WORD), PTR_AT(req, 16, WORD))) :
406 PTR_SEG_OFF_TO_LIN(PTR_AT(req, 16, WORD), PTR_AT(req, 14, WORD));
408 for (i = 0; i < PTR_AT(req, 18, WORD); i++) {
409 ptr += sprintf(ptr, "%02x ", ios[i]);
410 if ((i & 0x1F) == 0x1F) {
411 *ptr++ = '\n';
412 *ptr = 0;
415 break;
417 TRACE("%s\n", buf);
419 #else
420 #define MSCDEX_Dump(pfx, req, drm)
421 #endif
423 static void MSCDEX_StoreMSF(DWORD frame, BYTE* val)
425 val[3] = 0; /* zero */
426 val[2] = frame / CDFRAMES_PERMIN; /* minutes */
427 val[1] = (frame - CDFRAMES_PERMIN * val[2]) / CDFRAMES_PERSEC; /* seconds */
428 val[0] = frame - CDFRAMES_PERMIN * val[2] - CDFRAMES_PERSEC * val[1]; /* frames */
431 static void MSCDEX_Handler(CONTEXT86* context)
433 int drive, count;
434 char* p;
436 switch(AL_reg(context)) {
437 case 0x00: /* Installation check */
438 /* Count the number of contiguous CDROM drives
440 for (drive = count = 0; drive < MAX_DOS_DRIVES; drive++) {
441 if (DRIVE_GetType(drive) == TYPE_CDROM) {
442 while (DRIVE_GetType(drive + count) == TYPE_CDROM) count++;
443 break;
446 TRACE("Installation check: %d cdroms, starting at %d\n", count, drive);
447 BX_reg(context) = count;
448 CX_reg(context) = (drive < MAX_DOS_DRIVES) ? drive : 0;
449 break;
451 case 0x0B: /* drive check */
452 AX_reg(context) = (DRIVE_GetType(CX_reg(context)) == TYPE_CDROM);
453 BX_reg(context) = 0xADAD;
454 break;
456 case 0x0C: /* get version */
457 BX_reg(context) = 0x020a;
458 TRACE("Version number => %04x\n", BX_reg(context));
459 break;
461 case 0x0D: /* get drive letters */
462 p = CTX_SEG_OFF_TO_LIN(context, ES_reg(context), EBX_reg(context));
463 memset(p, 0, MAX_DOS_DRIVES);
464 for (drive = 0; drive < MAX_DOS_DRIVES; drive++) {
465 if (DRIVE_GetType(drive) == TYPE_CDROM) *p++ = drive;
467 TRACE("Get drive letters\n");
468 break;
470 case 0x10: /* direct driver access */
472 static WINE_CDAUDIO wcda;
473 BYTE* driver_request;
474 BYTE* io_stru;
475 BYTE Error = 255; /* No Error */
476 int dorealmode = ISV86(context);
478 driver_request = (dorealmode) ?
479 DOSMEM_MapRealToLinear(MAKELONG(BX_reg(context), ES_reg(context))) :
480 PTR_SEG_OFF_TO_LIN(ES_reg(context), BX_reg(context));
482 if (!driver_request) {
483 /* FIXME - to be deleted ?? */
484 ERR("ES:BX==0 ! SEGFAULT ?\n");
485 ERR("-->BX=0x%04x, ES=0x%04lx, DS=0x%04lx, CX=0x%04x\n",
486 BX_reg(context), ES_reg(context), DS_reg(context), CX_reg(context));
487 driver_request[4] |= 0x80;
488 driver_request[3] = 5; /* bad request length */
489 return;
491 /* FIXME - would be better to open the device at the beginning of the wine session...
492 * - the device is also never closed...
493 * - the current implementation only supports a single CD ROM
495 if (wcda.unixdev <= 0)
496 CDROM_Open(&wcda, -1);
497 TRACE("CDROM device driver -> command <%d>\n", (unsigned char)driver_request[2]);
499 for (drive = 0;
500 drive < MAX_DOS_DRIVES && DRIVE_GetType(drive) != TYPE_CDROM;
501 drive++);
502 /* drive contains the first CD ROM */
503 if (CX_reg(context) != drive) {
504 WARN("Request made doesn't match a CD ROM drive (%d/%d)\n", CX_reg(context), drive);
505 driver_request[4] |= 0x80;
506 driver_request[3] = 1; /* unknown unit */
507 return;
510 MSCDEX_Dump("Beg", driver_request, dorealmode);
512 /* set status to 0 */
513 PTR_AT(driver_request, 3, WORD) = 0;
514 CDROM_Audio_GetCDStatus(&wcda);
516 switch (driver_request[2]) {
517 case 3:
518 io_stru = (dorealmode) ?
519 DOSMEM_MapRealToLinear(MAKELONG(PTR_AT(driver_request, 14, WORD), PTR_AT(driver_request, 16, WORD))) :
520 PTR_SEG_OFF_TO_LIN(PTR_AT(driver_request, 16, WORD), PTR_AT(driver_request, 14, WORD));
522 TRACE(" --> IOCTL INPUT <%d>\n", io_stru[0]);
523 switch (io_stru[0]) {
524 #if 0
525 case 0: /* Get device Header */
527 static LPSTR ptr = 0;
528 if (ptr == 0) {
529 ptr = SEGPTR_ALLOC(22);
530 PTR_AT(ptr, 0, DWORD) = ~1; /* Next Device Driver */
531 PTR_AT(ptr, 4, WORD) = 0xC800; /* Device attributes */
532 PTR_AT(ptr, 6, WORD) = 0x1234; /* Pointer to device strategy routine: FIXME */
533 PTR_AT(ptr, 8, WORD) = 0x3142; /* Pointer to device interrupt routine: FIXME */
534 PTR_AT(ptr, 10, char) = 'W'; /* 8-byte character device name field */
535 PTR_AT(ptr, 11, char) = 'I';
536 PTR_AT(ptr, 12, char) = 'N';
537 PTR_AT(ptr, 13, char) = 'E';
538 PTR_AT(ptr, 14, char) = '_';
539 PTR_AT(ptr, 15, char) = 'C';
540 PTR_AT(ptr, 16, char) = 'D';
541 PTR_AT(ptr, 17, char) = '_';
542 PTR_AT(ptr, 18, WORD) = 0; /* Reserved (must be zero) */
543 PTR_AT(ptr, 20, BYTE) = 0; /* Drive letter (must be zero) */
544 PTR_AT(ptr, 21, BYTE) = 1; /* Number of units supported (one or more) FIXME*/
546 PTR_AT(io_stru, DWORD, 0) = SEGPTR_GET(ptr);
548 break;
549 #endif
551 case 1: /* location of head */
552 switch (io_stru[1]) {
553 case 0:
554 PTR_AT(io_stru, 2, DWORD) = wcda.dwCurFrame;
555 break;
556 case 1:
557 MSCDEX_StoreMSF(wcda.dwCurFrame, io_stru + 2);
558 break;
559 default:
560 ERR("CD-ROM driver: unsupported addressing mode !!\n");
561 Error = 0x0c;
563 TRACE(" ----> HEAD LOCATION <%ld>\n", PTR_AT(io_stru, 2, DWORD));
564 break;
566 case 4: /* Audio channel info */
567 io_stru[1] = 0;
568 io_stru[2] = 0xff;
569 io_stru[3] = 1;
570 io_stru[4] = 0xff;
571 io_stru[5] = 2;
572 io_stru[6] = 0;
573 io_stru[7] = 3;
574 io_stru[8] = 0;
575 TRACE(" ----> AUDIO CHANNEL INFO\n");
576 break;
578 case 6: /* device status */
579 PTR_AT(io_stru, 1, DWORD) = 0x00000290;
580 /* 290 =>
581 * 1 Supports HSG and Red Book addressing modes
582 * 0 Supports audio channel manipulation
584 * 1 Supports prefetching requests
585 * 0 Reserved
586 * 0 No interleaving
587 * 1 Data read and plays audio/video tracks
589 * 0 Read only
590 * 0 Supports only cooked reading
591 * 0 Door locked
592 * 0 see below (Door closed/opened)
594 if (wcda.cdaMode == WINE_CDA_OPEN)
595 io_stru[1] |= 1;
596 TRACE(" ----> DEVICE STATUS <0x%08lx>\n", PTR_AT(io_stru, 1, DWORD));
597 break;
599 case 8: /* Volume size */
600 PTR_AT(io_stru, 1, DWORD) = wcda.dwLastFrame;
601 TRACE(" ----> VOLUME SIZE <%ld>\n", PTR_AT(io_stru, 1, DWORD));
602 break;
604 case 9: /* media changed ? */
605 /* answers don't know... -1/1 for yes/no would be better */
606 io_stru[1] = 0; /* FIXME? 1? */
607 TRACE(" ----> MEDIA CHANGED <%d>\n", io_stru[1]);
608 break;
610 case 10: /* audio disk info */
611 io_stru[1] = wcda.nFirstTrack; /* starting track of the disc */
612 io_stru[2] = wcda.nLastTrack; /* ending track */
613 MSCDEX_StoreMSF(wcda.dwLastFrame, io_stru + 3);
615 TRACE(" ----> AUDIO DISK INFO <%d-%d/%08lx>\n",
616 io_stru[1], io_stru[2], PTR_AT(io_stru, 3, DWORD));
617 break;
619 case 11: /* audio track info */
620 if (io_stru[1] >= wcda.nFirstTrack && io_stru[1] <= wcda.nLastTrack) {
621 int nt = io_stru[1] - wcda.nFirstTrack;
622 MSCDEX_StoreMSF(wcda.lpdwTrackPos[nt], io_stru + 2);
623 /* starting point if the track */
624 io_stru[6] = (wcda.lpbTrackFlags[nt] & 0xF0) >> 4;
625 } else {
626 PTR_AT(io_stru, 2, DWORD) = 0;
627 io_stru[6] = 0;
629 TRACE(" ----> AUDIO TRACK INFO[%d] = [%08lx:%d]\n",
630 io_stru[1], PTR_AT(io_stru, 2, DWORD), io_stru[6]);
631 break;
633 case 12: /* get Q-Channel info */
634 io_stru[1] = wcda.lpbTrackFlags[wcda.nCurTrack - 1];
635 io_stru[2] = wcda.nCurTrack;
636 io_stru[3] = 0; /* FIXME ?? */
638 /* why the heck did MS use another format for 0MSF information... sigh */
640 BYTE bTmp[4];
642 MSCDEX_StoreMSF(wcda.dwCurFrame - wcda.lpdwTrackPos[wcda.nCurTrack - 1], bTmp);
643 io_stru[ 4] = bTmp[2];
644 io_stru[ 5] = bTmp[1];
645 io_stru[ 6] = bTmp[0];
646 io_stru[ 7] = 0;
648 MSCDEX_StoreMSF(wcda.dwCurFrame, bTmp);
649 io_stru[ 8] = bTmp[2];
650 io_stru[ 9] = bTmp[1];
651 io_stru[10] = bTmp[0];
652 io_stru[11] = 0;
654 TRACE("Q-Channel info: Ctrl/adr=%02x TNO=%02x X=%02x rtt=%02x:%02x:%02x rtd=%02x:%02x:%02x (cf=%08lx, tp=%08lx)\n",
655 io_stru[ 1], io_stru[ 2], io_stru[ 3],
656 io_stru[ 4], io_stru[ 5], io_stru[ 6],
657 io_stru[ 8], io_stru[ 9], io_stru[10],
658 wcda.dwCurFrame, wcda.lpdwTrackPos[wcda.nCurTrack - 1]);
659 break;
661 case 15: /* Audio status info */
662 /* !!!! FIXME FIXME FIXME !! */
663 PTR_AT(io_stru, 1, WORD) = 2 | ((wcda.cdaMode == WINE_CDA_PAUSE) ? 1 : 0);
664 if (wcda.cdaMode == WINE_CDA_OPEN) {
665 PTR_AT(io_stru, 3, DWORD) = 0;
666 PTR_AT(io_stru, 7, DWORD) = 0;
667 } else {
668 PTR_AT(io_stru, 3, DWORD) = wcda.lpdwTrackPos[0];
669 PTR_AT(io_stru, 7, DWORD) = wcda.lpdwTrackPos[wcda.nTracks - 1];
671 TRACE("Audio status info: status=%04x startLoc=%ld endLoc=%ld\n",
672 PTR_AT(io_stru, 1, WORD), PTR_AT(io_stru, 3, DWORD), PTR_AT(io_stru, 7, DWORD));
673 break;
675 default:
676 FIXME("IOCTL INPUT: Unimplemented <%d>!!\n", io_stru[0]);
677 Error = 0x0c;
678 break;
680 break;
682 case 12:
683 io_stru = (dorealmode) ?
684 DOSMEM_MapRealToLinear(MAKELONG(PTR_AT(driver_request, 14, WORD), PTR_AT(driver_request, 16, WORD))) :
685 PTR_SEG_OFF_TO_LIN(PTR_AT(driver_request, 16, WORD), PTR_AT(driver_request, 14, WORD));
687 TRACE(" --> IOCTL OUTPUT <%d>\n", io_stru[0]);
688 switch (io_stru[0]) {
689 case 0: /* eject */
690 CDROM_SetDoor(&wcda, 1);
691 TRACE(" ----> EJECT\n");
692 break;
693 case 2: /* reset drive */
694 CDROM_Reset(&wcda);
695 TRACE(" ----> RESET\n");
696 break;
697 case 3: /* Audio Channel Control */
698 FIXME(" ----> AUDIO CHANNEL CONTROL (NIY)\n");
699 break;
700 case 5: /* close tray */
701 CDROM_SetDoor(&wcda, 0);
702 TRACE(" ----> CLOSE TRAY\n");
703 break;
704 default:
705 FIXME(" IOCTL OUTPUT: Unimplemented <%d>!!\n", io_stru[0]);
706 Error = 0x0c;
707 break;
709 break;
711 case 131: /* seek */
713 DWORD at;
715 at = PTR_AT(driver_request, 20, DWORD);
717 TRACE(" --> SEEK AUDIO mode :<0x%02X>, [%ld]\n",
718 (BYTE)driver_request[13], at);
720 switch (driver_request[13]) {
721 case 1: /* Red book addressing mode = 0:m:s:f */
722 /* FIXME : frame <=> msf conversion routines could be shared
723 * between mscdex and mcicda
725 at = LOBYTE(HIWORD(at)) * CDFRAMES_PERMIN +
726 HIBYTE(LOWORD(at)) * CDFRAMES_PERSEC +
727 LOBYTE(LOWORD(at));
728 /* fall thru */
729 case 0: /* HSG addressing mode */
730 CDROM_Audio_Seek(&wcda, at);
731 break;
732 default:
733 ERR("Unsupported address mode !!\n");
734 Error = 0x0c;
735 break;
738 break;
740 case 132: /* play */
742 DWORD beg, end;
744 beg = end = PTR_AT(driver_request, 14, DWORD);
745 end += PTR_AT(driver_request, 18, DWORD);
747 TRACE(" --> PLAY AUDIO mode :<0x%02X>, [%ld-%ld]\n",
748 (BYTE)driver_request[13], beg, end);
750 switch (driver_request[13]) {
751 case 1: /* Red book addressing mode = 0:m:s:f */
752 /* FIXME : frame <=> msf conversion routines could be shared
753 * between mscdex and mcicda
755 beg = LOBYTE(HIWORD(beg)) * CDFRAMES_PERMIN +
756 HIBYTE(LOWORD(beg)) * CDFRAMES_PERSEC +
757 LOBYTE(LOWORD(beg));
758 end = LOBYTE(HIWORD(end)) * CDFRAMES_PERMIN +
759 HIBYTE(LOWORD(end)) * CDFRAMES_PERSEC +
760 LOBYTE(LOWORD(end));
761 /* fall thru */
762 case 0: /* HSG addressing mode */
763 CDROM_Audio_Play(&wcda, beg, end);
764 break;
765 default:
766 ERR("Unsupported address mode !!\n");
767 Error = 0x0c;
768 break;
771 break;
773 case 133:
774 if (wcda.cdaMode == WINE_CDA_PLAY) {
775 CDROM_Audio_Pause(&wcda, 1);
776 TRACE(" --> STOP AUDIO (Paused)\n");
777 } else {
778 CDROM_Audio_Stop(&wcda);
779 TRACE(" --> STOP AUDIO (Stopped)\n");
781 break;
783 case 136:
784 TRACE(" --> RESUME AUDIO\n");
785 CDROM_Audio_Pause(&wcda, 0);
786 break;
788 default:
789 FIXME(" ioctl uninplemented <%d>\n", driver_request[2]);
790 Error = 0x0c;
793 /* setting error codes if any */
794 if (Error < 255) {
795 driver_request[4] |= 0x80;
796 driver_request[3] = Error;
799 /* setting status bits
800 * 3 == playing && done
801 * 1 == done
803 driver_request[4] |= (wcda.cdaMode == WINE_CDA_PLAY) ? 3 : 1;
805 MSCDEX_Dump("End", driver_request, dorealmode);
807 break;
808 default:
809 FIXME("Unimplemented MSCDEX function 0x%02X.\n", AL_reg(context));
810 break;