Category : Files from Magazines
Archive   : WDAUG92.ZIP
Filename : 3N08036A

 
Output of file : 3N08036A contained in archive : WDAUG92.ZIP
; EGATOOL3.ASM -- EGA/VGA Icon Editor routines
; BY PEDER JUNGCK (Copyright 1991)
; Assembly language routines designed for C-style calling conventions
; All example routines use a near call model - assemble with /MX switch

; ======== COMPILER DIRECTIVES =======

.model small
.code

; ======== PUBLIC DEFINITIONS ========

Public _Video_Mode ;(int Mode)
Public _Set_Pixel ;(int x,int y,int Color)
Public _Display_Icon ;(int x,int y,void far *Data);
Public _Copy_Icon ;(int OrigX, int OrigY, int X, int Y);

; ============ CONSTANTS =============

BytesPerLine dw 40 ; screen width in bytes (320x200 Mode)
VOffset equ 0a000h ; video RAM offset

; =================================================================

Video_ModeParms struc
dw ? ; pushed BP
dw ? ; return address pushed by call
vm_mode dw ? ; pass new video mode parameter
Video_ModeParms ends

_Video_Mode proc near ; void Video_Mode(int Mode);
push bp
mov bp,sp ; put sp in bp, to get parameters on stack
mov ax,[bp+vm_mode]
xor ah,ah ; set video mode ( ah=0 )
int 10h ; call video BIOS
pop bp
ret
_Video_Mode endp


; ==============================================================

Set_PixelParms struc
dw ? ; pushed BP
dw ? ; return address pushed by call
ps_xpos dw ? ; X Position of Pixel
ps_ypos dw ? ; Y Position of Pixel
Color dw ? ; Color of Pixel
Set_PixelParms ends

_Set_Pixel proc near ; void Set_Pixel(int x, int y, int Color)
push bp
mov bp,sp
push ds ; save the data segment
mov ax,VOffset ; get the video RAM address
mov ds,ax ; set data segment to EGA/VGA
mov ax,[bp+ps_ypos] ; get the y coordinate
mul BytesPerLine ; get the offset to line y
mov bx,[bp+ps_xpos] ; get the x coordinate
mov cx,bx ; and save in CX
shr bx,1 ; and divide by 8
shr bx,1
shr bx,1
add bx,ax ; bx := BytesPerLine*y+(x/8)
; we now have x,y memory offset
and cl,7 ; generate mask for one pixel in byte
xor cl,7
mov ch,1
shl ch,cl ; ch := 1 >>>> (7-(x mod 8))

mov dx,3ceh ; now select write mode 2
mov al,5
out dx,al ; select mode (register 5)
mov dx,3cfh
mov al,2
out dx,al ; and set to write mode 2

mov dx,3ceh ; set up mask
mov al,8
out dx,al ; select mask (register 8)
mov dx,3cfh
mov al,ch
out dx,al ; set mask

mov al,[bx] ; read from card and color dot
mov ax,[bp+Color]
mov [bx],al ; write color to dot

mov dx,3ceh ; restore default mode
mov al,5
out dx,al ; select mode (register 5)
mov dx,3cfh
mov al,0
out dx,al ; set write mode back to 0
mov dx,3ceh
mov al,8
out dx,al ; select mask (register 8)
mov dx,3cfh
mov al,0ffh
out dx,al ; and set default mask
pop ds ; restore data segment
pop bp
ret
_Set_Pixel endp

; ==============================================================


Display_IconParms struc
dw ? ; pushed BP
dw ? ; return address pushed by call
di_xpos dw ? ; X position of Icon
di_ypos dw ? ; Y position of Icon
di_addr dd ? ; Address of Icon Data
Display_IconParms ends

; _Diaplay_Icon(int x, int y, void far *Data);
_Display_Icon proc near
push bp
mov bp,sp
push ds
push di
push si

mov di,BytesPerLine ; RAM Line length currently set

