Vous êtes sur la page 1sur 5

DUMP_SCREEN:

;Synopsis: Dump graphics mode 4 320X200 screen to Epson MX, FX, or RX


; dotmatrix printer. Image is oriented in upright position on
; printed page. Invoked from this prog. via shift/prt scr
; keystroke combination. Caller is prog. Int5 filter.
;
;Author: Pierre R. Desloover © 1989 for Ataspec Software
;
;REGISTER USAGE:
;(VARS)
; BL = line count; 25 total-> 25x8 scan lines=200 scans
; DH = byte count; 80 bytes/scan-> 80x200 scans = 16,000 bytes
; DL = pixel count; 8 pixels/byte-> 8X80 bytes= 640 head positions per line
; AH = pin count; 8 pins/head position
; AL = pins sum; sum of 8 pins in one head position
; CL = pixel mask; isolates operand bit position in screen byte
; CH = pin value; power of 2 value of operand pin number
; SI = screen buffer offset address
;(CONSTANTS)
; ES = screen buffer segment para value; 0b800h
; DI,BP = screen buffer interleave constants added to SI to address even/odd
; scans; regs assume these values interchangably: 2000h and 80-2000h
;
;FLOW CONTROL LOGIC:
; For line_count = 25 to 1
; For byte_count = 80 to 1
; For pixel_count = 8 to 1
; For pin_count = 8 to 1
; Next pin_count
; Next pixel_count
; Next byte_count
; Next line_count

;setup printer
comment |
;(1) reset it
mov al,1bh
call byte_2_prn
mov al,40h
call byte_2_prn
|

;(2) set line spacing to 8/72


mov al,1bh
call byte_2_prn
mov al,41h
call byte_2_prn
mov al,8 ;8/72
call byte_2_prn

;begin screen dump


push es
mov ax,0b800h
mov es,ax ;init screen buffer segment address

xor si,si ;init start buffer offset (even scan)


mov di,2000h ;next scan is odd
mov bp,80-2000h ;next scan is even again

mov bl,25+1 ;init line count

DOWHILE_Y:
dec bl
jnz loop_Y

;Y done, screen dump done


;output LF,LF,CR
mov al,0ah
call byte_2_prn
mov al,0ah
call byte_2_prn
mov al,0dh
call byte_2_prn

pop es
RET

LOOP_Y:
;output gr. density mode, line width
mov al,1bh
call byte_2_prn
mov al,2ah
call byte_2_prn
mov al,1 ;mode 1 =low speed double density
call byte_2_prn
mov al,192 ;LSB 960 dots/8" line
call byte_2_prn
mov al,3 ;MSB 960 dots/8" line
call byte_2_prn

mov dh,80+1 ;init byte count

DOWHILE_X:
dec dh
jnz loop_X

;X done
;For printer graphics mode 1, 960 dots/8" line, make up missing dots as
;screen provides only 640 dots: 960-640=320 dots remain to be output.
mov cx,320
xor al,al ;fire no pins

pad_dots:
call byte_2_prn
loop pad_dots

;output LF,CR
mov al,0ah
call byte_2_prn
mov al,0dh
call byte_2_prn

add si,320-80
jmp short dowhile_Y
LOOP_X:
mov cl,80h ;init pixel mask
mov dl,8+1 ;init pixel count

DOWHILE_PIX:
dec dl
jnz loop_PIX
inc si
jmp short dowhile_X

LOOP_PIX:
xor al,al ;init sum of pins
mov ch,80h ;init pin value
mov ah,8+1 ;init pin count

DOWHILE_PIN:
dec ah
jnz loop_PIN

;8 pins done: output sum of pins in AL


call byte_2_prn

shr cl,1 ;next pixel mask


sub si,320
jmp short dowhile_PIX

LOOP_PIN:
test byte ptr es:[si],cl ;pixel set?
jz next_scan ;pixel not set

;pixel was on
add al,ch ;add in PIN value to sum of pins

next_scan:
shr ch,1 ;next pin value
add si,di ;next buffer interleave
xchg di,bp
jmp short dowhile_PIN

BYTE_2_PRN:
;output byte in AL to printer 0
push ax
push dx

xor dx,dx
xor ah,ah
int 17h

pop dx
pop ax
ret
NEW_5_FILTER PROC FAR
;Synopsis:
;On Entry: interrupts are off
;On Exit : does not chain to old 5 interrupt

sti ;ints back on

;save all registers changed


push ax
push bx
push cx
push dx
push si
push di
push bp

;test int5_busy flag


test cs:[int5_busy],1
jnz exit_int5 ;busy, ignore request

;call screen dump routine


mov cs:[int5_busy],1 ;go busy

CALL DUMP_SCREEN

mov cs:[int5_busy],FALSE ;clear busy

exit_int5:
;restore all registers changed
pop bp
pop di
pop si
pop dx
pop cx
pop bx
pop ax
iret

NEW_5_FILTER ENDP
.CODE

START: jmp short START_G

;
; CS VARS
;

old_5_vector dd ? ;Old int 5 vector segment, offset address.


int5_busy db FALSE ;Int 5 shift/prn scr Filter's busy flag

START_G:
;Setup segments
mov ax,DGROUP
mov ds,ax
mov es,ax ;set es=ds

[… CODE …]

;Redirect shift/prt scr interrupt 5 to our filter


;get it
push ds
push es
push cs
pop ds ;set ds=cs

mov ax,3505h
int 21h
mov word ptr cs:[old_5_vector],bx
mov word ptr cs:[old_5_vector][2],es

;set it
mov ax,2505h
mov dx,offset new_5_filter ;in code segment
int 21h

pop es
pop ds

[… CODE …]

END START

Vous aimerez peut-être aussi