[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Building an Apple CP/M Disk
- Subject: Re: Building an Apple CP/M Disk
- From: "Bill Buckels" <bbuckels@mts.net>
- Date: Sat, 8 Nov 2008 05:57:13 -0600
- Newsgroups: comp.os.cpm, comp.sys.apple2, comp.sys.apple2.programmer
- References: <eUDQk.922$x51.197@newsfe01.iad> <72fRk.1144$sl.547@newsfe23.iad>
- Xref: g2news1.google.com comp.os.cpm:1514 comp.sys.apple2:4411 comp.sys.apple2.programmer:1012
"Bill Buckels" <bbuckels@mts.net> wrote in message
news:72fRk.1144$sl.547@newsfe23.iad...
>I have updated the Disk Images at the following link to include a utility
>called BHEAD.COM and have also included a version of MORE.COM and my Aztec
>C Source for both .
x--- snip ---x
/* -------------------------------------------------------------------
System : Apple II CP/M 80
Environment : Aztec C
Program : more.c
Description : paged or line oriented text file viewer
This program is a filter that displays a text file
either page by page if the spacebar is pressed
or line by line if enter is pressed.
If the [ESCAPE] key or the letter 'Q' is pressed
the program ends.
It will optionally accept a filename to read input
from. All output is to the standard output device
unless redirected.
It is oriented to the 80 column x 24 row display.
Example:
more abc.txt
read input from abc.txt,
output goes to screen.
more <abc.txt
same as previous example
Written by : Bill Buckels
Date Written : Nov 2008
Revision : 1.0 First Release
------------------------------------------------------------------ */
#include <stdio.h>
main(argc, argv)
int argc;
char **argv;
{
int c, d = 0, ctr = 0;
FILE *fp = NULL;
if (argc > 1)
fp = fopen(argv[1], "r");
for (;;) {
if (NULL == fp)
c = getchar();
else
c = fgetc(fp);
if (c==EOF)break;
putchar(c);
if(c=='\n') {
ctr++;
if (ctr > 22) {
d = getch();
if (d == 27 || d=='q' || d == 'Q')break;
else if (d == 32)ctr = 0;
else if (d == 13)ctr = 22;
}
}
}
if (d != 27 && d !='q' && d != 'Q') {
if (ctr > 0 && ctr < 22)getch();
}
if (NULL != fp) {
fclose(fp);
exit(0);
}
}
getch()
{
/* return the last key press */
int ch;
while((ch=bdos(6,0xff))==0);
return ch;
}