1 /* -*- tab-width: 8; c-basic-offset: 4 -*- */
3 * DOS interrupt 2fh handler
5 * Cdrom - device driver emulation - Audio features.
6 * (c) 1998 Petr Tomasek <tomasek@etf.cuni.cz>
7 * (c) 1999,2002 Eric Pouech
13 #include "wine/winbase16.h"
16 /* #define DEBUG_INT */
17 #include "debugtools.h"
22 DEFAULT_DEBUG_CHANNEL(int);
24 /* base WPROCS.DLL ordinal number for VxDs */
27 static void do_int2f_16( CONTEXT86
*context
);
28 static void MSCDEX_Handler( CONTEXT86
*context
);
30 /**********************************************************************
31 * INT_Int2fHandler (WPROCS.147)
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
))
42 AL_reg(context
) = 0xff; /* share is installed */
45 case 0x11: /* Network Redirector / IFSFUNC */
46 switch (LOBYTE(context
->Eax
))
48 case 0x00: /* Install check */
51 case 0x80: /* Enhanced services - Install check */
55 INT_BARF( context
, 0x2f );
61 switch (LOBYTE(context
->Eax
))
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 */
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. */
81 context
->SegEs
= 0x0001;
82 DI_reg(context
) = 0x0000;
85 FIXME("No real-mode handler for errors yet! (bye!)\n");
88 INT_BARF(context
, 0x2f);
92 INT_BARF(context
, 0x2f);
96 case 0x15: /* mscdex */
97 MSCDEX_Handler(context
);
101 do_int2f_16( context
);
104 case 0x1a: /* ANSI.SYS / AVATAR.SYS Install Check */
105 /* Not supported yet, do nothing */
110 switch (LOBYTE(context
->Eax
))
112 case 0x00: /* XMS v2+ installation check */
113 WARN("XMS is not fully implemented\n");
114 AL_reg(context
) = 0x80;
116 case 0x10: /* XMS v2+ get driver address */
118 context
->SegEs
= DOSMEM_xms_seg
;
123 INT_BARF( context
, 0x2f );
126 FIXME("check for XMS (not supported)\n");
127 AL_reg(context
) = 0x42; /* != 0x80 */
132 switch (LOBYTE(context
->Eax
))
143 /* Microsoft Profiler - not installed */
146 INT_BARF( context
, 0x2f );
151 switch(LOBYTE(context
->Eax
))
153 case 0x10: /* smartdrv */
154 break; /* not installed */
155 case 0x11: /* dblspace */
156 break; /* not installed */
157 case 0x12: /* realtime compression interface */
158 break; /* not installed */
159 case 0x32: /* patch IO.SYS (???) */
160 break; /* we have no IO.SYS, so we can't patch it :-/ */
162 INT_BARF( context
, 0x2f );
166 switch(LOBYTE(context
->Eax
))
173 FIXME("Task Switcher - not implemented\n");
176 INT_BARF( context
, 0x2f );
179 case 0x56: /* INTERLNK */
180 switch(LOBYTE(context
->Eax
))
182 case 0x01: /* check if redirected drive */
183 AL_reg(context
) = 0; /* not redirected */
186 INT_BARF( context
, 0x2f );
189 case 0x7a: /* NOVELL NetWare */
190 switch (LOBYTE(context
->Eax
))
192 case 0x0: /* Low-level Netware installation check AL=0 not installed.*/
195 case 0x20: /* Get VLM Call Address */
196 /* return nothing -> NetWare not installed */
199 INT_BARF( context
, 0x2f );
203 case 0xb7: /* append */
204 LOBYTE(context
->Eax
) = 0; /* not installed */
206 case 0xb8: /* network */
207 switch (LOBYTE(context
->Eax
))
209 case 0x00: /* Install check */
213 INT_BARF( context
, 0x2f );
217 case 0xbd: /* some Novell network install check ??? */
218 AX_reg(context
) = 0xa5a5; /* pretend to have Novell IPX installed */
220 case 0xbf: /* REDIRIFS.EXE */
221 switch (LOBYTE(context
->Eax
))
223 case 0x00: /* Install check */
227 INT_BARF( context
, 0x2f );
232 switch(LOBYTE(context
->Eax
))
234 case 0x01: /* Quarterdeck RPCI - QEMM/QRAM - PCL-838.EXE functions */
235 if(BX_reg(context
) == 0x5145 && CX_reg(context
) == 0x4D4D
236 && DX_reg(context
) == 0x3432)
237 TRACE("Check for QEMM v5.0+ (not installed)\n");
240 INT_BARF( context
, 0x2f );
244 case 0xd7: /* Banyan Vines */
245 switch (LOBYTE(context
->Eax
))
247 case 0x01: /* Install check - Get Int Number */
251 INT_BARF( context
, 0x2f );
256 switch(LOBYTE(context
->Eax
))
258 case 0x01: /* Quarterdeck QDPMI.SYS - DESQview */
259 if(BX_reg(context
) == 0x4450 && CX_reg(context
) == 0x4d49
260 && DX_reg(context
) == 0x8f4f)
261 TRACE("Check for QDPMI.SYS (not installed)\n");
264 INT_BARF( context
, 0x2f );
268 case 0xfa: /* Watcom debugger check, returns 0x666 if installed */
271 INT_BARF( context
, 0x2f );
277 /**********************************************************************
280 static void do_int2f_16( CONTEXT86
*context
)
284 switch(LOBYTE(context
->Eax
))
286 case 0x00: /* Windows enhanced mode installation check */
287 AX_reg(context
) = (GetWinFlags16() & WF_ENHANCED
) ?
288 LOWORD(GetVersion16()) : 0;
291 case 0x0a: /* Get Windows version and type */
293 BX_reg(context
) = (LOWORD(GetVersion16()) << 8) |
294 (LOWORD(GetVersion16()) >> 8);
295 CX_reg(context
) = (GetWinFlags16() & WF_ENHANCED
) ? 3 : 2;
298 case 0x0b: /* Identify Windows-aware TSRs */
299 /* we don't have any pre-Windows TSRs */
302 case 0x11: /* Get Shell Parameters - (SHELL= in CONFIG.SYS) */
303 /* We can mock this up. But not today... */
304 FIXME("Get Shell Parameters\n");
307 case 0x80: /* Release time-slice */
311 case 0x81: /* Begin critical section. */
315 case 0x82: /* End critical section. */
319 case 0x83: /* Return Current Virtual Machine ID */
320 /* Virtual Machines are usually created/destroyed when Windows runs
321 * DOS programs. Since we never do, we are always in the System VM.
322 * According to Ralf Brown's Interrupt List, never return 0. But it
323 * seems to work okay (returning 0), just to be sure we return 1.
325 BX_reg(context
) = 1; /* VM 1 is probably the System VM */
328 case 0x84: /* Get device API entry point */
330 HMODULE16 mod
= GetModuleHandle16("wprocs");
331 if (mod
< 32) mod
= LoadLibrary16( "wprocs" );
332 addr
= (DWORD
)GetProcAddress16( mod
, (LPCSTR
)(VXD_BASE
+ BX_reg(context
)) );
333 if (!addr
) /* not supported */
334 ERR("Accessing unknown VxD %04x - Expect a failure now.\n", BX_reg(context
) );
335 context
->SegEs
= SELECTOROF(addr
);
336 DI_reg(context
) = OFFSETOF(addr
);
340 case 0x86: /* DPMI detect mode */
341 AX_reg(context
) = 0; /* Running under DPMI */
344 case 0x87: /* DPMI installation check */
345 #if 1 /* DPMI still breaks pkunzip */
346 if (ISV86(context
)) break; /* so bail out for now if in v86 mode */
351 AX_reg(context
) = 0x0000; /* DPMI Installed */
352 BX_reg(context
) = 0x0001; /* 32bits available */
353 CL_reg(context
) = si
.wProcessorLevel
;
354 DX_reg(context
) = 0x005a; /* DPMI major/minor 0.90 */
355 SI_reg(context
) = 0; /* # of para. of DOS extended private data */
356 context
->SegEs
= DOSMEM_dpmi_seg
;
357 DI_reg(context
) = 0; /* ES:DI is DPMI switch entry point */
360 case 0x8a: /* DPMI get vendor-specific API entry point. */
361 /* The 1.0 specs say this should work with all 0.9 hosts. */
365 INT_BARF( context
, 0x2f );
369 /* FIXME: this macro may have to be changed on architectures where <size> reads/writes
370 * must be <size> aligned
371 * <size> could be WORD, DWORD...
372 * in this case, we would need two macros, one for read, the other one for write
373 * Note: PTR_AT can be used as an l-value
375 #define PTR_AT(_ptr, _ofs, _typ) (*((_typ*)(((char*)_ptr)+(_ofs))))
377 /* Use #if 1 if you want full int 2f debug... normal users can leave it at 0 */
379 /**********************************************************************
380 * MSCDEX_Dump [internal]
382 * Dumps mscdex requests to int debug channel.
384 static void MSCDEX_Dump(char* pfx
, BYTE
* req
, int dorealmode
)
392 ptr
+= sprintf(ptr
, "%s\tCommand => ", pfx
);
393 for (i
= 0; i
< req
[0]; i
++) {
394 ptr
+= sprintf(ptr
, "%02x ", req
[i
]);
400 ptr
+= sprintf(ptr
, "\n\t\t\t\tIO_struct => ");
401 ios
= (dorealmode
) ? PTR_REAL_TO_LIN( PTR_AT(req
, 16, WORD
), PTR_AT(req
, 14, WORD
)) :
402 MapSL(MAKESEGPTR(PTR_AT(req
, 16, WORD
), PTR_AT(req
, 14, WORD
)));
404 for (i
= 0; i
< PTR_AT(req
, 18, WORD
); i
++) {
405 ptr
+= sprintf(ptr
, "%02x ", ios
[i
]);
406 if ((i
& 0x1F) == 0x1F) {
416 #define MSCDEX_Dump(pfx, req, drm)
419 #define CDFRAMES_PERSEC 75
420 #define CDFRAMES_PERMIN (CDFRAMES_PERSEC * 60)
421 #define FRAME_OF_ADDR(a) ((a)[1] * CDFRAMES_PERMIN + (a)[2] * CDFRAMES_PERSEC + (a)[3])
422 #define FRAME_OF_TOC(toc, idx) FRAME_OF_ADDR((toc).TrackData[idx - (toc).FirstTrack].Address)
423 #define CTRL_OF_TOC(toc, idx) (((toc).TrackData[idx - (toc).FirstTrack].Control << 4) | \
424 (toc).TrackData[idx - (toc).FirstTrack].Adr)
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_PERSEC
) % 60; /* seconds */
431 val
[0] = frame
% CDFRAMES_PERSEC
; /* frames */
434 static int is_cdrom( int drive
)
436 char root
[] = "A:\\";
438 return (GetDriveTypeA(root
) == DRIVE_CDROM
);
441 static void MSCDEX_Handler(CONTEXT86
* context
)
446 switch (LOBYTE(context
->Eax
)) {
447 case 0x00: /* Installation check */
448 /* Count the number of contiguous CDROM drives
450 for (drive
= count
= 0; drive
< 26; drive
++) {
451 if (is_cdrom(drive
)) {
452 while (is_cdrom(drive
+ count
)) count
++;
456 TRACE("Installation check: %d cdroms, starting at %d\n", count
, drive
);
457 BX_reg(context
) = count
;
458 CX_reg(context
) = (drive
< 26) ? drive
: 0;
461 case 0x0B: /* drive check */
462 AX_reg(context
) = is_cdrom(CX_reg(context
));
463 BX_reg(context
) = 0xADAD;
466 case 0x0C: /* get version */
467 BX_reg(context
) = 0x020a;
468 TRACE("Version number => %04x\n", BX_reg(context
));
471 case 0x0D: /* get drive letters */
472 p
= CTX_SEG_OFF_TO_LIN(context
, context
->SegEs
, context
->Ebx
);
474 for (drive
= 0; drive
< 26; drive
++) {
475 if (is_cdrom(drive
)) *p
++ = drive
;
477 TRACE("Get drive letters\n");
480 case 0x10: /* direct driver access */
482 BYTE
* driver_request
;
484 BYTE Error
= 255; /* No Error */
485 int dorealmode
= ISV86(context
);
486 char devName
[] = "\\\\.\\@:";
489 CDROM_SUB_Q_DATA_FORMAT fmt
;
490 SUB_Q_CHANNEL_DATA data
;
492 DWORD present
= TRUE
;
494 driver_request
= CTX_SEG_OFF_TO_LIN(context
, context
->SegEs
, context
->Ebx
);
496 if (!driver_request
) {
497 /* FIXME - to be deleted ?? */
498 ERR("ES:BX==0 ! SEGFAULT ?\n");
499 ERR("-->BX=0x%04x, ES=0x%04lx, DS=0x%04lx, CX=0x%04x\n",
500 BX_reg(context
), context
->SegEs
, context
->SegDs
, CX_reg(context
));
501 driver_request
[4] |= 0x80;
502 driver_request
[3] = 5; /* bad request length */
506 * the following tests are wrong because lots of functions don't require the
507 * tray to be closed with a CD inside
509 TRACE("CDROM device driver -> command <%d>\n", (unsigned char)driver_request
[2]);
511 if (!is_cdrom(CX_reg(context
))) {
512 WARN("Request made doesn't match a CD ROM drive (%d)\n", CX_reg(context
));
513 driver_request
[4] |= 0x80;
514 driver_request
[3] = 1; /* unknown unit */
518 MSCDEX_Dump("Beg", driver_request
, dorealmode
);
520 /* set status to 0 */
521 PTR_AT(driver_request
, 3, WORD
) = 0;
522 devName
[4] = 'A' + CX_reg(context
);
523 h
= CreateFileA(devName
, GENERIC_READ
, FILE_SHARE_READ
, NULL
, OPEN_EXISTING
, 0, 0);
525 WARN("Couldn't open cdrom handle\n");
526 driver_request
[4] |= 0x80;
527 driver_request
[3] = 1; /* unknown unit */
531 fmt
.Format
= IOCTL_CDROM_CURRENT_POSITION
;
532 if (!DeviceIoControl(h
, IOCTL_CDROM_READ_TOC
, NULL
, 0, &toc
, sizeof(toc
), &br
, NULL
) ||
533 !DeviceIoControl(h
, IOCTL_CDROM_READ_Q_CHANNEL
, &fmt
, sizeof(fmt
),
534 &data
, sizeof(data
), &br
, NULL
)) {
535 if (GetLastError() == STATUS_NO_MEDIA_IN_DEVICE
)
537 if (driver_request
[2] != 6 && driver_request
[2] != 15)
539 driver_request
[4] |= 0x80;
540 driver_request
[3] = 2; /* drive not ready */
548 driver_request
[4] |= 0x80;
549 driver_request
[3] = 1; /* unknown unit */
555 switch (driver_request
[2]) {
557 io_stru
= (dorealmode
) ?
558 PTR_REAL_TO_LIN( PTR_AT(driver_request
, 16, WORD
), PTR_AT(driver_request
, 14, WORD
) ) :
559 MapSL( MAKESEGPTR(PTR_AT(driver_request
, 16, WORD
), PTR_AT(driver_request
, 14, WORD
)));
561 TRACE(" --> IOCTL INPUT <%d>\n", io_stru
[0]);
562 switch (io_stru
[0]) {
564 case 0: /* Get device Header */
566 static LPSTR ptr
= 0;
568 ptr
= SEGPTR_ALLOC(22);
569 PTR_AT(ptr
, 0, DWORD
) = ~1; /* Next Device Driver */
570 PTR_AT(ptr
, 4, WORD
) = 0xC800; /* Device attributes */
571 PTR_AT(ptr
, 6, WORD
) = 0x1234; /* Pointer to device strategy routine: FIXME */
572 PTR_AT(ptr
, 8, WORD
) = 0x3142; /* Pointer to device interrupt routine: FIXME */
573 PTR_AT(ptr
, 10, char) = 'W'; /* 8-byte character device name field */
574 PTR_AT(ptr
, 11, char) = 'I';
575 PTR_AT(ptr
, 12, char) = 'N';
576 PTR_AT(ptr
, 13, char) = 'E';
577 PTR_AT(ptr
, 14, char) = '_';
578 PTR_AT(ptr
, 15, char) = 'C';
579 PTR_AT(ptr
, 16, char) = 'D';
580 PTR_AT(ptr
, 17, char) = '_';
581 PTR_AT(ptr
, 18, WORD
) = 0; /* Reserved (must be zero) */
582 PTR_AT(ptr
, 20, BYTE
) = 0; /* Drive letter (must be zero) */
583 PTR_AT(ptr
, 21, BYTE
) = 1; /* Number of units supported (one or more) FIXME*/
585 PTR_AT(io_stru
, DWORD
, 0) = SEGPTR_GET(ptr
);
590 case 1: /* location of head */
591 switch (io_stru
[1]) {
593 PTR_AT(io_stru
, 2, DWORD
) =
594 FRAME_OF_ADDR(data
.CurrentPosition
.AbsoluteAddress
);
597 MSCDEX_StoreMSF(FRAME_OF_ADDR(data
.CurrentPosition
.AbsoluteAddress
),
601 ERR("CD-ROM driver: unsupported addressing mode !!\n");
604 TRACE(" ----> HEAD LOCATION <%ld>\n", PTR_AT(io_stru
, 2, DWORD
));
607 case 4: /* Audio channel info */
616 TRACE(" ----> AUDIO CHANNEL INFO\n");
619 case 6: /* device status */
620 PTR_AT(io_stru
, 1, DWORD
) = 0x00000290;
622 * 1 Supports HSG and Red Book addressing modes
623 * 0 Supports audio channel manipulation
625 * 1 Supports prefetching requests
628 * 1 Data read and plays audio/video tracks
631 * 0 Supports only cooked reading
633 * 0 see below (Door closed/opened)
635 if (!present
) PTR_AT(io_stru
, 1, DWORD
) |= 1;
636 TRACE(" ----> DEVICE STATUS <0x%08lx>\n", PTR_AT(io_stru
, 1, DWORD
));
639 case 8: /* Volume size */
640 PTR_AT(io_stru
, 1, DWORD
) = FRAME_OF_TOC(toc
, toc
.LastTrack
+ 1) -
641 FRAME_OF_TOC(toc
, toc
.FirstTrack
) - 1;
642 TRACE(" ----> VOLUME SIZE <%ld>\n", PTR_AT(io_stru
, 1, DWORD
));
645 case 9: /* media changed ? */
646 /* answers don't know... -1/1 for yes/no would be better */
647 io_stru
[1] = 0; /* FIXME? 1? */
648 TRACE(" ----> MEDIA CHANGED <%d>\n", io_stru
[1]);
651 case 10: /* audio disk info */
652 io_stru
[1] = toc
.FirstTrack
; /* starting track of the disc */
653 io_stru
[2] = toc
.LastTrack
; /* ending track */
654 MSCDEX_StoreMSF(FRAME_OF_TOC(toc
, toc
.LastTrack
+ 1) -
655 FRAME_OF_TOC(toc
, toc
.FirstTrack
) - 1, io_stru
+ 3);
657 TRACE(" ----> AUDIO DISK INFO <%d-%d/%08lx>\n",
658 io_stru
[1], io_stru
[2], PTR_AT(io_stru
, 3, DWORD
));
661 case 11: /* audio track info */
662 if (io_stru
[1] >= toc
.FirstTrack
&& io_stru
[1] <= toc
.LastTrack
) {
663 MSCDEX_StoreMSF(FRAME_OF_TOC(toc
, io_stru
[1]), io_stru
+ 2);
664 /* starting point if the track */
665 io_stru
[6] = CTRL_OF_TOC(toc
, io_stru
[1]);
667 PTR_AT(io_stru
, 2, DWORD
) = 0;
670 TRACE(" ----> AUDIO TRACK INFO[%d] = [%08lx:%d]\n",
671 io_stru
[1], PTR_AT(io_stru
, 2, DWORD
), io_stru
[6]);
674 case 12: /* get Q-Channel info */
675 io_stru
[1] = CTRL_OF_TOC(toc
, data
.CurrentPosition
.TrackNumber
);
676 io_stru
[2] = data
.CurrentPosition
.TrackNumber
;
677 io_stru
[3] = 0; /* FIXME ?? */
679 /* why the heck did MS use another format for 0MSF information... sigh */
683 MSCDEX_StoreMSF(FRAME_OF_ADDR(data
.CurrentPosition
.TrackRelativeAddress
), bTmp
);
684 io_stru
[ 4] = bTmp
[2];
685 io_stru
[ 5] = bTmp
[1];
686 io_stru
[ 6] = bTmp
[0];
689 MSCDEX_StoreMSF(FRAME_OF_ADDR(data
.CurrentPosition
.AbsoluteAddress
), bTmp
);
690 io_stru
[ 8] = bTmp
[2];
691 io_stru
[ 9] = bTmp
[1];
692 io_stru
[10] = bTmp
[0];
695 TRACE("Q-Channel info: Ctrl/adr=%02x TNO=%02x X=%02x rtt=%02x:%02x:%02x rtd=%02x:%02x:%02x (cf=%08x, tp=%08x)\n",
696 io_stru
[ 1], io_stru
[ 2], io_stru
[ 3],
697 io_stru
[ 4], io_stru
[ 5], io_stru
[ 6],
698 io_stru
[ 8], io_stru
[ 9], io_stru
[10],
699 FRAME_OF_ADDR(data
.CurrentPosition
.AbsoluteAddress
),
700 FRAME_OF_TOC(toc
, data
.CurrentPosition
.TrackNumber
));
703 case 15: /* Audio status info */
704 /* !!!! FIXME FIXME FIXME !! */
705 PTR_AT(io_stru
, 1, WORD
) = 2 | ((data
.CurrentPosition
.Header
.AudioStatus
== AUDIO_STATUS_PAUSED
) ? 1 : 0);
707 PTR_AT(io_stru
, 3, DWORD
) = 0;
708 PTR_AT(io_stru
, 7, DWORD
) = 0;
710 PTR_AT(io_stru
, 3, DWORD
) = FRAME_OF_TOC(toc
, toc
.FirstTrack
);
711 PTR_AT(io_stru
, 7, DWORD
) = FRAME_OF_TOC(toc
, toc
.LastTrack
+ 1);
713 TRACE("Audio status info: status=%04x startLoc=%ld endLoc=%ld\n",
714 PTR_AT(io_stru
, 1, WORD
), PTR_AT(io_stru
, 3, DWORD
), PTR_AT(io_stru
, 7, DWORD
));
718 FIXME("IOCTL INPUT: Unimplemented <%d>!!\n", io_stru
[0]);
725 io_stru
= (dorealmode
) ?
726 PTR_REAL_TO_LIN( PTR_AT(driver_request
, 16, WORD
), PTR_AT(driver_request
, 14, WORD
)) :
727 MapSL( MAKESEGPTR(PTR_AT(driver_request
, 16, WORD
), PTR_AT(driver_request
, 14, WORD
)));
729 TRACE(" --> IOCTL OUTPUT <%d>\n", io_stru
[0]);
730 switch (io_stru
[0]) {
732 DeviceIoControl(h
, IOCTL_STORAGE_EJECT_MEDIA
, NULL
, 0, NULL
, 0, &br
, NULL
);
733 TRACE(" ----> EJECT\n");
735 case 2: /* reset drive */
736 DeviceIoControl(h
, IOCTL_STORAGE_RESET_DEVICE
, NULL
, 0, NULL
, 0, &br
, NULL
);
737 TRACE(" ----> RESET\n");
739 case 3: /* Audio Channel Control */
740 FIXME(" ----> AUDIO CHANNEL CONTROL (NIY)\n");
742 case 5: /* close tray */
743 DeviceIoControl(h
, IOCTL_STORAGE_LOAD_MEDIA
, NULL
, 0, NULL
, 0, &br
, NULL
);
744 TRACE(" ----> CLOSE TRAY\n");
747 FIXME(" IOCTL OUTPUT: Unimplemented <%d>!!\n", io_stru
[0]);
753 case 128: /* read long */
755 LPVOID dst
= MapSL(MAKESEGPTR(PTR_AT(driver_request
, 16, WORD
),
756 PTR_AT(driver_request
, 14, WORD
)));
757 DWORD at
= PTR_AT(driver_request
, 20, DWORD
);
758 WORD num
= PTR_AT(driver_request
, 18, WORD
);
761 switch (driver_request
[13]) {
762 case 1: /* Red book addressing mode = 0:m:s:f */
763 /* FIXME : frame <=> msf conversion routines could be shared
764 * between mscdex and mcicda
766 at
= LOBYTE(HIWORD(at
)) * CDFRAMES_PERMIN
+
767 HIBYTE(LOWORD(at
)) * CDFRAMES_PERSEC
+
770 case 0: /* HSG addressing mode */
771 switch (PTR_AT(driver_request
, 24, BYTE
))
774 ReadFile(h
, dst
, num
* 2048, &br
, NULL
);
777 /* FIXME: computation is wrong */
778 rri
.DiskOffset
.s
.HighPart
= 0;
779 rri
.DiskOffset
.s
.LowPart
= at
<< 11;
780 rri
.TrackMode
= YellowMode2
;
781 rri
.SectorCount
= num
;
782 DeviceIoControl(h
, IOCTL_CDROM_RAW_READ
, &rri
, sizeof(rri
),
783 dst
, num
* 2352, &br
, NULL
);
786 ERR("Unsupported read mode !!\n");
792 ERR("Unsupported address mode !!\n");
802 CDROM_SEEK_AUDIO_MSF seek
;
804 at
= PTR_AT(driver_request
, 20, DWORD
);
806 TRACE(" --> SEEK AUDIO mode :<0x%02X>, [%ld]\n",
807 (BYTE
)driver_request
[13], at
);
809 switch (driver_request
[13]) {
810 case 1: /* Red book addressing mode = 0:m:s:f */
811 /* FIXME : frame <=> msf conversion routines could be shared
812 * between mscdex and mcicda
814 at
= LOBYTE(HIWORD(at
)) * CDFRAMES_PERMIN
+
815 HIBYTE(LOWORD(at
)) * CDFRAMES_PERSEC
+
818 case 0: /* HSG addressing mode */
819 seek
.M
= at
/ CDFRAMES_PERMIN
;
820 seek
.S
= (at
/ CDFRAMES_PERSEC
) % 60;
821 seek
.F
= at
% CDFRAMES_PERSEC
;
822 DeviceIoControl(h
, IOCTL_CDROM_SEEK_AUDIO_MSF
, &seek
, sizeof(seek
),
826 ERR("Unsupported address mode !!\n");
836 CDROM_PLAY_AUDIO_MSF play
;
838 beg
= end
= PTR_AT(driver_request
, 14, DWORD
);
839 end
+= PTR_AT(driver_request
, 18, DWORD
);
841 TRACE(" --> PLAY AUDIO mode :<0x%02X>, [%ld-%ld]\n",
842 (BYTE
)driver_request
[13], beg
, end
);
844 switch (driver_request
[13]) {
846 /* Red book addressing mode = 0:m:s:f */
847 /* FIXME : frame <=> msf conversion routines could be shared
848 * between mscdex and mcicda
850 beg
= LOBYTE(LOWORD(beg
)) * CDFRAMES_PERMIN
+
851 HIBYTE(LOWORD(beg
)) * CDFRAMES_PERSEC
+
853 end
= LOBYTE(LOWORD(end
)) * CDFRAMES_PERMIN
+
854 HIBYTE(LOWORD(end
)) * CDFRAMES_PERSEC
+
857 case 0: /* HSG addressing mode */
858 play
.StartingM
= beg
/ CDFRAMES_PERMIN
;
859 play
.StartingS
= (beg
/ CDFRAMES_PERSEC
) % 60;
860 play
.StartingF
= beg
% CDFRAMES_PERSEC
;
861 play
.EndingM
= end
/ CDFRAMES_PERMIN
;
862 play
.EndingS
= (end
/ CDFRAMES_PERSEC
) % 60;
863 play
.EndingF
= end
% CDFRAMES_PERSEC
;
864 DeviceIoControl(h
, IOCTL_CDROM_PLAY_AUDIO_MSF
, &play
, sizeof(play
),
868 ERR("Unsupported address mode !!\n");
876 if (data
.CurrentPosition
.Header
.AudioStatus
== AUDIO_STATUS_IN_PROGRESS
) {
877 DeviceIoControl(h
, IOCTL_CDROM_PAUSE_AUDIO
, NULL
, 0, NULL
, 0, &br
, NULL
);
878 TRACE(" --> STOP AUDIO (Paused)\n");
880 DeviceIoControl(h
, IOCTL_CDROM_STOP_AUDIO
, NULL
, 0, NULL
, 0, &br
, NULL
);
881 TRACE(" --> STOP AUDIO (Stopped)\n");
886 TRACE(" --> RESUME AUDIO\n");
887 DeviceIoControl(h
, IOCTL_CDROM_PAUSE_AUDIO
, NULL
, 0, NULL
, 0, &br
, NULL
);
891 FIXME(" ioctl unimplemented <%d>\n", driver_request
[2]);
895 /* setting error codes if any */
897 driver_request
[4] |= 0x80;
898 driver_request
[3] = Error
;
902 /* setting status bits
903 * 3 == playing && done
907 (data
.CurrentPosition
.Header
.AudioStatus
== AUDIO_STATUS_IN_PROGRESS
) ? 3 : 1;
909 MSCDEX_Dump("End", driver_request
, dorealmode
);
913 FIXME("Unimplemented MSCDEX function 0x%02X.\n", LOBYTE(context
->Eax
));