           PAGE    62,132 
           Title   DoubleDOS Utility: Partition Priority 

CR                 EQU     0Dh     ;ASCII Carriage Return
LF                 EQU     0Ah     ;ASCII Line Feed
$                  EQU     24h     ;String termination charachter '$'

Parm_Byte_Count    EQU     80h

Dos_Call           EQU     21h
Terminate_Process  EQU     4Ch
Put_String         EQU     09h

DD_Set_Timeshare   EQU     0E9h    ;Set timesharing priority

;  AL = 0 Visible program gets 70% Invisible gets 30% (Default)
;  AL = 1 Visible program gets 50% Invisible gets 50% of time  
;  AL = 2 Visible program gets 30% Invisible gets 70% of time  
;  AL = 3 Top     program gets 70% Bottom    gets 30% of time
;  AL = 4 Top     program gets 30% Bottom    gets 70% of time
;
;  Priority / - [V,I,E,T,B]
;
;  Calling sequence: /, or - optional.  The timesharing ratio will be
;    set according to the first valid parameter charachter:
;
;         V - Visible    partition       gets 70%
;         E - Equal      both partitions get  50%
;         I - Invisible  partition       gets 70%
;         T - Top        partition       gets 70%
;         B - Bottom     partition       gets 70%
;

Print_$    MACRO
           mov     ah,Put_String
           int     Dos_Call
           ENDM

Code_Seg   SEGMENT 
           ASSUME  cs:Code_Seg,ds:Code_Seg,es:Code_Seg
           ORG     0100h  
Main       PROC    NEAR


; Get parameter Byte count, copy parameters into buffer, converting
;   to Upper case as we go.

           mov     si,Parm_Byte_Count            ;Point to parm byte count 
           mov     di,OFFSET Parm_Copy           ;point to copy destination
           cld                                   ;  String Counts forward
           lodsb                                 ;  AL = Byte Count

           mov     Parm_Count,al                 ;Store Byte Count 
           mov     dx,OFFSET Prog_Info           ;Display program info
           PRINT_$
           mov     al,Parm_Count                 ;Restore Byte Count


; Some quick error checks: 0 < Parm_Count < 128

           cmp     al,00h
           jnz     Not_Err1                      ;No parms given?

           mov     dx,OFFSET Err_Msg1
           Print_$
           mov     dx,OFFSET Valid
           Print_$
           mov     Ret_Code,31h                  ;Return ERRORLEVEL 1
           jmp     Finished

Not_Err1:  test    al,80h
           jz      Not_Err2                      ;More than 127 bytes?

           mov     dx,OFFSET Err_Msg2
           Print_$
           mov     dx,OFFSET Valid
           Print_$
           mov     Ret_Code,32h                  ;Return ERRORLEVEL 2
           jmp     Finished                      

; End of Error checks, move and convert.

Not_Err2:  cbw                                   ;AX = Byte Count
           mov     cx,ax                         ;CX = Loop count
           cld 
Up_Loop:   lodsb                                 ;Copy parms into buffer
           cmp     al,60h                        ;  converting to UPPER
           jb      Up_Case                       ;  case as we go
           sub     al,20h
Up_Case:   stosb
           loop    Up_Loop


; Scan Parameters list for 1st occurence of a valid parameter, and
;   execute appropriate subroutine when found.

           mov     si,OFFSET Parm_Copy
           mov     al,Parm_Count
           cbw
           mov     cx,ax
Next_Char: cld
           lodsb                                 ;Look for valid parm char
           cmp     al,'V'                                           
           jz      Vis_Ok                        ;  Priority = Visible
           cmp     al,'E'                                           
           jz      Equ_Ok                        ;  Priority = Equal
           cmp     al,'I'                                           
           jz      Inv_Ok                        ;  Priority = Invisible
           cmp     al,'T'                                           
           jz      Top_Ok                        ;  Priority = Top
           cmp     al,'B'                                               
           jz      Bot_Ok                        ;  Priority = Bottom
           loop    Next_Char

           mov     dx,OFFSET Err_Msg3            ;No valid parms found!
           Print_$
           mov     dx,OFFSET Valid
           Print_$
           mov     Ret_Code,33h                  ;Return ERRORLEVEL 3
           jmp     Finished                      


; A valid parameter has been found.  Set up AL, and set new timesharing
;   ratio.  A User message will be output, and an ERRORLEVEL of 0 will 
;   be returned. 

Vis_Ok:    mov     dx,OFFSET Vis_Msg             ;Set-up  Timeshare parms
           Print_$
           mov     al,00h
           jmp     Kosher

Equ_Ok:    mov     dx,OFFSET Equ_Msg
           Print_$
           mov     al,01h
           jmp     Kosher

Inv_Ok:    mov     dx,OFFSET Inv_Msg
           Print_$
           mov     al,02h
           jmp     Kosher

Top_Ok:    mov     dx,OFFSET Top_Msg
           Print_$
           mov     al,03h
           jmp     Kosher

Bot_Ok:    mov     dx,OFFSET Bot_Msg
           Print_$
           mov     al,04h

Kosher:    mov     ah,DD_Set_Timeshare           ;Set Timesharing Ratio
           int     Dos_Call
           mov     Ret_Code,30h                  ;All Kosher, end program
           jmp     Finished                      ;Return ERRORLEVEL 0


;//////////////////
;
;  ERRORLEVEL return, Output to user, Terminate
;
;//////////////////

Finished:  mov     dx,OFFSET Finish_Msg          ;Display ERRORLEVEL MSG
           PRINT_$
           mov     ah,Terminate_Process          ;End Program
           mov     al,Ret_Code                   ;ERRORLEVEL in AL
           and     al,0Fh                        ;Ascii to binary integer
           int     Dos_Call


;//////////////////
;
;  Data Definition Area
;
;//////////////////

Prog_Info  DB      CR,LF,'DoubleDOS Utility - by Chris M. Magyar '
           DB      '- 12/20/85',CR,LF,CR,LF,$

Vis_Msg    DB      'Partition Priority: Visible 70%, Invisible 30%',CR,LF,$
Equ_Msg    DB      'Partition Priority: Both Partions recieve 50%',CR,LF,$
Inv_Msg    DB      'Partition Priority: Invisible 70%, Visible 30%',CR,LF,$
Top_Msg    DB      'Partition Priority: Top 70%, Bottom 30%',CR,LF,$
Bot_Msg    DB      'Partition Priority: Bottom 70%, Top 30%',CR,LF,$

Finish_Msg DB      CR,LF,'ERRORLEVEL : '
Ret_Code   DB      ?,' being returned.',CR,LF,$

Err_Msg1   DB      'No parameters given.',CR,LF,CR,LF,$
Err_Msg2   DB      'More than 127 bytes in parameter list!!!',CR,LF
           DB      'Must terminate now.',CR,LF,CR,LF,$
Err_Msg3   DB      'No valid parameters given.',CR,LF,CR,LF,$

Valid      DB      'The following are valid parameters for Priority'
           DB      CR,LF,CR,LF
           DB      '  V - Visible   partion gets 70% Priority',CR,LF
           DB      '  I - Invisible partion gets 70% Priority',CR,LF
           DB      '  T - Top       partion gets 70% Priority',CR,LF
           DB      '  B - Bottom    partion gets 70% Priority',CR,LF
           DB      '  E - Equal     each partition gets 50% Priority'
           DB      CR,LF,$

Parm_Count DB      ?
Parm_Copy  DB      128 DUP(?),CR,LF,$

Main       ENDP
Code_Seg   ENDS
           END Main

