home *** CD-ROM | disk | FTP | other *** search
- ;
- ; vram98.asm: hterm VRAM control for NEC PC98xx
- ;
- ; Author: HIRANO Satoshi (Watashiha konotameni 86no assembla wo oboeta!)
- ;
- ; (C) 1989 Halca Computer Science Laboratory TM
- ; University of Tokyo
- ;
- ; 2.2 89/05/16 Halca.Hirano V2.2 distribution
- ; 2.3 89/06/16 Halca.Hirano rewrite entirely to more generic form
- ; remove inslin(), dellin(), clcol(), etc.
- ; 2.4 89/07/27 Halca.Hirano far
- ; ---- V2.4.0 distribution ----
- ; add soft font support functions
- ;
- ;
- ; entry getDSeg(), splx(), spl7(),
- ; putChar(), fillVRAM(), moveForward(), moveBackward(), moveMemory()
- ; moveForByte(), moveBackByte()
- ;
- ; NOTE:
- ; structure of PC98 series VRAM :-
- ;
- ; $0000 + vramSegment
- ; | page 0 text area
- ; $0fff + vramSegment
- ; $1000 + vramSegment
- ; | page 1 text area
- ; $1fff + vramSegment
- ; $2000 + vramSegment
- ; | page 0 attribute area
- ; $2fff + vramSegment
- ; $3000 + vramSegment
- ; | page 1 attribute area
- ; $3fff + vramSegment
- ;
- ; Each of a character and an attribute are consisted of two bytes.
- ;
- ;
- ; $Header: vram98.asv 1.6 90/06/22 01:19:42 hirano Exp $
- ;
- ;
-
- ATTRAREA equ 02000h ; attribute area offset
-
- _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 ax,[10+bp] ; ax := data to fill
- mov cx,[8+bp] ; cx := fill words
- push di
- push cx
- rep stosw ; fill char
- pop cx
- pop di
- add di,ATTRAREA
- mov ax,[12+bp] ; ax := attribute to fill
- rep stosw ; fill attribute
- 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 also move attribute
- ;
- ; move char and attribute 'from' 'to' 'num' chars
- ; direction is from high address to low address
- ; this procedure is used for deleteLine() or softFontDeleteLine()
- ; if attribFlag is not zero, move attribute too
- ;
- ; 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
- push cx
- push di
- push si
- rep movsw ; move char
- pop si
- pop di
- pop cx
- mov ax,[12+bp] ; ? move attribute
- cmp ax,0
- je movef2 ; bra if no
- mov ax,ATTRAREA
- add di,ax
- add si,ax
- rep movsw ; move attribute
- movef2:
- 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 also move attribute
- ;
- ; move char and attribute 'from' 'to' 'num' chars
- ; direction is low address to high address
- ; this procedure is used in insertLine() or softFontInsertLine()
- ; if attribFlag is not zero, move attribute too
- ;
- 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
- push di
- push si
- push cx
- std ; direction is decrimental
- rep movsw ; move char
- pop cx
- pop si
- pop di
- mov ax,[12+bp] ; ? move attribute
- cmp ax,0
- je moveb2 ; bra if no
- mov ax,ATTRAREA
- add si,ax
- add di,ax
- rep movsw ; move attribute
- moveb2:
- 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
-