Category : Assembly Language Source Code
Archive   : LOADPIC.ZIP
Filename : LOADPIC.ASM

 
Output of file : LOADPIC.ASM contained in archive : LOADPIC.ZIP

;****************************************************************************
;* *
;* L O A D P I C *
;* *
;* John D. Jenkins *
;* 206-644-3210 *
;* *
;* This program takes graphics image (PIC) files created by PCPAINT or *
;* other programs and puts them in the graphics plane. *
;* Written for the HP Vectra Personal Computer, but should work with *
;* any IBM Compatible PC. *
;* *
;* Provides a replacement for the BLOAD statement in Microsoft QUICKBASIC. *
;* *
;* Calling sequence: *
;* *
;* Call Loadpic (ERCODE,PATH$) *
;* *
;* Where: ERCODE = Error code returned by LOADPIC: *
;* *
;* 0 = O.K. *
;* 2 = File not found *
;* 3 = Path not found *
;* 4 = No Handles Left *
;* 5 = Access Denied *
;* 6 = Invalid Handle *
;* 12 = Invalid Access Code *
;* 15 = Invalid Drive Spec *
;* *
;* PATH$ = Path of file i.e.: C:\PAINT\IMAGE.PIC *
;****************************************************************************
;
Dos_function EQU 21H
Open_file EQU 3DH
Close_file EQU 3EH
Read_file EQU 3FH
Move_pointer EQU 42H
Read_only_mode EQU 00H
Screen_buffer_seg EQU 47104D

DATA SEGMENT BYTE PUBLIC 'DATA'
PATH DB 63 DUP (0)
DATA ENDS

DGROUP GROUP DATA

CODE_SEG SEGMENT BYTE PUBLIC 'CODE'
ASSUME CS:CODE_SEG,DS:DGROUP
PUBLIC LOADPIC

LOADPIC PROC FAR

PUSH BP
MOV BP,SP
MOV BX,6[BP] ; String Descriptor
MOV CX,[BX] ; Length of Path
MOV DX,2[BX] ; Address of Path
PUSH DS
MOV SI,DX ; Set up for block move
MOV DI,OFFSET PATH
CLD
REP MOVSB ; Move string to data
MOV [DI],WORD PTR 00H ; area

MOV DX,OFFSET PATH ; Open File
MOV AH,Open_file
MOV AL,Read_only_mode

INT Dos_function
JC File_error ; Exit with code if err
PUSH AX ; Store file handle
MOV BX,AX ; Handle

MOV AH,Move_pointer ; Move file pointer
MOV AL,0 ; Begin of file + offset
MOV CX,0
MOV DX,7H ; 7 Bytes (past header in
INT DOS_function ; PCPAINT PIC files)

MOV AH,Read_file ; Transfer data to graphics plane
MOV CX,Screen_buffer_seg ; Segment to write to
MOV DS,CX
MOV CX,16391D ; # of bytes to read
MOV DX,0H ; offset to begin write
INT Dos_function

POP AX ; Get handle
MOV BX,AX
MOV AH,Close_file ; Close file
INT Dos_function
JC File_error ; Exit with code if error

Return_home: POP DS
POP BP
RET 4

File_error: MOV bx,[BP+8] ; Put error code in stack for
MOV [bx],AX ; return to calling program
JMP Return_home ; & return.

LOADPIC ENDP
CODE_SEG ENDS
END