home *** CD-ROM | disk | FTP | other *** search
- name clink
- page 55,132
- title CLINK Load and Link Graphics Characters
-
- ;
- ; CLINK - Load and Link Graphics Character Table
- ;
- ; Copyright 1982, 1986 by Ray Duncan
- ;
- ; The IBM PC allows the user to define the meanings of the
- ; characters in the range 80H-FFH in the graphics modes, by
- ; pointing the vector for Int 1FH to a bit table.
- ;
- ; This program takes a filename from the command line,
- ; reads a 1024 byte character bit table into memory,
- ; points the Int 1FH vector to the bit table, and then
- ; performs a "terminate and stay resident" with a return
- ; code of 0. If the character table cannot be found,
- ; or is not at least 1024 bytes long, the program aborts
- ; with a return code of 1.
- ;
- ; To assemble, link, and convert this program into
- ; a COM file, follow these steps:
- ;
- ; C>MASM CLINK;
- ; C>LINK CLINK;
- ; C>EXE2BIN CLINK.EXE CLINK.COM
- ; C>DEL CLINK.EXE
- ;
- ; Ignore the message "Warning: no stack segment" from the Linker.
- ;
-
- fcb equ 05ch ;default file control block
-
- cr equ 0dh ;ASCII carriage return
- lf equ 0ah ;ASCII line feed
-
- stdin equ 0 ;standard input device
- stdout equ 1 ;standard output device
- stderr equ 2 ;standard error device
-
-
- cseg segment para public 'CODE'
-
- assume cs:cseg,ds:cseg,es:cseg,ss:cseg
-
- org 100h
-
-
- clink proc near ;entry from PC-DOS
-
- mov dx,offset msg1 ;sign on message
- mov cx,offset msg1_len
- mov bx,stdout
- mov ah,40h
- int 21h
-
- mov bx,offset fcb
- mov byte ptr [bx+9],'C' ;force extension to .CHR
- mov byte ptr [bx+0ah],'H'
- mov byte ptr [bx+0bh],'R'
-
- mov dx,offset fcb ;try and open char table file
- mov ah,0fh
- int 21h
- or al,al
- jz clink2 ;file opened, proceed
- mov dx,offset msg2
- mov cx,msg2_len ;file not found
-
- clink1: mov bx,stderr ;display error message
- mov ah,40h
- int 21h
- mov ax,4c01h ;exit with retcode=1
- int 21h
-
- clink2: mov bx,offset fcb ;point to file control block
- mov word ptr [bx+0eh],1024 ;set record length
- mov word ptr [bx+21h],0 ;set record number
- mov word ptr [bx+23h],0
-
- mov dx,offset ctab ;set disk transfer addr
- mov ah,1ah
- int 21h
-
- mov dx,offset fcb ;read char table
- mov ah,21h
- int 21h
- push ax ;save read status
-
- mov ah,10h ;close file
- int 21h
-
- pop ax ;restore read status
- or al,al
- jz clink3 ;jump, read was ok
- mov dx,offset msg3
- mov cx,msg3_len ;read failed, print
- jmp clink1 ;error message
-
- clink3: mov ax,251fh ;set Int 1FH vector to
- mov dx,offset ctab ;point to character table
- int 21h
-
- mov dx,offset msg4 ;print success message
- mov cx,msg4_len
- mov bx,stdout
- mov ah,40h
- int 21h
-
- ;terminate and stay resident
- mov dx,((ctab_end-clink)/16)+11h
- mov ax,3100h ;with retcode of zero
- int 21h
-
-
- msg1 db cr,lf,'Character Set Loader for IBM PC'
- db cr,lf,'Copyright (C) 1982, 1986 Ray Duncan'
- db cr,lf,lf
- msg1_len equ $-msg1
-
- msg2 db 'No such file.',cr,lf
- msg2_len equ $-msg2
-
- msg3 db 'Incomplete or empty file.',cr,lf
- msg3_len equ $-msg3
-
- msg4 db 'Character table loaded.',cr,lf
- msg4_len equ $-msg4
-
- ctab db 1024 dup (?)
-
- ctab_end equ $
-
- clink endp
-
- cseg ends
-
- end clink