home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 2 BBS / 02-BBS.zip / MSGDP206.SZH / SCREEN2.ASM < prev    next >
Assembly Source File  |  1990-11-20  |  6KB  |  385 lines

  1. ;
  2. ; PUBLIC DOMAIN
  3. ;
  4.  
  5. .model large
  6.  
  7. extrn _vbase:word
  8. extrn _maxx:word
  9. extrn _maxy:word
  10. extrn _current_color:byte
  11. extrn _videomethod:word
  12.  
  13. public DCLS, DPUTC, DPUTS, DCLRWND, DSCROLLUP, DSCROLLDN
  14.  
  15. .CODE
  16.  
  17. DCLS    proc far
  18.  
  19.     push bp
  20.     mov bp,sp
  21.  
  22.     push di
  23.     mov es,_vbase        ; set the es segment to the bottom of video
  24.  
  25.     mov bx,_maxx
  26.     mov ax,_maxy
  27.     mul bl                ; determine size of screen in words
  28.  
  29.     mov cx,ax            ; set up the count for the screen size
  30.     xor di,di            ; point es:di to start of screen
  31.  
  32.     mov ah,_current_color ; set the attribute
  33.     mov al,20h            ; write a space
  34.  
  35.     cld                 ; make sure we're going in the right direction...
  36.     repnz stosw            ; slam that sucker out to memory..
  37.  
  38.     pop di
  39.     pop bp
  40.  
  41.     ret
  42.  
  43. DCLS    endp
  44.  
  45. DPUTC    proc far
  46.     push bp
  47.     mov bp,sp
  48.  
  49.     pushf
  50.     cld
  51.  
  52.     cmp _videomethod,1
  53.     je bsputc
  54.  
  55.     mov bx,[bp+6]        ; get the character to write
  56.     mov dx,[bp+8]        ; get the y location
  57.     mov es,_vbase        ; set up the video segment
  58.  
  59.     mov ax,_maxx
  60.     dec dl                ; off by one because of 1 base coords
  61.     mul dl
  62.     add ax,[bp+10]        ; get base video offset
  63.     dec ax                ; off by one because of 1 based coords
  64.     shl ax,1            ; double it (because of attribute)
  65.  
  66.     mov bh,_current_color
  67.  
  68.     xchg ax,bx
  69.     mov es:[bx],ax        ; put it on the screen
  70.  
  71.     popf
  72.     pop bp
  73.     ret 6
  74.  
  75. bsputc: mov ah,02h
  76.     mov cx,[bp+8]
  77.     mov dx,[bp+10]
  78.     mov dh,cl
  79.     dec dh
  80.     dec dl
  81.     mov bh,0
  82.     int 10h
  83.  
  84.     mov ax,[bp+6]
  85.     mov ah,09h
  86.     mov bh,0
  87.     mov cx,1
  88.     mov bl,_current_color
  89.     int 10h
  90.  
  91.     popf
  92.     pop bp
  93.     ret 6
  94.  
  95. DPUTC    endp
  96.  
  97. DPUTS    proc far
  98.  
  99.     push bp
  100.     mov bp,sp
  101.  
  102.     pushf
  103.     cld
  104.  
  105.     cmp _videomethod,1
  106.     je bsputs
  107.  
  108.     push di             ; save needed registers
  109.     push si
  110.     push ds
  111.  
  112.     mov ax,_maxx
  113.     mov es,_vbase        ; set up the video segment
  114.     mov dh,_current_color
  115.  
  116.     lds si,[bp+6]        ; get offset
  117.     mov bx,[bp+10]        ; get the y location
  118.     mov di,[bp+12]        ; get the x location
  119.  
  120.     dec bl                ; off by one because of 1 base coords
  121.     mul bl
  122.     add di,ax            ; get base video offset
  123.     dec di                ; off by one because of 1 based coords
  124.     shl di,1            ; double it (because of attribute)
  125.  
  126.     mov ah,dh            ; put the attribute in ah
  127.     mov dx,si
  128.  
  129.  
  130. l0:    lodsb                ; load character
  131.     cmp al,0            ; test for zero byte
  132.     jz l1                ; end of string
  133.     stosw                ; write character and attribute
  134.     jmp l0
  135.  
  136. l1:    sub si,dx            ; how many characters were written
  137.     mov ax,si
  138.     dec ax
  139.  
  140.     pop ds                ; restore registers
  141.     pop si
  142.     pop di
  143.  
  144.     popf
  145.  
  146.     pop bp
  147.     ret 8
  148.  
  149. bsputs: mov cx,[bp+10]
  150.     mov dx,[bp+12]
  151.     mov dh,cl
  152.     dec dh
  153.     dec dl
  154.     mov bh,0
  155.     
  156.     push ds
  157.     pop es
  158.     push si
  159.     push di
  160.     lds si,[bp+6]
  161.     mov di,si
  162.     mov bl,es:_current_color
  163.     mov cx,1
  164.  
  165. l5:    mov ah,2
  166.     int 10h
  167.     inc dl
  168.     mov ah,9
  169.     lodsb    
  170.     cmp al,0
  171.     jz l6
  172.     int 10h
  173.     jmp l5
  174.  
  175. l6:    mov ax,si
  176.     sub ax,di
  177.     dec ax
  178.     pop di
  179.     pop si
  180.     push es
  181.     pop ds
  182.  
  183.     popf
  184.  
  185.     pop bp
  186.     ret 8
  187.     
  188. DPUTS endp
  189.  
  190. DCLRWND proc far
  191.     push bp
  192.     mov bp,sp
  193.  
  194.     push di
  195.     push si
  196.  
  197.     mov es,_vbase    ; video segment
  198.  
  199.     mov di,[bp+12] ; (x2)
  200.  
  201.     mov cx,[bp+6] ;  (y1)
  202.     sub cx,[bp+10]  ; how many lines? (y1 - y2)
  203.     inc cx
  204.  
  205.     mov ax,_maxx
  206.     mov bx,[bp+10]
  207.     dec bl
  208.     mul bl
  209.     add di,ax
  210.     dec di
  211.     mov si,di
  212.  
  213.     mov ah,_current_color
  214.     mov al,20h
  215.  
  216.     mov bx,[bp+8]  ; x2
  217.     sub bx,[bp+12]  ; how many columns (x2 - x1)
  218.     inc bx
  219.  
  220. l2: mov dx,bx
  221.     xchg cx,dx
  222.     shl di,1
  223.     rep stosw
  224.     add si,_maxx
  225.     mov di,si
  226.     xchg cx,dx
  227.     loop l2
  228.  
  229.     pop si
  230.     pop di
  231.  
  232.     pop bp
  233.     ret 8
  234.  
  235. DCLRWND endp
  236.  
  237. DSCROLLUP proc far
  238.  
  239.     push bp
  240.     mov bp,sp
  241.  
  242.     sub sp,2        ; allocate a local
  243.  
  244.     pushf
  245.  
  246.     push di         ; save registers
  247.     push si
  248.     push ds
  249.  
  250.     cld             ; set direction to forward
  251.  
  252.     mov al,_current_color
  253.     mov [bp-2],al
  254.  
  255.     mov es,_vbase    ; point to the video screen
  256.     mov ax,_maxx    ; how many columns on the screen
  257.     mov si,ax
  258.  
  259.     mov cx,[bp+6]
  260.     sub cx,[bp+10]    ; how many lines?
  261.  
  262.     mov di,[bp+12]    ; x offset of first line
  263.     mov bx,[bp+10]    ; y offset of first line
  264.     dec bl            ; adjust for 1 base
  265.     mul bl
  266.     add di,ax
  267.     dec di            ; first line offset in di
  268.  
  269.     shl si,1
  270.     shl di,1
  271.  
  272.     mov ax,si        ; save maxx * 2
  273.     add si,di        ; offset of second line in si
  274.  
  275.     push es
  276.     pop ds            ; point both at video
  277.  
  278.     mov bx,[bp+8]
  279.     sub bx,[bp+12]    ; how many columns
  280.     inc bx
  281.  
  282. l3: mov dx,bx
  283.     xchg cx,dx
  284.     push si         ; store this offset
  285.     rep movsw
  286.     pop di
  287.     mov si,ax
  288.     add si,di
  289.     xchg cx,dx
  290.     loop l3
  291.  
  292.     xchg cx,bx
  293.     mov ah,[bp-2]
  294.     mov al,20h
  295.     rep stosw
  296.  
  297.     pop ds            ; restore registers
  298.     pop si
  299.     pop di
  300.  
  301.     popf
  302.  
  303.     mov sp,bp        ; drop locals
  304.  
  305.     pop bp
  306.     ret 8
  307.  
  308. DSCROLLUP endp
  309.  
  310. DSCROLLDN proc far
  311.  
  312.     push bp
  313.     mov bp,sp
  314.  
  315.     sub sp,2        ; allocate a local
  316.  
  317.     pushf
  318.  
  319.     push di         ; save registers
  320.     push si
  321.     push ds
  322.  
  323.     cld             ; set direction to forward
  324.  
  325.     mov al,_current_color
  326.     mov [bp-2],al
  327.  
  328.     mov es,_vbase    ; point to the video screen
  329.     mov ax,_maxx    ; how many columns on the screen
  330.     mov si,ax
  331.  
  332.     mov cx,[bp+6]
  333.     sub cx,[bp+10]    ; how many lines?
  334.  
  335.     mov di,[bp+12]    ; x offset of first line
  336.     mov bx,[bp+6]    ; y offset of last line
  337.     dec bl            ; adjust for 1 base
  338.     mul bl
  339.     add di,ax
  340.     dec di            ; last line offset in si
  341.  
  342.     shl si,1
  343.     shl di,1
  344.  
  345.     mov ax,si        ; save maxx * 2
  346.     mov si,di
  347.     sub si,ax        ; offset of second to last line in di
  348.  
  349.     push es
  350.     pop ds            ; point both at video
  351.  
  352.     mov bx,[bp+8]
  353.     sub bx,[bp+12]    ; how many columns
  354.     inc bx
  355.  
  356. l4: mov dx,bx
  357.     xchg cx,dx
  358.     push si        ; store this offset
  359.     rep movsw
  360.     pop di
  361.     mov si,di
  362.     sub si,ax
  363.     xchg cx,dx
  364.     loop l4
  365.  
  366.     xchg cx,bx
  367.     mov ah,[bp-2]
  368.     mov al,20h
  369.     rep stosw
  370.  
  371.     pop ds            ; restore registers
  372.     pop si
  373.     pop di
  374.  
  375.     popf
  376.  
  377.     mov sp,bp        ; drop locals
  378.  
  379.     pop bp
  380.     ret 8
  381.  
  382. DSCROLLDN endp
  383.  
  384. end
  385.