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

  1. ;
  2. ; vram98.asm: hterm VRAM control for NEC PC98xx
  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. ; 2.2 89/05/16 Halca.Hirano V2.2 distribution
  10. ; 2.3 89/06/16 Halca.Hirano rewrite entirely to more generic form
  11. ;        remove inslin(), dellin(), clcol(), etc.
  12. ; 2.4 89/07/27 Halca.Hirano far
  13. ;    ---- V2.4.0 distribution ----
  14. ;    add soft font support functions
  15. ;
  16. ;
  17. ; entry  getDSeg(), splx(), spl7(),
  18. ;    putChar(), fillVRAM(), moveForward(), moveBackward(), moveMemory()
  19. ;    moveForByte(), moveBackByte()
  20. ;
  21. ; NOTE:
  22. ;    structure of PC98 series VRAM :-
  23. ;
  24. ;    $0000 + vramSegment
  25. ;      |            page 0 text area
  26. ;    $0fff + vramSegment    
  27. ;    $1000 + vramSegment
  28. ;      |            page 1 text area
  29. ;    $1fff + vramSegment    
  30. ;    $2000 + vramSegment
  31. ;      |            page 0 attribute area
  32. ;    $2fff + vramSegment    
  33. ;    $3000 + vramSegment
  34. ;      |            page 1 attribute area
  35. ;    $3fff + vramSegment    
  36. ;
  37. ;    Each of a character and an attribute are consisted of two bytes.
  38. ;
  39. ;
  40. ; $Header: vram98.asv  1.6  90/06/22 01:19:42  hirano  Exp $
  41. ;
  42. ;
  43.  
  44. ATTRAREA equ    02000h        ; attribute area offset
  45.  
  46. _DATA    segment    word public 'DATA'
  47. _DATA    ends
  48.  
  49. extrn    _vramSegment:word    ; extern u_short vramSegment
  50. extrn    _gvramSegment:word    ; extern u_short gvramSegment
  51. _TEXT    segment    word public 'CODE'
  52.     assume    ds:_DATA,cs:_TEXT
  53.  
  54. ;
  55. ; u_short getDSeg()
  56. ; return:    data segment
  57. ;
  58.     public    _getDSeg
  59. _getDSeg proc    far
  60.     mov    ax,ds
  61.     ret
  62. _getDSeg endp
  63.  
  64. ;
  65. ; splx():    enable interrupt
  66. ;
  67.     public    _splx
  68. _splx    proc far
  69.     sti
  70.     ret
  71. _splx    endp
  72. ;
  73. ; spl7():    disable interrupt
  74. ;
  75.     public    _spl7
  76. _spl7    proc    far
  77.     cli
  78.     ret
  79. _spl7    endp
  80.     
  81. ;
  82. ; void fillVRAM(at, num, data, attrib)
  83. ; u_short at;        address to fill
  84. ; u_short num;        number to fill
  85. ; u_short data;        fill data
  86. ; u_short attrib;    fill attribute
  87. ;
  88. ; put 'num' 'data's at 'at' and put num 'attrib's at attribute area
  89. ;
  90.     public _fillVRAM
  91. _fillVRAM proc    far
  92.     push    bp
  93.     mov    bp,sp
  94.     push    cx
  95.     push    di
  96.     push    es
  97.     mov    ax,[6+bp]
  98.     mov    di,ax            ; di := address
  99.     mov    ax,_vramSegment
  100.     mov    es,ax            ; es := VRAM segment
  101.     mov    ax,[10+bp]        ; ax := data to fill
  102.     mov    cx,[8+bp]        ; cx := fill words
  103.     push    di
  104.     push    cx
  105.     rep    stosw            ; fill char
  106.     pop    cx
  107.     pop    di
  108.     add    di,ATTRAREA
  109.     mov    ax,[12+bp]        ; ax := attribute to fill
  110.     rep    stosw            ; fill attribute
  111.     pop    es
  112.     pop    di
  113.     pop    cx
  114.     pop    bp
  115.     ret
  116. _fillVRAM endp
  117.  
  118. ;
  119. ; void moveForward(to, from, num, attribFlag)
  120. ; u_short to;        destination address
  121. ; u_short from;        source address
  122. ; u_short num;        words to move
  123. ; int attribFlag    also move attribute
  124. ;
  125. ; move char and attribute 'from' 'to' 'num' chars
  126. ;  direction is from high address to low address
  127. ; this procedure is used for deleteLine() or softFontDeleteLine()
  128. ; if attribFlag is not zero, move attribute too
  129. ;
  130. ; note: rep mov   
  131. ;        ds,es    vram segment
  132. ;        cx        count
  133. ;        di        destination address
  134. ;        si        source address
  135. ;
  136.     public    _moveForward
  137. _moveForward proc far
  138.     push    bp
  139.     mov    bp,sp
  140.     push    cx
  141.     push    si
  142.     push    di
  143.     push    ds
  144.     push    es
  145.     mov    cx,[10+bp]        ; cx := count
  146.     mov    ax,[8+bp]
  147.     mov    si,ax            ; si := from
  148.     mov    ax,[6+bp]
  149.     mov    di,ax            ; di := to
  150.     cld                ; direction is forward
  151.     mov    ax,_vramSegment
  152.     mov    ds,ax
  153.     mov    es,ax            ; es := ds := vram segment
  154.     push    cx
  155.     push    di
  156.     push    si
  157.     rep    movsw            ; move char
  158.     pop    si
  159.     pop    di
  160.     pop    cx
  161.     mov    ax,[12+bp]        ; ? move attribute
  162.     cmp ax,0
  163.     je    movef2            ; bra if no
  164.     mov    ax,ATTRAREA
  165.     add    di,ax
  166.     add    si,ax
  167.     rep    movsw            ; move attribute
  168. movef2:
  169.     pop    es
  170.     pop    ds
  171.     pop    di
  172.     pop    si
  173.     pop    cx
  174.     pop    bp
  175.     ret    
  176. _moveForward endp
  177.  
  178. ;
  179. ; void moveBackward(to, from, num, attribFlag)
  180. ; u_short to;        destination address
  181. ; u_short from;        source address
  182. ; u_short num;        number of words to move
  183. ; int attribFlag    also move attribute
  184. ;
  185. ; move char and attribute 'from' 'to' 'num' chars
  186. ;  direction is low address to high address
  187. ; this procedure is used in insertLine() or softFontInsertLine()
  188. ; if attribFlag is not zero, move attribute too
  189. ;
  190.     public    _moveBackward
  191. _moveBackward proc far
  192.     push    bp
  193.     mov    bp,sp
  194.     push    cx
  195.     push    si
  196.     push    di
  197.     push    ds
  198.     push    es
  199.     mov    cx,[10+bp]
  200.     shl    cx,1            ; cx := count * 2
  201.     mov    ax,[8+bp]
  202.     mov    si,ax            ; si := from
  203.     add    si,cx            ; si := from + count (last word + 2)
  204.     sub    si,2            ; si := last word
  205.     mov    ax,[6+bp]
  206.     mov    di,ax            ; di := to
  207.     add    di,cx            ; di := to + count (last word + 2)
  208.     sub    di,2            ; di := last word
  209.     mov    cx,[10+bp]        ; cx := words to move
  210.     mov    ax,_vramSegment
  211.     mov    ds,ax
  212.     mov    es,ax            ; es := ds := vram segment
  213.     push    di
  214.     push    si
  215.     push    cx
  216.     std                ; direction is decrimental
  217.     rep    movsw            ; move char
  218.     pop    cx
  219.     pop    si
  220.     pop    di
  221.     mov    ax,[12+bp]        ; ? move attribute
  222.     cmp    ax,0
  223.     je    moveb2            ; bra if no
  224.     mov    ax,ATTRAREA
  225.     add    si,ax
  226.     add    di,ax
  227.     rep    movsw            ; move attribute
  228. moveb2:
  229.     cld
  230.     pop    es
  231.     pop    ds
  232.     pop    di
  233.     pop    si
  234.     pop    cx
  235.     pop    bp
  236.     ret    
  237. _moveBackward endp
  238.      
  239. ;
  240. ; void moveForByte(to, from, num)
  241. ; u_short to;        destination address
  242. ; u_short from;        source address
  243. ; u_short num;        words to move
  244. ;
  245. ; move memory in GRAM 'from' 'to' 'num' bytes
  246. ;  direction is from high address to low address
  247. ; this procedure is used for softFontDeleteChar()
  248. ;
  249. ; note: rep mov   
  250. ;        ds,es    vram segment
  251. ;        cx        count
  252. ;        di        destination address
  253. ;        si        source address
  254. ;
  255.     public    _moveForByte
  256. _moveForByte proc far
  257.     push    bp
  258.     mov    bp,sp
  259.     push    cx
  260.     push    si
  261.     push    di
  262.     push    ds
  263.     push    es
  264.     mov    cx,[10+bp]        ; cx := count
  265.     mov    ax,[8+bp]
  266.     mov    si,ax            ; si := from
  267.     mov    ax,[6+bp]
  268.     mov    di,ax            ; di := to
  269.     cld                ; direction is forward
  270.     mov    ax,_gvramSegment
  271.     mov    ds,ax
  272.     mov    es,ax            ; es := ds := vram segment
  273.     rep    movsb            ; move char
  274.     pop    es
  275.     pop    ds
  276.     pop    di
  277.     pop    si
  278.     pop    cx
  279.     pop    bp
  280.     ret    
  281. _moveForByte endp
  282.  
  283. ;
  284. ; void moveBackByte(to, from, num)
  285. ; u_short to;        destination address
  286. ; u_short from;        source address
  287. ; u_short num;        number of bytes to move
  288. ;
  289. ; move GRAM memory 'from' 'to' 'num' bytes
  290. ;  direction is low address to high address
  291. ; this procedure is used in softFontInsertChar()
  292. ;
  293.     public    _moveBackByte
  294. _moveBackByte proc far
  295.     push    bp
  296.     mov        bp,sp
  297.     push    cx
  298.     push    si
  299.     push    di
  300.     push    ds
  301.     push    es
  302.     mov    cx,[10+bp]
  303.     mov    ax,[8+bp]
  304.     mov    si,ax            ; si := from
  305.     add    si,cx            ; si := from + count (last byte + 1)
  306.     sub    si,1            ; si := last word
  307.     mov    ax,[6+bp]
  308.     mov    di,ax            ; di := to
  309.     add    di,cx            ; di := to + count (last byte + 1)
  310.     sub    di,1            ; di := last byte
  311.     mov    cx,[10+bp]        ; cx := bytes to move
  312.     mov    ax,_gvramSegment
  313.     mov    ds,ax
  314.     mov    es,ax            ; es := ds := vram segment
  315.     std                    ; direction is decrimental
  316.     rep    movsb            ; move char
  317.     cld
  318.     pop    es
  319.     pop    ds
  320.     pop    di
  321.     pop    si
  322.     pop    cx
  323.     pop    bp
  324.     ret    
  325. _moveBackByte endp
  326.      
  327. ;
  328. ; void moveMemory(to, toSeg, from, fromSeg, num)
  329. ; u_short to;        destination address
  330. ; u_short toSeg;    destination address
  331. ; u_short from;        source address
  332. ; u_short fromSeg;    source address
  333. ; u_short num;        words to move
  334. ;
  335. ; note: rep mov   
  336. ;        ds,es    vram segment
  337. ;        cx        count
  338. ;        di        destination address
  339. ;        si        source address
  340. ;
  341.     public    _moveMemory
  342. _moveMemory proc far
  343.     push    bp
  344.     mov    bp,sp
  345.     push    cx
  346.     push    si
  347.     push    di
  348.     push    ds
  349.     push    es
  350.     mov    cx,[14+bp]        ; cx := count
  351.     mov    ax,[12+bp]
  352.     mov    ds,ax            ; ds := from segment
  353.     mov    ax,[10+bp]
  354.     mov    si,ax            ; si := from offset
  355.     mov    ax,[8+bp]
  356.     mov    es,ax            ; es := to segment
  357.     mov    ax,[6+bp]
  358.     mov    di,ax            ; di := to segment
  359.     cld                ; direction is forward
  360.     rep    movsw            ; move char
  361.     pop    es
  362.     pop    ds
  363.     pop    di
  364.     pop    si
  365.     pop    cx
  366.     pop    bp
  367.     ret    
  368. _moveMemory endp
  369. _TEXT   ends
  370.     end
  371.