Posts filed under 'Uncategorized'
Program in C
Program in C
#include<stdio.h>
#include<dos.h>
#include<conio.h>
#include<process.h>
#include<stdlib.h>
#include<alloc.h>
#include<io.h>
#include<bios.h>
/*
This program will restore your hard disk’s track zero data. It is specifically designed to provide a remedy against the the so-called “Columbus day” virus. This program may be freely copied.
Author: John Clason, KZ1O [70441,2456]
*/
void error(int code)
{
switch (code) {
case 1:
fprintf(stderr, “Unable to allocate enough memory\n”);
break;
case 2:
fprintf(stderr, “Unable to open file A:TRACK.000\n”);
break;
case 4:
fprintf(stderr, “Unable to complete reading floppy disk\n”);
break;
default:
fprintf(stderr, “Unknown error occurred: %d\n”, code);
break;
}
exit(code);
}
int main(void)
{
char *buffer;
unsigned cx, dx;
int maxhead, maxsectors, h;
int fd;
unsigned bytes;
printf(“Restoring hard disk track zero from A:TRACK.000\n”
“More public domain software from John Clason [70441,2456]\n”);
_DL = 0×80;
_AH = 8;
geninterrupt(0×13); /* get params */
cx = _CX;
dx = _DX;
maxhead = dx >> 8;
maxsectors = cx & 0×3f;
#ifndef ALLCYLINDER
maxhead=0;
#endif
buffer = calloc(bytes = (maxsectors * 512), 1);
if (buffer == NULL)
error(1);
fd = _open(“a:track.000″, 0);
if (fd < 0)
error(2);
for (h = 0; h <= maxhead; h++) {
if (_read(fd, buffer, bytes) != bytes)
error(4);
biosdisk(3, 0×80, h, 0, 1, maxsectors, buffer);
}
close(fd);
return 0;
}
Add comment July 8, 2008
CODE OF ANIMATION USING C++
TO MAKE A PROGRAM WHICH PRODUCE THE ANIMATTION EFFECT OF A SQUARE TRANSFORMING TO A TRIANGLE AND THEN TO A CIRCLE
#include<stdio.h>
#include<conio.h>
#include<graphics.h>
#include<stdlib.h>
#include<dos.h>
void main()
{
int a[8],d=DETECT,g,xt,yt,r=1,i,x=200,y=100;
initgraph(&d,&g,”");
setcolor(RED);
rectangle(x,y,400,300);
delay(1000);
xt=x;
yt=y;
setcolor(BLACK);
rectangle(xt,yt,400,300);
i=1;
a[0]=a[2]=a[4]=a[6]=300;
a[1]=a[3]=a[5]=a[7]=200;
while(!kbhit())
{
setcolor(RED);
rectangle(x+i,y+i,400-i,300-i);
delay(20);
xt=x;
yt=y;
setcolor(BLACK);
rectangle(xt+i,yt+i,400-i,300-i);
i+=1;
if(x+i==300){
x=300;
y=200;
i=1;
while(!kbhit())
{
setcolor(RED);
drawpoly(4,a);
delay(20);
setcolor(BLACK);
drawpoly(4,a);
i++;
a[1]=200-i;
a[2]=300-i;
a[3]=200+i;
a[4]=300+i;
a[5]=200+i;
a[7]=200-i;
if(a[1]==100)
{ i–;
while(!kbhit())
{
setcolor(RED);
drawpoly(4,a);
delay(20);
setcolor(BLACK);
drawpoly(4,a);
i–;
a[1]=200-i;
a[2]=300-i;
a[3]=200+i;
a[4]=300+i;
a[5]=200+i;
a[7]=200-i;if(a[1]==200)
{
x=300;
y=200;
r=1;
while(!kbhit())
{
setcolor(RED);
circle(x,y,r);
delay(20);
setcolor(BLACK);
circle(x,y,r);
r++;
if(x-r==200)
{
exit(1);
}
}
}}}}}}
getch();
}
Add comment July 8, 2008