home *** CD-ROM | disk | FTP | other *** search
/ ProfitPress Mega CDROM2 …eeware (MSDOS)(1992)(Eng) / ProfitPress-MegaCDROM2.B6I / COMM / MISC / SRC26_2.ZIP / SRC / VRAMPC.ASM < prev    next >
Encoding:
Assembly Source File  |  1990-06-22  |  6.6 KB  |  332 lines

  1. ;
  2. ; vrampc.asm: hterm VRAM control for IBM-PC and AX machines
  3. ;
  4. ; Author: HIRANO Satoshi (Watashiha konotameni 86no assembla wo oboeta!)
  5. ;
  6. ; (C) 1989  Halca Computer Science Laboratory TM
  7. ;           University of Tokyo
  8. ;
  9. ; 1.1 89/07/07 Halca.Hirano converted from vram98.asm
  10. ; 1.2 89/07/27 Halca.Hirano far
  11. ;    ---- V2.4.0 distribution ----
  12. ; 1.3 90/06/22 Halca.Hirano
  13. ;    add soft font support functions
  14. ;
  15. ; entry  getDSeg(), splx(), spl7(),
  16. ;    putChar(), fillVRAM(), moveForward(), moveBackward()
  17. ;    moveForByte(), moveBackByte()
  18. ;
  19. ; NOTE:
  20. ;    structure of IBM-PC CGA/EGA/VGA VRAM :-
  21. ;
  22. ;    $0000 + vramSegment
  23. ;      |            page 0 char and attribute
  24. ;    $1fff + vramSegment    
  25. ;    $2000 + vramSegment
  26. ;      |            page 1 char and attribute
  27. ;    $3fff + vramSegment    
  28. ;    $4000 + vramSegment
  29. ;      |            page 2 char and attribute
  30. ;    $5fff + vramSegment    
  31. ;
  32. ;    one charactor is consisted of ASCII code and ATTRIBUTE code byte
  33. ;    ASC,ATTR
  34. ;
  35. ;
  36. ; $Header: vrampc.asv  1.5  90/06/22 01:20:40  hirano  Exp $
  37. ;
  38. ;
  39.  
  40. _DATA    segment    word public 'DATA'
  41. _DATA    ends
  42.  
  43. extrn    _vramSegment:word    ; extern u_short vramSegment
  44. extrn    _gvramSegment:word    ; extern u_short gvramSegment
  45.  
  46. _TEXT    segment    word public 'CODE'
  47.     assume    ds:_DATA,cs:_TEXT
  48.  
  49. ;
  50. ; u_short getDSeg()
  51. ; return:    data segment
  52. ;
  53.     public    _getDSeg
  54. _getDSeg proc    far
  55.     mov    ax,ds
  56.     ret
  57. _getDSeg endp
  58.  
  59. ;
  60. ; splx():    enable interrupt
  61. ;
  62.     public    _splx
  63. _splx    proc    far
  64.     sti
  65.     ret
  66. _splx    endp
  67.  
  68. ;
  69. ; spl7():    disable interrupt
  70. ;
  71.     public    _spl7
  72. _spl7    proc    far
  73.     cli
  74.     ret
  75. _spl7    endp
  76.     
  77.  
  78. ;
  79. ; void fillVRAM(at, num, data, attrib)
  80. ; u_short at;        address to fill
  81. ; u_short num;        number to fill
  82. ; u_short data;        fill data
  83. ; u_short attrib;    fill attribute
  84. ;
  85. ; put 'num' 'data's at 'at' and put num 'attrib's at attribute area
  86. ;
  87.     public _fillVRAM
  88. _fillVRAM proc    far
  89.     push    bp
  90.     mov    bp,sp
  91.     push    cx
  92.     push    di
  93.     push    es
  94.     mov    ax,[6+bp]
  95.     mov    di,ax            ; di := address
  96.     mov    ax,_vramSegment
  97.     mov    es,ax            ; es := VRAM segment
  98.     mov    al,[10+bp]        ; al := data to fill
  99.     mov    ah,[12+bp]        ; ah := attribute
  100.     mov    cx,[8+bp]        ; cx := fill words
  101.     rep    stosw            ; fill char
  102.     pop    es
  103.     pop    di
  104.     pop    cx
  105.     pop    bp
  106.     ret
  107. _fillVRAM endp
  108.  
  109. ;
  110. ; void moveForward(to, from, num, attribFlag)
  111. ; u_short to;        destination address
  112. ; u_short from;        source address
  113. ; u_short num;        words to move
  114. ; int attribFlag;    move attribute too (no meaning)
  115. ;
  116. ; move char and attribute 'from' 'to' 'num' chars
  117. ;  direction is from high address to low address
  118. ; this procedure is used for deleteLine()
  119. ;
  120. ; note: rep mov   
  121. ;        ds,es    vram segment
  122. ;        cx        count
  123. ;        di        destination address
  124. ;        si        source address
  125. ;
  126.     public    _moveForward
  127. _moveForward proc    far
  128.     push    bp
  129.     mov    bp,sp
  130.     push    cx
  131.     push    si
  132.     push    di
  133.     push    ds
  134.     push    es
  135.     mov    cx,[10+bp]        ; cx := count
  136.     mov    ax,[8+bp]
  137.     mov    si,ax            ; si := from
  138.     mov    ax,[6+bp]
  139.     mov    di,ax            ; di := to
  140.     cld                ; direction is forward
  141.     mov    ax,_vramSegment
  142.     mov    ds,ax
  143.     mov    es,ax            ; es := ds := vram segment
  144.     rep    movsw            ; move char
  145.     pop    es
  146.     pop    ds
  147.     pop    di
  148.     pop    si
  149.     pop    cx
  150.     pop    bp
  151.     ret    
  152. _moveForward endp
  153.  
  154. ;
  155. ; void moveBackward(to, from, num, attribFlag)
  156. ; u_short to;        destination address
  157. ; u_short from;        source address
  158. ; u_short num;        number of words to move
  159. ; int attribFlag;    move attribute too (no meaning)
  160. ;
  161. ; move char and attribute 'from' 'to' 'num' chars
  162. ;  direction is low address to high address
  163. ; this procedure is used in insertLine()
  164. ;
  165.     public    _moveBackward
  166. _moveBackward proc far
  167.     push    bp
  168.     mov    bp,sp
  169.     push    cx
  170.     push    si
  171.     push    di
  172.     push    ds
  173.     push    es
  174.     mov    cx,[10+bp]
  175.     shl    cx,1            ; cx := count * 2
  176.     mov    ax,[8+bp]
  177.     mov    si,ax            ; si := from
  178.     add    si,cx            ; si := from + count (last word + 2)
  179.     sub    si,2            ; si := last word
  180.     mov    ax,[6+bp]
  181.     mov    di,ax            ; di := to
  182.     add    di,cx            ; di := to + count (last word + 2)
  183.     sub    di,2            ; di := last word
  184.     mov    cx,[10+bp]        ; cx := words to move
  185.     mov    ax,_vramSegment
  186.     mov    ds,ax
  187.     mov    es,ax            ; es := ds := vram segment
  188.     std                ; direction is decrimental
  189.     rep    movsw            ; move char
  190.     cld
  191.     pop    es
  192.     pop    ds
  193.     pop    di
  194.     pop    si
  195.     pop    cx
  196.     pop    bp
  197.     ret    
  198. _moveBackward endp
  199.      
  200. ;
  201. ; void moveForByte(to, from, num)
  202. ; u_short to;        destination address
  203. ; u_short from;        source address
  204. ; u_short num;        words to move
  205. ;
  206. ; move memory in GRAM 'from' 'to' 'num' bytes
  207. ;  direction is from high address to low address
  208. ; this procedure is used for softFontDeleteChar()
  209. ;
  210. ; note: rep mov   
  211. ;        ds,es    vram segment
  212. ;        cx        count
  213. ;        di        destination address
  214. ;        si        source address
  215. ;
  216.     public    _moveForByte
  217. _moveForByte proc far
  218.     push    bp
  219.     mov    bp,sp
  220.     push    cx
  221.     push    si
  222.     push    di
  223.     push    ds
  224.     push    es
  225.     mov    cx,[10+bp]        ; cx := count
  226.     mov    ax,[8+bp]
  227.     mov    si,ax            ; si := from
  228.     mov    ax,[6+bp]
  229.     mov    di,ax            ; di := to
  230.     cld                ; direction is forward
  231.     mov    ax,_gvramSegment
  232.     mov    ds,ax
  233.     mov    es,ax            ; es := ds := vram segment
  234.     rep    movsb            ; move char
  235.     pop    es
  236.     pop    ds
  237.     pop    di
  238.     pop    si
  239.     pop    cx
  240.     pop    bp
  241.     ret    
  242. _moveForByte endp
  243.  
  244. ;
  245. ; void moveBackByte(to, from, num)
  246. ; u_short to;        destination address
  247. ; u_short from;        source address
  248. ; u_short num;        number of bytes to move
  249. ;
  250. ; move GRAM memory 'from' 'to' 'num' bytes
  251. ;  direction is low address to high address
  252. ; this procedure is used in softFontInsertChar()
  253. ;
  254.     public    _moveBackByte
  255. _moveBackByte proc far
  256.     push    bp
  257.     mov        bp,sp
  258.     push    cx
  259.     push    si
  260.     push    di
  261.     push    ds
  262.     push    es
  263.     mov    cx,[10+bp]
  264.     mov    ax,[8+bp]
  265.     mov    si,ax            ; si := from
  266.     add    si,cx            ; si := from + count (last byte + 1)
  267.     sub    si,1            ; si := last word
  268.     mov    ax,[6+bp]
  269.     mov    di,ax            ; di := to
  270.     add    di,cx            ; di := to + count (last byte + 1)
  271.     sub    di,1            ; di := last byte
  272.     mov    cx,[10+bp]        ; cx := bytes to move
  273.     mov    ax,_gvramSegment
  274.     mov    ds,ax
  275.     mov    es,ax            ; es := ds := vram segment
  276.     std                    ; direction is decrimental
  277.     rep    movsb            ; move char
  278.     cld
  279.     pop    es
  280.     pop    ds
  281.     pop    di
  282.     pop    si
  283.     pop    cx
  284.     pop    bp
  285.     ret    
  286. _moveBackByte endp
  287.  
  288. ;
  289. ; void moveMemory(to, toSeg, from, fromSeg, num)
  290. ; u_short to;        destination address
  291. ; u_short toSeg;    destination address
  292. ; u_short from;        source address
  293. ; u_short fromSeg;    source address
  294. ; u_short num;        words to move
  295. ;
  296. ; note: rep mov   
  297. ;        ds,es    vram segment
  298. ;        cx        count
  299. ;        di        destination address
  300. ;        si        source address
  301. ;
  302.     public    _moveMemory
  303. _moveMemory proc far
  304.     push    bp
  305.     mov    bp,sp
  306.     push    cx
  307.     push    si
  308.     push    di
  309.     push    ds
  310.     push    es
  311.     mov    cx,[14+bp]        ; cx := count
  312.     mov    ax,[12+bp]
  313.     mov    ds,ax            ; ds := from segment
  314.     mov    ax,[10+bp]
  315.     mov    si,ax            ; si := from offset
  316.     mov    ax,[8+bp]
  317.     mov    es,ax            ; es := to segment
  318.     mov    ax,[6+bp]
  319.     mov    di,ax            ; di := to segment
  320.     cld                ; direction is forward
  321.     rep    movsw            ; move char
  322.     pop    es
  323.     pop    ds
  324.     pop    di
  325.     pop    si
  326.     pop    cx
  327.     pop    bp
  328.     ret    
  329. _moveMemory endp
  330. _TEXT   ends
  331.     end
  332.