home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-386-Vol-2of3.iso / b / batdoor.zip / GETMODE.ZIP / GETMODE.ASM next >
Assembly Source File  |  1986-11-21  |  5KB  |  123 lines

  1. ;
  2. ; GETMODE : Indicates Graphics Mode type for Remote PCBoard DOORS users.
  3. ;
  4. ; Courtesy of: The BBS of Excellence (312)398-2872
  5. ;
  6. ; If the user exit through a DOOR in non-Graphics mode, then the
  7. ; returned errorlevel will be 0. An errorlevel of 1 indicates
  8. ; ANSI graphics is desired, and an errorlevel of 3 indicates that
  9. ; PCBOARD.SYS could not be found.
  10. ;
  11. cseg    segment  byte public 'CODE'
  12.         assume   cs:cseg,ds:cseg,es:cseg
  13.         org      100h
  14. GetMode proc     near
  15.         jmp      MainCode   ; Skip over constant
  16. ;
  17. ASCIIZ   dw      ?          ; Holder for ASCIIZ string address
  18. Handle   dw      ?          ; Save area for file "handle"
  19. DataArea db      60 dup(?)
  20. ModeType db      0
  21. ;
  22. MainCode:
  23.         Call     ValidateEntry  ; Validate the Command line entry format
  24.         Call     OpenFile       ; Go Open the file
  25.         Call     ReadFile       ; Read the file
  26.         Lea      SI,DataArea+56 ; Point to the indicator
  27.         Mov      AL,[SI]        ; Get the byte
  28.         Cmp      AL,'-'         ; Is it graphics ?
  29.         Jnz      EndMode        ; No..take the default
  30.         Mov      AL,1           ; Set up for
  31.         Mov      ModeType,AL    ;   Graphics
  32. EndMode:
  33.         Call     CloseFile      ; Close the file
  34.         Mov      AH,4Ch         ; Set up for errorlevel
  35.         Mov      AL,ModeType    ; Get the return code
  36.         Int      21h            ; Terminate program
  37. GetMode endp
  38.  
  39. ValidateEntry  Proc    Near
  40.            mov     SI,80h          ; point to the command buffer
  41.            Xor     CX,CX           ; Init the loop counter
  42.            Mov     CL,[SI]         ; Get the input length
  43.            Cmp     CL,0            ; Was there no input ?
  44.            JZ      BadEntry        ; True...then abort
  45. SkipLoop:
  46.            Inc     SI              ; Point to the next byte
  47.            Mov     DL,[SI]         ; Get the character
  48.            Cmp     DL,' '          ; Is it Blank ?
  49.            Jnz     ByteFound       ; No...continue
  50.            Loop    SkipLoop        ; Else, keep on looking
  51. ByteFound:
  52.            Mov     ASCIIZ,SI       ; Save the pointer
  53.            Cmp     DL,97           ; Is it in lower case ?
  54.            Jb      UpperCase       ; No..don't change it
  55.            Sub     DL,32           ; Make it upper case
  56. UpperCase:
  57.            Cmp     DL,'A'          ; Is it Alpha ?
  58.            Jb      BadEntry        ; No...Abort
  59.            Cmp     DL,'E'          ; Is it too high ?
  60.            Ja      BadEntry        ; Yes..Abort
  61.            Inc     SI              ; Point to the colon
  62.            Mov     DL,[SI]         ; Get the character
  63.            Cmp     DL,':'          ; Is it a Colon ?
  64.            Jnz     BadEntry        ; No..Abort
  65.            Inc     SI              ; Point to the Slash
  66.            Mov     DL,[SI]         ; Get the character
  67.            Cmp     DL,'\'          ; Is it a slash ?
  68.            Jnz     BadEntry        ; No...Abort
  69. ;
  70. LoopToEnd:
  71.            Inc     SI              ; Skip to the next character
  72.            Mov     DL,[SI]         ; Get the character
  73.            Cmp     DL,13           ; End of the line ?
  74.            Jnz     LoopToEnd       ; No...keep on scanning
  75.            Xor     AL,AL           ; Init the work area
  76.            Mov     [SI],AL         ; Add an end-of-ASCIIZ indicator
  77.            Jmp     ExitValidation  ; Exit this routine
  78. BadEntry:
  79.            Mov     AL,3            ; Set up bad errorlevel
  80.            Mov     AH,4Ch          ; Prepare to exit
  81.            Int     21h             ; Abort processing
  82. ExitValidation:
  83.            Ret
  84. ValidateEntry    Endp
  85.  
  86. OpenFile  Proc   Near
  87.           Mov    DX,ASCIIZ  ; Point to the ASCIIZ string
  88.           Xor    AL,AL      ; No file protection
  89.           Mov    AH,61      ; Set up the command
  90.           Int    21h        ; Do the Open
  91.           Jc     CantOpen   ; If unable to open, tell the user
  92.           Mov    Handle,AX  ; Save the "handle"
  93.           Jmp    ExitOpen   ; Exit this routine
  94. CantOpen:
  95.           Mov    AL,3       ; Setup BAD errorlevel
  96.           Mov    AH,4Ch     ; Prepare to terminate
  97.           Int    21h        ; Terminate processing
  98. ExitOpen:
  99.           Ret               ; Return to the caller
  100. OpenFile  Endp
  101.  
  102. CloseFile Proc   Near
  103.           Mov    DX,Handle  ; Get the file handle
  104.           Xor    AX,AX      ; Init the work register
  105.           Mov    AH,62      ; Set up the command
  106.           Int    21h        ; Execute it
  107.           Ret               ; Return to caller
  108. CloseFile Endp
  109.  
  110.  
  111. ReadFile  Proc   Near
  112.           Mov    BX,Handle  ; Get the file handle name
  113.           Lea    DX,DataArea  ; Point to the file area
  114.           Mov    CX,60      ; Read 60 bytes
  115.           Xor    AX,AX      ; Init the work register
  116.           Mov    AH,63      ; Set up the command
  117.           Int    21h        ; Execute it
  118.           Ret
  119. ReadFile  Endp
  120.  
  121. CSEG      Ends
  122.           End    GetMode
  123.