home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / vol_300 / 334_01 / corgraph.asm < prev    next >
Assembly Source File  |  1991-02-05  |  2KB  |  168 lines

  1. TITLE    Corona graphics module
  2. ;    Colin Kelley
  3. ;    January 1987
  4.  
  5. include header.mac
  6.  
  7. if1
  8. include lineproc.mac
  9. endif
  10.  
  11.  
  12. _text    segment
  13.  
  14. public    _GrInit,_GrReset,_GrOnly,_TxOnly,_GrandTx,_Cor_line,_Cor_mask
  15.  
  16. corpixel proc near
  17.     ror word ptr linemask,1
  18.     jc cont
  19.     ret
  20. cont:    push bp
  21.     mov bp,sp
  22.     push ax
  23.     push bx
  24.     push cx
  25.     mov es,ScSeg
  26.     shl bx,1            ; y
  27.     mov bx,word ptr LookUp[bx] ; bx has y mem address
  28.     mov cl,al            ; x
  29.     and cl,7
  30.     shr ax,1
  31.     shr ax,1
  32.     shr ax,1            ; ax /= 8
  33.     add bx,ax
  34.     mov al,1
  35.     shl al,cl            ; al contains bit mask
  36.     or byte ptr es:[bx],al
  37.     pop cx
  38.     pop bx
  39.     pop ax
  40.     pop bp
  41.     ret
  42.  
  43. lineproc _Cor_line, corpixel
  44.  
  45. beginproc _GrInit
  46.     push bp
  47.     mov bp,sp
  48.     push di
  49.     mov ax, [bp+X]            ; screen number (0 - 7)
  50.     mov cl,11
  51.     shl ax,cl            ; multiply by 2048 to get segment
  52.     mov ScSeg,ax            ; save segment for later
  53.     push ax
  54.     mov es, ax
  55.     xor ax,ax
  56.     mov di,ax
  57.     mov cx, 4000h
  58.     cld
  59.     rep stosw
  60.     pop cx
  61.     call near ptr GrAddr
  62.     mov ax,es
  63.     pop di
  64.     pop bp
  65.     ret
  66. _GrInit    endp
  67.  
  68. beginproc _GrReset
  69.     mov cx, 0
  70.     call near ptr GrAddr
  71.     ret
  72. _GrReset endp
  73.  
  74. GrAddr    proc near
  75.     mov dx,3b4h            ; address of 6845
  76.     mov al,0ch            ; register 12
  77.     out dx,al
  78.     inc dx
  79.     mov al,ch            ; Graphics Segment High
  80.     out dx,al
  81.     dec dx
  82.     mov al,0dh            ; register 13
  83.     out dx,al
  84.     mov al,cl            ; Graphics Segment Low
  85.     inc dx
  86.     out dx,al
  87.     ret
  88. GrAddr    endp
  89.  
  90. beginproc _GrOnly
  91.     mov dx,3b8h
  92.     mov al,0a0h
  93.     out dx,al
  94.     ret
  95. _GrOnly    endp
  96.  
  97. beginproc _TxOnly
  98.     mov dx,3b8h
  99.     mov al,28h
  100.     out dx,al
  101.     ret
  102. _TxOnly    endp
  103.  
  104. beginproc _GrandTx
  105.     mov dx,3b8h
  106.     mov al,0a8h
  107.     out dx,al
  108.     ret
  109. _GrandTx endp
  110.  
  111. beginproc _Cor_mask
  112.     push bp
  113.     mov bp,sp
  114.     mov ax,[bp+x]            ; mask
  115.     mov linemask,ax
  116.     pop bp
  117.     ret
  118. _Cor_mask endp
  119.  
  120. corpixel endp
  121.  
  122. _text    ends
  123.  
  124.  
  125. _data    segment
  126. linemask dw -1
  127. ScSeg    dw 0
  128. _data    ends
  129.  
  130. const    segment
  131.  
  132. K    equ 1024
  133.  
  134. mem_mac    MACRO x
  135.     dw x,2*K+x,4*K+x,6*K+x,8*K+x,10*K+x,12*K+x,14*K+x,16*K+x
  136.     dw 18*K+x,20*K+x,22*K+x,24*K+x
  137.     ENDM
  138. LookUp    equ $
  139.     mem_mac 0
  140.     mem_mac 80
  141.     mem_mac (80*2)
  142.     mem_mac (80*3)
  143.     mem_mac (80*4)
  144.     mem_mac (80*5)
  145.     mem_mac (80*6)
  146.     mem_mac (80*7)
  147.     mem_mac (80*8)
  148.     mem_mac (80*9)
  149.     mem_mac (80*10)
  150.     mem_mac (80*11)
  151.     mem_mac (80*12)
  152.     mem_mac (80*13)
  153.     mem_mac (80*14)
  154.     mem_mac (80*15)
  155.     mem_mac (80*16)
  156.     mem_mac (80*17)
  157.     mem_mac (80*18)
  158.     mem_mac (80*19)
  159.     mem_mac (80*20)
  160.     mem_mac (80*21)
  161.     mem_mac (80*22)
  162.     mem_mac (80*23)
  163.     mem_mac (80*24)
  164.  
  165. const    ends
  166.  
  167.     end
  168.