lds si,[bp+di_addr] ; ds:[si]=start of icon
mov dx,VOffset ; EGA address
mov es,dx ; segment ega

mov ax,[bp+di_ypos] ; get vertical line
mul di

mov bx,[bp+di_xpos] ; horizontal byte
add bx,ax ; (y*40) + bx <- the horiz byte
; normally in wm0

dec di ; Next line offset variable
; Adding at position 2 in icon
; to end up at position 1 in next
; line of the icon in video RAM

mov dx,03c4h ; select the map register.
mov al,2
out dx,al

mov cx,16 ; Number of lines per icon
DIStart: ; column 1
mov dx,3ceh
lodsb ; get the mask.
mov ah,8
xchg ah,al
out dx,ax

mov dx,03c5h ; load the map register data address.

mov al,1 ; plane 1.
out dx,al
lodsb
xchg es:[bx],al

mov al,2 ; plane 2.
out dx,al
lodsb
xchg es:[bx],al

mov al,4 ; plane 4.
out dx,al
lodsb
xchg es:[bx],al

mov al,8 ; plane 8.
out dx,al
lodsb
xchg es:[bx],al

inc bx ; column 2

mov dx,3ceh
lodsb ; get the mask.
mov ah,8
xchg ah,al
out dx,ax

mov dx,03c5h ; load the map register data address.

mov al,1 ; plane 1.
out dx,al
lodsb
xchg es:[bx],al

mov al,2 ; plane 2.
out dx,al
lodsb
xchg es:[bx],al

mov al,4 ; plane 4.
out dx,al
lodsb
xchg es:[bx],al

mov al,8 ; plane 8.
out dx,al
lodsb
xchg es:[bx],al

add bx,di ; Start of next line of icon
; in video RAM

loop DIStart ; do next row

mov al,0fh ;reset the map mask.
out dx,al

mov dx,3ceh
mov ax,0ff08h ; reset the bit mask to all ones.
out dx,ax

pop si
pop di
pop ds
pop bp
ret
_Display_Icon endp

;********************************************************************


Copy_IconParms struc
dw ? ; pushed BP
dw ? ; return address pushed by call
ci_oxpos dw ? ; Original X position
ci_oypos dw ? ; Original Y position
ci_xpos dw ? ; New X position
ci_ypos dw ? ; New Y position
Copy_IconParms ends

; Copy_Icon(int OrigX, int OrigY, int X, int Y);
_Copy_Icon proc near
push bp
mov bp,sp
push si
push di
push ds

mov dx,VOffset ; EGA address
mov es,dx ; segment ega
mov ds,dx ; segment for ega


; Get the origination icon addr
mov ax,[bp+ci_oypos] ; get vertical line
mul BytesPerLine

mov si,[bp+ci_oxpos] ; horizontal byte
add si,ax ; (y*40) + bx <- the horiz byte


mov ax,[bp+ci_ypos] ; get vertical line
mul BytesPerLine

mov di,[bp+ci_xpos] ; horizontal byte
add di,ax ; (y*40) + bx <- the horiz byte
; normally in wm0

mov dx,03c4h
mov al,02
out dx,al

mov dx,03c5h ; load the map register data address.

mov al,0fh ; enable all planes
out dx,al

mov dx,3ceh
mov al,5
out dx,al

inc dx
mov al,1
out dx,al ; select write mode 1

mov ax,BytesPerLine ; Offset to next line
dec ax ; Subtract icon width
dec ax

mov cx,16
CIStart:movsb ; reads ds:[si] then writes es:[di]
movsb ; reads icon place in memory then writes to dest

add si,ax ; Get to start of next line of
add di,ax ; the orig and dest addresses

loop CIStart


mov dx,3cfh ; write mode register already
mov al,0 ; selected, just output value now
out dx,al ; restore write mode 0

pop ds
pop di
pop si
pop bp
ret
_Copy_Icon endp

end




  3 Responses to “Category : Files from Magazines
Archive   : WDAUG92.ZIP
Filename : 3N08036A

  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/