home *** CD-ROM | disk | FTP | other *** search
- ;
- ; vrampc.asm: hterm VRAM control for IBM-PC and AX machines
- ;
- ; Author: HIRANO Satoshi (Watashiha konotameni 86no assembla wo oboeta!)
- ;
- ; (C) 1989 Halca Computer Science Laboratory TM
- ; University of Tokyo
- ;
- ; 1.1 89/07/07 Halca.Hirano converted from vram98.asm
- ; 1.2 89/07/27 Halca.Hirano far
- ; ---- V2.4.0 distribution ----
- ; 1.3 90/06/22 Halca.Hirano
- ; add soft font support functions
- ;
- ; entry getDSeg(), splx(), spl7(),
- ; putChar(), fillVRAM(), moveForward(), moveBackward()
- ; moveForByte(), moveBackByte()
- ;
- ; NOTE:
- ; structure of IBM-PC CGA/EGA/VGA VRAM :-
- ;
- ; $0000 + vramSegment
- ; | page 0 char and attribute
- ; $1fff + vramSegment
- ; $2000 + vramSegment
- ; | page 1 char and attribute
- ; $3fff + vramSegment
- ; $4000 + vramSegment
- ; | page 2 char and attribute
- ; $5fff + vramSegment
- ;
- ; one charactor is consisted of ASCII code and ATTRIBUTE code byte
- ; ASC,ATTR
- ;
- ;
- ; $Header: vrampc.asv 1.5 90/06/22 01:20:40 hirano Exp $
- ;
- ;
-
- _DATA segment word public 'DATA'
- _DATA ends
-
- extrn _vramSegment:word ; extern u_short vramSegment
- extrn _gvramSegment:word ; extern u_short gvramSegment
-
- _TEXT segment word public 'CODE'
- assume ds:_DATA,cs:_TEXT
-
- ;
- ; u_short getDSeg()
- ; return: data segment
- ;
- public _getDSeg
- _getDSeg proc far
- mov ax,ds
- ret
- _getDSeg endp
-
- ;
- ; splx(): enable interrupt
- ;
- public _splx
- _splx proc far
- sti
- ret
- _splx endp
-
- ;
- ; spl7(): disable interrupt
- ;
- public _spl7
- _spl7 proc far
- cli
- ret
- _spl7 endp
-
-
- ;
- ; void fillVRAM(at, num, data, attrib)
- ; u_short at; address to fill
- ; u_short num; number to fill
- ; u_short data; fill data
- ; u_short attrib; fill attribute
- ;
- ; put 'num' 'data's at 'at' and put num 'attrib's at attribute area
- ;
- public _fillVRAM
- _fillVRAM proc far
- push bp
- mov bp,sp
- push cx
- push di
- push es
- mov ax,[6+bp]
- mov di,ax ; di := address
- mov ax,_vramSegment
- mov es,ax ; es := VRAM segment
- mov al,[10+bp] ; al := data to fill
- mov ah,[12+bp] ; ah := attribute
- mov cx,[8+bp] ; cx := fill words
- rep stosw ; fill char
- pop es
- pop di
- pop cx
- pop bp
- ret
- _fillVRAM endp
-
- ;
- ; void moveForward(to, from, num, attribFlag)
- ; u_short to; destination address
- ; u_short from; source address
- ; u_short num; words to move
- ; int attribFlag; move attribute too (no meaning)
- ;
- ; move char and attribute 'from' 'to' 'num' chars
- ; direction is from high address to low address
- ; this procedure is used for deleteLine()
- ;
- ; note: rep mov
- ; ds,es vram segment
- ; cx count
- ; di destination address
- ; si source address
- ;
- public _moveForward
- _moveForward proc far
- push bp
- mov bp,sp
- push cx
- push si
- push di
- push ds
- push es
- mov cx,[10+bp] ; cx := count
- mov ax,[8+bp]
- mov si,ax ; si := from
- mov ax,[6+bp]
- mov di,ax ; di := to
- cld ; direction is forward
- mov ax,_vramSegment
- mov ds,ax
- mov es,ax ; es := ds := vram segment
- rep movsw ; move char
- pop es
- pop ds
- pop di
- pop si
- pop cx
- pop bp
- ret
- _moveForward endp
-
- ;
- ; void moveBackward(to, from, num, attribFlag)
- ; u_short to; destination address
- ; u_short from; source address
- ; u_short num; number of words to move
- ; int attribFlag; move attribute too (no meaning)
- ;
- ; move char and attribute 'from' 'to' 'num' chars
- ; direction is low address to high address
- ; this procedure is used in insertLine()
- ;
- public _moveBackward
- _moveBackward proc far
- push bp
- mov bp,sp
- push cx
- push si
- push di
- push ds
- push es
- mov cx,[10+bp]
- shl cx,1 ; cx := count * 2
- mov ax,[8+bp]
- mov si,ax ; si := from
- add si,cx ; si := from + count (last word + 2)
- sub si,2 ; si := last word
- mov ax,[6+bp]
- mov di,ax ; di := to
- add di,cx ; di := to + count (last word + 2)
- sub di,2 ; di := last word
- mov cx,[10+bp] ; cx := words to move
- mov ax,_vramSegment
- mov ds,ax
- mov es,ax ; es := ds := vram segment
- std ; direction is decrimental
- rep movsw ; move char
- cld
- pop es
- pop ds
- pop di
- pop si
- pop cx
- pop bp
- ret
- _moveBackward endp
-
- ;
- ; void moveForByte(to, from, num)
- ; u_short to; destination address
- ; u_short from; source address
- ; u_short num; words to move
- ;
- ; move memory in GRAM 'from' 'to' 'num' bytes
- ; direction is from high address to low address
- ; this procedure is used for softFontDeleteChar()
- ;
- ; note: rep mov
- ; ds,es vram segment
- ; cx count
- ; di destination address
- ; si source address
- ;
- public _moveForByte
- _moveForByte proc far
- push bp
- mov bp,sp
- push cx
- push si
- push di
- push ds
- push es
- mov cx,[10+bp] ; cx := count
- mov ax,[8+bp]
- mov si,ax ; si := from
- mov ax,[6+bp]
- mov di,ax ; di := to
- cld ; direction is forward
- mov ax,_gvramSegment
- mov ds,ax
- mov es,ax ; es := ds := vram segment
- rep movsb ; move char
- pop es
- pop ds
- pop di
- pop si
- pop cx
- pop bp
- ret
- _moveForByte endp
-
- ;
- ; void moveBackByte(to, from, num)
- ; u_short to; destination address
- ; u_short from; source address
- ; u_short num; number of bytes to move
- ;
- ; move GRAM memory 'from' 'to' 'num' bytes
- ; direction is low address to high address
- ; this procedure is used in softFontInsertChar()
- ;
- public _moveBackByte
- _moveBackByte proc far
- push bp
- mov bp,sp
- push cx
- push si
- push di
- push ds
- push es
- mov cx,[10+bp]
- mov ax,[8+bp]
- mov si,ax ; si := from
- add si,cx ; si := from + count (last byte + 1)
- sub si,1 ; si := last word
- mov ax,[6+bp]
- mov di,ax ; di := to
- add di,cx ; di := to + count (last byte + 1)
- sub di,1 ; di := last byte
- mov cx,[10+bp] ; cx := bytes to move
- mov ax,_gvramSegment
- mov ds,ax
- mov es,ax ; es := ds := vram segment
- std ; direction is decrimental
- rep movsb ; move char
- cld
- pop es
- pop ds
- pop di
- pop si
- pop cx
- pop bp
- ret
- _moveBackByte endp
-
- ;
- ; void moveMemory(to, toSeg, from, fromSeg, num)
- ; u_short to; destination address
- ; u_short toSeg; destination address
- ; u_short from; source address
- ; u_short fromSeg; source address
- ; u_short num; words to move
- ;
- ; note: rep mov
- ; ds,es vram segment
- ; cx count
- ; di destination address
- ; si source address
- ;
- public _moveMemory
- _moveMemory proc far
- push bp
- mov bp,sp
- push cx
- push si
- push di
- push ds
- push es
- mov cx,[14+bp] ; cx := count
- mov ax,[12+bp]
- mov ds,ax ; ds := from segment
- mov ax,[10+bp]
- mov si,ax ; si := from offset
- mov ax,[8+bp]
- mov es,ax ; es := to segment
- mov ax,[6+bp]
- mov di,ax ; di := to segment
- cld ; direction is forward
- rep movsw ; move char
- pop es
- pop ds
- pop di
- pop si
- pop cx
- pop bp
- ret
- _moveMemory endp
- _TEXT ends
- end
-