├── ALLOCERR.ASM ├── BEEP.ASM ├── BGINFO.ASM ├── BIOPRINT.ASM ├── BSCPOS.ASM ├── BSCSIZE.ASM ├── CHGATTR.ASM ├── CURFAT.ASM ├── CURHIDE.ASM ├── CURHOME.ASM ├── CURSR.ASM ├── CURTHIN.ASM ├── DOSCD.ASM ├── DOSFF.ASM ├── DOSFN.ASM ├── DOSFREE.ASM ├── DRAWBOX.ASM ├── DV.ASM ├── DVINIT.ASM ├── DVPAUSE.ASM ├── DVSR.ASM ├── GETDRIVE.ASM ├── GETKEY.ASM ├── GETTIME.ASM ├── KEYBOARD.H ├── KEYCODES.H ├── MAKEATTR.ASM ├── MIT-LICENSE.txt ├── MODLOG.ASM ├── MYLIB ├── MYLIB.H ├── MYLIB.LIB ├── README.md ├── SCRCORE.ASM ├── SCREEN ├── SCREEN.H ├── SCREEN.INC ├── SCREEN.LIB ├── SETDRIVE.ASM ├── SHELL.ASM ├── SPAUSE.ASM ├── TPAUSE.ASM ├── VCONFIG.ASM ├── VSBACK.ASM ├── VSBORDER.ASM ├── VSDISP.ASM ├── WAITTICK.ASM ├── WIN ├── WINDOW.H ├── WINDOW.INC ├── WINDOW.LIB ├── WNACT.ASM ├── WNBCHG.ASM ├── WNBCOL.ASM ├── WNBORDER.ASM ├── WNBPRINT.ASM ├── WNCLOSE.ASM ├── WNCLOSEA.ASM ├── WNCLS.ASM ├── WNCORE.ASM ├── WNCURSON.ASM ├── WNDEACT.ASM ├── WNEDIT.ASM ├── WNGETATT.ASM ├── WNGETCUR.ASM ├── WNHIDE.ASM ├── WNHIDEAL.ASM ├── WNINT24.ASM ├── WNKILL.ASM ├── WNKILLAL.ASM ├── WNMAKE.ASM ├── WNMOVE.ASM ├── WNOPEN.ASM ├── WNPRINT.ASM ├── WNPRINTX.ASM ├── WNPXYA.ASM ├── WNSACTCO.ASM ├── WNSCROLL.ASM ├── WNSETATT.ASM ├── WNSETCUR.ASM ├── WNSHADOW.ASM ├── WNSHOFF.ASM └── WNTITLE.ASM /ALLOCERR.ASM: -------------------------------------------------------------------------------- 1 | ; 2 | ; File Name : allocerr.asm 3 | ; 4 | ; Description : Window module memory allocation error handler. 5 | ; Handles memory allocation error... 6 | ; Releases all memory and prints message 7 | ; 8 | ; C Prototypes : void AllocError ( void ); 9 | ; 10 | ; 11 | .MODEL SMALL 12 | 13 | include window.inc 14 | 15 | public C AllocError 16 | extrn _WnExit:near 17 | 18 | .DATA 19 | 20 | message1 DB 0DH , 0AH ; cr and lf 21 | DB 'PROGRAMME ABORTED...' 22 | DB 'Unable to allocate enough memory to continue.' 23 | DB 0DH , 0AH ; cr and lf 24 | msg_len EQU $ - message1 25 | 26 | .CODE 27 | 28 | AllocError PROC C 29 | call near ptr _WnExit ; clean up 30 | ; 31 | ; use DOS to write message to screen 32 | ; 33 | mov ah , 40H ; write to file or device 34 | mov bx , 2 ; handle for standard error 35 | mov cx , msg_len ; length of the message 36 | mov dx , OFFSET DGROUP:message1 37 | int 21H 38 | ; 39 | ; use DOS to exit. Stops any exit routine being executed and over- 40 | ; writeing the message. 41 | ; 42 | mov ax , 4C01H ; Function 4CH return code = 1 43 | int 21H 44 | ret ; not really needed !! 45 | AllocError ENDP 46 | END 47 | -------------------------------------------------------------------------------- /BEEP.ASM: -------------------------------------------------------------------------------- 1 | ; 2 | ; 3 | ; File Name : Beep.asm 4 | ; 5 | ; Description : Makes the hardware BEEP 6 | ; 7 | ; C Prototypes : void Beep ( int Hz , int ticks ); 8 | ; 9 | 10 | .MODEL SMALL 11 | 12 | public C Beep 13 | extrn __WaitTick:near 14 | 15 | TIMER_DATA EQU 42H 16 | TIMER_CONTROL EQU 43H 17 | PORT_B EQU 61H 18 | 19 | .CODE 20 | 21 | Beep PROC C 22 | ARG freq:word , ticks:word 23 | USES bx , cx , dx 24 | 25 | mov bx , [freq] ; get frequency 26 | mov dx , 12H ; divide frequency 27 | xor ax , ax 28 | div bx 29 | mov bx , ax 30 | 31 | mov al , 10110110B ; set up port 32 | out TIMER_CONTROL , al 33 | mov ax , bx 34 | out TIMER_DATA , al ; output LSB to port 35 | mov al , ah ; ready for MSB 36 | out TIMER_DATA , al ; output MSB to port 37 | in al , PORT_B ; get status of potr B 38 | or al , 03H ; turn the speaker on 39 | out PORT_B , al ; send it 40 | 41 | mov cx , [ticks] ; number of ticks in cx 42 | call near ptr __WaitTick ; wait 43 | in al , PORT_B ; get status of potr B 44 | and al , 0FEH ; turn the speaker off 45 | out PORT_B , al ; send it 46 | 47 | ret 48 | Beep ENDP 49 | END 50 | -------------------------------------------------------------------------------- /BGINFO.ASM: -------------------------------------------------------------------------------- 1 | ; 2 | ; 3 | ; File Name : bginfo.asm 4 | ; 5 | ; Description : Bios Get Cursor Information. 6 | ; 7 | ; caller : nothing 8 | ; returns : cx = size 9 | ; : dx = position 10 | ; 11 | .MODEL SMALL 12 | 13 | public BiosGetCursInfo 14 | 15 | .CODE 16 | 17 | BiosGetCursInfo PROC 18 | mov ah , 3 19 | xor bh , bh ; always page 0 20 | push bp 21 | int 10H 22 | pop bp 23 | ret 24 | BiosGetCursInfo ENDP 25 | END 26 | -------------------------------------------------------------------------------- /BIOPRINT.ASM: -------------------------------------------------------------------------------- 1 | ; 2 | ; File Name : bioprint.asm 3 | ; 4 | ; Description : fuctions to use the BIOS to access the printer 5 | ; 6 | ; C Prototypes : 7 | ; void BiosPrintInit ( void ); // Initialises printer 0 8 | ; int BiosPrintStatus ( void ); // status of printer 0 9 | ; int BiosPrintChar ( char character ); // print a char on printer 0 10 | ; 11 | 12 | .MODEL SMALL 13 | 14 | Public C BiosPrintInit 15 | Public C BiosPrintStatus 16 | Public C BiosPrintChar 17 | 18 | .CODE 19 | 20 | ;------------------------------------------------------------------------------; 21 | ; Initialises printer 0 ( LPT1 ) ; 22 | ;------------------------------------------------------------------------------; 23 | BiosPrintInit PROC 24 | mov ah , 1 ; fuction 1 25 | xor dx , dx ; printer 0 ( LPT1 ) 26 | int 17H ; call bios 27 | mov al , ah 28 | xor ah , ah ; return status in ax 29 | ret 30 | BiosPrintInit ENDP 31 | 32 | ;------------------------------------------------------------------------------; 33 | ; Gets the status of printer LPT1. ; 34 | ;------------------------------------------------------------------------------; 35 | BiosPrintStatus PROC 36 | mov ah , 2 ; fuction 2 37 | xor dx , dx ; printer 0 ( LPT1 ) 38 | int 17H ; call bios 39 | mov al , ah 40 | xor ah , ah ; return status in ax 41 | ret 42 | BiosPrintStatus ENDP 43 | 44 | ;------------------------------------------------------------------------------; 45 | ; Sends a character to printer LPT1. ; 46 | ;------------------------------------------------------------------------------; 47 | BiosPrintChar PROC C 48 | ARG character : BYTE:1 49 | mov al , [character] ; Argument 1 - the character 50 | xor ah , ah ; fuction 0 51 | xor dx , dx ; printer 0 ( LPT1 ) 52 | int 17H ; call bios 53 | mov al , ah 54 | xor ah , ah ; return status in ax 55 | ret 56 | BiosPrintChar ENDP 57 | END 58 | -------------------------------------------------------------------------------- /BSCPOS.ASM: -------------------------------------------------------------------------------- 1 | ; 2 | ; File Name : bscpos.asm 3 | ; 4 | ; Description : Bios Set Cursor Position. 5 | ; 6 | ; caller : dl = column number [ x coordinate ] 7 | ; dh = row number [ y coordinate ] 8 | ; returns : nothing 9 | 10 | .MODEL SMALL 11 | 12 | public BiosSetCursPos 13 | 14 | .CODE 15 | BiosSetCursPos PROC 16 | mov ah , 2 17 | xor bh , bh ; always page 0 18 | push bp 19 | int 10H 20 | pop bp 21 | ret 22 | BiosSetCursPos ENDP 23 | END 24 | -------------------------------------------------------------------------------- /BSCSIZE.ASM: -------------------------------------------------------------------------------- 1 | ; 2 | ; File Name : bscsize.asm 3 | ; 4 | ; Description : Bios Set Cursor Size. 5 | ; 6 | ; caller : cx = size 7 | ; returns : nothing 8 | ; 9 | 10 | .MODEL SMALL 11 | 12 | public BiosSetCurSize 13 | 14 | .CODE 15 | 16 | BiosSetCurSize PROC 17 | mov ah , 1 18 | xor bh , bh ; always page 0 19 | push bp 20 | int 10H 21 | pop bp 22 | ret 23 | BiosSetCurSize ENDP 24 | END 25 | -------------------------------------------------------------------------------- /CHGATTR.ASM: -------------------------------------------------------------------------------- 1 | ; 2 | ; File Name : chgattr.asm 3 | ; 4 | ; Description : Contains WINDOW function to change a window attributes 5 | ; 6 | ; C Prototypes : 7 | ; void WnChgAttr ( WINDOW *ptr, int x, int y, int fgc, int bgc, int count ) 8 | ; Changes the onscreen colours at x , y for a 'count'. 9 | ; 10 | 11 | .MODEL SMALL 12 | 13 | include window.inc 14 | 15 | .CODE 16 | 17 | WnChgAttr PROC C 18 | ARG ptr:WORD , x:WORD , y:WORD , fgc:WORD , bgc:WORD , count:WORD 19 | USES di , si 20 | 21 | mov si , ARG_1 ; pointer to window in si 22 | ; 23 | ; attr = (char)MakeAttr ( fgc , bgc ); 24 | ; 25 | push ARG_5 26 | push ARG_4 27 | call MakeAttr 28 | add sp , 4 29 | mov bl , al ; save attribute in bl for later 30 | mov cx , ARG_6 ; count in cx 31 | 32 | chgattr0: 33 | or cx , cx ; if count EQ 0 then loop ends 34 | jz short chgattr6 35 | ; 36 | ; attr_ptr = (char *)( ptr -> ptr ) + 2 * ( ( y * wid ) + x ) + 1; 37 | ; 38 | mov ax , ARG_3 ; y 39 | mov dx , [si].W_WID ; wid 40 | imul dl ; * wid 41 | add ax , ARG_2 ; + x 42 | shl ax , 1 ; * 2 43 | mov di , [si].W_PTR ; [ ptr 44 | add di , ax ; + ax ] 45 | inc di ; + 1...leave in di for later. 46 | 47 | mov dx , [si].W_WID ; attr_count = wid - x; 48 | sub dx , ARG_2 ; leave in dx for later 49 | 50 | chgattr1: 51 | ; 52 | ; while ( ( attr_count ) AND ( count ) ) 53 | ; bl = attribute 54 | ; cx = count to change 55 | ; dx = attr_count 56 | ; di = attr_ptr 57 | ; 58 | chgattr2: 59 | or dx , dx 60 | jz short chgattr3 61 | mov byte ptr [di] , bl ; *attr_ptr = attr 62 | inc di 63 | inc di ; attr_ptr += 2 64 | dec dx ; attr_count-- 65 | loop short chgattr2 ; count-- + cmp cx , 0 66 | chgattr3: 67 | mov ARG_2 , 0 ; x = 0; 68 | ; 69 | ; y = ( y EQ ( hgt ) ) ? 0 : y + 1 70 | ; 71 | mov ax , [si].W_HGT 72 | cmp ax , ARG_3 73 | jne short chgattr5 74 | mov ARG_3 , 0 75 | jmp short chgattr0 76 | chgattr5: 77 | inc ARG_3 78 | jmp short chgattr0 79 | chgattr6: 80 | cmp [si].W_OPEN , 0 ; if the window is not open 81 | je short chgattr7 ; jump 82 | call ModLog 83 | chgattr7: 84 | ret 85 | WnChgAttr ENDP 86 | END 87 | -------------------------------------------------------------------------------- /CURFAT.ASM: -------------------------------------------------------------------------------- 1 | name curfat 2 | title CURFAT.ASM - makes the cursor FAT...uses the BIOS 3 | 4 | .MODEL SMALL 5 | ; 6 | ; C prototype : void CursorFat ( void ) 7 | ; 8 | 9 | include window.inc 10 | 11 | public _CursorFat 12 | extrn _adapter:word 13 | extrn BiosSetCurSize:near 14 | 15 | .CODE 16 | ; 17 | ; Cursor function .. Makes the cursor fat. 18 | ; 19 | ; caller : nothing 20 | ; returns : nothing 21 | ; 22 | _CursorFat PROC 23 | mov cx , 000DH ; mono size of cursor 24 | cmp adapter , MDA ; is it an MDA ? 25 | je short make_fat 26 | mov cx , 0007H ; colour size of cursor 27 | make_fat: 28 | call near ptr BiosSetCurSize 29 | ret 30 | _CursorFat ENDP 31 | END 32 | -------------------------------------------------------------------------------- /CURHIDE.ASM: -------------------------------------------------------------------------------- 1 | ;------------------------------------------------------------------------------; 2 | ; ; 3 | ; File Name : curhide.asm ; 4 | ; ; 5 | ; Description : hide the curser with the BIOS ; 6 | ; Internal function used by WINDOW modules. ; 7 | ; ; 8 | ;------------------------------------------------------------------------------; 9 | .MODEL SMALL 10 | 11 | include window.inc 12 | 13 | public _CursorHide 14 | extrn BiosSetCursPos:near 15 | 16 | .CODE 17 | ;------------------------------------------------------------------------------; 18 | ; Cursor function .. Hide cursor off bottom off screen. ; 19 | ;------------------------------------------------------------------------------; 20 | _CursorHide PROC 21 | mov dx , 2500H 22 | call near ptr BiosSetCursPos 23 | ret 24 | _CursorHide ENDP 25 | END 26 | 27 | 28 | -------------------------------------------------------------------------------- /CURHOME.ASM: -------------------------------------------------------------------------------- 1 | ;------------------------------------------------------------------------------; 2 | ; ; 3 | ; File Name : curhome.asm ; 4 | ; ; 5 | ; Description : Moves the cursor to 0,0 with the BIOS ; 6 | ; Internal function used by WINDOW modules. ; 7 | ; ; 8 | ;------------------------------------------------------------------------------; 9 | DOSSEG 10 | .MODEL SMALL 11 | 12 | include window.inc 13 | 14 | public _CursorHome 15 | extrn BiosSetCursPos:near 16 | 17 | .CODE 18 | ;------------------------------------------------------------------------------; 19 | ; Cursor function .. Move cursor to top left corner of the screen. ; 20 | ;------------------------------------------------------------------------------; 21 | _CursorHome PROC 22 | mov dx , 0000H 23 | call near ptr BiosSetCursPos 24 | ret 25 | _CursorHome ENDP 26 | END 27 | -------------------------------------------------------------------------------- /CURSR.ASM: -------------------------------------------------------------------------------- 1 | ;------------------------------------------------------------------------------; 2 | ; ; 3 | ; File Name : cursr.asm ; 4 | ; ; 5 | ; Description : Save and restore the cursor with the BIOS ; 6 | ; Internal function used by WINDOW modules. ; 7 | ; ; 8 | ;------------------------------------------------------------------------------; 9 | .MODEL SMALL 10 | 11 | include screen.inc 12 | 13 | public CursorSave 14 | public CursorRestore 15 | extrn _adapter:word 16 | extrn BiosGetCursInfo:near 17 | extrn BiosSetCurSize:near 18 | extrn BiosSetCursPos:near 19 | 20 | .DATA 21 | 22 | old_position dw 0 ; old cursor position 23 | old_size dw 0 ; old cursor size 24 | 25 | .CODE 26 | ;------------------------------------------------------------------------------; 27 | ; Cursor function .. Save old values to variables. ; 28 | ;------------------------------------------------------------------------------; 29 | CursorSave PROC 30 | call near ptr BiosGetCursInfo 31 | mov old_position , dx 32 | cmp _adapter , MDA ; is it an MDA ? 33 | jne short csave_end ; nope 34 | cmp cx , 0607H ; has the wrong size been returned 35 | jne short csave_end ; nope 36 | mov cx , 1112H ; replace buggy bios returned data 37 | csave_end: 38 | mov old_size , cx 39 | ret 40 | CursorSave ENDP 41 | ;------------------------------------------------------------------------------; 42 | ; Cursor function .. Restore cursor to variables. ; 43 | ;------------------------------------------------------------------------------; 44 | CursorRestore PROC 45 | mov cx , old_size 46 | call near ptr BiosSetCurSize 47 | mov dx , old_position 48 | call near ptr BiosSetCursPos 49 | ret 50 | CursorRestore ENDP 51 | END 52 | -------------------------------------------------------------------------------- /CURTHIN.ASM: -------------------------------------------------------------------------------- 1 | name curthin 2 | title CURTHIN.ASM - makes the cursor THIN..uses the BIOS 3 | 4 | .MODEL SMALL 5 | ; 6 | ; C prototype : void CursorThin ( void ) 7 | ; 8 | include window.inc 9 | 10 | public _CursorThin 11 | extrn _adapter:word 12 | extrn BiosSetCurSize:near 13 | 14 | .CODE 15 | ; 16 | ; Cursor function .. Makes the cursor thin 17 | ; 18 | ; caller : nothing 19 | ; returns : nothing 20 | ; 21 | _CursorThin PROC 22 | mov cx , 0C0DH ; mono size of cursor 23 | cmp adapter , MDA ; is it an MDA ? 24 | je short make_thin 25 | mov cx , 0607H ; colour size of cursor 26 | make_thin: 27 | call near ptr BiosSetCurSize 28 | ret 29 | _CursorThin ENDP 30 | END 31 | -------------------------------------------------------------------------------- /DOSCD.ASM: -------------------------------------------------------------------------------- 1 | ;------------------------------------------------------------------------------; 2 | ; ; 3 | ; File Name : doscd.asm ; 4 | ; ; 5 | ; Description : use DOS to change directory. ; 6 | ; ; 7 | ; ; 8 | ; C Prototypes ; 9 | ; ------------ ; 10 | ; int DosCD ( char *path ) ; 11 | ; ; 12 | ;------------------------------------------------------------------------------; 13 | .MODEL SMALL 14 | 15 | Public _DosCD 16 | 17 | .CODE 18 | 19 | _DosCD PROC 20 | push bp 21 | mov bp , sp 22 | mov dx , word ptr [bp + 4] 23 | mov ah , 3BH ; function # 24 | int 21H ; call DOS 25 | jb short cderror ; branch on error 26 | xor ax , ax ; return 0 if OK 27 | cderror: 28 | pop bp 29 | ret 30 | _DosCD ENDP 31 | END 32 | -------------------------------------------------------------------------------- /DOSFF.ASM: -------------------------------------------------------------------------------- 1 | ;------------------------------------------------------------------------------; 2 | ; ; 3 | ; File Name : dosff.asm ; 4 | ; ; 5 | ; Description : DOS find first file function ; 6 | ; ; 7 | ; ; 8 | ; C Prototypes ; 9 | ; ------------ ; 10 | ; int DosFindFirst ( char *filespec, int attributes, struct find_t *DTA ) ; 11 | ; ; 12 | ;------------------------------------------------------------------------------; 13 | .MODEL SMALL 14 | ; 15 | ; these make the code easier to read 16 | ; 17 | ARG_1 equ word ptr [bp + 4] ; Argument 1 18 | ARG_2 equ word ptr [bp + 6] ; Argument 2 19 | ARG_3 equ word ptr [bp + 8] ; Argument 3 20 | 21 | Public _DosFindFirst 22 | 23 | .CODE 24 | 25 | _DosFindFirst PROC 26 | push bp 27 | mov bp , sp 28 | push cx 29 | push dx 30 | 31 | mov dx , ARG_3 ; set up our own DTA 32 | mov ah , 1AH ; function # 33 | int 21H 34 | 35 | mov dx , ARG_1 ; pointer to filespec to look for 36 | mov cx , ARG_2 ; attributes to use 37 | mov ah , 4EH ; function # 38 | int 21H ; call DOS ax = error code 39 | jc short dff1 ; jump if error 40 | xor ax , ax ; no error return ax = 0 41 | dff1: 42 | pop dx 43 | pop cx 44 | pop bp 45 | ret 46 | _DosFindFirst ENDP 47 | END 48 | -------------------------------------------------------------------------------- /DOSFN.ASM: -------------------------------------------------------------------------------- 1 | ;------------------------------------------------------------------------------; 2 | ; ; 3 | ; File Name : dosfn.asm ; 4 | ; ; 5 | ; Description : DOS find next file function ; 6 | ; ; 7 | ; ; 8 | ; C Prototypes ; 9 | ; ------------ ; 10 | ; int DosFindNext ( struct find_t *DTA ) ; 11 | ; ; 12 | ;------------------------------------------------------------------------------; 13 | .MODEL SMALL 14 | 15 | Public _DosFindNext 16 | 17 | .CODE 18 | 19 | _DosFindNext PROC 20 | push bp 21 | mov bp , sp 22 | push dx 23 | 24 | mov dx , word ptr [bp + 4] ; set up our own DTA 25 | mov ah , 1AH ; function # 26 | int 21H ; call DOS 27 | 28 | mov ah , 4FH ; function # 29 | int 21H ; call DOS ax = error code 30 | jc short dfn1 ; jump if error 31 | xor ax , ax ; no error return ax = 0 32 | dfn1: 33 | pop dx 34 | pop bp 35 | ret 36 | _DosFindNext ENDP 37 | END 38 | -------------------------------------------------------------------------------- /DOSFREE.ASM: -------------------------------------------------------------------------------- 1 | ;------------------------------------------------------------------------------; 2 | ; ; 3 | ; File Name : ; 4 | ; ; 5 | ; Description : Returns the ammount of free space on the specified drive ; 6 | ; ; 7 | ; C Prototypes ; 8 | ; ------------ ; 9 | ; long DosGetFreeSpace ( int drive_number ) ; 10 | ; ; 11 | ;------------------------------------------------------------------------------; 12 | .MODEL SMALL 13 | 14 | Public _DosGetFreeSpace 15 | 16 | .CODE 17 | 18 | _DosGetFreeSpace PROC 19 | push bp 20 | mov bp , sp 21 | mov dx , word ptr [bp + 4] 22 | mov ah , 19H ; function # 23 | int 21H ; call DOS 24 | cbw ; clear the high byte of ax for return 25 | pop bp 26 | ret 27 | _DosGetFreeSpace ENDP 28 | END 29 | -------------------------------------------------------------------------------- /DRAWBOX.ASM: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rhulse/dos-asm-windowing-library/8bc3499a1c626ffbb91d20385c831d1059c1f9f7/DRAWBOX.ASM -------------------------------------------------------------------------------- /DV.ASM: -------------------------------------------------------------------------------- 1 | ;------------------------------------------------------------------------------; 2 | ; ; 3 | ; File Name : dv.asm ; 4 | ; ; 5 | ; Description : Routines to interface with DESQview. ; 6 | ; ; 7 | ; ; 8 | ; C Prototypes ; 9 | ; ------------ ; 10 | ; ; 11 | ; void AllocError ( void ); ; 12 | ; ; 13 | ;------------------------------------------------------------------------------; 14 | .MODEL SMALL 15 | 16 | public _DvInit 17 | public _DvSeize 18 | public _DvRelease 19 | public _DvPause 20 | public _DvGetVidBuffer 21 | public _DvAppNum 22 | public _DvSound 23 | public _DvNoSound 24 | 25 | public _in_dv 26 | 27 | TRUE EQU 1 28 | FALSE EQU 0 29 | 30 | .DATA 31 | 32 | _in_dv DW 00H ; are we in desqview 33 | 34 | .CODE 35 | ; The following routines deal with the DESQview interface 36 | _DvInit PROC NEAR 37 | ; This routine returns the DESQview major/minor number in ax, and sets up the 38 | ; _IN_DV variable for later use by other DESQview I/F programmes 39 | 40 | push bx 41 | push cx 42 | push dx 43 | mov word ptr _in_dv , 0 ; Assume DESQview not running 44 | mov cx , 'DE' ; Set cx, dx to an invalid date 45 | mov dx , 'SQ' 46 | mov ax , 2B01H ; DOS's Set Date function 47 | int 21H ; Call DOS 48 | cmp al , 0FFH ; Did DOS recognize it? 49 | je short no_desqview ; If not, DESQview isn't running 50 | mov ax , bx ; Else get version number 51 | mov word ptr _in_dv , 1 ; Indicate we're running under DESQview 52 | jmp short dv_end 53 | no_desqview: 54 | xor ax , ax ; Return no DESQview ( version 0 ) 55 | dv_end: 56 | pop dx 57 | pop cx 58 | pop bx 59 | ret 60 | _DvInit ENDP 61 | 62 | api_call PROC NEAR 63 | ; This routine takes a programme interface function in bx, and makes that 64 | ; call to DESQview after switching onto a stack that DESQview provides. 65 | 66 | push ax 67 | mov ax , 101AH ; this function to switch to DV's stack 68 | int 15H 69 | mov ax , bx ; Move the desired function into ax 70 | int 15H ; Make the call 71 | mov ax , 1025H ; Function to turn off DV's stack 72 | int 15H ; Make that call 73 | pop ax 74 | ret 75 | api_call ENDP 76 | 77 | _DvPause PROC NEAR 78 | ; This routine gives up the rest of your programme's time slice. It takes 79 | ; no parameters and returns nothing. 80 | 81 | cmp word ptr _in_dv , 1 ; See if running under DESQview 82 | jne short dvp_x ; If not, do nothing 83 | push bx 84 | mov bx , 1000H ; Else this is pause function call 85 | call near ptr api_call 86 | pop bx 87 | dvp_x: 88 | ret 89 | _DvPause ENDP 90 | 91 | _DvSeize PROC NEAR 92 | ; This routine tells DESQview not to slice away from your programme until 93 | ; you make a _DvRelease call. It takes no parameters and returns nothing. 94 | 95 | cmp word ptr _in_dv , 1 ; See if running under DESQview 96 | jne short dvs_x ; If not, do nothing 97 | push bx 98 | mov bx , 101BH ; This is Begin Critical function call 99 | call near ptr api_call 100 | pop bx 101 | dvs_x: 102 | ret 103 | _DvSeize ENDP 104 | 105 | _DvRelease PROC NEAR 106 | ; This routine tells DESQview that it is OK to not to slice away from your 107 | ; programme again. It takes no parameters and returns nothing. 108 | 109 | cmp word ptr _in_dv , 1 ; See if running under DESQview 110 | jne short dvr_x ; If not, do nothing 111 | push bx 112 | mov bx , 101CH ; This is End Critical function call 113 | call near ptr api_call 114 | pop bx 115 | dvr_x: 116 | ret 117 | _DvRelease ENDP 118 | 119 | ; void far *DVshadow_start(int *rows,int *cols) 120 | 121 | _DvGetVidBuffer proc near 122 | ; This routine returns the Segment of th video buffer 123 | push es 124 | cmp word ptr _in_dv , 1 ; See if running under DESQview 125 | jne short gcb_x ; If not, do nothing 126 | 127 | mov ah , 0FEH ; fuction # 128 | int 10H ; call DESQview 129 | mov ax , es ; put segment in ax 130 | pop es ; restore es 131 | gcb_x: 132 | ret 133 | 134 | _DvGetVidBuffer endp 135 | 136 | _DvAppNum proc near 137 | mov ax , 0DE07H 138 | int 15H ; number of aplication in the 139 | ret ; ax register 140 | _DvAppNum endp 141 | 142 | _DvSound proc near 143 | ; Gets DESQview to beep. 144 | ; 145 | push bp 146 | mov bp , bp 147 | push bx 148 | push cx 149 | 150 | mov bx , [bp + 4] ; frequency in hertz 151 | mov cx , [bp + 6] ; time in ticks 152 | mov ax , 1019H ; DESQview function # 153 | int 15H 154 | 155 | pop cx 156 | pop bx 157 | pop bp 158 | ret 159 | _DvSound endp 160 | 161 | _DvNoSound proc near 162 | ret 163 | _DvNoSound endp 164 | 165 | _TEXT ENDS 166 | END 167 | 168 | -------------------------------------------------------------------------------- /DVINIT.ASM: -------------------------------------------------------------------------------- 1 | ;------------------------------------------------------------------------------; 2 | ; ; 3 | ; File Name : ; 4 | ; ; 5 | ; Description : Contains the DESQview Init and api functions. ; 6 | ; ; 7 | ; ; 8 | ; C Prototypes ; 9 | ; ------------ ; 10 | ; int DvInit( void ); /* return DESQview version */ ; 11 | ; ; 12 | ;------------------------------------------------------------------------------; 13 | .MODEL SMALL 14 | 15 | public _DvInit 16 | public api_call 17 | 18 | public _in_dv 19 | 20 | .DATA 21 | 22 | _in_dv DW 00H ; are we in desqview 23 | 24 | .CODE 25 | 26 | _DvInit PROC 27 | ; This routine returns the DESQview major/minor number in ax, and sets up the 28 | ; _IN_DV variable for later use by other DESQview I/F programmes 29 | 30 | push bx 31 | push cx 32 | push dx 33 | mov cx , 'DE' ; Set cx, dx to an invalid date 34 | mov dx , 'SQ' 35 | mov ax , 2B01H ; DOS's Set Date function 36 | int 21H ; Call DOS 37 | cmp al , 0FFH ; Did DOS recognize it? 38 | je short no_desqview ; If not, DESQview isn't running 39 | mov ax , bx ; Else get version number 40 | mov word ptr _in_dv , 1 ; Indicate we're running under DESQview 41 | jmp short dv_end 42 | no_desqview: 43 | xor ax , ax ; Return no DESQview ( version 0 ) 44 | dv_end: 45 | pop dx 46 | pop cx 47 | pop bx 48 | ret 49 | _DvInit ENDP 50 | 51 | api_call PROC 52 | ; This routine takes a programme interface function in bx, and makes that 53 | ; call to DESQview after switching onto a stack that DESQview provides. 54 | 55 | push ax 56 | mov ax , 101AH ; this function to switch to DV's stack 57 | int 15H 58 | mov ax , bx ; Move the desired function into ax 59 | int 15H ; Make the call 60 | mov ax , 1025H ; Function to turn off DV's stack 61 | int 15H ; Make that call 62 | pop ax 63 | ret 64 | api_call ENDP 65 | END 66 | -------------------------------------------------------------------------------- /DVPAUSE.ASM: -------------------------------------------------------------------------------- 1 | ;------------------------------------------------------------------------------; 2 | ; ; 3 | ; File Name : dvpause.asm ; 4 | ; ; 5 | ; Description : gives up the rest of the programmes time slice in DESQview ; 6 | ; ; 7 | ; ; 8 | ; C Prototypes ; 9 | ; ------------ ; 10 | ; void DvPause( void ) ; 11 | ; ; 12 | ;------------------------------------------------------------------------------; 13 | .MODEL SMALL 14 | 15 | public _DvPause 16 | 17 | extrn api_call:near 18 | extrn _in_dv:word 19 | 20 | .CODE 21 | 22 | _DvPause PROC 23 | ; This routine gives up the rest of your programme's time slice. It takes 24 | ; no parameters and returns nothing. 25 | 26 | cmp word ptr _in_dv , 1 ; See if running under DESQview 27 | jne short dvp_x ; If not, do nothing 28 | push bx 29 | mov bx , 1000H ; Else this is pause function call 30 | call near ptr api_call 31 | pop bx 32 | dvp_x: 33 | ret 34 | _DvPause ENDP 35 | END 36 | -------------------------------------------------------------------------------- /DVSR.ASM: -------------------------------------------------------------------------------- 1 | ;------------------------------------------------------------------------------; 2 | ; ; 3 | ; File Name : ; 4 | ; ; 5 | ; Description : Critical process control for under DESQview ; 6 | ; ; 7 | ; ; 8 | ; C Prototypes ; 9 | ; ------------ ; 10 | ; void DvSeize( void ) ; 11 | ; void DvRelease( void ) ; 12 | ; ; 13 | ;------------------------------------------------------------------------------; 14 | .MODEL SMALL 15 | 16 | public _DvSeize 17 | public _DvRelease 18 | 19 | extrn api_call:near 20 | extrn _in_dv:word 21 | 22 | .CODE 23 | 24 | _DvSeize PROC 25 | ; This routine tells DESQview not to slice away from your programme until 26 | ; you make a _DvRelease call. It takes no parameters and returns nothing. 27 | 28 | cmp word ptr _in_dv , 1 ; See if running under DESQview 29 | jne short dvs_x ; If not, do nothing 30 | push bx 31 | mov bx , 101BH ; This is Begin Critical function call 32 | call near ptr api_call 33 | pop bx 34 | dvs_x: 35 | ret 36 | _DvSeize ENDP 37 | 38 | _DvRelease PROC NEAR 39 | ; This routine tells DESQview that it is OK to not to slice away from your 40 | ; programme again. It takes no parameters and returns nothing. 41 | 42 | cmp word ptr _in_dv , 1 ; See if running under DESQview 43 | jne short dvr_x ; If not, do nothing 44 | push bx 45 | mov bx , 101CH ; This is End Critical function call 46 | call near ptr api_call 47 | pop bx 48 | dvr_x: 49 | ret 50 | _DvRelease ENDP 51 | END 52 | -------------------------------------------------------------------------------- /GETDRIVE.ASM: -------------------------------------------------------------------------------- 1 | ;------------------------------------------------------------------------------; 2 | ; ; 3 | ; File Name : getdrive.asm ; 4 | ; ; 5 | ; Description : returns the current DOS drive number ; 6 | ; ; 7 | ; ; 8 | ; C Prototypes ; 9 | ; ------------ ; 10 | ; int DosGetDrive ( void ) ; 11 | ; ; 12 | ;------------------------------------------------------------------------------; 13 | .MODEL SMALL 14 | 15 | Public _DosGetDrive 16 | 17 | .CODE 18 | 19 | _DosGetDrive PROC 20 | mov ah , 19H ; function # 21 | int 21H ; call DOS 22 | cbw ; clear the high byte of ax for return 23 | ret 24 | _DosGetDrive ENDP 25 | END 26 | -------------------------------------------------------------------------------- /GETKEY.ASM: -------------------------------------------------------------------------------- 1 | ;------------------------------------------------------------------------------; 2 | ; ; 3 | ; File Name : getkey.asm ; 4 | ; ; 5 | ; Description : keyboard routines + mouse init ; 6 | ; ; 7 | ; ; 8 | ; C Prototypes ; 9 | ; ------------ ; 10 | ; int GetKey( void ) ; 11 | ; int KeyPressed( void ) ; 12 | ; void InitMouse( void ) ; 13 | ; ; 14 | ;------------------------------------------------------------------------------; 15 | .MODEL SMALL 16 | 17 | include window.inc 18 | 19 | public _GetKey 20 | public _KeyPressed 21 | public _InitMouse 22 | 23 | ;------------------------------------------------------------------------------; 24 | ; ; 25 | ; Get a key or translate mouse actions to a key if mouse installed. ; 26 | ; ; 27 | ;------------------------------------------------------------------------------; 28 | ; 29 | ; defines for getkey 30 | K_ENTER equ 000DH 31 | K_ESC equ 001BH 32 | U_ARROW equ 4800H 33 | D_ARROW equ 5000H 34 | L_ARROW equ 4B00H 35 | R_ARROW equ 4D00H 36 | K_F1 equ 3B00H 37 | POSCOUNT equ 34 38 | NEGCOUNT equ -34 39 | 40 | .DATA 41 | 42 | mouse db 0 ; is there a mouse available 43 | 44 | .CODE 45 | _GetKey PROC 46 | push bp 47 | push si 48 | push di 49 | 50 | cmp mouse , TRUE ; if a mouse is active then do a loop 51 | je short startloop 52 | jmp a_key ; get a key if not 53 | startloop: 54 | mov ax , 11 ; clear any extraneous counts 55 | int 33H 56 | mov ax , 5 ; and button presses 57 | int 33H ; Mouse interrupt 58 | xor si , si 59 | xor di , di 60 | mainloop: 61 | mov ah , 0Bh 62 | int 21H 63 | or al , al 64 | jnz short a_key 65 | 66 | mov ax , 11 67 | int 33H 68 | mov ax , si ; Accumulate vertical mouse motion counts 69 | add ax , dx 70 | mov si , ax 71 | mov ax , di ; Accumulate horizontal mouse motion counts 72 | add ax , cx 73 | mov di , ax 74 | ucheck: 75 | cmp si , NEGCOUNT ; check up motion 76 | jge short dcheck ; Not enough up motion 77 | mov ax , U_ARROW ; Return U_ARROW if enough mouse motion 78 | jmp short key_exit ; exit 79 | 80 | dcheck: 81 | cmp si , POSCOUNT ; check down motion 82 | jle short lcheck ; go and check buttons 83 | mov ax , D_ARROW ; Return D_ARROW if enough mouse motion 84 | jmp short key_exit ; exit 85 | lcheck: 86 | cmp di , NEGCOUNT ; check left motion 87 | jge short rcheck ; Not enough left motion 88 | mov ax , L_ARROW ; Return L_ARROW if enough mouse motion 89 | jmp short key_exit ; exit 90 | rcheck: 91 | cmp di , POSCOUNT ; check right motion 92 | jle short chkbuttons; Not enough right motion..check buttons 93 | mov ax , R_ARROW ; Return R_ARROW if enough mouse motion 94 | jmp short key_exit 95 | chkbuttons: 96 | mov ax , 5 ; Mouse Function 5 97 | xor bx , bx ; Get left button press information 98 | int 33H ; Mouse interrupt 99 | or bx , bx 100 | jz short chkright 101 | mov ax , K_ENTER ; if left button return ENTER 102 | jmp short key_exit 103 | chkright: 104 | mov ax , 5 ; Mouse Function 5 105 | mov bx , 1 ; Get right button press information 106 | int 33H ; Mouse interrupt 107 | or bx , bx 108 | jz short chkmid 109 | mov ax , K_ESC ; if right button return ESC 110 | jmp short key_exit 111 | chkmid: 112 | mov ax , 5 ; Mouse Function 5 113 | mov bx , 2 ; Get middle button press information 114 | int 33H ; Mouse interrupt 115 | or bx , bx 116 | jz short doloop 117 | mov ax , K_F1 ; if middle button return F1 118 | jmp short key_exit 119 | doloop: 120 | jmp short mainloop ; Loop back until anything is done ! 121 | a_key: 122 | mov ah , 07H 123 | int 21H 124 | xor ah , ah 125 | or al , al 126 | jnz short key_exit 127 | 128 | mov ah , 07H 129 | int 21H ; get extended key 130 | mov ah , al ; shift left 8 << 131 | xor al , al 132 | key_exit: 133 | pop di 134 | pop si 135 | pop bp 136 | ret 137 | _GetKey ENDP 138 | 139 | ;------------------------------------------------------------------------------; 140 | ; ; 141 | ; See if a keypress is available. Returns TRUE if there is. ; 142 | ; ; 143 | ;------------------------------------------------------------------------------; 144 | _KeyPressed PROC 145 | mov ah , 0Bh 146 | int 21H 147 | xor ah , ah 148 | or al , al ; a 0 means no key 149 | jz short kp_end 150 | mov ax , TRUE 151 | kp_end: 152 | ret 153 | _KeyPressed ENDP 154 | 155 | ;------------------------------------------------------------------------------; 156 | ; ; 157 | ; Initialise the mouse if there is one. ; 158 | ; ; 159 | ;------------------------------------------------------------------------------; 160 | _InitMouse PROC 161 | xor ax , ax 162 | int 33H 163 | or al , al 164 | jz short mouse_exit 165 | mov al , 01 166 | mouse_exit: 167 | mov mouse , al ; set mouse flag to true or false 168 | ret 169 | _InitMouse ENDP 170 | END 171 | -------------------------------------------------------------------------------- /GETTIME.ASM: -------------------------------------------------------------------------------- 1 | ;------------------------------------------------------------------------------; 2 | ; ; 3 | ; File Name : gettime.asm ; 4 | ; ; 5 | ; Description : Get the time from DOS ; 6 | ; ; 7 | ; ; 8 | ; C Prototypes ; 9 | ; ------------ ; 10 | ; long DosGetTime ( char *hours, char *min, char *secs, char *hund ) ; 11 | ; ; 12 | ;------------------------------------------------------------------------------; 13 | .MODEL SMALL 14 | 15 | Public _DosGetTime 16 | 17 | .CODE 18 | 19 | _DosGetTime PROC 20 | push bp 21 | mov bp , sp 22 | 23 | mov ah , 2CH ; get time function 24 | int 21H ; call DOS 25 | 26 | mov bx , [bp + 4] ; hour 27 | mov [bx] , ch 28 | mov bx , [bp + 6] ; min 29 | mov [bx] , cl 30 | mov bx , [bp + 8] ; sec 31 | mov [bx] , dh 32 | mov bx , [bp + 10] ; hundredths 33 | mov [bx] , dl 34 | mov ax , dx ; pack time into long 35 | mov dx , cx 36 | 37 | pop bp 38 | ret 39 | _DosGetTime ENDP 40 | END 41 | -------------------------------------------------------------------------------- /KEYBOARD.H: -------------------------------------------------------------------------------- 1 | // * * * * * * * * * * * * * * * * * * * * * * * * * 2 | // KEYBOARD.H * 3 | // This include file contains definitions and function declarations * 4 | // for the keyboard module. * 5 | // * 6 | // * * * * * * * * * * * * * * * * * * * * * * * * * 7 | #if !defined(KEYBOARD_H) 8 | #define KEYBOARD_H 9 | 10 | // miscelaneous defines 11 | 12 | #define NULL 0 13 | #define SOH 1 14 | #define BS 8 15 | #define TAB 9 16 | #define LF 0x0A 17 | #define FF 0x0C 18 | #define CR 0x0D 19 | #define ENTER 0x0D 20 | #define CTRLZ 0x1A 21 | #define ESC 0x1B 22 | #define SPACEBAR 0x20 23 | #define SPACE 0x20 24 | 25 | // Extended Codes 26 | 27 | #define ALT_0 0x8100 28 | #define ALT_1 0x7800 29 | #define ALT_2 0x7900 30 | #define ALT_3 0x7A00 31 | #define ALT_4 0x7B00 32 | #define ALT_5 0x7C00 33 | #define ALT_6 0x7D00 34 | #define ALT_7 0x7E00 35 | #define ALT_8 0x7F00 36 | #define ALT_9 0x8000 37 | 38 | #define ALT_MI 0x8200 // Alt_- 39 | #define ALT_EQ 0x8300 // Alt_= 40 | 41 | #define ALT_A 0x1E00 42 | #define ALT_B 0x3000 43 | #define ALT_C 0x2E00 44 | #define ALT_D 0x2000 45 | #define ALT_E 0x1200 46 | #define ALT_F 0x2100 47 | #define ALT_G 0x2200 48 | #define ALT_H 0x2300 49 | #define ALT_I 0x1700 50 | #define ALT_J 0x2400 51 | #define ALT_K 0x2500 52 | #define ALT_L 0x2600 53 | #define ALT_M 0x3200 54 | #define ALT_N 0x3100 55 | #define ALT_O 0x1800 56 | #define ALT_P 0x1900 57 | #define ALT_Q 0x1000 58 | #define ALT_R 0x1300 59 | #define ALT_S 0x1F00 60 | #define ALT_T 0x1400 61 | #define ALT_U 0x1600 62 | #define ALT_V 0x2F00 63 | #define ALT_W 0x1100 64 | #define ALT_X 0x2D00 65 | #define ALT_Y 0x1500 66 | #define ALT_Z 0x2E00 67 | 68 | #define F1 0x3B00 69 | #define F2 0x3C00 70 | #define F3 0x3D00 71 | #define F4 0x3E00 72 | #define F5 0x3F00 73 | #define F6 0x4000 74 | #define F7 0x4100 75 | #define F8 0x4200 76 | #define F9 0x4300 77 | #define F10 0x4400 78 | 79 | // shifted function key codes 80 | 81 | #define SF1 0x5400 82 | #define SF2 0x5500 83 | #define SF3 0x5600 84 | #define SF4 0x5700 85 | #define SF5 0x5800 86 | #define SF6 0x5900 87 | #define SF7 0x5A00 88 | #define SF8 0x5B00 89 | #define SF9 0x5C00 90 | #define SF10 0x5D00 91 | 92 | // ctrl funct key codes 93 | 94 | #define CF1 0x5E00 95 | #define CF2 0x5F00 96 | #define CF3 0x6000 97 | #define CF4 0x6100 98 | #define CF5 0x6200 99 | #define CF6 0x6300 100 | #define CF7 0x6400 101 | #define CF8 0x6500 102 | #define CF9 0x6600 103 | #define CF10 0x6700 104 | 105 | // alt funct key codes 106 | 107 | #define AF1 0x6800 108 | #define AF2 0x6900 109 | #define AF3 0x6A00 110 | #define AF4 0x6B00 111 | #define AF5 0x6C00 112 | #define AF6 0x6D00 113 | #define AF7 0x6E00 114 | #define AF8 0x6F00 115 | #define AF9 0x7000 116 | #define AF10 0x7100 117 | 118 | 119 | #define HOME 0x4700 120 | #define U_ARROW 0x4800 121 | #define PG_UP 0x4900 122 | #define L_ARROW 0x4B00 123 | #define R_ARROW 0x4D00 124 | #define END 0x4F00 125 | #define D_ARROW 0x5000 126 | #define PG_DN 0x5100 127 | #define INS 0x5200 128 | #define DEL 0x5300 129 | #define CTL_HOME 0x7700 130 | #define CTL_UARROW 0x8D00 131 | #define CTL_PG_UP 0x8400 132 | #define CTL_LARROW 0x7300 133 | #define CTL_RARROW 0x7400 134 | #define CTL_END 0x7500 135 | #define CTL_DARROW 0x9100 136 | #define CTL_PG_DN 0x7600 137 | #define BACKTAB 0x0F00 138 | 139 | // 140 | // Function prototypes 141 | // 142 | int GetKey( void ); 143 | int KeyPressed( void ); 144 | 145 | #endif 146 | -------------------------------------------------------------------------------- /KEYCODES.H: -------------------------------------------------------------------------------- 1 | /* * * * * * * * * * * * * * * * * * * * * * * * * * 2 | * * 3 | * This include file contains the keyboard definitions for GetKey. * 4 | * * 5 | * * 6 | * * * * * * * * * * * * * * * * * * * * * * * * * */ 7 | 8 | /* miscelaneous defines */ 9 | 10 | #define NULL 0 11 | #define SOH 1 12 | #define BS 8 13 | #define TAB 9 14 | #define LF 0x0A 15 | #define FF 0x0C 16 | #define CR 0x0D 17 | #define ENTER 0x0D 18 | #define CTRLZ 0x1A 19 | #define ESC 0x1B 20 | #define SPACEBAR 0x20 21 | #define SPACE 0x20 22 | 23 | /* Extended Codes */ 24 | 25 | #define ALT_0 0x8100 26 | #define ALT_1 0x7800 27 | #define ALT_2 0x7900 28 | #define ALT_3 0x7A00 29 | #define ALT_4 0x7B00 30 | #define ALT_5 0x7C00 31 | #define ALT_6 0x7D00 32 | #define ALT_7 0x7E00 33 | #define ALT_8 0x7F00 34 | #define ALT_9 0x8000 35 | 36 | #define ALT_MI 0x8200 /* Alt_- */ 37 | #define ALT_EQ 0x8300 /* Alt_= */ 38 | 39 | #define ALT_A 0x1E00 40 | #define ALT_B 0x3000 41 | #define ALT_C 0x2E00 42 | #define ALT_D 0x2000 43 | #define ALT_E 0x1200 44 | #define ALT_F 0x2100 45 | #define ALT_G 0x2200 46 | #define ALT_H 0x2300 47 | #define ALT_I 0x1700 48 | #define ALT_J 0x2400 49 | #define ALT_K 0x2500 50 | #define ALT_L 0x2600 51 | #define ALT_M 0x3200 52 | #define ALT_N 0x3100 53 | #define ALT_O 0x1800 54 | #define ALT_P 0x1900 55 | #define ALT_Q 0x1000 56 | #define ALT_R 0x1300 57 | #define ALT_S 0x1F00 58 | #define ALT_T 0x1400 59 | #define ALT_U 0x1600 60 | #define ALT_V 0x2F00 61 | #define ALT_W 0x1100 62 | #define ALT_X 0x2D00 63 | #define ALT_Y 0x1500 64 | #define ALT_Z 0x2E00 65 | 66 | #define F1 0x3B00 67 | #define F2 0x3C00 68 | #define F3 0x3D00 69 | #define F4 0x3E00 70 | #define F5 0x3F00 71 | #define F6 0x4000 72 | #define F7 0x4100 73 | #define F8 0x4200 74 | #define F9 0x4300 75 | #define F10 0x4400 76 | 77 | /* shifted function key codes */ 78 | 79 | #define SF1 0x5400 80 | #define SF2 0x5500 81 | #define SF3 0x5600 82 | #define SF4 0x5700 83 | #define SF5 0x5800 84 | #define SF6 0x5900 85 | #define SF7 0x5A00 86 | #define SF8 0x5B00 87 | #define SF9 0x5C00 88 | #define SF10 0x5D00 89 | 90 | /* ctrl funct key codes */ 91 | 92 | #define CF1 0x5E00 93 | #define CF2 0x5F00 94 | #define CF3 0x6000 95 | #define CF4 0x6100 96 | #define CF5 0x6200 97 | #define CF6 0x6300 98 | #define CF7 0x6400 99 | #define CF8 0x6500 100 | #define CF9 0x6600 101 | #define CF10 0x6700 102 | 103 | /* alt funct key codes */ 104 | 105 | #define AF1 0x6800 106 | #define AF2 0x6900 107 | #define AF3 0x6A00 108 | #define AF4 0x6B00 109 | #define AF5 0x6C00 110 | #define AF6 0x6D00 111 | #define AF7 0x6E00 112 | #define AF8 0x6F00 113 | #define AF9 0x7000 114 | #define AF10 0x7100 115 | 116 | 117 | #define HOME 0x4700 118 | #define U_ARROW 0x4800 119 | #define PG_UP 0x4900 120 | #define L_ARROW 0x4B00 121 | #define R_ARROW 0x4D00 122 | #define END 0x4F00 123 | #define D_ARROW 0x5000 124 | #define PG_DN 0x5100 125 | #define INS 0x5200 126 | #define DEL 0x5300 127 | #define CTL_HOME 0x7700 128 | #define CTL_UARROW 0x8D00 129 | #define CTL_PG_UP 0x8400 130 | #define CTL_LARROW 0x7300 131 | #define CTL_RARROW 0x7400 132 | #define CTL_END 0x7500 133 | #define CTL_DARROW 0x9100 134 | #define CTL_PG_DN 0x7600 135 | #define BACKTAB 0x0F00 136 | 137 | -------------------------------------------------------------------------------- /MAKEATTR.ASM: -------------------------------------------------------------------------------- 1 | ;------------------------------------------------------------------------------; 2 | ; ; 3 | ; File Name : makeattr.asm ; 4 | ; ; 5 | ; Description : WINDOW function to make an attribute from a FGC and BGC ; 6 | ; ; 7 | ; ; 8 | ; C Prototypes ; 9 | ; ------------ ; 10 | ; int MakeAttr ( int fgc , int bgc ) ; 11 | ; ; 12 | ;------------------------------------------------------------------------------; 13 | .MODEL SMALL 14 | 15 | include window.inc 16 | 17 | public _MakeAttr 18 | extrn _vdu:word 19 | 20 | .CODE 21 | 22 | _MakeAttr PROC 23 | push bp 24 | mov bp , sp 25 | 26 | cmp vdu , 7 ; do we use mono attributes ? 27 | jne short att_col 28 | cmp ARG_2 , 0 ; does bgc EQ black ? 29 | je short att1 ; yes - jump 30 | mov ax , 70H ; else inverse attribute 31 | jmp short att_end 32 | att1: 33 | cmp ARG_1 , 8 ; is fgc LT GREY 34 | jle short att2 ; jump 35 | mov ax , 0AH ; bright attribute 36 | jmp short att_end 37 | att2: 38 | mov ax , 2 ; normal attribute 39 | jmp short att_end 40 | att_col: 41 | ; 42 | ; attr = bgc * 16 + fgc; 43 | ; 44 | mov ax , ARG_2 ; bgc 45 | mov cl , 4 46 | shl ax , cl 47 | add ax , ARG_1 ; fgc 48 | att_end: 49 | pop bp 50 | ret 51 | _MakeAttr ENDP 52 | END 53 | -------------------------------------------------------------------------------- /MIT-LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2003-2013 Richard Hulse 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining 4 | a copy of this software and associated documentation files (the 5 | "Software"), to deal in the Software without restriction, including 6 | without limitation the rights to use, copy, modify, merge, publish, 7 | distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so, subject to 9 | the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be 12 | included in all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /MODLOG.ASM: -------------------------------------------------------------------------------- 1 | ;------------------------------------------------------------------------------; 2 | ; ; 3 | ; File Name : modlog.asm ; 4 | ; ; 5 | ; Description : logs the boundries of changes on the screen. ; 6 | ; Internal function used by WINDOW modules. ; 7 | ; ; 8 | ;------------------------------------------------------------------------------; 9 | .MODEL SMALL 10 | 11 | include window.inc 12 | 13 | public ModLog 14 | public log_start_x 15 | public log_start_y 16 | public log_end_x 17 | public log_end_y 18 | extrn _mod_flag:word 19 | 20 | .DATA 21 | 22 | log_start_x DW 0 23 | log_start_y DW 0 24 | log_end_x DW 80 ; set to do whole sceen 25 | log_end_y DW 25 ; first time through. 26 | 27 | .CODE 28 | ModLog PROC 29 | ; 30 | ; at entry si points to the WINDOW structure 31 | ; 32 | push bp ; si set to point at WINDOW structure 33 | 34 | mov ax , [si].W_X ; ax used for dec checking of shadow types 35 | mov bx , [si].W_Y 36 | mov cx , [si].W_WID 37 | mov dx , [si].W_HGT 38 | 39 | cmp [si].W_BDR , FALSE ; if there is a border expand to include it 40 | je short leave_alone 41 | dec ax 42 | dec bx 43 | inc cx 44 | inc cx 45 | inc dx 46 | inc dx 47 | leave_alone: 48 | cmp mod_flag , TRUE 49 | je short do_mods 50 | mov log_start_x , ax ; if first time through then set these 51 | mov log_start_y , bx ; to the first WINdows x & y 52 | mov log_end_x , ax 53 | mov log_end_y , bx 54 | mov mod_flag , TRUE 55 | do_mods: 56 | mov bp , [si].W_SHADOW ; if there is a shadow then we have to 57 | or bp , bp ; expand the size of the log data to 58 | jnz short modtype1 ; include its cast. 59 | jmp short mod_log1 60 | modtype1: 61 | inc cx ; all shadows require these three. 62 | inc cx 63 | inc dx 64 | 65 | dec bp 66 | jnz short modtype2 67 | dec ax 68 | dec ax 69 | dec bx 70 | jmp short mod_log1 71 | modtype2: 72 | dec bp 73 | jnz short modtype3 74 | dec bx 75 | jmp short mod_log1 76 | 77 | modtype3: 78 | dec bp 79 | jnz short modtype4 80 | jmp short mod_log1 81 | modtype4: ; nothing needed 82 | dec bp 83 | jnz short mod_log1 84 | dec ax 85 | dec ax 86 | mod_log1: 87 | cmp ax , log_start_x 88 | jge short mod_log2 89 | mov log_start_x , ax 90 | mod_log2: 91 | cmp bx , log_start_y 92 | jge short mod_log3 93 | mov log_start_y , bx 94 | mod_log3: 95 | add cx , ax ; add x + WID 96 | cmp cx , log_end_x 97 | jle short mod_log4 98 | mov log_end_x , cx 99 | mod_log4: 100 | add dx , bx ; add y + HGT 101 | cmp dx , log_end_y 102 | jle short mod_log_end 103 | mov log_end_y , dx 104 | mod_log_end: 105 | ; mov log_start_x , 0 ; debugging 106 | ; mov log_start_y , 0 107 | ; mov log_end_x , 80 108 | ; mov log_end_y , 25 109 | pop bp 110 | ret 111 | ModLog ENDP 112 | END 113 | -------------------------------------------------------------------------------- /MYLIB: -------------------------------------------------------------------------------- 1 | .AUTODEPEND 2 | # *Translator Definitions* 3 | ASSEMBLER = tasm 4 | TLIB = tlib 5 | TLINK = tlink 6 | LIBPATH = D:\BC\LIB 7 | INCLUDEPATH = D:\BC\INCLUDE 8 | 9 | .PRECIOUS : mylib.lib 10 | 11 | .asm.obj : 12 | &$(ASSEMBLER) /uT300 -zn -ml -w2 -x $(?:.obj=.asm) 13 | 14 | LIB_dependencies = \ 15 | beep.obj \ 16 | bioprint.obj \ 17 | doscd.obj \ 18 | dosff.obj \ 19 | dosfn.obj \ 20 | dvinit.obj \ 21 | dvpause.obj \ 22 | dvsr.obj \ 23 | getdrive.obj \ 24 | getkey.obj \ 25 | gettime.obj \ 26 | setdrive.obj \ 27 | spause.obj \ 28 | tpause.obj \ 29 | waittick.obj 30 | 31 | # *Explicit Rules* 32 | mylib.lib: $(LIB_dependencies) 33 | &$(TLIB) /C /E mylib.lib -+$? 34 | 35 | beep.obj : beep.asm 36 | bioprint.obj : bioprint.asm 37 | doscd.obj : doscd.asm 38 | dosff.obj : dosff.asm 39 | dosfn.obj : dosfn.asm 40 | dvinit.obj : dvinit.asm 41 | dvpause.obj : dvpause.asm 42 | dvsr.obj : dvsr.asm 43 | getdrive.obj : getdrive.asm 44 | getkey.obj : getkey.asm 45 | gettime.obj : gettime.asm 46 | setdrive.obj : setdrive.asm 47 | spause.obj : spause.asm 48 | tpause.obj : tpause.asm 49 | waittick.obj : waittick.asm 50 | 51 | 52 | -------------------------------------------------------------------------------- /MYLIB.H: -------------------------------------------------------------------------------- 1 | /* * * * * * * * * * * * * * * * * * * * * * * * * * 2 | * MYLIB.H * 3 | * This header provides function prototypes for the asm functions in * 4 | * my library. * 5 | * * 6 | * * * * * * * * * * * * * * * * * * * * * * * * * */ 7 | #if !defined(MYLIB_H) 8 | #define MYLIB_H 9 | 10 | 11 | /* 12 | * HARDWARE BEEPER PORT FUNCTIONS 13 | * Beep makes a noise of freq , duration in ticks 14 | */ 15 | 16 | void Beep( int , int ); 17 | 18 | /* 19 | * PAUSE FUNCTIONS 20 | */ 21 | 22 | /* waits for specified number of seconds */ 23 | 24 | void SPause( int ); 25 | 26 | /* waits for specified number of ticks */ 27 | 28 | void TPause( int ); 29 | 30 | /* all functions setup for printer # 1 */ 31 | 32 | void BiosPrintInit( void ); 33 | 34 | int BiosPrintStatus( void ); 35 | 36 | int BiosPrintChar( char ); 37 | 38 | /* 39 | * MY DOS FUNCTIONS 40 | */ 41 | 42 | struct dta { 43 | char reserved[21]; 44 | char attrib; 45 | unsigned wr_time; 46 | unsigned wr_date; 47 | long size; 48 | char name[13]; 49 | }; 50 | 51 | int DosGetDrive ( void ); 52 | 53 | int DosSetDrive ( int ); 54 | 55 | int DosCD ( char * ); 56 | 57 | int DosFindFirst ( char * , int , struct dta * ); 58 | 59 | int DosFindNext ( struct dta * ); 60 | 61 | long DosGetTime ( char * , char * , char * , char * ); 62 | 63 | long DosGetFreeSpace ( int ); 64 | 65 | #endif 66 | -------------------------------------------------------------------------------- /MYLIB.LIB: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rhulse/dos-asm-windowing-library/8bc3499a1c626ffbb91d20385c831d1059c1f9f7/MYLIB.LIB -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # MS Dos Windowing Library 2 | 3 | This library was written around 1990, and was inspired by Radio New Zelaland technician Phil Gibbs' C library, which did essentially the same thing. 4 | 5 | The library creates a screen buffer and text windows can be created, layered and moved around. When a window is moved, the library rewrites the windows to the screen buffer from top to bottom, and then flushes the buffer directlt to screen memory. Back in the day, this was the fastest way to update the screen. 6 | 7 | The library does include an option to use the BIOS to update the screen, but this is much slower (or was on 4-8 meghertz XT and AT grade PCs). 8 | 9 | The library was used for a number of small personal projects, and should still compile and be usable. (Feedback on this welcome) 10 | 11 | The main reason I have posted this here is for historical reference, but also so anyone can study or use it. For many years I thought the 1.44 floppy containing this code was lost, but I recently found a copy in a corner of my current machine's hard drive. 12 | 13 | I would be happy to take pull requests for documentation, as it has been many years since a looked at this, and while the individual files have some documentation, I am a but busy these days to trawl through it all. 14 | 15 | ## DOCS 16 | 17 | **WnInit** 18 | 19 | this must be called first to allocate all the buffers and do the required setup. 20 | 21 | **WINDOW \*WnMake ( int , int , int , int , v_col , v_col );** 22 | 23 | This function creates a window at the position and size states with foreground and background colours. 24 | The pointer that is returned can be passed to other functions to change position. 25 | 26 | Windows can be hidden, moved, edited, and have their colours changed. 27 | 28 | Windows can also cast a shadow on any content below. 29 | -------------------------------------------------------------------------------- /SCREEN: -------------------------------------------------------------------------------- 1 | .AUTODEPEND 2 | # *Translator Definitions* 3 | ASSEMBLER = tasm 4 | TLIB = tlib 5 | TLINK = tlink 6 | LIBPATH = D:\BC\LIB 7 | INCLUDEPATH = D:\BC\INCLUDE 8 | #curpos.asm 9 | #cursor.asm 10 | 11 | .PRECIOUS : screen.lib 12 | 13 | .asm.obj : 14 | &$(ASSEMBLER) -q /uT300 -zn -ml -w2 -x $(?:.obj=.asm) 15 | 16 | LIB_dependencies = \ 17 | bginfo.obj \ 18 | bscpos.obj \ 19 | bscsize.obj \ 20 | curthin.obj \ 21 | curhide.obj \ 22 | curfat.obj \ 23 | cursr.obj \ 24 | drawbox.obj \ 25 | modlog.obj \ 26 | vsback.obj \ 27 | vsborder.obj \ 28 | vconfig.obj \ 29 | vsdisp.obj 30 | 31 | # *Explicit Rules* 32 | screen.lib: $(LIB_dependencies) 33 | &$(TLIB) /C /E screen.lib -+$? 34 | 35 | bginfo.obj : bginfo.asm 36 | 37 | bscpos.obj : bscpos.asm 38 | 39 | bscsize.obj : bscsize.asm 40 | 41 | curthin.obj : curthin.asm 42 | 43 | curhide.obj : curhide.asm 44 | 45 | curfat.obj : curfat.asm 46 | 47 | cursr.obj : cursr.asm 48 | 49 | drawbox.obj : drawbox.asm 50 | 51 | modlog.obj : modlog.asm 52 | 53 | vsback.obj : vsback.asm 54 | 55 | vsborder.obj : vsborder.asm 56 | 57 | vconfig.obj : vconfig.asm 58 | 59 | vsdisp.obj : vsdisp.asm 60 | 61 | -------------------------------------------------------------------------------- /SCREEN.H: -------------------------------------------------------------------------------- 1 | // * * * * * * * * * * * * * * * * * * * * * * * * * 2 | // SCREEN.H * 3 | // This include file contains definitions and function declarations * 4 | // for the screen module. * 5 | // * 6 | // * * * * * * * * * * * * * * * * * * * * * * * * * 7 | #if !defined(SCREEN_H) 8 | #define SCREEN_H 9 | // 10 | // type of video screen access 11 | // 12 | #define BIOS 1 // Use only bios functions for screen access 13 | #define NO_SNOW 2 // Snow Free direct access 14 | #define DMA 3 // Direct writes to screen memory ( fastest ) 15 | // 16 | // video defines .. adapter types 17 | // 18 | 19 | #define MDA 0x01 // Monochrome Display Adapter 20 | #define CGA 0x02 // Colour Graphics Adapter 21 | #define EGA 0x03 // Enhanced Graphics Adapter 22 | #define MCGA 0x04 // Multi Colour Graphics Array 23 | #define VGA 0x05 // Video Graphics Array 24 | #define PGA 0x06 // Profesional Graphics Adapter 25 | #define HGC 0x80 // Hercules Graphics Card 26 | #define HG_P 0x81 // Hecules Graphics Plus Card 27 | #define HG_COL 0x82 // Hercules InColour Card 28 | 29 | // 30 | // screen types 31 | // 32 | #define MDA_display 0x01 33 | #define CGA_display 0x02 34 | #define EGA_colour 0x03 35 | #define PS2_mono 0x04 36 | #define PS2_colour 0x05 37 | #define PGA_display 0x06 38 | 39 | // 40 | // video modes 41 | // 42 | #define BW40 0x00 43 | #define CO40 0x01 44 | #define BW80 0x02 45 | #define CO80 0x03 46 | #define LORES_4CO 0x04 47 | #define LORES_BW 0x05 48 | #define LORES_2CO 0x06 49 | #define MONO 0x07 50 | #define PCJR_LORES 0x08 51 | #define PCJR_MIDRES 0x09 52 | #define PCJR_HIRES 0x0A 53 | #define EGA_LORES_16CO 0x0D 54 | #define EGA_MIDRES_16CO 0x0E 55 | #define EGA_HIRES_BW 0x0F 56 | #define EGA_HIRES_16CO 0x10 57 | #define VGA_HIRES_2CO 0x11 58 | #define VGA_HIRES_16CO 0x12 59 | #define VGA_LORES_256CO 0x13 60 | // 61 | // SCREEN module function definations for type checking. 62 | // 63 | void CursorHome( void ); 64 | void CursorHide( void ); 65 | void CursorThin( void ); 66 | void CursorFat( void ); 67 | void VsBorderCol ( int ); 68 | void VsBackground ( int , int , unsigned char ); 69 | void VsDisp( void ); 70 | 71 | #endif 72 | -------------------------------------------------------------------------------- /SCREEN.INC: -------------------------------------------------------------------------------- 1 | ;------------------------------------------------------------------------------; 2 | ; ; 3 | ; This INCLUDE file contains EQU's to make asm modules easier to read ; 4 | ; ; 5 | ;------------------------------------------------------------------------------; 6 | ; Includes for C file. 7 | ; 8 | ; #include "screen.h" function and structure declarations. 9 | ; 10 | ; ENTRY ROUTINE TO USE SCREEN MODULE 11 | ; 12 | ; 13 | ; these make the code easier to read 14 | ; 15 | ARG_1 equ word ptr [bp + 4] ; Argument 1 16 | ARG_2 equ word ptr [bp + 6] ; Argument 2 17 | ARG_3 equ word ptr [bp + 8] ; Argument 3 18 | ARG_4 equ word ptr [bp + 10] ; Argument 4 19 | ARG_5 equ word ptr [bp + 12] ; Argument 5 20 | ARG_6 equ word ptr [bp + 14] ; Argument 6 21 | VAR_1 equ word ptr [bp - 2] ; Variable 1 22 | VAR_2 equ word ptr [bp - 4] ; Variable 2 23 | VAR_3 equ word ptr [bp - 6] ; Variable 3 24 | VAR_4 equ word ptr [bp - 8] ; Variable 4 25 | TRUE equ 1 26 | FALSE equ 0 27 | ON equ 1 28 | OFF equ 0 29 | NULL equ 0 30 | ; 31 | ; used for the shadow column offsets and data. 32 | ; 33 | 34 | ; 35 | ; video adapter definitions 36 | ; 37 | MDA equ 01H ; Monochrome Display adapter 38 | CGA equ 02H ; Colour Graphics Adapter 39 | EGA equ 03H ; Enhanced Graphics Adapter 40 | MCGA equ 04H ; Memory Controller Gate Array 41 | VGA equ 05H ; Video Graphics Array 42 | PGA equ 06H ; Pofessional Graphics Adapter 43 | HGC equ 80H ; Hercules Graphics Adapter 44 | HG_P equ 81H ; Hercules Graphics Plus 45 | HG_COL equ 82H ; Hercules Graphics InColour Card 46 | ; 47 | ; types of video display 48 | ; 49 | MDA_display equ 01H 50 | CGA_display equ 02H 51 | EGA_colour equ 03H 52 | PS2_mono equ 04H 53 | PS2_colour equ 05H 54 | PGA_display equ 06H 55 | ; 56 | ; video adapter mode .... 57 | ; 58 | BW40 equ 00H 59 | CO40 equ 01H 60 | BW80 equ 02H 61 | CO80 equ 03H 62 | LORES_4CO equ 04H 63 | LORES_BW equ 05H 64 | LORES_2CO equ 06H 65 | MONO equ 07H 66 | PCJR_LORES equ 08H 67 | PCJR_MIDRES equ 09H 68 | PCJR_HIRES equ 0AH 69 | EGA_LORES_16CO equ 0DH 70 | EGA_MIDRES_16CO equ 0EH 71 | EGA_HIRES_BW equ 0FH 72 | EGA_HIRES_16CO equ 10H 73 | VGA_HIRES_2CO equ 11H 74 | VGA_HIRES_16CO equ 12H 75 | VGA_LORES_256CO equ 13H 76 | ; 77 | ; address of start of video memory 78 | ; 79 | MDA_addr equ 0B000H ; Start of Monochrome adapter 80 | COL_addr equ 0B800H ; Start of a colour adapter 81 | ; 82 | ; type of screen accesses 83 | ; 84 | BIOS equ 01H ; Use only bios functions for screen access 85 | NO_SNOW equ 02H ; Snow Free direct access 86 | DMA equ 03H ; Direct writes to screen memory ( fastest ) 87 | -------------------------------------------------------------------------------- /SCREEN.LIB: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rhulse/dos-asm-windowing-library/8bc3499a1c626ffbb91d20385c831d1059c1f9f7/SCREEN.LIB -------------------------------------------------------------------------------- /SETDRIVE.ASM: -------------------------------------------------------------------------------- 1 | ;------------------------------------------------------------------------------; 2 | ; ; 3 | ; File Name : setdrive.asm ; 4 | ; ; 5 | ; Description : use DOS to change drives ; 6 | ; ; 7 | ; ; 8 | ; C Prototypes ; 9 | ; ------------ ; 10 | ; ; 11 | ; void DosSetDrive ( int drive_number ) ; 12 | ; ; 13 | ;------------------------------------------------------------------------------; 14 | .MODEL SMALL 15 | 16 | Public _DosSetDrive 17 | 18 | .CODE 19 | 20 | _DosSetDrive PROC 21 | push bp 22 | mov bp , sp 23 | mov dx , word ptr [bp + 4] 24 | mov ah , 0EH ; function # 25 | int 21H ; call DOS 26 | cbw ; clear the high byte of ax for return 27 | pop bp 28 | ret 29 | _DosSetDrive ENDP 30 | END 31 | -------------------------------------------------------------------------------- /SHELL.ASM: -------------------------------------------------------------------------------- 1 | ;------------------------------------------------------------------------------; 2 | ; ; 3 | ; File Name : ; 4 | ; ; 5 | ; Description : ; 6 | ; ; 7 | ; ; 8 | ; C Prototypes ; 9 | ; ------------ ; 10 | ; ; 11 | ; void AllocError ( void ); ; 12 | ; ; 13 | ;------------------------------------------------------------------------------; 14 | ;------------------------------------------------------------------------------; 15 | ; ; 16 | ; Contains window function. ; 17 | ; ; 18 | ;------------------------------------------------------------------------------; 19 | _TEXT SEGMENT BYTE PUBLIC 'CODE' 20 | _TEXT ENDS 21 | _DATA SEGMENT WORD PUBLIC 'DATA' 22 | _DATA ENDS 23 | 24 | DGROUP GROUP _DATA 25 | ASSUME CS: _TEXT , DS: DGROUP , SS: DGROUP , ES: DGROUP 26 | 27 | include window.inc 28 | 29 | -------------------------------------------------------------------------------- /SPAUSE.ASM: -------------------------------------------------------------------------------- 1 | ;------------------------------------------------------------------------------; 2 | ; ; 3 | ; File Name : spause.asm ; 4 | ; ; 5 | ; Description : wait for specified number of seconds ; 6 | ; ; 7 | ; C Prototypes ; 8 | ; ------------ ; 9 | ; void SPause( int ) ; 10 | ; ; 11 | ;------------------------------------------------------------------------------; 12 | .MODEL SMALL 13 | 14 | Public _SPause 15 | extrn __WaitTick:near 16 | 17 | .CODE 18 | 19 | _SPause PROC 20 | push bp 21 | mov bp , sp 22 | push cx 23 | mov ax , [ bp+4 ] 24 | mov cx , 18 25 | imul cl 26 | mov cx , ax 27 | call near ptr __WaitTick 28 | pop cx 29 | pop bp 30 | ret 31 | 32 | _SPause ENDP 33 | END 34 | -------------------------------------------------------------------------------- /TPAUSE.ASM: -------------------------------------------------------------------------------- 1 | ;------------------------------------------------------------------------------; 2 | ; ; 3 | ; File Name : tpause.asm ; 4 | ; ; 5 | ; Description : wait for specified number of clock ticks ; 6 | ; ; 7 | ; C Prototypes ; 8 | ; ------------ ; 9 | ; void TPause( int ) ; 10 | ; ; 11 | ;------------------------------------------------------------------------------; 12 | .MODEL SMALL 13 | 14 | Public _TPause 15 | extrn __WaitTick:near 16 | 17 | .CODE 18 | 19 | _TPause PROC 20 | push bp 21 | mov bp , sp 22 | push cx 23 | mov cx , [ bp+4 ] 24 | call near ptr __WaitTick 25 | pop cx 26 | pop bp 27 | ret 28 | _TPause ENDP 29 | END 30 | -------------------------------------------------------------------------------- /VCONFIG.ASM: -------------------------------------------------------------------------------- 1 | ;------------------------------------------------------------------------------; 2 | ; ; 3 | ; File Name : vconfig.asm ; 4 | ; ; 5 | ; Description : WINDOW module video configuration functions ; 6 | ; Internal functions used by WINDOW modules. ; 7 | ; ; 8 | ;------------------------------------------------------------------------------; 9 | .MODEL SMALL 10 | 11 | include window.inc 12 | 13 | public GetVideoConfig 14 | ; FindPS2 15 | ; FindEGA 16 | ; FindCGA 17 | ; FindMono 18 | ; Find6845 19 | ; FindActive 20 | ; FoundDevice 21 | public GetVideoData 22 | public SetVideoMode 23 | public port_address ; address to check for retrace 24 | extrn _mode:word 25 | extrn _vpage:word 26 | extrn _inactive_adapter:word 27 | extrn _active_adapter:word 28 | extrn _active_screen:word 29 | extrn _inactive_screen:word 30 | 31 | .CODE 32 | ;------------------------------------------------------------------------------; 33 | ; Gets data on video systems and displays. ; 34 | ; look for the various video subsytems using various subroutines whose ; 35 | ; addresses are tabulated in TestSequence each subroutine sets flags to ; 36 | ; indicate whether subsequent subroutines need to be called. ; 37 | ;------------------------------------------------------------------------------; 38 | GetVideoConfig PROC 39 | push bp 40 | push si 41 | 42 | mov cx , OFFSET DGROUP:NumberOfTests 43 | mov si , OFFSET DGROUP:TestSequence 44 | vidcon1: 45 | lodsb ; AL = flag 46 | test al , al 47 | lodsw ; AX = subroutine address 48 | jz short vidcon2 ; skip subroutine if flag is FALSE 49 | 50 | push si 51 | push cx 52 | call ax ; call subroutine 53 | pop cx 54 | pop si 55 | vidcon2: 56 | loop vidcon1 57 | 58 | call FindActive ; determine which subsystem is active 59 | 60 | pop si ; exit routine 61 | pop bp 62 | ret 63 | 64 | GetVideoConfig ENDP 65 | 66 | ;------------------------------------------------------------------------------; 67 | ; Subroutine called by GetVideoConfig. ; 68 | ; This calls int 10H func 1AH to determine the video bios combination code ; 69 | ; ( DCC ) for each present video subsystem ; 70 | ;------------------------------------------------------------------------------; 71 | FindPS2 PROC 72 | mov ax , 1A00H 73 | int 10H 74 | cmp al , 1AH 75 | jne short find_ps4 ; exit if not supported ie. no VGA or MCGA 76 | 77 | ; convert BIOS DCCs into specific subsystems & displays 78 | 79 | mov cx , bx 80 | xor bh , bh ; BX = DCC for active subsystem 81 | or ch , ch 82 | jz short find_ps1 ; jump if only one subsystem present 83 | 84 | mov bl , ch ; BX = inactive DCC 85 | add bx , bx 86 | mov ax , [bx + OFFSET DGROUP: DCCTable] 87 | 88 | mov inactive_adapter , al 89 | mov inactive_screen , ah 90 | 91 | mov bl , cl 92 | xor bh , bh ; BX = active DCC 93 | find_ps1: 94 | add bx , bx 95 | mov ax , [bx + OFFSET DGROUP: DCCTable] 96 | 97 | mov active_adapter , al 98 | mov active_screen , ah 99 | 100 | ; reset flags for subsystems that have been ruled out 101 | 102 | mov byte ptr EGAFlag , FALSE 103 | mov byte ptr CGAFlag , FALSE 104 | 105 | cmp active_screen , MDA ; if there is an MDA present then 106 | jne short find_ps2 ; a hercules card cant be ruled out 107 | mov active_screen , 0 ; reset data 108 | mov active_adapter , 0 109 | jmp short find_ps4 ; dont reset flag. 110 | find_ps2: 111 | cmp inactive_screen , MDA ; same as above 112 | jne short find_ps3 ; 113 | mov inactive_screen , 0 114 | mov inactive_adapter , 0 115 | jmp short find_ps4 ; dont reset flag. 116 | find_ps3: 117 | mov byte ptr MonoFlag , FALSE 118 | find_ps4: 119 | ret 120 | 121 | FindPS2 ENDP 122 | 123 | ;------------------------------------------------------------------------------; 124 | ; Subroutine called by GetVideoConfig. ; 125 | ; Look for an EGA . This is done by calling an EGA BIOS function that ; 126 | ; doesn't exist in the default ( CGA , MDA ) BIOS ; 127 | ; caller: ah = flags ; 128 | ; returns: ah = flags ; 129 | ; VideoOType & display updated ; 130 | ;------------------------------------------------------------------------------; 131 | FindEGA PROC 132 | mov bl , 10H ; subfunction 10h ( return EGA info ) 133 | mov ah , 12H ; function number 134 | int 10H ; call BIOS for info 135 | ; if not present then BL != 10H 136 | ; CL = switch setting 137 | cmp bl , 10H 138 | je short find_ega2 ; jump if no EGA 139 | 140 | mov al , cl 141 | shr al , 1 ; check switches / 2 142 | mov bx , OFFSET DGROUP: EGADisplays 143 | xlat ; determine type from switches 144 | mov ah , al ; AH = display type 145 | mov al , EGA ; AL = Card type 146 | call FoundDevice 147 | 148 | cmp ah , MDA_display 149 | je short find_ega1 ; jump if EGA has MONO monitor 150 | mov byte ptr CGAFlag , FALSE; no CGA if EGA has colour display 151 | jmp short find_ega2 152 | find_ega1: 153 | mov byte ptr MonoFlag , FALSE ; EGA has a mono display so 154 | ; MDA and HERC ruled out 155 | find_ega2: 156 | ret 157 | 158 | FindEGA ENDP 159 | ;------------------------------------------------------------------------------; 160 | ; Subroutine called by GetVideoConfig. ; 161 | ; FindCGA is done by looking for the CGA's 6845 CRTC at I/O port 3D4H. ; 162 | ; ; 163 | ;------------------------------------------------------------------------------; 164 | FindCGA PROC 165 | 166 | mov dx , 3D4H ; DX = CRTC address port 167 | call Find6845 168 | jc short find_cga1 ; jump if not present 169 | 170 | mov al , CGA 171 | mov ah , CGA_display 172 | call FoundDevice 173 | find_cga1: 174 | ret 175 | FindCGA ENDP 176 | 177 | ;------------------------------------------------------------------------------; 178 | ; Subroutine called by GetVideoConfig. ; 179 | ; ; 180 | ; ; 181 | ; This is done by looking for the MDA 6845 CRTC at I/O port 3B4H . ; 182 | ; If a 6845 is found , the subroutine distinguishes between an MDA ; 183 | ; and A HERC card by monitoring bit 7 of the CRT status byte. ; 184 | ; This bit chinges on HERC adapters only . HERC cards are identified by ; 185 | ; bits 4 - 6 of the CRT Status Value : 001B = HGC+ ; 186 | ; 101B = HGC InColor card ; 187 | ; returns with variables updated ; 188 | ;------------------------------------------------------------------------------; 189 | FindMono PROC 190 | mov dx , 3B4H ; DX = CRTC address port 191 | call Find6845 192 | jc short find_m4 193 | 194 | mov dl ,0BAH ; DX = 3BAH ( status port ) 195 | in al , dx 196 | and al , 80H 197 | mov ah , al ; AH = bit 7 ( vertical sync on HGC ) 198 | mov cx , 8000H ; do this 32768 times !!! 199 | find_m1: 200 | in al , dx 201 | and al , 80H ; isolate bit 7 202 | cmp ah , al 203 | loope short find_m1 ; wait for bit 7 to change 204 | jne short find_m2 ; if bit 7 changes its a Hercules 205 | 206 | mov al , MDA ; if bit 7 didn't change its an MDA 207 | mov ah , MDA_display 208 | call FoundDevice 209 | jmp short find_m4 210 | find_m2: 211 | in al , dx 212 | mov dl , al ; DL = value from status port 213 | and dl , 01110000B ; mask off bits 4 - 6 214 | 215 | mov ah , MDA_display ; assume a mono display 216 | 217 | mov al , HG_P ; look for HERC+ 218 | cmp dl , 00010000B 219 | je short find_m3 220 | 221 | mov al , HG_COL ; look for an Incolor Card 222 | mov ah , EGA_colour 223 | cmp dl , 01010000B 224 | je short find_m3 225 | 226 | mov al , HGC ; must be an HGC 227 | mov ah , MDA_display 228 | find_m3: 229 | call FoundDevice 230 | find_m4: 231 | ret 232 | 233 | FindMono ENDP 234 | 235 | ;------------------------------------------------------------------------------; 236 | ; Subroutine called by GetVideoConfig. ; 237 | ; This routine detects the precense of the CRTC on an MDA , CGA , or HGC ; 238 | ; the technique is to write to and read register 0FH of the chip ; 239 | ; ( Cursor Location Low ). If the same value is read as writen it assumes ; 240 | ; the chip is present at the specified address ; 241 | ; callers: DX = port address ; 242 | ; returns: cf set if not present ; 243 | ;------------------------------------------------------------------------------; 244 | Find6845 PROC 245 | mov al , 0FH 246 | out dx , al ; select 6845 register 0FH 247 | inc dx 248 | 249 | in al , dx ; get cuurent cursor low value 250 | mov ah , al ; save in ah 251 | mov al , 66H ; arbitrary value 252 | out dx , al ; try to write it 253 | 254 | mov cx , 100H 255 | find_port1: 256 | loop find_port1 ; short loop to wait for 6845 to respond 257 | 258 | in al , dx 259 | xchg ah , al ; AH = returned value 260 | ; AL = original value 261 | out dx , al ; restore original value 262 | 263 | cmp ah , 66H ; has 6845 responded ? 264 | je short find_port2 ; jump if it did.. cf is reset 265 | 266 | stc ; set cf if no 6845 present 267 | find_port2: 268 | ret 269 | 270 | Find6845 ENDP 271 | 272 | ;------------------------------------------------------------------------------; 273 | ; Subroutine called by GetVideoConfig. ; 274 | ; This routine stores the active data as active_adapter and active_screen. ; 275 | ; The current video mode allways determines which subsystem is active. ; 276 | ;------------------------------------------------------------------------------; 277 | FindActive PROC 278 | 279 | cmp inactive_adapter , 0 280 | je short find_ac3 ; exit if only one subsystem 281 | 282 | cmp active_adapter , 4 ; exit if MCGA or VGA present 283 | jge short find_ac3 284 | 285 | cmp inactive_adapter , 4 ; int 10H / 1aH has already done 286 | jge short find_ac3 ; the work 287 | 288 | push es 289 | xor ax , ax ; check bios area for mode 290 | mov es , ax ; segment into es 291 | mov al , es:[449H] ; check location 292 | pop es 293 | 294 | and al , 7 295 | cmp al , 7 ; jump if mono 296 | je short find_ac1 ; ( mode 7 or 0FH ) 297 | 298 | cmp active_screen , MDA_display 299 | jne short find_ac3 ; exit if display0 is colour 300 | jmp short find_ac2 301 | find_ac1: 302 | cmp active_screen , MDA_display 303 | je short find_ac3 ; exit if active_screen is MONO 304 | find_ac2: 305 | mov al , active_screen ; swap data for 1 and 2 306 | xchg al , inactive_screen ; make active_adapter currently active 307 | mov active_screen , al 308 | mov ah , active_adapter 309 | xchg ah , inactive_adapter 310 | mov active_adapter , ah 311 | find_ac3: 312 | ret 313 | 314 | FindActive ENDP 315 | 316 | ;------------------------------------------------------------------------------; 317 | ; Subroutine called by GetVideoConfig. ; 318 | ; This routine updates the list of subsystems ; 319 | ; Caller: ah = display # ; 320 | ; al = subsystem # ; 321 | ; destroys bx ; 322 | ;------------------------------------------------------------------------------; 323 | FoundDevice PROC 324 | cmp active_adapter , 0 325 | jne short find_d1 ; jump if not first subsystem 326 | mov active_screen , ah 327 | mov active_adapter , al 328 | jmp short find_d2 ; jump if first subsystem 329 | find_d1: 330 | mov inactive_screen , ah 331 | mov inactive_adapter , al ; must be second system 332 | find_d2: 333 | ret 334 | FoundDevice ENDP 335 | 336 | _TEXT ENDS 337 | ;------------------------------------------------------------------------------; 338 | ; Data used by GetVideoConfig. ; 339 | ;------------------------------------------------------------------------------; 340 | .DATA 341 | EGADisplays DB CGA_display 342 | DB EGA_colour 343 | DB MDA_display 344 | DB CGA_display 345 | DB EGA_colour 346 | DB MDA_display 347 | 348 | DCCTable DB 0 , 0 349 | DB MDA , MDA_display 350 | DB CGA , CGA_display 351 | DB 0 , 0 352 | DB EGA , EGA_colour 353 | DB EGA , MDA_display 354 | DB PGA , PGA_display 355 | DB VGA , PS2_mono 356 | DB VGA , PS2_colour 357 | DB 0 , 0 358 | DB MCGA , EGA_colour 359 | DB MCGA , PS2_mono 360 | DB MCGA , PS2_colour 361 | 362 | TestSequence DB TRUE ; all flags set to true 363 | DW FindPS2 364 | 365 | EGAFlag DB TRUE 366 | DW FindEGA 367 | 368 | CGAFlag DB TRUE 369 | DW FindCGA 370 | 371 | MonoFlag DB TRUE 372 | DW FindMono 373 | 374 | NumberOfTests EQU ($-TestSequence) / 3 375 | 376 | ;------------------------------------------------------------------------------; 377 | ; ; 378 | ;Gets the current video mode and page from the BIOS data area and stores them. ; 379 | ; ; 380 | ;------------------------------------------------------------------------------; 381 | 382 | port_address DW 0 ; address to check for retrace 383 | 384 | .CODE 385 | GetVideoData PROC 386 | push es 387 | 388 | xor ax , ax 389 | mov es , ax ; check bios area for mode .. segment into es 390 | 391 | mov al , es:[449H] ; check location 392 | mov mode , ax ; Set mode MONO or COLour */ 393 | 394 | mov al , es:[462H] ; get current page 395 | mov vpage , ax ; save it 396 | 397 | mov ax , es:[463H] ; setup CRTC base address of active card 398 | add ax , 6 ; add 6 to get status register 399 | mov port_address , ax ; save address 400 | 401 | pop es ; restore old es 402 | ret 403 | GetVideoData ENDP 404 | 405 | ;------------------------------------------------------------------------------; 406 | ; ; 407 | ; Restore the old video environment before exiting. ; 408 | ; ; 409 | ;------------------------------------------------------------------------------; 410 | SetVideoMode PROC 411 | ; mode required is in al 412 | xor ah , ah ; function 0 413 | int 10H ; call bios 414 | ret 415 | SetVideoMode ENDP 416 | END 417 | -------------------------------------------------------------------------------- /VSBACK.ASM: -------------------------------------------------------------------------------- 1 | ;------------------------------------------------------------------------------; 2 | ; ; 3 | ; File Name : vsback.asm ; 4 | ; ; 5 | ; Description : Set the character to use a fill for the background. ; 6 | ; ; 7 | ; C Prototypes ; 8 | ; ------------ ; 9 | ; void VsBackground ( int fgc , int bgc , unsigned char fill ); ; 10 | ; ; 11 | ;------------------------------------------------------------------------------; 12 | .MODEL SMALL 13 | 14 | include window.inc 15 | 16 | public _VsBackground 17 | extrn _MakeAttr:near 18 | extrn _vsfiller:word 19 | extrn log_start_x:word 20 | extrn log_start_y:word 21 | extrn log_end_x:word 22 | extrn log_end_y:word 23 | 24 | .CODE 25 | _VsBackground PROC 26 | push bp 27 | mov bp , sp 28 | ; attr = MakeAttr ( fgc , bgc ) * 256; 29 | ; 30 | push ARG_2 31 | push ARG_1 32 | call near ptr _MakeAttr 33 | add sp , 4 34 | mov ah , al ; attribute in ah 35 | mov al , byte ptr [bp + 8] ; Argument 3 + 'x' 36 | mov vsfiller , ax 37 | 38 | mov log_start_x , 0 39 | mov log_start_y , 0 40 | mov log_end_x , 80 ; set mod log to do whole sceen 41 | mov log_end_y , 25 ; to show the change. 42 | 43 | pop bp 44 | ret 45 | _VsBackground ENDP 46 | END 47 | -------------------------------------------------------------------------------- /VSBORDER.ASM: -------------------------------------------------------------------------------- 1 | ;------------------------------------------------------------------------------; 2 | ; ; 3 | ; File Name : vsborder.asm ; 4 | ; ; 5 | ; Description : controls the hardware border control functions ; 6 | ; ; 7 | ; ; 8 | ; C Prototypes ; 9 | ; ------------ ; 10 | ; void VsBorderCol ( int colour ) ; 11 | ; ; 12 | ;------------------------------------------------------------------------------; 13 | .MODEL SMALL 14 | 15 | include window.inc 16 | 17 | public VsBorder 18 | public _VsBorderCol 19 | extrn _vdu:word 20 | 21 | ;------------------------------------------------------------------------------; 22 | ; ; 23 | ; This saves or restores the overscan colour. ; 24 | ; called by setupvideo and WnExit ; 25 | ;------------------------------------------------------------------------------; 26 | .DATA 27 | 28 | old_border_col DB 0 ; old colour of overscan 29 | 30 | .CODE 31 | VsBorder PROC 32 | ; action is in dx 33 | cmp vdu , MONO ; if mono vdu no border 34 | je short vsb2 35 | mov ah , 10H ; function 10H 36 | cmp dx , 1 ; is it 1 ( save ) 37 | jne short vsb1 38 | 39 | mov al , 8 ; sub function 8 get border colour 40 | int 10H 41 | mov old_border_col , bh 42 | jmp short vsb2 43 | vsb1: 44 | cmp dx , 2 ; is it 2 ( restore ) 45 | jne short vsb2 ; exit if not 46 | 47 | mov al , 1 ; sub function 1 set border colour 48 | mov bh , old_border_col 49 | int 10H 50 | vsb2: 51 | ret 52 | VsBorder ENDP 53 | 54 | ;------------------------------------------------------------------------------; 55 | ; ; 56 | ; This alters the overscan colour. ; 57 | ; ; 58 | ;------------------------------------------------------------------------------; 59 | _VsBorderCol PROC 60 | push bp 61 | mov bp , sp 62 | 63 | cmp vdu , MONO ; if mono vdu no bordercol 64 | je short vsbcol1 65 | 66 | mov ax , ARG_1 67 | mov bh , al ; set bh to colour 68 | mov ah , 10H ; function 10H 69 | mov al , 1 ; sub function 1 set border colour 70 | int 10H 71 | vsbcol1: 72 | pop bp 73 | ret 74 | _VsBorderCol ENDP 75 | END 76 | -------------------------------------------------------------------------------- /VSDISP.ASM: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rhulse/dos-asm-windowing-library/8bc3499a1c626ffbb91d20385c831d1059c1f9f7/VSDISP.ASM -------------------------------------------------------------------------------- /WAITTICK.ASM: -------------------------------------------------------------------------------- 1 | ;------------------------------------------------------------------------------; 2 | ; ; 3 | ; File Name : waittick.asm ; 4 | ; ; 5 | ; Description : waits for one timer tick to tick over ! ; 6 | ; called by SPause and TPause ; 7 | ; ; 8 | ;------------------------------------------------------------------------------; 9 | .MODEL SMALL 10 | 11 | Public __WaitTick 12 | 13 | .CODE 14 | 15 | ; call with cx set to number of ticks to wait 16 | 17 | __WaitTick PROC 18 | push es 19 | push ax 20 | push dx 21 | 22 | xor ax , ax 23 | mov es , ax 24 | wt1: 25 | mov ax , WORD PTR es:[46CH] 26 | mov dx , WORD PTR es:[46EH] 27 | wt2: 28 | cmp ax , WORD PTR es:[46CH] ; is MSB different ? 29 | jne short wt3 ; yes jump and reload 30 | cmp dx , WORD PTR es:[46EH] ; is LSB different ? 31 | je short wt2 ; no - compare again 32 | wt3: 33 | loop short wt1 34 | 35 | pop dx 36 | pop ax 37 | pop es 38 | ret 39 | __WaitTick ENDP 40 | END 41 | -------------------------------------------------------------------------------- /WIN: -------------------------------------------------------------------------------- 1 | .AUTODEPEND 2 | # *Translator Definitions* 3 | ASSEMBLER = tasm 4 | TLIB = tlib 5 | TLINK = tlink 6 | LIBPATH = D:\BC\LIB 7 | INCLUDEPATH = D:\BC\INCLUDE 8 | 9 | .PRECIOUS : window.lib 10 | 11 | .asm.obj : 12 | &$(ASSEMBLER) /uT300 -q -zn -ml -w2 -x $(?:.obj=.asm) 13 | 14 | LIB_dependencies = \ 15 | allocerr.obj \ 16 | chgattr.obj \ 17 | makeattr.obj \ 18 | wnact.obj \ 19 | wnbcol.obj \ 20 | wnbchg.obj \ 21 | wnborder.obj \ 22 | wnclose.obj \ 23 | wnclosea.obj \ 24 | wncls.obj \ 25 | wncore.obj \ 26 | wncurson.obj \ 27 | wndeact.obj \ 28 | wnedit.obj \ 29 | wngetatt.obj \ 30 | wngetcur.obj \ 31 | wnhide.obj \ 32 | wnhideal.obj \ 33 | wnint24.obj \ 34 | wnkill.obj \ 35 | wnkillal.obj \ 36 | wnmake.obj \ 37 | wnmove.obj \ 38 | wnopen.obj \ 39 | wnprint.obj \ 40 | wnprintx.obj \ 41 | wnpxya.obj \ 42 | wnsactco.obj \ 43 | wnscroll.obj \ 44 | wnsetatt.obj \ 45 | wnsetcur.obj \ 46 | wnshadow.obj \ 47 | wnshoff.obj \ 48 | wntitle.obj 49 | 50 | # *Explicit Rules* 51 | window.lib: $(LIB_dependencies) 52 | &$(TLIB) /C /E window.lib -+$? 53 | 54 | allocerr.obj : allocerr.asm 55 | 56 | chgattr.obj : chgattr.asm 57 | 58 | makeattr.obj : makeattr.asm 59 | 60 | wnact.obj : wnact.asm 61 | 62 | wnbcol.obj : wnbcol.asm 63 | 64 | wnbchg.obj : wnbchg.asm 65 | 66 | wnborder.obj : wnborder.asm 67 | 68 | wnclose.obj : wnclose.asm 69 | 70 | wnclosea.obj : wnclosea.asm 71 | 72 | wncls.obj : wncls.asm 73 | 74 | wncore.obj : wncore.asm 75 | 76 | wncurson.obj : wncurson.asm 77 | 78 | wndeact.obj : wndeact.asm 79 | 80 | wnedit.obj : wnedit.asm 81 | 82 | wngetatt.obj : wngetatt.asm 83 | 84 | wngetcur.obj : wngetcur.asm 85 | 86 | wnhide.obj : wnhide.asm 87 | 88 | wnhideal.obj : wnhideal.asm 89 | 90 | wnint24.obj : wnint24.asm 91 | 92 | wnkill.obj : wnkill.asm 93 | 94 | wnkillal.obj : wnkillal.asm 95 | 96 | wnmake.obj : wnmake.asm 97 | 98 | wnmove.obj : wnmove.asm 99 | 100 | wnopen.obj : wnopen.asm 101 | 102 | wnprint.obj : wnprint.asm 103 | 104 | wnprintx.obj : wnprintx.asm 105 | 106 | wnpxya.obj : wnpxya.asm 107 | 108 | wnsactco.obj : wnsactco.asm 109 | 110 | wnscroll.obj : wnscroll.asm 111 | 112 | wnsetatt.obj : wnsetatt.asm 113 | 114 | wnsetcur.obj : wnsetcur.asm 115 | 116 | wnshadow.obj : wnshadow.asm 117 | 118 | wnshoff.obj : wnshoff.asm 119 | 120 | wntitle.obj : wntitle.asm 121 | 122 | -------------------------------------------------------------------------------- /WINDOW.H: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rhulse/dos-asm-windowing-library/8bc3499a1c626ffbb91d20385c831d1059c1f9f7/WINDOW.H -------------------------------------------------------------------------------- /WINDOW.INC: -------------------------------------------------------------------------------- 1 | ;------------------------------------------------------------------------------; 2 | ; ; 3 | ; This INCLUDE file contains EQU's to make asm modules easier to read ; 4 | ; ; 5 | ;------------------------------------------------------------------------------; 6 | ; Includes for C file. 7 | ; 8 | ; #include "window.h" function and structure declarations. 9 | ; #include "keycodes.h" keycodes returned by ketpress 10 | ; #include "easyc.h" use this to make C code easier to read. 11 | ; 12 | ; ENTRY ROUTINE TO USE WINDOW MODULE 13 | ; 14 | ; These globals tell WnInit what to do. They must be set BEFORE 15 | ; WnInit is called. Only video_method can be changed during run-time. 16 | ; These are sugested values and are the defaults.ie no need to enter them 17 | ; unless you want to change one to a value other than the ones shown. 18 | ; 19 | ; hide_cursor = TRUE; /* hides the cursor off screen */ 20 | ; save_screen = TRUE; /* save the screen and cursor at the programmes entry */ 21 | ; video_method = DMA; /* use direct screen writes */ 22 | ; snow_free = TRUE; /* if a CGA is active then do snow free screen writes */ 23 | ; shadow_attr = TRUE; /* use attribute shadowing if colour is available */ 24 | ; mode_change = TRUE; /* if false then use any 80 x 25 text mode */ 25 | ; /* otherwise try for 80 x 25 colour text */ 26 | ; mono_attr = FALSE /* use monochrome attributes on colour system */ 27 | ; 28 | ; WnInit(); /* set up window module variables */ 29 | ; /* MUST be called betore any window functions are called */ 30 | ; InitMouse(); /* initialise the mouse if there is one */ 31 | ; 32 | ; After WnInit the variable `vdu' can be set to a value other than 7 33 | ; to force dof to use monochrome attributes. Use to provide a better 34 | ; display on Laptops. 35 | ; 36 | ; EXIT ROUTINE 37 | ; 38 | ; ExitWindow resets and restores anything that was changed 39 | ; in WnInit automatically. 40 | ; 41 | ; WnExit(); this must always be the last function in a programme 42 | ; 43 | ; If malloc is used the the function AllocError(); can be used 44 | ; to exit the programme if there is an allocation error. This 45 | ; fuction does a proper tidy up before exiting. 46 | 47 | ; 48 | ; WINDOW STRUCTURE ....coresponds with the structure in window.h 49 | ; 50 | WINDOW STRUC 51 | 52 | W_WID DW ? ; [reg + 0 ] width of window 53 | W_HGT DW ? ; [reg + 2 ] height of window 54 | W_X DW ? ; [reg + 4 ] x position on screen 55 | W_Y DW ? ; [reg + 6 ] y position on screen 56 | W_FGC DW ? ; [reg + 8 ] fg colour of window 57 | W_BGC DW ? ; [reg + 10] bg colour of window 58 | W_CURSX DW ? ; [reg + 12] x position of cursor 59 | W_CURSY DW ? ; [reg + 14] y position of cursor 60 | W_SHADOW DW ? ; [reg + 16] shadow type 61 | W_SHADCHAR DW ? ; [reg + 18] shadow character 62 | W_BDR DW ? ; [reg + 20] border type 63 | W_BDR_ATTR DW ? ; [reg + 22] colour of border 64 | W_BDR_CHG DW ? ; [reg + 24] change bdr colour if active 65 | W_OPEN DW ? ; [reg + 26] window open ??? 66 | W_HIDE DW ? ; [reg + 28] is it hidden ?? 67 | W_PREV DW ? ; [reg + 30] ptr to previous win 68 | W_NEXT DW ? ; [reg + 32] ptr to next window 69 | W_SELF DW ? ; [reg + 34] ptr to self for checking 70 | W_COPT DW ? ; [reg + 36] use this for anything 71 | W_PTR DW ? ; [reg + 38] ptr to virtual screen 72 | W_TITLE DW ? ; [reg + 40] the windows title 73 | W_RES DW ? ; [reg + 42] resource pointer 74 | 75 | WINDOW ENDS 76 | 77 | SIZEOF_WINDOW equ 44 78 | ; 79 | ; these make the code easier to read 80 | ; 81 | ARG_1 equ word ptr [bp + 4] ; Argument 1 82 | ARG_2 equ word ptr [bp + 6] ; Argument 2 83 | ARG_3 equ word ptr [bp + 8] ; Argument 3 84 | ARG_4 equ word ptr [bp + 10] ; Argument 4 85 | ARG_5 equ word ptr [bp + 12] ; Argument 5 86 | ARG_6 equ word ptr [bp + 14] ; Argument 6 87 | VAR_1 equ word ptr [bp - 2] ; Variable 1 88 | VAR_2 equ word ptr [bp - 4] ; Variable 2 89 | VAR_3 equ word ptr [bp - 6] ; Variable 3 90 | VAR_4 equ word ptr [bp - 8] ; Variable 4 91 | TRUE equ 1 92 | FALSE equ 0 93 | NULL equ 0 94 | ; 95 | ; used for the shadow column offsets and data. 96 | ; 97 | ONE_LINE equ 160 ; Length of a line in BYTES ! 98 | Offset1 equ 2 ; Offset of ONE column ( 2 bytes ) 99 | Offset2 equ 4 ; Offset of TWO columns ( 4 bytes ) 100 | Offset3 equ 164 ; 101 | Offset4 equ 156 ; 102 | 103 | ; 104 | ; video adapter definitions 105 | ; 106 | MDA equ 01H ; Monochrome Display adapter 107 | CGA equ 02H ; Colour Graphics Adapter 108 | EGA equ 03H ; Enhanced Graphics Adapter 109 | MCGA equ 04H ; Memory Controller Gate Array 110 | VGA equ 05H ; Video Graphics Array 111 | PGA equ 06H ; Pofessional Graphics Adapter 112 | HGC equ 80H ; Hercules Graphics Adapter 113 | HG_P equ 81H ; Hercules Graphics Plus 114 | HG_COL equ 82H ; Hercules Graphics InColour Card 115 | ; 116 | ; types of video display 117 | ; 118 | MDA_display equ 01H 119 | CGA_display equ 02H 120 | EGA_colour equ 03H 121 | PS2_mono equ 04H 122 | PS2_colour equ 05H 123 | PGA_display equ 06H 124 | ; 125 | ; video adapter mode .... 126 | ; 127 | BW40 equ 00H 128 | CO40 equ 01H 129 | BW80 equ 02H 130 | CO80 equ 03H 131 | LORES_4CO equ 04H 132 | LORES_BW equ 05H 133 | LORES_2CO equ 06H 134 | MONO equ 07H 135 | PCJR_LORES equ 08H 136 | PCJR_MIDRES equ 09H 137 | PCJR_HIRES equ 0AH 138 | EGA_LORES_16CO equ 0DH 139 | EGA_MIDRES_16CO equ 0EH 140 | EGA_HIRES_BW equ 0FH 141 | EGA_HIRES_16CO equ 10H 142 | VGA_HIRES_2CO equ 11H 143 | VGA_HIRES_16CO equ 12H 144 | VGA_LORES_256CO equ 13H 145 | ; 146 | ; address of start of video memory 147 | ; 148 | MDA_addr equ 0B000H ; Start of Monochrome adapter 149 | COL_addr equ 0B800H ; Start of a colour adapter 150 | ; 151 | ; type of screen accesses 152 | ; 153 | BIOS equ 01H ; Use only bios functions for screen access 154 | NO_SNOW equ 02H ; Snow Free direct access 155 | DMA equ 03H ; Direct writes to screen memory ( fastest ) 156 | 157 | 158 | old_screen equ 159 | base_screen equ 160 | hide_cursor equ 161 | save_screen equ 162 | video_method equ 163 | snow_free equ 164 | mod_flag equ 165 | vpage equ 166 | old_vpage equ 167 | vdu equ 168 | mode equ 169 | old_mode equ 170 | no_wins equ 171 | col_shadow equ 172 | first_win equ 173 | last_win equ 174 | background equ 175 | mode_change equ 176 | mono_attr equ 177 | vsfiller equ 178 | adapter equ 179 | active_adapter equ 180 | inactive_adapter equ 181 | active_screen equ 182 | inactive_screen equ 183 | in_dv equ 184 | last_win equ 185 | active_win equ 186 | activated_win equ 187 | active_win_attr equ 188 | inactive_win_attr equ 189 | ;old_prev equ word ptr DGROUP: old_prev 190 | ;old_next equ word ptr DGROUP: old_next 191 | shadow_char equ 192 | shadow_attr equ 193 | shadow_type equ 194 | 195 | ; global functions 196 | 197 | GLOBAL C WnChgAttr : PROC 198 | GLOBAL C MakeAttr : PROC 199 | GLOBAL ModLog : PROC 200 | 201 | 202 | 203 | -------------------------------------------------------------------------------- /WINDOW.LIB: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rhulse/dos-asm-windowing-library/8bc3499a1c626ffbb91d20385c831d1059c1f9f7/WINDOW.LIB -------------------------------------------------------------------------------- /WNACT.ASM: -------------------------------------------------------------------------------- 1 | ;------------------------------------------------------------------------------; 2 | ; ; 3 | ; File Name : wnact.asm ; 4 | ; ; 5 | ; Description : make specified window active. ; 6 | ; ; 7 | ; C Prototypes ; 8 | ; ------------ ; 9 | ; void WnActivate ( WINDOW *ptr ) ; 10 | ; ; 11 | ;------------------------------------------------------------------------------; 12 | .MODEL SMALL 13 | 14 | include window.inc 15 | 16 | public _WnActivate 17 | extrn _WnDeactivate:near 18 | extrn _WnOpen:near 19 | extrn KOpen:near 20 | extrn KClose:near 21 | extrn KClose:near 22 | extrn ModLog:near 23 | extrn _active_win:word 24 | extrn _activated_win:word 25 | extrn old_prev:word 26 | extrn old_next:word 27 | 28 | .CODE 29 | _WnActivate PROC 30 | push bp 31 | mov bp , sp 32 | push si 33 | mov si , ARG_1 34 | 35 | or si , si 36 | jz short no_way ; cant do anything with a NULL !!!! 37 | 38 | cmp si , active_win ; is it already active ? 39 | je short no_way ; yes - then exit. 40 | 41 | cmp [si].W_OPEN , TRUE ; if its open then carry on 42 | je short carry_on 43 | 44 | push si ; if it is closed then just open 45 | call near ptr _WnOpen ; it in the ordinary way 46 | inc sp 47 | inc sp 48 | jmp short no_way 49 | carry_on: 50 | call near ptr _WnDeactivate ; deactivate old one. 51 | mov ax , [si].W_PREV ; save old pointers for later 52 | mov old_prev , ax 53 | 54 | mov ax , [si].W_NEXT ; save old pointers for later 55 | mov old_next , ax 56 | 57 | call near ptr KClose ; must be open - remove it first. 58 | call near ptr KOpen ; then bring to the top 59 | call near ptr ModLog ; and log changes 60 | mov activated_win , TRUE ; let deactivate function know 61 | no_way: 62 | pop si 63 | pop bp 64 | ret 65 | _WnActivate ENDP 66 | END 67 | -------------------------------------------------------------------------------- /WNBCHG.ASM: -------------------------------------------------------------------------------- 1 | ;------------------------------------------------------------------------------; 2 | ; ; 3 | ; File Name : wnbchg.asm ; 4 | ; ; 5 | ; Description : WINDOW function to stop or let the border colour be changed ; 6 | ; if the window is active. ; 7 | ; ; 8 | ; C Prototypes ; 9 | ; ------------ ; 10 | ; void WnBorderChg( WINDOW *ptr , int allow ) ; 11 | ; ; 12 | ;------------------------------------------------------------------------------; 13 | .MODEL SMALL 14 | 15 | include window.inc 16 | 17 | public _WnBorderChg 18 | extrn ModLog:near 19 | 20 | .CODE 21 | _WnBorderChg PROC 22 | push bp 23 | mov bp , sp 24 | push si 25 | mov si , ARG_1 26 | 27 | cmp [si].W_BDR , 0 ; is there really a border ? 28 | je short bchg_end ; if not end 29 | 30 | mov ax , ARG_2 31 | mov [si].W_BDR_CHG , ax ; is there really a border ? 32 | 33 | call near ptr ModLog 34 | bchg_end: 35 | pop si 36 | pop bp 37 | ret 38 | _WnBorderChg ENDP 39 | END 40 | -------------------------------------------------------------------------------- /WNBCOL.ASM: -------------------------------------------------------------------------------- 1 | ;------------------------------------------------------------------------------; 2 | ; ; 3 | ; File Name : wnbcol.asm ; 4 | ; ; 5 | ; Description : sets the attribute for vsdisp to use on the border. ; 6 | ; ; 7 | ; C Prototypes ; 8 | ; ------------ ; 9 | ; void WnBorderCol( WINDOW *ptr , int fgc , int bgc ) ; 10 | ; ; 11 | ;------------------------------------------------------------------------------; 12 | .MODEL SMALL 13 | 14 | include window.inc 15 | 16 | public _WnBorderCol 17 | extrn _MakeAttr:near 18 | extrn ModLog:near 19 | 20 | .CODE 21 | _WnBorderCol PROC 22 | push bp 23 | mov bp , sp 24 | push si 25 | mov si , ARG_1 26 | 27 | cmp [si].W_BDR , 0 ; is there really a border ? 28 | je short bcol_end ; if not end 29 | ; 30 | ; attr = MakeAttr ( fgc , bgc ); 31 | ; 32 | push ARG_3 33 | push ARG_2 34 | call near ptr _MakeAttr 35 | add sp , 4 36 | mov [si].W_BDR_ATTR , ax ; save attribute 37 | 38 | call near ptr ModLog 39 | bcol_end: 40 | pop si 41 | pop bp 42 | ret 43 | _WnBorderCol ENDP 44 | END 45 | -------------------------------------------------------------------------------- /WNBORDER.ASM: -------------------------------------------------------------------------------- 1 | ;------------------------------------------------------------------------------; 2 | ; ; 3 | ; File Name : wnborder.asm ; 4 | ; ; 5 | ; Description : WINDOW function to set border type for a window. ; 6 | ; ; 7 | ; C Prototypes ; 8 | ; ------------ ; 9 | ; void WnBorder ( WINDOW *win_ptr , int type ) ; 10 | ; ; 11 | ;------------------------------------------------------------------------------; 12 | .MODEL SMALL 13 | 14 | include window.inc 15 | 16 | public _WnBorder 17 | extrn _MakeAttr:near 18 | extrn ModLog:near 19 | ; BORDER TYPES # CALL FROM C 20 | ; 21 | ; None. 0 FALSE 22 | ; Spaces. 1 SPACES 23 | ; Single line. 2 SINGLE 24 | ; Double line. 3 DOUBLE 25 | ; Double top , Single side. 4 DTOP_SSIDE 26 | ; Single top , Double side. 5 STOP_DSIDE 27 | ; Block. 6 BLOCK 28 | ; 29 | .CODE 30 | _WnBorder PROC 31 | push bp 32 | mov bp , sp 33 | push si 34 | mov si , ARG_1 35 | 36 | mov ax , ARG_2 ; type in ax 37 | or ax , ax ; if there is no border , then check 38 | jnz short not_too_small ; to see if the window is too small 39 | cmp [si].W_WID , 1 ; is it 1 wide 40 | jle short too_small ; dont do a shadow 41 | cmp [si].W_HGT , 1 ; or 1 high 42 | jg short not_too_small ; dont do a shadow 43 | too_small: 44 | mov [si].W_SHADCHAR , 32 ; ptr -> shadchar = 0x20 45 | mov [si].W_SHADOW , FALSE ; ptr -> shadow = FALSE 46 | not_too_small: 47 | mov [si].W_BDR , ax ; win_ptr -> bdr = type; 48 | 49 | call near ptr ModLog 50 | 51 | pop si 52 | pop bp 53 | ret 54 | _WnBorder ENDP 55 | END 56 | -------------------------------------------------------------------------------- /WNBPRINT.ASM: -------------------------------------------------------------------------------- 1 | ;------------------------------------------------------------------------------; 2 | ; ; 3 | ; File Name : ; 4 | ; ; 5 | ; Description : ; 6 | ; ; 7 | ; ; 8 | ; C Prototypes ; 9 | ; ------------ ; 10 | ; ; 11 | ; void AllocError ( void ); ; 12 | ; ; 13 | ;------------------------------------------------------------------------------; 14 | ;------------------------------------------------------------------------------; 15 | ; ; 16 | ; This module contains a function to write on the bottom row of a box; 17 | ; ; 18 | ;------------------------------------------------------------------------------; 19 | .MODEL SMALL 20 | 21 | include window.inc 22 | 23 | public _WnBorderPrint 24 | extrn _WnPrintxy:near 25 | 26 | ;------------------------------------------------------------------------------; 27 | ; ; 28 | ; Sets text over the top of the top edge in a window ; 29 | ;void WnBorderPrint(WINDOW *ptr, int edge, int x, char *text ); ; 30 | ; arg1 arg2 arg3 arg4 ; 31 | ; arg2 sets top or bottom arg3 set distance ; 32 | ;------------------------------------------------------------------------------; 33 | .CODE 34 | 35 | _WnBorderPrint PROC 36 | push bp 37 | mov bp , sp 38 | push si 39 | mov si , ARG_1 40 | 41 | cmp [si].W_BDR , 0 ; is there really a border to write on ? 42 | je short title_end ; if not end 43 | 44 | push [si].W_BDR ; save old border type 45 | mov [si].W_BDR , 0 ; turn off border 46 | 47 | ; push arguments 48 | push ARG_4 ; text pointer 49 | 50 | mov ax , 0 ; set for TOP row 51 | cmp ARG_2 , 0 ; is it the TOP row ? 52 | je top_row ; don't change 53 | mov ax , [si].W_HGT ; mov height in 54 | dec ax 55 | top_row: 56 | push ax ; top or bottom row 57 | push ARG_3 ; x position 58 | push ARG_1 ; *WINDOW 59 | 60 | call _WnPrintxy ; print it 61 | 62 | add sp , 8 63 | 64 | pop [si].W_BDR ; restore old border type 65 | title_end: 66 | pop si 67 | pop bp 68 | ret 69 | _WnBorderPrint ENDP 70 | END 71 | -------------------------------------------------------------------------------- /WNCLOSE.ASM: -------------------------------------------------------------------------------- 1 | ;------------------------------------------------------------------------------; 2 | ; ; 3 | ; File Name : wnclose.asm ; 4 | ; ; 5 | ; Description : WINDOW functions to close a window and remove from linked list; 6 | ; ; 7 | ; C Prototypes ; 8 | ; ------------ ; 9 | ; void WnClose ( WINDOW * ptr ); ; 10 | ; ; 11 | ;------------------------------------------------------------------------------; 12 | .MODEL SMALL 13 | 14 | include window.inc 15 | 16 | public _WnClose 17 | public KClose 18 | extrn ModLog:near 19 | extrn _WnDeActivate:near 20 | extrn _first_win:word 21 | extrn _last_win:word 22 | extrn _no_wins:word 23 | extrn _active_win:word 24 | extrn old_prev:word 25 | extrn old_next:word 26 | 27 | .CODE 28 | _WnClose PROC 29 | push bp 30 | mov bp , sp 31 | push si 32 | mov si , ARG_1 33 | 34 | cmp [si].W_OPEN , FALSE ; if its closed then exit 35 | je short close_end 36 | 37 | cmp si , active_win ; if active and ... 38 | jne short close1 39 | call near ptr _WnDeActivate ; ... open then deactivate first 40 | close1: 41 | call near ptr KClose ; just close it 42 | call near ptr ModLog ; and log the changes 43 | close_end: 44 | pop si 45 | pop bp 46 | ret 47 | _WnClose ENDP 48 | 49 | 50 | KClose PROC 51 | ; 52 | ; at entry si points to the window structure. 53 | ; 54 | push di 55 | 56 | mov di , [si].W_NEXT ; on_ptr = ptr -> on_link 57 | mov bx , [si].W_PREV ; back_ptr = ptr -> back_link 58 | 59 | cmp si , old_prev ; is it old prev 60 | jne short kc1 ; no - jump 61 | mov old_prev , bx ; yes - replace with W_PREV 62 | kc1: 63 | cmp si , old_next ; is it old next 64 | jne short kc2 ; no - jump 65 | mov old_next , di ; yes - replace with W_NEXT 66 | kc2: 67 | or bx , bx ; if ( back_ptr EQ (WINDOW *)NULL ) 68 | jne short kc3 69 | mov first_win , di ; first_win = on_ptr 70 | jmp short kc4 71 | kc3: 72 | mov [bx].W_NEXT , di ; else back_ptr -> on_link = on_ptr 73 | kc4: 74 | or di , di ;if ( on_ptr EQ (WINDOW *)NULL ) 75 | jne short kc5 76 | 77 | mov last_win , bx ; else { last_win = back_ptr } 78 | mov active_win , bx ; previous is now active window too 79 | push si 80 | mov si , bx 81 | call near ptr ModLog ; log new active window position 82 | pop si 83 | jmp short kc6 84 | kc5: 85 | mov [di].W_PREV , bx ; on_ptr -> back_link = back_ptr; 86 | kc6: 87 | ; call near ptr ModLog ; log old active window position 88 | mov [si].W_OPEN , 0 ; ptr -> open = FALSE; 89 | dec no_wins ; one less window open 90 | 91 | pop di 92 | ret 93 | KClose ENDP 94 | END 95 | -------------------------------------------------------------------------------- /WNCLOSEA.ASM: -------------------------------------------------------------------------------- 1 | ;------------------------------------------------------------------------------; 2 | ; ; 3 | ; File Name : ; 4 | ; ; 5 | ; Description : ; 6 | ; ; 7 | ; ; 8 | ; C Prototypes ; 9 | ; ------------ ; 10 | ; ; 11 | ; void AllocError ( void ); ; 12 | ; ; 13 | ;------------------------------------------------------------------------------; 14 | ;------------------------------------------------------------------------------; 15 | ; ; 16 | ; Contains WnCloseAll window functions. ; 17 | ; ; 18 | ;------------------------------------------------------------------------------; 19 | .MODEL SMALL 20 | 21 | include window.inc 22 | 23 | public _WnCloseAll 24 | extrn _first_win:word 25 | extrn _WnClose:near 26 | 27 | 28 | .CODE 29 | 30 | ;------------------------------------------------------------------------------; 31 | ; ; 32 | ; Closes All windows. ; 33 | ; void WnCloseAll ( void ) ; 34 | ; ; 35 | ;------------------------------------------------------------------------------; 36 | _WnCloseAll PROC 37 | ; 38 | ; while ( first_win NE (WINDOW *)NULL ) 39 | ; WnClose ( first_win ); 40 | ; 41 | closeall1: 42 | cmp first_win , 0 43 | je short closeall2 44 | push first_win 45 | call near ptr _WnClose 46 | inc sp 47 | inc sp 48 | jmp short closeall1 49 | closeall2: 50 | ret 51 | _WnCloseAll ENDP 52 | 53 | END 54 | 55 | -------------------------------------------------------------------------------- /WNCLS.ASM: -------------------------------------------------------------------------------- 1 | ;------------------------------------------------------------------------------; 2 | ; ; 3 | ; File Name : ; 4 | ; ; 5 | ; Description : ; 6 | ; ; 7 | ; ; 8 | ; C Prototypes ; 9 | ; ------------ ; 10 | ; ; 11 | ; void AllocError ( void ); ; 12 | ; ; 13 | ;------------------------------------------------------------------------------; 14 | ;------------------------------------------------------------------------------; 15 | ; ; 16 | ; Contains the cls window function. ; 17 | ; ; 18 | ;------------------------------------------------------------------------------; 19 | .MODEL SMALL 20 | 21 | include window.inc 22 | 23 | public _WnCls 24 | extrn _MakeAttr:near 25 | extrn ModLog:near 26 | 27 | .CODE 28 | ;------------------------------------------------------------------------------; 29 | ; ; 30 | ; Clears the WINDOW at row start for count y ; 31 | ; void WnCls ( WINDOW *window , int start , int ycount ) ; 32 | ; + 4 + 6 + 8 ; 33 | ;------------------------------------------------------------------------------; 34 | _WnCls PROC 35 | push bp 36 | mov bp , sp 37 | push si 38 | push di 39 | mov si , ARG_1 40 | 41 | mov dx , [si].W_WID ; int xcount = window -> wid; 42 | mov di , [si].W_PTR ; int *ptr = window -> ptr; 43 | mov ax , dx 44 | mov cx , ARG_2 45 | imul cl 46 | shl ax , 1 47 | add di , ax ; ptr += wid * start; 48 | ; 49 | ; attr = MakeAttr ( window -> fgc , window -> bgc ) * 256; 50 | ; 51 | push [si].W_BGC 52 | push [si].W_FGC 53 | call near ptr _MakeAttr 54 | add sp , 4 55 | mov ah , al 56 | mov al , 32 ; set up an ' ' in the current colour in ax 57 | 58 | ; 59 | ; while ( ycount-- ) 60 | ; for ( n = xcount ; n GT 0 ; n-- ) 61 | ; ax = attribute + ' ' 62 | ; cx = holds x & y counts at different points in the loop. 63 | ; dx = xcount from earlier 64 | ; di = destination for ax 65 | ; 66 | mov cx , ARG_3 ; ycount 67 | cls2: 68 | push cx ; push y count 69 | mov cx , dx ; xcount 70 | rep stosw ; do a row 71 | pop cx ; pop y count 72 | loop short cls2 ; dec ycount..loop if not 0.... 73 | cls3: 74 | cmp [si].W_OPEN , 0 ; if its not open 75 | je short cls4 ; jump 76 | call near ptr ModLog 77 | cls4: 78 | pop di 79 | pop si 80 | pop bp 81 | ret 82 | _WnCls ENDP 83 | 84 | END 85 | 86 | 87 | -------------------------------------------------------------------------------- /WNCORE.ASM: -------------------------------------------------------------------------------- 1 | ;------------------------------------------------------------------------------; 2 | ; ; 3 | ; File Name : wncore.asm ; 4 | ; ; 5 | ; Description : the central variables, init and exit routines ; 6 | ; of the WINDOW module ; 7 | ; ; 8 | ; C Prototypes ; 9 | ; ------------ ; 10 | ; void WnInit( void ) ; 11 | ; void WnExit( void ) ; 12 | ; ; 13 | ;------------------------------------------------------------------------------; 14 | .MODEL SMALL 15 | 16 | include window.inc 17 | 18 | public _WnInit 19 | public _WnExit 20 | ; SetupVideo 21 | 22 | extrn _WnKillAll:near 23 | extrn _CursorHide:near 24 | extrn _DvInit:near 25 | extrn _InitMouse:near 26 | extrn CursorSave:near 27 | extrn SetVideoMode:near 28 | extrn GetVideoData:near 29 | extrn CursorRestore:near 30 | extrn OldScreen:near 31 | extrn VsBorder:near 32 | extrn GetVideoConfig:near 33 | extrn GetVideoData:near 34 | extrn GetScreenSeg:near 35 | extrn _in_dv:word 36 | 37 | 38 | ; 39 | ; All Variables in this module. Publics are marked as such. 40 | ; 41 | public _hide_cursor ; hide the cursor off screen ? 42 | public _save_screen ; save the screen and cursor at the programmes entry ? 43 | public _video_method ; method of screen writes 44 | public _snow_free ; do we use snow free on a CGA ? 45 | public _col_shadow ; use colour shadowing if colour is available ? 46 | public _background ; use old screen as background ? 47 | public _mode_change ; do we change to a colour mode if available 48 | public _mono_attr ; use mono attributes on a colour system 49 | public _shadow_char ; character to use for shadow 50 | public _shadow_fgc ; character fgc 51 | public _shadow_bgc ; character fgc 52 | public _shadow_type ; where the shadow sits 53 | public _border_type ; default border type 54 | public _first_win ; pointer to first window in linked list 55 | public _last_win ; pointer to last window in linked list 56 | public _active_win 57 | public _activated_win ; is there a window activated at present ? 58 | public _active_win_attr; fg colour to use 59 | public old_prev 60 | public old_next 61 | 62 | public _adapter ; active video adapter 63 | public _active_adapter ; active video adapter 64 | public _inactive_adapter ; inactive video adapter 65 | public _active_screen ; active video screen 66 | public _inactive_screen ; inactive video screen 67 | public _mode ; current video mode 68 | public _old_mode ; holds the video mode current at prog entry 69 | public _vdu ; checked by MakeAttr to do attributes 70 | public _old_screen ; an area to save the old screen 71 | public _base_screen ; an area to assemble the windows on 72 | public _vpage ; holds the current video page 73 | public _old_vpage ; holds the video page current at prog entry 74 | public _mod_flag ; has anything visible changed ? 75 | public _no_wins ; number of windows 76 | public _vsfiller ; background filler default = WHITE on BLACK space 77 | public _DISP_addr ; address of display buffer. 78 | 79 | .DATA 80 | 81 | _DISP_addr DW 0B000H ; address of display memory ( default B & W ) 82 | _adapter DW 0 ; active video adapter 83 | _active_adapter DW 0 ; active video adapter 84 | _inactive_adapter DW 0 ; inactive video adapter 85 | _active_screen DW 0 ; active video screen 86 | _inactive_screen DW 0 ; inactive video screen 87 | _hide_cursor DW TRUE ; hide the cursor off screen ? 88 | _save_screen DW TRUE ; save the screen and cursor at the programmes entry 89 | _video_method DW DMA ; method of screen writes ( DMA ) 90 | _snow_free DW TRUE ; do we do snow free on CGA only ?? 91 | _col_shadow DW TRUE ; use attribute shadowing if colour is available ? 92 | _background DW FALSE ; is the old_screen to be used as a background 93 | _mode_change DW TRUE ; can we try for a colour text mode ? 94 | _mono_attr DW FALSE ; use mono_attributes ?? 95 | _vsfiller DW 0720H ; WHITE on BLACK ' ' for background 96 | _shadow_char DB 00B0H ; coarse block type 97 | _shadow_fgc DW 0008H ; grey foreground 98 | _shadow_bgc DW 0000H ; black background 99 | _shadow_type DW 0003H ; lower right corner 100 | _border_type DW 0002H ; single border as default 101 | _first_win DW 0000H ; pointer to first window in linked list 102 | _last_win DW 0000H ; pointer to last window in linked list 103 | _active_win DW 0000H ; pointer to the current active window 104 | _activated_win DW FALSE ; was the active window activated ? 105 | _active_win_attr DW 0FH 106 | old_prev DW 0 107 | old_next DW 0 108 | 109 | .DATA? 110 | 111 | _old_screen DW 2000 dup (?) ; an area to save the old screen 112 | _base_screen DW 2000 dup (?) ; an area to assemble the windows on 113 | _vpage DW ? ; holds the current video page 114 | _old_vpage DW ? ; holds the video page current at prog entry 115 | _vdu DW ? ; what VDU for attribute mapping 116 | _mode DW ? ; current video mode 117 | _old_mode DW ? ; holds the video mode current at prog entry 118 | _mod_flag DW ? ; has anything visible changed ? 119 | _no_wins DW ? ; number of windows 120 | 121 | .CODE 122 | ;------------------------------------------------------------------------------; 123 | ; ; 124 | ; Initialises the WINDOWs module. ; 125 | ; void WnInit( void ) ; 126 | ; WARNING : If this function isnt called first NOTHING will work !!!!!! ; 127 | ;------------------------------------------------------------------------------; 128 | _WnInit PROC 129 | call near ptr _DvInit ; see if under DESQview 130 | call near ptr _InitMouse ; see if there is a mouse 131 | call near ptr SetupVideo ; set up video variables 132 | mov first_win , 0 ; first_win = ( WINDOW *)NULL 133 | mov last_win , 0 ; last_win = ( WINDOW *)NULL 134 | mov no_wins , 0 ; no_wins = 0 135 | mov mod_flag , TRUE ; mod_flag = TRUE; 136 | ret 137 | _WnInit ENDP 138 | ;------------------------------------------------------------------------------; 139 | ; ; 140 | ; Exits the WINDOWs module and tidies up afterwards. ; 141 | ; void WnExit( void ) ; 142 | ; WARNING : Do this last or else who knows what might happen !!!! ; 143 | ;------------------------------------------------------------------------------; 144 | _WnExit PROC 145 | call near ptr _WnKillAll ; Release all memory 146 | mov ax , old_mode ; compare old and new 147 | cmp mode , ax 148 | je short exit_win1 ; only change if they are different 149 | call near ptr SetVideoMode 150 | exit_win1: 151 | mov ax , old_vpage ; compare old and new 152 | cmp vpage , ax 153 | je short exit_win2 ; only change if they are different 154 | mov ah , 5 155 | int 10H 156 | jmp short exit_win4 ; no need to restore old screen 157 | exit_win2: 158 | cmp save_screen , FALSE; ; do we restore old screen 159 | je short exit_win3 ; no jump 160 | call near ptr GetVideoData ; update mode variable for OldScreen 161 | call near ptr CursorRestore ; restore old cursor 162 | mov ax , 2 163 | push ax 164 | call near ptr OldScreen ; restore old screen 165 | pop ax 166 | jmp short exit_win4 ; exit 167 | exit_win3: 168 | mov ax , old_mode ; resetting the mode again does a CLS 169 | call near ptr SetVideoMode ; and homes the cursor 170 | exit_win4: 171 | mov dx , 2 172 | call near ptr VsBorder ; restore border colour 173 | ret 174 | _WnExit ENDP 175 | ;------------------------------------------------------------------------------; 176 | ; ; 177 | ; Set up the video environment. ; 178 | ; ; 179 | ;------------------------------------------------------------------------------; 180 | SetupVideo PROC 181 | call near ptr GetVideoConfig ; set adapter global variables. 182 | call near ptr GetVideoData ; set mode and old_page global 183 | 184 | mov cx , mode 185 | mov old_mode , cx ; save old mode 186 | mov vdu , cx ; set vdu 187 | 188 | cmp active_adapter , HGC 189 | jb short set_vid1 ; if any hercules graphics card 190 | mov bx , MDA ; is found then change adapter to MDA 191 | jmp short set_vid2 192 | set_vid1: 193 | mov bx , _active_adapter 194 | set_vid2: 195 | mov adapter , bx 196 | 197 | cmp bx , MDA ; is it an MDA 198 | je short set_vid4 ; only one page so nothing to change 199 | 200 | cmp in_dv , TRUE ; are we in DESQview 201 | jne short set_vid2a ; no - jump past next bit 202 | mov video_method , DMA ; force DMA writes. 203 | jmp short set_vid3 204 | set_vid2a: 205 | cmp snow_free , TRUE ; does user want snow free screen writes 206 | jne short set_vid3 ; no - nothing to change 207 | cmp bx , CGA ; snow free on CGA only allowed 208 | jne short set_vid3 ; no - nothing to change 209 | cmp video_method , DMA ; are going direct ? 210 | jne short set_vid3 ; no - nothing to change 211 | mov video_method , NO_SNOW ; yes - change method to snow free 212 | set_vid3: 213 | mov ax , vpage 214 | mov old_vpage , ax 215 | or ax , ax ; are we on page 0 ?? 216 | jz short set_vid4 ; yes - no need to change it. 217 | mov ax , 0500H ; function 5 page 0 218 | int 10H ; call bios 219 | jmp short set_vid8 ; no need to save screen either 220 | set_vid4: 221 | cmp cx , CO80 ; is it any colour TEXT mode ? 222 | jbe short set_vid5 ; then we can continue 223 | cmp cx , MONO ; is it mono TEXT mode ? 224 | je short set_vid5 ; then we can also continue 225 | jmp short set_vid8 ; else its graphics - dont save. 226 | set_vid5: 227 | cmp background , FALSE ; old screen as background ? 228 | je short set_vid6 ; no - test for save screen 229 | cmp cx , BW80 ; yes - is it an 80 column TEXT mode ? 230 | jae short set_vid7 ; yes - then use it - jump to save. 231 | mov background , FALSE ; no - then we cant use it as background 232 | jmp short set_vid6 ; so stop it being used!! 233 | set_vid6: 234 | cmp save_screen , FALSE ; check if we have to save it 235 | je short set_vid8 ; no - carry on 236 | set_vid7: ; save for use as background enters here 237 | 238 | push cx ; save mode 239 | call near ptr CursorSave ; save old cursor position 240 | mov ax , 1 241 | push ax ; push SAVE 242 | call near ptr OldScreen ; call oldscreen 243 | inc sp 244 | inc sp 245 | pop cx ; restore mode 246 | set_vid8: 247 | cmp adapter , MDA ; is it an MDA ? 248 | je short set_vid10 ; only change attribute shadowing. 249 | cmp mode_change , TRUE ; are we allowed to change mode ? 250 | je short set_vid9 ; yes - jump 251 | cmp cx , MONO ; leave if its MONO mode. 252 | je short set_vid10 ; but change attribute shadowing 253 | cmp cx , BW80 ; is it B & W 80 x 25 text ? 254 | je short set_vid11 ; don't turn off attribute shadowing 255 | set_vid9: 256 | cmp cx , CO80 ; is it colour 80 x 25 text ? 257 | je short set_vid11 ; no need to change anything. 258 | 259 | mov ax , CO80 ; try to set mode 3 260 | call near ptr SetVideoMode ; call routine 261 | call near ptr GetVideoData ; set globals to new data 262 | cmp mode , MONO ; double check mode was changed. 263 | jne short set_vid11 264 | set_vid10: 265 | mov col_shadow , FALSE ; turn off colour shadowing 266 | set_vid11: ; this is last because a change of mode 267 | ; will unhide the cursor 268 | cmp hide_cursor , FALSE ; do we hide the cursor ? 269 | je short set_vid12 ; no 270 | call near ptr _CursorHide ; hide cursor off the screen 271 | set_vid12: 272 | call near ptr GetScreenSeg ; set _DISP_addr to screen buffer. 273 | set_vid13: 274 | mov dx , 1 275 | call near ptr VsBorder ; save border colour 276 | set_vid14: 277 | cmp mono_attr , TRUE ; do we set for mono attributes ? 278 | jne short set_vid15 ; dont change 279 | mov vdu , MONO ; set vdu for mono 280 | mov col_shadow , FALSE ; turn off colour shadowing too 281 | set_vid15: 282 | ret 283 | SetupVideo ENDP 284 | END 285 | -------------------------------------------------------------------------------- /WNCURSON.ASM: -------------------------------------------------------------------------------- 1 | ;------------------------------------------------------------------------------; 2 | ; ; 3 | ; File Name : wncuson.asm ; 4 | ; ; 5 | ; Description : Turns the hardware cursor on in the specified WINDOW. ; 6 | ; ; 7 | ; C Prototypes ; 8 | ; ------------ ; 9 | ; void WnCursOn ( WINDOW *ptr ) ; 10 | ; ; 11 | ;------------------------------------------------------------------------------; 12 | .MODEL SMALL 13 | 14 | include window.inc 15 | 16 | public _WnCursOn 17 | extrn BiosSetCursPos:near 18 | 19 | .CODE 20 | _WnCursOn PROC 21 | push bp 22 | mov bp , sp 23 | push si 24 | mov si , ARG_1 25 | 26 | mov dl , BYTE PTR [si].W_X ; x = ptr -> x + ptr -> cursx 27 | add dl , BYTE PTR [si].W_CURSX 28 | mov dh , BYTE PTR [si].W_Y ; y = ptr -> y + ptr -> cursy 29 | add dh , BYTE PTR [si].W_CURSY 30 | 31 | call near ptr BiosSetCursPos ; set cursor position. dl is x. dh is y 32 | 33 | pop si 34 | pop bp 35 | ret 36 | _WnCursOn ENDP 37 | END 38 | -------------------------------------------------------------------------------- /WNDEACT.ASM: -------------------------------------------------------------------------------- 1 | ;------------------------------------------------------------------------------; 2 | ; ; 3 | ; File Name : wndeact.asm ; 4 | ; ; 5 | ; Description : WINDOW module function to Deactivate an ACTIVATED window. ; 6 | ; ; 7 | ; C Prototypes ; 8 | ; ------------ ; 9 | ; void WnDeActivate ( WINDOW *ptr ) ; 10 | ; ; 11 | ;------------------------------------------------------------------------------; 12 | .MODEL SMALL 13 | 14 | include window.inc 15 | 16 | public _WnDeActivate 17 | 18 | extrn ModLog:near 19 | extrn KClose:near 20 | extrn old_prev:word 21 | extrn old_next:word 22 | extrn _first_win:word 23 | extrn _last_win:word 24 | extrn _active_win:word 25 | extrn _activated_win:word 26 | 27 | .CODE 28 | 29 | 30 | _WnDeActivate PROC 31 | push si 32 | push di 33 | 34 | mov si , active_win 35 | or si , si 36 | jz deact7 ; cant close a null window ptr 37 | 38 | cmp activated_win , FALSE 39 | je short deact6 40 | deact1: 41 | call near ptr KClose 42 | 43 | mov bx , old_prev 44 | mov [si].W_PREV , bx 45 | mov di , old_next 46 | mov [si].W_NEXT , di 47 | 48 | or bx , bx ; is it a NULL 49 | jne short deact2 ; no 50 | mov first_win , si ; yes then this one is first 51 | jmp short deact3 52 | deact2: 53 | mov [bx].W_NEXT , si ; make prev window point on to this one 54 | deact3: 55 | or di , di ; is it a NULL 56 | jne short deact4 ; no 57 | mov last_win , si ; yes - then this one is last. 58 | mov active_win , si ; and active one. 59 | jmp short deact5 60 | deact4: 61 | mov [di].W_PREV , si ; make next window point back to this one 62 | deact5: 63 | mov [si].W_OPEN , TRUE ; make it open on the list !! 64 | mov [si].W_HIDE , FALSE ; and unhide it. 65 | mov activated_win , FALSE 66 | deact6: 67 | call near ptr ModLog ; log the deactivated window 68 | 69 | deact7: 70 | pop di 71 | pop si 72 | ret 73 | _WnDeActivate ENDP 74 | END 75 | -------------------------------------------------------------------------------- /WNEDIT.ASM: -------------------------------------------------------------------------------- 1 | ;------------------------------------------------------------------------------; 2 | ; ; 3 | ; File Name : ; 4 | ; ; 5 | ; Description : A simple editor..returns TRUE if any changes are made. ; 6 | ; ; 7 | ; C Prototypes ; 8 | ; ------------ ; 9 | ; int WnEdit ( WINDOW *win , int size , int x , int y , char *buffer ) ; 10 | ; ; 11 | ;------------------------------------------------------------------------------; 12 | .MODEL SMALL 13 | 14 | ; Readability helpers 15 | K_BS equ 0008H 16 | K_ENTER equ 000DH 17 | K_ESC equ 001BH 18 | L_ARROW equ 4B00H 19 | R_ARROW equ 4D00H 20 | K_DEL equ 5300H 21 | 22 | include window.inc 23 | 24 | public _WnEdit 25 | 26 | extrn _CursorFat:near 27 | extrn _WnPrintxy:near 28 | extrn _WnSetCurs:near 29 | extrn _WnCursOn:near 30 | extrn _VsDisp:near 31 | extrn _GetKey:near 32 | extrn BiosSetCursPos:near 33 | extrn __ctype:byte ; c library function 34 | 35 | .CODE 36 | _WnEdit PROC 37 | push bp 38 | mov bp , sp 39 | dec sp 40 | dec sp 41 | push si 42 | push di 43 | ; 44 | ; int loop = TRUE , result = TRUE , n = 0 , z , key; 45 | ; no loop variable needed ... 46 | ; if loop not needed then key routine jumps to edit_end 47 | 48 | mov VAR_1 , TRUE 49 | xor si , si 50 | call near ptr _CursorFat 51 | ; 52 | ; while ( loop ) 53 | ; WnPrintxy ( win , x , y , buffer ); 54 | ; 55 | edit0: 56 | push ARG_5 57 | push ARG_4 58 | push ARG_3 59 | push ARG_1 60 | call near ptr _WnPrintxy 61 | add sp , 8 62 | ; 63 | ; WnSetCurs ( win , x + n , y ); 64 | ; 65 | push ARG_4 66 | mov ax , ARG_3 67 | add ax , si 68 | push ax 69 | push ARG_1 70 | call near ptr _WnSetCurs 71 | add sp , 6 72 | 73 | ; 74 | ; WnCursOn ( win ); 75 | ; 76 | push ARG_1 77 | call near ptr _WnCursOn 78 | inc sp 79 | inc sp 80 | ; 81 | ; while ( kbhit() EQ 0 ) 82 | ; VsDisp(); 83 | ; NB. DOS func 0BH used instead of kbhit. 84 | edit1: 85 | call near ptr _VsDisp 86 | mov ah , 0Bh 87 | int 21H 88 | or al , al 89 | je short edit1 90 | ; 91 | ; key = GetKey(); 92 | ; 93 | call near ptr _GetKey 94 | mov dx , ax 95 | ; 96 | ; switch( key ) 97 | ; 98 | mov cx , 6 99 | mov bx , offset KEY_TABLE 100 | edit2: 101 | mov ax , word ptr cs:[bx] 102 | cmp ax , dx 103 | je short edit3 104 | inc bx 105 | inc bx 106 | loop short edit2 107 | jmp short edit9 108 | edit3: 109 | jmp word ptr cs:[bx + 12] 110 | 111 | ;------------------------------------------------------------------------ 112 | 113 | edit_larrow: ; case L_ARROW : n = ( n ) ? n - 1 : n; break; 114 | 115 | or si , si 116 | jne short edit4 117 | jmp edit14 118 | edit4: 119 | mov ax , si 120 | dec ax 121 | jmp edit15 122 | 123 | 124 | ;------------------------------------------------------------------------ 125 | 126 | edit_rarrow: ; case R_ARROW : n = ( n LT ( size - 1 ) ) ? n + 1 : n; break; 127 | 128 | mov ax , ARG_2 129 | dec ax 130 | cmp ax , si 131 | jle short edit7 132 | jmp short edit13 133 | edit7: 134 | jmp short edit14 135 | 136 | ;------------------------------------------------------------------------ 137 | 138 | edit_del: ; case DEL 139 | 140 | mov di , si ; z = n 141 | mov cx , ARG_2 142 | dec cx 143 | edit8: 144 | cmp cx , di 145 | jge short edit8@ 146 | ; 147 | ; while ( z LT ( size - 1 ) ) 148 | ; buffer[z++] = buffer[z + 1]; 149 | ; 150 | mov bx , ARG_5 151 | mov al , byte ptr [bx + di + 1] 152 | mov byte ptr [bx + di] , al 153 | inc di 154 | jmp short edit8 155 | edit8@: 156 | mov bx , ARG_5 157 | mov byte ptr [bx + di] , 32 ; buffer[z] = ' '; 158 | 159 | jmp edit0 ; break 160 | 161 | ;------------------------------------------------------------------------ 162 | 163 | edit_bs: ; case BS : if ( n ) 164 | 165 | or si , si ; if n = 0 166 | je short edit_break ; jump 167 | ; 168 | ; buffer[--n] = ' '; 169 | ; 170 | dec si 171 | mov bx , ARG_5 172 | mov byte ptr [bx + si] , 32 173 | edit_break: 174 | jmp edit0 ; break; 175 | 176 | 177 | ;------------------------------------------------------------------------ 178 | 179 | edit_enter: ; case ENTER : buffer[n] = '\0'; loop = FALSE; break; 180 | 181 | mov bx , ARG_5 182 | mov byte ptr [bx + si] , 0 183 | 184 | jmp short edit_end ; no need to loop..go to end 185 | 186 | ;------------------------------------------------------------------------ 187 | 188 | edit_esc: ; case ESC : result = FALSE; break; 189 | 190 | mov VAR_1 , FALSE 191 | jmp short edit_end ; no need to go to loop test !! 192 | 193 | ;------------------------------------------------------------------------ 194 | 195 | edit9: ; default : if ( isprint ( key BAND 0x00FF ) ) 196 | 197 | mov bx , dx 198 | and bx , 00FFH 199 | test byte ptr DGROUP:__ctype[bx + 1] , 87 200 | jne short edit10 201 | jmp edit0 202 | ; 203 | ; key = toupper ( key ); 204 | ; 205 | edit10: 206 | test byte ptr DGROUP:__ctype[bx + 1] , 2 ; is it upper 207 | je short edit11 ; yes..jump 208 | mov ax , dx ; else convert to upper 209 | and ax , 000FFH 210 | add ax , 0FFE0H 211 | jmp short edit12 212 | edit11: 213 | mov ax , dx 214 | and ax , 00FFH 215 | edit12: 216 | mov bx , ARG_5 217 | mov byte ptr [bx + si] , al ; buffer[n] = ( char )( key ) 218 | ; 219 | ; n = ( n LT ( size - 1 ) ) ? n + 1 : n; 220 | ; 221 | mov ax , ARG_2 222 | dec ax 223 | cmp ax , si 224 | jle short edit14 225 | 226 | edit13: 227 | mov ax , si 228 | inc ax 229 | jmp short edit15 230 | edit14: 231 | mov ax , si 232 | edit15: 233 | mov si , ax 234 | jmp edit0 ; break 235 | edit_end: 236 | ; 237 | ; Cursor ( C_HIDE ); 238 | ; 239 | mov dx , 2500H 240 | call near ptr BiosSetCursPos 241 | ; 242 | ; return ( result ); 243 | ; 244 | mov ax , VAR_1 245 | 246 | pop di 247 | pop si 248 | mov sp , bp 249 | pop bp 250 | ret 251 | _WnEdit ENDP 252 | DW (?) 253 | KEY_TABLE LABEL WORD 254 | DW K_BS 255 | DW K_ENTER 256 | DW K_ESC 257 | DW L_ARROW 258 | DW R_ARROW 259 | DW K_DEL 260 | DW edit_bs 261 | DW edit_enter 262 | DW edit_esc 263 | DW edit_larrow 264 | DW edit_rarrow 265 | DW edit_del 266 | END 267 | -------------------------------------------------------------------------------- /WNGETATT.ASM: -------------------------------------------------------------------------------- 1 | ;------------------------------------------------------------------------------; 2 | ; ; 3 | ; File Name : wngetatt.asm ; 4 | ; ; 5 | ; Description : Contains WINDOW function to get a windows attributes. ; 6 | ; ; 7 | ; C Prototypes ; 8 | ; ------------ ; 9 | ; void WnGetAttr ( WINDOW *ptr , int *fgc , int *bgc ) ; 10 | ; ; 11 | ;------------------------------------------------------------------------------; 12 | .MODEL SMALL 13 | 14 | include window.inc 15 | 16 | public _WnGetAttr 17 | 18 | .CODE 19 | _WnGetAttr PROC 20 | push bp 21 | mov bp , sp 22 | push si 23 | mov si , ARG_1 24 | 25 | mov ax , [si].W_FGC 26 | mov bx , ARG_2 27 | mov WORD PTR [bx] , ax ; *fgc = ptr -> fgc 28 | 29 | mov ax , [si].W_BGC 30 | mov bx , ARG_3 31 | mov WORD PTR [bx] , ax ; *bgc = ptr -> bgc 32 | 33 | pop si 34 | pop bp 35 | ret 36 | _WnGetAttr ENDP 37 | END 38 | -------------------------------------------------------------------------------- /WNGETCUR.ASM: -------------------------------------------------------------------------------- 1 | ;------------------------------------------------------------------------------; 2 | ; ; 3 | ; File Name : wngetcur.asm ; 4 | ; ; 5 | ; Description : Contains WINDOW function to get a windows cursor position. ; 6 | ; ; 7 | ; C Prototypes ; 8 | ; ------------ ; 9 | ; void WnGetCurs ( WINDOW *ptr , int *x , int *y ) ; 10 | ; ; 11 | ;------------------------------------------------------------------------------; 12 | .MODEL SMALL 13 | 14 | include window.inc 15 | 16 | public _WnGetCurs 17 | 18 | .CODE 19 | _WnGetCurs PROC 20 | push bp 21 | mov bp , sp 22 | push si 23 | mov si , ARG_1 24 | 25 | mov ax , [si].W_CURSX 26 | mov bx , ARG_2 27 | mov WORD PTR [bx] , ax ; *x = ptr -> cursx 28 | 29 | mov ax , [si].W_CURSY 30 | mov bx , ARG_3 31 | mov WORD PTR [bx] , ax ; *y = ptr -> cursy 32 | 33 | pop si 34 | pop bp 35 | ret 36 | _WnGetCurs ENDP 37 | END 38 | -------------------------------------------------------------------------------- /WNHIDE.ASM: -------------------------------------------------------------------------------- 1 | ;------------------------------------------------------------------------------; 2 | ; ; 3 | ; File Name : wnhide.asm ; 4 | ; ; 5 | ; Description : Contains functions to Hide and unhide single windows. ; 6 | ; ; 7 | ; C Prototypes ; 8 | ; ------------ ; 9 | ; void WnHide ( WINDOW *ptr ); ; 10 | ; void WnUnHide ( WINDOW *ptr ); ; 11 | ; ; 12 | ;------------------------------------------------------------------------------; 13 | .MODEL SMALL 14 | 15 | include window.inc 16 | 17 | public _WnHide 18 | public _WnUnHide 19 | extrn ModLog:near 20 | extrn _active_win:word 21 | 22 | .CODE 23 | _WnHide PROC 24 | push bp 25 | mov bp , sp 26 | push si 27 | mov si , ARG_1 28 | 29 | ; cmp si , _active_win ; dont hide it if it is active ! 30 | ; je short dont_hide 31 | 32 | mov ax , TRUE 33 | mov [si].W_HIDE , ax 34 | dont_hide: 35 | call near ptr ModLog 36 | pop si 37 | pop bp 38 | ret 39 | _WnHide ENDP 40 | 41 | _WnUnHide PROC 42 | push bp 43 | mov bp , sp 44 | push si 45 | mov si , ARG_1 46 | 47 | xor ax , ax 48 | mov [si].W_HIDE , ax 49 | 50 | call near ptr ModLog 51 | pop si 52 | pop bp 53 | ret 54 | _WnUnHide ENDP 55 | END 56 | 57 | -------------------------------------------------------------------------------- /WNHIDEAL.ASM: -------------------------------------------------------------------------------- 1 | ;------------------------------------------------------------------------------; 2 | ; ; 3 | ; File Name : ; 4 | ; ; 5 | ; Description : ; 6 | ; ; 7 | ; ; 8 | ; C Prototypes ; 9 | ; ------------ ; 10 | ; ; 11 | ; void AllocError ( void ); ; 12 | ; ; 13 | ;------------------------------------------------------------------------------; 14 | ;------------------------------------------------------------------------------; 15 | ; ; 16 | ; Contains functions to Hide and Unhide all windows. ; 17 | ; ; 18 | ;------------------------------------------------------------------------------; 19 | .MODEL SMALL 20 | 21 | include window.inc 22 | 23 | public _WnHideAll 24 | public _WnUnHideAll 25 | extrn ModLog:near 26 | 27 | .CODE 28 | _WnHideAll PROC 29 | push si 30 | mov si , ARG_1 31 | 32 | mov ax , TRUE 33 | hideall1: 34 | mov [si].W_HIDE , ax 35 | mov bx , [si].W_NEXT 36 | or bx , bx 37 | jz hideall2 38 | jmp hideall1 39 | hideall2: 40 | call near ptr ModLog 41 | pop si 42 | ret 43 | _WnHideAll ENDP 44 | 45 | 46 | _WnUnHideAll PROC 47 | push si 48 | mov si , ARG_1 49 | 50 | xor ax , ax 51 | unhideall1: 52 | mov [si].W_HIDE , ax 53 | mov bx , [si].W_NEXT 54 | or bx , bx 55 | jz unhideall2 56 | jmp unhideall1 57 | unhideall2: 58 | call near ptr ModLog 59 | pop si 60 | ret 61 | _WnUnHideAll ENDP 62 | END 63 | 64 | -------------------------------------------------------------------------------- /WNINT24.ASM: -------------------------------------------------------------------------------- 1 | ;------------------------------------------------------------------------------; 2 | ; ; 3 | ; File Name : ; 4 | ; ; 5 | ; Description : Window module int 24 ( critical error ) handler. ; 6 | ; ; 7 | ;------------------------------------------------------------------------------; 8 | 9 | .MODEL SMALL 10 | 11 | include window.inc 12 | 13 | public _wnint24 14 | public _WnStealInt24 15 | public _WnRestoreInt24 16 | public _critical_error 17 | extrn _WnKill:near 18 | extrn _WnPrint:near 19 | extrn _WnMake:near 20 | extrn _VsDisp:near 21 | extrn _GetKey:near 22 | extrn _WnOpen:near 23 | extrn _WnBorder:near 24 | extrn _WnShadow:near 25 | extrn _WnChgAttr:near 26 | extrn _Beep:near 27 | 28 | 29 | .DATA 30 | err0 DB 'Write protected disk',0 31 | err1 DB 'Drive not known',0 32 | err2 DB 'Drive not ready',0 33 | err3 DB 'Invalid command',0 34 | err4 DB 'CRC data error',0 35 | err5 DB 'Structure length error',0 36 | err6 DB 'Disk seek error',0 37 | err7 DB 'Non - MS DOS disk',0 38 | err8 DB 'Sector not found',0 39 | errA DB 'Write fault',0 40 | errB DB 'Read fault',0 41 | errC DB 'General failure',0 42 | errF DB 'Invalid disk change',0 43 | errZ DB 'Try again or Quit ?',0 44 | errG DB 'Error accessing drive ',0 45 | errU DB 'Unknown error',0 46 | error_strings DW err0 47 | DW err1 48 | DW err2 49 | DW err3 50 | DW err4 51 | DW err5 52 | DW err6 53 | DW err7 54 | DW err8 55 | DW errU 56 | DW errA 57 | DW errB 58 | DW errC 59 | DW errU 60 | DW errU 61 | DW errF 62 | 63 | keys DB 'tTqQ' 64 | keys_len equ $ - keys 65 | codes DB 1, 1, 3, 3 66 | _critical_error DW FALSE 67 | old24 DD 0 68 | drive DB 0 69 | DB 0 ; null terminater for drive 70 | 71 | .DATA? 72 | dos_version LABEL WORD 73 | minorversion DB ? 74 | majorversion DB ? 75 | 76 | 77 | .CODE 78 | ; 79 | ; Set int 24 vector to point to my routine 80 | ; 81 | _WnStealInt24 PROC 82 | push ds 83 | push es 84 | 85 | mov ah , 30H ; get dos version 86 | int 21H ; call DOS 87 | xchg ah , al ; ah = major ver al = minor ver. 88 | mov word ptr dos_version , ax ; save it 89 | 90 | mov ax , 3524H ; get vector 91 | int 21H 92 | 93 | mov word ptr old24 , bx ; save it 94 | mov word ptr old24 + 2 , es 95 | 96 | push cs 97 | pop ds 98 | mov dx , offset _TEXT:_wnint24 99 | mov ax , 2524H ; change vector 100 | int 21H 101 | 102 | pop es 103 | pop ds 104 | ret 105 | _WnStealInt24 ENDP 106 | ; 107 | ; Restore original int 24 vector 108 | ; 109 | _WnRestoreInt24 PROC 110 | push ds 111 | lds dx , old24 112 | mov ax , 2524H 113 | int 21H 114 | 115 | pop ds 116 | ret 117 | _WnRestoreInt24 ENDP 118 | 119 | _wnint24 PROC FAR 120 | sti ; restore interupts 121 | push bp 122 | push bx 123 | push cx 124 | push dx 125 | push si 126 | push di 127 | push ds 128 | push es 129 | 130 | push ax ; save code 131 | mov ax , DGROUP 132 | mov ds , ax 133 | mov es , ax 134 | 135 | mov ax , 5 136 | push ax 137 | mov ax , 150 138 | push ax 139 | call near ptr _Beep 140 | add sp , 4 141 | 142 | mov ax , 3 143 | push ax 144 | mov ax , 300 145 | push ax 146 | call near ptr _Beep 147 | add sp , 4 148 | 149 | xor ax , ax ; bgc BLACK 150 | push ax 151 | mov ax , 0FH ; fgc LTWHITE 152 | push ax 153 | mov ax , 9 ; y 154 | push ax 155 | mov ax , 17 ; x 156 | push ax 157 | mov ax , 3 ; height 158 | push ax 159 | mov ax , 44 ; width 160 | push ax 161 | 162 | call near ptr _WnMake ; make the window 163 | add sp , 12 164 | mov si , ax ; ptr to win in si 165 | 166 | mov ax , 3 ; double line border. 167 | push ax 168 | push si 169 | call near ptr _WnBorder 170 | add sp , 4 171 | 172 | mov [si].W_FGC , 5 ; change colours of window 173 | mov [si].W_BGC , 0 174 | 175 | push si 176 | call near ptr _WnOpen 177 | inc sp 178 | inc sp 179 | 180 | pop ax ; restore data 181 | and ah , 80H ; disk error ? 182 | jne short no_disk_err 183 | 184 | add al , 'A' ; add the drive letter on the end. 185 | mov byte ptr drive , al 186 | 187 | mov [si].W_CURSX , 9 ; set up cursor position to write at 188 | mov [si].W_CURSY , 0 189 | 190 | mov ax , offset errG 191 | push ax 192 | push si 193 | call near ptr _WnPrint 194 | add sp , 4 195 | 196 | mov ax , offset drive 197 | push ax 198 | push si 199 | call near ptr _WnPrint 200 | add sp , 4 201 | no_disk_err: 202 | mov [si].W_CURSX , 7 ; set up cursor position to write at 203 | mov [si].W_CURSY , 1 204 | 205 | and di , 0FFH ; clear high nibble 206 | shl di , 1 ; convert to word pointer 207 | mov bx , offset error_strings ; get pointer to strings 208 | mov ax , [ bx + di ] ; point to appropriate one 209 | push ax ; push address 210 | push si ; push win 211 | call near ptr _WnPrint ; print it 212 | add sp , 4 213 | 214 | mov [si].W_CURSX , 9 ; set up cursor position to write at 215 | mov [si].W_CURSY , 2 216 | mov ax , offset errZ ; Retry or Quit message 217 | push ax 218 | push si 219 | call near ptr _WnPrint ; print it 220 | add sp , 4 221 | 222 | ; highlight T and Q in message. 223 | 224 | mov ax , 1 ; count 225 | push ax 226 | xor ax , ax ; bgc BLACK 227 | push ax 228 | mov ax , 0EH ; fgc YELLOW 229 | push ax 230 | mov ax , 2 ; y 231 | push ax 232 | mov ax , 9 ; x 233 | push ax 234 | push si ; win 235 | call near ptr _WnChgAttr 236 | add sp , 12 237 | 238 | mov ax , 1 ; count 239 | push ax 240 | xor ax , ax ; bgc BLACK 241 | push ax 242 | mov ax , 0EH ; fgc YELLOW 243 | push ax 244 | mov ax , 2 ; y 245 | push ax 246 | mov ax , 22 ; x 247 | push ax 248 | push si ; win 249 | call near ptr _WnChgAttr 250 | add sp , 12 251 | 252 | call near ptr _VsDisp ; display it all !! 253 | try_again: 254 | call near ptr _GetKey 255 | 256 | mov di , offset keys 257 | mov cx , keys_len 258 | cld 259 | repne scasb 260 | jnz short try_again 261 | 262 | mov al , [di + keys_len - 1] 263 | cmp al , 3 264 | jne short not_fail 265 | cmp byte ptr majorversion , 3 ; fail on version 3.x 266 | je short no_change 267 | xor al , al ; ignore if version 2.x 268 | no_change: 269 | mov word ptr _critical_error , TRUE 270 | not_fail: 271 | push ax ; save action 272 | push si 273 | call near ptr _WnKill 274 | inc sp 275 | inc sp 276 | pop ax ; restore action 277 | 278 | pop es 279 | pop ds 280 | pop di 281 | pop si 282 | pop dx 283 | pop cx 284 | pop bx 285 | pop bp 286 | iret 287 | _wnint24 ENDP 288 | END 289 | -------------------------------------------------------------------------------- /WNKILL.ASM: -------------------------------------------------------------------------------- 1 | ;------------------------------------------------------------------------------; 2 | ; ; 3 | ; File Name : wnkill.asm ; 4 | ; ; 5 | ; Description : Kills a Window by closing it and freeing its memory. ; 6 | ; ; 7 | ; C Prototypes ; 8 | ; ------------ ; 9 | ; void WnKill ( WINDOW *ptr ) ; 10 | ; ; 11 | ;------------------------------------------------------------------------------; 12 | .MODEL SMALL 13 | 14 | include window.inc 15 | 16 | public _WnKill 17 | extrn _WnClose:near 18 | extrn _free:near ; c library function 19 | 20 | .CODE 21 | _WnKill PROC 22 | push bp 23 | mov bp , sp 24 | 25 | push ARG_1 26 | call near ptr _WnClose ; WnClose ( ptr ) 27 | call near ptr _free ; free ( ptr ) 28 | inc sp 29 | inc sp 30 | 31 | pop bp 32 | ret 33 | _WnKill ENDP 34 | END 35 | -------------------------------------------------------------------------------- /WNKILLAL.ASM: -------------------------------------------------------------------------------- 1 | ;------------------------------------------------------------------------------; 2 | ; ; 3 | ; File Name : ; 4 | ; ; 5 | ; Description : Kills all windows by closeing and then freeing their memory. ; 6 | ; ; 7 | ; C Prototypes ; 8 | ; ------------ ; 9 | ; void WnKillAll( void ) ; 10 | ; ; 11 | ;------------------------------------------------------------------------------; 12 | .MODEL SMALL 13 | 14 | include window.inc 15 | 16 | public _WnKillAll 17 | extrn _first_win:word 18 | extrn _WnKill:near 19 | 20 | .CODE 21 | _WnKillAll PROC 22 | ; 23 | ; while ( first_win NE (WINDOW *)NULL ) 24 | ; WnKill ( first_win ); 25 | ; 26 | killall1: 27 | cmp first_win , 0 28 | je short killall2 29 | push first_win 30 | call near ptr _WnKill 31 | inc sp 32 | inc sp 33 | jmp short killall1 34 | killall2: 35 | ret 36 | _WnKillAll ENDP 37 | END 38 | -------------------------------------------------------------------------------- /WNMAKE.ASM: -------------------------------------------------------------------------------- 1 | ;------------------------------------------------------------------------------; 2 | ; ; 3 | ; File Name : wnmake.asm ; 4 | ; ; 5 | ; Description : Makes A Window. Sets up structure and allocate memory. ; 6 | ; ; 7 | ; C Prototypes ; 8 | ; ------------ ; 9 | ; WINDOW *WnMake ( int wid , int hgt , int x , int y , int fgc , int bgc ) ; 10 | ; ; 11 | ;------------------------------------------------------------------------------; 12 | .MODEL SMALL 13 | 14 | include window.inc 15 | 16 | public _WnMake 17 | extrn _malloc:near 18 | extrn _AllocError:near 19 | extrn _MakeAttr:near 20 | extrn _shadow_char:byte ; character to use for shadow 21 | extrn _shadow_fgc:word ; character fgc 22 | extrn _shadow_bgc:word ; character bgc 23 | extrn _shadow_type:word ; where the shadow sits 24 | extrn _border_type:word ; the default border 25 | 26 | .CODE 27 | _WnMake PROC 28 | push bp 29 | mov bp , sp 30 | push si 31 | push di 32 | ; 33 | ; ptr = (WINDOW *)malloc ( sizeof ( WINDOW ) + ( wid * hgt * sizeof ( int ) ) ); 34 | ; 35 | mov ax , ARG_1 ; wid 36 | mov cx , ARG_2 ; hgt 37 | cmp ax , 80 ; maximun width 38 | jle short check_hgt ; exceeding 80 * 25 causes big 39 | mov ax , 80 ; problems !!!!!!!!! 40 | check_hgt: ; 41 | cmp cx , 25 ; maximum hgt 42 | jle short size_ok 43 | mov cx , 25 44 | size_ok: 45 | imul cl 46 | push ax ; save hgt * wid for later 47 | shl ax , 1 ; * 2 48 | add ax , SIZEOF_WINDOW ; sizeof WINDOW 49 | push ax 50 | call near ptr _malloc 51 | inc sp 52 | inc sp 53 | mov si , ax ; ptr 54 | 55 | or ax , ax ; if ( ptr EQ NULL ) 56 | jne short alloc_ok 57 | call near ptr _AllocError ; releases all window memory 58 | ; and exits via dos. 59 | alloc_ok: 60 | mov [si].W_SELF , si ; used for checking 61 | 62 | mov ax , ARG_1 ; si = start of memory block 63 | mov [si].W_WID , ax ; ptr -> wid = wid 64 | mov ax , ARG_2 65 | mov [si].W_HGT , ax ; ptr -> hgt = hgt 66 | 67 | mov ax , ARG_3 68 | mov [si].W_X , ax ; ptr -> x = x 69 | mov ax , ARG_4 70 | mov [si].W_Y , ax ; ptr -> y = y 71 | 72 | mov ax , ARG_5 73 | mov [si].W_FGC , ax ; ptr -> fgc = fgc 74 | mov ax , ARG_6 75 | mov [si].W_BGC , ax ; ptr -> bgc = bgc 76 | 77 | xor ax , ax ; 0 or FALSE 78 | 79 | mov [si].W_CURSX , ax ; ptr -> cursx = 0 80 | mov [si].W_CURSY , ax ; ptr -> cursy = 0 81 | 82 | mov [si].W_COPT , ax ; ptr -> copt = 0 83 | mov [si].W_OPEN , ax ; ptr -> open = FALSE 84 | mov [si].W_HIDE , ax ; ptr -> hide = FALSE 85 | mov [si].W_TITLE , ax ; ptr -> title = NULL 86 | mov [si].W_BDR_CHG , TRUE ; ptr -> bdr_chg = TRUE 87 | 88 | mov ax , _border_type ; ptr -> bdr = border_type 89 | mov [si].W_BDR , ax ; save it 90 | 91 | or ax , ax ; if there is no border , then check 92 | jnz short not_too_small ; to see if the window is too small 93 | cmp [si].W_WID , 1 ; is it 1 wide 94 | jle short too_small ; dont do a shadow 95 | cmp [si].W_HGT , 1 ; or 1 high 96 | jg short not_too_small ; dont do a shadow 97 | too_small: 98 | mov [si].W_SHADCHAR , 32 ; ptr -> shadchar = 0x20 99 | mov [si].W_SHADOW , FALSE ; ptr -> shadow = FALSE 100 | jmp short alot_pointer 101 | not_too_small: 102 | push _shadow_bgc 103 | push _shadow_fgc 104 | call near ptr _MakeAttr 105 | add sp , 4 106 | 107 | mov ah , al ; save attribute in ah 108 | mov al , _shadow_char 109 | mov [si].W_SHADCHAR , ax ; ptr -> shadchar = default settings 110 | mov ax , _shadow_type 111 | mov [si].W_SHADOW , ax ; ptr -> shadow = default 112 | alot_pointer: 113 | ; 114 | ; ptr -> ptr = (int *)( (int)ptr + (int)sizeof ( WINDOW ) ); 115 | ; 116 | mov ax , si 117 | add ax , SIZEOF_WINDOW 118 | mov [si].W_PTR , ax 119 | mov di , [si].W_PTR ; screen_ptr = ptr -> ptr; 120 | ; 121 | ; attr = MakeAttr ( fgc , bgc ) * 256; 122 | ; 123 | push ARG_6 124 | push ARG_5 125 | call near ptr _MakeAttr 126 | add sp , 4 127 | 128 | mov [si].W_BDR_ATTR , ax ; save current attribute for the border 129 | 130 | mov ah , al ; attribute in ah 131 | mov al , 32 ; + ' ' 132 | ; 133 | ; for ( n = ( hgt * wid ) ; n GT 0 ; n-- ) 134 | ; 135 | pop cx ; get size of screen off stack 136 | rep stosw ; *screen_ptr++ = ax (attr + ' ') 137 | 138 | mov ax , si ; return ( ptr ); 139 | pop di 140 | pop si 141 | pop bp 142 | ret 143 | _WnMake ENDP 144 | END 145 | -------------------------------------------------------------------------------- /WNMOVE.ASM: -------------------------------------------------------------------------------- 1 | ;------------------------------------------------------------------------------; 2 | ; ; 3 | ; File Name : wnmove.asm ; 4 | ; ; 5 | ; Description : Moves the position of a WINDOW on the screen. ; 6 | ; ; 7 | ; C Prototypes ; 8 | ; ------------ ; 9 | ; void WnMove ( WINDOW *ptr , int x , int y ) ; 10 | ; ; 11 | ;------------------------------------------------------------------------------; 12 | .MODEL SMALL 13 | 14 | include window.inc 15 | 16 | public _WnMove 17 | extrn ModLog:near 18 | 19 | .CODE 20 | _WnMove PROC 21 | push bp 22 | mov bp , sp 23 | push si 24 | mov si , ARG_1 25 | 26 | call near ptr ModLog ; must be called to log OLD position of window 27 | 28 | mov ax , ARG_2 29 | mov [si].W_X , ax ; ptr -> x = x 30 | mov ax , ARG_3 31 | mov [si].W_Y , ax ; ptr -> y = y 32 | 33 | cmp [si].W_OPEN , 0 ; if its not open 34 | je short move1 ; jump 35 | 36 | call near ptr ModLog 37 | move1: 38 | pop si 39 | pop bp 40 | ret 41 | _WnMove ENDP 42 | 43 | END 44 | -------------------------------------------------------------------------------- /WNOPEN.ASM: -------------------------------------------------------------------------------- 1 | ;------------------------------------------------------------------------------; 2 | ; ; 3 | ; File Name : wnopen.asm ; 4 | ; ; 5 | ; Description : WINDOW functions to open a window and add to linked list ; 6 | ; ; 7 | ; C Prototypes ; 8 | ; ------------ ; 9 | ; void WnOpen ( WINDOW *ptr ) ; 10 | ; ; 11 | ;------------------------------------------------------------------------------; 12 | .MODEL SMALL 13 | 14 | include window.inc 15 | 16 | public _WnOpen 17 | public KOpen 18 | 19 | extrn KClose:near 20 | extrn ModLog:near 21 | extrn _WnDeActivate:near 22 | extrn _first_win:word 23 | extrn _last_win:word 24 | extrn _active_win:word 25 | extrn _no_wins:word 26 | 27 | .CODE 28 | _WnOpen PROC 29 | push bp 30 | mov bp , sp 31 | push si 32 | mov si , ARG_1 ; WINDOW *ptr 33 | 34 | call near ptr _WnDeActivate ; any ACTIVATED window must be deactivated first 35 | 36 | cmp [si].W_OPEN , TRUE ; is it open ? 37 | jne short open1 ; no .. jump 38 | call near ptr KClose ; yes .. close it first 39 | open1: 40 | call near ptr KOpen ; link this one on to end of list 41 | call near ptr ModLog ; log changes 42 | 43 | pop si 44 | pop bp 45 | ret 46 | _WnOpen ENDP 47 | 48 | 49 | KOpen PROC 50 | ; 51 | ; at entry si points to the window structure. 52 | ; 53 | push di 54 | 55 | mov ax , last_win ; ptr -> back_link = last_win 56 | mov [si].W_PREV , ax ; get last window in list and tack this one on 57 | 58 | mov [si].W_NEXT , 0 ; ptr -> on_link = ( WINDOW *)NULL 59 | 60 | cmp first_win , 0 ; if ( first_win EQ (WINDOW *)NULL ) 61 | jne short kop1 ; if others open then make it last 62 | mov first_win , si ; else make it first 63 | jmp short kop2 ; first_win = ptr 64 | kop1: 65 | mov di , [si].W_PREV ; else { temp_ptr = ptr -> back_link } 66 | mov [di].W_NEXT , si ; temp_ptr -> on_link = ptr 67 | kop2: 68 | mov last_win , si ; make this one the last one 69 | mov active_win , si ; and the active window 70 | mov [si].W_HIDE , FALSE ; ptr -> hide = FALSE 71 | mov [si].W_OPEN , TRUE ; ptr -> open = TRUE 72 | inc no_wins ; one more window 73 | 74 | pop di 75 | ret 76 | KOpen ENDP 77 | END 78 | -------------------------------------------------------------------------------- /WNPRINT.ASM: -------------------------------------------------------------------------------- 1 | ;------------------------------------------------------------------------------; 2 | ; ; 3 | ; File Name : wnprint.asm ; 4 | ; ; 5 | ; Description : Contains WINDOW function to print at the ; 6 | ; current cursor position. ; 7 | ; ; 8 | ; C Prototypes ; 9 | ; ------------ ; 10 | ; void WnPrint ( WINDOW *ptr , char *string ) ; 11 | ; ; 12 | ;------------------------------------------------------------------------------; 13 | .MODEL SMALL 14 | 15 | include window.inc 16 | 17 | newline EQU 0AH ; newline character 18 | 19 | public _WnPrint 20 | extrn _MakeAttr:near 21 | extrn ModLog:near 22 | 23 | .CODE 24 | _WnPrint PROC 25 | push bp 26 | mov bp , sp 27 | push di 28 | push si 29 | 30 | mov bx , ARG_1 ; WINDOW *ptr 31 | mov si , ARG_2 ; move string ptr into si. 32 | 33 | push [bx].W_BGC 34 | push [bx].W_FGC 35 | call near ptr _MakeAttr 36 | add sp , 4 37 | mov ah , al ; mov attribute into ah for loop 38 | mov cx , [bx].W_CURSX 39 | mov dx , [bx].W_CURSY 40 | print1: 41 | ; cursor = ( ptr -> ptr ) + ( cursy * ( ptr -> wid ) ) + cursx 42 | push ax ; save attribute 43 | push cx ; and cursx 44 | mov ax , dx 45 | mov cx , [bx].W_WID 46 | imul cl 47 | shl ax , 1 48 | mov di , [bx].W_PTR 49 | add di , ax 50 | pop cx ; restore cursx 51 | mov ax , cx 52 | shl ax , 1 53 | add di , ax 54 | pop ax ; restore attribute 55 | print2: 56 | lodsb ; mov char into al 57 | or al , al ; is it \0 58 | jz short print4 59 | cmp al , newline ; it a \n 60 | je short print3 61 | stosw ; mov ax into [di] 62 | inc cx ; cursx ++ 63 | cmp cx , [bx].W_WID 64 | jl short print2 65 | xor cx , cx 66 | inc dx 67 | cmp dx , [bx].W_HGT 68 | jl short print2 69 | xor dx , dx 70 | jmp short print1 ; wrap around so update destination pointer 71 | print3: 72 | xor cx , cx ; routine for newline 73 | inc dx 74 | cmp dx , [bx].W_HGT 75 | jl short print1 76 | xor dx , dx 77 | jmp short print1 78 | print4: 79 | mov [bx].W_CURSX , cx 80 | mov [bx].W_CURSY , dx 81 | cmp [bx].W_OPEN , FALSE ; if the window is not open 82 | je short print_end ; jump 83 | xchg si , bx ; modlog requires WINDOW ptr in si 84 | call near ptr ModLog 85 | print_end: 86 | pop si 87 | pop di 88 | pop bp 89 | ret 90 | _WnPrint ENDP 91 | END 92 | -------------------------------------------------------------------------------- /WNPRINTX.ASM: -------------------------------------------------------------------------------- 1 | ;------------------------------------------------------------------------------; 2 | ; ; 3 | ; File Name : ; 4 | ; ; 5 | ; Description : Prints a string at the specified cursor position. ; 6 | ; ; 7 | ; C Prototypes ; 8 | ; ------------ ; 9 | ; void WnPrintxy ( WINDOW *ptr , int x , int y , char *string ) ; 10 | ; ; 11 | ;------------------------------------------------------------------------------; 12 | .MODEL SMALL 13 | 14 | include window.inc 15 | 16 | public _WnPrintxy 17 | extrn _WnPrint:near 18 | extrn _MakeAttr:near 19 | 20 | .CODE 21 | _WnPrintxy PROC 22 | push bp 23 | mov bp , sp 24 | push si 25 | push di 26 | mov si , ARG_1 27 | ; save values on the stack 28 | push [si].W_CURSX ; oldx = ptr -> cursx 29 | push [si].W_CURSY ; oldy = ptr -> cursy 30 | 31 | mov ax , ARG_2 32 | mov [si].W_CURSX , ax ; ptr -> cursx = x 33 | 34 | mov ax , ARG_3 35 | mov [si].W_CURSY , ax ; ptr -> cursy = y 36 | 37 | push ARG_4 ; WnPrint ( ptr , string ); 38 | push si 39 | call near ptr _WnPrint 40 | add sp , 4 41 | ; 42 | ; WnSetCurs ( ptr , oldx , oldy ); 43 | ; ; restore values from the stack 44 | pop [si].W_CURSY ; oldx 45 | pop [si].W_CURSX ; oldy 46 | 47 | pop di 48 | pop si 49 | pop bp 50 | ret 51 | _WnPrintxy ENDP 52 | END 53 | -------------------------------------------------------------------------------- /WNPXYA.ASM: -------------------------------------------------------------------------------- 1 | ;------------------------------------------------------------------------------; 2 | ; ; 3 | ; File Name : wnpxya.asm ; 4 | ; ; 5 | ; Description : Contains WINDOW function to print at x , y with attributes. ; 6 | ; ; 7 | ; C Prototypes ; 8 | ; ------------ ; 9 | ; void WnPrintxya( WINDOW *ptr, int x, int y, char *string, int fgc, int bgc ) ; 10 | ; ; 11 | ;------------------------------------------------------------------------------; 12 | .MODEL SMALL 13 | 14 | include window.inc 15 | 16 | public _WnPrintxya 17 | extrn _WnPrint:near 18 | 19 | .CODE 20 | _WnPrintxya PROC 21 | push bp 22 | mov bp , sp 23 | push si 24 | push di 25 | mov si , ARG_1 26 | ; save values on the stack 27 | push [si].W_CURSX ; oldx = ptr -> cursx 28 | push [si].W_CURSY ; oldy = ptr -> cursy 29 | push [si].W_FGC ; old_fgc = ptr -> fgc 30 | push [si].W_BGC ; old_bgc = ptr -> bgc 31 | 32 | mov ax , ARG_2 ; x 33 | mov [si].W_CURSX , ax ; ptr -> cursx = x 34 | 35 | mov ax , ARG_3 ; y 36 | mov [si].W_CURSY , ax ; ptr -> cursy = y 37 | 38 | mov ax , ARG_5 ; fgc 39 | mov [si].W_FGC , ax ; ptr -> fgc = fgc 40 | 41 | mov ax , ARG_6 ; bgc 42 | mov [si].W_BGC , ax ; ptr -> bgc = bgc 43 | ; 44 | ; WnPrint ( ptr , string ); 45 | ; 46 | push ARG_4 47 | push si 48 | call near ptr _WnPrint 49 | add sp , 4 50 | ; restore values from the stack 51 | pop [si].W_BGC ; ptr -> bgc = old_bgc 52 | pop [si].W_FGC ; ptr -> fgc = old_fgc 53 | pop [si].W_CURSY ; ptr -> cursy = oldy 54 | pop [si].W_CURSX ; ptr -> cursx = oldx 55 | 56 | pop di 57 | pop si 58 | pop bp 59 | ret 60 | _WnPrintxya ENDP 61 | END 62 | -------------------------------------------------------------------------------- /WNSACTCO.ASM: -------------------------------------------------------------------------------- 1 | ;------------------------------------------------------------------------------; 2 | ; ; 3 | ; File Name : ; 4 | ; ; 5 | ; Description : Contains functions to set and return the WINDOW modules ; 6 | ; Active border colours ; 7 | ; ; 8 | ; ; 9 | ; C Prototypes ; 10 | ; ------------ ; 11 | ; void WnSetActColours ( int fgc , int bgc ) ; 12 | ; void WnGetActColours ( int *fgc , int *bgc ) ; 13 | ; ; 14 | ;------------------------------------------------------------------------------; 15 | .MODEL SMALL 16 | 17 | include window.inc 18 | 19 | public _WnSetActColours 20 | public _WnGetActColours 21 | extrn _MakeAttr:near 22 | extrn _active_win_attr:word 23 | 24 | .CODE 25 | _WnSetActColours PROC 26 | push bp 27 | mov bp , sp 28 | 29 | push ARG_2 30 | push ARG_1 31 | 32 | call near ptr _MakeAttr 33 | add sp , 4 34 | 35 | mov active_win_attr , ax 36 | 37 | pop bp 38 | ret 39 | _WnSetActColours ENDP 40 | 41 | 42 | _WnGetActColours PROC 43 | push bp 44 | mov bp , sp 45 | 46 | mov ax , active_win_attr 47 | mov cx , ax 48 | 49 | or cx , 00F0H 50 | mov bx , ARG_2 51 | mov WORD PTR [bx] , cx 52 | 53 | mov cl , 4 54 | shr ax , cl 55 | mov bx , ARG_1 56 | mov WORD PTR [bx] , ax 57 | 58 | pop bp 59 | ret 60 | _WnGetActColours ENDP 61 | END 62 | -------------------------------------------------------------------------------- /WNSCROLL.ASM: -------------------------------------------------------------------------------- 1 | ;------------------------------------------------------------------------------; 2 | ; ; 3 | ; File Name : ; 4 | ; ; 5 | ; Description : Scroll the WINDOW up or down. ; 6 | ; ; 7 | ; C Prototypes ; 8 | ; ------------ ; 9 | ; void WnScroll ( WINDOW *ptr , int dir , int start_line , int count ) ; 10 | ; ; 11 | ;------------------------------------------------------------------------------; 12 | .MODEL SMALL 13 | 14 | include window.inc 15 | 16 | public _WnScroll 17 | extrn ModLog:near 18 | extrn BiosSetCursPos:near 19 | 20 | .CODE 21 | _WnScroll PROC 22 | push bp 23 | mov bp , sp 24 | push si 25 | push di 26 | 27 | mov si , ARG_1 28 | mov cx , [si].W_WID ; int wid = ptr -> wid; 29 | 30 | mov ax , ARG_4 ; count *= wid; 31 | imul cx 32 | mov ARG_4 , ax 33 | shl cx , 1 34 | ; 35 | ; src_ptr = ptr -> ptr + start_line * wid; 36 | ; 37 | mov ax , ARG_3 38 | imul cx 39 | add ax , [si].W_PTR 40 | mov bx , ax 41 | 42 | cmp ARG_2 , 1 ; are we going up ? 43 | jne short scroll2 ; no...jump 44 | 45 | mov di , bx ; dst_ptr = src_ptr - wid; 46 | sub di , cx 47 | jmp short scroll3 ; do scroll 48 | scroll2: 49 | ; 50 | ; going DOWN !! 51 | ; src_ptr = ptr -> ptr + start_line * wid ( bx ) + count - 1; 52 | ; 53 | mov ax , ARG_4 54 | shl ax , 1 55 | add ax , 65534 56 | add bx , ax 57 | mov di , bx ; dst_ptr = src_ptr + wid; 58 | add di , cx 59 | std ; set direction flag on ( dec si & di ) 60 | scroll3: 61 | xchg bx , si ; swap source from bx to si 62 | 63 | ; 64 | ; while ( count-- ) 65 | ; *dst_ptr++ = *src_ptr++; if DF = 0 66 | ; *dst_ptr-- = *src_ptr--; if DF = 1 67 | ; in di in si 68 | ; 69 | mov cx , ARG_4 ; count in dx 70 | rep movsw ; do the transfer 71 | cld ; clear the direction flag 72 | 73 | xchg bx , si ; swap WINDOW from bx to si 74 | cmp [si].W_OPEN , 0 75 | je short scroll4 ; dont change mod_flag 76 | 77 | call near ptr ModLog 78 | scroll4: 79 | pop di 80 | pop si 81 | pop bp 82 | ret 83 | _WnScroll ENDP 84 | END 85 | -------------------------------------------------------------------------------- /WNSETATT.ASM: -------------------------------------------------------------------------------- 1 | ;------------------------------------------------------------------------------; 2 | ; ; 3 | ; File Name : wnsetatt.asm ; 4 | ; ; 5 | ; Description : Contains WINDOW function to set a windows attributes. ; 6 | ; ; 7 | ; C Prototypes ; 8 | ; ------------ ; 9 | ; void WnSetAttr ( WINDOW *ptr , int fgc , int bgc ) ; 10 | ; ; 11 | ;------------------------------------------------------------------------------; 12 | .MODEL SMALL 13 | 14 | include window.inc 15 | 16 | public _WnSetAttr 17 | 18 | .CODE 19 | _WnSetAttr PROC 20 | push bp 21 | mov bp , sp 22 | push si 23 | mov si , ARG_1 24 | 25 | mov ax , ARG_2 ; ptr -> fgc = fgc 26 | mov [si].W_FGC , ax 27 | 28 | mov ax , ARG_3 ; ptr -> bgc = bgc 29 | mov [si].W_BGC , ax 30 | 31 | pop si 32 | pop bp 33 | ret 34 | _WnSetAttr ENDP 35 | END 36 | -------------------------------------------------------------------------------- /WNSETCUR.ASM: -------------------------------------------------------------------------------- 1 | ;------------------------------------------------------------------------------; 2 | ; ; 3 | ; File Name : wnsetcur.asm ; 4 | ; ; 5 | ; Description : Contains WINDOW function to set a windows cursor position. ; 6 | ; ; 7 | ; C Prototypes ; 8 | ; ------------ ; 9 | ; void WnSetCurs ( WINDOW *ptr , int x , int y ) ; 10 | ; ; 11 | ;------------------------------------------------------------------------------; 12 | .MODEL SMALL 13 | 14 | include window.inc 15 | 16 | public _WnSetCurs 17 | 18 | .CODE 19 | _WnSetCurs PROC 20 | push bp 21 | mov bp , sp 22 | push si 23 | mov si , ARG_1 24 | 25 | mov ax , ARG_2 ; ptr -> cursx = x 26 | mov [si].W_CURSX , ax 27 | 28 | mov ax , ARG_3 ; ptr -> cursy = y 29 | mov [si].W_CURSY , ax 30 | 31 | pop si 32 | pop bp 33 | ret 34 | _WnSetCurs ENDP 35 | END 36 | -------------------------------------------------------------------------------- /WNSHADOW.ASM: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rhulse/dos-asm-windowing-library/8bc3499a1c626ffbb91d20385c831d1059c1f9f7/WNSHADOW.ASM -------------------------------------------------------------------------------- /WNSHOFF.ASM: -------------------------------------------------------------------------------- 1 | ;------------------------------------------------------------------------------; 2 | ; ; 3 | ; File Name : wnshoff.asm ; 4 | ; ; 5 | ; Description : turn the shadow of the specified window off. ; 6 | ; ; 7 | ; C Prototypes ; 8 | ; ------------ ; 9 | ; ; 10 | ; void WnShadowOff ( WINDOW *ptr ); ; 11 | ; ; 12 | ;------------------------------------------------------------------------------; 13 | .MODEL SMALL 14 | 15 | include window.inc 16 | 17 | public _WnShadowOff 18 | extrn ModLog:near 19 | extrn _MakeAttr:near 20 | 21 | .CODE 22 | 23 | _WnShadowOff PROC 24 | push bp 25 | mov bp , sp 26 | push si 27 | mov si , ARG_1 28 | 29 | call near ptr ModLog ; if shadow is changed - stops bits being left 30 | 31 | mov [si].W_SHADCHAR , 32 ; ptr -> shadchar = 0x20 32 | mov [si].W_SHADOW , ax ; ptr -> shadow = FALSE 33 | 34 | call near ptr ModLog 35 | 36 | pop si 37 | pop bp 38 | ret 39 | _WnShadowOff ENDP 40 | END 41 | -------------------------------------------------------------------------------- /WNTITLE.ASM: -------------------------------------------------------------------------------- 1 | ;------------------------------------------------------------------------------; 2 | ; ; 3 | ; File Name : wntitle.asm ; 4 | ; ; 5 | ; Description : set the string to display as the title in the border. ; 6 | ; ; 7 | ; C Prototypes ; 8 | ; ------------ ; 9 | ; void WnTitle ( WINDOW *ptr , char *static text ) ; 10 | ; ; 11 | ;------------------------------------------------------------------------------; 12 | .MODEL SMALL 13 | 14 | include window.inc 15 | 16 | public _WnTitle 17 | 18 | .CODE 19 | _WnTitle PROC 20 | push bp 21 | mov bp , sp 22 | push si 23 | mov si , ARG_1 24 | 25 | mov ax , ARG_2 26 | mov [si].W_TITLE , ax 27 | 28 | pop si 29 | pop bp 30 | ret 31 | _WnTitle ENDP 32 | END 33 | --------------------------------------------------------------------------------