Speccom - PC část

Zdrojový kód


;********************************* COMSPEC *********************************
	jmp Start
;***************************************************************************

hlav1:	db 0
hlav2:	db 0			;Hlavicka

kolik:	dw 0			;Kolik se ma jeste prenest
akce:	dw 0			;Akce pri pristim preruseni
				;0 - prijmam hlavicku
scr:	dw 0b800h
buf_pt:	dw 0


off_x:	db 0			;+-------------------
off_y:	db 0			;|	|
x_len:	db 64			;|	|
y_len:	db 24			;|------x = off x,y-----+
x:	db 0			;|	|		|
y:	db 0			;|	|		|
xx_len:	db 80			;|	+---------------x = x,y_len
yy_len: db 25

err:	db 0
lerr:	dw 0

dta:	db 2bh dup 0

cesta:	db 'c:\autoexec.*',0
	db 66 dup 0
attr:	db 00110110 b
	db 0
buffer:	db 2048 dup 0


New_int:

	push ax
	push bx
	push cx
	push dx			;Uloz registry
	push ds
	push es
	push di
	push si

	mov ds,cs

	mov dx,port+1
	in al,dx
	inc dx
	mov ah,al
	and al,10000000b	;1 = spec->pec    0 = pec->spec
	jnz dal
	mov al,00010000b	;datovka pec->spec
	out dx,al	
	jmp pesp		;skoc na pec->spec
dal:
	mov al,00110000b		;datovka spec->pec
	out dx,al

	and ah,00100000b	;test na hlav.
	jz no_hlav

	call read		;precti 1. bajt hlavicky
	mov [hlav1],al		;a zapamatuj si ho
	mov w[kolik],2		;precti jeste 2 bajty
	mov b[akce],0		;dalsi akce 0 - jeste cti hlav.
	jmp konec



;[][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][]

no_hlav:
	mov al,[akce]
	or al,al
	jz rd_hlav		;0 - cti hlavicku
	dec al
	jz rd_set		;1 - nastav veci
	dec al
	jz rd_key		;2 - cti klavesu
	dec al
	jz rd_pth		;3 - cti cestu

	;...
				;jinak delej nic
	call read
	jmp konec		;>nil: 


;..............................................................

rd_set:				;*** 0+1 nastav veci ***
	call rd_buf
	mov ax,[buffer]
	mov [off_x],ax
	mov ax,[buffer+2]
	mov [x_len],ax

	jmp konec

;..............................................................

rd_key:				;*** 0+2 cti klavesu ***
	call rd_buf
	jnz sux2
	mov ch,[buffer]
	mov cl,[buffer+1]
	mov ah,05h
	int 16h
	jmp konec

;..............................................................

rd_pth:
	call rd_buf
	jnz sux2
	mov ax,buffer
	mov bx,cesta
	mov cx,82
	call ldir
sux2:	jmp konec

;..............................................................
rd_buf:
	mov si,[buf_pt]
	call read
	mov [si],al
	inc si
	mov [buf_pt],si
	dec w[kolik]
	ret

;..............................................................

rd_hlav:			;*** 0+0 cti hlavicku ***
	call read
	dec w[kolik]
	jnz jeste
	mov bl,al
	mov bh,[hlav2]		;bx - kolik bajtu cist/psat
	mov al,[hlav1]		;al - akce
	mov [kolik],bx
	mov [akce],al
	mov [buf_pt],buffer
	mov ah,al
	and al,128
	mov al,ah
	jnz hl_write

	dec al			;nastaveni read sluzeb
	dec al
	dec al


	jmp konec

jeste:	mov [hlav2],al
	jmp konec


hl_write:			;nastaveni write sluzeb
	and al,01111111b
	dec al
	jz h_winf		;1
	dec al
	jz h_wscr		;2
	dec al
	jz h_wscr		;3
	dec al
	jz h_wscr		;4
	dec al
	jz h_werr		;5
	dec al
	jz h_f1st		;6
	dec al
	jz h_fxt		;7

	jmp konec

h_winf:				;nastaveni send info
	mov si,[buf_pt]
	mov ah,0fh
	int 10h
	mov [si],al		;mod
	inc si
	mov ah,03h
	int 10h
	mov [si],dl		;radek kurz.
	inc si
	mov [si],dh		;sloupec kurz.
	inc si
	mov [si],cl		;zacatek kurz.
	inc si
	mov [si],ch		;konec kurz.
