Category : Files from Magazines
Archive   : PJ91.ZIP
Filename : MONOSCRN.ASM

 
Output of file : MONOSCRN.ASM contained in archive : PJ91.ZIP
;*******************************************************************************
;| |
;| Module: Monochrome Screen access from Windows 3.0 |
;| |
;| Description: This module demonstrates how to access memory mapped |
;| devices within the Windows environment. |
;| |
;| Author: Chris Schwartz (c) 10/25/90 |
;| |
;*******************************************************************************

.MODEL SMALL

PUBLIC DllInit ;dll entry point
PUBLIC WEP ;dll exit point

PUBLIC VioInit
PUBLIC VioWrtStrAttr
PUBLIC DpmActiveMode
PUBLIC DpmSelectorFromSegment

.DATA

bogusData dw 8 DUP(0) ;just to keep windows from wigging out
wVideoSeg dw 0

.CODE
;*******************************************************************************
;| |
;| FAR PASCAL Calling Convention |
;| |
;| BOOL DllInit(VOID); - Dll entry point, called by windows during loading|
;| |
;| Entry Values: DS = Library Data Segment ES = Command Line Sel |
;| DI = Module Handle SI = Command Line Off |
;| CX = Local Heap Size |
;| |
;| Return Values: AX = 0 Failed, don't load |
;| AX != 0 Success, load this puppy. |
;| |
;*******************************************************************************
;-------------------------------------------------------------------------------
DllInit PROC FAR
mov ax, 1 ;load this puppy
ret
DllInit ENDP

;*******************************************************************************
;| |
;| FAR PASCAL Calling Convention |
;| |
;| BOOL WEP(WORD wExitMode); - Dll exit point |
;| |
;| Return Values: AX = 0 Failed Cleanup |
;| AX != 0 Success |
;| |
;*******************************************************************************
;-------------------------------------------------------------------------------
WEP PROC FAR
mov ax, 1 ;goodbye
ret 2
WEP ENDP

;*******************************************************************************
;| |
;| FAR PASCAL Calling Convention |
;| |
;| BOOL DpmActiveMode(VOID); |
;| |
;| Return Values: AX = 0 Protected Mode under DPMI |
;| AX != 0 Real mode, or not under DPMI |
;| |
;*******************************************************************************
;-------------------------------------------------------------------------------
DpmActiveMode PROC FAR
mov ax, 1686h ;DPMI Mode Detection Op Code
int 2Fh ;only changes the AX register
ret
DpmActiveMode ENDP

;*******************************************************************************
;| |
;| FAR PASCAL Calling Convention |
;| |
;| WORD DpmSelectorFromSegment(WORD); |
;| |
;| Return Value: AX = 0 Then function failed, else we have a selector. |
;| |
;*******************************************************************************
;-------------- Formal Parameters ----------------------------------------------
wRealSegment equ [bp+06]
;-------------------------------------------------------------------------------
DpmSelectorFromSegment PROC FAR
push bp
mov bp, sp

mov ax, 02h
mov bx, wRealSegment
int 31h
jnc DpmSFSExit ;return protected mode selector

xor ax, ax ;return error code
DpmSFSExit:
pop bp
ret 2
DpmSelectorFromSegment ENDP

;*******************************************************************************
;| |
;| FAR PASCAL Calling Convention |
;| |
;| VOID VioInit(VOID); |
;| |
;*******************************************************************************
;-------------------------------------------------------------------------------
VioInit PROC FAR
push ds
mov ax, DGROUP
mov ds, ax ;fixup the dll's data segment

call DpmActiveMode
or ax, ax
je VioInitProtMode

mov wVideoSeg, 0B000h
ret
VioInitProtMode:
mov ax, 0B000h ;monochrome segment value
push ax
call DpmSelectorFromSegment
or ax, ax
je VioInitExit

mov wVideoSeg, ax
VioInitExit:
pop ds
ret
VioInit ENDP

;*******************************************************************************
;| |
;*******************************************************************************
ScreenOffset PROC NEAR
mov bx, ax
mov cx, 6
shl ax, cl
sub cx, 2
shl bx, cl
add ax, bx
add ax, dx
shl ax, 1
mov dx, wVideoSeg
ret
ScreenOffset ENDP

;*******************************************************************************
;| |
;| FAR PASCAL Calling Convention |
;| |
;| VioWrtStrAttr(lpData, wLen, wRow, wCol, lpAttr) |
;| |
;*******************************************************************************
;-------------- Formal Parameters ----------------------------------------------
lpData equ [bp+16]
wLen equ [bp+14]
wRow equ [bp+12]
wCol equ [bp+10]
lpAttr equ [bp+06]
;-------------------------------------------------------------------------------
VioWrtStrAttr PROC FAR
push bp
mov bp, sp
push ds
mov ax, DGROUP
mov ds, ax ;fixup dll's data segment
push es
push di
push si

mov ax, wRow
mov dx, wCol

call ScreenOffset ;returns proper video address
or dx, dx
je VioWrtStrAttrExit

mov es, dx
mov di, ax
mov cx, wLen

lds si, lpAttr
lodsb
mov ah, al
lds si, lpData

VioWrtStrAttrLoop:

lodsb
stosw
loop VioWrtStrAttrLoop ;cook those puppies

VioWrtStrAttrExit:
pop si
pop di
pop es
pop ds
pop bp
ret 14
VioWrtStrAttr ENDP
END DllInit


  3 Responses to “Category : Files from Magazines
Archive   : PJ91.ZIP
Filename : MONOSCRN.ASM

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/