;  E.O.S exec for demo parts and music system 


.386p
INCLUDE OS.INC

CODE32 SEGMENT PUBLIC PARA USE32 'CODE'
ASSUME  CS:CODE32,DS:CODE32,ES:CODE32,SS:CODE32

INCLUDE HARDWARE.INC
INCLUDE USMPLAY.INC   ; USM player
INCLUDE USS.INC       ; Useless Sound System
INCLUDE USSVAR.INC    ; DEV_Name definition
INCLUDE XMLOAD.INC


INCLUDE UTILS.INC     ; Display macros (write, writeln)

USMOffset DD 0
Module    DB 'backup2.xm',0
Loadersoffset DD Offset XM_Load

parmblk	DW	00				; Parameter block
        DD      offset comline               ;  .
        DD      00,00                ;  ..
        DD      00,00                ;  ...

comline db  07H,'',0DH

file1   DB  'text2.exe',0
file2   DB  'plasma.exe',0
file3   DB  'bump3.exe',0
file4   DB  '3dpart2.exe',0
file5   DB  'flipart.exe',0
file6   DB  'mujmor2.exe',0
file7   DB  'mujfeed2.exe',0
file8   DB  '3dpart1.exe',0
file9   DB  'tunell2.exe',0
file10  DB  'mybump.exe',0
file11  DB  'scrolly.exe',0


;=============================================================================

Start32:

	mov ah,Detect_Windows
        Int_EOS
        or al,al
        jz NothingDOZE
        writeln '    þ Sorry, Windoze detect, use DOS only!!!!'
        jmp _Pend               ;Win detection


NothingDOZE:

 	mov ah,48h
 	mov bx,0ffffh
	dosint 21h
        cmp ebx,6600h
        jns goodmem
        writeln '    þ Not enough base memory for executing demo-parts!'  
        jmp _Pend 

goodmem:        

        
; ** Player Start

	call HardwareInit


; ** Sound system Setup **

   
	call USS_Setup	
 	jc _PEnd
	
        mov edx,_DEV_Name
        mov ah,9
	int 21h
        writeln



; ** "Load" the file **
; ** ! Warning: Do this only one time.

        mov esi,Offset Module

        call LoadFile

        mov USMOffset,esi

; ** Start the output **


        mov edx,0
	call USMP_StartPlay


        mov ah,Use_Int_09                ;inicializace sluzeb klavesnice
        mov bx,On
        Int_EOS

        mov edx,offset file1
        call execution                      ;pismo
        call sethiden                       ;skreje kurzor
        cmp Key_Map[All],Escape             ;Escape stlaceno?
        je keypressing

        mov edx,offset file2
        call execution                      ;plasma
        call sethiden                       ;skreje kurzor
        cmp Key_Map[All],Escape             ;Escape stlaceno?
        je keypressing

        mov edx,offset file3
        call execution                      ;prvni bump
        call sethiden                       ;skreje kurzor
        cmp Key_Map[All],Escape             ;Escape stlaceno?
        je keypressing

        mov edx,offset file4
        call execution                      ;letadlo
        call sethiden                       ;skreje kurzor
        cmp Key_Map[All],Escape             ;Escape stlaceno?
        je keypressing

        mov edx,offset file5
        call execution                      ;flick
        call sethiden                       ;skreje kurzor
        cmp Key_Map[All],Escape             ;Escape stlaceno?
        je keypressing

        mov edx,offset file6
        call execution                      ;morph
        call sethiden                       ;skreje kurzor
        cmp Key_Map[All],Escape             ;Escape stlaceno?
        je keypressing

        mov edx,offset file7
        call execution                      ;feedback
        call sethiden                       ;skreje kurzor
        cmp Key_Map[All],Escape             ;Escape stlaceno?
        je keypressing

        mov edx,offset file8
        call execution                      ;3d part 2
        call sethiden                       ;skreje kurzor
        cmp Key_Map[All],Escape             ;Escape stlaceno?
        je keypressing

        mov edx,offset file9
        call execution                      ;tunell
        call sethiden                       ;skreje kurzor
        cmp Key_Map[All],Escape             ;Escape stlaceno?
        je keypressing

        mov edx,offset file10
        call execution                      ;second bump
        call sethiden                       ;skreje kurzor
        cmp Key_Map[All],Escape             ;Escape stlaceno?
        je keypressing

        mov edx,offset file11
        call execution                      ;scroll
        call sethiden                       ;skreje kurzor
        cmp Key_Map[All],Escape             ;Escape stlaceno?
        je keypressing

        mov ax,03h			   ;textmode
	dosint 10h
        jmp deinit

keypressing:                        ;  neco se zmacklo
        mov ax,03h
        dosint 10h
        writeln 'breaks is your way'
        jmp deinit

deinit:
        mov ah,Use_Int_09               ;klavdeinit
        mov bx,Off
        Int_EOS

P2end:
;--------STOP MUSIC--------
        call USMP_StopPlay
        mov esi,USMOffset
        call USMP_FreeModule

_PEnd:
	mov   ax,4C00h
        int   21h

;====================================================================
LoadFile Proc
        

        push esi
        write 'Loading '
        mov ecx,80
        call print_str
        writeln
        pop esi

        call LoadersOffset
        ret
LoadFile Endp

;=================================================================
sethiden proc
        mov   ax,03
	dosint 10h
	mov ah,1
	mov cx,2000h
	dosint 10h
	ret
sethiden endp

;======================= EXECprocedure ===================

execution  Proc

        
	MOV	AX,CODE32_SEL 			; cs = segment pro
	MOV	WORD PTR parmblk+2,AX		;  prik. radku a FCB
	MOV	WORD PTR parmblk+6,AX		;  .
	MOV	WORD PTR parmblk+10,AX		;  ..



  	MOV	EBX,offset parmblk		;  .
	MOV	AX,4B00H			;  ..

        INT	21H				; Shell to DOS

        ret

      execution       ENDP     


CODE32 ENDS
;=============================================================================
END