;	inc si
	jmp konec


h_wscr:				;nastaveni send screenu
	mov ax,[off_x]
	mov [x],ax
	jmp konec


h_werr:				;nastaveni send last error
	mov si,[buf_pt]
	mov al,[err]
	mov [si],al		;chyba ano/ne
	inc si
	mov ax,[lerr]
	mov [si],ax		;kod chyby
	jmp konec


h_f1st:
	mov ds:dx,cesta
	mov cx,[attr]
	mov ah,4eh
f1st1:	int 21h
	call error
	mov ax,dta+15h
	mov bx,buffer
	mov cx,22
	call ldir
	jmp konec


h_fxt:
	mov ds:dx,dta		;DTA
	mov ah,4fh
	jmp f1st1

;[][][][][][][][][][][][][][][][][][][][][][][]
;[][][][][][][][][][][][][][][][][][][][][][][]

pesp:

	mov al,[akce]
;****** !!!!!!!!!!!!!!!!	test jestli je 7. bit 1 - jinak posilej nuly
	mov ah,al		;tohle je snad zbytecny
	and al,10000000b
	mov al,ah
	jz shit
	
	and al,01111111b
	dec al
	jz wr_buf		;*** 1+1 posli info ***
	dec al
	jz wr_scr		;2=scr bez atr (scr)
	dec al
	jnz sux5
	jmp wr_atr		;3=scr s atr + covert (atr)
sux5:	dec al
	jnz sux6
	jmp wr_atr1		;4=scr s atr (atr)
sux6:	dec al
	jz wr_buf		;5=posli posledni chybu (chyba)
	dec al
	jz wr_buf		;6=hledej prvni (dta - info)
	dec al
	jz wr_buf		;7=hledej dalsi (dta - info)
	dec al
	jz wr_buf		;8=otevri soubor (handle)
	dec al
	jz wr_buf		;9=posli souboru (file)


shit:				;jinak delej nic
	xor al,al
	call write
	jmp konec1		;nuly 

wr_buf:
	cmp w[kolik],0
	jz shit
	mov si,[buf_pt]
	mov al,[si]
	inc si
	mov [buf_pt],si
	dec w[kolik]
	call write
	jmp konec1


;..........................................................

wr_scr:				;*** 1+2 posli vyrez okna ***
	mov cx,[x]
	mov al,ch
	xor ah,ah		; ???
	mov bl,[xx_len]
	mul bl			;sirka obrazovky v aktualnim rezimu
	xor bh,bh
	mov bl,cl
	add ax,bx		;ax = pozice v obrazovce
	add ax,ax
	
	mov es,[scr]
	mov si,ax

	inc cl
	mov al,[x_len]
	add al,[off_x]
	cmp cl,al
	jnz skk1
	mov cl,[off_x]
	inc ch
	mov al,[y_len]
	add al,[off_y]
	cmp ch,al
	jnz skk1
	mov ch,[off_y]
skk1:
	mov [x],cx
	mov ax,[es:si]		;al na vystup... v ah atributy ?

	call write
	jmp konec1

;..................................................................

wr_atr:				;*** 1+3 posli vyrez okna s atr ***
	mov cx,[x]
	mov al,ch
	xor ah,ah		; ???
	mov bl,[xx_len]
	mul bl			;sirka obrazovky v aktualnim rezimu
	xor bh,bh
	mov bl,cl
	add ax,bx		;ax = pozice v obrazovce
	add ax,ax
	
	mov es,[scr]
	mov si,ax

	inc cl
	mov al,[x_len]
	add al,[off_x]
	cmp cl,al
	jnz skk1a
	mov cl,[off_x]
	inc ch
	mov al,[y_len]
	add al,[off_y]
	cmp ch,al
	jnz skk1a
	mov ch,[off_y]
skk1a:
	mov [x],cx
	mov ax,[es:si]		;ah atributy ?

				;prekoduj atributy
	mov cl,ah
	xor ch,ch
	and cl,15
	mov bx,t_atr
	add bx,cx
	mov al,[bx]

	mov cl,ah
	shr cl,4
	and cl,7
	mov bx,t_atr
	add bx,cx
	mov cl,[bx]
	shl cl,3

	and ah,128
	or al,ah
	or al,cl

	call write
	jmp konec1

t_atr:	db 0,1,4,5,2,3,6,7
	db 6,65,68,69,66,67,70,71

;...........................................................
	
wr_atr1:			;*** 1+3 posli atr ***
	mov cx,[x]
	mov al,ch
	xor ah,ah		; ???
	mov bl,[xx_len]
	mul bl			;sirka obrazovky v aktualnim rezimu
	xor bh,bh
	mov bl,cl
	add ax,bx		;ax = pozice v obrazovce
	add ax,ax
	
	mov es,[scr]
	mov si,ax

	inc cl
	mov al,[x_len]
	add al,[off_x]
	cmp cl,al
	jnz skk11
	mov cl,[off_x]
	inc ch
	mov al,[y_len]
	add al,[off_y]
	cmp ch,al
	jnz skk11
	mov ch,[off_y]
skk11:
	mov [x],cx
	mov ax,[es:si]		;al na vystup... v ah atributy ?
	mov al,ah
	
	call write
	jmp konec1

;..............................................



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

konec1:
	mov dx,port+2
	mov al,00010001b
	out dx,al
	dec dx
sk2:
	in al,dx
	and al,01000000b
	jnz sk2
	inc dx
	mov al,00010000b
	out dx,al
	jmp kon1


konec:
	mov dx,port+2
	mov al,00110001b
	out dx,al
	dec dx
sk1:
	in al,dx
	and al,01000000b
	jnz sk1
	inc dx
	mov al,00110000b
	out dx,al		;busy
kon1:	
	mov al,20h
	out 20h,al		;Konec preruseni
	out 8ah,al

	pop si	
	pop di
	pop es
	pop ds
	pop dx
	pop cx
	pop bx
	pop ax
	iret			;Navrat z preruseni


read:
	mov dx,port
	in al,dx
	ret

write:
	mov dx,port
	out dx,al
	ret

error:
	mov [lerr],ax
	mov b[err],255
	jc err1
	mov b[err],0
err1:	ret


ldir:
	mov si,ax
	mov di,bx
ldr:	mov [di],[si] 
	inc di
	inc si
	loop ldr
	ret


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


	mov ch,0		;CH-scan, CL-ASCII
	mov cl,al
	mov ah,05h		;Zapis do klavesnicoveho bufferu jen AT
	int 16h			;AL-0 operace OK, AL-1 buffer plny
	
	
;	mov ah,02h
;	int 21h


;**************************************************
;************ Rezidentni instalace ****************

Start:
	mov ax,250fh
	mov dx,offset New_int
	int 21h			;nastav vektor int 0fh na novou obsluhu

	mov dx,text
	mov ah,09h
	int 21h			;Vypis text

	mov ah,1ah		;nastav DTA
	mov ds:dx,dta
	int 21h

	mov dx,port+402h
	in al,dx
	and al,00011111b
	or  al,00100000b
	out dx,al		;nastaveni ECP portu - PS2 mode
	
	mov dx,port+2
	mov al,00110000b
	out dx,al		;Povol obousmerny prenos+nastav busy

	in al,82h
	mov ah,al
	in al,21h
	and ax,1111111101111111b
	out 21h,al
	mov al,ah
	out 82h,al
				;Nacti radic preruseni
				;Povol preruseni IRQ7,int 0fh, tj. zapis 0
	
	lea dx,start+2
	int 27h			;ukonci se a zustan resident

	
text:	db 10,13
	db ' ***************************************',10,13
	db ' *** SpecCom 0.2 - (C) 1999 dR0n^K3l ***',10,13
	db ' ***************************************',10,13,36


port equ 0378h			;LPT1



Popis
Rezidentní program který na požádání (ze strany Speccyho) vykoná příslušnou akci. V současné době jsou podporovány nejzákladnější akce typu "pošli obsah obrazovky" atd... Projekt(ant) vytuhnul na pokusu otevřít ze Speccyho soubor na PC.

Poznámky
Bez připojeného počítače (s příslušným programem) nevykazuje navenek žádnou činnost.

Poslal
dR0n_K3l