home *** CD-ROM | disk | FTP | other *** search
/ CD-X 1 / cdx_01.iso / shareuti / secdev13 / source / conio.asm next >
Encoding:
Assembly Source File  |  1994-05-02  |  7.1 KB  |  188 lines

  1. ; This file is a part of SecureDevice 1.3
  2. ; Copyright (C) 1994 by Max Loewenthal and Arthur Helwig
  3.  
  4. ; This program is free software; you can redistribute it and/or modify
  5. ; it under the terms of the GNU General Public License as published by
  6. ; the Free Software Foundation; either version 2 of the License, or
  7. ; (at your option) any later version.
  8.  
  9. ; This program is distributed in the hope that it will be useful,
  10. ; but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12. ; GNU General Public License for more details.
  13.  
  14. ; You should have received a copy of the GNU General Public License
  15. ; along with this program; if not, write to the Free Software
  16. ; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  17.  
  18.  
  19. IDEAL
  20. MODEL       TINY,C
  21.  
  22. CODESEG
  23.  
  24. PUBLIC      MovePart,InitScreen,Write,ScreenHeight,ScreenWidth,Graphic
  25.  
  26. PROC        MovePart
  27.             ASSUME      DS:@CODE,ES:NOTHING,SS:@CODE,CS:@CODE
  28.             ARG         ToScreen:BYTE           ; <>0 = buffer->screen, 0 = screen->buffer
  29.             ARG         Buffer:WORD,X1:WORD,Y1:WORD,X2:WORD,Y2:WORD
  30.  
  31.                         PUSH        DS ES SI DI CX DX BX AX
  32.                         MOV         SI,0
  33.                         MOV         DS,[ScreenBase]
  34.             ASSUME      DS:NOTHING
  35.                         MOV         DI,[Buffer]
  36.  
  37.                         MOV         CX,[Y2]
  38.                         SUB         CX,[Y1]       ; cx = # of lines
  39.                         INC         CX
  40.  
  41.                         MOV         AX,[Y1]
  42.                         MOV         BX,[ScreenWidth]
  43.                         MUL         BX
  44.                         SHL         AX,1
  45.                         ADD         SI,AX         ; ds:si-> 1st line
  46.  
  47.                         MOV         BX,[X2]
  48.                         SUB         BX,[X1]       ; bx = # of words to be moved
  49.                         INC         BX
  50.                         MOV         DX,[X1]
  51.                         SHL         DX,1          ; dx = offset from beginning of line
  52.                         MOV         AX,[ScreenWidth]
  53.                         SHL         AX,1          ; ax = size of one line
  54.  
  55.                         CLD
  56.  
  57.                         JCXZ        @@Exit
  58.  
  59.             @@NextLine: PUSH        CX
  60.                         PUSH        SI
  61.                         ADD         SI,DX
  62.                         MOV         CX,BX
  63.  
  64.                         CMP         [ToScreen],0
  65.                         JE          @@1
  66.  
  67.                         PUSH        DS ES
  68.                         POP         DS ES
  69.                         XCHG        DI,SI
  70.  
  71.             @@1:        REP         MOVSW
  72.  
  73.                         CMP         [ToScreen],0
  74.                         JE          @@2
  75.  
  76.                         PUSH        DS ES
  77.                         POP         DS ES
  78.                         XCHG        DI,SI
  79.  
  80.             @@2:        POP         SI
  81.                         ADD         SI,AX
  82.                         POP         CX
  83.                         LOOP        @@NextLine
  84.  
  85.             @@Exit:     POP         AX BX DX CX DI SI ES DS
  86.                         RET
  87. ENDP        MovePart
  88.  
  89. PROC        InitScreen
  90.             LOCAL       VideoPage:BYTE
  91.                         PUSH        ES AX BX CX DX
  92.                         MOV         AH,0Fh
  93.                         INT         10h
  94.                         MOV         [ScreenBase],0B000h
  95.                         MOV         [VideoPage],BH
  96.                         AND         AL,7Fh
  97.                         CMP         AL,7
  98.                         JZ          @@1
  99.                         MOV         [ScreenBase],0B800h
  100.  
  101.             @@1:        MOV         AL,AH
  102.                         MOV         AH,0
  103.                         MOV         [ScreenWidth],AX
  104.                         MOV         AX,1130h
  105.                         MOV         BH,0
  106.                         MOV         DL,0
  107.                         PUSH        BP
  108.                         INT         10h
  109.                         POP         BP
  110.                         CMP         DL,0
  111.                         JNE         @@2
  112.                         MOV         DL,24
  113.  
  114.             @@2:        INC         DL
  115.                         MOV         AL,DL
  116.                         MOV         AH,0
  117.                         MOV         [ScreenHeight],AX
  118.  
  119.             @@NoDV:     XOR         AX,AX
  120.                         MOV         ES,AX
  121.                         MOV         AX,[ES:44Eh]
  122.                         ADD         [ScreenBase],AX
  123.  
  124.                         MOV         [Graphic],1
  125.                         MOV         ES,[ScreenBase]
  126.                         MOV         DL,[ES:0]
  127.                         PUSH        DX
  128.                         MOV         [BYTE PTR ES:0],'A'
  129.                         CMP         [BYTE PTR ES:0],'A'
  130.                         JNE         @@3
  131.  
  132.                         MOV         BH,[VideoPage]
  133.                         MOV         AH,3
  134.                         INT         10h
  135.                         MOV         CX,DX                   ; save cursor pos in CX
  136.                         MOV         AH,2
  137.                         MOV         DX,0
  138.                         INT         10h                     ; move cursor to (0,0)
  139.                         MOV         AH,8
  140.                         INT         10h                     ; read char
  141.                         MOV         DX,CX                   ; put old cursor pos in DX
  142.                         MOV         CX,AX                   ; save char in CX
  143.                         MOV         AH,2
  144.                         INT         10h                     ; restore cursor pos
  145.                         CMP         AL,'A'
  146.                         JNE         @@3
  147.                         MOV         [Graphic],0
  148.                         
  149.             @@3:        POP         DX
  150.                         MOV         [ES:0],DL
  151.  
  152.                         POP         DX CX BX AX ES
  153.                         RET
  154. ENDP        InitScreen
  155.  
  156. PROC        Write
  157.             ARG         X:WORD,Y:WORD,Attr:BYTE,String:WORD
  158.  
  159.                         PUSH        DS ES AX BX SI DI
  160.                         MOV         ES,[ScreenBase]
  161.                         MOV         DI,0
  162.                         MOV         SI,[String]
  163.                         MOV         AX,[ScreenWidth]
  164.                         MOV         BX,[Y]
  165.                         MUL         BL
  166.                         ADD         AX,[X]
  167.                         SHL         AX,1
  168.                         ADD         DI,AX
  169.  
  170.                         MOV         AH,[Attr]
  171.                         CLD
  172.  
  173.             @NextChar:  LODSB
  174.                         CMP         AL,0
  175.                         JE          @Exit
  176.                         STOSW
  177.                         JMP         @NextChar
  178.  
  179.             @Exit:      POP         DI SI BX AX ES DS
  180.                         RET
  181. ENDP        Write
  182.  
  183.             ScreenBase  DW          0
  184.             ScreenWidth DW          0
  185.             ScreenHeight DW         0
  186.             Graphic     DB          0
  187. END
  188.