! eject.S for dosemu 0.53+, 8/18/94
!    eject cd in drive
!

use16
.text
.data
.bss

.align 0

.globl _main           ! for ld86
_main:

	.org     0
	mov	ah, #0xC0		! Get ROM BIOS information
	int	0x15
	mov	cx, #7
	mov	di, bx			! ES:DI = BIOS name
	add	di, #10
	mov	si, #VerCheck		! DS:SI = Version check
	add	si, #0x100
	.byte   0xf3, 0xa6		! repz	cmpsb
	jcxz	Version_OK

	mov	ax, #0x35E6		! Get the Int 0xE6 vector
	int	0x21

	mov	ax, es			! Sanity check -- if 0xE6 -> 0000:0000
	or	ax, bx			!   don't call it!
	jz	Exit

Version_Old:
        mov	al, #0x40		! unlock door
        mov	ah, #0x0C
        int	#0xe6

	mov	al, #0x40		! eject disk
        mov	ah, #0x0D
	int	#0xe6
	jmp	Exit

Version_OK:				! Version 0.61+
        mov	ah, #0x0C		! unlock door
	call	#0xFC00:#0x0FF4		! CDROM helper

        mov	ah, #0x0D		! eject disk
	call	#0xFC00:#0x0FF4		! CDROM helper
Exit:
	int	0x20			! exit

VerCheck:
	.ascii	"DOSEMU "

	int     #0x20  ! exit



