home *** CD-ROM | disk | FTP | other *** search
-
- ; module: vlib
- ; programmer: Ray L. McVay
- ; started: 10 Oct 82
- ; version: 2.01, 3 Aug 84
- ; version: 2.1, 13 Jun 86 Larry A. Thiel
- ;
- ; A library of c bios video functions originally written to
- ; replace the int10() function of small-c:PC.
-
- ; history:
- ; 1.0 small-c:PC version
- ; 2.0 ported to DeSmet c
- ; 2.1 added get_page_, get_curtyp_, kbd_ci_, and kbd_csts
-
- ; Calling convention for DeSmet is to push parameters
- ; rightmost first then do an intrasegment call to the
- ; function.
-
- ; Char's, int's and unsigned's are returned in AX.
- ; Long's are returned in DX:AX.
-
- ; CS, DS, SS, SP and BP should be preserved.
-
- CSEG
- VIDEO EQU 16 ;BIOS video interrupt
-
-
- ; get video mode
- ; int get_mode();
-
- PUBLIC GET_MODE_
- GET_MODE_:
- mov ah,15
- int VIDEO
- cbw
- ret
-
-
- ; get video page
- ; int get_page();
-
- PUBLIC GET_PAGE_
- GET_PAGE_:
- mov ah,15
- int VIDEO
- mov al,bh
- cbw
- ret
-
-
- ; set video mode
- ; void set_mode(mode)
- ; int mode;
-
- PUBLIC SET_MODE_
- SET_MODE_:
- push bp
- mov bp,sp
- mov al,[bp+4]
- mov ah,0
- INT VIDEO
- pop bp
- RET
-
-
- ; set cursor type
- ; void set_curtyp(start,end)
- ; int start,end;
- ; Note: if start > end then cursor is turned off.
-
- PUBLIC SET_CURTYP_
- SET_CURTYP_:
- push bp
- mov bp,sp
- mov ch,[bp+4] ; top line
- mov cl,[bp+6] ; bottom line
- mov ah,1
- INT VIDEO
- pop bp
- RET
-
-
- ; read cursor type
- ; int get_curtyp(page)
- ; int page;
- ; startline = get_curtyp(page) & 255; /* also contains blink, etc. flags */
- ; endline = get_curtyp(page) >> 8;
-
- PUBLIC GET_CURTYP_
- GET_CURTYP_:
- push bp
- mov bp,sp
- mov bh,[bp+4] ;BH = page
- MOV AH,3
- INT VIDEO
- MOV AX,CX ;return(256*row+column)
- pop bp
- RET
-
-
- ; gotoxy - set cursor position
- ; void gotoxy(x, y, page)
- ; int x,y,page;
-
- PUBLIC GOTOXY_
- GOTOXY_:
- push bp
- mov bp,sp
- mov dl,[bp+4] ; DL = x = column
- mov dh,[bp+6] ; DH = y = row
- mov bh,[bp+8] ; BH = page
- mov ah,2
- INT VIDEO
- pop bp
- RET
-
-
- ; read cursor position
- ; int getxy(page)
- ; int page;
- ; xpos = getxy(page) & 255;
- ; ypos = getxy(page) >> 8;
-
- PUBLIC GETXY_
- GETXY_:
- push bp
- mov bp,sp
- mov bh,[bp+4] ;BH = page
- MOV AH,3
- INT VIDEO
- MOV AX,DX ;return(256*row+column)
- pop bp
- RET
-
-
- ; get light pen position
- ; int gltpen(buff)
- ; int buff[4];
- ; Note: Returns 0 if pen was not triggered, 1 if it was.
- ; Stores XY values in integer array at buff.
-
- PUBLIC GLTPEN_
- GLTPEN_:
- push bp
- mov bp,sp
- MOV AH,4
- INT VIDEO
- OR AH,AH ;check status
- JZ DOSTAT ;it was bad
- mov si,[bp+4] ;get addres of buffer
- MOV [SI],BX ;buff[0]=X for graphics
- MOV [SI]+2,CH ;buff[1]=Y
- MOV [SI]+4,DL ;buff[2]=X for text
- MOV [SI]+6,DH ;buff[3]=Y for text
- MOV AH,1 ;return OK status
- DOSTAT:
- MOV AL,AH
- CBW
- pop bp
- RET
-
-
- ; select active page
- ; void setpage(page)
- ; int page;
-
- PUBLIC SETPAGE_
- SETPAGE_:
- push bp
- mov bp,sp
- mov al,[bp+4] ;page
- MOV AH,5
- INT VIDEO
- pop bp
- RET
-
-
- ; scroll a window up
- ; void scrlup(window,count,attrib)
- ; int window[4],count,attrib;
- ; Note: Window defines the upper-left and lower-right
- ; character positions of an area of the text screen.
- ; A count of 0 clears the window.
- ; The attribute is used on the line(s) blanked.
-
- PUBLIC SCRLUP_
- SCRLUP_:
- push bp
- CALL SCRL1
- MOV AH,6
- INT VIDEO
- pop bp
- RET
-
- SCRL1: mov bp,sp
- mov bx,[bp+6] ;get base of window array
- MOV CL,[bx] ;window[0] = U.L. X
- MOV CH,[bx]+2 ;window[1] = U.L. Y
- MOV DL,[bx]+4 ;window[2] = L.R. X
- MOV DH,[bx]+6 ;window[3] = L.R. Y
- mov al,[bp+8] ;AL = count
- mov bh,[bp+10] ;BH = attribute
- RET
-
-
- ; scroll a window down
- ; void scrldn(window,count,attrib)
- ; int window[4],count,attrib;
-
- PUBLIC SCRLDN_
- SCRLDN_:
- push bp
- CALL SCRL1
- MOV AH,7
- INT VIDEO
- pop bp
- RET
-
-
- ; read character & attribute under the cursor
- ; int vgetc(page)
- ; int page;
-
- PUBLIC VGETC_
- VGETC_:
- push bp
- mov bp,sp
- MOV BH,[bp+4]
- MOV AH,8
- INT VIDEO
- pop bp
- RET
-
-
- ; write character & attribute at cursor
- ; void vputca(chr,page,count)
- ; int chr,page,count;
- ; Note: Chr contains attribute in hi byte.
- ; Count is the number of times to write the character.
- ; (Good for tops and bottoms of windows or boxes.)
-
- PUBLIC VPUTCA_
- VPUTCA_:
- push bp
- CALL VPUT1
- MOV AH,9
- INT VIDEO
- pop bp
- RET
-
- VPUT1:
- mov bp,sp
- mov AX,[bp+6] ;attrib/char
- mov bh,[bp+8] ;page
- mov CX,[bp+10] ;count
- MOV BL,AH ;attrib to BL
- RET
-
-
- ; vputc - write character only at cursor
- ; void vputc(chr,page,count)
- ; int chr,page,count;
- ; Note: Same as vputca() except uses existing attributes.
-
- PUBLIC VPUTC_
- VPUTC_:
- push bp
- CALL VPUT1
- MOV AH,10
- INT VIDEO
- pop bp
- RET
-
-
- ; set background or pallet or alpha border color
- ; void pcolor(id,val)
- ; int id,val;
- ; Note: If id == 0 then val is background color.
- ; If id == 1 and mode is graphics then val is pallet.
- ; If id == 1 and mode is text then val is border.
-
- PUBLIC PCOLOR_
- PCOLOR_:
- push bp
- mov bp,sp
- mov bh,[bp+4] ;id
- mov bl,[bp+6] ;val
- MOV AH,11
- INT VIDEO
- pop bp
- RET
-
-
- ; write a graphics dot
- ; void plot(color,horz,vert)
- ; int color,horz,vert;
-
- PUBLIC PLOT_
- PLOT_:
- push bp
- CALL SETDOT
- MOV AH,12
- INT VIDEO
- pop bp
- RET
-
- SETDOT:
- mov bp,sp
- mov AX,[bp+6] ;color
- mov CX,[bp+8] ;horiz
- mov DX,[bp+10] ;vert
- RET
-
-
- ; read a graphic dot color
- ; int get_dot(dummy,horz,vert)
- ; int dummy,horz,vert;
- ; Note: the dummy parameter is used so SETDOT can be shared.
-
- PUBLIC GET_DOT_
- GET_DOT_:
- push bp
- CALL SETDOT ; set up the registers
- MOV AH,13
- INT VIDEO
- cbw
- pop bp
- RET ; AX = dot color
-
- dseg
- ; Larry A. Thiel 06/13/86
- ;
- ; translated keyboard routines for use with the modified window package
- ; originally downloaded from the cware bbs.
- ;
- ; While this code was largely lifted from PCIO.A for DeSmet v2.51 and
- ; is only useful for DeSmet owners, the extended key translation has
- ; been changed to provide a translations for all the most useful keys
- ; without implications of function as there are in PCIO.A.
- ; The translated output conforms to the standards set by the IBMKEYS.H
- ; file distributed with:
- ;
- ; The Greenleaf Functions - Copyright (C) 1983,84,85 Greenleaf Software Inc.
- ;
- ; This was done so to allow users of Greenleaf (such as myself) to use
- ; only one include file of extended key definitions. I would have used
- ; the Greenleaf functions but then could not have shared the modified
- ; window package.
-
- F1 equ 80h
- F2 equ 81h
- F3 equ 82h
- F4 equ 83h
- F5 equ 84h
- F6 equ 85h
- F7 equ 86h
- F8 equ 87h
- F9 equ 88h
- F10 equ 89h
-
- SF1 equ 90h
- SF2 equ 91h
- SF3 equ 92h
- SF4 equ 93h
- SF5 equ 94h
- SF6 equ 95h
- SF7 equ 96h
- SF8 equ 97h
- SF9 equ 98h
- SF10 equ 99h
-
- CF1 equ 0A0h
- CF2 equ 0A1h
- CF3 equ 0A2h
- CF4 equ 0A3h
- CF5 equ 0A4h
- CF6 equ 0A5h
- CF7 equ 0A6h
- CF8 equ 0A7h
- CF9 equ 0A8h
- CF10 equ 0A9h
-
- AF1 equ 0E0h
- AF2 equ 0E1h
- AF3 equ 0E2h
- AF4 equ 0E3h
- AF5 equ 0E4h
- AF6 equ 0E5h
- AF7 equ 0E6h
- AF8 equ 0E7h
- AF9 equ 0E8h
- AF10 equ 0E9h
-
- HOME equ 8Ah ; HOME key
- CURLF equ 8Bh ; <-
- ENDKEY equ 8Ch ; END key
- CURUP equ 8Dh ; up arrow
- CURDN equ 8Eh ; down arrow
- PGUP equ 9Ah ; PgUp
- CURRT equ 9Bh ; ->
- PGDN equ 9Ch ; PgDn
- INSERT equ 9Dh ; Ins
- DELETE equ 9Eh ; Del
- CTRLHOME equ 0AAh ; Ctrl Home
- CTRLCURLF equ 0ABh ; Ctrl <-
- CTRLEND equ 0ACh ; Ctrl End
- CTRLPRTSC equ 0AEh ; Ctrl PrtSc
- CTRLPGUP equ 0BAh ; Ctrl PgUp
- CTRLCURRT equ 0BBh ; Ctrl ->
- CTRLPGDN equ 0BCh ; Ctrl PgDn
- REVTAB equ 08Fh ; Shift Tab
- ALTMINUS equ 0BDh ; Alt -
- ALTEQUAL equ 0BEh ; Alt =
-
- ALT1 equ 0B1h
- ALT2 equ 0B2h
- ALT3 equ 0B3h
- ALT4 equ 0B4h
- ALT5 equ 0B5h
- ALT6 equ 0B6h
- ALT7 equ 0B7h
- ALT8 equ 0B8h
- ALT9 equ 0B9h
- ALT0 equ 0B0h
-
- ALTA equ 0C1h
- ALTB equ 0C2h
- ALTC equ 0C3h
- ALTD equ 0C4h
- ALTE equ 0C5h
- ALTF equ 0C6h
- ALTG equ 0C7h
- ALTH equ 0C8h
- ALTI equ 0C9h
- ALTJ equ 0CAh
- ALTK equ 0CBh
- ALTL equ 0CCh
- ALTM equ 0CDh
- ALTN equ 0CEh
- ALTO equ 0CFh
- ALTP equ 0D0h
- ALTQ equ 0D1h
- ALTR equ 0D2h
- ALTS equ 0D3h
- ALTT equ 0D4h
- ALTU equ 0D5h
- ALTV equ 0D6h
- ALTW equ 0D7h
- ALTX equ 0D8h
- ALTY equ 0D9h
- ALTZ equ 0DAh
-
- CTRLBREAK equ 0 ; when break testing is off
- NULKEY equ 003h
- BADKEY equ 0FFh ; invalid value
-
- ; table used to make extended key code translations
-
- convert:
- ; return value extended scan code
- ; ------------ ------------------
- db BADKEY ;0
- db BADKEY ;1
- db BADKEY ;2
- db CTRLBREAK ;3
- db BADKEY ;4
- db BADKEY ;5
- db BADKEY ;6
- db BADKEY ;7
- db BADKEY ;8
- db BADKEY ;9
- db BADKEY ;10
- db BADKEY ;11
- db BADKEY ;12
- db BADKEY ;13
- db BADKEY ;14
- db REVTAB ;15
- db ALTQ ;16
- db ALTW ;17
- db ALTE ;18
- db ALTR ;19
- db ALTT ;20
- db ALTY ;21
- db ALTU ;22
- db ALTI ;23
- db ALTO ;24
- db ALTP ;25
- db BADKEY ;26
- db BADKEY ;27
- db BADKEY ;28
- db BADKEY ;29
- db ALTA ;30
- db ALTS ;31
- db ALTD ;32
- db ALTF ;33
- db ALTG ;34
- db ALTH ;35
- db ALTJ ;36
- db ALTK ;37
- db ALTL ;38
- db BADKEY ;39
- db BADKEY ;40
- db BADKEY ;41
- db BADKEY ;42
- db BADKEY ;43
- db ALTZ ;44
- db ALTX ;45
- db ALTC ;46
- db ALTV ;47
- db ALTB ;48
- db ALTN ;49
- db ALTM ;50
- db BADKEY ;51
- db BADKEY ;52
- db BADKEY ;53
- db BADKEY ;54
- db BADKEY ;55
- db BADKEY ;56
- db BADKEY ;57
- db BADKEY ;58
- db F1 ;59
- db F2 ;60
- db F3 ;61
- db F4 ;62
- db F5 ;63
- db F6 ;64
- db F7 ;65
- db F8 ;66
- db F9 ;67
- db F10 ;68
- db BADKEY ;69
- db BADKEY ;70
- db HOME ;71
- db CURUP ;72
- db PGUP ;73
- db BADKEY ;74
- db CURLF ;75
- db BADKEY ;76
- db CURRT ;77
- db BADKEY ;78
- db ENDKEY ;79
- db CURDN ;80
- db PGDN ;81
- db INSERT ;82
- db DELETE ;83
- db SF1 ;84
- db SF2 ;85
- db SF3 ;86
- db SF4 ;87
- db SF5 ;88
- db SF6 ;89
- db SF7 ;90
- db SF8 ;91
- db SF9 ;92
- db SF10 ;93
- db CF1 ;94
- db CF2 ;95
- db CF3 ;96
- db CF4 ;97
- db CF5 ;98
- db CF6 ;99
- db CF7 ;100
- db CF8 ;101
- db CF9 ;102
- db CF10 ;103
- db AF1 ;104
- db AF2 ;105
- db AF3 ;106
- db AF4 ;107
- db AF5 ;108
- db AF6 ;109
- db AF7 ;110
- db AF8 ;111
- db AF9 ;112
- db AF10 ;113
- db CTRLPRTSC ;114
- db CTRLCURLF ;115
- db CTRLCURRT ;116
- db CTRLEND ;117
- db CTRLPGDN ;118
- db CTRLHOME ;119
- db ALT1 ;120
- db ALT2 ;121
- db ALT3 ;122
- db ALT4 ;123
- db ALT5 ;124
- db ALT6 ;125
- db ALT7 ;126
- db ALT8 ;127
- db ALT9 ;128
- db ALT0 ;129
- db ALTMINUS ;130
- db ALTEQUAL ;131
- db CTRLPGUP ;132
- tbl_end:
-
- ; equates for bios interface.
-
-
- ; the interrupt and codes for the keyboard interface.
-
- keyboard equ 16h ;interrupt 16 to deal with keyboard
-
- cicode equ 0 ;code for reading a character
- cstscode equ 1 ;code for keyboard status
-
- cseg
-
- ; KBD_CI_ keyboard input. function and soft keys are
- ; translated. see equates for values.
-
- ; Usage: character = kbd_ci();
-
- public kbd_ci_
- kbd_ci_: ;return the next character
- ; translate if necessary
- push bp
- mov ah,cicode ;ask for a keyboard character
- int keyboard
- cmp al,0
- jne not_special
- mov bx, offset convert ; convert special key
- mov al, ah
- mov ah, 0
- add bx, ax ;offset by extended code
- cmp bx, offset tbl_end ;verify in table
- jle translate
- mov al, BADKEY ;indicate if not
- jmp not_special
- translate: mov al, [bx] ;get translation
- not_special: mov ah,0
- pop bp
- ret
-
-
- ; KBD_CSTS_ return character if any available. otherwise
- ; return zero.
-
- ; Usage: character = kbd_csts();
-
- public kbd_csts_
- kbd_csts_: ;return coded character if any available
- push bp
- mov ah,cstscode
- int keyboard
- mov ax,0
- jz csts_over
- call kbd_ci_ ;get the coded character
- csts_over: pop bp
- ret
-
-
- END
-