Fixed a slight bug that was included in the change from WND ptr to
[wine/hacks.git] / msdos / int2f.c
blobf370ed560177a755b2d294047e9ec218b32a6dbb
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 0xd7: /* Banyan Vines */
229 switch (AL_reg(context))
231 case 0x01: /* Install check - Get Int Number */
232 /* not installed */
233 break;
234 default:
235 INT_BARF( context, 0x2f );
236 break;
238 break;
239 case 0xfa: /* Watcom debugger check, returns 0x666 if installed */
240 break;
241 default:
242 INT_BARF( context, 0x2f );
243 break;
248 /**********************************************************************
249 * do_int2f_16
251 static void do_int2f_16( CONTEXT *context )
253 DWORD addr;
255 switch(AL_reg(context))
257 case 0x00: /* Windows enhanced mode installation check */
258 AX_reg(context) = (GetWinFlags16() & WF_ENHANCED) ?
259 LOWORD(GetVersion16()) : 0;
260 break;
262 case 0x0a: /* Get Windows version and type */
263 AX_reg(context) = 0;
264 BX_reg(context) = (LOWORD(GetVersion16()) << 8) |
265 (LOWORD(GetVersion16()) >> 8);
266 CX_reg(context) = (GetWinFlags16() & WF_ENHANCED) ? 3 : 2;
267 break;
269 case 0x0b: /* Identify Windows-aware TSRs */
270 /* we don't have any pre-Windows TSRs */
271 break;
273 case 0x11: /* Get Shell Parameters - (SHELL= in CONFIG.SYS) */
274 /* We can mock this up. But not today... */
275 FIXME(int, "Get Shell Parameters\n");
276 break;
278 case 0x80: /* Release time-slice */
279 AL_reg(context) = 0;
280 break;
282 case 0x81: /* Begin critical section. */
283 /* FIXME? */
284 break;
286 case 0x82: /* End critical section. */
287 /* FIXME? */
288 break;
290 case 0x83: /* Return Current Virtual Machine ID */
291 /* Virtual Machines are usually created/destroyed when Windows runs
292 * DOS programs. Since we never do, we are always in the System VM.
293 * According to Ralf Brown's Interrupt List, never return 0. But it
294 * seems to work okay (returning 0), just to be sure we return 1.
296 BX_reg(context) = 1; /* VM 1 is probably the System VM */
297 break;
299 case 0x84: /* Get device API entry point */
300 addr = (DWORD)NE_GetEntryPoint( GetModuleHandle16("WPROCS"),
301 VXD_BASE + BX_reg(context) );
302 if (!addr) /* not supported */
304 ERR(int, "Accessing unknown VxD %04x - Expect a failure now.\n",
305 BX_reg(context) );
307 ES_reg(context) = SELECTOROF(addr);
308 DI_reg(context) = OFFSETOF(addr);
309 break;
311 case 0x86: /* DPMI detect mode */
312 AX_reg(context) = 0; /* Running under DPMI */
313 break;
315 case 0x87: /* DPMI installation check */
316 #if 1 /* DPMI still breaks pkunzip */
317 if (ISV86(context)) break; /* so bail out for now if in v86 mode */
318 #endif
320 TDB *pTask = (TDB *)GlobalLock16( GetCurrentTask() );
321 NE_MODULE *pModule = pTask ? NE_GetPtr( pTask->hModule ) : NULL;
322 SYSTEM_INFO si;
324 GlobalUnlock16( GetCurrentTask() );
325 GetSystemInfo(&si);
326 AX_reg(context) = 0x0000; /* DPMI Installed */
327 BX_reg(context) = 0x0001; /* 32bits available */
328 CL_reg(context) = si.wProcessorLevel;
329 DX_reg(context) = 0x005a; /* DPMI major/minor 0.90 */
330 SI_reg(context) = 0; /* # of para. of DOS extended private data */
331 #ifdef MZ_SUPPORTED /* ES:DI is DPMI switch entry point */
332 if (pModule && pModule->lpDosTask)
333 ES_reg(context) = pModule->lpDosTask->dpmi_seg;
334 else
335 #endif
336 ES_reg(context) = 0;
337 DI_reg(context) = 0;
338 break;
340 case 0x8a: /* DPMI get vendor-specific API entry point. */
341 /* The 1.0 specs say this should work with all 0.9 hosts. */
342 break;
344 default:
345 INT_BARF( context, 0x2f );
349 /* FIXME: this macro may have to be changed on architectures where <size> reads/writes
350 * must be <size> aligned
351 * <size> could be WORD, DWORD...
352 * in this case, we would need two macros, one for read, the other one for write
353 * Note: PTR_AT can be used as an l-value
355 #define PTR_AT(_ptr, _ofs, _typ) (*((_typ*)(((char*)_ptr)+(_ofs))))
357 /* Use #if 1 if you want full int 2f debug... normal users can leave it at 0 */
358 #if 0
359 /**********************************************************************
360 * MSCDEX_Dump [internal]
362 * Dumps mscdex requests to int debug channel.
364 static void MSCDEX_Dump(char* pfx, BYTE* req, int dorealmode)
366 int i;
367 BYTE buf[2048];
368 BYTE* ptr;
369 BYTE* ios;
371 ptr = buf;
372 ptr += sprintf(ptr, "%s\tCommand => ", pfx);
373 for (i = 0; i < req[0]; i++) {
374 ptr += sprintf(ptr, "%02x ", req[i]);
377 switch (req[2]) {
378 case 3:
379 case 12:
380 ptr += sprintf(ptr, "\n\t\t\t\tIO_struct => ");
381 ios = (dorealmode) ?
382 DOSMEM_MapRealToLinear(MAKELONG(PTR_AT(req, 14, WORD), PTR_AT(req, 16, WORD))) :
383 PTR_SEG_OFF_TO_LIN(PTR_AT(req, 16, WORD), PTR_AT(req, 14, WORD));
385 for (i = 0; i < PTR_AT(req, 18, WORD); i++) {
386 ptr += sprintf(ptr, "%02x ", ios[i]);
387 if ((i & 0x1F) == 0x1F) {
388 *ptr++ = '\n';
389 *ptr = 0;
392 break;
394 TRACE(int, "%s\n", buf);
396 #else
397 #define MSCDEX_Dump(pfx, req, drm)
398 #endif
400 static void MSCDEX_StoreMSF(DWORD frame, BYTE* val)
402 val[3] = 0; /* zero */
403 val[2] = frame / CDFRAMES_PERMIN; /* minutes */
404 val[1] = (frame - CDFRAMES_PERMIN * val[2]) / CDFRAMES_PERSEC; /* seconds */
405 val[0] = frame - CDFRAMES_PERMIN * val[2] - CDFRAMES_PERSEC * val[1]; /* frames */
408 static void MSCDEX_Handler(CONTEXT* context)
410 int drive, count;
411 char* p;
413 switch(AL_reg(context)) {
414 case 0x00: /* Installation check */
415 /* Count the number of contiguous CDROM drives
417 for (drive = count = 0; drive < MAX_DOS_DRIVES; drive++) {
418 if (DRIVE_GetType(drive) == TYPE_CDROM) {
419 while (DRIVE_GetType(drive + count) == TYPE_CDROM) count++;
420 break;
423 TRACE(int, "Installation check: %d cdroms, starting at %d\n", count, drive);
424 BX_reg(context) = count;
425 CX_reg(context) = (drive < MAX_DOS_DRIVES) ? drive : 0;
426 break;
428 case 0x0B: /* drive check */
429 AX_reg(context) = (DRIVE_GetType(CX_reg(context)) == TYPE_CDROM);
430 BX_reg(context) = 0xADAD;
431 break;
433 case 0x0C: /* get version */
434 BX_reg(context) = 0x020a;
435 TRACE(int, "Version number => %04x\n", BX_reg(context));
436 break;
438 case 0x0D: /* get drive letters */
439 p = CTX_SEG_OFF_TO_LIN(context, ES_reg(context), EBX_reg(context));
440 memset(p, 0, MAX_DOS_DRIVES);
441 for (drive = 0; drive < MAX_DOS_DRIVES; drive++) {
442 if (DRIVE_GetType(drive) == TYPE_CDROM) *p++ = drive;
444 TRACE(int, "Get drive letters\n");
445 break;
447 case 0x10: /* direct driver acces */
449 static WINE_CDAUDIO wcda;
450 BYTE* driver_request;
451 BYTE* io_stru;
452 BYTE Error = 255; /* No Error */
453 int dorealmode = ISV86(context);
455 driver_request = (dorealmode) ?
456 DOSMEM_MapRealToLinear(MAKELONG(BX_reg(context), ES_reg(context))) :
457 PTR_SEG_OFF_TO_LIN(ES_reg(context), BX_reg(context));
459 if (!driver_request) {
460 /* FIXME - to be deleted ?? */
461 ERR(int, "ES:BX==0 ! SEGFAULT ?\n");
462 ERR(int, "-->BX=0x%04x, ES=0x%04lx, DS=0x%04lx, CX=0x%04x\n",
463 BX_reg(context), ES_reg(context), DS_reg(context), CX_reg(context));
464 driver_request[4] |= 0x80;
465 driver_request[3] = 5; /* bad request length */
466 return;
468 /* FIXME - would be better to open the device at the begining of the wine session...
469 * - the device is also never closed...
470 * - the current implementation only supports a single CD ROM
472 if (wcda.unixdev <= 0)
473 CDAUDIO_Open(&wcda);
474 TRACE(int, "CDROM device driver -> command <%d>\n", (unsigned char)driver_request[2]);
476 for (drive = 0;
477 drive < MAX_DOS_DRIVES && DRIVE_GetType(drive) != TYPE_CDROM;
478 drive++);
479 /* drive contains the first CD ROM */
480 if (CX_reg(context) != drive) {
481 WARN(int, "Request made doesn't match a CD ROM drive (%d/%d)\n", CX_reg(context), drive);
482 driver_request[4] |= 0x80;
483 driver_request[3] = 1; /* unknown unit */
484 return;
487 MSCDEX_Dump("Beg", driver_request, dorealmode);
489 /* set status to 0 */
490 PTR_AT(driver_request, 3, WORD) = 0;
491 CDAUDIO_GetCDStatus(&wcda);
493 switch (driver_request[2]) {
494 case 3:
495 io_stru = (dorealmode) ?
496 DOSMEM_MapRealToLinear(MAKELONG(PTR_AT(driver_request, 14, WORD), PTR_AT(driver_request, 16, WORD))) :
497 PTR_SEG_OFF_TO_LIN(PTR_AT(driver_request, 16, WORD), PTR_AT(driver_request, 14, WORD));
499 TRACE(int, " --> IOCTL INPUT <%d>\n", io_stru[0]);
500 switch (io_stru[0]) {
501 #if 0
502 case 0: /* Get device Header */
504 static LPSTR ptr = 0;
505 if (ptr == 0) {
506 ptr = SEGPTR_ALLOC(22);
507 PTR_AT(ptr, 0, DWORD) = ~1; /* Next Device Driver */
508 PTR_AT(ptr, 4, WORD) = 0xC800; /* Device attributes */
509 PTR_AT(ptr, 6, WORD) = 0x1234; /* Pointer to device strategy routine: FIXME */
510 PTR_AT(ptr, 8, WORD) = 0x3142; /* Pointer to device interrupt routine: FIXME */
511 PTR_AT(ptr, 10, char) = 'W'; /* 8-byte character device name field */
512 PTR_AT(ptr, 11, char) = 'I';
513 PTR_AT(ptr, 12, char) = 'N';
514 PTR_AT(ptr, 13, char) = 'E';
515 PTR_AT(ptr, 14, char) = '_';
516 PTR_AT(ptr, 15, char) = 'C';
517 PTR_AT(ptr, 16, char) = 'D';
518 PTR_AT(ptr, 17, char) = '_';
519 PTR_AT(ptr, 18, WORD) = 0; /* Reserved (must be zero) */
520 PTR_AT(ptr, 20, BYTE) = 0; /* Drive letter (must be zero) */
521 PTR_AT(ptr, 21, BYTE) = 1; /* Number of units supported (one or more) FIXME*/
523 PTR_AT(io_stru, DWORD, 0) = SEGPTR_GET(ptr);
525 break;
526 #endif
528 case 1: /* location of head */
529 switch (io_stru[1]) {
530 case 0:
531 PTR_AT(io_stru, 2, DWORD) = wcda.dwCurFrame;
532 break;
533 case 1:
534 MSCDEX_StoreMSF(wcda.dwCurFrame, io_stru + 2);
535 break;
536 default:
537 ERR(int, "CDRom-Driver: Unsupported addressing mode !!\n");
538 Error = 0x0c;
540 TRACE(int, " ----> HEAD LOCATION <%ld>\n", PTR_AT(io_stru, 2, DWORD));
541 break;
543 case 4: /* Audio channel info */
544 io_stru[1] = 0;
545 io_stru[2] = 0xff;
546 io_stru[3] = 1;
547 io_stru[4] = 0xff;
548 io_stru[5] = 2;
549 io_stru[6] = 0;
550 io_stru[7] = 3;
551 io_stru[8] = 0;
552 TRACE(int, " ----> AUDIO CHANNEL INFO\n");
553 break;
555 case 6: /* device status */
556 PTR_AT(io_stru, 1, DWORD) = 0x00000290;
557 /* 290 =>
558 * 1 Supports HSG and Red Book addressing modes
559 * 0 Supports audio channel manipulation
561 * 1 Supports prefetching requests
562 * 0 Reserved
563 * 0 No interleaving
564 * 1 Data read and plays audio/video tracks
566 * 0 Read only
567 * 0 Supports only cooked reading
568 * 0 Door locked
569 * 0 see below (Door closed/opened)
571 if (wcda.cdaMode == WINE_CDA_OPEN)
572 io_stru[1] |= 1;
573 TRACE(int, " ----> DEVICE STATUS <0x%08lx>\n", PTR_AT(io_stru, 1, DWORD));
574 break;
576 case 8: /* Volume size */
577 PTR_AT(io_stru, 1, DWORD) = wcda.dwTotalLen;
578 TRACE(int, " ----> VOLUME SIZE <%ld>\n", PTR_AT(io_stru, 1, DWORD));
579 break;
581 case 9: /* media changed ? */
582 /* answers don't know... -1/1 for yes/no would be better */
583 io_stru[1] = 0; /* FIXME? 1? */
584 TRACE(int, " ----> MEDIA CHANGED <%d>\n", io_stru[1]);
585 break;
587 case 10: /* audio disk info */
588 io_stru[1] = wcda.nFirstTrack; /* starting track of the disc */
589 io_stru[2] = wcda.nLastTrack; /* ending track */
590 MSCDEX_StoreMSF(wcda.dwTotalLen, io_stru + 3);
592 TRACE(int, " ----> AUDIO DISK INFO <%d-%d/%08lx>\n",
593 io_stru[1], io_stru[2], PTR_AT(io_stru, 3, DWORD));
594 break;
596 case 11: /* audio track info */
597 if (io_stru[1] >= wcda.nFirstTrack && io_stru[1] <= wcda.nLastTrack) {
598 int nt = io_stru[1] - wcda.nFirstTrack;
599 MSCDEX_StoreMSF(wcda.lpdwTrackPos[nt], io_stru + 2);
600 /* starting point if the track */
601 io_stru[6] = (wcda.lpbTrackFlags[nt] & 0xF0) >> 4;
602 } else {
603 PTR_AT(io_stru, 2, DWORD) = 0;
604 io_stru[6] = 0;
606 TRACE(int, " ----> AUDIO TRACK INFO[%d] = [%08lx:%d]\n",
607 io_stru[1], PTR_AT(io_stru, 2, DWORD), io_stru[6]);
608 break;
610 case 12: /* get Q-Channel info */
611 io_stru[1] = wcda.lpbTrackFlags[wcda.nCurTrack - 1];
612 io_stru[2] = wcda.nCurTrack;
613 io_stru[3] = 0; /* FIXME ?? */
615 /* why the heck did MS use another format for 0MSF information... sigh */
617 BYTE bTmp[4];
619 MSCDEX_StoreMSF(wcda.dwCurFrame - wcda.lpdwTrackPos[wcda.nCurTrack - 1], bTmp);
620 io_stru[ 4] = bTmp[2];
621 io_stru[ 5] = bTmp[1];
622 io_stru[ 6] = bTmp[0];
623 io_stru[ 7] = 0;
625 MSCDEX_StoreMSF(wcda.dwCurFrame, bTmp);
626 io_stru[ 8] = bTmp[2];
627 io_stru[ 9] = bTmp[1];
628 io_stru[10] = bTmp[0];
629 io_stru[11] = 0;
631 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",
632 io_stru[ 1], io_stru[ 2], io_stru[ 3],
633 io_stru[ 4], io_stru[ 5], io_stru[ 6],
634 io_stru[ 8], io_stru[ 9], io_stru[10],
635 wcda.dwCurFrame, wcda.lpdwTrackPos[wcda.nCurTrack - 1]);
636 break;
638 case 15: /* Audio status info */
639 /* !!!! FIXME FIXME FIXME !! */
640 PTR_AT(io_stru, 1, WORD) = 2 | ((wcda.cdaMode == WINE_CDA_PAUSE) ? 1 : 0);
641 PTR_AT(io_stru, 3, DWORD) = wcda.lpdwTrackPos[0];
642 PTR_AT(io_stru, 7, DWORD) = wcda.lpdwTrackPos[wcda.nTracks - 1];
643 TRACE(int, "Audio status info: status=%04x startLoc=%ld endLoc=%ld\n",
644 PTR_AT(io_stru, 1, WORD), PTR_AT(io_stru, 3, DWORD), PTR_AT(io_stru, 7, DWORD));
645 break;
647 default:
648 FIXME(int, "IOCTL INPUT: Unimplemented <%d>!!\n", io_stru[0]);
649 Error = 0x0c;
650 break;
652 break;
654 case 12:
655 io_stru = (dorealmode) ?
656 DOSMEM_MapRealToLinear(MAKELONG(PTR_AT(driver_request, 14, WORD), PTR_AT(driver_request, 16, WORD))) :
657 PTR_SEG_OFF_TO_LIN(PTR_AT(driver_request, 16, WORD), PTR_AT(driver_request, 14, WORD));
659 TRACE(int, " --> IOCTL OUTPUT <%d>\n", io_stru[0]);
660 switch (io_stru[0]) {
661 case 0: /* eject */
662 CDAUDIO_SetDoor(&wcda, 1);
663 TRACE(int, " ----> EJECT\n");
664 break;
665 case 2: /* reset drive */
666 CDAUDIO_Reset(&wcda);
667 TRACE(int, " ----> RESET\n");
668 break;
669 case 3: /* Audio Channel Control */
670 FIXME(int, " ----> AUDIO CHANNEL CONTROL (NIY)\n");
671 break;
672 case 5: /* close tray */
673 CDAUDIO_SetDoor(&wcda, 0);
674 TRACE(int, " ----> CLOSE TRAY\n");
675 break;
676 default:
677 FIXME(int, " IOCTL OUPUT: Unimplemented <%d>!!\n", io_stru[0]);
678 Error = 0x0c;
679 break;
681 break;
683 case 131: /* seek */
685 DWORD at;
687 at = PTR_AT(driver_request, 20, DWORD);
689 TRACE(int, " --> SEEK AUDIO mode :<0x%02X>, [%ld]\n",
690 (BYTE)driver_request[13], at);
692 switch (driver_request[13]) {
693 case 1: /* Red book addressing mode = 0:m:s:f */
694 /* FIXME : frame <=> msf conversion routines could be shared
695 * between mscdex and mcicda
697 at = LOBYTE(HIWORD(at)) * CDFRAMES_PERMIN +
698 HIBYTE(LOWORD(at)) * CDFRAMES_PERSEC +
699 LOBYTE(LOWORD(at));
700 /* fall thru */
701 case 0: /* HSG addressing mode */
702 CDAUDIO_Seek(&wcda, at);
703 break;
704 default:
705 ERR(int, "Unsupported address mode !!\n");
706 Error = 0x0c;
707 break;
710 break;
712 case 132: /* play */
714 DWORD beg, end;
716 beg = end = PTR_AT(driver_request, 14, DWORD);
717 end += PTR_AT(driver_request, 18, DWORD);
719 TRACE(int, " --> PLAY AUDIO mode :<0x%02X>, [%ld-%ld]\n",
720 (BYTE)driver_request[13], beg, end);
722 switch (driver_request[13]) {
723 case 1: /* Red book addressing mode = 0:m:s:f */
724 /* FIXME : frame <=> msf conversion routines could be shared
725 * between mscdex and mcicda
727 beg = LOBYTE(HIWORD(beg)) * CDFRAMES_PERMIN +
728 HIBYTE(LOWORD(beg)) * CDFRAMES_PERSEC +
729 LOBYTE(LOWORD(beg));
730 end = LOBYTE(HIWORD(end)) * CDFRAMES_PERMIN +
731 HIBYTE(LOWORD(end)) * CDFRAMES_PERSEC +
732 LOBYTE(LOWORD(end));
733 /* fall thru */
734 case 0: /* HSG addressing mode */
735 CDAUDIO_Play(&wcda, beg, end);
736 break;
737 default:
738 ERR(int, "Unsupported address mode !!\n");
739 Error = 0x0c;
740 break;
743 break;
745 case 133:
746 if (wcda.cdaMode == WINE_CDA_PLAY) {
747 CDAUDIO_Pause(&wcda, 1);
748 TRACE(int, " --> STOP AUDIO (Paused)\n");
749 } else {
750 CDAUDIO_Stop(&wcda);
751 TRACE(int, " --> STOP AUDIO (Stopped)\n");
753 break;
755 case 136:
756 TRACE(int, " --> RESUME AUDIO\n");
757 CDAUDIO_Pause(&wcda, 0);
758 break;
760 default:
761 FIXME(int, " ioctl uninplemented <%d>\n", driver_request[2]);
762 Error = 0x0c;
765 /* setting error codes if any */
766 if (Error < 255) {
767 driver_request[4] |= 0x80;
768 driver_request[3] = Error;
771 /* setting status bits
772 * 3 == playing && done
773 * 1 == done
775 driver_request[4] |= (wcda.cdaMode == WINE_CDA_PLAY) ? 3 : 1;
777 MSCDEX_Dump("End", driver_request, dorealmode);
779 break;
780 default:
781 FIXME(int, "Unimplemented MSCDEX function 0x%02X.\n", AL_reg(context));
782 break;