diff -ur --new-file cpm-0.2.1/COPYRIGHT.GNU cpm-0.2.1-glibc-rjm/COPYRIGHT.GNU --- cpm-0.2.1/COPYRIGHT.GNU Mon Jun 6 22:08:27 1994 +++ cpm-0.2.1-glibc-rjm/COPYRIGHT.GNU Thu Mar 18 13:15:25 1999 @@ -278,3 +278,62 @@ POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) 19yy + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) 19yy name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Library General +Public License instead of this License. diff -ur --new-file cpm-0.2.1/ChangeLog cpm-0.2.1-glibc-rjm/ChangeLog --- cpm-0.2.1/ChangeLog Thu Jan 1 01:00:00 1970 +++ cpm-0.2.1-glibc-rjm/ChangeLog Thu Mar 18 14:21:33 1999 @@ -0,0 +1,42 @@ +1999-03-18 Russell Marks + + * README: updated. + + * Makefile: made it slightly clearer what's going on, and added an + `install' target. + + * low.c: fixed some glibc-related problems (sa_mask zeroed + with `=0', ioperm() not in unistd.h any more, mmap() using + void * for first arg rather than caddr_t). Still gives a + warning about usleep() not having a prototype - might be due + to _POSIX_SOURCE definition in cpmemu.h, but it doesn't worth + the risk of possibly breaking things just to avoid a warning. + :-) + + * Removed the `-N' from the Makefile. (The program doesn't + actually need it, as far as I can tell, and using `-N' seems (for + ELF) to require linking statically.) + + * Made COPYRIGHT.GNU a full copy of the usual GNU GPL `COPYING' + file. + + * Added Michael's copyright banner to a file I noticed he'd + omitted it from, `low.c'. + + * bios.c: fixed DIR problem, which I think was related to POSIX + semantics for struct dirent in libc5/6 (i.e. ELF) which didn't + exist in libc4 (i.e. a.out). + + * bios.c: the compute-file-size and set-random-record BDOS + functions were *completely* broken. (These weren't new problems, + but meant some useful things weren't usable - pmarc, for example.) + + * bios.c: fixed get/set user code BDOS functions. (Though it's + debatable whether this is of any real use of not.) + + * bios.c: corrected assumption that fstat() returns 0 on failure - + it returns 0 on *success*, and -1 on failure. This didn't actually + cause any problems in practice as he'd opened the file just + before, but I fixed it all the same. + + * Started this change log. diff -ur --new-file cpm-0.2.1/Makefile cpm-0.2.1-glibc-rjm/Makefile --- cpm-0.2.1/Makefile Wed Mar 4 10:12:02 1998 +++ cpm-0.2.1-glibc-rjm/Makefile Thu Mar 18 14:17:50 1999 @@ -1,15 +1,34 @@ -CPMLIBDIR = /usr/local/lib/cpm -CFLAGS = -O2 -pipe -ansi -Wall -Wshadow -Wpointer-arith -Wcast-qual \ - -Wcast-align -Waggregate-return \ - -Wstrict-prototypes -Wmissing-prototypes \ - -Wnested-externs -Wwrite-strings -g -DCPMLIBDIR=\"$(CPMLIBDIR)\" -LDFLAGS = -s -N +# makefile for cpm + + +# basic prefix for installation +PREFIX = /usr/local + +# where to install `cpm' executable. +BINDIR = $(PREFIX)/bin + +# where `cpm' looks for its files (cpm.sys and .com files). +CPMLIBDIR = $(PREFIX)/lib/cpm + + +# You shouldn't need to edit below this line. + +CC = gcc + +CFLAGS = -O2 -pipe -ansi -Wall \ + -Wshadow -Wpointer-arith -Wcast-qual -Wcast-align \ + -Waggregate-return -Wstrict-prototypes -Wmissing-prototypes \ + -Wnested-externs -Wwrite-strings \ + -DCPMLIBDIR=\"$(CPMLIBDIR)\" + +LDFLAGS = -s + OBJS = single.o z80emu.o em.o io.o bios.o \ - commands.o running.o main.o disneu.o disz80.o low.o -# old: z80out.o + commands.o running.o main.o disneu.o disz80.o low.o TARGETS = cpm format + all: $(TARGETS) loads.s: makeloads.c @@ -21,8 +40,13 @@ single.o: single.S code.s loads.s code2.s codeix.s codeiy.s cpm: $(OBJS) - gcc $(LDFLAGS) -o cpm $(OBJS) + $(CC) $(LDFLAGS) -o cpm $(OBJS) clean: rm -f *~ loads.s makeloads *.o $(TARGETS) +install: all + install -m 511 cpm $(BINDIR) + -mkdir $(CPMLIBDIR) + chmod 755 $(CPMLIBDIR) + install -m 444 z80-binaries/* $(CPMLIBDIR) diff -ur --new-file cpm-0.2.1/README cpm-0.2.1-glibc-rjm/README --- cpm-0.2.1/README Wed Mar 4 10:21:24 1998 +++ cpm-0.2.1-glibc-rjm/README Thu Mar 18 14:32:37 1999 @@ -1,3 +1,31 @@ +cpm 0.2.1-glibc-rjm README + +A few months ago (at the time of writing), I noticed (and fixed) a few +bugs in cpm 0.2.1. Mail to the maintainer didn't seem to elicit any +response. They weren't absolute showstopper bugs, so I left it at +that. But when I upgraded to a glibc-based (libc6) distribution, there +were some bugs which, while minor, were enough to prevent it +compiling. So I decided to fix those and upload all my changes as a +patch to 0.2.1. + +The main changes are that `dir' works now, and so do pmarc and ZDE. +Also, you can now compile and install cpm with `make' then (as root) +`make install'. This sets it up to use the `BDOS emulator', meaning +you use Linux files. I'd recommend you avoid using dirs containing +files with uppercase/mixed-case names, or names which don't fit into +CP/M's 8.3 filename restriction - the BDOS can't cope with these and +can act oddly if a program asks to read/write one of them. (This is +not a new problem, but Michael (cpm's author) only half-mentioned it +in passing.) + +See ChangeLog for a full list of changes. + +- Russell Marks (rus@forfree.at). + +The cpm 0.2.1 README follows: + + +---------------------------------------------------------------------- The original author of cpm-0.2, Michael Bischoff, cannot be reached under the e-mail address given in the cpm.lsm. I have therefore decided to put this version on sunsite myself. The only changes so far were to diff -ur --new-file cpm-0.2.1/bios.c cpm-0.2.1-glibc-rjm/bios.c --- cpm-0.2.1/bios.c Wed Mar 4 10:12:45 1998 +++ cpm-0.2.1-glibc-rjm/bios.c Thu Mar 18 13:15:25 1999 @@ -523,7 +523,7 @@ dmaaddr = z80regs.de; break; case 32: /* Get/Set User Code */ - if (z80regs.de & 0xff == 0xff) /* Get Code */ + if ((z80regs.de & 0xff) == 0xff) /* Get Code */ z80regs.af = z80regs.hl = usercode; else usercode = z80regs.de & 0x0f; @@ -564,7 +564,7 @@ /* success */ memset(z80mem+z80regs.de+12, 0, 33-12); z80mem[z80regs.de+15] = 0; /* rc field of FCB */ - if (fstat(fileno(fp), &stbuf) || !S_ISREG(stbuf.st_mode)) { + if ((fstat(fileno(fp), &stbuf)==-1) || !S_ISREG(stbuf.st_mode)) { z80regs.af = z80regs.hl = 0xff; fclose(fp); break; @@ -601,6 +601,7 @@ { struct dirent *de; unsigned char *p; const char *sr; + int len; nocpmname: if (!(de = readdir(dp))) { closedir(dp); @@ -613,10 +614,11 @@ memset(p = z80mem+dmaaddr, 0, 128); /* dmaaddr instead of DIRBUF!! */ if (*de->d_name == '.') goto nocpmname; + len = strlen(de->d_name); if (strchr(sr = de->d_name, '.')) { - if (de->d_reclen > 12) /* POSIX: namlen */ + if (len > 12) goto nocpmname; - } else if (de->d_reclen > 8) + } else if (len > 8) goto nocpmname; /* seems OK */ for (i = 0; i < 8; ++i) @@ -690,26 +692,45 @@ fp = getfp(z80regs.de); /* printf("data is %02x %02x %02x\n", z80mem[z80regs.de+33], z80mem[z80regs.de+34], z80mem[z80regs.de+35]); */ - fseek(fp, ADDRESS, SEEK_SET); + if(fseek(fp, ADDRESS, SEEK_SET)==-1) { + z80regs.af = z80regs.hl = 0x1; /* ff => pip error */ + } goto readseq; case 34: /* write random record */ fp = getfp(z80regs.de); /* printf("data is %02x %02x %02x\n", z80mem[z80regs.de+33], z80mem[z80regs.de+34], z80mem[z80regs.de+35]); */ - fseek(fp, ADDRESS, SEEK_SET); + if(fseek(fp, ADDRESS, SEEK_SET)==-1) { + z80regs.af = z80regs.hl = 0x1; /* ff => pip error */ + } goto writeseq; case 35: /* compute file size */ - fp = getfp(z80regs.de); - fseek(fp, 0L, SEEK_END); - /* fall through */ + { long pos, oldpos; + fp = getfp(z80regs.de); + oldpos = ftell(fp); + fseek(fp, 0L, SEEK_END); + pos = ftell(fp) >> 7; + /* native files may very well *not* be exact multiples of + * 128 long, so add extra `record' (to simulate what the + * length would be on CP/M) if it isn't. -rjm + */ + if ((ftell(fp) & 127) != 0) + pos++; + fseek(fp, oldpos, SEEK_SET); + z80regs.af = z80regs.hl = 0x00; /* dunno, if necessary */ + z80mem[z80regs.de+0x21] = pos & 0xff; + z80mem[z80regs.de+0x22] = pos >> 8; + z80mem[z80regs.de+0x23] = pos >> 16; + } + break; case 36: /* set random record */ fp = getfp(z80regs.de); { long pos; pos = ftell(fp) >> 7; z80regs.af = z80regs.hl = 0x00; /* dunno, if necessary */ - z80mem[z80regs.de+21] = pos & 0xff; - z80mem[z80regs.de+22] = pos >> 8; - z80mem[z80regs.de+23] = pos >> 16; + z80mem[z80regs.de+0x21] = pos & 0xff; + z80mem[z80regs.de+0x22] = pos >> 8; + z80mem[z80regs.de+0x23] = pos >> 16; } break; case 41: @@ -717,6 +738,13 @@ *s = tolower(*s); z80regs.af = z80regs.hl = restricted_mode || chdir(z80mem+z80regs.de) ? 0xff : 0x00; + break; + case 48: + /* needs to be tolerated for ZDE not to bomb out + * (CP/M 2.2 would just have ignored it, you see). + * Presumably some other programs need this too. -rjm + */ + z80regs.af = z80regs.hl = 0; /* not really necessary but nicer */ break; default: printf("\n\nUnrecognized BDOS-Function:\n"); diff -ur --new-file cpm-0.2.1/code.s cpm-0.2.1-glibc-rjm/code.s --- cpm-0.2.1/code.s Wed Mar 4 10:12:30 1998 +++ cpm-0.2.1-glibc-rjm/code.s Thu Mar 18 13:15:26 1999 @@ -275,8 +275,8 @@ rcrb $1,%al xchg %eax,%edi lahf - andl $0x0100h,%eax - andl $0xecffh,%edi + andl $0x0100,%eax + andl $0xecff,%edi orl %edi,%eax dispatch @@ -651,7 +651,7 @@ oped: movzbl (%esi,%ebp),%edi inc %esi sall $2,%edi - jmp jumptab2(%edi) + jmp *jumptab2(%edi) opcode (0xcb) /* z80 */ opcb: movzbl (%esi,%ebp),%edi @@ -708,13 +708,13 @@ opdd: movzbl (%esi,%ebp),%edi inc %esi sall $2,%edi - jmp jumptabix(%edi) + jmp *jumptabix(%edi) opcode (0xfd) opfd: movzbl (%esi,%ebp),%edi inc %esi sall $2,%edi - jmp jumptabiy(%edi) + jmp *jumptabiy(%edi) /* out command: if no hardware access allowed, or if port != 0x61, */ /* trap this opcode and enter debugger */ diff -ur --new-file cpm-0.2.1/disz80.c cpm-0.2.1-glibc-rjm/disz80.c --- cpm-0.2.1/disz80.c Wed Jun 15 16:02:27 1994 +++ cpm-0.2.1-glibc-rjm/disz80.c Thu Mar 18 13:15:26 1999 @@ -15,6 +15,7 @@ #include #include #include +#include "cpmemu.h" /* 8-Bit registers */ static const char *dtab1[] = { "B", "C", "D", "E", "H", "L", NULL, "A" }; @@ -105,7 +106,7 @@ unsigned o, m, r; const char *regh, *regl, *ir; char i_offset[8]; - unsigned w; + unsigned w = 0; dtab1[6] = "(HL)"; ir = "HL"; diff -ur --new-file cpm-0.2.1/low.c cpm-0.2.1-glibc-rjm/low.c --- cpm-0.2.1/low.c Tue Jun 21 19:17:08 1994 +++ cpm-0.2.1-glibc-rjm/low.c Thu Mar 18 13:23:26 1999 @@ -1,6 +1,27 @@ +/*****************************************************************************/ +/* */ +/* */ +/* CP/M emulator version 0.1 */ +/* */ +/* written by Michael Bischoff (mbi@mo.math.nat.tu-bs.de) */ +/* June-1994 */ +/* */ +/* This file is distributed under the GNU COPYRIGHT */ +/* see COPYRIGHT.GNU for Copyright details */ +/* */ +/* */ +/*****************************************************************************/ + +/* according to an email I got from Michael a few years back, the + * restrict-to-2MHz stuff and speaker access is for some sort of + * minimal (I think) TRS-80 support - just enough to get some TRS-80 + * space-invaders-type game working, I think it was. :-) -rjm + */ + #include "cpmemu.h" #include #include +#include /* needed for ioperm() -rjm */ #include #include #include @@ -74,14 +95,14 @@ /* install signal handler */ sa.sa_handler = tickerint; - sa.sa_mask = 0; + sigemptyset(&sa.sa_mask); sa.sa_flags = 0; sigaction(SIGALRM, &sa, NULL); /* make video memory accessible */ memfd = open("/dev/mem", O_RDWR); if (memfd > 0) - cptr = mmap((caddr_t)0, (size_t) 2048, PROT_READ|PROT_WRITE, + cptr = mmap((void *)0, (size_t) 2048, PROT_READ|PROT_WRITE, MAP_SHARED, memfd, (off_t) 0xb8000); /* printf("fd=%d, ptr=%p\n", memfd, cptr); */ diff -ur --new-file cpm-0.2.1/single.S cpm-0.2.1-glibc-rjm/single.S --- cpm-0.2.1/single.S Wed Mar 4 10:12:11 1998 +++ cpm-0.2.1-glibc-rjm/single.S Thu Mar 18 13:15:26 1999 @@ -37,7 +37,7 @@ movzbl (%esi,%ebp),%edi inc %esi sall $2,%edi - jmp jumptab(%edi) + jmp *jumptab(%edi) .align 4,0x90 exitemu: /* decl %esi */ diff -ur --new-file cpm-0.2.1/z80emu.S cpm-0.2.1-glibc-rjm/z80emu.S --- cpm-0.2.1/z80emu.S Wed Mar 4 10:12:17 1998 +++ cpm-0.2.1-glibc-rjm/z80emu.S Thu Mar 18 13:15:26 1999 @@ -21,7 +21,7 @@ movzbl (%esi,%ebp),%edi; \ inc %esi; \ sall $2,%edi; \ - jmp jumptab(%edi) + jmp *jumptab(%edi) .globl emulate emulate: