home *** CD-ROM | disk | FTP | other *** search
-
- program DCFG; {dirt cheap frame grabber}
- uses crt, dos;
-
- type screenarray = array[0..65000] of byte;
- bytearray = array[0..65000] of byte;
- vptr=^bytearray;
- var
- xx,yy,i:integer;
- oldmode:byte;
- crtmode:byte absolute $40:$49;
- s:screenarray absolute $A000:0;
- prnarray:array[0..3] of word absolute $40:$08;
- prnport:word;
- prnbase,inport:word;
- regs:registers;
- cx,ch:char;
- vary:vptr;
- framesize:word;
-
- const homekey = char($80+71);
- endkey = char($80+79);
- pageup = char($80+73);
- pagedn = char($80+81);
- uparrow = char($80+72);
- dnarrow = char($80+80);
- leftarrow = char($80+75);
- rightarrow = char($80+77);
-
- begin
- new(vary);
-
- prnport := 0; {find out what port they want}
- if ParamCount > 0 then
- begin
- if ParamStr(1) = '2' then
- prnport := 1
- else if ParamStr(2) = '3' then
- prnport := 2
- else if ParamStr(3) = '4' then
- prnport := 3;
- end;
- prnbase := prnarray[prnport]; {init port base addr}
-
- port[prnbase] := $ff; {set data lines high}
- port[prnbase+2] := $04; {init output control lines}
- inport := prnbase+1;
- directvideo := false;
-
- OldMode := CrtMode;
- regs.ax := $0013;
- regs.bx := 0;
- intr($10,regs);
- ch := #$55;
- cx := #$55;
-
- xx := 45; {init X sample size}
- yy := 82; {init Y sample size}
-
- Write('loading '); {load the palette registers}
-
- asm
- mov ax,1010h {sync level - 143}
- mov ch,0 {green}
- mov cl,0 {blue}
- mov dh,0 {red}
- mov bx,143
- int 10h
- end;
- asm
- mov ax,1010h {level 1 - 127}
- mov ch,03fh {green}
- mov cl,03fh {blue}
- mov dh,03fh {red}
- mov bx,127
- int 10h
- end;
-
- asm
- mov ax,1010h {level 2 - 63}
- mov ch,01fh {green}
- mov cl,01fh {blue}
- mov dh,01fh {red}
- mov dx,63
- int 10h
- end;
-
- asm
- mov ax,1010h {level 3 - 31}
- mov ch,0fh {green}
- mov cl,0fh {blue}
- mov dh,0fh {red}
- mov bx,31
- int 10h
- end;
-
- asm
- mov ax,1010h {level 4 - 15}
- mov ch,0 {green}
- mov cl,0 {blue}
- mov dh,0 {red}
- mov bx,15
- int 10h
- end;
- Write('ready '); {all done, start collecting data}
- gotoxy(1,20);
-
- Write('xx:',xx,' yy:',yy,'......');
-
- framesize := 30000; {how many bytes to collect for a frame}
-
- repeat
- {grab a video frame from the printer port}
- asm
- mov bx,0
- les di,[vary] {point es:di to frame buffer}
- mov cx,[framesize] {get number bytes to grab}
- @lp:
- dec bx {don't get hung up here}
- jz @stopit
- mov dx,[inport]
- in al,dx
- cmp al,143 {wait for the vert sync}
- jnz @lp
- in al,dx
- cmp al,143
- jnz @lp
- in al,dx
- cmp al,143
- jnz @lp
- in al,dx
- cmp al,143
- jnz @lp
- in al,dx
- cmp al,143
- jnz @lp
-
- cli {disable ints while we do this}
- rep
- db 6ch {grab a frame of video in one chunk}
- sti {ok, you can have ints again}
- @stopit:
- end;
-
- {now we are gonna display the video on the screen}
- asm
- mov dx,[yy]
- mov cx,[framesize]
-
- mov ax,0A000h
- mov es,ax
- mov di,0
- mov bx,0
- push bp
- mov bp,[xx]
- push ds
- lds si,[vary]
- add si,bp
- add si,bp
- add si,bp
- add si,bp
- add si,bp
- add si,bp
- add si,bp
- add si,bp
- add si,bp
- add si,bp
- add si,bp
- add si,bp
- add si,bp
- add si,bp
- add si,bp
- add si,bp
- add si,bp
- add si,bp
- add si,bp
- @tsi:
- dec cx
- jz @done
- mov al,ds:[si]
- or al,$0f;
- inc si
- cmp al,143
- jnz @tsi
-
- @t2:
- mov cx,bp
- mov ah,0
- @tlp:
- dec ah
- jz @done
- mov al,ds:[si]
- or al,$0f;
- inc si
- cmp al,143
- jz @tlp
-
- mov es:[di],al
- inc di
- mov es:[di],al
- inc di
- loop @tlp
-
- add bx,320
- add si,bp
- add si,bp
- mov di,bx
- dec dx
- jnz @t2
- @done:
- pop ds
- pop bp
- end;
- { write(port[inport],' '); }
-
- if keypressed then
- begin
- cx := readkey;
- if cx = #0 then cx := char($80+ord(readkey));
-
- if cx = homekey then xx := xx -10;
- if cx = endkey then xx := xx +10;
- if cx = leftarrow then xx := xx -1;
- if cx = rightarrow then xx := xx +1;
- if cx = pageup then yy := yy -10;
- if cx = pagedn then yy := yy +10;
- if cx = uparrow then yy := yy -1;
- if cx = dnarrow then yy := yy +1;
- if xx < 0 then xx := 1;
- if yy < 0 then yy := 1;
- if xx > 160 then xx := 159;
- if yy > 200 then yy := 199;
- gotoxy(1,20);
- write('xx:',xx,' yy:',yy,'......');
- end;
- until cx < #32;
-
- regs.ah := $00;
- regs.al := oldmode;
- regs.bx := 0;
- intr($10,regs);
- end.
-
-
-