home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Archive Magazine 1996
/
ARCHIVE_96.iso
/
discs
/
mag_discs
/
volume_9
/
issue_02
/
weather
/
faxdisp
< prev
Wrap
Text File
|
1995-07-04
|
2KB
|
109 lines
/* > c.faxdisp */
/* sets up via, uses assembler (afax) to get data and display it */
/* no limit to amount of data, can be run off radio */
/* set sampling freq. for pixels per line, 1000Hz and 500 pix/line */
#include "kernel.h"
#include <stdio.h>
#include <stdlib.h>
#define pcr 0x0c
#define acr 0x0b
#define tmrlo 0x04
#define tmrhi 0x05
#define ifr 0x0d
/* some subroutines to help the main program */
void awrite(int offset,int value)
/* writes 'value' to address 'offset' in VIA space */
{
_kernel_swi_regs point1,point2,*ptr1,*ptr2 ;
int code =0x80940 , pno=0 , block=0 ;
ptr1=&point1;
ptr2=&point2;
point1.r[0]=pno;
point1.r[1]=block;
point1.r[2]=offset;
point1.r[3]=value ;
_kernel_swi(code,ptr1,ptr2) ;
}
int aread(int offset)
/* returns a value read from address 'offset' in VIA space */
{
_kernel_swi_regs point1,point2,*ptr1,*ptr2 ;
int code =0x80941,temp , pno=0 , block=0 ;
ptr1=&point1;
ptr2=&point2;
point1.r[0]=pno;
point1.r[1]=block;
point1.r[2]=offset;
_kernel_swi(code,ptr1,ptr2) ;
temp=point2.r[3] ;
return temp ;
}
void sync()
/* sets the timing mode for use of the expansion bus */
/* with the 6522 VIA */
{
_kernel_swi_regs point1,point2,*ptr1,*ptr2 ;
int podno=0, code=0x80947;
ptr1=&point1 ;
ptr2=&point2 ;
point1.r[0]=podno;
_kernel_swi(code,ptr1,ptr2);
}
/* afax is defined and color[] is used outside this program */
extern void afax(void) ;
char color[16] = {0xff,0xfe,0xfd,0xfc,
0xd3,0xd2,0xd1,0xd0,
0x2f,0x2e,0x2d,0x2c,
0x03,0x02,0x01,0x00 } ;
int main()
{
void awrite(int,int);
void sync(void) ;
void afax(void) ;
int aread(int);
int value, value2, temp, ddra=3 ;
int porta=1,portb=0, ctrlo,ctrhi ;
sync() ;
/* set timer mode and request the sampling frequency */
value=0xee ;
awrite(pcr,value) ; /* cb2 , ca2 high */
value=0xc0 ;
awrite(acr,value);
printf("Sampling frequency, max. of 10 000Hz ");
scanf("%d",&value);
value2=1e6 /(value) ;
ctrlo=( value2 % 256)-2 ;
awrite(tmrlo,ctrlo);
ctrhi=value2 / 256 ;
awrite(tmrhi,ctrhi); /* timer/clock now running */
printf("ctrlo=%d, ctrhi=%d\n",ctrlo,ctrhi) ;
temp=0;
awrite(ddra,temp); /* port A input */
temp=aread(portb);
temp=aread(porta) ; /* ensure ca1 is reset */
afax() ; /* call the display program */
}