Fixed typo.
[wine.git] / msdos / int2f.c
blob913f67d4994212b50b837d552014d321da6f1edf
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 <stdlib.h>
11 #include <string.h>
12 #include <unistd.h>
14 #include "wine/winbase16.h"
15 #include "ldt.h"
16 #include "drive.h"
17 #include "msdos.h"
18 #include "miscemu.h"
19 #include "module.h"
20 #include "task.h"
21 #include "dosexe.h"
22 #include "heap.h"
23 /* #define DEBUG_INT */
24 #include "debug.h"
25 #include "cdrom.h"
27 /* base WPROCS.DLL ordinal number for VxDs */
28 #define VXD_BASE 400
30 static void do_int2f_16( CONTEXT *context );
31 static void MSCDEX_Handler( CONTEXT *context );
33 /**********************************************************************
34 * INT_Int2fHandler
36 * Handler for int 2fh (multiplex).
38 void WINAPI INT_Int2fHandler( CONTEXT *context )
40 TRACE(int,"Subfunction 0x%X\n", AX_reg(context));
42 switch(AH_reg(context))
44 case 0x10:
45 AL_reg(context) = 0xff; /* share is installed */
46 break;
48 case 0x11: /* Network Redirector / IFSFUNC */
49 switch (AL_reg(context))
51 case 0x00: /* Install check */
52 /* not installed */
53 break;
54 case 0x80: /* Enhanced services - Install check */
55 /* not installed */
56 break;
57 default:
58 INT_BARF( context, 0x2f );
59 break;
61 break;
63 case 0x12:
64 switch (AL_reg(context))
66 case 0x2e: /* get or set DOS error table address */
67 switch (DL_reg(context))
69 /* Four tables: even commands are 'get', odd are 'set' */
70 /* DOS 5.0+ ignores "set" commands */
71 case 0x01:
72 case 0x03:
73 case 0x05:
74 case 0x07:
75 case 0x09:
76 break;
77 /* Instead of having a message table in DOS-space, */
78 /* we can use a special case for MS-DOS to force */
79 /* the secondary interface. */
80 case 0x00:
81 case 0x02:
82 case 0x04:
83 case 0x06:
84 ES_reg(context) = 0x0001;
85 DI_reg(context) = 0x0000;
86 break;
87 case 0x08:
88 FIXME(int, "No real-mode handler for errors yet! (bye!)");
89 break;
90 default:
91 INT_BARF(context, 0x2f);
93 break;
94 default:
95 INT_BARF(context, 0x2f);
97 break;
99 case 0x15: /* mscdex */
100 MSCDEX_Handler(context);
101 break;
103 case 0x16:
104 do_int2f_16( context );
105 break;
107 case 0x1a: /* ANSI.SYS / AVATAR.SYS Install Check */
108 /* Not supported yet, do nothing */
109 break;
111 case 0x43:
112 #if 1
113 switch (AL_reg(context))
115 case 0x00: /* XMS v2+ installation check */
116 WARN(int,"XMS is not fully implemented\n");
117 AL_reg(context) = 0x80;
118 break;
119 case 0x10: /* XMS v2+ get driver address */
121 TDB *pTask = (TDB *)GlobalLock16( GetCurrentTask() );
122 NE_MODULE *pModule = pTask ? NE_GetPtr( pTask->hModule ) : NULL;
123 GlobalUnlock16( GetCurrentTask() );
124 #ifdef MZ_SUPPORTED
125 if (pModule && pModule->lpDosTask)
126 ES_reg(context) = pModule->lpDosTask->xms_seg;
127 else
128 #endif
129 ES_reg(context) = 0;
130 BX_reg(context) = 0;
131 break;
133 default:
134 INT_BARF( context, 0x2f );
136 #else
137 FIXME(int,"check for XMS (not supported)\n");
138 AL_reg(context) = 0x42; /* != 0x80 */
139 #endif
140 break;
142 case 0x45:
143 switch (AL_reg(context))
145 case 0x00:
146 case 0x01:
147 case 0x02:
148 case 0x03:
149 case 0x04:
150 case 0x05:
151 case 0x06:
152 case 0x07:
153 case 0x08:
154 /* Microsoft Profiler - not installed */
155 break;
156 default:
157 INT_BARF( context, 0x2f );
159 break;
161 case 0x4a:
162 switch(AL_reg(context))
164 case 0x10: /* smartdrv */
165 break; /* not installed */
166 case 0x11: /* dblspace */
167 break; /* not installed */
168 case 0x12: /* realtime compression interface */
169 break; /* not installed */
170 case 0x32: /* patch IO.SYS (???) */
171 break; /* we have no IO.SYS, so we can't patch it :-/ */
172 default:
173 INT_BARF( context, 0x2f );
175 break;
176 case 0x56: /* INTERLNK */
177 switch(AL_reg(context))
179 case 0x01: /* check if redirected drive */
180 AL_reg(context) = 0; /* not redirected */
181 break;
182 default:
183 INT_BARF( context, 0x2f );
185 break;
186 case 0x7a: /* NOVELL NetWare */
187 switch (AL_reg(context))
189 case 0x0: /* Low-level Netware installation check AL=0 not installed.*/
190 AL_reg(context) = 0;
191 break;
192 case 0x20: /* Get VLM Call Address */
193 /* return nothing -> NetWare not installed */
194 break;
195 default:
196 INT_BARF( context, 0x2f );
197 break;
199 break;
200 case 0xb7: /* append */
201 AL_reg(context) = 0; /* not installed */
202 break;
203 case 0xb8: /* network */
204 switch (AL_reg(context))
206 case 0x00: /* Install check */
207 /* not installed */
208 break;
209 default:
210 INT_BARF( context, 0x2f );
211 break;
213 break;
214 case 0xbd: /* some Novell network install check ??? */
215 AX_reg(context) = 0xa5a5; /* pretend to have Novell IPX installed */
216 break;
217 case 0xbf: /* REDIRIFS.EXE */
218 switch (AL_reg(context))
220 case 0x00: /* Install check */
221 /* not installed */
222 break;
223 default:
224 INT_BARF( context, 0x2f );
225 break;
227 break;
228 case 0xd2:
229 switch(AL_reg(context))
231 case 0x01: /* Quarterdeck RPCI - QEMM/QRAM - PCL-838.EXE functions */
232 if(BX_reg(context) == 0x5145 && CX_reg(context) == 0x4D4D
233 && DX_reg(context) == 0x3432)
234 TRACE(int, "Check for QEMM v5.0+ (not installed)\n");
235 break;
236 default:
237 INT_BARF( context, 0x2f );
238 break;
240 break;
241 case 0xd7: /* Banyan Vines */
242 switch (AL_reg(context))
244 case 0x01: /* Install check - Get Int Number */
245 /* not installed */
246 break;
247 default:
248 INT_BARF( context, 0x2f );
249 break;
251 break;
252 case 0xde:
253 switch(AL_reg(context))
255 case 0x01: /* Quarterdeck QDPMI.SYS - DESQview */
256 if(BX_reg(context) == 0x4450 && CX_reg(context) == 0x4d49
257 && DX_reg(context) == 0x8f4f)
258 TRACE(int, "Check for QDPMI.SYS (not installed)\n");
259 break;
260 default:
261 INT_BARF( context, 0x2f );
262 break;
264 break;
265 case 0xfa: /* Watcom debugger check, returns 0x666 if installed */
266 break;
267 default:
268 INT_BARF( context, 0x2f );
269 break;
274 /**********************************************************************
275 * do_int2f_16
277 static void do_int2f_16( CONTEXT *context )
279 DWORD addr;
281 switch(AL_reg(context))
283 case 0x00: /* Windows enhanced mode installation check */
284 AX_reg(context) = (GetWinFlags16() & WF_ENHANCED) ?
285 LOWORD(GetVersion16()) : 0;
286 break;
288 case 0x0a: /* Get Windows version and type */
289 AX_reg(context) = 0;
290 BX_reg(context) = (LOWORD(GetVersion16()) << 8) |
291 (LOWORD(GetVersion16()) >> 8);
292 CX_reg(context) = (GetWinFlags16() & WF_ENHANCED) ? 3 : 2;
293 break;
295 case 0x0b: /* Identify Windows-aware TSRs */
296 /* we don't have any pre-Windows TSRs */
297 break;
299 case 0x11: /* Get Shell Parameters - (SHELL= in CONFIG.SYS) */
300 /* We can mock this up. But not today... */
301 FIXME(int, "Get Shell Parameters\n");
302 break;
304 case 0x80: /* Release time-slice */
305 AL_reg(context) = 0;
306 break;
308 case 0x81: /* Begin critical section. */
309 /* FIXME? */
310 break;
312 case 0x82: /* End critical section. */
313 /* FIXME? */
314 break;
316 case 0x83: /* Return Current Virtual Machine ID */
317 /* Virtual Machines are usually created/destroyed when Windows runs
318 * DOS programs. Since we never do, we are always in the System VM.
319 * According to Ralf Brown's Interrupt List, never return 0. But it
320 * seems to work okay (returning 0), just to be sure we return 1.
322 BX_reg(context) = 1; /* VM 1 is probably the System VM */
323 break;
325 case 0x84: /* Get device API entry point */
326 addr = (DWORD)NE_GetEntryPoint( GetModuleHandle16("WPROCS"),
327 VXD_BASE + BX_reg(context) );
328 if (!addr) /* not supported */
330 ERR(int, "Accessing unknown VxD %04x - Expect a failure now.\n",
331 BX_reg(context) );
333 ES_reg(context) = SELECTOROF(addr);
334 DI_reg(context) = OFFSETOF(addr);
335 break;
337 case 0x86: /* DPMI detect mode */
338 AX_reg(context) = 0; /* Running under DPMI */
339 break;
341 case 0x87: /* DPMI installation check */
342 #if 1 /* DPMI still breaks pkunzip */
343 if (ISV86(context)) break; /* so bail out for now if in v86 mode */
344 #endif
346 TDB *pTask = (TDB *)GlobalLock16( GetCurrentTask() );
347 NE_MODULE *pModule = pTask ? NE_GetPtr( pTask->hModule ) : NULL;
348 SYSTEM_INFO si;
350 GlobalUnlock16( GetCurrentTask() );
351 GetSystemInfo(&si);
352 AX_reg(context) = 0x0000; /* DPMI Installed */
353 BX_reg(context) = 0x0001; /* 32bits available */
354 CL_reg(context) = si.wProcessorLevel;
355 DX_reg(context) = 0x005a; /* DPMI major/minor 0.90 */
356 SI_reg(context) = 0; /* # of para. of DOS extended private data */
357 #ifdef MZ_SUPPORTED /* ES:DI is DPMI switch entry point */
358 if (pModule && pModule->lpDosTask)
359 ES_reg(context) = pModule->lpDosTask->dpmi_seg;
360 else
361 #endif
362 ES_reg(context) = 0;
363 DI_reg(context) = 0;
364 break;
366 case 0x8a: /* DPMI get vendor-specific API entry point. */
367 /* The 1.0 specs say this should work with all 0.9 hosts. */
368 break;
370 default:
371 INT_BARF( context, 0x2f );
375 /* FIXME: this macro may have to be changed on architectures where <size> reads/writes
376 * must be <size> aligned
377 * <size> could be WORD, DWORD...
378 * in this case, we would need two macros, one for read, the other one for write
379 * Note: PTR_AT can be used as an l-value
381 #define PTR_AT(_ptr, _ofs, _typ) (*((_typ*)(((char*)_ptr)+(_ofs))))
383 /* Use #if 1 if you want full int 2f debug... normal users can leave it at 0 */
384 #if 0
385 /**********************************************************************
386 * MSCDEX_Dump [internal]
388 * Dumps mscdex requests to int debug channel.
390 static void MSCDEX_Dump(char* pfx, BYTE* req, int dorealmode)
392 int i;
393 BYTE buf[2048];
394 BYTE* ptr;
395 BYTE* ios;
397 ptr = buf;
398 ptr += sprintf(ptr, "%s\tCommand => ", pfx);
399 for (i = 0; i < req[0]; i++) {
400 ptr += sprintf(ptr, "%02x ", req[i]);
403 switch (req[2]) {
404 case 3:
405 case 12:
406 ptr += sprintf(ptr, "\n\t\t\t\tIO_struct => ");
407 ios = (dorealmode) ?
408 DOSMEM_MapRealToLinear(MAKELONG(PTR_AT(req, 14, WORD), PTR_AT(req, 16, WORD))) :
409 PTR_SEG_OFF_TO_LIN(PTR_AT(req, 16, WORD), PTR_AT(req, 14, WORD));
411 for (i = 0; i < PTR_AT(req, 18, WORD); i++) {
412 ptr += sprintf(ptr, "%02x ", ios[i]);
413 if ((i & 0x1F) == 0x1F) {
414 *ptr++ = '\n';
415 *ptr = 0;
418 break;
420 TRACE(int, "%s\n", buf);
422 #else
423 #define MSCDEX_Dump(pfx, req, drm)
424 #endif
426 static void MSCDEX_StoreMSF(DWORD frame, BYTE* val)
428 val[3] = 0; /* zero */
429 val[2] = frame / CDFRAMES_PERMIN; /* minutes */
430 val[1] = (frame - CDFRAMES_PERMIN * val[2]) / CDFRAMES_PERSEC; /* seconds */
431 val[0] = frame - CDFRAMES_PERMIN * val[2] - CDFRAMES_PERSEC * val[1]; /* frames */
434 static void MSCDEX_Handler(CONTEXT* context)
436 int drive, count;
437 char* p;
439 switch(AL_reg(context)) {
440 case 0x00: /* Installation check */
441 /* Count the number of contiguous CDROM drives
443 for (drive = count = 0; drive < MAX_DOS_DRIVES; drive++) {
444 if (DRIVE_GetType(drive) == TYPE_CDROM) {
445 while (DRIVE_GetType(drive + count) == TYPE_CDROM) count++;
446 break;
449 TRACE(int, "Installation check: %d cdroms, starting at %d\n", count, drive);
450 BX_reg(context) = count;
451 CX_reg(context) = (drive < MAX_DOS_DRIVES) ? drive : 0;
452 break;
454 case 0x0B: /* drive check */
455 AX_reg(context) = (DRIVE_GetType(CX_reg(context)) == TYPE_CDROM);
456 BX_reg(context) = 0xADAD;
457 break;
459 case 0x0C: /* get version */
460 BX_reg(context) = 0x020a;
461 TRACE(int, "Version number => %04x\n", BX_reg(context));
462 break;
464 case 0x0D: /* get drive letters */
465 p = CTX_SEG_OFF_TO_LIN(context, ES_reg(context), EBX_reg(context));
466 memset(p, 0, MAX_DOS_DRIVES);
467 for (drive = 0; drive < MAX_DOS_DRIVES; drive++) {
468 if (DRIVE_GetType(drive) == TYPE_CDROM) *p++ = drive;
470 TRACE(int, "Get drive letters\n");
471 break;
473 case 0x10: /* direct driver acces */
475 static WINE_CDAUDIO wcda;
476 BYTE* driver_request;
477 BYTE* io_stru;
478 BYTE Error = 255; /* No Error */
479 int dorealmode = ISV86(context);
481 driver_request = (dorealmode) ?
482 DOSMEM_MapRealToLinear(MAKELONG(BX_reg(context), ES_reg(context))) :
483 PTR_SEG_OFF_TO_LIN(ES_reg(context), BX_reg(context));
485 if (!driver_request) {
486 /* FIXME - to be deleted ?? */
487 ERR(int, "ES:BX==0 ! SEGFAULT ?\n");
488 ERR(int, "-->BX=0x%04x, ES=0x%04lx, DS=0x%04lx, CX=0x%04x\n",
489 BX_reg(context), ES_reg(context), DS_reg(context), CX_reg(context));
490 driver_request[4] |= 0x80;
491 driver_request[3] = 5; /* bad request length */
492 return;
494 /* FIXME - would be better to open the device at the begining of the wine session...
495 * - the device is also never closed...
496 * - the current implementation only supports a single CD ROM
498 if (wcda.unixdev <= 0)
499 CDAUDIO_Open(&wcda);
500 TRACE(int, "CDROM device driver -> command <%d>\n", (unsigned char)driver_request[2]);
502 for (drive = 0;
503 drive < MAX_DOS_DRIVES && DRIVE_GetType(drive) != TYPE_CDROM;
504 drive++);
505 /* drive contains the first CD ROM */
506 if (CX_reg(context) != drive) {
507 WARN(int, "Request made doesn't match a CD ROM drive (%d/%d)\n", CX_reg(context), drive);
508 driver_request[4] |= 0x80;
509 driver_request[3] = 1; /* unknown unit */
510 return;
513 MSCDEX_Dump("Beg", driver_request, dorealmode);
515 /* set status to 0 */
516 PTR_AT(driver_request, 3, WORD) = 0;
517 CDAUDIO_GetCDStatus(&wcda);
519 switch (driver_request[2]) {
520 case 3:
521 io_stru = (dorealmode) ?
522 DOSMEM_MapRealToLinear(MAKELONG(PTR_AT(driver_request, 14, WORD), PTR_AT(driver_request, 16, WORD))) :
523 PTR_SEG_OFF_TO_LIN(PTR_AT(driver_request, 16, WORD), PTR_AT(driver_request, 14, WORD));
525 TRACE(int, " --> IOCTL INPUT <%d>\n", io_stru[0]);
526 switch (io_stru[0]) {
527 #if 0
528 case 0: /* Get device Header */
530 static LPSTR ptr = 0;
531 if (ptr == 0) {
532 ptr = SEGPTR_ALLOC(22);
533 PTR_AT(ptr, 0, DWORD) = ~1; /* Next Device Driver */
534 PTR_AT(ptr, 4, WORD) = 0xC800; /* Device attributes */
535 PTR_AT(ptr, 6, WORD) = 0x1234; /* Pointer to device strategy routine: FIXME */
536 PTR_AT(ptr, 8, WORD) = 0x3142; /* Pointer to device interrupt routine: FIXME */
537 PTR_AT(ptr, 10, char) = 'W'; /* 8-byte character device name field */
538 PTR_AT(ptr, 11, char) = 'I';
539 PTR_AT(ptr, 12, char) = 'N';
540 PTR_AT(ptr, 13, char) = 'E';
541 PTR_AT(ptr, 14, char) = '_';
542 PTR_AT(ptr, 15, char) = 'C';
543 PTR_AT(ptr, 16, char) = 'D';
544 PTR_AT(ptr, 17, char) = '_';
545 PTR_AT(ptr, 18, WORD) = 0; /* Reserved (must be zero) */
546 PTR_AT(ptr, 20, BYTE) = 0; /* Drive letter (must be zero) */
547 PTR_AT(ptr, 21, BYTE) = 1; /* Number of units supported (one or more) FIXME*/
549 PTR_AT(io_stru, DWORD, 0) = SEGPTR_GET(ptr);
551 break;
552 #endif
554 case 1: /* location of head */
555 switch (io_stru[1]) {
556 case 0:
557 PTR_AT(io_stru, 2, DWORD) = wcda.dwCurFrame;
558 break;
559 case 1:
560 MSCDEX_StoreMSF(wcda.dwCurFrame, io_stru + 2);
561 break;
562 default:
563 ERR(int, "CDRom-Driver: Unsupported addressing mode !!\n");
564 Error = 0x0c;
566 TRACE(int, " ----> HEAD LOCATION <%ld>\n", PTR_AT(io_stru, 2, DWORD));
567 break;
569 case 4: /* Audio channel info */
570 io_stru[1] = 0;
571 io_stru[2] = 0xff;
572 io_stru[3] = 1;
573 io_stru[4] = 0xff;
574 io_stru[5] = 2;
575 io_stru[6] = 0;
576 io_stru[7] = 3;
577 io_stru[8] = 0;
578 TRACE(int, " ----> AUDIO CHANNEL INFO\n");
579 break;
581 case 6: /* device status */
582 PTR_AT(io_stru, 1, DWORD) = 0x00000290;
583 /* 290 =>
584 * 1 Supports HSG and Red Book addressing modes
585 * 0 Supports audio channel manipulation
587 * 1 Supports prefetching requests
588 * 0 Reserved
589 * 0 No interleaving
590 * 1 Data read and plays audio/video tracks
592 * 0 Read only
593 * 0 Supports only cooked reading
594 * 0 Door locked
595 * 0 see below (Door closed/opened)
597 if (wcda.cdaMode == WINE_CDA_OPEN)
598 io_stru[1] |= 1;
599 TRACE(int, " ----> DEVICE STATUS <0x%08lx>\n", PTR_AT(io_stru, 1, DWORD));
600 break;
602 case 8: /* Volume size */
603 PTR_AT(io_stru, 1, DWORD) = wcda.dwTotalLen;
604 TRACE(int, " ----> VOLUME SIZE <%ld>\n", PTR_AT(io_stru, 1, DWORD));
605 break;
607 case 9: /* media changed ? */
608 /* answers don't know... -1/1 for yes/no would be better */
609 io_stru[1] = 0; /* FIXME? 1? */
610 TRACE(int, " ----> MEDIA CHANGED <%d>\n", io_stru[1]);
611 break;
613 case 10: /* audio disk info */
614 io_stru[1] = wcda.nFirstTrack; /* starting track of the disc */
615 io_stru[2] = wcda.nLastTrack; /* ending track */
616 MSCDEX_StoreMSF(wcda.dwTotalLen, io_stru + 3);
618 TRACE(int, " ----> AUDIO DISK INFO <%d-%d/%08lx>\n",
619 io_stru[1], io_stru[2], PTR_AT(io_stru, 3, DWORD));
620 break;
622 case 11: /* audio track info */
623 if (io_stru[1] >= wcda.nFirstTrack && io_stru[1] <= wcda.nLastTrack) {
624 int nt = io_stru[1] - wcda.nFirstTrack;
625 MSCDEX_StoreMSF(wcda.lpdwTrackPos[nt], io_stru + 2);
626 /* starting point if the track */
627 io_stru[6] = (wcda.lpbTrackFlags[nt] & 0xF0) >> 4;
628 } else {
629 PTR_AT(io_stru, 2, DWORD) = 0;
630 io_stru[6] = 0;
632 TRACE(int, " ----> AUDIO TRACK INFO[%d] = [%08lx:%d]\n",
633 io_stru[1], PTR_AT(io_stru, 2, DWORD), io_stru[6]);
634 break;
636 case 12: /* get Q-Channel info */
637 io_stru[1] = wcda.lpbTrackFlags[wcda.nCurTrack - 1];
638 io_stru[2] = wcda.nCurTrack;
639 io_stru[3] = 0; /* FIXME ?? */
641 /* why the heck did MS use another format for 0MSF information... sigh */
643 BYTE bTmp[4];
645 MSCDEX_StoreMSF(wcda.dwCurFrame - wcda.lpdwTrackPos[wcda.nCurTrack - 1], bTmp);
646 io_stru[ 4] = bTmp[2];
647 io_stru[ 5] = bTmp[1];
648 io_stru[ 6] = bTmp[0];
649 io_stru[ 7] = 0;
651 MSCDEX_StoreMSF(wcda.dwCurFrame, bTmp);
652 io_stru[ 8] = bTmp[2];
653 io_stru[ 9] = bTmp[1];
654 io_stru[10] = bTmp[0];
655 io_stru[11] = 0;
657 TRACE(int, "Q-Channel info: Ctrl/adr=%02x TNO=%02x X=%02x rtt=%02x:%02x:%02x rtd=%02x:%02x:%02x (cf=%08lx, tp=%08lx)\n",
658 io_stru[ 1], io_stru[ 2], io_stru[ 3],
659 io_stru[ 4], io_stru[ 5], io_stru[ 6],
660 io_stru[ 8], io_stru[ 9], io_stru[10],
661 wcda.dwCurFrame, wcda.lpdwTrackPos[wcda.nCurTrack - 1]);
662 break;
664 case 15: /* Audio status info */
665 /* !!!! FIXME FIXME FIXME !! */
666 PTR_AT(io_stru, 1, WORD) = 2 | ((wcda.cdaMode == WINE_CDA_PAUSE) ? 1 : 0);
667 PTR_AT(io_stru, 3, DWORD) = wcda.lpdwTrackPos[0];
668 PTR_AT(io_stru, 7, DWORD) = wcda.lpdwTrackPos[wcda.nTracks - 1];
669 TRACE(int, "Audio status info: status=%04x startLoc=%ld endLoc=%ld\n",
670 PTR_AT(io_stru, 1, WORD), PTR_AT(io_stru, 3, DWORD), PTR_AT(io_stru, 7, DWORD));
671 break;
673 default:
674 FIXME(int, "IOCTL INPUT: Unimplemented <%d>!!\n", io_stru[0]);
675 Error = 0x0c;
676 break;
678 break;
680 case 12:
681 io_stru = (dorealmode) ?
682 DOSMEM_MapRealToLinear(MAKELONG(PTR_AT(driver_request, 14, WORD), PTR_AT(driver_request, 16, WORD))) :
683 PTR_SEG_OFF_TO_LIN(PTR_AT(driver_request, 16, WORD), PTR_AT(driver_request, 14, WORD));
685 TRACE(int, " --> IOCTL OUTPUT <%d>\n", io_stru[0]);
686 switch (io_stru[0]) {
687 case 0: /* eject */
688 CDAUDIO_SetDoor(&wcda, 1);
689 TRACE(int, " ----> EJECT\n");
690 break;
691 case 2: /* reset drive */
692 CDAUDIO_Reset(&wcda);
693 TRACE(int, " ----> RESET\n");
694 break;
695 case 3: /* Audio Channel Control */
696 FIXME(int, " ----> AUDIO CHANNEL CONTROL (NIY)\n");
697 break;
698 case 5: /* close tray */
699 CDAUDIO_SetDoor(&wcda, 0);
700 TRACE(int, " ----> CLOSE TRAY\n");
701 break;
702 default:
703 FIXME(int, " IOCTL OUPUT: Unimplemented <%d>!!\n", io_stru[0]);
704 Error = 0x0c;
705 break;
707 break;
709 case 131: /* seek */
711 DWORD at;
713 at = PTR_AT(driver_request, 20, DWORD);
715 TRACE(int, " --> SEEK AUDIO mode :<0x%02X>, [%ld]\n",
716 (BYTE)driver_request[13], at);
718 switch (driver_request[13]) {
719 case 1: /* Red book addressing mode = 0:m:s:f */
720 /* FIXME : frame <=> msf conversion routines could be shared
721 * between mscdex and mcicda
723 at = LOBYTE(HIWORD(at)) * CDFRAMES_PERMIN +
724 HIBYTE(LOWORD(at)) * CDFRAMES_PERSEC +
725 LOBYTE(LOWORD(at));
726 /* fall thru */
727 case 0: /* HSG addressing mode */
728 CDAUDIO_Seek(&wcda, at);
729 break;
730 default:
731 ERR(int, "Unsupported address mode !!\n");
732 Error = 0x0c;
733 break;
736 break;
738 case 132: /* play */
740 DWORD beg, end;
742 beg = end = PTR_AT(driver_request, 14, DWORD);
743 end += PTR_AT(driver_request, 18, DWORD);
745 TRACE(int, " --> PLAY AUDIO mode :<0x%02X>, [%ld-%ld]\n",
746 (BYTE)driver_request[13], beg, end);
748 switch (driver_request[13]) {
749 case 1: /* Red book addressing mode = 0:m:s:f */
750 /* FIXME : frame <=> msf conversion routines could be shared
751 * between mscdex and mcicda
753 beg = LOBYTE(HIWORD(beg)) * CDFRAMES_PERMIN +
754 HIBYTE(LOWORD(beg)) * CDFRAMES_PERSEC +
755 LOBYTE(LOWORD(beg));
756 end = LOBYTE(HIWORD(end)) * CDFRAMES_PERMIN +
757 HIBYTE(LOWORD(end)) * CDFRAMES_PERSEC +
758 LOBYTE(LOWORD(end));
759 /* fall thru */
760 case 0: /* HSG addressing mode */
761 CDAUDIO_Play(&wcda, beg, end);
762 break;
763 default:
764 ERR(int, "Unsupported address mode !!\n");
765 Error = 0x0c;
766 break;
769 break;
771 case 133:
772 if (wcda.cdaMode == WINE_CDA_PLAY) {
773 CDAUDIO_Pause(&wcda, 1);
774 TRACE(int, " --> STOP AUDIO (Paused)\n");
775 } else {
776 CDAUDIO_Stop(&wcda);
777 TRACE(int, " --> STOP AUDIO (Stopped)\n");
779 break;
781 case 136:
782 TRACE(int, " --> RESUME AUDIO\n");
783 CDAUDIO_Pause(&wcda, 0);
784 break;
786 default:
787 FIXME(int, " ioctl uninplemented <%d>\n", driver_request[2]);
788 Error = 0x0c;
791 /* setting error codes if any */
792 if (Error < 255) {
793 driver_request[4] |= 0x80;
794 driver_request[3] = Error;
797 /* setting status bits
798 * 3 == playing && done
799 * 1 == done
801 driver_request[4] |= (wcda.cdaMode == WINE_CDA_PLAY) ? 3 : 1;
803 MSCDEX_Dump("End", driver_request, dorealmode);
805 break;
806 default:
807 FIXME(int, "Unimplemented MSCDEX function 0x%02X.\n", AL_reg(context));
808 break;